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.
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CanvasPlugin } from './types-7kfWcm0L.cjs';
2
+ import { C as CanvasPlugin } from './types-BLXR7g_L.cjs';
3
3
  import 'react';
4
4
  import './types-CB0TZZuk.cjs';
5
5
  import './camera-BwQjm5oh.cjs';
package/dist/chatbot.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CanvasPlugin } from './types-C4k_AMvi.js';
2
+ import { C as CanvasPlugin } from './types-Cm7IsgL4.js';
3
3
  import 'react';
4
4
  import './types-CB0TZZuk.js';
5
5
  import './camera-KwCYYPhm.js';
package/dist/react.cjs CHANGED
@@ -6455,6 +6455,7 @@ function InteractionOverlay({
6455
6455
  }
6456
6456
  );
6457
6457
  }
6458
+ init_shape_builders();
6458
6459
 
6459
6460
  // src/react/presence/peer-color.ts
6460
6461
  function defaultPresenceColorForId(id) {
@@ -6480,6 +6481,9 @@ function strokePaint(tool, fallback) {
6480
6481
  return { stroke: fallback, strokeOpacity: 0.95, widthWorld: 3.5 };
6481
6482
  }
6482
6483
  }
6484
+ function isFreehandTool(tool) {
6485
+ return tool === "draw" || tool === "marker" || tool === "pencil" || tool === "brush";
6486
+ }
6483
6487
  function PresenceRemoteLayer({
6484
6488
  camera,
6485
6489
  cameraVersion: _cameraVersion,
@@ -6515,35 +6519,78 @@ function PresenceRemoteLayer({
6515
6519
  const markup = peer.markupStroke;
6516
6520
  let strokeNode = null;
6517
6521
  if (markup && markup.points.length > 0) {
6518
- const paint = strokePaint(markup.tool, color);
6519
- const d = markup.points.length >= 2 ? smoothFreehandPointsToPathD([...markup.points]) : null;
6520
- if (d) {
6521
- strokeNode = /* @__PURE__ */ jsxRuntime.jsx(
6522
- "path",
6523
- {
6524
- d,
6525
- fill: "none",
6526
- stroke: paint.stroke,
6527
- strokeOpacity: paint.strokeOpacity,
6528
- strokeWidth: Math.max(paint.widthWorld / z, overlayStrokePx),
6529
- strokeLinecap: "round",
6530
- strokeLinejoin: "round",
6531
- shapeRendering: "geometricPrecision",
6532
- vectorEffect: "non-scaling-stroke"
6533
- }
6522
+ const fallbackPaint = strokePaint(markup.tool, color);
6523
+ const paint = {
6524
+ stroke: markup.stroke ?? fallbackPaint.stroke,
6525
+ strokeOpacity: markup.strokeOpacity ?? fallbackPaint.strokeOpacity,
6526
+ widthWorld: markup.strokeWidth ?? fallbackPaint.widthWorld
6527
+ };
6528
+ if (markup.tool === "laser") {
6529
+ const d = markup.points.length >= 2 ? smoothFreehandPointsToPathD([...markup.points]) : null;
6530
+ if (d) {
6531
+ strokeNode = /* @__PURE__ */ jsxRuntime.jsx(
6532
+ "path",
6533
+ {
6534
+ d,
6535
+ fill: "none",
6536
+ stroke: paint.stroke,
6537
+ strokeOpacity: paint.strokeOpacity,
6538
+ strokeWidth: Math.max(paint.widthWorld / z, overlayStrokePx),
6539
+ strokeLinecap: "round",
6540
+ strokeLinejoin: "round",
6541
+ shapeRendering: "geometricPrecision",
6542
+ vectorEffect: "non-scaling-stroke"
6543
+ }
6544
+ );
6545
+ }
6546
+ } else if (isFreehandTool(markup.tool)) {
6547
+ const style = {
6548
+ stroke: paint.stroke,
6549
+ strokeWidth: paint.widthWorld,
6550
+ ...paint.strokeOpacity != null ? { strokeOpacity: paint.strokeOpacity } : {}
6551
+ };
6552
+ const payload = computeFreehandSvgPayload(
6553
+ markup.points.map((p) => ({ x: p.x, y: p.y })),
6554
+ style,
6555
+ markup.tool,
6556
+ false
6534
6557
  );
6535
- } else {
6536
- const p0 = markup.points[0];
6537
- if (p0) {
6558
+ if (payload?.kind === "circle") {
6538
6559
  strokeNode = /* @__PURE__ */ jsxRuntime.jsx(
6539
6560
  "circle",
6540
6561
  {
6541
- cx: p0.x,
6542
- cy: p0.y,
6543
- r: Math.max(3 / z, 2),
6544
- fill: paint.stroke,
6545
- fillOpacity: paint.strokeOpacity,
6546
- vectorEffect: "non-scaling-stroke"
6562
+ cx: payload.cx,
6563
+ cy: payload.cy,
6564
+ r: payload.r,
6565
+ fill: payload.fill,
6566
+ ...payload.fillOpacity != null ? { fillOpacity: payload.fillOpacity } : {},
6567
+ shapeRendering: "geometricPrecision"
6568
+ }
6569
+ );
6570
+ } else if (payload?.kind === "fillPath") {
6571
+ strokeNode = /* @__PURE__ */ jsxRuntime.jsx(
6572
+ "path",
6573
+ {
6574
+ d: payload.d,
6575
+ fill: payload.fill,
6576
+ fillRule: "nonzero",
6577
+ stroke: "none",
6578
+ ...payload.fillOpacity != null ? { fillOpacity: payload.fillOpacity } : {},
6579
+ shapeRendering: "geometricPrecision"
6580
+ }
6581
+ );
6582
+ } else if (payload?.kind === "strokePath") {
6583
+ strokeNode = /* @__PURE__ */ jsxRuntime.jsx(
6584
+ "path",
6585
+ {
6586
+ d: payload.d,
6587
+ fill: "none",
6588
+ stroke: payload.stroke,
6589
+ strokeWidth: payload.strokeWidth,
6590
+ ...payload.strokeOpacity != null ? { strokeOpacity: payload.strokeOpacity } : {},
6591
+ strokeLinecap: "round",
6592
+ strokeLinejoin: "round",
6593
+ shapeRendering: "geometricPrecision"
6547
6594
  }
6548
6595
  );
6549
6596
  }
@@ -7424,14 +7471,15 @@ var VectorViewport = react.forwardRef(
7424
7471
  const directRemoteStrokePreviewRef = react.useRef(false);
7425
7472
  const remoteStrokePreviewFrameRef = react.useRef(null);
7426
7473
  const pendingRemoteStrokePreviewRef = react.useRef(null);
7427
- const flushRemoteStrokePreview = react.useCallback(() => {
7474
+ const flushRemoteStrokePreviewWithStyle = react.useCallback(() => {
7428
7475
  remoteStrokePreviewFrameRef.current = null;
7429
7476
  const pending = pendingRemoteStrokePreviewRef.current;
7430
7477
  if (!pending) return;
7431
7478
  onPlacementPreviewChangeRef.current?.({
7432
7479
  kind: "stroke",
7433
7480
  tool: pending.tool,
7434
- points: pending.points
7481
+ points: pending.points,
7482
+ style: { ...strokeStyleRef.current }
7435
7483
  });
7436
7484
  }, []);
7437
7485
  const emitRemoteStrokePreview = react.useCallback(
@@ -7441,10 +7489,10 @@ var VectorViewport = react.forwardRef(
7441
7489
  pendingRemoteStrokePreviewRef.current = { tool, points };
7442
7490
  if (remoteStrokePreviewFrameRef.current != null) return;
7443
7491
  remoteStrokePreviewFrameRef.current = requestAnimationFrame(
7444
- flushRemoteStrokePreview
7492
+ flushRemoteStrokePreviewWithStyle
7445
7493
  );
7446
7494
  },
7447
- [flushRemoteStrokePreview]
7495
+ [flushRemoteStrokePreviewWithStyle]
7448
7496
  );
7449
7497
  const emitRemoteStrokePreviewClear = react.useCallback(() => {
7450
7498
  if (remoteStrokePreviewFrameRef.current != null) {
@@ -8707,7 +8755,8 @@ var VectorViewport = react.forwardRef(
8707
8755
  setPlacementPreview({
8708
8756
  kind: "stroke",
8709
8757
  tool,
8710
- points: [startPoint]
8758
+ points: [startPoint],
8759
+ style: { ...strokeStyleRef.current }
8711
8760
  });
8712
8761
  }
8713
8762
  captureInteractionPointer(e.currentTarget, e.pointerId);
@@ -9074,7 +9123,8 @@ var VectorViewport = react.forwardRef(
9074
9123
  setPlacementPreview({
9075
9124
  kind: "stroke",
9076
9125
  tool: st.tool,
9077
- points: interpolated
9126
+ points: interpolated,
9127
+ style: { ...strokeStyleRef.current }
9078
9128
  });
9079
9129
  }
9080
9130
  return;