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.js CHANGED
@@ -3073,22 +3073,6 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
3073
3073
  }
3074
3074
 
3075
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
3076
  function buildNativeStrokePreviewPath(points) {
3093
3077
  if (points.length < 2) return null;
3094
3078
  const d = smoothFreehandPointsToPathD(points);
@@ -5994,22 +5978,19 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5994
5978
  const dx = worldX - (last?.x ?? worldX);
5995
5979
  const dy = worldY - (last?.y ?? worldY);
5996
5980
  const shouldAppendPoint = Math.hypot(dx, dy) > 0.5 / cam.zoom;
5997
- if (shouldAppendPoint) {
5998
- pts.push({ x: worldX, y: worldY });
5999
- }
5981
+ if (!shouldAppendPoint) return;
5982
+ pts.push({ x: worldX, y: worldY });
6000
5983
  if (st.tool === "laser") {
6001
- if (shouldAppendPoint) {
6002
- setLaserTrail((prev) => [
6003
- ...prev,
6004
- { x: worldX, y: worldY, t: Date.now() }
6005
- ]);
6006
- }
5984
+ setLaserTrail((prev) => [
5985
+ ...prev,
5986
+ { x: worldX, y: worldY, t: Date.now() }
5987
+ ]);
6007
5988
  return;
6008
5989
  }
6009
5990
  setRealtimePlacementPreview({
6010
5991
  kind: "stroke",
6011
5992
  tool: st.tool,
6012
- points: sampleNativeStrokePreviewPoints(pts),
5993
+ points: pts.map((previewPoint) => ({ ...previewPoint })),
6013
5994
  style: { ...strokeStyleRef.current }
6014
5995
  });
6015
5996
  return;