@pixldocs/canvas-renderer 0.5.275 → 0.5.277

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.
@@ -10476,6 +10476,10 @@ const SELECTION_PRIMARY = "hsl(217, 91%, 60%)";
10476
10476
  const SELECTION_BORDER_SCALE = 2;
10477
10477
  let ensureCanvaControlRenders = () => {
10478
10478
  };
10479
+ const shouldLogGroupMove = () => {
10480
+ if (typeof window === "undefined") return false;
10481
+ return window.__pixldocsDebugGroupMove !== false;
10482
+ };
10479
10483
  try {
10480
10484
  const InteractiveBase = fabric.InteractiveFabricObject ?? fabric.Object;
10481
10485
  if ((InteractiveBase == null ? void 0 : InteractiveBase.prototype) && !InteractiveBase.prototype.__pixldocsCenteredSelectionBorder) {
@@ -10925,20 +10929,31 @@ try {
10925
10929
  } catch (e) {
10926
10930
  }
10927
10931
  };
10928
- const origObj = cu.createObjectDefaultControls.bind(cu);
10929
- cu.createObjectDefaultControls = () => installPillRenders(origObj());
10930
- if (typeof cu.createTextboxDefaultControls === "function") {
10931
- const origTb = cu.createTextboxDefaultControls.bind(cu);
10932
- cu.createTextboxDefaultControls = () => installPillRenders(origTb());
10933
- }
10932
+ const tryPatchFactory = (target, key, bindTarget = target) => {
10933
+ try {
10934
+ if (!target || typeof target[key] !== "function") return;
10935
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
10936
+ if (descriptor && descriptor.writable === false && !descriptor.set) return;
10937
+ const original = target[key].bind(bindTarget);
10938
+ target[key] = () => installPillRenders(original());
10939
+ } catch {
10940
+ }
10941
+ };
10942
+ tryPatchFactory(cu, "createObjectDefaultControls");
10943
+ tryPatchFactory(cu, "createTextboxDefaultControls");
10934
10944
  const wrapClassCreateControls = (Klass) => {
10935
- if (!Klass || typeof Klass.createControls !== "function") return;
10936
- const orig = Klass.createControls.bind(Klass);
10937
- Klass.createControls = () => {
10938
- const res = orig();
10939
- if (res && res.controls) installPillRenders(res.controls);
10940
- return res;
10941
- };
10945
+ try {
10946
+ if (!Klass || typeof Klass.createControls !== "function") return;
10947
+ const descriptor = Object.getOwnPropertyDescriptor(Klass, "createControls");
10948
+ if (descriptor && descriptor.writable === false && !descriptor.set) return;
10949
+ const orig = Klass.createControls.bind(Klass);
10950
+ Klass.createControls = () => {
10951
+ const res = orig();
10952
+ if (res && res.controls) installPillRenders(res.controls);
10953
+ return res;
10954
+ };
10955
+ } catch {
10956
+ }
10942
10957
  };
10943
10958
  wrapClassCreateControls(fabric.InteractiveFabricObject);
10944
10959
  wrapClassCreateControls(fabric.FabricObject);
@@ -10961,8 +10976,7 @@ try {
10961
10976
  };
10962
10977
  }
10963
10978
  }
10964
- } catch (e) {
10965
- console.warn("[PageCanvas] Failed to install Canva-style control handles:", e);
10979
+ } catch {
10966
10980
  }
10967
10981
  const scaleTextPathConfig = (textPath, sx, sy, uniform) => {
10968
10982
  if (!textPath || typeof textPath !== "object") return textPath;
@@ -13890,9 +13904,23 @@ const PageCanvas = forwardRef(
13890
13904
  });
13891
13905
  let cropGroupSaveTimer = null;
13892
13906
  fabricCanvas.on("object:modified", (e) => {
13893
- var _a2, _b2, _c, _d, _e, _f, _g, _h;
13907
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13894
13908
  try {
13895
13909
  dragStarted = false;
13910
+ if (shouldLogGroupMove()) {
13911
+ const t = e.target;
13912
+ console.log("[GRP-MOVE] object:modified fired", {
13913
+ targetType: (_a2 = t == null ? void 0 : t.constructor) == null ? void 0 : _a2.name,
13914
+ isActiveSelection: t instanceof fabric.ActiveSelection,
13915
+ groupSelectionId: t ? t.__pixldocsGroupSelection : null,
13916
+ memberIds: t instanceof fabric.ActiveSelection ? t.getObjects().map((o) => getObjectId(o)) : [getObjectId(t)],
13917
+ targetLeft: t == null ? void 0 : t.left,
13918
+ targetTop: t == null ? void 0 : t.top,
13919
+ scaleX: t == null ? void 0 : t.scaleX,
13920
+ scaleY: t == null ? void 0 : t.scaleY,
13921
+ angle: t == null ? void 0 : t.angle
13922
+ });
13923
+ }
13896
13924
  setGuides([]);
13897
13925
  setGroupOverlayLiveBoundsRef.current(null);
13898
13926
  objectResizeActiveSnapRef.current = null;
@@ -13934,7 +13962,7 @@ const PageCanvas = forwardRef(
13934
13962
  const active = fabricCanvas.getActiveObject();
13935
13963
  const activeId = active ? getObjectId(active) : null;
13936
13964
  if (active && activeId && activeId !== "__background__" && !(active instanceof fabric.Group)) {
13937
- const pageChildrenForParent = ((_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
13965
+ const pageChildrenForParent = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13938
13966
  const parentGroup = findParentGroup(pageChildrenForParent, activeId);
13939
13967
  if (parentGroup && isGroup(parentGroup) && parentGroup.backgroundColor) {
13940
13968
  let fabricSectionGroup = active.group && active.group instanceof fabric.Group ? active.group : null;
@@ -14016,7 +14044,7 @@ const PageCanvas = forwardRef(
14016
14044
  useEditorStore.getState().reflowStackGroupInPage(pageId, groupId);
14017
14045
  }
14018
14046
  const stateAfter = useEditorStore.getState();
14019
- const pageAfter = ((_b2 = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
14047
+ const pageAfter = ((_c = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
14020
14048
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14021
14049
  if (groupNodeAfter) {
14022
14050
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14078,7 +14106,7 @@ const PageCanvas = forwardRef(
14078
14106
  }
14079
14107
  if (active && active instanceof fabric.Group && active.__docuforgeSectionGroup && getObjectId(active)) {
14080
14108
  const groupId = getObjectId(active);
14081
- const pageChildrenSec = ((_c = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
14109
+ const pageChildrenSec = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
14082
14110
  const modifiedTarget2 = e == null ? void 0 : e.target;
14083
14111
  const resizeScaleTarget = lastResizeScaleTargetRef.current;
14084
14112
  lastResizeScaleTargetRef.current = null;
@@ -14109,7 +14137,7 @@ const PageCanvas = forwardRef(
14109
14137
  const node = findNodeById(pageChildrenSec, groupId);
14110
14138
  if (isChildModified && node && !groupMoved) {
14111
14139
  const stateAfter = useEditorStore.getState();
14112
- const pageAfter = ((_d = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
14140
+ const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14113
14141
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14114
14142
  if (groupNodeAfter) {
14115
14143
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14125,7 +14153,7 @@ const PageCanvas = forwardRef(
14125
14153
  }
14126
14154
  if (active && active instanceof fabric.Group && !(active instanceof fabric.ActiveSelection) && getObjectId(active)) {
14127
14155
  const groupId = getObjectId(active);
14128
- const pageChildren3 = ((_e = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14156
+ const pageChildren3 = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
14129
14157
  const w = (active.width ?? 0) * (active.scaleX ?? 1);
14130
14158
  const h = (active.height ?? 0) * (active.scaleY ?? 1);
14131
14159
  const centerX = active.left ?? 0;
@@ -14147,7 +14175,7 @@ const PageCanvas = forwardRef(
14147
14175
  }
14148
14176
  const activeObj = fabricCanvas.getActiveObject();
14149
14177
  let activeObjects = fabricCanvas.getActiveObjects();
14150
- const activeSelectionMoveStart = activeObj instanceof fabric.ActiveSelection && ((_f = activeSelectionMoveStartRef.current) == null ? void 0 : _f.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14178
+ const activeSelectionMoveStart = activeObj instanceof fabric.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14151
14179
  const activeSelectionDelta = activeObj instanceof fabric.ActiveSelection && activeSelectionMoveStart ? (() => {
14152
14180
  const rect = activeObj.getBoundingRect();
14153
14181
  return {
@@ -14238,6 +14266,22 @@ const PageCanvas = forwardRef(
14238
14266
  return memberIds.every((mid) => selectedSet.has(mid));
14239
14267
  })();
14240
14268
  const groupToMove = candidateIsStack || allMembersSelected ? candidateGroup : null;
14269
+ if (shouldLogGroupMove()) {
14270
+ console.log("[GRP-MOVE] entry", {
14271
+ selectedElementIds,
14272
+ isActiveSelection,
14273
+ activeSelectionGroupId: activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : null,
14274
+ parentGroupIds: parentGroups.map((g) => g.id),
14275
+ sameDirectParent,
14276
+ commonAncestorId: commonAncestor == null ? void 0 : commonAncestor.id,
14277
+ candidateGroupId: candidateGroup == null ? void 0 : candidateGroup.id,
14278
+ candidateIsStack,
14279
+ allMembersSelected,
14280
+ groupToMoveId: (groupToMove == null ? void 0 : groupToMove.id) ?? null,
14281
+ activeSelectionHadTransform,
14282
+ selectedLogicalGroupIds
14283
+ });
14284
+ }
14241
14285
  if (groupToMove) {
14242
14286
  const activeGroupSelectionId = activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0;
14243
14287
  const transformStart = activeGroupSelectionId === groupToMove.id ? groupSelectionTransformStartRef.current : null;
@@ -14298,7 +14342,7 @@ const PageCanvas = forwardRef(
14298
14342
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14299
14343
  const newLeft = (groupToMove.left ?? 0) + deltaX;
14300
14344
  const newTop = (groupToMove.top ?? 0) + deltaY;
14301
- const __dbg = !!(typeof window !== "undefined" && window.__pixldocsDebugGroupMove);
14345
+ const __dbg = shouldLogGroupMove();
14302
14346
  if (__dbg) {
14303
14347
  console.log("[GRP-MOVE] commit", {
14304
14348
  groupId: groupToMove.id,
@@ -14331,7 +14375,7 @@ const PageCanvas = forwardRef(
14331
14375
  }
14332
14376
  } catch {
14333
14377
  }
14334
- const pageAfterMove = ((_g = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _g.children) ?? [];
14378
+ const pageAfterMove = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14335
14379
  const groupAfterMove = findNodeById(pageAfterMove, groupToMove.id);
14336
14380
  const memberIdsAfterMove = groupAfterMove && isGroup(groupAfterMove) ? getAllElementIds(groupAfterMove.children ?? []) : targetObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
14337
14381
  preservedGroupMemberIds = memberIdsAfterMove;
@@ -14350,7 +14394,7 @@ const PageCanvas = forwardRef(
14350
14394
  obj.set({ left: abs.left, top: abs.top });
14351
14395
  }
14352
14396
  obj.setCoords();
14353
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove) {
14397
+ if (shouldLogGroupMove()) {
14354
14398
  console.log("[GRP-MOVE] rebake-member", {
14355
14399
  id,
14356
14400
  nodeType: node.type,
@@ -14646,7 +14690,7 @@ const PageCanvas = forwardRef(
14646
14690
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14647
14691
  obj.setCoords();
14648
14692
  }
14649
- const pageChildrenForReflow = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14693
+ const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14650
14694
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14651
14695
  for (const id of modifiedIdsThisRound) {
14652
14696
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -15604,7 +15648,7 @@ const PageCanvas = forwardRef(
15604
15648
  } else {
15605
15649
  const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15606
15650
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15607
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove && (forceStorePositionSync || preserveSelectionMemberPosition || (deltaX > 0.1 || deltaY > 0.1))) {
15651
+ if (shouldLogGroupMove() && (forceStorePositionSync || preserveSelectionMemberPosition || (deltaX > 0.1 || deltaY > 0.1))) {
15608
15652
  console.log("[GRP-MOVE] doSync-member", {
15609
15653
  id: element.id,
15610
15654
  type: element.type,
@@ -23807,9 +23851,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23807
23851
  }
23808
23852
  return svgString;
23809
23853
  }
23810
- const resolvedPackageVersion = "0.5.275";
23854
+ const resolvedPackageVersion = "0.5.277";
23811
23855
  const PACKAGE_VERSION = resolvedPackageVersion;
23812
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.275";
23856
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.277";
23813
23857
  const roundParityValue = (value) => {
23814
23858
  if (typeof value !== "number") return value;
23815
23859
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24623,7 +24667,7 @@ class PixldocsRenderer {
24623
24667
  await this.waitForCanvasScene(container, cloned, i);
24624
24668
  }
24625
24669
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24626
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CZa1TypE.js");
24670
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CateNrsD.js");
24627
24671
  const prepared = preparePagesForExport(
24628
24672
  cloned.pages,
24629
24673
  canvasWidth,
@@ -26943,7 +26987,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26943
26987
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26944
26988
  sanitizeSvgTreeForPdf(svgToDraw);
26945
26989
  try {
26946
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CZa1TypE.js");
26990
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CateNrsD.js");
26947
26991
  try {
26948
26992
  await logTextMeasurementDiagnostic(svgToDraw);
26949
26993
  } catch {
@@ -27343,4 +27387,4 @@ export {
27343
27387
  buildTeaserBlurFlatKeys as y,
27344
27388
  collectFontDescriptorsFromConfig as z
27345
27389
  };
27346
- //# sourceMappingURL=index-Cs7F2355.js.map
27390
+ //# sourceMappingURL=index-uuizjIPx.js.map