canvu-react 0.3.7 → 0.3.9
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/README.md +192 -0
- package/dist/chatbot.d.cts +1 -1
- package/dist/chatbot.d.ts +1 -1
- package/dist/index.cjs +32 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -144
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +31 -109
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +31 -109
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +1449 -1353
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +147 -4
- package/dist/react.d.ts +147 -4
- package/dist/react.js +1449 -1354
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +244 -11
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +20 -7
- package/dist/realtime.d.ts +20 -7
- package/dist/realtime.js +244 -12
- package/dist/realtime.js.map +1 -1
- package/dist/tldraw.cjs +30 -142
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +30 -142
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-B_rv7p8b.d.cts → types-BtLGGw0r.d.cts} +126 -1
- package/dist/{types-BCtWx3zP.d.ts → types-ChnTSRSe.d.ts} +126 -1
- package/package.json +1 -1
|
@@ -5,6 +5,109 @@ import { C as Camera2D } from './camera-BwQjm5oh.cjs';
|
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { S as StrokeStyle } from './shape-builders-DxPoOecg.cjs';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Kind of binary selected through the built-in canvu asset ingestion flow.
|
|
10
|
+
*
|
|
11
|
+
* Use this to branch your backend upload logic when images and PDFs should be
|
|
12
|
+
* stored differently.
|
|
13
|
+
*/
|
|
14
|
+
type VectorViewportAssetKind = "image" | "pdf";
|
|
15
|
+
/**
|
|
16
|
+
* Original browser `File` intercepted from the built-in asset flow.
|
|
17
|
+
*
|
|
18
|
+
* This is the high-level hook for apps that want canvu to keep its native file
|
|
19
|
+
* UX while still uploading the raw binary to their backend or object storage.
|
|
20
|
+
*
|
|
21
|
+
* The same request shape is also reused by
|
|
22
|
+
* {@link ingestAssetFilesToSceneItems}, so custom import flows and the native
|
|
23
|
+
* viewport UX can share one backend contract.
|
|
24
|
+
*/
|
|
25
|
+
type VectorViewportAssetUploadRequest = {
|
|
26
|
+
/** Original browser file before canvu converts it into scene items. */
|
|
27
|
+
file: File;
|
|
28
|
+
/** High-level bucket for routing image vs PDF upload behavior. */
|
|
29
|
+
kind: VectorViewportAssetKind;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Persisted metadata returned by a custom asset upload.
|
|
33
|
+
*
|
|
34
|
+
* The returned `pluginData` is shallow-merged into every `VectorSceneItem`
|
|
35
|
+
* created from the uploaded file, making it available to custom persistence
|
|
36
|
+
* adapters and later hydration flows.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const assetStore: VectorViewportAssetStore = {
|
|
41
|
+
* async upload({ file, kind }) {
|
|
42
|
+
* const form = new FormData();
|
|
43
|
+
* form.append("file", file);
|
|
44
|
+
* form.append("kind", kind);
|
|
45
|
+
*
|
|
46
|
+
* const response = await fetch("/api/canvu/assets", {
|
|
47
|
+
* method: "POST",
|
|
48
|
+
* body: form,
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const asset = await response.json();
|
|
52
|
+
* return {
|
|
53
|
+
* pluginData: {
|
|
54
|
+
* assetId: asset.id,
|
|
55
|
+
* assetKey: asset.key,
|
|
56
|
+
* mimeType: file.type,
|
|
57
|
+
* },
|
|
58
|
+
* };
|
|
59
|
+
* },
|
|
60
|
+
* async resolve({ assetIds }) {
|
|
61
|
+
* const response = await fetch("/api/canvu/assets/resolve", {
|
|
62
|
+
* method: "POST",
|
|
63
|
+
* headers: { "content-type": "application/json" },
|
|
64
|
+
* body: JSON.stringify({ assetIds }),
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* return response.json();
|
|
68
|
+
* },
|
|
69
|
+
* };
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
type VectorViewportAssetUploadResult = {
|
|
73
|
+
/**
|
|
74
|
+
* Opaque persisted metadata attached to created items.
|
|
75
|
+
*
|
|
76
|
+
* Use this for asset ids, bucket keys, original file names, or any backend
|
|
77
|
+
* reference needed to rehydrate the binary later from your own persistence
|
|
78
|
+
* adapter.
|
|
79
|
+
*/
|
|
80
|
+
pluginData?: VectorSceneItem["pluginData"];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Request to resolve persisted asset ids back into runtime URLs.
|
|
84
|
+
*
|
|
85
|
+
* This is useful inside custom persistence adapters when you want to rehydrate
|
|
86
|
+
* signed URLs or CDN URLs after loading a snapshot.
|
|
87
|
+
*/
|
|
88
|
+
type VectorViewportAssetResolveRequest = {
|
|
89
|
+
assetIds: string[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Runtime URL payload returned by a custom asset resolver.
|
|
93
|
+
*/
|
|
94
|
+
type VectorViewportAssetResolveResult = Record<string, {
|
|
95
|
+
url: string;
|
|
96
|
+
thumbnailUrl?: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* High-level hook for apps that want to persist raw binaries out-of-band while
|
|
100
|
+
* keeping canvu's built-in file UX.
|
|
101
|
+
*
|
|
102
|
+
* `upload` is used by the built-in file picker / drag-and-drop flow and by
|
|
103
|
+
* {@link ingestAssetFilesToSceneItems}. `resolve` is optional for custom
|
|
104
|
+
* persistence adapters and future hydration flows.
|
|
105
|
+
*/
|
|
106
|
+
type VectorViewportAssetStore = {
|
|
107
|
+
upload: (request: VectorViewportAssetUploadRequest) => Promise<VectorViewportAssetUploadResult | undefined>;
|
|
108
|
+
resolve?: (request: VectorViewportAssetResolveRequest) => Promise<VectorViewportAssetResolveResult>;
|
|
109
|
+
};
|
|
110
|
+
|
|
8
111
|
type CanvuChromeActiveToolStyle = StrokeStyle & {
|
|
9
112
|
toolKind: "draw" | "marker";
|
|
10
113
|
label?: string;
|
|
@@ -274,6 +377,13 @@ type RemotePresenceMarkupStroke = {
|
|
|
274
377
|
}[];
|
|
275
378
|
readonly tool: "draw" | "pencil" | "brush" | "marker" | "laser";
|
|
276
379
|
};
|
|
380
|
+
type RemotePresenceCamera = {
|
|
381
|
+
readonly x: number;
|
|
382
|
+
readonly y: number;
|
|
383
|
+
readonly zoom: number;
|
|
384
|
+
readonly viewportWidth: number;
|
|
385
|
+
readonly viewportHeight: number;
|
|
386
|
+
};
|
|
277
387
|
/**
|
|
278
388
|
* One connected participant. Your WebSocket layer maps server messages → this shape;
|
|
279
389
|
* {@link VectorViewport} renders it in world space.
|
|
@@ -293,6 +403,8 @@ type RemotePresencePeer = {
|
|
|
293
403
|
} | null;
|
|
294
404
|
/** Optional live stroke while the peer is drawing (same semantics as local placement preview). */
|
|
295
405
|
readonly markupStroke?: RemotePresenceMarkupStroke | null;
|
|
406
|
+
/** Optional live camera snapshot for richer collaboration UIs. */
|
|
407
|
+
readonly camera?: RemotePresenceCamera | null;
|
|
296
408
|
/** Connection-scoped id when collaboration is backed by a realtime session. */
|
|
297
409
|
readonly clientId?: string;
|
|
298
410
|
/** Stable participant identity when collaboration is backed by a realtime session. */
|
|
@@ -425,6 +537,19 @@ type VectorViewportProps = {
|
|
|
425
537
|
* placement is resolved by the current `toolId`.
|
|
426
538
|
*/
|
|
427
539
|
customPlacements?: readonly CustomShapePlacementOptions[];
|
|
540
|
+
/**
|
|
541
|
+
* Optional asset persistence bridge for the built-in image/file flow.
|
|
542
|
+
*
|
|
543
|
+
* Use this when you want canvu to keep its native file picker and drag-and-drop
|
|
544
|
+
* behavior, while also uploading the original binary to your backend or bucket.
|
|
545
|
+
* Returned `pluginData` is persisted on every created item from that file.
|
|
546
|
+
*
|
|
547
|
+
* This is a high-level persistence hook. For fully custom ingestion UIs or
|
|
548
|
+
* imports that start outside the viewport, prefer
|
|
549
|
+
* `ingestAssetFilesToSceneItems(...)` so your app reuses the same pipeline as
|
|
550
|
+
* canvu's native file tool.
|
|
551
|
+
*/
|
|
552
|
+
assetStore?: VectorViewportAssetStore;
|
|
428
553
|
/**
|
|
429
554
|
* When false (default), finishing a draw/place/erase gesture requests switching back to `autoResetToolTo`.
|
|
430
555
|
* Use with controlled tool state (`onToolChangeRequest`) to keep "select-after-use" behavior.
|
|
@@ -572,4 +697,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
|
|
|
572
697
|
*/
|
|
573
698
|
declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
|
|
574
699
|
|
|
575
|
-
export {
|
|
700
|
+
export { type PresenceOverlayRenderContext as $, VectorSelectionInspector as A, type BoardComponentPosition as B, type CanvasPlugin as C, type VectorSelectionInspectorProps as D, VectorViewport as E, type VectorViewportAssetResolveRequest as F, type VectorViewportAssetResolveResult as G, type VectorViewportAssetUploadRequest as H, type VectorViewportAssetUploadResult as I, type VectorViewportHandle as J, type VectorViewportProps as K, createCanvuPlugin as L, getBoardPositionStyle as M, NavMenu as N, useCanvuChromeContext as O, type PlacementPreview as P, useCanvuDocumentContext as Q, useCanvuPluginContext as R, useCanvuPluginContribution as S, useCanvuResolvedTools as T, useCanvuViewportContext as U, type VectorViewportAssetKind as V, type WorldPointerDownDetail as W, type RemotePresenceMarkupStroke as X, type RemotePresencePeer as Y, type RemotePresenceCamera as Z, type RealtimeConnectionState as _, type VectorViewportAssetStore as a, type VectorToolDefinition as b, type CanvasPluginComponentProps as c, type CanvasPluginContribution as d, type CanvasPluginItemsChangeMiddlewareContext as e, type CanvasPluginRenderContext as f, type CanvuChromeActiveToolStyle as g, CanvuChromeContext as h, type CanvuChromeContextValue as i, type CanvuChromeSelectionStyleChange as j, CanvuPluginContext as k, type CanvuPluginContextValue as l, type CanvuPluginViewportSnapshot as m, type CustomShapePlacementOptions as n, type NavMenuProps as o, VectorCanvas as p, VectorCanvasBody as q, VectorCanvasHeader as r, VectorCanvasMain as s, VectorCanvasRoot as t, type VectorCanvasSlotProps as u, type VectorCanvasSpacePosition as v, type VectorCanvasSpaceProps as w, VectorCanvasToolbar as x, type VectorCanvasToolbarProps as y, VectorCanvasViewportSurface as z };
|
|
@@ -5,6 +5,109 @@ import { C as Camera2D } from './camera-KwCYYPhm.js';
|
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { S as StrokeStyle } from './shape-builders-DTYvub8W.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Kind of binary selected through the built-in canvu asset ingestion flow.
|
|
10
|
+
*
|
|
11
|
+
* Use this to branch your backend upload logic when images and PDFs should be
|
|
12
|
+
* stored differently.
|
|
13
|
+
*/
|
|
14
|
+
type VectorViewportAssetKind = "image" | "pdf";
|
|
15
|
+
/**
|
|
16
|
+
* Original browser `File` intercepted from the built-in asset flow.
|
|
17
|
+
*
|
|
18
|
+
* This is the high-level hook for apps that want canvu to keep its native file
|
|
19
|
+
* UX while still uploading the raw binary to their backend or object storage.
|
|
20
|
+
*
|
|
21
|
+
* The same request shape is also reused by
|
|
22
|
+
* {@link ingestAssetFilesToSceneItems}, so custom import flows and the native
|
|
23
|
+
* viewport UX can share one backend contract.
|
|
24
|
+
*/
|
|
25
|
+
type VectorViewportAssetUploadRequest = {
|
|
26
|
+
/** Original browser file before canvu converts it into scene items. */
|
|
27
|
+
file: File;
|
|
28
|
+
/** High-level bucket for routing image vs PDF upload behavior. */
|
|
29
|
+
kind: VectorViewportAssetKind;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Persisted metadata returned by a custom asset upload.
|
|
33
|
+
*
|
|
34
|
+
* The returned `pluginData` is shallow-merged into every `VectorSceneItem`
|
|
35
|
+
* created from the uploaded file, making it available to custom persistence
|
|
36
|
+
* adapters and later hydration flows.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const assetStore: VectorViewportAssetStore = {
|
|
41
|
+
* async upload({ file, kind }) {
|
|
42
|
+
* const form = new FormData();
|
|
43
|
+
* form.append("file", file);
|
|
44
|
+
* form.append("kind", kind);
|
|
45
|
+
*
|
|
46
|
+
* const response = await fetch("/api/canvu/assets", {
|
|
47
|
+
* method: "POST",
|
|
48
|
+
* body: form,
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const asset = await response.json();
|
|
52
|
+
* return {
|
|
53
|
+
* pluginData: {
|
|
54
|
+
* assetId: asset.id,
|
|
55
|
+
* assetKey: asset.key,
|
|
56
|
+
* mimeType: file.type,
|
|
57
|
+
* },
|
|
58
|
+
* };
|
|
59
|
+
* },
|
|
60
|
+
* async resolve({ assetIds }) {
|
|
61
|
+
* const response = await fetch("/api/canvu/assets/resolve", {
|
|
62
|
+
* method: "POST",
|
|
63
|
+
* headers: { "content-type": "application/json" },
|
|
64
|
+
* body: JSON.stringify({ assetIds }),
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* return response.json();
|
|
68
|
+
* },
|
|
69
|
+
* };
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
type VectorViewportAssetUploadResult = {
|
|
73
|
+
/**
|
|
74
|
+
* Opaque persisted metadata attached to created items.
|
|
75
|
+
*
|
|
76
|
+
* Use this for asset ids, bucket keys, original file names, or any backend
|
|
77
|
+
* reference needed to rehydrate the binary later from your own persistence
|
|
78
|
+
* adapter.
|
|
79
|
+
*/
|
|
80
|
+
pluginData?: VectorSceneItem["pluginData"];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Request to resolve persisted asset ids back into runtime URLs.
|
|
84
|
+
*
|
|
85
|
+
* This is useful inside custom persistence adapters when you want to rehydrate
|
|
86
|
+
* signed URLs or CDN URLs after loading a snapshot.
|
|
87
|
+
*/
|
|
88
|
+
type VectorViewportAssetResolveRequest = {
|
|
89
|
+
assetIds: string[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Runtime URL payload returned by a custom asset resolver.
|
|
93
|
+
*/
|
|
94
|
+
type VectorViewportAssetResolveResult = Record<string, {
|
|
95
|
+
url: string;
|
|
96
|
+
thumbnailUrl?: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* High-level hook for apps that want to persist raw binaries out-of-band while
|
|
100
|
+
* keeping canvu's built-in file UX.
|
|
101
|
+
*
|
|
102
|
+
* `upload` is used by the built-in file picker / drag-and-drop flow and by
|
|
103
|
+
* {@link ingestAssetFilesToSceneItems}. `resolve` is optional for custom
|
|
104
|
+
* persistence adapters and future hydration flows.
|
|
105
|
+
*/
|
|
106
|
+
type VectorViewportAssetStore = {
|
|
107
|
+
upload: (request: VectorViewportAssetUploadRequest) => Promise<VectorViewportAssetUploadResult | undefined>;
|
|
108
|
+
resolve?: (request: VectorViewportAssetResolveRequest) => Promise<VectorViewportAssetResolveResult>;
|
|
109
|
+
};
|
|
110
|
+
|
|
8
111
|
type CanvuChromeActiveToolStyle = StrokeStyle & {
|
|
9
112
|
toolKind: "draw" | "marker";
|
|
10
113
|
label?: string;
|
|
@@ -274,6 +377,13 @@ type RemotePresenceMarkupStroke = {
|
|
|
274
377
|
}[];
|
|
275
378
|
readonly tool: "draw" | "pencil" | "brush" | "marker" | "laser";
|
|
276
379
|
};
|
|
380
|
+
type RemotePresenceCamera = {
|
|
381
|
+
readonly x: number;
|
|
382
|
+
readonly y: number;
|
|
383
|
+
readonly zoom: number;
|
|
384
|
+
readonly viewportWidth: number;
|
|
385
|
+
readonly viewportHeight: number;
|
|
386
|
+
};
|
|
277
387
|
/**
|
|
278
388
|
* One connected participant. Your WebSocket layer maps server messages → this shape;
|
|
279
389
|
* {@link VectorViewport} renders it in world space.
|
|
@@ -293,6 +403,8 @@ type RemotePresencePeer = {
|
|
|
293
403
|
} | null;
|
|
294
404
|
/** Optional live stroke while the peer is drawing (same semantics as local placement preview). */
|
|
295
405
|
readonly markupStroke?: RemotePresenceMarkupStroke | null;
|
|
406
|
+
/** Optional live camera snapshot for richer collaboration UIs. */
|
|
407
|
+
readonly camera?: RemotePresenceCamera | null;
|
|
296
408
|
/** Connection-scoped id when collaboration is backed by a realtime session. */
|
|
297
409
|
readonly clientId?: string;
|
|
298
410
|
/** Stable participant identity when collaboration is backed by a realtime session. */
|
|
@@ -425,6 +537,19 @@ type VectorViewportProps = {
|
|
|
425
537
|
* placement is resolved by the current `toolId`.
|
|
426
538
|
*/
|
|
427
539
|
customPlacements?: readonly CustomShapePlacementOptions[];
|
|
540
|
+
/**
|
|
541
|
+
* Optional asset persistence bridge for the built-in image/file flow.
|
|
542
|
+
*
|
|
543
|
+
* Use this when you want canvu to keep its native file picker and drag-and-drop
|
|
544
|
+
* behavior, while also uploading the original binary to your backend or bucket.
|
|
545
|
+
* Returned `pluginData` is persisted on every created item from that file.
|
|
546
|
+
*
|
|
547
|
+
* This is a high-level persistence hook. For fully custom ingestion UIs or
|
|
548
|
+
* imports that start outside the viewport, prefer
|
|
549
|
+
* `ingestAssetFilesToSceneItems(...)` so your app reuses the same pipeline as
|
|
550
|
+
* canvu's native file tool.
|
|
551
|
+
*/
|
|
552
|
+
assetStore?: VectorViewportAssetStore;
|
|
428
553
|
/**
|
|
429
554
|
* When false (default), finishing a draw/place/erase gesture requests switching back to `autoResetToolTo`.
|
|
430
555
|
* Use with controlled tool state (`onToolChangeRequest`) to keep "select-after-use" behavior.
|
|
@@ -572,4 +697,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
|
|
|
572
697
|
*/
|
|
573
698
|
declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
|
|
574
699
|
|
|
575
|
-
export {
|
|
700
|
+
export { type PresenceOverlayRenderContext as $, VectorSelectionInspector as A, type BoardComponentPosition as B, type CanvasPlugin as C, type VectorSelectionInspectorProps as D, VectorViewport as E, type VectorViewportAssetResolveRequest as F, type VectorViewportAssetResolveResult as G, type VectorViewportAssetUploadRequest as H, type VectorViewportAssetUploadResult as I, type VectorViewportHandle as J, type VectorViewportProps as K, createCanvuPlugin as L, getBoardPositionStyle as M, NavMenu as N, useCanvuChromeContext as O, type PlacementPreview as P, useCanvuDocumentContext as Q, useCanvuPluginContext as R, useCanvuPluginContribution as S, useCanvuResolvedTools as T, useCanvuViewportContext as U, type VectorViewportAssetKind as V, type WorldPointerDownDetail as W, type RemotePresenceMarkupStroke as X, type RemotePresencePeer as Y, type RemotePresenceCamera as Z, type RealtimeConnectionState as _, type VectorViewportAssetStore as a, type VectorToolDefinition as b, type CanvasPluginComponentProps as c, type CanvasPluginContribution as d, type CanvasPluginItemsChangeMiddlewareContext as e, type CanvasPluginRenderContext as f, type CanvuChromeActiveToolStyle as g, CanvuChromeContext as h, type CanvuChromeContextValue as i, type CanvuChromeSelectionStyleChange as j, CanvuPluginContext as k, type CanvuPluginContextValue as l, type CanvuPluginViewportSnapshot as m, type CustomShapePlacementOptions as n, type NavMenuProps as o, VectorCanvas as p, VectorCanvasBody as q, VectorCanvasHeader as r, VectorCanvasMain as s, VectorCanvasRoot as t, type VectorCanvasSlotProps as u, type VectorCanvasSpacePosition as v, type VectorCanvasSpaceProps as w, VectorCanvasToolbar as x, type VectorCanvasToolbarProps as y, VectorCanvasViewportSurface as z };
|