@lace-cloud/canvas 0.10.0 → 0.12.0
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/README.md +24 -0
- package/dist/{Canvas-IXCFWQNP.css → Canvas-J6F7YHEK.css} +9 -10
- package/dist/index.cjs +132 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +133 -127
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ import { CanvasView, Diagnostic, NodeConfig, EdgeConfig, SettingsConfig, RenderE
|
|
|
2
2
|
export { CanvasView, Diagnostic, EdgeConfig, GeneratePhase, HostToWebview, NodeConfig, NodePin, ProjectionMeta, RenderEdge, RenderError, RenderGroup, RenderInput, RenderNode, RenderOutput, SettingsConfig, ViewportIntent, projectCanvasView } from '@lace-cloud/proto';
|
|
3
3
|
export { Toast } from '@lace-cloud/ui/feedback';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
6
5
|
import * as React from 'react';
|
|
7
6
|
import React__default from 'react';
|
|
7
|
+
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
8
8
|
import { NodeProps, Node } from '@xyflow/react';
|
|
9
9
|
|
|
10
10
|
interface Bundle {
|
|
@@ -526,6 +526,11 @@ type HostBridge = {
|
|
|
526
526
|
type AppProps = {
|
|
527
527
|
engine: CanvasEngine;
|
|
528
528
|
hostBridge: HostBridge;
|
|
529
|
+
/**
|
|
530
|
+
* Height of the canvas root. Defaults to `100vh`; embedded consumers can
|
|
531
|
+
* pass `100%` when their parent establishes an explicit height.
|
|
532
|
+
*/
|
|
533
|
+
height?: React__default.CSSProperties['height'];
|
|
529
534
|
/**
|
|
530
535
|
* When true, the canvas renders in read-only mode: pan/zoom/drag/inspect
|
|
531
536
|
* still work, but every IR-mutating affordance (save, delete, rename,
|
|
@@ -537,7 +542,7 @@ type AppProps = {
|
|
|
537
542
|
/** API token for registry access. */
|
|
538
543
|
apiToken?: string;
|
|
539
544
|
};
|
|
540
|
-
declare function App({ engine, hostBridge, readOnly, registryBaseUrl, apiToken, }: AppProps): react_jsx_runtime.JSX.Element;
|
|
545
|
+
declare function App({ engine, hostBridge, height, readOnly, registryBaseUrl, apiToken, }: AppProps): react_jsx_runtime.JSX.Element;
|
|
541
546
|
|
|
542
547
|
type Props$a = {
|
|
543
548
|
title: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { CanvasView, Diagnostic, NodeConfig, EdgeConfig, SettingsConfig, RenderE
|
|
|
2
2
|
export { CanvasView, Diagnostic, EdgeConfig, GeneratePhase, HostToWebview, NodeConfig, NodePin, ProjectionMeta, RenderEdge, RenderError, RenderGroup, RenderInput, RenderNode, RenderOutput, SettingsConfig, ViewportIntent, projectCanvasView } from '@lace-cloud/proto';
|
|
3
3
|
export { Toast } from '@lace-cloud/ui/feedback';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
6
5
|
import * as React from 'react';
|
|
7
6
|
import React__default from 'react';
|
|
7
|
+
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
8
8
|
import { NodeProps, Node } from '@xyflow/react';
|
|
9
9
|
|
|
10
10
|
interface Bundle {
|
|
@@ -526,6 +526,11 @@ type HostBridge = {
|
|
|
526
526
|
type AppProps = {
|
|
527
527
|
engine: CanvasEngine;
|
|
528
528
|
hostBridge: HostBridge;
|
|
529
|
+
/**
|
|
530
|
+
* Height of the canvas root. Defaults to `100vh`; embedded consumers can
|
|
531
|
+
* pass `100%` when their parent establishes an explicit height.
|
|
532
|
+
*/
|
|
533
|
+
height?: React__default.CSSProperties['height'];
|
|
529
534
|
/**
|
|
530
535
|
* When true, the canvas renders in read-only mode: pan/zoom/drag/inspect
|
|
531
536
|
* still work, but every IR-mutating affordance (save, delete, rename,
|
|
@@ -537,7 +542,7 @@ type AppProps = {
|
|
|
537
542
|
/** API token for registry access. */
|
|
538
543
|
apiToken?: string;
|
|
539
544
|
};
|
|
540
|
-
declare function App({ engine, hostBridge, readOnly, registryBaseUrl, apiToken, }: AppProps): react_jsx_runtime.JSX.Element;
|
|
545
|
+
declare function App({ engine, hostBridge, height, readOnly, registryBaseUrl, apiToken, }: AppProps): react_jsx_runtime.JSX.Element;
|
|
541
546
|
|
|
542
547
|
type Props$a = {
|
|
543
548
|
title: string;
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,11 @@ import { Toast as Toast2 } from "@lace-cloud/ui/feedback";
|
|
|
4
4
|
|
|
5
5
|
// src/App.tsx
|
|
6
6
|
import { ReactFlowProvider } from "@xyflow/react";
|
|
7
|
-
import { useCallback as useCallback21, useEffect as useEffect17, useState as useState24 } from "react";
|
|
7
|
+
import { useCallback as useCallback21, useEffect as useEffect17, useRef as useRef10, useState as useState24 } from "react";
|
|
8
8
|
|
|
9
9
|
// src/Canvas.tsx
|
|
10
|
-
import "
|
|
10
|
+
import "@xyflow/react/dist/style.css";
|
|
11
|
+
import "./Canvas-J6F7YHEK.css";
|
|
11
12
|
import { Toast } from "@lace-cloud/ui/feedback";
|
|
12
13
|
import {
|
|
13
14
|
applyEdgeChanges,
|
|
@@ -4092,6 +4093,7 @@ var nodeTypes = {
|
|
|
4092
4093
|
moduleNode: ModuleNode_default,
|
|
4093
4094
|
groupNode: GroupNode_default
|
|
4094
4095
|
};
|
|
4096
|
+
var FIT_VIEW_OPTIONS = { padding: 0.2, duration: 300 };
|
|
4095
4097
|
function CompositeEditor({
|
|
4096
4098
|
view,
|
|
4097
4099
|
readOnly,
|
|
@@ -4125,11 +4127,6 @@ function CompositeEditor({
|
|
|
4125
4127
|
const nodesInitialized = xyflowInitialized || view.nodes.length === 0;
|
|
4126
4128
|
const selectedIdsRef = useRef8([]);
|
|
4127
4129
|
const pendingSelectIdsRef = useRef8(null);
|
|
4128
|
-
useEffect15(() => {
|
|
4129
|
-
if (view.nodes.length > 0) {
|
|
4130
|
-
requestAnimationFrame(() => fitView({ padding: 0.2, duration: 300 }));
|
|
4131
|
-
}
|
|
4132
|
-
}, []);
|
|
4133
4130
|
useEffect15(() => {
|
|
4134
4131
|
registerGoToNode((nodeId) => {
|
|
4135
4132
|
const n = getNode(nodeId);
|
|
@@ -4154,8 +4151,8 @@ function CompositeEditor({
|
|
|
4154
4151
|
if (viewportIntent.kind === "fit-all") {
|
|
4155
4152
|
if (view.nodes.length > 0) {
|
|
4156
4153
|
fitView({
|
|
4157
|
-
padding: viewportIntent.padding ??
|
|
4158
|
-
duration: viewportIntent.duration ??
|
|
4154
|
+
padding: viewportIntent.padding ?? FIT_VIEW_OPTIONS.padding,
|
|
4155
|
+
duration: viewportIntent.duration ?? FIT_VIEW_OPTIONS.duration
|
|
4159
4156
|
});
|
|
4160
4157
|
}
|
|
4161
4158
|
return;
|
|
@@ -4175,7 +4172,7 @@ function CompositeEditor({
|
|
|
4175
4172
|
}
|
|
4176
4173
|
);
|
|
4177
4174
|
});
|
|
4178
|
-
}, [
|
|
4175
|
+
}, [viewportIntentSeq]);
|
|
4179
4176
|
const groupLogic = useGroupLogic(view.nodes, view.edges, view.groups, newNodeIds, erroredNodeIds);
|
|
4180
4177
|
const rfEdgesFromView = groupLogic.rfEdges;
|
|
4181
4178
|
const [rfEdges, setRfEdges] = useState23(rfEdgesFromView);
|
|
@@ -4331,7 +4328,15 @@ function CompositeEditor({
|
|
|
4331
4328
|
nodeColor: "var(--lace-color-accent)"
|
|
4332
4329
|
}
|
|
4333
4330
|
) : null,
|
|
4334
|
-
/* @__PURE__ */ jsx20(
|
|
4331
|
+
/* @__PURE__ */ jsx20(
|
|
4332
|
+
Controls,
|
|
4333
|
+
{
|
|
4334
|
+
position: "bottom-right",
|
|
4335
|
+
showInteractive: false,
|
|
4336
|
+
fitViewOptions: FIT_VIEW_OPTIONS,
|
|
4337
|
+
style: { bottom: 20, right: 20 }
|
|
4338
|
+
}
|
|
4339
|
+
),
|
|
4335
4340
|
/* @__PURE__ */ jsx20(
|
|
4336
4341
|
ActionBar,
|
|
4337
4342
|
{
|
|
@@ -4358,7 +4363,7 @@ function CompositeEditor({
|
|
|
4358
4363
|
}
|
|
4359
4364
|
);
|
|
4360
4365
|
}
|
|
4361
|
-
function Canvas({ registryBaseUrl, apiToken }
|
|
4366
|
+
function Canvas({ height, registryBaseUrl, apiToken }) {
|
|
4362
4367
|
const { state, readOnly, localGroupCollapseOverrides } = useCanvas();
|
|
4363
4368
|
const engine = useEngine();
|
|
4364
4369
|
const viewRef = useRef8(state.view);
|
|
@@ -4568,7 +4573,7 @@ function Canvas({ registryBaseUrl, apiToken } = {}) {
|
|
|
4568
4573
|
"div",
|
|
4569
4574
|
{
|
|
4570
4575
|
style: {
|
|
4571
|
-
height
|
|
4576
|
+
height,
|
|
4572
4577
|
display: "flex",
|
|
4573
4578
|
alignItems: "center",
|
|
4574
4579
|
justifyContent: "center",
|
|
@@ -4584,118 +4589,112 @@ function Canvas({ registryBaseUrl, apiToken } = {}) {
|
|
|
4584
4589
|
localGroupCollapseOverrides,
|
|
4585
4590
|
readOnly
|
|
4586
4591
|
);
|
|
4587
|
-
return /* @__PURE__ */ jsxs18(
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
nodeIds: erroredNodeIds,
|
|
4610
|
-
onGoToNode: (nodeId) => goToNodeRef.current?.(nodeId),
|
|
4611
|
-
onOpenFile: (relativePath, line, column) => window.dispatchEvent(
|
|
4612
|
-
new CustomEvent(CANVAS_EVENTS.OPEN_FILE, { detail: { relativePath, line, column } })
|
|
4613
|
-
),
|
|
4614
|
-
onDismiss: dismissErrorBanner
|
|
4615
|
-
}
|
|
4592
|
+
return /* @__PURE__ */ jsxs18("div", { style: { position: "relative", display: "flex", flexDirection: "column", height }, children: [
|
|
4593
|
+
/* @__PURE__ */ jsx20(Toast, { toast }),
|
|
4594
|
+
/* @__PURE__ */ jsx20(
|
|
4595
|
+
ContextMenu,
|
|
4596
|
+
{
|
|
4597
|
+
contextMenu,
|
|
4598
|
+
onCopy,
|
|
4599
|
+
onCut,
|
|
4600
|
+
onPaste,
|
|
4601
|
+
onGroupSelected,
|
|
4602
|
+
onUngroup,
|
|
4603
|
+
onDismiss: dismissContextMenu
|
|
4604
|
+
}
|
|
4605
|
+
),
|
|
4606
|
+
!errorBannerDismissed && validationErrors.length > 0 && !toast && /* @__PURE__ */ jsx20(
|
|
4607
|
+
ValidationErrorBanner,
|
|
4608
|
+
{
|
|
4609
|
+
diagnostics: validationErrors,
|
|
4610
|
+
nodeIds: erroredNodeIds,
|
|
4611
|
+
onGoToNode: (nodeId) => goToNodeRef.current?.(nodeId),
|
|
4612
|
+
onOpenFile: (relativePath, line, column) => window.dispatchEvent(
|
|
4613
|
+
new CustomEvent(CANVAS_EVENTS.OPEN_FILE, { detail: { relativePath, line, column } })
|
|
4616
4614
|
),
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
)
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
)
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4615
|
+
onDismiss: dismissErrorBanner
|
|
4616
|
+
}
|
|
4617
|
+
),
|
|
4618
|
+
/* @__PURE__ */ jsxs18("div", { style: { position: "relative", flex: "1 1 auto", minHeight: 0 }, children: [
|
|
4619
|
+
/* @__PURE__ */ jsx20(
|
|
4620
|
+
CompositeEditor,
|
|
4621
|
+
{
|
|
4622
|
+
view,
|
|
4623
|
+
readOnly,
|
|
4624
|
+
isGenerating: generating,
|
|
4625
|
+
erroredNodeIds,
|
|
4626
|
+
newNodeIds,
|
|
4627
|
+
forcePositionsRef,
|
|
4628
|
+
onDragStop,
|
|
4629
|
+
onConnect,
|
|
4630
|
+
onEdgeClick,
|
|
4631
|
+
onEdgesDelete,
|
|
4632
|
+
onNodesDelete,
|
|
4633
|
+
onSave,
|
|
4634
|
+
onUndo,
|
|
4635
|
+
onRedo,
|
|
4636
|
+
onClearGraph,
|
|
4637
|
+
onGenerate,
|
|
4638
|
+
onOpenSettings,
|
|
4639
|
+
onOpenPolicy: readOnly ? void 0 : onOpenPolicy,
|
|
4640
|
+
onOpenRegistry: canBrowseRegistry ? openRegistry : void 0,
|
|
4641
|
+
showMiniMap,
|
|
4642
|
+
onToggleMiniMap: toggleMiniMap,
|
|
4643
|
+
registerGoToNode,
|
|
4644
|
+
registerGetSelectedIds,
|
|
4645
|
+
registerSelectNodes,
|
|
4646
|
+
viewportIntent: state.viewportIntent,
|
|
4647
|
+
viewportIntentSeq: state.viewportIntentSeq
|
|
4648
|
+
}
|
|
4649
|
+
),
|
|
4650
|
+
/* @__PURE__ */ jsx20(SlidePanel, { open: !!configTarget, children: configTarget && /* @__PURE__ */ jsx20(
|
|
4651
|
+
ModuleConfigPanel,
|
|
4652
|
+
{
|
|
4653
|
+
instance_id: configTarget,
|
|
4654
|
+
engine,
|
|
4655
|
+
onClose: () => setConfigTarget(null),
|
|
4656
|
+
onModified: clearNew
|
|
4657
|
+
}
|
|
4658
|
+
) }),
|
|
4659
|
+
/* @__PURE__ */ jsx20(SlidePanel, { open: !!selectedEdge, zIndex: 40, children: selectedEdge && /* @__PURE__ */ jsx20(
|
|
4660
|
+
EdgeInspectorPanel,
|
|
4661
|
+
{
|
|
4662
|
+
source: selectedEdge.source,
|
|
4663
|
+
target: selectedEdge.target,
|
|
4664
|
+
sourceOutput: selectedEdge.sourceOutput,
|
|
4665
|
+
targetInput: selectedEdge.targetInput,
|
|
4666
|
+
onDelete: onDeleteSelectedEdge,
|
|
4667
|
+
onClose: clearSelectedEdge
|
|
4668
|
+
}
|
|
4669
|
+
) }),
|
|
4670
|
+
/* @__PURE__ */ jsx20(SlidePanel, { open: settingsOpen, children: settingsOpen && /* @__PURE__ */ jsx20(
|
|
4671
|
+
UnifiedSettingsPanel,
|
|
4672
|
+
{
|
|
4673
|
+
engine,
|
|
4674
|
+
onClose: () => setSettingsOpen(false),
|
|
4675
|
+
onSaved: () => showToast("Settings saved", "success")
|
|
4676
|
+
}
|
|
4677
|
+
) }),
|
|
4678
|
+
!readOnly && /* @__PURE__ */ jsx20(SlidePanel, { open: policyOpen, children: policyOpen && /* @__PURE__ */ jsx20(
|
|
4679
|
+
PolicySidebar,
|
|
4680
|
+
{
|
|
4681
|
+
resolution: policyResolution,
|
|
4682
|
+
onPreview: previewPolicy,
|
|
4683
|
+
onClose: () => setPolicyOpen(false)
|
|
4684
|
+
}
|
|
4685
|
+
) }),
|
|
4686
|
+
canBrowseRegistry && /* @__PURE__ */ jsx20(SlidePanel, { open: registryOpen, children: registryOpen && /* @__PURE__ */ jsx20(
|
|
4687
|
+
RegistryBrowser,
|
|
4688
|
+
{
|
|
4689
|
+
engine,
|
|
4690
|
+
registryBaseUrl,
|
|
4691
|
+
apiToken,
|
|
4692
|
+
showToast,
|
|
4693
|
+
onClose: closeRegistry
|
|
4694
|
+
}
|
|
4695
|
+
) })
|
|
4696
|
+
] })
|
|
4697
|
+
] });
|
|
4699
4698
|
}
|
|
4700
4699
|
|
|
4701
4700
|
// src/components/ErrorBoundary.tsx
|
|
@@ -4751,9 +4750,11 @@ function useWindowEvent(eventName, handler, options) {
|
|
|
4751
4750
|
|
|
4752
4751
|
// src/App.tsx
|
|
4753
4752
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
4753
|
+
var FIT_ALL_INTENT = { kind: "fit-all" };
|
|
4754
4754
|
function App({
|
|
4755
4755
|
engine,
|
|
4756
4756
|
hostBridge,
|
|
4757
|
+
height = "100vh",
|
|
4757
4758
|
readOnly = false,
|
|
4758
4759
|
registryBaseUrl,
|
|
4759
4760
|
apiToken
|
|
@@ -4769,15 +4770,20 @@ function App({
|
|
|
4769
4770
|
const toggleLocalGroupCollapse = useCallback21((groupId, currentCollapsed) => {
|
|
4770
4771
|
setLocalGroupCollapseOverrides((prev) => ({ ...prev, [groupId]: !currentCollapsed }));
|
|
4771
4772
|
}, []);
|
|
4773
|
+
const refitOnNextStateRef = useRef10(true);
|
|
4772
4774
|
useEffect17(() => {
|
|
4775
|
+
refitOnNextStateRef.current = true;
|
|
4773
4776
|
return engine.onEvent((event) => {
|
|
4774
4777
|
if (event.type === "stateUpdated") {
|
|
4778
|
+
const refit = refitOnNextStateRef.current;
|
|
4779
|
+
refitOnNextStateRef.current = false;
|
|
4780
|
+
const viewportIntent = event.viewportIntent ?? (refit ? FIT_ALL_INTENT : null);
|
|
4775
4781
|
setState((prev) => ({
|
|
4776
4782
|
view: event.view,
|
|
4777
4783
|
loading: false,
|
|
4778
4784
|
generation: prev.generation + 1,
|
|
4779
|
-
viewportIntent
|
|
4780
|
-
viewportIntentSeq: prev.viewportIntentSeq + (
|
|
4785
|
+
viewportIntent,
|
|
4786
|
+
viewportIntentSeq: prev.viewportIntentSeq + (viewportIntent ? 1 : 0)
|
|
4781
4787
|
}));
|
|
4782
4788
|
}
|
|
4783
4789
|
});
|
|
@@ -4809,7 +4815,7 @@ function App({
|
|
|
4809
4815
|
localGroupCollapseOverrides,
|
|
4810
4816
|
toggleLocalGroupCollapse
|
|
4811
4817
|
},
|
|
4812
|
-
children: /* @__PURE__ */ jsx22(ReactFlowProvider, { children: /* @__PURE__ */ jsx22(Canvas, { registryBaseUrl, apiToken }) })
|
|
4818
|
+
children: /* @__PURE__ */ jsx22(ReactFlowProvider, { children: /* @__PURE__ */ jsx22(Canvas, { height, registryBaseUrl, apiToken }) })
|
|
4813
4819
|
}
|
|
4814
4820
|
) });
|
|
4815
4821
|
}
|