@pixldocs/canvas-renderer 0.5.276 → 0.5.278

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.
@@ -10494,6 +10494,10 @@ const SELECTION_PRIMARY = "hsl(217, 91%, 60%)";
10494
10494
  const SELECTION_BORDER_SCALE = 2;
10495
10495
  let ensureCanvaControlRenders = () => {
10496
10496
  };
10497
+ const shouldLogGroupMove = () => {
10498
+ if (typeof window === "undefined") return false;
10499
+ return window.__pixldocsDebugGroupMove !== false;
10500
+ };
10497
10501
  try {
10498
10502
  const InteractiveBase = fabric__namespace.InteractiveFabricObject ?? fabric__namespace.Object;
10499
10503
  if ((InteractiveBase == null ? void 0 : InteractiveBase.prototype) && !InteractiveBase.prototype.__pixldocsCenteredSelectionBorder) {
@@ -10943,20 +10947,31 @@ try {
10943
10947
  } catch (e) {
10944
10948
  }
10945
10949
  };
10946
- const origObj = cu.createObjectDefaultControls.bind(cu);
10947
- cu.createObjectDefaultControls = () => installPillRenders(origObj());
10948
- if (typeof cu.createTextboxDefaultControls === "function") {
10949
- const origTb = cu.createTextboxDefaultControls.bind(cu);
10950
- cu.createTextboxDefaultControls = () => installPillRenders(origTb());
10951
- }
10950
+ const tryPatchFactory = (target, key, bindTarget = target) => {
10951
+ try {
10952
+ if (!target || typeof target[key] !== "function") return;
10953
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
10954
+ if (descriptor && descriptor.writable === false && !descriptor.set) return;
10955
+ const original = target[key].bind(bindTarget);
10956
+ target[key] = () => installPillRenders(original());
10957
+ } catch {
10958
+ }
10959
+ };
10960
+ tryPatchFactory(cu, "createObjectDefaultControls");
10961
+ tryPatchFactory(cu, "createTextboxDefaultControls");
10952
10962
  const wrapClassCreateControls = (Klass) => {
10953
- if (!Klass || typeof Klass.createControls !== "function") return;
10954
- const orig = Klass.createControls.bind(Klass);
10955
- Klass.createControls = () => {
10956
- const res = orig();
10957
- if (res && res.controls) installPillRenders(res.controls);
10958
- return res;
10959
- };
10963
+ try {
10964
+ if (!Klass || typeof Klass.createControls !== "function") return;
10965
+ const descriptor = Object.getOwnPropertyDescriptor(Klass, "createControls");
10966
+ if (descriptor && descriptor.writable === false && !descriptor.set) return;
10967
+ const orig = Klass.createControls.bind(Klass);
10968
+ Klass.createControls = () => {
10969
+ const res = orig();
10970
+ if (res && res.controls) installPillRenders(res.controls);
10971
+ return res;
10972
+ };
10973
+ } catch {
10974
+ }
10960
10975
  };
10961
10976
  wrapClassCreateControls(fabric__namespace.InteractiveFabricObject);
10962
10977
  wrapClassCreateControls(fabric__namespace.FabricObject);
@@ -10979,8 +10994,7 @@ try {
10979
10994
  };
10980
10995
  }
10981
10996
  }
10982
- } catch (e) {
10983
- console.warn("[PageCanvas] Failed to install Canva-style control handles:", e);
10997
+ } catch {
10984
10998
  }
10985
10999
  const scaleTextPathConfig = (textPath, sx, sy, uniform) => {
10986
11000
  if (!textPath || typeof textPath !== "object") return textPath;
@@ -13907,14 +13921,24 @@ const PageCanvas = react.forwardRef(
13907
13921
  }
13908
13922
  });
13909
13923
  let cropGroupSaveTimer = null;
13924
+ let objectModifiedInFlight = false;
13910
13925
  fabricCanvas.on("object:modified", (e) => {
13911
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
13926
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
13927
+ if (objectModifiedInFlight) {
13928
+ if (shouldLogGroupMove()) {
13929
+ console.log("[GRP-MOVE] object:modified re-entry skipped", {
13930
+ targetType: (_b2 = (_a2 = e.target) == null ? void 0 : _a2.constructor) == null ? void 0 : _b2.name
13931
+ });
13932
+ }
13933
+ return;
13934
+ }
13935
+ objectModifiedInFlight = true;
13912
13936
  try {
13913
13937
  dragStarted = false;
13914
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove) {
13938
+ if (shouldLogGroupMove()) {
13915
13939
  const t = e.target;
13916
13940
  console.log("[GRP-MOVE] object:modified fired", {
13917
- targetType: (_a2 = t == null ? void 0 : t.constructor) == null ? void 0 : _a2.name,
13941
+ targetType: (_c = t == null ? void 0 : t.constructor) == null ? void 0 : _c.name,
13918
13942
  isActiveSelection: t instanceof fabric__namespace.ActiveSelection,
13919
13943
  groupSelectionId: t ? t.__pixldocsGroupSelection : null,
13920
13944
  memberIds: t instanceof fabric__namespace.ActiveSelection ? t.getObjects().map((o) => getObjectId(o)) : [getObjectId(t)],
@@ -13966,7 +13990,7 @@ const PageCanvas = react.forwardRef(
13966
13990
  const active = fabricCanvas.getActiveObject();
13967
13991
  const activeId = active ? getObjectId(active) : null;
13968
13992
  if (active && activeId && activeId !== "__background__" && !(active instanceof fabric__namespace.Group)) {
13969
- const pageChildrenForParent = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13993
+ const pageChildrenForParent = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13970
13994
  const parentGroup = findParentGroup(pageChildrenForParent, activeId);
13971
13995
  if (parentGroup && isGroup(parentGroup) && parentGroup.backgroundColor) {
13972
13996
  let fabricSectionGroup = active.group && active.group instanceof fabric__namespace.Group ? active.group : null;
@@ -14048,7 +14072,7 @@ const PageCanvas = react.forwardRef(
14048
14072
  useEditorStore.getState().reflowStackGroupInPage(pageId, groupId);
14049
14073
  }
14050
14074
  const stateAfter = useEditorStore.getState();
14051
- const pageAfter = ((_c = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
14075
+ const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14052
14076
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14053
14077
  if (groupNodeAfter) {
14054
14078
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14110,7 +14134,7 @@ const PageCanvas = react.forwardRef(
14110
14134
  }
14111
14135
  if (active && active instanceof fabric__namespace.Group && active.__docuforgeSectionGroup && getObjectId(active)) {
14112
14136
  const groupId = getObjectId(active);
14113
- const pageChildrenSec = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
14137
+ const pageChildrenSec = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
14114
14138
  const modifiedTarget2 = e == null ? void 0 : e.target;
14115
14139
  const resizeScaleTarget = lastResizeScaleTargetRef.current;
14116
14140
  lastResizeScaleTargetRef.current = null;
@@ -14141,7 +14165,7 @@ const PageCanvas = react.forwardRef(
14141
14165
  const node = findNodeById(pageChildrenSec, groupId);
14142
14166
  if (isChildModified && node && !groupMoved) {
14143
14167
  const stateAfter = useEditorStore.getState();
14144
- const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
14168
+ const pageAfter = ((_g = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _g.children) ?? [];
14145
14169
  const groupNodeAfter = findNodeById(pageAfter, groupId);
14146
14170
  if (groupNodeAfter) {
14147
14171
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -14157,7 +14181,7 @@ const PageCanvas = react.forwardRef(
14157
14181
  }
14158
14182
  if (active && active instanceof fabric__namespace.Group && !(active instanceof fabric__namespace.ActiveSelection) && getObjectId(active)) {
14159
14183
  const groupId = getObjectId(active);
14160
- const pageChildren3 = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
14184
+ const pageChildren3 = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14161
14185
  const w = (active.width ?? 0) * (active.scaleX ?? 1);
14162
14186
  const h = (active.height ?? 0) * (active.scaleY ?? 1);
14163
14187
  const centerX = active.left ?? 0;
@@ -14179,7 +14203,7 @@ const PageCanvas = react.forwardRef(
14179
14203
  }
14180
14204
  const activeObj = fabricCanvas.getActiveObject();
14181
14205
  let activeObjects = fabricCanvas.getActiveObjects();
14182
- const activeSelectionMoveStart = activeObj instanceof fabric__namespace.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14206
+ const activeSelectionMoveStart = activeObj instanceof fabric__namespace.ActiveSelection && ((_i = activeSelectionMoveStartRef.current) == null ? void 0 : _i.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
14183
14207
  const activeSelectionDelta = activeObj instanceof fabric__namespace.ActiveSelection && activeSelectionMoveStart ? (() => {
14184
14208
  const rect = activeObj.getBoundingRect();
14185
14209
  return {
@@ -14270,7 +14294,7 @@ const PageCanvas = react.forwardRef(
14270
14294
  return memberIds.every((mid) => selectedSet.has(mid));
14271
14295
  })();
14272
14296
  const groupToMove = candidateIsStack || allMembersSelected ? candidateGroup : null;
14273
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove) {
14297
+ if (shouldLogGroupMove()) {
14274
14298
  console.log("[GRP-MOVE] entry", {
14275
14299
  selectedElementIds,
14276
14300
  isActiveSelection,
@@ -14346,7 +14370,7 @@ const PageCanvas = react.forwardRef(
14346
14370
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14347
14371
  const newLeft = (groupToMove.left ?? 0) + deltaX;
14348
14372
  const newTop = (groupToMove.top ?? 0) + deltaY;
14349
- const __dbg = !!(typeof window !== "undefined" && window.__pixldocsDebugGroupMove);
14373
+ const __dbg = shouldLogGroupMove();
14350
14374
  if (__dbg) {
14351
14375
  console.log("[GRP-MOVE] commit", {
14352
14376
  groupId: groupToMove.id,
@@ -14379,7 +14403,7 @@ const PageCanvas = react.forwardRef(
14379
14403
  }
14380
14404
  } catch {
14381
14405
  }
14382
- const pageAfterMove = ((_h = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _h.children) ?? [];
14406
+ const pageAfterMove = ((_j = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
14383
14407
  const groupAfterMove = findNodeById(pageAfterMove, groupToMove.id);
14384
14408
  const memberIdsAfterMove = groupAfterMove && isGroup(groupAfterMove) ? getAllElementIds(groupAfterMove.children ?? []) : targetObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__");
14385
14409
  preservedGroupMemberIds = memberIdsAfterMove;
@@ -14398,7 +14422,7 @@ const PageCanvas = react.forwardRef(
14398
14422
  obj.set({ left: abs.left, top: abs.top });
14399
14423
  }
14400
14424
  obj.setCoords();
14401
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove) {
14425
+ if (shouldLogGroupMove()) {
14402
14426
  console.log("[GRP-MOVE] rebake-member", {
14403
14427
  id,
14404
14428
  nodeType: node.type,
@@ -14694,7 +14718,7 @@ const PageCanvas = react.forwardRef(
14694
14718
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
14695
14719
  obj.setCoords();
14696
14720
  }
14697
- const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
14721
+ const pageChildrenForReflow = ((_k = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _k.children) ?? [];
14698
14722
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
14699
14723
  for (const id of modifiedIdsThisRound) {
14700
14724
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -14763,6 +14787,8 @@ const PageCanvas = react.forwardRef(
14763
14787
  } catch (e2) {
14764
14788
  lastResizeScaleCornerRef.current = null;
14765
14789
  unlockEditsSoon();
14790
+ } finally {
14791
+ objectModifiedInFlight = false;
14766
14792
  }
14767
14793
  });
14768
14794
  fabricCanvas.on("before:selection:cleared", (e) => {
@@ -15652,7 +15678,7 @@ const PageCanvas = react.forwardRef(
15652
15678
  } else {
15653
15679
  const skipPositionBecauseSelection = preserveSelectionMemberPosition || !forceStorePositionSync && isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15654
15680
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15655
- if (typeof window !== "undefined" && window.__pixldocsDebugGroupMove && (forceStorePositionSync || preserveSelectionMemberPosition || (deltaX > 0.1 || deltaY > 0.1))) {
15681
+ if (shouldLogGroupMove() && (forceStorePositionSync || preserveSelectionMemberPosition || (deltaX > 0.1 || deltaY > 0.1))) {
15656
15682
  console.log("[GRP-MOVE] doSync-member", {
15657
15683
  id: element.id,
15658
15684
  type: element.type,
@@ -23855,9 +23881,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23855
23881
  }
23856
23882
  return svgString;
23857
23883
  }
23858
- const resolvedPackageVersion = "0.5.276";
23884
+ const resolvedPackageVersion = "0.5.278";
23859
23885
  const PACKAGE_VERSION = resolvedPackageVersion;
23860
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.276";
23886
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.278";
23861
23887
  const roundParityValue = (value) => {
23862
23888
  if (typeof value !== "number") return value;
23863
23889
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24671,7 +24697,7 @@ class PixldocsRenderer {
24671
24697
  await this.waitForCanvasScene(container, cloned, i);
24672
24698
  }
24673
24699
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24674
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CvLitjuI.cjs"));
24700
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-IKhMqJIE.cjs"));
24675
24701
  const prepared = preparePagesForExport(
24676
24702
  cloned.pages,
24677
24703
  canvasWidth,
@@ -26991,7 +27017,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26991
27017
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26992
27018
  sanitizeSvgTreeForPdf(svgToDraw);
26993
27019
  try {
26994
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CvLitjuI.cjs"));
27020
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-IKhMqJIE.cjs"));
26995
27021
  try {
26996
27022
  await logTextMeasurementDiagnostic(svgToDraw);
26997
27023
  } catch {
@@ -27388,4 +27414,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27388
27414
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27389
27415
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27390
27416
  exports.warmTemplateFromForm = warmTemplateFromForm;
27391
- //# sourceMappingURL=index-AzU8Pmse.cjs.map
27417
+ //# sourceMappingURL=index-C_w-eu19.cjs.map