@pixldocs/canvas-renderer 0.5.445 → 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.
@@ -11682,7 +11682,7 @@ const applyTransformPreservingFlip = (obj, matrix) => {
11682
11682
  const restorePersistedFlipState = (obj, flipX, flipY, angle) => {
11683
11683
  const sx = Math.abs(Number(obj.scaleX ?? 1)) || 1;
11684
11684
  const sy = Math.abs(Number(obj.scaleY ?? 1)) || 1;
11685
- obj.set({ scaleX: sx, scaleY: sy, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11685
+ obj.set({ scaleX: sx, scaleY: sy, skewX: 0, skewY: 0, flipX, flipY, ...Number.isFinite(angle) ? { angle } : {} });
11686
11686
  obj.setCoords();
11687
11687
  obj.dirty = true;
11688
11688
  };
@@ -11793,11 +11793,16 @@ function applyWarpAwareSelectionBorders(selection) {
11793
11793
  selection.calcTransformMatrix()
11794
11794
  );
11795
11795
  kids.forEach((k, index) => {
11796
+ var _a3;
11796
11797
  const beforeRestore = summarizeRotDriftObject(k);
11797
11798
  const localMatrix = fabric__namespace.util.multiplyTransformMatrices(
11798
11799
  invSelection,
11799
11800
  worldMatrices[index]
11800
11801
  );
11802
+ const isImageLikeKid = k instanceof fabric__namespace.FabricImage || k instanceof fabric__namespace.Group && (k.__cropGroup || ((_a3 = k._ct) == null ? void 0 : _a3.isCropGroup));
11803
+ const persistedKidFlipX = !!k.flipX;
11804
+ const persistedKidFlipY = !!k.flipY;
11805
+ const expectedCleanKidAngle = isImageLikeKid && (persistedKidFlipX || persistedKidFlipY) ? fabric__namespace.util.qrDecompose(toggleLogicalFlipInMatrix(localMatrix, persistedKidFlipX, persistedKidFlipY)).angle ?? 0 : void 0;
11801
11806
  const savedLayout = k.layoutManager;
11802
11807
  try {
11803
11808
  if (savedLayout) k.layoutManager = void 0;
@@ -11807,6 +11812,9 @@ function applyWarpAwareSelectionBorders(selection) {
11807
11812
  );
11808
11813
  const expectedCenter = new fabric__namespace.Point(decomposed.translateX, decomposed.translateY);
11809
11814
  k.setPositionByOrigin(expectedCenter, "center", "center");
11815
+ if (isImageLikeKid && (persistedKidFlipX || persistedKidFlipY)) {
11816
+ restorePersistedFlipState(k, persistedKidFlipX, persistedKidFlipY, expectedCleanKidAngle);
11817
+ }
11810
11818
  } finally {
11811
11819
  if (savedLayout) k.layoutManager = savedLayout;
11812
11820
  }
@@ -14647,7 +14655,7 @@ const PageCanvas = react.forwardRef(
14647
14655
  fabricCanvas.on("selection:cleared", () => {
14648
14656
  });
14649
14657
  fabricCanvas.on("object:scaling", (e) => {
14650
- 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;
14651
14659
  if (!isActiveRef.current) return;
14652
14660
  const t = e.target;
14653
14661
  if (t) lastResizeScaleTargetRef.current = t;
@@ -14941,120 +14949,46 @@ const PageCanvas = react.forwardRef(
14941
14949
  if (child.__asLiveGestureKey !== liveGestureKey) {
14942
14950
  child.__asLiveGestureKey = liveGestureKey;
14943
14951
  child.__asLiveOrigAngle = Number.isFinite(child.angle) ? child.angle ?? 0 : 0;
14952
+ child.__asLiveOrigFlipX = !!child.flipX;
14953
+ child.__asLiveOrigFlipY = !!child.flipY;
14944
14954
  }
14945
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_m = child._ct) == null ? void 0 : _m.isCropGroup))) {
14946
- const ct = child.__cropData;
14947
- if (!ct) continue;
14948
- if (child.__asLiveOrigAngle == null) {
14949
- child.__asLiveOrigAngle = child.angle ?? 0;
14950
- }
14951
- const childAngleDegC = child.__asLiveOrigAngle;
14952
- const asSxC = isXSide ? sAxis : 1;
14953
- const asSyC = isXSide ? 1 : sAxis;
14954
- const thetaC = fabric__namespace.util.degreesToRadians(childAngleDegC);
14955
- const cosTC = Math.cos(thetaC);
14956
- const sinTC = Math.sin(thetaC);
14957
- const sLocalC = isXSide ? asSxC * cosTC * cosTC + sinTC * sinTC : asSyC * cosTC * cosTC + sinTC * sinTC;
14958
- if (isXSide) {
14959
- if (child.__asLiveOrigW == null) {
14960
- const baseW = child.width ?? ct.frameW ?? 0;
14961
- child.__asLiveOrigW = baseW * (child.scaleX ?? 1);
14962
- }
14963
- const origW = child.__asLiveOrigW;
14964
- const newW = Math.max(20, origW * sLocalC);
14965
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
14966
- ct.frameW = newW;
14967
- child._set("width", newW);
14968
- }
14969
- } else {
14970
- if (child.__asLiveOrigH == null) {
14971
- const baseH = child.height ?? ct.frameH ?? 0;
14972
- child.__asLiveOrigH = baseH * (child.scaleY ?? 1);
14973
- }
14974
- const origH = child.__asLiveOrigH;
14975
- const newH = Math.max(20, origH * sLocalC);
14976
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
14977
- ct.frameH = newH;
14978
- child._set("height", newH);
14979
- }
14980
- }
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;
14981
14972
  try {
14982
- const invC = [1 / asSxC, 0, 0, 1 / asSyC, 0, 0];
14983
- const RthetaC = fabric__namespace.util.composeMatrix({
14984
- angle: childAngleDegC,
14985
- scaleX: 1,
14986
- scaleY: 1,
14987
- translateX: 0,
14988
- translateY: 0
14989
- });
14990
- const MC = fabric__namespace.util.multiplyTransformMatrices(invC, RthetaC);
14991
- const decC = fabric__namespace.util.qrDecompose(MC);
14992
- child._set("angle", decC.angle);
14993
- child._set("scaleX", decC.scaleX);
14994
- child._set("scaleY", decC.scaleY);
14995
- child._set("skewX", decC.skewX);
14996
- child._set("skewY", decC.skewY);
14997
- } catch {
14998
- }
14999
- try {
15000
- updateCoverLayout(child);
15001
- } catch {
15002
- }
15003
- child.setCoords();
15004
- captureAsLiveWorldSnapshot(child, ct.frameW ?? child.width ?? 0, ct.frameH ?? child.height ?? 0);
15005
- child.dirty = true;
15006
- continue;
15007
- }
15008
- if (child instanceof fabric__namespace.FabricImage && !child.__cropGroup && !child.smartElementType) {
15009
- if (child.__asLiveOrigAngle == null) {
15010
- child.__asLiveOrigAngle = child.angle ?? 0;
15011
- }
15012
- const childAngleDegI = child.__asLiveOrigAngle;
15013
- const asSxI = isXSide ? sAxis : 1;
15014
- const asSyI = isXSide ? 1 : sAxis;
15015
- const thetaI = fabric__namespace.util.degreesToRadians(childAngleDegI);
15016
- const cosTI = Math.cos(thetaI);
15017
- const sinTI = Math.sin(thetaI);
15018
- const sLocalI = isXSide ? asSxI * cosTI * cosTI + sinTI * sinTI : asSyI * cosTI * cosTI + sinTI * sinTI;
15019
- if (isXSide) {
15020
- if (child.__asLiveOrigW == null) {
15021
- child.__asLiveOrigW = (child.width ?? 0) * (child.scaleX ?? 1);
15022
- }
15023
- const origW = child.__asLiveOrigW;
15024
- const newW = Math.max(1, origW * sLocalI);
15025
- if (Math.abs((child.width ?? 0) - newW) > 0.5) {
15026
- child._set("width", newW);
15027
- }
15028
- } else {
15029
- if (child.__asLiveOrigH == null) {
15030
- child.__asLiveOrigH = (child.height ?? 0) * (child.scaleY ?? 1);
15031
- }
15032
- const origH = child.__asLiveOrigH;
15033
- const newH = Math.max(1, origH * sLocalI);
15034
- if (Math.abs((child.height ?? 0) - newH) > 0.5) {
15035
- child._set("height", newH);
15036
- }
15037
- }
15038
- try {
15039
- const invI = [1 / asSxI, 0, 0, 1 / asSyI, 0, 0];
15040
- const RthetaI = fabric__namespace.util.composeMatrix({
15041
- angle: childAngleDegI,
15042
- scaleX: 1,
15043
- scaleY: 1,
15044
- translateX: 0,
15045
- translateY: 0
15046
- });
15047
- const MI = fabric__namespace.util.multiplyTransformMatrices(invI, RthetaI);
15048
- const decI = fabric__namespace.util.qrDecompose(MI);
15049
- child._set("angle", decI.angle);
15050
- child._set("scaleX", decI.scaleX);
15051
- child._set("scaleY", decI.scaleY);
15052
- child._set("skewX", decI.skewX);
15053
- child._set("skewY", decI.skewY);
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));
15054
14988
  } catch {
15055
14989
  }
14990
+ captureAsLiveWorldSnapshot(child, liveW, liveH);
15056
14991
  child.setCoords();
15057
- captureAsLiveWorldSnapshot(child, child.width ?? 0, child.height ?? 0);
15058
14992
  child.dirty = true;
15059
14993
  continue;
15060
14994
  }
@@ -15111,7 +15045,7 @@ const PageCanvas = react.forwardRef(
15111
15045
  child.dirty = true;
15112
15046
  didReflowTextChild = true;
15113
15047
  }
15114
- if (isXSide && ((_n = groupShiftReflowSnapshotRef.current) == null ? void 0 : _n.selection) === obj) {
15048
+ if (isXSide && ((_p = groupShiftReflowSnapshotRef.current) == null ? void 0 : _p.selection) === obj) {
15115
15049
  const snap = groupShiftReflowSnapshotRef.current;
15116
15050
  const anchorEntry = snap.children[0];
15117
15051
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -15273,7 +15207,7 @@ const PageCanvas = react.forwardRef(
15273
15207
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
15274
15208
  if (drilledGroupIdRef.current) {
15275
15209
  try {
15276
- (_o = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _o.call(fabricCanvas);
15210
+ (_q = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _q.call(fabricCanvas);
15277
15211
  } catch {
15278
15212
  }
15279
15213
  }
@@ -15500,6 +15434,8 @@ const PageCanvas = react.forwardRef(
15500
15434
  for (const child of t.getObjects()) {
15501
15435
  delete child.__asLiveOrigW;
15502
15436
  delete child.__asLiveOrigH;
15437
+ delete child.__asLiveOrigScaleX;
15438
+ delete child.__asLiveOrigScaleY;
15503
15439
  delete child.__asLiveRotSnap;
15504
15440
  delete child.__asLiveGestureKey;
15505
15441
  }
@@ -16202,10 +16138,12 @@ const PageCanvas = react.forwardRef(
16202
16138
  const ownSy = Math.abs(obj.scaleY ?? 1);
16203
16139
  const bakedW = Math.max(1, intrinsicWidth * ownSx * (imgIsXSide ? sLocalI : 1));
16204
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));
16205
16143
  try {
16206
16144
  obj.set({
16207
- width: bakedW,
16208
- height: bakedH,
16145
+ width: cleanW,
16146
+ height: cleanH,
16209
16147
  scaleX: 1,
16210
16148
  scaleY: 1,
16211
16149
  skewX: 0,
@@ -16224,8 +16162,8 @@ const PageCanvas = react.forwardRef(
16224
16162
  obj.setCoords();
16225
16163
  } catch {
16226
16164
  }
16227
- finalWidth = Math.max(1, Number(obj.__asLiveFinalW ?? bakedW));
16228
- finalHeight = Math.max(1, Number(obj.__asLiveFinalH ?? bakedH));
16165
+ finalWidth = cleanW;
16166
+ finalHeight = cleanH;
16229
16167
  finalScaleX = 1;
16230
16168
  finalScaleY = 1;
16231
16169
  const worldCx = Number.isFinite(obj.__asLiveWorldCenterX) ? obj.__asLiveWorldCenterX : decomposed.translateX ?? 0;
@@ -16647,6 +16585,12 @@ const PageCanvas = react.forwardRef(
16647
16585
  objectBeforeStoreWrite: summarizeFabricObjectForResizeDebug(obj)
16648
16586
  });
16649
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
+ }
16650
16594
  if (isActiveSelection) {
16651
16595
  logRotGroupImageDrift("store-update-child", {
16652
16596
  time: Math.round(performance.now()),
@@ -16831,6 +16775,10 @@ const PageCanvas = react.forwardRef(
16831
16775
  if (t instanceof fabric__namespace.ActiveSelection) {
16832
16776
  for (const child of t.getObjects()) {
16833
16777
  delete child.__asLiveOrigAngle;
16778
+ delete child.__asLiveOrigFlipX;
16779
+ delete child.__asLiveOrigFlipY;
16780
+ delete child.__asLiveOrigScaleX;
16781
+ delete child.__asLiveOrigScaleY;
16834
16782
  delete child.__asLiveGestureKey;
16835
16783
  delete child.__asLiveWorldAngle;
16836
16784
  delete child.__asLiveWorldCenterX;
@@ -25941,9 +25889,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25941
25889
  }
25942
25890
  return svgString;
25943
25891
  }
25944
- const resolvedPackageVersion = "0.5.445";
25892
+ const resolvedPackageVersion = "0.5.447";
25945
25893
  const PACKAGE_VERSION = resolvedPackageVersion;
25946
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.445";
25894
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.447";
25947
25895
  const roundParityValue = (value) => {
25948
25896
  if (typeof value !== "number") return value;
25949
25897
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26757,7 +26705,7 @@ class PixldocsRenderer {
26757
26705
  await this.waitForCanvasScene(container, cloned, i);
26758
26706
  }
26759
26707
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26760
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CuC9pjN_.cjs"));
26708
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BVQkDFXD.cjs"));
26761
26709
  const prepared = preparePagesForExport(
26762
26710
  cloned.pages,
26763
26711
  canvasWidth,
@@ -29077,7 +29025,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29077
29025
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29078
29026
  sanitizeSvgTreeForPdf(svgToDraw);
29079
29027
  try {
29080
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CuC9pjN_.cjs"));
29028
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BVQkDFXD.cjs"));
29081
29029
  try {
29082
29030
  await logTextMeasurementDiagnostic(svgToDraw);
29083
29031
  } catch {
@@ -29474,4 +29422,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29474
29422
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29475
29423
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29476
29424
  exports.warmTemplateFromForm = warmTemplateFromForm;
29477
- //# sourceMappingURL=index-BtExVWAT.cjs.map
29425
+ //# sourceMappingURL=index-D7JnQkpf.cjs.map