@pooder/kit 3.5.0 → 4.1.0

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
@@ -753,13 +753,16 @@ function createFeatureItem(feature, center) {
753
753
  }
754
754
  return item;
755
755
  }
756
- function getDielineShape(options) {
756
+ function getPerimeterShape(options) {
757
757
  let mainShape = createBaseShape(options);
758
758
  const { features } = options;
759
759
  if (features && features.length > 0) {
760
+ const edgeFeatures = features.filter(
761
+ (f) => !f.placement || f.placement === "edge"
762
+ );
760
763
  const adds = [];
761
764
  const subtracts = [];
762
- features.forEach((f) => {
765
+ edgeFeatures.forEach((f) => {
763
766
  const pos = resolveFeaturePosition(f, options);
764
767
  const center = new paper2.Point(pos.x, pos.y);
765
768
  const item = createFeatureItem(f, center);
@@ -798,14 +801,42 @@ function getDielineShape(options) {
798
801
  }
799
802
  return mainShape;
800
803
  }
804
+ function applySurfaceFeatures(shape, features, options) {
805
+ const internalFeatures = features.filter((f) => f.placement === "internal");
806
+ if (internalFeatures.length === 0) return shape;
807
+ let result = shape;
808
+ for (const f of internalFeatures) {
809
+ const pos = resolveFeaturePosition(f, options);
810
+ const center = new paper2.Point(pos.x, pos.y);
811
+ const item = createFeatureItem(f, center);
812
+ try {
813
+ if (f.operation === "add") {
814
+ const temp = result.unite(item);
815
+ result.remove();
816
+ item.remove();
817
+ result = temp;
818
+ } else {
819
+ const temp = result.subtract(item);
820
+ result.remove();
821
+ item.remove();
822
+ result = temp;
823
+ }
824
+ } catch (e) {
825
+ console.error("Geometry: Failed to apply surface feature", e);
826
+ item.remove();
827
+ }
828
+ }
829
+ return result;
830
+ }
801
831
  function generateDielinePath(options) {
802
832
  const paperWidth = options.canvasWidth || options.width * 2 || 2e3;
803
833
  const paperHeight = options.canvasHeight || options.height * 2 || 2e3;
804
834
  ensurePaper(paperWidth, paperHeight);
805
835
  paper2.project.activeLayer.removeChildren();
806
- const mainShape = getDielineShape(options);
807
- const pathData = mainShape.pathData;
808
- mainShape.remove();
836
+ const perimeter = getPerimeterShape(options);
837
+ const finalShape = applySurfaceFeatures(perimeter, options.features, options);
838
+ const pathData = finalShape.pathData;
839
+ finalShape.remove();
809
840
  return pathData;
810
841
  }
811
842
  function generateMaskPath(options) {
@@ -816,7 +847,8 @@ function generateMaskPath(options) {
816
847
  point: [0, 0],
817
848
  size: [canvasWidth, canvasHeight]
818
849
  });
819
- const mainShape = getDielineShape(options);
850
+ const perimeter = getPerimeterShape(options);
851
+ const mainShape = applySurfaceFeatures(perimeter, options.features, options);
820
852
  const finalMask = maskRect.subtract(mainShape);
821
853
  maskRect.remove();
822
854
  mainShape.remove();
@@ -829,8 +861,10 @@ function generateBleedZonePath(originalOptions, offsetOptions, offset) {
829
861
  const paperHeight = originalOptions.canvasHeight || originalOptions.height * 2 || 2e3;
830
862
  ensurePaper(paperWidth, paperHeight);
831
863
  paper2.project.activeLayer.removeChildren();
832
- const shapeOriginal = getDielineShape(originalOptions);
833
- const shapeOffset = getDielineShape(offsetOptions);
864
+ const pOriginal = getPerimeterShape(originalOptions);
865
+ const shapeOriginal = applySurfaceFeatures(pOriginal, originalOptions.features, originalOptions);
866
+ const pOffset = getPerimeterShape(offsetOptions);
867
+ const shapeOffset = applySurfaceFeatures(pOffset, offsetOptions.features, offsetOptions);
834
868
  let bleedZone;
835
869
  if (offset > 0) {
836
870
  bleedZone = shapeOffset.subtract(shapeOriginal);
@@ -866,6 +900,105 @@ function getPathBounds(pathData) {
866
900
  };
867
901
  }
868
902
 
903
+ // src/constraints.ts
904
+ var ConstraintRegistry = class {
905
+ static register(type, handler) {
906
+ this.handlers.set(type, handler);
907
+ }
908
+ static apply(x, y, feature, context) {
909
+ if (!feature.constraints || !feature.constraints.type) {
910
+ return { x, y };
911
+ }
912
+ const handler = this.handlers.get(feature.constraints.type);
913
+ if (handler) {
914
+ return handler(x, y, feature, context);
915
+ }
916
+ return { x, y };
917
+ }
918
+ };
919
+ ConstraintRegistry.handlers = /* @__PURE__ */ new Map();
920
+ var edgeConstraint = (x, y, feature, context) => {
921
+ var _a;
922
+ const { dielineWidth, dielineHeight } = context;
923
+ const params = ((_a = feature.constraints) == null ? void 0 : _a.params) || {};
924
+ const allowedEdges = params.allowedEdges || [
925
+ "top",
926
+ "bottom",
927
+ "left",
928
+ "right"
929
+ ];
930
+ const confine = params.confine || false;
931
+ const offset = params.offset || 0;
932
+ const distances = [];
933
+ if (allowedEdges.includes("top"))
934
+ distances.push({ edge: "top", dist: y * dielineHeight });
935
+ if (allowedEdges.includes("bottom"))
936
+ distances.push({ edge: "bottom", dist: (1 - y) * dielineHeight });
937
+ if (allowedEdges.includes("left"))
938
+ distances.push({ edge: "left", dist: x * dielineWidth });
939
+ if (allowedEdges.includes("right"))
940
+ distances.push({ edge: "right", dist: (1 - x) * dielineWidth });
941
+ if (distances.length === 0) return { x, y };
942
+ distances.sort((a, b) => a.dist - b.dist);
943
+ const nearest = distances[0].edge;
944
+ let newX = x;
945
+ let newY = y;
946
+ const fw = feature.width || 0;
947
+ const fh = feature.height || 0;
948
+ switch (nearest) {
949
+ case "top":
950
+ newY = 0 + offset / dielineHeight;
951
+ if (confine) {
952
+ const minX = fw / 2 / dielineWidth;
953
+ const maxX = 1 - minX;
954
+ newX = Math.max(minX, Math.min(newX, maxX));
955
+ }
956
+ break;
957
+ case "bottom":
958
+ newY = 1 - offset / dielineHeight;
959
+ if (confine) {
960
+ const minX = fw / 2 / dielineWidth;
961
+ const maxX = 1 - minX;
962
+ newX = Math.max(minX, Math.min(newX, maxX));
963
+ }
964
+ break;
965
+ case "left":
966
+ newX = 0 + offset / dielineWidth;
967
+ if (confine) {
968
+ const minY = fh / 2 / dielineHeight;
969
+ const maxY = 1 - minY;
970
+ newY = Math.max(minY, Math.min(newY, maxY));
971
+ }
972
+ break;
973
+ case "right":
974
+ newX = 1 - offset / dielineWidth;
975
+ if (confine) {
976
+ const minY = fh / 2 / dielineHeight;
977
+ const maxY = 1 - minY;
978
+ newY = Math.max(minY, Math.min(newY, maxY));
979
+ }
980
+ break;
981
+ }
982
+ return { x: newX, y: newY };
983
+ };
984
+ var internalConstraint = (x, y, feature, context) => {
985
+ var _a;
986
+ const { dielineWidth, dielineHeight } = context;
987
+ const params = ((_a = feature.constraints) == null ? void 0 : _a.params) || {};
988
+ const margin = params.margin || 0;
989
+ const fw = feature.width || 0;
990
+ const fh = feature.height || 0;
991
+ const minX = (margin + fw / 2) / dielineWidth;
992
+ const maxX = 1 - (margin + fw / 2) / dielineWidth;
993
+ const minY = (margin + fh / 2) / dielineHeight;
994
+ const maxY = 1 - (margin + fh / 2) / dielineHeight;
995
+ const clampedX = minX > maxX ? 0.5 : Math.max(minX, Math.min(x, maxX));
996
+ const clampedY = minY > maxY ? 0.5 : Math.max(minY, Math.min(y, maxY));
997
+ return { x: clampedX, y: clampedY };
998
+ };
999
+ ConstraintRegistry.register("edge", edgeConstraint);
1000
+ ConstraintRegistry.register("internal", internalConstraint);
1001
+
869
1002
  // src/dieline.ts
870
1003
  var DielineTool = class {
871
1004
  constructor(options) {
@@ -1160,6 +1293,37 @@ var DielineTool = class {
1160
1293
  }
1161
1294
  ],
1162
1295
  [ContributionPointIds2.COMMANDS]: [
1296
+ {
1297
+ command: "updateFeaturePosition",
1298
+ title: "Update Feature Position",
1299
+ handler: (groupId, x, y) => {
1300
+ var _a;
1301
+ const configService = (_a = this.context) == null ? void 0 : _a.services.get(
1302
+ "ConfigurationService"
1303
+ );
1304
+ if (!configService) return;
1305
+ const features = configService.get("dieline.features") || [];
1306
+ const dielineWidth = configService.get("dieline.width") || 500;
1307
+ const dielineHeight = configService.get("dieline.height") || 500;
1308
+ let changed = false;
1309
+ const newFeatures = features.map((f) => {
1310
+ if (f.groupId === groupId) {
1311
+ const constrained = ConstraintRegistry.apply(x, y, f, {
1312
+ dielineWidth,
1313
+ dielineHeight
1314
+ });
1315
+ if (f.x !== constrained.x || f.y !== constrained.y) {
1316
+ changed = true;
1317
+ return { ...f, x: constrained.x, y: constrained.y };
1318
+ }
1319
+ }
1320
+ return f;
1321
+ });
1322
+ if (changed) {
1323
+ configService.update("dieline.features", newFeatures);
1324
+ }
1325
+ }
1326
+ },
1163
1327
  {
1164
1328
  command: "getGeometry",
1165
1329
  title: "Get Geometry",
@@ -1304,16 +1468,10 @@ var DielineTool = class {
1304
1468
  radius: (f.radius || 0) * featureScale
1305
1469
  };
1306
1470
  });
1307
- const originalFeatures = absoluteFeatures.filter(
1308
- (f) => !f.target || f.target === "original" || f.target === "both"
1309
- );
1310
- const offsetFeatures = absoluteFeatures.filter(
1311
- (f) => f.target === "offset" || f.target === "both"
1312
- );
1471
+ const cutFeatures = absoluteFeatures.filter((f) => !f.skipCut);
1313
1472
  const cutW = Math.max(0, visualWidth + visualOffset * 2);
1314
1473
  const cutH = Math.max(0, visualHeight + visualOffset * 2);
1315
1474
  const cutR = visualRadius === 0 ? 0 : Math.max(0, visualRadius + visualOffset);
1316
- const maskFeatures = visualOffset !== 0 ? offsetFeatures : originalFeatures;
1317
1475
  const maskPathData = generateMaskPath({
1318
1476
  canvasWidth: canvasW,
1319
1477
  canvasHeight: canvasH,
@@ -1323,7 +1481,7 @@ var DielineTool = class {
1323
1481
  radius: cutR,
1324
1482
  x: cx,
1325
1483
  y: cy,
1326
- features: maskFeatures,
1484
+ features: cutFeatures,
1327
1485
  pathData: this.state.pathData
1328
1486
  });
1329
1487
  const mask = new Path(maskPathData, {
@@ -1345,7 +1503,7 @@ var DielineTool = class {
1345
1503
  radius: cutR,
1346
1504
  x: cx,
1347
1505
  y: cy,
1348
- features: maskFeatures,
1506
+ features: cutFeatures,
1349
1507
  // Use same features as mask for consistency
1350
1508
  pathData: this.state.pathData,
1351
1509
  canvasWidth: canvasW,
@@ -1371,7 +1529,7 @@ var DielineTool = class {
1371
1529
  radius: visualRadius,
1372
1530
  x: cx,
1373
1531
  y: cy,
1374
- features: originalFeatures,
1532
+ features: cutFeatures,
1375
1533
  pathData: this.state.pathData,
1376
1534
  canvasWidth: canvasW,
1377
1535
  canvasHeight: canvasH
@@ -1383,7 +1541,7 @@ var DielineTool = class {
1383
1541
  radius: cutR,
1384
1542
  x: cx,
1385
1543
  y: cy,
1386
- features: offsetFeatures,
1544
+ features: cutFeatures,
1387
1545
  pathData: this.state.pathData,
1388
1546
  canvasWidth: canvasW,
1389
1547
  canvasHeight: canvasH
@@ -1412,7 +1570,7 @@ var DielineTool = class {
1412
1570
  radius: cutR,
1413
1571
  x: cx,
1414
1572
  y: cy,
1415
- features: offsetFeatures,
1573
+ features: cutFeatures,
1416
1574
  pathData: this.state.pathData,
1417
1575
  canvasWidth: canvasW,
1418
1576
  canvasHeight: canvasH
@@ -1436,7 +1594,7 @@ var DielineTool = class {
1436
1594
  radius: visualRadius,
1437
1595
  x: cx,
1438
1596
  y: cy,
1439
- features: originalFeatures,
1597
+ features: absoluteFeatures,
1440
1598
  pathData: this.state.pathData,
1441
1599
  canvasWidth: canvasW,
1442
1600
  canvasHeight: canvasH
@@ -1536,9 +1694,7 @@ var DielineTool = class {
1536
1694
  radius: (f.radius || 0) * featureScale
1537
1695
  };
1538
1696
  });
1539
- const originalFeatures = absoluteFeatures.filter(
1540
- (f) => !f.target || f.target === "original" || f.target === "both"
1541
- );
1697
+ const cutFeatures = absoluteFeatures.filter((f) => !f.skipCut);
1542
1698
  const generatedPathData = generateDielinePath({
1543
1699
  shape,
1544
1700
  width: visualWidth,
@@ -1546,7 +1702,7 @@ var DielineTool = class {
1546
1702
  radius: visualRadius,
1547
1703
  x: cx,
1548
1704
  y: cy,
1549
- features: originalFeatures,
1705
+ features: cutFeatures,
1550
1706
  pathData,
1551
1707
  canvasWidth: canvasW,
1552
1708
  canvasHeight: canvasH
@@ -1747,10 +1903,15 @@ var FeatureTool = class {
1747
1903
  };
1748
1904
  this.features = [];
1749
1905
  this.isUpdatingConfig = false;
1906
+ this.isToolActive = false;
1750
1907
  this.handleMoving = null;
1751
1908
  this.handleModified = null;
1752
1909
  this.handleDielineChange = null;
1753
1910
  this.currentGeometry = null;
1911
+ this.onToolActivated = (event) => {
1912
+ this.isToolActive = event.id === this.id;
1913
+ this.updateVisibility();
1914
+ };
1754
1915
  if (options) {
1755
1916
  Object.assign(this, options);
1756
1917
  }
@@ -1775,13 +1936,32 @@ var FeatureTool = class {
1775
1936
  }
1776
1937
  });
1777
1938
  }
1939
+ context.eventBus.on("tool:activated", this.onToolActivated);
1778
1940
  this.setup();
1779
1941
  }
1780
1942
  deactivate(context) {
1943
+ context.eventBus.off("tool:activated", this.onToolActivated);
1781
1944
  this.teardown();
1782
1945
  this.canvasService = void 0;
1783
1946
  this.context = void 0;
1784
1947
  }
1948
+ updateVisibility() {
1949
+ if (!this.canvasService) return;
1950
+ const canvas = this.canvasService.canvas;
1951
+ const markers = canvas.getObjects().filter((obj) => {
1952
+ var _a;
1953
+ return ((_a = obj.data) == null ? void 0 : _a.type) === "feature-marker";
1954
+ });
1955
+ markers.forEach((marker) => {
1956
+ marker.set({
1957
+ visible: this.isToolActive,
1958
+ // Or just selectable: false if we want them visible but locked
1959
+ selectable: this.isToolActive,
1960
+ evented: this.isToolActive
1961
+ });
1962
+ });
1963
+ canvas.requestRenderAll();
1964
+ }
1785
1965
  contribute() {
1786
1966
  return {
1787
1967
  [ContributionPointIds4.COMMANDS]: [
@@ -1834,7 +2014,7 @@ var FeatureTool = class {
1834
2014
  const newFeature = {
1835
2015
  id: Date.now().toString(),
1836
2016
  operation: type,
1837
- target: "original",
2017
+ placement: "edge",
1838
2018
  shape: "rect",
1839
2019
  x: 0.5,
1840
2020
  y: 0,
@@ -1868,6 +2048,7 @@ var FeatureTool = class {
1868
2048
  groupId,
1869
2049
  operation: "add",
1870
2050
  shape: "circle",
2051
+ placement: "edge",
1871
2052
  x: 0.5,
1872
2053
  y: 0,
1873
2054
  radius: lugRadius,
@@ -1879,6 +2060,7 @@ var FeatureTool = class {
1879
2060
  groupId,
1880
2061
  operation: "subtract",
1881
2062
  shape: "circle",
2063
+ placement: "edge",
1882
2064
  x: 0.5,
1883
2065
  y: 0,
1884
2066
  radius: holeRadius,
@@ -1895,14 +2077,6 @@ var FeatureTool = class {
1895
2077
  return true;
1896
2078
  }
1897
2079
  getGeometryForFeature(geometry, feature) {
1898
- if ((feature == null ? void 0 : feature.target) === "offset" && geometry.offset !== 0) {
1899
- return {
1900
- ...geometry,
1901
- width: geometry.width + geometry.offset * 2,
1902
- height: geometry.height + geometry.offset * 2,
1903
- radius: geometry.radius === 0 ? 0 : Math.max(0, geometry.radius + geometry.offset)
1904
- };
1905
- }
1906
2080
  return geometry;
1907
2081
  }
1908
2082
  setup() {
@@ -1959,7 +2133,7 @@ var FeatureTool = class {
1959
2133
  const markerStrokeWidth = (target.strokeWidth || 2) * (target.scaleX || 1);
1960
2134
  const minDim = Math.min(target.getScaledWidth(), target.getScaledHeight());
1961
2135
  const limit = Math.max(0, minDim / 2 - markerStrokeWidth);
1962
- const snapped = this.constrainPosition(p, geometry, limit);
2136
+ const snapped = this.constrainPosition(p, geometry, limit, feature);
1963
2137
  target.set({
1964
2138
  left: snapped.x,
1965
2139
  top: snapped.y
@@ -2043,7 +2217,34 @@ var FeatureTool = class {
2043
2217
  objects.forEach((obj) => canvas.remove(obj));
2044
2218
  this.canvasService.requestRenderAll();
2045
2219
  }
2046
- constrainPosition(p, geometry, limit) {
2220
+ constrainPosition(p, geometry, limit, feature) {
2221
+ if (feature && feature.constraints) {
2222
+ const minX = geometry.x - geometry.width / 2;
2223
+ const minY = geometry.y - geometry.height / 2;
2224
+ const nx = geometry.width > 0 ? (p.x - minX) / geometry.width : 0.5;
2225
+ const ny = geometry.height > 0 ? (p.y - minY) / geometry.height : 0.5;
2226
+ const scale2 = geometry.scale || 1;
2227
+ const dielineWidth = geometry.width / scale2;
2228
+ const dielineHeight = geometry.height / scale2;
2229
+ const constrained = ConstraintRegistry.apply(nx, ny, feature, {
2230
+ dielineWidth,
2231
+ dielineHeight
2232
+ });
2233
+ return {
2234
+ x: minX + constrained.x * geometry.width,
2235
+ y: minY + constrained.y * geometry.height
2236
+ };
2237
+ }
2238
+ if (feature && feature.placement === "internal") {
2239
+ const minX = geometry.x - geometry.width / 2;
2240
+ const maxX = geometry.x + geometry.width / 2;
2241
+ const minY = geometry.y - geometry.height / 2;
2242
+ const maxY = geometry.y + geometry.height / 2;
2243
+ return {
2244
+ x: Math.max(minX, Math.min(maxX, p.x)),
2245
+ y: Math.max(minY, Math.min(maxY, p.y))
2246
+ };
2247
+ }
2047
2248
  const nearest = getNearestPointOnDieline({ x: p.x, y: p.y }, {
2048
2249
  ...geometry,
2049
2250
  features: []
@@ -2168,7 +2369,9 @@ var FeatureTool = class {
2168
2369
  const pos = resolveFeaturePosition(feature, geometry2);
2169
2370
  const marker = createMarkerShape(feature, pos);
2170
2371
  marker.set({
2171
- selectable: true,
2372
+ visible: this.isToolActive,
2373
+ selectable: this.isToolActive,
2374
+ evented: this.isToolActive,
2172
2375
  hasControls: false,
2173
2376
  hasBorders: false,
2174
2377
  hoverCursor: "move",
@@ -2211,7 +2414,9 @@ var FeatureTool = class {
2211
2414
  return createMarkerShape(feature, pos);
2212
2415
  });
2213
2416
  const groupObj = new Group(shapes, {
2214
- selectable: true,
2417
+ visible: this.isToolActive,
2418
+ selectable: this.isToolActive,
2419
+ evented: this.isToolActive,
2215
2420
  hasControls: false,
2216
2421
  hasBorders: false,
2217
2422
  hoverCursor: "move",
@@ -2285,7 +2490,8 @@ var FeatureTool = class {
2285
2490
  const snapped = this.constrainPosition(
2286
2491
  new Point(marker.left, marker.top),
2287
2492
  geometry,
2288
- limit
2493
+ limit,
2494
+ feature
2289
2495
  );
2290
2496
  marker.set({ left: snapped.x, top: snapped.y });
2291
2497
  marker.setCoords();
@@ -2309,6 +2515,11 @@ var ImageTool = class {
2309
2515
  this.objectMap = /* @__PURE__ */ new Map();
2310
2516
  this.loadResolvers = /* @__PURE__ */ new Map();
2311
2517
  this.isUpdatingConfig = false;
2518
+ this.isToolActive = false;
2519
+ this.onToolActivated = (event) => {
2520
+ this.isToolActive = event.id === this.id;
2521
+ this.updateInteractivity();
2522
+ };
2312
2523
  }
2313
2524
  activate(context) {
2314
2525
  this.context = context;
@@ -2317,6 +2528,7 @@ var ImageTool = class {
2317
2528
  console.warn("CanvasService not found for ImageTool");
2318
2529
  return;
2319
2530
  }
2531
+ context.eventBus.on("tool:activated", this.onToolActivated);
2320
2532
  const configService = context.services.get(
2321
2533
  "ConfigurationService"
2322
2534
  );
@@ -2334,6 +2546,7 @@ var ImageTool = class {
2334
2546
  this.updateImages();
2335
2547
  }
2336
2548
  deactivate(context) {
2549
+ context.eventBus.off("tool:activated", this.onToolActivated);
2337
2550
  if (this.canvasService) {
2338
2551
  const layer = this.canvasService.getLayer("user");
2339
2552
  if (layer) {
@@ -2347,6 +2560,18 @@ var ImageTool = class {
2347
2560
  this.context = void 0;
2348
2561
  }
2349
2562
  }
2563
+ updateInteractivity() {
2564
+ var _a;
2565
+ this.objectMap.forEach((obj) => {
2566
+ obj.set({
2567
+ selectable: this.isToolActive,
2568
+ evented: this.isToolActive,
2569
+ hasControls: this.isToolActive,
2570
+ hasBorders: this.isToolActive
2571
+ });
2572
+ });
2573
+ (_a = this.canvasService) == null ? void 0 : _a.requestRenderAll();
2574
+ }
2350
2575
  contribute() {
2351
2576
  return {
2352
2577
  [ContributionPointIds5.CONFIGURATIONS]: [
@@ -2534,6 +2759,14 @@ var ImageTool = class {
2534
2759
  const layout = this.getLayoutInfo();
2535
2760
  this.items.forEach((item, index) => {
2536
2761
  let obj = this.objectMap.get(item.id);
2762
+ if (obj && obj.getSrc) {
2763
+ const currentSrc = obj.getSrc();
2764
+ if (currentSrc !== item.url) {
2765
+ layer.remove(obj);
2766
+ this.objectMap.delete(item.id);
2767
+ obj = void 0;
2768
+ }
2769
+ }
2537
2770
  if (!obj) {
2538
2771
  this.loadImage(item, layer, layout);
2539
2772
  } else {
@@ -2590,7 +2823,11 @@ var ImageTool = class {
2590
2823
  originY: "center",
2591
2824
  data: { id: item.id },
2592
2825
  uniformScaling: true,
2593
- lockScalingFlip: true
2826
+ lockScalingFlip: true,
2827
+ selectable: this.isToolActive,
2828
+ evented: this.isToolActive,
2829
+ hasControls: this.isToolActive,
2830
+ hasBorders: this.isToolActive
2594
2831
  });
2595
2832
  image.setControlsVisibility({
2596
2833
  mt: false,
@@ -3447,6 +3684,24 @@ var CanvasService = class {
3447
3684
  ...options
3448
3685
  });
3449
3686
  }
3687
+ if (options == null ? void 0 : options.eventBus) {
3688
+ this.setEventBus(options.eventBus);
3689
+ }
3690
+ }
3691
+ setEventBus(eventBus) {
3692
+ this.eventBus = eventBus;
3693
+ this.setupEvents();
3694
+ }
3695
+ setupEvents() {
3696
+ if (!this.eventBus) return;
3697
+ const bus = this.eventBus;
3698
+ const forward = (name) => (e) => bus.emit(name, e);
3699
+ this.canvas.on("selection:created", forward("selection:created"));
3700
+ this.canvas.on("selection:updated", forward("selection:updated"));
3701
+ this.canvas.on("selection:cleared", forward("selection:cleared"));
3702
+ this.canvas.on("object:modified", forward("object:modified"));
3703
+ this.canvas.on("object:added", forward("object:added"));
3704
+ this.canvas.on("object:removed", forward("object:removed"));
3450
3705
  }
3451
3706
  dispose() {
3452
3707
  this.canvas.dispose();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pooder/kit",
3
- "version": "3.5.0",
3
+ "version": "4.1.0",
4
4
  "description": "Standard plugins for Pooder editor",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "paper": "^0.12.18",
21
21
  "fabric": "^7.0.0",
22
- "@pooder/core": "1.2.0"
22
+ "@pooder/core": "2.0.0"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts --format cjs,esm --dts",