canvu-react 0.4.78 → 0.4.79

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
@@ -5257,6 +5257,22 @@ function resizeItemByHandle(item, start, handle, currentWorld) {
5257
5257
  return { ...item, x: nb.x, y: nb.y, bounds: nb };
5258
5258
  }
5259
5259
 
5260
+ // src/scene/draw-stroke-memory.ts
5261
+ var DEFAULT_DRAW_STROKE_WIDTH = 10;
5262
+ function resolveDrawStrokeWidthMemory({
5263
+ toolId,
5264
+ previousToolId,
5265
+ currentStrokeWidth,
5266
+ lastDrawStrokeWidth
5267
+ }) {
5268
+ const leavingDrawTool = previousToolId === "draw" && toolId !== "draw";
5269
+ const nextLastDrawStrokeWidth = leavingDrawTool ? currentStrokeWidth : lastDrawStrokeWidth;
5270
+ return {
5271
+ drawStrokeWidth: nextLastDrawStrokeWidth,
5272
+ nextLastDrawStrokeWidth
5273
+ };
5274
+ }
5275
+
5260
5276
  // src/native/native-remote-presence-hit-test.ts
5261
5277
  var REMOTE_CURSOR_SCREEN_PX2 = 22;
5262
5278
  var REMOTE_LABEL_SCREEN_PX2 = 12;
@@ -5769,6 +5785,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5769
5785
  const markerStrokeStyleRef = useRef({ ...MARKER_TOOL_STYLE });
5770
5786
  const styleBeforeMarkerRef = useRef({ ...DEFAULT_STROKE_STYLE });
5771
5787
  const lastToolIdRef = useRef(toolId);
5788
+ const lastDrawStrokeWidthRef = useRef(DEFAULT_DRAW_STROKE_WIDTH);
5772
5789
  const [strokeStyleState, setStrokeStyleState] = useState({
5773
5790
  ...DEFAULT_STROKE_STYLE
5774
5791
  });
@@ -5799,6 +5816,13 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5799
5816
  useEffect(() => {
5800
5817
  const previousToolId = lastToolIdRef.current;
5801
5818
  const current = strokeStyleRef.current;
5819
+ const { drawStrokeWidth, nextLastDrawStrokeWidth } = resolveDrawStrokeWidthMemory({
5820
+ toolId,
5821
+ previousToolId,
5822
+ currentStrokeWidth: current.strokeWidth,
5823
+ lastDrawStrokeWidth: lastDrawStrokeWidthRef.current
5824
+ });
5825
+ lastDrawStrokeWidthRef.current = nextLastDrawStrokeWidth;
5802
5826
  let next = current;
5803
5827
  if (toolId === "marker") {
5804
5828
  if (previousToolId !== "marker") {
@@ -5810,13 +5834,13 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
5810
5834
  const restored = styleBeforeMarkerRef.current;
5811
5835
  next = {
5812
5836
  stroke: restored.stroke,
5813
- strokeWidth: toolId === "draw" && restored.strokeWidth === DEFAULT_STROKE_STYLE.strokeWidth ? 10 : restored.strokeWidth,
5837
+ strokeWidth: toolId === "draw" ? drawStrokeWidth : restored.strokeWidth,
5814
5838
  ...restored.strokeDash != null ? { strokeDash: restored.strokeDash } : {}
5815
5839
  };
5816
5840
  } else if (toolId === "draw") {
5817
5841
  next = {
5818
5842
  ...current,
5819
- strokeWidth: current.strokeWidth === DEFAULT_STROKE_STYLE.strokeWidth ? 10 : current.strokeWidth
5843
+ strokeWidth: drawStrokeWidth
5820
5844
  };
5821
5845
  } else if (isDefaultMarkerToolStyle(current)) {
5822
5846
  next = {