@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.
@@ -4722,6 +4722,104 @@ const svgMaskApply = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
4722
4722
  syncSvgMaskClipPath
4723
4723
  }, Symbol.toStringTag, { value: "Module" }));
4724
4724
  const SELECTION_BORDER_SCALE$1 = 2;
4725
+ const ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX = "[Pixldocs][rotated-group-image-resize]";
4726
+ const ROTATED_GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES = 400;
4727
+ function isInsideRotatedActiveSelection(obj) {
4728
+ const parent = obj.group;
4729
+ if (!(parent instanceof fabric__namespace.ActiveSelection)) return false;
4730
+ const angle = Math.abs(((parent.angle ?? 0) % 360 + 360) % 360);
4731
+ return Math.min(angle, 360 - angle) > 0.5;
4732
+ }
4733
+ function summarizeResizeObject(obj) {
4734
+ var _a2, _b2, _c2, _d;
4735
+ if (!obj) return null;
4736
+ try {
4737
+ const matrix = (_a2 = obj.calcTransformMatrix) == null ? void 0 : _a2.call(obj);
4738
+ const decomp = matrix ? fabric__namespace.util.qrDecompose(matrix) : null;
4739
+ const rect = (_b2 = obj.getBoundingRect) == null ? void 0 : _b2.call(obj);
4740
+ const center = (_c2 = obj.getCenterPoint) == null ? void 0 : _c2.call(obj);
4741
+ return {
4742
+ type: obj.type ?? ((_d = obj.constructor) == null ? void 0 : _d.name),
4743
+ left: obj.left,
4744
+ top: obj.top,
4745
+ width: obj.width,
4746
+ height: obj.height,
4747
+ scaleX: obj.scaleX,
4748
+ scaleY: obj.scaleY,
4749
+ angle: obj.angle,
4750
+ originX: obj.originX,
4751
+ originY: obj.originY,
4752
+ centerX: center == null ? void 0 : center.x,
4753
+ centerY: center == null ? void 0 : center.y,
4754
+ brLeft: rect == null ? void 0 : rect.left,
4755
+ brTop: rect == null ? void 0 : rect.top,
4756
+ brWidth: rect == null ? void 0 : rect.width,
4757
+ brHeight: rect == null ? void 0 : rect.height,
4758
+ worldX: decomp == null ? void 0 : decomp.translateX,
4759
+ worldY: decomp == null ? void 0 : decomp.translateY,
4760
+ worldAngle: decomp == null ? void 0 : decomp.angle,
4761
+ worldScaleX: decomp == null ? void 0 : decomp.scaleX,
4762
+ worldScaleY: decomp == null ? void 0 : decomp.scaleY
4763
+ };
4764
+ } catch (error) {
4765
+ return { type: obj == null ? void 0 : obj.type, error: String(error) };
4766
+ }
4767
+ }
4768
+ function logRotatedGroupImageResize(phase, target, payload = {}) {
4769
+ if (typeof console === "undefined" || !isInsideRotatedActiveSelection(target)) return;
4770
+ try {
4771
+ const seen = /* @__PURE__ */ new WeakSet();
4772
+ const normalize = (value) => {
4773
+ if (value == null) return value;
4774
+ if (typeof value === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
4775
+ if (typeof value === "string" || typeof value === "boolean") return value;
4776
+ if (Array.isArray(value)) return value.map(normalize);
4777
+ if (typeof value === "object") {
4778
+ if (seen.has(value)) return "[Circular]";
4779
+ seen.add(value);
4780
+ if (value instanceof fabric__namespace.FabricObject) return normalize(summarizeResizeObject(value));
4781
+ const out = {};
4782
+ Object.entries(value).forEach(([key, entry]) => {
4783
+ out[key] = normalize(entry);
4784
+ });
4785
+ return out;
4786
+ }
4787
+ return String(value);
4788
+ };
4789
+ const debugTarget = target;
4790
+ const parent = debugTarget.group;
4791
+ const ct = debugTarget.__cropData;
4792
+ const start = debugTarget.__cornerResizeStart;
4793
+ const safeStart = start ? {
4794
+ corner: start.corner,
4795
+ angle: start.angle,
4796
+ baseW: start.baseW,
4797
+ baseH: start.baseH,
4798
+ anchorX: start.anchorX,
4799
+ anchorY: start.anchorY,
4800
+ signX: start.signX,
4801
+ signY: start.signY
4802
+ } : void 0;
4803
+ const line = `${ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalize({
4804
+ ...payload,
4805
+ target: summarizeResizeObject(target),
4806
+ parent: summarizeResizeObject(parent),
4807
+ frameW: ct == null ? void 0 : ct.frameW,
4808
+ frameH: ct == null ? void 0 : ct.frameH,
4809
+ img: summarizeResizeObject(ct == null ? void 0 : ct._img),
4810
+ snapshot: safeStart,
4811
+ lastPointer: debugTarget.__lastPointerForCrop
4812
+ }))}`;
4813
+ if (typeof window !== "undefined") {
4814
+ const debugWindow = window;
4815
+ debugWindow.__pixldocsRotatedGroupImageResizeLogs = Array.isArray(debugWindow.__pixldocsRotatedGroupImageResizeLogs) ? debugWindow.__pixldocsRotatedGroupImageResizeLogs.slice(-ROTATED_GROUP_IMAGE_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
4816
+ debugWindow.__pixldocsRotatedGroupImageResizeLogs.push(line);
4817
+ }
4818
+ console.log(line);
4819
+ } catch {
4820
+ console.log(ROTATED_GROUP_IMAGE_RESIZE_DEBUG_PREFIX, phase, payload);
4821
+ }
4822
+ }
4725
4823
  function clamp$1(v, min, max) {
4726
4824
  return Math.max(min, Math.min(max, v));
4727
4825
  }
@@ -4968,9 +5066,20 @@ function getLocalDeltaStable(target, eventData) {
4968
5066
  const angle = fabric__namespace.util.degreesToRadians(getWorldAngleDeg(target));
4969
5067
  const cos = Math.cos(-angle);
4970
5068
  const sin = Math.sin(-angle);
5069
+ const localDx = dx * cos - dy * sin;
5070
+ const localDy = dx * sin + dy * cos;
5071
+ logRotatedGroupImageResize("side-delta", target, {
5072
+ pointer: p,
5073
+ previousPointer: last,
5074
+ canvasDx: dx,
5075
+ canvasDy: dy,
5076
+ worldAngle: getWorldAngleDeg(target),
5077
+ localDx,
5078
+ localDy
5079
+ });
4971
5080
  return {
4972
- localDx: dx * cos - dy * sin,
4973
- localDy: dx * sin + dy * cos
5081
+ localDx,
5082
+ localDy
4974
5083
  };
4975
5084
  }
4976
5085
  function worldDeltaToLocal(dx, dy, angleDeg) {
@@ -5091,6 +5200,14 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5091
5200
  signY: defaultSigns.y
5092
5201
  };
5093
5202
  g.__cornerResizeStart = snap;
5203
+ logRotatedGroupImageResize("corner-start", g, {
5204
+ corner,
5205
+ pointer,
5206
+ center,
5207
+ anchorLocal,
5208
+ anchorWorld,
5209
+ snapshot: snap
5210
+ });
5094
5211
  return snap;
5095
5212
  })();
5096
5213
  const localDelta = worldDeltaToLocal(pointer.x - snapshot.anchorX, pointer.y - snapshot.anchorY, snapshot.angle);
@@ -5103,6 +5220,19 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5103
5220
  const s = Math.min(scaleFromW, scaleFromH);
5104
5221
  const newW = Math.max(MIN_SIZE, snapshot.baseW * s);
5105
5222
  const newH = Math.max(MIN_SIZE, snapshot.baseH * s);
5223
+ logRotatedGroupImageResize("corner-tick-before-apply", g, {
5224
+ corner,
5225
+ pointer,
5226
+ angle,
5227
+ localDelta,
5228
+ rawW,
5229
+ rawH,
5230
+ scaleFromW,
5231
+ scaleFromH,
5232
+ uniformScale: s,
5233
+ newW,
5234
+ newH
5235
+ });
5106
5236
  ct.frameW = newW;
5107
5237
  ct.frameH = newH;
5108
5238
  const centerLocal = {
@@ -5113,6 +5243,12 @@ function resizeFrameFromCornerUniform(eventData, transform, _x, _y) {
5113
5243
  setCenterFromWorld(g, snapshot.anchorX + centerWorld.x, snapshot.anchorY + centerWorld.y);
5114
5244
  g.set({ width: newW, height: newH });
5115
5245
  updateCoverLayout(g);
5246
+ logRotatedGroupImageResize("corner-tick-after-layout", g, {
5247
+ corner,
5248
+ centerLocal,
5249
+ centerWorld,
5250
+ targetWorldCenter: { x: snapshot.anchorX + centerWorld.x, y: snapshot.anchorY + centerWorld.y }
5251
+ });
5116
5252
  canvas.requestRenderAll();
5117
5253
  return true;
5118
5254
  }
@@ -5141,7 +5277,9 @@ function resizeFrameFromSide(g, side, localDx, localDy) {
5141
5277
  ct.frameH = Math.max(minSize, ct.frameH - localDy);
5142
5278
  moveCenterAlongLocalAxis(g, 0, localDy / 2);
5143
5279
  }
5280
+ logRotatedGroupImageResize("side-before-layout", g, { side, localDx, localDy });
5144
5281
  updateCoverLayout(g);
5282
+ logRotatedGroupImageResize("side-after-layout", g, { side, localDx, localDy });
5145
5283
  }
5146
5284
  function installCanvaMaskControls(g) {
5147
5285
  const ct = g.__cropData;
@@ -5158,9 +5296,16 @@ function installCanvaMaskControls(g) {
5158
5296
  };
5159
5297
  g.set(controlStyle);
5160
5298
  const notifyResizeSnap = (target, corner) => {
5161
- if (target.group instanceof fabric__namespace.ActiveSelection) return;
5299
+ if (target.group instanceof fabric__namespace.ActiveSelection) {
5300
+ logRotatedGroupImageResize("snap-skipped-active-selection-child", target, { corner });
5301
+ return;
5302
+ }
5162
5303
  const handler = target.__resizeSnapHandler;
5163
- if (typeof handler === "function") handler(target, corner);
5304
+ if (typeof handler === "function") {
5305
+ logRotatedGroupImageResize("snap-before", target, { corner });
5306
+ handler(target, corner);
5307
+ logRotatedGroupImageResize("snap-after", target, { corner });
5308
+ }
5164
5309
  };
5165
5310
  g.setControlsVisibility({
5166
5311
  mt: true,
@@ -11223,8 +11368,6 @@ const scaleUpdateNumber = (updates, source, key, factor) => {
11223
11368
  const value = Number(source == null ? void 0 : source[key]);
11224
11369
  if (Number.isFinite(value)) updates[key] = value * factor;
11225
11370
  };
11226
- const GROUP_TEXT_RESIZE_DEBUG_PREFIX = "[Pixldocs][group-text-corner-resize]";
11227
- const GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES = 200;
11228
11371
  const isCornerResizeHandle = (handle) => handle === "tl" || handle === "tr" || handle === "bl" || handle === "br";
11229
11372
  const summarizeFabricObjectForResizeDebug = (obj) => {
11230
11373
  var _a2;
@@ -11255,66 +11398,12 @@ const summarizeFabricObjectForResizeDebug = (obj) => {
11255
11398
  }
11256
11399
  };
11257
11400
  const logGroupTextResizeDebug = (phase, payload) => {
11258
- if (typeof console === "undefined") return;
11259
- try {
11260
- const seen = /* @__PURE__ */ new WeakSet();
11261
- const normalize = (value) => {
11262
- if (value == null) return value;
11263
- const valueType = typeof value;
11264
- if (valueType === "number") return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11265
- if (valueType === "string" || valueType === "boolean") return value;
11266
- if (valueType === "function") return `[Function ${value.name || "anonymous"}]`;
11267
- if (Array.isArray(value)) return value.map((entry) => normalize(entry));
11268
- if (valueType === "object") {
11269
- if (seen.has(value)) return "[Circular]";
11270
- seen.add(value);
11271
- if (value instanceof fabric__namespace.FabricObject) return normalize(summarizeFabricObjectForResizeDebug(value));
11272
- const output = {};
11273
- Object.entries(value).forEach(([key, entry]) => {
11274
- output[key] = normalize(entry);
11275
- });
11276
- return output;
11277
- }
11278
- return String(value);
11279
- };
11280
- const normalizedPayload = normalize(payload);
11281
- const line = `${GROUP_TEXT_RESIZE_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizedPayload)}`;
11282
- const debugWindow = window;
11283
- debugWindow.__pixldocsGroupTextResizeLogs = Array.isArray(debugWindow.__pixldocsGroupTextResizeLogs) ? debugWindow.__pixldocsGroupTextResizeLogs.slice(-GROUP_TEXT_RESIZE_DEBUG_MAX_ENTRIES + 1) : [];
11284
- debugWindow.__pixldocsGroupTextResizeLogs.push(line);
11285
- console.log(line);
11286
- } catch {
11287
- console.log(GROUP_TEXT_RESIZE_DEBUG_PREFIX, phase, payload);
11288
- }
11401
+ return;
11289
11402
  };
11290
- const ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX = "[Pixldocs][rot-group-image-drift]";
11291
- const ROT_GROUP_IMAGE_DRIFT_DEBUG_MAX_ENTRIES = 500;
11292
11403
  const roundRotDriftNumber = (value) => {
11293
11404
  if (typeof value !== "number") return value;
11294
11405
  return Number.isFinite(value) ? Math.round(value * 1e3) / 1e3 : String(value);
11295
11406
  };
11296
- const normalizeRotDriftPayload = (value) => {
11297
- const seen = /* @__PURE__ */ new WeakSet();
11298
- const normalize = (entry) => {
11299
- if (entry == null) return entry;
11300
- const valueType = typeof entry;
11301
- if (valueType === "number") return roundRotDriftNumber(entry);
11302
- if (valueType === "string" || valueType === "boolean") return entry;
11303
- if (Array.isArray(entry)) return entry.map((item) => normalize(item));
11304
- if (valueType === "object") {
11305
- if (seen.has(entry)) return "[Circular]";
11306
- seen.add(entry);
11307
- if (entry instanceof fabric__namespace.FabricObject) return normalize(summarizeRotDriftObject(entry));
11308
- const output = {};
11309
- Object.entries(entry).forEach(([key, item]) => {
11310
- output[key] = normalize(item);
11311
- });
11312
- return output;
11313
- }
11314
- return String(entry);
11315
- };
11316
- return normalize(value);
11317
- };
11318
11407
  const matrixForRotDriftLog = (matrix) => {
11319
11408
  if (!matrix) return void 0;
11320
11409
  return matrix.map((entry) => roundRotDriftNumber(entry));
@@ -11370,52 +11459,13 @@ const summarizeRotDriftObject = (obj, worldMatrix) => {
11370
11459
  }
11371
11460
  };
11372
11461
  const logRotGroupImageDrift = (phase, payload) => {
11373
- if (typeof console === "undefined") return;
11374
- try {
11375
- const line = `${ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX} ${phase} ${JSON.stringify(normalizeRotDriftPayload(payload))}`;
11376
- if (typeof window !== "undefined") {
11377
- const debugWindow = window;
11378
- debugWindow.__pixldocsRotGroupImageDriftLogs = Array.isArray(debugWindow.__pixldocsRotGroupImageDriftLogs) ? debugWindow.__pixldocsRotGroupImageDriftLogs.slice(-ROT_GROUP_IMAGE_DRIFT_DEBUG_MAX_ENTRIES + 1) : [];
11379
- debugWindow.__pixldocsRotGroupImageDriftLogs.push(line);
11380
- }
11381
- console.log(line);
11382
- } catch {
11383
- console.log(ROT_GROUP_IMAGE_DRIFT_DEBUG_PREFIX, phase, payload);
11384
- }
11462
+ return;
11385
11463
  };
11386
11464
  const shouldLogRotDriftLiveTick = (target, phase) => {
11387
- if (!target) return false;
11388
- const anyTarget = target;
11389
- const key = `__pixldocsRotDrift_${phase}_count`;
11390
- const count = (anyTarget[key] ?? 0) + 1;
11391
- anyTarget[key] = count;
11392
- return count <= 3 || count % 8 === 0;
11465
+ return false;
11393
11466
  };
11394
11467
  const logRotDriftSelectionSnapshot = (phase, target, extra = {}) => {
11395
- if (!target) return;
11396
- const anyTarget = target;
11397
- const kids = typeof anyTarget.getObjects === "function" ? anyTarget.getObjects() : [];
11398
- const selectionMatrix = target instanceof fabric__namespace.ActiveSelection ? target.calcTransformMatrix() : null;
11399
- logRotGroupImageDrift(phase, {
11400
- ...extra,
11401
- target: summarizeRotDriftObject(target),
11402
- childCount: kids.length,
11403
- groupSelectionId: anyTarget.__pixldocsGroupSelection,
11404
- alignedAngle: anyTarget.__pixldocsAlignedAngle
11405
- });
11406
- kids.forEach((kid, childIndex) => {
11407
- var _a2, _b2;
11408
- const childWorldMatrix = selectionMatrix ? fabric__namespace.util.multiplyTransformMatrices(
11409
- selectionMatrix,
11410
- kid.calcOwnMatrix()
11411
- ) : (_a2 = kid.calcTransformMatrix) == null ? void 0 : _a2.call(kid);
11412
- logRotGroupImageDrift(`${phase}-child`, {
11413
- ...extra,
11414
- childIndex,
11415
- parentType: anyTarget.type ?? ((_b2 = target.constructor) == null ? void 0 : _b2.name),
11416
- child: summarizeRotDriftObject(kid, childWorldMatrix ?? null)
11417
- });
11418
- });
11468
+ return;
11419
11469
  };
11420
11470
  const bakeTextboxScaleIntoTypography = (obj, sourceElement) => {
11421
11471
  const sx = Math.abs(obj.scaleX ?? 1) || 1;
@@ -13350,9 +13400,6 @@ const PageCanvas = react.forwardRef(
13350
13400
  };
13351
13401
  logRotDriftSelectionSnapshot("transform-start", active, {
13352
13402
  time: Math.round(performance.now()),
13353
- groupId,
13354
- groupAbs,
13355
- selectionRect: rect,
13356
13403
  transformStart: groupSelectionTransformStartRef.current,
13357
13404
  selectedStoreIds: useEditorStore.getState().canvas.selectedIds
13358
13405
  });
@@ -14259,7 +14306,7 @@ const PageCanvas = react.forwardRef(
14259
14306
  prepareGroupSelectionTransformStart(t);
14260
14307
  markTransforming(t);
14261
14308
  didTransformRef.current = true;
14262
- if (shouldLogRotDriftLiveTick(t, "scaling")) {
14309
+ if (shouldLogRotDriftLiveTick()) {
14263
14310
  logRotDriftSelectionSnapshot("scaling", t, {
14264
14311
  time: Math.round(performance.now()),
14265
14312
  corner: t == null ? void 0 : t.__corner,
@@ -14909,7 +14956,7 @@ const PageCanvas = react.forwardRef(
14909
14956
  didTransformRef.current = true;
14910
14957
  const tr = e.target;
14911
14958
  prepareGroupSelectionTransformStart(tr);
14912
- if (shouldLogRotDriftLiveTick(tr, "rotating")) {
14959
+ if (shouldLogRotDriftLiveTick()) {
14913
14960
  logRotDriftSelectionSnapshot("rotating", tr, {
14914
14961
  time: Math.round(performance.now()),
14915
14962
  transformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
@@ -14950,7 +14997,7 @@ const PageCanvas = react.forwardRef(
14950
14997
  prepareGroupSelectionTransformStart(e.target);
14951
14998
  markTransforming(e.target);
14952
14999
  didTransformRef.current = true;
14953
- if (shouldLogRotDriftLiveTick(e.target, "moving")) {
15000
+ if (shouldLogRotDriftLiveTick(e.target)) {
14954
15001
  logRotDriftSelectionSnapshot("moving", e.target, {
14955
15002
  time: Math.round(performance.now()),
14956
15003
  transformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
@@ -25222,9 +25269,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25222
25269
  }
25223
25270
  return svgString;
25224
25271
  }
25225
- const resolvedPackageVersion = "0.5.409";
25272
+ const resolvedPackageVersion = "0.5.410";
25226
25273
  const PACKAGE_VERSION = resolvedPackageVersion;
25227
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.409";
25274
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.410";
25228
25275
  const roundParityValue = (value) => {
25229
25276
  if (typeof value !== "number") return value;
25230
25277
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -26038,7 +26085,7 @@ class PixldocsRenderer {
26038
26085
  await this.waitForCanvasScene(container, cloned, i);
26039
26086
  }
26040
26087
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
26041
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CI2YBgI3.cjs"));
26088
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BnnUwU40.cjs"));
26042
26089
  const prepared = preparePagesForExport(
26043
26090
  cloned.pages,
26044
26091
  canvasWidth,
@@ -28358,7 +28405,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28358
28405
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28359
28406
  sanitizeSvgTreeForPdf(svgToDraw);
28360
28407
  try {
28361
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CI2YBgI3.cjs"));
28408
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BnnUwU40.cjs"));
28362
28409
  try {
28363
28410
  await logTextMeasurementDiagnostic(svgToDraw);
28364
28411
  } catch {
@@ -28755,4 +28802,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28755
28802
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28756
28803
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28757
28804
  exports.warmTemplateFromForm = warmTemplateFromForm;
28758
- //# sourceMappingURL=index-DaL8UMXJ.cjs.map
28805
+ //# sourceMappingURL=index-xCnkRHXB.cjs.map