canvu-react 0.4.5 → 0.4.6
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/{asset-hydration-B7yMDQE-.d.cts → asset-hydration-CWhld14A.d.cts} +1 -1
- package/dist/{asset-hydration-CbwQVAwh.d.ts → asset-hydration-D35mHbUP.d.ts} +1 -1
- package/dist/chatbot.d.cts +3 -3
- package/dist/chatbot.d.ts +3 -3
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/link-item-Bg5vj0RI.d.ts +151 -0
- package/dist/link-item-D870_X6P.d.cts +151 -0
- package/dist/native.cjs +146 -144
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +4 -3
- package/dist/native.d.ts +4 -3
- package/dist/native.js +145 -145
- package/dist/native.js.map +1 -1
- package/dist/react.d.cts +7 -7
- package/dist/react.d.ts +7 -7
- package/dist/realtime.d.cts +4 -4
- package/dist/realtime.d.ts +4 -4
- package/dist/{shape-builders-BAWu-PxX.d.cts → shape-builders-CKEMjivV.d.cts} +42 -143
- package/dist/{shape-builders-ClKv9tz9.d.ts → shape-builders-Cyh8zvDG.d.ts} +42 -143
- package/dist/{types-BC9Xgfu6.d.cts → types-Bw1SdC9v.d.cts} +2 -2
- package/dist/{types-DlSVGX0w.d.ts → types-DeXFfs7Y.d.ts} +2 -2
- package/package.json +1 -1
- package/dist/camera-CVVG7z56.d.cts +0 -50
- package/dist/camera-CoRYN_IV.d.ts +0 -50
package/dist/react.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { I as IndexedDbImageStore } from './asset-hydration-
|
|
2
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
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,
|
|
5
|
-
export {
|
|
6
|
-
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-
|
|
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-
|
|
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 './
|
|
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-
|
|
2
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
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,
|
|
5
|
-
export {
|
|
6
|
-
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CanvasPlugin, a as VectorSelectionInspector } from './types-
|
|
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-
|
|
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 './
|
|
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
|
|
package/dist/realtime.d.cts
CHANGED
|
@@ -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-
|
|
2
|
-
export { F as PresenceOverlayRenderContext } from './types-
|
|
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 './
|
|
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 './
|
|
8
|
+
import './link-item-D870_X6P.cjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Maps a local {@link PlacementPreview} stroke to {@link RemotePresenceMarkupStroke} for broadcasting.
|
package/dist/realtime.d.ts
CHANGED
|
@@ -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-
|
|
2
|
-
export { F as PresenceOverlayRenderContext } from './types-
|
|
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 './
|
|
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 './
|
|
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 {
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
42
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
42
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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 {
|
|
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 './
|
|
5
|
-
import {
|
|
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 './
|
|
5
|
-
import {
|
|
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,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 };
|