canvu-react 0.4.47 → 0.4.48
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-Dc7fsnTG.d.ts → asset-hydration-BSjiek7Q.d.ts} +2 -2
- package/dist/{asset-hydration-Cy_2FyV5.d.cts → asset-hydration-F6aM5C7x.d.cts} +2 -2
- package/dist/{asset-store-TzOPvlgn.d.cts → asset-store-35ysK28r.d.cts} +1 -1
- package/dist/{asset-store-DQPRZEcy.d.ts → asset-store-D_FjW_CN.d.ts} +1 -1
- package/dist/chatbot.d.cts +6 -6
- package/dist/chatbot.d.ts +6 -6
- package/dist/index.cjs +49 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -1
- package/dist/{link-item-DwzXOwU5.d.cts → link-item-BMV3VUCr.d.cts} +1 -1
- package/dist/{link-item-IW4GTnxl.d.ts → link-item-COoNNvCu.d.ts} +1 -1
- package/dist/native.cjs +47 -7
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +6 -6
- package/dist/native.d.ts +6 -6
- package/dist/native.js +47 -7
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +259 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +29 -13
- package/dist/react.d.ts +29 -13
- package/dist/react.js +259 -18
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +3 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +8 -8
- package/dist/realtime.d.ts +8 -8
- package/dist/realtime.js +3 -1
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.d.cts +4 -4
- package/dist/realtimeNative.d.ts +4 -4
- package/dist/{shape-builders-Cyh8zvDG.d.ts → shape-builders-BCOAG0pS.d.ts} +1 -1
- package/dist/{shape-builders-CKEMjivV.d.cts → shape-builders-BmLS8CNh.d.cts} +1 -1
- package/dist/tldraw.cjs +3 -1
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.d.cts +1 -1
- package/dist/tldraw.d.ts +1 -1
- package/dist/tldraw.js +3 -1
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-BUPc2Zgw.d.cts → types-6HszqSa5.d.cts} +1 -1
- package/dist/{types-B7xZAKVJ.d.ts → types-BAEHaIYO.d.ts} +43 -6
- package/dist/{types-B82WiQQh.d.ts → types-BMMPUak7.d.ts} +1 -1
- package/dist/{types-BQUbxMgz.d.cts → types-BOQLWyCw.d.cts} +1 -1
- package/dist/{types-CYtq9Pr9.d.ts → types-BtWbGOqh.d.ts} +1 -1
- package/dist/{types-BCCvY6ie.d.cts → types-fJNwEnHf.d.cts} +35 -1
- package/dist/{types-BCCvY6ie.d.ts → types-fJNwEnHf.d.ts} +35 -1
- package/dist/{types-C4wI3Jyc.d.cts → types-uzeExFkd.d.cts} +43 -6
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VectorSceneItem } from './types-
|
|
2
|
-
import { a as VectorViewportAssetStore } from './asset-store-
|
|
1
|
+
import { V as VectorSceneItem } from './types-fJNwEnHf.js';
|
|
2
|
+
import { a as VectorViewportAssetStore } from './asset-store-D_FjW_CN.js';
|
|
3
3
|
|
|
4
4
|
declare class IndexedDbImageStore {
|
|
5
5
|
private dbPromise;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VectorSceneItem } from './types-
|
|
2
|
-
import { a as VectorViewportAssetStore } from './asset-store-
|
|
1
|
+
import { V as VectorSceneItem } from './types-fJNwEnHf.cjs';
|
|
2
|
+
import { a as VectorViewportAssetStore } from './asset-store-35ysK28r.cjs';
|
|
3
3
|
|
|
4
4
|
declare class IndexedDbImageStore {
|
|
5
5
|
private dbPromise;
|
package/dist/chatbot.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { a as CanvasPlugin } from './types-uzeExFkd.cjs';
|
|
3
3
|
import 'react';
|
|
4
|
-
import './types-
|
|
5
|
-
import './shape-builders-
|
|
6
|
-
import './link-item-
|
|
7
|
-
import './asset-store-
|
|
8
|
-
import './types-
|
|
4
|
+
import './types-fJNwEnHf.cjs';
|
|
5
|
+
import './shape-builders-BmLS8CNh.cjs';
|
|
6
|
+
import './link-item-BMV3VUCr.cjs';
|
|
7
|
+
import './asset-store-35ysK28r.cjs';
|
|
8
|
+
import './types-BOQLWyCw.cjs';
|
|
9
9
|
|
|
10
10
|
type ChatbotPluginPanelProps = {
|
|
11
11
|
/**
|
package/dist/chatbot.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { a as CanvasPlugin } from './types-BAEHaIYO.js';
|
|
3
3
|
import 'react';
|
|
4
|
-
import './types-
|
|
5
|
-
import './shape-builders-
|
|
6
|
-
import './link-item-
|
|
7
|
-
import './asset-store-
|
|
8
|
-
import './types-
|
|
4
|
+
import './types-fJNwEnHf.js';
|
|
5
|
+
import './shape-builders-BCOAG0pS.js';
|
|
6
|
+
import './link-item-COoNNvCu.js';
|
|
7
|
+
import './asset-store-D_FjW_CN.js';
|
|
8
|
+
import './types-BMMPUak7.js';
|
|
9
9
|
|
|
10
10
|
type ChatbotPluginPanelProps = {
|
|
11
11
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -974,7 +974,7 @@ function buildCustomShapeChildrenSvg(inner, intrinsic, bounds) {
|
|
|
974
974
|
const sy = b.height / intrinsic.height;
|
|
975
975
|
return `<g transform="scale(${sx},${sy})">${inner}</g>`;
|
|
976
976
|
}
|
|
977
|
-
function createCustomShapeItem(id, bounds, content) {
|
|
977
|
+
function createCustomShapeItem(id, bounds, content, options = {}) {
|
|
978
978
|
const r = normalizeRect(bounds);
|
|
979
979
|
const intrinsic = { width: r.width, height: r.height };
|
|
980
980
|
const inner = resolveCustomInner(content, intrinsic);
|
|
@@ -986,6 +986,8 @@ function createCustomShapeItem(id, bounds, content) {
|
|
|
986
986
|
toolKind: "custom",
|
|
987
987
|
customIntrinsicSize: intrinsic,
|
|
988
988
|
customInnerSvg: inner,
|
|
989
|
+
...options.resizeHandles !== void 0 ? { customResizeHandles: options.resizeHandles } : {},
|
|
990
|
+
...options.svgClassName ? { svgClassName: options.svgClassName } : {},
|
|
989
991
|
childrenSvg: buildCustomShapeChildrenSvg(inner, intrinsic, r)
|
|
990
992
|
};
|
|
991
993
|
}
|
|
@@ -2813,6 +2815,14 @@ function formatItemPlacementTransform(item) {
|
|
|
2813
2815
|
const cy = r.height / 2;
|
|
2814
2816
|
return `translate(${item.x}, ${item.y}) translate(${cx}, ${cy}) rotate(${deg}) translate(${-cx}, ${-cy})`;
|
|
2815
2817
|
}
|
|
2818
|
+
function itemClassName(item) {
|
|
2819
|
+
const kind = item.toolKind ?? "unknown";
|
|
2820
|
+
const classes = [`canvu-item`, `canvu-item--${kind}`];
|
|
2821
|
+
if (item.svgClassName) {
|
|
2822
|
+
classes.push(item.svgClassName);
|
|
2823
|
+
}
|
|
2824
|
+
return classes.join(" ");
|
|
2825
|
+
}
|
|
2816
2826
|
var SvgVectorRenderer = class {
|
|
2817
2827
|
container;
|
|
2818
2828
|
scene;
|
|
@@ -2820,6 +2830,8 @@ var SvgVectorRenderer = class {
|
|
|
2820
2830
|
svg;
|
|
2821
2831
|
rootG;
|
|
2822
2832
|
itemNodeCache = /* @__PURE__ */ new Map();
|
|
2833
|
+
selectedIds = /* @__PURE__ */ new Set();
|
|
2834
|
+
hoveredItemId = null;
|
|
2823
2835
|
liveOverlay = null;
|
|
2824
2836
|
resizeObserver;
|
|
2825
2837
|
constructor(options) {
|
|
@@ -2840,6 +2852,20 @@ var SvgVectorRenderer = class {
|
|
|
2840
2852
|
this.resizeObserver = new ResizeObserver(() => this.render());
|
|
2841
2853
|
this.resizeObserver.observe(this.container);
|
|
2842
2854
|
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Updates interaction attributes on item groups for CSS hooks.
|
|
2857
|
+
*
|
|
2858
|
+
* Use `[data-canvu-selected="true"]` and `[data-canvu-hovered="true"]`
|
|
2859
|
+
* for animations in interactive canvases where the scene SVG may ignore
|
|
2860
|
+
* pointer events.
|
|
2861
|
+
*/
|
|
2862
|
+
setInteractionState(state) {
|
|
2863
|
+
this.selectedIds = new Set(state.selectedIds ?? []);
|
|
2864
|
+
this.hoveredItemId = state.hoveredItemId ?? null;
|
|
2865
|
+
for (const [id, cached] of this.itemNodeCache) {
|
|
2866
|
+
this.applyInteractionAttributes(cached.g, id);
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2843
2869
|
/**
|
|
2844
2870
|
* Reads container size, culls items, and updates the SVG (incrementally when possible).
|
|
2845
2871
|
*/
|
|
@@ -2876,6 +2902,7 @@ var SvgVectorRenderer = class {
|
|
|
2876
2902
|
if (!this.liveOverlay) {
|
|
2877
2903
|
const g = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2878
2904
|
g.setAttribute("data-live-overlay", "true");
|
|
2905
|
+
g.setAttribute("data-canvu-item", "true");
|
|
2879
2906
|
this.liveOverlay = {
|
|
2880
2907
|
g,
|
|
2881
2908
|
lastChildrenSvg: "",
|
|
@@ -2885,6 +2912,11 @@ var SvgVectorRenderer = class {
|
|
|
2885
2912
|
}
|
|
2886
2913
|
const cached = this.liveOverlay;
|
|
2887
2914
|
const t = formatItemPlacementTransform(item);
|
|
2915
|
+
cached.g.setAttribute("class", itemClassName(item));
|
|
2916
|
+
cached.g.setAttribute("data-item-id", item.id);
|
|
2917
|
+
cached.g.setAttribute("data-tool-kind", item.toolKind ?? "");
|
|
2918
|
+
cached.g.setAttribute("data-canvu-selected", "false");
|
|
2919
|
+
cached.g.setAttribute("data-canvu-hovered", "false");
|
|
2888
2920
|
if (cached.lastTransform !== t) {
|
|
2889
2921
|
cached.g.setAttribute("transform", t);
|
|
2890
2922
|
cached.lastTransform = t;
|
|
@@ -2915,6 +2947,7 @@ var SvgVectorRenderer = class {
|
|
|
2915
2947
|
let cached = this.itemNodeCache.get(item.id);
|
|
2916
2948
|
if (!cached) {
|
|
2917
2949
|
const g2 = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2950
|
+
g2.setAttribute("data-canvu-item", "true");
|
|
2918
2951
|
g2.setAttribute("data-item-id", item.id);
|
|
2919
2952
|
cached = {
|
|
2920
2953
|
g: g2,
|
|
@@ -2924,6 +2957,11 @@ var SvgVectorRenderer = class {
|
|
|
2924
2957
|
this.itemNodeCache.set(item.id, cached);
|
|
2925
2958
|
}
|
|
2926
2959
|
const { g } = cached;
|
|
2960
|
+
g.setAttribute("class", itemClassName(item));
|
|
2961
|
+
g.setAttribute("data-canvu-item", "true");
|
|
2962
|
+
g.setAttribute("data-item-id", item.id);
|
|
2963
|
+
g.setAttribute("data-tool-kind", item.toolKind ?? "");
|
|
2964
|
+
this.applyInteractionAttributes(g, item.id);
|
|
2927
2965
|
const t = formatItemPlacementTransform(item);
|
|
2928
2966
|
if (cached.lastTransform !== t) {
|
|
2929
2967
|
g.setAttribute("transform", t);
|
|
@@ -2940,6 +2978,16 @@ var SvgVectorRenderer = class {
|
|
|
2940
2978
|
previousNode = g;
|
|
2941
2979
|
}
|
|
2942
2980
|
}
|
|
2981
|
+
applyInteractionAttributes(g, itemId) {
|
|
2982
|
+
g.setAttribute(
|
|
2983
|
+
"data-canvu-selected",
|
|
2984
|
+
this.selectedIds.has(itemId) ? "true" : "false"
|
|
2985
|
+
);
|
|
2986
|
+
g.setAttribute(
|
|
2987
|
+
"data-canvu-hovered",
|
|
2988
|
+
this.hoveredItemId === itemId ? "true" : "false"
|
|
2989
|
+
);
|
|
2990
|
+
}
|
|
2943
2991
|
destroy() {
|
|
2944
2992
|
this.resizeObserver.disconnect();
|
|
2945
2993
|
this.itemNodeCache.clear();
|