canvas-editor-engine 2.3.16 → 2.3.17

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.mjs CHANGED
@@ -2201,7 +2201,7 @@ var DrawAccumulator = function() {
2201
2201
  }));
2202
2202
  }));
2203
2203
  };
2204
- DrawAccumulator.prototype.remove = function(id) {
2204
+ DrawAccumulator.prototype.removePainter = function(id) {
2205
2205
  return __awaiter(this, void 0, void 0, (function() {
2206
2206
  var painter;
2207
2207
  return __generator(this, (function(_a) {
@@ -2213,6 +2213,25 @@ var DrawAccumulator = function() {
2213
2213
  return painter.id !== id;
2214
2214
  }));
2215
2215
  }
2216
+ this.drawLayersService.removePainter(id);
2217
+ return [ 2 ];
2218
+ }));
2219
+ }));
2220
+ };
2221
+ DrawAccumulator.prototype.smoothFilter = function(painterId, smoothFilterOptions) {
2222
+ return __awaiter(this, void 0, void 0, (function() {
2223
+ var useStore, options, filterOptions, painter;
2224
+ var _this = this;
2225
+ return __generator(this, (function(_a) {
2226
+ useStore = smoothFilterOptions.useStore, options = smoothFilterOptions.options,
2227
+ filterOptions = smoothFilterOptions.filterOptions;
2228
+ painter = this.painters.find((function(painter) {
2229
+ return painter.id === painterId;
2230
+ }));
2231
+ if (!painter) return [ 2 ];
2232
+ painter.drawService.drawSmoothImage(useStore, options, filterOptions).then((function() {
2233
+ _this.update();
2234
+ }));
2216
2235
  return [ 2 ];
2217
2236
  }));
2218
2237
  }));
@@ -2396,16 +2415,22 @@ var DrawService = function() {
2396
2415
  }));
2397
2416
  };
2398
2417
  DrawService.prototype.drawSmoothImage = function(useStore, options, filterOptions) {
2399
- var _this = this;
2400
- var filterArgs = this.getFilterArgs(useStore, options);
2401
- this.eventService.dispatch("loading-start");
2402
- if (!this.imageProcessor) {
2403
- throw new Error("No valid ImageProcessor instance found");
2404
- }
2405
- this.imageProcessor.vague(filterArgs, filterOptions).then((function(data) {
2406
- return _this.updateImageStateAfterVague(data);
2407
- })).finally((function() {
2408
- return _this.eventService.dispatch("loading-end");
2418
+ return __awaiter(this, void 0, void 0, (function() {
2419
+ var filterArgs;
2420
+ var _this = this;
2421
+ return __generator(this, (function(_a) {
2422
+ filterArgs = this.getFilterArgs(useStore, options);
2423
+ this.eventService.dispatch("loading-start");
2424
+ if (!this.imageProcessor) {
2425
+ throw new Error("No valid ImageProcessor instance found");
2426
+ }
2427
+ return [ 2, this.imageProcessor.vague(filterArgs, filterOptions).then((function(data) {
2428
+ _this.updateImageStateAfterVague(data);
2429
+ return data;
2430
+ })).finally((function() {
2431
+ return _this.eventService.dispatch("loading-end");
2432
+ })) ];
2433
+ }));
2409
2434
  }));
2410
2435
  };
2411
2436
  DrawService.prototype.updateImageStateAfterVague = function(data) {
@@ -2617,6 +2642,19 @@ var DrawLayersService = function() {
2617
2642
  this.layerList[layerIndex] = layer;
2618
2643
  this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
2619
2644
  };
2645
+ DrawLayersService.prototype.removePainter = function(id) {
2646
+ var layerIndex = this.layerList.findIndex((function(layer) {
2647
+ return layer.painters.find((function(painter) {
2648
+ return painter.id === id;
2649
+ }));
2650
+ }));
2651
+ if (layerIndex === -1) return;
2652
+ this.layerList[layerIndex].painters = this.layerList[layerIndex].painters.filter((function(painter) {
2653
+ return painter.id !== id;
2654
+ }));
2655
+ var layer = this.layerList[layerIndex];
2656
+ this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
2657
+ };
2620
2658
  return DrawLayersService;
2621
2659
  }();
2622
2660
 
@@ -13,4 +13,5 @@ export default class DrawLayersService {
13
13
  getLayerById(layerId: ILayer['id']): ILayer;
14
14
  addToLayer(id: ILayer['id'], painter: IPainter): void;
15
15
  updateLayer(id: ILayer['id'], updateData?: ILayerUpdate): void;
16
+ removePainter(id: IPainter['id']): void;
16
17
  }
@@ -2,7 +2,7 @@ import AppConfig from "../config";
2
2
  import { IImageStateReduce } from "../store/image.state";
3
3
  import AppStoreRepository from "../store/storeRepository";
4
4
  import { ILayer } from "../types/draw-layers";
5
- import { IPainter, TDrawType } from "../types/draw-service";
5
+ import { IPainter, ISmoothFilterOptions, TDrawType } from "../types/draw-service";
6
6
  import type { IDrawImageArgs, IDrawImageProcessor, IFilterOptions, IImageLoggingDataVague, IImageOptions } from "../types/image";
7
7
  import { Project } from "../types/project";
8
8
  import { ITempCanvasOptions } from "../types/temp-canvas";
@@ -17,7 +17,8 @@ export declare class DrawAccumulator {
17
17
  painters: IPainter[];
18
18
  constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService, drawLayersService: DrawLayersService);
19
19
  add<DrawType extends TDrawType>(layerId: ILayer['id'], drawType: DrawType, options: DrawService['options'][DrawType], initialSize: ITempCanvasOptions): Promise<void>;
20
- remove(id: string): Promise<void>;
20
+ removePainter(id: string): Promise<void>;
21
+ smoothFilter(painterId: IPainter['id'], smoothFilterOptions: ISmoothFilterOptions): Promise<void>;
21
22
  private update;
22
23
  private get gradient();
23
24
  private clearCanvas;
@@ -49,7 +50,7 @@ export default class DrawService {
49
50
  reduceData: IImageStateReduce | null;
50
51
  message: string | null;
51
52
  }>;
52
- drawSmoothImage(useStore: boolean, options: IDrawImageArgs, filterOptions: IFilterOptions): void;
53
+ drawSmoothImage(useStore: boolean, options: IDrawImageArgs, filterOptions: IFilterOptions): Promise<IImageLoggingDataVague>;
53
54
  updateImageStateAfterVague(data: IImageLoggingDataVague): void;
54
55
  getFilterArgs(useStore: boolean, options: IDrawImageArgs): IImageOptions;
55
56
  }
@@ -1,7 +1,13 @@
1
1
  import DrawService from "../services/draw.service";
2
+ import { IDrawImageArgs, IFilterOptions } from "./image";
2
3
  export type TDrawType = keyof DrawService['options'];
3
4
  export interface IPainter {
4
5
  drawService: DrawService;
5
6
  drawType: TDrawType;
6
7
  id: string;
7
8
  }
9
+ export interface ISmoothFilterOptions {
10
+ useStore: boolean;
11
+ options: IDrawImageArgs;
12
+ filterOptions: IFilterOptions;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.3.16",
3
+ "version": "2.3.17",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",