@pixldocs/canvas-renderer 0.5.409 → 0.5.410

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.
@@ -4704,6 +4704,104 @@ const svgMaskApply = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
4704
4704
  syncSvgMaskClipPath
4705
4705
  }, Symbol.toStringTag, { value: "Module" }));
4706
4706
  const SELECTION_BORDER_SCALE$1 = 2;
4707
+ const ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX = "[Pixldocs][rotated-group-image-resize]";
4708
+ const ROTATED_GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES = 400;
4709
+ function isInsideRotatedActiveSelection(obj) {
4710
+ const parent = obj.group;
4711
+ if (!(parent instanceof fabric.ActiveSelection)) return false;
4712
+ const angle = Math.abs(((parent.angle ?? 0) % 360 + 360) % 360);
4713
+ return Math.min(angle, 360 - angle) > 0.5;
4714
+ }
4715
+ function summarizeResizeObject(obj) {
4716
+ var _a2, _b2, _c2, _d;
4717
+ if (!obj) return null;
4718
+ try {
4719
+ const matrix = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
4720
+ const decomp = matrix ? fabric.util.qrDecompose(matrix) : null;
4721
+ const rect = (_b2 = obj.getBoundingRect) == null ? void 0 : _b2.call(obj);
4722
+ const center = (_c2 = obj.getCenterPoint) == null ? void 0 : _c2.call(obj);
4723
+ return {
4724
+ type: obj.type ?? ((_d = obj.constructor) == null ? void 0 : _d.name),
4725
+ left: obj.left,
4726
+ top: obj.top,
4727
+ width: obj.width,
4728
+ height: obj.height,
4729
+ scaleX: obj.scaleX,
4730
+ scaleY: obj.scaleY,
4731
+ angle: obj.angle,
4732
+ originX: obj.originX,
4733
+ originY: obj.originY,
4734
+ centerX: center == null ? void 0 : center.x,
4735
+ centerY: center == null ? void 0 : center.y,
4736
+ brLeft: rect == null ? void 0 : rect.left,
4737
+ brTop: rect == null ? void 0 : rect.top,
4738
+ brWidth: rect == null ? void 0 : rect.width,
4739
+ brHeight: rect == null ? void 0 : rect.height,
4740
+ worldX: decomp == null ? void 0 : decomp.translateX,
4741
+ worldY: decomp == null ? void 0 : decomp.translateY,
4742
+ worldAngle: decomp == null ? void 0 : decomp.angle,
4743
+ worldScaleX: decomp == null ? void 0 : decomp.scaleX,
4744
+ worldScaleY: decomp == null ? void 0 : decomp.scaleY
4745
+ };
4746
+ } catch (error) {
4747
+ return { type: obj == null ? void 0 : obj.type, error: String(error) };
4748
+ }
4749
+ }
4750
+ function logRotatedGroupImageResize(phase, target, payload = {}) {
4751
+ if (typeof console === "undefined" || !isInsideRotatedActiveSelection(target)) return;
4752
+ try {
4753
+ const seen = /* @__PURE__ */ new WeakSet();
4754
+ const normalize = (value) => {
4755
+ if (value == null) return value;
4756
+ if (typeof value === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
4757
+ if (typeof value === "string" || typeof value === "boolean") return value;
4758
+ if (Array.isArray(value)) return value.map(normalize);
4759
+ if (typeof value === "object") {
4760
+ if (seen.has(value)) return "[Circular]";
4761
+ seen.add(value);
4762
+ if (value instanceof fabric.FabricObject) return normalize(summarizeResizeObject(value));
4763
+ const out = {};
4764
+ Object.entries(value).forEach(([key, entry]) => {
4765
+ out[key] = normalize(entry);
4766
+ });
4767
+ return out;
4768
+ }
4769
+ return String(value);
4770
+ };
4771
+ const debugTarget = target;
4772
+ const parent = debugTarget.group;
4773
+ const ct = debugTarget.__cropData;
4774
+ const start = debugTarget.__cornerResizeStart;
4775
+ const safeStart = start ? {
4776
+ corner: start.corner,
4777
+ angle: start.angle,
4778
+ baseW: start.baseW,
4779
+ baseH: start.baseH,
4780
+ anchorX: start.anchorX,
4781
+ anchorY: start.anchorY,
4782
+ signX: start.signX,
4783
+ signY: start.signY
4784
+ } : void 0;
4785
+ const line = `${ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalize({
4786
+ ...payload,
4787
+ target: summarizeResizeObject(target),
4788
+ parent: summarizeResizeObject(parent),
4789
+ frameW: ct == null ? void 0 : ct.frameW,
4790
+ frameH: ct == null ? void 0 : ct.frameH,
4791
+ img: summarizeResizeObject(ct == null ? void 0 : ct._img),
4792
+ snapshot: safeStart,
4793
+ lastPointer: debugTarget.__lastPointerForCrop
4794
+ }))}`;
4795
+ if (typeof window !== "undefined") {
4796
+ const debugWindow = window;
4797
+ debugWindow.__pixldocsRotatedGroupImageResizeLogs = Array.isArray(debugWindow.__pixldocsRotatedGroupImageResizeLogs) ? debugWindow.__pixldocsRotatedGroupImageResizeLogs.slice(-ROTATED_GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
4798
+ debugWindow.__pixldocsRotatedGroupImageResizeLogs.push(line);
4799
+ }
4800
+ console.log(line);
4801
+ } catch {
4802
+ console.log(ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX, phase, payload);
4803
+ }
4804
+ }
4707
4805
  function clamp$1(v, min, max) {
4708
4806
  return Math.max(min, Math.min(max, v));
4709
4807
  }
@@ -4950,9 +5048,20 @@ function getLocalDeltaStable(target, eventData) {
4950
5048
  const angle = fabric.util.degreesToRadians(getWorldAngleDeg(target));
4951
5049
  const cos = Math.cos(-angle);
4952
5050
  const sin = Math.sin(-angle);
5051
+ const localDx = dx * cos - dy * sin;
5052
+ const localDy = dx * sin + dy * cos;
5053
+ logRotatedGroupImageResize("side-delta", target, {
5054
+ pointer: p,
5055
+ previousPointer: last,
5056
+ canvasDx: dx,
5057
+ canvasDy: dy,
5058
+ worldAngle: getWorldAngleDeg(target),
5059
+ localDx,
5060
+ localDy
5061
+ });
4953
5062
  return {
4954
- localDx: dx * cos - dy * sin,
4955
- localDy: dx * sin + dy * cos
5063
+ localDx,
5064
+ localDy
4956
5065
  };
4957
5066
  }
4958
5067
  function worldDeltaToLocal(dx, dy, angleDeg) {
@@ -5073,6 +5182,14 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5073
5182
  signY: defaultSigns.y
5074
5183
  };
5075
5184
  g.__cornerResizeStart = snap;
5185
+ logRotatedGroupImageResize("corner-start", g, {
5186
+ corner,
5187
+ pointer,
5188
+ center,
5189
+ anchorLocal,
5190
+ anchorWorld,
5191
+ snapshot: snap
5192
+ });
5076
5193
  return snap;
5077
5194
  })();
5078
5195
  const localDelta = worldDeltaToLocal(pointer.x - snapshot.anchorX, pointer.y - snapshot.anchorY, snapshot.angle);
@@ -5085,6 +5202,19 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5085
5202
  const s = Math.min(scaleFromW, scaleFromH);
5086
5203
  const newW = Math.max(MIN_SIZE, snapshot.baseW * s);
5087
5204
  const newH = Math.max(MIN_SIZE, snapshot.baseH * s);
5205
+ logRotatedGroupImageResize("corner-tick-before-apply", g, {
5206
+ corner,
5207
+ pointer,
5208
+ angle,
5209
+ localDelta,
5210
+ rawW,
5211
+ rawH,
5212
+ scaleFromW,
5213
+ scaleFromH,
5214
+ uniformScale: s,
5215
+ newW,
5216
+ newH
5217
+ });
5088
5218
  ct.frameW = newW;
5089
5219
  ct.frameH = newH;
5090
5220
  const centerLocal = {
@@ -5095,6 +5225,12 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5095
5225
  setCenterFromWorld(g, snapshot.anchorX + centerWorld.x, snapshot.anchorY + centerWorld.y);
5096
5226
  g.set({ width: newW, height: newH });
5097
5227
  updateCoverLayout(g);
5228
+ logRotatedGroupImageResize("corner-tick-after-layout", g, {
5229
+ corner,
5230
+ centerLocal,
5231
+ centerWorld,
5232
+ targetWorldCenter: { x: snapshot.anchorX + centerWorld.x, y: snapshot.anchorY + centerWorld.y }
5233
+ });
5098
5234
  canvas.requestRenderAll();
5099
5235
  return true;
5100
5236
  }
@@ -5123,7 +5259,9 @@ function resizeFrameFromSide(g, side, localDx, localDy) {
5123
5259
  ct.frameH = Math.max(minSize, ct.frameH - localDy);
5124
5260
  moveCenterAlongLocalAxis(g, 0, localDy / 2);
5125
5261
  }
5262
+ logRotatedGroupImageResize("side-before-layout", g, { side, localDx, localDy });
5126
5263
  updateCoverLayout(g);
5264
+ logRotatedGroupImageResize("side-after-layout", g, { side, localDx, localDy });
5127
5265
  }
5128
5266
  function installCanvaMaskControls(g) {
5129
5267
  const ct = g.__cropData;
@@ -5140,9 +5278,16 @@ function installCanvaMaskControls(g) {
5140
5278
  };
5141
5279
  g.set(controlStyle);
5142
5280
  const notifyResizeSnap = (target, corner) => {
5143
- if (target.group instanceof fabric.ActiveSelection) return;
5281
+ if (target.group instanceof fabric.ActiveSelection) {
5282
+ logRotatedGroupImageResize("snap-skipped-active-selection-child", target, { corner });
5283
+ return;
5284
+ }
5144
5285
  const handler = target.__resizeSnapHandler;
5145
- if (typeof handler === "function") handler(target, corner);
5286
+ if (typeof handler === "function") {
5287
+ logRotatedGroupImageResize("snap-before", target, { corner });
5288
+ handler(target, corner);
5289
+ logRotatedGroupImageResize("snap-after", target, { corner });
5290
+ }
5146
5291
  };
5147
5292
  g.setControlsVisibility({
5148
5293
  mt: true,
@@ -11205,8 +11350,6 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11205
11350
  const value = Number(source == null ? void 0 : source[key]);
11206
11351
  if (Number.isFinite(value)) updates[key] = value * factor;
11207
11352
  };
11208
- const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
11209
- const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11210
11353
  const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11211
11354
  const summarizeFabricObjectForResizeDebug = (obj) => {
11212
11355
  var _a2;
@@ -11237,66 +11380,12 @@ const summarizeFabricObjectForResizeDebug = (obj) => {
11237
11380
  }
11238
11381
  };
11239
11382
  const logGroupTextResizeDebug = (phase, payload) => {
11240
- if (typeof console === "undefined") return;
11241
- try {
11242
- const seen = /* @__PURE__ */ new WeakSet();
11243
- const normalize = (value) => {
11244
- if (value == null) return value;
11245
- const valueType = typeof value;
11246
- if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11247
- if (valueType === "string" || valueType === "boolean") return value;
11248
- if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11249
- if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11250
- if (valueType === "object") {
11251
- if (seen.has(value)) return "[Circular]";
11252
- seen.add(value);
11253
- if (value instanceof fabric.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11254
- const output = {};
11255
- Object.entries(value).forEach(([key, entry]) => {
11256
- output[key] = normalize(entry);
11257
- });
11258
- return output;
11259
- }
11260
- return String(value);
11261
- };
11262
- const normalizedPayload = normalize(payload);
11263
- const line = `${GROUP_TEXT_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11264
- const debugWindow = window;
11265
- debugWindow.__pixldocsGroupTextResizeLogs = Array.isArray(debugWindow.__pixldocsGroupTextResizeLogs) ? debugWindow.__pixldocsGroupTextResizeLogs.slice(-GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11266
- debugWindow.__pixldocsGroupTextResizeLogs.push(line);
11267
- console.log(line);
11268
- } catch {
11269
- console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11270
- }
11383
+ return;
11271
11384
  };
11272
- const ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX = "[Pixldocs][rot-group-image-drift]";
11273
- const ROT_GROUP_IMAGE_DRIFT_DEBUG_MAX_ENTRIES = 500;
11274
11385
  const roundRotDriftNumber = (value) => {
11275
11386
  if (typeof value !== "number") return value;
11276
11387
  return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11277
11388
  };
11278
- const normalizeRotDriftPayload = (value) => {
11279
- const seen = /* @__PURE__ */ new WeakSet();
11280
- const normalize = (entry) => {
11281
- if (entry == null) return entry;
11282
- const valueType = typeof entry;
11283
- if (valueType === "number") return roundRotDriftNumber(entry);
11284
- if (valueType === "string" || valueType === "boolean") return entry;
11285
- if (Array.isArray(entry)) return entry.map((item) => normalize(item));
11286
- if (valueType === "object") {
11287
- if (seen.has(entry)) return "[Circular]";
11288
- seen.add(entry);
11289
- if (entry instanceof fabric.FabricObject) return normalize(summarizeRotDriftObject(entry));
11290
- const output = {};
11291
- Object.entries(entry).forEach(([key, item]) => {
11292
- output[key] = normalize(item);
11293
- });
11294
- return output;
11295
- }
11296
- return String(entry);
11297
- };
11298
- return normalize(value);
11299
- };
11300
11389
  const matrixForRotDriftLog = (matrix) => {
11301
11390
  if (!matrix) return void 0;
11302
11391
  return matrix.map((entry) => roundRotDriftNumber(entry));
@@ -11352,52 +11441,13 @@ const summarizeRotDriftObject = (obj, worldMatrix) => {
11352
11441
  }
11353
11442
  };
11354
11443
  const logRotGroupImageDrift = (phase, payload) => {
11355
- if (typeof console === "undefined") return;
11356
- try {
11357
- const line = `${ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizeRotDriftPayload(payload))}`;
11358
- if (typeof window !== "undefined") {
11359
- const debugWindow = window;
11360
- debugWindow.__pixldocsRotGroupImageDriftLogs = Array.isArray(debugWindow.__pixldocsRotGroupImageDriftLogs) ? debugWindow.__pixldocsRotGroupImageDriftLogs.slice(-ROT_GROUP_IMAGE_DRIFT_DEBUG_MAX_ENTRIES + 1) : [];
11361
- debugWindow.__pixldocsRotGroupImageDriftLogs.push(line);
11362
- }
11363
- console.log(line);
11364
- } catch {
11365
- console.log(ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX, phase, payload);
11366
- }
11444
+ return;
11367
11445
  };
11368
11446
  const shouldLogRotDriftLiveTick = (target, phase) => {
11369
- if (!target) return false;
11370
- const anyTarget = target;
11371
- const key = `__pixldocsRotDrift_${phase}_count`;
11372
- const count = (anyTarget[key] ?? 0) + 1;
11373
- anyTarget[key] = count;
11374
- return count <= 3 || count % 8 === 0;
11447
+ return false;
11375
11448
  };
11376
11449
  const logRotDriftSelectionSnapshot = (phase, target, extra = {}) => {
11377
- if (!target) return;
11378
- const anyTarget = target;
11379
- const kids = typeof anyTarget.getObjects === "function" ? anyTarget.getObjects() : [];
11380
- const selectionMatrix = target instanceof fabric.ActiveSelection ? target.calcTransformMatrix() : null;
11381
- logRotGroupImageDrift(phase, {
11382
- ...extra,
11383
- target: summarizeRotDriftObject(target),
11384
- childCount: kids.length,
11385
- groupSelectionId: anyTarget.__pixldocsGroupSelection,
11386
- alignedAngle: anyTarget.__pixldocsAlignedAngle
11387
- });
11388
- kids.forEach((kid, childIndex) => {
11389
- var _a2, _b2;
11390
- const childWorldMatrix = selectionMatrix ? fabric.util.multiplyTransformMatrices(
11391
- selectionMatrix,
11392
- kid.calcOwnMatrix()
11393
- ) : (_a2 = kid.calcTransformMatrix) == null ? void 0 : _a2.call(kid);
11394
- logRotGroupImageDrift(`${phase}-child`, {
11395
- ...extra,
11396
- childIndex,
11397
- parentType: anyTarget.type ?? ((_b2 = target.constructor) == null ? void 0 : _b2.name),
11398
- child: summarizeRotDriftObject(kid, childWorldMatrix ?? null)
11399
- });
11400
- });
11450
+ return;
11401
11451
  };
11402
11452
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11403
11453
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
@@ -13332,9 +13382,6 @@ const PageCanvas = forwardRef(
13332
13382
  };
13333
13383
  logRotDriftSelectionSnapshot("transform-start", active, {
13334
13384
  time: Math.round(performance.now()),
13335
- groupId,
13336
- groupAbs,
13337
- selectionRect: rect,
13338
13385
  transformStart: groupSelectionTransformStartRef.current,
13339
13386
  selectedStoreIds: useEditorStore.getState().canvas.selectedIds
13340
13387
  });
@@ -14241,7 +14288,7 @@ const PageCanvas = forwardRef(
14241
14288
  prepareGroupSelectionTransformStart(t);
14242
14289
  markTransforming(t);
14243
14290
  didTransformRef.current = true;
14244
- if (shouldLogRotDriftLiveTick(t, "scaling")) {
14291
+ if (shouldLogRotDriftLiveTick()) {
14245
14292
  logRotDriftSelectionSnapshot("scaling", t, {
14246
14293
  time: Math.round(performance.now()),
14247
14294
  corner: t == null ? void 0 : t.__corner,
@@ -14891,7 +14938,7 @@ const PageCanvas = forwardRef(
14891
14938
  didTransformRef.current = true;
14892
14939
  const tr = e.target;
14893
14940
  prepareGroupSelectionTransformStart(tr);
14894
- if (shouldLogRotDriftLiveTick(tr, "rotating")) {
14941
+ if (shouldLogRotDriftLiveTick()) {
14895
14942
  logRotDriftSelectionSnapshot("rotating", tr, {
14896
14943
  time: Math.round(performance.now()),
14897
14944
  transformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
@@ -14932,7 +14979,7 @@ const PageCanvas = forwardRef(
14932
14979
  prepareGroupSelectionTransformStart(e.target);
14933
14980
  markTransforming(e.target);
14934
14981
  didTransformRef.current = true;
14935
- if (shouldLogRotDriftLiveTick(e.target, "moving")) {
14982
+ if (shouldLogRotDriftLiveTick(e.target)) {
14936
14983
  logRotDriftSelectionSnapshot("moving", e.target, {
14937
14984
  time: Math.round(performance.now()),
14938
14985
  transformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
@@ -25204,9 +25251,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25204
25251
  }
25205
25252
  return svgString;
25206
25253
  }
25207
- const resolvedPackageVersion = "0.5.409";
25254
+ const resolvedPackageVersion = "0.5.410";
25208
25255
  const PACKAGE_VERSION = resolvedPackageVersion;
25209
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.409";
25256
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.410";
25210
25257
  const roundParityValue = (value) => {
25211
25258
  if (typeof value !== "number") return value;
25212
25259
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26020,7 +26067,7 @@ class PixldocsRenderer {
26020
26067
  await this.waitForCanvasScene(container, cloned, i);
26021
26068
  }
26022
26069
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26023
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BZbppXw8.js");
26070
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DE2UhH5g.js");
26024
26071
  const prepared = preparePagesForExport(
26025
26072
  cloned.pages,
26026
26073
  canvasWidth,
@@ -28340,7 +28387,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28340
28387
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28341
28388
  sanitizeSvgTreeForPdf(svgToDraw);
28342
28389
  try {
28343
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BZbppXw8.js");
28390
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DE2UhH5g.js");
28344
28391
  try {
28345
28392
  await logTextMeasurementDiagnostic(svgToDraw);
28346
28393
  } catch {
@@ -28740,4 +28787,4 @@ export {
28740
28787
  buildTeaserBlurFlatKeys as y,
28741
28788
  collectFontDescriptorsFromConfig as z
28742
28789
  };
28743
- //# sourceMappingURL=index-DAOxGNQt.js.map
28790
+ //# sourceMappingURL=index-CS_cFpCL.js.map