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/native.cjs CHANGED
@@ -349,6 +349,22 @@ function resolveStrokeStyle(item) {
349
349
  function strokeOpacityAttr(style) {
350
350
  return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
351
351
  }
352
+ function svgNumber(value) {
353
+ if (!Number.isFinite(value)) return "0";
354
+ const rounded = Math.round(value * 100) / 100;
355
+ return Number.isInteger(rounded) ? String(rounded) : String(rounded);
356
+ }
357
+ function approximateEllipsePerimeter(rx, ry) {
358
+ if (rx <= 0 || ry <= 0) return 0;
359
+ return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
360
+ }
361
+ function architecturalCloudScallopCount(rx, ry, amplitude) {
362
+ const perimeter = approximateEllipsePerimeter(rx, ry);
363
+ const targetScallopLength = Math.max(10, amplitude * 2);
364
+ let count = Math.max(12, Math.round(perimeter / targetScallopLength));
365
+ if (count % 2 === 1) count += 1;
366
+ return count;
367
+ }
352
368
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
353
369
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
354
370
  }
@@ -357,6 +373,49 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
357
373
  const ry = height / 2;
358
374
  return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
359
375
  }
376
+ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
377
+ const w = Math.max(0, width);
378
+ const h = Math.max(0, height);
379
+ if (w <= 0 || h <= 0) return "";
380
+ const inset = Math.max(0.5, strokeWidth / 2);
381
+ const outerRx = Math.max(0, w / 2 - inset);
382
+ const outerRy = Math.max(0, h / 2 - inset);
383
+ if (outerRx <= 0 || outerRy <= 0) return "";
384
+ const amplitude = Math.min(
385
+ outerRx * 0.45,
386
+ outerRy * 0.45,
387
+ Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
388
+ );
389
+ const innerRx = Math.max(0, outerRx - amplitude);
390
+ const innerRy = Math.max(0, outerRy - amplitude);
391
+ const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
392
+ const angleStep = Math.PI * 2 / scallopCount;
393
+ const cx = w / 2;
394
+ const cy = h / 2;
395
+ const startAngle = -Math.PI / 2;
396
+ const pointOnEllipse = (theta, radiusX, radiusY) => [
397
+ cx + Math.cos(theta) * radiusX,
398
+ cy + Math.sin(theta) * radiusY
399
+ ];
400
+ const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
401
+ const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
402
+ for (let index = 0; index < scallopCount; index += 1) {
403
+ const segmentStart = startAngle + index * angleStep;
404
+ const segmentMid = segmentStart + angleStep / 2;
405
+ const segmentEnd = segmentStart + angleStep;
406
+ const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
407
+ const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
408
+ segments.push(
409
+ `Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
410
+ );
411
+ }
412
+ segments.push("Z");
413
+ return segments.join(" ");
414
+ }
415
+ function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
416
+ const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
417
+ return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
418
+ }
360
419
  function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
361
420
  return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
362
421
  }
@@ -490,6 +549,13 @@ function rebuildItemSvg(item) {
490
549
  childrenSvg: buildEllipseSvg(b.width, b.height, style)
491
550
  };
492
551
  }
552
+ if (k === "architectural-cloud") {
553
+ const b = normalizeRect(item.bounds);
554
+ return {
555
+ ...item,
556
+ childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
557
+ };
558
+ }
493
559
  if ((k === "line" || k === "arrow") && item.line) {
494
560
  const line = item.line;
495
561
  const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);