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.
package/dist/react.d.cts CHANGED
@@ -1,14 +1,14 @@
1
- import { I as IndexedDbImageStore } from './asset-hydration-B7yMDQE-.cjs';
2
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-B7yMDQE-.cjs';
1
+ import { I as IndexedDbImageStore } from './asset-hydration-CWhld14A.cjs';
2
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-CWhld14A.cjs';
3
3
  import { V as VectorSceneItem } from './types-BCCvY6ie.cjs';
4
- import { V as VectorViewportAssetKind, E as VectorViewportAssetStore } from './shape-builders-BAWu-PxX.cjs';
5
- export { G as VectorViewportAssetHydrationRequest, H as VectorViewportAssetResolveRequest, I as VectorViewportAssetResolveResult, J as VectorViewportAssetUploadRequest, K as VectorViewportAssetUploadResult } from './shape-builders-BAWu-PxX.cjs';
6
- import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-BC9Xgfu6.cjs';
7
- export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-BC9Xgfu6.cjs';
4
+ import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './link-item-D870_X6P.cjs';
5
+ export { d as VectorViewportAssetHydrationRequest, e as VectorViewportAssetResolveRequest, f as VectorViewportAssetResolveResult, h as VectorViewportAssetUploadRequest, j as VectorViewportAssetUploadResult } from './link-item-D870_X6P.cjs';
6
+ import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-Bw1SdC9v.cjs';
7
+ export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-Bw1SdC9v.cjs';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import * as react from 'react';
10
10
  import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
11
- import { C as Camera2D } from './camera-CVVG7z56.cjs';
11
+ import { C as Camera2D } from './shape-builders-CKEMjivV.cjs';
12
12
  import { V as VectorCanvasPersistenceAdapter, a as VectorCanvasRemoteAdapter } from './types-BUPc2Zgw.cjs';
13
13
  export { b as VectorCanvasSnapshot } from './types-BUPc2Zgw.cjs';
14
14
 
package/dist/react.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { I as IndexedDbImageStore } from './asset-hydration-CbwQVAwh.js';
2
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-CbwQVAwh.js';
1
+ import { I as IndexedDbImageStore } from './asset-hydration-D35mHbUP.js';
2
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-D35mHbUP.js';
3
3
  import { V as VectorSceneItem } from './types-BCCvY6ie.js';
4
- import { V as VectorViewportAssetKind, E as VectorViewportAssetStore } from './shape-builders-ClKv9tz9.js';
5
- export { G as VectorViewportAssetHydrationRequest, H as VectorViewportAssetResolveRequest, I as VectorViewportAssetResolveResult, J as VectorViewportAssetUploadRequest, K as VectorViewportAssetUploadResult } from './shape-builders-ClKv9tz9.js';
6
- import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-DlSVGX0w.js';
7
- export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-DlSVGX0w.js';
4
+ import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './link-item-Bg5vj0RI.js';
5
+ export { d as VectorViewportAssetHydrationRequest, e as VectorViewportAssetResolveRequest, f as VectorViewportAssetResolveResult, h as VectorViewportAssetUploadRequest, j as VectorViewportAssetUploadResult } from './link-item-Bg5vj0RI.js';
6
+ import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-DeXFfs7Y.js';
7
+ export { b as CanvasPluginComponentProps, c as CanvasPluginContribution, d as CanvasPluginItemsChangeMiddlewareContext, e as CanvasPluginRenderContext, f as CanvuChromeActiveToolStyle, g as CanvuChromeContext, h as CanvuChromeContextValue, i as CanvuChromeSelectionStyleChange, j as CanvuPluginContext, k as CanvuPluginContextValue, l as CanvuPluginViewportSnapshot, m as CustomShapePlacementOptions, P as PlacementPreview, n as VectorCanvasSpacePosition, o as VectorSelectionInspectorProps, p as VectorViewport, q as VectorViewportHandle, r as VectorViewportProps, W as WorldPointerDownDetail, s as createCanvuPlugin, t as getBoardPositionStyle, u as useCanvuChromeContext, v as useCanvuDocumentContext, w as useCanvuPluginContext, x as useCanvuPluginContribution, y as useCanvuResolvedTools, z as useCanvuViewportContext } from './types-DeXFfs7Y.js';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import * as react from 'react';
10
10
  import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
11
- import { C as Camera2D } from './camera-CoRYN_IV.js';
11
+ import { C as Camera2D } from './shape-builders-Cyh8zvDG.js';
12
12
  import { V as VectorCanvasPersistenceAdapter, a as VectorCanvasRemoteAdapter } from './types-CYtq9Pr9.js';
13
13
  export { b as VectorCanvasSnapshot } from './types-CYtq9Pr9.js';
14
14
 
@@ -1,11 +1,11 @@
1
- import { P as PlacementPreview, R as RemotePresenceMarkupStroke, A as RemotePresencePeer, D as RemotePresenceCamera, E as RealtimeConnectionState, q as VectorViewportHandle, V as VectorToolDefinition, r as VectorViewportProps, C as CanvasPlugin, e as CanvasPluginRenderContext } from './types-BC9Xgfu6.cjs';
2
- export { F as PresenceOverlayRenderContext } from './types-BC9Xgfu6.cjs';
1
+ import { P as PlacementPreview, R as RemotePresenceMarkupStroke, A as RemotePresencePeer, D as RemotePresenceCamera, E as RealtimeConnectionState, q as VectorViewportHandle, V as VectorToolDefinition, r as VectorViewportProps, C as CanvasPlugin, e as CanvasPluginRenderContext } from './types-Bw1SdC9v.cjs';
2
+ export { F as PresenceOverlayRenderContext } from './types-Bw1SdC9v.cjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { C as Camera2D } from './camera-CVVG7z56.cjs';
4
+ import { C as Camera2D } from './shape-builders-CKEMjivV.cjs';
5
5
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.cjs';
6
6
  import { ReactNode, RefObject } from 'react';
7
7
  import { a as VectorCanvasRemoteAdapter } from './types-BUPc2Zgw.cjs';
8
- import './shape-builders-BAWu-PxX.cjs';
8
+ import './link-item-D870_X6P.cjs';
9
9
 
10
10
  /**
11
11
  * Maps a local {@link PlacementPreview} stroke to {@link RemotePresenceMarkupStroke} for broadcasting.
@@ -1,11 +1,11 @@
1
- import { P as PlacementPreview, R as RemotePresenceMarkupStroke, A as RemotePresencePeer, D as RemotePresenceCamera, E as RealtimeConnectionState, q as VectorViewportHandle, V as VectorToolDefinition, r as VectorViewportProps, C as CanvasPlugin, e as CanvasPluginRenderContext } from './types-DlSVGX0w.js';
2
- export { F as PresenceOverlayRenderContext } from './types-DlSVGX0w.js';
1
+ import { P as PlacementPreview, R as RemotePresenceMarkupStroke, A as RemotePresencePeer, D as RemotePresenceCamera, E as RealtimeConnectionState, q as VectorViewportHandle, V as VectorToolDefinition, r as VectorViewportProps, C as CanvasPlugin, e as CanvasPluginRenderContext } from './types-DeXFfs7Y.js';
2
+ export { F as PresenceOverlayRenderContext } from './types-DeXFfs7Y.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import { C as Camera2D } from './camera-CoRYN_IV.js';
4
+ import { C as Camera2D } from './shape-builders-Cyh8zvDG.js';
5
5
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.js';
6
6
  import { ReactNode, RefObject } from 'react';
7
7
  import { a as VectorCanvasRemoteAdapter } from './types-CYtq9Pr9.js';
8
- import './shape-builders-ClKv9tz9.js';
8
+ import './link-item-Bg5vj0RI.js';
9
9
 
10
10
  /**
11
11
  * Maps a local {@link PlacementPreview} stroke to {@link RemotePresenceMarkupStroke} for broadcasting.
@@ -1,152 +1,51 @@
1
- import { V as VectorSceneItem, R as Rect, L as LineEndpointsLocal, b as VectorPathPoint, a as ArrowBindings } from './types-BCCvY6ie.cjs';
1
+ import { R as Rect, V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, a as ArrowBindings } from './types-BCCvY6ie.cjs';
2
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;
3
+ type Camera2DOptions = {
4
+ /** Minimum zoom scale (world units per CSS pixel). */
5
+ minZoom?: number;
6
+ /** Maximum zoom scale. */
7
+ maxZoom?: number;
25
8
  };
26
9
  /**
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);
10
+ * 2D camera: pan (`x`, `y`) in **screen space** (CSS pixels) and uniform zoom `zoom`.
40
11
  *
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
- * ```
12
+ * Screen mapping: `screen = world * zoom + cameraOffset`
13
+ * (world origin maps to `(x, y)` on screen).
66
14
  */
67
- type VectorViewportAssetUploadResult = {
15
+ declare class Camera2D {
16
+ x: number;
17
+ y: number;
18
+ /** Scale: world units per CSS pixel (larger = more zoomed in). */
19
+ zoom: number;
20
+ readonly minZoom: number;
21
+ readonly maxZoom: number;
22
+ constructor(options?: Camera2DOptions);
68
23
  /**
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.
24
+ * Converts a point from world coordinates to CSS pixel coordinates relative to the viewport top-left.
74
25
  */
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
- };
26
+ worldToScreen(worldX: number, worldY: number): {
27
+ screenX: number;
28
+ screenY: number;
29
+ };
30
+ /**
31
+ * Converts a point from CSS pixel coordinates (viewport-relative) to world coordinates.
32
+ */
33
+ screenToWorld(screenX: number, screenY: number): {
34
+ worldX: number;
35
+ worldY: number;
36
+ };
37
+ /**
38
+ * Sets zoom, clamped to `[minZoom, maxZoom]`, optionally anchoring a screen point so it stays under the cursor.
39
+ */
40
+ setZoom(nextZoom: number, anchorScreen?: {
41
+ x: number;
42
+ y: number;
43
+ }): void;
44
+ /**
45
+ * Returns the world-space rectangle visible in a viewport of `viewportWidth` x `viewportHeight` CSS pixels.
46
+ */
47
+ getVisibleWorldRect(viewportWidth: number, viewportHeight: number): Rect;
48
+ }
150
49
 
151
50
  /** Stroke dash pattern for freehand drawings. `solid` = perfect-freehand fill; `dashed` = centerline stroke with dashes. */
152
51
  type StrokeDash = "solid" | "dashed";
@@ -283,4 +182,4 @@ declare function createImageFromVectorTrace(id: string, bounds: Rect, imageVecto
283
182
  height: number;
284
183
  }): VectorSceneItem;
285
184
 
286
- export { rebuildItemSvg as A, resolveStrokeStyle as B, type CanvuLinkData as C, DEFAULT_LINK_CARD_SIZE as D, type VectorViewportAssetStore as E, type FreehandSvgPayload as F, type VectorViewportAssetHydrationRequest as G, type VectorViewportAssetResolveRequest as H, type VectorViewportAssetResolveResult as I, type VectorViewportAssetUploadRequest as J, type VectorViewportAssetUploadResult as K, LINK_PLUGIN_KEY as L, type StrokeStyle as S, type VectorViewportAssetKind as V, DEFAULT_STROKE_STYLE as a, applyStrokeToItem as b, buildArchitecturalCloudPathD as c, buildArchitecturalCloudSvg as d, buildArrowSvg as e, buildDrawDotSvg as f, buildEllipseSvg as g, buildFreehandPathSvg as h, buildLineSvg as i, buildLinkCardSvg as j, buildRectSvg as k, computeFreehandSvgPayload as l, createArchitecturalCloudItem as m, createDrawDotItem as n, createEllipseItem as o, createFreehandStrokeItem as p, createImageFromVectorTrace as q, createImageItem as r, createLineItem as s, createLinkItem as t, createRectangleItem as u, createShapeId as v, createTextItem as w, getLinkData as x, isLinkItem as y, lineEndpointsToLocal as z };
185
+ export { Camera2D as C, DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type Camera2DOptions as a, applyStrokeToItem as b, buildArchitecturalCloudPathD as c, buildArchitecturalCloudSvg as d, buildArrowSvg as e, buildDrawDotSvg as f, buildEllipseSvg as g, buildFreehandPathSvg as h, buildLineSvg as i, buildRectSvg as j, computeFreehandSvgPayload as k, createArchitecturalCloudItem as l, createDrawDotItem as m, createEllipseItem as n, createFreehandStrokeItem as o, createImageFromVectorTrace as p, createImageItem as q, createLineItem as r, createRectangleItem as s, createShapeId as t, createTextItem as u, lineEndpointsToLocal as v, rebuildItemSvg as w, resolveStrokeStyle as x };
@@ -1,152 +1,51 @@
1
- import { V as VectorSceneItem, R as Rect, L as LineEndpointsLocal, b as VectorPathPoint, a as ArrowBindings } from './types-BCCvY6ie.js';
1
+ import { R as Rect, V as VectorSceneItem, L as LineEndpointsLocal, b as VectorPathPoint, a as ArrowBindings } from './types-BCCvY6ie.js';
2
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;
3
+ type Camera2DOptions = {
4
+ /** Minimum zoom scale (world units per CSS pixel). */
5
+ minZoom?: number;
6
+ /** Maximum zoom scale. */
7
+ maxZoom?: number;
25
8
  };
26
9
  /**
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);
10
+ * 2D camera: pan (`x`, `y`) in **screen space** (CSS pixels) and uniform zoom `zoom`.
40
11
  *
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
- * ```
12
+ * Screen mapping: `screen = world * zoom + cameraOffset`
13
+ * (world origin maps to `(x, y)` on screen).
66
14
  */
67
- type VectorViewportAssetUploadResult = {
15
+ declare class Camera2D {
16
+ x: number;
17
+ y: number;
18
+ /** Scale: world units per CSS pixel (larger = more zoomed in). */
19
+ zoom: number;
20
+ readonly minZoom: number;
21
+ readonly maxZoom: number;
22
+ constructor(options?: Camera2DOptions);
68
23
  /**
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.
24
+ * Converts a point from world coordinates to CSS pixel coordinates relative to the viewport top-left.
74
25
  */
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
- };
26
+ worldToScreen(worldX: number, worldY: number): {
27
+ screenX: number;
28
+ screenY: number;
29
+ };
30
+ /**
31
+ * Converts a point from CSS pixel coordinates (viewport-relative) to world coordinates.
32
+ */
33
+ screenToWorld(screenX: number, screenY: number): {
34
+ worldX: number;
35
+ worldY: number;
36
+ };
37
+ /**
38
+ * Sets zoom, clamped to `[minZoom, maxZoom]`, optionally anchoring a screen point so it stays under the cursor.
39
+ */
40
+ setZoom(nextZoom: number, anchorScreen?: {
41
+ x: number;
42
+ y: number;
43
+ }): void;
44
+ /**
45
+ * Returns the world-space rectangle visible in a viewport of `viewportWidth` x `viewportHeight` CSS pixels.
46
+ */
47
+ getVisibleWorldRect(viewportWidth: number, viewportHeight: number): Rect;
48
+ }
150
49
 
151
50
  /** Stroke dash pattern for freehand drawings. `solid` = perfect-freehand fill; `dashed` = centerline stroke with dashes. */
152
51
  type StrokeDash = "solid" | "dashed";
@@ -283,4 +182,4 @@ declare function createImageFromVectorTrace(id: string, bounds: Rect, imageVecto
283
182
  height: number;
284
183
  }): VectorSceneItem;
285
184
 
286
- export { rebuildItemSvg as A, resolveStrokeStyle as B, type CanvuLinkData as C, DEFAULT_LINK_CARD_SIZE as D, type VectorViewportAssetStore as E, type FreehandSvgPayload as F, type VectorViewportAssetHydrationRequest as G, type VectorViewportAssetResolveRequest as H, type VectorViewportAssetResolveResult as I, type VectorViewportAssetUploadRequest as J, type VectorViewportAssetUploadResult as K, LINK_PLUGIN_KEY as L, type StrokeStyle as S, type VectorViewportAssetKind as V, DEFAULT_STROKE_STYLE as a, applyStrokeToItem as b, buildArchitecturalCloudPathD as c, buildArchitecturalCloudSvg as d, buildArrowSvg as e, buildDrawDotSvg as f, buildEllipseSvg as g, buildFreehandPathSvg as h, buildLineSvg as i, buildLinkCardSvg as j, buildRectSvg as k, computeFreehandSvgPayload as l, createArchitecturalCloudItem as m, createDrawDotItem as n, createEllipseItem as o, createFreehandStrokeItem as p, createImageFromVectorTrace as q, createImageItem as r, createLineItem as s, createLinkItem as t, createRectangleItem as u, createShapeId as v, createTextItem as w, getLinkData as x, isLinkItem as y, lineEndpointsToLocal as z };
185
+ export { Camera2D as C, DEFAULT_STROKE_STYLE as D, type FreehandSvgPayload as F, type StrokeStyle as S, type Camera2DOptions as a, applyStrokeToItem as b, buildArchitecturalCloudPathD as c, buildArchitecturalCloudSvg as d, buildArrowSvg as e, buildDrawDotSvg as f, buildEllipseSvg as g, buildFreehandPathSvg as h, buildLineSvg as i, buildRectSvg as j, computeFreehandSvgPayload as k, createArchitecturalCloudItem as l, createDrawDotItem as m, createEllipseItem as n, createFreehandStrokeItem as o, createImageFromVectorTrace as p, createImageItem as q, createLineItem as r, createRectangleItem as s, createShapeId as t, createTextItem as u, lineEndpointsToLocal as v, rebuildItemSvg as w, resolveStrokeStyle as x };
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties, ReactNode, RefObject } from 'react';
3
3
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.cjs';
4
- import { C as Camera2D } from './camera-CVVG7z56.cjs';
5
- import { S as StrokeStyle, C as CanvuLinkData, E as VectorViewportAssetStore } from './shape-builders-BAWu-PxX.cjs';
4
+ import { S as StrokeStyle, C as Camera2D } from './shape-builders-CKEMjivV.cjs';
5
+ import { C as CanvuLinkData, a as VectorViewportAssetStore } from './link-item-D870_X6P.cjs';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
 
8
8
  type CanvuChromeActiveToolStyle = StrokeStyle & {
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties, ReactNode, RefObject } from 'react';
3
3
  import { V as VectorSceneItem, R as Rect } from './types-BCCvY6ie.js';
4
- import { C as Camera2D } from './camera-CoRYN_IV.js';
5
- import { S as StrokeStyle, C as CanvuLinkData, E as VectorViewportAssetStore } from './shape-builders-ClKv9tz9.js';
4
+ import { S as StrokeStyle, C as Camera2D } from './shape-builders-Cyh8zvDG.js';
5
+ import { C as CanvuLinkData, a as VectorViewportAssetStore } from './link-item-Bg5vj0RI.js';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
 
8
8
  type CanvuChromeActiveToolStyle = StrokeStyle & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvu-react",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Vector-first infinite canvas (SVG) with pan, zoom, React bindings, and optional plugins",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,50 +0,0 @@
1
- import { R as Rect } from './types-BCCvY6ie.cjs';
2
-
3
- type Camera2DOptions = {
4
- /** Minimum zoom scale (world units per CSS pixel). */
5
- minZoom?: number;
6
- /** Maximum zoom scale. */
7
- maxZoom?: number;
8
- };
9
- /**
10
- * 2D camera: pan (`x`, `y`) in **screen space** (CSS pixels) and uniform zoom `zoom`.
11
- *
12
- * Screen mapping: `screen = world * zoom + cameraOffset`
13
- * (world origin maps to `(x, y)` on screen).
14
- */
15
- declare class Camera2D {
16
- x: number;
17
- y: number;
18
- /** Scale: world units per CSS pixel (larger = more zoomed in). */
19
- zoom: number;
20
- readonly minZoom: number;
21
- readonly maxZoom: number;
22
- constructor(options?: Camera2DOptions);
23
- /**
24
- * Converts a point from world coordinates to CSS pixel coordinates relative to the viewport top-left.
25
- */
26
- worldToScreen(worldX: number, worldY: number): {
27
- screenX: number;
28
- screenY: number;
29
- };
30
- /**
31
- * Converts a point from CSS pixel coordinates (viewport-relative) to world coordinates.
32
- */
33
- screenToWorld(screenX: number, screenY: number): {
34
- worldX: number;
35
- worldY: number;
36
- };
37
- /**
38
- * Sets zoom, clamped to `[minZoom, maxZoom]`, optionally anchoring a screen point so it stays under the cursor.
39
- */
40
- setZoom(nextZoom: number, anchorScreen?: {
41
- x: number;
42
- y: number;
43
- }): void;
44
- /**
45
- * Returns the world-space rectangle visible in a viewport of `viewportWidth` x `viewportHeight` CSS pixels.
46
- */
47
- getVisibleWorldRect(viewportWidth: number, viewportHeight: number): Rect;
48
- }
49
-
50
- export { Camera2D as C, type Camera2DOptions as a };
@@ -1,50 +0,0 @@
1
- import { R as Rect } from './types-BCCvY6ie.js';
2
-
3
- type Camera2DOptions = {
4
- /** Minimum zoom scale (world units per CSS pixel). */
5
- minZoom?: number;
6
- /** Maximum zoom scale. */
7
- maxZoom?: number;
8
- };
9
- /**
10
- * 2D camera: pan (`x`, `y`) in **screen space** (CSS pixels) and uniform zoom `zoom`.
11
- *
12
- * Screen mapping: `screen = world * zoom + cameraOffset`
13
- * (world origin maps to `(x, y)` on screen).
14
- */
15
- declare class Camera2D {
16
- x: number;
17
- y: number;
18
- /** Scale: world units per CSS pixel (larger = more zoomed in). */
19
- zoom: number;
20
- readonly minZoom: number;
21
- readonly maxZoom: number;
22
- constructor(options?: Camera2DOptions);
23
- /**
24
- * Converts a point from world coordinates to CSS pixel coordinates relative to the viewport top-left.
25
- */
26
- worldToScreen(worldX: number, worldY: number): {
27
- screenX: number;
28
- screenY: number;
29
- };
30
- /**
31
- * Converts a point from CSS pixel coordinates (viewport-relative) to world coordinates.
32
- */
33
- screenToWorld(screenX: number, screenY: number): {
34
- worldX: number;
35
- worldY: number;
36
- };
37
- /**
38
- * Sets zoom, clamped to `[minZoom, maxZoom]`, optionally anchoring a screen point so it stays under the cursor.
39
- */
40
- setZoom(nextZoom: number, anchorScreen?: {
41
- x: number;
42
- y: number;
43
- }): void;
44
- /**
45
- * Returns the world-space rectangle visible in a viewport of `viewportWidth` x `viewportHeight` CSS pixels.
46
- */
47
- getVisibleWorldRect(viewportWidth: number, viewportHeight: number): Rect;
48
- }
49
-
50
- export { Camera2D as C, type Camera2DOptions as a };