@dxos/react-ui-canvas-compute 0.8.2-staging.7ac8446 → 0.8.3-main.672df60
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/lib/browser/index.mjs +1022 -836
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1040 -854
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1022 -836
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +2 -18
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +18 -18
- package/dist/types/src/json.test.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +19 -19
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +19 -19
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +19 -19
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +19 -19
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +70 -70
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +19 -19
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +20 -20
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +19 -19
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +19 -19
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +19 -19
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +19 -19
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +37 -37
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +37 -37
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +19 -19
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +21 -21
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +19 -19
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +19 -19
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +19 -19
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +19 -19
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +20 -20
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +19 -19
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +19 -19
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +19 -19
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +47 -45
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +5 -5
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +18 -19
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -40
- package/src/compute.stories.tsx +3 -3
- package/src/graph/controller.ts +12 -12
- package/src/hooks/useComputeNodeState.ts +3 -3
- package/src/hooks/useGraphMonitor.ts +3 -5
- package/src/json.test.ts +10 -10
- package/src/schema.test.ts +7 -7
- package/src/shapes/Append.tsx +5 -5
- package/src/shapes/Array.tsx +5 -5
- package/src/shapes/Audio.tsx +5 -5
- package/src/shapes/Beacon.tsx +5 -5
- package/src/shapes/Boolean.tsx +5 -5
- package/src/shapes/Chat.tsx +5 -5
- package/src/shapes/Constant.tsx +6 -6
- package/src/shapes/Database.tsx +5 -5
- package/src/shapes/Function.tsx +8 -7
- package/src/shapes/Gpt.tsx +6 -6
- package/src/shapes/GptRealtime.tsx +8 -8
- package/src/shapes/Json.tsx +9 -9
- package/src/shapes/Logic.tsx +9 -9
- package/src/shapes/Queue.tsx +5 -5
- package/src/shapes/RNG.tsx +7 -7
- package/src/shapes/Scope.tsx +5 -5
- package/src/shapes/Surface.tsx +5 -5
- package/src/shapes/Switch.tsx +5 -5
- package/src/shapes/Table.tsx +6 -6
- package/src/shapes/Template.tsx +8 -7
- package/src/shapes/Text.tsx +5 -5
- package/src/shapes/TextToImage.tsx +5 -5
- package/src/shapes/Thread.tsx +6 -6
- package/src/shapes/Trigger.tsx +32 -33
- package/src/shapes/common/FunctionBody.tsx +11 -9
- package/src/shapes/defs.ts +9 -9
|
@@ -142,8 +142,8 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts
|
|
145
|
+
import { Schema } from "effect";
|
|
145
146
|
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
146
|
-
import { S } from "@dxos/echo-schema";
|
|
147
147
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
148
148
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
149
149
|
var useComputeNodeState = (shape) => {
|
|
@@ -200,8 +200,8 @@ var useComputeNodeState = (shape) => {
|
|
|
200
200
|
return {
|
|
201
201
|
node: controller.getComputeNode(shape.node),
|
|
202
202
|
meta: meta ?? {
|
|
203
|
-
input:
|
|
204
|
-
output:
|
|
203
|
+
input: Schema.Struct({}),
|
|
204
|
+
output: Schema.Struct({})
|
|
205
205
|
},
|
|
206
206
|
runtime: {
|
|
207
207
|
inputs: controller.getInputs(shape.node),
|
|
@@ -218,9 +218,8 @@ var useComputeNodeState = (shape) => {
|
|
|
218
218
|
// packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts
|
|
219
219
|
import { useMemo } from "react";
|
|
220
220
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
221
|
-
import { ObjectId as ObjectId2 } from "@dxos/echo-schema";
|
|
221
|
+
import { ObjectId as ObjectId2, Ref } from "@dxos/echo-schema";
|
|
222
222
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
223
|
-
import { DXN } from "@dxos/keys";
|
|
224
223
|
import { getSpace } from "@dxos/react-client/echo";
|
|
225
224
|
import { isNonNullable } from "@dxos/util";
|
|
226
225
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
@@ -229,7 +228,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
229
228
|
const targetNode = graph.findNode(target);
|
|
230
229
|
invariant3(sourceNode?.node, void 0, {
|
|
231
230
|
F: __dxlog_file3,
|
|
232
|
-
L:
|
|
231
|
+
L: 26,
|
|
233
232
|
S: void 0,
|
|
234
233
|
A: [
|
|
235
234
|
"sourceNode?.node",
|
|
@@ -238,7 +237,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
238
237
|
});
|
|
239
238
|
invariant3(targetNode?.node, void 0, {
|
|
240
239
|
F: __dxlog_file3,
|
|
241
|
-
L:
|
|
240
|
+
L: 27,
|
|
242
241
|
S: void 0,
|
|
243
242
|
A: [
|
|
244
243
|
"targetNode?.node",
|
|
@@ -262,7 +261,7 @@ var useGraphMonitor = (model) => {
|
|
|
262
261
|
}
|
|
263
262
|
invariant3(node.type, void 0, {
|
|
264
263
|
F: __dxlog_file3,
|
|
265
|
-
L:
|
|
264
|
+
L: 52,
|
|
266
265
|
S: void 0,
|
|
267
266
|
A: [
|
|
268
267
|
"node.type",
|
|
@@ -320,16 +319,15 @@ var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
|
320
319
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
321
320
|
invariant3(functionTrigger, void 0, {
|
|
322
321
|
F: __dxlog_file3,
|
|
323
|
-
L:
|
|
322
|
+
L: 115,
|
|
324
323
|
S: void 0,
|
|
325
324
|
A: [
|
|
326
325
|
"functionTrigger",
|
|
327
326
|
""
|
|
328
327
|
]
|
|
329
328
|
});
|
|
330
|
-
functionTrigger.function =
|
|
331
|
-
functionTrigger.
|
|
332
|
-
functionTrigger.meta.computeNodeId = computeNode.id;
|
|
329
|
+
functionTrigger.function = Ref.make(graph.root);
|
|
330
|
+
functionTrigger.inputNodeId = computeNode.id;
|
|
333
331
|
};
|
|
334
332
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
335
333
|
const space = getSpace(computeGraph.root);
|
|
@@ -369,19 +367,9 @@ var createComputeGraphController = (graph, services) => {
|
|
|
369
367
|
};
|
|
370
368
|
var ComputeGraphController = class extends Resource {
|
|
371
369
|
constructor(_graph) {
|
|
372
|
-
super()
|
|
373
|
-
this._graph = _graph;
|
|
374
|
-
this._executor = new GraphExecutor({
|
|
370
|
+
super(), this._graph = _graph, this._executor = new GraphExecutor({
|
|
375
371
|
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
376
|
-
});
|
|
377
|
-
this._diagnostics = [];
|
|
378
|
-
this._services = {};
|
|
379
|
-
this._forcedOutputs = {};
|
|
380
|
-
this._runtimeStateInputs = {};
|
|
381
|
-
this._runtimeStateOutputs = {};
|
|
382
|
-
this.update = new Event();
|
|
383
|
-
this.output = new Event();
|
|
384
|
-
this.events = new Event();
|
|
372
|
+
}), this._diagnostics = [], this._services = {}, this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
|
|
385
373
|
}
|
|
386
374
|
toJSON() {
|
|
387
375
|
return {
|
|
@@ -649,6 +637,7 @@ var computeValueBag = (bag) => {
|
|
|
649
637
|
import { noteShape } from "@dxos/react-ui-canvas-editor";
|
|
650
638
|
|
|
651
639
|
// packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx
|
|
640
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
652
641
|
import React, { forwardRef } from "react";
|
|
653
642
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
654
643
|
import { Icon, IconButton } from "@dxos/react-ui";
|
|
@@ -658,74 +647,80 @@ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-com
|
|
|
658
647
|
var headerHeight = 32;
|
|
659
648
|
var footerHeight = 32;
|
|
660
649
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
ev.stopPropagation()
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
650
|
+
var _effect = _useSignals();
|
|
651
|
+
try {
|
|
652
|
+
invariant4(shape.type, void 0, {
|
|
653
|
+
F: __dxlog_file5,
|
|
654
|
+
L: 30,
|
|
655
|
+
S: void 0,
|
|
656
|
+
A: [
|
|
657
|
+
"shape.type",
|
|
658
|
+
""
|
|
659
|
+
]
|
|
660
|
+
});
|
|
661
|
+
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
662
|
+
icon: "ph--placeholder--regular"
|
|
663
|
+
};
|
|
664
|
+
const { debug } = useEditorContext();
|
|
665
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
666
|
+
ref: forwardedRef,
|
|
667
|
+
className: "flex flex-col h-full w-full justify-between"
|
|
668
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
669
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
|
|
670
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
671
|
+
icon,
|
|
672
|
+
classNames: "mx-2"
|
|
673
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
674
|
+
className: "grow text-sm truncate"
|
|
675
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
|
|
676
|
+
classNames: "p-1 text-green-500",
|
|
677
|
+
variant: "ghost",
|
|
678
|
+
icon: "ph--play--regular",
|
|
679
|
+
size: 4,
|
|
680
|
+
label: "run",
|
|
681
|
+
iconOnly: true,
|
|
682
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
683
|
+
onClick: (ev) => {
|
|
684
|
+
ev.stopPropagation();
|
|
685
|
+
onAction?.("run");
|
|
686
|
+
}
|
|
687
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
688
|
+
className: mx("flex flex-col h-full grow overflow-hidden", classNames)
|
|
689
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
690
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
|
|
691
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
692
|
+
className: "grow px-2 text-sm truncate"
|
|
693
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
694
|
+
classNames: "p-1",
|
|
695
|
+
variant: "ghost",
|
|
696
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
697
|
+
size: 4,
|
|
698
|
+
label: open ? "close" : "open",
|
|
699
|
+
iconOnly: true,
|
|
700
|
+
onClick: (ev) => {
|
|
701
|
+
ev.stopPropagation();
|
|
702
|
+
onAction?.(open ? "close" : "open");
|
|
703
|
+
}
|
|
704
|
+
})));
|
|
705
|
+
} finally {
|
|
706
|
+
_effect.f();
|
|
707
|
+
}
|
|
714
708
|
});
|
|
715
709
|
|
|
716
710
|
// packages/ui/react-ui-canvas-compute/src/shapes/common/FunctionBody.tsx
|
|
711
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
712
|
+
import { SchemaAST as SchemaAST2 } from "effect";
|
|
717
713
|
import React2, { useRef, useState as useState3 } from "react";
|
|
718
714
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
719
|
-
import { AST as AST2 } from "@dxos/echo-schema";
|
|
720
715
|
import { useCanvasContext } from "@dxos/react-ui-canvas";
|
|
721
716
|
import { getParentShapeElement, createAnchors, rowHeight } from "@dxos/react-ui-canvas-editor";
|
|
722
717
|
|
|
723
718
|
// packages/ui/react-ui-canvas-compute/src/shapes/defs.ts
|
|
724
|
-
import {
|
|
719
|
+
import { Schema as Schema2, SchemaAST } from "effect";
|
|
725
720
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
726
|
-
import { ObjectId as ObjectId3
|
|
721
|
+
import { ObjectId as ObjectId3 } from "@dxos/echo-schema";
|
|
727
722
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
728
|
-
var getProperties = (ast) =>
|
|
723
|
+
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
729
724
|
name: name.toString()
|
|
730
725
|
}));
|
|
731
726
|
var createAnchorId = (kind, property = kind === "input" ? DEFAULT_INPUT2 : DEFAULT_OUTPUT2) => [
|
|
@@ -739,12 +734,12 @@ var parseAnchorId = (id) => {
|
|
|
739
734
|
id
|
|
740
735
|
];
|
|
741
736
|
};
|
|
742
|
-
var ComputeShape =
|
|
737
|
+
var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
|
|
743
738
|
// TODO(burdon): Rename computeNode?
|
|
744
|
-
node:
|
|
745
|
-
|
|
739
|
+
node: Schema2.optional(ObjectId3.annotations({
|
|
740
|
+
description: "Compute node id"
|
|
746
741
|
}))
|
|
747
|
-
}).pipe(
|
|
742
|
+
}).pipe(Schema2.mutable));
|
|
748
743
|
var createShape = ({ id, ...rest }) => {
|
|
749
744
|
return {
|
|
750
745
|
id: id ?? ObjectId3.random(),
|
|
@@ -756,73 +751,78 @@ var createShape = ({ id, ...rest }) => {
|
|
|
756
751
|
var bodyPadding = 8;
|
|
757
752
|
var expandedHeight = 200;
|
|
758
753
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
case "open": {
|
|
768
|
-
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
769
|
-
const { height } = el.getBoundingClientRect();
|
|
770
|
-
el.style.height = `${height / scale + expandedHeight}px`;
|
|
771
|
-
setOpen(true);
|
|
772
|
-
break;
|
|
754
|
+
var _effect = _useSignals2();
|
|
755
|
+
try {
|
|
756
|
+
const { scale } = useCanvasContext();
|
|
757
|
+
const rootRef = useRef(null);
|
|
758
|
+
const [open, setOpen] = useState3(false);
|
|
759
|
+
const handleAction = (action) => {
|
|
760
|
+
if (!rootRef.current) {
|
|
761
|
+
return;
|
|
773
762
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
763
|
+
switch (action) {
|
|
764
|
+
case "open": {
|
|
765
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
766
|
+
const { height } = el.getBoundingClientRect();
|
|
767
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
768
|
+
setOpen(true);
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
case "close": {
|
|
772
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
773
|
+
el.style.height = "";
|
|
774
|
+
setOpen(false);
|
|
775
|
+
break;
|
|
776
|
+
}
|
|
779
777
|
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
778
|
+
};
|
|
779
|
+
const inputs = getProperties(inputSchema.ast);
|
|
780
|
+
const outputs = getProperties(outputSchema.ast);
|
|
781
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
782
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
783
|
+
ref: rootRef,
|
|
784
|
+
shape,
|
|
785
|
+
title: name,
|
|
786
|
+
classNames: "divide-y divide-separator",
|
|
787
|
+
open,
|
|
788
|
+
onAction: handleAction,
|
|
789
|
+
...props
|
|
790
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
791
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
792
|
+
style: {
|
|
793
|
+
paddingTop: bodyPadding,
|
|
794
|
+
paddingBottom: bodyPadding
|
|
795
|
+
}
|
|
796
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
797
|
+
className: "flex flex-col"
|
|
798
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
799
|
+
key: name2,
|
|
800
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
801
|
+
style: {
|
|
802
|
+
height: rowHeight
|
|
803
|
+
}
|
|
804
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
805
|
+
className: "flex flex-col"
|
|
806
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
807
|
+
key: name2,
|
|
808
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
809
|
+
style: {
|
|
810
|
+
height: rowHeight
|
|
811
|
+
}
|
|
812
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
813
|
+
className: "flex flex-col grow overflow-hidden"
|
|
814
|
+
}, content));
|
|
815
|
+
} finally {
|
|
816
|
+
_effect.f();
|
|
817
|
+
}
|
|
818
818
|
};
|
|
819
819
|
var getHeight = (input) => {
|
|
820
|
-
const properties =
|
|
820
|
+
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
821
821
|
return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2;
|
|
822
822
|
};
|
|
823
823
|
var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
824
|
-
const inputs =
|
|
825
|
-
const outputs =
|
|
824
|
+
const inputs = SchemaAST2.getPropertySignatures(input.ast).map(({ name }) => createAnchorId("input", name.toString()));
|
|
825
|
+
const outputs = SchemaAST2.getPropertySignatures(output.ast).map(({ name }) => createAnchorId("output", name.toString()));
|
|
826
826
|
return createAnchors({
|
|
827
827
|
shape,
|
|
828
828
|
inputs,
|
|
@@ -835,35 +835,47 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
835
835
|
};
|
|
836
836
|
|
|
837
837
|
// packages/ui/react-ui-canvas-compute/src/shapes/common/TypeSelect.tsx
|
|
838
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
838
839
|
import React3 from "react";
|
|
839
840
|
import { ComputeValueType } from "@dxos/conductor";
|
|
840
841
|
import { Select } from "@dxos/react-ui";
|
|
841
842
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
843
|
+
var _effect = _useSignals3();
|
|
844
|
+
try {
|
|
845
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
846
|
+
value,
|
|
847
|
+
onValueChange
|
|
848
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
849
|
+
variant: "ghost",
|
|
850
|
+
classNames: "w-full !px-0"
|
|
851
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
852
|
+
key: type,
|
|
853
|
+
value: type
|
|
854
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
855
|
+
} finally {
|
|
856
|
+
_effect.f();
|
|
857
|
+
}
|
|
852
858
|
};
|
|
853
859
|
|
|
854
860
|
// packages/ui/react-ui-canvas-compute/src/shapes/Array.tsx
|
|
861
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
862
|
+
import { Schema as Schema3 } from "effect";
|
|
855
863
|
import React4 from "react";
|
|
856
864
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
type: S3.Literal("reducer")
|
|
865
|
+
var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
866
|
+
type: Schema3.Literal("reducer")
|
|
860
867
|
}));
|
|
861
868
|
var ReducerComponent = ({ shape }) => {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
869
|
+
var _effect = _useSignals4();
|
|
870
|
+
try {
|
|
871
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
872
|
+
shape,
|
|
873
|
+
inputSchema: ReducerInput,
|
|
874
|
+
outputSchema: ReducerOutput
|
|
875
|
+
});
|
|
876
|
+
} finally {
|
|
877
|
+
_effect.f();
|
|
878
|
+
}
|
|
867
879
|
};
|
|
868
880
|
var createReducer = ({ id, size = {
|
|
869
881
|
width: 192,
|
|
@@ -883,11 +895,12 @@ var reducerShape = {
|
|
|
883
895
|
};
|
|
884
896
|
|
|
885
897
|
// packages/ui/react-ui-canvas-compute/src/shapes/Append.tsx
|
|
898
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
899
|
+
import { Schema as Schema4 } from "effect";
|
|
886
900
|
import React5 from "react";
|
|
887
901
|
import { AppendInput } from "@dxos/conductor";
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
type: S4.Literal("append")
|
|
902
|
+
var AppendShape = Schema4.extend(ComputeShape, Schema4.Struct({
|
|
903
|
+
type: Schema4.Literal("append")
|
|
891
904
|
}));
|
|
892
905
|
var createAppend = (props) => createShape({
|
|
893
906
|
type: "append",
|
|
@@ -898,10 +911,15 @@ var createAppend = (props) => createShape({
|
|
|
898
911
|
...props
|
|
899
912
|
});
|
|
900
913
|
var AppendComponent = ({ shape }) => {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
914
|
+
var _effect = _useSignals5();
|
|
915
|
+
try {
|
|
916
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
917
|
+
shape,
|
|
918
|
+
inputSchema: AppendInput
|
|
919
|
+
});
|
|
920
|
+
} finally {
|
|
921
|
+
_effect.f();
|
|
922
|
+
}
|
|
905
923
|
};
|
|
906
924
|
var appendShape = {
|
|
907
925
|
type: "append",
|
|
@@ -913,12 +931,13 @@ var appendShape = {
|
|
|
913
931
|
};
|
|
914
932
|
|
|
915
933
|
// packages/ui/react-ui-canvas-compute/src/shapes/Audio.tsx
|
|
934
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
935
|
+
import { Schema as Schema5 } from "effect";
|
|
916
936
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
917
|
-
import { S as S5 } from "@dxos/echo-schema";
|
|
918
937
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
919
938
|
import { createAnchorMap } from "@dxos/react-ui-canvas-editor";
|
|
920
|
-
var AudioShape =
|
|
921
|
-
type:
|
|
939
|
+
var AudioShape = Schema5.extend(ComputeShape, Schema5.Struct({
|
|
940
|
+
type: Schema5.Literal("audio")
|
|
922
941
|
}));
|
|
923
942
|
var createAudio = (props) => createShape({
|
|
924
943
|
type: "audio",
|
|
@@ -929,24 +948,29 @@ var createAudio = (props) => createShape({
|
|
|
929
948
|
...props
|
|
930
949
|
});
|
|
931
950
|
var AudioComponent = ({ shape }) => {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
"
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
951
|
+
var _effect = _useSignals6();
|
|
952
|
+
try {
|
|
953
|
+
const { node } = useComputeNodeState(shape);
|
|
954
|
+
const [active, setActive] = useState4(false);
|
|
955
|
+
useEffect3(() => {
|
|
956
|
+
node.value = active;
|
|
957
|
+
}, [
|
|
958
|
+
active
|
|
959
|
+
]);
|
|
960
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
961
|
+
className: "flex w-full justify-center items-center"
|
|
962
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
963
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
964
|
+
classNames: [
|
|
965
|
+
"transition opacity-20 duration-1000",
|
|
966
|
+
active && "opacity-100 text-red-500"
|
|
967
|
+
],
|
|
968
|
+
size: 8,
|
|
969
|
+
onClick: () => setActive(!active)
|
|
970
|
+
}));
|
|
971
|
+
} finally {
|
|
972
|
+
_effect.f();
|
|
973
|
+
}
|
|
950
974
|
};
|
|
951
975
|
var audioShape = {
|
|
952
976
|
type: "audio",
|
|
@@ -963,14 +987,15 @@ var audioShape = {
|
|
|
963
987
|
};
|
|
964
988
|
|
|
965
989
|
// packages/ui/react-ui-canvas-compute/src/shapes/Beacon.tsx
|
|
990
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
991
|
+
import { Schema as Schema6 } from "effect";
|
|
966
992
|
import React7 from "react";
|
|
967
993
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
968
|
-
import { S as S6 } from "@dxos/echo-schema";
|
|
969
994
|
import { Icon as Icon3 } from "@dxos/react-ui";
|
|
970
995
|
import { createAnchorMap as createAnchorMap2 } from "@dxos/react-ui-canvas-editor";
|
|
971
996
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
972
|
-
var BeaconShape =
|
|
973
|
-
type:
|
|
997
|
+
var BeaconShape = Schema6.extend(ComputeShape, Schema6.Struct({
|
|
998
|
+
type: Schema6.Literal("beacon")
|
|
974
999
|
}));
|
|
975
1000
|
var createBeacon = (props) => createShape({
|
|
976
1001
|
type: "beacon",
|
|
@@ -981,16 +1006,21 @@ var createBeacon = (props) => createShape({
|
|
|
981
1006
|
...props
|
|
982
1007
|
});
|
|
983
1008
|
var BeaconComponent = ({ shape }) => {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1009
|
+
var _effect = _useSignals7();
|
|
1010
|
+
try {
|
|
1011
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1012
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
1013
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
1014
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1015
|
+
className: "flex w-full justify-center items-center"
|
|
1016
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
1017
|
+
icon: "ph--sun--regular",
|
|
1018
|
+
classNames: mx2("transition opacity-20 duration-1000", isTruthy(value) && "opacity-100 text-yellow-500"),
|
|
1019
|
+
size: 8
|
|
1020
|
+
}));
|
|
1021
|
+
} finally {
|
|
1022
|
+
_effect.f();
|
|
1023
|
+
}
|
|
994
1024
|
};
|
|
995
1025
|
var beaconShape = {
|
|
996
1026
|
type: "beacon",
|
|
@@ -1007,11 +1037,12 @@ var beaconShape = {
|
|
|
1007
1037
|
};
|
|
1008
1038
|
|
|
1009
1039
|
// packages/ui/react-ui-canvas-compute/src/shapes/Boolean.tsx
|
|
1040
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1041
|
+
import { Schema as Schema7 } from "effect";
|
|
1010
1042
|
import React8 from "react";
|
|
1011
|
-
import { S as S7 } from "@dxos/echo-schema";
|
|
1012
1043
|
import { createAnchors as createAnchors2, getAnchorPoints } from "@dxos/react-ui-canvas-editor";
|
|
1013
|
-
var GateShape =
|
|
1014
|
-
type:
|
|
1044
|
+
var GateShape = Schema7.extend(ComputeShape, Schema7.Struct({
|
|
1045
|
+
type: Schema7.String
|
|
1015
1046
|
}));
|
|
1016
1047
|
var createGate = (props) => createShape({
|
|
1017
1048
|
size: {
|
|
@@ -1020,10 +1051,17 @@ var createGate = (props) => createShape({
|
|
|
1020
1051
|
},
|
|
1021
1052
|
...props
|
|
1022
1053
|
});
|
|
1023
|
-
var GateComponent = (Symbol2) =>
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1054
|
+
var GateComponent = (Symbol2) => {
|
|
1055
|
+
var _effect = _useSignals8();
|
|
1056
|
+
try {
|
|
1057
|
+
return () => {
|
|
1058
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1059
|
+
className: "flex w-full justify-center items-center"
|
|
1060
|
+
}, /* @__PURE__ */ React8.createElement(Symbol2, null));
|
|
1061
|
+
};
|
|
1062
|
+
} finally {
|
|
1063
|
+
_effect.f();
|
|
1064
|
+
}
|
|
1027
1065
|
};
|
|
1028
1066
|
var defineShape = ({ type, name, icon, Symbol: Symbol2, createShape: createShape2, inputs, outputs = [
|
|
1029
1067
|
createAnchorId("output")
|
|
@@ -1039,48 +1077,55 @@ var defineShape = ({ type, name, icon, Symbol: Symbol2, createShape: createShape
|
|
|
1039
1077
|
outputs
|
|
1040
1078
|
})
|
|
1041
1079
|
});
|
|
1042
|
-
var Symbol = (pathConstructor, inputs) =>
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1080
|
+
var Symbol = (pathConstructor, inputs) => {
|
|
1081
|
+
var _effect = _useSignals8();
|
|
1082
|
+
try {
|
|
1083
|
+
return ({
|
|
1084
|
+
width = 64,
|
|
1085
|
+
height = 32,
|
|
1086
|
+
// TODO(burdon): Same as line color.
|
|
1087
|
+
className = "fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500",
|
|
1088
|
+
strokeWidth = 1
|
|
1089
|
+
}) => {
|
|
1090
|
+
const startX = width * 0.25;
|
|
1091
|
+
const endX = width * 0.75;
|
|
1092
|
+
const centerY = height / 2;
|
|
1093
|
+
const paths = pathConstructor({
|
|
1094
|
+
startX,
|
|
1095
|
+
endX,
|
|
1096
|
+
height
|
|
1097
|
+
});
|
|
1098
|
+
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1099
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1100
|
+
className: "w-full h-full"
|
|
1101
|
+
}, getAnchorPoints({
|
|
1102
|
+
x: 0,
|
|
1103
|
+
y: centerY
|
|
1104
|
+
}, inputs).map(({ x, y }, i) => /* @__PURE__ */ React8.createElement("line", {
|
|
1105
|
+
key: i,
|
|
1106
|
+
x1: x,
|
|
1107
|
+
y1: y,
|
|
1108
|
+
x2: startX * 1.3,
|
|
1109
|
+
y2: y,
|
|
1110
|
+
strokeWidth,
|
|
1111
|
+
className
|
|
1112
|
+
})), /* @__PURE__ */ React8.createElement("line", {
|
|
1113
|
+
x1: endX,
|
|
1114
|
+
y1: centerY,
|
|
1115
|
+
x2: width,
|
|
1116
|
+
y2: centerY,
|
|
1117
|
+
strokeWidth,
|
|
1118
|
+
className
|
|
1119
|
+
}), paths.map((path, i) => /* @__PURE__ */ React8.createElement("path", {
|
|
1120
|
+
key: i,
|
|
1121
|
+
d: path,
|
|
1122
|
+
strokeWidth,
|
|
1123
|
+
className
|
|
1124
|
+
})));
|
|
1125
|
+
};
|
|
1126
|
+
} finally {
|
|
1127
|
+
_effect.f();
|
|
1128
|
+
}
|
|
1084
1129
|
};
|
|
1085
1130
|
var AndSymbol = Symbol(({ startX, endX, height }) => {
|
|
1086
1131
|
const arcRadius = (endX - startX) / 2;
|
|
@@ -1178,32 +1223,38 @@ var notShape = defineShape({
|
|
|
1178
1223
|
});
|
|
1179
1224
|
|
|
1180
1225
|
// packages/ui/react-ui-canvas-compute/src/shapes/Chat.tsx
|
|
1226
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1227
|
+
import { Schema as Schema8 } from "effect";
|
|
1181
1228
|
import React9, { useRef as useRef2 } from "react";
|
|
1182
1229
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
1183
|
-
import { S as S8 } from "@dxos/echo-schema";
|
|
1184
1230
|
import { TextBox } from "@dxos/react-ui-canvas-editor";
|
|
1185
1231
|
import { createAnchorMap as createAnchorMap3 } from "@dxos/react-ui-canvas-editor";
|
|
1186
|
-
var ChatShape =
|
|
1187
|
-
type:
|
|
1232
|
+
var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
1233
|
+
type: Schema8.Literal("chat")
|
|
1188
1234
|
}));
|
|
1189
1235
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1236
|
+
var _effect = _useSignals9();
|
|
1237
|
+
try {
|
|
1238
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1239
|
+
const inputRef = useRef2(null);
|
|
1240
|
+
const handleEnter = (text) => {
|
|
1241
|
+
const value = text.trim();
|
|
1242
|
+
if (value.length) {
|
|
1243
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1244
|
+
inputRef.current?.setText("");
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1248
|
+
shape,
|
|
1249
|
+
title
|
|
1250
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1251
|
+
ref: inputRef,
|
|
1252
|
+
onEnter: handleEnter,
|
|
1253
|
+
...props
|
|
1254
|
+
}));
|
|
1255
|
+
} finally {
|
|
1256
|
+
_effect.f();
|
|
1257
|
+
}
|
|
1207
1258
|
};
|
|
1208
1259
|
var createChat = (props) => createShape({
|
|
1209
1260
|
type: "chat",
|
|
@@ -1233,16 +1284,17 @@ var chatShape = {
|
|
|
1233
1284
|
};
|
|
1234
1285
|
|
|
1235
1286
|
// packages/ui/react-ui-canvas-compute/src/shapes/Constant.tsx
|
|
1287
|
+
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1288
|
+
import { Schema as Schema9 } from "effect";
|
|
1236
1289
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1237
1290
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
1238
|
-
import { S as S9 } from "@dxos/echo-schema";
|
|
1239
1291
|
import { Input } from "@dxos/react-ui";
|
|
1240
1292
|
import { TextBox as TextBox2 } from "@dxos/react-ui-canvas-editor";
|
|
1241
1293
|
import { createAnchorMap as createAnchorMap4 } from "@dxos/react-ui-canvas-editor";
|
|
1242
1294
|
import { safeParseJson } from "@dxos/util";
|
|
1243
|
-
var ConstantShape =
|
|
1244
|
-
type:
|
|
1245
|
-
value:
|
|
1295
|
+
var ConstantShape = Schema9.extend(ComputeShape, Schema9.Struct({
|
|
1296
|
+
type: Schema9.Literal("constant"),
|
|
1297
|
+
value: Schema9.optional(Schema9.Any)
|
|
1246
1298
|
}));
|
|
1247
1299
|
var inferType = (value) => {
|
|
1248
1300
|
if (typeof value === "string") {
|
|
@@ -1256,52 +1308,57 @@ var inferType = (value) => {
|
|
|
1256
1308
|
}
|
|
1257
1309
|
};
|
|
1258
1310
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
if (
|
|
1268
|
-
|
|
1311
|
+
var _effect = _useSignals10();
|
|
1312
|
+
try {
|
|
1313
|
+
const { node } = useComputeNodeState(shape);
|
|
1314
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1315
|
+
const inputRef = useRef3(null);
|
|
1316
|
+
const handleEnter = useCallback2((text) => {
|
|
1317
|
+
const value = text.trim();
|
|
1318
|
+
if (value.length) {
|
|
1319
|
+
if (type === "number") {
|
|
1320
|
+
const floatValue = parseFloat(value);
|
|
1321
|
+
if (!isNaN(floatValue)) {
|
|
1322
|
+
node.value = floatValue;
|
|
1323
|
+
}
|
|
1324
|
+
} else if (type === "object") {
|
|
1325
|
+
node.value = safeParseJson(value, {});
|
|
1326
|
+
} else {
|
|
1327
|
+
node.value = value;
|
|
1269
1328
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1329
|
+
inputRef.current?.focus();
|
|
1330
|
+
}
|
|
1331
|
+
}, [
|
|
1332
|
+
type
|
|
1333
|
+
]);
|
|
1334
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1335
|
+
shape,
|
|
1336
|
+
title,
|
|
1337
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1338
|
+
value: type,
|
|
1339
|
+
onValueChange: setType
|
|
1340
|
+
})
|
|
1341
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1342
|
+
...props,
|
|
1343
|
+
ref: inputRef,
|
|
1344
|
+
value: node.value,
|
|
1345
|
+
onEnter: handleEnter
|
|
1346
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1347
|
+
...props,
|
|
1348
|
+
ref: inputRef,
|
|
1349
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1350
|
+
language: "json"
|
|
1351
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1352
|
+
className: "flex grow justify-center items-center"
|
|
1353
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1354
|
+
checked: node.value,
|
|
1355
|
+
onCheckedChange: (value) => {
|
|
1273
1356
|
node.value = value;
|
|
1274
1357
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
]);
|
|
1280
|
-
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1281
|
-
shape,
|
|
1282
|
-
title,
|
|
1283
|
-
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1284
|
-
value: type,
|
|
1285
|
-
onValueChange: setType
|
|
1286
|
-
})
|
|
1287
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1288
|
-
...props,
|
|
1289
|
-
ref: inputRef,
|
|
1290
|
-
value: node.value,
|
|
1291
|
-
onEnter: handleEnter
|
|
1292
|
-
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1293
|
-
...props,
|
|
1294
|
-
ref: inputRef,
|
|
1295
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1296
|
-
language: "json"
|
|
1297
|
-
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1298
|
-
className: "flex grow justify-center items-center"
|
|
1299
|
-
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1300
|
-
checked: node.value,
|
|
1301
|
-
onCheckedChange: (value) => {
|
|
1302
|
-
node.value = value;
|
|
1303
|
-
}
|
|
1304
|
-
}))));
|
|
1358
|
+
}))));
|
|
1359
|
+
} finally {
|
|
1360
|
+
_effect.f();
|
|
1361
|
+
}
|
|
1305
1362
|
};
|
|
1306
1363
|
var createConstant = (props) => createShape({
|
|
1307
1364
|
type: "constant",
|
|
@@ -1330,11 +1387,12 @@ var constantShape = {
|
|
|
1330
1387
|
};
|
|
1331
1388
|
|
|
1332
1389
|
// packages/ui/react-ui-canvas-compute/src/shapes/Database.tsx
|
|
1390
|
+
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1391
|
+
import { Schema as Schema10 } from "effect";
|
|
1333
1392
|
import React11 from "react";
|
|
1334
|
-
import { S as S10 } from "@dxos/echo-schema";
|
|
1335
1393
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
1336
|
-
var DatabaseShape =
|
|
1337
|
-
type:
|
|
1394
|
+
var DatabaseShape = Schema10.extend(ComputeShape, Schema10.Struct({
|
|
1395
|
+
type: Schema10.Literal("database")
|
|
1338
1396
|
}));
|
|
1339
1397
|
var createDatabase = (props) => createShape({
|
|
1340
1398
|
type: "database",
|
|
@@ -1345,9 +1403,14 @@ var createDatabase = (props) => createShape({
|
|
|
1345
1403
|
...props
|
|
1346
1404
|
});
|
|
1347
1405
|
var DatabaseComponent = ({ shape }) => {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1406
|
+
var _effect = _useSignals11();
|
|
1407
|
+
try {
|
|
1408
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1409
|
+
shape
|
|
1410
|
+
});
|
|
1411
|
+
} finally {
|
|
1412
|
+
_effect.f();
|
|
1413
|
+
}
|
|
1351
1414
|
};
|
|
1352
1415
|
var databaseShape = {
|
|
1353
1416
|
type: "database",
|
|
@@ -1364,15 +1427,17 @@ var databaseShape = {
|
|
|
1364
1427
|
};
|
|
1365
1428
|
|
|
1366
1429
|
// packages/ui/react-ui-canvas-compute/src/shapes/Function.tsx
|
|
1430
|
+
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1431
|
+
import { Schema as Schema11 } from "effect";
|
|
1367
1432
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1368
1433
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1369
|
-
import { getSnapshot, isInstanceOf,
|
|
1370
|
-
import { FunctionType, ScriptType } from "@dxos/functions
|
|
1434
|
+
import { getSnapshot, isInstanceOf, Ref as Ref2 } from "@dxos/echo-schema";
|
|
1435
|
+
import { FunctionType, ScriptType } from "@dxos/functions";
|
|
1371
1436
|
import { useClient } from "@dxos/react-client";
|
|
1372
1437
|
import { Filter, makeRef, parseId } from "@dxos/react-client/echo";
|
|
1373
1438
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1374
|
-
var FunctionShape =
|
|
1375
|
-
type:
|
|
1439
|
+
var FunctionShape = Schema11.extend(ComputeShape, Schema11.Struct({
|
|
1440
|
+
type: Schema11.Literal("function")
|
|
1376
1441
|
}));
|
|
1377
1442
|
var createFunction = (props) => createShape({
|
|
1378
1443
|
type: "function",
|
|
@@ -1383,54 +1448,59 @@ var createFunction = (props) => createShape({
|
|
|
1383
1448
|
...props
|
|
1384
1449
|
});
|
|
1385
1450
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
const
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1451
|
+
var _effect = _useSignals12();
|
|
1452
|
+
try {
|
|
1453
|
+
const client = useClient();
|
|
1454
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1455
|
+
const inputRef = useRef4(null);
|
|
1456
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1457
|
+
const value = text.trim();
|
|
1458
|
+
const { spaceId, objectId } = parseId(value);
|
|
1459
|
+
if (!spaceId || !objectId) {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
const space = client.spaces.get(spaceId);
|
|
1463
|
+
const object = space?.db.getObjectById(objectId);
|
|
1464
|
+
if (!space || !isInstanceOf(ScriptType, object)) {
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
|
|
1468
|
+
source: Ref2.make(object)
|
|
1469
|
+
})).run();
|
|
1470
|
+
if (!fn) {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
node.value = value;
|
|
1474
|
+
node.function = makeRef(fn);
|
|
1475
|
+
node.inputSchema = getSnapshot(fn.inputSchema);
|
|
1476
|
+
node.outputSchema = getSnapshot(fn.outputSchema);
|
|
1477
|
+
}, [
|
|
1478
|
+
client,
|
|
1479
|
+
node
|
|
1480
|
+
]);
|
|
1481
|
+
const handleAction = useCallback3((action) => {
|
|
1482
|
+
if (action !== "run") {
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
runtime.evalNode();
|
|
1486
|
+
}, [
|
|
1487
|
+
runtime
|
|
1488
|
+
]);
|
|
1489
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1490
|
+
shape,
|
|
1491
|
+
title: "Function",
|
|
1492
|
+
onAction: handleAction
|
|
1493
|
+
}, /* @__PURE__ */ React12.createElement(TextBox3, {
|
|
1494
|
+
...props,
|
|
1495
|
+
ref: inputRef,
|
|
1496
|
+
value: node.value,
|
|
1497
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1498
|
+
onBlur: handleEnter,
|
|
1499
|
+
onEnter: handleEnter
|
|
1500
|
+
}));
|
|
1501
|
+
} finally {
|
|
1502
|
+
_effect.f();
|
|
1503
|
+
}
|
|
1434
1504
|
};
|
|
1435
1505
|
var functionShape = {
|
|
1436
1506
|
type: "function",
|
|
@@ -1442,11 +1512,12 @@ var functionShape = {
|
|
|
1442
1512
|
};
|
|
1443
1513
|
|
|
1444
1514
|
// packages/ui/react-ui-canvas-compute/src/shapes/Gpt.tsx
|
|
1515
|
+
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
1516
|
+
import { Schema as Schema12 } from "effect";
|
|
1445
1517
|
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1446
1518
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
type: S12.Literal("gpt")
|
|
1519
|
+
var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1520
|
+
type: Schema12.Literal("gpt")
|
|
1450
1521
|
}));
|
|
1451
1522
|
var createGpt = (props) => createShape({
|
|
1452
1523
|
type: "gpt",
|
|
@@ -1457,49 +1528,54 @@ var createGpt = (props) => createShape({
|
|
|
1457
1528
|
...props
|
|
1458
1529
|
});
|
|
1459
1530
|
var GptComponent = ({ shape }) => {
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1531
|
+
var _effect = _useSignals13();
|
|
1532
|
+
try {
|
|
1533
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1534
|
+
const [text, setText] = useState6("");
|
|
1535
|
+
const [tokens, setTokens] = useState6(0);
|
|
1536
|
+
useEffect4(() => {
|
|
1537
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1538
|
+
switch (ev.type) {
|
|
1539
|
+
case "begin-compute": {
|
|
1540
|
+
setText("");
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
case "custom": {
|
|
1544
|
+
const token = ev.event;
|
|
1545
|
+
switch (token.type) {
|
|
1546
|
+
case "content_block_delta":
|
|
1547
|
+
switch (token.delta.type) {
|
|
1548
|
+
case "text_delta": {
|
|
1549
|
+
const delta = token.delta.text;
|
|
1550
|
+
setText((prev) => {
|
|
1551
|
+
const text2 = prev + delta;
|
|
1552
|
+
setTokens(text2.split(" ").length);
|
|
1553
|
+
return text2;
|
|
1554
|
+
});
|
|
1555
|
+
break;
|
|
1556
|
+
}
|
|
1483
1557
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
break;
|
|
1486
1561
|
}
|
|
1487
|
-
break;
|
|
1488
1562
|
}
|
|
1489
|
-
}
|
|
1563
|
+
});
|
|
1564
|
+
}, [
|
|
1565
|
+
runtime?.subscribeToEventLog
|
|
1566
|
+
]);
|
|
1567
|
+
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1568
|
+
shape,
|
|
1569
|
+
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1570
|
+
className: "px-2 py-1 overflow-y-scroll"
|
|
1571
|
+
}, text),
|
|
1572
|
+
status: `${tokens} tokens`,
|
|
1573
|
+
inputSchema: meta.input,
|
|
1574
|
+
outputSchema: meta.output
|
|
1490
1575
|
});
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1495
|
-
shape,
|
|
1496
|
-
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1497
|
-
className: "px-2 py-1 overflow-y-scroll"
|
|
1498
|
-
}, text),
|
|
1499
|
-
status: `${tokens} tokens`,
|
|
1500
|
-
inputSchema: meta.input,
|
|
1501
|
-
outputSchema: meta.output
|
|
1502
|
-
});
|
|
1576
|
+
} finally {
|
|
1577
|
+
_effect.f();
|
|
1578
|
+
}
|
|
1503
1579
|
};
|
|
1504
1580
|
var gptShape = {
|
|
1505
1581
|
type: "gpt",
|
|
@@ -1512,32 +1588,43 @@ var gptShape = {
|
|
|
1512
1588
|
};
|
|
1513
1589
|
|
|
1514
1590
|
// packages/ui/react-ui-canvas-compute/src/shapes/Json.tsx
|
|
1591
|
+
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
1592
|
+
import { Schema as Schema13 } from "effect";
|
|
1515
1593
|
import React14 from "react";
|
|
1516
1594
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1517
|
-
import { S as S13 } from "@dxos/echo-schema";
|
|
1518
1595
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1519
1596
|
import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
|
|
1520
|
-
var JsonShape =
|
|
1521
|
-
type:
|
|
1597
|
+
var JsonShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1598
|
+
type: Schema13.Literal("json")
|
|
1522
1599
|
}));
|
|
1523
|
-
var JsonTransformShape =
|
|
1524
|
-
type:
|
|
1600
|
+
var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1601
|
+
type: Schema13.Literal("json-transform")
|
|
1525
1602
|
}));
|
|
1526
1603
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1604
|
+
var _effect = _useSignals14();
|
|
1605
|
+
try {
|
|
1606
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1607
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1608
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1609
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1610
|
+
shape
|
|
1611
|
+
}, /* @__PURE__ */ React14.createElement(JsonFilter, {
|
|
1612
|
+
data: value,
|
|
1613
|
+
classNames: "text-xs"
|
|
1614
|
+
}));
|
|
1615
|
+
} finally {
|
|
1616
|
+
_effect.f();
|
|
1617
|
+
}
|
|
1536
1618
|
};
|
|
1537
1619
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1620
|
+
var _effect = _useSignals14();
|
|
1621
|
+
try {
|
|
1622
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1623
|
+
shape
|
|
1624
|
+
});
|
|
1625
|
+
} finally {
|
|
1626
|
+
_effect.f();
|
|
1627
|
+
}
|
|
1541
1628
|
};
|
|
1542
1629
|
var createJson = (props) => createShape({
|
|
1543
1630
|
type: "json",
|
|
@@ -1584,28 +1671,39 @@ var jsonTransformShape = {
|
|
|
1584
1671
|
};
|
|
1585
1672
|
|
|
1586
1673
|
// packages/ui/react-ui-canvas-compute/src/shapes/Logic.tsx
|
|
1674
|
+
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
1675
|
+
import { Schema as Schema14 } from "effect";
|
|
1587
1676
|
import React15 from "react";
|
|
1588
1677
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
type: S14.Literal("if")
|
|
1678
|
+
var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1679
|
+
type: Schema14.Literal("if")
|
|
1592
1680
|
}));
|
|
1593
|
-
var IfElseShape =
|
|
1594
|
-
type:
|
|
1681
|
+
var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1682
|
+
type: Schema14.Literal("if-else")
|
|
1595
1683
|
}));
|
|
1596
1684
|
var IfComponent = ({ shape, ...props }) => {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1685
|
+
var _effect = _useSignals15();
|
|
1686
|
+
try {
|
|
1687
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1688
|
+
shape,
|
|
1689
|
+
inputSchema: IfInput,
|
|
1690
|
+
outputSchema: IfOutput
|
|
1691
|
+
});
|
|
1692
|
+
} finally {
|
|
1693
|
+
_effect.f();
|
|
1694
|
+
}
|
|
1602
1695
|
};
|
|
1603
1696
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1697
|
+
var _effect = _useSignals15();
|
|
1698
|
+
try {
|
|
1699
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1700
|
+
shape,
|
|
1701
|
+
inputSchema: IfElseInput,
|
|
1702
|
+
outputSchema: IfElseOutput
|
|
1703
|
+
});
|
|
1704
|
+
} finally {
|
|
1705
|
+
_effect.f();
|
|
1706
|
+
}
|
|
1609
1707
|
};
|
|
1610
1708
|
var createIf = (props) => createShape({
|
|
1611
1709
|
type: "if",
|
|
@@ -1641,12 +1739,13 @@ var ifElseShape = {
|
|
|
1641
1739
|
};
|
|
1642
1740
|
|
|
1643
1741
|
// packages/ui/react-ui-canvas-compute/src/shapes/Queue.tsx
|
|
1742
|
+
import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
|
|
1743
|
+
import { Schema as Schema15 } from "effect";
|
|
1644
1744
|
import React16, { Fragment } from "react";
|
|
1645
1745
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1646
|
-
import { S as S15 } from "@dxos/echo-schema";
|
|
1647
1746
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
1648
|
-
var QueueShape =
|
|
1649
|
-
type:
|
|
1747
|
+
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1748
|
+
type: Schema15.Literal("queue")
|
|
1650
1749
|
}));
|
|
1651
1750
|
var createQueue = (props) => createShape({
|
|
1652
1751
|
type: "queue",
|
|
@@ -1657,40 +1756,50 @@ var createQueue = (props) => createShape({
|
|
|
1657
1756
|
...props
|
|
1658
1757
|
});
|
|
1659
1758
|
var QueueComponent = ({ shape }) => {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1759
|
+
var _effect = _useSignals16();
|
|
1760
|
+
try {
|
|
1761
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1762
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1763
|
+
const handleAction = (action) => {
|
|
1764
|
+
if (action === "run") {
|
|
1765
|
+
runtime.evalNode();
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1769
|
+
shape,
|
|
1770
|
+
status: `${items.length} items`,
|
|
1771
|
+
onAction: handleAction
|
|
1772
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1773
|
+
className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
|
|
1774
|
+
}, [
|
|
1775
|
+
...items
|
|
1776
|
+
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1777
|
+
key: i,
|
|
1778
|
+
classNames: "p-1 px-2",
|
|
1779
|
+
item
|
|
1780
|
+
}))));
|
|
1781
|
+
} finally {
|
|
1782
|
+
_effect.f();
|
|
1783
|
+
}
|
|
1680
1784
|
};
|
|
1681
1785
|
var QueueItem = ({ classNames, item }) => {
|
|
1682
|
-
|
|
1786
|
+
var _effect = _useSignals16();
|
|
1787
|
+
try {
|
|
1788
|
+
if (typeof item !== "object") {
|
|
1789
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
1790
|
+
className: mx3(classNames, "whitespace-pre-wrap")
|
|
1791
|
+
}, item);
|
|
1792
|
+
}
|
|
1683
1793
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1684
|
-
className: mx3(
|
|
1685
|
-
}, item)
|
|
1794
|
+
className: mx3("grid grid-cols-[80px,1fr]", classNames)
|
|
1795
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1796
|
+
key
|
|
1797
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1798
|
+
className: "p-1 text-xs text-subdued"
|
|
1799
|
+
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1800
|
+
} finally {
|
|
1801
|
+
_effect.f();
|
|
1686
1802
|
}
|
|
1687
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1688
|
-
className: mx3("grid grid-cols-[80px,1fr]", classNames)
|
|
1689
|
-
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1690
|
-
key
|
|
1691
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1692
|
-
className: "p-1 text-xs text-subdued"
|
|
1693
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1694
1803
|
};
|
|
1695
1804
|
var queueShape = {
|
|
1696
1805
|
type: "queue",
|
|
@@ -1703,16 +1812,17 @@ var queueShape = {
|
|
|
1703
1812
|
};
|
|
1704
1813
|
|
|
1705
1814
|
// packages/ui/react-ui-canvas-compute/src/shapes/RNG.tsx
|
|
1815
|
+
import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
|
|
1816
|
+
import { Schema as Schema16 } from "effect";
|
|
1706
1817
|
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1707
1818
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1708
|
-
import { S as S16 } from "@dxos/echo-schema";
|
|
1709
1819
|
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1710
1820
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1711
1821
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1712
|
-
var RandomShape =
|
|
1713
|
-
type:
|
|
1714
|
-
min:
|
|
1715
|
-
max:
|
|
1822
|
+
var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1823
|
+
type: Schema16.Literal("rng"),
|
|
1824
|
+
min: Schema16.optional(Schema16.Number),
|
|
1825
|
+
max: Schema16.optional(Schema16.Number)
|
|
1716
1826
|
}));
|
|
1717
1827
|
var createRandom = (props) => createShape({
|
|
1718
1828
|
type: "rng",
|
|
@@ -1732,37 +1842,42 @@ var icons = [
|
|
|
1732
1842
|
];
|
|
1733
1843
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1734
1844
|
var RandomComponent = ({ shape }) => {
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1845
|
+
var _effect = _useSignals17();
|
|
1846
|
+
try {
|
|
1847
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1848
|
+
const [spin, setSpin] = useState7(false);
|
|
1849
|
+
const [icon, setIcon] = useState7(pickIcon());
|
|
1850
|
+
useEffect5(() => {
|
|
1851
|
+
if (!spin) {
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1855
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1856
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1857
|
+
return () => {
|
|
1858
|
+
clearInterval(i);
|
|
1859
|
+
clearTimeout(t1);
|
|
1860
|
+
clearTimeout(t2);
|
|
1861
|
+
};
|
|
1862
|
+
}, [
|
|
1863
|
+
spin
|
|
1864
|
+
]);
|
|
1865
|
+
const handleClick = (ev) => {
|
|
1866
|
+
ev.stopPropagation();
|
|
1867
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1868
|
+
setSpin(true);
|
|
1749
1869
|
};
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}
|
|
1761
|
-
icon,
|
|
1762
|
-
classNames: mx4(spin && "animate-[spin_1s]"),
|
|
1763
|
-
size: 10,
|
|
1764
|
-
onClick: handleClick
|
|
1765
|
-
}));
|
|
1870
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
1871
|
+
className: "flex grow items-center justify-center"
|
|
1872
|
+
}, /* @__PURE__ */ React17.createElement(Icon4, {
|
|
1873
|
+
icon,
|
|
1874
|
+
classNames: mx4(spin && "animate-[spin_1s]"),
|
|
1875
|
+
size: 10,
|
|
1876
|
+
onClick: handleClick
|
|
1877
|
+
}));
|
|
1878
|
+
} finally {
|
|
1879
|
+
_effect.f();
|
|
1880
|
+
}
|
|
1766
1881
|
};
|
|
1767
1882
|
var randomShape = {
|
|
1768
1883
|
type: "rng",
|
|
@@ -1779,13 +1894,14 @@ var randomShape = {
|
|
|
1779
1894
|
};
|
|
1780
1895
|
|
|
1781
1896
|
// packages/ui/react-ui-canvas-compute/src/shapes/Scope.tsx
|
|
1897
|
+
import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
|
|
1898
|
+
import { Schema as Schema17 } from "effect";
|
|
1782
1899
|
import React18 from "react";
|
|
1783
1900
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1784
|
-
import { S as S17 } from "@dxos/echo-schema";
|
|
1785
1901
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1786
1902
|
import { useAudioStream, Chaos, shaderPresets } from "@dxos/react-ui-sfx";
|
|
1787
|
-
var ScopeShape =
|
|
1788
|
-
type:
|
|
1903
|
+
var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1904
|
+
type: Schema17.Literal("scope")
|
|
1789
1905
|
}));
|
|
1790
1906
|
var createScope = (props) => createShape({
|
|
1791
1907
|
type: "scope",
|
|
@@ -1797,20 +1913,25 @@ var createScope = (props) => createShape({
|
|
|
1797
1913
|
...props
|
|
1798
1914
|
});
|
|
1799
1915
|
var ScopeComponent = ({ shape }) => {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1916
|
+
var _effect = _useSignals18();
|
|
1917
|
+
try {
|
|
1918
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1919
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1920
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1921
|
+
const { getAverage } = useAudioStream(active);
|
|
1922
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1923
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
1924
|
+
}, /* @__PURE__ */ React18.createElement(Chaos, {
|
|
1925
|
+
active,
|
|
1926
|
+
getValue: getAverage,
|
|
1927
|
+
options: {
|
|
1928
|
+
...shaderPresets.heptapod,
|
|
1929
|
+
zoom: 1.2
|
|
1930
|
+
}
|
|
1931
|
+
}));
|
|
1932
|
+
} finally {
|
|
1933
|
+
_effect.f();
|
|
1934
|
+
}
|
|
1814
1935
|
};
|
|
1815
1936
|
var scopeShape = {
|
|
1816
1937
|
type: "scope",
|
|
@@ -1827,13 +1948,14 @@ var scopeShape = {
|
|
|
1827
1948
|
};
|
|
1828
1949
|
|
|
1829
1950
|
// packages/ui/react-ui-canvas-compute/src/shapes/Surface.tsx
|
|
1951
|
+
import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
|
|
1952
|
+
import { Schema as Schema18 } from "effect";
|
|
1830
1953
|
import React19 from "react";
|
|
1831
1954
|
import { Surface } from "@dxos/app-framework";
|
|
1832
1955
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1833
|
-
import { S as S18 } from "@dxos/echo-schema";
|
|
1834
1956
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1835
|
-
var SurfaceShape =
|
|
1836
|
-
type:
|
|
1957
|
+
var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1958
|
+
type: Schema18.Literal("surface")
|
|
1837
1959
|
}));
|
|
1838
1960
|
var createSurface = (props) => createShape({
|
|
1839
1961
|
type: "surface",
|
|
@@ -1844,24 +1966,29 @@ var createSurface = (props) => createShape({
|
|
|
1844
1966
|
...props
|
|
1845
1967
|
});
|
|
1846
1968
|
var SurfaceComponent = ({ shape }) => {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1969
|
+
var _effect = _useSignals19();
|
|
1970
|
+
try {
|
|
1971
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1972
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1973
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1974
|
+
const handleAction = (action) => {
|
|
1975
|
+
if (action === "run") {
|
|
1976
|
+
runtime.evalNode();
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
return /* @__PURE__ */ React19.createElement(Box, {
|
|
1980
|
+
shape,
|
|
1981
|
+
onAction: handleAction
|
|
1982
|
+
}, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
|
|
1983
|
+
role: "canvas-node",
|
|
1984
|
+
data: {
|
|
1985
|
+
value
|
|
1986
|
+
},
|
|
1987
|
+
limit: 1
|
|
1988
|
+
}));
|
|
1989
|
+
} finally {
|
|
1990
|
+
_effect.f();
|
|
1991
|
+
}
|
|
1865
1992
|
};
|
|
1866
1993
|
var surfaceShape = {
|
|
1867
1994
|
type: "surface",
|
|
@@ -1879,13 +2006,14 @@ var surfaceShape = {
|
|
|
1879
2006
|
};
|
|
1880
2007
|
|
|
1881
2008
|
// packages/ui/react-ui-canvas-compute/src/shapes/Switch.tsx
|
|
2009
|
+
import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
|
|
2010
|
+
import { Schema as Schema19 } from "effect";
|
|
1882
2011
|
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1883
2012
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1884
|
-
import { S as S19 } from "@dxos/echo-schema";
|
|
1885
2013
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1886
2014
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1887
|
-
var SwitchShape =
|
|
1888
|
-
type:
|
|
2015
|
+
var SwitchShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
2016
|
+
type: Schema19.Literal("switch")
|
|
1889
2017
|
}));
|
|
1890
2018
|
var createSwitch = (props) => createShape({
|
|
1891
2019
|
type: "switch",
|
|
@@ -1896,20 +2024,25 @@ var createSwitch = (props) => createShape({
|
|
|
1896
2024
|
...props
|
|
1897
2025
|
});
|
|
1898
2026
|
var SwitchComponent = ({ shape }) => {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
2027
|
+
var _effect = _useSignals20();
|
|
2028
|
+
try {
|
|
2029
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2030
|
+
const [value, setValue] = useState8(false);
|
|
2031
|
+
useEffect6(() => {
|
|
2032
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
2033
|
+
}, [
|
|
2034
|
+
value
|
|
2035
|
+
]);
|
|
2036
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
2037
|
+
className: "flex w-full justify-center items-center",
|
|
2038
|
+
onClick: (ev) => ev.stopPropagation()
|
|
2039
|
+
}, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
|
|
2040
|
+
checked: value,
|
|
2041
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
2042
|
+
})));
|
|
2043
|
+
} finally {
|
|
2044
|
+
_effect.f();
|
|
2045
|
+
}
|
|
1913
2046
|
};
|
|
1914
2047
|
var switchShape = {
|
|
1915
2048
|
type: "switch",
|
|
@@ -1926,13 +2059,14 @@ var switchShape = {
|
|
|
1926
2059
|
};
|
|
1927
2060
|
|
|
1928
2061
|
// packages/ui/react-ui-canvas-compute/src/shapes/Table.tsx
|
|
2062
|
+
import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
|
|
2063
|
+
import { Schema as Schema20 } from "effect";
|
|
1929
2064
|
import React21 from "react";
|
|
1930
2065
|
import { createInputSchema, createOutputSchema, GptMessage } from "@dxos/conductor";
|
|
1931
|
-
import { S as S20 } from "@dxos/echo-schema";
|
|
1932
2066
|
var InputSchema = createInputSchema(GptMessage);
|
|
1933
|
-
var OutputSchema = createOutputSchema(
|
|
1934
|
-
var TableShape =
|
|
1935
|
-
type:
|
|
2067
|
+
var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(GptMessage)));
|
|
2068
|
+
var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2069
|
+
type: Schema20.Literal("table")
|
|
1936
2070
|
}));
|
|
1937
2071
|
var createTable = (props) => createShape({
|
|
1938
2072
|
type: "table",
|
|
@@ -1943,9 +2077,14 @@ var createTable = (props) => createShape({
|
|
|
1943
2077
|
...props
|
|
1944
2078
|
});
|
|
1945
2079
|
var TableComponent = ({ shape }) => {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2080
|
+
var _effect = _useSignals21();
|
|
2081
|
+
try {
|
|
2082
|
+
return /* @__PURE__ */ React21.createElement(Box, {
|
|
2083
|
+
shape
|
|
2084
|
+
});
|
|
2085
|
+
} finally {
|
|
2086
|
+
_effect.f();
|
|
2087
|
+
}
|
|
1949
2088
|
};
|
|
1950
2089
|
var tableShape = {
|
|
1951
2090
|
type: "table",
|
|
@@ -1958,55 +2097,62 @@ var tableShape = {
|
|
|
1958
2097
|
};
|
|
1959
2098
|
|
|
1960
2099
|
// packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx
|
|
2100
|
+
import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
|
|
2101
|
+
import { Schema as Schema21 } from "effect";
|
|
1961
2102
|
import React22, { useRef as useRef5 } from "react";
|
|
1962
2103
|
import { ComputeValueType as ComputeValueType3, getTemplateInputSchema as getTemplateInputSchema2, TemplateOutput, VoidInput as VoidInput2 } from "@dxos/conductor";
|
|
1963
|
-
import {
|
|
2104
|
+
import { toJsonSchema as toJsonSchema2 } from "@dxos/echo-schema";
|
|
1964
2105
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1965
2106
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
1966
2107
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
1967
|
-
var TemplateShape =
|
|
1968
|
-
type:
|
|
1969
|
-
valueType:
|
|
2108
|
+
var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2109
|
+
type: Schema21.Literal("template"),
|
|
2110
|
+
valueType: Schema21.optional(ComputeValueType3)
|
|
1970
2111
|
}));
|
|
1971
2112
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
const
|
|
1976
|
-
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2113
|
+
var _effect = _useSignals22();
|
|
2114
|
+
try {
|
|
2115
|
+
const { node } = useComputeNodeState(shape);
|
|
2116
|
+
const inputRef = useRef5(null);
|
|
2117
|
+
const handleEnter = (text) => {
|
|
2118
|
+
const value = text.trim();
|
|
2119
|
+
if (value.length) {
|
|
2120
|
+
const schema = getTemplateInputSchema2(node);
|
|
2121
|
+
node.value = value;
|
|
2122
|
+
node.inputSchema = toJsonSchema2(schema);
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
const handleTypeChange = (newType) => {
|
|
2126
|
+
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2127
|
+
F: __dxlog_file6,
|
|
2128
|
+
L: 58,
|
|
2129
|
+
S: void 0,
|
|
2130
|
+
A: [
|
|
2131
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
2132
|
+
"'Invalid type'"
|
|
2133
|
+
]
|
|
2134
|
+
});
|
|
2135
|
+
node.valueType = newType;
|
|
2136
|
+
node.inputSchema = toJsonSchema2(getTemplateInputSchema2(node));
|
|
2137
|
+
};
|
|
2138
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
2139
|
+
shape,
|
|
2140
|
+
title: "Template",
|
|
2141
|
+
status: /* @__PURE__ */ React22.createElement(TypeSelect, {
|
|
2142
|
+
value: node.valueType ?? "string",
|
|
2143
|
+
onValueChange: handleTypeChange
|
|
2144
|
+
})
|
|
2145
|
+
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
2146
|
+
...props,
|
|
2147
|
+
ref: inputRef,
|
|
2148
|
+
value: node.value,
|
|
2149
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2150
|
+
onBlur: handleEnter,
|
|
2151
|
+
onEnter: handleEnter
|
|
2152
|
+
}));
|
|
2153
|
+
} finally {
|
|
2154
|
+
_effect.f();
|
|
2155
|
+
}
|
|
2010
2156
|
};
|
|
2011
2157
|
var createTemplate = (props) => createShape({
|
|
2012
2158
|
type: "template",
|
|
@@ -2030,13 +2176,14 @@ var templateShape = {
|
|
|
2030
2176
|
};
|
|
2031
2177
|
|
|
2032
2178
|
// packages/ui/react-ui-canvas-compute/src/shapes/Text.tsx
|
|
2179
|
+
import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
|
|
2180
|
+
import { Schema as Schema22 } from "effect";
|
|
2033
2181
|
import React23 from "react";
|
|
2034
2182
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2035
|
-
import { S as S22 } from "@dxos/echo-schema";
|
|
2036
2183
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2037
2184
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2038
|
-
var TextShape =
|
|
2039
|
-
type:
|
|
2185
|
+
var TextShape = Schema22.extend(ComputeShape, Schema22.Struct({
|
|
2186
|
+
type: Schema22.Literal("text")
|
|
2040
2187
|
}));
|
|
2041
2188
|
var createText = (props) => createShape({
|
|
2042
2189
|
type: "text",
|
|
@@ -2047,20 +2194,25 @@ var createText = (props) => createShape({
|
|
|
2047
2194
|
...props
|
|
2048
2195
|
});
|
|
2049
2196
|
var TextComponent = ({ shape }) => {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2197
|
+
var _effect = _useSignals23();
|
|
2198
|
+
try {
|
|
2199
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2200
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2201
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2202
|
+
const handleAction = (action) => {
|
|
2203
|
+
if (action === "run") {
|
|
2204
|
+
runtime.evalNode();
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2208
|
+
shape,
|
|
2209
|
+
onAction: handleAction
|
|
2210
|
+
}, /* @__PURE__ */ React23.createElement(TextBox5, {
|
|
2211
|
+
value
|
|
2212
|
+
}));
|
|
2213
|
+
} finally {
|
|
2214
|
+
_effect.f();
|
|
2215
|
+
}
|
|
2064
2216
|
};
|
|
2065
2217
|
var textShape = {
|
|
2066
2218
|
type: "text",
|
|
@@ -2078,14 +2230,15 @@ var textShape = {
|
|
|
2078
2230
|
};
|
|
2079
2231
|
|
|
2080
2232
|
// packages/ui/react-ui-canvas-compute/src/shapes/Thread.tsx
|
|
2233
|
+
import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
|
|
2234
|
+
import { Schema as Schema23 } from "effect";
|
|
2081
2235
|
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2082
2236
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2, GptMessage as GptMessage2 } from "@dxos/conductor";
|
|
2083
|
-
import { S as S23 } from "@dxos/echo-schema";
|
|
2084
2237
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
2085
2238
|
var InputSchema2 = createInputSchema2(GptMessage2);
|
|
2086
|
-
var OutputSchema2 = createOutputSchema2(
|
|
2087
|
-
var ThreadShape =
|
|
2088
|
-
type:
|
|
2239
|
+
var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(GptMessage2)));
|
|
2240
|
+
var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2241
|
+
type: Schema23.Literal("thread")
|
|
2089
2242
|
}));
|
|
2090
2243
|
var createThread = (props) => createShape({
|
|
2091
2244
|
type: "thread",
|
|
@@ -2096,39 +2249,49 @@ var createThread = (props) => createShape({
|
|
|
2096
2249
|
...props
|
|
2097
2250
|
});
|
|
2098
2251
|
var ThreadComponent = ({ shape }) => {
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
item
|
|
2118
|
-
|
|
2252
|
+
var _effect = _useSignals24();
|
|
2253
|
+
try {
|
|
2254
|
+
const items = [];
|
|
2255
|
+
const scrollRef = useRef6(null);
|
|
2256
|
+
useEffect7(() => {
|
|
2257
|
+
if (scrollRef.current) {
|
|
2258
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2259
|
+
}
|
|
2260
|
+
}, [
|
|
2261
|
+
items
|
|
2262
|
+
]);
|
|
2263
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2264
|
+
shape
|
|
2265
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2266
|
+
ref: scrollRef,
|
|
2267
|
+
className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
|
|
2268
|
+
}, [
|
|
2269
|
+
...items
|
|
2270
|
+
].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
|
|
2271
|
+
key: i,
|
|
2272
|
+
item
|
|
2273
|
+
}))));
|
|
2274
|
+
} finally {
|
|
2275
|
+
_effect.f();
|
|
2276
|
+
}
|
|
2119
2277
|
};
|
|
2120
2278
|
var ThreadItem = ({ classNames, item }) => {
|
|
2121
|
-
|
|
2279
|
+
var _effect = _useSignals24();
|
|
2280
|
+
try {
|
|
2281
|
+
if (typeof item !== "object") {
|
|
2282
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2283
|
+
className: mx5(classNames)
|
|
2284
|
+
}, item);
|
|
2285
|
+
}
|
|
2286
|
+
const { role, message } = item;
|
|
2122
2287
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2123
|
-
className: mx5(classNames)
|
|
2124
|
-
},
|
|
2288
|
+
className: mx5("flex", classNames, role === "user" && "justify-end")
|
|
2289
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2290
|
+
className: mx5("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2291
|
+
}, message));
|
|
2292
|
+
} finally {
|
|
2293
|
+
_effect.f();
|
|
2125
2294
|
}
|
|
2126
|
-
const { role, message } = item;
|
|
2127
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2128
|
-
className: mx5("flex", classNames, role === "user" && "justify-end")
|
|
2129
|
-
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2130
|
-
className: mx5("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2131
|
-
}, message));
|
|
2132
2295
|
};
|
|
2133
2296
|
var threadShape = {
|
|
2134
2297
|
type: "thread",
|
|
@@ -2141,11 +2304,12 @@ var threadShape = {
|
|
|
2141
2304
|
};
|
|
2142
2305
|
|
|
2143
2306
|
// packages/ui/react-ui-canvas-compute/src/shapes/TextToImage.tsx
|
|
2307
|
+
import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
|
|
2308
|
+
import { Schema as Schema24 } from "effect";
|
|
2144
2309
|
import React25 from "react";
|
|
2145
|
-
import { S as S24 } from "@dxos/echo-schema";
|
|
2146
2310
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2147
|
-
var TextToImageShape =
|
|
2148
|
-
type:
|
|
2311
|
+
var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2312
|
+
type: Schema24.Literal("text-to-image")
|
|
2149
2313
|
}));
|
|
2150
2314
|
var createTextToImage = (props) => createShape({
|
|
2151
2315
|
type: "text-to-image",
|
|
@@ -2156,9 +2320,14 @@ var createTextToImage = (props) => createShape({
|
|
|
2156
2320
|
...props
|
|
2157
2321
|
});
|
|
2158
2322
|
var TextToImageComponent = ({ shape }) => {
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2323
|
+
var _effect = _useSignals25();
|
|
2324
|
+
try {
|
|
2325
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2326
|
+
shape
|
|
2327
|
+
});
|
|
2328
|
+
} finally {
|
|
2329
|
+
_effect.f();
|
|
2330
|
+
}
|
|
2162
2331
|
};
|
|
2163
2332
|
var textToImageShape = {
|
|
2164
2333
|
type: "text-to-image",
|
|
@@ -2175,19 +2344,21 @@ var textToImageShape = {
|
|
|
2175
2344
|
};
|
|
2176
2345
|
|
|
2177
2346
|
// packages/ui/react-ui-canvas-compute/src/shapes/Trigger.tsx
|
|
2347
|
+
import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
|
|
2348
|
+
import { Schema as Schema25 } from "effect";
|
|
2178
2349
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2179
|
-
import {
|
|
2180
|
-
import { ObjectId as ObjectId4, Ref
|
|
2181
|
-
import { FunctionTrigger, TriggerKind } from "@dxos/functions
|
|
2182
|
-
import { DXN
|
|
2183
|
-
import {
|
|
2350
|
+
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2351
|
+
import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo-schema";
|
|
2352
|
+
import { FunctionTrigger, TriggerKind, EmailTriggerOutput, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, WebhookTriggerOutput } from "@dxos/functions";
|
|
2353
|
+
import { DXN, SpaceId } from "@dxos/keys";
|
|
2354
|
+
import { live, makeRef as makeRef2, useSpace } from "@dxos/react-client/echo";
|
|
2184
2355
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2185
|
-
var TriggerShape =
|
|
2186
|
-
type:
|
|
2187
|
-
functionTrigger:
|
|
2356
|
+
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2357
|
+
type: Schema25.Literal("trigger"),
|
|
2358
|
+
functionTrigger: Schema25.optional(Ref3(FunctionTrigger))
|
|
2188
2359
|
}));
|
|
2189
2360
|
var createTrigger = (props) => {
|
|
2190
|
-
const functionTrigger =
|
|
2361
|
+
const functionTrigger = live(FunctionTrigger, {
|
|
2191
2362
|
enabled: true,
|
|
2192
2363
|
spec: createTriggerSpec(props)
|
|
2193
2364
|
});
|
|
@@ -2202,87 +2373,97 @@ var createTrigger = (props) => {
|
|
|
2202
2373
|
});
|
|
2203
2374
|
};
|
|
2204
2375
|
var TriggerComponent = ({ shape }) => {
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2376
|
+
var _effect = _useSignals26();
|
|
2377
|
+
try {
|
|
2378
|
+
const space = useSpace();
|
|
2379
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2380
|
+
useEffect8(() => {
|
|
2381
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2382
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2383
|
+
triggerKind: TriggerKind.Email,
|
|
2384
|
+
spaceId: space?.id
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
}, [
|
|
2388
|
+
functionTrigger,
|
|
2389
|
+
functionTrigger?.spec
|
|
2390
|
+
]);
|
|
2391
|
+
useEffect8(() => {
|
|
2392
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? TriggerKind.Email));
|
|
2393
|
+
}, [
|
|
2394
|
+
functionTrigger?.spec?.kind
|
|
2395
|
+
]);
|
|
2396
|
+
const setKind = (kind) => {
|
|
2397
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2398
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2399
|
+
triggerKind: kind,
|
|
2400
|
+
spaceId: space?.id
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
if (!functionTrigger?.spec) {
|
|
2405
|
+
return;
|
|
2229
2406
|
}
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2407
|
+
return /* @__PURE__ */ React26.createElement(FunctionBody, {
|
|
2408
|
+
shape,
|
|
2409
|
+
status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
|
|
2410
|
+
value: functionTrigger.spec?.kind,
|
|
2411
|
+
onValueChange: (kind) => setKind(kind)
|
|
2412
|
+
}),
|
|
2413
|
+
inputSchema: VoidInput3,
|
|
2414
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2415
|
+
});
|
|
2416
|
+
} finally {
|
|
2417
|
+
_effect.f();
|
|
2233
2418
|
}
|
|
2234
|
-
return /* @__PURE__ */ React26.createElement(FunctionBody, {
|
|
2235
|
-
shape,
|
|
2236
|
-
status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
|
|
2237
|
-
value: functionTrigger.spec?.type,
|
|
2238
|
-
onValueChange: (kind) => setKind(kind)
|
|
2239
|
-
}),
|
|
2240
|
-
inputSchema: VoidInput3,
|
|
2241
|
-
outputSchema: getOutputSchema(functionTrigger.spec.type)
|
|
2242
|
-
});
|
|
2243
2419
|
};
|
|
2244
2420
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2421
|
+
var _effect = _useSignals26();
|
|
2422
|
+
try {
|
|
2423
|
+
return /* @__PURE__ */ React26.createElement(Select2.Root, {
|
|
2424
|
+
value,
|
|
2425
|
+
onValueChange
|
|
2426
|
+
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2427
|
+
variant: "ghost",
|
|
2428
|
+
classNames: "w-full !px-0"
|
|
2429
|
+
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Object.values(TriggerKind).map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
|
|
2430
|
+
key: kind,
|
|
2431
|
+
value: kind
|
|
2432
|
+
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2433
|
+
} finally {
|
|
2434
|
+
_effect.f();
|
|
2435
|
+
}
|
|
2255
2436
|
};
|
|
2256
2437
|
var createTriggerSpec = (props) => {
|
|
2257
2438
|
const kind = props.triggerKind ?? TriggerKind.Email;
|
|
2258
2439
|
switch (kind) {
|
|
2259
2440
|
case TriggerKind.Timer:
|
|
2260
2441
|
return {
|
|
2261
|
-
|
|
2442
|
+
kind: TriggerKind.Timer,
|
|
2262
2443
|
cron: "*/10 * * * * *"
|
|
2263
2444
|
};
|
|
2264
2445
|
case TriggerKind.Webhook:
|
|
2265
2446
|
return {
|
|
2266
|
-
|
|
2447
|
+
kind: TriggerKind.Webhook,
|
|
2267
2448
|
method: "POST"
|
|
2268
2449
|
};
|
|
2269
2450
|
case TriggerKind.Subscription:
|
|
2270
2451
|
return {
|
|
2271
|
-
|
|
2452
|
+
kind: TriggerKind.Subscription,
|
|
2272
2453
|
filter: {}
|
|
2273
2454
|
};
|
|
2274
2455
|
case TriggerKind.Email:
|
|
2275
2456
|
return {
|
|
2276
|
-
|
|
2457
|
+
kind: TriggerKind.Email
|
|
2277
2458
|
};
|
|
2278
2459
|
case TriggerKind.Queue: {
|
|
2279
|
-
const dxn = new
|
|
2460
|
+
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2280
2461
|
"data",
|
|
2281
2462
|
props.spaceId ?? SpaceId.random(),
|
|
2282
2463
|
ObjectId4.random()
|
|
2283
2464
|
]).toString();
|
|
2284
2465
|
return {
|
|
2285
|
-
|
|
2466
|
+
kind: TriggerKind.Queue,
|
|
2286
2467
|
queue: dxn
|
|
2287
2468
|
};
|
|
2288
2469
|
}
|
|
@@ -2304,18 +2485,19 @@ var triggerShape = {
|
|
|
2304
2485
|
icon: "ph--lightning--regular",
|
|
2305
2486
|
component: TriggerComponent,
|
|
2306
2487
|
createShape: createTrigger,
|
|
2307
|
-
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.
|
|
2488
|
+
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? TriggerKind.Email))
|
|
2308
2489
|
};
|
|
2309
2490
|
|
|
2310
2491
|
// packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx
|
|
2492
|
+
import { useSignals as _useSignals27 } from "@preact-signals/safe-react/tracking";
|
|
2493
|
+
import { Schema as Schema26 } from "effect";
|
|
2311
2494
|
import React27, { useState as useState9 } from "react";
|
|
2312
|
-
import { S as S26 } from "@dxos/echo-schema";
|
|
2313
2495
|
import { log as log2 } from "@dxos/log";
|
|
2314
2496
|
import { useConfig } from "@dxos/react-client";
|
|
2315
2497
|
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2316
2498
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2317
|
-
var GptRealtimeShape =
|
|
2318
|
-
type:
|
|
2499
|
+
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2500
|
+
type: Schema26.Literal("gpt-realtime")
|
|
2319
2501
|
}));
|
|
2320
2502
|
var createGptRealtime = (props) => createShape({
|
|
2321
2503
|
type: "gpt-realtime",
|
|
@@ -2326,100 +2508,105 @@ var createGptRealtime = (props) => createShape({
|
|
|
2326
2508
|
...props
|
|
2327
2509
|
});
|
|
2328
2510
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
direction: "sendrecv"
|
|
2350
|
-
}));
|
|
2351
|
-
const offer = await peerConnection.createOffer();
|
|
2352
|
-
await peerConnection.setLocalDescription(offer);
|
|
2353
|
-
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2354
|
-
const response = await fetch(aiServiceUrl, {
|
|
2355
|
-
method: "POST",
|
|
2356
|
-
body: offer.sdp,
|
|
2357
|
-
headers: {
|
|
2358
|
-
"Content-Type": "application/sdp"
|
|
2359
|
-
}
|
|
2360
|
-
});
|
|
2361
|
-
const answer = await response.text();
|
|
2362
|
-
await peerConnection.setRemoteDescription({
|
|
2363
|
-
sdp: answer,
|
|
2364
|
-
type: "answer"
|
|
2365
|
-
});
|
|
2366
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2367
|
-
const configureData = () => {
|
|
2368
|
-
log2.info("Configuring data channel", void 0, {
|
|
2369
|
-
F: __dxlog_file7,
|
|
2370
|
-
L: 87,
|
|
2371
|
-
S: void 0,
|
|
2372
|
-
C: (f, a) => f(...a)
|
|
2511
|
+
var _effect = _useSignals27();
|
|
2512
|
+
try {
|
|
2513
|
+
const [isLive, setIsLive] = useState9(false);
|
|
2514
|
+
const [isReady, setIsReady] = useState9(false);
|
|
2515
|
+
const config = useConfig();
|
|
2516
|
+
const start = async () => {
|
|
2517
|
+
setIsLive(true);
|
|
2518
|
+
try {
|
|
2519
|
+
const peerConnection = new RTCPeerConnection();
|
|
2520
|
+
peerConnection.ontrack = (event) => {
|
|
2521
|
+
const audioElement = document.createElement("audio");
|
|
2522
|
+
audioElement.srcObject = event.streams[0];
|
|
2523
|
+
audioElement.autoplay = true;
|
|
2524
|
+
audioElement.controls = false;
|
|
2525
|
+
audioElement.style.display = "none";
|
|
2526
|
+
document.body.appendChild(audioElement);
|
|
2527
|
+
setIsReady(true);
|
|
2528
|
+
};
|
|
2529
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2530
|
+
audio: true
|
|
2373
2531
|
});
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2532
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2533
|
+
direction: "sendrecv"
|
|
2534
|
+
}));
|
|
2535
|
+
const offer = await peerConnection.createOffer();
|
|
2536
|
+
await peerConnection.setLocalDescription(offer);
|
|
2537
|
+
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2538
|
+
const response = await fetch(aiServiceUrl, {
|
|
2539
|
+
method: "POST",
|
|
2540
|
+
body: offer.sdp,
|
|
2541
|
+
headers: {
|
|
2542
|
+
"Content-Type": "application/sdp"
|
|
2383
2543
|
}
|
|
2544
|
+
});
|
|
2545
|
+
const answer = await response.text();
|
|
2546
|
+
await peerConnection.setRemoteDescription({
|
|
2547
|
+
sdp: answer,
|
|
2548
|
+
type: "answer"
|
|
2549
|
+
});
|
|
2550
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
2551
|
+
const configureData = () => {
|
|
2552
|
+
log2.info("Configuring data channel", void 0, {
|
|
2553
|
+
F: __dxlog_file7,
|
|
2554
|
+
L: 87,
|
|
2555
|
+
S: void 0,
|
|
2556
|
+
C: (f, a) => f(...a)
|
|
2557
|
+
});
|
|
2558
|
+
const event = {
|
|
2559
|
+
type: "session.update",
|
|
2560
|
+
session: {
|
|
2561
|
+
modalities: [
|
|
2562
|
+
"text",
|
|
2563
|
+
"audio"
|
|
2564
|
+
],
|
|
2565
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2566
|
+
tools: []
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2569
|
+
dataChannel.send(JSON.stringify(event));
|
|
2384
2570
|
};
|
|
2385
|
-
dataChannel.
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2571
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
2572
|
+
log2.info("Opening data channel", {
|
|
2573
|
+
ev
|
|
2574
|
+
}, {
|
|
2575
|
+
F: __dxlog_file7,
|
|
2576
|
+
L: 100,
|
|
2577
|
+
S: void 0,
|
|
2578
|
+
C: (f, a) => f(...a)
|
|
2579
|
+
});
|
|
2580
|
+
configureData();
|
|
2581
|
+
});
|
|
2582
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
2583
|
+
const msg = JSON.parse(ev.data);
|
|
2584
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
} catch (error) {
|
|
2588
|
+
log2.error("Error in realtime session:", {
|
|
2589
|
+
error
|
|
2390
2590
|
}, {
|
|
2391
2591
|
F: __dxlog_file7,
|
|
2392
|
-
L:
|
|
2592
|
+
L: 140,
|
|
2393
2593
|
S: void 0,
|
|
2394
2594
|
C: (f, a) => f(...a)
|
|
2395
2595
|
});
|
|
2396
|
-
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
C: (f, a) => f(...a)
|
|
2411
|
-
});
|
|
2412
|
-
throw error;
|
|
2413
|
-
}
|
|
2414
|
-
};
|
|
2415
|
-
return /* @__PURE__ */ React27.createElement("div", {
|
|
2416
|
-
className: "flex w-full justify-center items-center"
|
|
2417
|
-
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2418
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2419
|
-
size: 16,
|
|
2420
|
-
classNames: !isLive && "cursor-pointer",
|
|
2421
|
-
onClick: start
|
|
2422
|
-
}));
|
|
2596
|
+
throw error;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
return /* @__PURE__ */ React27.createElement("div", {
|
|
2600
|
+
className: "flex w-full justify-center items-center"
|
|
2601
|
+
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2602
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2603
|
+
size: 16,
|
|
2604
|
+
classNames: !isLive && "cursor-pointer",
|
|
2605
|
+
onClick: start
|
|
2606
|
+
}));
|
|
2607
|
+
} finally {
|
|
2608
|
+
_effect.f();
|
|
2609
|
+
}
|
|
2423
2610
|
};
|
|
2424
2611
|
var gptRealtimeShape = {
|
|
2425
2612
|
type: "gpt-realtime",
|
|
@@ -2428,9 +2615,9 @@ var gptRealtimeShape = {
|
|
|
2428
2615
|
component: GptRealtimeComponent,
|
|
2429
2616
|
createShape: createGptRealtime,
|
|
2430
2617
|
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
2431
|
-
getAnchors: (shape) => createFunctionAnchors(shape,
|
|
2432
|
-
audio:
|
|
2433
|
-
}),
|
|
2618
|
+
getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
|
|
2619
|
+
audio: Schema26.Any
|
|
2620
|
+
}), Schema26.Struct({})),
|
|
2434
2621
|
resizable: true
|
|
2435
2622
|
};
|
|
2436
2623
|
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
@@ -2503,8 +2690,7 @@ import { toEffectSchema } from "@dxos/echo-schema";
|
|
|
2503
2690
|
import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
|
|
2504
2691
|
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2505
2692
|
constructor(_controller, registry2) {
|
|
2506
|
-
super(registry2);
|
|
2507
|
-
this._controller = _controller;
|
|
2693
|
+
super(registry2), this._controller = _controller;
|
|
2508
2694
|
}
|
|
2509
2695
|
// TODO(burdon): Doesn't update.
|
|
2510
2696
|
getAnchors(shape) {
|