canvas-editor-engine 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_1 = require("../config");
4
4
  const component_service_1 = require("../services/component.service");
5
+ const logger_service_1 = require("../services/logger.service");
5
6
  class CanvasComponent extends component_service_1.default {
7
+ ;
6
8
  static getComponent() {
7
9
  const canvasTemplate = CanvasComponent.getTemplate(CanvasComponent.template);
8
10
  const canvasStyle = CanvasComponent.getStyle(CanvasComponent.css);
@@ -72,4 +74,13 @@ CanvasComponent._cursorStyle = {
72
74
  before: null,
73
75
  current: 'default',
74
76
  };
77
+ (() => {
78
+ logger_service_1.default.components.add({
79
+ info: {
80
+ name: 'canvas',
81
+ description: 'canvas component',
82
+ },
83
+ prototype: CanvasComponent,
84
+ });
85
+ })();
75
86
  exports.default = CanvasComponent;
@@ -0,0 +1,5 @@
1
+ import ComponentService from "../services/component.service";
2
+ export default class CropComponent extends ComponentService {
3
+ private static template;
4
+ private static css;
5
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const component_service_1 = require("../services/component.service");
4
+ class CropComponent extends component_service_1.default {
5
+ }
6
+ CropComponent.template = '';
7
+ CropComponent.css = '';
8
+ exports.default = CropComponent;
@@ -1,5 +1,5 @@
1
1
  import ComponentService from "../services/component.service";
2
- import type { IExcretionsCoords, TExcretionToolState } from "../types/excretion";
2
+ import type { IExcretionsCoords, TExcretionStyle, TExcretionToolState } from "../types/excretion";
3
3
  export default class ExcretionsComponent extends ComponentService {
4
4
  private static template;
5
5
  private static css;
@@ -10,6 +10,10 @@ export default class ExcretionsComponent extends ComponentService {
10
10
  private static _excretionToolState;
11
11
  private static _tempCoords;
12
12
  static excretionsCoords: IExcretionsCoords[];
13
+ private static _style;
14
+ static get style(): TExcretionStyle;
15
+ static set style(value: TExcretionStyle);
16
+ private static applyExcretionStyle;
13
17
  private static tool;
14
18
  static getComponent(): {
15
19
  excretionsTemplate: HTMLElement;
@@ -3,7 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const component_service_1 = require("../services/component.service");
4
4
  const tool_service_1 = require("../services/tool.service");
5
5
  const canvas_component_1 = require("./canvas.component");
6
+ const logger_service_1 = require("../services/logger.service");
6
7
  class ExcretionsComponent extends component_service_1.default {
8
+ static get style() {
9
+ return ExcretionsComponent._style;
10
+ }
11
+ static set style(value) {
12
+ ExcretionsComponent._style = value;
13
+ ExcretionsComponent.applyExcretionStyle();
14
+ }
15
+ static applyExcretionStyle() {
16
+ if (ExcretionsComponent._style === 'crop') {
17
+ ExcretionsComponent._excretions.forEach((excretion) => {
18
+ if (!!excretion) {
19
+ if (!excretion.classList.contains('excretion_crop')) {
20
+ excretion.classList.add("excretion_crop");
21
+ }
22
+ }
23
+ });
24
+ }
25
+ else {
26
+ ExcretionsComponent._excretions.forEach((excretion) => {
27
+ if (!!excretion) {
28
+ if (excretion.classList.contains('excretion_crop')) {
29
+ excretion.classList.remove("excretion_crop");
30
+ }
31
+ }
32
+ });
33
+ }
34
+ }
35
+ ;
7
36
  static getComponent() {
8
37
  const wrapOptions = {
9
38
  className: 'excretions-wrap',
@@ -16,6 +45,7 @@ class ExcretionsComponent extends component_service_1.default {
16
45
  }
17
46
  static set excretionState(state) {
18
47
  ExcretionsComponent._excretionState = state;
48
+ ExcretionsComponent.applyExcretionStyle();
19
49
  switch (state) {
20
50
  case 'abandoned':
21
51
  canvas_component_1.default.cursorStyle = 'default';
@@ -96,6 +126,7 @@ class ExcretionsComponent extends component_service_1.default {
96
126
  };
97
127
  ExcretionsComponent._tempCoords.push(tempStart);
98
128
  }
129
+ ExcretionsComponent.applyExcretionStyle();
99
130
  ExcretionsComponent._excretionActivity = 'active';
100
131
  });
101
132
  canvas_component_1.default.subscribe('mousemove', (event, cursorPosition) => {
@@ -164,6 +195,10 @@ ExcretionsComponent.css = `
164
195
  animation: border-dance 1s infinite linear;
165
196
  }
166
197
 
198
+ .excretion_crop {
199
+ box-shadow: 0px 0px 0px 100% rgba(34, 60, 80, 0.2);
200
+ }
201
+
167
202
  @keyframes border-dance {
168
203
  0% {
169
204
  background-position: left top, right bottom, left bottom, right top;
@@ -179,6 +214,7 @@ ExcretionsComponent._excretionActivity = 'abandoned';
179
214
  ExcretionsComponent._excretionToolState = 'abandoned';
180
215
  ExcretionsComponent._tempCoords = [];
181
216
  ExcretionsComponent.excretionsCoords = [];
217
+ ExcretionsComponent._style = 'default';
182
218
  ExcretionsComponent.tool = {
183
219
  id: 1,
184
220
  name: 'excretion',
@@ -188,5 +224,12 @@ ExcretionsComponent.tool = {
188
224
  };
189
225
  (() => {
190
226
  tool_service_1.default.add(ExcretionsComponent.tool);
227
+ logger_service_1.default.components.add({
228
+ info: {
229
+ name: 'excretion',
230
+ description: 'excretion component',
231
+ },
232
+ prototype: ExcretionsComponent,
233
+ });
191
234
  })();
192
235
  exports.default = ExcretionsComponent;
@@ -4,6 +4,7 @@ const convert_1 = require("../utils/convert");
4
4
  const canvas_component_1 = require("./canvas.component");
5
5
  const component_service_1 = require("../services/component.service");
6
6
  const tool_service_1 = require("../services/tool.service");
7
+ const logger_service_1 = require("../services/logger.service");
7
8
  class PipetteComponent extends component_service_1.default {
8
9
  static set pipetteColor(color) {
9
10
  PipetteComponent._pipetteColor = color;
@@ -134,5 +135,12 @@ PipetteComponent.tool = {
134
135
  };
135
136
  (() => {
136
137
  tool_service_1.default.add(PipetteComponent.tool);
138
+ logger_service_1.default.components.add({
139
+ info: {
140
+ name: 'pipette',
141
+ description: 'pipette component',
142
+ },
143
+ prototype: PipetteComponent,
144
+ });
137
145
  })();
138
146
  exports.default = PipetteComponent;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const component_service_1 = require("../services/component.service");
4
+ const logger_service_1 = require("../services/logger.service");
4
5
  class SlotComponent extends component_service_1.default {
5
6
  static getComponent(slotName) {
6
7
  const wrapOptions = {
@@ -17,4 +18,13 @@ SlotComponent.template = `
17
18
  <slot class="slot"></slot>
18
19
  `;
19
20
  SlotComponent.css = ``;
21
+ (() => {
22
+ logger_service_1.default.components.add({
23
+ info: {
24
+ name: 'slot',
25
+ description: 'slot component',
26
+ },
27
+ prototype: SlotComponent,
28
+ });
29
+ })();
20
30
  exports.default = SlotComponent;
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import ExcretionComponent from "./components/excretions.component";
6
6
  import SlotComponent from "./components/slot.component";
7
7
  import DrawService from "./services/draw.service";
8
8
  import ToolService from "./services/tool.service";
9
+ import LoggerService from "./services/logger.service";
9
10
  declare class CanvasEditorEngine {
10
11
  constructor(webComponentTagName?: string);
11
12
  getInitial(): {
@@ -22,4 +23,4 @@ declare class VueCanvasEditorEngine extends CanvasEditorEngine {
22
23
  getContext2D(): CanvasRenderingContext2D;
23
24
  getCanvas(): HTMLCanvasElement;
24
25
  }
25
- export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, ToolService, DrawService, StaticCanvasEditorEngine, VueCanvasEditorEngine, };
26
+ export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, ToolService, DrawService, LoggerService, 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.DrawService = exports.ToolService = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
3
+ exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.LoggerService = exports.DrawService = exports.ToolService = 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");
@@ -16,6 +16,8 @@ const draw_service_1 = require("./services/draw.service");
16
16
  exports.DrawService = draw_service_1.default;
17
17
  const tool_service_1 = require("./services/tool.service");
18
18
  exports.ToolService = tool_service_1.default;
19
+ const logger_service_1 = require("./services/logger.service");
20
+ exports.LoggerService = logger_service_1.default;
19
21
  class CanvasEditorEngine {
20
22
  constructor(webComponentTagName) {
21
23
  config_1.default.WEB_COMPONENT_TAG_NAME = webComponentTagName;
@@ -0,0 +1,20 @@
1
+ import { ILog, ILogItem } from "../types/log";
2
+ import ComponentService from "./component.service";
3
+ export default class LoggerService {
4
+ static log: ILog<ComponentService, any, any>;
5
+ static get components(): {
6
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
7
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
8
+ };
9
+ static get services(): {
10
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
11
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
12
+ };
13
+ static get planed(): {
14
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
15
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
16
+ };
17
+ private static getMethods;
18
+ private static _add;
19
+ private static _get;
20
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class LoggerService {
4
+ static get components() {
5
+ return LoggerService.getMethods('components');
6
+ }
7
+ ;
8
+ static get services() {
9
+ return LoggerService.getMethods('services');
10
+ }
11
+ ;
12
+ static get planed() {
13
+ return LoggerService.getMethods('planed');
14
+ }
15
+ ;
16
+ static getMethods(fields) {
17
+ return {
18
+ add(logItem) {
19
+ LoggerService._add(fields, logItem);
20
+ },
21
+ get(...args) {
22
+ LoggerService._get(...args);
23
+ },
24
+ };
25
+ }
26
+ static _add(field, logItem) {
27
+ LoggerService.log[field].push(logItem);
28
+ }
29
+ static _get(field, name) {
30
+ return LoggerService.log[field].find((logItem) => logItem.info.name === name);
31
+ }
32
+ }
33
+ LoggerService.log = {
34
+ components: [],
35
+ services: [],
36
+ planed: [],
37
+ };
38
+ exports.default = LoggerService;
@@ -24,3 +24,4 @@ export type TExcretionTempCoords = (IExcretionTempStart | IExcretionTempEnd)[];
24
24
  export type TExcretionToolState = 'taken' | 'abandoned';
25
25
  export type TExcretionState = 'create' | 'add' | 'remove' | 'abandoned';
26
26
  export type TExcretionActivity = 'active' | 'end' | 'abandoned';
27
+ export type TExcretionStyle = 'default' | 'crop';
@@ -0,0 +1,13 @@
1
+ export interface ILog<A, R, P> {
2
+ components: ILogItem<A>[];
3
+ services: ILogItem<R>[];
4
+ planed: ILogItem<P>[];
5
+ }
6
+ export interface ILogItem<TLogPrototype> {
7
+ info: ILogItemInfo;
8
+ prototype: TLogPrototype;
9
+ }
10
+ export interface ILogItemInfo {
11
+ name: string;
12
+ description: string;
13
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ ;
5
+ ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",