canvu-react 0.4.55 → 0.4.56

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/native.d.cts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { C as CanvuLinkData } from './link-item-BMV3VUCr.cjs';
2
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';
3
+ import { C as Camera2D, S as StrokeStyle } from './shape-builders-DzhCOuzo.cjs';
4
+ export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-DzhCOuzo.cjs';
5
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-BOQLWyCw.cjs';
10
+ import { R as RemotePresencePeer } from './types-DqsqQQVf.cjs';
11
11
 
12
12
  type NativeImagesMenuLabels = {
13
13
  title?: string;
package/dist/native.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { C as CanvuLinkData } from './link-item-COoNNvCu.js';
2
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';
3
+ import { C as Camera2D, S as StrokeStyle } from './shape-builders-xG3A66sv.js';
4
+ export { o as createFreehandStrokeItem, q as createImageItem, t as createShapeId } from './shape-builders-xG3A66sv.js';
5
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-BMMPUak7.js';
10
+ import { R as RemotePresencePeer } from './types-BXa2CIrc.js';
11
11
 
12
12
  type NativeImagesMenuLabels = {
13
13
  title?: string;
package/dist/native.js CHANGED
@@ -418,203 +418,6 @@ function svgNumber(value) {
418
418
  return Number.isInteger(rounded) ? String(rounded) : String(rounded);
419
419
  }
420
420
  var ARCHITECTURAL_CLOUD_RADIUS = 38;
421
- var ARCHITECTURAL_CLOUD_TARGET_SPACING = 50;
422
- var ARCHITECTURAL_CLOUD_FLAT_RADIUS_RATIO = 0.38;
423
- var ARCHITECTURAL_CLOUD_ROUNDED_RADIUS = 72;
424
- var ARCHITECTURAL_CLOUD_ROUNDED_MIN_RADIUS = 44;
425
- var ARCHITECTURAL_CLOUD_ROUNDED_TARGET_SPACING = 98;
426
- function architecturalCloudCenterCount(edgeLength, radius) {
427
- const targetSpacing = Math.min(
428
- ARCHITECTURAL_CLOUD_TARGET_SPACING,
429
- Math.max(1, radius * 1.3)
430
- );
431
- return Math.max(2, Math.round(edgeLength / targetSpacing) + 1);
432
- }
433
- function distributeRange(start, end, count) {
434
- if (count <= 1) return [start];
435
- const step = (end - start) / (count - 1);
436
- return Array.from({ length: count }, (_, index) => start + step * index);
437
- }
438
- function lineCloudPathSegment(start, end) {
439
- const dx = end[0] - start[0];
440
- const dy = end[1] - start[1];
441
- const length = Math.hypot(dx, dy);
442
- return {
443
- length,
444
- pointAt: (t) => [start[0] + dx * t, start[1] + dy * t]
445
- };
446
- }
447
- function ellipsePoint(centerX, centerY, radiusX, radiusY, angle) {
448
- return [centerX + Math.cos(angle) * radiusX, centerY + Math.sin(angle) * radiusY];
449
- }
450
- function approximateEllipseArcLength(radiusX, radiusY, startAngle, endAngle) {
451
- const steps = Math.max(
452
- 4,
453
- Math.ceil(Math.abs(endAngle - startAngle) / (Math.PI / 16))
454
- );
455
- let length = 0;
456
- let previous = ellipsePoint(0, 0, radiusX, radiusY, startAngle);
457
- for (let index = 1; index <= steps; index += 1) {
458
- const angle = startAngle + (endAngle - startAngle) * index / steps;
459
- const next = ellipsePoint(0, 0, radiusX, radiusY, angle);
460
- length += Math.hypot(next[0] - previous[0], next[1] - previous[1]);
461
- previous = next;
462
- }
463
- return length;
464
- }
465
- function ellipseCloudPathSegment(centerX, centerY, radiusX, radiusY, startAngle, endAngle) {
466
- return {
467
- length: approximateEllipseArcLength(radiusX, radiusY, startAngle, endAngle),
468
- pointAt: (t) => ellipsePoint(
469
- centerX,
470
- centerY,
471
- radiusX,
472
- radiusY,
473
- startAngle + (endAngle - startAngle) * t
474
- )
475
- };
476
- }
477
- function cloudPathPerimeter(segments) {
478
- const usableSegments = segments.filter((segment) => segment.length > 1e-9);
479
- return usableSegments.reduce((sum, segment) => sum + segment.length, 0);
480
- }
481
- function pointOnCloudPath(segments, distance) {
482
- const perimeter = cloudPathPerimeter(segments);
483
- if (perimeter <= 0) return [0, 0];
484
- let remaining = (distance % perimeter + perimeter) % perimeter;
485
- for (const segment of segments) {
486
- if (segment.length <= 1e-9) continue;
487
- if (remaining <= segment.length) {
488
- const t = remaining / segment.length;
489
- return segment.pointAt(t);
490
- }
491
- remaining -= segment.length;
492
- }
493
- const fallback = segments.find((segment) => segment.length > 1e-9);
494
- return fallback?.pointAt(0) ?? [0, 0];
495
- }
496
- function buildRoundedCapsulePathSegments(width, height, inset) {
497
- const left = inset;
498
- const top = inset;
499
- const right = width - inset;
500
- const bottom = height - inset;
501
- const capsuleWidth = Math.max(0, right - left);
502
- const capsuleHeight = Math.max(0, bottom - top);
503
- const radius = Math.min(capsuleWidth, capsuleHeight) / 2;
504
- if (radius <= 0) return [];
505
- const leftCenterX = left + radius;
506
- const rightCenterX = right - radius;
507
- const topCenterY = top + radius;
508
- const bottomCenterY = bottom - radius;
509
- return [
510
- lineCloudPathSegment([leftCenterX, top], [rightCenterX, top]),
511
- ellipseCloudPathSegment(
512
- rightCenterX,
513
- topCenterY,
514
- radius,
515
- radius,
516
- -Math.PI / 2,
517
- 0
518
- ),
519
- lineCloudPathSegment([right, topCenterY], [right, bottomCenterY]),
520
- ellipseCloudPathSegment(
521
- rightCenterX,
522
- bottomCenterY,
523
- radius,
524
- radius,
525
- 0,
526
- Math.PI / 2
527
- ),
528
- lineCloudPathSegment([rightCenterX, bottom], [leftCenterX, bottom]),
529
- ellipseCloudPathSegment(
530
- leftCenterX,
531
- bottomCenterY,
532
- radius,
533
- radius,
534
- Math.PI / 2,
535
- Math.PI
536
- ),
537
- lineCloudPathSegment([left, bottomCenterY], [left, topCenterY]),
538
- ellipseCloudPathSegment(
539
- leftCenterX,
540
- topCenterY,
541
- radius,
542
- radius,
543
- Math.PI,
544
- Math.PI * 1.5
545
- )
546
- ];
547
- }
548
- function buildRoundedArcCloudPathD(cloudWidth, cloudHeight, center) {
549
- const minDimension = Math.min(cloudWidth, cloudHeight);
550
- const radius = Math.min(
551
- ARCHITECTURAL_CLOUD_ROUNDED_RADIUS,
552
- Math.max(ARCHITECTURAL_CLOUD_ROUNDED_MIN_RADIUS, minDimension * 0.16)
553
- );
554
- const centerPath = buildRoundedCapsulePathSegments(
555
- cloudWidth,
556
- cloudHeight,
557
- radius
558
- );
559
- const centerPerimeter = cloudPathPerimeter(centerPath);
560
- if (centerPerimeter <= 0) return "";
561
- const lobeCount = Math.max(
562
- 8,
563
- Math.round(centerPerimeter / ARCHITECTURAL_CLOUD_ROUNDED_TARGET_SPACING)
564
- );
565
- const centers = Array.from(
566
- { length: lobeCount },
567
- (_, index) => pointOnCloudPath(centerPath, centerPerimeter * index / lobeCount)
568
- );
569
- const points = centers.map((point, index) => {
570
- const previous = centers[(index - 1 + centers.length) % centers.length] ?? point;
571
- return cloudCircleIntersection(previous, point, radius, center);
572
- });
573
- const [startX, startY] = points[0] ?? [0, 0];
574
- const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
575
- for (const [endX, endY] of points.slice(1)) {
576
- segments.push(
577
- `A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(endX)} ${svgNumber(endY)}`
578
- );
579
- }
580
- segments.push(
581
- `A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(startX)} ${svgNumber(startY)}`
582
- );
583
- segments.push("Z");
584
- return segments.join(" ");
585
- }
586
- function cloudCircleIntersection(a, b, radius, center) {
587
- const midX = (a[0] + b[0]) / 2;
588
- const midY = (a[1] + b[1]) / 2;
589
- const dx = b[0] - a[0];
590
- const dy = b[1] - a[1];
591
- const distance = Math.hypot(dx, dy);
592
- if (distance <= 1e-9) return [midX, midY];
593
- const halfDistance = distance / 2;
594
- const offset = Math.sqrt(
595
- Math.max(0, radius * radius - halfDistance * halfDistance)
596
- );
597
- const normalX = -dy / distance;
598
- const normalY = dx / distance;
599
- const first = [midX + normalX * offset, midY + normalY * offset];
600
- const second = [
601
- midX - normalX * offset,
602
- midY - normalY * offset
603
- ];
604
- const firstDistance = (first[0] - center[0]) * (first[0] - center[0]) + (first[1] - center[1]) * (first[1] - center[1]);
605
- const secondDistance = (second[0] - center[0]) * (second[0] - center[0]) + (second[1] - center[1]) * (second[1] - center[1]);
606
- return firstDistance >= secondDistance ? first : second;
607
- }
608
- function cloudEllipseIntersection(a, b, radiusX, radiusY, center) {
609
- const scaleY = radiusX / radiusY;
610
- const [x, y] = cloudCircleIntersection(
611
- [a[0], a[1] * scaleY],
612
- [b[0], b[1] * scaleY],
613
- radiusX,
614
- [center[0], center[1] * scaleY]
615
- );
616
- return [x, y / scaleY];
617
- }
618
421
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
619
422
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
620
423
  }
@@ -623,67 +426,42 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
623
426
  const ry = height / 2;
624
427
  return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
625
428
  }
626
- function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
627
- const w = Math.max(0, width);
628
- const h = Math.max(0, height);
629
- if (w <= 0 || h <= 0) return "";
429
+ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth, arcRadius = ARCHITECTURAL_CLOUD_RADIUS, bulge = 1) {
630
430
  const padding = Math.max(0, strokeWidth * 2);
631
- const cloudWidth = Math.max(0, w - padding);
632
- const cloudHeight = Math.max(0, h - padding);
633
- if (cloudWidth <= 0 || cloudHeight <= 0) return "";
634
- const radiusX = Math.min(
635
- ARCHITECTURAL_CLOUD_RADIUS,
636
- cloudWidth * ARCHITECTURAL_CLOUD_FLAT_RADIUS_RATIO
637
- );
638
- const radiusY = Math.min(
639
- ARCHITECTURAL_CLOUD_RADIUS,
640
- cloudHeight * ARCHITECTURAL_CLOUD_FLAT_RADIUS_RATIO
641
- );
642
- if (radiusX <= 0 || radiusY <= 0) return "";
643
- const center = [cloudWidth / 2, cloudHeight / 2];
644
- const leftCenterX = radiusX;
645
- const rightCenterX = cloudWidth - radiusX;
646
- const topCenterY = radiusY;
647
- const bottomCenterY = cloudHeight - radiusY;
648
- const horizontalCenters = distributeRange(
649
- leftCenterX,
650
- rightCenterX,
651
- architecturalCloudCenterCount(Math.max(0, rightCenterX - leftCenterX), radiusX)
652
- );
653
- const verticalCenters = distributeRange(
654
- topCenterY,
655
- bottomCenterY,
656
- architecturalCloudCenterCount(Math.max(0, bottomCenterY - topCenterY), radiusY)
657
- );
658
- if (horizontalCenters.length > 3 && verticalCenters.length > 3) {
659
- const roundedArcCloudPath = buildRoundedArcCloudPathD(
660
- cloudWidth,
661
- cloudHeight,
662
- center
663
- );
664
- if (roundedArcCloudPath !== "") return roundedArcCloudPath;
665
- }
666
- const rectangularCenters = [
667
- ...horizontalCenters.map((x) => [x, topCenterY]),
668
- ...verticalCenters.slice(1).map((y) => [rightCenterX, y]),
669
- ...horizontalCenters.slice(0, -1).reverse().map((x) => [x, bottomCenterY]),
670
- ...verticalCenters.slice(1, -1).reverse().map((y) => [leftCenterX, y])
431
+ const cloudWidth = Math.max(0, width - padding);
432
+ const cloudHeight = Math.max(0, height - padding);
433
+ if (cloudWidth <= 0 || cloudHeight <= 0 || arcRadius <= 0 || bulge <= 0) return "";
434
+ const offset = padding / 2;
435
+ const corners = [
436
+ [offset, offset],
437
+ [offset + cloudWidth, offset],
438
+ [offset + cloudWidth, offset + cloudHeight],
439
+ [offset, offset + cloudHeight]
671
440
  ];
672
- const centers = rectangularCenters;
673
- const points = centers.map((point, index) => {
674
- const previous = centers[(index - 1 + centers.length) % centers.length] ?? point;
675
- return cloudEllipseIntersection(previous, point, radiusX, radiusY, center);
676
- });
677
- const [startX, startY] = points[0] ?? [0, 0];
441
+ const points = [];
442
+ for (let index = 0; index < corners.length; index += 1) {
443
+ const [startX2, startY2] = corners[index] ?? [0, 0];
444
+ const [endX, endY] = corners[(index + 1) % corners.length] ?? [0, 0];
445
+ const edgeLength = Math.hypot(endX - startX2, endY - startY2);
446
+ const arcCount = Math.max(1, Math.round(edgeLength / (2 * arcRadius)));
447
+ const chord = edgeLength / arcCount;
448
+ for (let arcIndex = 1; arcIndex <= arcCount; arcIndex += 1) {
449
+ const t = arcIndex / arcCount;
450
+ points.push([
451
+ startX2 + (endX - startX2) * t,
452
+ startY2 + (endY - startY2) * t,
453
+ chord
454
+ ]);
455
+ }
456
+ }
457
+ const [startX, startY] = corners[0] ?? [0, 0];
678
458
  const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
679
- for (const [endX, endY] of points.slice(1)) {
459
+ for (const [pointX, pointY, chord] of points) {
460
+ const radius = chord / 2 * bulge;
680
461
  segments.push(
681
- `A ${svgNumber(radiusX)} ${svgNumber(radiusY)} 0 0 1 ${svgNumber(endX)} ${svgNumber(endY)}`
462
+ `A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(pointX)} ${svgNumber(pointY)}`
682
463
  );
683
464
  }
684
- segments.push(
685
- `A ${svgNumber(radiusX)} ${svgNumber(radiusY)} 0 0 1 ${svgNumber(startX)} ${svgNumber(startY)}`
686
- );
687
465
  segments.push("Z");
688
466
  return segments.join(" ");
689
467
  }