@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.
@@ -11043,6 +11043,8 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11043
11043
  };
11044
11044
  const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
11045
11045
  const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11046
+ const GROUP_IMAGE_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-image-side-resize]";
11047
+ const GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES = 300;
11046
11048
  const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11047
11049
  const summarizeFabricObjectForResizeDebug = (obj) => {
11048
11050
  var _a2;
@@ -11105,6 +11107,43 @@ const logGroupTextResizeDebug = (phase, payload) => {
11105
11107
  console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11106
11108
  }
11107
11109
  };
11110
+ const isGroupResizeImageLikeObject = (obj) => {
11111
+ var _a2;
11112
+ return !!obj && (obj instanceof fabric__namespace.FabricImage || obj instanceof fabric__namespace.Group && (obj.__cropGroup || ((_a2 = obj._ct) == null ? void 0 : _a2.isCropGroup)));
11113
+ };
11114
+ const logGroupImageResizeDebug = (phase, payload) => {
11115
+ if (typeof console === "undefined") return;
11116
+ try {
11117
+ const seen = /* @__PURE__ */ new WeakSet();
11118
+ const normalize = (value) => {
11119
+ if (value == null) return value;
11120
+ const valueType = typeof value;
11121
+ if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11122
+ if (valueType === "string" || valueType === "boolean") return value;
11123
+ if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11124
+ if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11125
+ if (valueType === "object") {
11126
+ if (seen.has(value)) return "[Circular]";
11127
+ seen.add(value);
11128
+ if (value instanceof fabric__namespace.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11129
+ const output = {};
11130
+ Object.entries(value).forEach(([key, entry]) => {
11131
+ output[key] = normalize(entry);
11132
+ });
11133
+ return output;
11134
+ }
11135
+ return String(value);
11136
+ };
11137
+ const normalizedPayload = normalize(payload);
11138
+ const line = `${GROUP_IMAGE_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11139
+ const debugWindow = window;
11140
+ debugWindow.__pixldocsGroupImageResizeLogs = Array.isArray(debugWindow.__pixldocsGroupImageResizeLogs) ? debugWindow.__pixldocsGroupImageResizeLogs.slice(-GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11141
+ debugWindow.__pixldocsGroupImageResizeLogs.push(line);
11142
+ console.log(line);
11143
+ } catch {
11144
+ console.log(GROUP_IMAGE_RESIZE_DEBUG_PREFIX, phase, payload);
11145
+ }
11146
+ };
11108
11147
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11109
11148
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
11110
11149
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
@@ -13764,6 +13803,21 @@ const PageCanvas = react.forwardRef(
13764
13803
  const selectionAngle = ((obj.angle ?? 0) % 180 + 180) % 180;
13765
13804
  const isSelectionRotated = !(selectionAngle < 0.5 || selectionAngle > 179.5);
13766
13805
  const shouldPinNonTextChildren = hasRotatedChild || isSelectionRotated;
13806
+ const shouldDebugGroupImageResize = obj.getObjects().some((child) => isGroupResizeImageLikeObject(child));
13807
+ if (shouldDebugGroupImageResize) {
13808
+ logGroupImageResizeDebug("live-start", {
13809
+ time: Math.round(performance.now()),
13810
+ corner,
13811
+ isXSide,
13812
+ sAxis,
13813
+ hasRotatedChild,
13814
+ isSelectionRotated,
13815
+ shouldPinNonTextChildren,
13816
+ groupSelectionId: obj.__pixldocsGroupSelection,
13817
+ selection: summarizeFabricObjectForResizeDebug(obj),
13818
+ children: obj.getObjects().map((child) => summarizeFabricObjectForResizeDebug(child))
13819
+ });
13820
+ }
13767
13821
  if ((isXSide || shouldPinNonTextChildren) && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13768
13822
  groupShiftReflowSnapshotRef.current = null;
13769
13823
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -13836,12 +13890,25 @@ const PageCanvas = react.forwardRef(
13836
13890
  targetLeft = (pin == null ? void 0 : pin.left) ?? targetLeft;
13837
13891
  targetTop = (pin == null ? void 0 : pin.top) ?? targetTop;
13838
13892
  }
13893
+ const beforeRestore = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13839
13894
  if (Math.abs((child.left ?? 0) - targetLeft) > 0.01) child._set("left", targetLeft);
13840
13895
  if (Math.abs((child.top ?? 0) - targetTop) > 0.01) child._set("top", targetTop);
13841
13896
  if (isXSide) child._set("scaleX", childCounterScale);
13842
13897
  else child._set("scaleY", childCounterScale);
13843
13898
  child.setCoords();
13844
13899
  child.dirty = true;
13900
+ if (shouldDebugGroupImageResize) {
13901
+ logGroupImageResizeDebug("restore-non-text", {
13902
+ time: Math.round(performance.now()),
13903
+ corner,
13904
+ childId: getObjectId(child),
13905
+ targetLeft,
13906
+ targetTop,
13907
+ pin,
13908
+ before: beforeRestore,
13909
+ after: summarizeFabricObjectForResizeDebug(child)
13910
+ });
13911
+ }
13845
13912
  }
13846
13913
  }
13847
13914
  };
@@ -13855,6 +13922,7 @@ const PageCanvas = react.forwardRef(
13855
13922
  };
13856
13923
  for (const child of obj.getObjects()) {
13857
13924
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13925
+ const beforeImageChildResize = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13858
13926
  const ct = child.__cropData;
13859
13927
  if (ct) {
13860
13928
  if (child.__asLiveOrigW == null) {
@@ -13881,10 +13949,22 @@ const PageCanvas = react.forwardRef(
13881
13949
  else child._set("scaleY", childCounterScale);
13882
13950
  child.setCoords();
13883
13951
  child.dirty = true;
13952
+ if (shouldDebugGroupImageResize) {
13953
+ logGroupImageResizeDebug("live-crop-child-resized", {
13954
+ time: Math.round(performance.now()),
13955
+ corner,
13956
+ sAxis,
13957
+ childCounterScale,
13958
+ before: beforeImageChildResize,
13959
+ after: summarizeFabricObjectForResizeDebug(child),
13960
+ cropData: ct ? { frameW: ct.frameW, frameH: ct.frameH } : null
13961
+ });
13962
+ }
13884
13963
  didReflowTextChild = true;
13885
13964
  continue;
13886
13965
  }
13887
13966
  if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
13967
+ const beforeImageChildResize = shouldDebugGroupImageResize ? summarizeFabricObjectForResizeDebug(child) : null;
13888
13968
  if (isXSide) {
13889
13969
  if (child.__asLiveOrigW == null) {
13890
13970
  child.__asLiveOrigW = (child.width ?? 0) * Math.abs(child.scaleX ?? 1);
@@ -13902,6 +13982,18 @@ const PageCanvas = react.forwardRef(
13902
13982
  else child._set("scaleY", childCounterScale);
13903
13983
  child.setCoords();
13904
13984
  child.dirty = true;
13985
+ if (shouldDebugGroupImageResize) {
13986
+ logGroupImageResizeDebug("live-image-child-resized", {
13987
+ time: Math.round(performance.now()),
13988
+ corner,
13989
+ sAxis,
13990
+ childCounterScale,
13991
+ liveOrigW: child.__asLiveOrigW,
13992
+ liveOrigH: child.__asLiveOrigH,
13993
+ before: beforeImageChildResize,
13994
+ after: summarizeFabricObjectForResizeDebug(child)
13995
+ });
13996
+ }
13905
13997
  didReflowTextChild = true;
13906
13998
  continue;
13907
13999
  }
@@ -13985,6 +14077,15 @@ const PageCanvas = react.forwardRef(
13985
14077
  }
13986
14078
  restoreNonTextChildren(nonTextPinsBeforeLayout);
13987
14079
  restoredNonTextAfterLayout = !!nonTextPinsBeforeLayout;
14080
+ if (shouldDebugGroupImageResize) {
14081
+ logGroupImageResizeDebug("after-trigger-layout", {
14082
+ time: Math.round(performance.now()),
14083
+ corner,
14084
+ selection: summarizeFabricObjectForResizeDebug(obj),
14085
+ nonTextPinsBeforeLayout,
14086
+ children: obj.getObjects().map((child) => summarizeFabricObjectForResizeDebug(child))
14087
+ });
14088
+ }
13988
14089
  obj._set("width", asW0);
13989
14090
  obj._set("scaleX", asSx0);
13990
14091
  obj._set("scaleY", asSy0);
@@ -14579,6 +14680,18 @@ const PageCanvas = react.forwardRef(
14579
14680
  const isActiveSelection = activeObj instanceof fabric__namespace.ActiveSelection || activeObjects.length > 1;
14580
14681
  const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14581
14682
  const debugGroupTextCornerResize = activeObj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(activeSelectionResizeHandle) && activeObjects.some((candidate) => candidate instanceof fabric__namespace.Textbox);
14683
+ const debugGroupImageSideResize = activeObj instanceof fabric__namespace.ActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb") && activeObjects.some((candidate) => isGroupResizeImageLikeObject(candidate));
14684
+ if (debugGroupImageSideResize) {
14685
+ logGroupImageResizeDebug("modified-start", {
14686
+ time: Math.round(performance.now()),
14687
+ handle: activeSelectionResizeHandle,
14688
+ target: summarizeFabricObjectForResizeDebug(modifiedTarget),
14689
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14690
+ activeObjectIds: activeObjects.map((candidate) => getObjectId(candidate)),
14691
+ selectedStoreIds: useEditorStore.getState().canvas.selectedIds,
14692
+ members: activeObjects.map((candidate) => summarizeFabricObjectForResizeDebug(candidate))
14693
+ });
14694
+ }
14582
14695
  if (debugGroupTextCornerResize) {
14583
14696
  logGroupTextResizeDebug("modified-start", {
14584
14697
  time: Math.round(performance.now()),
@@ -14933,6 +15046,7 @@ const PageCanvas = react.forwardRef(
14933
15046
  useEditorStore.getState().updateElement(objId, { src: newSrc }, { recordHistory: false, skipLayoutRecalc: true });
14934
15047
  }
14935
15048
  } else if (isActiveSelection && (Math.abs((decomposed.scaleX ?? 1) - 1) > 1e-3 || Math.abs((decomposed.scaleY ?? 1) - 1) > 1e-3)) {
15049
+ const debugImageBeforeBake = debugGroupImageSideResize ? summarizeFabricObjectForResizeDebug(obj) : null;
14936
15050
  const sx = Math.abs(decomposed.scaleX || 1);
14937
15051
  const sy = Math.abs(decomposed.scaleY || 1);
14938
15052
  const handle = activeSelectionResizeHandle;
@@ -15003,6 +15117,38 @@ const PageCanvas = react.forwardRef(
15003
15117
  skewX: finalSkewX ?? 0,
15004
15118
  skewY: finalSkewY ?? 0
15005
15119
  });
15120
+ if (debugGroupImageSideResize) {
15121
+ logGroupImageResizeDebug("image-bake", {
15122
+ time: Math.round(performance.now()),
15123
+ handle: activeSelectionResizeHandle,
15124
+ imageId: objId,
15125
+ source: sourceElement ? {
15126
+ left: sourceElement.left,
15127
+ top: sourceElement.top,
15128
+ width: sourceElement.width,
15129
+ height: sourceElement.height,
15130
+ angle: sourceElement.angle,
15131
+ scaleX: sourceElement.scaleX,
15132
+ scaleY: sourceElement.scaleY
15133
+ } : null,
15134
+ factors: { sx, sy, fx, fy, isCornerHandle },
15135
+ beforeBake: debugImageBeforeBake,
15136
+ afterBake: summarizeFabricObjectForResizeDebug(obj),
15137
+ persistedGeometry: {
15138
+ absoluteLeft,
15139
+ absoluteTop,
15140
+ finalWidth,
15141
+ finalHeight,
15142
+ finalScaleX,
15143
+ finalScaleY,
15144
+ finalAngle,
15145
+ finalSkewX,
15146
+ finalSkewY,
15147
+ decomposed,
15148
+ finalAbsoluteMatrix
15149
+ }
15150
+ });
15151
+ }
15006
15152
  } else {
15007
15153
  finalWidth = intrinsicWidth;
15008
15154
  finalHeight = intrinsicHeight;
@@ -15220,6 +15366,16 @@ const PageCanvas = react.forwardRef(
15220
15366
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
15221
15367
  });
15222
15368
  }
15369
+ if (debugGroupImageSideResize && isGroupResizeImageLikeObject(obj)) {
15370
+ logGroupImageResizeDebug("store-update-image", {
15371
+ time: Math.round(performance.now()),
15372
+ handle: activeSelectionResizeHandle,
15373
+ imageId: objId,
15374
+ storePos,
15375
+ elementUpdate,
15376
+ objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
15377
+ });
15378
+ }
15223
15379
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15224
15380
  obj.setCoords();
15225
15381
  }
@@ -15250,6 +15406,16 @@ const PageCanvas = react.forwardRef(
15250
15406
  renderOnAddRemove: fabricCanvas.renderOnAddRemove
15251
15407
  });
15252
15408
  }
15409
+ if (debugGroupImageSideResize) {
15410
+ logGroupImageResizeDebug("before-reselect", {
15411
+ time: Math.round(performance.now()),
15412
+ handle: activeSelectionResizeHandle,
15413
+ wasGroupSel,
15414
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
15415
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
15416
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
15417
+ });
15418
+ }
15253
15419
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
15254
15420
  fabricCanvas.renderOnAddRemove = false;
15255
15421
  skipSelectionClearOnDiscardRef.current = true;
@@ -15294,6 +15460,16 @@ const PageCanvas = react.forwardRef(
15294
15460
  renderOnAddRemove: fabricCanvas.renderOnAddRemove
15295
15461
  });
15296
15462
  }
15463
+ if (debugGroupImageSideResize) {
15464
+ logGroupImageResizeDebug("after-reselect", {
15465
+ time: Math.round(performance.now()),
15466
+ handle: activeSelectionResizeHandle,
15467
+ wasGroupSel,
15468
+ selection: summarizeFabricObjectForResizeDebug(newSel),
15469
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
15470
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
15471
+ });
15472
+ }
15297
15473
  } else if (membersToReselect.length === 1) {
15298
15474
  fabricCanvas.setActiveObject(membersToReselect[0]);
15299
15475
  }
@@ -24343,9 +24519,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24343
24519
  }
24344
24520
  return svgString;
24345
24521
  }
24346
- const resolvedPackageVersion = "0.5.332";
24522
+ const resolvedPackageVersion = "0.5.333";
24347
24523
  const PACKAGE_VERSION = resolvedPackageVersion;
24348
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.332";
24524
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.333";
24349
24525
  const roundParityValue = (value) => {
24350
24526
  if (typeof value !== "number") return value;
24351
24527
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25159,7 +25335,7 @@ class PixldocsRenderer {
25159
25335
  await this.waitForCanvasScene(container, cloned, i);
25160
25336
  }
25161
25337
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25162
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BnF6Lk4i.cjs"));
25338
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Cc-1U0NL.cjs"));
25163
25339
  const prepared = preparePagesForExport(
25164
25340
  cloned.pages,
25165
25341
  canvasWidth,
@@ -27479,7 +27655,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27479
27655
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27480
27656
  sanitizeSvgTreeForPdf(svgToDraw);
27481
27657
  try {
27482
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BnF6Lk4i.cjs"));
27658
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Cc-1U0NL.cjs"));
27483
27659
  try {
27484
27660
  await logTextMeasurementDiagnostic(svgToDraw);
27485
27661
  } catch {
@@ -27876,4 +28052,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27876
28052
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27877
28053
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27878
28054
  exports.warmTemplateFromForm = warmTemplateFromForm;
27879
- //# sourceMappingURL=index-B9Lpo1N6.cjs.map
28055
+ //# sourceMappingURL=index-k8mzlqgs.cjs.map