@pixldocs/canvas-renderer 0.5.291 → 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 {
@@ -14521,6 +14586,25 @@ const PageCanvas = react.forwardRef(
14521
14586
  obj.setCoords();
14522
14587
  } catch {
14523
14588
  }
14589
+ try {
14590
+ const angleRad = (decomposed.angle ?? 0) * Math.PI / 180;
14591
+ const cos = Math.cos(angleRad);
14592
+ const sin = Math.sin(angleRad);
14593
+ const hw = finalWidth / 2;
14594
+ const hh = finalHeight / 2;
14595
+ const corners = [
14596
+ { x: -hw, y: -hh },
14597
+ { x: hw, y: -hh },
14598
+ { x: hw, y: hh },
14599
+ { x: -hw, y: hh }
14600
+ ].map((p) => ({
14601
+ x: decomposed.translateX + p.x * cos - p.y * sin,
14602
+ y: decomposed.translateY + p.x * sin + p.y * cos
14603
+ }));
14604
+ absoluteLeft = Math.min(...corners.map((p) => p.x));
14605
+ absoluteTop = Math.min(...corners.map((p) => p.y));
14606
+ } catch {
14607
+ }
14524
14608
  finalAbsoluteMatrix = fabric__namespace.util.composeMatrix({
14525
14609
  translateX: decomposed.translateX,
14526
14610
  translateY: decomposed.translateY,
@@ -14530,6 +14614,36 @@ const PageCanvas = react.forwardRef(
14530
14614
  skewX: 0,
14531
14615
  skewY: 0
14532
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
+ }
14533
14647
  } else if (preserveCornerGeometry) {
14534
14648
  const scaledW = Math.max(1, intrinsicWidth * Math.abs(decomposed.scaleX || 1));
14535
14649
  const scaledH = Math.max(1, intrinsicHeight * Math.abs(decomposed.scaleY || 1));
@@ -14593,6 +14707,15 @@ const PageCanvas = react.forwardRef(
14593
14707
  if (sourceElement && sourceElement.opacity !== void 0) {
14594
14708
  elementUpdate.opacity = sourceElement.opacity;
14595
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
+ }
14596
14719
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14597
14720
  obj.setCoords();
14598
14721
  }
@@ -14613,6 +14736,16 @@ const PageCanvas = react.forwardRef(
14613
14736
  const oid = getObjectId(o);
14614
14737
  return !!oid && oid !== "__background__";
14615
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
+ }
14616
14749
  const prevRenderOnAddRemove = fabricCanvas.renderOnAddRemove;
14617
14750
  fabricCanvas.renderOnAddRemove = false;
14618
14751
  skipSelectionClearOnDiscardRef.current = true;
@@ -14646,6 +14779,16 @@ const PageCanvas = react.forwardRef(
14646
14779
  if (wasGroupSel) restoreGroupSelectionVisualState(newSel, wasGroupSel);
14647
14780
  fabricCanvas.setActiveObject(newSel);
14648
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
+ }
14649
14792
  } else if (membersToReselect.length === 1) {
14650
14793
  fabricCanvas.setActiveObject(membersToReselect[0]);
14651
14794
  }
@@ -23676,9 +23819,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23676
23819
  }
23677
23820
  return svgString;
23678
23821
  }
23679
- const resolvedPackageVersion = "0.5.291";
23822
+ const resolvedPackageVersion = "0.5.293";
23680
23823
  const PACKAGE_VERSION = resolvedPackageVersion;
23681
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.291";
23824
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.293";
23682
23825
  const roundParityValue = (value) => {
23683
23826
  if (typeof value !== "number") return value;
23684
23827
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24492,7 +24635,7 @@ class PixldocsRenderer {
24492
24635
  await this.waitForCanvasScene(container, cloned, i);
24493
24636
  }
24494
24637
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24495
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CFg39g3k.cjs"));
24638
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B089WLSf.cjs"));
24496
24639
  const prepared = preparePagesForExport(
24497
24640
  cloned.pages,
24498
24641
  canvasWidth,
@@ -26812,7 +26955,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26812
26955
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26813
26956
  sanitizeSvgTreeForPdf(svgToDraw);
26814
26957
  try {
26815
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CFg39g3k.cjs"));
26958
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B089WLSf.cjs"));
26816
26959
  try {
26817
26960
  await logTextMeasurementDiagnostic(svgToDraw);
26818
26961
  } catch {
@@ -27209,4 +27352,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27209
27352
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27210
27353
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27211
27354
  exports.warmTemplateFromForm = warmTemplateFromForm;
27212
- //# sourceMappingURL=index-DUC4YCF2.cjs.map
27355
+ //# sourceMappingURL=index-CvP_zeI7.cjs.map