canvu-react 0.4.5 → 0.4.7

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.
@@ -1,5 +1,5 @@
1
1
  import { V as VectorSceneItem } from './types-BCCvY6ie.cjs';
2
- import { E as VectorViewportAssetStore } from './shape-builders-BAWu-PxX.cjs';
2
+ import { a as VectorViewportAssetStore } from './link-item-D870_X6P.cjs';
3
3
 
4
4
  declare class IndexedDbImageStore {
5
5
  private dbPromise;
@@ -1,5 +1,5 @@
1
1
  import { V as VectorSceneItem } from './types-BCCvY6ie.js';
2
- import { E as VectorViewportAssetStore } from './shape-builders-ClKv9tz9.js';
2
+ import { a as VectorViewportAssetStore } from './link-item-Bg5vj0RI.js';
3
3
 
4
4
  declare class IndexedDbImageStore {
5
5
  private dbPromise;
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CanvasPlugin } from './types-BC9Xgfu6.cjs';
2
+ import { C as CanvasPlugin } from './types-Bw1SdC9v.cjs';
3
3
  import 'react';
4
4
  import './types-BCCvY6ie.cjs';
5
- import './camera-CVVG7z56.cjs';
6
- import './shape-builders-BAWu-PxX.cjs';
5
+ import './shape-builders-CKEMjivV.cjs';
6
+ import './link-item-D870_X6P.cjs';
7
7
 
8
8
  type ChatbotPluginPanelProps = {
9
9
  /**
package/dist/chatbot.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CanvasPlugin } from './types-DlSVGX0w.js';
2
+ import { C as CanvasPlugin } from './types-DeXFfs7Y.js';
3
3
  import 'react';
4
4
  import './types-BCCvY6ie.js';
5
- import './camera-CoRYN_IV.js';
6
- import './shape-builders-ClKv9tz9.js';
5
+ import './shape-builders-Cyh8zvDG.js';
6
+ import './link-item-Bg5vj0RI.js';
7
7
 
8
8
  type ChatbotPluginPanelProps = {
9
9
  /**
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as Camera2D } from './camera-CVVG7z56.cjs';
2
- export { a as Camera2DOptions } from './camera-CVVG7z56.cjs';
1
+ import { C as Camera2D } from './shape-builders-CKEMjivV.cjs';
2
+ export { a as Camera2DOptions, D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildRectSvg, k as computeFreehandSvgPayload, l as createArchitecturalCloudItem, m as createDrawDotItem, n as createEllipseItem, o as createFreehandStrokeItem, p as createImageFromVectorTrace, q as createImageItem, r as createLineItem, s as createRectangleItem, t as createShapeId, u as createTextItem, v as lineEndpointsToLocal, w as rebuildItemSvg, x as resolveStrokeStyle } from './shape-builders-CKEMjivV.cjs';
3
3
  import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-BCCvY6ie.cjs';
4
4
  export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-BCCvY6ie.cjs';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-B7yMDQE-.cjs';
6
- export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, a as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, L as LINK_PLUGIN_KEY, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildLinkCardSvg, k as buildRectSvg, l as computeFreehandSvgPayload, m as createArchitecturalCloudItem, n as createDrawDotItem, o as createEllipseItem, p as createFreehandStrokeItem, q as createImageFromVectorTrace, r as createImageItem, s as createLineItem, t as createLinkItem, u as createRectangleItem, v as createShapeId, w as createTextItem, x as getLinkData, y as isLinkItem, z as lineEndpointsToLocal, A as rebuildItemSvg, B as resolveStrokeStyle } from './shape-builders-BAWu-PxX.cjs';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-CWhld14A.cjs';
6
+ export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, L as LINK_PLUGIN_KEY, b as buildLinkCardSvg, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-D870_X6P.cjs';
7
7
 
8
8
  type EncodeCanvasToBlobOptions = {
9
9
  mimeType?: string;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as Camera2D } from './camera-CoRYN_IV.js';
2
- export { a as Camera2DOptions } from './camera-CoRYN_IV.js';
1
+ import { C as Camera2D } from './shape-builders-Cyh8zvDG.js';
2
+ export { a as Camera2DOptions, D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildRectSvg, k as computeFreehandSvgPayload, l as createArchitecturalCloudItem, m as createDrawDotItem, n as createEllipseItem, o as createFreehandStrokeItem, p as createImageFromVectorTrace, q as createImageItem, r as createLineItem, s as createRectangleItem, t as createShapeId, u as createTextItem, v as lineEndpointsToLocal, w as rebuildItemSvg, x as resolveStrokeStyle } from './shape-builders-Cyh8zvDG.js';
3
3
  import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-BCCvY6ie.js';
4
4
  export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-BCCvY6ie.js';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-CbwQVAwh.js';
6
- export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, a as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, L as LINK_PLUGIN_KEY, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildLinkCardSvg, k as buildRectSvg, l as computeFreehandSvgPayload, m as createArchitecturalCloudItem, n as createDrawDotItem, o as createEllipseItem, p as createFreehandStrokeItem, q as createImageFromVectorTrace, r as createImageItem, s as createLineItem, t as createLinkItem, u as createRectangleItem, v as createShapeId, w as createTextItem, x as getLinkData, y as isLinkItem, z as lineEndpointsToLocal, A as rebuildItemSvg, B as resolveStrokeStyle } from './shape-builders-ClKv9tz9.js';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-D35mHbUP.js';
6
+ export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, L as LINK_PLUGIN_KEY, b as buildLinkCardSvg, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-Bg5vj0RI.js';
7
7
 
8
8
  type EncodeCanvasToBlobOptions = {
9
9
  mimeType?: string;
@@ -0,0 +1,151 @@
1
+ import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.js';
2
+
3
+ /**
4
+ * Kind of binary selected through the built-in canvu asset ingestion flow.
5
+ *
6
+ * Use this to branch your backend upload logic when images and PDFs should be
7
+ * stored differently.
8
+ */
9
+ type VectorViewportAssetKind = "image" | "pdf";
10
+ /**
11
+ * Original browser `File` intercepted from the built-in asset flow.
12
+ *
13
+ * This is the high-level hook for apps that want canvu to keep its native file
14
+ * UX while still uploading the raw binary to their backend or object storage.
15
+ *
16
+ * The same request shape is also reused by
17
+ * {@link ingestAssetFilesToSceneItems}, so custom import flows and the native
18
+ * viewport UX can share one backend contract.
19
+ */
20
+ type VectorViewportAssetUploadRequest = {
21
+ /** Original browser file before canvu converts it into scene items. */
22
+ file: File;
23
+ /** High-level bucket for routing image vs PDF upload behavior. */
24
+ kind: VectorViewportAssetKind;
25
+ };
26
+ /**
27
+ * Persisted metadata returned by a custom asset upload.
28
+ *
29
+ * The returned `pluginData` is shallow-merged into every `VectorSceneItem`
30
+ * created from the uploaded file, making it available to custom persistence
31
+ * adapters and later hydration flows.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const assetStore: VectorViewportAssetStore = {
36
+ * async upload({ file, kind }) {
37
+ * const form = new FormData();
38
+ * form.append("file", file);
39
+ * form.append("kind", kind);
40
+ *
41
+ * const response = await fetch("/api/canvu/assets", {
42
+ * method: "POST",
43
+ * body: form,
44
+ * });
45
+ *
46
+ * const asset = await response.json();
47
+ * return {
48
+ * pluginData: {
49
+ * assetId: asset.id,
50
+ * assetKey: asset.key,
51
+ * mimeType: file.type,
52
+ * },
53
+ * };
54
+ * },
55
+ * async resolve({ assetIds }) {
56
+ * const response = await fetch("/api/canvu/assets/resolve", {
57
+ * method: "POST",
58
+ * headers: { "content-type": "application/json" },
59
+ * body: JSON.stringify({ assetIds }),
60
+ * });
61
+ *
62
+ * return response.json();
63
+ * },
64
+ * };
65
+ * ```
66
+ */
67
+ type VectorViewportAssetUploadResult = {
68
+ /**
69
+ * Opaque persisted metadata attached to created items.
70
+ *
71
+ * Use this for asset ids, bucket keys, original file names, or any backend
72
+ * reference needed to rehydrate the binary later from your own persistence
73
+ * adapter.
74
+ */
75
+ pluginData?: VectorSceneItem["pluginData"];
76
+ };
77
+ /**
78
+ * Request to resolve persisted asset ids back into runtime URLs.
79
+ *
80
+ * This is useful inside custom persistence adapters when you want to rehydrate
81
+ * signed URLs or CDN URLs after loading a snapshot.
82
+ */
83
+ type VectorViewportAssetResolveRequest = {
84
+ assetIds: string[];
85
+ };
86
+ /**
87
+ * Runtime URL payload returned by a custom asset resolver.
88
+ */
89
+ type VectorViewportAssetResolveResult = Record<string, {
90
+ url: string;
91
+ thumbnailUrl?: string;
92
+ }>;
93
+ type VectorViewportAssetHydrationRequest = {
94
+ assetId: string;
95
+ kind: VectorViewportAssetKind;
96
+ pageNumber?: number;
97
+ scale?: number;
98
+ };
99
+ /**
100
+ * High-level hook for apps that want to persist raw binaries out-of-band while
101
+ * keeping canvu's built-in file UX.
102
+ *
103
+ * `upload` is used by the built-in file picker / drag-and-drop flow and by
104
+ * {@link ingestAssetFilesToSceneItems}. `resolve` is optional for custom
105
+ * persistence adapters and future hydration flows.
106
+ */
107
+ type VectorViewportAssetStore = {
108
+ upload: (request: VectorViewportAssetUploadRequest) => Promise<VectorViewportAssetUploadResult | undefined>;
109
+ resolve?: (request: VectorViewportAssetResolveRequest) => Promise<VectorViewportAssetResolveResult>;
110
+ getHydrationRequest?: (item: VectorSceneItem) => VectorViewportAssetHydrationRequest | null;
111
+ };
112
+
113
+ /** Plugin key under which link metadata is stored on a link item's `pluginData`. */
114
+ declare const LINK_PLUGIN_KEY = "canvuLink";
115
+ /**
116
+ * Metadata describing a clickable link/bookmark item.
117
+ * `href` is required; the rest enrich the rendered card (unfurl result).
118
+ */
119
+ type CanvuLinkData = {
120
+ /** Absolute URL the card points to. */
121
+ href: string;
122
+ /** Human readable title (falls back to the hostname). */
123
+ title?: string;
124
+ /** Short description shown under the title. */
125
+ description?: string;
126
+ /** Preview image URL (og:image). */
127
+ image?: string;
128
+ /** Favicon URL shown in the leading badge. */
129
+ favicon?: string;
130
+ };
131
+ /**
132
+ * Builds the inner SVG (no outer `<svg>`) for a link/bookmark card at the given box size.
133
+ * Uses fixed pixel bands so text never overlaps regardless of the card's aspect ratio.
134
+ */
135
+ declare function buildLinkCardSvg(width: number, height: number, link: CanvuLinkData): string;
136
+ /** Reads the link metadata from an item, or `null` when the item is not a link. */
137
+ declare function getLinkData(item: VectorSceneItem): CanvuLinkData | null;
138
+ /** True when the item carries link metadata (clickable card). */
139
+ declare function isLinkItem(item: VectorSceneItem): boolean;
140
+ /**
141
+ * Creates a clickable link/bookmark card item ready to append to the scene.
142
+ * The card resizes by scaling its authored SVG, like other custom shapes.
143
+ */
144
+ declare function createLinkItem(id: string, bounds: Rect, link: CanvuLinkData): VectorSceneItem;
145
+ /** Default card size used when placing a new link without explicit bounds. */
146
+ declare const DEFAULT_LINK_CARD_SIZE: {
147
+ readonly width: 360;
148
+ readonly height: 132;
149
+ };
150
+
151
+ export { type CanvuLinkData as C, DEFAULT_LINK_CARD_SIZE as D, LINK_PLUGIN_KEY as L, type VectorViewportAssetKind as V, type VectorViewportAssetStore as a, buildLinkCardSvg as b, createLinkItem as c, type VectorViewportAssetHydrationRequest as d, type VectorViewportAssetResolveRequest as e, type VectorViewportAssetResolveResult as f, getLinkData as g, type VectorViewportAssetUploadRequest as h, isLinkItem as i, type VectorViewportAssetUploadResult as j };
@@ -0,0 +1,151 @@
1
+ import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.cjs';
2
+
3
+ /**
4
+ * Kind of binary selected through the built-in canvu asset ingestion flow.
5
+ *
6
+ * Use this to branch your backend upload logic when images and PDFs should be
7
+ * stored differently.
8
+ */
9
+ type VectorViewportAssetKind = "image" | "pdf";
10
+ /**
11
+ * Original browser `File` intercepted from the built-in asset flow.
12
+ *
13
+ * This is the high-level hook for apps that want canvu to keep its native file
14
+ * UX while still uploading the raw binary to their backend or object storage.
15
+ *
16
+ * The same request shape is also reused by
17
+ * {@link ingestAssetFilesToSceneItems}, so custom import flows and the native
18
+ * viewport UX can share one backend contract.
19
+ */
20
+ type VectorViewportAssetUploadRequest = {
21
+ /** Original browser file before canvu converts it into scene items. */
22
+ file: File;
23
+ /** High-level bucket for routing image vs PDF upload behavior. */
24
+ kind: VectorViewportAssetKind;
25
+ };
26
+ /**
27
+ * Persisted metadata returned by a custom asset upload.
28
+ *
29
+ * The returned `pluginData` is shallow-merged into every `VectorSceneItem`
30
+ * created from the uploaded file, making it available to custom persistence
31
+ * adapters and later hydration flows.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const assetStore: VectorViewportAssetStore = {
36
+ * async upload({ file, kind }) {
37
+ * const form = new FormData();
38
+ * form.append("file", file);
39
+ * form.append("kind", kind);
40
+ *
41
+ * const response = await fetch("/api/canvu/assets", {
42
+ * method: "POST",
43
+ * body: form,
44
+ * });
45
+ *
46
+ * const asset = await response.json();
47
+ * return {
48
+ * pluginData: {
49
+ * assetId: asset.id,
50
+ * assetKey: asset.key,
51
+ * mimeType: file.type,
52
+ * },
53
+ * };
54
+ * },
55
+ * async resolve({ assetIds }) {
56
+ * const response = await fetch("/api/canvu/assets/resolve", {
57
+ * method: "POST",
58
+ * headers: { "content-type": "application/json" },
59
+ * body: JSON.stringify({ assetIds }),
60
+ * });
61
+ *
62
+ * return response.json();
63
+ * },
64
+ * };
65
+ * ```
66
+ */
67
+ type VectorViewportAssetUploadResult = {
68
+ /**
69
+ * Opaque persisted metadata attached to created items.
70
+ *
71
+ * Use this for asset ids, bucket keys, original file names, or any backend
72
+ * reference needed to rehydrate the binary later from your own persistence
73
+ * adapter.
74
+ */
75
+ pluginData?: VectorSceneItem["pluginData"];
76
+ };
77
+ /**
78
+ * Request to resolve persisted asset ids back into runtime URLs.
79
+ *
80
+ * This is useful inside custom persistence adapters when you want to rehydrate
81
+ * signed URLs or CDN URLs after loading a snapshot.
82
+ */
83
+ type VectorViewportAssetResolveRequest = {
84
+ assetIds: string[];
85
+ };
86
+ /**
87
+ * Runtime URL payload returned by a custom asset resolver.
88
+ */
89
+ type VectorViewportAssetResolveResult = Record<string, {
90
+ url: string;
91
+ thumbnailUrl?: string;
92
+ }>;
93
+ type VectorViewportAssetHydrationRequest = {
94
+ assetId: string;
95
+ kind: VectorViewportAssetKind;
96
+ pageNumber?: number;
97
+ scale?: number;
98
+ };
99
+ /**
100
+ * High-level hook for apps that want to persist raw binaries out-of-band while
101
+ * keeping canvu's built-in file UX.
102
+ *
103
+ * `upload` is used by the built-in file picker / drag-and-drop flow and by
104
+ * {@link ingestAssetFilesToSceneItems}. `resolve` is optional for custom
105
+ * persistence adapters and future hydration flows.
106
+ */
107
+ type VectorViewportAssetStore = {
108
+ upload: (request: VectorViewportAssetUploadRequest) => Promise<VectorViewportAssetUploadResult | undefined>;
109
+ resolve?: (request: VectorViewportAssetResolveRequest) => Promise<VectorViewportAssetResolveResult>;
110
+ getHydrationRequest?: (item: VectorSceneItem) => VectorViewportAssetHydrationRequest | null;
111
+ };
112
+
113
+ /** Plugin key under which link metadata is stored on a link item's `pluginData`. */
114
+ declare const LINK_PLUGIN_KEY = "canvuLink";
115
+ /**
116
+ * Metadata describing a clickable link/bookmark item.
117
+ * `href` is required; the rest enrich the rendered card (unfurl result).
118
+ */
119
+ type CanvuLinkData = {
120
+ /** Absolute URL the card points to. */
121
+ href: string;
122
+ /** Human readable title (falls back to the hostname). */
123
+ title?: string;
124
+ /** Short description shown under the title. */
125
+ description?: string;
126
+ /** Preview image URL (og:image). */
127
+ image?: string;
128
+ /** Favicon URL shown in the leading badge. */
129
+ favicon?: string;
130
+ };
131
+ /**
132
+ * Builds the inner SVG (no outer `<svg>`) for a link/bookmark card at the given box size.
133
+ * Uses fixed pixel bands so text never overlaps regardless of the card's aspect ratio.
134
+ */
135
+ declare function buildLinkCardSvg(width: number, height: number, link: CanvuLinkData): string;
136
+ /** Reads the link metadata from an item, or `null` when the item is not a link. */
137
+ declare function getLinkData(item: VectorSceneItem): CanvuLinkData | null;
138
+ /** True when the item carries link metadata (clickable card). */
139
+ declare function isLinkItem(item: VectorSceneItem): boolean;
140
+ /**
141
+ * Creates a clickable link/bookmark card item ready to append to the scene.
142
+ * The card resizes by scaling its authored SVG, like other custom shapes.
143
+ */
144
+ declare function createLinkItem(id: string, bounds: Rect, link: CanvuLinkData): VectorSceneItem;
145
+ /** Default card size used when placing a new link without explicit bounds. */
146
+ declare const DEFAULT_LINK_CARD_SIZE: {
147
+ readonly width: 360;
148
+ readonly height: 132;
149
+ };
150
+
151
+ export { type CanvuLinkData as C, DEFAULT_LINK_CARD_SIZE as D, LINK_PLUGIN_KEY as L, type VectorViewportAssetKind as V, type VectorViewportAssetStore as a, buildLinkCardSvg as b, createLinkItem as c, type VectorViewportAssetHydrationRequest as d, type VectorViewportAssetResolveRequest as e, type VectorViewportAssetResolveResult as f, getLinkData as g, type VectorViewportAssetUploadRequest as h, isLinkItem as i, type VectorViewportAssetUploadResult as j };