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.d.cts
CHANGED
|
@@ -113,8 +113,9 @@ type NativeSceneRendererProps = {
|
|
|
113
113
|
readonly camera: Camera2D;
|
|
114
114
|
readonly width: number;
|
|
115
115
|
readonly height: number;
|
|
116
|
+
readonly renderTick: number;
|
|
116
117
|
};
|
|
117
|
-
declare
|
|
118
|
+
declare const NativeSceneRenderer: react.NamedExoticComponent<NativeSceneRendererProps>;
|
|
118
119
|
|
|
119
120
|
type NativeShapeRendererProps = {
|
|
120
121
|
readonly item: VectorSceneItem;
|
package/dist/native.d.ts
CHANGED
|
@@ -113,8 +113,9 @@ type NativeSceneRendererProps = {
|
|
|
113
113
|
readonly camera: Camera2D;
|
|
114
114
|
readonly width: number;
|
|
115
115
|
readonly height: number;
|
|
116
|
+
readonly renderTick: number;
|
|
116
117
|
};
|
|
117
|
-
declare
|
|
118
|
+
declare const NativeSceneRenderer: react.NamedExoticComponent<NativeSceneRendererProps>;
|
|
118
119
|
|
|
119
120
|
type NativeShapeRendererProps = {
|
|
120
121
|
readonly item: VectorSceneItem;
|
package/dist/native.js
CHANGED
|
@@ -3094,11 +3094,14 @@ function buildNativeStrokePreviewPath(points) {
|
|
|
3094
3094
|
const d = smoothFreehandPointsToPathD(points);
|
|
3095
3095
|
return d || null;
|
|
3096
3096
|
}
|
|
3097
|
-
function
|
|
3098
|
-
if (
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3097
|
+
function buildNativeFreehandStrokePreviewPayload(points, style, tool) {
|
|
3098
|
+
if (tool === "laser") return null;
|
|
3099
|
+
return computeFreehandSvgPayload(
|
|
3100
|
+
points.map((point) => ({ x: point.x, y: point.y })),
|
|
3101
|
+
style,
|
|
3102
|
+
tool,
|
|
3103
|
+
true
|
|
3104
|
+
);
|
|
3102
3105
|
}
|
|
3103
3106
|
|
|
3104
3107
|
// src/native/native-vector-interactions.ts
|
|
@@ -3476,6 +3479,57 @@ function NativeInteractionOverlay({
|
|
|
3476
3479
|
style.stroke,
|
|
3477
3480
|
isLaser ? 0.85 : style.strokeOpacity
|
|
3478
3481
|
);
|
|
3482
|
+
if (!isLaser) {
|
|
3483
|
+
const payload = buildNativeFreehandStrokePreviewPayload(
|
|
3484
|
+
p.points,
|
|
3485
|
+
style,
|
|
3486
|
+
p.tool
|
|
3487
|
+
);
|
|
3488
|
+
if (payload?.kind === "circle") {
|
|
3489
|
+
return /* @__PURE__ */ jsx(
|
|
3490
|
+
Circle,
|
|
3491
|
+
{
|
|
3492
|
+
cx: payload.cx,
|
|
3493
|
+
cy: payload.cy,
|
|
3494
|
+
r: payload.r,
|
|
3495
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3496
|
+
style: "fill",
|
|
3497
|
+
antiAlias: true
|
|
3498
|
+
}
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
if (payload?.kind === "fillPath") {
|
|
3502
|
+
return /* @__PURE__ */ jsx(
|
|
3503
|
+
Path,
|
|
3504
|
+
{
|
|
3505
|
+
path: payload.d,
|
|
3506
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3507
|
+
style: "fill",
|
|
3508
|
+
fillType: "winding",
|
|
3509
|
+
antiAlias: true
|
|
3510
|
+
}
|
|
3511
|
+
);
|
|
3512
|
+
}
|
|
3513
|
+
if (payload?.kind === "strokePath") {
|
|
3514
|
+
const intervals = dashIntervalsFromStrokeDasharray3(
|
|
3515
|
+
payload.strokeDasharray
|
|
3516
|
+
);
|
|
3517
|
+
return /* @__PURE__ */ jsx(
|
|
3518
|
+
Path,
|
|
3519
|
+
{
|
|
3520
|
+
path: payload.d,
|
|
3521
|
+
color: colorWithOpacity(payload.stroke, payload.strokeOpacity),
|
|
3522
|
+
style: "stroke",
|
|
3523
|
+
strokeWidth: payload.strokeWidth,
|
|
3524
|
+
strokeCap: "round",
|
|
3525
|
+
strokeJoin: "round",
|
|
3526
|
+
antiAlias: true,
|
|
3527
|
+
children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
|
|
3528
|
+
}
|
|
3529
|
+
);
|
|
3530
|
+
}
|
|
3531
|
+
return null;
|
|
3532
|
+
}
|
|
3479
3533
|
if (p.points.length === 1) {
|
|
3480
3534
|
const point = p.points[0];
|
|
3481
3535
|
if (!point) return null;
|
|
@@ -3493,8 +3547,6 @@ function NativeInteractionOverlay({
|
|
|
3493
3547
|
}
|
|
3494
3548
|
const path = buildNativeStrokePreviewPath(p.points);
|
|
3495
3549
|
if (!path) return null;
|
|
3496
|
-
const strokeDasharray = nativeStrokePreviewDashArray(style, p.tool);
|
|
3497
|
-
const intervals = dashIntervalsFromStrokeDasharray3(strokeDasharray);
|
|
3498
3550
|
return /* @__PURE__ */ jsx(
|
|
3499
3551
|
Path,
|
|
3500
3552
|
{
|
|
@@ -3504,8 +3556,7 @@ function NativeInteractionOverlay({
|
|
|
3504
3556
|
strokeWidth: style.strokeWidth,
|
|
3505
3557
|
strokeCap: "round",
|
|
3506
3558
|
strokeJoin: "round",
|
|
3507
|
-
antiAlias: true
|
|
3508
|
-
children: intervals ? /* @__PURE__ */ jsx(DashPathEffect, { intervals }) : null
|
|
3559
|
+
antiAlias: true
|
|
3509
3560
|
}
|
|
3510
3561
|
);
|
|
3511
3562
|
}
|
|
@@ -3868,11 +3919,12 @@ var MemoShape = memo(function MemoShape2({
|
|
|
3868
3919
|
if (rotationTransform.length === 0) return shape;
|
|
3869
3920
|
return /* @__PURE__ */ jsx(Group, { transform: rotationTransform, origin: rotationOrigin, children: shape });
|
|
3870
3921
|
});
|
|
3871
|
-
|
|
3922
|
+
var NativeSceneRenderer = memo(function NativeSceneRenderer2({
|
|
3872
3923
|
items,
|
|
3873
3924
|
camera,
|
|
3874
3925
|
width,
|
|
3875
|
-
height
|
|
3926
|
+
height,
|
|
3927
|
+
renderTick
|
|
3876
3928
|
}) {
|
|
3877
3929
|
const cameraTransform = skiaCameraTransform(camera.zoom, camera.x, camera.y);
|
|
3878
3930
|
const visible = cullItemsByViewport(
|
|
@@ -3881,7 +3933,7 @@ function NativeSceneRenderer({
|
|
|
3881
3933
|
);
|
|
3882
3934
|
if (width <= 0 || height <= 0) return null;
|
|
3883
3935
|
return /* @__PURE__ */ jsx(Canvas, { style: { width, height }, children: /* @__PURE__ */ jsx(Group, { transform: cameraTransform, children: visible.map((item) => /* @__PURE__ */ jsx(MemoShape, { item }, item.id)) }) });
|
|
3884
|
-
}
|
|
3936
|
+
});
|
|
3885
3937
|
|
|
3886
3938
|
// src/native/native-style-inspector-values.ts
|
|
3887
3939
|
var NATIVE_STYLE_PALETTE = [
|
|
@@ -5666,6 +5718,11 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
5666
5718
|
return activeItems.filter((item) => !hidden.has(item.id));
|
|
5667
5719
|
}, [activeItems, eraserPreviewIds]);
|
|
5668
5720
|
const showResizeHandles = interactive && selectedItems.length === 1 && !selectedItems[0]?.locked && supportsNativeResizeHandles(selectedItems[0]);
|
|
5721
|
+
const eraserPreviewItems = useMemo(() => {
|
|
5722
|
+
if (eraserPreviewIds.length === 0) return [];
|
|
5723
|
+
const eraserPreviewIdSet = new Set(eraserPreviewIds);
|
|
5724
|
+
return activeItems.filter((item) => eraserPreviewIdSet.has(item.id));
|
|
5725
|
+
}, [activeItems, eraserPreviewIds]);
|
|
5669
5726
|
const patchSelectedItemsStrokeStyle = useCallback(
|
|
5670
5727
|
(patch) => {
|
|
5671
5728
|
const change = onItemsChangeRef.current;
|
|
@@ -6472,7 +6529,8 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
6472
6529
|
items: sceneItems,
|
|
6473
6530
|
camera,
|
|
6474
6531
|
width: size.width,
|
|
6475
|
-
height: size.height
|
|
6532
|
+
height: size.height,
|
|
6533
|
+
renderTick: cameraTick
|
|
6476
6534
|
}
|
|
6477
6535
|
),
|
|
6478
6536
|
interactive && /* @__PURE__ */ jsx(
|
|
@@ -6486,9 +6544,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
6486
6544
|
placementPreview,
|
|
6487
6545
|
laserTrail,
|
|
6488
6546
|
eraserTrail,
|
|
6489
|
-
eraserPreviewItems
|
|
6490
|
-
(item) => eraserPreviewIds.includes(item.id)
|
|
6491
|
-
),
|
|
6547
|
+
eraserPreviewItems,
|
|
6492
6548
|
previewStrokeStyle: strokeStyleState,
|
|
6493
6549
|
remotePresence
|
|
6494
6550
|
}
|