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