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
|
@@ -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) {
|
|
@@ -2071,6 +2108,14 @@ async function loadSkiaImageFromHref(href) {
|
|
|
2071
2108
|
var nativeSkiaImageCache = createNativeImageCache({
|
|
2072
2109
|
loadImage: loadSkiaImageFromHref
|
|
2073
2110
|
});
|
|
2111
|
+
function resolveNativeImageLoadingState(href, loadedImage) {
|
|
2112
|
+
if (loadedImage?.image) return loadedImage;
|
|
2113
|
+
return { href, image: null };
|
|
2114
|
+
}
|
|
2115
|
+
function resolveNativeImageRenderValue(href, loadedImage) {
|
|
2116
|
+
if (!href) return null;
|
|
2117
|
+
return loadedImage?.image ?? null;
|
|
2118
|
+
}
|
|
2074
2119
|
function useCachedSkiaImage(href) {
|
|
2075
2120
|
const [loadedImage, setLoadedImage] = react.useState(
|
|
2076
2121
|
() => href ? { href, image: nativeSkiaImageCache.getCached(href) } : null
|
|
@@ -2087,7 +2132,9 @@ function useCachedSkiaImage(href) {
|
|
|
2087
2132
|
return releaseImage;
|
|
2088
2133
|
}
|
|
2089
2134
|
let active = true;
|
|
2090
|
-
setLoadedImage(
|
|
2135
|
+
setLoadedImage(
|
|
2136
|
+
(currentLoadedImage) => resolveNativeImageLoadingState(href, currentLoadedImage)
|
|
2137
|
+
);
|
|
2091
2138
|
void nativeSkiaImageCache.load(href).then(
|
|
2092
2139
|
(loadedImage2) => {
|
|
2093
2140
|
if (active) setLoadedImage({ href, image: loadedImage2 });
|
|
@@ -2101,8 +2148,7 @@ function useCachedSkiaImage(href) {
|
|
|
2101
2148
|
releaseImage();
|
|
2102
2149
|
};
|
|
2103
2150
|
}, [href]);
|
|
2104
|
-
|
|
2105
|
-
return loadedImage.image;
|
|
2151
|
+
return resolveNativeImageRenderValue(href, loadedImage);
|
|
2106
2152
|
}
|
|
2107
2153
|
|
|
2108
2154
|
// src/native/skia-transform.ts
|
|
@@ -3110,7 +3156,8 @@ function hitTestNativeSelectionHandle({
|
|
|
3110
3156
|
worldPoint.x,
|
|
3111
3157
|
worldPoint.y,
|
|
3112
3158
|
handleRadiusWorld,
|
|
3113
|
-
rotation
|
|
3159
|
+
rotation,
|
|
3160
|
+
resolveResizeHandlesForItem(selectedItem)
|
|
3114
3161
|
);
|
|
3115
3162
|
return handle ? { kind: "resize", handle } : null;
|
|
3116
3163
|
}
|
|
@@ -3146,7 +3193,6 @@ function nativeRotationDragStart(input) {
|
|
|
3146
3193
|
startRotation: input.item.rotation ?? 0
|
|
3147
3194
|
};
|
|
3148
3195
|
}
|
|
3149
|
-
var HANDLE_ORDER = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
3150
3196
|
var ERASER_PREVIEW_OPACITY = 0.3;
|
|
3151
3197
|
var OVERLAY_STROKE_PX = 1.25;
|
|
3152
3198
|
var MARQUEE_DASH_PX = 4;
|
|
@@ -3235,7 +3281,7 @@ function NativeInteractionOverlay({
|
|
|
3235
3281
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
|
|
3236
3282
|
}),
|
|
3237
3283
|
showResizeHandles && bSingle && single && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3238
|
-
|
|
3284
|
+
resolveResizeHandlesForItem(single).map((hid) => {
|
|
3239
3285
|
const p = getHandleWorldPositionRotated(bSingle, hid, rotSingle);
|
|
3240
3286
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNativeSkia.Group, { children: [
|
|
3241
3287
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5032,6 +5078,9 @@ function applyRotationFromPointer(item, startRotation, startPointerAngleRad, poi
|
|
|
5032
5078
|
}
|
|
5033
5079
|
function resizeItemByHandle(item, start, handle, currentWorld) {
|
|
5034
5080
|
const sb = normalizeRect(start.bounds);
|
|
5081
|
+
if (!itemAllowsResizeHandle(item, handle)) {
|
|
5082
|
+
return item;
|
|
5083
|
+
}
|
|
5035
5084
|
const newBoundsRaw = computeNewBoundsForResize(item, sb, handle, currentWorld);
|
|
5036
5085
|
const nb = normalizeRect(newBoundsRaw);
|
|
5037
5086
|
const k = item.toolKind;
|