@dxos/react-ui-canvas-compute 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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.
@@ -367,19 +367,9 @@ var createComputeGraphController = (graph, services) => {
367
367
  };
368
368
  var ComputeGraphController = class extends Resource {
369
369
  constructor(_graph) {
370
- super();
371
- this._graph = _graph;
372
- this._executor = new GraphExecutor({
370
+ super(), this._graph = _graph, this._executor = new GraphExecutor({
373
371
  computeNodeResolver: (node) => resolveComputeNode(node)
374
- });
375
- this._diagnostics = [];
376
- this._services = {};
377
- this._forcedOutputs = {};
378
- this._runtimeStateInputs = {};
379
- this._runtimeStateOutputs = {};
380
- this.update = new Event();
381
- this.output = new Event();
382
- 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();
383
373
  }
384
374
  toJSON() {
385
375
  return {
@@ -647,6 +637,7 @@ var computeValueBag = (bag) => {
647
637
  import { noteShape } from "@dxos/react-ui-canvas-editor";
648
638
 
649
639
  // packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx
640
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
650
641
  import React, { forwardRef } from "react";
651
642
  import { invariant as invariant4 } from "@dxos/invariant";
652
643
  import { Icon, IconButton } from "@dxos/react-ui";
@@ -656,62 +647,68 @@ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-com
656
647
  var headerHeight = 32;
657
648
  var footerHeight = 32;
658
649
  var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
659
- invariant4(shape.type, void 0, {
660
- F: __dxlog_file5,
661
- L: 30,
662
- S: void 0,
663
- A: [
664
- "shape.type",
665
- ""
666
- ]
667
- });
668
- const { icon, name, openable } = useShapeDef(shape.type) ?? {
669
- icon: "ph--placeholder--regular"
670
- };
671
- const { debug } = useEditorContext();
672
- return /* @__PURE__ */ React.createElement("div", {
673
- ref: forwardedRef,
674
- className: "flex flex-col h-full w-full justify-between"
675
- }, /* @__PURE__ */ React.createElement("div", {
676
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
677
- }, /* @__PURE__ */ React.createElement(Icon, {
678
- icon,
679
- classNames: "mx-2"
680
- }), /* @__PURE__ */ React.createElement("div", {
681
- className: "grow text-sm truncate"
682
- }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
683
- classNames: "p-1 text-green-500",
684
- variant: "ghost",
685
- icon: "ph--play--regular",
686
- size: 4,
687
- label: "run",
688
- iconOnly: true,
689
- onDoubleClick: (ev) => ev.stopPropagation(),
690
- onClick: (ev) => {
691
- ev.stopPropagation();
692
- onAction?.("run");
693
- }
694
- })), /* @__PURE__ */ React.createElement("div", {
695
- className: mx("flex flex-col h-full grow overflow-hidden", classNames)
696
- }, children), /* @__PURE__ */ React.createElement("div", {
697
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
698
- }, /* @__PURE__ */ React.createElement("div", {
699
- className: "grow px-2 text-sm truncate"
700
- }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
701
- classNames: "p-1",
702
- variant: "ghost",
703
- icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
704
- size: 4,
705
- label: open ? "close" : "open",
706
- iconOnly: true,
707
- onClick: (ev) => {
708
- ev.stopPropagation();
709
- onAction?.(open ? "close" : "open");
710
- }
711
- })));
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
+ }
712
708
  });
713
709
 
714
710
  // packages/ui/react-ui-canvas-compute/src/shapes/common/FunctionBody.tsx
711
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
715
712
  import { SchemaAST as SchemaAST2 } from "effect";
716
713
  import React2, { useRef, useState as useState3 } from "react";
717
714
  import { VoidInput, VoidOutput } from "@dxos/conductor";
@@ -740,7 +737,7 @@ var parseAnchorId = (id) => {
740
737
  var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
741
738
  // TODO(burdon): Rename computeNode?
742
739
  node: Schema2.optional(ObjectId3.annotations({
743
- [SchemaAST.DescriptionAnnotationId]: "Compute node id"
740
+ description: "Compute node id"
744
741
  }))
745
742
  }).pipe(Schema2.mutable));
746
743
  var createShape = ({ id, ...rest }) => {
@@ -754,65 +751,70 @@ var createShape = ({ id, ...rest }) => {
754
751
  var bodyPadding = 8;
755
752
  var expandedHeight = 200;
756
753
  var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
757
- const { scale } = useCanvasContext();
758
- const rootRef = useRef(null);
759
- const [open, setOpen] = useState3(false);
760
- const handleAction = (action) => {
761
- if (!rootRef.current) {
762
- return;
763
- }
764
- switch (action) {
765
- case "open": {
766
- const el = getParentShapeElement(rootRef.current, shape.id);
767
- const { height } = el.getBoundingClientRect();
768
- el.style.height = `${height / scale + expandedHeight}px`;
769
- setOpen(true);
770
- 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;
771
762
  }
772
- case "close": {
773
- const el = getParentShapeElement(rootRef.current, shape.id);
774
- el.style.height = "";
775
- setOpen(false);
776
- break;
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
+ }
777
777
  }
778
- }
779
- };
780
- const inputs = getProperties(inputSchema.ast);
781
- const outputs = getProperties(outputSchema.ast);
782
- const columnCount = inputs.length && outputs.length ? 2 : 1;
783
- return /* @__PURE__ */ React2.createElement(Box, {
784
- ref: rootRef,
785
- shape,
786
- title: name,
787
- classNames: "divide-y divide-separator",
788
- open,
789
- onAction: handleAction,
790
- ...props
791
- }, /* @__PURE__ */ React2.createElement("div", {
792
- className: `grid grid-cols-${columnCount} items-center`,
793
- style: {
794
- paddingTop: bodyPadding,
795
- paddingBottom: bodyPadding
796
- }
797
- }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
798
- className: "flex flex-col"
799
- }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
800
- key: name2,
801
- className: "px-2 truncate text-sm font-mono items-center",
802
- style: {
803
- height: rowHeight
804
- }
805
- }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
806
- className: "flex flex-col"
807
- }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
808
- key: name2,
809
- className: "px-2 truncate text-sm font-mono items-center text-right",
810
- style: {
811
- height: rowHeight
812
- }
813
- }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
814
- className: "flex flex-col grow overflow-hidden"
815
- }, content));
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
+ }
816
818
  };
817
819
  var getHeight = (input) => {
818
820
  const properties = SchemaAST2.getPropertySignatures(input.ast);
@@ -833,23 +835,30 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
833
835
  };
834
836
 
835
837
  // packages/ui/react-ui-canvas-compute/src/shapes/common/TypeSelect.tsx
838
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
836
839
  import React3 from "react";
837
840
  import { ComputeValueType } from "@dxos/conductor";
838
841
  import { Select } from "@dxos/react-ui";
839
842
  var TypeSelect = ({ value, onValueChange }) => {
840
- return /* @__PURE__ */ React3.createElement(Select.Root, {
841
- value,
842
- onValueChange
843
- }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
844
- variant: "ghost",
845
- classNames: "w-full !px-0"
846
- }), /* @__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, {
847
- key: type,
848
- value: type
849
- }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
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
+ }
850
858
  };
851
859
 
852
860
  // packages/ui/react-ui-canvas-compute/src/shapes/Array.tsx
861
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
853
862
  import { Schema as Schema3 } from "effect";
854
863
  import React4 from "react";
855
864
  import { ReducerInput, ReducerOutput } from "@dxos/conductor";
@@ -857,11 +866,16 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
857
866
  type: Schema3.Literal("reducer")
858
867
  }));
859
868
  var ReducerComponent = ({ shape }) => {
860
- return /* @__PURE__ */ React4.createElement(FunctionBody, {
861
- shape,
862
- inputSchema: ReducerInput,
863
- outputSchema: ReducerOutput
864
- });
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
+ }
865
879
  };
866
880
  var createReducer = ({ id, size = {
867
881
  width: 192,
@@ -881,6 +895,7 @@ var reducerShape = {
881
895
  };
882
896
 
883
897
  // packages/ui/react-ui-canvas-compute/src/shapes/Append.tsx
898
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
884
899
  import { Schema as Schema4 } from "effect";
885
900
  import React5 from "react";
886
901
  import { AppendInput } from "@dxos/conductor";
@@ -896,10 +911,15 @@ var createAppend = (props) => createShape({
896
911
  ...props
897
912
  });
898
913
  var AppendComponent = ({ shape }) => {
899
- return /* @__PURE__ */ React5.createElement(FunctionBody, {
900
- shape,
901
- inputSchema: AppendInput
902
- });
914
+ var _effect = _useSignals5();
915
+ try {
916
+ return /* @__PURE__ */ React5.createElement(FunctionBody, {
917
+ shape,
918
+ inputSchema: AppendInput
919
+ });
920
+ } finally {
921
+ _effect.f();
922
+ }
903
923
  };
904
924
  var appendShape = {
905
925
  type: "append",
@@ -911,6 +931,7 @@ var appendShape = {
911
931
  };
912
932
 
913
933
  // packages/ui/react-ui-canvas-compute/src/shapes/Audio.tsx
934
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
914
935
  import { Schema as Schema5 } from "effect";
915
936
  import React6, { useEffect as useEffect3, useState as useState4 } from "react";
916
937
  import { Icon as Icon2 } from "@dxos/react-ui";
@@ -927,24 +948,29 @@ var createAudio = (props) => createShape({
927
948
  ...props
928
949
  });
929
950
  var AudioComponent = ({ shape }) => {
930
- const { node } = useComputeNodeState(shape);
931
- const [active, setActive] = useState4(false);
932
- useEffect3(() => {
933
- node.value = active;
934
- }, [
935
- active
936
- ]);
937
- return /* @__PURE__ */ React6.createElement("div", {
938
- className: "flex w-full justify-center items-center"
939
- }, /* @__PURE__ */ React6.createElement(Icon2, {
940
- icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
941
- classNames: [
942
- "transition opacity-20 duration-1000",
943
- active && "opacity-100 text-red-500"
944
- ],
945
- size: 8,
946
- onClick: () => setActive(!active)
947
- }));
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
+ }
948
974
  };
949
975
  var audioShape = {
950
976
  type: "audio",
@@ -961,6 +987,7 @@ var audioShape = {
961
987
  };
962
988
 
963
989
  // packages/ui/react-ui-canvas-compute/src/shapes/Beacon.tsx
990
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
964
991
  import { Schema as Schema6 } from "effect";
965
992
  import React7 from "react";
966
993
  import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
@@ -979,16 +1006,21 @@ var createBeacon = (props) => createShape({
979
1006
  ...props
980
1007
  });
981
1008
  var BeaconComponent = ({ shape }) => {
982
- const { runtime } = useComputeNodeState(shape);
983
- const input = runtime.inputs[DEFAULT_INPUT3];
984
- const value = input?.type === "executed" ? input.value : false;
985
- return /* @__PURE__ */ React7.createElement("div", {
986
- className: "flex w-full justify-center items-center"
987
- }, /* @__PURE__ */ React7.createElement(Icon3, {
988
- icon: "ph--sun--regular",
989
- classNames: mx2("transition opacity-20 duration-1000", isTruthy(value) && "opacity-100 text-yellow-500"),
990
- size: 8
991
- }));
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
+ }
992
1024
  };
993
1025
  var beaconShape = {
994
1026
  type: "beacon",
@@ -1005,6 +1037,7 @@ var beaconShape = {
1005
1037
  };
1006
1038
 
1007
1039
  // packages/ui/react-ui-canvas-compute/src/shapes/Boolean.tsx
1040
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1008
1041
  import { Schema as Schema7 } from "effect";
1009
1042
  import React8 from "react";
1010
1043
  import { createAnchors as createAnchors2, getAnchorPoints } from "@dxos/react-ui-canvas-editor";
@@ -1018,10 +1051,17 @@ var createGate = (props) => createShape({
1018
1051
  },
1019
1052
  ...props
1020
1053
  });
1021
- var GateComponent = (Symbol2) => () => {
1022
- return /* @__PURE__ */ React8.createElement("div", {
1023
- className: "flex w-full justify-center items-center"
1024
- }, /* @__PURE__ */ React8.createElement(Symbol2, null));
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
+ }
1025
1065
  };
1026
1066
  var defineShape = ({ type, name, icon, Symbol: Symbol2, createShape: createShape2, inputs, outputs = [
1027
1067
  createAnchorId("output")
@@ -1037,48 +1077,55 @@ var defineShape = ({ type, name, icon, Symbol: Symbol2, createShape: createShape
1037
1077
  outputs
1038
1078
  })
1039
1079
  });
1040
- var Symbol = (pathConstructor, inputs) => ({
1041
- width = 64,
1042
- height = 32,
1043
- // TODO(burdon): Same as line color.
1044
- className = "fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500",
1045
- strokeWidth = 1
1046
- }) => {
1047
- const startX = width * 0.25;
1048
- const endX = width * 0.75;
1049
- const centerY = height / 2;
1050
- const paths = pathConstructor({
1051
- startX,
1052
- endX,
1053
- height
1054
- });
1055
- return /* @__PURE__ */ React8.createElement("svg", {
1056
- viewBox: `0 0 ${width} ${height}`,
1057
- className: "w-full h-full"
1058
- }, getAnchorPoints({
1059
- x: 0,
1060
- y: centerY
1061
- }, inputs).map(({ x, y }, i) => /* @__PURE__ */ React8.createElement("line", {
1062
- key: i,
1063
- x1: x,
1064
- y1: y,
1065
- x2: startX * 1.3,
1066
- y2: y,
1067
- strokeWidth,
1068
- className
1069
- })), /* @__PURE__ */ React8.createElement("line", {
1070
- x1: endX,
1071
- y1: centerY,
1072
- x2: width,
1073
- y2: centerY,
1074
- strokeWidth,
1075
- className
1076
- }), paths.map((path, i) => /* @__PURE__ */ React8.createElement("path", {
1077
- key: i,
1078
- d: path,
1079
- strokeWidth,
1080
- className
1081
- })));
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
+ }
1082
1129
  };
1083
1130
  var AndSymbol = Symbol(({ startX, endX, height }) => {
1084
1131
  const arcRadius = (endX - startX) / 2;
@@ -1176,6 +1223,7 @@ var notShape = defineShape({
1176
1223
  });
1177
1224
 
1178
1225
  // packages/ui/react-ui-canvas-compute/src/shapes/Chat.tsx
1226
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1179
1227
  import { Schema as Schema8 } from "effect";
1180
1228
  import React9, { useRef as useRef2 } from "react";
1181
1229
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
@@ -1185,23 +1233,28 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
1185
1233
  type: Schema8.Literal("chat")
1186
1234
  }));
1187
1235
  var TextInputComponent = ({ shape, title, ...props }) => {
1188
- const { runtime } = useComputeNodeState(shape);
1189
- const inputRef = useRef2(null);
1190
- const handleEnter = (text) => {
1191
- const value = text.trim();
1192
- if (value.length) {
1193
- runtime.setOutput(DEFAULT_OUTPUT3, value);
1194
- inputRef.current?.setText("");
1195
- }
1196
- };
1197
- return /* @__PURE__ */ React9.createElement(Box, {
1198
- shape,
1199
- title
1200
- }, /* @__PURE__ */ React9.createElement(TextBox, {
1201
- ref: inputRef,
1202
- onEnter: handleEnter,
1203
- ...props
1204
- }));
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
+ }
1205
1258
  };
1206
1259
  var createChat = (props) => createShape({
1207
1260
  type: "chat",
@@ -1231,6 +1284,7 @@ var chatShape = {
1231
1284
  };
1232
1285
 
1233
1286
  // packages/ui/react-ui-canvas-compute/src/shapes/Constant.tsx
1287
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1234
1288
  import { Schema as Schema9 } from "effect";
1235
1289
  import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
1236
1290
  import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
@@ -1254,52 +1308,57 @@ var inferType = (value) => {
1254
1308
  }
1255
1309
  };
1256
1310
  var ConstantComponent = ({ shape, title, chat, ...props }) => {
1257
- const { node } = useComputeNodeState(shape);
1258
- const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1259
- const inputRef = useRef3(null);
1260
- const handleEnter = useCallback2((text) => {
1261
- const value = text.trim();
1262
- if (value.length) {
1263
- if (type === "number") {
1264
- const floatValue = parseFloat(value);
1265
- if (!isNaN(floatValue)) {
1266
- node.value = floatValue;
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;
1267
1328
  }
1268
- } else if (type === "object") {
1269
- node.value = safeParseJson(value, {});
1270
- } else {
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) => {
1271
1356
  node.value = value;
1272
1357
  }
1273
- inputRef.current?.focus();
1274
- }
1275
- }, [
1276
- type
1277
- ]);
1278
- return /* @__PURE__ */ React10.createElement(Box, {
1279
- shape,
1280
- title,
1281
- status: /* @__PURE__ */ React10.createElement(TypeSelect, {
1282
- value: type,
1283
- onValueChange: setType
1284
- })
1285
- }, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
1286
- ...props,
1287
- ref: inputRef,
1288
- value: node.value,
1289
- onEnter: handleEnter
1290
- }), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
1291
- ...props,
1292
- ref: inputRef,
1293
- value: JSON.stringify(node.value, null, 2),
1294
- language: "json"
1295
- }), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
1296
- className: "flex grow justify-center items-center"
1297
- }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
1298
- checked: node.value,
1299
- onCheckedChange: (value) => {
1300
- node.value = value;
1301
- }
1302
- }))));
1358
+ }))));
1359
+ } finally {
1360
+ _effect.f();
1361
+ }
1303
1362
  };
1304
1363
  var createConstant = (props) => createShape({
1305
1364
  type: "constant",
@@ -1328,6 +1387,7 @@ var constantShape = {
1328
1387
  };
1329
1388
 
1330
1389
  // packages/ui/react-ui-canvas-compute/src/shapes/Database.tsx
1390
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1331
1391
  import { Schema as Schema10 } from "effect";
1332
1392
  import React11 from "react";
1333
1393
  import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
@@ -1343,9 +1403,14 @@ var createDatabase = (props) => createShape({
1343
1403
  ...props
1344
1404
  });
1345
1405
  var DatabaseComponent = ({ shape }) => {
1346
- return /* @__PURE__ */ React11.createElement(Box, {
1347
- shape
1348
- });
1406
+ var _effect = _useSignals11();
1407
+ try {
1408
+ return /* @__PURE__ */ React11.createElement(Box, {
1409
+ shape
1410
+ });
1411
+ } finally {
1412
+ _effect.f();
1413
+ }
1349
1414
  };
1350
1415
  var databaseShape = {
1351
1416
  type: "database",
@@ -1362,6 +1427,7 @@ var databaseShape = {
1362
1427
  };
1363
1428
 
1364
1429
  // packages/ui/react-ui-canvas-compute/src/shapes/Function.tsx
1430
+ import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1365
1431
  import { Schema as Schema11 } from "effect";
1366
1432
  import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
1367
1433
  import { AnyOutput, FunctionInput } from "@dxos/conductor";
@@ -1382,54 +1448,59 @@ var createFunction = (props) => createShape({
1382
1448
  ...props
1383
1449
  });
1384
1450
  var TextInputComponent2 = ({ shape, title, ...props }) => {
1385
- const client = useClient();
1386
- const { node, runtime } = useComputeNodeState(shape);
1387
- const inputRef = useRef4(null);
1388
- const handleEnter = useCallback3(async (text) => {
1389
- const value = text.trim();
1390
- const { spaceId, objectId } = parseId(value);
1391
- if (!spaceId || !objectId) {
1392
- return;
1393
- }
1394
- const space = client.spaces.get(spaceId);
1395
- const object = space?.db.getObjectById(objectId);
1396
- if (!space || !isInstanceOf(ScriptType, object)) {
1397
- return;
1398
- }
1399
- const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
1400
- source: Ref2.make(object)
1401
- })).run();
1402
- if (!fn) {
1403
- return;
1404
- }
1405
- node.value = value;
1406
- node.function = makeRef(fn);
1407
- node.inputSchema = getSnapshot(fn.inputSchema);
1408
- node.outputSchema = getSnapshot(fn.outputSchema);
1409
- }, [
1410
- client,
1411
- node
1412
- ]);
1413
- const handleAction = useCallback3((action) => {
1414
- if (action !== "run") {
1415
- return;
1416
- }
1417
- runtime.evalNode();
1418
- }, [
1419
- runtime
1420
- ]);
1421
- return /* @__PURE__ */ React12.createElement(Box, {
1422
- shape,
1423
- title: "Function",
1424
- onAction: handleAction
1425
- }, /* @__PURE__ */ React12.createElement(TextBox3, {
1426
- ...props,
1427
- ref: inputRef,
1428
- value: node.value,
1429
- language: node.valueType === "object" ? "json" : void 0,
1430
- onBlur: handleEnter,
1431
- onEnter: handleEnter
1432
- }));
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
+ }
1433
1504
  };
1434
1505
  var functionShape = {
1435
1506
  type: "function",
@@ -1441,6 +1512,7 @@ var functionShape = {
1441
1512
  };
1442
1513
 
1443
1514
  // packages/ui/react-ui-canvas-compute/src/shapes/Gpt.tsx
1515
+ import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1444
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";
@@ -1456,49 +1528,54 @@ var createGpt = (props) => createShape({
1456
1528
  ...props
1457
1529
  });
1458
1530
  var GptComponent = ({ shape }) => {
1459
- const { meta, runtime } = useComputeNodeState(shape);
1460
- const [text, setText] = useState6("");
1461
- const [tokens, setTokens] = useState6(0);
1462
- useEffect4(() => {
1463
- return runtime.subscribeToEventLog((ev) => {
1464
- switch (ev.type) {
1465
- case "begin-compute": {
1466
- setText("");
1467
- break;
1468
- }
1469
- case "custom": {
1470
- const token = ev.event;
1471
- switch (token.type) {
1472
- case "content_block_delta":
1473
- switch (token.delta.type) {
1474
- case "text_delta": {
1475
- const delta = token.delta.text;
1476
- setText((prev) => {
1477
- const text2 = prev + delta;
1478
- setTokens(text2.split(" ").length);
1479
- return text2;
1480
- });
1481
- break;
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
+ }
1482
1557
  }
1483
- }
1484
- break;
1558
+ break;
1559
+ }
1560
+ break;
1485
1561
  }
1486
- break;
1487
1562
  }
1488
- }
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
1489
1575
  });
1490
- }, [
1491
- runtime?.subscribeToEventLog
1492
- ]);
1493
- return /* @__PURE__ */ React13.createElement(FunctionBody, {
1494
- shape,
1495
- content: /* @__PURE__ */ React13.createElement("div", {
1496
- className: "px-2 py-1 overflow-y-scroll"
1497
- }, text),
1498
- status: `${tokens} tokens`,
1499
- inputSchema: meta.input,
1500
- outputSchema: meta.output
1501
- });
1576
+ } finally {
1577
+ _effect.f();
1578
+ }
1502
1579
  };
1503
1580
  var gptShape = {
1504
1581
  type: "gpt",
@@ -1511,6 +1588,7 @@ var gptShape = {
1511
1588
  };
1512
1589
 
1513
1590
  // packages/ui/react-ui-canvas-compute/src/shapes/Json.tsx
1591
+ import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
1514
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";
@@ -1523,20 +1601,30 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1523
1601
  type: Schema13.Literal("json-transform")
1524
1602
  }));
1525
1603
  var JsonComponent = ({ shape, ...props }) => {
1526
- const { runtime } = useComputeNodeState(shape);
1527
- const input = runtime.inputs[DEFAULT_INPUT4];
1528
- const value = input?.type === "executed" ? input.value : void 0;
1529
- return /* @__PURE__ */ React14.createElement(Box, {
1530
- shape
1531
- }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1532
- data: value,
1533
- classNames: "text-xs"
1534
- }));
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
+ }
1535
1618
  };
1536
1619
  var JsonTransformComponent = ({ shape, ...props }) => {
1537
- return /* @__PURE__ */ React14.createElement(Box, {
1538
- shape
1539
- });
1620
+ var _effect = _useSignals14();
1621
+ try {
1622
+ return /* @__PURE__ */ React14.createElement(Box, {
1623
+ shape
1624
+ });
1625
+ } finally {
1626
+ _effect.f();
1627
+ }
1540
1628
  };
1541
1629
  var createJson = (props) => createShape({
1542
1630
  type: "json",
@@ -1583,6 +1671,7 @@ var jsonTransformShape = {
1583
1671
  };
1584
1672
 
1585
1673
  // packages/ui/react-ui-canvas-compute/src/shapes/Logic.tsx
1674
+ import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
1586
1675
  import { Schema as Schema14 } from "effect";
1587
1676
  import React15 from "react";
1588
1677
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
@@ -1593,18 +1682,28 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1593
1682
  type: Schema14.Literal("if-else")
1594
1683
  }));
1595
1684
  var IfComponent = ({ shape, ...props }) => {
1596
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1597
- shape,
1598
- inputSchema: IfInput,
1599
- outputSchema: IfOutput
1600
- });
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
+ }
1601
1695
  };
1602
1696
  var IfElseComponent = ({ shape, ...props }) => {
1603
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1604
- shape,
1605
- inputSchema: IfElseInput,
1606
- outputSchema: IfElseOutput
1607
- });
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
+ }
1608
1707
  };
1609
1708
  var createIf = (props) => createShape({
1610
1709
  type: "if",
@@ -1640,6 +1739,7 @@ var ifElseShape = {
1640
1739
  };
1641
1740
 
1642
1741
  // packages/ui/react-ui-canvas-compute/src/shapes/Queue.tsx
1742
+ import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
1643
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";
@@ -1656,40 +1756,50 @@ var createQueue = (props) => createShape({
1656
1756
  ...props
1657
1757
  });
1658
1758
  var QueueComponent = ({ shape }) => {
1659
- const { runtime } = useComputeNodeState(shape);
1660
- const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1661
- const handleAction = (action) => {
1662
- if (action === "run") {
1663
- runtime.evalNode();
1664
- }
1665
- };
1666
- return /* @__PURE__ */ React16.createElement(Box, {
1667
- shape,
1668
- status: `${items.length} items`,
1669
- onAction: handleAction
1670
- }, /* @__PURE__ */ React16.createElement("div", {
1671
- className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
1672
- }, [
1673
- ...items
1674
- ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1675
- key: i,
1676
- classNames: "p-1 px-2",
1677
- item
1678
- }))));
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
+ }
1679
1784
  };
1680
1785
  var QueueItem = ({ classNames, item }) => {
1681
- if (typeof item !== "object") {
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
+ }
1682
1793
  return /* @__PURE__ */ React16.createElement("div", {
1683
- className: mx3(classNames, "whitespace-pre-wrap")
1684
- }, 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();
1685
1802
  }
1686
- return /* @__PURE__ */ React16.createElement("div", {
1687
- className: mx3("grid grid-cols-[80px,1fr]", classNames)
1688
- }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1689
- key
1690
- }, /* @__PURE__ */ React16.createElement("div", {
1691
- className: "p-1 text-xs text-subdued"
1692
- }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1693
1803
  };
1694
1804
  var queueShape = {
1695
1805
  type: "queue",
@@ -1702,6 +1812,7 @@ var queueShape = {
1702
1812
  };
1703
1813
 
1704
1814
  // packages/ui/react-ui-canvas-compute/src/shapes/RNG.tsx
1815
+ import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
1705
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";
@@ -1731,37 +1842,42 @@ var icons = [
1731
1842
  ];
1732
1843
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1733
1844
  var RandomComponent = ({ shape }) => {
1734
- const { runtime } = useComputeNodeState(shape);
1735
- const [spin, setSpin] = useState7(false);
1736
- const [icon, setIcon] = useState7(pickIcon());
1737
- useEffect5(() => {
1738
- if (!spin) {
1739
- return;
1740
- }
1741
- const i = setInterval(() => setIcon(pickIcon()), 250);
1742
- const t1 = setTimeout(() => clearInterval(i), 900);
1743
- const t2 = setTimeout(() => setSpin(false), 1100);
1744
- return () => {
1745
- clearInterval(i);
1746
- clearTimeout(t1);
1747
- clearTimeout(t2);
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);
1748
1869
  };
1749
- }, [
1750
- spin
1751
- ]);
1752
- const handleClick = (ev) => {
1753
- ev.stopPropagation();
1754
- runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1755
- setSpin(true);
1756
- };
1757
- return /* @__PURE__ */ React17.createElement("div", {
1758
- className: "flex grow items-center justify-center"
1759
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1760
- icon,
1761
- classNames: mx4(spin && "animate-[spin_1s]"),
1762
- size: 10,
1763
- onClick: handleClick
1764
- }));
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
+ }
1765
1881
  };
1766
1882
  var randomShape = {
1767
1883
  type: "rng",
@@ -1778,6 +1894,7 @@ var randomShape = {
1778
1894
  };
1779
1895
 
1780
1896
  // packages/ui/react-ui-canvas-compute/src/shapes/Scope.tsx
1897
+ import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
1781
1898
  import { Schema as Schema17 } from "effect";
1782
1899
  import React18 from "react";
1783
1900
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
@@ -1796,20 +1913,25 @@ var createScope = (props) => createShape({
1796
1913
  ...props
1797
1914
  });
1798
1915
  var ScopeComponent = ({ shape }) => {
1799
- const { runtime } = useComputeNodeState(shape);
1800
- const input = runtime.inputs[DEFAULT_INPUT5];
1801
- const active = input?.type === "executed" ? input.value : false;
1802
- const { getAverage } = useAudioStream(active);
1803
- return /* @__PURE__ */ React18.createElement("div", {
1804
- className: "flex w-full justify-center items-center bg-black"
1805
- }, /* @__PURE__ */ React18.createElement(Chaos, {
1806
- active,
1807
- getValue: getAverage,
1808
- options: {
1809
- ...shaderPresets.heptapod,
1810
- zoom: 1.2
1811
- }
1812
- }));
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
+ }
1813
1935
  };
1814
1936
  var scopeShape = {
1815
1937
  type: "scope",
@@ -1826,6 +1948,7 @@ var scopeShape = {
1826
1948
  };
1827
1949
 
1828
1950
  // packages/ui/react-ui-canvas-compute/src/shapes/Surface.tsx
1951
+ import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
1829
1952
  import { Schema as Schema18 } from "effect";
1830
1953
  import React19 from "react";
1831
1954
  import { Surface } from "@dxos/app-framework";
@@ -1843,24 +1966,29 @@ var createSurface = (props) => createShape({
1843
1966
  ...props
1844
1967
  });
1845
1968
  var SurfaceComponent = ({ shape }) => {
1846
- const { runtime } = useComputeNodeState(shape);
1847
- const input = runtime.inputs[DEFAULT_INPUT6];
1848
- const value = input?.type === "executed" ? input.value : null;
1849
- const handleAction = (action) => {
1850
- if (action === "run") {
1851
- runtime.evalNode();
1852
- }
1853
- };
1854
- return /* @__PURE__ */ React19.createElement(Box, {
1855
- shape,
1856
- onAction: handleAction
1857
- }, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
1858
- role: "canvas-node",
1859
- data: {
1860
- value
1861
- },
1862
- limit: 1
1863
- }));
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
+ }
1864
1992
  };
1865
1993
  var surfaceShape = {
1866
1994
  type: "surface",
@@ -1878,6 +2006,7 @@ var surfaceShape = {
1878
2006
  };
1879
2007
 
1880
2008
  // packages/ui/react-ui-canvas-compute/src/shapes/Switch.tsx
2009
+ import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
1881
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";
@@ -1895,20 +2024,25 @@ var createSwitch = (props) => createShape({
1895
2024
  ...props
1896
2025
  });
1897
2026
  var SwitchComponent = ({ shape }) => {
1898
- const { runtime } = useComputeNodeState(shape);
1899
- const [value, setValue] = useState8(false);
1900
- useEffect6(() => {
1901
- runtime.setOutput(DEFAULT_OUTPUT6, value);
1902
- }, [
1903
- value
1904
- ]);
1905
- return /* @__PURE__ */ React20.createElement("div", {
1906
- className: "flex w-full justify-center items-center",
1907
- onClick: (ev) => ev.stopPropagation()
1908
- }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
1909
- checked: value,
1910
- onCheckedChange: (value2) => setValue(value2)
1911
- })));
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
+ }
1912
2046
  };
1913
2047
  var switchShape = {
1914
2048
  type: "switch",
@@ -1925,6 +2059,7 @@ var switchShape = {
1925
2059
  };
1926
2060
 
1927
2061
  // packages/ui/react-ui-canvas-compute/src/shapes/Table.tsx
2062
+ import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
1928
2063
  import { Schema as Schema20 } from "effect";
1929
2064
  import React21 from "react";
1930
2065
  import { createInputSchema, createOutputSchema, GptMessage } from "@dxos/conductor";
@@ -1942,9 +2077,14 @@ var createTable = (props) => createShape({
1942
2077
  ...props
1943
2078
  });
1944
2079
  var TableComponent = ({ shape }) => {
1945
- return /* @__PURE__ */ React21.createElement(Box, {
1946
- shape
1947
- });
2080
+ var _effect = _useSignals21();
2081
+ try {
2082
+ return /* @__PURE__ */ React21.createElement(Box, {
2083
+ shape
2084
+ });
2085
+ } finally {
2086
+ _effect.f();
2087
+ }
1948
2088
  };
1949
2089
  var tableShape = {
1950
2090
  type: "table",
@@ -1957,6 +2097,7 @@ var tableShape = {
1957
2097
  };
1958
2098
 
1959
2099
  // packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx
2100
+ import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
1960
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";
@@ -1969,44 +2110,49 @@ var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
1969
2110
  valueType: Schema21.optional(ComputeValueType3)
1970
2111
  }));
1971
2112
  var TextInputComponent3 = ({ shape, title, ...props }) => {
1972
- const { node } = useComputeNodeState(shape);
1973
- const inputRef = useRef5(null);
1974
- const handleEnter = (text) => {
1975
- const value = text.trim();
1976
- if (value.length) {
1977
- const schema = getTemplateInputSchema2(node);
1978
- node.value = value;
1979
- node.inputSchema = toJsonSchema2(schema);
1980
- }
1981
- };
1982
- const handleTypeChange = (newType) => {
1983
- invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
1984
- F: __dxlog_file6,
1985
- L: 58,
1986
- S: void 0,
1987
- A: [
1988
- "Schema.is(ComputeValueType)(newType)",
1989
- "'Invalid type'"
1990
- ]
1991
- });
1992
- node.valueType = newType;
1993
- node.inputSchema = toJsonSchema2(getTemplateInputSchema2(node));
1994
- };
1995
- return /* @__PURE__ */ React22.createElement(Box, {
1996
- shape,
1997
- title: "Template",
1998
- status: /* @__PURE__ */ React22.createElement(TypeSelect, {
1999
- value: node.valueType ?? "string",
2000
- onValueChange: handleTypeChange
2001
- })
2002
- }, /* @__PURE__ */ React22.createElement(TextBox4, {
2003
- ...props,
2004
- ref: inputRef,
2005
- value: node.value,
2006
- language: node.valueType === "object" ? "json" : void 0,
2007
- onBlur: handleEnter,
2008
- onEnter: handleEnter
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,6 +2176,7 @@ 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";
2033
2180
  import { Schema as Schema22 } from "effect";
2034
2181
  import React23 from "react";
2035
2182
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
@@ -2047,20 +2194,25 @@ var createText = (props) => createShape({
2047
2194
  ...props
2048
2195
  });
2049
2196
  var TextComponent = ({ shape }) => {
2050
- const { runtime } = useComputeNodeState(shape);
2051
- const input = runtime.inputs[DEFAULT_INPUT7];
2052
- const value = input?.type === "executed" ? input.value : 0;
2053
- const handleAction = (action) => {
2054
- if (action === "run") {
2055
- runtime.evalNode();
2056
- }
2057
- };
2058
- return /* @__PURE__ */ React23.createElement(Box, {
2059
- shape,
2060
- onAction: handleAction
2061
- }, /* @__PURE__ */ React23.createElement(TextBox5, {
2062
- value
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,6 +2230,7 @@ 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";
2081
2234
  import { Schema as Schema23 } from "effect";
2082
2235
  import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2083
2236
  import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2, GptMessage as GptMessage2 } from "@dxos/conductor";
@@ -2096,39 +2249,49 @@ var createThread = (props) => createShape({
2096
2249
  ...props
2097
2250
  });
2098
2251
  var ThreadComponent = ({ shape }) => {
2099
- const items = [];
2100
- const scrollRef = useRef6(null);
2101
- useEffect7(() => {
2102
- if (scrollRef.current) {
2103
- scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2104
- }
2105
- }, [
2106
- items
2107
- ]);
2108
- return /* @__PURE__ */ React24.createElement(Box, {
2109
- shape
2110
- }, /* @__PURE__ */ React24.createElement("div", {
2111
- ref: scrollRef,
2112
- className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
2113
- }, [
2114
- ...items
2115
- ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2116
- key: i,
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
- if (typeof item !== "object") {
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
- }, item);
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,6 +2304,7 @@ 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";
2144
2308
  import { Schema as Schema24 } from "effect";
2145
2309
  import React25 from "react";
2146
2310
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
@@ -2156,9 +2320,14 @@ var createTextToImage = (props) => createShape({
2156
2320
  ...props
2157
2321
  });
2158
2322
  var TextToImageComponent = ({ shape }) => {
2159
- return /* @__PURE__ */ React25.createElement(Box, {
2160
- shape
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,6 +2344,7 @@ 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";
2178
2348
  import { Schema as Schema25 } from "effect";
2179
2349
  import React26, { useEffect as useEffect8 } from "react";
2180
2350
  import { VoidInput as VoidInput3 } from "@dxos/conductor";
@@ -2203,56 +2373,66 @@ var createTrigger = (props) => {
2203
2373
  });
2204
2374
  };
2205
2375
  var TriggerComponent = ({ shape }) => {
2206
- const space = useSpace();
2207
- const functionTrigger = shape.functionTrigger?.target;
2208
- useEffect8(() => {
2209
- if (functionTrigger && !functionTrigger.spec) {
2210
- functionTrigger.spec = createTriggerSpec({
2211
- triggerKind: TriggerKind.Email,
2212
- spaceId: space?.id
2213
- });
2214
- }
2215
- }, [
2216
- functionTrigger,
2217
- functionTrigger?.spec
2218
- ]);
2219
- useEffect8(() => {
2220
- shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? TriggerKind.Email));
2221
- }, [
2222
- functionTrigger?.spec?.kind
2223
- ]);
2224
- const setKind = (kind) => {
2225
- if (functionTrigger?.spec?.kind !== kind) {
2226
- functionTrigger.spec = createTriggerSpec({
2227
- triggerKind: kind,
2228
- spaceId: space?.id
2229
- });
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;
2230
2406
  }
2231
- };
2232
- if (!functionTrigger?.spec) {
2233
- return;
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();
2234
2418
  }
2235
- return /* @__PURE__ */ React26.createElement(FunctionBody, {
2236
- shape,
2237
- status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2238
- value: functionTrigger.spec?.kind,
2239
- onValueChange: (kind) => setKind(kind)
2240
- }),
2241
- inputSchema: VoidInput3,
2242
- outputSchema: getOutputSchema(functionTrigger.spec.kind)
2243
- });
2244
2419
  };
2245
2420
  var TriggerKindSelect = ({ value, onValueChange }) => {
2246
- return /* @__PURE__ */ React26.createElement(Select2.Root, {
2247
- value,
2248
- onValueChange
2249
- }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2250
- variant: "ghost",
2251
- classNames: "w-full !px-0"
2252
- }), /* @__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, {
2253
- key: kind,
2254
- value: kind
2255
- }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
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
+ }
2256
2436
  };
2257
2437
  var createTriggerSpec = (props) => {
2258
2438
  const kind = props.triggerKind ?? TriggerKind.Email;
@@ -2309,6 +2489,7 @@ var triggerShape = {
2309
2489
  };
2310
2490
 
2311
2491
  // packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx
2492
+ import { useSignals as _useSignals27 } from "@preact-signals/safe-react/tracking";
2312
2493
  import { Schema as Schema26 } from "effect";
2313
2494
  import React27, { useState as useState9 } from "react";
2314
2495
  import { log as log2 } from "@dxos/log";
@@ -2327,100 +2508,105 @@ var createGptRealtime = (props) => createShape({
2327
2508
  ...props
2328
2509
  });
2329
2510
  var GptRealtimeComponent = ({ shape }) => {
2330
- const [isLive, setIsLive] = useState9(false);
2331
- const [isReady, setIsReady] = useState9(false);
2332
- const config = useConfig();
2333
- const start = async () => {
2334
- setIsLive(true);
2335
- try {
2336
- const peerConnection = new RTCPeerConnection();
2337
- peerConnection.ontrack = (event) => {
2338
- const audioElement = document.createElement("audio");
2339
- audioElement.srcObject = event.streams[0];
2340
- audioElement.autoplay = true;
2341
- audioElement.controls = false;
2342
- audioElement.style.display = "none";
2343
- document.body.appendChild(audioElement);
2344
- setIsReady(true);
2345
- };
2346
- const stream = await navigator.mediaDevices.getUserMedia({
2347
- audio: true
2348
- });
2349
- stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2350
- direction: "sendrecv"
2351
- }));
2352
- const offer = await peerConnection.createOffer();
2353
- await peerConnection.setLocalDescription(offer);
2354
- const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2355
- const response = await fetch(aiServiceUrl, {
2356
- method: "POST",
2357
- body: offer.sdp,
2358
- headers: {
2359
- "Content-Type": "application/sdp"
2360
- }
2361
- });
2362
- const answer = await response.text();
2363
- await peerConnection.setRemoteDescription({
2364
- sdp: answer,
2365
- type: "answer"
2366
- });
2367
- const dataChannel = peerConnection.createDataChannel("response");
2368
- const configureData = () => {
2369
- log2.info("Configuring data channel", void 0, {
2370
- F: __dxlog_file7,
2371
- L: 87,
2372
- S: void 0,
2373
- 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
2374
2531
  });
2375
- const event = {
2376
- type: "session.update",
2377
- session: {
2378
- modalities: [
2379
- "text",
2380
- "audio"
2381
- ],
2382
- // Provide the tools. Note they match the keys in the `fns` object above
2383
- tools: []
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"
2384
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));
2385
2570
  };
2386
- dataChannel.send(JSON.stringify(event));
2387
- };
2388
- dataChannel.addEventListener("open", (ev) => {
2389
- log2.info("Opening data channel", {
2390
- ev
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
2391
2590
  }, {
2392
2591
  F: __dxlog_file7,
2393
- L: 100,
2592
+ L: 140,
2394
2593
  S: void 0,
2395
2594
  C: (f, a) => f(...a)
2396
2595
  });
2397
- configureData();
2398
- });
2399
- dataChannel.addEventListener("message", async (ev) => {
2400
- const msg = JSON.parse(ev.data);
2401
- if (msg.type === "response.function_call_arguments.done") {
2402
- }
2403
- });
2404
- } catch (error) {
2405
- log2.error("Error in realtime session:", {
2406
- error
2407
- }, {
2408
- F: __dxlog_file7,
2409
- L: 140,
2410
- S: void 0,
2411
- C: (f, a) => f(...a)
2412
- });
2413
- throw error;
2414
- }
2415
- };
2416
- return /* @__PURE__ */ React27.createElement("div", {
2417
- className: "flex w-full justify-center items-center"
2418
- }, /* @__PURE__ */ React27.createElement(Icon5, {
2419
- icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2420
- size: 16,
2421
- classNames: !isLive && "cursor-pointer",
2422
- onClick: start
2423
- }));
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
+ }
2424
2610
  };
2425
2611
  var gptRealtimeShape = {
2426
2612
  type: "gpt-realtime",
@@ -2504,8 +2690,7 @@ import { toEffectSchema } from "@dxos/echo-schema";
2504
2690
  import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
2505
2691
  var ComputeShapeLayout = class extends ShapeLayout {
2506
2692
  constructor(_controller, registry2) {
2507
- super(registry2);
2508
- this._controller = _controller;
2693
+ super(registry2), this._controller = _controller;
2509
2694
  }
2510
2695
  // TODO(burdon): Doesn't update.
2511
2696
  getAnchors(shape) {