canvu-react 0.3.28 → 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 +183 -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 +183 -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/tldraw.d.cts
CHANGED
package/dist/tldraw.d.ts
CHANGED
package/dist/tldraw.js
CHANGED
|
@@ -217,6 +217,41 @@ function resolveStrokeStyle(item) {
|
|
|
217
217
|
function strokeOpacityAttr(style) {
|
|
218
218
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
219
219
|
}
|
|
220
|
+
function clampNumber(value, min, max) {
|
|
221
|
+
return Math.min(max, Math.max(min, value));
|
|
222
|
+
}
|
|
223
|
+
function svgNumber(value) {
|
|
224
|
+
if (!Number.isFinite(value)) return "0";
|
|
225
|
+
return Number(value.toFixed(3)).toString();
|
|
226
|
+
}
|
|
227
|
+
function architecturalCloudScallopCount(length, depth) {
|
|
228
|
+
if (length <= 1e-6) return 0;
|
|
229
|
+
return Math.max(1, Math.round(length / Math.max(depth * 2.05, 8)));
|
|
230
|
+
}
|
|
231
|
+
function appendHorizontalScallops(segments, startX, endX, y, controlY, count) {
|
|
232
|
+
if (count <= 0) return;
|
|
233
|
+
const step = (endX - startX) / count;
|
|
234
|
+
for (let index = 1; index <= count; index += 1) {
|
|
235
|
+
const x0 = startX + step * (index - 1);
|
|
236
|
+
const x1 = index === count ? endX : startX + step * index;
|
|
237
|
+
const cx = (x0 + x1) / 2;
|
|
238
|
+
segments.push(
|
|
239
|
+
`Q${svgNumber(cx)} ${svgNumber(controlY)} ${svgNumber(x1)} ${svgNumber(y)}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function appendVerticalScallops(segments, startY, endY, x, controlX, count) {
|
|
244
|
+
if (count <= 0) return;
|
|
245
|
+
const step = (endY - startY) / count;
|
|
246
|
+
for (let index = 1; index <= count; index += 1) {
|
|
247
|
+
const y0 = startY + step * (index - 1);
|
|
248
|
+
const y1 = index === count ? endY : startY + step * index;
|
|
249
|
+
const cy = (y0 + y1) / 2;
|
|
250
|
+
segments.push(
|
|
251
|
+
`Q${svgNumber(controlX)} ${svgNumber(cy)} ${svgNumber(x)} ${svgNumber(y1)}`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
220
255
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
221
256
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
222
257
|
}
|
|
@@ -225,6 +260,63 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
|
225
260
|
const ry = height / 2;
|
|
226
261
|
return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
227
262
|
}
|
|
263
|
+
function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
|
|
264
|
+
const w = Math.max(0, width);
|
|
265
|
+
const h = Math.max(0, height);
|
|
266
|
+
if (w <= 0 || h <= 0) return "";
|
|
267
|
+
const inset = Math.min(w / 2, h / 2, Math.max(0.5, strokeWidth / 2));
|
|
268
|
+
const x0 = inset;
|
|
269
|
+
const y0 = inset;
|
|
270
|
+
const x1 = Math.max(x0, w - inset);
|
|
271
|
+
const y1 = Math.max(y0, h - inset);
|
|
272
|
+
const innerW = Math.max(0, x1 - x0);
|
|
273
|
+
const innerH = Math.max(0, y1 - y0);
|
|
274
|
+
if (innerW <= 0 || innerH <= 0) return "";
|
|
275
|
+
const maxDepth = Math.max(0.5, Math.min(innerW, innerH) * 0.18);
|
|
276
|
+
const depth = clampNumber(Math.min(w, h) * 0.08, 2, Math.min(12, maxDepth));
|
|
277
|
+
const corner = Math.min(depth * 1.2, innerW / 2, innerH / 2);
|
|
278
|
+
const topStart = x0 + corner;
|
|
279
|
+
const topEnd = x1 - corner;
|
|
280
|
+
const rightStart = y0 + corner;
|
|
281
|
+
const rightEnd = y1 - corner;
|
|
282
|
+
const bottomStart = x1 - corner;
|
|
283
|
+
const bottomEnd = x0 + corner;
|
|
284
|
+
const leftStart = y1 - corner;
|
|
285
|
+
const leftEnd = y0 + corner;
|
|
286
|
+
const topCount = architecturalCloudScallopCount(topEnd - topStart, depth);
|
|
287
|
+
const rightCount = architecturalCloudScallopCount(rightEnd - rightStart, depth);
|
|
288
|
+
const bottomCount = architecturalCloudScallopCount(bottomStart - bottomEnd, depth);
|
|
289
|
+
const leftCount = architecturalCloudScallopCount(leftStart - leftEnd, depth);
|
|
290
|
+
const segments = [`M${svgNumber(topStart)} ${svgNumber(y0)}`];
|
|
291
|
+
appendHorizontalScallops(segments, topStart, topEnd, y0, y0 + depth, topCount);
|
|
292
|
+
segments.push(
|
|
293
|
+
`Q${svgNumber(x1)} ${svgNumber(y0)} ${svgNumber(x1)} ${svgNumber(rightStart)}`
|
|
294
|
+
);
|
|
295
|
+
appendVerticalScallops(segments, rightStart, rightEnd, x1, x1 - depth, rightCount);
|
|
296
|
+
segments.push(
|
|
297
|
+
`Q${svgNumber(x1)} ${svgNumber(y1)} ${svgNumber(bottomStart)} ${svgNumber(y1)}`
|
|
298
|
+
);
|
|
299
|
+
appendHorizontalScallops(
|
|
300
|
+
segments,
|
|
301
|
+
bottomStart,
|
|
302
|
+
bottomEnd,
|
|
303
|
+
y1,
|
|
304
|
+
y1 - depth,
|
|
305
|
+
bottomCount
|
|
306
|
+
);
|
|
307
|
+
segments.push(
|
|
308
|
+
`Q${svgNumber(x0)} ${svgNumber(y1)} ${svgNumber(x0)} ${svgNumber(leftStart)}`
|
|
309
|
+
);
|
|
310
|
+
appendVerticalScallops(segments, leftStart, leftEnd, x0, x0 + depth, leftCount);
|
|
311
|
+
segments.push(
|
|
312
|
+
`Q${svgNumber(x0)} ${svgNumber(y0)} ${svgNumber(topStart)} ${svgNumber(y0)} Z`
|
|
313
|
+
);
|
|
314
|
+
return segments.join(" ");
|
|
315
|
+
}
|
|
316
|
+
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
317
|
+
const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
|
|
318
|
+
return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
|
|
319
|
+
}
|
|
228
320
|
function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
|
|
229
321
|
return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
|
|
230
322
|
}
|
|
@@ -363,6 +455,13 @@ function rebuildItemSvg(item) {
|
|
|
363
455
|
childrenSvg: buildEllipseSvg(b.width, b.height, style)
|
|
364
456
|
};
|
|
365
457
|
}
|
|
458
|
+
if (k === "architectural-cloud") {
|
|
459
|
+
const b = normalizeRect(item.bounds);
|
|
460
|
+
return {
|
|
461
|
+
...item,
|
|
462
|
+
childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
|
|
463
|
+
};
|
|
464
|
+
}
|
|
366
465
|
if ((k === "line" || k === "arrow") && item.line) {
|
|
367
466
|
const line = item.line;
|
|
368
467
|
const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
|
|
@@ -1789,8 +1888,8 @@ function itemsToTldrawSnapshot(items) {
|
|
|
1789
1888
|
if (item.strokeOpacity != null) {
|
|
1790
1889
|
props.opacity = Math.round(item.strokeOpacity * 100);
|
|
1791
1890
|
}
|
|
1792
|
-
if (type === "rect" || type === "ellipse") {
|
|
1793
|
-
props.geo = type === "ellipse" ? "ellipse" : "rectangle";
|
|
1891
|
+
if (type === "rect" || type === "ellipse" || type === "architectural-cloud") {
|
|
1892
|
+
props.geo = type === "ellipse" ? "ellipse" : type === "architectural-cloud" ? "cloud" : "rectangle";
|
|
1794
1893
|
props.fill = "none";
|
|
1795
1894
|
} else if (type === "draw" || type === "marker") {
|
|
1796
1895
|
props.segments = [
|