canvu-react 0.3.7 → 0.3.8
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 +1388 -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 +1388 -1354
- package/dist/react.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- 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-CW146bKP.d.cts} +117 -1
- package/dist/{types-BCtWx3zP.d.ts → types-CpqlbbCP.d.ts} +117 -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;
|
|
@@ -425,6 +528,19 @@ type VectorViewportProps = {
|
|
|
425
528
|
* placement is resolved by the current `toolId`.
|
|
426
529
|
*/
|
|
427
530
|
customPlacements?: readonly CustomShapePlacementOptions[];
|
|
531
|
+
/**
|
|
532
|
+
* Optional asset persistence bridge for the built-in image/file flow.
|
|
533
|
+
*
|
|
534
|
+
* Use this when you want canvu to keep its native file picker and drag-and-drop
|
|
535
|
+
* behavior, while also uploading the original binary to your backend or bucket.
|
|
536
|
+
* Returned `pluginData` is persisted on every created item from that file.
|
|
537
|
+
*
|
|
538
|
+
* This is a high-level persistence hook. For fully custom ingestion UIs or
|
|
539
|
+
* imports that start outside the viewport, prefer
|
|
540
|
+
* `ingestAssetFilesToSceneItems(...)` so your app reuses the same pipeline as
|
|
541
|
+
* canvu's native file tool.
|
|
542
|
+
*/
|
|
543
|
+
assetStore?: VectorViewportAssetStore;
|
|
428
544
|
/**
|
|
429
545
|
* When false (default), finishing a draw/place/erase gesture requests switching back to `autoResetToolTo`.
|
|
430
546
|
* Use with controlled tool state (`onToolChangeRequest`) to keep "select-after-use" behavior.
|
|
@@ -572,4 +688,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
|
|
|
572
688
|
*/
|
|
573
689
|
declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
|
|
574
690
|
|
|
575
|
-
export {
|
|
691
|
+
export { 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 RealtimeConnectionState as Z, type PresenceOverlayRenderContext 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;
|
|
@@ -425,6 +528,19 @@ type VectorViewportProps = {
|
|
|
425
528
|
* placement is resolved by the current `toolId`.
|
|
426
529
|
*/
|
|
427
530
|
customPlacements?: readonly CustomShapePlacementOptions[];
|
|
531
|
+
/**
|
|
532
|
+
* Optional asset persistence bridge for the built-in image/file flow.
|
|
533
|
+
*
|
|
534
|
+
* Use this when you want canvu to keep its native file picker and drag-and-drop
|
|
535
|
+
* behavior, while also uploading the original binary to your backend or bucket.
|
|
536
|
+
* Returned `pluginData` is persisted on every created item from that file.
|
|
537
|
+
*
|
|
538
|
+
* This is a high-level persistence hook. For fully custom ingestion UIs or
|
|
539
|
+
* imports that start outside the viewport, prefer
|
|
540
|
+
* `ingestAssetFilesToSceneItems(...)` so your app reuses the same pipeline as
|
|
541
|
+
* canvu's native file tool.
|
|
542
|
+
*/
|
|
543
|
+
assetStore?: VectorViewportAssetStore;
|
|
428
544
|
/**
|
|
429
545
|
* When false (default), finishing a draw/place/erase gesture requests switching back to `autoResetToolTo`.
|
|
430
546
|
* Use with controlled tool state (`onToolChangeRequest`) to keep "select-after-use" behavior.
|
|
@@ -572,4 +688,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
|
|
|
572
688
|
*/
|
|
573
689
|
declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
|
|
574
690
|
|
|
575
|
-
export {
|
|
691
|
+
export { 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 RealtimeConnectionState as Z, type PresenceOverlayRenderContext 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 };
|