canvas-editor-engine 2.0.1 → 2.0.4
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.d.ts +574 -18
- package/dist/index.mjs.js +2 -0
- package/dist/index.mjs.js.LICENSE.txt +8 -0
- package/package.json +9 -4
- package/dist/components/canvas.component.d.ts +0 -21
- package/dist/components/canvas.component.js +0 -90
- package/dist/components/excretions.component.d.ts +0 -32
- package/dist/components/excretions.component.js +0 -280
- package/dist/components/loading.component.d.ts +0 -14
- package/dist/components/loading.component.js +0 -96
- package/dist/components/pipette.component.d.ts +0 -23
- package/dist/components/pipette.component.js +0 -149
- package/dist/components/slot.component.d.ts +0 -10
- package/dist/components/slot.component.js +0 -31
- package/dist/config.d.ts +0 -23
- package/dist/config.js +0 -67
- package/dist/filters/collection/vague.d.ts +0 -13
- package/dist/filters/collection/vague.js +0 -150
- package/dist/filters/index.d.ts +0 -2
- package/dist/filters/index.js +0 -5
- package/dist/index.js +0 -69
- package/dist/services/component.service.d.ts +0 -5
- package/dist/services/component.service.js +0 -37
- package/dist/services/crop.service.d.ts +0 -7
- package/dist/services/crop.service.js +0 -50
- package/dist/services/download.service.d.ts +0 -4
- package/dist/services/download.service.js +0 -15
- package/dist/services/draw.service.d.ts +0 -17
- package/dist/services/draw.service.js +0 -152
- package/dist/services/event.service.d.ts +0 -16
- package/dist/services/event.service.js +0 -35
- package/dist/services/logger.service.d.ts +0 -20
- package/dist/services/logger.service.js +0 -38
- package/dist/services/projects.service.d.ts +0 -11
- package/dist/services/projects.service.js +0 -98
- package/dist/services/pull-project.service.d.ts +0 -8
- package/dist/services/pull-project.service.js +0 -34
- package/dist/services/store.service.d.ts +0 -6
- package/dist/services/store.service.js +0 -11
- package/dist/services/through-history.service.d.ts +0 -12
- package/dist/services/through-history.service.js +0 -49
- package/dist/services/tool-layers.service.d.ts +0 -4
- package/dist/services/tool-layers.service.js +0 -12
- package/dist/services/tool.service.d.ts +0 -10
- package/dist/services/tool.service.js +0 -56
- package/dist/store/history.state.d.ts +0 -15
- package/dist/store/history.state.js +0 -76
- package/dist/store/image.state.d.ts +0 -30
- package/dist/store/image.state.js +0 -70
- package/dist/store/store.d.ts +0 -13
- package/dist/store/store.js +0 -31
- package/dist/types/canvas.d.ts +0 -10
- package/dist/types/canvas.js +0 -3
- package/dist/types/cursor.d.ts +0 -9
- package/dist/types/cursor.js +0 -3
- package/dist/types/excretion.d.ts +0 -27
- package/dist/types/excretion.js +0 -5
- package/dist/types/general.d.ts +0 -24
- package/dist/types/general.js +0 -5
- package/dist/types/history.d.ts +0 -7
- package/dist/types/history.js +0 -2
- package/dist/types/image.d.ts +0 -48
- package/dist/types/image.js +0 -10
- package/dist/types/log.d.ts +0 -13
- package/dist/types/log.js +0 -5
- package/dist/types/pipette.d.ts +0 -1
- package/dist/types/pipette.js +0 -2
- package/dist/types/project.d.ts +0 -38
- package/dist/types/project.js +0 -14
- package/dist/utils/convert.d.ts +0 -12
- package/dist/utils/convert.js +0 -27
- package/dist/utils/filter.d.ts +0 -21
- package/dist/utils/filter.js +0 -150
- package/dist/utils/guid4.d.ts +0 -13
- package/dist/utils/guid4.js +0 -111
- package/dist/utils/project-file-serializer.d.ts +0 -13
- package/dist/utils/project-file-serializer.js +0 -79
- package/dist/web-component.d.ts +0 -30
- package/dist/web-component.js +0 -108
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const component_service_1 = require("../services/component.service");
|
|
4
|
-
const tool_service_1 = require("../services/tool.service");
|
|
5
|
-
const canvas_component_1 = require("./canvas.component");
|
|
6
|
-
const logger_service_1 = require("../services/logger.service");
|
|
7
|
-
const crop_service_1 = require("../services/crop.service");
|
|
8
|
-
const tool_layers_service_1 = require("../services/tool-layers.service");
|
|
9
|
-
class ExcretionsComponent extends component_service_1.default {
|
|
10
|
-
static template = ``;
|
|
11
|
-
static templateExcretion = `
|
|
12
|
-
<button type="button" class="crop-button">
|
|
13
|
-
<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>
|
|
14
|
-
</button>
|
|
15
|
-
`;
|
|
16
|
-
static _excretionDefaultStyle = ['excretion'];
|
|
17
|
-
static css = `
|
|
18
|
-
.excretion {
|
|
19
|
-
display: flex;
|
|
20
|
-
position: absolute;
|
|
21
|
-
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%);
|
|
22
|
-
background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
|
|
23
|
-
background-size: 8px 1px, 8px 1px, 1px 8px, 1px 8px;
|
|
24
|
-
background-position: left top, right bottom, left bottom, right top;
|
|
25
|
-
animation: border-dance 1s infinite linear;
|
|
26
|
-
z-index: ${tool_layers_service_1.default.getLayerIndex('low')};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.excretion_crop {
|
|
30
|
-
box-shadow: 0px 0px 0px calc(100vw + 100vh) #50505070;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.crop-button {
|
|
34
|
-
display: none;
|
|
35
|
-
justify-content: center;
|
|
36
|
-
align-items: center;
|
|
37
|
-
position: absolute;
|
|
38
|
-
padding: 5px;
|
|
39
|
-
right: -35px;
|
|
40
|
-
top: 0;
|
|
41
|
-
background: #232222;
|
|
42
|
-
border: 1px solid #ffffff50;
|
|
43
|
-
border-radius: 4px;
|
|
44
|
-
width: 30px;
|
|
45
|
-
height: 30px;
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
z-index: ${tool_layers_service_1.default.getLayerIndex('high')};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.crop-button--view {
|
|
51
|
-
display: flex;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@keyframes border-dance {
|
|
55
|
-
0% {
|
|
56
|
-
background-position: left top, right bottom, left bottom, right top;
|
|
57
|
-
}
|
|
58
|
-
100% {
|
|
59
|
-
background-position: left 8px top, right 8px bottom, left bottom 8px, right top 8px;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
static excretionWrap;
|
|
64
|
-
static _excretions = [];
|
|
65
|
-
static _excretionState = 'abandoned';
|
|
66
|
-
static _excretionActivity = 'abandoned';
|
|
67
|
-
static _excretionToolState = 'abandoned';
|
|
68
|
-
static _tempCoords = [];
|
|
69
|
-
static excretionsCoords = [];
|
|
70
|
-
static _additionStyle = 'default';
|
|
71
|
-
static get additionStyle() {
|
|
72
|
-
return ExcretionsComponent._additionStyle;
|
|
73
|
-
}
|
|
74
|
-
static set additionStyle(value) {
|
|
75
|
-
ExcretionsComponent._additionStyle = value;
|
|
76
|
-
ExcretionsComponent.applyExcretionStyle();
|
|
77
|
-
}
|
|
78
|
-
static applyExcretionStyle() {
|
|
79
|
-
switch (ExcretionsComponent._additionStyle) {
|
|
80
|
-
case 'crop':
|
|
81
|
-
ExcretionsComponent.determineCropStyle();
|
|
82
|
-
break;
|
|
83
|
-
case 'default':
|
|
84
|
-
ExcretionsComponent.determineDefaultStyle();
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
ExcretionsComponent.determineDefaultStyle();
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
;
|
|
92
|
-
static determineCropStyle() {
|
|
93
|
-
ExcretionsComponent._excretions.forEach((excretion) => {
|
|
94
|
-
if (!!excretion === false)
|
|
95
|
-
return;
|
|
96
|
-
if (!excretion.classList.contains('excretion_crop')) {
|
|
97
|
-
excretion.classList.add("excretion_crop");
|
|
98
|
-
crop_service_1.default.viewCropButton();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
static determineDefaultStyle() {
|
|
103
|
-
ExcretionsComponent._excretions.forEach((excretion) => {
|
|
104
|
-
if (!!excretion === false)
|
|
105
|
-
return;
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
excretion.classList = ExcretionsComponent._excretionDefaultStyle;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
static tool = {
|
|
111
|
-
id: 1,
|
|
112
|
-
name: 'excretion',
|
|
113
|
-
onAction: () => ExcretionsComponent.setToolState('taken'),
|
|
114
|
-
offAction: () => ExcretionsComponent.setToolState('abandoned'),
|
|
115
|
-
support: () => {
|
|
116
|
-
ExcretionsComponent.clearExcretionsCoords();
|
|
117
|
-
ExcretionsComponent.additionStyle = 'default';
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
static {
|
|
121
|
-
tool_service_1.default.add(ExcretionsComponent.tool);
|
|
122
|
-
logger_service_1.default.components.add({
|
|
123
|
-
info: {
|
|
124
|
-
name: 'excretion',
|
|
125
|
-
description: 'excretion component',
|
|
126
|
-
},
|
|
127
|
-
prototype: ExcretionsComponent,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
static getComponent() {
|
|
131
|
-
const wrapOptions = {
|
|
132
|
-
className: 'excretions-wrap',
|
|
133
|
-
};
|
|
134
|
-
const excretionsTemplate = ExcretionsComponent.getTemplate(ExcretionsComponent.template, wrapOptions);
|
|
135
|
-
const excretionsStyle = ExcretionsComponent.getStyle(ExcretionsComponent.css);
|
|
136
|
-
ExcretionsComponent.excretionWrap = excretionsTemplate;
|
|
137
|
-
ExcretionsComponent.emmit();
|
|
138
|
-
return { excretionsTemplate, excretionsStyle };
|
|
139
|
-
}
|
|
140
|
-
static set excretionState(state) {
|
|
141
|
-
ExcretionsComponent._excretionState = state;
|
|
142
|
-
ExcretionsComponent.applyExcretionStyle();
|
|
143
|
-
switch (state) {
|
|
144
|
-
case 'abandoned':
|
|
145
|
-
canvas_component_1.default.cursorStyle = 'default';
|
|
146
|
-
break;
|
|
147
|
-
case 'create':
|
|
148
|
-
canvas_component_1.default.cursorStyle = 'crosshair';
|
|
149
|
-
break;
|
|
150
|
-
case 'add':
|
|
151
|
-
canvas_component_1.default.cursorStyle = 'copy';
|
|
152
|
-
break;
|
|
153
|
-
case 'remove':
|
|
154
|
-
canvas_component_1.default.cursorStyle = 'alias';
|
|
155
|
-
break;
|
|
156
|
-
default:
|
|
157
|
-
canvas_component_1.default.cursorStyle = 'default';
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
static setToolState(toolState) {
|
|
162
|
-
ExcretionsComponent._excretionToolState = toolState;
|
|
163
|
-
switch (toolState) {
|
|
164
|
-
case 'abandoned':
|
|
165
|
-
ExcretionsComponent.excretionState = 'abandoned';
|
|
166
|
-
ExcretionsComponent._excretionActivity = 'abandoned';
|
|
167
|
-
break;
|
|
168
|
-
case 'taken':
|
|
169
|
-
ExcretionsComponent.excretionState = 'create';
|
|
170
|
-
break;
|
|
171
|
-
default:
|
|
172
|
-
ExcretionsComponent.excretionState = 'abandoned';
|
|
173
|
-
ExcretionsComponent._excretionActivity = 'abandoned';
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
static clearExcretionsCoords() {
|
|
178
|
-
console.log('clear!');
|
|
179
|
-
ExcretionsComponent._excretions.forEach((excretion) => excretion.remove());
|
|
180
|
-
ExcretionsComponent._excretions = [];
|
|
181
|
-
ExcretionsComponent.excretionsCoords = [];
|
|
182
|
-
}
|
|
183
|
-
static getTempCoords() {
|
|
184
|
-
const startCoords = ExcretionsComponent._tempCoords[0];
|
|
185
|
-
const endCoords = ExcretionsComponent._tempCoords[1];
|
|
186
|
-
const coords = Object.assign(startCoords, endCoords);
|
|
187
|
-
ExcretionsComponent._tempCoords = [];
|
|
188
|
-
return coords;
|
|
189
|
-
}
|
|
190
|
-
static endExcretion() {
|
|
191
|
-
const coords = ExcretionsComponent.getTempCoords();
|
|
192
|
-
ExcretionsComponent.excretionsCoords.push(coords);
|
|
193
|
-
ExcretionsComponent._excretionActivity = 'end';
|
|
194
|
-
console.log('ExcretionsComponent.excretionsCoords', ExcretionsComponent.excretionsCoords);
|
|
195
|
-
}
|
|
196
|
-
static emmit() {
|
|
197
|
-
canvas_component_1.default.subscribe('mousedown', (event, cursorPosition) => {
|
|
198
|
-
const toolState = ExcretionsComponent._excretionToolState;
|
|
199
|
-
if (toolState === 'abandoned')
|
|
200
|
-
return;
|
|
201
|
-
const state = ExcretionsComponent._excretionState;
|
|
202
|
-
if (state === 'create') {
|
|
203
|
-
const wrapOptions = {
|
|
204
|
-
className: ExcretionsComponent._excretionDefaultStyle[0],
|
|
205
|
-
};
|
|
206
|
-
const excretionTemplate = ExcretionsComponent.getTemplate(ExcretionsComponent.templateExcretion, wrapOptions);
|
|
207
|
-
ExcretionsComponent.clearExcretionsCoords();
|
|
208
|
-
const tempStart = {
|
|
209
|
-
start: cursorPosition,
|
|
210
|
-
};
|
|
211
|
-
excretionTemplate.style.left = `${tempStart.start.x}px`;
|
|
212
|
-
excretionTemplate.style.top = `${tempStart.start.y}px`;
|
|
213
|
-
const excretionElement = ExcretionsComponent.excretionWrap.appendChild(excretionTemplate);
|
|
214
|
-
ExcretionsComponent._excretions.push(excretionElement);
|
|
215
|
-
ExcretionsComponent._tempCoords.push(tempStart);
|
|
216
|
-
}
|
|
217
|
-
if (state === 'add') {
|
|
218
|
-
const tempStart = {
|
|
219
|
-
start: cursorPosition,
|
|
220
|
-
};
|
|
221
|
-
ExcretionsComponent._tempCoords.push(tempStart);
|
|
222
|
-
}
|
|
223
|
-
ExcretionsComponent.applyExcretionStyle();
|
|
224
|
-
ExcretionsComponent._excretionActivity = 'active';
|
|
225
|
-
});
|
|
226
|
-
canvas_component_1.default.subscribe('mousemove', (event, cursorPosition) => {
|
|
227
|
-
const toolState = ExcretionsComponent._excretionToolState;
|
|
228
|
-
if (toolState === 'abandoned')
|
|
229
|
-
return;
|
|
230
|
-
const activity = ExcretionsComponent._excretionActivity;
|
|
231
|
-
if (event.altKey && ExcretionsComponent._excretionState !== 'abandoned') {
|
|
232
|
-
ExcretionsComponent._excretionState = 'add';
|
|
233
|
-
}
|
|
234
|
-
if (activity === 'abandoned')
|
|
235
|
-
return;
|
|
236
|
-
if (activity === 'active') {
|
|
237
|
-
const excretionLastIndex = ExcretionsComponent._excretions.length - 1;
|
|
238
|
-
const excretion = ExcretionsComponent._excretions[excretionLastIndex];
|
|
239
|
-
const excretionX = +(excretion.style.left.split('px')[0]);
|
|
240
|
-
const excretionY = +(excretion.style.top.split('px')[0]);
|
|
241
|
-
const width = Math.abs(cursorPosition.x - excretionX);
|
|
242
|
-
const height = Math.abs(cursorPosition.y - excretionY);
|
|
243
|
-
excretion.style.width = width + 'px';
|
|
244
|
-
excretion.style.height = height + 'px';
|
|
245
|
-
const isRightBottom = cursorPosition.x > excretionX && cursorPosition.y > excretionY;
|
|
246
|
-
const isLeftBottom = cursorPosition.x < excretionX && cursorPosition.y > excretionY;
|
|
247
|
-
const isLeftTop = cursorPosition.x < excretionX && cursorPosition.y < excretionY;
|
|
248
|
-
const isRightTop = cursorPosition.x > excretionX && cursorPosition.y < excretionY;
|
|
249
|
-
if (isRightBottom) {
|
|
250
|
-
excretion.style.transform = `translateX(0px) translateY(0px)`;
|
|
251
|
-
}
|
|
252
|
-
else if (isLeftBottom) {
|
|
253
|
-
excretion.style.transform = `translateX(-${width}px) translateY(0px)`;
|
|
254
|
-
}
|
|
255
|
-
else if (isLeftTop) {
|
|
256
|
-
excretion.style.transform = `translateX(-${width}px) translateY(-${height}px)`;
|
|
257
|
-
}
|
|
258
|
-
else if (isRightTop) {
|
|
259
|
-
excretion.style.transform = `translateX(0px) translateY(-${height}px)`;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
canvas_component_1.default.subscribe('mouseup', (event, cursorPosition) => {
|
|
264
|
-
const toolState = ExcretionsComponent._excretionToolState;
|
|
265
|
-
if (toolState === 'abandoned')
|
|
266
|
-
return;
|
|
267
|
-
const state = ExcretionsComponent._excretionState;
|
|
268
|
-
if (state === 'abandoned')
|
|
269
|
-
return;
|
|
270
|
-
if (state === 'create' || state === 'add') {
|
|
271
|
-
const tempEnd = {
|
|
272
|
-
end: cursorPosition,
|
|
273
|
-
};
|
|
274
|
-
ExcretionsComponent._tempCoords.push(tempEnd);
|
|
275
|
-
ExcretionsComponent.endExcretion();
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
exports.default = ExcretionsComponent;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import ComponentService from "../services/component.service";
|
|
2
|
-
export default class LoadingComponent extends ComponentService {
|
|
3
|
-
private static template;
|
|
4
|
-
private static css;
|
|
5
|
-
static loading: HTMLElement;
|
|
6
|
-
static getComponent(): {
|
|
7
|
-
loadingTemplate: HTMLElement;
|
|
8
|
-
loadingStyle: HTMLStyleElement;
|
|
9
|
-
};
|
|
10
|
-
static hide(): void;
|
|
11
|
-
static view(): void;
|
|
12
|
-
private static subscribeLoadingStart;
|
|
13
|
-
private static subscribeLoadingEnd;
|
|
14
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const component_service_1 = require("../services/component.service");
|
|
4
|
-
const event_service_1 = require("../services/event.service");
|
|
5
|
-
const logger_service_1 = require("../services/logger.service");
|
|
6
|
-
class LoadingComponent extends component_service_1.default {
|
|
7
|
-
static template = `
|
|
8
|
-
<span class="loader"></span>
|
|
9
|
-
`;
|
|
10
|
-
static css = `
|
|
11
|
-
.loading-wrapper {
|
|
12
|
-
display: none;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
align-items: center;
|
|
15
|
-
position: absolute;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
background: #ffffff30;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.loader {
|
|
22
|
-
width: 48px;
|
|
23
|
-
height: 48px;
|
|
24
|
-
border-radius: 50%;
|
|
25
|
-
position: relative;
|
|
26
|
-
animation: rotate 1s linear infinite
|
|
27
|
-
}
|
|
28
|
-
.loader::before , .loader::after {
|
|
29
|
-
content: "";
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
position: absolute;
|
|
32
|
-
inset: 0px;
|
|
33
|
-
border-radius: 50%;
|
|
34
|
-
border: 5px solid #FFF;
|
|
35
|
-
animation: prixClipFix 2s linear infinite ;
|
|
36
|
-
}
|
|
37
|
-
.loader::after{
|
|
38
|
-
inset: 8px;
|
|
39
|
-
transform: rotate3d(90, 90, 0, 180deg );
|
|
40
|
-
border-color: #FF3D00;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@keyframes rotate {
|
|
44
|
-
0% {transform: rotate(0deg)}
|
|
45
|
-
100% {transform: rotate(360deg)}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@keyframes prixClipFix {
|
|
49
|
-
0% {clip-path:polygon(50% 50%,0 0,0 0,0 0,0 0,0 0)}
|
|
50
|
-
50% {clip-path:polygon(50% 50%,0 0,100% 0,100% 0,100% 0,100% 0)}
|
|
51
|
-
75%, 100% {clip-path:polygon(50% 50%,0 0,100% 0,100% 100%,100% 100%,100% 100%)}
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
static loading;
|
|
55
|
-
static {
|
|
56
|
-
logger_service_1.default.components.add({
|
|
57
|
-
info: {
|
|
58
|
-
name: 'loading',
|
|
59
|
-
description: 'loading component',
|
|
60
|
-
},
|
|
61
|
-
prototype: LoadingComponent,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
static getComponent() {
|
|
65
|
-
const wrapOptions = {
|
|
66
|
-
className: 'loading-wrapper',
|
|
67
|
-
};
|
|
68
|
-
const loadingTemplate = LoadingComponent.getTemplate(LoadingComponent.template, wrapOptions);
|
|
69
|
-
const loadingStyle = LoadingComponent.getStyle(LoadingComponent.css);
|
|
70
|
-
LoadingComponent.loading = loadingTemplate;
|
|
71
|
-
LoadingComponent.subscribeLoadingStart();
|
|
72
|
-
LoadingComponent.subscribeLoadingEnd();
|
|
73
|
-
return { loadingTemplate, loadingStyle };
|
|
74
|
-
}
|
|
75
|
-
static hide() {
|
|
76
|
-
LoadingComponent.loading.style.display = 'none';
|
|
77
|
-
}
|
|
78
|
-
static view() {
|
|
79
|
-
LoadingComponent.loading.style.display = 'flex';
|
|
80
|
-
}
|
|
81
|
-
static subscribeLoadingStart() {
|
|
82
|
-
const controlEvent = {
|
|
83
|
-
name: 'loading-start',
|
|
84
|
-
action: () => LoadingComponent.view(),
|
|
85
|
-
};
|
|
86
|
-
event_service_1.default.subcribe(controlEvent);
|
|
87
|
-
}
|
|
88
|
-
static subscribeLoadingEnd() {
|
|
89
|
-
const controlEvent = {
|
|
90
|
-
name: 'loading-end',
|
|
91
|
-
action: () => LoadingComponent.hide(),
|
|
92
|
-
};
|
|
93
|
-
event_service_1.default.subcribe(controlEvent);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.default = LoadingComponent;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TPipetteState } from "../types/pipette";
|
|
2
|
-
import { THEXColor } from "../types/general";
|
|
3
|
-
import ComponentService from "../services/component.service";
|
|
4
|
-
export default class PipetteComponent extends ComponentService {
|
|
5
|
-
static template: string;
|
|
6
|
-
static css: string;
|
|
7
|
-
static pipette: HTMLElement;
|
|
8
|
-
private static _pipetteColor;
|
|
9
|
-
static set pipetteColor(color: THEXColor);
|
|
10
|
-
static get pipetteColor(): THEXColor;
|
|
11
|
-
private static _pipetteColorElement;
|
|
12
|
-
private static _pipetteState;
|
|
13
|
-
private static tool;
|
|
14
|
-
static getComponent(): {
|
|
15
|
-
pipetteTemplate: HTMLElement;
|
|
16
|
-
pipetteStyle: HTMLStyleElement;
|
|
17
|
-
};
|
|
18
|
-
static setState(state: TPipetteState): void;
|
|
19
|
-
static emmit(): void;
|
|
20
|
-
private static setColorFromChoosenPixel;
|
|
21
|
-
private static show;
|
|
22
|
-
private static hide;
|
|
23
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const convert_1 = require("../utils/convert");
|
|
4
|
-
const canvas_component_1 = require("./canvas.component");
|
|
5
|
-
const component_service_1 = require("../services/component.service");
|
|
6
|
-
const tool_service_1 = require("../services/tool.service");
|
|
7
|
-
const logger_service_1 = require("../services/logger.service");
|
|
8
|
-
class PipetteComponent extends component_service_1.default {
|
|
9
|
-
static template = `
|
|
10
|
-
<div class="pipette_border-out">
|
|
11
|
-
<div class="pipette_color">
|
|
12
|
-
<div class="pipette_border-in">
|
|
13
|
-
<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>
|
|
14
|
-
</div>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
`;
|
|
18
|
-
static css = `
|
|
19
|
-
.pipette {
|
|
20
|
-
position: absolute;
|
|
21
|
-
display: none;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
align-items: center;
|
|
24
|
-
width: 48px;
|
|
25
|
-
height: 48px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.pipette_border-out {
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
align-items: center;
|
|
32
|
-
border-radius: 100px;
|
|
33
|
-
border: solid 2px #d9d9d9;
|
|
34
|
-
width: 44px;
|
|
35
|
-
height: 44px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.pipette_border-in {
|
|
39
|
-
display: flex;
|
|
40
|
-
justify-content: center;
|
|
41
|
-
align-items: center;
|
|
42
|
-
border-radius: 100px;
|
|
43
|
-
border: solid 1px #d9d9d9;
|
|
44
|
-
width: 32px;
|
|
45
|
-
height: 32px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.pipette_color {
|
|
49
|
-
display: flex;
|
|
50
|
-
justify-content: center;
|
|
51
|
-
align-items: center;
|
|
52
|
-
width: 34px;
|
|
53
|
-
height: 34px;
|
|
54
|
-
border-radius: 100px;
|
|
55
|
-
border-color: blue;
|
|
56
|
-
border-style: solid;
|
|
57
|
-
border-width: 5px;
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
static pipette;
|
|
61
|
-
static _pipetteColor;
|
|
62
|
-
static set pipetteColor(color) {
|
|
63
|
-
PipetteComponent._pipetteColor = color;
|
|
64
|
-
PipetteComponent._pipetteColorElement.style.borderColor = PipetteComponent._pipetteColor;
|
|
65
|
-
}
|
|
66
|
-
static get pipetteColor() {
|
|
67
|
-
return PipetteComponent._pipetteColor;
|
|
68
|
-
}
|
|
69
|
-
static _pipetteColorElement;
|
|
70
|
-
static _pipetteState = 'abandoned';
|
|
71
|
-
static tool = {
|
|
72
|
-
id: 0,
|
|
73
|
-
name: 'pipette',
|
|
74
|
-
onAction: () => PipetteComponent.setState('taken'),
|
|
75
|
-
offAction: () => PipetteComponent.setState('abandoned'),
|
|
76
|
-
};
|
|
77
|
-
static {
|
|
78
|
-
tool_service_1.default.add(PipetteComponent.tool);
|
|
79
|
-
logger_service_1.default.components.add({
|
|
80
|
-
info: {
|
|
81
|
-
name: 'pipette',
|
|
82
|
-
description: 'pipette component',
|
|
83
|
-
},
|
|
84
|
-
prototype: PipetteComponent,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
static getComponent() {
|
|
88
|
-
const wrapOptions = {
|
|
89
|
-
className: 'pipette',
|
|
90
|
-
};
|
|
91
|
-
const pipetteTemplate = PipetteComponent.getTemplate(PipetteComponent.template, wrapOptions);
|
|
92
|
-
const pipetteStyle = PipetteComponent.getStyle(PipetteComponent.css);
|
|
93
|
-
PipetteComponent.pipette = pipetteTemplate;
|
|
94
|
-
PipetteComponent._pipetteColorElement = pipetteTemplate.querySelector('.pipette_color');
|
|
95
|
-
PipetteComponent.emmit();
|
|
96
|
-
return { pipetteTemplate, pipetteStyle };
|
|
97
|
-
}
|
|
98
|
-
static setState(state) {
|
|
99
|
-
PipetteComponent._pipetteState = state;
|
|
100
|
-
switch (state) {
|
|
101
|
-
case 'abandoned':
|
|
102
|
-
return PipetteComponent.hide();
|
|
103
|
-
case 'taken':
|
|
104
|
-
return PipetteComponent.show();
|
|
105
|
-
case 'selected-color':
|
|
106
|
-
return PipetteComponent.show();
|
|
107
|
-
default:
|
|
108
|
-
return PipetteComponent.hide();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
static emmit() {
|
|
112
|
-
canvas_component_1.default.subscribe('mousemove', (event, cursorPosition) => {
|
|
113
|
-
const state = PipetteComponent._pipetteState;
|
|
114
|
-
if (state === 'taken' || state === 'selected-color') {
|
|
115
|
-
const { x, y } = cursorPosition;
|
|
116
|
-
PipetteComponent.pipette.style.left = `${x + 10}px`;
|
|
117
|
-
PipetteComponent.pipette.style.top = `${y + 10}px`;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
canvas_component_1.default.subscribe('click', (event, cursorPosition) => {
|
|
121
|
-
const state = PipetteComponent._pipetteState;
|
|
122
|
-
if (state === 'taken' || state === 'selected-color') {
|
|
123
|
-
console.log('pipetteState', state);
|
|
124
|
-
if (state === 'taken') {
|
|
125
|
-
PipetteComponent.setColorFromChoosenPixel(cursorPosition);
|
|
126
|
-
PipetteComponent.setState('selected-color');
|
|
127
|
-
}
|
|
128
|
-
if (state === 'selected-color') {
|
|
129
|
-
PipetteComponent.setColorFromChoosenPixel(cursorPosition);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
static setColorFromChoosenPixel(cursorPosition) {
|
|
135
|
-
const { x, y } = cursorPosition;
|
|
136
|
-
const pixel = canvas_component_1.default.ctx.getImageData(x, y, 1, 1).data;
|
|
137
|
-
const hexPixel = convert_1.Convert.rgbToHex(pixel[0], pixel[1], pixel[2]);
|
|
138
|
-
PipetteComponent.pipetteColor = hexPixel;
|
|
139
|
-
}
|
|
140
|
-
static show() {
|
|
141
|
-
PipetteComponent.pipette.style.display = 'flex';
|
|
142
|
-
canvas_component_1.default.cursorStyle = 'default';
|
|
143
|
-
}
|
|
144
|
-
static hide() {
|
|
145
|
-
PipetteComponent.pipette.style.display = 'none';
|
|
146
|
-
canvas_component_1.default.cursorStyle = 'default';
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.default = PipetteComponent;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import ComponentService from "../services/component.service";
|
|
2
|
-
export default class SlotComponent extends ComponentService {
|
|
3
|
-
private static template;
|
|
4
|
-
private static css;
|
|
5
|
-
static slot: HTMLSlotElement;
|
|
6
|
-
static getComponent(slotName: string): {
|
|
7
|
-
slotTemplate: HTMLElement;
|
|
8
|
-
slotStyle: HTMLStyleElement;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const component_service_1 = require("../services/component.service");
|
|
4
|
-
const logger_service_1 = require("../services/logger.service");
|
|
5
|
-
class SlotComponent extends component_service_1.default {
|
|
6
|
-
static template = `
|
|
7
|
-
<slot class="slot"></slot>
|
|
8
|
-
`;
|
|
9
|
-
static css = ``;
|
|
10
|
-
static slot;
|
|
11
|
-
static {
|
|
12
|
-
logger_service_1.default.components.add({
|
|
13
|
-
info: {
|
|
14
|
-
name: 'slot',
|
|
15
|
-
description: 'slot component',
|
|
16
|
-
},
|
|
17
|
-
prototype: SlotComponent,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
static getComponent(slotName) {
|
|
21
|
-
const wrapOptions = {
|
|
22
|
-
className: 'slot-wrapper',
|
|
23
|
-
};
|
|
24
|
-
const slotTemplate = SlotComponent.getTemplate(SlotComponent.template, wrapOptions);
|
|
25
|
-
const slotStyle = SlotComponent.getStyle(SlotComponent.css);
|
|
26
|
-
SlotComponent.slot = slotTemplate.querySelector('slot');
|
|
27
|
-
SlotComponent.slot.name = slotName;
|
|
28
|
-
return { slotTemplate, slotStyle };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.default = SlotComponent;
|
package/dist/config.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ICanvasSize } from "./types/canvas";
|
|
2
|
-
export interface ILayer {
|
|
3
|
-
name: string;
|
|
4
|
-
index: number;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class ConfigStore {
|
|
7
|
-
static _WEB_COMPONENT_TAG_NAME: string;
|
|
8
|
-
static _CANVAS_SIZE: ICanvasSize;
|
|
9
|
-
static _LAYERS: ILayer[];
|
|
10
|
-
}
|
|
11
|
-
export declare class ConfigFabric implements ConfigStore {
|
|
12
|
-
protected static _WEB_COMPONENT_TAG_NAME: string;
|
|
13
|
-
protected static _CANVAS_SIZE: ICanvasSize;
|
|
14
|
-
protected static _LAYERS: ILayer[];
|
|
15
|
-
}
|
|
16
|
-
export default class AppConfig extends ConfigFabric {
|
|
17
|
-
static get WEB_COMPONENT_TAG_NAME(): string;
|
|
18
|
-
static set WEB_COMPONENT_TAG_NAME(value: string | undefined);
|
|
19
|
-
static get CANVAS_SIZE(): ICanvasSize;
|
|
20
|
-
static set CANVAS_SIZE(value: ICanvasSize | undefined);
|
|
21
|
-
static get LAYERS(): ILayer[];
|
|
22
|
-
static set LAYERS(value: ILayer[]);
|
|
23
|
-
}
|