canvu-react 0.3.38 → 0.3.39
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-DrTOgDdd.d.ts → asset-hydration-DdFLdlqX.d.ts} +1 -1
- package/dist/{asset-hydration-EtEuBwb7.d.cts → asset-hydration-DowNdaOJ.d.cts} +1 -1
- package/dist/chatbot.d.cts +2 -2
- package/dist/chatbot.d.ts +2 -2
- package/dist/index.cjs +105 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +100 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +32 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +32 -3
- package/dist/react.js.map +1 -1
- package/dist/realtime.d.cts +3 -3
- package/dist/realtime.d.ts +3 -3
- package/dist/{shape-builders-CsSXKCcs.d.ts → shape-builders-C7bxJBGR.d.ts} +40 -2
- package/dist/{shape-builders-CsbSRZnQ.d.cts → shape-builders-Dedcl6tw.d.cts} +40 -2
- package/dist/tldraw.cjs +134 -65
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +134 -65
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-B6PAYKzx.d.ts → types-BBb8KoyW.d.ts} +10 -1
- package/dist/{types-DWGk2_GZ.d.cts → types-DUW61Tjy.d.cts} +10 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { C as Camera2D } from './camera-Di5R_Rwl.cjs';
|
|
|
2
2
|
export { a as Camera2DOptions } from './camera-Di5R_Rwl.cjs';
|
|
3
3
|
import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-Bnq2HtHQ.cjs';
|
|
4
4
|
export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-Bnq2HtHQ.cjs';
|
|
5
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
6
|
-
export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle,
|
|
5
|
+
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-DowNdaOJ.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-Dedcl6tw.cjs';
|
|
7
7
|
|
|
8
8
|
type EncodeCanvasToBlobOptions = {
|
|
9
9
|
mimeType?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { C as Camera2D } from './camera-AoTwBSoE.js';
|
|
|
2
2
|
export { a as Camera2DOptions } from './camera-AoTwBSoE.js';
|
|
3
3
|
import { V as VectorSceneItem, A as ArrowEndpointBinding, R as Rect } from './types-Bnq2HtHQ.js';
|
|
4
4
|
export { a as ArrowBindings, b as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-Bnq2HtHQ.js';
|
|
5
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
6
|
-
export { D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle,
|
|
5
|
+
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-DdFLdlqX.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-C7bxJBGR.js';
|
|
7
7
|
|
|
8
8
|
type EncodeCanvasToBlobOptions = {
|
|
9
9
|
mimeType?: string;
|
package/dist/index.js
CHANGED
|
@@ -2754,6 +2754,105 @@ function cloneVectorSceneItemsWithNewIds(items) {
|
|
|
2754
2754
|
return items.map(cloneVectorSceneItemWithNewId);
|
|
2755
2755
|
}
|
|
2756
2756
|
|
|
2757
|
+
// src/scene/link-item.ts
|
|
2758
|
+
var LINK_PLUGIN_KEY = "canvuLink";
|
|
2759
|
+
var DEFAULT_LINK_CARD_WIDTH = 360;
|
|
2760
|
+
var DEFAULT_LINK_CARD_HEIGHT = 132;
|
|
2761
|
+
var LINK_CARD_BORDER = "#e2e8f0";
|
|
2762
|
+
var LINK_CARD_ACCENT = "#2563eb";
|
|
2763
|
+
var LINK_CARD_TITLE_COLOR = "#0f172a";
|
|
2764
|
+
var LINK_CARD_TEXT_COLOR = "#475569";
|
|
2765
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
2766
|
+
var formatNumber = (value) => {
|
|
2767
|
+
const rounded = Math.round(value * 100) / 100;
|
|
2768
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
2769
|
+
};
|
|
2770
|
+
var escapeXmlAttribute = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2771
|
+
var escapeHtmlText2 = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
2772
|
+
var getLinkHostname = (href) => {
|
|
2773
|
+
try {
|
|
2774
|
+
return new URL(href).hostname.replace(/^www\./, "");
|
|
2775
|
+
} catch {
|
|
2776
|
+
return href;
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
var buildLinkTextBand = (band) => {
|
|
2780
|
+
const lineHeight = band.fontSize * 1.3;
|
|
2781
|
+
const weight = band.fontWeight != null ? `font-weight:${band.fontWeight};` : "";
|
|
2782
|
+
const lineClampStyle = band.clampLines ? `display:-webkit-box;-webkit-line-clamp:${band.clampLines};-webkit-box-orient:vertical;` : "";
|
|
2783
|
+
return `<foreignObject x="${formatNumber(band.x)}" y="${formatNumber(band.y)}" width="${formatNumber(Math.max(1, band.width))}" height="${formatNumber(Math.max(1, band.height))}"><div xmlns="http://www.w3.org/1999/xhtml" style="box-sizing:border-box;width:100%;height:100%;margin:0;font-family:system-ui,sans-serif;font-size:${formatNumber(band.fontSize)}px;line-height:${formatNumber(lineHeight)}px;color:${band.color};overflow:hidden;word-break:break-word;${lineClampStyle}${weight}">${escapeHtmlText2(band.text)}</div></foreignObject>`;
|
|
2784
|
+
};
|
|
2785
|
+
function buildLinkCardSvg(width, height, link) {
|
|
2786
|
+
const cardWidth = Math.max(1, width);
|
|
2787
|
+
const cardHeight = Math.max(1, height);
|
|
2788
|
+
const padding = 14;
|
|
2789
|
+
const badgeSize = clamp(Math.min(72, cardHeight - padding * 2), 28, 96);
|
|
2790
|
+
const textX = padding + badgeSize + 14;
|
|
2791
|
+
const textWidth = Math.max(1, cardWidth - textX - padding);
|
|
2792
|
+
const hostname = getLinkHostname(link.href);
|
|
2793
|
+
const title = link.title?.trim() || hostname || "Link";
|
|
2794
|
+
const description = link.description?.trim() || link.href;
|
|
2795
|
+
const titleY = padding;
|
|
2796
|
+
const titleHeight = clamp(cardHeight * 0.22, 18, 28);
|
|
2797
|
+
const hostY = titleY + titleHeight + 2;
|
|
2798
|
+
const hostHeight = 16;
|
|
2799
|
+
const descY = hostY + hostHeight + 4;
|
|
2800
|
+
const descHeight = Math.max(1, cardHeight - descY - padding);
|
|
2801
|
+
const badge = link.favicon ? `<clipPath id="canvu-link-badge"><rect x="${formatNumber(padding)}" y="${formatNumber(padding)}" width="${formatNumber(badgeSize)}" height="${formatNumber(badgeSize)}" rx="12" /></clipPath>
|
|
2802
|
+
<rect x="${formatNumber(padding)}" y="${formatNumber(padding)}" width="${formatNumber(badgeSize)}" height="${formatNumber(badgeSize)}" rx="12" fill="#f8fafc" stroke="${LINK_CARD_BORDER}" stroke-width="1" />
|
|
2803
|
+
<image href="${escapeXmlAttribute(link.favicon)}" x="${formatNumber(padding)}" y="${formatNumber(padding)}" width="${formatNumber(badgeSize)}" height="${formatNumber(badgeSize)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#canvu-link-badge)" />` : `<rect x="${formatNumber(padding)}" y="${formatNumber(padding)}" width="${formatNumber(badgeSize)}" height="${formatNumber(badgeSize)}" rx="12" fill="${LINK_CARD_ACCENT}" fill-opacity="0.1" stroke="${LINK_CARD_ACCENT}" stroke-opacity="0.3" stroke-width="1" />
|
|
2804
|
+
<g transform="translate(${formatNumber(padding + badgeSize / 2)},${formatNumber(padding + badgeSize / 2)})" stroke="${LINK_CARD_ACCENT}" stroke-width="2.4" stroke-linecap="round" fill="none">
|
|
2805
|
+
<path d="M-9 3 a6 6 0 0 1 0 -8 l4 -4 a6 6 0 0 1 8 8 l-2 2" />
|
|
2806
|
+
<path d="M9 -3 a6 6 0 0 1 0 8 l-4 4 a6 6 0 0 1 -8 -8 l2 -2" />
|
|
2807
|
+
</g>`;
|
|
2808
|
+
const externalIconX = cardWidth - padding - 16;
|
|
2809
|
+
const externalIcon = `<g transform="translate(${formatNumber(externalIconX)},${formatNumber(padding)})" stroke="${LINK_CARD_TEXT_COLOR}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none">
|
|
2810
|
+
<path d="M6 1 H11 V6" />
|
|
2811
|
+
<path d="M11 1 L4.5 7.5" />
|
|
2812
|
+
<path d="M9 7 V10 a1 1 0 0 1 -1 1 H2 a1 1 0 0 1 -1 -1 V4 a1 1 0 0 1 1 -1 H5" />
|
|
2813
|
+
</g>`;
|
|
2814
|
+
return `
|
|
2815
|
+
<rect width="${formatNumber(cardWidth)}" height="${formatNumber(cardHeight)}" rx="16" fill="#ffffff" stroke="${LINK_CARD_BORDER}" stroke-width="1.5" />
|
|
2816
|
+
${badge}
|
|
2817
|
+
${externalIcon}
|
|
2818
|
+
${buildLinkTextBand({ x: textX, y: titleY, width: textWidth - 18, height: titleHeight, text: title, fontSize: 15, color: LINK_CARD_TITLE_COLOR, fontWeight: 700, clampLines: 1 })}
|
|
2819
|
+
${buildLinkTextBand({ x: textX, y: hostY, width: textWidth, height: hostHeight, text: hostname, fontSize: 12, color: LINK_CARD_ACCENT, clampLines: 1 })}
|
|
2820
|
+
${buildLinkTextBand({ x: textX, y: descY, width: textWidth, height: descHeight, text: description, fontSize: 12, color: LINK_CARD_TEXT_COLOR, clampLines: 2 })}
|
|
2821
|
+
`;
|
|
2822
|
+
}
|
|
2823
|
+
var isCanvuLinkData = (value) => {
|
|
2824
|
+
if (!value || typeof value !== "object") return false;
|
|
2825
|
+
const candidate = value;
|
|
2826
|
+
return typeof candidate.href === "string" && candidate.href.length > 0;
|
|
2827
|
+
};
|
|
2828
|
+
function getLinkData(item) {
|
|
2829
|
+
const entry = item.pluginData?.[LINK_PLUGIN_KEY];
|
|
2830
|
+
return isCanvuLinkData(entry) ? entry : null;
|
|
2831
|
+
}
|
|
2832
|
+
function isLinkItem(item) {
|
|
2833
|
+
return getLinkData(item) != null;
|
|
2834
|
+
}
|
|
2835
|
+
function createLinkItem(id, bounds, link) {
|
|
2836
|
+
const width = bounds.width || DEFAULT_LINK_CARD_WIDTH;
|
|
2837
|
+
const height = bounds.height || DEFAULT_LINK_CARD_HEIGHT;
|
|
2838
|
+
const item = createCustomShapeItem(
|
|
2839
|
+
id,
|
|
2840
|
+
{ ...bounds, width, height },
|
|
2841
|
+
{ render: (size) => buildLinkCardSvg(size.width, size.height, link) }
|
|
2842
|
+
);
|
|
2843
|
+
return {
|
|
2844
|
+
...item,
|
|
2845
|
+
pluginData: {
|
|
2846
|
+
...item.pluginData ?? {},
|
|
2847
|
+
[LINK_PLUGIN_KEY]: link
|
|
2848
|
+
}
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
var DEFAULT_LINK_CARD_SIZE = {
|
|
2852
|
+
width: DEFAULT_LINK_CARD_WIDTH,
|
|
2853
|
+
height: DEFAULT_LINK_CARD_HEIGHT
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2757
2856
|
// src/scene/managed-images.ts
|
|
2758
2857
|
var MANAGED_KEY = "managed";
|
|
2759
2858
|
var STACK_GAP_WORLD = 16;
|
|
@@ -2856,6 +2955,6 @@ var VectorScene = class {
|
|
|
2856
2955
|
}
|
|
2857
2956
|
};
|
|
2858
2957
|
|
|
2859
|
-
export { ARROW_BIND_SNAP_PX, Camera2D, DEFAULT_STROKE_STYLE, DEFAULT_TEXT_FONT_SIZE, MANAGED_KEY, MAX_RASTER_EMBED_DIMENSION, SvgVectorRenderer, VectorScene, addManagedImage, applyStrokeToItem, attachApplePencilNavigation, attachViewportInput, bakeArrowItemToAbsolute, buildArchitecturalCloudPathD, buildArchitecturalCloudSvg, buildArrowSvg, buildCustomShapeChildrenSvg, buildDrawDotSvg, buildEllipseSvg, buildFreehandPathSvg, buildLineSvg, buildRectSvg, buildTextSvg, cloneVectorSceneItemWithNewId, cloneVectorSceneItemsWithNewIds, collectEraserTargetsAtWorldPoint, computeFreehandSvgPayload, copyManagedImage, createArchitecturalCloudItem, createCustomShapeItem, createDrawDotItem, createEllipseItem, createFreehandStrokeItem, createImageFromVectorTrace, createImageItem, createLineItem, createRectangleItem, createShapeId, createTextItem, cullItemsByViewport, deleteManagedImage, encodeCanvasToBlob, expandCustomShapeTemplate, formatCameraTransform, formatItemPlacementTransform, hitTestWorldPoint, hydrateSceneItemsWithAssets, isArrowBindTarget, isManagedImage, itemHitTestWorldPoint, lineEndpointsToLocal, loadImageFileAsRasterSceneSource, markImageAsManaged, normalizeRect, rebuildItemSvg, rectsIntersect, reorderManagedImages, resolveArrowBindingsInScene, resolveStrokeStyle, restackManagedImages, rotateManagedImage, snapArrowEndpointToShape };
|
|
2958
|
+
export { ARROW_BIND_SNAP_PX, Camera2D, DEFAULT_LINK_CARD_SIZE, DEFAULT_STROKE_STYLE, DEFAULT_TEXT_FONT_SIZE, LINK_PLUGIN_KEY, MANAGED_KEY, MAX_RASTER_EMBED_DIMENSION, SvgVectorRenderer, VectorScene, addManagedImage, applyStrokeToItem, attachApplePencilNavigation, attachViewportInput, bakeArrowItemToAbsolute, buildArchitecturalCloudPathD, buildArchitecturalCloudSvg, buildArrowSvg, buildCustomShapeChildrenSvg, buildDrawDotSvg, buildEllipseSvg, buildFreehandPathSvg, buildLineSvg, buildLinkCardSvg, buildRectSvg, buildTextSvg, cloneVectorSceneItemWithNewId, cloneVectorSceneItemsWithNewIds, collectEraserTargetsAtWorldPoint, computeFreehandSvgPayload, copyManagedImage, createArchitecturalCloudItem, createCustomShapeItem, createDrawDotItem, createEllipseItem, createFreehandStrokeItem, createImageFromVectorTrace, createImageItem, createLineItem, createLinkItem, createRectangleItem, createShapeId, createTextItem, cullItemsByViewport, deleteManagedImage, encodeCanvasToBlob, expandCustomShapeTemplate, formatCameraTransform, formatItemPlacementTransform, getLinkData, hitTestWorldPoint, hydrateSceneItemsWithAssets, isArrowBindTarget, isLinkItem, isManagedImage, itemHitTestWorldPoint, lineEndpointsToLocal, loadImageFileAsRasterSceneSource, markImageAsManaged, normalizeRect, rebuildItemSvg, rectsIntersect, reorderManagedImages, resolveArrowBindingsInScene, resolveStrokeStyle, restackManagedImages, rotateManagedImage, snapArrowEndpointToShape };
|
|
2860
2959
|
//# sourceMappingURL=index.js.map
|
|
2861
2960
|
//# sourceMappingURL=index.js.map
|