canvu-react 0.4.54 → 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/chatbot.d.cts +3 -3
- package/dist/chatbot.d.ts +3 -3
- package/dist/index.cjs +30 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -252
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +39 -260
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +3 -3
- package/dist/native.d.ts +3 -3
- package/dist/native.js +39 -260
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +31 -253
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +31 -253
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +4 -4
- package/dist/realtime.d.ts +4 -4
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.d.cts +2 -2
- package/dist/realtimeNative.d.ts +2 -2
- package/dist/{shape-builders-BmLS8CNh.d.cts → shape-builders-DzhCOuzo.d.cts} +1 -1
- package/dist/{shape-builders-BCOAG0pS.d.ts → shape-builders-xG3A66sv.d.ts} +1 -1
- package/dist/tldraw.cjs +30 -252
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +30 -252
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-uzeExFkd.d.cts → types-BFZpRGyr.d.cts} +2 -2
- package/dist/{types-BMMPUak7.d.ts → types-BXa2CIrc.d.ts} +1 -1
- package/dist/{types-BAEHaIYO.d.ts → types-D2zesNI8.d.ts} +2 -2
- package/dist/{types-BOQLWyCw.d.cts → types-DqsqQQVf.d.cts} +1 -1
- package/package.json +1 -1
package/dist/tldraw.js
CHANGED
|
@@ -374,203 +374,6 @@ function svgNumber(value) {
|
|
|
374
374
|
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
375
375
|
}
|
|
376
376
|
var ARCHITECTURAL_CLOUD_RADIUS = 38;
|
|
377
|
-
var ARCHITECTURAL_CLOUD_TARGET_SPACING = 50;
|
|
378
|
-
var ARCHITECTURAL_CLOUD_FLAT_RADIUS_RATIO = 0.38;
|
|
379
|
-
var ARCHITECTURAL_CLOUD_ROUNDED_RADIUS = 72;
|
|
380
|
-
var ARCHITECTURAL_CLOUD_ROUNDED_MIN_RADIUS = 44;
|
|
381
|
-
var ARCHITECTURAL_CLOUD_ROUNDED_TARGET_SPACING = 98;
|
|
382
|
-
function architecturalCloudCenterCount(edgeLength, radius) {
|
|
383
|
-
const targetSpacing = Math.min(
|
|
384
|
-
ARCHITECTURAL_CLOUD_TARGET_SPACING,
|
|
385
|
-
Math.max(1, radius * 1.3)
|
|
386
|
-
);
|
|
387
|
-
return Math.max(2, Math.round(edgeLength / targetSpacing) + 1);
|
|
388
|
-
}
|
|
389
|
-
function distributeRange(start, end, count) {
|
|
390
|
-
if (count <= 1) return [start];
|
|
391
|
-
const step = (end - start) / (count - 1);
|
|
392
|
-
return Array.from({ length: count }, (_, index) => start + step * index);
|
|
393
|
-
}
|
|
394
|
-
function lineCloudPathSegment(start, end) {
|
|
395
|
-
const dx = end[0] - start[0];
|
|
396
|
-
const dy = end[1] - start[1];
|
|
397
|
-
const length = Math.hypot(dx, dy);
|
|
398
|
-
return {
|
|
399
|
-
length,
|
|
400
|
-
pointAt: (t) => [start[0] + dx * t, start[1] + dy * t]
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function ellipsePoint(centerX, centerY, radiusX, radiusY, angle) {
|
|
404
|
-
return [centerX + Math.cos(angle) * radiusX, centerY + Math.sin(angle) * radiusY];
|
|
405
|
-
}
|
|
406
|
-
function approximateEllipseArcLength(radiusX, radiusY, startAngle, endAngle) {
|
|
407
|
-
const steps = Math.max(
|
|
408
|
-
4,
|
|
409
|
-
Math.ceil(Math.abs(endAngle - startAngle) / (Math.PI / 16))
|
|
410
|
-
);
|
|
411
|
-
let length = 0;
|
|
412
|
-
let previous = ellipsePoint(0, 0, radiusX, radiusY, startAngle);
|
|
413
|
-
for (let index = 1; index <= steps; index += 1) {
|
|
414
|
-
const angle = startAngle + (endAngle - startAngle) * index / steps;
|
|
415
|
-
const next = ellipsePoint(0, 0, radiusX, radiusY, angle);
|
|
416
|
-
length += Math.hypot(next[0] - previous[0], next[1] - previous[1]);
|
|
417
|
-
previous = next;
|
|
418
|
-
}
|
|
419
|
-
return length;
|
|
420
|
-
}
|
|
421
|
-
function ellipseCloudPathSegment(centerX, centerY, radiusX, radiusY, startAngle, endAngle) {
|
|
422
|
-
return {
|
|
423
|
-
length: approximateEllipseArcLength(radiusX, radiusY, startAngle, endAngle),
|
|
424
|
-
pointAt: (t) => ellipsePoint(
|
|
425
|
-
centerX,
|
|
426
|
-
centerY,
|
|
427
|
-
radiusX,
|
|
428
|
-
radiusY,
|
|
429
|
-
startAngle + (endAngle - startAngle) * t
|
|
430
|
-
)
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function cloudPathPerimeter(segments) {
|
|
434
|
-
const usableSegments = segments.filter((segment) => segment.length > 1e-9);
|
|
435
|
-
return usableSegments.reduce((sum, segment) => sum + segment.length, 0);
|
|
436
|
-
}
|
|
437
|
-
function pointOnCloudPath(segments, distance) {
|
|
438
|
-
const perimeter = cloudPathPerimeter(segments);
|
|
439
|
-
if (perimeter <= 0) return [0, 0];
|
|
440
|
-
let remaining = (distance % perimeter + perimeter) % perimeter;
|
|
441
|
-
for (const segment of segments) {
|
|
442
|
-
if (segment.length <= 1e-9) continue;
|
|
443
|
-
if (remaining <= segment.length) {
|
|
444
|
-
const t = remaining / segment.length;
|
|
445
|
-
return segment.pointAt(t);
|
|
446
|
-
}
|
|
447
|
-
remaining -= segment.length;
|
|
448
|
-
}
|
|
449
|
-
const fallback = segments.find((segment) => segment.length > 1e-9);
|
|
450
|
-
return fallback?.pointAt(0) ?? [0, 0];
|
|
451
|
-
}
|
|
452
|
-
function buildRoundedCapsulePathSegments(width, height, inset) {
|
|
453
|
-
const left = inset;
|
|
454
|
-
const top = inset;
|
|
455
|
-
const right = width - inset;
|
|
456
|
-
const bottom = height - inset;
|
|
457
|
-
const capsuleWidth = Math.max(0, right - left);
|
|
458
|
-
const capsuleHeight = Math.max(0, bottom - top);
|
|
459
|
-
const radius = Math.min(capsuleWidth, capsuleHeight) / 2;
|
|
460
|
-
if (radius <= 0) return [];
|
|
461
|
-
const leftCenterX = left + radius;
|
|
462
|
-
const rightCenterX = right - radius;
|
|
463
|
-
const topCenterY = top + radius;
|
|
464
|
-
const bottomCenterY = bottom - radius;
|
|
465
|
-
return [
|
|
466
|
-
lineCloudPathSegment([leftCenterX, top], [rightCenterX, top]),
|
|
467
|
-
ellipseCloudPathSegment(
|
|
468
|
-
rightCenterX,
|
|
469
|
-
topCenterY,
|
|
470
|
-
radius,
|
|
471
|
-
radius,
|
|
472
|
-
-Math.PI / 2,
|
|
473
|
-
0
|
|
474
|
-
),
|
|
475
|
-
lineCloudPathSegment([right, topCenterY], [right, bottomCenterY]),
|
|
476
|
-
ellipseCloudPathSegment(
|
|
477
|
-
rightCenterX,
|
|
478
|
-
bottomCenterY,
|
|
479
|
-
radius,
|
|
480
|
-
radius,
|
|
481
|
-
0,
|
|
482
|
-
Math.PI / 2
|
|
483
|
-
),
|
|
484
|
-
lineCloudPathSegment([rightCenterX, bottom], [leftCenterX, bottom]),
|
|
485
|
-
ellipseCloudPathSegment(
|
|
486
|
-
leftCenterX,
|
|
487
|
-
bottomCenterY,
|
|
488
|
-
radius,
|
|
489
|
-
radius,
|
|
490
|
-
Math.PI / 2,
|
|
491
|
-
Math.PI
|
|
492
|
-
),
|
|
493
|
-
lineCloudPathSegment([left, bottomCenterY], [left, topCenterY]),
|
|
494
|
-
ellipseCloudPathSegment(
|
|
495
|
-
leftCenterX,
|
|
496
|
-
topCenterY,
|
|
497
|
-
radius,
|
|
498
|
-
radius,
|
|
499
|
-
Math.PI,
|
|
500
|
-
Math.PI * 1.5
|
|
501
|
-
)
|
|
502
|
-
];
|
|
503
|
-
}
|
|
504
|
-
function buildRoundedArcCloudPathD(cloudWidth, cloudHeight, center) {
|
|
505
|
-
const minDimension = Math.min(cloudWidth, cloudHeight);
|
|
506
|
-
const radius = Math.min(
|
|
507
|
-
ARCHITECTURAL_CLOUD_ROUNDED_RADIUS,
|
|
508
|
-
Math.max(ARCHITECTURAL_CLOUD_ROUNDED_MIN_RADIUS, minDimension * 0.16)
|
|
509
|
-
);
|
|
510
|
-
const centerPath = buildRoundedCapsulePathSegments(
|
|
511
|
-
cloudWidth,
|
|
512
|
-
cloudHeight,
|
|
513
|
-
radius
|
|
514
|
-
);
|
|
515
|
-
const centerPerimeter = cloudPathPerimeter(centerPath);
|
|
516
|
-
if (centerPerimeter <= 0) return "";
|
|
517
|
-
const lobeCount = Math.max(
|
|
518
|
-
8,
|
|
519
|
-
Math.round(centerPerimeter / ARCHITECTURAL_CLOUD_ROUNDED_TARGET_SPACING)
|
|
520
|
-
);
|
|
521
|
-
const centers = Array.from(
|
|
522
|
-
{ length: lobeCount },
|
|
523
|
-
(_, index) => pointOnCloudPath(centerPath, centerPerimeter * index / lobeCount)
|
|
524
|
-
);
|
|
525
|
-
const points = centers.map((point, index) => {
|
|
526
|
-
const previous = centers[(index - 1 + centers.length) % centers.length] ?? point;
|
|
527
|
-
return cloudCircleIntersection(previous, point, radius, center);
|
|
528
|
-
});
|
|
529
|
-
const [startX, startY] = points[0] ?? [0, 0];
|
|
530
|
-
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
531
|
-
for (const [endX, endY] of points.slice(1)) {
|
|
532
|
-
segments.push(
|
|
533
|
-
`A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
|
-
segments.push(
|
|
537
|
-
`A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(startX)} ${svgNumber(startY)}`
|
|
538
|
-
);
|
|
539
|
-
segments.push("Z");
|
|
540
|
-
return segments.join(" ");
|
|
541
|
-
}
|
|
542
|
-
function cloudCircleIntersection(a, b, radius, center) {
|
|
543
|
-
const midX = (a[0] + b[0]) / 2;
|
|
544
|
-
const midY = (a[1] + b[1]) / 2;
|
|
545
|
-
const dx = b[0] - a[0];
|
|
546
|
-
const dy = b[1] - a[1];
|
|
547
|
-
const distance = Math.hypot(dx, dy);
|
|
548
|
-
if (distance <= 1e-9) return [midX, midY];
|
|
549
|
-
const halfDistance = distance / 2;
|
|
550
|
-
const offset = Math.sqrt(
|
|
551
|
-
Math.max(0, radius * radius - halfDistance * halfDistance)
|
|
552
|
-
);
|
|
553
|
-
const normalX = -dy / distance;
|
|
554
|
-
const normalY = dx / distance;
|
|
555
|
-
const first = [midX + normalX * offset, midY + normalY * offset];
|
|
556
|
-
const second = [
|
|
557
|
-
midX - normalX * offset,
|
|
558
|
-
midY - normalY * offset
|
|
559
|
-
];
|
|
560
|
-
const firstDistance = (first[0] - center[0]) * (first[0] - center[0]) + (first[1] - center[1]) * (first[1] - center[1]);
|
|
561
|
-
const secondDistance = (second[0] - center[0]) * (second[0] - center[0]) + (second[1] - center[1]) * (second[1] - center[1]);
|
|
562
|
-
return firstDistance >= secondDistance ? first : second;
|
|
563
|
-
}
|
|
564
|
-
function cloudEllipseIntersection(a, b, radiusX, radiusY, center) {
|
|
565
|
-
const scaleY = radiusX / radiusY;
|
|
566
|
-
const [x, y] = cloudCircleIntersection(
|
|
567
|
-
[a[0], a[1] * scaleY],
|
|
568
|
-
[b[0], b[1] * scaleY],
|
|
569
|
-
radiusX,
|
|
570
|
-
[center[0], center[1] * scaleY]
|
|
571
|
-
);
|
|
572
|
-
return [x, y / scaleY];
|
|
573
|
-
}
|
|
574
377
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
575
378
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
576
379
|
}
|
|
@@ -579,67 +382,42 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
|
579
382
|
const ry = height / 2;
|
|
580
383
|
return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
581
384
|
}
|
|
582
|
-
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
|
|
583
|
-
const w = Math.max(0, width);
|
|
584
|
-
const h = Math.max(0, height);
|
|
585
|
-
if (w <= 0 || h <= 0) return "";
|
|
385
|
+
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth, arcRadius = ARCHITECTURAL_CLOUD_RADIUS, bulge = 1) {
|
|
586
386
|
const padding = Math.max(0, strokeWidth * 2);
|
|
587
|
-
const cloudWidth = Math.max(0,
|
|
588
|
-
const cloudHeight = Math.max(0,
|
|
589
|
-
if (cloudWidth <= 0 || cloudHeight <= 0) return "";
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
cloudHeight * ARCHITECTURAL_CLOUD_FLAT_RADIUS_RATIO
|
|
597
|
-
);
|
|
598
|
-
if (radiusX <= 0 || radiusY <= 0) return "";
|
|
599
|
-
const center = [cloudWidth / 2, cloudHeight / 2];
|
|
600
|
-
const leftCenterX = radiusX;
|
|
601
|
-
const rightCenterX = cloudWidth - radiusX;
|
|
602
|
-
const topCenterY = radiusY;
|
|
603
|
-
const bottomCenterY = cloudHeight - radiusY;
|
|
604
|
-
const horizontalCenters = distributeRange(
|
|
605
|
-
leftCenterX,
|
|
606
|
-
rightCenterX,
|
|
607
|
-
architecturalCloudCenterCount(Math.max(0, rightCenterX - leftCenterX), radiusX)
|
|
608
|
-
);
|
|
609
|
-
const verticalCenters = distributeRange(
|
|
610
|
-
topCenterY,
|
|
611
|
-
bottomCenterY,
|
|
612
|
-
architecturalCloudCenterCount(Math.max(0, bottomCenterY - topCenterY), radiusY)
|
|
613
|
-
);
|
|
614
|
-
if (horizontalCenters.length > 3 && verticalCenters.length > 3) {
|
|
615
|
-
const roundedArcCloudPath = buildRoundedArcCloudPathD(
|
|
616
|
-
cloudWidth,
|
|
617
|
-
cloudHeight,
|
|
618
|
-
center
|
|
619
|
-
);
|
|
620
|
-
if (roundedArcCloudPath !== "") return roundedArcCloudPath;
|
|
621
|
-
}
|
|
622
|
-
const rectangularCenters = [
|
|
623
|
-
...horizontalCenters.map((x) => [x, topCenterY]),
|
|
624
|
-
...verticalCenters.slice(1).map((y) => [rightCenterX, y]),
|
|
625
|
-
...horizontalCenters.slice(0, -1).reverse().map((x) => [x, bottomCenterY]),
|
|
626
|
-
...verticalCenters.slice(1, -1).reverse().map((y) => [leftCenterX, y])
|
|
387
|
+
const cloudWidth = Math.max(0, width - padding);
|
|
388
|
+
const cloudHeight = Math.max(0, height - padding);
|
|
389
|
+
if (cloudWidth <= 0 || cloudHeight <= 0 || arcRadius <= 0 || bulge <= 0) return "";
|
|
390
|
+
const offset = padding / 2;
|
|
391
|
+
const corners = [
|
|
392
|
+
[offset, offset],
|
|
393
|
+
[offset + cloudWidth, offset],
|
|
394
|
+
[offset + cloudWidth, offset + cloudHeight],
|
|
395
|
+
[offset, offset + cloudHeight]
|
|
627
396
|
];
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
397
|
+
const points = [];
|
|
398
|
+
for (let index = 0; index < corners.length; index += 1) {
|
|
399
|
+
const [startX2, startY2] = corners[index] ?? [0, 0];
|
|
400
|
+
const [endX, endY] = corners[(index + 1) % corners.length] ?? [0, 0];
|
|
401
|
+
const edgeLength = Math.hypot(endX - startX2, endY - startY2);
|
|
402
|
+
const arcCount = Math.max(1, Math.round(edgeLength / (2 * arcRadius)));
|
|
403
|
+
const chord = edgeLength / arcCount;
|
|
404
|
+
for (let arcIndex = 1; arcIndex <= arcCount; arcIndex += 1) {
|
|
405
|
+
const t = arcIndex / arcCount;
|
|
406
|
+
points.push([
|
|
407
|
+
startX2 + (endX - startX2) * t,
|
|
408
|
+
startY2 + (endY - startY2) * t,
|
|
409
|
+
chord
|
|
410
|
+
]);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const [startX, startY] = corners[0] ?? [0, 0];
|
|
634
414
|
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
635
|
-
for (const [
|
|
415
|
+
for (const [pointX, pointY, chord] of points) {
|
|
416
|
+
const radius = chord / 2 * bulge;
|
|
636
417
|
segments.push(
|
|
637
|
-
`A ${svgNumber(
|
|
418
|
+
`A ${svgNumber(radius)} ${svgNumber(radius)} 0 0 1 ${svgNumber(pointX)} ${svgNumber(pointY)}`
|
|
638
419
|
);
|
|
639
420
|
}
|
|
640
|
-
segments.push(
|
|
641
|
-
`A ${svgNumber(radiusX)} ${svgNumber(radiusY)} 0 0 1 ${svgNumber(startX)} ${svgNumber(startY)}`
|
|
642
|
-
);
|
|
643
421
|
segments.push("Z");
|
|
644
422
|
return segments.join(" ");
|
|
645
423
|
}
|