canvu-react 0.3.29 → 0.3.30
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 +118 -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 +116 -2
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +99 -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 +99 -0
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +175 -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 +175 -8
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +10 -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 +10 -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 +101 -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 +101 -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.cjs
CHANGED
|
@@ -349,6 +349,41 @@ function resolveStrokeStyle(item) {
|
|
|
349
349
|
function strokeOpacityAttr(style) {
|
|
350
350
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
351
351
|
}
|
|
352
|
+
function clampNumber(value, min, max) {
|
|
353
|
+
return Math.min(max, Math.max(min, value));
|
|
354
|
+
}
|
|
355
|
+
function svgNumber(value) {
|
|
356
|
+
if (!Number.isFinite(value)) return "0";
|
|
357
|
+
return Number(value.toFixed(3)).toString();
|
|
358
|
+
}
|
|
359
|
+
function architecturalCloudScallopCount(length, depth) {
|
|
360
|
+
if (length <= 1e-6) return 0;
|
|
361
|
+
return Math.max(1, Math.round(length / Math.max(depth * 2.05, 8)));
|
|
362
|
+
}
|
|
363
|
+
function appendHorizontalScallops(segments, startX, endX, y, controlY, count) {
|
|
364
|
+
if (count <= 0) return;
|
|
365
|
+
const step = (endX - startX) / count;
|
|
366
|
+
for (let index = 1; index <= count; index += 1) {
|
|
367
|
+
const x0 = startX + step * (index - 1);
|
|
368
|
+
const x1 = index === count ? endX : startX + step * index;
|
|
369
|
+
const cx = (x0 + x1) / 2;
|
|
370
|
+
segments.push(
|
|
371
|
+
`Q${svgNumber(cx)} ${svgNumber(controlY)} ${svgNumber(x1)} ${svgNumber(y)}`
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function appendVerticalScallops(segments, startY, endY, x, controlX, count) {
|
|
376
|
+
if (count <= 0) return;
|
|
377
|
+
const step = (endY - startY) / count;
|
|
378
|
+
for (let index = 1; index <= count; index += 1) {
|
|
379
|
+
const y0 = startY + step * (index - 1);
|
|
380
|
+
const y1 = index === count ? endY : startY + step * index;
|
|
381
|
+
const cy = (y0 + y1) / 2;
|
|
382
|
+
segments.push(
|
|
383
|
+
`Q${svgNumber(controlX)} ${svgNumber(cy)} ${svgNumber(x)} ${svgNumber(y1)}`
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
352
387
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
353
388
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
354
389
|
}
|
|
@@ -357,6 +392,63 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
|
357
392
|
const ry = height / 2;
|
|
358
393
|
return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
359
394
|
}
|
|
395
|
+
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
|
|
396
|
+
const w = Math.max(0, width);
|
|
397
|
+
const h = Math.max(0, height);
|
|
398
|
+
if (w <= 0 || h <= 0) return "";
|
|
399
|
+
const inset = Math.min(w / 2, h / 2, Math.max(0.5, strokeWidth / 2));
|
|
400
|
+
const x0 = inset;
|
|
401
|
+
const y0 = inset;
|
|
402
|
+
const x1 = Math.max(x0, w - inset);
|
|
403
|
+
const y1 = Math.max(y0, h - inset);
|
|
404
|
+
const innerW = Math.max(0, x1 - x0);
|
|
405
|
+
const innerH = Math.max(0, y1 - y0);
|
|
406
|
+
if (innerW <= 0 || innerH <= 0) return "";
|
|
407
|
+
const maxDepth = Math.max(0.5, Math.min(innerW, innerH) * 0.18);
|
|
408
|
+
const depth = clampNumber(Math.min(w, h) * 0.08, 2, Math.min(12, maxDepth));
|
|
409
|
+
const corner = Math.min(depth * 1.2, innerW / 2, innerH / 2);
|
|
410
|
+
const topStart = x0 + corner;
|
|
411
|
+
const topEnd = x1 - corner;
|
|
412
|
+
const rightStart = y0 + corner;
|
|
413
|
+
const rightEnd = y1 - corner;
|
|
414
|
+
const bottomStart = x1 - corner;
|
|
415
|
+
const bottomEnd = x0 + corner;
|
|
416
|
+
const leftStart = y1 - corner;
|
|
417
|
+
const leftEnd = y0 + corner;
|
|
418
|
+
const topCount = architecturalCloudScallopCount(topEnd - topStart, depth);
|
|
419
|
+
const rightCount = architecturalCloudScallopCount(rightEnd - rightStart, depth);
|
|
420
|
+
const bottomCount = architecturalCloudScallopCount(bottomStart - bottomEnd, depth);
|
|
421
|
+
const leftCount = architecturalCloudScallopCount(leftStart - leftEnd, depth);
|
|
422
|
+
const segments = [`M${svgNumber(topStart)} ${svgNumber(y0)}`];
|
|
423
|
+
appendHorizontalScallops(segments, topStart, topEnd, y0, y0 + depth, topCount);
|
|
424
|
+
segments.push(
|
|
425
|
+
`Q${svgNumber(x1)} ${svgNumber(y0)} ${svgNumber(x1)} ${svgNumber(rightStart)}`
|
|
426
|
+
);
|
|
427
|
+
appendVerticalScallops(segments, rightStart, rightEnd, x1, x1 - depth, rightCount);
|
|
428
|
+
segments.push(
|
|
429
|
+
`Q${svgNumber(x1)} ${svgNumber(y1)} ${svgNumber(bottomStart)} ${svgNumber(y1)}`
|
|
430
|
+
);
|
|
431
|
+
appendHorizontalScallops(
|
|
432
|
+
segments,
|
|
433
|
+
bottomStart,
|
|
434
|
+
bottomEnd,
|
|
435
|
+
y1,
|
|
436
|
+
y1 - depth,
|
|
437
|
+
bottomCount
|
|
438
|
+
);
|
|
439
|
+
segments.push(
|
|
440
|
+
`Q${svgNumber(x0)} ${svgNumber(y1)} ${svgNumber(x0)} ${svgNumber(leftStart)}`
|
|
441
|
+
);
|
|
442
|
+
appendVerticalScallops(segments, leftStart, leftEnd, x0, x0 + depth, leftCount);
|
|
443
|
+
segments.push(
|
|
444
|
+
`Q${svgNumber(x0)} ${svgNumber(y0)} ${svgNumber(topStart)} ${svgNumber(y0)} Z`
|
|
445
|
+
);
|
|
446
|
+
return segments.join(" ");
|
|
447
|
+
}
|
|
448
|
+
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
449
|
+
const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
|
|
450
|
+
return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
|
|
451
|
+
}
|
|
360
452
|
function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
|
|
361
453
|
return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
362
454
|
}
|
|
@@ -490,6 +582,13 @@ function rebuildItemSvg(item) {
|
|
|
490
582
|
childrenSvg: buildEllipseSvg(b.width, b.height, style)
|
|
491
583
|
};
|
|
492
584
|
}
|
|
585
|
+
if (k === "architectural-cloud") {
|
|
586
|
+
const b = normalizeRect(item.bounds);
|
|
587
|
+
return {
|
|
588
|
+
...item,
|
|
589
|
+
childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
|
|
590
|
+
};
|
|
591
|
+
}
|
|
493
592
|
if ((k === "line" || k === "arrow") && item.line) {
|
|
494
593
|
const line = item.line;
|
|
495
594
|
const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
|