canvas-editor-engine 2.3.36 → 2.3.38

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 (2) hide show
  1. package/dist/index.mjs +59 -47
  2. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import ExecutionDelay from "execution-delay";
2
+
1
3
  var extendStatics = function(d, b) {
2
4
  extendStatics = Object.setPrototypeOf || {
3
5
  __proto__: []
@@ -2562,49 +2564,52 @@ var Painter = function() {
2562
2564
  return Painter;
2563
2565
  }();
2564
2566
 
2565
- var DrawAccumulatorService = function() {
2566
- function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService) {
2567
- this.appConfig = appConfig;
2568
- this.appStoreRepository = appStoreRepository;
2569
- this.eventService = eventService;
2570
- this.drawLayersService = drawLayersService;
2571
- this.painters = new Proxy([], {
2572
- get: function(target, name) {
2573
- return target[name];
2574
- },
2575
- set: function(target, name, value) {
2576
- try {
2577
- if (typeof (value === null || value === void 0 ? void 0 : value.object) !== "undefined") {
2578
- target[name] = value.object;
2579
- value.update();
2580
- return true;
2567
+ function createDynamicPainterStore() {
2568
+ return new Proxy([], {
2569
+ get: function(target, name) {
2570
+ return target[name];
2571
+ },
2572
+ set: function(target, name, value) {
2573
+ try {
2574
+ if (typeof (value === null || value === void 0 ? void 0 : value.object) !== "undefined") {
2575
+ target[name] = value.object;
2576
+ value.update();
2577
+ return true;
2578
+ } else {
2579
+ if (name != "length") {
2580
+ console.warn("Proxy set error: object denied");
2581
+ return false;
2581
2582
  } else {
2582
- if (name != "length") {
2583
- console.warn("Proxy set error: object denied");
2584
- return false;
2585
- } else {
2586
- var MIN_LENGTH = -1;
2587
- var MAX_LENGTH = __spreadArray([], Object.keys(target), true);
2588
- if (value <= Math.max.apply(Math, __spreadArray([ MIN_LENGTH ], MAX_LENGTH, false)) + 1) {
2589
- target.length = value;
2590
- }
2583
+ var MIN_LENGTH = -1;
2584
+ var MAX_LENGTH = __spreadArray([], Object.keys(target), true);
2585
+ if (value <= Math.max.apply(Math, __spreadArray([ MIN_LENGTH ], MAX_LENGTH, false)) + 1) {
2586
+ target.length = value;
2591
2587
  }
2592
- return true;
2593
2588
  }
2594
- } catch (error) {
2595
- console.error("Proxy set error:", error);
2596
- return false;
2597
- }
2598
- },
2599
- deleteProperty: function(target, prop) {
2600
- if (prop in target) {
2601
- delete target[prop];
2602
- console.log("property removed: ".concat(prop));
2603
2589
  return true;
2604
2590
  }
2591
+ } catch (error) {
2592
+ console.error("Proxy set error:", error);
2605
2593
  return false;
2606
2594
  }
2607
- });
2595
+ },
2596
+ deleteProperty: function(target, prop) {
2597
+ if (prop in target) {
2598
+ delete target[prop];
2599
+ return true;
2600
+ }
2601
+ return false;
2602
+ }
2603
+ });
2604
+ }
2605
+
2606
+ var DrawAccumulatorService = function() {
2607
+ function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService) {
2608
+ this.appConfig = appConfig;
2609
+ this.appStoreRepository = appStoreRepository;
2610
+ this.eventService = eventService;
2611
+ this.drawLayersService = drawLayersService;
2612
+ this.painters = createDynamicPainterStore();
2608
2613
  }
2609
2614
  DrawAccumulatorService.prototype.add = function(layerId, drawType, options, initialSize) {
2610
2615
  return __awaiter(this, void 0, void 0, (function() {
@@ -2632,19 +2637,26 @@ var DrawAccumulatorService = function() {
2632
2637
  };
2633
2638
  DrawAccumulatorService.prototype.removePainter = function(painterId) {
2634
2639
  return __awaiter(this, void 0, void 0, (function() {
2635
- var painterIndex;
2640
+ var painter, filteredPainters;
2641
+ var _this = this;
2636
2642
  return __generator(this, (function(_a) {
2637
- console.log(this.painters);
2638
- painterIndex = this.painters.findIndex((function(painter) {
2643
+ painter = this.painters.find((function(painter) {
2639
2644
  return painter.id === painterId;
2640
2645
  }));
2641
- if (painterIndex != -1) {
2642
- delete this.painters[painterIndex];
2643
- this.drawLayersService.removePainter(painterId);
2644
- this.update();
2645
- } else {
2646
- console.warn("Painter not found");
2647
- }
2646
+ if (!painter) return [ 2, console.warn("Painter not found") ];
2647
+ filteredPainters = JSON.parse(JSON.stringify(this.painters.filter((function(painter) {
2648
+ return painter.id !== painterId;
2649
+ }))));
2650
+ if (!(filteredPainters === null || filteredPainters === void 0 ? void 0 : filteredPainters.length)) return [ 2, console.warn("Painter not found") ];
2651
+ this.painters = createDynamicPainterStore();
2652
+ filteredPainters.forEach((function(painter) {
2653
+ _this.painters.push({
2654
+ object: painter,
2655
+ update: _this.update.bind(_this)
2656
+ });
2657
+ }));
2658
+ this.drawLayersService.removePainter(painterId);
2659
+ this.update();
2648
2660
  return [ 2 ];
2649
2661
  }));
2650
2662
  }));
@@ -2693,7 +2705,7 @@ var DrawAccumulatorService = function() {
2693
2705
  };
2694
2706
  DrawAccumulatorService.prototype.update = function() {
2695
2707
  var _this = this;
2696
- setTimeout((function() {
2708
+ ExecutionDelay.add("[DrawAccumulatorService] update", (function() {
2697
2709
  _this.clearCanvas();
2698
2710
  _this.invokePaintersOnLayers();
2699
2711
  }), 1e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.3.36",
3
+ "version": "2.3.38",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -30,6 +30,7 @@
30
30
  "typescript": "^5.7.2"
31
31
  },
32
32
  "dependencies": {
33
+ "execution-delay": "^1.0.3",
33
34
  "rollup-plugin-multi-input": "^1.5.0",
34
35
  "tslib": "^2.8.1"
35
36
  }