canvu-react 0.4.46 → 0.4.48
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/{asset-hydration-Dc7fsnTG.d.ts → asset-hydration-BSjiek7Q.d.ts} +2 -2
- package/dist/{asset-hydration-Cy_2FyV5.d.cts → asset-hydration-F6aM5C7x.d.cts} +2 -2
- package/dist/{asset-store-TzOPvlgn.d.cts → asset-store-35ysK28r.d.cts} +1 -1
- package/dist/{asset-store-DQPRZEcy.d.ts → asset-store-D_FjW_CN.d.ts} +1 -1
- package/dist/chatbot.d.cts +6 -6
- package/dist/chatbot.d.ts +6 -6
- package/dist/index.cjs +49 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -1
- package/dist/{link-item-DwzXOwU5.d.cts → link-item-BMV3VUCr.d.cts} +1 -1
- package/dist/{link-item-IW4GTnxl.d.ts → link-item-COoNNvCu.d.ts} +1 -1
- package/dist/native.cjs +104 -51
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +6 -6
- package/dist/native.d.ts +6 -6
- package/dist/native.js +104 -51
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +259 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +29 -13
- package/dist/react.d.ts +29 -13
- package/dist/react.js +259 -18
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +3 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +8 -8
- package/dist/realtime.d.ts +8 -8
- package/dist/realtime.js +3 -1
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.d.cts +4 -4
- package/dist/realtimeNative.d.ts +4 -4
- package/dist/{shape-builders-Cyh8zvDG.d.ts → shape-builders-BCOAG0pS.d.ts} +1 -1
- package/dist/{shape-builders-CKEMjivV.d.cts → shape-builders-BmLS8CNh.d.cts} +1 -1
- package/dist/tldraw.cjs +3 -1
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.d.cts +1 -1
- package/dist/tldraw.d.ts +1 -1
- package/dist/tldraw.js +3 -1
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-BUPc2Zgw.d.cts → types-6HszqSa5.d.cts} +1 -1
- package/dist/{types-B7xZAKVJ.d.ts → types-BAEHaIYO.d.ts} +43 -6
- package/dist/{types-B82WiQQh.d.ts → types-BMMPUak7.d.ts} +1 -1
- package/dist/{types-BQUbxMgz.d.cts → types-BOQLWyCw.d.cts} +1 -1
- package/dist/{types-CYtq9Pr9.d.ts → types-BtWbGOqh.d.ts} +1 -1
- package/dist/{types-BCCvY6ie.d.cts → types-fJNwEnHf.d.cts} +35 -1
- package/dist/{types-BCCvY6ie.d.ts → types-fJNwEnHf.d.ts} +35 -1
- package/dist/{types-C4wI3Jyc.d.cts → types-uzeExFkd.d.cts} +43 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, V as VectorSceneItem } from './types-
|
|
1
|
+
import { R as Rect, V as VectorSceneItem } from './types-fJNwEnHf.cjs';
|
|
2
2
|
|
|
3
3
|
/** Plugin key under which link metadata is stored on a link item's `pluginData`. */
|
|
4
4
|
declare const LINK_PLUGIN_KEY = "canvuLink";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, V as VectorSceneItem } from './types-
|
|
1
|
+
import { R as Rect, V as VectorSceneItem } from './types-fJNwEnHf.js';
|
|
2
2
|
|
|
3
3
|
/** Plugin key under which link metadata is stored on a link item's `pluginData`. */
|
|
4
4
|
declare const LINK_PLUGIN_KEY = "canvuLink";
|
package/dist/native.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function buildCustomShapeChildrenSvg(inner, intrinsic, bounds) {
|
|
|
41
41
|
const sy = b.height / intrinsic.height;
|
|
42
42
|
return `<g transform="scale(${sx},${sy})">${inner}</g>`;
|
|
43
43
|
}
|
|
44
|
-
function createCustomShapeItem(id, bounds, content) {
|
|
44
|
+
function createCustomShapeItem(id, bounds, content, options = {}) {
|
|
45
45
|
const r = normalizeRect(bounds);
|
|
46
46
|
const intrinsic = { width: r.width, height: r.height };
|
|
47
47
|
const inner = resolveCustomInner(content, intrinsic);
|
|
@@ -53,6 +53,8 @@ function createCustomShapeItem(id, bounds, content) {
|
|
|
53
53
|
toolKind: "custom",
|
|
54
54
|
customIntrinsicSize: intrinsic,
|
|
55
55
|
customInnerSvg: inner,
|
|
56
|
+
...options.resizeHandles !== void 0 ? { customResizeHandles: options.resizeHandles } : {},
|
|
57
|
+
...options.svgClassName ? { svgClassName: options.svgClassName } : {},
|
|
56
58
|
childrenSvg: buildCustomShapeChildrenSvg(inner, intrinsic, r)
|
|
57
59
|
};
|
|
58
60
|
}
|
|
@@ -1595,7 +1597,42 @@ var styles = reactNative.StyleSheet.create({
|
|
|
1595
1597
|
});
|
|
1596
1598
|
|
|
1597
1599
|
// src/interaction/resize-handles.ts
|
|
1598
|
-
var
|
|
1600
|
+
var ALL_RESIZE_HANDLES = [
|
|
1601
|
+
"nw",
|
|
1602
|
+
"n",
|
|
1603
|
+
"ne",
|
|
1604
|
+
"e",
|
|
1605
|
+
"se",
|
|
1606
|
+
"s",
|
|
1607
|
+
"sw",
|
|
1608
|
+
"w"
|
|
1609
|
+
];
|
|
1610
|
+
var CORNER_RESIZE_HANDLES = [
|
|
1611
|
+
"nw",
|
|
1612
|
+
"ne",
|
|
1613
|
+
"se",
|
|
1614
|
+
"sw"
|
|
1615
|
+
];
|
|
1616
|
+
function dedupeHandles(handles) {
|
|
1617
|
+
const allowed = new Set(handles);
|
|
1618
|
+
return ALL_RESIZE_HANDLES.filter((handle) => allowed.has(handle));
|
|
1619
|
+
}
|
|
1620
|
+
function resolveCustomResizeHandles(handles) {
|
|
1621
|
+
if (handles === "corners") return CORNER_RESIZE_HANDLES;
|
|
1622
|
+
if (handles === "all" || handles === void 0) return ALL_RESIZE_HANDLES;
|
|
1623
|
+
return dedupeHandles(handles);
|
|
1624
|
+
}
|
|
1625
|
+
function resolveResizeHandlesForItem(item) {
|
|
1626
|
+
if (!item) return ALL_RESIZE_HANDLES;
|
|
1627
|
+
if (getLinkData(item)) return CORNER_RESIZE_HANDLES;
|
|
1628
|
+
if (item.toolKind === "custom") {
|
|
1629
|
+
return resolveCustomResizeHandles(item.customResizeHandles);
|
|
1630
|
+
}
|
|
1631
|
+
return ALL_RESIZE_HANDLES;
|
|
1632
|
+
}
|
|
1633
|
+
function itemAllowsResizeHandle(item, handle) {
|
|
1634
|
+
return resolveResizeHandlesForItem(item).includes(handle);
|
|
1635
|
+
}
|
|
1599
1636
|
function getHandleWorldPosition(bounds, id) {
|
|
1600
1637
|
const r = normalizeRect(bounds);
|
|
1601
1638
|
const cx = r.x + r.width / 2;
|
|
@@ -1619,7 +1656,7 @@ function getHandleWorldPosition(bounds, id) {
|
|
|
1619
1656
|
return { x: r.x, y: cy };
|
|
1620
1657
|
}
|
|
1621
1658
|
}
|
|
1622
|
-
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0) {
|
|
1659
|
+
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0, handles = ALL_RESIZE_HANDLES) {
|
|
1623
1660
|
const r = normalizeRect(bounds);
|
|
1624
1661
|
const pl = worldToItemLocal(
|
|
1625
1662
|
worldX,
|
|
@@ -1633,7 +1670,7 @@ function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad =
|
|
|
1633
1670
|
const localBounds2 = { x: 0, y: 0, width: r.width, height: r.height };
|
|
1634
1671
|
let best = null;
|
|
1635
1672
|
let bestD = radiusWorld;
|
|
1636
|
-
for (const id of
|
|
1673
|
+
for (const id of handles) {
|
|
1637
1674
|
const p = getHandleWorldPosition(localBounds2, id);
|
|
1638
1675
|
const d = Math.hypot(pl.x - p.x, pl.y - p.y);
|
|
1639
1676
|
if (d <= bestD) {
|
|
@@ -3032,6 +3069,35 @@ function resolveNativeStrokePreviewStyle(tool, previewStrokeStyle) {
|
|
|
3032
3069
|
};
|
|
3033
3070
|
}
|
|
3034
3071
|
|
|
3072
|
+
// src/native/native-stroke-preview.ts
|
|
3073
|
+
var NATIVE_STROKE_PREVIEW_MAX_POINTS = 160;
|
|
3074
|
+
function sampleNativeStrokePreviewPoints(points, maxPoints = NATIVE_STROKE_PREVIEW_MAX_POINTS) {
|
|
3075
|
+
if (points.length <= maxPoints) return points.map((point) => ({ ...point }));
|
|
3076
|
+
if (maxPoints <= 1) {
|
|
3077
|
+
const last2 = points[points.length - 1];
|
|
3078
|
+
return last2 ? [{ ...last2 }] : [];
|
|
3079
|
+
}
|
|
3080
|
+
const lastIndex = points.length - 1;
|
|
3081
|
+
const last = points[lastIndex];
|
|
3082
|
+
if (!last) return [];
|
|
3083
|
+
const step = lastIndex / (maxPoints - 1);
|
|
3084
|
+
return Array.from({ length: maxPoints }, (_, index) => {
|
|
3085
|
+
const point = points[Math.round(index * step)] ?? last;
|
|
3086
|
+
return { x: point.x, y: point.y };
|
|
3087
|
+
});
|
|
3088
|
+
}
|
|
3089
|
+
function buildNativeStrokePreviewPath(points) {
|
|
3090
|
+
if (points.length < 2) return null;
|
|
3091
|
+
const d = smoothFreehandPointsToPathD(points);
|
|
3092
|
+
return d || null;
|
|
3093
|
+
}
|
|
3094
|
+
function nativeStrokePreviewDashArray(style, tool) {
|
|
3095
|
+
if (style.strokeDash !== "dashed" || tool !== "draw") return void 0;
|
|
3096
|
+
const dash = Math.max(style.strokeWidth * 1.8, 4);
|
|
3097
|
+
const gap = Math.max(style.strokeWidth * 1.4, 3);
|
|
3098
|
+
return `${dash} ${gap}`;
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3035
3101
|
// src/native/native-vector-interactions.ts
|
|
3036
3102
|
var NATIVE_SELECTION_HANDLE_HIT_RADIUS_PX = 24;
|
|
3037
3103
|
function nativeItemPlacementBounds(item) {
|
|
@@ -3081,7 +3147,8 @@ function hitTestNativeSelectionHandle({
|
|
|
3081
3147
|
worldPoint.x,
|
|
3082
3148
|
worldPoint.y,
|
|
3083
3149
|
handleRadiusWorld,
|
|
3084
|
-
rotation
|
|
3150
|
+
rotation,
|
|
3151
|
+
resolveResizeHandlesForItem(selectedItem)
|
|
3085
3152
|
);
|
|
3086
3153
|
return handle ? { kind: "resize", handle } : null;
|
|
3087
3154
|
}
|
|
@@ -3117,7 +3184,6 @@ function nativeRotationDragStart(input) {
|
|
|
3117
3184
|
startRotation: input.item.rotation ?? 0
|
|
3118
3185
|
};
|
|
3119
3186
|
}
|
|
3120
|
-
var HANDLE_ORDER = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
3121
3187
|
var ERASER_PREVIEW_OPACITY = 0.3;
|
|
3122
3188
|
var OVERLAY_STROKE_PX = 1.25;
|
|
3123
3189
|
var MARQUEE_DASH_PX = 4;
|
|
@@ -3206,7 +3272,7 @@ function NativeInteractionOverlay({
|
|
|
3206
3272
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
|
|
3207
3273
|
}),
|
|
3208
3274
|
showResizeHandles && bSingle && single && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3209
|
-
|
|
3275
|
+
resolveResizeHandlesForItem(single).map((hid) => {
|
|
3210
3276
|
const p = getHandleWorldPositionRotated(bSingle, hid, rotSingle);
|
|
3211
3277
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNativeSkia.Group, { children: [
|
|
3212
3278
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3403,58 +3469,42 @@ function NativeInteractionOverlay({
|
|
|
3403
3469
|
p.tool,
|
|
3404
3470
|
p.style ?? previewStrokeStyle
|
|
3405
3471
|
);
|
|
3406
|
-
const
|
|
3407
|
-
|
|
3408
|
-
style
|
|
3409
|
-
isLaser ? "draw" : p.tool,
|
|
3410
|
-
p.points.length === 2
|
|
3472
|
+
const strokeColor = colorWithOpacity(
|
|
3473
|
+
style.stroke,
|
|
3474
|
+
isLaser ? 0.85 : style.strokeOpacity
|
|
3411
3475
|
);
|
|
3412
|
-
if (
|
|
3413
|
-
|
|
3476
|
+
if (p.points.length === 1) {
|
|
3477
|
+
const point = p.points[0];
|
|
3478
|
+
if (!point) return null;
|
|
3414
3479
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3415
3480
|
reactNativeSkia.Circle,
|
|
3416
3481
|
{
|
|
3417
|
-
cx:
|
|
3418
|
-
cy:
|
|
3419
|
-
r:
|
|
3420
|
-
color:
|
|
3421
|
-
style: "fill",
|
|
3422
|
-
antiAlias: true
|
|
3423
|
-
}
|
|
3424
|
-
);
|
|
3425
|
-
}
|
|
3426
|
-
if (payload.kind === "fillPath") {
|
|
3427
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3428
|
-
reactNativeSkia.Path,
|
|
3429
|
-
{
|
|
3430
|
-
path: payload.d,
|
|
3431
|
-
color: colorWithOpacity(payload.fill, payload.fillOpacity),
|
|
3482
|
+
cx: point.x,
|
|
3483
|
+
cy: point.y,
|
|
3484
|
+
r: Math.max(0.5, style.strokeWidth / 2),
|
|
3485
|
+
color: strokeColor,
|
|
3432
3486
|
style: "fill",
|
|
3433
|
-
fillType: "winding",
|
|
3434
3487
|
antiAlias: true
|
|
3435
3488
|
}
|
|
3436
3489
|
);
|
|
3437
3490
|
}
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
);
|
|
3456
|
-
}
|
|
3457
|
-
return null;
|
|
3491
|
+
const path = buildNativeStrokePreviewPath(p.points);
|
|
3492
|
+
if (!path) return null;
|
|
3493
|
+
const strokeDasharray = nativeStrokePreviewDashArray(style, p.tool);
|
|
3494
|
+
const intervals = dashIntervalsFromStrokeDasharray3(strokeDasharray);
|
|
3495
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3496
|
+
reactNativeSkia.Path,
|
|
3497
|
+
{
|
|
3498
|
+
path,
|
|
3499
|
+
color: strokeColor,
|
|
3500
|
+
style: "stroke",
|
|
3501
|
+
strokeWidth: style.strokeWidth,
|
|
3502
|
+
strokeCap: "round",
|
|
3503
|
+
strokeJoin: "round",
|
|
3504
|
+
antiAlias: true,
|
|
3505
|
+
children: intervals ? /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.DashPathEffect, { intervals }) : null
|
|
3506
|
+
}
|
|
3507
|
+
);
|
|
3458
3508
|
}
|
|
3459
3509
|
return null;
|
|
3460
3510
|
}, [placementPreview, previewStrokeStyle, overlayStrokeWorld, marqueeDashWorld]);
|
|
@@ -5019,6 +5069,9 @@ function applyRotationFromPointer(item, startRotation, startPointerAngleRad, poi
|
|
|
5019
5069
|
}
|
|
5020
5070
|
function resizeItemByHandle(item, start, handle, currentWorld) {
|
|
5021
5071
|
const sb = normalizeRect(start.bounds);
|
|
5072
|
+
if (!itemAllowsResizeHandle(item, handle)) {
|
|
5073
|
+
return item;
|
|
5074
|
+
}
|
|
5022
5075
|
const newBoundsRaw = computeNewBoundsForResize(item, sb, handle, currentWorld);
|
|
5023
5076
|
const nb = normalizeRect(newBoundsRaw);
|
|
5024
5077
|
const k = item.toolKind;
|
|
@@ -5896,7 +5949,7 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
5896
5949
|
setRealtimePlacementPreview({
|
|
5897
5950
|
kind: "stroke",
|
|
5898
5951
|
tool: st.tool,
|
|
5899
|
-
points:
|
|
5952
|
+
points: sampleNativeStrokePreviewPoints(pts),
|
|
5900
5953
|
style: { ...strokeStyleRef.current }
|
|
5901
5954
|
});
|
|
5902
5955
|
return;
|