@sqlrooms/canvas 0.29.0-rc.2 → 0.29.0-rc.3
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 +7 -2
- package/dist/Canvas.d.ts +3 -1
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/Canvas.js +6 -10
- package/dist/Canvas.js.map +1 -1
- package/dist/CanvasSlice.d.ts +9 -8
- package/dist/CanvasSlice.d.ts.map +1 -1
- package/dist/CanvasSlice.js +64 -63
- package/dist/CanvasSlice.js.map +1 -1
- package/dist/crdt.d.ts +5 -5
- package/dist/crdt.d.ts.map +1 -1
- package/dist/crdt.js +16 -16
- package/dist/crdt.js.map +1 -1
- package/dist/edgeUtils.d.ts +2 -2
- package/dist/edgeUtils.d.ts.map +1 -1
- package/dist/edgeUtils.js +3 -3
- package/dist/edgeUtils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nodes/AddNodePopover.d.ts +1 -0
- package/dist/nodes/AddNodePopover.d.ts.map +1 -1
- package/dist/nodes/AddNodePopover.js +4 -5
- package/dist/nodes/AddNodePopover.js.map +1 -1
- package/dist/nodes/CanvasNodeContainer.d.ts.map +1 -1
- package/dist/nodes/CanvasNodeContainer.js +2 -1
- package/dist/nodes/CanvasNodeContainer.js.map +1 -1
- package/package.json +8 -8
- package/dist/CanvasAssistantDrawer.d.ts +0 -3
- package/dist/CanvasAssistantDrawer.d.ts.map +0 -1
- package/dist/CanvasAssistantDrawer.js +0 -14
- package/dist/CanvasAssistantDrawer.js.map +0 -1
- package/dist/dag.d.ts +0 -53
- package/dist/dag.d.ts.map +0 -1
- package/dist/dag.js +0 -126
- package/dist/dag.js.map +0 -1
- package/dist/nodes/SqlNode.d.ts +0 -11
- package/dist/nodes/SqlNode.d.ts.map +0 -1
- package/dist/nodes/SqlNode.js +0 -52
- package/dist/nodes/SqlNode.js.map +0 -1
- package/dist/nodes/VegaNode.d.ts +0 -11
- package/dist/nodes/VegaNode.d.ts.map +0 -1
- package/dist/nodes/VegaNode.js +0 -12
- package/dist/nodes/VegaNode.js.map +0 -1
package/dist/crdt.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CanvasSliceConfig } from './CanvasSlice';
|
|
|
5
5
|
*/
|
|
6
6
|
export const canvasMirrorSchema = schema.LoroMap({
|
|
7
7
|
config: schema.LoroMap({
|
|
8
|
-
|
|
8
|
+
artifacts: schema.LoroList(schema.LoroMap({
|
|
9
9
|
id: schema.String(),
|
|
10
10
|
nodes: schema.LoroList(schema.LoroMap({
|
|
11
11
|
id: schema.String(),
|
|
@@ -20,7 +20,7 @@ export const canvasMirrorSchema = schema.LoroMap({
|
|
|
20
20
|
nodeOrder: schema.LoroList(schema.String()),
|
|
21
21
|
// viewport is kept local (unsynced)
|
|
22
22
|
}),
|
|
23
|
-
}), (
|
|
23
|
+
}), (artifact) => artifact.id),
|
|
24
24
|
}),
|
|
25
25
|
});
|
|
26
26
|
/**
|
|
@@ -28,7 +28,7 @@ export const canvasMirrorSchema = schema.LoroMap({
|
|
|
28
28
|
*/
|
|
29
29
|
export const canvasMirrorInitialState = {
|
|
30
30
|
config: {
|
|
31
|
-
|
|
31
|
+
artifacts: [],
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
@@ -40,11 +40,11 @@ export function createCanvasCrdtMirror() {
|
|
|
40
40
|
initialState: canvasMirrorInitialState,
|
|
41
41
|
select: (state) => ({
|
|
42
42
|
config: {
|
|
43
|
-
|
|
44
|
-
id:
|
|
45
|
-
nodes: Object.values(
|
|
43
|
+
artifacts: Object.values(state.canvas.config.artifacts).map((artifact) => ({
|
|
44
|
+
id: artifact.id,
|
|
45
|
+
nodes: Object.values(artifact.nodes),
|
|
46
46
|
meta: {
|
|
47
|
-
nodeOrder:
|
|
47
|
+
nodeOrder: artifact.meta.nodeOrder,
|
|
48
48
|
},
|
|
49
49
|
})),
|
|
50
50
|
},
|
|
@@ -53,19 +53,19 @@ export function createCanvasCrdtMirror() {
|
|
|
53
53
|
if (!value?.config)
|
|
54
54
|
return;
|
|
55
55
|
const currentConfig = get().canvas.config;
|
|
56
|
-
const
|
|
57
|
-
for (const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
id:
|
|
61
|
-
nodes: (
|
|
56
|
+
const newArtifacts = {};
|
|
57
|
+
for (const artifactValue of value.config.artifacts || []) {
|
|
58
|
+
const localArtifact = currentConfig.artifacts[artifactValue.id];
|
|
59
|
+
newArtifacts[artifactValue.id] = {
|
|
60
|
+
id: artifactValue.id,
|
|
61
|
+
nodes: (artifactValue.nodes || []).reduce((acc, node) => {
|
|
62
62
|
acc[node.id] = node;
|
|
63
63
|
return acc;
|
|
64
64
|
}, {}),
|
|
65
65
|
meta: {
|
|
66
|
-
...
|
|
66
|
+
...artifactValue.meta,
|
|
67
67
|
// Keep local viewport or use default
|
|
68
|
-
viewport:
|
|
68
|
+
viewport: localArtifact?.meta.viewport ?? { x: 0, y: 0, zoom: 1 },
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
}
|
|
@@ -75,7 +75,7 @@ export function createCanvasCrdtMirror() {
|
|
|
75
75
|
...state.canvas,
|
|
76
76
|
config: CanvasSliceConfig.parse({
|
|
77
77
|
...currentConfig,
|
|
78
|
-
|
|
78
|
+
artifacts: newArtifacts,
|
|
79
79
|
}),
|
|
80
80
|
},
|
|
81
81
|
}));
|
package/dist/crdt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crdt.js","sourceRoot":"","sources":["../src/crdt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAC,iBAAiB,EAAwB,MAAM,eAAe,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/C,MAAM,E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,GAAG,aAAa,CAAC,IAAI;wBACrB,qCAAqC;wBACrC,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC;qBAChE;iBACF,CAAC;YACJ,CAAC;YAED,GAAG,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,CAAC;gBACjB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,GAAG,KAAK,CAAC,MAAM;oBACf,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC;wBAC9B,GAAG,aAAa;wBAChB,SAAS,EAAE,YAAY;qBACxB,CAAC;iBACH;aACF,CAAC,CAAC,CAAC;QACN,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC","sourcesContent":["import {schema} from 'loro-mirror';\nimport type {CrdtMirror} from '@sqlrooms/crdt';\nimport {CanvasSliceConfig, type CanvasSliceState} from './CanvasSlice';\n\n/**\n * Mirror schema for syncing the `@sqlrooms/canvas` slice via `@sqlrooms/crdt`.\n */\nexport const canvasMirrorSchema = schema.LoroMap({\n config: schema.LoroMap({\n artifacts: schema.LoroList(\n schema.LoroMap({\n id: schema.String(),\n nodes: schema.LoroList(\n schema.LoroMap({\n id: schema.String(),\n position: schema.LoroMap({\n x: schema.Number(),\n y: schema.Number(),\n }),\n width: schema.Number(),\n height: schema.Number(),\n }),\n (node) => node.id,\n ),\n meta: schema.LoroMap({\n nodeOrder: schema.LoroList(schema.String()),\n // viewport is kept local (unsynced)\n }),\n }),\n (artifact) => artifact.id,\n ),\n }),\n});\n\nexport type CanvasMirrorSchema = typeof canvasMirrorSchema;\n\n/**\n * Default initial mirror state for the canvas CRDT schema.\n */\nexport const canvasMirrorInitialState = {\n config: {\n artifacts: [],\n },\n};\n\n/**\n * Creates a CRDT mirror bundle for the canvas slice.\n */\nexport function createCanvasCrdtMirror<\n S extends CanvasSliceState = CanvasSliceState,\n>(): CrdtMirror<S, typeof canvasMirrorSchema> {\n return {\n schema: canvasMirrorSchema,\n initialState: canvasMirrorInitialState,\n select: (state) => ({\n config: {\n artifacts: Object.values(state.canvas.config.artifacts).map(\n (artifact) => ({\n id: artifact.id,\n nodes: Object.values(artifact.nodes),\n meta: {\n nodeOrder: artifact.meta.nodeOrder,\n },\n }),\n ),\n },\n }),\n apply: (value, set, get) => {\n if (!value?.config) return;\n const currentConfig = get().canvas.config;\n\n const newArtifacts: Record<string, any> = {};\n for (const artifactValue of value.config.artifacts || []) {\n const localArtifact = currentConfig.artifacts[artifactValue.id];\n newArtifacts[artifactValue.id] = {\n id: artifactValue.id,\n nodes: (artifactValue.nodes || []).reduce(\n (acc: Record<string, any>, node: any) => {\n acc[node.id] = node;\n return acc;\n },\n {},\n ),\n meta: {\n ...artifactValue.meta,\n // Keep local viewport or use default\n viewport: localArtifact?.meta.viewport ?? {x: 0, y: 0, zoom: 1},\n },\n };\n }\n\n set((state: S) => ({\n ...state,\n canvas: {\n ...state.canvas,\n config: CanvasSliceConfig.parse({\n ...currentConfig,\n artifacts: newArtifacts,\n }),\n },\n }));\n },\n };\n}\n\n/**\n * @deprecated Use `createCanvasCrdtMirror` instead.\n */\nexport const createCanvasCrdtModule = createCanvasCrdtMirror;\n"]}
|
package/dist/edgeUtils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Edge, type
|
|
2
|
-
export declare function getRenderableEdges(
|
|
1
|
+
import { type Edge, type CellArtifactRuntime } from '@sqlrooms/cells';
|
|
2
|
+
export declare function getRenderableEdges(artifact: CellArtifactRuntime | undefined): Edge[];
|
|
3
3
|
//# sourceMappingURL=edgeUtils.d.ts.map
|
package/dist/edgeUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgeUtils.d.ts","sourceRoot":"","sources":["../src/edgeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,
|
|
1
|
+
{"version":3,"file":"edgeUtils.d.ts","sourceRoot":"","sources":["../src/edgeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GACxC,IAAI,EAAE,CAGR"}
|
package/dist/edgeUtils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRenderableDependencyEdges, } from '@sqlrooms/cells';
|
|
2
|
-
export function getRenderableEdges(
|
|
3
|
-
if (!
|
|
2
|
+
export function getRenderableEdges(artifact) {
|
|
3
|
+
if (!artifact)
|
|
4
4
|
return [];
|
|
5
|
-
return getRenderableDependencyEdges(
|
|
5
|
+
return getRenderableDependencyEdges(artifact);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=edgeUtils.js.map
|
package/dist/edgeUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgeUtils.js","sourceRoot":"","sources":["../src/edgeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,GAG7B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,UAAU,kBAAkB,
|
|
1
|
+
{"version":3,"file":"edgeUtils.js","sourceRoot":"","sources":["../src/edgeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,GAG7B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,UAAU,kBAAkB,CAChC,QAAyC;IAEzC,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,OAAO,4BAA4B,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import {\n getRenderableDependencyEdges,\n type Edge,\n type CellArtifactRuntime,\n} from '@sqlrooms/cells';\n\nexport function getRenderableEdges(\n artifact: CellArtifactRuntime | undefined,\n): Edge[] {\n if (!artifact) return [];\n return getRenderableDependencyEdges(artifact);\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { createCanvasSlice, createDefaultCanvasConfig } from './CanvasSlice';
|
|
6
6
|
export type { CanvasSliceState } from './CanvasSlice';
|
|
7
|
-
export { CanvasSliceConfig, CanvasNodeMeta,
|
|
7
|
+
export { CanvasSliceConfig, CanvasNodeMeta, CanvasArtifactMeta, } from './CanvasSlice';
|
|
8
8
|
export { Canvas } from './Canvas';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
5
|
export { createCanvasSlice, createDefaultCanvasConfig } from './CanvasSlice';
|
|
6
|
-
export { CanvasSliceConfig, CanvasNodeMeta,
|
|
6
|
+
export { CanvasSliceConfig, CanvasNodeMeta, CanvasArtifactMeta, } from './CanvasSlice';
|
|
7
7
|
export { Canvas } from './Canvas';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {createCanvasSlice, createDefaultCanvasConfig} from './CanvasSlice';\nexport type {CanvasSliceState} from './CanvasSlice';\nexport {\n CanvasSliceConfig,\n CanvasNodeMeta,\n CanvasArtifactMeta,\n} from './CanvasSlice';\nexport {Canvas} from './Canvas';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNodePopover.d.ts","sourceRoot":"","sources":["../../src/nodes/AddNodePopover.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAGtD,eAAO,MAAM,cAAc,EAAE,EAAE,CAC7B,iBAAiB,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,
|
|
1
|
+
{"version":3,"file":"AddNodePopover.d.ts","sourceRoot":"","sources":["../../src/nodes/AddNodePopover.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAGtD,eAAO,MAAM,cAAc,EAAE,EAAE,CAC7B,iBAAiB,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAiCH,CAAC"}
|
|
@@ -2,18 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button, cn, Popover, PopoverContent, PopoverTrigger, toast, } from '@sqlrooms/ui';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { useStoreWithCanvas } from '../CanvasSlice';
|
|
5
|
-
export const AddNodePopover = ({ className, parentId, children }) => {
|
|
5
|
+
export const AddNodePopover = ({ artifactId, className, parentId, children }) => {
|
|
6
6
|
const [open, setOpen] = useState(false);
|
|
7
7
|
const addNode = useStoreWithCanvas((s) => s.canvas.addNode);
|
|
8
|
-
const sheetId = useStoreWithCanvas((s) => s.cells.config.currentSheetId);
|
|
9
8
|
const registry = useStoreWithCanvas((s) => s.cells.cellRegistry);
|
|
10
9
|
const onAdd = (type) => {
|
|
11
|
-
if (
|
|
12
|
-
addNode({
|
|
10
|
+
if (artifactId) {
|
|
11
|
+
addNode({ artifactId, parentId, nodeType: type });
|
|
13
12
|
setOpen(false);
|
|
14
13
|
}
|
|
15
14
|
else {
|
|
16
|
-
toast.error('No
|
|
15
|
+
toast.error('No artifact selected');
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
18
|
return (_jsx("div", { className: cn(className), children: _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: children }), _jsx(PopoverContent, { side: "right", align: "center", className: "flex w-auto flex-col gap-2 p-2", children: Object.entries(registry).map(([type, reg]) => (_jsx(Button, { size: "xs", onClick: () => onAdd(type), children: reg.title }, type))) })] }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNodePopover.js","sourceRoot":"","sources":["../../src/nodes/AddNodePopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,EAAE,EACF,OAAO,EACP,cAAc,EACd,cAAc,EACd,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAAwB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"AddNodePopover.js","sourceRoot":"","sources":["../../src/nodes/AddNodePopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,EAAE,EACF,OAAO,EACP,cAAc,EACd,cAAc,EACd,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAAwB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAMvB,CAAC,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAC,EAAE,EAAE;IAClD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEjE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;QAC7B,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,EAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,YAC3B,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,aACxC,KAAC,cAAc,IAAC,OAAO,kBAAE,QAAQ,GAAkB,EACnD,KAAC,cAAc,IACb,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,QAAQ,EACd,SAAS,EAAC,gCAAgC,YAEzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAC7C,KAAC,MAAM,IAAY,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,YACpD,GAAG,CAAC,KAAK,IADC,IAAI,CAER,CACV,CAAC,GACa,IACT,GACN,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n Button,\n cn,\n Popover,\n PopoverContent,\n PopoverTrigger,\n toast,\n} from '@sqlrooms/ui';\nimport {FC, PropsWithChildren, useState} from 'react';\nimport {useStoreWithCanvas} from '../CanvasSlice';\n\nexport const AddNodePopover: FC<\n PropsWithChildren<{\n artifactId: string;\n className?: string;\n parentId?: string;\n }>\n> = ({artifactId, className, parentId, children}) => {\n const [open, setOpen] = useState(false);\n const addNode = useStoreWithCanvas((s) => s.canvas.addNode);\n const registry = useStoreWithCanvas((s) => s.cells.cellRegistry);\n\n const onAdd = (type: string) => {\n if (artifactId) {\n addNode({artifactId, parentId, nodeType: type});\n setOpen(false);\n } else {\n toast.error('No artifact selected');\n }\n };\n\n return (\n <div className={cn(className)}>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{children}</PopoverTrigger>\n <PopoverContent\n side=\"right\"\n align=\"center\"\n className=\"flex w-auto flex-col gap-2 p-2\"\n >\n {Object.entries(registry).map(([type, reg]) => (\n <Button key={type} size=\"xs\" onClick={() => onAdd(type)}>\n {reg.title}\n </Button>\n ))}\n </PopoverContent>\n </Popover>\n </div>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasNodeContainer.d.ts","sourceRoot":"","sources":["../../src/nodes/CanvasNodeContainer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAUpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAClC,iBAAiB,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC,
|
|
1
|
+
{"version":3,"file":"CanvasNodeContainer.d.ts","sourceRoot":"","sources":["../../src/nodes/CanvasNodeContainer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAUpE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAClC,iBAAiB,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC,CA2EH,CAAC"}
|
|
@@ -18,10 +18,11 @@ const PROMPT_PLACEHOLDER = {
|
|
|
18
18
|
export const CanvasNodeContainer = ({ id, className, headerRight, children }) => {
|
|
19
19
|
const renameNode = useStoreWithCanvas((s) => s.canvas.renameNode);
|
|
20
20
|
const cell = useStoreWithCanvas((s) => s.cells.config.data[id]);
|
|
21
|
+
const artifactId = useStoreWithCanvas((s) => s.cells.getArtifactIdForCell(id));
|
|
21
22
|
const title = cell?.data?.title;
|
|
22
23
|
const onTitleChange = useCallback(async (v) => {
|
|
23
24
|
await renameNode(id, v);
|
|
24
25
|
}, [id, renameNode]);
|
|
25
|
-
return (_jsxs("div", { className: cn(`bg-background relative flex h-full w-full rounded-md border shadow-sm`, className), children: [_jsx(NodeResizer, { minWidth: 200, minHeight: 200 }), _jsxs("div", { className: "flex h-full min-h-0 w-full flex-col items-center", children: [(title !== undefined || headerRight) && (_jsxs("div", { className: "flex w-full items-center justify-between gap-2 border-b px-3 py-2", children: [_jsx(EditableText, { className: "text-sm font-medium", value: title ?? '', onChange: (v) => onTitleChange?.(v) }), _jsx("div", { className: "flex items-center gap-2", children: headerRight })] })), _jsx("div", { className: "w-full flex-1 overflow-auto", children: children })] }), _jsx(AddNodePopover, { className: "absolute top-1/2 -right-10", parentId: id, children: _jsx(Button, { variant: "default", className: "h-8 w-8 -translate-y-1/2 rounded-full", title: "Add child node", children: _jsx(PlusIcon, { className: "h-4 w-4" }) }) }), _jsx(Handle, { type: "source", position: Position.Right }), _jsx(Handle, { type: "target", position: Position.Left })] }));
|
|
26
|
+
return (_jsxs("div", { className: cn(`bg-background relative flex h-full w-full rounded-md border shadow-sm`, className), children: [_jsx(NodeResizer, { minWidth: 200, minHeight: 200 }), _jsxs("div", { className: "flex h-full min-h-0 w-full flex-col items-center", children: [(title !== undefined || headerRight) && (_jsxs("div", { className: "flex w-full items-center justify-between gap-2 border-b px-3 py-2", children: [_jsx(EditableText, { className: "text-sm font-medium", value: title ?? '', onChange: (v) => onTitleChange?.(v) }), _jsx("div", { className: "flex items-center gap-2", children: headerRight })] })), _jsx("div", { className: "w-full flex-1 overflow-auto", children: children })] }), _jsx(AddNodePopover, { artifactId: artifactId ?? '', className: "absolute top-1/2 -right-10", parentId: id, children: _jsx(Button, { variant: "default", className: "h-8 w-8 -translate-y-1/2 rounded-full", title: "Add child node", children: _jsx(PlusIcon, { className: "h-4 w-4" }) }) }), _jsx(Handle, { type: "source", position: Position.Right }), _jsx(Handle, { type: "target", position: Position.Left })] }));
|
|
26
27
|
};
|
|
27
28
|
//# sourceMappingURL=CanvasNodeContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasNodeContainer.js","sourceRoot":"","sources":["../../src/nodes/CanvasNodeContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAmC,WAAW,EAAC,MAAM,OAAO,CAAC;AACpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,8CAA8C;IACnD,IAAI,EAAE,2CAA2C;IACjD,OAAO,EAAE,4BAA4B;CACtC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAO5B,CAAC,EAAC,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC7C,MAAM,UAAU,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CanvasNodeContainer.js","sourceRoot":"","sources":["../../src/nodes/CanvasNodeContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,EAAE,EA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AS,CACV,aAED,KAAC,WAAW,IAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAI,EAC9C,eAAK,SAAS,EAAC,kDAAkD,aAC9D,CAAC,KAAK,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,CACvC,eAAK,SAAS,EAAC,mEAAmE,aAChF,KAAC,YAAY,IACX,SAAS,EAAC,qBAAqB,EAC/B,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,GACnC,EACF,cAAK,SAAS,EAAC,yBAAyB,YAAE,WAAW,GAAO,IACxD,CACP,EAuBD,cAAK,SAAS,EAAC,6BAA6B,YAAE,QAAQ,GAAO,IACzD,EACN,KAAC,cAAc,IACb,UAAU,EAAE,UAAU,IAAI,EAAE,EAC5B,SAAS,EAAC,4BAA4B,EACtC,QAAQ,EAAE,EAAE,YAEZ,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,uCAAuC,EACjD,KAAK,EAAC,gBAAgB,YAEtB,KAAC,QAAQ,IAAC,SAAS,EAAC,SAAS,GAAG,GACzB,GACM,EACjB,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,GAAI,EAClD,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,GAAI,IAC7C,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, EditableText, cn} from '@sqlrooms/ui';\nimport {Handle, NodeResizer, Position} from '@xyflow/react';\nimport {PlusIcon} from 'lucide-react';\nimport {FC, PropsWithChildren, ReactNode, useCallback} from 'react';\nimport {useStoreWithCanvas} from '../CanvasSlice';\nimport {AddNodePopover} from './AddNodePopover';\n\nconst PROMPT_PLACEHOLDER = {\n sql: 'What would you like to learn about the data?',\n vega: 'How would you like to visualize the data?',\n default: 'What would you like to do?',\n};\n\n/**\n * Container applied to every canvas node. Provides resizing, connection handles,\n * and a standard \"add child\" affordance that creates downstream nodes.\n * Also renders an optional shared header with editable title and customizable right-side content.\n */\nexport const CanvasNodeContainer: FC<\n PropsWithChildren<{\n id: string;\n className?: string;\n /** Right-side header content (e.g. buttons, badges). */\n headerRight?: ReactNode;\n }>\n> = ({id, className, headerRight, children}) => {\n const renameNode = useStoreWithCanvas((s) => s.canvas.renameNode);\n const cell = useStoreWithCanvas((s) => s.cells.config.data[id]);\n const artifactId = useStoreWithCanvas((s) =>\n s.cells.getArtifactIdForCell(id),\n );\n\n const title = (cell?.data as any)?.title;\n const onTitleChange = useCallback(\n async (v: string) => {\n await renameNode(id, v);\n },\n [id, renameNode],\n );\n return (\n <div\n className={cn(\n `bg-background relative flex h-full w-full rounded-md border shadow-sm`,\n className,\n )}\n >\n <NodeResizer minWidth={200} minHeight={200} />\n <div className=\"flex h-full min-h-0 w-full flex-col items-center\">\n {(title !== undefined || headerRight) && (\n <div className=\"flex w-full items-center justify-between gap-2 border-b px-3 py-2\">\n <EditableText\n className=\"text-sm font-medium\"\n value={title ?? ''}\n onChange={(v) => onTitleChange?.(v)}\n />\n <div className=\"flex items-center gap-2\">{headerRight}</div>\n </div>\n )}\n {/* <Popover>\n <PopoverTrigger asChild>\n <Button\n variant=\"default\"\n className=\"h-8 w-8 -translate-y-1/2 rounded-full\"\n >\n <SparklesIcon className=\"h-4 w-4\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"max-h-[50vh] w-[400px] overflow-auto\">\n <QueryControls\n placeholder={`✨ ${\n PROMPT_PLACEHOLDER[\n (cell?.type ?? 'default') as keyof typeof PROMPT_PLACEHOLDER\n ]\n }`}\n onRun={() => {\n setAssistantOpen?.(true);\n }}\n />\n </PopoverContent>\n </Popover> */}\n <div className=\"w-full flex-1 overflow-auto\">{children}</div>\n </div>\n <AddNodePopover\n artifactId={artifactId ?? ''}\n className=\"absolute top-1/2 -right-10\"\n parentId={id}\n >\n <Button\n variant=\"default\"\n className=\"h-8 w-8 -translate-y-1/2 rounded-full\"\n title=\"Add child node\"\n >\n <PlusIcon className=\"h-4 w-4\" />\n </Button>\n </AddNodePopover>\n <Handle type=\"source\" position={Position.Right} />\n <Handle type=\"target\" position={Position.Left} />\n </div>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/canvas",
|
|
3
|
-
"version": "0.29.0-rc.
|
|
3
|
+
"version": "0.29.0-rc.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@paralleldrive/cuid2": "^3.0.0",
|
|
35
|
-
"@sqlrooms/cells": "0.29.0-rc.
|
|
36
|
-
"@sqlrooms/crdt": "0.29.0-rc.
|
|
37
|
-
"@sqlrooms/duckdb": "0.29.0-rc.
|
|
38
|
-
"@sqlrooms/room-store": "0.29.0-rc.
|
|
39
|
-
"@sqlrooms/ui": "0.29.0-rc.
|
|
40
|
-
"@sqlrooms/utils": "0.29.0-rc.
|
|
35
|
+
"@sqlrooms/cells": "0.29.0-rc.3",
|
|
36
|
+
"@sqlrooms/crdt": "0.29.0-rc.3",
|
|
37
|
+
"@sqlrooms/duckdb": "0.29.0-rc.3",
|
|
38
|
+
"@sqlrooms/room-store": "0.29.0-rc.3",
|
|
39
|
+
"@sqlrooms/ui": "0.29.0-rc.3",
|
|
40
|
+
"@sqlrooms/utils": "0.29.0-rc.3",
|
|
41
41
|
"@xyflow/react": "^12.8.5",
|
|
42
42
|
"immer": "^11.0.1",
|
|
43
43
|
"loro-mirror": "^1.1.2",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"typecheck": "tsc --noEmit",
|
|
56
56
|
"typedoc": "typedoc"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4ffaf6c31d41c27f96bd3e4f5e83d431968721c3"
|
|
59
59
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasAssistantDrawer.d.ts","sourceRoot":"","sources":["../src/CanvasAssistantDrawer.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAGzB,eAAO,MAAM,qBAAqB,EAAE,EAiDnC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Chat } from '@sqlrooms/ai';
|
|
3
|
-
import { Button, Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from '@sqlrooms/ui';
|
|
4
|
-
import { SparklesIcon, XIcon } from 'lucide-react';
|
|
5
|
-
import { useStoreWithCanvas } from './CanvasSlice';
|
|
6
|
-
export const CanvasAssistantDrawer = () => {
|
|
7
|
-
const isAssistantOpen = useStoreWithCanvas((state) => state.canvas.isAssistantOpen);
|
|
8
|
-
const setAssistantOpen = useStoreWithCanvas((state) => state.canvas.setAssistantOpen);
|
|
9
|
-
return (_jsxs(Drawer, { direction: "right", open: isAssistantOpen, onOpenChange: setAssistantOpen, children: [_jsx(DrawerTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "absolute right-4 top-4 z-10 h-8 w-8 rounded-full", children: _jsx(SparklesIcon, { className: "h-4 w-4" }) }) }), _jsx(DrawerContent, { className: "border-none bg-transparent p-4 outline-none", style: {
|
|
10
|
-
width: 500,
|
|
11
|
-
maxWidth: '50%',
|
|
12
|
-
}, "data-vaul-drawer-direction": "right", overlayClassName: "bg-transparent", children: _jsx("div", { className: "border-border bg-background relative mx-auto flex h-full w-full flex-col gap-0 overflow-hidden rounded-md border", children: _jsxs(Chat, { children: [_jsxs(DrawerHeader, { children: [_jsx(DrawerTitle, { children: "Assistant" }), _jsx(DrawerClose, { asChild: true, className: "absolute right-2 top-2", children: _jsx(Button, { variant: "ghost", size: "xs", children: _jsx(XIcon, { className: "h-4 w-4" }) }) })] }), _jsx(Chat.Messages, { className: "flex-grow overflow-auto px-4" }), _jsx(DrawerFooter, { children: _jsx(Chat.Composer, { placeholder: "What would you like to do?" }) })] }) }) })] }));
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=CanvasAssistantDrawer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasAssistantDrawer.js","sourceRoot":"","sources":["../src/CanvasAssistantDrawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,YAAY,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAO,GAAG,EAAE;IAC5C,MAAM,eAAe,GAAG,kBAAkB,CACxC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CACxC,CAAC;IACF,MAAM,gBAAgB,GAAG,kBAAkB,CACzC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CACzC,CAAC;IACF,OAAO,CACL,MAAC,MAAM,IACL,SAAS,EAAC,OAAO,EACjB,IAAI,EAAE,eAAe,EACrB,YAAY,EAAE,gBAAgB,aAE9B,KAAC,aAAa,IAAC,OAAO,kBACpB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,kDAAkD,YAE5D,KAAC,YAAY,IAAC,SAAS,EAAC,SAAS,GAAG,GAC7B,GACK,EAChB,KAAC,aAAa,IACZ,SAAS,EAAC,6CAA6C,EACvD,KAAK,EAAE;oBACL,KAAK,EAAE,GAAG;oBACV,QAAQ,EAAE,KAAK;iBAChB,gCAC0B,OAAO,EAClC,gBAAgB,EAAC,gBAAgB,YAEjC,cAAK,SAAS,EAAC,kHAAkH,YAC/H,MAAC,IAAI,eACH,MAAC,YAAY,eACX,KAAC,WAAW,4BAAwB,EACpC,KAAC,WAAW,IAAC,OAAO,QAAC,SAAS,EAAC,wBAAwB,YACrD,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,YAC/B,KAAC,KAAK,IAAC,SAAS,EAAC,SAAS,GAAG,GACtB,GACG,IACD,EACf,KAAC,IAAI,CAAC,QAAQ,IAAC,SAAS,EAAC,8BAA8B,GAAG,EAC1D,KAAC,YAAY,cACX,KAAC,IAAI,CAAC,QAAQ,IAAC,WAAW,EAAC,4BAA4B,GAAG,GAC7C,IACV,GACH,GACQ,IACT,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Chat} from '@sqlrooms/ai';\nimport {\n Button,\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerFooter,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from '@sqlrooms/ui';\nimport {SparklesIcon, XIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {useStoreWithCanvas} from './CanvasSlice';\n\nexport const CanvasAssistantDrawer: FC = () => {\n const isAssistantOpen = useStoreWithCanvas(\n (state) => state.canvas.isAssistantOpen,\n );\n const setAssistantOpen = useStoreWithCanvas(\n (state) => state.canvas.setAssistantOpen,\n );\n return (\n <Drawer\n direction=\"right\"\n open={isAssistantOpen}\n onOpenChange={setAssistantOpen}\n >\n <DrawerTrigger asChild>\n <Button\n variant=\"default\"\n className=\"absolute right-4 top-4 z-10 h-8 w-8 rounded-full\"\n >\n <SparklesIcon className=\"h-4 w-4\" />\n </Button>\n </DrawerTrigger>\n <DrawerContent\n className=\"border-none bg-transparent p-4 outline-none\"\n style={{\n width: 500,\n maxWidth: '50%',\n }}\n data-vaul-drawer-direction=\"right\"\n overlayClassName=\"bg-transparent\"\n >\n <div className=\"border-border bg-background relative mx-auto flex h-full w-full flex-col gap-0 overflow-hidden rounded-md border\">\n <Chat>\n <DrawerHeader>\n <DrawerTitle>Assistant</DrawerTitle>\n <DrawerClose asChild className=\"absolute right-2 top-2\">\n <Button variant=\"ghost\" size=\"xs\">\n <XIcon className=\"h-4 w-4\" />\n </Button>\n </DrawerClose>\n </DrawerHeader>\n <Chat.Messages className=\"flex-grow overflow-auto px-4\" />\n <DrawerFooter>\n <Chat.Composer placeholder=\"What would you like to do?\" />\n </DrawerFooter>\n </Chat>\n </div>\n </DrawerContent>\n </Drawer>\n );\n};\n"]}
|
package/dist/dag.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** A minimal graph node with an `id`. */
|
|
2
|
-
export type DagNode = {
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
/** A directed edge from `source` to `target`. */
|
|
6
|
-
export type DagEdge = {
|
|
7
|
-
source: string;
|
|
8
|
-
target: string;
|
|
9
|
-
};
|
|
10
|
-
/** Forward adjacency list mapping node id to its child node ids. */
|
|
11
|
-
export type Adjacency = Record<string, string[]>;
|
|
12
|
-
/**
|
|
13
|
-
* Build a forward adjacency list for a directed graph.
|
|
14
|
-
* Ensures that every node id exists in the adjacency map, even if it has no outgoing edges.
|
|
15
|
-
*
|
|
16
|
-
* @param nodes - The set of nodes to include in the graph.
|
|
17
|
-
* @param edges - Directed edges where `source` points to `target`.
|
|
18
|
-
* @returns A mapping from node id to an array of child node ids.
|
|
19
|
-
*/
|
|
20
|
-
export declare function buildAdjacency(nodes: DagNode[], edges: DagEdge[]): Adjacency;
|
|
21
|
-
/**
|
|
22
|
-
* Find a node by id in a list of nodes.
|
|
23
|
-
*
|
|
24
|
-
* @param nodes - Array of nodes with an `id` field.
|
|
25
|
-
* @param id - The node id to find.
|
|
26
|
-
* @returns The node if found, otherwise undefined.
|
|
27
|
-
*/
|
|
28
|
-
export declare function findNodeById<T extends {
|
|
29
|
-
id: string;
|
|
30
|
-
}>(nodes: T[], id: string): T | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Topologically sort all nodes in the graph using Kahn's algorithm.
|
|
33
|
-
* If a cycle is detected, the remaining nodes are appended in arbitrary order,
|
|
34
|
-
* and a warning is logged.
|
|
35
|
-
*
|
|
36
|
-
* @param nodes - The set of nodes to sort.
|
|
37
|
-
* @param edges - Directed edges defining dependencies.
|
|
38
|
-
* @returns An array of node ids in dependency order (parents before children).
|
|
39
|
-
*/
|
|
40
|
-
export declare function topoSortAll(nodes: DagNode[], edges: DagEdge[]): string[];
|
|
41
|
-
/**
|
|
42
|
-
* Get a topological order for the downstream subgraph reachable from `startId`.
|
|
43
|
-
* Only nodes reachable from the start are included (the starting node is excluded).
|
|
44
|
-
* If a cycle exists within the reachable subgraph, the remaining nodes are appended
|
|
45
|
-
* at the end in arbitrary order and a warning is logged.
|
|
46
|
-
*
|
|
47
|
-
* @param startId - The node id to start traversal from.
|
|
48
|
-
* @param nodes - The set of nodes in the full graph.
|
|
49
|
-
* @param edges - Directed edges defining the full graph dependencies.
|
|
50
|
-
* @returns Node ids reachable from `startId`, in dependency order.
|
|
51
|
-
*/
|
|
52
|
-
export declare function topoSortDownstream(startId: string, nodes: DagNode[], edges: DagEdge[]): string[];
|
|
53
|
-
//# sourceMappingURL=dag.d.ts.map
|
package/dist/dag.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag.d.ts","sourceRoot":"","sources":["../src/dag.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,MAAM,OAAO,GAAG;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,CAAC;AACnC,iDAAiD;AACjD,MAAM,MAAM,OAAO,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AACvD,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,SAAS,CAQ5E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,EACjD,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,MAAM,GACT,CAAC,GAAG,SAAS,CAEf;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAkCxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EAAE,EAChB,KAAK,EAAE,OAAO,EAAE,GACf,MAAM,EAAE,CA8CV"}
|
package/dist/dag.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a forward adjacency list for a directed graph.
|
|
3
|
-
* Ensures that every node id exists in the adjacency map, even if it has no outgoing edges.
|
|
4
|
-
*
|
|
5
|
-
* @param nodes - The set of nodes to include in the graph.
|
|
6
|
-
* @param edges - Directed edges where `source` points to `target`.
|
|
7
|
-
* @returns A mapping from node id to an array of child node ids.
|
|
8
|
-
*/
|
|
9
|
-
export function buildAdjacency(nodes, edges) {
|
|
10
|
-
const adjacency = {};
|
|
11
|
-
for (const n of nodes)
|
|
12
|
-
adjacency[n.id] = [];
|
|
13
|
-
for (const e of edges) {
|
|
14
|
-
const list = adjacency[e.source] || (adjacency[e.source] = []);
|
|
15
|
-
list.push(e.target);
|
|
16
|
-
}
|
|
17
|
-
return adjacency;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Find a node by id in a list of nodes.
|
|
21
|
-
*
|
|
22
|
-
* @param nodes - Array of nodes with an `id` field.
|
|
23
|
-
* @param id - The node id to find.
|
|
24
|
-
* @returns The node if found, otherwise undefined.
|
|
25
|
-
*/
|
|
26
|
-
export function findNodeById(nodes, id) {
|
|
27
|
-
return nodes.find((n) => n.id === id);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Topologically sort all nodes in the graph using Kahn's algorithm.
|
|
31
|
-
* If a cycle is detected, the remaining nodes are appended in arbitrary order,
|
|
32
|
-
* and a warning is logged.
|
|
33
|
-
*
|
|
34
|
-
* @param nodes - The set of nodes to sort.
|
|
35
|
-
* @param edges - Directed edges defining dependencies.
|
|
36
|
-
* @returns An array of node ids in dependency order (parents before children).
|
|
37
|
-
*/
|
|
38
|
-
export function topoSortAll(nodes, edges) {
|
|
39
|
-
const adjacency = buildAdjacency(nodes, edges);
|
|
40
|
-
const inDegree = {};
|
|
41
|
-
for (const n of nodes)
|
|
42
|
-
inDegree[n.id] = 0;
|
|
43
|
-
for (const e of edges) {
|
|
44
|
-
inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;
|
|
45
|
-
}
|
|
46
|
-
const queue = Object.keys(inDegree).filter((id) => (inDegree[id] ?? 0) === 0);
|
|
47
|
-
const order = [];
|
|
48
|
-
while (queue.length) {
|
|
49
|
-
const cur = queue.shift();
|
|
50
|
-
order.push(cur);
|
|
51
|
-
const neighbors = adjacency[cur] || [];
|
|
52
|
-
for (const nb of neighbors) {
|
|
53
|
-
inDegree[nb] = (inDegree[nb] ?? 0) - 1;
|
|
54
|
-
if (inDegree[nb] === 0)
|
|
55
|
-
queue.push(nb);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (order.length < nodes.length) {
|
|
59
|
-
const remaining = nodes
|
|
60
|
-
.map((n) => n.id)
|
|
61
|
-
.filter((id) => !order.includes(id));
|
|
62
|
-
// eslint-disable-next-line no-console
|
|
63
|
-
console.warn('[dag.topoSortAll] Cycle detected; appending remaining nodes arbitrarily:', remaining);
|
|
64
|
-
order.push(...remaining);
|
|
65
|
-
}
|
|
66
|
-
return order;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get a topological order for the downstream subgraph reachable from `startId`.
|
|
70
|
-
* Only nodes reachable from the start are included (the starting node is excluded).
|
|
71
|
-
* If a cycle exists within the reachable subgraph, the remaining nodes are appended
|
|
72
|
-
* at the end in arbitrary order and a warning is logged.
|
|
73
|
-
*
|
|
74
|
-
* @param startId - The node id to start traversal from.
|
|
75
|
-
* @param nodes - The set of nodes in the full graph.
|
|
76
|
-
* @param edges - Directed edges defining the full graph dependencies.
|
|
77
|
-
* @returns Node ids reachable from `startId`, in dependency order.
|
|
78
|
-
*/
|
|
79
|
-
export function topoSortDownstream(startId, nodes, edges) {
|
|
80
|
-
const adjacency = buildAdjacency(nodes, edges);
|
|
81
|
-
// Collect reachable nodes from startId (excluding start)
|
|
82
|
-
const reachable = new Set();
|
|
83
|
-
const queue = [...(adjacency[startId] || [])];
|
|
84
|
-
while (queue.length) {
|
|
85
|
-
const cur = queue.shift();
|
|
86
|
-
if (reachable.has(cur))
|
|
87
|
-
continue;
|
|
88
|
-
reachable.add(cur);
|
|
89
|
-
const neighbors = adjacency[cur] || [];
|
|
90
|
-
for (const nb of neighbors)
|
|
91
|
-
queue.push(nb);
|
|
92
|
-
}
|
|
93
|
-
if (reachable.size === 0)
|
|
94
|
-
return [];
|
|
95
|
-
// Kahn's algorithm for topological sort within subgraph
|
|
96
|
-
const inDegree = {};
|
|
97
|
-
for (const id of reachable)
|
|
98
|
-
inDegree[id] = 0;
|
|
99
|
-
for (const e of edges) {
|
|
100
|
-
if (reachable.has(e.source) && reachable.has(e.target)) {
|
|
101
|
-
inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const queue2 = Array.from(reachable).filter((id) => (inDegree[id] ?? 0) === 0);
|
|
105
|
-
const order = [];
|
|
106
|
-
while (queue2.length) {
|
|
107
|
-
const cur = queue2.shift();
|
|
108
|
-
order.push(cur);
|
|
109
|
-
const neighbors = adjacency[cur] || [];
|
|
110
|
-
for (const nb of neighbors) {
|
|
111
|
-
if (!reachable.has(nb))
|
|
112
|
-
continue;
|
|
113
|
-
inDegree[nb] = (inDegree[nb] ?? 0) - 1;
|
|
114
|
-
if (inDegree[nb] === 0)
|
|
115
|
-
queue2.push(nb);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (order.length < reachable.size) {
|
|
119
|
-
const remaining = Array.from(reachable).filter((id) => !order.includes(id));
|
|
120
|
-
// eslint-disable-next-line no-console
|
|
121
|
-
console.warn('[dag.topoSortDownstream] Cycle detected in downstream graph:', remaining);
|
|
122
|
-
order.push(...remaining);
|
|
123
|
-
}
|
|
124
|
-
return order;
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=dag.js.map
|
package/dist/dag.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag.js","sourceRoot":"","sources":["../src/dag.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgB,EAAE,KAAgB;IAC/D,MAAM,SAAS,GAAc,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;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CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5E,sCAAsC;QACtC,OAAO,CAAC,IAAI,CACV,8DAA8D,EAC9D,SAAS,CACV,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/** A minimal graph node with an `id`. */\nexport type DagNode = {id: string};\n/** A directed edge from `source` to `target`. */\nexport type DagEdge = {source: string; target: string};\n/** Forward adjacency list mapping node id to its child node ids. */\nexport type Adjacency = Record<string, string[]>;\n\n/**\n * Build a forward adjacency list for a directed graph.\n * Ensures that every node id exists in the adjacency map, even if it has no outgoing edges.\n *\n * @param nodes - The set of nodes to include in the graph.\n * @param edges - Directed edges where `source` points to `target`.\n * @returns A mapping from node id to an array of child node ids.\n */\nexport function buildAdjacency(nodes: DagNode[], edges: DagEdge[]): Adjacency {\n const adjacency: Adjacency = {};\n for (const n of nodes) adjacency[n.id] = [];\n for (const e of edges) {\n const list = adjacency[e.source] || (adjacency[e.source] = []);\n list.push(e.target);\n }\n return adjacency;\n}\n\n/**\n * Find a node by id in a list of nodes.\n *\n * @param nodes - Array of nodes with an `id` field.\n * @param id - The node id to find.\n * @returns The node if found, otherwise undefined.\n */\nexport function findNodeById<T extends {id: string}>(\n nodes: T[],\n id: string,\n): T | undefined {\n return nodes.find((n) => n.id === id);\n}\n\n/**\n * Topologically sort all nodes in the graph using Kahn's algorithm.\n * If a cycle is detected, the remaining nodes are appended in arbitrary order,\n * and a warning is logged.\n *\n * @param nodes - The set of nodes to sort.\n * @param edges - Directed edges defining dependencies.\n * @returns An array of node ids in dependency order (parents before children).\n */\nexport function topoSortAll(nodes: DagNode[], edges: DagEdge[]): string[] {\n const adjacency = buildAdjacency(nodes, edges);\n const inDegree: Record<string, number> = {};\n for (const n of nodes) inDegree[n.id] = 0;\n for (const e of edges) {\n inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;\n }\n\n const queue: string[] = Object.keys(inDegree).filter(\n (id) => (inDegree[id] ?? 0) === 0,\n );\n const order: string[] = [];\n while (queue.length) {\n const cur = queue.shift() as string;\n order.push(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) {\n inDegree[nb] = (inDegree[nb] ?? 0) - 1;\n if (inDegree[nb] === 0) queue.push(nb);\n }\n }\n\n if (order.length < nodes.length) {\n const remaining = nodes\n .map((n) => n.id)\n .filter((id) => !order.includes(id));\n // eslint-disable-next-line no-console\n console.warn(\n '[dag.topoSortAll] Cycle detected; appending remaining nodes arbitrarily:',\n remaining,\n );\n order.push(...remaining);\n }\n return order;\n}\n\n/**\n * Get a topological order for the downstream subgraph reachable from `startId`.\n * Only nodes reachable from the start are included (the starting node is excluded).\n * If a cycle exists within the reachable subgraph, the remaining nodes are appended\n * at the end in arbitrary order and a warning is logged.\n *\n * @param startId - The node id to start traversal from.\n * @param nodes - The set of nodes in the full graph.\n * @param edges - Directed edges defining the full graph dependencies.\n * @returns Node ids reachable from `startId`, in dependency order.\n */\nexport function topoSortDownstream(\n startId: string,\n nodes: DagNode[],\n edges: DagEdge[],\n): string[] {\n const adjacency = buildAdjacency(nodes, edges);\n // Collect reachable nodes from startId (excluding start)\n const reachable = new Set<string>();\n const queue: string[] = [...(adjacency[startId] || [])];\n while (queue.length) {\n const cur = queue.shift() as string;\n if (reachable.has(cur)) continue;\n reachable.add(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) queue.push(nb);\n }\n if (reachable.size === 0) return [];\n\n // Kahn's algorithm for topological sort within subgraph\n const inDegree: Record<string, number> = {};\n for (const id of reachable) inDegree[id] = 0;\n for (const e of edges) {\n if (reachable.has(e.source) && reachable.has(e.target)) {\n inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;\n }\n }\n const queue2: string[] = Array.from(reachable).filter(\n (id) => (inDegree[id] ?? 0) === 0,\n );\n const order: string[] = [];\n while (queue2.length) {\n const cur = queue2.shift() as string;\n order.push(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) {\n if (!reachable.has(nb)) continue;\n inDegree[nb] = (inDegree[nb] ?? 0) - 1;\n if (inDegree[nb] === 0) queue2.push(nb);\n }\n }\n if (order.length < reachable.size) {\n const remaining = Array.from(reachable).filter((id) => !order.includes(id));\n // eslint-disable-next-line no-console\n console.warn(\n '[dag.topoSortDownstream] Cycle detected in downstream graph:',\n remaining,\n );\n order.push(...remaining);\n }\n return order;\n}\n"]}
|
package/dist/nodes/SqlNode.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { CanvasNodeData } from '../CanvasSlice';
|
|
3
|
-
type SqlData = Extract<CanvasNodeData, {
|
|
4
|
-
type: 'sql';
|
|
5
|
-
}>;
|
|
6
|
-
export declare const SqlNode: FC<{
|
|
7
|
-
id: string;
|
|
8
|
-
data: SqlData;
|
|
9
|
-
}>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=SqlNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlNode.d.ts","sourceRoot":"","sources":["../../src/nodes/SqlNode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAoB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAC,cAAc,EAAqB,MAAM,gBAAgB,CAAC;AAelE,KAAK,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE;IAAC,IAAI,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAC,CAgGnD,CAAC"}
|