canvu-react 0.4.51 → 0.4.53
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 +43 -107
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +43 -107
- package/dist/native.js.map +1 -1
- package/package.json +1 -1
package/dist/native.cjs
CHANGED
|
@@ -3078,38 +3078,6 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
|
|
|
3078
3078
|
};
|
|
3079
3079
|
}
|
|
3080
3080
|
|
|
3081
|
-
// src/native/native-stroke-preview.ts
|
|
3082
|
-
var NATIVE_STROKE_PREVIEW_MAX_POINTS = 160;
|
|
3083
|
-
function sampleNativeStrokePreviewPoints(points, maxPoints = NATIVE_STROKE_PREVIEW_MAX_POINTS) {
|
|
3084
|
-
if (points.length <= maxPoints) return points.map((point) => ({ ...point }));
|
|
3085
|
-
if (maxPoints <= 1) {
|
|
3086
|
-
const last2 = points[points.length - 1];
|
|
3087
|
-
return last2 ? [{ ...last2 }] : [];
|
|
3088
|
-
}
|
|
3089
|
-
const lastIndex = points.length - 1;
|
|
3090
|
-
const last = points[lastIndex];
|
|
3091
|
-
if (!last) return [];
|
|
3092
|
-
const step = lastIndex / (maxPoints - 1);
|
|
3093
|
-
return Array.from({ length: maxPoints }, (_, index) => {
|
|
3094
|
-
const point = points[Math.round(index * step)] ?? last;
|
|
3095
|
-
return { x: point.x, y: point.y };
|
|
3096
|
-
});
|
|
3097
|
-
}
|
|
3098
|
-
function buildNativeStrokePreviewPath(points) {
|
|
3099
|
-
if (points.length < 2) return null;
|
|
3100
|
-
const d = smoothFreehandPointsToPathD(points);
|
|
3101
|
-
return d || null;
|
|
3102
|
-
}
|
|
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
|
-
);
|
|
3111
|
-
}
|
|
3112
|
-
|
|
3113
3081
|
// src/native/native-vector-interactions.ts
|
|
3114
3082
|
var NATIVE_SELECTION_HANDLE_HIT_RADIUS_PX = 24;
|
|
3115
3083
|
function nativeItemPlacementBounds(item) {
|
|
@@ -3481,90 +3449,58 @@ function NativeInteractionOverlay({
|
|
|
3481
3449
|
p.tool,
|
|
3482
3450
|
p.style ?? previewStrokeStyle
|
|
3483
3451
|
);
|
|
3484
|
-
const
|
|
3485
|
-
|
|
3486
|
-
|
|
3452
|
+
const payload = computeFreehandSvgPayload(
|
|
3453
|
+
p.points,
|
|
3454
|
+
style,
|
|
3455
|
+
isLaser ? "draw" : p.tool,
|
|
3456
|
+
p.points.length === 2
|
|
3487
3457
|
);
|
|
3488
|
-
if (!
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3458
|
+
if (!payload) return null;
|
|
3459
|
+
if (payload.kind === "circle") {
|
|
3460
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3461
|
+
reactNativeSkia.Circle,
|
|
3462
|
+
{
|
|
3463
|
+
cx: payload.cx,
|
|
3464
|
+
cy: payload.cy,
|
|
3465
|
+
r: payload.r,
|
|
3466
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3467
|
+
style: "fill",
|
|
3468
|
+
antiAlias: true
|
|
3469
|
+
}
|
|
3493
3470
|
);
|
|
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
3471
|
}
|
|
3539
|
-
if (
|
|
3540
|
-
const point = p.points[0];
|
|
3541
|
-
if (!point) return null;
|
|
3472
|
+
if (payload.kind === "fillPath") {
|
|
3542
3473
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3543
|
-
reactNativeSkia.
|
|
3474
|
+
reactNativeSkia.Path,
|
|
3544
3475
|
{
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
r: Math.max(0.5, style.strokeWidth / 2),
|
|
3548
|
-
color: strokeColor,
|
|
3476
|
+
path: payload.d,
|
|
3477
|
+
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3549
3478
|
style: "fill",
|
|
3479
|
+
fillType: "winding",
|
|
3550
3480
|
antiAlias: true
|
|
3551
3481
|
}
|
|
3552
3482
|
);
|
|
3553
3483
|
}
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3484
|
+
if (payload.kind === "strokePath") {
|
|
3485
|
+
const intervals = dashIntervalsFromStrokeDasharray3(payload.strokeDasharray);
|
|
3486
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3487
|
+
reactNativeSkia.Path,
|
|
3488
|
+
{
|
|
3489
|
+
path: payload.d,
|
|
3490
|
+
color: colorWithOpacity(
|
|
3491
|
+
payload.stroke,
|
|
3492
|
+
isLaser ? 0.85 : payload.strokeOpacity
|
|
3493
|
+
),
|
|
3494
|
+
style: "stroke",
|
|
3495
|
+
strokeWidth: payload.strokeWidth,
|
|
3496
|
+
strokeCap: "round",
|
|
3497
|
+
strokeJoin: "round",
|
|
3498
|
+
antiAlias: true,
|
|
3499
|
+
children: intervals ? /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.DashPathEffect, { intervals }) : null
|
|
3500
|
+
}
|
|
3501
|
+
);
|
|
3502
|
+
}
|
|
3503
|
+
return null;
|
|
3568
3504
|
}
|
|
3569
3505
|
return null;
|
|
3570
3506
|
}, [placementPreview, previewStrokeStyle, overlayStrokeWorld, marqueeDashWorld]);
|
|
@@ -6015,7 +5951,7 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
6015
5951
|
setRealtimePlacementPreview({
|
|
6016
5952
|
kind: "stroke",
|
|
6017
5953
|
tool: st.tool,
|
|
6018
|
-
points:
|
|
5954
|
+
points: [...pts],
|
|
6019
5955
|
style: { ...strokeStyleRef.current }
|
|
6020
5956
|
});
|
|
6021
5957
|
return;
|