@pixldocs/canvas-renderer 0.5.446 → 0.5.447

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.
@@ -14655,7 +14655,7 @@ const PageCanvas = react.forwardRef(
14655
14655
  fabricCanvas.on("selection:cleared", () => {
14656
14656
  });
14657
14657
  fabricCanvas.on("object:scaling", (e) => {
14658
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
14658
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
14659
14659
  if (!isActiveRef.current) return;
14660
14660
  const t = e.target;
14661
14661
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14893,6 +14893,22 @@ const PageCanvas = react.forwardRef(
14893
14893
  const startSy = Math.abs(Number(((_h = _cur == null ? void 0 : _cur.original) == null ? void 0 : _h.scaleY) ?? 1)) || 1;
14894
14894
  const sAxis = isXSide ? Math.abs((obj.scaleX ?? 1) / startSx) : Math.abs((obj.scaleY ?? 1) / startSy);
14895
14895
  if (sAxis > 1e-3) {
14896
+ const captureAsLiveWorldSnapshot = (childObj, liveW, liveH) => {
14897
+ try {
14898
+ const selectionMatrix = obj.calcTransformMatrix();
14899
+ const childMatrix = childObj.calcOwnMatrix();
14900
+ const worldMatrix = fabric__namespace.util.multiplyTransformMatrices(selectionMatrix, childMatrix);
14901
+ const live = fabric__namespace.util.qrDecompose(worldMatrix);
14902
+ const childOrigLocalAngle = Number.isFinite(childObj.__asLiveOrigAngle) ? childObj.__asLiveOrigAngle : childObj.angle ?? 0;
14903
+ childObj.__asLiveWorldAngle = (obj.angle ?? 0) + childOrigLocalAngle;
14904
+ childObj.__asLiveWorldCenterX = live.translateX;
14905
+ childObj.__asLiveWorldCenterY = live.translateY;
14906
+ childObj.__asLiveParentWorldAngle = obj.angle ?? 0;
14907
+ if (Number.isFinite(liveW)) childObj.__asLiveFinalW = liveW;
14908
+ if (Number.isFinite(liveH)) childObj.__asLiveFinalH = liveH;
14909
+ } catch {
14910
+ }
14911
+ };
14896
14912
  if (isXSide && ((_i = groupShiftReflowSnapshotRef.current) == null ? void 0 : _i.selection) !== obj) {
14897
14913
  groupShiftReflowSnapshotRef.current = null;
14898
14914
  const logicalGroupId = obj.__pixldocsGroupSelection;
@@ -14933,13 +14949,45 @@ const PageCanvas = react.forwardRef(
14933
14949
  if (child.__asLiveGestureKey !== liveGestureKey) {
14934
14950
  child.__asLiveGestureKey = liveGestureKey;
14935
14951
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14952
+ child.__asLiveOrigFlipX = !!child.flipX;
14953
+ child.__asLiveOrigFlipY = !!child.flipY;
14936
14954
  }
14937
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14938
- child.setCoords();
14939
- child.dirty = true;
14940
- continue;
14941
- }
14942
- if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
14955
+ const liveAsSx = isXSide ? sAxis : 1;
14956
+ const liveAsSy = isXSide ? 1 : sAxis;
14957
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup)) || child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
14958
+ const childAngleDeg2 = child.__asLiveOrigAngle ?? (child.angle ?? 0);
14959
+ const theta2 = fabric__namespace.util.degreesToRadians(childAngleDeg2);
14960
+ const cosT2 = Math.cos(theta2);
14961
+ const sinT2 = Math.sin(theta2);
14962
+ const dX = isXSide ? Math.max(1e-3, liveAsSx * cosT2 * cosT2 + sinT2 * sinT2) : 1;
14963
+ const dY = isXSide ? 1 : Math.max(1e-3, liveAsSy * cosT2 * cosT2 + sinT2 * sinT2);
14964
+ if (child.__asLiveOrigScaleX == null) child.__asLiveOrigScaleX = Math.abs(Number(child.scaleX ?? 1)) || 1;
14965
+ if (child.__asLiveOrigScaleY == null) child.__asLiveOrigScaleY = Math.abs(Number(child.scaleY ?? 1)) || 1;
14966
+ const origScaleX = child.__asLiveOrigScaleX;
14967
+ const origScaleY = child.__asLiveOrigScaleY;
14968
+ const baseW = Math.max(1, Number(((_n = child.__cropData) == null ? void 0 : _n.frameW) ?? child.width ?? 1));
14969
+ const baseH = Math.max(1, Number(((_o = child.__cropData) == null ? void 0 : _o.frameH) ?? child.height ?? 1));
14970
+ const liveW = baseW * origScaleX * dX;
14971
+ const liveH = baseH * origScaleY * dY;
14972
+ try {
14973
+ const inv = [1 / liveAsSx, 0, 0, 1 / liveAsSy, 0, 0];
14974
+ const Rtheta = fabric__namespace.util.composeMatrix({ angle: childAngleDeg2, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0 });
14975
+ const Dscale = fabric__namespace.util.composeMatrix({ angle: 0, scaleX: origScaleX * dX, scaleY: origScaleY * dY, translateX: 0, translateY: 0 });
14976
+ const M = fabric__namespace.util.multiplyTransformMatrices(
14977
+ fabric__namespace.util.multiplyTransformMatrices(inv, Rtheta),
14978
+ Dscale
14979
+ );
14980
+ const dec = fabric__namespace.util.qrDecompose(M);
14981
+ child._set("angle", dec.angle);
14982
+ child._set("scaleX", dec.scaleX);
14983
+ child._set("scaleY", dec.scaleY);
14984
+ child._set("skewX", dec.skewX);
14985
+ child._set("skewY", dec.skewY);
14986
+ child._set("flipX", !!(child.__asLiveOrigFlipX ?? child.flipX));
14987
+ child._set("flipY", !!(child.__asLiveOrigFlipY ?? child.flipY));
14988
+ } catch {
14989
+ }
14990
+ captureAsLiveWorldSnapshot(child, liveW, liveH);
14943
14991
  child.setCoords();
14944
14992
  child.dirty = true;
14945
14993
  continue;
@@ -14997,7 +15045,7 @@ const PageCanvas = react.forwardRef(
14997
15045
  child.dirty = true;
14998
15046
  didReflowTextChild = true;
14999
15047
  }
15000
- if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15048
+ if (isXSide && ((_p = groupShiftReflowSnapshotRef.current) == null ? void 0 : _p.selection) === obj) {
15001
15049
  const snap = groupShiftReflowSnapshotRef.current;
15002
15050
  const anchorEntry = snap.children[0];
15003
15051
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15159,7 +15207,7 @@ const PageCanvas = react.forwardRef(
15159
15207
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15160
15208
  if (drilledGroupIdRef.current) {
15161
15209
  try {
15162
- (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15210
+ (_q = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _q.call(fabricCanvas);
15163
15211
  } catch {
15164
15212
  }
15165
15213
  }
@@ -15386,6 +15434,8 @@ const PageCanvas = react.forwardRef(
15386
15434
  for (const child of t.getObjects()) {
15387
15435
  delete child.__asLiveOrigW;
15388
15436
  delete child.__asLiveOrigH;
15437
+ delete child.__asLiveOrigScaleX;
15438
+ delete child.__asLiveOrigScaleY;
15389
15439
  delete child.__asLiveRotSnap;
15390
15440
  delete child.__asLiveGestureKey;
15391
15441
  }
@@ -16088,10 +16138,12 @@ const PageCanvas = react.forwardRef(
16088
16138
  const ownSy = Math.abs(obj.scaleY ?? 1);
16089
16139
  const bakedW = Math.max(1, intrinsicWidth * ownSx * (imgIsXSide ? sLocalI : 1));
16090
16140
  const bakedH = Math.max(1, intrinsicHeight * ownSy * (imgIsXSide ? 1 : sLocalI));
16141
+ const cleanW = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16142
+ const cleanH = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16091
16143
  try {
16092
16144
  obj.set({
16093
- width: bakedW,
16094
- height: bakedH,
16145
+ width: cleanW,
16146
+ height: cleanH,
16095
16147
  scaleX: 1,
16096
16148
  scaleY: 1,
16097
16149
  skewX: 0,
@@ -16110,8 +16162,8 @@ const PageCanvas = react.forwardRef(
16110
16162
  obj.setCoords();
16111
16163
  } catch {
16112
16164
  }
16113
- finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16114
- finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16165
+ finalWidth = cleanW;
16166
+ finalHeight = cleanH;
16115
16167
  finalScaleX = 1;
16116
16168
  finalScaleY = 1;
16117
16169
  const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
@@ -16533,6 +16585,12 @@ const PageCanvas = react.forwardRef(
16533
16585
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
16534
16586
  });
16535
16587
  }
16588
+ if (isActiveSelection && (obj instanceof fabric__namespace.FabricImage || obj instanceof fabric__namespace.Group && obj.__cropGroup)) {
16589
+ const restore = activeSelectionFlipRestores.find((entry) => entry.obj === obj);
16590
+ if (restore) {
16591
+ restore.angle = Number.isFinite(elementUpdate.angle) ? elementUpdate.angle : persistedAngle;
16592
+ }
16593
+ }
16536
16594
  if (isActiveSelection) {
16537
16595
  logRotGroupImageDrift("store-update-child", {
16538
16596
  time: Math.round(performance.now()),
@@ -16717,6 +16775,10 @@ const PageCanvas = react.forwardRef(
16717
16775
  if (t instanceof fabric__namespace.ActiveSelection) {
16718
16776
  for (const child of t.getObjects()) {
16719
16777
  delete child.__asLiveOrigAngle;
16778
+ delete child.__asLiveOrigFlipX;
16779
+ delete child.__asLiveOrigFlipY;
16780
+ delete child.__asLiveOrigScaleX;
16781
+ delete child.__asLiveOrigScaleY;
16720
16782
  delete child.__asLiveGestureKey;
16721
16783
  delete child.__asLiveWorldAngle;
16722
16784
  delete child.__asLiveWorldCenterX;
@@ -25827,9 +25889,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25827
25889
  }
25828
25890
  return svgString;
25829
25891
  }
25830
- const resolvedPackageVersion = "0.5.446";
25892
+ const resolvedPackageVersion = "0.5.447";
25831
25893
  const PACKAGE_VERSION = resolvedPackageVersion;
25832
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.446";
25894
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.447";
25833
25895
  const roundParityValue = (value) => {
25834
25896
  if (typeof value !== "number") return value;
25835
25897
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26643,7 +26705,7 @@ class PixldocsRenderer {
26643
26705
  await this.waitForCanvasScene(container, cloned, i);
26644
26706
  }
26645
26707
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26646
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D7WHhcGD.cjs"));
26708
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BVQkDFXD.cjs"));
26647
26709
  const prepared = preparePagesForExport(
26648
26710
  cloned.pages,
26649
26711
  canvasWidth,
@@ -28963,7 +29025,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28963
29025
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28964
29026
  sanitizeSvgTreeForPdf(svgToDraw);
28965
29027
  try {
28966
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D7WHhcGD.cjs"));
29028
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BVQkDFXD.cjs"));
28967
29029
  try {
28968
29030
  await logTextMeasurementDiagnostic(svgToDraw);
28969
29031
  } catch {
@@ -29360,4 +29422,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29360
29422
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29361
29423
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29362
29424
  exports.warmTemplateFromForm = warmTemplateFromForm;
29363
- //# sourceMappingURL=index-BAQIJf_b.cjs.map
29425
+ //# sourceMappingURL=index-D7JnQkpf.cjs.map