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.
Files changed (45) hide show
  1. package/dist/{asset-hydration-BEG21hMp.d.ts → asset-hydration-DrTOgDdd.d.ts} +2 -2
  2. package/dist/{asset-hydration-3Iv5xHxM.d.cts → asset-hydration-EtEuBwb7.d.cts} +2 -2
  3. package/dist/{camera-KwCYYPhm.d.ts → camera-AoTwBSoE.d.ts} +1 -1
  4. package/dist/{camera-BwQjm5oh.d.cts → camera-Di5R_Rwl.d.cts} +1 -1
  5. package/dist/chatbot.d.cts +4 -4
  6. package/dist/chatbot.d.ts +4 -4
  7. package/dist/index.cjs +85 -1
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +6 -6
  10. package/dist/index.d.ts +6 -6
  11. package/dist/index.js +83 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/native.cjs +66 -0
  14. package/dist/native.cjs.map +1 -1
  15. package/dist/native.d.cts +2 -2
  16. package/dist/native.d.ts +2 -2
  17. package/dist/native.js +66 -0
  18. package/dist/native.js.map +1 -1
  19. package/dist/react.cjs +143 -7
  20. package/dist/react.cjs.map +1 -1
  21. package/dist/react.d.cts +15 -12
  22. package/dist/react.d.ts +15 -12
  23. package/dist/react.js +143 -8
  24. package/dist/react.js.map +1 -1
  25. package/dist/realtime.cjs +11 -0
  26. package/dist/realtime.cjs.map +1 -1
  27. package/dist/realtime.d.cts +6 -6
  28. package/dist/realtime.d.ts +6 -6
  29. package/dist/realtime.js +11 -0
  30. package/dist/realtime.js.map +1 -1
  31. package/dist/{shape-builders-DFudWDFI.d.cts → shape-builders-CsSXKCcs.d.ts} +43 -2
  32. package/dist/{shape-builders-ENwnK-zT.d.ts → shape-builders-CsbSRZnQ.d.cts} +43 -2
  33. package/dist/tldraw.cjs +68 -2
  34. package/dist/tldraw.cjs.map +1 -1
  35. package/dist/tldraw.d.cts +1 -1
  36. package/dist/tldraw.d.ts +1 -1
  37. package/dist/tldraw.js +68 -2
  38. package/dist/tldraw.js.map +1 -1
  39. package/dist/{types-DNwjgs5U.d.cts → types-B2Na677H.d.cts} +1 -1
  40. package/dist/{types-BLXR7g_L.d.cts → types-B6PAYKzx.d.ts} +4 -4
  41. package/dist/{types-CB0TZZuk.d.cts → types-Bnq2HtHQ.d.cts} +1 -1
  42. package/dist/{types-CB0TZZuk.d.ts → types-Bnq2HtHQ.d.ts} +1 -1
  43. package/dist/{types-Cm7IsgL4.d.ts → types-DWGk2_GZ.d.cts} +4 -4
  44. package/dist/{types-BtAJFS_-.d.ts → types-zmUah-vP.d.ts} +1 -1
  45. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, R as Rect, a as ArrowBindings } from './types-CB0TZZuk.cjs';
1
+ import { V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, R as Rect, a as ArrowBindings } from './types-Bnq2HtHQ.js';
2
2
 
3
3
  /**
4
4
  * Kind of binary selected through the built-in canvu asset ingestion flow.
@@ -120,6 +120,28 @@ declare const DEFAULT_STROKE_STYLE: StrokeStyle;
120
120
  declare function resolveStrokeStyle(item: VectorSceneItem): StrokeStyle;
121
121
  declare function buildRectSvg(width: number, height: number, style?: StrokeStyle): string;
122
122
  declare function buildEllipseSvg(width: number, height: number, style?: StrokeStyle): string;
123
+ /**
124
+ * Returns the local SVG path for a scalable architectural revision cloud.
125
+ *
126
+ * Use this low-level helper when you need to preview or inspect the shape without
127
+ * creating a full scene item. Prefer {@link createArchitecturalCloudItem} when
128
+ * adding a cloud to a `VectorSceneItem[]`, because it keeps `toolKind`, bounds,
129
+ * stroke fields, and `childrenSvg` synchronized for editing.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const d = buildArchitecturalCloudPathD(180, 90);
134
+ * ```
135
+ */
136
+ declare function buildArchitecturalCloudPathD(width: number, height: number, strokeWidth?: number): string;
137
+ /**
138
+ * Builds an SVG fragment for an architectural revision cloud outline.
139
+ *
140
+ * This is the renderer-level primitive behind the built-in `"architectural-cloud"`
141
+ * tool. Prefer {@link createArchitecturalCloudItem} for app code that inserts a
142
+ * normal editable scene item.
143
+ */
144
+ declare function buildArchitecturalCloudSvg(width: number, height: number, style?: StrokeStyle): string;
123
145
  declare function buildLineSvg(line: LineEndpointsLocal, style?: StrokeStyle): string;
124
146
  declare function buildArrowSvg(itemId: string, line: LineEndpointsLocal, style?: StrokeStyle): string;
125
147
  declare function buildDrawDotSvg(r: number, style?: StrokeStyle): string;
@@ -181,6 +203,25 @@ declare function applyStrokeToItem(item: VectorSceneItem, patch: Partial<Pick<Ve
181
203
  declare function createRectangleItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
182
204
  /** Creates an ellipse shape. */
183
205
  declare function createEllipseItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
206
+ /**
207
+ * Creates an architectural revision cloud shape.
208
+ *
209
+ * Use this high-level builder when adding the built-in cloud shape from code or
210
+ * from custom integrations. It creates an editable `VectorSceneItem` with
211
+ * `toolKind: "architectural-cloud"`, so resize, stroke styling, selection, and
212
+ * serialization continue to work like the built-in rectangle and ellipse tools.
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * const cloud = createArchitecturalCloudItem(createShapeId(), {
217
+ * x: 40,
218
+ * y: 30,
219
+ * width: 180,
220
+ * height: 90,
221
+ * });
222
+ * ```
223
+ */
224
+ declare function createArchitecturalCloudItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
184
225
  /** Creates a straight line or arrow; `line` is usually from {@link lineEndpointsToLocal}. */
185
226
  declare function createLineItem(id: string, bounds: Rect, line: LineEndpointsLocal, toolKind: "line" | "arrow", style?: Partial<StrokeStyle>, arrowBind?: ArrowBindings): VectorSceneItem;
186
227
  /** “Draw dot” tool: a small filled circle at (`worldX`, `worldY`). */
@@ -200,4 +241,4 @@ declare function createImageFromVectorTrace(id: string, bounds: Rect, imageVecto
200
241
  height: number;
201
242
  }): VectorSceneItem;
202
243
 
203
- export { DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type VectorViewportAssetKind as V, applyStrokeToItem as a, buildArrowSvg as b, buildDrawDotSvg as c, buildEllipseSvg as d, buildFreehandPathSvg as e, buildLineSvg as f, buildRectSvg as g, computeFreehandSvgPayload as h, createDrawDotItem as i, createEllipseItem as j, createFreehandStrokeItem as k, createImageFromVectorTrace as l, createImageItem as m, createLineItem as n, createRectangleItem as o, createShapeId as p, createTextItem as q, lineEndpointsToLocal as r, rebuildItemSvg as s, resolveStrokeStyle as t, type VectorViewportAssetStore as u, type VectorViewportAssetHydrationRequest as v, type VectorViewportAssetResolveRequest as w, type VectorViewportAssetResolveResult as x, type VectorViewportAssetUploadRequest as y, type VectorViewportAssetUploadResult as z };
244
+ export { type VectorViewportAssetResolveResult as A, type VectorViewportAssetUploadRequest as B, type VectorViewportAssetUploadResult as C, DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type VectorViewportAssetKind as V, applyStrokeToItem as a, buildArchitecturalCloudPathD as b, buildArchitecturalCloudSvg as c, buildArrowSvg as d, buildDrawDotSvg as e, buildEllipseSvg as f, buildFreehandPathSvg as g, buildLineSvg as h, buildRectSvg as i, computeFreehandSvgPayload as j, createArchitecturalCloudItem as k, createDrawDotItem as l, createEllipseItem as m, createFreehandStrokeItem as n, createImageFromVectorTrace as o, createImageItem as p, createLineItem as q, createRectangleItem as r, createShapeId as s, createTextItem as t, lineEndpointsToLocal as u, rebuildItemSvg as v, resolveStrokeStyle as w, type VectorViewportAssetStore as x, type VectorViewportAssetHydrationRequest as y, type VectorViewportAssetResolveRequest as z };
@@ -1,4 +1,4 @@
1
- import { V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, R as Rect, a as ArrowBindings } from './types-CB0TZZuk.js';
1
+ import { V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, R as Rect, a as ArrowBindings } from './types-Bnq2HtHQ.cjs';
2
2
 
3
3
  /**
4
4
  * Kind of binary selected through the built-in canvu asset ingestion flow.
@@ -120,6 +120,28 @@ declare const DEFAULT_STROKE_STYLE: StrokeStyle;
120
120
  declare function resolveStrokeStyle(item: VectorSceneItem): StrokeStyle;
121
121
  declare function buildRectSvg(width: number, height: number, style?: StrokeStyle): string;
122
122
  declare function buildEllipseSvg(width: number, height: number, style?: StrokeStyle): string;
123
+ /**
124
+ * Returns the local SVG path for a scalable architectural revision cloud.
125
+ *
126
+ * Use this low-level helper when you need to preview or inspect the shape without
127
+ * creating a full scene item. Prefer {@link createArchitecturalCloudItem} when
128
+ * adding a cloud to a `VectorSceneItem[]`, because it keeps `toolKind`, bounds,
129
+ * stroke fields, and `childrenSvg` synchronized for editing.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const d = buildArchitecturalCloudPathD(180, 90);
134
+ * ```
135
+ */
136
+ declare function buildArchitecturalCloudPathD(width: number, height: number, strokeWidth?: number): string;
137
+ /**
138
+ * Builds an SVG fragment for an architectural revision cloud outline.
139
+ *
140
+ * This is the renderer-level primitive behind the built-in `"architectural-cloud"`
141
+ * tool. Prefer {@link createArchitecturalCloudItem} for app code that inserts a
142
+ * normal editable scene item.
143
+ */
144
+ declare function buildArchitecturalCloudSvg(width: number, height: number, style?: StrokeStyle): string;
123
145
  declare function buildLineSvg(line: LineEndpointsLocal, style?: StrokeStyle): string;
124
146
  declare function buildArrowSvg(itemId: string, line: LineEndpointsLocal, style?: StrokeStyle): string;
125
147
  declare function buildDrawDotSvg(r: number, style?: StrokeStyle): string;
@@ -181,6 +203,25 @@ declare function applyStrokeToItem(item: VectorSceneItem, patch: Partial<Pick<Ve
181
203
  declare function createRectangleItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
182
204
  /** Creates an ellipse shape. */
183
205
  declare function createEllipseItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
206
+ /**
207
+ * Creates an architectural revision cloud shape.
208
+ *
209
+ * Use this high-level builder when adding the built-in cloud shape from code or
210
+ * from custom integrations. It creates an editable `VectorSceneItem` with
211
+ * `toolKind: "architectural-cloud"`, so resize, stroke styling, selection, and
212
+ * serialization continue to work like the built-in rectangle and ellipse tools.
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * const cloud = createArchitecturalCloudItem(createShapeId(), {
217
+ * x: 40,
218
+ * y: 30,
219
+ * width: 180,
220
+ * height: 90,
221
+ * });
222
+ * ```
223
+ */
224
+ declare function createArchitecturalCloudItem(id: string, bounds: Rect, style?: Partial<StrokeStyle>): VectorSceneItem;
184
225
  /** Creates a straight line or arrow; `line` is usually from {@link lineEndpointsToLocal}. */
185
226
  declare function createLineItem(id: string, bounds: Rect, line: LineEndpointsLocal, toolKind: "line" | "arrow", style?: Partial<StrokeStyle>, arrowBind?: ArrowBindings): VectorSceneItem;
186
227
  /** “Draw dot” tool: a small filled circle at (`worldX`, `worldY`). */
@@ -200,4 +241,4 @@ declare function createImageFromVectorTrace(id: string, bounds: Rect, imageVecto
200
241
  height: number;
201
242
  }): VectorSceneItem;
202
243
 
203
- export { DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type VectorViewportAssetKind as V, applyStrokeToItem as a, buildArrowSvg as b, buildDrawDotSvg as c, buildEllipseSvg as d, buildFreehandPathSvg as e, buildLineSvg as f, buildRectSvg as g, computeFreehandSvgPayload as h, createDrawDotItem as i, createEllipseItem as j, createFreehandStrokeItem as k, createImageFromVectorTrace as l, createImageItem as m, createLineItem as n, createRectangleItem as o, createShapeId as p, createTextItem as q, lineEndpointsToLocal as r, rebuildItemSvg as s, resolveStrokeStyle as t, type VectorViewportAssetStore as u, type VectorViewportAssetHydrationRequest as v, type VectorViewportAssetResolveRequest as w, type VectorViewportAssetResolveResult as x, type VectorViewportAssetUploadRequest as y, type VectorViewportAssetUploadResult as z };
244
+ export { type VectorViewportAssetResolveResult as A, type VectorViewportAssetUploadRequest as B, type VectorViewportAssetUploadResult as C, DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type VectorViewportAssetKind as V, applyStrokeToItem as a, buildArchitecturalCloudPathD as b, buildArchitecturalCloudSvg as c, buildArrowSvg as d, buildDrawDotSvg as e, buildEllipseSvg as f, buildFreehandPathSvg as g, buildLineSvg as h, buildRectSvg as i, computeFreehandSvgPayload as j, createArchitecturalCloudItem as k, createDrawDotItem as l, createEllipseItem as m, createFreehandStrokeItem as n, createImageFromVectorTrace as o, createImageItem as p, createLineItem as q, createRectangleItem as r, createShapeId as s, createTextItem as t, lineEndpointsToLocal as u, rebuildItemSvg as v, resolveStrokeStyle as w, type VectorViewportAssetStore as x, type VectorViewportAssetHydrationRequest as y, type VectorViewportAssetResolveRequest as z };
package/dist/tldraw.cjs CHANGED
@@ -223,6 +223,22 @@ function resolveStrokeStyle(item) {
223
223
  function strokeOpacityAttr(style) {
224
224
  return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
225
225
  }
226
+ function svgNumber(value) {
227
+ if (!Number.isFinite(value)) return "0";
228
+ const rounded = Math.round(value * 100) / 100;
229
+ return Number.isInteger(rounded) ? String(rounded) : String(rounded);
230
+ }
231
+ function approximateEllipsePerimeter(rx, ry) {
232
+ if (rx <= 0 || ry <= 0) return 0;
233
+ return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
234
+ }
235
+ function architecturalCloudScallopCount(rx, ry, amplitude) {
236
+ const perimeter = approximateEllipsePerimeter(rx, ry);
237
+ const targetScallopLength = Math.max(10, amplitude * 2);
238
+ let count = Math.max(12, Math.round(perimeter / targetScallopLength));
239
+ if (count % 2 === 1) count += 1;
240
+ return count;
241
+ }
226
242
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
227
243
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
228
244
  }
@@ -231,6 +247,49 @@ function buildEllipseSvg(width, height, style = DEFAULT_STROKE_STYLE) {
231
247
  const ry = height / 2;
232
248
  return `<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
233
249
  }
250
+ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROKE_STYLE.strokeWidth) {
251
+ const w = Math.max(0, width);
252
+ const h = Math.max(0, height);
253
+ if (w <= 0 || h <= 0) return "";
254
+ const inset = Math.max(0.5, strokeWidth / 2);
255
+ const outerRx = Math.max(0, w / 2 - inset);
256
+ const outerRy = Math.max(0, h / 2 - inset);
257
+ if (outerRx <= 0 || outerRy <= 0) return "";
258
+ const amplitude = Math.min(
259
+ outerRx * 0.45,
260
+ outerRy * 0.45,
261
+ Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
262
+ );
263
+ const innerRx = Math.max(0, outerRx - amplitude);
264
+ const innerRy = Math.max(0, outerRy - amplitude);
265
+ const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
266
+ const angleStep = Math.PI * 2 / scallopCount;
267
+ const cx = w / 2;
268
+ const cy = h / 2;
269
+ const startAngle = -Math.PI / 2;
270
+ const pointOnEllipse = (theta, radiusX, radiusY) => [
271
+ cx + Math.cos(theta) * radiusX,
272
+ cy + Math.sin(theta) * radiusY
273
+ ];
274
+ const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
275
+ const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
276
+ for (let index = 0; index < scallopCount; index += 1) {
277
+ const segmentStart = startAngle + index * angleStep;
278
+ const segmentMid = segmentStart + angleStep / 2;
279
+ const segmentEnd = segmentStart + angleStep;
280
+ const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
281
+ const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
282
+ segments.push(
283
+ `Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
284
+ );
285
+ }
286
+ segments.push("Z");
287
+ return segments.join(" ");
288
+ }
289
+ function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
290
+ const d = buildArchitecturalCloudPathD(width, height, style.strokeWidth);
291
+ return `<path d="${d}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${strokeOpacityAttr(style)} />`;
292
+ }
234
293
  function buildLineSvg(line, style = DEFAULT_STROKE_STYLE) {
235
294
  return `<line x1="${line.x1}" y1="${line.y1}" x2="${line.x2}" y2="${line.y2}" stroke="${style.stroke}" stroke-width="${style.strokeWidth}"${strokeOpacityAttr(style)} />`;
236
295
  }
@@ -369,6 +428,13 @@ function rebuildItemSvg(item) {
369
428
  childrenSvg: buildEllipseSvg(b.width, b.height, style)
370
429
  };
371
430
  }
431
+ if (k === "architectural-cloud") {
432
+ const b = normalizeRect(item.bounds);
433
+ return {
434
+ ...item,
435
+ childrenSvg: buildArchitecturalCloudSvg(b.width, b.height, style)
436
+ };
437
+ }
372
438
  if ((k === "line" || k === "arrow") && item.line) {
373
439
  const line = item.line;
374
440
  const childrenSvg = k === "arrow" ? buildArrowSvg(item.id, line, style) : buildLineSvg(line, style);
@@ -1795,8 +1861,8 @@ function itemsToTldrawSnapshot(items) {
1795
1861
  if (item.strokeOpacity != null) {
1796
1862
  props.opacity = Math.round(item.strokeOpacity * 100);
1797
1863
  }
1798
- if (type === "rect" || type === "ellipse") {
1799
- props.geo = type === "ellipse" ? "ellipse" : "rectangle";
1864
+ if (type === "rect" || type === "ellipse" || type === "architectural-cloud") {
1865
+ props.geo = type === "ellipse" ? "ellipse" : type === "architectural-cloud" ? "cloud" : "rectangle";
1800
1866
  props.fill = "none";
1801
1867
  } else if (type === "draw" || type === "marker") {
1802
1868
  props.segments = [