canvu-react 0.4.49 → 0.4.51
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.cjs +72 -16
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +2 -1
- package/dist/native.d.ts +2 -1
- package/dist/native.js +72 -16
- package/dist/native.js.map +1 -1
- package/package.json +1 -1
package/dist/native.cjs
CHANGED
|
@@ -3100,11 +3100,14 @@ function buildNativeStrokePreviewPath(points) {
|
|
|
3100
3100
|
const d = smoothFreehandPointsToPathD(points);
|
|
3101
3101
|
return d || null;
|
|
3102
3102
|
}
|
|
3103
|
-
function
|
|
3104
|
-
if (
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3103
|
+
function buildNativeFreehandStrokePreviewPayload(points, style, tool) {
|
|
3104
|
+
if (tool === "laser") return null;
|
|
3105
|
+
return computeFreehandSvgPayload(
|
|
3106
|
+
points.map((point) => ({ x: point.x, y: point.y })),
|
|
3107
|
+
style,
|
|
3108
|
+
tool,
|
|
3109
|
+
true
|
|
3110
|
+
);
|
|
3108
3111
|
}
|
|
3109
3112
|
|
|
3110
3113
|
// src/native/native-vector-interactions.ts
|
|
@@ -3482,6 +3485,57 @@ function NativeInteractionOverlay({
|
|
|
3482
3485
|
style.stroke,
|
|
3483
3486
|
isLaser ? 0.85 : style.strokeOpacity
|
|
3484
3487
|
);
|
|
3488
|
+
if (!isLaser) {
|
|
3489
|
+
const payload = buildNativeFreehandStrokePreviewPayload(
|
|
3490
|
+
p.points,
|
|
3491
|
+
style,
|
|
3492
|
+
p.tool
|
|
3493
|
+
);
|
|
3494
|
+
if (payload?.kind === "circle") {
|
|
3495
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3496
|
+
reactNativeSkia.Circle,
|
|
3497
|
+
{
|
|
3498
|
+
cx: payload.cx,
|
|
3499
|
+
cy: payload.cy,
|
|
3500
|
+
r: payload.r,
|
|
3501
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3502
|
+
style: "fill",
|
|
3503
|
+
antiAlias: true
|
|
3504
|
+
}
|
|
3505
|
+
);
|
|
3506
|
+
}
|
|
3507
|
+
if (payload?.kind === "fillPath") {
|
|
3508
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3509
|
+
reactNativeSkia.Path,
|
|
3510
|
+
{
|
|
3511
|
+
path: payload.d,
|
|
3512
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3513
|
+
style: "fill",
|
|
3514
|
+
fillType: "winding",
|
|
3515
|
+
antiAlias: true
|
|
3516
|
+
}
|
|
3517
|
+
);
|
|
3518
|
+
}
|
|
3519
|
+
if (payload?.kind === "strokePath") {
|
|
3520
|
+
const intervals = dashIntervalsFromStrokeDasharray3(
|
|
3521
|
+
payload.strokeDasharray
|
|
3522
|
+
);
|
|
3523
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3524
|
+
reactNativeSkia.Path,
|
|
3525
|
+
{
|
|
3526
|
+
path: payload.d,
|
|
3527
|
+
color: colorWithOpacity(payload.stroke, payload.strokeOpacity),
|
|
3528
|
+
style: "stroke",
|
|
3529
|
+
strokeWidth: payload.strokeWidth,
|
|
3530
|
+
strokeCap: "round",
|
|
3531
|
+
strokeJoin: "round",
|
|
3532
|
+
antiAlias: true,
|
|
3533
|
+
children: intervals ? /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.DashPathEffect, { intervals }) : null
|
|
3534
|
+
}
|
|
3535
|
+
);
|
|
3536
|
+
}
|
|
3537
|
+
return null;
|
|
3538
|
+
}
|
|
3485
3539
|
if (p.points.length === 1) {
|
|
3486
3540
|
const point = p.points[0];
|
|
3487
3541
|
if (!point) return null;
|
|
@@ -3499,8 +3553,6 @@ function NativeInteractionOverlay({
|
|
|
3499
3553
|
}
|
|
3500
3554
|
const path = buildNativeStrokePreviewPath(p.points);
|
|
3501
3555
|
if (!path) return null;
|
|
3502
|
-
const strokeDasharray = nativeStrokePreviewDashArray(style, p.tool);
|
|
3503
|
-
const intervals = dashIntervalsFromStrokeDasharray3(strokeDasharray);
|
|
3504
3556
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3505
3557
|
reactNativeSkia.Path,
|
|
3506
3558
|
{
|
|
@@ -3510,8 +3562,7 @@ function NativeInteractionOverlay({
|
|
|
3510
3562
|
strokeWidth: style.strokeWidth,
|
|
3511
3563
|
strokeCap: "round",
|
|
3512
3564
|
strokeJoin: "round",
|
|
3513
|
-
antiAlias: true
|
|
3514
|
-
children: intervals ? /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.DashPathEffect, { intervals }) : null
|
|
3565
|
+
antiAlias: true
|
|
3515
3566
|
}
|
|
3516
3567
|
);
|
|
3517
3568
|
}
|
|
@@ -3874,11 +3925,12 @@ var MemoShape = react.memo(function MemoShape2({
|
|
|
3874
3925
|
if (rotationTransform.length === 0) return shape;
|
|
3875
3926
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: shape });
|
|
3876
3927
|
});
|
|
3877
|
-
|
|
3928
|
+
var NativeSceneRenderer = react.memo(function NativeSceneRenderer2({
|
|
3878
3929
|
items,
|
|
3879
3930
|
camera,
|
|
3880
3931
|
width,
|
|
3881
|
-
height
|
|
3932
|
+
height,
|
|
3933
|
+
renderTick
|
|
3882
3934
|
}) {
|
|
3883
3935
|
const cameraTransform = skiaCameraTransform(camera.zoom, camera.x, camera.y);
|
|
3884
3936
|
const visible = cullItemsByViewport(
|
|
@@ -3887,7 +3939,7 @@ function NativeSceneRenderer({
|
|
|
3887
3939
|
);
|
|
3888
3940
|
if (width <= 0 || height <= 0) return null;
|
|
3889
3941
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Canvas, { style: { width, height }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: cameraTransform, children: visible.map((item) => /* @__PURE__ */ jsxRuntime.jsx(MemoShape, { item }, item.id)) }) });
|
|
3890
|
-
}
|
|
3942
|
+
});
|
|
3891
3943
|
|
|
3892
3944
|
// src/native/native-style-inspector-values.ts
|
|
3893
3945
|
var NATIVE_STYLE_PALETTE = [
|
|
@@ -5672,6 +5724,11 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
5672
5724
|
return activeItems.filter((item) => !hidden.has(item.id));
|
|
5673
5725
|
}, [activeItems, eraserPreviewIds]);
|
|
5674
5726
|
const showResizeHandles = interactive && selectedItems.length === 1 && !selectedItems[0]?.locked && supportsNativeResizeHandles(selectedItems[0]);
|
|
5727
|
+
const eraserPreviewItems = react.useMemo(() => {
|
|
5728
|
+
if (eraserPreviewIds.length === 0) return [];
|
|
5729
|
+
const eraserPreviewIdSet = new Set(eraserPreviewIds);
|
|
5730
|
+
return activeItems.filter((item) => eraserPreviewIdSet.has(item.id));
|
|
5731
|
+
}, [activeItems, eraserPreviewIds]);
|
|
5675
5732
|
const patchSelectedItemsStrokeStyle = react.useCallback(
|
|
5676
5733
|
(patch) => {
|
|
5677
5734
|
const change = onItemsChangeRef.current;
|
|
@@ -6478,7 +6535,8 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
6478
6535
|
items: sceneItems,
|
|
6479
6536
|
camera,
|
|
6480
6537
|
width: size.width,
|
|
6481
|
-
height: size.height
|
|
6538
|
+
height: size.height,
|
|
6539
|
+
renderTick: cameraTick
|
|
6482
6540
|
}
|
|
6483
6541
|
),
|
|
6484
6542
|
interactive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6492,9 +6550,7 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
6492
6550
|
placementPreview,
|
|
6493
6551
|
laserTrail,
|
|
6494
6552
|
eraserTrail,
|
|
6495
|
-
eraserPreviewItems
|
|
6496
|
-
(item) => eraserPreviewIds.includes(item.id)
|
|
6497
|
-
),
|
|
6553
|
+
eraserPreviewItems,
|
|
6498
6554
|
previewStrokeStyle: strokeStyleState,
|
|
6499
6555
|
remotePresence
|
|
6500
6556
|
}
|