@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.
@@ -11013,6 +11013,70 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11013
11013
  const value = Number(source == null ? void 0 : source[key]);
11014
11014
  if (Number.isFinite(value)) updates[key] = value * factor;
11015
11015
  };
11016
+ const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
11017
+ const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11018
+ const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11019
+ const summarizeFabricObjectForResizeDebug = (obj) => {
11020
+ var _a2;
11021
+ if (!obj) return null;
11022
+ try {
11023
+ const rect = obj.getBoundingRect();
11024
+ const center = obj.getCenterPoint();
11025
+ const matrix = obj.calcTransformMatrix();
11026
+ const decomposed = fabric__namespace.util.qrDecompose(matrix);
11027
+ return {
11028
+ id: getObjectId(obj),
11029
+ kind: obj instanceof fabric__namespace.ActiveSelection ? "ActiveSelection" : obj instanceof fabric__namespace.Textbox ? "Textbox" : obj.type ?? ((_a2 = obj.constructor) == null ? void 0 : _a2.name),
11030
+ left: obj.left,
11031
+ top: obj.top,
11032
+ width: obj.width,
11033
+ height: obj.height,
11034
+ scaleX: obj.scaleX,
11035
+ scaleY: obj.scaleY,
11036
+ angle: obj.angle,
11037
+ originX: obj.originX,
11038
+ originY: obj.originY,
11039
+ center: { x: center.x, y: center.y },
11040
+ boundingRect: rect,
11041
+ decomposed
11042
+ };
11043
+ } catch (error) {
11044
+ return { id: getObjectId(obj), error: String(error) };
11045
+ }
11046
+ };
11047
+ const logGroupTextResizeDebug = (phase, payload) => {
11048
+ if (typeof console === "undefined") return;
11049
+ try {
11050
+ const seen = /* @__PURE__ */ new WeakSet();
11051
+ const normalize = (value) => {
11052
+ if (value == null) return value;
11053
+ const valueType = typeof value;
11054
+ if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11055
+ if (valueType === "string" || valueType === "boolean") return value;
11056
+ if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11057
+ if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11058
+ if (valueType === "object") {
11059
+ if (seen.has(value)) return "[Circular]";
11060
+ seen.add(value);
11061
+ if (value instanceof fabric__namespace.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11062
+ const output = {};
11063
+ Object.entries(value).forEach(([key, entry]) => {
11064
+ output[key] = normalize(entry);
11065
+ });
11066
+ return output;
11067
+ }
11068
+ return String(value);
11069
+ };
11070
+ const normalizedPayload = normalize(payload);
11071
+ const line = `${GROUP_TEXT_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11072
+ const debugWindow = window;
11073
+ debugWindow.__pixldocsGroupTextResizeLogs = Array.isArray(debugWindow.__pixldocsGroupTextResizeLogs) ? debugWindow.__pixldocsGroupTextResizeLogs.slice(-GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11074
+ debugWindow.__pixldocsGroupTextResizeLogs.push(line);
11075
+ console.log(line);
11076
+ } catch {
11077
+ console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11078
+ }
11079
+ };
11016
11080
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11017
11081
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
11018
11082
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
@@ -13368,7 +13432,7 @@ const PageCanvas = react.forwardRef(
13368
13432
  fabricCanvas.on("selection:cleared", () => {
13369
13433
  });
13370
13434
  fabricCanvas.on("object:scaling", (e) => {
13371
- var _a2;
13435
+ var _a2, _b2;
13372
13436
  if (!isActiveRef.current) return;
13373
13437
  const t = e.target;
13374
13438
  if (t) lastResizeScaleTargetRef.current = t;
@@ -13530,6 +13594,16 @@ const PageCanvas = react.forwardRef(
13530
13594
  const corner = (transform == null ? void 0 : transform.corner) || "";
13531
13595
  if (obj instanceof fabric__namespace.ActiveSelection && corner) {
13532
13596
  activeSelectionResizeHandleRef.current = corner;
13597
+ if (isCornerResizeHandle(corner) && obj.getObjects().some((child) => child instanceof fabric__namespace.Textbox)) {
13598
+ obj.__pixldocsLastGroupTextScaleDebug = {
13599
+ time: Math.round(performance.now()),
13600
+ corner,
13601
+ groupSelectionId: obj.__pixldocsGroupSelection,
13602
+ currentTransformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
13603
+ selection: summarizeFabricObjectForResizeDebug(obj),
13604
+ textChildren: obj.getObjects().filter((child) => child instanceof fabric__namespace.Textbox).map((child) => summarizeFabricObjectForResizeDebug(child))
13605
+ };
13606
+ }
13533
13607
  }
13534
13608
  if (obj instanceof fabric__namespace.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13535
13609
  const isXSide = corner === "ml" || corner === "mr";
@@ -13692,7 +13766,7 @@ const PageCanvas = react.forwardRef(
13692
13766
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13693
13767
  if (drilledGroupIdRef.current) {
13694
13768
  try {
13695
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13769
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13696
13770
  } catch {
13697
13771
  }
13698
13772
  }
@@ -14154,6 +14228,20 @@ const PageCanvas = react.forwardRef(
14154
14228
  }
14155
14229
  const isActiveSelection = activeObj instanceof fabric__namespace.ActiveSelection || activeObjects.length > 1;
14156
14230
  const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14231
+ const debugGroupTextCornerResize = activeObj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(activeSelectionResizeHandle) && activeObjects.some((candidate) => candidate instanceof fabric__namespace.Textbox);
14232
+ if (debugGroupTextCornerResize) {
14233
+ logGroupTextResizeDebug("modified-start", {
14234
+ time: Math.round(performance.now()),
14235
+ handle: activeSelectionResizeHandle,
14236
+ target: summarizeFabricObjectForResizeDebug(modifiedTarget),
14237
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14238
+ activeObjectCount: activeObjects.length,
14239
+ activeObjectIds: activeObjects.map((candidate) => getObjectId(candidate)),
14240
+ selectedStoreIds: useEditorStore.getState().canvas.selectedIds,
14241
+ transformStart: groupSelectionTransformStartRef.current,
14242
+ lastScalingFrame: activeObj.__pixldocsLastGroupTextScaleDebug
14243
+ });
14244
+ }
14157
14245
  if (activeObj instanceof fabric__namespace.ActiveSelection && activeObjects.length > 1) {
14158
14246
  const memberIds = activeObjects.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__");
14159
14247
  if (memberIds.length > 1) {
@@ -14494,6 +14582,7 @@ const PageCanvas = react.forwardRef(
14494
14582
  const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
14495
14583
  const nextMinH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH * sy : isHeightSideHandle ? Math.max(1, intrinsicHeight * sy) : void 0;
14496
14584
  const bakedTextScaleUpdates = { width: bakedWidth };
14585
+ const debugTextBeforeBake = debugGroupTextCornerResize ? summarizeFabricObjectForResizeDebug(obj) : null;
14497
14586
  finalScaleX = 1;
14498
14587
  finalScaleY = 1;
14499
14588
  try {
@@ -14549,6 +14638,36 @@ const PageCanvas = react.forwardRef(
14549
14638
  skewX: 0,
14550
14639
  skewY: 0
14551
14640
  });
14641
+ if (debugGroupTextCornerResize) {
14642
+ logGroupTextResizeDebug("text-bake", {
14643
+ time: Math.round(performance.now()),
14644
+ handle: activeSelectionResizeHandle,
14645
+ textId: objId,
14646
+ source: sourceElement ? {
14647
+ left: sourceElement.left,
14648
+ top: sourceElement.top,
14649
+ width: sourceElement.width,
14650
+ height: sourceElement.height,
14651
+ fontSize: sourceElement.fontSize,
14652
+ scaleX: sourceElement.scaleX,
14653
+ scaleY: sourceElement.scaleY
14654
+ } : null,
14655
+ factors: { sx, sy, fontScale, isCornerHandle, isHeightSideHandle },
14656
+ beforeBake: debugTextBeforeBake,
14657
+ afterBake: summarizeFabricObjectForResizeDebug(obj),
14658
+ persistedGeometry: {
14659
+ absoluteLeft,
14660
+ absoluteTop,
14661
+ finalWidth,
14662
+ finalHeight,
14663
+ finalScaleX,
14664
+ finalScaleY,
14665
+ decomposed,
14666
+ finalAbsoluteMatrix,
14667
+ bakedTextScaleUpdates
14668
+ }
14669
+ });
14670
+ }
14552
14671
  } else if (preserveCornerGeometry) {
14553
14672
  const scaledW = Math.max(1, intrinsicWidth * Math.abs(decomposed.scaleX || 1));
14554
14673
  const scaledH = Math.max(1, intrinsicHeight * Math.abs(decomposed.scaleY || 1));
@@ -14612,6 +14731,15 @@ const PageCanvas = react.forwardRef(
14612
14731
  if (sourceElement && sourceElement.opacity !== void 0) {
14613
14732
  elementUpdate.opacity = sourceElement.opacity;
14614
14733
  }
14734
+ if (debugGroupTextCornerResize && obj instanceof fabric__namespace.Textbox) {
14735
+ logGroupTextResizeDebug("store-update-text", {
14736
+ time: Math.round(performance.now()),
14737
+ handle: activeSelectionResizeHandle,
14738
+ textId: objId,
14739
+ elementUpdate,
14740
+ objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
14741
+ });
14742
+ }
14615
14743
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14616
14744
  obj.setCoords();
14617
14745
  }
@@ -14632,6 +14760,16 @@ const PageCanvas = react.forwardRef(
14632
14760
  const oid = getObjectId(o);
14633
14761
  return !!oid && oid !== "__background__";
14634
14762
  });
14763
+ if (debugGroupTextCornerResize) {
14764
+ logGroupTextResizeDebug("before-reselect", {
14765
+ time: Math.round(performance.now()),
14766
+ handle: activeSelectionResizeHandle,
14767
+ wasGroupSel,
14768
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14769
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14770
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14771
+ });
14772
+ }
14635
14773
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
14636
14774
  fabricCanvas.renderOnAddRemove = false;
14637
14775
  skipSelectionClearOnDiscardRef.current = true;
@@ -14665,6 +14803,16 @@ const PageCanvas = react.forwardRef(
14665
14803
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
14666
14804
  fabricCanvas.setActiveObject(newSel);
14667
14805
  newSel.setCoords();
14806
+ if (debugGroupTextCornerResize) {
14807
+ logGroupTextResizeDebug("after-reselect", {
14808
+ time: Math.round(performance.now()),
14809
+ handle: activeSelectionResizeHandle,
14810
+ wasGroupSel,
14811
+ selection: summarizeFabricObjectForResizeDebug(newSel),
14812
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14813
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14814
+ });
14815
+ }
14668
14816
  } else if (membersToReselect.length === 1) {
14669
14817
  fabricCanvas.setActiveObject(membersToReselect[0]);
14670
14818
  }
@@ -23695,9 +23843,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23695
23843
  }
23696
23844
  return svgString;
23697
23845
  }
23698
- const resolvedPackageVersion = "0.5.292";
23846
+ const resolvedPackageVersion = "0.5.294";
23699
23847
  const PACKAGE_VERSION = resolvedPackageVersion;
23700
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.292";
23848
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.294";
23701
23849
  const roundParityValue = (value) => {
23702
23850
  if (typeof value !== "number") return value;
23703
23851
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24511,7 +24659,7 @@ class PixldocsRenderer {
24511
24659
  await this.waitForCanvasScene(container, cloned, i);
24512
24660
  }
24513
24661
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24514
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Q0sI218Z.cjs"));
24662
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CtQnH_h8.cjs"));
24515
24663
  const prepared = preparePagesForExport(
24516
24664
  cloned.pages,
24517
24665
  canvasWidth,
@@ -26831,7 +26979,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26831
26979
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26832
26980
  sanitizeSvgTreeForPdf(svgToDraw);
26833
26981
  try {
26834
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Q0sI218Z.cjs"));
26982
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CtQnH_h8.cjs"));
26835
26983
  try {
26836
26984
  await logTextMeasurementDiagnostic(svgToDraw);
26837
26985
  } catch {
@@ -27228,4 +27376,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27228
27376
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27229
27377
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27230
27378
  exports.warmTemplateFromForm = warmTemplateFromForm;
27231
- //# sourceMappingURL=index-BnsuaZL0.cjs.map
27379
+ //# sourceMappingURL=index-YNCK2XyZ.cjs.map