@pixldocs/canvas-renderer 0.5.332 → 0.5.333

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.
@@ -11025,6 +11025,8 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11025
11025
  };
11026
11026
  const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
11027
11027
  const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11028
+ const GROUP_IMAGE_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-image-side-resize]";
11029
+ const GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES = 300;
11028
11030
  const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11029
11031
  const summarizeFabricObjectForResizeDebug = (obj) => {
11030
11032
  var _a2;
@@ -11087,6 +11089,43 @@ const logGroupTextResizeDebug = (phase, payload) => {
11087
11089
  console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11088
11090
  }
11089
11091
  };
11092
+ const isGroupResizeImageLikeObject = (obj) => {
11093
+ var _a2;
11094
+ return !!obj && (obj instanceof fabric.FabricImage || obj instanceof fabric.Group && (obj.__cropGroup || ((_a2 = obj._ct) == null ? void 0 : _a2.isCropGroup)));
11095
+ };
11096
+ const logGroupImageResizeDebug = (phase, payload) => {
11097
+ if (typeof console === "undefined") return;
11098
+ try {
11099
+ const seen = /* @__PURE__ */ new WeakSet();
11100
+ const normalize = (value) => {
11101
+ if (value == null) return value;
11102
+ const valueType = typeof value;
11103
+ if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11104
+ if (valueType === "string" || valueType === "boolean") return value;
11105
+ if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11106
+ if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11107
+ if (valueType === "object") {
11108
+ if (seen.has(value)) return "[Circular]";
11109
+ seen.add(value);
11110
+ if (value instanceof fabric.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11111
+ const output = {};
11112
+ Object.entries(value).forEach(([key, entry]) => {
11113
+ output[key] = normalize(entry);
11114
+ });
11115
+ return output;
11116
+ }
11117
+ return String(value);
11118
+ };
11119
+ const normalizedPayload = normalize(payload);
11120
+ const line = `${GROUP_IMAGE_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11121
+ const debugWindow = window;
11122
+ debugWindow.__pixldocsGroupImageResizeLogs = Array.isArray(debugWindow.__pixldocsGroupImageResizeLogs) ? debugWindow.__pixldocsGroupImageResizeLogs.slice(-GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11123
+ debugWindow.__pixldocsGroupImageResizeLogs.push(line);
11124
+ console.log(line);
11125
+ } catch {
11126
+ console.log(GROUP_IMAGE_RESIZE_DEBUG_PREFIX, phase, payload);
11127
+ }
11128
+ };
11090
11129
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11091
11130
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
11092
11131
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
@@ -13746,6 +13785,21 @@ const PageCanvas = forwardRef(
13746
13785
  const selectionAngle = ((obj.angle ?? 0) % 180 + 180) % 180;
13747
13786
  const isSelectionRotated = !(selectionAngle < 0.5 || selectionAngle > 179.5);
13748
13787
  const shouldPinNonTextChildren = hasRotatedChild || isSelectionRotated;
13788
+ const shouldDebugGroupImageResize = obj.getObjects().some((child) => isGroupResizeImageLikeObject(child));
13789
+ if (shouldDebugGroupImageResize) {
13790
+ logGroupImageResizeDebug("live-start", {
13791
+ time: Math.round(performance.now()),
13792
+ corner,
13793
+ isXSide,
13794
+ sAxis,
13795
+ hasRotatedChild,
13796
+ isSelectionRotated,
13797
+ shouldPinNonTextChildren,
13798
+ groupSelectionId: obj.__pixldocsGroupSelection,
13799
+ selection: summarizeFabricObjectForResizeDebug(obj),
13800
+ children: obj.getObjects().map((child) => summarizeFabricObjectForResizeDebug(child))
13801
+ });
13802
+ }
13749
13803
  if ((isXSide || shouldPinNonTextChildren) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13750
13804
  groupShiftReflowSnapshotRef.current = null;
13751
13805
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -13818,12 +13872,25 @@ const PageCanvas = forwardRef(
13818
13872
  targetLeft = (pin == null ? void 0 : pin.left) ?? targetLeft;
13819
13873
  targetTop = (pin == null ? void 0 : pin.top) ?? targetTop;
13820
13874
  }
13875
+ const beforeRestore = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13821
13876
  if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13822
13877
  if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13823
13878
  if (isXSide) child._set("scaleX", childCounterScale);
13824
13879
  else child._set("scaleY", childCounterScale);
13825
13880
  child.setCoords();
13826
13881
  child.dirty = true;
13882
+ if (shouldDebugGroupImageResize) {
13883
+ logGroupImageResizeDebug("restore-non-text", {
13884
+ time: Math.round(performance.now()),
13885
+ corner,
13886
+ childId: getObjectId(child),
13887
+ targetLeft,
13888
+ targetTop,
13889
+ pin,
13890
+ before: beforeRestore,
13891
+ after: summarizeFabricObjectForResizeDebug(child)
13892
+ });
13893
+ }
13827
13894
  }
13828
13895
  }
13829
13896
  };
@@ -13837,6 +13904,7 @@ const PageCanvas = forwardRef(
13837
13904
  };
13838
13905
  for (const child of obj.getObjects()) {
13839
13906
  if (child instanceof fabric.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13907
+ const beforeImageChildResize = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13840
13908
  const ct = child.__cropData;
13841
13909
  if (ct) {
13842
13910
  if (child.__asLiveOrigW == null) {
@@ -13863,10 +13931,22 @@ const PageCanvas = forwardRef(
13863
13931
  else child._set("scaleY", childCounterScale);
13864
13932
  child.setCoords();
13865
13933
  child.dirty = true;
13934
+ if (shouldDebugGroupImageResize) {
13935
+ logGroupImageResizeDebug("live-crop-child-resized", {
13936
+ time: Math.round(performance.now()),
13937
+ corner,
13938
+ sAxis,
13939
+ childCounterScale,
13940
+ before: beforeImageChildResize,
13941
+ after: summarizeFabricObjectForResizeDebug(child),
13942
+ cropData: ct ? { frameW: ct.frameW, frameH: ct.frameH } : null
13943
+ });
13944
+ }
13866
13945
  didReflowTextChild = true;
13867
13946
  continue;
13868
13947
  }
13869
13948
  if (child instanceof fabric.FabricImage && !child.__cropGroup && !child.smartElementType) {
13949
+ const beforeImageChildResize = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13870
13950
  if (isXSide) {
13871
13951
  if (child.__asLiveOrigW == null) {
13872
13952
  child.__asLiveOrigW = (child.width ?? 0) * Math.abs(child.scaleX ?? 1);
@@ -13884,6 +13964,18 @@ const PageCanvas = forwardRef(
13884
13964
  else child._set("scaleY", childCounterScale);
13885
13965
  child.setCoords();
13886
13966
  child.dirty = true;
13967
+ if (shouldDebugGroupImageResize) {
13968
+ logGroupImageResizeDebug("live-image-child-resized", {
13969
+ time: Math.round(performance.now()),
13970
+ corner,
13971
+ sAxis,
13972
+ childCounterScale,
13973
+ liveOrigW: child.__asLiveOrigW,
13974
+ liveOrigH: child.__asLiveOrigH,
13975
+ before: beforeImageChildResize,
13976
+ after: summarizeFabricObjectForResizeDebug(child)
13977
+ });
13978
+ }
13887
13979
  didReflowTextChild = true;
13888
13980
  continue;
13889
13981
  }
@@ -13967,6 +14059,15 @@ const PageCanvas = forwardRef(
13967
14059
  }
13968
14060
  restoreNonTextChildren(nonTextPinsBeforeLayout);
13969
14061
  restoredNonTextAfterLayout = !!nonTextPinsBeforeLayout;
14062
+ if (shouldDebugGroupImageResize) {
14063
+ logGroupImageResizeDebug("after-trigger-layout", {
14064
+ time: Math.round(performance.now()),
14065
+ corner,
14066
+ selection: summarizeFabricObjectForResizeDebug(obj),
14067
+ nonTextPinsBeforeLayout,
14068
+ children: obj.getObjects().map((child) => summarizeFabricObjectForResizeDebug(child))
14069
+ });
14070
+ }
13970
14071
  obj._set("width", asW0);
13971
14072
  obj._set("scaleX", asSx0);
13972
14073
  obj._set("scaleY", asSy0);
@@ -14561,6 +14662,18 @@ const PageCanvas = forwardRef(
14561
14662
  const isActiveSelection = activeObj instanceof fabric.ActiveSelection || activeObjects.length > 1;
14562
14663
  const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14563
14664
  const debugGroupTextCornerResize = activeObj instanceof fabric.ActiveSelection && isCornerResizeHandle(activeSelectionResizeHandle) && activeObjects.some((candidate) => candidate instanceof fabric.Textbox);
14665
+ const debugGroupImageSideResize = activeObj instanceof fabric.ActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") && activeObjects.some((candidate) => isGroupResizeImageLikeObject(candidate));
14666
+ if (debugGroupImageSideResize) {
14667
+ logGroupImageResizeDebug("modified-start", {
14668
+ time: Math.round(performance.now()),
14669
+ handle: activeSelectionResizeHandle,
14670
+ target: summarizeFabricObjectForResizeDebug(modifiedTarget),
14671
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14672
+ activeObjectIds: activeObjects.map((candidate) => getObjectId(candidate)),
14673
+ selectedStoreIds: useEditorStore.getState().canvas.selectedIds,
14674
+ members: activeObjects.map((candidate) => summarizeFabricObjectForResizeDebug(candidate))
14675
+ });
14676
+ }
14564
14677
  if (debugGroupTextCornerResize) {
14565
14678
  logGroupTextResizeDebug("modified-start", {
14566
14679
  time: Math.round(performance.now()),
@@ -14915,6 +15028,7 @@ const PageCanvas = forwardRef(
14915
15028
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
14916
15029
  }
14917
15030
  } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15031
+ const debugImageBeforeBake = debugGroupImageSideResize ? summarizeFabricObjectForResizeDebug(obj) : null;
14918
15032
  const sx = Math.abs(decomposed.scaleX || 1);
14919
15033
  const sy = Math.abs(decomposed.scaleY || 1);
14920
15034
  const handle = activeSelectionResizeHandle;
@@ -14985,6 +15099,38 @@ const PageCanvas = forwardRef(
14985
15099
  skewX: finalSkewX ?? 0,
14986
15100
  skewY: finalSkewY ?? 0
14987
15101
  });
15102
+ if (debugGroupImageSideResize) {
15103
+ logGroupImageResizeDebug("image-bake", {
15104
+ time: Math.round(performance.now()),
15105
+ handle: activeSelectionResizeHandle,
15106
+ imageId: objId,
15107
+ source: sourceElement ? {
15108
+ left: sourceElement.left,
15109
+ top: sourceElement.top,
15110
+ width: sourceElement.width,
15111
+ height: sourceElement.height,
15112
+ angle: sourceElement.angle,
15113
+ scaleX: sourceElement.scaleX,
15114
+ scaleY: sourceElement.scaleY
15115
+ } : null,
15116
+ factors: { sx, sy, fx, fy, isCornerHandle },
15117
+ beforeBake: debugImageBeforeBake,
15118
+ afterBake: summarizeFabricObjectForResizeDebug(obj),
15119
+ persistedGeometry: {
15120
+ absoluteLeft,
15121
+ absoluteTop,
15122
+ finalWidth,
15123
+ finalHeight,
15124
+ finalScaleX,
15125
+ finalScaleY,
15126
+ finalAngle,
15127
+ finalSkewX,
15128
+ finalSkewY,
15129
+ decomposed,
15130
+ finalAbsoluteMatrix
15131
+ }
15132
+ });
15133
+ }
14988
15134
  } else {
14989
15135
  finalWidth = intrinsicWidth;
14990
15136
  finalHeight = intrinsicHeight;
@@ -15202,6 +15348,16 @@ const PageCanvas = forwardRef(
15202
15348
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
15203
15349
  });
15204
15350
  }
15351
+ if (debugGroupImageSideResize && isGroupResizeImageLikeObject(obj)) {
15352
+ logGroupImageResizeDebug("store-update-image", {
15353
+ time: Math.round(performance.now()),
15354
+ handle: activeSelectionResizeHandle,
15355
+ imageId: objId,
15356
+ storePos,
15357
+ elementUpdate,
15358
+ objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
15359
+ });
15360
+ }
15205
15361
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15206
15362
  obj.setCoords();
15207
15363
  }
@@ -15232,6 +15388,16 @@ const PageCanvas = forwardRef(
15232
15388
  renderOnAddRemove: fabricCanvas.renderOnAddRemove
15233
15389
  });
15234
15390
  }
15391
+ if (debugGroupImageSideResize) {
15392
+ logGroupImageResizeDebug("before-reselect", {
15393
+ time: Math.round(performance.now()),
15394
+ handle: activeSelectionResizeHandle,
15395
+ wasGroupSel,
15396
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
15397
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
15398
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
15399
+ });
15400
+ }
15235
15401
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
15236
15402
  fabricCanvas.renderOnAddRemove = false;
15237
15403
  skipSelectionClearOnDiscardRef.current = true;
@@ -15276,6 +15442,16 @@ const PageCanvas = forwardRef(
15276
15442
  renderOnAddRemove: fabricCanvas.renderOnAddRemove
15277
15443
  });
15278
15444
  }
15445
+ if (debugGroupImageSideResize) {
15446
+ logGroupImageResizeDebug("after-reselect", {
15447
+ time: Math.round(performance.now()),
15448
+ handle: activeSelectionResizeHandle,
15449
+ wasGroupSel,
15450
+ selection: summarizeFabricObjectForResizeDebug(newSel),
15451
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
15452
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
15453
+ });
15454
+ }
15279
15455
  } else if (membersToReselect.length === 1) {
15280
15456
  fabricCanvas.setActiveObject(membersToReselect[0]);
15281
15457
  }
@@ -24325,9 +24501,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24325
24501
  }
24326
24502
  return svgString;
24327
24503
  }
24328
- const resolvedPackageVersion = "0.5.332";
24504
+ const resolvedPackageVersion = "0.5.333";
24329
24505
  const PACKAGE_VERSION = resolvedPackageVersion;
24330
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.332";
24506
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.333";
24331
24507
  const roundParityValue = (value) => {
24332
24508
  if (typeof value !== "number") return value;
24333
24509
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25141,7 +25317,7 @@ class PixldocsRenderer {
25141
25317
  await this.waitForCanvasScene(container, cloned, i);
25142
25318
  }
25143
25319
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25144
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BE-V6kqQ.js");
25320
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BSV5NYSE.js");
25145
25321
  const prepared = preparePagesForExport(
25146
25322
  cloned.pages,
25147
25323
  canvasWidth,
@@ -27461,7 +27637,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27461
27637
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27462
27638
  sanitizeSvgTreeForPdf(svgToDraw);
27463
27639
  try {
27464
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BE-V6kqQ.js");
27640
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BSV5NYSE.js");
27465
27641
  try {
27466
27642
  await logTextMeasurementDiagnostic(svgToDraw);
27467
27643
  } catch {
@@ -27861,4 +28037,4 @@ export {
27861
28037
  buildTeaserBlurFlatKeys as y,
27862
28038
  collectFontDescriptorsFromConfig as z
27863
28039
  };
27864
- //# sourceMappingURL=index-xMYBX3BX.js.map
28040
+ //# sourceMappingURL=index-CAdMLx_E.js.map