canvas-editor-engine 1.0.46 → 1.0.48
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/loading.component.d.ts +14 -0
- package/dist/components/loading.component.js +96 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/services/crop.service.js +0 -1
- package/dist/services/draw.service.js +2 -0
- package/dist/services/event.service.d.ts +7 -10
- package/dist/services/event.service.js +10 -11
- package/dist/web-component.js +6 -0
- package/package.json +1 -1
@@ -0,0 +1,14 @@
|
|
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
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const config_1 = require("../config");
|
4
|
+
const component_service_1 = require("../services/component.service");
|
5
|
+
const event_service_1 = require("../services/event.service");
|
6
|
+
const logger_service_1 = require("../services/logger.service");
|
7
|
+
class LoadingComponent extends component_service_1.default {
|
8
|
+
static template = `
|
9
|
+
<span class="loader"></span>
|
10
|
+
`;
|
11
|
+
static css = `
|
12
|
+
.loading-wrapper {
|
13
|
+
display: none;
|
14
|
+
justify-content: center;
|
15
|
+
align-items: center;
|
16
|
+
position: absolute;
|
17
|
+
width: ${config_1.default.CANVAS_SIZE.width}px;
|
18
|
+
height: ${config_1.default.CANVAS_SIZE.height}px;
|
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;
|
package/dist/index.d.ts
CHANGED
@@ -4,6 +4,7 @@ import CanvasComponent from "./components/canvas.component";
|
|
4
4
|
import PipetteComponent from "./components/pipette.component";
|
5
5
|
import ExcretionComponent from "./components/excretions.component";
|
6
6
|
import SlotComponent from "./components/slot.component";
|
7
|
+
import LoadingComponent from "./components/loading.component";
|
7
8
|
import DrawService from "./services/draw.service";
|
8
9
|
import ToolService from "./services/tool.service";
|
9
10
|
import LoggerService from "./services/logger.service";
|
@@ -26,4 +27,4 @@ declare class VueCanvasEditorEngine extends CanvasEditorEngine {
|
|
26
27
|
getContext2D(): CanvasRenderingContext2D;
|
27
28
|
getCanvas(): HTMLCanvasElement;
|
28
29
|
}
|
29
|
-
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, StaticCanvasEditorEngine, VueCanvasEditorEngine, };
|
30
|
+
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, StaticCanvasEditorEngine, VueCanvasEditorEngine, };
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.ToolLayerService = exports.DownloadService = exports.CropService = exports.LoggerService = exports.DrawService = exports.ToolService = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
|
3
|
+
exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.ToolLayerService = exports.DownloadService = exports.CropService = exports.LoggerService = exports.DrawService = exports.ToolService = exports.LoadingComponent = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
|
4
4
|
const config_1 = require("./config");
|
5
5
|
exports.AppConfig = config_1.default;
|
6
6
|
const web_component_1 = require("./web-component");
|
@@ -12,6 +12,8 @@ const excretions_component_1 = require("./components/excretions.component");
|
|
12
12
|
exports.ExcretionComponent = excretions_component_1.default;
|
13
13
|
const slot_component_1 = require("./components/slot.component");
|
14
14
|
exports.SlotComponent = slot_component_1.default;
|
15
|
+
const loading_component_1 = require("./components/loading.component");
|
16
|
+
exports.LoadingComponent = loading_component_1.default;
|
15
17
|
const draw_service_1 = require("./services/draw.service");
|
16
18
|
exports.DrawService = draw_service_1.default;
|
17
19
|
const tool_service_1 = require("./services/tool.service");
|
@@ -11,7 +11,6 @@ class CropService {
|
|
11
11
|
static crop(ctx) {
|
12
12
|
if (!!excretions_component_1.default.excretionsCoords?.length === false)
|
13
13
|
return;
|
14
|
-
console.log(CropService.options);
|
15
14
|
const filter = new filter_1.Filter(ctx);
|
16
15
|
const options = CropService.options;
|
17
16
|
const imageData = filter.copy(options);
|
@@ -4,6 +4,7 @@ exports.SCImage = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
5
5
|
const filters_1 = require("../filters");
|
6
6
|
const store_1 = require("../store/store");
|
7
|
+
const event_service_1 = require("./event.service");
|
7
8
|
class DrawService {
|
8
9
|
static scImage;
|
9
10
|
static drawImage(ctx, src, options) {
|
@@ -12,6 +13,7 @@ class DrawService {
|
|
12
13
|
}
|
13
14
|
static drawSmoothImage(useStore, options, filterOptions) {
|
14
15
|
const filterArgs = DrawService.getFilterArgs(useStore, options);
|
16
|
+
event_service_1.default.dispatch('loading-start');
|
15
17
|
this.scImage.vague(filterArgs, filterOptions);
|
16
18
|
}
|
17
19
|
static getFilterArgs(useStore, options) {
|
@@ -1,24 +1,21 @@
|
|
1
1
|
import { IGUID4 } from "../types/general";
|
2
2
|
export declare abstract class ControlEvent {
|
3
3
|
name: string;
|
4
|
-
action: (args?: any) =>
|
4
|
+
action: (args?: any) => any;
|
5
5
|
}
|
6
6
|
export declare class EventAtom implements ControlEvent {
|
7
7
|
id: IGUID4;
|
8
8
|
name: string;
|
9
|
-
action: (args?: any) =>
|
9
|
+
action: (args?: any) => any;
|
10
10
|
}
|
11
|
-
export declare abstract class
|
12
|
-
eventList: EventAtom[];
|
13
|
-
abstract subcribe(event: EventAtom): void;
|
14
|
-
abstract dispatch(name: ControlEvent['name'], eventArgs?: any): void;
|
11
|
+
export declare abstract class AbstractEventService {
|
15
12
|
abstract applyEvents(baseElement: HTMLDivElement): void;
|
16
13
|
}
|
17
|
-
export
|
14
|
+
export default class EventService implements AbstractEventService {
|
18
15
|
private baseElement;
|
19
|
-
eventList: EventAtom[];
|
16
|
+
static eventList: EventAtom[];
|
20
17
|
constructor(baseElement: HTMLDivElement);
|
21
|
-
subcribe(controlEvent: ControlEvent): void;
|
22
|
-
dispatch(name: ControlEvent['name'], eventArgs?: any): void;
|
18
|
+
static subcribe(controlEvent: ControlEvent): void;
|
19
|
+
static dispatch(name: ControlEvent['name'], eventArgs?: any): void;
|
23
20
|
applyEvents(): void;
|
24
21
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.AbstractEventService = exports.EventAtom = exports.ControlEvent = void 0;
|
4
4
|
const guid4_1 = require("../utils/guid4");
|
5
5
|
class ControlEvent {
|
6
6
|
name;
|
@@ -13,31 +13,30 @@ class EventAtom {
|
|
13
13
|
action;
|
14
14
|
}
|
15
15
|
exports.EventAtom = EventAtom;
|
16
|
-
class
|
17
|
-
eventList;
|
16
|
+
class AbstractEventService {
|
18
17
|
}
|
19
|
-
exports.
|
18
|
+
exports.AbstractEventService = AbstractEventService;
|
20
19
|
class EventService {
|
21
20
|
baseElement;
|
22
|
-
eventList;
|
21
|
+
static eventList;
|
23
22
|
constructor(baseElement) {
|
24
23
|
this.baseElement = baseElement;
|
25
24
|
}
|
26
|
-
subcribe(controlEvent) {
|
25
|
+
static subcribe(controlEvent) {
|
27
26
|
const eventAtom = {
|
28
27
|
id: new guid4_1.Guid4().finite,
|
29
28
|
...controlEvent
|
30
29
|
};
|
31
|
-
|
30
|
+
EventService.eventList.push(eventAtom);
|
32
31
|
}
|
33
|
-
dispatch(name, eventArgs) {
|
34
|
-
const eventAtom =
|
32
|
+
static dispatch(name, eventArgs) {
|
33
|
+
const eventAtom = EventService.eventList.find((event) => event.name === name);
|
35
34
|
eventAtom.action(eventArgs);
|
36
35
|
}
|
37
36
|
applyEvents() {
|
38
|
-
|
37
|
+
EventService.eventList.forEach((event) => {
|
39
38
|
this.baseElement.addEventListener(event.name, event.action);
|
40
39
|
});
|
41
40
|
}
|
42
41
|
}
|
43
|
-
exports.
|
42
|
+
exports.default = EventService;
|
package/dist/web-component.js
CHANGED
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebComponentWrapper = void 0;
|
4
4
|
const canvas_component_1 = require("./components/canvas.component");
|
5
5
|
const excretions_component_1 = require("./components/excretions.component");
|
6
|
+
const loading_component_1 = require("./components/loading.component");
|
6
7
|
const pipette_component_1 = require("./components/pipette.component");
|
7
8
|
const slot_component_1 = require("./components/slot.component");
|
9
|
+
const event_service_1 = require("./services/event.service");
|
8
10
|
class WebComponentWrapper {
|
9
11
|
baseElement;
|
10
12
|
editorWrapElement;
|
@@ -88,8 +90,12 @@ class WebComponent extends HTMLElement {
|
|
88
90
|
webComponentWrapper.toolsWrap.add(slotTemplate, slotStyle);
|
89
91
|
const { excretionsTemplate, excretionsStyle } = excretions_component_1.default.getComponent();
|
90
92
|
webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
|
93
|
+
const { loadingTemplate, loadingStyle } = loading_component_1.default.getComponent();
|
94
|
+
webComponentWrapper.editorWrap.add(loadingTemplate, loadingStyle);
|
91
95
|
shadowRoot.appendChild(webComponentWrapper.baseElement);
|
92
96
|
canvas_component_1.default.simulateSubscriptions();
|
97
|
+
const eventService = new event_service_1.default(webComponentWrapper.baseElement);
|
98
|
+
eventService.applyEvents();
|
93
99
|
this.addEventListener('initial', () => {
|
94
100
|
this.dispatchEvent(new CustomEvent('get-editor-element', {
|
95
101
|
detail: {
|