canvas-editor-engine 2.3.22 → 2.3.23

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.
Files changed (56) hide show
  1. package/dist/index.mjs +68 -0
  2. package/dist/services/draw-accumulator.service.d.ts +2 -1
  3. package/dist/services/draw-layers.service.d.ts +4 -2
  4. package/dist/types/draw-layers.d.ts +8 -0
  5. package/dist/web-component.d.ts +1 -1
  6. package/package.json +7 -5
  7. package/dist/components/canvas.component.js +0 -102
  8. package/dist/components/excretions.component.js +0 -258
  9. package/dist/components/loading.component.js +0 -71
  10. package/dist/components/pipette.component.js +0 -120
  11. package/dist/components/slot.component.js +0 -45
  12. package/dist/config.js +0 -95
  13. package/dist/filters/collection/vague.js +0 -168
  14. package/dist/filters/index.js +0 -2
  15. package/dist/index.js +0 -75
  16. package/dist/services/component.service.js +0 -40
  17. package/dist/services/crop.service.js +0 -60
  18. package/dist/services/download.service.js +0 -16
  19. package/dist/services/draw-accumulator.service.js +0 -222
  20. package/dist/services/draw-layers.service.js +0 -72
  21. package/dist/services/draw.service.js +0 -259
  22. package/dist/services/event.service.js +0 -45
  23. package/dist/services/logger.service.js +0 -57
  24. package/dist/services/projects.service.js +0 -103
  25. package/dist/services/pull-project.service.js +0 -40
  26. package/dist/services/serize.service.js +0 -23
  27. package/dist/services/store.service.js +0 -14
  28. package/dist/services/through-history.service.js +0 -51
  29. package/dist/services/tool-layers.service.js +0 -13
  30. package/dist/services/tool.service.js +0 -59
  31. package/dist/store/draw-layers.state.js +0 -85
  32. package/dist/store/history.state.js +0 -77
  33. package/dist/store/image.state.js +0 -80
  34. package/dist/store/store.js +0 -41
  35. package/dist/store/storeRepository.js +0 -6
  36. package/dist/types/canvas.js +0 -2
  37. package/dist/types/cursor.js +0 -2
  38. package/dist/types/draw-layers.js +0 -3
  39. package/dist/types/draw-service.js +0 -2
  40. package/dist/types/excretion.js +0 -4
  41. package/dist/types/general.js +0 -5
  42. package/dist/types/history.js +0 -1
  43. package/dist/types/image.js +0 -9
  44. package/dist/types/log.js +0 -4
  45. package/dist/types/pipette.js +0 -1
  46. package/dist/types/project.js +0 -14
  47. package/dist/types/temp-canvas.js +0 -2
  48. package/dist/utils/convert.js +0 -27
  49. package/dist/utils/filter.js +0 -153
  50. package/dist/utils/generation.js +0 -7
  51. package/dist/utils/guid4.js +0 -122
  52. package/dist/utils/project-file-serializer.js +0 -77
  53. package/dist/utils/reflect.js +0 -30
  54. package/dist/utils/temp-canvas.js +0 -19
  55. package/dist/web-component.js +0 -179
  56. /package/dist/services/{serize.service.d.ts → resize.service.d.ts} +0 -0
@@ -1,27 +0,0 @@
1
- var Convert = /** @class */ (function () {
2
- function Convert() {
3
- }
4
- Convert.byteRGBToHEX = function (color) {
5
- var red = color[0];
6
- var green = color[1];
7
- var blue = color[2];
8
- return Convert.rgbToHex(red, green, blue);
9
- };
10
- Convert.rgbToHex = function (r, g, b) {
11
- return "#".concat(Convert.componentToHEX(r)).concat(Convert.componentToHEX(g)).concat(Convert.componentToHEX(b));
12
- };
13
- Convert.hexToRgb = function (hex) {
14
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
15
- return result ? {
16
- r: parseInt(result[1], 16),
17
- g: parseInt(result[2], 16),
18
- b: parseInt(result[3], 16)
19
- } : null;
20
- };
21
- Convert.componentToHEX = function (colorComponent) {
22
- var hex = colorComponent.toString(16);
23
- return hex.length == 1 ? "0" + hex : hex;
24
- };
25
- return Convert;
26
- }());
27
- export { Convert };
@@ -1,153 +0,0 @@
1
- import { Convert } from "./convert";
2
- import { range } from './generation';
3
- var Filter = /** @class */ (function () {
4
- function Filter(appConfig, ctx) {
5
- this.appConfig = appConfig;
6
- this.ctx = ctx;
7
- }
8
- Filter.prototype.setImageSize = function (size) {
9
- this.imageSize = size;
10
- };
11
- Filter.prototype.copy = function (options) {
12
- var width = (options === null || options === void 0 ? void 0 : options.width) ? options.width : this.appConfig.CANVAS_SIZE.width;
13
- var height = (options === null || options === void 0 ? void 0 : options.height) ? options.height : this.appConfig.CANVAS_SIZE.height;
14
- var imgData = this.ctx.getImageData(options.x, options.y, width, height);
15
- return imgData;
16
- };
17
- Filter.prototype.copyExtendedModel = function (options) {
18
- var width = (options === null || options === void 0 ? void 0 : options.width) ? options.width : this.appConfig.CANVAS_SIZE.width;
19
- var height = (options === null || options === void 0 ? void 0 : options.height) ? options.height : this.appConfig.CANVAS_SIZE.height;
20
- var imgData = this.ctx.getImageData(options.x, options.y, width, height);
21
- var extendedImageData = this.clearEmptyPixels(imgData);
22
- return extendedImageData;
23
- };
24
- Filter.prototype.update = function (imgData, options) {
25
- this.ctx.clearRect(0, 0, this.appConfig.CANVAS_SIZE.width, this.appConfig.CANVAS_SIZE.height);
26
- this.ctx.putImageData(imgData, options.x, options.y);
27
- };
28
- Filter.prototype.clearEmptyPixels = function (imageData) {
29
- var rowRGBABuff = this.getRowRGBABuff(imageData);
30
- var RGBAMatrix = this.getRGBAMatrix(rowRGBABuff, { width: imageData.width, height: imageData.height });
31
- var beforeSize = {
32
- width: imageData.width,
33
- height: imageData.height,
34
- };
35
- var tempSize = this.getSizeOfSparseMatrix(RGBAMatrix, beforeSize);
36
- var cleared = rowRGBABuff.filter(function (byteArray) {
37
- var alpha = byteArray[3 /* E_RGBA.a */];
38
- return !!alpha;
39
- });
40
- var clearedBuff = cleared.flat();
41
- var tempCanvas = document.createElement('canvas');
42
- var tempCtx = tempCanvas.getContext('2d');
43
- var tempImageData = tempCtx.createImageData(tempSize.width, tempSize.height);
44
- clearedBuff.forEach(function (_, i) { return tempImageData.data[i] = clearedBuff[i]; });
45
- return {
46
- imageData: tempImageData,
47
- size: tempSize
48
- };
49
- };
50
- Filter.prototype.getSizeOfSparseMatrix = function (RGBAMatrix, tempSize) {
51
- // case 1: Xcanvas -> Ximage && Ycanvas -> Yimage
52
- var leftIndex;
53
- var upIndex;
54
- for (var iy = 0; iy < RGBAMatrix.length; iy++) {
55
- var row = RGBAMatrix[iy];
56
- for (var ix = 0; ix < row.length; ix++) {
57
- var rowItem = row[ix];
58
- var isNotEmpty = rowItem[3 /* E_RGBA.a */] !== 0;
59
- if (isNotEmpty) {
60
- leftIndex = ix;
61
- upIndex = iy;
62
- break;
63
- }
64
- }
65
- if (leftIndex !== undefined && upIndex !== undefined) {
66
- break;
67
- }
68
- }
69
- // case 2 reverse matrix: Ximage <- Xcanvas && Yimage <- Ycanvas
70
- var rightIndex;
71
- var downIndex;
72
- for (var iy = RGBAMatrix.length - 1; iy >= 0; iy--) {
73
- var row = RGBAMatrix[iy];
74
- for (var ix = row.length - 1; ix >= 0; ix--) {
75
- var rowItem = row[ix];
76
- var isNotEmpty = rowItem[3 /* E_RGBA.a */] !== 0;
77
- if (isNotEmpty) {
78
- rightIndex = row.length - 1 - ix;
79
- downIndex = RGBAMatrix.length - 1 - iy;
80
- break;
81
- }
82
- }
83
- if (rightIndex !== undefined && downIndex !== undefined) {
84
- break;
85
- }
86
- }
87
- var reduceWidth = function (tempWidth) { return tempWidth - (leftIndex + rightIndex); };
88
- var reduceHeight = function (tempHeight) { return tempHeight - (upIndex + downIndex); };
89
- var resultSize = {
90
- width: reduceWidth(tempSize.width),
91
- height: reduceHeight(tempSize.height),
92
- };
93
- return resultSize;
94
- };
95
- Filter.prototype.getBuffCollection = function (imageData) {
96
- var rowRGBABuff = this.getRowRGBABuff(imageData);
97
- var hexBuff = rowRGBABuff.map(Convert.byteRGBToHEX);
98
- var buff = this.getBuff(hexBuff);
99
- return { rowRGBABuff: rowRGBABuff, hexBuff: hexBuff, buff: buff };
100
- };
101
- Filter.prototype.getBuff = function (hexBuff) {
102
- var _this = this;
103
- var distanceRow = range(0, this.imageSize.height).map(function (i) { return _this.imageSize.width * i; });
104
- var buff = [];
105
- var indexOfDistance = 0;
106
- hexBuff.forEach(function (pxColor, pxIndex) {
107
- var _a;
108
- if (pxIndex >= distanceRow[indexOfDistance + 1]) {
109
- indexOfDistance++;
110
- }
111
- (_a = buff[indexOfDistance]) !== null && _a !== void 0 ? _a : (buff[indexOfDistance] = []);
112
- buff[indexOfDistance].push(pxColor);
113
- });
114
- return buff;
115
- };
116
- Filter.prototype.getRGBAMatrix = function (rowRGBABuff, size) {
117
- var maybeSize = {
118
- width: size.width || this.imageSize.width,
119
- height: size.height || this.imageSize.height,
120
- };
121
- var distanceRow = range(0, maybeSize.height).map(function (i) { return maybeSize.width * i; });
122
- var buff = [];
123
- var indexOfDistance = 0;
124
- rowRGBABuff.forEach(function (pxRGBA, pxIndex) {
125
- var _a;
126
- if (pxIndex >= distanceRow[indexOfDistance + 1]) {
127
- indexOfDistance++;
128
- }
129
- (_a = buff[indexOfDistance]) !== null && _a !== void 0 ? _a : (buff[indexOfDistance] = []);
130
- buff[indexOfDistance].push(pxRGBA);
131
- });
132
- return buff;
133
- };
134
- Filter.prototype.getRowRGBABuff = function (imageData) {
135
- var rowRGBABuff = []; // [ [0, 0, 0, 0], [0, 0, 0, 0], ... ]
136
- var colorIndx = 0;
137
- var colorRGBAIndx = 0;
138
- imageData.data.forEach(function (pxColor) {
139
- var _a;
140
- if (colorIndx >= 4) {
141
- colorIndx = 0;
142
- colorRGBAIndx++;
143
- }
144
- colorIndx++;
145
- // @ts-ignore
146
- (_a = rowRGBABuff[colorRGBAIndx]) !== null && _a !== void 0 ? _a : (rowRGBABuff[colorRGBAIndx] = []);
147
- rowRGBABuff[colorRGBAIndx].push(pxColor);
148
- });
149
- return rowRGBABuff;
150
- };
151
- return Filter;
152
- }());
153
- export { Filter };
@@ -1,7 +0,0 @@
1
- export var range = function (start, end) {
2
- var result = [];
3
- for (var i = start; i < end; i++) {
4
- result.push(i);
5
- }
6
- return result;
7
- };
@@ -1,122 +0,0 @@
1
- var Guid4 = /** @class */ (function () {
2
- function Guid4() {
3
- this.stack = [];
4
- // generateWithFactor not working
5
- // this.generateWithFactor(this.attempt);
6
- }
7
- Guid4.prototype.generate = function () {
8
- return this.Guid4;
9
- };
10
- Object.defineProperty(Guid4.prototype, "finite", {
11
- get: function () {
12
- var _a;
13
- var guid4 = this.stack[(_a = this.stack) === null || _a === void 0 ? void 0 : _a.length];
14
- if (!!guid4) {
15
- return guid4;
16
- }
17
- else {
18
- throw new Error("Guid4 not generate");
19
- }
20
- },
21
- enumerable: false,
22
- configurable: true
23
- });
24
- ;
25
- Guid4.prototype.generateWithFactor = function (attempt) {
26
- var factor = this.getFactor(this.guid4);
27
- attempt.use('withError').run(factor);
28
- };
29
- Guid4.prototype.getFactor = function (guid4) {
30
- var _this = this;
31
- return function (attempt) {
32
- guid4 = _this.Guid4;
33
- if (!_this.stack.includes(guid4)) {
34
- attempt.current = attempt.max;
35
- _this.stack.push(guid4);
36
- }
37
- };
38
- };
39
- Object.defineProperty(Guid4.prototype, "attempt", {
40
- get: function () {
41
- var attemptConfig = {
42
- attempt: {
43
- current: 1,
44
- max: 5,
45
- },
46
- error: {
47
- message: '[Fatal Error] Guid4 module cannot generate unique guid4'
48
- }
49
- };
50
- var attempt = new GenerateAttempt(attemptConfig.attempt, attemptConfig.error);
51
- return attempt;
52
- },
53
- enumerable: false,
54
- configurable: true
55
- });
56
- Object.defineProperty(Guid4.prototype, "Guid4", {
57
- get: function () {
58
- var base = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
59
- var regex = /[xy]/g;
60
- var guid4 = base.replace(regex, this.formating);
61
- return guid4;
62
- },
63
- enumerable: false,
64
- configurable: true
65
- });
66
- Guid4.prototype.formating = function (char) {
67
- var preformer = Math.random() * 16 | 0;
68
- var formattedChar = (char == 'x') ? preformer : (preformer & 0x3 | 0x8);
69
- return formattedChar.toString(16);
70
- };
71
- return Guid4;
72
- }());
73
- export { Guid4 };
74
- ;
75
- var GenerateAttempt = /** @class */ (function () {
76
- function GenerateAttempt(config, error) {
77
- this._attempt = config;
78
- if (!!error)
79
- this._error = error;
80
- }
81
- GenerateAttempt.prototype.use = function (strategy) {
82
- if (strategy === void 0) { strategy = 'default'; }
83
- var context = this;
84
- switch (strategy) {
85
- case 'default':
86
- return {
87
- run: function (action) {
88
- context.defaultRun(action);
89
- },
90
- };
91
- case 'withError':
92
- return {
93
- run: function (action) {
94
- context.withErrorRun(action);
95
- },
96
- };
97
- }
98
- };
99
- GenerateAttempt.prototype.defaultRun = function (action) {
100
- var attemptCondition = this._attempt.current <= this._attempt.max;
101
- while (attemptCondition) {
102
- action(this._attempt);
103
- this._attempt.current++;
104
- }
105
- };
106
- GenerateAttempt.prototype.withErrorRun = function (action) {
107
- var attemptCondition = this._attempt.current <= this._attempt.max;
108
- var errorCondition = this._attempt.current === this._attempt.max;
109
- var errorMessage = this._error.message;
110
- while (attemptCondition) {
111
- this.throwError(errorCondition, errorMessage);
112
- action(this._attempt);
113
- this._attempt.current++;
114
- }
115
- };
116
- GenerateAttempt.prototype.throwError = function (condition, message) {
117
- if (condition) {
118
- throw new Error(message);
119
- }
120
- };
121
- return GenerateAttempt;
122
- }());
@@ -1,77 +0,0 @@
1
- var ProjectFileSerializer = /** @class */ (function () {
2
- function ProjectFileSerializer(file) {
3
- this.projects = [];
4
- this.file = file;
5
- this.projects = this.load();
6
- }
7
- ;
8
- ProjectFileSerializer.prototype.load = function () {
9
- var rowProjects = JSON.parse(this.file);
10
- var imageDataProcessor = function (temp) {
11
- var data;
12
- var size;
13
- if (temp === null || temp === void 0 ? void 0 : temp.current) {
14
- data = Object.values(temp === null || temp === void 0 ? void 0 : temp.current.imageData.data);
15
- size = temp === null || temp === void 0 ? void 0 : temp.current.size;
16
- }
17
- else if (temp === null || temp === void 0 ? void 0 : temp.state) {
18
- data = Object.values(temp === null || temp === void 0 ? void 0 : temp.state.tempImageData.data);
19
- size = temp === null || temp === void 0 ? void 0 : temp.state.size;
20
- }
21
- var tempImageData = new ImageData(size.width, size.height);
22
- data.forEach(function (colorAtom, index) {
23
- tempImageData.data[index] = colorAtom;
24
- });
25
- return tempImageData;
26
- };
27
- var projects = rowProjects.map(function (project) {
28
- project.state.current.imageData = imageDataProcessor({ current: project.state.current });
29
- project.state.history = project.state.history.map(function (historyLine) {
30
- historyLine.stateValue.tempImageData = imageDataProcessor({ state: historyLine.stateValue });
31
- return historyLine;
32
- });
33
- project.state.cache = project.state.cache.map(function (historyLine) {
34
- historyLine.stateValue.tempImageData = imageDataProcessor({ state: historyLine.stateValue });
35
- return historyLine;
36
- });
37
- return project;
38
- });
39
- return projects;
40
- };
41
- ProjectFileSerializer.prototype.saveProjects = function (projects) {
42
- // TODO: not sure if this works
43
- this.file.save(JSON.stringify(projects));
44
- };
45
- ProjectFileSerializer.prototype.getProjects = function () {
46
- return this.projects;
47
- };
48
- ProjectFileSerializer.prototype.getProject = function (projectId) {
49
- return this.projects.find(function (project) { return project.id === projectId; });
50
- };
51
- ProjectFileSerializer.prototype.saveProject = function (project) {
52
- var index = this.projects.findIndex(function (p) { return p.id === project.id; });
53
- if (index !== -1) {
54
- this.projects[index] = project;
55
- }
56
- else {
57
- this.projects.push(project);
58
- }
59
- this.saveProjects(this.projects);
60
- };
61
- ProjectFileSerializer.prototype.removeProject = function (projectId) {
62
- var index = this.projects.findIndex(function (p) { return p.id === projectId; });
63
- if (index !== -1) {
64
- this.projects.splice(index, 1);
65
- this.saveProjects(this.projects);
66
- }
67
- };
68
- ProjectFileSerializer.prototype.updateProject = function (project) {
69
- var index = this.projects.findIndex(function (p) { return p.id === project.id; });
70
- if (index !== -1) {
71
- this.projects[index] = project;
72
- this.saveProjects(this.projects);
73
- }
74
- };
75
- return ProjectFileSerializer;
76
- }());
77
- export { ProjectFileSerializer };
@@ -1,30 +0,0 @@
1
- export var reflect = function () {
2
- if (
3
- // No Reflect, no classes, no need for shim because native custom elements
4
- // require ES2015 classes or Reflect.
5
- window.Reflect === undefined ||
6
- window.customElements === undefined ||
7
- // The webcomponentsjs custom elements polyfill doesn't require
8
- // ES2015-compatible construction (`super()` or `Reflect.construct`).
9
- // @ts-ignore
10
- window.customElements.polyfillWrapFlushCallback) {
11
- return;
12
- }
13
- var BuiltInHTMLElement = HTMLElement;
14
- /**
15
- * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.
16
- * However, if we declare the function as a property on an object literal, and
17
- * use quotes for the property name, then closure will leave that much intact,
18
- * which is enough for the JS VM to correctly set Function.prototype.name.
19
- */
20
- var wrapperForTheName = {
21
- 'HTMLElement': /** @this {!Object} */ function HTMLElement() {
22
- return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ (this.constructor));
23
- }
24
- };
25
- // @ts-ignore
26
- window.HTMLElement = wrapperForTheName['HTMLElement'];
27
- HTMLElement.prototype = BuiltInHTMLElement.prototype;
28
- HTMLElement.prototype.constructor = HTMLElement;
29
- Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement);
30
- };
@@ -1,19 +0,0 @@
1
- var TempCanvas = /** @class */ (function () {
2
- function TempCanvas() {
3
- this.canvas = document.createElement('canvas');
4
- this.ctx = this.canvas.getContext('2d', { willReadFrequently: true });
5
- }
6
- TempCanvas.prototype.bindOptions = function (options) {
7
- this.canvas.width = options.width;
8
- this.canvas.height = options.height;
9
- this.ctx = this.canvas.getContext('2d', { willReadFrequently: true });
10
- };
11
- TempCanvas.prototype.destroy = function () {
12
- this.canvas.remove();
13
- };
14
- TempCanvas.prototype.getImageData = function () {
15
- return this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
16
- };
17
- return TempCanvas;
18
- }());
19
- export { TempCanvas };
@@ -1,179 +0,0 @@
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;