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.
- package/dist/{asset-hydration-BEG21hMp.d.ts → asset-hydration-DrTOgDdd.d.ts} +2 -2
- package/dist/{asset-hydration-3Iv5xHxM.d.cts → asset-hydration-EtEuBwb7.d.cts} +2 -2
- package/dist/{camera-KwCYYPhm.d.ts → camera-AoTwBSoE.d.ts} +1 -1
- package/dist/{camera-BwQjm5oh.d.cts → camera-Di5R_Rwl.d.cts} +1 -1
- package/dist/chatbot.d.cts +4 -4
- package/dist/chatbot.d.ts +4 -4
- package/dist/index.cjs +85 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +83 -2
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +66 -0
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +2 -2
- package/dist/native.d.ts +2 -2
- package/dist/native.js +66 -0
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +143 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +15 -12
- package/dist/react.d.ts +15 -12
- package/dist/react.js +143 -8
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +11 -0
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +6 -6
- package/dist/realtime.d.ts +6 -6
- package/dist/realtime.js +11 -0
- package/dist/realtime.js.map +1 -1
- package/dist/{shape-builders-DFudWDFI.d.cts → shape-builders-CsSXKCcs.d.ts} +43 -2
- package/dist/{shape-builders-ENwnK-zT.d.ts → shape-builders-CsbSRZnQ.d.cts} +43 -2
- package/dist/tldraw.cjs +68 -2
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.d.cts +1 -1
- package/dist/tldraw.d.ts +1 -1
- package/dist/tldraw.js +68 -2
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-DNwjgs5U.d.cts → types-B2Na677H.d.cts} +1 -1
- package/dist/{types-BLXR7g_L.d.cts → types-B6PAYKzx.d.ts} +4 -4
- package/dist/{types-CB0TZZuk.d.cts → types-Bnq2HtHQ.d.cts} +1 -1
- package/dist/{types-CB0TZZuk.d.ts → types-Bnq2HtHQ.d.ts} +1 -1
- package/dist/{types-Cm7IsgL4.d.ts → types-DWGk2_GZ.d.cts} +4 -4
- package/dist/{types-BtAJFS_-.d.ts → types-zmUah-vP.d.ts} +1 -1
- package/package.json +1 -1
package/dist/native.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Camera2D } from './camera-
|
|
3
|
-
import { V as VectorSceneItem, R as Rect } from './types-
|
|
2
|
+
import { C as Camera2D } from './camera-Di5R_Rwl.cjs';
|
|
3
|
+
import { V as VectorSceneItem, R as Rect } from './types-Bnq2HtHQ.cjs';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
|
|
6
6
|
type PlacementPreview = {
|
package/dist/native.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Camera2D } from './camera-
|
|
3
|
-
import { V as VectorSceneItem, R as Rect } from './types-
|
|
2
|
+
import { C as Camera2D } from './camera-AoTwBSoE.js';
|
|
3
|
+
import { V as VectorSceneItem, R as Rect } from './types-Bnq2HtHQ.js';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
|
|
6
6
|
type PlacementPreview = {
|
package/dist/native.js
CHANGED
|
@@ -343,6 +343,22 @@ function resolveStrokeStyle(item) {
|
|
|
343
343
|
function strokeOpacityAttr(style) {
|
|
344
344
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
345
345
|
}
|
|
346
|
+
function svgNumber(value) {
|
|
347
|
+
if (!Number.isFinite(value)) return "0";
|
|
348
|
+
const rounded = Math.round(value * 100) / 100;
|
|
349
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
350
|
+
}
|
|
351
|
+
function approximateEllipsePerimeter(rx, ry) {
|
|
352
|
+
if (rx <= 0 || ry <= 0) return 0;
|
|
353
|
+
return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
|
354
|
+
}
|
|
355
|
+
function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
356
|
+
const perimeter = approximateEllipsePerimeter(rx, ry);
|
|
357
|
+
const targetScallopLength = Math.max(10, amplitude * 2);
|
|
358
|
+
let count = Math.max(12, Math.round(perimeter / targetScallopLength));
|
|
359
|
+
if (count % 2 === 1) count += 1;
|
|
360
|
+
return count;
|
|
361
|
+
}
|
|
346
362
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
347
363
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
348
364
|
}
|
|
@@ -351,6 +367,49 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
|
351
367
|
const ry = height / 2;
|
|
352
368
|
return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
353
369
|
}
|
|
370
|
+
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
|
|
371
|
+
const w = Math.max(0, width);
|
|
372
|
+
const h = Math.max(0, height);
|
|
373
|
+
if (w <= 0 || h <= 0) return "";
|
|
374
|
+
const inset = Math.max(0.5, strokeWidth / 2);
|
|
375
|
+
const outerRx = Math.max(0, w / 2 - inset);
|
|
376
|
+
const outerRy = Math.max(0, h / 2 - inset);
|
|
377
|
+
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
378
|
+
const amplitude = Math.min(
|
|
379
|
+
outerRx * 0.45,
|
|
380
|
+
outerRy * 0.45,
|
|
381
|
+
Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
|
|
382
|
+
);
|
|
383
|
+
const innerRx = Math.max(0, outerRx - amplitude);
|
|
384
|
+
const innerRy = Math.max(0, outerRy - amplitude);
|
|
385
|
+
const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
|
|
386
|
+
const angleStep = Math.PI * 2 / scallopCount;
|
|
387
|
+
const cx = w / 2;
|
|
388
|
+
const cy = h / 2;
|
|
389
|
+
const startAngle = -Math.PI / 2;
|
|
390
|
+
const pointOnEllipse = (theta, radiusX, radiusY) => [
|
|
391
|
+
cx + Math.cos(theta) * radiusX,
|
|
392
|
+
cy + Math.sin(theta) * radiusY
|
|
393
|
+
];
|
|
394
|
+
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
395
|
+
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
396
|
+
for (let index = 0; index < scallopCount; index += 1) {
|
|
397
|
+
const segmentStart = startAngle + index * angleStep;
|
|
398
|
+
const segmentMid = segmentStart + angleStep / 2;
|
|
399
|
+
const segmentEnd = segmentStart + angleStep;
|
|
400
|
+
const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
|
|
401
|
+
const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
|
|
402
|
+
segments.push(
|
|
403
|
+
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
segments.push("Z");
|
|
407
|
+
return segments.join(" ");
|
|
408
|
+
}
|
|
409
|
+
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
410
|
+
const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
|
|
411
|
+
return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
|
|
412
|
+
}
|
|
354
413
|
function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
|
|
355
414
|
return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
356
415
|
}
|
|
@@ -484,6 +543,13 @@ function rebuildItemSvg(item) {
|
|
|
484
543
|
childrenSvg: buildEllipseSvg(b.width, b.height, style)
|
|
485
544
|
};
|
|
486
545
|
}
|
|
546
|
+
if (k === "architectural-cloud") {
|
|
547
|
+
const b = normalizeRect(item.bounds);
|
|
548
|
+
return {
|
|
549
|
+
...item,
|
|
550
|
+
childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
|
|
551
|
+
};
|
|
552
|
+
}
|
|
487
553
|
if ((k === "line" || k === "arrow") && item.line) {
|
|
488
554
|
const line = item.line;
|
|
489
555
|
const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
|