canvu-react 0.3.26 → 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.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,
@@ -6514,34 +6518,72 @@ function PresenceRemoteLayer({
6514
6518
  strokeOpacity: markup.strokeOpacity ?? fallbackPaint.strokeOpacity,
6515
6519
  widthWorld: markup.strokeWidth ?? fallbackPaint.widthWorld
6516
6520
  };
6517
- const d = markup.points.length >= 2 ? smoothFreehandPointsToPathD([...markup.points]) : null;
6518
- if (d) {
6519
- strokeNode = /* @__PURE__ */ jsx(
6520
- "path",
6521
- {
6522
- d,
6523
- fill: "none",
6524
- stroke: paint.stroke,
6525
- strokeOpacity: paint.strokeOpacity,
6526
- strokeWidth: Math.max(paint.widthWorld / z, overlayStrokePx),
6527
- strokeLinecap: "round",
6528
- strokeLinejoin: "round",
6529
- shapeRendering: "geometricPrecision",
6530
- vectorEffect: "non-scaling-stroke"
6531
- }
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
6532
6550
  );
6533
- } else {
6534
- const p0 = markup.points[0];
6535
- if (p0) {
6551
+ if (payload?.kind === "circle") {
6536
6552
  strokeNode = /* @__PURE__ */ jsx(
6537
6553
  "circle",
6538
6554
  {
6539
- cx: p0.x,
6540
- cy: p0.y,
6541
- r: Math.max(3 / z, 2),
6542
- fill: paint.stroke,
6543
- fillOpacity: paint.strokeOpacity,
6544
- 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"
6545
6587
  }
6546
6588
  );
6547
6589
  }