@pixldocs/canvas-renderer 0.5.378 → 0.5.379

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.
@@ -10836,6 +10836,28 @@ try {
10836
10836
  if (atLeftRight && atTopBottom) return `${y < 0 ? "t" : "b"}${x < 0 ? "l" : "r"}`;
10837
10837
  return null;
10838
10838
  };
10839
+ const isRotateControl = (control, controlKey) => {
10840
+ const actionName = String((control == null ? void 0 : control.actionName) ?? "");
10841
+ return controlKey === "mtr" || actionName === "rotate" || Math.abs(Number((control == null ? void 0 : control.x) ?? 0)) < 1e-3 && Math.abs(Number((control == null ? void 0 : control.y) ?? 0) + 0.5) < 1e-3 && Number((control == null ? void 0 : control.offsetY) ?? 0) < 0;
10842
+ };
10843
+ const resolveCanvaControlCursor = (fabricObject, controlKey, control) => {
10844
+ if (!fabricObject) return null;
10845
+ const key = typeof controlKey === "string" ? controlKey : null;
10846
+ const resolvedControl = control ?? (key && (fabricObject == null ? void 0 : fabricObject.controls) ? fabricObject.controls[key] : null);
10847
+ if (isRotateControl(resolvedControl, key)) return getRotateCursor(fabricObject);
10848
+ const resizeKey = key && baseAngleFor[key] !== void 0 ? key : inferControlKey(resolvedControl);
10849
+ return resizeKey && baseAngleFor[resizeKey] !== void 0 ? getRotatedCursor(resizeKey, fabricObject) : null;
10850
+ };
10851
+ const resolveCanvasControlCursor = (canvasLike, target) => {
10852
+ var _a2, _b2, _c2, _d, _e, _f;
10853
+ const transform = canvasLike == null ? void 0 : canvasLike._currentTransform;
10854
+ const fabricObject = target ?? (transform == null ? void 0 : transform.target) ?? ((_a2 = canvasLike == null ? void 0 : canvasLike.getActiveObject) == null ? void 0 : _a2.call(canvasLike));
10855
+ if (!fabricObject) return null;
10856
+ const key = typeof (transform == null ? void 0 : transform.corner) === "string" ? transform.corner : typeof fabricObject.__corner === "string" ? fabricObject.__corner : (_c2 = (_b2 = fabricObject.getActiveControl) == null ? void 0 : _b2.call(fabricObject)) == null ? void 0 : _c2.key;
10857
+ if (!key) return null;
10858
+ const control = ((_d = fabricObject.controls) == null ? void 0 : _d[key]) ?? ((_f = (_e = fabricObject.getActiveControl) == null ? void 0 : _e.call(fabricObject)) == null ? void 0 : _f.control);
10859
+ return resolveCanvaControlCursor(fabricObject, key, control);
10860
+ };
10839
10861
  const installPillRenders = (controls) => {
10840
10862
  var _a2;
10841
10863
  const MOVE_PATHS_2D = [
@@ -11020,13 +11042,14 @@ try {
11020
11042
  };
11021
11043
  ControlProto.__pixldocsCanvaRenderFallback = true;
11022
11044
  }
11023
- if (ControlProto && !ControlProto.__pixldocsCanvaCursorFallback) {
11024
- const originalCursorHandler = ControlProto.cursorStyleHandler;
11045
+ if (ControlProto && ControlProto.__pixldocsCanvaCursorFallbackVersion !== 2) {
11046
+ const originalCursorHandler = ControlProto.__pixldocsOriginalCursorStyleHandler ?? ControlProto.cursorStyleHandler;
11047
+ ControlProto.__pixldocsOriginalCursorStyleHandler = originalCursorHandler;
11025
11048
  ControlProto.cursorStyleHandler = function(eventData, control, fabricObject) {
11026
- const actionName = String(this.actionName ?? (control == null ? void 0 : control.actionName) ?? "");
11027
- const isRotateHandle = actionName === "rotate" || Math.abs(Number(this.x ?? (control == null ? void 0 : control.x) ?? 0)) < 1e-3 && Math.abs(Number(this.y ?? (control == null ? void 0 : control.y) ?? 0) + 0.5) < 1e-3 && Number(this.offsetY ?? (control == null ? void 0 : control.offsetY) ?? 0) < 0;
11028
- if (isRotateHandle) {
11029
- const cursor = getRotateCursor(fabricObject);
11049
+ const activeCorner = typeof (fabricObject == null ? void 0 : fabricObject.__corner) === "string" ? fabricObject.__corner : null;
11050
+ const key = activeCorner ?? inferControlKey(this) ?? inferControlKey(control);
11051
+ const cursor = resolveCanvaControlCursor(fabricObject, key, this ?? control);
11052
+ if (cursor) {
11030
11053
  try {
11031
11054
  const canvas = fabricObject == null ? void 0 : fabricObject.canvas;
11032
11055
  if (canvas) canvas.__pixldocsGetRotateCursor = getRotateCursor;
@@ -11036,17 +11059,13 @@ try {
11036
11059
  }
11037
11060
  return cursor;
11038
11061
  }
11039
- const activeCorner = typeof (fabricObject == null ? void 0 : fabricObject.__corner) === "string" ? fabricObject.__corner : null;
11040
- const key = activeCorner && baseAngleFor[activeCorner] !== void 0 ? activeCorner : inferControlKey(this) ?? inferControlKey(control);
11041
- if (key && baseAngleFor[key] !== void 0) {
11042
- return getRotatedCursor(key, fabricObject);
11043
- }
11044
11062
  if (typeof originalCursorHandler === "function") {
11045
11063
  return originalCursorHandler.call(this, eventData, control, fabricObject);
11046
11064
  }
11047
11065
  return this.cursorStyle || "default";
11048
11066
  };
11049
11067
  ControlProto.__pixldocsCanvaCursorFallback = true;
11068
+ ControlProto.__pixldocsCanvaCursorFallbackVersion = 2;
11050
11069
  }
11051
11070
  ensureCanvaControlRenders = (obj) => {
11052
11071
  try {
@@ -11081,18 +11100,25 @@ try {
11081
11100
  wrapClassCreateControls(fabric__namespace.ActiveSelection);
11082
11101
  wrapClassCreateControls(fabric__namespace.Group);
11083
11102
  const CanvasProto = (_c = fabric__namespace.Canvas) == null ? void 0 : _c.prototype;
11084
- if (CanvasProto && typeof CanvasProto._setCursorFromEvent === "function") {
11085
- const origSet = CanvasProto._setCursorFromEvent;
11103
+ if (CanvasProto && CanvasProto.__pixldocsCanvaSetCursorVersion !== 1 && typeof CanvasProto.setCursor === "function") {
11104
+ const origSetCursor = CanvasProto.__pixldocsOriginalSetCursor ?? CanvasProto.setCursor;
11105
+ CanvasProto.__pixldocsOriginalSetCursor = origSetCursor;
11106
+ CanvasProto.setCursor = function(value) {
11107
+ const cursor = resolveCanvasControlCursor(this);
11108
+ return origSetCursor.call(this, cursor || value);
11109
+ };
11110
+ CanvasProto.__pixldocsCanvaSetCursorVersion = 1;
11111
+ }
11112
+ if (CanvasProto && typeof CanvasProto._setCursorFromEvent === "function" && CanvasProto.__pixldocsCanvaCursorEventVersion !== 2) {
11113
+ const origSet = CanvasProto.__pixldocsOriginalSetCursorFromEvent ?? CanvasProto._setCursorFromEvent;
11114
+ CanvasProto.__pixldocsOriginalSetCursorFromEvent = origSet;
11086
11115
  CanvasProto._setCursorFromEvent = function(e, target) {
11087
11116
  const prev = target && target.__corner;
11088
11117
  const res = origSet.call(this, e, target);
11089
11118
  const next = target && target.__corner;
11090
11119
  try {
11091
11120
  const control = next && (target == null ? void 0 : target.controls) ? target.controls[next] : null;
11092
- const actionName = String((control == null ? void 0 : control.actionName) ?? "");
11093
- const isRotateHandle = next === "mtr" || actionName === "rotate" || control && Math.abs(Number(control.x ?? 0)) < 1e-3 && Math.abs(Number(control.y ?? 0) + 0.5) < 1e-3 && Number(control.offsetY ?? 0) < 0;
11094
- const key = typeof next === "string" && baseAngleFor[next] !== void 0 ? next : inferControlKey(control);
11095
- const cursor = isRotateHandle ? getRotateCursor(target) : key ? getRotatedCursor(key, target) : null;
11121
+ const cursor = resolveCanvaControlCursor(target, typeof next === "string" ? next : null, control);
11096
11122
  if (cursor) {
11097
11123
  if (typeof this.setCursor === "function") this.setCursor(cursor);
11098
11124
  else if (this.upperCanvasEl) this.upperCanvasEl.style.cursor = cursor;
@@ -11107,6 +11133,7 @@ try {
11107
11133
  }
11108
11134
  return res;
11109
11135
  };
11136
+ CanvasProto.__pixldocsCanvaCursorEventVersion = 2;
11110
11137
  }
11111
11138
  }
11112
11139
  } catch (e) {
@@ -24781,9 +24808,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24781
24808
  }
24782
24809
  return svgString;
24783
24810
  }
24784
- const resolvedPackageVersion = "0.5.378";
24811
+ const resolvedPackageVersion = "0.5.379";
24785
24812
  const PACKAGE_VERSION = resolvedPackageVersion;
24786
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.378";
24813
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.379";
24787
24814
  const roundParityValue = (value) => {
24788
24815
  if (typeof value !== "number") return value;
24789
24816
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25597,7 +25624,7 @@ class PixldocsRenderer {
25597
25624
  await this.waitForCanvasScene(container, cloned, i);
25598
25625
  }
25599
25626
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25600
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BShYUaFY.cjs"));
25627
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-C1UzGCn0.cjs"));
25601
25628
  const prepared = preparePagesForExport(
25602
25629
  cloned.pages,
25603
25630
  canvasWidth,
@@ -27917,7 +27944,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27917
27944
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27918
27945
  sanitizeSvgTreeForPdf(svgToDraw);
27919
27946
  try {
27920
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BShYUaFY.cjs"));
27947
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-C1UzGCn0.cjs"));
27921
27948
  try {
27922
27949
  await logTextMeasurementDiagnostic(svgToDraw);
27923
27950
  } catch {
@@ -28314,4 +28341,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28314
28341
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28315
28342
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28316
28343
  exports.warmTemplateFromForm = warmTemplateFromForm;
28317
- //# sourceMappingURL=index-DHsYlRj5.cjs.map
28344
+ //# sourceMappingURL=index-D_l8rDHU.cjs.map