@pixldocs/canvas-renderer 0.5.292 → 0.5.293

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,46 @@ 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 isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11018
+ const summarizeFabricObjectForResizeDebug = (obj) => {
11019
+ var _a2;
11020
+ if (!obj) return null;
11021
+ try {
11022
+ const rect = obj.getBoundingRect();
11023
+ const center = obj.getCenterPoint();
11024
+ const matrix = obj.calcTransformMatrix();
11025
+ const decomposed = fabric__namespace.util.qrDecompose(matrix);
11026
+ return {
11027
+ id: getObjectId(obj),
11028
+ kind: obj instanceof fabric__namespace.ActiveSelection ? "ActiveSelection" : obj instanceof fabric__namespace.Textbox ? "Textbox" : obj.type ?? ((_a2 = obj.constructor) == null ? void 0 : _a2.name),
11029
+ left: obj.left,
11030
+ top: obj.top,
11031
+ width: obj.width,
11032
+ height: obj.height,
11033
+ scaleX: obj.scaleX,
11034
+ scaleY: obj.scaleY,
11035
+ angle: obj.angle,
11036
+ originX: obj.originX,
11037
+ originY: obj.originY,
11038
+ center: { x: center.x, y: center.y },
11039
+ boundingRect: rect,
11040
+ decomposed
11041
+ };
11042
+ } catch (error) {
11043
+ return { id: getObjectId(obj), error: String(error) };
11044
+ }
11045
+ };
11046
+ const logGroupTextResizeDebug = (phase, payload) => {
11047
+ if (typeof console === "undefined") return;
11048
+ try {
11049
+ console.groupCollapsed(`${GROUP_TEXT_RESIZE_DEBUG_PREFIX} ${phase}`);
11050
+ console.log(payload);
11051
+ console.groupEnd();
11052
+ } catch {
11053
+ console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11054
+ }
11055
+ };
11016
11056
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11017
11057
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
11018
11058
  const sy = Math.abs(obj.scaleY ?? 1) || 1;
@@ -13368,7 +13408,7 @@ const PageCanvas = react.forwardRef(
13368
13408
  fabricCanvas.on("selection:cleared", () => {
13369
13409
  });
13370
13410
  fabricCanvas.on("object:scaling", (e) => {
13371
- var _a2;
13411
+ var _a2, _b2;
13372
13412
  if (!isActiveRef.current) return;
13373
13413
  const t = e.target;
13374
13414
  if (t) lastResizeScaleTargetRef.current = t;
@@ -13530,6 +13570,16 @@ const PageCanvas = react.forwardRef(
13530
13570
  const corner = (transform == null ? void 0 : transform.corner) || "";
13531
13571
  if (obj instanceof fabric__namespace.ActiveSelection && corner) {
13532
13572
  activeSelectionResizeHandleRef.current = corner;
13573
+ if (isCornerResizeHandle(corner) && obj.getObjects().some((child) => child instanceof fabric__namespace.Textbox)) {
13574
+ obj.__pixldocsLastGroupTextScaleDebug = {
13575
+ time: Math.round(performance.now()),
13576
+ corner,
13577
+ groupSelectionId: obj.__pixldocsGroupSelection,
13578
+ currentTransformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
13579
+ selection: summarizeFabricObjectForResizeDebug(obj),
13580
+ textChildren: obj.getObjects().filter((child) => child instanceof fabric__namespace.Textbox).map((child) => summarizeFabricObjectForResizeDebug(child))
13581
+ };
13582
+ }
13533
13583
  }
13534
13584
  if (obj instanceof fabric__namespace.ActiveSelection && (corner === "ml" || corner === "mr" || corner === "mt" || corner === "mb")) {
13535
13585
  const isXSide = corner === "ml" || corner === "mr";
@@ -13692,7 +13742,7 @@ const PageCanvas = react.forwardRef(
13692
13742
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
13693
13743
  if (drilledGroupIdRef.current) {
13694
13744
  try {
13695
- (_a2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _a2.call(fabricCanvas);
13745
+ (_b2 = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _b2.call(fabricCanvas);
13696
13746
  } catch {
13697
13747
  }
13698
13748
  }
@@ -14154,6 +14204,20 @@ const PageCanvas = react.forwardRef(
14154
14204
  }
14155
14205
  const isActiveSelection = activeObj instanceof fabric__namespace.ActiveSelection || activeObjects.length > 1;
14156
14206
  const activeSelectionResizeHandle = isActiveSelection ? activeSelectionResizeHandleRef.current : null;
14207
+ const debugGroupTextCornerResize = activeObj instanceof fabric__namespace.ActiveSelection && isCornerResizeHandle(activeSelectionResizeHandle) && activeObjects.some((candidate) => candidate instanceof fabric__namespace.Textbox);
14208
+ if (debugGroupTextCornerResize) {
14209
+ logGroupTextResizeDebug("modified-start", {
14210
+ time: Math.round(performance.now()),
14211
+ handle: activeSelectionResizeHandle,
14212
+ target: summarizeFabricObjectForResizeDebug(modifiedTarget),
14213
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14214
+ activeObjectCount: activeObjects.length,
14215
+ activeObjectIds: activeObjects.map((candidate) => getObjectId(candidate)),
14216
+ selectedStoreIds: useEditorStore.getState().canvas.selectedIds,
14217
+ transformStart: groupSelectionTransformStartRef.current,
14218
+ lastScalingFrame: activeObj.__pixldocsLastGroupTextScaleDebug
14219
+ });
14220
+ }
14157
14221
  if (activeObj instanceof fabric__namespace.ActiveSelection && activeObjects.length > 1) {
14158
14222
  const memberIds = activeObjects.map((o) => getObjectId(o)).filter((id) => !!id && id !== "__background__");
14159
14223
  if (memberIds.length > 1) {
@@ -14494,6 +14558,7 @@ const PageCanvas = react.forwardRef(
14494
14558
  const baseMinH = Number(obj.minBoxHeight ?? (sourceElement == null ? void 0 : sourceElement.minBoxHeight));
14495
14559
  const nextMinH = Number.isFinite(baseMinH) && baseMinH > 0 ? baseMinH * sy : isHeightSideHandle ? Math.max(1, intrinsicHeight * sy) : void 0;
14496
14560
  const bakedTextScaleUpdates = { width: bakedWidth };
14561
+ const debugTextBeforeBake = debugGroupTextCornerResize ? summarizeFabricObjectForResizeDebug(obj) : null;
14497
14562
  finalScaleX = 1;
14498
14563
  finalScaleY = 1;
14499
14564
  try {
@@ -14549,6 +14614,36 @@ const PageCanvas = react.forwardRef(
14549
14614
  skewX: 0,
14550
14615
  skewY: 0
14551
14616
  });
14617
+ if (debugGroupTextCornerResize) {
14618
+ logGroupTextResizeDebug("text-bake", {
14619
+ time: Math.round(performance.now()),
14620
+ handle: activeSelectionResizeHandle,
14621
+ textId: objId,
14622
+ source: sourceElement ? {
14623
+ left: sourceElement.left,
14624
+ top: sourceElement.top,
14625
+ width: sourceElement.width,
14626
+ height: sourceElement.height,
14627
+ fontSize: sourceElement.fontSize,
14628
+ scaleX: sourceElement.scaleX,
14629
+ scaleY: sourceElement.scaleY
14630
+ } : null,
14631
+ factors: { sx, sy, fontScale, isCornerHandle, isHeightSideHandle },
14632
+ beforeBake: debugTextBeforeBake,
14633
+ afterBake: summarizeFabricObjectForResizeDebug(obj),
14634
+ persistedGeometry: {
14635
+ absoluteLeft,
14636
+ absoluteTop,
14637
+ finalWidth,
14638
+ finalHeight,
14639
+ finalScaleX,
14640
+ finalScaleY,
14641
+ decomposed,
14642
+ finalAbsoluteMatrix,
14643
+ bakedTextScaleUpdates
14644
+ }
14645
+ });
14646
+ }
14552
14647
  } else if (preserveCornerGeometry) {
14553
14648
  const scaledW = Math.max(1, intrinsicWidth * Math.abs(decomposed.scaleX || 1));
14554
14649
  const scaledH = Math.max(1, intrinsicHeight * Math.abs(decomposed.scaleY || 1));
@@ -14612,6 +14707,15 @@ const PageCanvas = react.forwardRef(
14612
14707
  if (sourceElement && sourceElement.opacity !== void 0) {
14613
14708
  elementUpdate.opacity = sourceElement.opacity;
14614
14709
  }
14710
+ if (debugGroupTextCornerResize && obj instanceof fabric__namespace.Textbox) {
14711
+ logGroupTextResizeDebug("store-update-text", {
14712
+ time: Math.round(performance.now()),
14713
+ handle: activeSelectionResizeHandle,
14714
+ textId: objId,
14715
+ elementUpdate,
14716
+ objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
14717
+ });
14718
+ }
14615
14719
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14616
14720
  obj.setCoords();
14617
14721
  }
@@ -14632,6 +14736,16 @@ const PageCanvas = react.forwardRef(
14632
14736
  const oid = getObjectId(o);
14633
14737
  return !!oid && oid !== "__background__";
14634
14738
  });
14739
+ if (debugGroupTextCornerResize) {
14740
+ logGroupTextResizeDebug("before-reselect", {
14741
+ time: Math.round(performance.now()),
14742
+ handle: activeSelectionResizeHandle,
14743
+ wasGroupSel,
14744
+ selection: summarizeFabricObjectForResizeDebug(activeObj),
14745
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14746
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14747
+ });
14748
+ }
14635
14749
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
14636
14750
  fabricCanvas.renderOnAddRemove = false;
14637
14751
  skipSelectionClearOnDiscardRef.current = true;
@@ -14665,6 +14779,16 @@ const PageCanvas = react.forwardRef(
14665
14779
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
14666
14780
  fabricCanvas.setActiveObject(newSel);
14667
14781
  newSel.setCoords();
14782
+ if (debugGroupTextCornerResize) {
14783
+ logGroupTextResizeDebug("after-reselect", {
14784
+ time: Math.round(performance.now()),
14785
+ handle: activeSelectionResizeHandle,
14786
+ wasGroupSel,
14787
+ selection: summarizeFabricObjectForResizeDebug(newSel),
14788
+ members: membersToReselect.map((member) => summarizeFabricObjectForResizeDebug(member)),
14789
+ renderOnAddRemove: fabricCanvas.renderOnAddRemove
14790
+ });
14791
+ }
14668
14792
  } else if (membersToReselect.length === 1) {
14669
14793
  fabricCanvas.setActiveObject(membersToReselect[0]);
14670
14794
  }
@@ -23695,9 +23819,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23695
23819
  }
23696
23820
  return svgString;
23697
23821
  }
23698
- const resolvedPackageVersion = "0.5.292";
23822
+ const resolvedPackageVersion = "0.5.293";
23699
23823
  const PACKAGE_VERSION = resolvedPackageVersion;
23700
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.292";
23824
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.293";
23701
23825
  const roundParityValue = (value) => {
23702
23826
  if (typeof value !== "number") return value;
23703
23827
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24511,7 +24635,7 @@ class PixldocsRenderer {
24511
24635
  await this.waitForCanvasScene(container, cloned, i);
24512
24636
  }
24513
24637
  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"));
24638
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B089WLSf.cjs"));
24515
24639
  const prepared = preparePagesForExport(
24516
24640
  cloned.pages,
24517
24641
  canvasWidth,
@@ -26831,7 +26955,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26831
26955
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26832
26956
  sanitizeSvgTreeForPdf(svgToDraw);
26833
26957
  try {
26834
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Q0sI218Z.cjs"));
26958
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B089WLSf.cjs"));
26835
26959
  try {
26836
26960
  await logTextMeasurementDiagnostic(svgToDraw);
26837
26961
  } catch {
@@ -27228,4 +27352,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27228
27352
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27229
27353
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27230
27354
  exports.warmTemplateFromForm = warmTemplateFromForm;
27231
- //# sourceMappingURL=index-BnsuaZL0.cjs.map
27355
+ //# sourceMappingURL=index-CvP_zeI7.cjs.map