canvu-react 0.3.26 → 0.3.28
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.cjs +87 -29
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +87 -29
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +190 -56
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +186 -56
- package/dist/realtime.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
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
|
-
|
|
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:
|
|
6540
|
-
cy:
|
|
6541
|
-
r:
|
|
6542
|
-
fill:
|
|
6543
|
-
fillOpacity:
|
|
6544
|
-
|
|
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
|
}
|
|
@@ -7421,7 +7463,14 @@ var VectorViewport = forwardRef(
|
|
|
7421
7463
|
onPlacementPreviewChangeRef.current = onPlacementPreviewChange;
|
|
7422
7464
|
const directRemoteStrokePreviewRef = useRef(false);
|
|
7423
7465
|
const remoteStrokePreviewFrameRef = useRef(null);
|
|
7466
|
+
const remoteStrokePreviewClearTimerRef = useRef(null);
|
|
7424
7467
|
const pendingRemoteStrokePreviewRef = useRef(null);
|
|
7468
|
+
const cancelPendingRemoteStrokePreviewClear = useCallback(() => {
|
|
7469
|
+
if (remoteStrokePreviewClearTimerRef.current != null) {
|
|
7470
|
+
clearTimeout(remoteStrokePreviewClearTimerRef.current);
|
|
7471
|
+
remoteStrokePreviewClearTimerRef.current = null;
|
|
7472
|
+
}
|
|
7473
|
+
}, []);
|
|
7425
7474
|
const flushRemoteStrokePreviewWithStyle = useCallback(() => {
|
|
7426
7475
|
remoteStrokePreviewFrameRef.current = null;
|
|
7427
7476
|
const pending = pendingRemoteStrokePreviewRef.current;
|
|
@@ -7436,6 +7485,7 @@ var VectorViewport = forwardRef(
|
|
|
7436
7485
|
const emitRemoteStrokePreview = useCallback(
|
|
7437
7486
|
(tool, points) => {
|
|
7438
7487
|
if (tool === "laser") return;
|
|
7488
|
+
cancelPendingRemoteStrokePreviewClear();
|
|
7439
7489
|
directRemoteStrokePreviewRef.current = true;
|
|
7440
7490
|
pendingRemoteStrokePreviewRef.current = { tool, points };
|
|
7441
7491
|
if (remoteStrokePreviewFrameRef.current != null) return;
|
|
@@ -7443,17 +7493,22 @@ var VectorViewport = forwardRef(
|
|
|
7443
7493
|
flushRemoteStrokePreviewWithStyle
|
|
7444
7494
|
);
|
|
7445
7495
|
},
|
|
7446
|
-
[flushRemoteStrokePreviewWithStyle]
|
|
7496
|
+
[cancelPendingRemoteStrokePreviewClear, flushRemoteStrokePreviewWithStyle]
|
|
7447
7497
|
);
|
|
7498
|
+
const REMOTE_STROKE_PREVIEW_HOLD_MS = 350;
|
|
7448
7499
|
const emitRemoteStrokePreviewClear = useCallback(() => {
|
|
7449
7500
|
if (remoteStrokePreviewFrameRef.current != null) {
|
|
7450
7501
|
cancelAnimationFrame(remoteStrokePreviewFrameRef.current);
|
|
7451
7502
|
remoteStrokePreviewFrameRef.current = null;
|
|
7452
7503
|
}
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7504
|
+
cancelPendingRemoteStrokePreviewClear();
|
|
7505
|
+
remoteStrokePreviewClearTimerRef.current = window.setTimeout(() => {
|
|
7506
|
+
remoteStrokePreviewClearTimerRef.current = null;
|
|
7507
|
+
pendingRemoteStrokePreviewRef.current = null;
|
|
7508
|
+
directRemoteStrokePreviewRef.current = false;
|
|
7509
|
+
onPlacementPreviewChangeRef.current?.(null);
|
|
7510
|
+
}, REMOTE_STROKE_PREVIEW_HOLD_MS);
|
|
7511
|
+
}, [cancelPendingRemoteStrokePreviewClear]);
|
|
7457
7512
|
const overlayCameraTickRef = useRef(false);
|
|
7458
7513
|
overlayCameraTickRef.current = interactive || remotePresence != null && remotePresence.length > 0 || presenceOverlay != null;
|
|
7459
7514
|
const pruneEraserTrail = useCallback(
|
|
@@ -7706,6 +7761,9 @@ var VectorViewport = forwardRef(
|
|
|
7706
7761
|
if (remoteStrokePreviewFrameRef.current != null) {
|
|
7707
7762
|
cancelAnimationFrame(remoteStrokePreviewFrameRef.current);
|
|
7708
7763
|
}
|
|
7764
|
+
if (remoteStrokePreviewClearTimerRef.current != null) {
|
|
7765
|
+
clearTimeout(remoteStrokePreviewClearTimerRef.current);
|
|
7766
|
+
}
|
|
7709
7767
|
};
|
|
7710
7768
|
}, []);
|
|
7711
7769
|
useEffect(() => {
|