canvu-react 0.4.52 → 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,22 +3072,6 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
3072
3072
  };
3073
3073
  }
3074
3074
 
3075
- // src/native/native-stroke-preview.ts
3076
- function buildNativeStrokePreviewPath(points) {
3077
- if (points.length < 2) return null;
3078
- const d = smoothFreehandPointsToPathD(points);
3079
- return d || null;
3080
- }
3081
- function buildNativeFreehandStrokePreviewPayload(points, style, tool) {
3082
- if (tool === "laser") return null;
3083
- return computeFreehandSvgPayload(
3084
- points.map((point) => ({ x: point.x, y: point.y })),
3085
- style,
3086
- tool,
3087
- true
3088
- );
3089
- }
3090
-
3091
3075
  // src/native/native-vector-interactions.ts
3092
3076
  var NATIVE_SELECTION_HANDLE_HIT_RADIUS_PX = 24;
3093
3077
  function nativeItemPlacementBounds(item) {
@@ -3459,90 +3443,58 @@ function NativeInteractionOverlay({
3459
3443
  p.tool,
3460
3444
  p.style ?? previewStrokeStyle
3461
3445
  );
3462
- const strokeColor = colorWithOpacity(
3463
- style.stroke,
3464
- isLaser ? 0.85 : style.strokeOpacity
3446
+ const payload = computeFreehandSvgPayload(
3447
+ p.points,
3448
+ style,
3449
+ isLaser ? "draw" : p.tool,
3450
+ p.points.length === 2
3465
3451
  );
3466
- if (!isLaser) {
3467
- const payload = buildNativeFreehandStrokePreviewPayload(
3468
- p.points,
3469
- style,
3470
- 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
+ }
3471
3464
  );
3472
- if (payload?.kind === "circle") {
3473
- return /* @__PURE__ */ jsx(
3474
- Circle,
3475
- {
3476
- cx: payload.cx,
3477
- cy: payload.cy,
3478
- r: payload.r,
3479
- color: colorWithOpacity(payload.fill, payload.fillOpacity),
3480
- style: "fill",
3481
- antiAlias: true
3482
- }
3483
- );
3484
- }
3485
- if (payload?.kind === "fillPath") {
3486
- return /* @__PURE__ */ jsx(
3487
- Path,
3488
- {
3489
- path: payload.d,
3490
- color: colorWithOpacity(payload.fill, payload.fillOpacity),
3491
- style: "fill",
3492
- fillType: "winding",
3493
- antiAlias: true
3494
- }
3495
- );
3496
- }
3497
- if (payload?.kind === "strokePath") {
3498
- const intervals = dashIntervalsFromStrokeDasharray3(
3499
- payload.strokeDasharray
3500
- );
3501
- return /* @__PURE__ */ jsx(
3502
- Path,
3503
- {
3504
- path: payload.d,
3505
- color: colorWithOpacity(payload.stroke, payload.strokeOpacity),
3506
- style: "stroke",
3507
- strokeWidth: payload.strokeWidth,
3508
- strokeCap: "round",
3509
- strokeJoin: "round",
3510
- antiAlias: true,
3511
- children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
3512
- }
3513
- );
3514
- }
3515
- return null;
3516
3465
  }
3517
- if (p.points.length === 1) {
3518
- const point = p.points[0];
3519
- if (!point) return null;
3466
+ if (payload.kind === "fillPath") {
3520
3467
  return /* @__PURE__ */ jsx(
3521
- Circle,
3468
+ Path,
3522
3469
  {
3523
- cx: point.x,
3524
- cy: point.y,
3525
- r: Math.max(0.5, style.strokeWidth / 2),
3526
- color: strokeColor,
3470
+ path: payload.d,
3471
+ color: colorWithOpacity(payload.fill, payload.fillOpacity),
3527
3472
  style: "fill",
3473
+ fillType: "winding",
3528
3474
  antiAlias: true
3529
3475
  }
3530
3476
  );
3531
3477
  }
3532
- const path = buildNativeStrokePreviewPath(p.points);
3533
- if (!path) return null;
3534
- return /* @__PURE__ */ jsx(
3535
- Path,
3536
- {
3537
- path,
3538
- color: strokeColor,
3539
- style: "stroke",
3540
- strokeWidth: style.strokeWidth,
3541
- strokeCap: "round",
3542
- strokeJoin: "round",
3543
- antiAlias: true
3544
- }
3545
- );
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;
3546
3498
  }
3547
3499
  return null;
3548
3500
  }, [placementPreview, previewStrokeStyle, overlayStrokeWorld, marqueeDashWorld]);
@@ -5978,19 +5930,22 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5978
5930
  const dx = worldX - (last?.x ?? worldX);
5979
5931
  const dy = worldY - (last?.y ?? worldY);
5980
5932
  const shouldAppendPoint = Math.hypot(dx, dy) > 0.5 / cam.zoom;
5981
- if (!shouldAppendPoint) return;
5982
- pts.push({ x: worldX, y: worldY });
5933
+ if (shouldAppendPoint) {
5934
+ pts.push({ x: worldX, y: worldY });
5935
+ }
5983
5936
  if (st.tool === "laser") {
5984
- setLaserTrail((prev) => [
5985
- ...prev,
5986
- { x: worldX, y: worldY, t: Date.now() }
5987
- ]);
5937
+ if (shouldAppendPoint) {
5938
+ setLaserTrail((prev) => [
5939
+ ...prev,
5940
+ { x: worldX, y: worldY, t: Date.now() }
5941
+ ]);
5942
+ }
5988
5943
  return;
5989
5944
  }
5990
5945
  setRealtimePlacementPreview({
5991
5946
  kind: "stroke",
5992
5947
  tool: st.tool,
5993
- points: pts.map((previewPoint) => ({ ...previewPoint })),
5948
+ points: [...pts],
5994
5949
  style: { ...strokeStyleRef.current }
5995
5950
  });
5996
5951
  return;