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/tldraw.d.cts
CHANGED
package/dist/tldraw.d.ts
CHANGED
package/dist/tldraw.js
CHANGED
|
@@ -217,6 +217,22 @@ function resolveStrokeStyle(item) {
|
|
|
217
217
|
function strokeOpacityAttr(style) {
|
|
218
218
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
219
219
|
}
|
|
220
|
+
function svgNumber(value) {
|
|
221
|
+
if (!Number.isFinite(value)) return "0";
|
|
222
|
+
const rounded = Math.round(value * 100) / 100;
|
|
223
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
224
|
+
}
|
|
225
|
+
function approximateEllipsePerimeter(rx, ry) {
|
|
226
|
+
if (rx <= 0 || ry <= 0) return 0;
|
|
227
|
+
return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
|
228
|
+
}
|
|
229
|
+
function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
230
|
+
const perimeter = approximateEllipsePerimeter(rx, ry);
|
|
231
|
+
const targetScallopLength = Math.max(10, amplitude * 2);
|
|
232
|
+
let count = Math.max(12, Math.round(perimeter / targetScallopLength));
|
|
233
|
+
if (count % 2 === 1) count += 1;
|
|
234
|
+
return count;
|
|
235
|
+
}
|
|
220
236
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
221
237
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
222
238
|
}
|
|
@@ -225,6 +241,49 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
|
225
241
|
const ry = height / 2;
|
|
226
242
|
return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
227
243
|
}
|
|
244
|
+
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
|
|
245
|
+
const w = Math.max(0, width);
|
|
246
|
+
const h = Math.max(0, height);
|
|
247
|
+
if (w <= 0 || h <= 0) return "";
|
|
248
|
+
const inset = Math.max(0.5, strokeWidth / 2);
|
|
249
|
+
const outerRx = Math.max(0, w / 2 - inset);
|
|
250
|
+
const outerRy = Math.max(0, h / 2 - inset);
|
|
251
|
+
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
252
|
+
const amplitude = Math.min(
|
|
253
|
+
outerRx * 0.45,
|
|
254
|
+
outerRy * 0.45,
|
|
255
|
+
Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
|
|
256
|
+
);
|
|
257
|
+
const innerRx = Math.max(0, outerRx - amplitude);
|
|
258
|
+
const innerRy = Math.max(0, outerRy - amplitude);
|
|
259
|
+
const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
|
|
260
|
+
const angleStep = Math.PI * 2 / scallopCount;
|
|
261
|
+
const cx = w / 2;
|
|
262
|
+
const cy = h / 2;
|
|
263
|
+
const startAngle = -Math.PI / 2;
|
|
264
|
+
const pointOnEllipse = (theta, radiusX, radiusY) => [
|
|
265
|
+
cx + Math.cos(theta) * radiusX,
|
|
266
|
+
cy + Math.sin(theta) * radiusY
|
|
267
|
+
];
|
|
268
|
+
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
269
|
+
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
270
|
+
for (let index = 0; index < scallopCount; index += 1) {
|
|
271
|
+
const segmentStart = startAngle + index * angleStep;
|
|
272
|
+
const segmentMid = segmentStart + angleStep / 2;
|
|
273
|
+
const segmentEnd = segmentStart + angleStep;
|
|
274
|
+
const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
|
|
275
|
+
const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
|
|
276
|
+
segments.push(
|
|
277
|
+
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
segments.push("Z");
|
|
281
|
+
return segments.join(" ");
|
|
282
|
+
}
|
|
283
|
+
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
284
|
+
const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
|
|
285
|
+
return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
|
|
286
|
+
}
|
|
228
287
|
function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
|
|
229
288
|
return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
230
289
|
}
|
|
@@ -363,6 +422,13 @@ function rebuildItemSvg(item) {
|
|
|
363
422
|
childrenSvg: buildEllipseSvg(b.width, b.height, style)
|
|
364
423
|
};
|
|
365
424
|
}
|
|
425
|
+
if (k === "architectural-cloud") {
|
|
426
|
+
const b = normalizeRect(item.bounds);
|
|
427
|
+
return {
|
|
428
|
+
...item,
|
|
429
|
+
childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
366
432
|
if ((k === "line" || k === "arrow") && item.line) {
|
|
367
433
|
const line = item.line;
|
|
368
434
|
const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
|
|
@@ -1789,8 +1855,8 @@ function itemsToTldrawSnapshot(items) {
|
|
|
1789
1855
|
if (item.strokeOpacity != null) {
|
|
1790
1856
|
props.opacity = Math.round(item.strokeOpacity * 100);
|
|
1791
1857
|
}
|
|
1792
|
-
if (type === "rect" || type === "ellipse") {
|
|
1793
|
-
props.geo = type === "ellipse" ? "ellipse" : "rectangle";
|
|
1858
|
+
if (type === "rect" || type === "ellipse" || type === "architectural-cloud") {
|
|
1859
|
+
props.geo = type === "ellipse" ? "ellipse" : type === "architectural-cloud" ? "cloud" : "rectangle";
|
|
1794
1860
|
props.fill = "none";
|
|
1795
1861
|
} else if (type === "draw" || type === "marker") {
|
|
1796
1862
|
props.segments = [
|