canvu-react 0.3.25 → 0.3.27

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/react.d.cts CHANGED
@@ -3,8 +3,8 @@ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAsse
3
3
  import { V as VectorSceneItem } from './types-CB0TZZuk.cjs';
4
4
  import { V as VectorViewportAssetKind, u as VectorViewportAssetStore } from './shape-builders-DFudWDFI.cjs';
5
5
  export { v as VectorViewportAssetHydrationRequest, w as VectorViewportAssetResolveRequest, x as VectorViewportAssetResolveResult, y as VectorViewportAssetUploadRequest, z as VectorViewportAssetUploadResult } from './shape-builders-DFudWDFI.cjs';
6
- import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-7kfWcm0L.cjs';
7
- export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-7kfWcm0L.cjs';
6
+ import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-BLXR7g_L.cjs';
7
+ export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-BLXR7g_L.cjs';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import * as react from 'react';
10
10
  import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
package/dist/react.d.ts CHANGED
@@ -3,8 +3,8 @@ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAsse
3
3
  import { V as VectorSceneItem } from './types-CB0TZZuk.js';
4
4
  import { V as VectorViewportAssetKind, u as VectorViewportAssetStore } from './shape-builders-ENwnK-zT.js';
5
5
  export { v as VectorViewportAssetHydrationRequest, w as VectorViewportAssetResolveRequest, x as VectorViewportAssetResolveResult, y as VectorViewportAssetUploadRequest, z as VectorViewportAssetUploadResult } from './shape-builders-ENwnK-zT.js';
6
- import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-C4k_AMvi.js';
7
- export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-C4k_AMvi.js';
6
+ import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-Cm7IsgL4.js';
7
+ export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-Cm7IsgL4.js';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import * as react from 'react';
10
10
  import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
package/dist/react.js CHANGED
@@ -6448,6 +6448,7 @@ function InteractionOverlay({
6448
6448
  }
6449
6449
  );
6450
6450
  }
6451
+ init_shape_builders();
6451
6452
 
6452
6453
  // src/react/presence/peer-color.ts
6453
6454
  function defaultPresenceColorForId(id) {
@@ -6473,6 +6474,9 @@ function strokePaint(tool, fallback) {
6473
6474
  return { stroke: fallback, strokeOpacity: 0.95, widthWorld: 3.5 };
6474
6475
  }
6475
6476
  }
6477
+ function isFreehandTool(tool) {
6478
+ return tool === "draw" || tool === "marker" || tool === "pencil" || tool === "brush";
6479
+ }
6476
6480
  function PresenceRemoteLayer({
6477
6481
  camera,
6478
6482
  cameraVersion: _cameraVersion,
@@ -6508,35 +6512,78 @@ function PresenceRemoteLayer({
6508
6512
  const markup = peer.markupStroke;
6509
6513
  let strokeNode = null;
6510
6514
  if (markup && markup.points.length > 0) {
6511
- const paint = strokePaint(markup.tool, color);
6512
- const d = markup.points.length >= 2 ? smoothFreehandPointsToPathD([...markup.points]) : null;
6513
- if (d) {
6514
- strokeNode = /* @__PURE__ */ jsx(
6515
- "path",
6516
- {
6517
- d,
6518
- fill: "none",
6519
- stroke: paint.stroke,
6520
- strokeOpacity: paint.strokeOpacity,
6521
- strokeWidth: Math.max(paint.widthWorld / z, overlayStrokePx),
6522
- strokeLinecap: "round",
6523
- strokeLinejoin: "round",
6524
- shapeRendering: "geometricPrecision",
6525
- vectorEffect: "non-scaling-stroke"
6526
- }
6515
+ const fallbackPaint = strokePaint(markup.tool, color);
6516
+ const paint = {
6517
+ stroke: markup.stroke ?? fallbackPaint.stroke,
6518
+ strokeOpacity: markup.strokeOpacity ?? fallbackPaint.strokeOpacity,
6519
+ widthWorld: markup.strokeWidth ?? fallbackPaint.widthWorld
6520
+ };
6521
+ if (markup.tool === "laser") {
6522
+ const d = markup.points.length >= 2 ? smoothFreehandPointsToPathD([...markup.points]) : null;
6523
+ if (d) {
6524
+ strokeNode = /* @__PURE__ */ jsx(
6525
+ "path",
6526
+ {
6527
+ d,
6528
+ fill: "none",
6529
+ stroke: paint.stroke,
6530
+ strokeOpacity: paint.strokeOpacity,
6531
+ strokeWidth: Math.max(paint.widthWorld / z, overlayStrokePx),
6532
+ strokeLinecap: "round",
6533
+ strokeLinejoin: "round",
6534
+ shapeRendering: "geometricPrecision",
6535
+ vectorEffect: "non-scaling-stroke"
6536
+ }
6537
+ );
6538
+ }
6539
+ } else if (isFreehandTool(markup.tool)) {
6540
+ const style = {
6541
+ stroke: paint.stroke,
6542
+ strokeWidth: paint.widthWorld,
6543
+ ...paint.strokeOpacity != null ? { strokeOpacity: paint.strokeOpacity } : {}
6544
+ };
6545
+ const payload = computeFreehandSvgPayload(
6546
+ markup.points.map((p) => ({ x: p.x, y: p.y })),
6547
+ style,
6548
+ markup.tool,
6549
+ false
6527
6550
  );
6528
- } else {
6529
- const p0 = markup.points[0];
6530
- if (p0) {
6551
+ if (payload?.kind === "circle") {
6531
6552
  strokeNode = /* @__PURE__ */ jsx(
6532
6553
  "circle",
6533
6554
  {
6534
- cx: p0.x,
6535
- cy: p0.y,
6536
- r: Math.max(3 / z, 2),
6537
- fill: paint.stroke,
6538
- fillOpacity: paint.strokeOpacity,
6539
- vectorEffect: "non-scaling-stroke"
6555
+ cx: payload.cx,
6556
+ cy: payload.cy,
6557
+ r: payload.r,
6558
+ fill: payload.fill,
6559
+ ...payload.fillOpacity != null ? { fillOpacity: payload.fillOpacity } : {},
6560
+ shapeRendering: "geometricPrecision"
6561
+ }
6562
+ );
6563
+ } else if (payload?.kind === "fillPath") {
6564
+ strokeNode = /* @__PURE__ */ jsx(
6565
+ "path",
6566
+ {
6567
+ d: payload.d,
6568
+ fill: payload.fill,
6569
+ fillRule: "nonzero",
6570
+ stroke: "none",
6571
+ ...payload.fillOpacity != null ? { fillOpacity: payload.fillOpacity } : {},
6572
+ shapeRendering: "geometricPrecision"
6573
+ }
6574
+ );
6575
+ } else if (payload?.kind === "strokePath") {
6576
+ strokeNode = /* @__PURE__ */ jsx(
6577
+ "path",
6578
+ {
6579
+ d: payload.d,
6580
+ fill: "none",
6581
+ stroke: payload.stroke,
6582
+ strokeWidth: payload.strokeWidth,
6583
+ ...payload.strokeOpacity != null ? { strokeOpacity: payload.strokeOpacity } : {},
6584
+ strokeLinecap: "round",
6585
+ strokeLinejoin: "round",
6586
+ shapeRendering: "geometricPrecision"
6540
6587
  }
6541
6588
  );
6542
6589
  }
@@ -7417,14 +7464,15 @@ var VectorViewport = forwardRef(
7417
7464
  const directRemoteStrokePreviewRef = useRef(false);
7418
7465
  const remoteStrokePreviewFrameRef = useRef(null);
7419
7466
  const pendingRemoteStrokePreviewRef = useRef(null);
7420
- const flushRemoteStrokePreview = useCallback(() => {
7467
+ const flushRemoteStrokePreviewWithStyle = useCallback(() => {
7421
7468
  remoteStrokePreviewFrameRef.current = null;
7422
7469
  const pending = pendingRemoteStrokePreviewRef.current;
7423
7470
  if (!pending) return;
7424
7471
  onPlacementPreviewChangeRef.current?.({
7425
7472
  kind: "stroke",
7426
7473
  tool: pending.tool,
7427
- points: pending.points
7474
+ points: pending.points,
7475
+ style: { ...strokeStyleRef.current }
7428
7476
  });
7429
7477
  }, []);
7430
7478
  const emitRemoteStrokePreview = useCallback(
@@ -7434,10 +7482,10 @@ var VectorViewport = forwardRef(
7434
7482
  pendingRemoteStrokePreviewRef.current = { tool, points };
7435
7483
  if (remoteStrokePreviewFrameRef.current != null) return;
7436
7484
  remoteStrokePreviewFrameRef.current = requestAnimationFrame(
7437
- flushRemoteStrokePreview
7485
+ flushRemoteStrokePreviewWithStyle
7438
7486
  );
7439
7487
  },
7440
- [flushRemoteStrokePreview]
7488
+ [flushRemoteStrokePreviewWithStyle]
7441
7489
  );
7442
7490
  const emitRemoteStrokePreviewClear = useCallback(() => {
7443
7491
  if (remoteStrokePreviewFrameRef.current != null) {
@@ -8700,7 +8748,8 @@ var VectorViewport = forwardRef(
8700
8748
  setPlacementPreview({
8701
8749
  kind: "stroke",
8702
8750
  tool,
8703
- points: [startPoint]
8751
+ points: [startPoint],
8752
+ style: { ...strokeStyleRef.current }
8704
8753
  });
8705
8754
  }
8706
8755
  captureInteractionPointer(e.currentTarget, e.pointerId);
@@ -9067,7 +9116,8 @@ var VectorViewport = forwardRef(
9067
9116
  setPlacementPreview({
9068
9117
  kind: "stroke",
9069
9118
  tool: st.tool,
9070
- points: interpolated
9119
+ points: interpolated,
9120
+ style: { ...strokeStyleRef.current }
9071
9121
  });
9072
9122
  }
9073
9123
  return;