@pooder/kit 5.0.1 → 5.0.3

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.js CHANGED
@@ -3005,6 +3005,8 @@ var FeatureTool = class {
3005
3005
  this.workingFeatures = [];
3006
3006
  this.isUpdatingConfig = false;
3007
3007
  this.isToolActive = false;
3008
+ this.isFeatureSessionActive = false;
3009
+ this.sessionOriginalFeatures = null;
3008
3010
  this.hasWorkingChanges = false;
3009
3011
  this.handleMoving = null;
3010
3012
  this.handleModified = null;
@@ -3012,6 +3014,9 @@ var FeatureTool = class {
3012
3014
  this.currentGeometry = null;
3013
3015
  this.onToolActivated = (event) => {
3014
3016
  this.isToolActive = event.id === this.id;
3017
+ if (!this.isToolActive) {
3018
+ this.restoreSessionFeaturesToConfig();
3019
+ }
3015
3020
  this.updateVisibility();
3016
3021
  };
3017
3022
  if (options) {
@@ -3035,6 +3040,7 @@ var FeatureTool = class {
3035
3040
  configService.onAnyChange((e) => {
3036
3041
  if (this.isUpdatingConfig) return;
3037
3042
  if (e.key === "dieline.features") {
3043
+ if (this.isFeatureSessionActive) return;
3038
3044
  const next = e.value || [];
3039
3045
  this.workingFeatures = this.cloneFeatures(next);
3040
3046
  this.hasWorkingChanges = false;
@@ -3054,6 +3060,7 @@ var FeatureTool = class {
3054
3060
  deactivate(context) {
3055
3061
  var _a;
3056
3062
  context.eventBus.off("tool:activated", this.onToolActivated);
3063
+ this.restoreSessionFeaturesToConfig();
3057
3064
  (_a = this.dirtyTrackerDisposable) == null ? void 0 : _a.dispose();
3058
3065
  this.dirtyTrackerDisposable = void 0;
3059
3066
  this.teardown();
@@ -3085,9 +3092,9 @@ var FeatureTool = class {
3085
3092
  name: "Feature",
3086
3093
  interaction: "session",
3087
3094
  commands: {
3088
- begin: "resetWorkingFeatures",
3095
+ begin: "beginFeatureSession",
3089
3096
  commit: "completeFeatures",
3090
- rollback: "resetWorkingFeatures"
3097
+ rollback: "rollbackFeatureSession"
3091
3098
  },
3092
3099
  session: {
3093
3100
  autoBegin: false,
@@ -3096,6 +3103,25 @@ var FeatureTool = class {
3096
3103
  }
3097
3104
  ],
3098
3105
  [import_core4.ContributionPointIds.COMMANDS]: [
3106
+ {
3107
+ command: "beginFeatureSession",
3108
+ title: "Begin Feature Session",
3109
+ handler: async () => {
3110
+ if (this.isFeatureSessionActive) {
3111
+ return { ok: true };
3112
+ }
3113
+ const original = this.getCommittedFeatures();
3114
+ this.sessionOriginalFeatures = this.cloneFeatures(original);
3115
+ this.isFeatureSessionActive = true;
3116
+ await this.refreshGeometry();
3117
+ this.setWorkingFeatures(this.cloneFeatures(original));
3118
+ this.hasWorkingChanges = false;
3119
+ this.redraw();
3120
+ this.emitWorkingChange();
3121
+ this.updateCommittedFeatures([]);
3122
+ return { ok: true };
3123
+ }
3124
+ },
3099
3125
  {
3100
3126
  command: "addFeature",
3101
3127
  title: "Add Edge Feature",
@@ -3148,19 +3174,27 @@ var FeatureTool = class {
3148
3174
  }
3149
3175
  },
3150
3176
  {
3151
- command: "resetWorkingFeatures",
3152
- title: "Reset Working Features",
3177
+ command: "rollbackFeatureSession",
3178
+ title: "Rollback Feature Session",
3153
3179
  handler: async () => {
3154
- var _a;
3155
- const configService = (_a = this.context) == null ? void 0 : _a.services.get(
3156
- "ConfigurationService"
3180
+ const original = this.cloneFeatures(
3181
+ this.sessionOriginalFeatures || this.getCommittedFeatures()
3157
3182
  );
3158
- const next = (configService == null ? void 0 : configService.get("dieline.features", [])) || [];
3159
3183
  await this.refreshGeometry();
3160
- this.setWorkingFeatures(this.cloneFeatures(next));
3184
+ this.setWorkingFeatures(original);
3161
3185
  this.hasWorkingChanges = false;
3162
3186
  this.redraw();
3163
3187
  this.emitWorkingChange();
3188
+ this.updateCommittedFeatures(original);
3189
+ this.clearFeatureSessionState();
3190
+ return { ok: true };
3191
+ }
3192
+ },
3193
+ {
3194
+ command: "resetWorkingFeatures",
3195
+ title: "Reset Working Features",
3196
+ handler: async () => {
3197
+ await this.resetWorkingFeaturesFromSource();
3164
3198
  return { ok: true };
3165
3199
  }
3166
3200
  },
@@ -3184,6 +3218,37 @@ var FeatureTool = class {
3184
3218
  cloneFeatures(features) {
3185
3219
  return JSON.parse(JSON.stringify(features || []));
3186
3220
  }
3221
+ getConfigService() {
3222
+ var _a;
3223
+ return (_a = this.context) == null ? void 0 : _a.services.get("ConfigurationService");
3224
+ }
3225
+ getCommittedFeatures() {
3226
+ const configService = this.getConfigService();
3227
+ const committed = (configService == null ? void 0 : configService.get("dieline.features", [])) || [];
3228
+ return this.cloneFeatures(committed);
3229
+ }
3230
+ updateCommittedFeatures(next) {
3231
+ const configService = this.getConfigService();
3232
+ if (!configService) return;
3233
+ this.isUpdatingConfig = true;
3234
+ try {
3235
+ configService.update("dieline.features", next);
3236
+ } finally {
3237
+ this.isUpdatingConfig = false;
3238
+ }
3239
+ }
3240
+ clearFeatureSessionState() {
3241
+ this.isFeatureSessionActive = false;
3242
+ this.sessionOriginalFeatures = null;
3243
+ }
3244
+ restoreSessionFeaturesToConfig() {
3245
+ if (!this.isFeatureSessionActive) return;
3246
+ const original = this.cloneFeatures(
3247
+ this.sessionOriginalFeatures || this.getCommittedFeatures()
3248
+ );
3249
+ this.updateCommittedFeatures(original);
3250
+ this.clearFeatureSessionState();
3251
+ }
3187
3252
  emitWorkingChange() {
3188
3253
  var _a;
3189
3254
  (_a = this.context) == null ? void 0 : _a.eventBus.emit("feature:working:change", {
@@ -3202,6 +3267,16 @@ var FeatureTool = class {
3202
3267
  } catch (e) {
3203
3268
  }
3204
3269
  }
3270
+ async resetWorkingFeaturesFromSource() {
3271
+ const next = this.cloneFeatures(
3272
+ this.isFeatureSessionActive && this.sessionOriginalFeatures ? this.sessionOriginalFeatures : this.getCommittedFeatures()
3273
+ );
3274
+ await this.refreshGeometry();
3275
+ this.setWorkingFeatures(next);
3276
+ this.hasWorkingChanges = false;
3277
+ this.redraw();
3278
+ this.emitWorkingChange();
3279
+ }
3205
3280
  setWorkingFeatures(next) {
3206
3281
  this.workingFeatures = next;
3207
3282
  }
@@ -3258,12 +3333,7 @@ var FeatureTool = class {
3258
3333
  this.workingFeatures,
3259
3334
  { dielineWidth, dielineHeight },
3260
3335
  (next) => {
3261
- this.isUpdatingConfig = true;
3262
- try {
3263
- configService.update("dieline.features", next);
3264
- } finally {
3265
- this.isUpdatingConfig = false;
3266
- }
3336
+ this.updateCommittedFeatures(next);
3267
3337
  this.workingFeatures = this.cloneFeatures(next);
3268
3338
  this.emitWorkingChange();
3269
3339
  }
@@ -3275,6 +3345,7 @@ var FeatureTool = class {
3275
3345
  };
3276
3346
  }
3277
3347
  this.hasWorkingChanges = false;
3348
+ this.clearFeatureSessionState();
3278
3349
  this.redraw();
3279
3350
  return { ok: true };
3280
3351
  }
@@ -3847,10 +3918,7 @@ var ImageTool = class {
3847
3918
  context.eventBus.on("selection:created", this.onSelectionChanged);
3848
3919
  context.eventBus.on("selection:updated", this.onSelectionChanged);
3849
3920
  context.eventBus.on("selection:cleared", this.onSelectionCleared);
3850
- context.eventBus.on(
3851
- "scene:layout:change",
3852
- this.onSceneLayoutChanged
3853
- );
3921
+ context.eventBus.on("scene:layout:change", this.onSceneLayoutChanged);
3854
3922
  const configService = context.services.get(
3855
3923
  "ConfigurationService"
3856
3924
  );
@@ -3890,10 +3958,7 @@ var ImageTool = class {
3890
3958
  context.eventBus.off("selection:created", this.onSelectionChanged);
3891
3959
  context.eventBus.off("selection:updated", this.onSelectionChanged);
3892
3960
  context.eventBus.off("selection:cleared", this.onSelectionCleared);
3893
- context.eventBus.off(
3894
- "scene:layout:change",
3895
- this.onSceneLayoutChanged
3896
- );
3961
+ context.eventBus.off("scene:layout:change", this.onSceneLayoutChanged);
3897
3962
  (_a = this.dirtyTrackerDisposable) == null ? void 0 : _a.dispose();
3898
3963
  this.dirtyTrackerDisposable = void 0;
3899
3964
  this.clearRenderedImages();
@@ -4002,7 +4067,7 @@ var ImageTool = class {
4002
4067
  id: "image.frame.outerBackground",
4003
4068
  type: "color",
4004
4069
  label: "Image Frame Outer Background",
4005
- default: "rgba(0,0,0,0.18)"
4070
+ default: "#f5f5f5"
4006
4071
  }
4007
4072
  ],
4008
4073
  [import_core5.ContributionPointIds.COMMANDS]: [
@@ -4045,6 +4110,7 @@ var ImageTool = class {
4045
4110
  this.workingItems = this.cloneItems(this.items);
4046
4111
  this.hasWorkingChanges = false;
4047
4112
  this.updateImages();
4113
+ this.emitWorkingChange();
4048
4114
  }
4049
4115
  },
4050
4116
  {
@@ -4159,6 +4225,13 @@ var ImageTool = class {
4159
4225
  cloneItems(items) {
4160
4226
  return this.normalizeItems((items || []).map((i) => ({ ...i })));
4161
4227
  }
4228
+ emitWorkingChange(changedId = null) {
4229
+ var _a;
4230
+ (_a = this.context) == null ? void 0 : _a.eventBus.emit("image:working:change", {
4231
+ changedId,
4232
+ items: this.cloneItems(this.workingItems)
4233
+ });
4234
+ }
4162
4235
  generateId() {
4163
4236
  return Math.random().toString(36).substring(2, 9);
4164
4237
  }
@@ -4227,6 +4300,7 @@ var ImageTool = class {
4227
4300
  if (this.workingItems.some((existing) => existing.id === item.id)) return;
4228
4301
  this.workingItems = this.cloneItems([...this.workingItems, item]);
4229
4302
  this.updateImages();
4303
+ this.emitWorkingChange(item.id);
4230
4304
  }
4231
4305
  async updateImage(id, updates, options = {}) {
4232
4306
  this.syncToolActiveFromWorkbench();
@@ -4410,10 +4484,7 @@ var ImageTool = class {
4410
4484
  "image.frame.innerBackground",
4411
4485
  "rgba(0,0,0,0)"
4412
4486
  ) || "rgba(0,0,0,0)",
4413
- outerBackground: this.getConfig(
4414
- "image.frame.outerBackground",
4415
- "rgba(0,0,0,0.18)"
4416
- ) || "rgba(0,0,0,0.18)"
4487
+ outerBackground: "#f5f5f5"
4417
4488
  };
4418
4489
  }
4419
4490
  resolveRenderImageState(item) {
@@ -4557,10 +4628,21 @@ var ImageTool = class {
4557
4628
  const canvasW = this.canvasService.canvas.width || 0;
4558
4629
  const canvasH = this.canvasService.canvas.height || 0;
4559
4630
  const visual = this.getFrameVisualConfig();
4560
- const topH = Math.max(0, frame.top);
4561
- const bottomH = Math.max(0, canvasH - (frame.top + frame.height));
4562
- const leftW = Math.max(0, frame.left);
4563
- const rightW = Math.max(0, canvasW - (frame.left + frame.width));
4631
+ const frameLeft = Math.max(0, Math.min(canvasW, frame.left));
4632
+ const frameTop = Math.max(0, Math.min(canvasH, frame.top));
4633
+ const frameRight = Math.max(
4634
+ frameLeft,
4635
+ Math.min(canvasW, frame.left + frame.width)
4636
+ );
4637
+ const frameBottom = Math.max(
4638
+ frameTop,
4639
+ Math.min(canvasH, frame.top + frame.height)
4640
+ );
4641
+ const visibleFrameH = Math.max(0, frameBottom - frameTop);
4642
+ const topH = frameTop;
4643
+ const bottomH = Math.max(0, canvasH - frameBottom);
4644
+ const leftW = frameLeft;
4645
+ const rightW = Math.max(0, canvasW - frameRight);
4564
4646
  const mask = [
4565
4647
  {
4566
4648
  id: "image.cropMask.top",
@@ -4584,7 +4666,7 @@ var ImageTool = class {
4584
4666
  data: { id: "image.cropMask.bottom", zIndex: 2 },
4585
4667
  props: {
4586
4668
  left: canvasW / 2,
4587
- top: frame.top + frame.height + bottomH / 2,
4669
+ top: frameBottom + bottomH / 2,
4588
4670
  width: canvasW,
4589
4671
  height: bottomH,
4590
4672
  originX: "center",
@@ -4600,9 +4682,9 @@ var ImageTool = class {
4600
4682
  data: { id: "image.cropMask.left", zIndex: 3 },
4601
4683
  props: {
4602
4684
  left: leftW / 2,
4603
- top: frame.top + frame.height / 2,
4685
+ top: frameTop + visibleFrameH / 2,
4604
4686
  width: leftW,
4605
- height: frame.height,
4687
+ height: visibleFrameH,
4606
4688
  originX: "center",
4607
4689
  originY: "center",
4608
4690
  fill: visual.outerBackground,
@@ -4615,10 +4697,10 @@ var ImageTool = class {
4615
4697
  type: "rect",
4616
4698
  data: { id: "image.cropMask.right", zIndex: 4 },
4617
4699
  props: {
4618
- left: frame.left + frame.width + rightW / 2,
4619
- top: frame.top + frame.height / 2,
4700
+ left: frameRight + rightW / 2,
4701
+ top: frameTop + visibleFrameH / 2,
4620
4702
  width: rightW,
4621
- height: frame.height,
4703
+ height: visibleFrameH,
4622
4704
  originX: "center",
4623
4705
  originY: "center",
4624
4706
  fill: visual.outerBackground,
@@ -4708,6 +4790,7 @@ var ImageTool = class {
4708
4790
  if (this.isToolActive) {
4709
4791
  this.updateImages();
4710
4792
  }
4793
+ this.emitWorkingChange(id);
4711
4794
  }
4712
4795
  async updateImageInConfig(id, updates) {
4713
4796
  var _a, _b, _c, _d;
@@ -4788,6 +4871,7 @@ var ImageTool = class {
4788
4871
  this.isImageSelectionActive = true;
4789
4872
  this.focusedImageId = id;
4790
4873
  this.updateImages();
4874
+ this.emitWorkingChange(id);
4791
4875
  }
4792
4876
  focusImageSelection(id) {
4793
4877
  if (!this.canvasService) return;
@@ -4880,6 +4964,7 @@ var ImageTool = class {
4880
4964
  this.hasWorkingChanges = false;
4881
4965
  this.workingItems = this.cloneItems(next);
4882
4966
  this.updateConfig(next);
4967
+ this.emitWorkingChange(focusId);
4883
4968
  if (focusId) {
4884
4969
  this.focusedImageId = focusId;
4885
4970
  this.isImageSelectionActive = true;
package/dist/index.mjs CHANGED
@@ -2954,6 +2954,8 @@ var FeatureTool = class {
2954
2954
  this.workingFeatures = [];
2955
2955
  this.isUpdatingConfig = false;
2956
2956
  this.isToolActive = false;
2957
+ this.isFeatureSessionActive = false;
2958
+ this.sessionOriginalFeatures = null;
2957
2959
  this.hasWorkingChanges = false;
2958
2960
  this.handleMoving = null;
2959
2961
  this.handleModified = null;
@@ -2961,6 +2963,9 @@ var FeatureTool = class {
2961
2963
  this.currentGeometry = null;
2962
2964
  this.onToolActivated = (event) => {
2963
2965
  this.isToolActive = event.id === this.id;
2966
+ if (!this.isToolActive) {
2967
+ this.restoreSessionFeaturesToConfig();
2968
+ }
2964
2969
  this.updateVisibility();
2965
2970
  };
2966
2971
  if (options) {
@@ -2984,6 +2989,7 @@ var FeatureTool = class {
2984
2989
  configService.onAnyChange((e) => {
2985
2990
  if (this.isUpdatingConfig) return;
2986
2991
  if (e.key === "dieline.features") {
2992
+ if (this.isFeatureSessionActive) return;
2987
2993
  const next = e.value || [];
2988
2994
  this.workingFeatures = this.cloneFeatures(next);
2989
2995
  this.hasWorkingChanges = false;
@@ -3003,6 +3009,7 @@ var FeatureTool = class {
3003
3009
  deactivate(context) {
3004
3010
  var _a;
3005
3011
  context.eventBus.off("tool:activated", this.onToolActivated);
3012
+ this.restoreSessionFeaturesToConfig();
3006
3013
  (_a = this.dirtyTrackerDisposable) == null ? void 0 : _a.dispose();
3007
3014
  this.dirtyTrackerDisposable = void 0;
3008
3015
  this.teardown();
@@ -3034,9 +3041,9 @@ var FeatureTool = class {
3034
3041
  name: "Feature",
3035
3042
  interaction: "session",
3036
3043
  commands: {
3037
- begin: "resetWorkingFeatures",
3044
+ begin: "beginFeatureSession",
3038
3045
  commit: "completeFeatures",
3039
- rollback: "resetWorkingFeatures"
3046
+ rollback: "rollbackFeatureSession"
3040
3047
  },
3041
3048
  session: {
3042
3049
  autoBegin: false,
@@ -3045,6 +3052,25 @@ var FeatureTool = class {
3045
3052
  }
3046
3053
  ],
3047
3054
  [ContributionPointIds4.COMMANDS]: [
3055
+ {
3056
+ command: "beginFeatureSession",
3057
+ title: "Begin Feature Session",
3058
+ handler: async () => {
3059
+ if (this.isFeatureSessionActive) {
3060
+ return { ok: true };
3061
+ }
3062
+ const original = this.getCommittedFeatures();
3063
+ this.sessionOriginalFeatures = this.cloneFeatures(original);
3064
+ this.isFeatureSessionActive = true;
3065
+ await this.refreshGeometry();
3066
+ this.setWorkingFeatures(this.cloneFeatures(original));
3067
+ this.hasWorkingChanges = false;
3068
+ this.redraw();
3069
+ this.emitWorkingChange();
3070
+ this.updateCommittedFeatures([]);
3071
+ return { ok: true };
3072
+ }
3073
+ },
3048
3074
  {
3049
3075
  command: "addFeature",
3050
3076
  title: "Add Edge Feature",
@@ -3097,19 +3123,27 @@ var FeatureTool = class {
3097
3123
  }
3098
3124
  },
3099
3125
  {
3100
- command: "resetWorkingFeatures",
3101
- title: "Reset Working Features",
3126
+ command: "rollbackFeatureSession",
3127
+ title: "Rollback Feature Session",
3102
3128
  handler: async () => {
3103
- var _a;
3104
- const configService = (_a = this.context) == null ? void 0 : _a.services.get(
3105
- "ConfigurationService"
3129
+ const original = this.cloneFeatures(
3130
+ this.sessionOriginalFeatures || this.getCommittedFeatures()
3106
3131
  );
3107
- const next = (configService == null ? void 0 : configService.get("dieline.features", [])) || [];
3108
3132
  await this.refreshGeometry();
3109
- this.setWorkingFeatures(this.cloneFeatures(next));
3133
+ this.setWorkingFeatures(original);
3110
3134
  this.hasWorkingChanges = false;
3111
3135
  this.redraw();
3112
3136
  this.emitWorkingChange();
3137
+ this.updateCommittedFeatures(original);
3138
+ this.clearFeatureSessionState();
3139
+ return { ok: true };
3140
+ }
3141
+ },
3142
+ {
3143
+ command: "resetWorkingFeatures",
3144
+ title: "Reset Working Features",
3145
+ handler: async () => {
3146
+ await this.resetWorkingFeaturesFromSource();
3113
3147
  return { ok: true };
3114
3148
  }
3115
3149
  },
@@ -3133,6 +3167,37 @@ var FeatureTool = class {
3133
3167
  cloneFeatures(features) {
3134
3168
  return JSON.parse(JSON.stringify(features || []));
3135
3169
  }
3170
+ getConfigService() {
3171
+ var _a;
3172
+ return (_a = this.context) == null ? void 0 : _a.services.get("ConfigurationService");
3173
+ }
3174
+ getCommittedFeatures() {
3175
+ const configService = this.getConfigService();
3176
+ const committed = (configService == null ? void 0 : configService.get("dieline.features", [])) || [];
3177
+ return this.cloneFeatures(committed);
3178
+ }
3179
+ updateCommittedFeatures(next) {
3180
+ const configService = this.getConfigService();
3181
+ if (!configService) return;
3182
+ this.isUpdatingConfig = true;
3183
+ try {
3184
+ configService.update("dieline.features", next);
3185
+ } finally {
3186
+ this.isUpdatingConfig = false;
3187
+ }
3188
+ }
3189
+ clearFeatureSessionState() {
3190
+ this.isFeatureSessionActive = false;
3191
+ this.sessionOriginalFeatures = null;
3192
+ }
3193
+ restoreSessionFeaturesToConfig() {
3194
+ if (!this.isFeatureSessionActive) return;
3195
+ const original = this.cloneFeatures(
3196
+ this.sessionOriginalFeatures || this.getCommittedFeatures()
3197
+ );
3198
+ this.updateCommittedFeatures(original);
3199
+ this.clearFeatureSessionState();
3200
+ }
3136
3201
  emitWorkingChange() {
3137
3202
  var _a;
3138
3203
  (_a = this.context) == null ? void 0 : _a.eventBus.emit("feature:working:change", {
@@ -3151,6 +3216,16 @@ var FeatureTool = class {
3151
3216
  } catch (e) {
3152
3217
  }
3153
3218
  }
3219
+ async resetWorkingFeaturesFromSource() {
3220
+ const next = this.cloneFeatures(
3221
+ this.isFeatureSessionActive && this.sessionOriginalFeatures ? this.sessionOriginalFeatures : this.getCommittedFeatures()
3222
+ );
3223
+ await this.refreshGeometry();
3224
+ this.setWorkingFeatures(next);
3225
+ this.hasWorkingChanges = false;
3226
+ this.redraw();
3227
+ this.emitWorkingChange();
3228
+ }
3154
3229
  setWorkingFeatures(next) {
3155
3230
  this.workingFeatures = next;
3156
3231
  }
@@ -3207,12 +3282,7 @@ var FeatureTool = class {
3207
3282
  this.workingFeatures,
3208
3283
  { dielineWidth, dielineHeight },
3209
3284
  (next) => {
3210
- this.isUpdatingConfig = true;
3211
- try {
3212
- configService.update("dieline.features", next);
3213
- } finally {
3214
- this.isUpdatingConfig = false;
3215
- }
3285
+ this.updateCommittedFeatures(next);
3216
3286
  this.workingFeatures = this.cloneFeatures(next);
3217
3287
  this.emitWorkingChange();
3218
3288
  }
@@ -3224,6 +3294,7 @@ var FeatureTool = class {
3224
3294
  };
3225
3295
  }
3226
3296
  this.hasWorkingChanges = false;
3297
+ this.clearFeatureSessionState();
3227
3298
  this.redraw();
3228
3299
  return { ok: true };
3229
3300
  }
@@ -3798,10 +3869,7 @@ var ImageTool = class {
3798
3869
  context.eventBus.on("selection:created", this.onSelectionChanged);
3799
3870
  context.eventBus.on("selection:updated", this.onSelectionChanged);
3800
3871
  context.eventBus.on("selection:cleared", this.onSelectionCleared);
3801
- context.eventBus.on(
3802
- "scene:layout:change",
3803
- this.onSceneLayoutChanged
3804
- );
3872
+ context.eventBus.on("scene:layout:change", this.onSceneLayoutChanged);
3805
3873
  const configService = context.services.get(
3806
3874
  "ConfigurationService"
3807
3875
  );
@@ -3841,10 +3909,7 @@ var ImageTool = class {
3841
3909
  context.eventBus.off("selection:created", this.onSelectionChanged);
3842
3910
  context.eventBus.off("selection:updated", this.onSelectionChanged);
3843
3911
  context.eventBus.off("selection:cleared", this.onSelectionCleared);
3844
- context.eventBus.off(
3845
- "scene:layout:change",
3846
- this.onSceneLayoutChanged
3847
- );
3912
+ context.eventBus.off("scene:layout:change", this.onSceneLayoutChanged);
3848
3913
  (_a = this.dirtyTrackerDisposable) == null ? void 0 : _a.dispose();
3849
3914
  this.dirtyTrackerDisposable = void 0;
3850
3915
  this.clearRenderedImages();
@@ -3953,7 +4018,7 @@ var ImageTool = class {
3953
4018
  id: "image.frame.outerBackground",
3954
4019
  type: "color",
3955
4020
  label: "Image Frame Outer Background",
3956
- default: "rgba(0,0,0,0.18)"
4021
+ default: "#f5f5f5"
3957
4022
  }
3958
4023
  ],
3959
4024
  [ContributionPointIds5.COMMANDS]: [
@@ -3996,6 +4061,7 @@ var ImageTool = class {
3996
4061
  this.workingItems = this.cloneItems(this.items);
3997
4062
  this.hasWorkingChanges = false;
3998
4063
  this.updateImages();
4064
+ this.emitWorkingChange();
3999
4065
  }
4000
4066
  },
4001
4067
  {
@@ -4110,6 +4176,13 @@ var ImageTool = class {
4110
4176
  cloneItems(items) {
4111
4177
  return this.normalizeItems((items || []).map((i) => ({ ...i })));
4112
4178
  }
4179
+ emitWorkingChange(changedId = null) {
4180
+ var _a;
4181
+ (_a = this.context) == null ? void 0 : _a.eventBus.emit("image:working:change", {
4182
+ changedId,
4183
+ items: this.cloneItems(this.workingItems)
4184
+ });
4185
+ }
4113
4186
  generateId() {
4114
4187
  return Math.random().toString(36).substring(2, 9);
4115
4188
  }
@@ -4178,6 +4251,7 @@ var ImageTool = class {
4178
4251
  if (this.workingItems.some((existing) => existing.id === item.id)) return;
4179
4252
  this.workingItems = this.cloneItems([...this.workingItems, item]);
4180
4253
  this.updateImages();
4254
+ this.emitWorkingChange(item.id);
4181
4255
  }
4182
4256
  async updateImage(id, updates, options = {}) {
4183
4257
  this.syncToolActiveFromWorkbench();
@@ -4361,10 +4435,7 @@ var ImageTool = class {
4361
4435
  "image.frame.innerBackground",
4362
4436
  "rgba(0,0,0,0)"
4363
4437
  ) || "rgba(0,0,0,0)",
4364
- outerBackground: this.getConfig(
4365
- "image.frame.outerBackground",
4366
- "rgba(0,0,0,0.18)"
4367
- ) || "rgba(0,0,0,0.18)"
4438
+ outerBackground: "#f5f5f5"
4368
4439
  };
4369
4440
  }
4370
4441
  resolveRenderImageState(item) {
@@ -4508,10 +4579,21 @@ var ImageTool = class {
4508
4579
  const canvasW = this.canvasService.canvas.width || 0;
4509
4580
  const canvasH = this.canvasService.canvas.height || 0;
4510
4581
  const visual = this.getFrameVisualConfig();
4511
- const topH = Math.max(0, frame.top);
4512
- const bottomH = Math.max(0, canvasH - (frame.top + frame.height));
4513
- const leftW = Math.max(0, frame.left);
4514
- const rightW = Math.max(0, canvasW - (frame.left + frame.width));
4582
+ const frameLeft = Math.max(0, Math.min(canvasW, frame.left));
4583
+ const frameTop = Math.max(0, Math.min(canvasH, frame.top));
4584
+ const frameRight = Math.max(
4585
+ frameLeft,
4586
+ Math.min(canvasW, frame.left + frame.width)
4587
+ );
4588
+ const frameBottom = Math.max(
4589
+ frameTop,
4590
+ Math.min(canvasH, frame.top + frame.height)
4591
+ );
4592
+ const visibleFrameH = Math.max(0, frameBottom - frameTop);
4593
+ const topH = frameTop;
4594
+ const bottomH = Math.max(0, canvasH - frameBottom);
4595
+ const leftW = frameLeft;
4596
+ const rightW = Math.max(0, canvasW - frameRight);
4515
4597
  const mask = [
4516
4598
  {
4517
4599
  id: "image.cropMask.top",
@@ -4535,7 +4617,7 @@ var ImageTool = class {
4535
4617
  data: { id: "image.cropMask.bottom", zIndex: 2 },
4536
4618
  props: {
4537
4619
  left: canvasW / 2,
4538
- top: frame.top + frame.height + bottomH / 2,
4620
+ top: frameBottom + bottomH / 2,
4539
4621
  width: canvasW,
4540
4622
  height: bottomH,
4541
4623
  originX: "center",
@@ -4551,9 +4633,9 @@ var ImageTool = class {
4551
4633
  data: { id: "image.cropMask.left", zIndex: 3 },
4552
4634
  props: {
4553
4635
  left: leftW / 2,
4554
- top: frame.top + frame.height / 2,
4636
+ top: frameTop + visibleFrameH / 2,
4555
4637
  width: leftW,
4556
- height: frame.height,
4638
+ height: visibleFrameH,
4557
4639
  originX: "center",
4558
4640
  originY: "center",
4559
4641
  fill: visual.outerBackground,
@@ -4566,10 +4648,10 @@ var ImageTool = class {
4566
4648
  type: "rect",
4567
4649
  data: { id: "image.cropMask.right", zIndex: 4 },
4568
4650
  props: {
4569
- left: frame.left + frame.width + rightW / 2,
4570
- top: frame.top + frame.height / 2,
4651
+ left: frameRight + rightW / 2,
4652
+ top: frameTop + visibleFrameH / 2,
4571
4653
  width: rightW,
4572
- height: frame.height,
4654
+ height: visibleFrameH,
4573
4655
  originX: "center",
4574
4656
  originY: "center",
4575
4657
  fill: visual.outerBackground,
@@ -4659,6 +4741,7 @@ var ImageTool = class {
4659
4741
  if (this.isToolActive) {
4660
4742
  this.updateImages();
4661
4743
  }
4744
+ this.emitWorkingChange(id);
4662
4745
  }
4663
4746
  async updateImageInConfig(id, updates) {
4664
4747
  var _a, _b, _c, _d;
@@ -4739,6 +4822,7 @@ var ImageTool = class {
4739
4822
  this.isImageSelectionActive = true;
4740
4823
  this.focusedImageId = id;
4741
4824
  this.updateImages();
4825
+ this.emitWorkingChange(id);
4742
4826
  }
4743
4827
  focusImageSelection(id) {
4744
4828
  if (!this.canvasService) return;
@@ -4831,6 +4915,7 @@ var ImageTool = class {
4831
4915
  this.hasWorkingChanges = false;
4832
4916
  this.workingItems = this.cloneItems(next);
4833
4917
  this.updateConfig(next);
4918
+ this.emitWorkingChange(focusId);
4834
4919
  if (focusId) {
4835
4920
  this.focusedImageId = focusId;
4836
4921
  this.isImageSelectionActive = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pooder/kit",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Standard plugins for Pooder editor",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",