canvu-react 0.4.47 → 0.4.49
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 +59 -10
- 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 +59 -10
- 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
package/dist/native.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as CanvuLinkData } from './link-item-
|
|
2
|
-
export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-
|
|
3
|
-
import { C as Camera2D, S as StrokeStyle } from './shape-builders-
|
|
4
|
-
export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-
|
|
5
|
-
import { V as VectorSceneItem, R as Rect } from './types-
|
|
1
|
+
import { C as CanvuLinkData } from './link-item-BMV3VUCr.cjs';
|
|
2
|
+
export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-BMV3VUCr.cjs';
|
|
3
|
+
import { C as Camera2D, S as StrokeStyle } from './shape-builders-BmLS8CNh.cjs';
|
|
4
|
+
export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-BmLS8CNh.cjs';
|
|
5
|
+
import { V as VectorSceneItem, R as Rect } from './types-fJNwEnHf.cjs';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
9
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
10
|
-
import { R as RemotePresencePeer } from './types-
|
|
10
|
+
import { R as RemotePresencePeer } from './types-BOQLWyCw.cjs';
|
|
11
11
|
|
|
12
12
|
type NativeImagesMenuLabels = {
|
|
13
13
|
title?: string;
|
package/dist/native.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as CanvuLinkData } from './link-item-
|
|
2
|
-
export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-
|
|
3
|
-
import { C as Camera2D, S as StrokeStyle } from './shape-builders-
|
|
4
|
-
export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-
|
|
5
|
-
import { V as VectorSceneItem, R as Rect } from './types-
|
|
1
|
+
import { C as CanvuLinkData } from './link-item-COoNNvCu.js';
|
|
2
|
+
export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-COoNNvCu.js';
|
|
3
|
+
import { C as Camera2D, S as StrokeStyle } from './shape-builders-BCOAG0pS.js';
|
|
4
|
+
export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-BCOAG0pS.js';
|
|
5
|
+
import { V as VectorSceneItem, R as Rect } from './types-fJNwEnHf.js';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import { ReactNode } from 'react';
|
|
9
9
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
10
|
-
import { R as RemotePresencePeer } from './types-
|
|
10
|
+
import { R as RemotePresencePeer } from './types-BMMPUak7.js';
|
|
11
11
|
|
|
12
12
|
type NativeImagesMenuLabels = {
|
|
13
13
|
title?: string;
|
package/dist/native.js
CHANGED
|
@@ -35,7 +35,7 @@ function buildCustomShapeChildrenSvg(inner, intrinsic, bounds) {
|
|
|
35
35
|
const sy = b.height / intrinsic.height;
|
|
36
36
|
return `<g transform="scale(${sx},${sy})">${inner}</g>`;
|
|
37
37
|
}
|
|
38
|
-
function createCustomShapeItem(id, bounds, content) {
|
|
38
|
+
function createCustomShapeItem(id, bounds, content, options = {}) {
|
|
39
39
|
const r = normalizeRect(bounds);
|
|
40
40
|
const intrinsic = { width: r.width, height: r.height };
|
|
41
41
|
const inner = resolveCustomInner(content, intrinsic);
|
|
@@ -47,6 +47,8 @@ function createCustomShapeItem(id, bounds, content) {
|
|
|
47
47
|
toolKind: "custom",
|
|
48
48
|
customIntrinsicSize: intrinsic,
|
|
49
49
|
customInnerSvg: inner,
|
|
50
|
+
...options.resizeHandles !== void 0 ? { customResizeHandles: options.resizeHandles } : {},
|
|
51
|
+
...options.svgClassName ? { svgClassName: options.svgClassName } : {},
|
|
50
52
|
childrenSvg: buildCustomShapeChildrenSvg(inner, intrinsic, r)
|
|
51
53
|
};
|
|
52
54
|
}
|
|
@@ -1589,7 +1591,42 @@ var styles = StyleSheet.create({
|
|
|
1589
1591
|
});
|
|
1590
1592
|
|
|
1591
1593
|
// src/interaction/resize-handles.ts
|
|
1592
|
-
var
|
|
1594
|
+
var ALL_RESIZE_HANDLES = [
|
|
1595
|
+
"nw",
|
|
1596
|
+
"n",
|
|
1597
|
+
"ne",
|
|
1598
|
+
"e",
|
|
1599
|
+
"se",
|
|
1600
|
+
"s",
|
|
1601
|
+
"sw",
|
|
1602
|
+
"w"
|
|
1603
|
+
];
|
|
1604
|
+
var CORNER_RESIZE_HANDLES = [
|
|
1605
|
+
"nw",
|
|
1606
|
+
"ne",
|
|
1607
|
+
"se",
|
|
1608
|
+
"sw"
|
|
1609
|
+
];
|
|
1610
|
+
function dedupeHandles(handles) {
|
|
1611
|
+
const allowed = new Set(handles);
|
|
1612
|
+
return ALL_RESIZE_HANDLES.filter((handle) => allowed.has(handle));
|
|
1613
|
+
}
|
|
1614
|
+
function resolveCustomResizeHandles(handles) {
|
|
1615
|
+
if (handles === "corners") return CORNER_RESIZE_HANDLES;
|
|
1616
|
+
if (handles === "all" || handles === void 0) return ALL_RESIZE_HANDLES;
|
|
1617
|
+
return dedupeHandles(handles);
|
|
1618
|
+
}
|
|
1619
|
+
function resolveResizeHandlesForItem(item) {
|
|
1620
|
+
if (!item) return ALL_RESIZE_HANDLES;
|
|
1621
|
+
if (getLinkData(item)) return CORNER_RESIZE_HANDLES;
|
|
1622
|
+
if (item.toolKind === "custom") {
|
|
1623
|
+
return resolveCustomResizeHandles(item.customResizeHandles);
|
|
1624
|
+
}
|
|
1625
|
+
return ALL_RESIZE_HANDLES;
|
|
1626
|
+
}
|
|
1627
|
+
function itemAllowsResizeHandle(item, handle) {
|
|
1628
|
+
return resolveResizeHandlesForItem(item).includes(handle);
|
|
1629
|
+
}
|
|
1593
1630
|
function getHandleWorldPosition(bounds, id) {
|
|
1594
1631
|
const r = normalizeRect(bounds);
|
|
1595
1632
|
const cx = r.x + r.width / 2;
|
|
@@ -1613,7 +1650,7 @@ function getHandleWorldPosition(bounds, id) {
|
|
|
1613
1650
|
return { x: r.x, y: cy };
|
|
1614
1651
|
}
|
|
1615
1652
|
}
|
|
1616
|
-
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0) {
|
|
1653
|
+
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0, handles = ALL_RESIZE_HANDLES) {
|
|
1617
1654
|
const r = normalizeRect(bounds);
|
|
1618
1655
|
const pl = worldToItemLocal(
|
|
1619
1656
|
worldX,
|
|
@@ -1627,7 +1664,7 @@ function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad =
|
|
|
1627
1664
|
const localBounds2 = { x: 0, y: 0, width: r.width, height: r.height };
|
|
1628
1665
|
let best = null;
|
|
1629
1666
|
let bestD = radiusWorld;
|
|
1630
|
-
for (const id of
|
|
1667
|
+
for (const id of handles) {
|
|
1631
1668
|
const p = getHandleWorldPosition(localBounds2, id);
|
|
1632
1669
|
const d = Math.hypot(pl.x - p.x, pl.y - p.y);
|
|
1633
1670
|
if (d <= bestD) {
|
|
@@ -2065,6 +2102,14 @@ async function loadSkiaImageFromHref(href) {
|
|
|
2065
2102
|
var nativeSkiaImageCache = createNativeImageCache({
|
|
2066
2103
|
loadImage: loadSkiaImageFromHref
|
|
2067
2104
|
});
|
|
2105
|
+
function resolveNativeImageLoadingState(href, loadedImage) {
|
|
2106
|
+
if (loadedImage?.image) return loadedImage;
|
|
2107
|
+
return { href, image: null };
|
|
2108
|
+
}
|
|
2109
|
+
function resolveNativeImageRenderValue(href, loadedImage) {
|
|
2110
|
+
if (!href) return null;
|
|
2111
|
+
return loadedImage?.image ?? null;
|
|
2112
|
+
}
|
|
2068
2113
|
function useCachedSkiaImage(href) {
|
|
2069
2114
|
const [loadedImage, setLoadedImage] = useState(
|
|
2070
2115
|
() => href ? { href, image: nativeSkiaImageCache.getCached(href) } : null
|
|
@@ -2081,7 +2126,9 @@ function useCachedSkiaImage(href) {
|
|
|
2081
2126
|
return releaseImage;
|
|
2082
2127
|
}
|
|
2083
2128
|
let active = true;
|
|
2084
|
-
setLoadedImage(
|
|
2129
|
+
setLoadedImage(
|
|
2130
|
+
(currentLoadedImage) => resolveNativeImageLoadingState(href, currentLoadedImage)
|
|
2131
|
+
);
|
|
2085
2132
|
void nativeSkiaImageCache.load(href).then(
|
|
2086
2133
|
(loadedImage2) => {
|
|
2087
2134
|
if (active) setLoadedImage({ href, image: loadedImage2 });
|
|
@@ -2095,8 +2142,7 @@ function useCachedSkiaImage(href) {
|
|
|
2095
2142
|
releaseImage();
|
|
2096
2143
|
};
|
|
2097
2144
|
}, [href]);
|
|
2098
|
-
|
|
2099
|
-
return loadedImage.image;
|
|
2145
|
+
return resolveNativeImageRenderValue(href, loadedImage);
|
|
2100
2146
|
}
|
|
2101
2147
|
|
|
2102
2148
|
// src/native/skia-transform.ts
|
|
@@ -3104,7 +3150,8 @@ function hitTestNativeSelectionHandle({
|
|
|
3104
3150
|
worldPoint.x,
|
|
3105
3151
|
worldPoint.y,
|
|
3106
3152
|
handleRadiusWorld,
|
|
3107
|
-
rotation
|
|
3153
|
+
rotation,
|
|
3154
|
+
resolveResizeHandlesForItem(selectedItem)
|
|
3108
3155
|
);
|
|
3109
3156
|
return handle ? { kind: "resize", handle } : null;
|
|
3110
3157
|
}
|
|
@@ -3140,7 +3187,6 @@ function nativeRotationDragStart(input) {
|
|
|
3140
3187
|
startRotation: input.item.rotation ?? 0
|
|
3141
3188
|
};
|
|
3142
3189
|
}
|
|
3143
|
-
var HANDLE_ORDER = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
3144
3190
|
var ERASER_PREVIEW_OPACITY = 0.3;
|
|
3145
3191
|
var OVERLAY_STROKE_PX = 1.25;
|
|
3146
3192
|
var MARQUEE_DASH_PX = 4;
|
|
@@ -3229,7 +3275,7 @@ function NativeInteractionOverlay({
|
|
|
3229
3275
|
return /* @__PURE__ */ jsx(Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
|
|
3230
3276
|
}),
|
|
3231
3277
|
showResizeHandles && bSingle && single && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3232
|
-
|
|
3278
|
+
resolveResizeHandlesForItem(single).map((hid) => {
|
|
3233
3279
|
const p = getHandleWorldPositionRotated(bSingle, hid, rotSingle);
|
|
3234
3280
|
return /* @__PURE__ */ jsxs(Group, { children: [
|
|
3235
3281
|
/* @__PURE__ */ jsx(
|
|
@@ -5026,6 +5072,9 @@ function applyRotationFromPointer(item, startRotation, startPointerAngleRad, poi
|
|
|
5026
5072
|
}
|
|
5027
5073
|
function resizeItemByHandle(item, start, handle, currentWorld) {
|
|
5028
5074
|
const sb = normalizeRect(start.bounds);
|
|
5075
|
+
if (!itemAllowsResizeHandle(item, handle)) {
|
|
5076
|
+
return item;
|
|
5077
|
+
}
|
|
5029
5078
|
const newBoundsRaw = computeNewBoundsForResize(item, sb, handle, currentWorld);
|
|
5030
5079
|
const nb = normalizeRect(newBoundsRaw);
|
|
5031
5080
|
const k = item.toolKind;
|