canvu-react 0.4.47 → 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.
Files changed (51) hide show
  1. package/dist/{asset-hydration-Dc7fsnTG.d.ts → asset-hydration-BSjiek7Q.d.ts} +2 -2
  2. package/dist/{asset-hydration-Cy_2FyV5.d.cts → asset-hydration-F6aM5C7x.d.cts} +2 -2
  3. package/dist/{asset-store-TzOPvlgn.d.cts → asset-store-35ysK28r.d.cts} +1 -1
  4. package/dist/{asset-store-DQPRZEcy.d.ts → asset-store-D_FjW_CN.d.ts} +1 -1
  5. package/dist/chatbot.d.cts +6 -6
  6. package/dist/chatbot.d.ts +6 -6
  7. package/dist/index.cjs +49 -1
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +53 -9
  10. package/dist/index.d.ts +53 -9
  11. package/dist/index.js +49 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/{link-item-DwzXOwU5.d.cts → link-item-BMV3VUCr.d.cts} +1 -1
  14. package/dist/{link-item-IW4GTnxl.d.ts → link-item-COoNNvCu.d.ts} +1 -1
  15. package/dist/native.cjs +47 -7
  16. package/dist/native.cjs.map +1 -1
  17. package/dist/native.d.cts +6 -6
  18. package/dist/native.d.ts +6 -6
  19. package/dist/native.js +47 -7
  20. package/dist/native.js.map +1 -1
  21. package/dist/react.cjs +259 -18
  22. package/dist/react.cjs.map +1 -1
  23. package/dist/react.d.cts +29 -13
  24. package/dist/react.d.ts +29 -13
  25. package/dist/react.js +259 -18
  26. package/dist/react.js.map +1 -1
  27. package/dist/realtime.cjs +3 -1
  28. package/dist/realtime.cjs.map +1 -1
  29. package/dist/realtime.d.cts +8 -8
  30. package/dist/realtime.d.ts +8 -8
  31. package/dist/realtime.js +3 -1
  32. package/dist/realtime.js.map +1 -1
  33. package/dist/realtimeNative.d.cts +4 -4
  34. package/dist/realtimeNative.d.ts +4 -4
  35. package/dist/{shape-builders-Cyh8zvDG.d.ts → shape-builders-BCOAG0pS.d.ts} +1 -1
  36. package/dist/{shape-builders-CKEMjivV.d.cts → shape-builders-BmLS8CNh.d.cts} +1 -1
  37. package/dist/tldraw.cjs +3 -1
  38. package/dist/tldraw.cjs.map +1 -1
  39. package/dist/tldraw.d.cts +1 -1
  40. package/dist/tldraw.d.ts +1 -1
  41. package/dist/tldraw.js +3 -1
  42. package/dist/tldraw.js.map +1 -1
  43. package/dist/{types-BUPc2Zgw.d.cts → types-6HszqSa5.d.cts} +1 -1
  44. package/dist/{types-B7xZAKVJ.d.ts → types-BAEHaIYO.d.ts} +43 -6
  45. package/dist/{types-B82WiQQh.d.ts → types-BMMPUak7.d.ts} +1 -1
  46. package/dist/{types-BQUbxMgz.d.cts → types-BOQLWyCw.d.cts} +1 -1
  47. package/dist/{types-CYtq9Pr9.d.ts → types-BtWbGOqh.d.ts} +1 -1
  48. package/dist/{types-BCCvY6ie.d.cts → types-fJNwEnHf.d.cts} +35 -1
  49. package/dist/{types-BCCvY6ie.d.ts → types-fJNwEnHf.d.ts} +35 -1
  50. package/dist/{types-C4wI3Jyc.d.cts → types-uzeExFkd.d.cts} +43 -6
  51. package/package.json +1 -1
package/dist/native.d.cts CHANGED
@@ -1,13 +1,13 @@
1
- import { C as CanvuLinkData } from './link-item-DwzXOwU5.cjs';
2
- export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-DwzXOwU5.cjs';
3
- import { C as Camera2D, S as StrokeStyle } from './shape-builders-CKEMjivV.cjs';
4
- export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-CKEMjivV.cjs';
5
- import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.cjs';
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-BQUbxMgz.cjs';
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-IW4GTnxl.js';
2
- export { D as DEFAULT_LINK_CARD_SIZE, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-IW4GTnxl.js';
3
- import { C as Camera2D, S as StrokeStyle } from './shape-builders-Cyh8zvDG.js';
4
- export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-Cyh8zvDG.js';
5
- import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.js';
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-B82WiQQh.js';
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 HANDLE_IDS = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
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 HANDLE_IDS) {
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) {
@@ -3104,7 +3141,8 @@ function hitTestNativeSelectionHandle({
3104
3141
  worldPoint.x,
3105
3142
  worldPoint.y,
3106
3143
  handleRadiusWorld,
3107
- rotation
3144
+ rotation,
3145
+ resolveResizeHandlesForItem(selectedItem)
3108
3146
  );
3109
3147
  return handle ? { kind: "resize", handle } : null;
3110
3148
  }
@@ -3140,7 +3178,6 @@ function nativeRotationDragStart(input) {
3140
3178
  startRotation: input.item.rotation ?? 0
3141
3179
  };
3142
3180
  }
3143
- var HANDLE_ORDER = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
3144
3181
  var ERASER_PREVIEW_OPACITY = 0.3;
3145
3182
  var OVERLAY_STROKE_PX = 1.25;
3146
3183
  var MARQUEE_DASH_PX = 4;
@@ -3229,7 +3266,7 @@ function NativeInteractionOverlay({
3229
3266
  return /* @__PURE__ */ jsx(Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
3230
3267
  }),
3231
3268
  showResizeHandles && bSingle && single && /* @__PURE__ */ jsxs(Fragment, { children: [
3232
- HANDLE_ORDER.map((hid) => {
3269
+ resolveResizeHandlesForItem(single).map((hid) => {
3233
3270
  const p = getHandleWorldPositionRotated(bSingle, hid, rotSingle);
3234
3271
  return /* @__PURE__ */ jsxs(Group, { children: [
3235
3272
  /* @__PURE__ */ jsx(
@@ -5026,6 +5063,9 @@ function applyRotationFromPointer(item, startRotation, startPointerAngleRad, poi
5026
5063
  }
5027
5064
  function resizeItemByHandle(item, start, handle, currentWorld) {
5028
5065
  const sb = normalizeRect(start.bounds);
5066
+ if (!itemAllowsResizeHandle(item, handle)) {
5067
+ return item;
5068
+ }
5029
5069
  const newBoundsRaw = computeNewBoundsForResize(item, sb, handle, currentWorld);
5030
5070
  const nb = normalizeRect(newBoundsRaw);
5031
5071
  const k = item.toolKind;