canvu-react 0.4.51 → 0.4.53

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.
package/dist/native.js CHANGED
@@ -3072,38 +3072,6 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
3072
3072
  };
3073
3073
  }
3074
3074
 
3075
- // src/native/native-stroke-preview.ts
3076
- var NATIVE_STROKE_PREVIEW_MAX_POINTS = 160;
3077
- function sampleNativeStrokePreviewPoints(points, maxPoints = NATIVE_STROKE_PREVIEW_MAX_POINTS) {
3078
- if (points.length <= maxPoints) return points.map((point) => ({ ...point }));
3079
- if (maxPoints <= 1) {
3080
- const last2 = points[points.length - 1];
3081
- return last2 ? [{ ...last2 }] : [];
3082
- }
3083
- const lastIndex = points.length - 1;
3084
- const last = points[lastIndex];
3085
- if (!last) return [];
3086
- const step = lastIndex / (maxPoints - 1);
3087
- return Array.from({ length: maxPoints }, (_, index) => {
3088
- const point = points[Math.round(index * step)] ?? last;
3089
- return { x: point.x, y: point.y };
3090
- });
3091
- }
3092
- function buildNativeStrokePreviewPath(points) {
3093
- if (points.length < 2) return null;
3094
- const d = smoothFreehandPointsToPathD(points);
3095
- return d || null;
3096
- }
3097
- function buildNativeFreehandStrokePreviewPayload(points, style, tool) {
3098
- if (tool === "laser") return null;
3099
- return computeFreehandSvgPayload(
3100
- points.map((point) => ({ x: point.x, y: point.y })),
3101
- style,
3102
- tool,
3103
- true
3104
- );
3105
- }
3106
-
3107
3075
  // src/native/native-vector-interactions.ts
3108
3076
  var NATIVE_SELECTION_HANDLE_HIT_RADIUS_PX = 24;
3109
3077
  function nativeItemPlacementBounds(item) {
@@ -3475,90 +3443,58 @@ function NativeInteractionOverlay({
3475
3443
  p.tool,
3476
3444
  p.style ?? previewStrokeStyle
3477
3445
  );
3478
- const strokeColor = colorWithOpacity(
3479
- style.stroke,
3480
- isLaser ? 0.85 : style.strokeOpacity
3446
+ const payload = computeFreehandSvgPayload(
3447
+ p.points,
3448
+ style,
3449
+ isLaser ? "draw" : p.tool,
3450
+ p.points.length === 2
3481
3451
  );
3482
- if (!isLaser) {
3483
- const payload = buildNativeFreehandStrokePreviewPayload(
3484
- p.points,
3485
- style,
3486
- p.tool
3452
+ if (!payload) return null;
3453
+ if (payload.kind === "circle") {
3454
+ return /* @__PURE__ */ jsx(
3455
+ Circle,
3456
+ {
3457
+ cx: payload.cx,
3458
+ cy: payload.cy,
3459
+ r: payload.r,
3460
+ color: colorWithOpacity(payload.fill, payload.fillOpacity),
3461
+ style: "fill",
3462
+ antiAlias: true
3463
+ }
3487
3464
  );
3488
- if (payload?.kind === "circle") {
3489
- return /* @__PURE__ */ jsx(
3490
- Circle,
3491
- {
3492
- cx: payload.cx,
3493
- cy: payload.cy,
3494
- r: payload.r,
3495
- color: colorWithOpacity(payload.fill, payload.fillOpacity),
3496
- style: "fill",
3497
- antiAlias: true
3498
- }
3499
- );
3500
- }
3501
- if (payload?.kind === "fillPath") {
3502
- return /* @__PURE__ */ jsx(
3503
- Path,
3504
- {
3505
- path: payload.d,
3506
- color: colorWithOpacity(payload.fill, payload.fillOpacity),
3507
- style: "fill",
3508
- fillType: "winding",
3509
- antiAlias: true
3510
- }
3511
- );
3512
- }
3513
- if (payload?.kind === "strokePath") {
3514
- const intervals = dashIntervalsFromStrokeDasharray3(
3515
- payload.strokeDasharray
3516
- );
3517
- return /* @__PURE__ */ jsx(
3518
- Path,
3519
- {
3520
- path: payload.d,
3521
- color: colorWithOpacity(payload.stroke, payload.strokeOpacity),
3522
- style: "stroke",
3523
- strokeWidth: payload.strokeWidth,
3524
- strokeCap: "round",
3525
- strokeJoin: "round",
3526
- antiAlias: true,
3527
- children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
3528
- }
3529
- );
3530
- }
3531
- return null;
3532
3465
  }
3533
- if (p.points.length === 1) {
3534
- const point = p.points[0];
3535
- if (!point) return null;
3466
+ if (payload.kind === "fillPath") {
3536
3467
  return /* @__PURE__ */ jsx(
3537
- Circle,
3468
+ Path,
3538
3469
  {
3539
- cx: point.x,
3540
- cy: point.y,
3541
- r: Math.max(0.5, style.strokeWidth / 2),
3542
- color: strokeColor,
3470
+ path: payload.d,
3471
+ color: colorWithOpacity(payload.fill, payload.fillOpacity),
3543
3472
  style: "fill",
3473
+ fillType: "winding",
3544
3474
  antiAlias: true
3545
3475
  }
3546
3476
  );
3547
3477
  }
3548
- const path = buildNativeStrokePreviewPath(p.points);
3549
- if (!path) return null;
3550
- return /* @__PURE__ */ jsx(
3551
- Path,
3552
- {
3553
- path,
3554
- color: strokeColor,
3555
- style: "stroke",
3556
- strokeWidth: style.strokeWidth,
3557
- strokeCap: "round",
3558
- strokeJoin: "round",
3559
- antiAlias: true
3560
- }
3561
- );
3478
+ if (payload.kind === "strokePath") {
3479
+ const intervals = dashIntervalsFromStrokeDasharray3(payload.strokeDasharray);
3480
+ return /* @__PURE__ */ jsx(
3481
+ Path,
3482
+ {
3483
+ path: payload.d,
3484
+ color: colorWithOpacity(
3485
+ payload.stroke,
3486
+ isLaser ? 0.85 : payload.strokeOpacity
3487
+ ),
3488
+ style: "stroke",
3489
+ strokeWidth: payload.strokeWidth,
3490
+ strokeCap: "round",
3491
+ strokeJoin: "round",
3492
+ antiAlias: true,
3493
+ children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
3494
+ }
3495
+ );
3496
+ }
3497
+ return null;
3562
3498
  }
3563
3499
  return null;
3564
3500
  }, [placementPreview, previewStrokeStyle, overlayStrokeWorld, marqueeDashWorld]);
@@ -6009,7 +5945,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
6009
5945
  setRealtimePlacementPreview({
6010
5946
  kind: "stroke",
6011
5947
  tool: st.tool,
6012
- points: sampleNativeStrokePreviewPoints(pts),
5948
+ points: [...pts],
6013
5949
  style: { ...strokeStyleRef.current }
6014
5950
  });
6015
5951
  return;