canvu-react 0.3.28 → 0.3.30

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 (45) hide show
  1. package/dist/{asset-hydration-BEG21hMp.d.ts → asset-hydration-DrTOgDdd.d.ts} +2 -2
  2. package/dist/{asset-hydration-3Iv5xHxM.d.cts → asset-hydration-EtEuBwb7.d.cts} +2 -2
  3. package/dist/{camera-KwCYYPhm.d.ts → camera-AoTwBSoE.d.ts} +1 -1
  4. package/dist/{camera-BwQjm5oh.d.cts → camera-Di5R_Rwl.d.cts} +1 -1
  5. package/dist/chatbot.d.cts +4 -4
  6. package/dist/chatbot.d.ts +4 -4
  7. package/dist/index.cjs +118 -1
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +6 -6
  10. package/dist/index.d.ts +6 -6
  11. package/dist/index.js +116 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/native.cjs +99 -0
  14. package/dist/native.cjs.map +1 -1
  15. package/dist/native.d.cts +2 -2
  16. package/dist/native.d.ts +2 -2
  17. package/dist/native.js +99 -0
  18. package/dist/native.js.map +1 -1
  19. package/dist/react.cjs +183 -7
  20. package/dist/react.cjs.map +1 -1
  21. package/dist/react.d.cts +15 -12
  22. package/dist/react.d.ts +15 -12
  23. package/dist/react.js +183 -8
  24. package/dist/react.js.map +1 -1
  25. package/dist/realtime.cjs +10 -0
  26. package/dist/realtime.cjs.map +1 -1
  27. package/dist/realtime.d.cts +6 -6
  28. package/dist/realtime.d.ts +6 -6
  29. package/dist/realtime.js +10 -0
  30. package/dist/realtime.js.map +1 -1
  31. package/dist/{shape-builders-DFudWDFI.d.cts → shape-builders-CsSXKCcs.d.ts} +43 -2
  32. package/dist/{shape-builders-ENwnK-zT.d.ts → shape-builders-CsbSRZnQ.d.cts} +43 -2
  33. package/dist/tldraw.cjs +101 -2
  34. package/dist/tldraw.cjs.map +1 -1
  35. package/dist/tldraw.d.cts +1 -1
  36. package/dist/tldraw.d.ts +1 -1
  37. package/dist/tldraw.js +101 -2
  38. package/dist/tldraw.js.map +1 -1
  39. package/dist/{types-DNwjgs5U.d.cts → types-B2Na677H.d.cts} +1 -1
  40. package/dist/{types-BLXR7g_L.d.cts → types-B6PAYKzx.d.ts} +4 -4
  41. package/dist/{types-CB0TZZuk.d.cts → types-Bnq2HtHQ.d.cts} +1 -1
  42. package/dist/{types-CB0TZZuk.d.ts → types-Bnq2HtHQ.d.ts} +1 -1
  43. package/dist/{types-Cm7IsgL4.d.ts → types-DWGk2_GZ.d.cts} +4 -4
  44. package/dist/{types-BtAJFS_-.d.ts → types-zmUah-vP.d.ts} +1 -1
  45. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as Camera2D } from './camera-BwQjm5oh.cjs';
2
- export { a as Camera2DOptions } from './camera-BwQjm5oh.cjs';
3
- import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-CB0TZZuk.cjs';
4
- export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-CB0TZZuk.cjs';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-3Iv5xHxM.cjs';
6
- export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, a as applyStrokeToItem, b as buildArrowSvg, c as buildDrawDotSvg, d as buildEllipseSvg, e as buildFreehandPathSvg, f as buildLineSvg, g as buildRectSvg, h as computeFreehandSvgPayload, i as createDrawDotItem, j as createEllipseItem, k as createFreehandStrokeItem, l as createImageFromVectorTrace, m as createImageItem, n as createLineItem, o as createRectangleItem, p as createShapeId, q as createTextItem, r as lineEndpointsToLocal, s as rebuildItemSvg, t as resolveStrokeStyle } from './shape-builders-DFudWDFI.cjs';
1
+ import { C as Camera2D } from './camera-Di5R_Rwl.cjs';
2
+ export { a as Camera2DOptions } from './camera-Di5R_Rwl.cjs';
3
+ import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-Bnq2HtHQ.cjs';
4
+ export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-Bnq2HtHQ.cjs';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-EtEuBwb7.cjs';
6
+ export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, a as applyStrokeToItem, b as buildArchitecturalCloudPathD, c as buildArchitecturalCloudSvg, d as buildArrowSvg, e as buildDrawDotSvg, f as buildEllipseSvg, g as buildFreehandPathSvg, h as buildLineSvg, i as buildRectSvg, j as computeFreehandSvgPayload, k as createArchitecturalCloudItem, l as createDrawDotItem, m as createEllipseItem, n as createFreehandStrokeItem, o as createImageFromVectorTrace, p as createImageItem, q as createLineItem, r as createRectangleItem, s as createShapeId, t as createTextItem, u as lineEndpointsToLocal, v as rebuildItemSvg, w as resolveStrokeStyle } from './shape-builders-CsbSRZnQ.cjs';
7
7
 
8
8
  type EncodeCanvasToBlobOptions = {
9
9
  mimeType?: string;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as Camera2D } from './camera-KwCYYPhm.js';
2
- export { a as Camera2DOptions } from './camera-KwCYYPhm.js';
3
- import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-CB0TZZuk.js';
4
- export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-CB0TZZuk.js';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-BEG21hMp.js';
6
- export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, a as applyStrokeToItem, b as buildArrowSvg, c as buildDrawDotSvg, d as buildEllipseSvg, e as buildFreehandPathSvg, f as buildLineSvg, g as buildRectSvg, h as computeFreehandSvgPayload, i as createDrawDotItem, j as createEllipseItem, k as createFreehandStrokeItem, l as createImageFromVectorTrace, m as createImageItem, n as createLineItem, o as createRectangleItem, p as createShapeId, q as createTextItem, r as lineEndpointsToLocal, s as rebuildItemSvg, t as resolveStrokeStyle } from './shape-builders-ENwnK-zT.js';
1
+ import { C as Camera2D } from './camera-AoTwBSoE.js';
2
+ export { a as Camera2DOptions } from './camera-AoTwBSoE.js';
3
+ import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-Bnq2HtHQ.js';
4
+ export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-Bnq2HtHQ.js';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-DrTOgDdd.js';
6
+ export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, a as applyStrokeToItem, b as buildArchitecturalCloudPathD, c as buildArchitecturalCloudSvg, d as buildArrowSvg, e as buildDrawDotSvg, f as buildEllipseSvg, g as buildFreehandPathSvg, h as buildLineSvg, i as buildRectSvg, j as computeFreehandSvgPayload, k as createArchitecturalCloudItem, l as createDrawDotItem, m as createEllipseItem, n as createFreehandStrokeItem, o as createImageFromVectorTrace, p as createImageItem, q as createLineItem, r as createRectangleItem, s as createShapeId, t as createTextItem, u as lineEndpointsToLocal, v as rebuildItemSvg, w as resolveStrokeStyle } from './shape-builders-CsSXKCcs.js';
7
7
 
8
8
  type EncodeCanvasToBlobOptions = {
9
9
  mimeType?: string;
package/dist/index.js CHANGED
@@ -1038,6 +1038,41 @@ function resolveStrokeStyle(item) {
1038
1038
  function strokeOpacityAttr(style) {
1039
1039
  return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
1040
1040
  }
1041
+ function clampNumber(value, min, max) {
1042
+ return Math.min(max, Math.max(min, value));
1043
+ }
1044
+ function svgNumber(value) {
1045
+ if (!Number.isFinite(value)) return "0";
1046
+ return Number(value.toFixed(3)).toString();
1047
+ }
1048
+ function architecturalCloudScallopCount(length, depth) {
1049
+ if (length <= 1e-6) return 0;
1050
+ return Math.max(1, Math.round(length / Math.max(depth * 2.05, 8)));
1051
+ }
1052
+ function appendHorizontalScallops(segments, startX, endX, y, controlY, count) {
1053
+ if (count <= 0) return;
1054
+ const step = (endX - startX) / count;
1055
+ for (let index = 1; index <= count; index += 1) {
1056
+ const x0 = startX + step * (index - 1);
1057
+ const x1 = index === count ? endX : startX + step * index;
1058
+ const cx = (x0 + x1) / 2;
1059
+ segments.push(
1060
+ `Q${svgNumber(cx)} ${svgNumber(controlY)} ${svgNumber(x1)} ${svgNumber(y)}`
1061
+ );
1062
+ }
1063
+ }
1064
+ function appendVerticalScallops(segments, startY, endY, x, controlX, count) {
1065
+ if (count <= 0) return;
1066
+ const step = (endY - startY) / count;
1067
+ for (let index = 1; index <= count; index += 1) {
1068
+ const y0 = startY + step * (index - 1);
1069
+ const y1 = index === count ? endY : startY + step * index;
1070
+ const cy = (y0 + y1) / 2;
1071
+ segments.push(
1072
+ `Q${svgNumber(controlX)} ${svgNumber(cy)} ${svgNumber(x)} ${svgNumber(y1)}`
1073
+ );
1074
+ }
1075
+ }
1041
1076
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
1042
1077
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
1043
1078
  }
@@ -1046,6 +1081,63 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
1046
1081
  const ry = height / 2;
1047
1082
  return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
1048
1083
  }
1084
+ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
1085
+ const w = Math.max(0, width);
1086
+ const h = Math.max(0, height);
1087
+ if (w <= 0 || h <= 0) return "";
1088
+ const inset = Math.min(w / 2, h / 2, Math.max(0.5, strokeWidth / 2));
1089
+ const x0 = inset;
1090
+ const y0 = inset;
1091
+ const x1 = Math.max(x0, w - inset);
1092
+ const y1 = Math.max(y0, h - inset);
1093
+ const innerW = Math.max(0, x1 - x0);
1094
+ const innerH = Math.max(0, y1 - y0);
1095
+ if (innerW <= 0 || innerH <= 0) return "";
1096
+ const maxDepth = Math.max(0.5, Math.min(innerW, innerH) * 0.18);
1097
+ const depth = clampNumber(Math.min(w, h) * 0.08, 2, Math.min(12, maxDepth));
1098
+ const corner = Math.min(depth * 1.2, innerW / 2, innerH / 2);
1099
+ const topStart = x0 + corner;
1100
+ const topEnd = x1 - corner;
1101
+ const rightStart = y0 + corner;
1102
+ const rightEnd = y1 - corner;
1103
+ const bottomStart = x1 - corner;
1104
+ const bottomEnd = x0 + corner;
1105
+ const leftStart = y1 - corner;
1106
+ const leftEnd = y0 + corner;
1107
+ const topCount = architecturalCloudScallopCount(topEnd - topStart, depth);
1108
+ const rightCount = architecturalCloudScallopCount(rightEnd - rightStart, depth);
1109
+ const bottomCount = architecturalCloudScallopCount(bottomStart - bottomEnd, depth);
1110
+ const leftCount = architecturalCloudScallopCount(leftStart - leftEnd, depth);
1111
+ const segments = [`M${svgNumber(topStart)} ${svgNumber(y0)}`];
1112
+ appendHorizontalScallops(segments, topStart, topEnd, y0, y0 + depth, topCount);
1113
+ segments.push(
1114
+ `Q${svgNumber(x1)} ${svgNumber(y0)} ${svgNumber(x1)} ${svgNumber(rightStart)}`
1115
+ );
1116
+ appendVerticalScallops(segments, rightStart, rightEnd, x1, x1 - depth, rightCount);
1117
+ segments.push(
1118
+ `Q${svgNumber(x1)} ${svgNumber(y1)} ${svgNumber(bottomStart)} ${svgNumber(y1)}`
1119
+ );
1120
+ appendHorizontalScallops(
1121
+ segments,
1122
+ bottomStart,
1123
+ bottomEnd,
1124
+ y1,
1125
+ y1 - depth,
1126
+ bottomCount
1127
+ );
1128
+ segments.push(
1129
+ `Q${svgNumber(x0)} ${svgNumber(y1)} ${svgNumber(x0)} ${svgNumber(leftStart)}`
1130
+ );
1131
+ appendVerticalScallops(segments, leftStart, leftEnd, x0, x0 + depth, leftCount);
1132
+ segments.push(
1133
+ `Q${svgNumber(x0)} ${svgNumber(y0)} ${svgNumber(topStart)} ${svgNumber(y0)} Z`
1134
+ );
1135
+ return segments.join(" ");
1136
+ }
1137
+ function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
1138
+ const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
1139
+ return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
1140
+ }
1049
1141
  function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
1050
1142
  return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
1051
1143
  }
@@ -1188,6 +1280,13 @@ function rebuildItemSvg(item) {
1188
1280
  childrenSvg: buildEllipseSvg(b.width, b.height, style)
1189
1281
  };
1190
1282
  }
1283
+ if (k === "architectural-cloud") {
1284
+ const b = normalizeRect(item.bounds);
1285
+ return {
1286
+ ...item,
1287
+ childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
1288
+ };
1289
+ }
1191
1290
  if ((k === "line" || k === "arrow") && item.line) {
1192
1291
  const line = item.line;
1193
1292
  const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
@@ -1300,6 +1399,21 @@ function createEllipseItem(id, bounds, style) {
1300
1399
  childrenSvg: ""
1301
1400
  });
1302
1401
  }
1402
+ function createArchitecturalCloudItem(id, bounds, style) {
1403
+ const r = normalizeRect(bounds);
1404
+ const s = { ...DEFAULT_STROKE_STYLE, ...style };
1405
+ return rebuildItemSvg({
1406
+ id,
1407
+ x: r.x,
1408
+ y: r.y,
1409
+ bounds: { ...r },
1410
+ toolKind: "architectural-cloud",
1411
+ stroke: s.stroke,
1412
+ strokeWidth: s.strokeWidth,
1413
+ ...s.strokeOpacity != null ? { strokeOpacity: s.strokeOpacity } : {},
1414
+ childrenSvg: ""
1415
+ });
1416
+ }
1303
1417
  function createLineItem(id, bounds, line, toolKind, style, arrowBind) {
1304
1418
  const r = normalizeRect(bounds);
1305
1419
  const s = { ...DEFAULT_STROKE_STYLE, ...style };
@@ -1519,7 +1633,7 @@ function isArrowBindTarget(item) {
1519
1633
  if (item.locked) return false;
1520
1634
  const k = item.toolKind;
1521
1635
  if (!k) return false;
1522
- return k === "rect" || k === "ellipse" || k === "text" || k === "image" || k === "custom";
1636
+ return k === "rect" || k === "ellipse" || k === "architectural-cloud" || k === "text" || k === "image" || k === "custom";
1523
1637
  }
1524
1638
  function closestPointOnShapeBoundaryLocal(item, lx, ly, w, h) {
1525
1639
  if (item.toolKind === "ellipse") {
@@ -2386,6 +2500,6 @@ var VectorScene = class {
2386
2500
  }
2387
2501
  };
2388
2502
 
2389
- export { ARROW_BIND_SNAP_PX, Camera2D, DEFAULT_STROKE_STYLE, DEFAULT_TEXT_FONT_SIZE, MANAGED_KEY, MAX_RASTER_EMBED_DIMENSION, SvgVectorRenderer, VectorScene, addManagedImage, applyStrokeToItem, attachApplePencilNavigation, attachViewportInput, bakeArrowItemToAbsolute, buildArrowSvg, buildCustomShapeChildrenSvg, buildDrawDotSvg, buildEllipseSvg, buildFreehandPathSvg, buildLineSvg, buildRectSvg, buildTextSvg, cloneVectorSceneItemWithNewId, cloneVectorSceneItemsWithNewIds, collectEraserTargetsAtWorldPoint, computeFreehandSvgPayload, copyManagedImage, createCustomShapeItem, createDrawDotItem, createEllipseItem, createFreehandStrokeItem, createImageFromVectorTrace, createImageItem, createLineItem, createRectangleItem, createShapeId, createTextItem, cullItemsByViewport, deleteManagedImage, encodeCanvasToBlob, expandCustomShapeTemplate, formatCameraTransform, formatItemPlacementTransform, hitTestWorldPoint, hydrateSceneItemsWithAssets, isArrowBindTarget, isManagedImage, itemHitTestWorldPoint, lineEndpointsToLocal, loadImageFileAsRasterSceneSource, markImageAsManaged, normalizeRect, rebuildItemSvg, rectsIntersect, reorderManagedImages, resolveArrowBindingsInScene, resolveStrokeStyle, restackManagedImages, rotateManagedImage, snapArrowEndpointToShape };
2503
+ export { ARROW_BIND_SNAP_PX, Camera2D, DEFAULT_STROKE_STYLE, DEFAULT_TEXT_FONT_SIZE, MANAGED_KEY, MAX_RASTER_EMBED_DIMENSION, SvgVectorRenderer, VectorScene, addManagedImage, applyStrokeToItem, attachApplePencilNavigation, attachViewportInput, bakeArrowItemToAbsolute, buildArchitecturalCloudPathD, buildArchitecturalCloudSvg, buildArrowSvg, buildCustomShapeChildrenSvg, buildDrawDotSvg, buildEllipseSvg, buildFreehandPathSvg, buildLineSvg, buildRectSvg, buildTextSvg, cloneVectorSceneItemWithNewId, cloneVectorSceneItemsWithNewIds, collectEraserTargetsAtWorldPoint, computeFreehandSvgPayload, copyManagedImage, createArchitecturalCloudItem, createCustomShapeItem, createDrawDotItem, createEllipseItem, createFreehandStrokeItem, createImageFromVectorTrace, createImageItem, createLineItem, createRectangleItem, createShapeId, createTextItem, cullItemsByViewport, deleteManagedImage, encodeCanvasToBlob, expandCustomShapeTemplate, formatCameraTransform, formatItemPlacementTransform, hitTestWorldPoint, hydrateSceneItemsWithAssets, isArrowBindTarget, isManagedImage, itemHitTestWorldPoint, lineEndpointsToLocal, loadImageFileAsRasterSceneSource, markImageAsManaged, normalizeRect, rebuildItemSvg, rectsIntersect, reorderManagedImages, resolveArrowBindingsInScene, resolveStrokeStyle, restackManagedImages, rotateManagedImage, snapArrowEndpointToShape };
2390
2504
  //# sourceMappingURL=index.js.map
2391
2505
  //# sourceMappingURL=index.js.map