canvu-react 0.4.51 → 0.4.52

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
@@ -3079,22 +3079,6 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
3079
3079
  }
3080
3080
 
3081
3081
  // src/native/native-stroke-preview.ts
3082
- var NATIVE_STROKE_PREVIEW_MAX_POINTS = 160;
3083
- function sampleNativeStrokePreviewPoints(points, maxPoints = NATIVE_STROKE_PREVIEW_MAX_POINTS) {
3084
- if (points.length <= maxPoints) return points.map((point) => ({ ...point }));
3085
- if (maxPoints <= 1) {
3086
- const last2 = points[points.length - 1];
3087
- return last2 ? [{ ...last2 }] : [];
3088
- }
3089
- const lastIndex = points.length - 1;
3090
- const last = points[lastIndex];
3091
- if (!last) return [];
3092
- const step = lastIndex / (maxPoints - 1);
3093
- return Array.from({ length: maxPoints }, (_, index) => {
3094
- const point = points[Math.round(index * step)] ?? last;
3095
- return { x: point.x, y: point.y };
3096
- });
3097
- }
3098
3082
  function buildNativeStrokePreviewPath(points) {
3099
3083
  if (points.length < 2) return null;
3100
3084
  const d = smoothFreehandPointsToPathD(points);
@@ -6000,22 +5984,19 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
6000
5984
  const dx = worldX - (last?.x ?? worldX);
6001
5985
  const dy = worldY - (last?.y ?? worldY);
6002
5986
  const shouldAppendPoint = Math.hypot(dx, dy) > 0.5 / cam.zoom;
6003
- if (shouldAppendPoint) {
6004
- pts.push({ x: worldX, y: worldY });
6005
- }
5987
+ if (!shouldAppendPoint) return;
5988
+ pts.push({ x: worldX, y: worldY });
6006
5989
  if (st.tool === "laser") {
6007
- if (shouldAppendPoint) {
6008
- setLaserTrail((prev) => [
6009
- ...prev,
6010
- { x: worldX, y: worldY, t: Date.now() }
6011
- ]);
6012
- }
5990
+ setLaserTrail((prev) => [
5991
+ ...prev,
5992
+ { x: worldX, y: worldY, t: Date.now() }
5993
+ ]);
6013
5994
  return;
6014
5995
  }
6015
5996
  setRealtimePlacementPreview({
6016
5997
  kind: "stroke",
6017
5998
  tool: st.tool,
6018
- points: sampleNativeStrokePreviewPoints(pts),
5999
+ points: pts.map((previewPoint) => ({ ...previewPoint })),
6019
6000
  style: { ...strokeStyleRef.current }
6020
6001
  });
6021
6002
  return;