canvas-editor-engine 2.3.14 → 2.3.16

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
@@ -2181,7 +2181,7 @@ var DrawAccumulator = function() {
2181
2181
  }
2182
2182
  DrawAccumulator.prototype.add = function(layerId, drawType, options, initialSize) {
2183
2183
  return __awaiter(this, void 0, void 0, (function() {
2184
- var id, painter, inStore;
2184
+ var id, painter;
2185
2185
  return __generator(this, (function(_a) {
2186
2186
  id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
2187
2187
  painter = {
@@ -2196,8 +2196,7 @@ var DrawAccumulator = function() {
2196
2196
  update: this.update.bind(this)
2197
2197
  });
2198
2198
  this.drawLayersService.addToLayer(layerId, painter);
2199
- inStore = true;
2200
- this.invokePainter(drawType, painter.drawService, inStore);
2199
+ this.invokePainter(drawType, painter.drawService);
2201
2200
  return [ 2 ];
2202
2201
  }));
2203
2202
  }));
@@ -2247,11 +2246,11 @@ var DrawAccumulator = function() {
2247
2246
  DrawAccumulator.prototype.clearCanvas = function() {
2248
2247
  var ctx = this.appConfig.canvas.getContext("2d");
2249
2248
  ctx.clearRect(0, 0, this.appConfig.CANVAS_SIZE.width, this.appConfig.CANVAS_SIZE.height);
2249
+ ctx.save();
2250
2250
  };
2251
2251
  DrawAccumulator.prototype.invokePaintersOnLayers = function() {
2252
2252
  var _this = this;
2253
2253
  var stash = [];
2254
- var ctx = this.appConfig.canvas.getContext("2d");
2255
2254
  this.gradient.forEach((function(order) {
2256
2255
  _this.painters.forEach((function(painter) {
2257
2256
  var layer = _this.drawLayersService.layerList.find((function(layer) {
@@ -2259,43 +2258,31 @@ var DrawAccumulator = function() {
2259
2258
  }));
2260
2259
  if (!layer) return console.warn("[invoke] Layer not found");
2261
2260
  if (!stash.includes(painter) && layer.order === order) {
2262
- _this.invokePainterWithTempCtx(ctx, painter.drawType, painter.drawService);
2261
+ _this.invokePainterWithTempCtx(painter.drawType, painter.drawService);
2263
2262
  stash.push(painter);
2264
2263
  }
2265
2264
  }));
2266
2265
  }));
2267
2266
  };
2268
- DrawAccumulator.prototype.invokePainter = function(drawType_1, painter_1) {
2269
- return __awaiter(this, arguments, void 0, (function(drawType, painter, inStore) {
2270
- var _a, reduceData, message, isAddToStore, _b, reduceData, message, isAddToStore;
2271
- if (inStore === void 0) {
2272
- inStore = false;
2273
- }
2274
- return __generator(this, (function(_c) {
2275
- switch (_c.label) {
2267
+ DrawAccumulator.prototype.invokePainter = function(drawType, painter) {
2268
+ return __awaiter(this, void 0, void 0, (function() {
2269
+ return __generator(this, (function(_a) {
2270
+ switch (_a.label) {
2276
2271
  case 0:
2277
2272
  if (!(drawType === "image")) return [ 3, 2 ];
2278
- return [ 4, painter.drawImage(inStore) ];
2273
+ return [ 4, painter.drawImage() ];
2279
2274
 
2280
2275
  case 1:
2281
- _a = _c.sent(), reduceData = _a.reduceData, message = _a.message;
2282
- isAddToStore = !!reduceData && !!message && inStore;
2283
- if (isAddToStore) {
2284
- this.appStoreRepository.store.imageState.reduce(reduceData, message);
2285
- }
2276
+ _a.sent();
2286
2277
  return [ 3, 4 ];
2287
2278
 
2288
2279
  case 2:
2289
2280
  if (!(drawType === "project")) return [ 3, 4 ];
2290
- return [ 4, painter.drawProject(inStore) ];
2281
+ return [ 4, painter.drawProject() ];
2291
2282
 
2292
2283
  case 3:
2293
- _b = _c.sent(), reduceData = _b.reduceData, message = _b.message;
2294
- isAddToStore = !!reduceData && !!message && inStore;
2295
- if (isAddToStore) {
2296
- this.appStoreRepository.store.imageState.reduce(reduceData, message);
2297
- }
2298
- _c.label = 4;
2284
+ _a.sent();
2285
+ _a.label = 4;
2299
2286
 
2300
2287
  case 4:
2301
2288
  return [ 2 ];
@@ -2303,17 +2290,20 @@ var DrawAccumulator = function() {
2303
2290
  }));
2304
2291
  }));
2305
2292
  };
2306
- DrawAccumulator.prototype.invokePainterWithTempCtx = function(ctx, drawType, painter) {
2293
+ DrawAccumulator.prototype.invokePainterWithTempCtx = function(drawType, painter) {
2307
2294
  return __awaiter(this, void 0, void 0, (function() {
2308
- var imageData, x, y;
2295
+ var imageData, ctx, x, y;
2309
2296
  return __generator(this, (function(_a) {
2310
2297
  imageData = painter.tempCanvas.getImageData();
2298
+ ctx = this.appConfig.canvas.getContext("2d");
2311
2299
  if (drawType === "image") {
2312
2300
  x = painter.options.image.drawImageArgs.position.x;
2313
2301
  y = painter.options.image.drawImageArgs.position.y;
2314
2302
  ctx.putImageData(imageData, x, y);
2303
+ ctx.save();
2315
2304
  } else if (drawType === "project") {
2316
2305
  ctx.putImageData(imageData, 0, 0);
2306
+ ctx.save();
2317
2307
  }
2318
2308
  return [ 2 ];
2319
2309
  }));
@@ -2338,12 +2328,9 @@ var DrawService = function() {
2338
2328
  this.options[drawType] = options;
2339
2329
  };
2340
2330
  DrawService.prototype.drawImage = function() {
2341
- return __awaiter(this, arguments, void 0, (function(isReturnReduceData) {
2331
+ return __awaiter(this, void 0, void 0, (function() {
2342
2332
  var _a, src, drawImageArgs, ctx;
2343
2333
  var _this = this;
2344
- if (isReturnReduceData === void 0) {
2345
- isReturnReduceData = false;
2346
- }
2347
2334
  return __generator(this, (function(_b) {
2348
2335
  switch (_b.label) {
2349
2336
  case 0:
@@ -2355,7 +2342,6 @@ var DrawService = function() {
2355
2342
  reduceData: null,
2356
2343
  message: null
2357
2344
  };
2358
- if (!isReturnReduceData) return responseData;
2359
2345
  var zeroPosition = {
2360
2346
  x: 0,
2361
2347
  y: 0
@@ -2368,6 +2354,7 @@ var DrawService = function() {
2368
2354
  size: _this.appConfig.CANVAS_SIZE
2369
2355
  };
2370
2356
  responseData.message = "Image loaded";
2357
+ _this.appStoreRepository.store.imageState.reduce(responseData.reduceData, responseData.message);
2371
2358
  return responseData;
2372
2359
  })) ];
2373
2360
 
@@ -2378,12 +2365,9 @@ var DrawService = function() {
2378
2365
  }));
2379
2366
  };
2380
2367
  DrawService.prototype.drawProject = function() {
2381
- return __awaiter(this, arguments, void 0, (function(isReturnReduceData) {
2368
+ return __awaiter(this, void 0, void 0, (function() {
2382
2369
  var project, ctx, imageData, position, size;
2383
2370
  var _this = this;
2384
- if (isReturnReduceData === void 0) {
2385
- isReturnReduceData = false;
2386
- }
2387
2371
  return __generator(this, (function(_a) {
2388
2372
  project = this.options.project;
2389
2373
  ctx = this.tempCanvas.ctx;
@@ -2399,13 +2383,13 @@ var DrawService = function() {
2399
2383
  reduceData: null,
2400
2384
  message: null
2401
2385
  };
2402
- if (!isReturnReduceData) return responseData;
2403
2386
  responseData.reduceData = {
2404
2387
  tempImageData: imageData,
2405
2388
  position,
2406
2389
  size
2407
2390
  };
2408
2391
  responseData.message = "Project loaded";
2392
+ _this.appStoreRepository.store.imageState.reduce(responseData.reduceData, responseData.message);
2409
2393
  return responseData;
2410
2394
  })) ];
2411
2395
  }));
@@ -41,11 +41,11 @@ export default class DrawService {
41
41
  tempCanvas: TempCanvas;
42
42
  constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService);
43
43
  bindOptions<DrawType extends TDrawType>(drawType: DrawType, options: DrawService['options'][DrawType]): void;
44
- drawImage(isReturnReduceData?: boolean): Promise<{
44
+ drawImage(): Promise<{
45
45
  reduceData: IImageStateReduce | null;
46
46
  message: string | null;
47
47
  }>;
48
- drawProject(isReturnReduceData?: boolean): Promise<{
48
+ drawProject(): Promise<{
49
49
  reduceData: IImageStateReduce | null;
50
50
  message: string | null;
51
51
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.3.14",
3
+ "version": "2.3.16",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",