canvu-react 0.3.29 → 0.3.31

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 +85 -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 +83 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/native.cjs +66 -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 +66 -0
  18. package/dist/native.js.map +1 -1
  19. package/dist/react.cjs +143 -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 +143 -8
  24. package/dist/react.js.map +1 -1
  25. package/dist/realtime.cjs +11 -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 +11 -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 +68 -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 +68 -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/react.cjs CHANGED
@@ -181,6 +181,8 @@ __export(shape_builders_exports, {
181
181
  DEFAULT_TEXT_FONT_SIZE: () => DEFAULT_TEXT_FONT_SIZE,
182
182
  applyStrokeToItem: () => applyStrokeToItem,
183
183
  applyTextDraftWhileEditing: () => applyTextDraftWhileEditing,
184
+ buildArchitecturalCloudPathD: () => buildArchitecturalCloudPathD,
185
+ buildArchitecturalCloudSvg: () => buildArchitecturalCloudSvg,
184
186
  buildArrowSvg: () => buildArrowSvg,
185
187
  buildDrawDotSvg: () => buildDrawDotSvg,
186
188
  buildEllipseSvg: () => buildEllipseSvg,
@@ -192,6 +194,7 @@ __export(shape_builders_exports, {
192
194
  buildTextSvg: () => buildTextSvg,
193
195
  computeFreehandSvgPayload: () => computeFreehandSvgPayload,
194
196
  computeStraightArrowGeometry: () => computeStraightArrowGeometry,
197
+ createArchitecturalCloudItem: () => createArchitecturalCloudItem,
195
198
  createDrawDotItem: () => createDrawDotItem,
196
199
  createEllipseItem: () => createEllipseItem,
197
200
  createFreehandStrokeItem: () => createFreehandStrokeItem,
@@ -283,6 +286,22 @@ function resolveStrokeStyle(item) {
283
286
  function strokeOpacityAttr(style) {
284
287
  return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
285
288
  }
289
+ function svgNumber(value) {
290
+ if (!Number.isFinite(value)) return "0";
291
+ const rounded = Math.round(value * 100) / 100;
292
+ return Number.isInteger(rounded) ? String(rounded) : String(rounded);
293
+ }
294
+ function approximateEllipsePerimeter(rx, ry) {
295
+ if (rx <= 0 || ry <= 0) return 0;
296
+ return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
297
+ }
298
+ function architecturalCloudScallopCount(rx, ry, amplitude) {
299
+ const perimeter = approximateEllipsePerimeter(rx, ry);
300
+ const targetScallopLength = Math.max(10, amplitude * 2);
301
+ let count = Math.max(12, Math.round(perimeter / targetScallopLength));
302
+ if (count % 2 === 1) count += 1;
303
+ return count;
304
+ }
286
305
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
287
306
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
288
307
  }
@@ -291,6 +310,49 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
291
310
  const ry = height / 2;
292
311
  return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
293
312
  }
313
+ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
314
+ const w = Math.max(0, width);
315
+ const h = Math.max(0, height);
316
+ if (w <= 0 || h <= 0) return "";
317
+ const inset = Math.max(0.5, strokeWidth / 2);
318
+ const outerRx = Math.max(0, w / 2 - inset);
319
+ const outerRy = Math.max(0, h / 2 - inset);
320
+ if (outerRx <= 0 || outerRy <= 0) return "";
321
+ const amplitude = Math.min(
322
+ outerRx * 0.45,
323
+ outerRy * 0.45,
324
+ Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
325
+ );
326
+ const innerRx = Math.max(0, outerRx - amplitude);
327
+ const innerRy = Math.max(0, outerRy - amplitude);
328
+ const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
329
+ const angleStep = Math.PI * 2 / scallopCount;
330
+ const cx = w / 2;
331
+ const cy = h / 2;
332
+ const startAngle = -Math.PI / 2;
333
+ const pointOnEllipse = (theta, radiusX, radiusY) => [
334
+ cx + Math.cos(theta) * radiusX,
335
+ cy + Math.sin(theta) * radiusY
336
+ ];
337
+ const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
338
+ const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
339
+ for (let index = 0; index < scallopCount; index += 1) {
340
+ const segmentStart = startAngle + index * angleStep;
341
+ const segmentMid = segmentStart + angleStep / 2;
342
+ const segmentEnd = segmentStart + angleStep;
343
+ const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
344
+ const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
345
+ segments.push(
346
+ `Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
347
+ );
348
+ }
349
+ segments.push("Z");
350
+ return segments.join(" ");
351
+ }
352
+ function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
353
+ const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
354
+ return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
355
+ }
294
356
  function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
295
357
  return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
296
358
  }
@@ -433,6 +495,13 @@ function rebuildItemSvg(item) {
433
495
  childrenSvg: buildEllipseSvg(b.width, b.height, style)
434
496
  };
435
497
  }
498
+ if (k === "architectural-cloud") {
499
+ const b = normalizeRect(item.bounds);
500
+ return {
501
+ ...item,
502
+ childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
503
+ };
504
+ }
436
505
  if ((k === "line" || k === "arrow") && item.line) {
437
506
  const line = item.line;
438
507
  const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
@@ -545,6 +614,21 @@ function createEllipseItem(id, bounds, style) {
545
614
  childrenSvg: ""
546
615
  });
547
616
  }
617
+ function createArchitecturalCloudItem(id, bounds, style) {
618
+ const r = normalizeRect(bounds);
619
+ const s = { ...DEFAULT_STROKE_STYLE, ...style };
620
+ return rebuildItemSvg({
621
+ id,
622
+ x: r.x,
623
+ y: r.y,
624
+ bounds: { ...r },
625
+ toolKind: "architectural-cloud",
626
+ stroke: s.stroke,
627
+ strokeWidth: s.strokeWidth,
628
+ ...s.strokeOpacity != null ? { strokeOpacity: s.strokeOpacity } : {},
629
+ childrenSvg: ""
630
+ });
631
+ }
548
632
  function createLineItem(id, bounds, line, toolKind, style, arrowBind) {
549
633
  const r = normalizeRect(bounds);
550
634
  const s = { ...DEFAULT_STROKE_STYLE, ...style };
@@ -3019,6 +3103,7 @@ function ShapeContextMenu({
3019
3103
  }
3020
3104
  return reactDom.createPortal(menu, document.body);
3021
3105
  }
3106
+ var architecturalCloudIconPath = "M12 8.28 Q14.33 7.17 15.86 8.78 Q18.36 8.46 18.69 10.14 Q20.69 10.71 19.72 12 Q20.69 13.29 18.69 13.86 Q18.36 15.54 15.86 15.22 Q14.33 16.83 12 15.72 Q9.67 16.83 8.14 15.22 Q5.64 15.54 5.31 13.86 Q3.31 13.29 4.28 12 Q3.31 10.71 5.31 10.14 Q5.64 8.46 8.14 8.78 Q9.67 7.17 12 8.28 Z";
3022
3107
  var base = {
3023
3108
  width: 20,
3024
3109
  height: 20,
@@ -3049,6 +3134,9 @@ function IconRect(props) {
3049
3134
  function IconEllipse(props) {
3050
3135
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("ellipse", { cx: "12", cy: "12", rx: "9", ry: "6" }) });
3051
3136
  }
3137
+ function IconArchitecturalCloud(props) {
3138
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: architecturalCloudIconPath, transform: "translate(0 4)" }) });
3139
+ }
3052
3140
  function IconLine(props) {
3053
3141
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }) });
3054
3142
  }
@@ -3093,6 +3181,7 @@ var ic = { size: 20, strokeWidth: 2 };
3093
3181
  var DEFAULT_OVERFLOW_TOOL_IDS = [
3094
3182
  "rect",
3095
3183
  "ellipse",
3184
+ "architectural-cloud",
3096
3185
  "line",
3097
3186
  "marker",
3098
3187
  "laser",
@@ -3123,6 +3212,13 @@ var DEFAULT_VECTOR_TOOLS = [
3123
3212
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { ...ic, "aria-hidden": true }),
3124
3213
  shortcutHint: "O"
3125
3214
  },
3215
+ {
3216
+ id: "architectural-cloud",
3217
+ label: "Nuvem arquitetural",
3218
+ tooltipLabel: "Architectural cloud",
3219
+ icon: /* @__PURE__ */ jsxRuntime.jsx(IconArchitecturalCloud, { "aria-hidden": true }),
3220
+ shortcutHint: "C"
3221
+ },
3126
3222
  {
3127
3223
  id: "line",
3128
3224
  label: "Line",
@@ -3200,7 +3296,7 @@ function normalizeHex(stroke) {
3200
3296
  return "#2563eb";
3201
3297
  }
3202
3298
  function isStylableKind(tk) {
3203
- return tk === "rect" || tk === "ellipse" || tk === "line" || tk === "arrow" || tk === "draw" || tk === "pencil" || tk === "brush" || tk === "marker" || tk === "text";
3299
+ return tk === "rect" || tk === "ellipse" || tk === "architectural-cloud" || tk === "line" || tk === "arrow" || tk === "draw" || tk === "pencil" || tk === "brush" || tk === "marker" || tk === "text";
3204
3300
  }
3205
3301
  function VectorSelectionInspector({
3206
3302
  items: itemsProp,
@@ -4561,6 +4657,7 @@ var HandBinding = makeToolBinding("hand");
4561
4657
  var SelectBinding = makeToolBinding("select");
4562
4658
  var RectBinding = makeToolBinding("rect");
4563
4659
  var EllipseBinding = makeToolBinding("ellipse");
4660
+ var ArchitecturalCloudBinding = makeToolBinding("architectural-cloud");
4564
4661
  var LineBinding = makeToolBinding("line");
4565
4662
  var ArrowBinding = makeToolBinding("arrow");
4566
4663
  var DrawBinding = makeToolBinding("draw");
@@ -4580,6 +4677,7 @@ var VectorToolbar = Object.assign(
4580
4677
  Select: SelectBinding,
4581
4678
  Rect: RectBinding,
4582
4679
  Ellipse: EllipseBinding,
4680
+ ArchitecturalCloud: ArchitecturalCloudBinding,
4583
4681
  Line: LineBinding,
4584
4682
  Arrow: ArrowBinding,
4585
4683
  Draw: DrawBinding,
@@ -5309,7 +5407,7 @@ function isArrowBindTarget(item) {
5309
5407
  if (item.locked) return false;
5310
5408
  const k = item.toolKind;
5311
5409
  if (!k) return false;
5312
- return k === "rect" || k === "ellipse" || k === "text" || k === "image" || k === "custom";
5410
+ return k === "rect" || k === "ellipse" || k === "architectural-cloud" || k === "text" || k === "image" || k === "custom";
5313
5411
  }
5314
5412
  function closestPointOnShapeBoundaryLocal(item, lx, ly, w, h) {
5315
5413
  if (item.toolKind === "ellipse") {
@@ -5648,6 +5746,16 @@ function resizeItemByHandle(item, start, handle, currentWorld) {
5648
5746
  childrenSvg: buildEllipseSvg(nb.width, nb.height, style)
5649
5747
  };
5650
5748
  }
5749
+ if (k === "architectural-cloud") {
5750
+ const style = resolveStrokeStyle(item);
5751
+ return {
5752
+ ...item,
5753
+ x: nb.x,
5754
+ y: nb.y,
5755
+ bounds: nb,
5756
+ childrenSvg: buildArchitecturalCloudSvg(nb.width, nb.height, style)
5757
+ };
5758
+ }
5651
5759
  if (k === "text" && item.text !== void 0) {
5652
5760
  const sfw = Math.max(sb.width, 1e-6);
5653
5761
  const sfh = Math.max(sb.height, 1e-6);
@@ -6190,7 +6298,7 @@ function InteractionOverlay({
6190
6298
  vectorEffect: "non-scaling-stroke"
6191
6299
  }
6192
6300
  );
6193
- } else if (placementPreview.kind === "rect" || placementPreview.kind === "ellipse") {
6301
+ } else if (placementPreview.kind === "rect" || placementPreview.kind === "ellipse" || placementPreview.kind === "architectural-cloud") {
6194
6302
  const r = normalizeRect(placementPreview.rect);
6195
6303
  preview = placementPreview.kind === "rect" ? /* @__PURE__ */ jsxRuntime.jsx(
6196
6304
  "rect",
@@ -6205,7 +6313,7 @@ function InteractionOverlay({
6205
6313
  strokeDasharray: dashPattern,
6206
6314
  vectorEffect: "non-scaling-stroke"
6207
6315
  }
6208
- ) : /* @__PURE__ */ jsxRuntime.jsx(
6316
+ ) : placementPreview.kind === "ellipse" ? /* @__PURE__ */ jsxRuntime.jsx(
6209
6317
  "ellipse",
6210
6318
  {
6211
6319
  cx: r.x + r.width / 2,
@@ -6218,7 +6326,19 @@ function InteractionOverlay({
6218
6326
  strokeDasharray: dashPattern,
6219
6327
  vectorEffect: "non-scaling-stroke"
6220
6328
  }
6221
- );
6329
+ ) : /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${r.x}, ${r.y})`, children: /* @__PURE__ */ jsxRuntime.jsx(
6330
+ "path",
6331
+ {
6332
+ d: buildArchitecturalCloudPathD(r.width, r.height, overlayStrokePx),
6333
+ fill: "none",
6334
+ stroke: "#64748b",
6335
+ strokeWidth: overlayStrokePx,
6336
+ strokeDasharray: dashPattern,
6337
+ strokeLinecap: "round",
6338
+ strokeLinejoin: "round",
6339
+ vectorEffect: "non-scaling-stroke"
6340
+ }
6341
+ ) });
6222
6342
  } else if (placementPreview.kind === "line" || placementPreview.kind === "arrow") {
6223
6343
  const { start, end } = placementPreview;
6224
6344
  const geometry = placementPreview.kind === "arrow" ? computeStraightArrowGeometry(
@@ -6791,6 +6911,7 @@ function cursorForVectorToolId(toolId) {
6791
6911
  return "default";
6792
6912
  case "rect":
6793
6913
  case "ellipse":
6914
+ case "architectural-cloud":
6794
6915
  case "line":
6795
6916
  case "arrow":
6796
6917
  return "crosshair";
@@ -6841,7 +6962,7 @@ function replaceItem(items, id, next) {
6841
6962
  }
6842
6963
  function supportsResizeHandles(item) {
6843
6964
  const k = item?.toolKind;
6844
- if (k === "rect" || k === "ellipse" || k === "line" || k === "arrow" || k === "image" || k === "text") {
6965
+ if (k === "rect" || k === "ellipse" || k === "architectural-cloud" || k === "line" || k === "arrow" || k === "image" || k === "text") {
6845
6966
  return true;
6846
6967
  }
6847
6968
  if ((k === "draw" || k === "pencil" || k === "brush" || k === "marker") && item?.pathPointsLocal && item.pathPointsLocal.length > 0) {
@@ -6898,6 +7019,9 @@ function defaultPlacementWorld(tool, center) {
6898
7019
  if (tool === "ellipse") {
6899
7020
  return { raw: { x: cx - 70, y: cy - 45, width: 140, height: 90 } };
6900
7021
  }
7022
+ if (tool === "architectural-cloud") {
7023
+ return { raw: { x: cx - 90, y: cy - 50, width: 180, height: 100 } };
7024
+ }
6901
7025
  const a = { x: cx - 50, y: cy };
6902
7026
  const b = { x: cx + 50, y: cy };
6903
7027
  return {
@@ -8801,7 +8925,7 @@ var VectorViewport = react.forwardRef(
8801
8925
  return;
8802
8926
  }
8803
8927
  const cp = customPlacementRef.current;
8804
- if (tool === "rect" || tool === "ellipse" || tool === "line" || tool === "arrow" || cp && tool === cp.toolId) {
8928
+ if (tool === "rect" || tool === "ellipse" || tool === "architectural-cloud" || tool === "line" || tool === "arrow" || cp && tool === cp.toolId) {
8805
8929
  dragStateRef.current = {
8806
8930
  kind: "place",
8807
8931
  tool,
@@ -9221,6 +9345,11 @@ var VectorViewport = react.forwardRef(
9221
9345
  setPlacementPreview({ kind: "rect", rect: rectFromCorners(a, b) });
9222
9346
  } else if (st.tool === "ellipse") {
9223
9347
  setPlacementPreview({ kind: "ellipse", rect: rectFromCorners(a, b) });
9348
+ } else if (st.tool === "architectural-cloud") {
9349
+ setPlacementPreview({
9350
+ kind: "architectural-cloud",
9351
+ rect: rectFromCorners(a, b)
9352
+ });
9224
9353
  } else if (st.tool === "line") {
9225
9354
  setPlacementPreview({
9226
9355
  kind: "line",
@@ -9479,6 +9608,12 @@ var VectorViewport = react.forwardRef(
9479
9608
  } else if (st.tool === "ellipse") {
9480
9609
  change([...itemsRef.current, createEllipseItem(id, raw, pen)]);
9481
9610
  setEffectiveSelectedIdsRef.current([id]);
9611
+ } else if (st.tool === "architectural-cloud") {
9612
+ change([
9613
+ ...itemsRef.current,
9614
+ createArchitecturalCloudItem(id, raw, pen)
9615
+ ]);
9616
+ setEffectiveSelectedIdsRef.current([id]);
9482
9617
  } else if (st.tool === "line" || st.tool === "arrow") {
9483
9618
  const line = lineEndpointsToLocal(raw, lineA, lineB);
9484
9619
  change([
@@ -9800,6 +9935,7 @@ exports.CanvuPluginContext = CanvuPluginContext;
9800
9935
  exports.DEFAULT_OVERFLOW_TOOL_IDS = DEFAULT_OVERFLOW_TOOL_IDS;
9801
9936
  exports.DEFAULT_VECTOR_CANVAS_STORAGE_KEY = DEFAULT_VECTOR_CANVAS_STORAGE_KEY;
9802
9937
  exports.DEFAULT_VECTOR_TOOLS = DEFAULT_VECTOR_TOOLS;
9938
+ exports.IconArchitecturalCloud = IconArchitecturalCloud;
9803
9939
  exports.IconArrow = IconArrow;
9804
9940
  exports.IconDraw = IconDraw;
9805
9941
  exports.IconEllipse = IconEllipse;