@pixldocs/canvas-renderer 0.5.292 → 0.5.294

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.
@@ -10995,6 +10995,70 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
10995
10995
  const value = Number(source == null ? void 0 : source[key]);
10996
10996
  if (Number.isFinite(value)) updates[key] = value * factor;
10997
10997
  };
10998
+ const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
10999
+ const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11000
+ const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11001
+ const summarizeFabricObjectForResizeDebug = (obj) => {
11002
+ var _a2;
11003
+ if (!obj) return null;
11004
+ try {
11005
+ const rect = obj.getBoundingRect();
11006
+ const center = obj.getCenterPoint();
11007
+ const matrix = obj.calcTransformMatrix();
11008
+ const decomposed = fabric.util.qrDecompose(matrix);
11009
+ return {
11010
+ id: getObjectId(obj),
11011
+ kind: obj instanceof fabric.ActiveSelection ? "ActiveSelection" : obj instanceof fabric.Textbox ? "Textbox" : obj.type ?? ((_a2 = obj.constructor) == null ? void 0 : _a2.name),
11012
+ left: obj.left,
11013
+ top: obj.top,
11014
+ width: obj.width,
11015
+ height: obj.height,
11016
+ scaleX: obj.scaleX,
11017
+ scaleY: obj.scaleY,
11018
+ angle: obj.angle,
11019
+ originX: obj.originX,
11020
+ originY: obj.originY,
11021
+ center: { x: center.x, y: center.y },
11022
+ boundingRect: rect,
11023
+ decomposed
11024
+ };
11025
+ } catch (error) {
11026
+ return { id: getObjectId(obj), error: String(error) };
11027
+ }
11028
+ };
11029
+ const logGroupTextResizeDebug = (phase, payload) => {
11030
+ if (typeof console === "undefined") return;
11031
+ try {
11032
+ const seen = /* @__PURE__ */ new WeakSet();
11033
+ const normalize = (value) => {
11034
+ if (value == null) return value;
11035
+ const valueType = typeof value;
11036
+ if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11037
+ if (valueType === "string" || valueType === "boolean") return value;
11038
+ if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11039
+ if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11040
+ if (valueType === "object") {
11041
+ if (seen.has(value)) return "[Circular]";
11042
+ seen.add(value);
11043
+ if (value instanceof fabric.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11044
+ const output = {};
11045
+ Object.entries(value).forEach(([key, entry]) => {
11046
+ output[key] = normalize(entry);
11047
+ });
11048
+ return output;
11049
+ }
11050
+ return String(value);
11051
+ };
11052
+ const normalizedPayload = normalize(payload);
11053
+ const line = `${GROUP_TEXT_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11054
+ const debugWindow = window;
11055
+ debugWindow.__pixldocsGroupTextResizeLogs = Array.isArray(debugWindow.__pixldocsGroupTextResizeLogs) ? debugWindow.__pixldocsGroupTextResizeLogs.slice(-GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11056
+ debugWindow.__pixldocsGroupTextResizeLogs.push(line);
11057
+ console.log(line);
11058
+ } catch {
11059
+ console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11060
+ }
11061
+ };
10998
11062
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
10999
11063
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
11000
11064
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
@@ -13350,7 +13414,7 @@ const PageCanvas = forwardRef(
13350
13414
  fabricCanvas.on("selection:cleared", () => {
13351
13415
  });
13352
13416
  fabricCanvas.on("object:scaling", (e) => {
13353
- var _a2;
13417
+ var _a2, _b2;
13354
13418
  if (!isActiveRef.current) return;
13355
13419
  const t = e.target;
13356
13420
  if (t) lastResizeScaleTargetRef.current = t;
@@ -13512,6 +13576,16 @@ const PageCanvas = forwardRef(
13512
13576
  const corner = (transform == null ? void 0 : transform.corner) || "";
13513
13577
  if (obj instanceof fabric.ActiveSelection && corner) {
13514
13578
  activeSelectionResizeHandleRef.current = corner;
13579
+ if (isCornerResizeHandle(corner) && obj.getObjects().some((child) => child instanceof fabric.Textbox)) {
13580
+ obj.__pixldocsLastGroupTextScaleDebug = {
13581
+ time: Math.round(performance.now()),
13582
+ corner,
13583
+ groupSelectionId: obj.__pixldocsGroupSelection,
13584
+ currentTransformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
13585
+ selection: summarizeFabricObjectForResizeDebug(obj),
13586
+ textChildren: obj.getObjects().filter((child) => child instanceof fabric.Textbox).map((child) => summarizeFabricObjectForResizeDebug(child))
13587
+ };
13588
+ }
13515
13589
  }
13516
13590
  if (obj instanceof fabric.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13517
13591
  const isXSide = corner === "ml" || corner === "mr";
@@ -13674,7 +13748,7 @@ const PageCanvas = forwardRef(
13674
13748
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13675
13749
  if (drilledGroupIdRef.current) {
13676
13750
  try {
13677
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13751
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13678
13752
  } catch {
13679
13753
  }
13680
13754
  }
@@ -14136,6 +14210,20 @@ const PageCanvas = forwardRef(
14136
14210
  }
14137
14211
  const isActiveSelection = activeObj instanceof fabric.ActiveSelection || activeObjects.length > 1;
14138
14212
  const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14213
+ const debugGroupTextCornerResize = activeObj instanceof fabric.ActiveSelection && isCornerResizeHandle(activeSelectionResizeHandle) && activeObjects.some((candidate) => candidate instanceof fabric.Textbox);
14214
+ if (debugGroupTextCornerResize) {
14215
+ logGroupTextResizeDebug("modified-start", {
14216
+ time: Math.round(performance.now()),
14217
+ handle: activeSelectionResizeHandle,
14218
+ target: summarizeFabricObjectForResizeDebug(modifiedTarget),
14219
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14220
+ activeObjectCount: activeObjects.length,
14221
+ activeObjectIds: activeObjects.map((candidate) => getObjectId(candidate)),
14222
+ selectedStoreIds: useEditorStore.getState().canvas.selectedIds,
14223
+ transformStart: groupSelectionTransformStartRef.current,
14224
+ lastScalingFrame: activeObj.__pixldocsLastGroupTextScaleDebug
14225
+ });
14226
+ }
14139
14227
  if (activeObj instanceof fabric.ActiveSelection && activeObjects.length > 1) {
14140
14228
  const memberIds = activeObjects.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__");
14141
14229
  if (memberIds.length > 1) {
@@ -14476,6 +14564,7 @@ const PageCanvas = forwardRef(
14476
14564
  const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
14477
14565
  const nextMinH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH * sy : isHeightSideHandle ? Math.max(1, intrinsicHeight * sy) : void 0;
14478
14566
  const bakedTextScaleUpdates = { width: bakedWidth };
14567
+ const debugTextBeforeBake = debugGroupTextCornerResize ? summarizeFabricObjectForResizeDebug(obj) : null;
14479
14568
  finalScaleX = 1;
14480
14569
  finalScaleY = 1;
14481
14570
  try {
@@ -14531,6 +14620,36 @@ const PageCanvas = forwardRef(
14531
14620
  skewX: 0,
14532
14621
  skewY: 0
14533
14622
  });
14623
+ if (debugGroupTextCornerResize) {
14624
+ logGroupTextResizeDebug("text-bake", {
14625
+ time: Math.round(performance.now()),
14626
+ handle: activeSelectionResizeHandle,
14627
+ textId: objId,
14628
+ source: sourceElement ? {
14629
+ left: sourceElement.left,
14630
+ top: sourceElement.top,
14631
+ width: sourceElement.width,
14632
+ height: sourceElement.height,
14633
+ fontSize: sourceElement.fontSize,
14634
+ scaleX: sourceElement.scaleX,
14635
+ scaleY: sourceElement.scaleY
14636
+ } : null,
14637
+ factors: { sx, sy, fontScale, isCornerHandle, isHeightSideHandle },
14638
+ beforeBake: debugTextBeforeBake,
14639
+ afterBake: summarizeFabricObjectForResizeDebug(obj),
14640
+ persistedGeometry: {
14641
+ absoluteLeft,
14642
+ absoluteTop,
14643
+ finalWidth,
14644
+ finalHeight,
14645
+ finalScaleX,
14646
+ finalScaleY,
14647
+ decomposed,
14648
+ finalAbsoluteMatrix,
14649
+ bakedTextScaleUpdates
14650
+ }
14651
+ });
14652
+ }
14534
14653
  } else if (preserveCornerGeometry) {
14535
14654
  const scaledW = Math.max(1, intrinsicWidth * Math.abs(decomposed.scaleX || 1));
14536
14655
  const scaledH = Math.max(1, intrinsicHeight * Math.abs(decomposed.scaleY || 1));
@@ -14594,6 +14713,15 @@ const PageCanvas = forwardRef(
14594
14713
  if (sourceElement && sourceElement.opacity !== void 0) {
14595
14714
  elementUpdate.opacity = sourceElement.opacity;
14596
14715
  }
14716
+ if (debugGroupTextCornerResize && obj instanceof fabric.Textbox) {
14717
+ logGroupTextResizeDebug("store-update-text", {
14718
+ time: Math.round(performance.now()),
14719
+ handle: activeSelectionResizeHandle,
14720
+ textId: objId,
14721
+ elementUpdate,
14722
+ objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
14723
+ });
14724
+ }
14597
14725
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14598
14726
  obj.setCoords();
14599
14727
  }
@@ -14614,6 +14742,16 @@ const PageCanvas = forwardRef(
14614
14742
  const oid = getObjectId(o);
14615
14743
  return !!oid && oid !== "__background__";
14616
14744
  });
14745
+ if (debugGroupTextCornerResize) {
14746
+ logGroupTextResizeDebug("before-reselect", {
14747
+ time: Math.round(performance.now()),
14748
+ handle: activeSelectionResizeHandle,
14749
+ wasGroupSel,
14750
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14751
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14752
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14753
+ });
14754
+ }
14617
14755
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
14618
14756
  fabricCanvas.renderOnAddRemove = false;
14619
14757
  skipSelectionClearOnDiscardRef.current = true;
@@ -14647,6 +14785,16 @@ const PageCanvas = forwardRef(
14647
14785
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
14648
14786
  fabricCanvas.setActiveObject(newSel);
14649
14787
  newSel.setCoords();
14788
+ if (debugGroupTextCornerResize) {
14789
+ logGroupTextResizeDebug("after-reselect", {
14790
+ time: Math.round(performance.now()),
14791
+ handle: activeSelectionResizeHandle,
14792
+ wasGroupSel,
14793
+ selection: summarizeFabricObjectForResizeDebug(newSel),
14794
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14795
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14796
+ });
14797
+ }
14650
14798
  } else if (membersToReselect.length === 1) {
14651
14799
  fabricCanvas.setActiveObject(membersToReselect[0]);
14652
14800
  }
@@ -23677,9 +23825,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23677
23825
  }
23678
23826
  return svgString;
23679
23827
  }
23680
- const resolvedPackageVersion = "0.5.292";
23828
+ const resolvedPackageVersion = "0.5.294";
23681
23829
  const PACKAGE_VERSION = resolvedPackageVersion;
23682
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.292";
23830
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.294";
23683
23831
  const roundParityValue = (value) => {
23684
23832
  if (typeof value !== "number") return value;
23685
23833
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24493,7 +24641,7 @@ class PixldocsRenderer {
24493
24641
  await this.waitForCanvasScene(container, cloned, i);
24494
24642
  }
24495
24643
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24496
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DS6A8tQu.js");
24644
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-uoX8_JuH.js");
24497
24645
  const prepared = preparePagesForExport(
24498
24646
  cloned.pages,
24499
24647
  canvasWidth,
@@ -26813,7 +26961,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26813
26961
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26814
26962
  sanitizeSvgTreeForPdf(svgToDraw);
26815
26963
  try {
26816
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DS6A8tQu.js");
26964
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-uoX8_JuH.js");
26817
26965
  try {
26818
26966
  await logTextMeasurementDiagnostic(svgToDraw);
26819
26967
  } catch {
@@ -27213,4 +27361,4 @@ export {
27213
27361
  buildTeaserBlurFlatKeys as y,
27214
27362
  collectFontDescriptorsFromConfig as z
27215
27363
  };
27216
- //# sourceMappingURL=index-CgvNkm0U.js.map
27364
+ //# sourceMappingURL=index-CvuMfLba.js.map