@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.
- package/dist/lib/browser/index.mjs +900 -715
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +900 -715
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +900 -715
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/graph/controller.d.ts +1 -1
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +1 -1
- package/package.json +40 -38
- package/src/compute.stories.tsx +1 -1
- package/src/graph/controller.ts +12 -12
- package/src/shapes/Gpt.tsx +1 -1
- package/src/shapes/defs.ts +1 -1
package/dist/lib/node/index.cjs
CHANGED
|
@@ -189,11 +189,13 @@ var import_invariant3 = require("@dxos/invariant");
|
|
|
189
189
|
var import_echo = require("@dxos/react-client/echo");
|
|
190
190
|
var import_util = require("@dxos/util");
|
|
191
191
|
var import_react_ui_canvas_editor = require("@dxos/react-ui-canvas-editor");
|
|
192
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
192
193
|
var import_react5 = __toESM(require("react"));
|
|
193
194
|
var import_invariant4 = require("@dxos/invariant");
|
|
194
195
|
var import_react_ui = require("@dxos/react-ui");
|
|
195
196
|
var import_react_ui_canvas_editor2 = require("@dxos/react-ui-canvas-editor");
|
|
196
197
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
198
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
197
199
|
var import_effect3 = require("effect");
|
|
198
200
|
var import_react6 = __toESM(require("react"));
|
|
199
201
|
var import_conductor4 = require("@dxos/conductor");
|
|
@@ -203,33 +205,41 @@ var import_effect4 = require("effect");
|
|
|
203
205
|
var import_conductor5 = require("@dxos/conductor");
|
|
204
206
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
205
207
|
var import_react_ui_canvas_editor4 = require("@dxos/react-ui-canvas-editor");
|
|
208
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
206
209
|
var import_react7 = __toESM(require("react"));
|
|
207
210
|
var import_conductor6 = require("@dxos/conductor");
|
|
208
211
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
212
|
+
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
209
213
|
var import_effect5 = require("effect");
|
|
210
214
|
var import_react8 = __toESM(require("react"));
|
|
211
215
|
var import_conductor7 = require("@dxos/conductor");
|
|
216
|
+
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
212
217
|
var import_effect6 = require("effect");
|
|
213
218
|
var import_react9 = __toESM(require("react"));
|
|
214
219
|
var import_conductor8 = require("@dxos/conductor");
|
|
220
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
215
221
|
var import_effect7 = require("effect");
|
|
216
222
|
var import_react10 = __toESM(require("react"));
|
|
217
223
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
218
224
|
var import_react_ui_canvas_editor5 = require("@dxos/react-ui-canvas-editor");
|
|
225
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
219
226
|
var import_effect8 = require("effect");
|
|
220
227
|
var import_react11 = __toESM(require("react"));
|
|
221
228
|
var import_conductor9 = require("@dxos/conductor");
|
|
222
229
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
223
230
|
var import_react_ui_canvas_editor6 = require("@dxos/react-ui-canvas-editor");
|
|
224
231
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
232
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
225
233
|
var import_effect9 = require("effect");
|
|
226
234
|
var import_react12 = __toESM(require("react"));
|
|
227
235
|
var import_react_ui_canvas_editor7 = require("@dxos/react-ui-canvas-editor");
|
|
236
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
228
237
|
var import_effect10 = require("effect");
|
|
229
238
|
var import_react13 = __toESM(require("react"));
|
|
230
239
|
var import_conductor10 = require("@dxos/conductor");
|
|
231
240
|
var import_react_ui_canvas_editor8 = require("@dxos/react-ui-canvas-editor");
|
|
232
241
|
var import_react_ui_canvas_editor9 = require("@dxos/react-ui-canvas-editor");
|
|
242
|
+
var import_tracking10 = require("@preact-signals/safe-react/tracking");
|
|
233
243
|
var import_effect11 = require("effect");
|
|
234
244
|
var import_react14 = __toESM(require("react"));
|
|
235
245
|
var import_conductor11 = require("@dxos/conductor");
|
|
@@ -237,9 +247,11 @@ var import_react_ui5 = require("@dxos/react-ui");
|
|
|
237
247
|
var import_react_ui_canvas_editor10 = require("@dxos/react-ui-canvas-editor");
|
|
238
248
|
var import_react_ui_canvas_editor11 = require("@dxos/react-ui-canvas-editor");
|
|
239
249
|
var import_util2 = require("@dxos/util");
|
|
250
|
+
var import_tracking11 = require("@preact-signals/safe-react/tracking");
|
|
240
251
|
var import_effect12 = require("effect");
|
|
241
252
|
var import_react15 = __toESM(require("react"));
|
|
242
253
|
var import_react_ui_canvas_editor12 = require("@dxos/react-ui-canvas-editor");
|
|
254
|
+
var import_tracking12 = require("@preact-signals/safe-react/tracking");
|
|
243
255
|
var import_effect13 = require("effect");
|
|
244
256
|
var import_react16 = __toESM(require("react"));
|
|
245
257
|
var import_conductor12 = require("@dxos/conductor");
|
|
@@ -248,63 +260,77 @@ var import_functions = require("@dxos/functions");
|
|
|
248
260
|
var import_react_client = require("@dxos/react-client");
|
|
249
261
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
250
262
|
var import_react_ui_canvas_editor13 = require("@dxos/react-ui-canvas-editor");
|
|
263
|
+
var import_tracking13 = require("@preact-signals/safe-react/tracking");
|
|
251
264
|
var import_effect14 = require("effect");
|
|
252
265
|
var import_react17 = __toESM(require("react"));
|
|
253
266
|
var import_conductor13 = require("@dxos/conductor");
|
|
267
|
+
var import_tracking14 = require("@preact-signals/safe-react/tracking");
|
|
254
268
|
var import_effect15 = require("effect");
|
|
255
269
|
var import_react18 = __toESM(require("react"));
|
|
256
270
|
var import_conductor14 = require("@dxos/conductor");
|
|
257
271
|
var import_react_ui_canvas_editor14 = require("@dxos/react-ui-canvas-editor");
|
|
258
272
|
var import_react_ui_syntax_highlighter = require("@dxos/react-ui-syntax-highlighter");
|
|
273
|
+
var import_tracking15 = require("@preact-signals/safe-react/tracking");
|
|
259
274
|
var import_effect16 = require("effect");
|
|
260
275
|
var import_react19 = __toESM(require("react"));
|
|
261
276
|
var import_conductor15 = require("@dxos/conductor");
|
|
277
|
+
var import_tracking16 = require("@preact-signals/safe-react/tracking");
|
|
262
278
|
var import_effect17 = require("effect");
|
|
263
279
|
var import_react20 = __toESM(require("react"));
|
|
264
280
|
var import_conductor16 = require("@dxos/conductor");
|
|
265
281
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
282
|
+
var import_tracking17 = require("@preact-signals/safe-react/tracking");
|
|
266
283
|
var import_effect18 = require("effect");
|
|
267
284
|
var import_react21 = __toESM(require("react"));
|
|
268
285
|
var import_conductor17 = require("@dxos/conductor");
|
|
269
286
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
270
287
|
var import_react_ui_canvas_editor15 = require("@dxos/react-ui-canvas-editor");
|
|
271
288
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
289
|
+
var import_tracking18 = require("@preact-signals/safe-react/tracking");
|
|
272
290
|
var import_effect19 = require("effect");
|
|
273
291
|
var import_react22 = __toESM(require("react"));
|
|
274
292
|
var import_conductor18 = require("@dxos/conductor");
|
|
275
293
|
var import_react_ui_canvas_editor16 = require("@dxos/react-ui-canvas-editor");
|
|
276
294
|
var import_react_ui_sfx = require("@dxos/react-ui-sfx");
|
|
295
|
+
var import_tracking19 = require("@preact-signals/safe-react/tracking");
|
|
277
296
|
var import_effect20 = require("effect");
|
|
278
297
|
var import_react23 = __toESM(require("react"));
|
|
279
298
|
var import_app_framework = require("@dxos/app-framework");
|
|
280
299
|
var import_conductor19 = require("@dxos/conductor");
|
|
281
300
|
var import_react_ui_canvas_editor17 = require("@dxos/react-ui-canvas-editor");
|
|
301
|
+
var import_tracking20 = require("@preact-signals/safe-react/tracking");
|
|
282
302
|
var import_effect21 = require("effect");
|
|
283
303
|
var import_react24 = __toESM(require("react"));
|
|
284
304
|
var import_conductor20 = require("@dxos/conductor");
|
|
285
305
|
var import_react_ui7 = require("@dxos/react-ui");
|
|
286
306
|
var import_react_ui_canvas_editor18 = require("@dxos/react-ui-canvas-editor");
|
|
307
|
+
var import_tracking21 = require("@preact-signals/safe-react/tracking");
|
|
287
308
|
var import_effect22 = require("effect");
|
|
288
309
|
var import_react25 = __toESM(require("react"));
|
|
289
310
|
var import_conductor21 = require("@dxos/conductor");
|
|
311
|
+
var import_tracking22 = require("@preact-signals/safe-react/tracking");
|
|
290
312
|
var import_effect23 = require("effect");
|
|
291
313
|
var import_react26 = __toESM(require("react"));
|
|
292
314
|
var import_conductor22 = require("@dxos/conductor");
|
|
293
315
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
294
316
|
var import_invariant5 = require("@dxos/invariant");
|
|
295
317
|
var import_react_ui_canvas_editor19 = require("@dxos/react-ui-canvas-editor");
|
|
318
|
+
var import_tracking23 = require("@preact-signals/safe-react/tracking");
|
|
296
319
|
var import_effect24 = require("effect");
|
|
297
320
|
var import_react27 = __toESM(require("react"));
|
|
298
321
|
var import_conductor23 = require("@dxos/conductor");
|
|
299
322
|
var import_react_ui_canvas_editor20 = require("@dxos/react-ui-canvas-editor");
|
|
300
323
|
var import_react_ui_canvas_editor21 = require("@dxos/react-ui-canvas-editor");
|
|
324
|
+
var import_tracking24 = require("@preact-signals/safe-react/tracking");
|
|
301
325
|
var import_effect25 = require("effect");
|
|
302
326
|
var import_react28 = __toESM(require("react"));
|
|
303
327
|
var import_conductor24 = require("@dxos/conductor");
|
|
304
328
|
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
329
|
+
var import_tracking25 = require("@preact-signals/safe-react/tracking");
|
|
305
330
|
var import_effect26 = require("effect");
|
|
306
331
|
var import_react29 = __toESM(require("react"));
|
|
307
332
|
var import_react_ui_canvas_editor22 = require("@dxos/react-ui-canvas-editor");
|
|
333
|
+
var import_tracking26 = require("@preact-signals/safe-react/tracking");
|
|
308
334
|
var import_effect27 = require("effect");
|
|
309
335
|
var import_react30 = __toESM(require("react"));
|
|
310
336
|
var import_conductor25 = require("@dxos/conductor");
|
|
@@ -313,6 +339,7 @@ var import_functions2 = require("@dxos/functions");
|
|
|
313
339
|
var import_keys = require("@dxos/keys");
|
|
314
340
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
315
341
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
342
|
+
var import_tracking27 = require("@preact-signals/safe-react/tracking");
|
|
316
343
|
var import_effect28 = require("effect");
|
|
317
344
|
var import_react31 = __toESM(require("react"));
|
|
318
345
|
var import_log2 = require("@dxos/log");
|
|
@@ -653,19 +680,9 @@ var createComputeGraphController = (graph, services) => {
|
|
|
653
680
|
};
|
|
654
681
|
var ComputeGraphController = class extends import_context.Resource {
|
|
655
682
|
constructor(_graph) {
|
|
656
|
-
super()
|
|
657
|
-
this._graph = _graph;
|
|
658
|
-
this._executor = new import_conductor.GraphExecutor({
|
|
683
|
+
super(), this._graph = _graph, this._executor = new import_conductor.GraphExecutor({
|
|
659
684
|
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
660
|
-
});
|
|
661
|
-
this._diagnostics = [];
|
|
662
|
-
this._services = {};
|
|
663
|
-
this._forcedOutputs = {};
|
|
664
|
-
this._runtimeStateInputs = {};
|
|
665
|
-
this._runtimeStateOutputs = {};
|
|
666
|
-
this.update = new import_async.Event();
|
|
667
|
-
this.output = new import_async.Event();
|
|
668
|
-
this.events = new import_async.Event();
|
|
685
|
+
}), this._diagnostics = [], this._services = {}, this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new import_async.Event(), this.output = new import_async.Event(), this.events = new import_async.Event();
|
|
669
686
|
}
|
|
670
687
|
toJSON() {
|
|
671
688
|
return {
|
|
@@ -932,59 +949,64 @@ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-com
|
|
|
932
949
|
var headerHeight = 32;
|
|
933
950
|
var footerHeight = 32;
|
|
934
951
|
var Box = /* @__PURE__ */ (0, import_react5.forwardRef)(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
935
|
-
(0,
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
ev.stopPropagation()
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
952
|
+
var _effect = (0, import_tracking.useSignals)();
|
|
953
|
+
try {
|
|
954
|
+
(0, import_invariant4.invariant)(shape.type, void 0, {
|
|
955
|
+
F: __dxlog_file5,
|
|
956
|
+
L: 30,
|
|
957
|
+
S: void 0,
|
|
958
|
+
A: [
|
|
959
|
+
"shape.type",
|
|
960
|
+
""
|
|
961
|
+
]
|
|
962
|
+
});
|
|
963
|
+
const { icon, name, openable } = (0, import_react_ui_canvas_editor2.useShapeDef)(shape.type) ?? {
|
|
964
|
+
icon: "ph--placeholder--regular"
|
|
965
|
+
};
|
|
966
|
+
const { debug } = (0, import_react_ui_canvas_editor2.useEditorContext)();
|
|
967
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
968
|
+
ref: forwardedRef,
|
|
969
|
+
className: "flex flex-col h-full w-full justify-between"
|
|
970
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
971
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
|
|
972
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui.Icon, {
|
|
973
|
+
icon,
|
|
974
|
+
classNames: "mx-2"
|
|
975
|
+
}), /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
976
|
+
className: "grow text-sm truncate"
|
|
977
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ import_react5.default.createElement(import_react_ui.IconButton, {
|
|
978
|
+
classNames: "p-1 text-green-500",
|
|
979
|
+
variant: "ghost",
|
|
980
|
+
icon: "ph--play--regular",
|
|
981
|
+
size: 4,
|
|
982
|
+
label: "run",
|
|
983
|
+
iconOnly: true,
|
|
984
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
985
|
+
onClick: (ev) => {
|
|
986
|
+
ev.stopPropagation();
|
|
987
|
+
onAction?.("run");
|
|
988
|
+
}
|
|
989
|
+
})), /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
990
|
+
className: (0, import_react_ui_theme.mx)("flex flex-col h-full grow overflow-hidden", classNames)
|
|
991
|
+
}, children), /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
992
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
|
|
993
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
994
|
+
className: "grow px-2 text-sm truncate"
|
|
995
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ import_react5.default.createElement(import_react_ui.IconButton, {
|
|
996
|
+
classNames: "p-1",
|
|
997
|
+
variant: "ghost",
|
|
998
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
999
|
+
size: 4,
|
|
1000
|
+
label: open ? "close" : "open",
|
|
1001
|
+
iconOnly: true,
|
|
1002
|
+
onClick: (ev) => {
|
|
1003
|
+
ev.stopPropagation();
|
|
1004
|
+
onAction?.(open ? "close" : "open");
|
|
1005
|
+
}
|
|
1006
|
+
})));
|
|
1007
|
+
} finally {
|
|
1008
|
+
_effect.f();
|
|
1009
|
+
}
|
|
988
1010
|
});
|
|
989
1011
|
var getProperties = (ast) => import_effect4.SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
990
1012
|
name: name.toString()
|
|
@@ -1003,7 +1025,7 @@ var parseAnchorId = (id) => {
|
|
|
1003
1025
|
var ComputeShape = import_effect4.Schema.extend(import_react_ui_canvas_editor4.Polygon, import_effect4.Schema.Struct({
|
|
1004
1026
|
// TODO(burdon): Rename computeNode?
|
|
1005
1027
|
node: import_effect4.Schema.optional(import_echo_schema3.ObjectId.annotations({
|
|
1006
|
-
|
|
1028
|
+
description: "Compute node id"
|
|
1007
1029
|
}))
|
|
1008
1030
|
}).pipe(import_effect4.Schema.mutable));
|
|
1009
1031
|
var createShape = ({ id, ...rest }) => {
|
|
@@ -1015,65 +1037,70 @@ var createShape = ({ id, ...rest }) => {
|
|
|
1015
1037
|
var bodyPadding = 8;
|
|
1016
1038
|
var expandedHeight = 200;
|
|
1017
1039
|
var FunctionBody = ({ shape, name, content, inputSchema = import_conductor4.VoidInput, outputSchema = import_conductor4.VoidOutput, ...props }) => {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
case "open": {
|
|
1027
|
-
const el = (0, import_react_ui_canvas_editor3.getParentShapeElement)(rootRef.current, shape.id);
|
|
1028
|
-
const { height } = el.getBoundingClientRect();
|
|
1029
|
-
el.style.height = `${height / scale + expandedHeight}px`;
|
|
1030
|
-
setOpen(true);
|
|
1031
|
-
break;
|
|
1040
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
1041
|
+
try {
|
|
1042
|
+
const { scale } = (0, import_react_ui_canvas.useCanvasContext)();
|
|
1043
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
1044
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1045
|
+
const handleAction = (action) => {
|
|
1046
|
+
if (!rootRef.current) {
|
|
1047
|
+
return;
|
|
1032
1048
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1049
|
+
switch (action) {
|
|
1050
|
+
case "open": {
|
|
1051
|
+
const el = (0, import_react_ui_canvas_editor3.getParentShapeElement)(rootRef.current, shape.id);
|
|
1052
|
+
const { height } = el.getBoundingClientRect();
|
|
1053
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
1054
|
+
setOpen(true);
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
case "close": {
|
|
1058
|
+
const el = (0, import_react_ui_canvas_editor3.getParentShapeElement)(rootRef.current, shape.id);
|
|
1059
|
+
el.style.height = "";
|
|
1060
|
+
setOpen(false);
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1038
1063
|
}
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
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
|
-
}
|
|
1064
|
+
};
|
|
1065
|
+
const inputs = getProperties(inputSchema.ast);
|
|
1066
|
+
const outputs = getProperties(outputSchema.ast);
|
|
1067
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
1068
|
+
return /* @__PURE__ */ import_react6.default.createElement(Box, {
|
|
1069
|
+
ref: rootRef,
|
|
1070
|
+
shape,
|
|
1071
|
+
title: name,
|
|
1072
|
+
classNames: "divide-y divide-separator",
|
|
1073
|
+
open,
|
|
1074
|
+
onAction: handleAction,
|
|
1075
|
+
...props
|
|
1076
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1077
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
1078
|
+
style: {
|
|
1079
|
+
paddingTop: bodyPadding,
|
|
1080
|
+
paddingBottom: bodyPadding
|
|
1081
|
+
}
|
|
1082
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1083
|
+
className: "flex flex-col"
|
|
1084
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1085
|
+
key: name2,
|
|
1086
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
1087
|
+
style: {
|
|
1088
|
+
height: import_react_ui_canvas_editor3.rowHeight
|
|
1089
|
+
}
|
|
1090
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1091
|
+
className: "flex flex-col"
|
|
1092
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1093
|
+
key: name2,
|
|
1094
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
1095
|
+
style: {
|
|
1096
|
+
height: import_react_ui_canvas_editor3.rowHeight
|
|
1097
|
+
}
|
|
1098
|
+
}, name2)))), open && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
1099
|
+
className: "flex flex-col grow overflow-hidden"
|
|
1100
|
+
}, content));
|
|
1101
|
+
} finally {
|
|
1102
|
+
_effect.f();
|
|
1103
|
+
}
|
|
1077
1104
|
};
|
|
1078
1105
|
var getHeight = (input) => {
|
|
1079
1106
|
const properties = import_effect3.SchemaAST.getPropertySignatures(input.ast);
|
|
@@ -1093,26 +1120,36 @@ var createFunctionAnchors = (shape, input = import_conductor4.VoidInput, output
|
|
|
1093
1120
|
});
|
|
1094
1121
|
};
|
|
1095
1122
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1123
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
1124
|
+
try {
|
|
1125
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Root, {
|
|
1126
|
+
value,
|
|
1127
|
+
onValueChange
|
|
1128
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.TriggerButton, {
|
|
1129
|
+
variant: "ghost",
|
|
1130
|
+
classNames: "w-full !px-0"
|
|
1131
|
+
}), /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Portal, null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Content, null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.ScrollUpButton, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Viewport, null, import_conductor6.ComputeValueType.literals.map((type) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Option, {
|
|
1132
|
+
key: type,
|
|
1133
|
+
value: type
|
|
1134
|
+
}, type))), /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.ScrollDownButton, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui2.Select.Arrow, null))));
|
|
1135
|
+
} finally {
|
|
1136
|
+
_effect.f();
|
|
1137
|
+
}
|
|
1106
1138
|
};
|
|
1107
1139
|
var ReducerShape = import_effect5.Schema.extend(ComputeShape, import_effect5.Schema.Struct({
|
|
1108
1140
|
type: import_effect5.Schema.Literal("reducer")
|
|
1109
1141
|
}));
|
|
1110
1142
|
var ReducerComponent = ({ shape }) => {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1143
|
+
var _effect = (0, import_tracking4.useSignals)();
|
|
1144
|
+
try {
|
|
1145
|
+
return /* @__PURE__ */ import_react8.default.createElement(FunctionBody, {
|
|
1146
|
+
shape,
|
|
1147
|
+
inputSchema: import_conductor7.ReducerInput,
|
|
1148
|
+
outputSchema: import_conductor7.ReducerOutput
|
|
1149
|
+
});
|
|
1150
|
+
} finally {
|
|
1151
|
+
_effect.f();
|
|
1152
|
+
}
|
|
1116
1153
|
};
|
|
1117
1154
|
var createReducer = ({ id, size = {
|
|
1118
1155
|
width: 192,
|
|
@@ -1142,10 +1179,15 @@ var createAppend = (props) => createShape({
|
|
|
1142
1179
|
...props
|
|
1143
1180
|
});
|
|
1144
1181
|
var AppendComponent = ({ shape }) => {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1182
|
+
var _effect = (0, import_tracking5.useSignals)();
|
|
1183
|
+
try {
|
|
1184
|
+
return /* @__PURE__ */ import_react9.default.createElement(FunctionBody, {
|
|
1185
|
+
shape,
|
|
1186
|
+
inputSchema: import_conductor8.AppendInput
|
|
1187
|
+
});
|
|
1188
|
+
} finally {
|
|
1189
|
+
_effect.f();
|
|
1190
|
+
}
|
|
1149
1191
|
};
|
|
1150
1192
|
var appendShape = {
|
|
1151
1193
|
type: "append",
|
|
@@ -1167,24 +1209,29 @@ var createAudio = (props) => createShape({
|
|
|
1167
1209
|
...props
|
|
1168
1210
|
});
|
|
1169
1211
|
var AudioComponent = ({ shape }) => {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
"
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1212
|
+
var _effect = (0, import_tracking6.useSignals)();
|
|
1213
|
+
try {
|
|
1214
|
+
const { node } = useComputeNodeState(shape);
|
|
1215
|
+
const [active, setActive] = (0, import_react10.useState)(false);
|
|
1216
|
+
(0, import_react10.useEffect)(() => {
|
|
1217
|
+
node.value = active;
|
|
1218
|
+
}, [
|
|
1219
|
+
active
|
|
1220
|
+
]);
|
|
1221
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1222
|
+
className: "flex w-full justify-center items-center"
|
|
1223
|
+
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui3.Icon, {
|
|
1224
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
1225
|
+
classNames: [
|
|
1226
|
+
"transition opacity-20 duration-1000",
|
|
1227
|
+
active && "opacity-100 text-red-500"
|
|
1228
|
+
],
|
|
1229
|
+
size: 8,
|
|
1230
|
+
onClick: () => setActive(!active)
|
|
1231
|
+
}));
|
|
1232
|
+
} finally {
|
|
1233
|
+
_effect.f();
|
|
1234
|
+
}
|
|
1188
1235
|
};
|
|
1189
1236
|
var audioShape = {
|
|
1190
1237
|
type: "audio",
|
|
@@ -1211,16 +1258,21 @@ var createBeacon = (props) => createShape({
|
|
|
1211
1258
|
...props
|
|
1212
1259
|
});
|
|
1213
1260
|
var BeaconComponent = ({ shape }) => {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1261
|
+
var _effect = (0, import_tracking7.useSignals)();
|
|
1262
|
+
try {
|
|
1263
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1264
|
+
const input = runtime.inputs[import_conductor9.DEFAULT_INPUT];
|
|
1265
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
1266
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
1267
|
+
className: "flex w-full justify-center items-center"
|
|
1268
|
+
}, /* @__PURE__ */ import_react11.default.createElement(import_react_ui4.Icon, {
|
|
1269
|
+
icon: "ph--sun--regular",
|
|
1270
|
+
classNames: (0, import_react_ui_theme2.mx)("transition opacity-20 duration-1000", (0, import_conductor9.isTruthy)(value) && "opacity-100 text-yellow-500"),
|
|
1271
|
+
size: 8
|
|
1272
|
+
}));
|
|
1273
|
+
} finally {
|
|
1274
|
+
_effect.f();
|
|
1275
|
+
}
|
|
1224
1276
|
};
|
|
1225
1277
|
var beaconShape = {
|
|
1226
1278
|
type: "beacon",
|
|
@@ -1245,10 +1297,17 @@ var createGate = (props) => createShape({
|
|
|
1245
1297
|
},
|
|
1246
1298
|
...props
|
|
1247
1299
|
});
|
|
1248
|
-
var GateComponent = (Symbol22) =>
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1300
|
+
var GateComponent = (Symbol22) => {
|
|
1301
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
1302
|
+
try {
|
|
1303
|
+
return () => {
|
|
1304
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
1305
|
+
className: "flex w-full justify-center items-center"
|
|
1306
|
+
}, /* @__PURE__ */ import_react12.default.createElement(Symbol22, null));
|
|
1307
|
+
};
|
|
1308
|
+
} finally {
|
|
1309
|
+
_effect.f();
|
|
1310
|
+
}
|
|
1252
1311
|
};
|
|
1253
1312
|
var defineShape = ({ type, name, icon, Symbol: Symbol22, createShape: createShape2, inputs, outputs = [
|
|
1254
1313
|
createAnchorId("output")
|
|
@@ -1264,48 +1323,55 @@ var defineShape = ({ type, name, icon, Symbol: Symbol22, createShape: createShap
|
|
|
1264
1323
|
outputs
|
|
1265
1324
|
})
|
|
1266
1325
|
});
|
|
1267
|
-
var Symbol2 = (pathConstructor, inputs) =>
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1326
|
+
var Symbol2 = (pathConstructor, inputs) => {
|
|
1327
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
1328
|
+
try {
|
|
1329
|
+
return ({
|
|
1330
|
+
width = 64,
|
|
1331
|
+
height = 32,
|
|
1332
|
+
// TODO(burdon): Same as line color.
|
|
1333
|
+
className = "fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500",
|
|
1334
|
+
strokeWidth = 1
|
|
1335
|
+
}) => {
|
|
1336
|
+
const startX = width * 0.25;
|
|
1337
|
+
const endX = width * 0.75;
|
|
1338
|
+
const centerY = height / 2;
|
|
1339
|
+
const paths = pathConstructor({
|
|
1340
|
+
startX,
|
|
1341
|
+
endX,
|
|
1342
|
+
height
|
|
1343
|
+
});
|
|
1344
|
+
return /* @__PURE__ */ import_react12.default.createElement("svg", {
|
|
1345
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1346
|
+
className: "w-full h-full"
|
|
1347
|
+
}, (0, import_react_ui_canvas_editor7.getAnchorPoints)({
|
|
1348
|
+
x: 0,
|
|
1349
|
+
y: centerY
|
|
1350
|
+
}, inputs).map(({ x, y }, i) => /* @__PURE__ */ import_react12.default.createElement("line", {
|
|
1351
|
+
key: i,
|
|
1352
|
+
x1: x,
|
|
1353
|
+
y1: y,
|
|
1354
|
+
x2: startX * 1.3,
|
|
1355
|
+
y2: y,
|
|
1356
|
+
strokeWidth,
|
|
1357
|
+
className
|
|
1358
|
+
})), /* @__PURE__ */ import_react12.default.createElement("line", {
|
|
1359
|
+
x1: endX,
|
|
1360
|
+
y1: centerY,
|
|
1361
|
+
x2: width,
|
|
1362
|
+
y2: centerY,
|
|
1363
|
+
strokeWidth,
|
|
1364
|
+
className
|
|
1365
|
+
}), paths.map((path, i) => /* @__PURE__ */ import_react12.default.createElement("path", {
|
|
1366
|
+
key: i,
|
|
1367
|
+
d: path,
|
|
1368
|
+
strokeWidth,
|
|
1369
|
+
className
|
|
1370
|
+
})));
|
|
1371
|
+
};
|
|
1372
|
+
} finally {
|
|
1373
|
+
_effect.f();
|
|
1374
|
+
}
|
|
1309
1375
|
};
|
|
1310
1376
|
var AndSymbol = Symbol2(({ startX, endX, height }) => {
|
|
1311
1377
|
const arcRadius = (endX - startX) / 2;
|
|
@@ -1405,23 +1471,28 @@ var ChatShape = import_effect10.Schema.extend(ComputeShape, import_effect10.Sche
|
|
|
1405
1471
|
type: import_effect10.Schema.Literal("chat")
|
|
1406
1472
|
}));
|
|
1407
1473
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1474
|
+
var _effect = (0, import_tracking9.useSignals)();
|
|
1475
|
+
try {
|
|
1476
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1477
|
+
const inputRef = (0, import_react13.useRef)(null);
|
|
1478
|
+
const handleEnter = (text) => {
|
|
1479
|
+
const value = text.trim();
|
|
1480
|
+
if (value.length) {
|
|
1481
|
+
runtime.setOutput(import_conductor10.DEFAULT_OUTPUT, value);
|
|
1482
|
+
inputRef.current?.setText("");
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
return /* @__PURE__ */ import_react13.default.createElement(Box, {
|
|
1486
|
+
shape,
|
|
1487
|
+
title
|
|
1488
|
+
}, /* @__PURE__ */ import_react13.default.createElement(import_react_ui_canvas_editor8.TextBox, {
|
|
1489
|
+
ref: inputRef,
|
|
1490
|
+
onEnter: handleEnter,
|
|
1491
|
+
...props
|
|
1492
|
+
}));
|
|
1493
|
+
} finally {
|
|
1494
|
+
_effect.f();
|
|
1495
|
+
}
|
|
1425
1496
|
};
|
|
1426
1497
|
var createChat = (props) => createShape({
|
|
1427
1498
|
type: "chat",
|
|
@@ -1465,52 +1536,57 @@ var inferType = (value) => {
|
|
|
1465
1536
|
}
|
|
1466
1537
|
};
|
|
1467
1538
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
if (
|
|
1477
|
-
|
|
1539
|
+
var _effect = (0, import_tracking10.useSignals)();
|
|
1540
|
+
try {
|
|
1541
|
+
const { node } = useComputeNodeState(shape);
|
|
1542
|
+
const [type, setType] = (0, import_react14.useState)(inferType(node.value) ?? import_conductor11.ComputeValueType.literals[0]);
|
|
1543
|
+
const inputRef = (0, import_react14.useRef)(null);
|
|
1544
|
+
const handleEnter = (0, import_react14.useCallback)((text) => {
|
|
1545
|
+
const value = text.trim();
|
|
1546
|
+
if (value.length) {
|
|
1547
|
+
if (type === "number") {
|
|
1548
|
+
const floatValue = parseFloat(value);
|
|
1549
|
+
if (!isNaN(floatValue)) {
|
|
1550
|
+
node.value = floatValue;
|
|
1551
|
+
}
|
|
1552
|
+
} else if (type === "object") {
|
|
1553
|
+
node.value = (0, import_util2.safeParseJson)(value, {});
|
|
1554
|
+
} else {
|
|
1555
|
+
node.value = value;
|
|
1478
1556
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1557
|
+
inputRef.current?.focus();
|
|
1558
|
+
}
|
|
1559
|
+
}, [
|
|
1560
|
+
type
|
|
1561
|
+
]);
|
|
1562
|
+
return /* @__PURE__ */ import_react14.default.createElement(Box, {
|
|
1563
|
+
shape,
|
|
1564
|
+
title,
|
|
1565
|
+
status: /* @__PURE__ */ import_react14.default.createElement(TypeSelect, {
|
|
1566
|
+
value: type,
|
|
1567
|
+
onValueChange: setType
|
|
1568
|
+
})
|
|
1569
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ import_react14.default.createElement(import_react_ui_canvas_editor10.TextBox, {
|
|
1570
|
+
...props,
|
|
1571
|
+
ref: inputRef,
|
|
1572
|
+
value: node.value,
|
|
1573
|
+
onEnter: handleEnter
|
|
1574
|
+
}), type === "object" && /* @__PURE__ */ import_react14.default.createElement(import_react_ui_canvas_editor10.TextBox, {
|
|
1575
|
+
...props,
|
|
1576
|
+
ref: inputRef,
|
|
1577
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1578
|
+
language: "json"
|
|
1579
|
+
}), type === "boolean" && /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1580
|
+
className: "flex grow justify-center items-center"
|
|
1581
|
+
}, /* @__PURE__ */ import_react14.default.createElement(import_react_ui5.Input.Root, null, /* @__PURE__ */ import_react14.default.createElement(import_react_ui5.Input.Switch, {
|
|
1582
|
+
checked: node.value,
|
|
1583
|
+
onCheckedChange: (value) => {
|
|
1482
1584
|
node.value = value;
|
|
1483
1585
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
]);
|
|
1489
|
-
return /* @__PURE__ */ import_react14.default.createElement(Box, {
|
|
1490
|
-
shape,
|
|
1491
|
-
title,
|
|
1492
|
-
status: /* @__PURE__ */ import_react14.default.createElement(TypeSelect, {
|
|
1493
|
-
value: type,
|
|
1494
|
-
onValueChange: setType
|
|
1495
|
-
})
|
|
1496
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ import_react14.default.createElement(import_react_ui_canvas_editor10.TextBox, {
|
|
1497
|
-
...props,
|
|
1498
|
-
ref: inputRef,
|
|
1499
|
-
value: node.value,
|
|
1500
|
-
onEnter: handleEnter
|
|
1501
|
-
}), type === "object" && /* @__PURE__ */ import_react14.default.createElement(import_react_ui_canvas_editor10.TextBox, {
|
|
1502
|
-
...props,
|
|
1503
|
-
ref: inputRef,
|
|
1504
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1505
|
-
language: "json"
|
|
1506
|
-
}), type === "boolean" && /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1507
|
-
className: "flex grow justify-center items-center"
|
|
1508
|
-
}, /* @__PURE__ */ import_react14.default.createElement(import_react_ui5.Input.Root, null, /* @__PURE__ */ import_react14.default.createElement(import_react_ui5.Input.Switch, {
|
|
1509
|
-
checked: node.value,
|
|
1510
|
-
onCheckedChange: (value) => {
|
|
1511
|
-
node.value = value;
|
|
1512
|
-
}
|
|
1513
|
-
}))));
|
|
1586
|
+
}))));
|
|
1587
|
+
} finally {
|
|
1588
|
+
_effect.f();
|
|
1589
|
+
}
|
|
1514
1590
|
};
|
|
1515
1591
|
var createConstant = (props) => createShape({
|
|
1516
1592
|
type: "constant",
|
|
@@ -1549,9 +1625,14 @@ var createDatabase = (props) => createShape({
|
|
|
1549
1625
|
...props
|
|
1550
1626
|
});
|
|
1551
1627
|
var DatabaseComponent = ({ shape }) => {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1628
|
+
var _effect = (0, import_tracking11.useSignals)();
|
|
1629
|
+
try {
|
|
1630
|
+
return /* @__PURE__ */ import_react15.default.createElement(Box, {
|
|
1631
|
+
shape
|
|
1632
|
+
});
|
|
1633
|
+
} finally {
|
|
1634
|
+
_effect.f();
|
|
1635
|
+
}
|
|
1555
1636
|
};
|
|
1556
1637
|
var databaseShape = {
|
|
1557
1638
|
type: "database",
|
|
@@ -1578,54 +1659,59 @@ var createFunction = (props) => createShape({
|
|
|
1578
1659
|
...props
|
|
1579
1660
|
});
|
|
1580
1661
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
const
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1662
|
+
var _effect = (0, import_tracking12.useSignals)();
|
|
1663
|
+
try {
|
|
1664
|
+
const client = (0, import_react_client.useClient)();
|
|
1665
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1666
|
+
const inputRef = (0, import_react16.useRef)(null);
|
|
1667
|
+
const handleEnter = (0, import_react16.useCallback)(async (text) => {
|
|
1668
|
+
const value = text.trim();
|
|
1669
|
+
const { spaceId, objectId } = (0, import_echo2.parseId)(value);
|
|
1670
|
+
if (!spaceId || !objectId) {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
const space = client.spaces.get(spaceId);
|
|
1674
|
+
const object = space?.db.getObjectById(objectId);
|
|
1675
|
+
if (!space || !(0, import_echo_schema4.isInstanceOf)(import_functions.ScriptType, object)) {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
const { objects: [fn] } = await space.db.query(import_echo2.Filter.type(import_functions.FunctionType, {
|
|
1679
|
+
source: import_echo_schema4.Ref.make(object)
|
|
1680
|
+
})).run();
|
|
1681
|
+
if (!fn) {
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
node.value = value;
|
|
1685
|
+
node.function = (0, import_echo2.makeRef)(fn);
|
|
1686
|
+
node.inputSchema = (0, import_echo_schema4.getSnapshot)(fn.inputSchema);
|
|
1687
|
+
node.outputSchema = (0, import_echo_schema4.getSnapshot)(fn.outputSchema);
|
|
1688
|
+
}, [
|
|
1689
|
+
client,
|
|
1690
|
+
node
|
|
1691
|
+
]);
|
|
1692
|
+
const handleAction = (0, import_react16.useCallback)((action) => {
|
|
1693
|
+
if (action !== "run") {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
runtime.evalNode();
|
|
1697
|
+
}, [
|
|
1698
|
+
runtime
|
|
1699
|
+
]);
|
|
1700
|
+
return /* @__PURE__ */ import_react16.default.createElement(Box, {
|
|
1701
|
+
shape,
|
|
1702
|
+
title: "Function",
|
|
1703
|
+
onAction: handleAction
|
|
1704
|
+
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui_canvas_editor13.TextBox, {
|
|
1705
|
+
...props,
|
|
1706
|
+
ref: inputRef,
|
|
1707
|
+
value: node.value,
|
|
1708
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1709
|
+
onBlur: handleEnter,
|
|
1710
|
+
onEnter: handleEnter
|
|
1711
|
+
}));
|
|
1712
|
+
} finally {
|
|
1713
|
+
_effect.f();
|
|
1714
|
+
}
|
|
1629
1715
|
};
|
|
1630
1716
|
var functionShape = {
|
|
1631
1717
|
type: "function",
|
|
@@ -1647,49 +1733,54 @@ var createGpt = (props) => createShape({
|
|
|
1647
1733
|
...props
|
|
1648
1734
|
});
|
|
1649
1735
|
var GptComponent = ({ shape }) => {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1736
|
+
var _effect = (0, import_tracking13.useSignals)();
|
|
1737
|
+
try {
|
|
1738
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1739
|
+
const [text, setText] = (0, import_react17.useState)("");
|
|
1740
|
+
const [tokens, setTokens] = (0, import_react17.useState)(0);
|
|
1741
|
+
(0, import_react17.useEffect)(() => {
|
|
1742
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1743
|
+
switch (ev.type) {
|
|
1744
|
+
case "begin-compute": {
|
|
1745
|
+
setText("");
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
case "custom": {
|
|
1749
|
+
const token = ev.event;
|
|
1750
|
+
switch (token.type) {
|
|
1751
|
+
case "content_block_delta":
|
|
1752
|
+
switch (token.delta.type) {
|
|
1753
|
+
case "text_delta": {
|
|
1754
|
+
const delta = token.delta.text;
|
|
1755
|
+
setText((prev) => {
|
|
1756
|
+
const text2 = prev + delta;
|
|
1757
|
+
setTokens(text2.split(" ").length);
|
|
1758
|
+
return text2;
|
|
1759
|
+
});
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1673
1762
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1763
|
+
break;
|
|
1764
|
+
}
|
|
1765
|
+
break;
|
|
1676
1766
|
}
|
|
1677
|
-
break;
|
|
1678
1767
|
}
|
|
1679
|
-
}
|
|
1768
|
+
});
|
|
1769
|
+
}, [
|
|
1770
|
+
runtime?.subscribeToEventLog
|
|
1771
|
+
]);
|
|
1772
|
+
return /* @__PURE__ */ import_react17.default.createElement(FunctionBody, {
|
|
1773
|
+
shape,
|
|
1774
|
+
content: /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1775
|
+
className: "px-2 py-1 overflow-y-scroll"
|
|
1776
|
+
}, text),
|
|
1777
|
+
status: `${tokens} tokens`,
|
|
1778
|
+
inputSchema: meta.input,
|
|
1779
|
+
outputSchema: meta.output
|
|
1680
1780
|
});
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
return /* @__PURE__ */ import_react17.default.createElement(FunctionBody, {
|
|
1685
|
-
shape,
|
|
1686
|
-
content: /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1687
|
-
className: "px-2 py-1 overflow-y-scroll"
|
|
1688
|
-
}, text),
|
|
1689
|
-
status: `${tokens} tokens`,
|
|
1690
|
-
inputSchema: meta.input,
|
|
1691
|
-
outputSchema: meta.output
|
|
1692
|
-
});
|
|
1781
|
+
} finally {
|
|
1782
|
+
_effect.f();
|
|
1783
|
+
}
|
|
1693
1784
|
};
|
|
1694
1785
|
var gptShape = {
|
|
1695
1786
|
type: "gpt",
|
|
@@ -1707,20 +1798,30 @@ var JsonTransformShape = import_effect15.Schema.extend(ComputeShape, import_effe
|
|
|
1707
1798
|
type: import_effect15.Schema.Literal("json-transform")
|
|
1708
1799
|
}));
|
|
1709
1800
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1801
|
+
var _effect = (0, import_tracking14.useSignals)();
|
|
1802
|
+
try {
|
|
1803
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1804
|
+
const input = runtime.inputs[import_conductor14.DEFAULT_INPUT];
|
|
1805
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1806
|
+
return /* @__PURE__ */ import_react18.default.createElement(Box, {
|
|
1807
|
+
shape
|
|
1808
|
+
}, /* @__PURE__ */ import_react18.default.createElement(import_react_ui_syntax_highlighter.JsonFilter, {
|
|
1809
|
+
data: value,
|
|
1810
|
+
classNames: "text-xs"
|
|
1811
|
+
}));
|
|
1812
|
+
} finally {
|
|
1813
|
+
_effect.f();
|
|
1814
|
+
}
|
|
1719
1815
|
};
|
|
1720
1816
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1817
|
+
var _effect = (0, import_tracking14.useSignals)();
|
|
1818
|
+
try {
|
|
1819
|
+
return /* @__PURE__ */ import_react18.default.createElement(Box, {
|
|
1820
|
+
shape
|
|
1821
|
+
});
|
|
1822
|
+
} finally {
|
|
1823
|
+
_effect.f();
|
|
1824
|
+
}
|
|
1724
1825
|
};
|
|
1725
1826
|
var createJson = (props) => createShape({
|
|
1726
1827
|
type: "json",
|
|
@@ -1772,18 +1873,28 @@ var IfElseShape = import_effect16.Schema.extend(ComputeShape, import_effect16.Sc
|
|
|
1772
1873
|
type: import_effect16.Schema.Literal("if-else")
|
|
1773
1874
|
}));
|
|
1774
1875
|
var IfComponent = ({ shape, ...props }) => {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1876
|
+
var _effect = (0, import_tracking15.useSignals)();
|
|
1877
|
+
try {
|
|
1878
|
+
return /* @__PURE__ */ import_react19.default.createElement(FunctionBody, {
|
|
1879
|
+
shape,
|
|
1880
|
+
inputSchema: import_conductor15.IfInput,
|
|
1881
|
+
outputSchema: import_conductor15.IfOutput
|
|
1882
|
+
});
|
|
1883
|
+
} finally {
|
|
1884
|
+
_effect.f();
|
|
1885
|
+
}
|
|
1780
1886
|
};
|
|
1781
1887
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1888
|
+
var _effect = (0, import_tracking15.useSignals)();
|
|
1889
|
+
try {
|
|
1890
|
+
return /* @__PURE__ */ import_react19.default.createElement(FunctionBody, {
|
|
1891
|
+
shape,
|
|
1892
|
+
inputSchema: import_conductor15.IfElseInput,
|
|
1893
|
+
outputSchema: import_conductor15.IfElseOutput
|
|
1894
|
+
});
|
|
1895
|
+
} finally {
|
|
1896
|
+
_effect.f();
|
|
1897
|
+
}
|
|
1787
1898
|
};
|
|
1788
1899
|
var createIf = (props) => createShape({
|
|
1789
1900
|
type: "if",
|
|
@@ -1829,40 +1940,50 @@ var createQueue = (props) => createShape({
|
|
|
1829
1940
|
...props
|
|
1830
1941
|
});
|
|
1831
1942
|
var QueueComponent = ({ shape }) => {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1943
|
+
var _effect = (0, import_tracking16.useSignals)();
|
|
1944
|
+
try {
|
|
1945
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1946
|
+
const items = runtime.outputs[import_conductor16.DEFAULT_OUTPUT]?.type === "executed" ? runtime.outputs[import_conductor16.DEFAULT_OUTPUT].value : [];
|
|
1947
|
+
const handleAction = (action) => {
|
|
1948
|
+
if (action === "run") {
|
|
1949
|
+
runtime.evalNode();
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
return /* @__PURE__ */ import_react20.default.createElement(Box, {
|
|
1953
|
+
shape,
|
|
1954
|
+
status: `${items.length} items`,
|
|
1955
|
+
onAction: handleAction
|
|
1956
|
+
}, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1957
|
+
className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
|
|
1958
|
+
}, [
|
|
1959
|
+
...items
|
|
1960
|
+
].map((item, i) => /* @__PURE__ */ import_react20.default.createElement(QueueItem, {
|
|
1961
|
+
key: i,
|
|
1962
|
+
classNames: "p-1 px-2",
|
|
1963
|
+
item
|
|
1964
|
+
}))));
|
|
1965
|
+
} finally {
|
|
1966
|
+
_effect.f();
|
|
1967
|
+
}
|
|
1852
1968
|
};
|
|
1853
1969
|
var QueueItem = ({ classNames, item }) => {
|
|
1854
|
-
|
|
1970
|
+
var _effect = (0, import_tracking16.useSignals)();
|
|
1971
|
+
try {
|
|
1972
|
+
if (typeof item !== "object") {
|
|
1973
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1974
|
+
className: (0, import_react_ui_theme3.mx)(classNames, "whitespace-pre-wrap")
|
|
1975
|
+
}, item);
|
|
1976
|
+
}
|
|
1855
1977
|
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1856
|
-
className: (0, import_react_ui_theme3.mx)(
|
|
1857
|
-
}, item)
|
|
1978
|
+
className: (0, import_react_ui_theme3.mx)("grid grid-cols-[80px,1fr]", classNames)
|
|
1979
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ import_react20.default.createElement(import_react20.Fragment, {
|
|
1980
|
+
key
|
|
1981
|
+
}, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1982
|
+
className: "p-1 text-xs text-subdued"
|
|
1983
|
+
}, key), /* @__PURE__ */ import_react20.default.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1984
|
+
} finally {
|
|
1985
|
+
_effect.f();
|
|
1858
1986
|
}
|
|
1859
|
-
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1860
|
-
className: (0, import_react_ui_theme3.mx)("grid grid-cols-[80px,1fr]", classNames)
|
|
1861
|
-
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ import_react20.default.createElement(import_react20.Fragment, {
|
|
1862
|
-
key
|
|
1863
|
-
}, /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1864
|
-
className: "p-1 text-xs text-subdued"
|
|
1865
|
-
}, key), /* @__PURE__ */ import_react20.default.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1866
1987
|
};
|
|
1867
1988
|
var queueShape = {
|
|
1868
1989
|
type: "queue",
|
|
@@ -1896,37 +2017,42 @@ var icons = [
|
|
|
1896
2017
|
];
|
|
1897
2018
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1898
2019
|
var RandomComponent = ({ shape }) => {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
2020
|
+
var _effect = (0, import_tracking17.useSignals)();
|
|
2021
|
+
try {
|
|
2022
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2023
|
+
const [spin, setSpin] = (0, import_react21.useState)(false);
|
|
2024
|
+
const [icon, setIcon] = (0, import_react21.useState)(pickIcon());
|
|
2025
|
+
(0, import_react21.useEffect)(() => {
|
|
2026
|
+
if (!spin) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
2030
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
2031
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
2032
|
+
return () => {
|
|
2033
|
+
clearInterval(i);
|
|
2034
|
+
clearTimeout(t1);
|
|
2035
|
+
clearTimeout(t2);
|
|
2036
|
+
};
|
|
2037
|
+
}, [
|
|
2038
|
+
spin
|
|
2039
|
+
]);
|
|
2040
|
+
const handleClick = (ev) => {
|
|
2041
|
+
ev.stopPropagation();
|
|
2042
|
+
runtime.setOutput(import_conductor17.DEFAULT_OUTPUT, Math.random());
|
|
2043
|
+
setSpin(true);
|
|
1913
2044
|
};
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
}
|
|
1925
|
-
icon,
|
|
1926
|
-
classNames: (0, import_react_ui_theme4.mx)(spin && "animate-[spin_1s]"),
|
|
1927
|
-
size: 10,
|
|
1928
|
-
onClick: handleClick
|
|
1929
|
-
}));
|
|
2045
|
+
return /* @__PURE__ */ import_react21.default.createElement("div", {
|
|
2046
|
+
className: "flex grow items-center justify-center"
|
|
2047
|
+
}, /* @__PURE__ */ import_react21.default.createElement(import_react_ui6.Icon, {
|
|
2048
|
+
icon,
|
|
2049
|
+
classNames: (0, import_react_ui_theme4.mx)(spin && "animate-[spin_1s]"),
|
|
2050
|
+
size: 10,
|
|
2051
|
+
onClick: handleClick
|
|
2052
|
+
}));
|
|
2053
|
+
} finally {
|
|
2054
|
+
_effect.f();
|
|
2055
|
+
}
|
|
1930
2056
|
};
|
|
1931
2057
|
var randomShape = {
|
|
1932
2058
|
type: "rng",
|
|
@@ -1954,20 +2080,25 @@ var createScope = (props) => createShape({
|
|
|
1954
2080
|
...props
|
|
1955
2081
|
});
|
|
1956
2082
|
var ScopeComponent = ({ shape }) => {
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2083
|
+
var _effect = (0, import_tracking18.useSignals)();
|
|
2084
|
+
try {
|
|
2085
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2086
|
+
const input = runtime.inputs[import_conductor18.DEFAULT_INPUT];
|
|
2087
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
2088
|
+
const { getAverage } = (0, import_react_ui_sfx.useAudioStream)(active);
|
|
2089
|
+
return /* @__PURE__ */ import_react22.default.createElement("div", {
|
|
2090
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
2091
|
+
}, /* @__PURE__ */ import_react22.default.createElement(import_react_ui_sfx.Chaos, {
|
|
2092
|
+
active,
|
|
2093
|
+
getValue: getAverage,
|
|
2094
|
+
options: {
|
|
2095
|
+
...import_react_ui_sfx.shaderPresets.heptapod,
|
|
2096
|
+
zoom: 1.2
|
|
2097
|
+
}
|
|
2098
|
+
}));
|
|
2099
|
+
} finally {
|
|
2100
|
+
_effect.f();
|
|
2101
|
+
}
|
|
1971
2102
|
};
|
|
1972
2103
|
var scopeShape = {
|
|
1973
2104
|
type: "scope",
|
|
@@ -1994,24 +2125,29 @@ var createSurface = (props) => createShape({
|
|
|
1994
2125
|
...props
|
|
1995
2126
|
});
|
|
1996
2127
|
var SurfaceComponent = ({ shape }) => {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2128
|
+
var _effect = (0, import_tracking19.useSignals)();
|
|
2129
|
+
try {
|
|
2130
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2131
|
+
const input = runtime.inputs[import_conductor19.DEFAULT_INPUT];
|
|
2132
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
2133
|
+
const handleAction = (action) => {
|
|
2134
|
+
if (action === "run") {
|
|
2135
|
+
runtime.evalNode();
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
return /* @__PURE__ */ import_react23.default.createElement(Box, {
|
|
2139
|
+
shape,
|
|
2140
|
+
onAction: handleAction
|
|
2141
|
+
}, value !== null && /* @__PURE__ */ import_react23.default.createElement(import_app_framework.Surface, {
|
|
2142
|
+
role: "canvas-node",
|
|
2143
|
+
data: {
|
|
2144
|
+
value
|
|
2145
|
+
},
|
|
2146
|
+
limit: 1
|
|
2147
|
+
}));
|
|
2148
|
+
} finally {
|
|
2149
|
+
_effect.f();
|
|
2150
|
+
}
|
|
2015
2151
|
};
|
|
2016
2152
|
var surfaceShape = {
|
|
2017
2153
|
type: "surface",
|
|
@@ -2039,20 +2175,25 @@ var createSwitch = (props) => createShape({
|
|
|
2039
2175
|
...props
|
|
2040
2176
|
});
|
|
2041
2177
|
var SwitchComponent = ({ shape }) => {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2178
|
+
var _effect = (0, import_tracking20.useSignals)();
|
|
2179
|
+
try {
|
|
2180
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2181
|
+
const [value, setValue] = (0, import_react24.useState)(false);
|
|
2182
|
+
(0, import_react24.useEffect)(() => {
|
|
2183
|
+
runtime.setOutput(import_conductor20.DEFAULT_OUTPUT, value);
|
|
2184
|
+
}, [
|
|
2185
|
+
value
|
|
2186
|
+
]);
|
|
2187
|
+
return /* @__PURE__ */ import_react24.default.createElement("div", {
|
|
2188
|
+
className: "flex w-full justify-center items-center",
|
|
2189
|
+
onClick: (ev) => ev.stopPropagation()
|
|
2190
|
+
}, /* @__PURE__ */ import_react24.default.createElement(import_react_ui7.Input.Root, null, /* @__PURE__ */ import_react24.default.createElement(import_react_ui7.Input.Switch, {
|
|
2191
|
+
checked: value,
|
|
2192
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
2193
|
+
})));
|
|
2194
|
+
} finally {
|
|
2195
|
+
_effect.f();
|
|
2196
|
+
}
|
|
2056
2197
|
};
|
|
2057
2198
|
var switchShape = {
|
|
2058
2199
|
type: "switch",
|
|
@@ -2081,9 +2222,14 @@ var createTable = (props) => createShape({
|
|
|
2081
2222
|
...props
|
|
2082
2223
|
});
|
|
2083
2224
|
var TableComponent = ({ shape }) => {
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2225
|
+
var _effect = (0, import_tracking21.useSignals)();
|
|
2226
|
+
try {
|
|
2227
|
+
return /* @__PURE__ */ import_react25.default.createElement(Box, {
|
|
2228
|
+
shape
|
|
2229
|
+
});
|
|
2230
|
+
} finally {
|
|
2231
|
+
_effect.f();
|
|
2232
|
+
}
|
|
2087
2233
|
};
|
|
2088
2234
|
var tableShape = {
|
|
2089
2235
|
type: "table",
|
|
@@ -2100,44 +2246,49 @@ var TemplateShape = import_effect23.Schema.extend(ComputeShape, import_effect23.
|
|
|
2100
2246
|
valueType: import_effect23.Schema.optional(import_conductor22.ComputeValueType)
|
|
2101
2247
|
}));
|
|
2102
2248
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2108
|
-
const
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2249
|
+
var _effect = (0, import_tracking22.useSignals)();
|
|
2250
|
+
try {
|
|
2251
|
+
const { node } = useComputeNodeState(shape);
|
|
2252
|
+
const inputRef = (0, import_react26.useRef)(null);
|
|
2253
|
+
const handleEnter = (text) => {
|
|
2254
|
+
const value = text.trim();
|
|
2255
|
+
if (value.length) {
|
|
2256
|
+
const schema = (0, import_conductor22.getTemplateInputSchema)(node);
|
|
2257
|
+
node.value = value;
|
|
2258
|
+
node.inputSchema = (0, import_echo_schema5.toJsonSchema)(schema);
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
const handleTypeChange = (newType) => {
|
|
2262
|
+
(0, import_invariant5.invariant)(import_effect23.Schema.is(import_conductor22.ComputeValueType)(newType), "Invalid type", {
|
|
2263
|
+
F: __dxlog_file6,
|
|
2264
|
+
L: 58,
|
|
2265
|
+
S: void 0,
|
|
2266
|
+
A: [
|
|
2267
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
2268
|
+
"'Invalid type'"
|
|
2269
|
+
]
|
|
2270
|
+
});
|
|
2271
|
+
node.valueType = newType;
|
|
2272
|
+
node.inputSchema = (0, import_echo_schema5.toJsonSchema)((0, import_conductor22.getTemplateInputSchema)(node));
|
|
2273
|
+
};
|
|
2274
|
+
return /* @__PURE__ */ import_react26.default.createElement(Box, {
|
|
2275
|
+
shape,
|
|
2276
|
+
title: "Template",
|
|
2277
|
+
status: /* @__PURE__ */ import_react26.default.createElement(TypeSelect, {
|
|
2278
|
+
value: node.valueType ?? "string",
|
|
2279
|
+
onValueChange: handleTypeChange
|
|
2280
|
+
})
|
|
2281
|
+
}, /* @__PURE__ */ import_react26.default.createElement(import_react_ui_canvas_editor19.TextBox, {
|
|
2282
|
+
...props,
|
|
2283
|
+
ref: inputRef,
|
|
2284
|
+
value: node.value,
|
|
2285
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2286
|
+
onBlur: handleEnter,
|
|
2287
|
+
onEnter: handleEnter
|
|
2288
|
+
}));
|
|
2289
|
+
} finally {
|
|
2290
|
+
_effect.f();
|
|
2291
|
+
}
|
|
2141
2292
|
};
|
|
2142
2293
|
var createTemplate = (props) => createShape({
|
|
2143
2294
|
type: "template",
|
|
@@ -2171,20 +2322,25 @@ var createText = (props) => createShape({
|
|
|
2171
2322
|
...props
|
|
2172
2323
|
});
|
|
2173
2324
|
var TextComponent = ({ shape }) => {
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2325
|
+
var _effect = (0, import_tracking23.useSignals)();
|
|
2326
|
+
try {
|
|
2327
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2328
|
+
const input = runtime.inputs[import_conductor23.DEFAULT_INPUT];
|
|
2329
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2330
|
+
const handleAction = (action) => {
|
|
2331
|
+
if (action === "run") {
|
|
2332
|
+
runtime.evalNode();
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2335
|
+
return /* @__PURE__ */ import_react27.default.createElement(Box, {
|
|
2336
|
+
shape,
|
|
2337
|
+
onAction: handleAction
|
|
2338
|
+
}, /* @__PURE__ */ import_react27.default.createElement(import_react_ui_canvas_editor20.TextBox, {
|
|
2339
|
+
value
|
|
2340
|
+
}));
|
|
2341
|
+
} finally {
|
|
2342
|
+
_effect.f();
|
|
2343
|
+
}
|
|
2188
2344
|
};
|
|
2189
2345
|
var textShape = {
|
|
2190
2346
|
type: "text",
|
|
@@ -2214,39 +2370,49 @@ var createThread = (props) => createShape({
|
|
|
2214
2370
|
...props
|
|
2215
2371
|
});
|
|
2216
2372
|
var ThreadComponent = ({ shape }) => {
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
item
|
|
2236
|
-
|
|
2373
|
+
var _effect = (0, import_tracking24.useSignals)();
|
|
2374
|
+
try {
|
|
2375
|
+
const items = [];
|
|
2376
|
+
const scrollRef = (0, import_react28.useRef)(null);
|
|
2377
|
+
(0, import_react28.useEffect)(() => {
|
|
2378
|
+
if (scrollRef.current) {
|
|
2379
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2380
|
+
}
|
|
2381
|
+
}, [
|
|
2382
|
+
items
|
|
2383
|
+
]);
|
|
2384
|
+
return /* @__PURE__ */ import_react28.default.createElement(Box, {
|
|
2385
|
+
shape
|
|
2386
|
+
}, /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2387
|
+
ref: scrollRef,
|
|
2388
|
+
className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
|
|
2389
|
+
}, [
|
|
2390
|
+
...items
|
|
2391
|
+
].map((item, i) => /* @__PURE__ */ import_react28.default.createElement(ThreadItem, {
|
|
2392
|
+
key: i,
|
|
2393
|
+
item
|
|
2394
|
+
}))));
|
|
2395
|
+
} finally {
|
|
2396
|
+
_effect.f();
|
|
2397
|
+
}
|
|
2237
2398
|
};
|
|
2238
2399
|
var ThreadItem = ({ classNames, item }) => {
|
|
2239
|
-
|
|
2400
|
+
var _effect = (0, import_tracking24.useSignals)();
|
|
2401
|
+
try {
|
|
2402
|
+
if (typeof item !== "object") {
|
|
2403
|
+
return /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2404
|
+
className: (0, import_react_ui_theme5.mx)(classNames)
|
|
2405
|
+
}, item);
|
|
2406
|
+
}
|
|
2407
|
+
const { role, message } = item;
|
|
2240
2408
|
return /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2241
|
-
className: (0, import_react_ui_theme5.mx)(classNames)
|
|
2242
|
-
},
|
|
2409
|
+
className: (0, import_react_ui_theme5.mx)("flex", classNames, role === "user" && "justify-end")
|
|
2410
|
+
}, /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2411
|
+
className: (0, import_react_ui_theme5.mx)("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")
|
|
2412
|
+
}, message));
|
|
2413
|
+
} finally {
|
|
2414
|
+
_effect.f();
|
|
2243
2415
|
}
|
|
2244
|
-
const { role, message } = item;
|
|
2245
|
-
return /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2246
|
-
className: (0, import_react_ui_theme5.mx)("flex", classNames, role === "user" && "justify-end")
|
|
2247
|
-
}, /* @__PURE__ */ import_react28.default.createElement("div", {
|
|
2248
|
-
className: (0, import_react_ui_theme5.mx)("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")
|
|
2249
|
-
}, message));
|
|
2250
2416
|
};
|
|
2251
2417
|
var threadShape = {
|
|
2252
2418
|
type: "thread",
|
|
@@ -2269,9 +2435,14 @@ var createTextToImage = (props) => createShape({
|
|
|
2269
2435
|
...props
|
|
2270
2436
|
});
|
|
2271
2437
|
var TextToImageComponent = ({ shape }) => {
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2438
|
+
var _effect = (0, import_tracking25.useSignals)();
|
|
2439
|
+
try {
|
|
2440
|
+
return /* @__PURE__ */ import_react29.default.createElement(Box, {
|
|
2441
|
+
shape
|
|
2442
|
+
});
|
|
2443
|
+
} finally {
|
|
2444
|
+
_effect.f();
|
|
2445
|
+
}
|
|
2275
2446
|
};
|
|
2276
2447
|
var textToImageShape = {
|
|
2277
2448
|
type: "text-to-image",
|
|
@@ -2306,56 +2477,66 @@ var createTrigger = (props) => {
|
|
|
2306
2477
|
});
|
|
2307
2478
|
};
|
|
2308
2479
|
var TriggerComponent = ({ shape }) => {
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2480
|
+
var _effect = (0, import_tracking26.useSignals)();
|
|
2481
|
+
try {
|
|
2482
|
+
const space = (0, import_echo3.useSpace)();
|
|
2483
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2484
|
+
(0, import_react30.useEffect)(() => {
|
|
2485
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2486
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2487
|
+
triggerKind: import_functions2.TriggerKind.Email,
|
|
2488
|
+
spaceId: space?.id
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
}, [
|
|
2492
|
+
functionTrigger,
|
|
2493
|
+
functionTrigger?.spec
|
|
2494
|
+
]);
|
|
2495
|
+
(0, import_react30.useEffect)(() => {
|
|
2496
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? import_functions2.TriggerKind.Email));
|
|
2497
|
+
}, [
|
|
2498
|
+
functionTrigger?.spec?.kind
|
|
2499
|
+
]);
|
|
2500
|
+
const setKind = (kind) => {
|
|
2501
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2502
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2503
|
+
triggerKind: kind,
|
|
2504
|
+
spaceId: space?.id
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
if (!functionTrigger?.spec) {
|
|
2509
|
+
return;
|
|
2333
2510
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2511
|
+
return /* @__PURE__ */ import_react30.default.createElement(FunctionBody, {
|
|
2512
|
+
shape,
|
|
2513
|
+
status: /* @__PURE__ */ import_react30.default.createElement(TriggerKindSelect, {
|
|
2514
|
+
value: functionTrigger.spec?.kind,
|
|
2515
|
+
onValueChange: (kind) => setKind(kind)
|
|
2516
|
+
}),
|
|
2517
|
+
inputSchema: import_conductor25.VoidInput,
|
|
2518
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2519
|
+
});
|
|
2520
|
+
} finally {
|
|
2521
|
+
_effect.f();
|
|
2337
2522
|
}
|
|
2338
|
-
return /* @__PURE__ */ import_react30.default.createElement(FunctionBody, {
|
|
2339
|
-
shape,
|
|
2340
|
-
status: /* @__PURE__ */ import_react30.default.createElement(TriggerKindSelect, {
|
|
2341
|
-
value: functionTrigger.spec?.kind,
|
|
2342
|
-
onValueChange: (kind) => setKind(kind)
|
|
2343
|
-
}),
|
|
2344
|
-
inputSchema: import_conductor25.VoidInput,
|
|
2345
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2346
|
-
});
|
|
2347
2523
|
};
|
|
2348
2524
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2525
|
+
var _effect = (0, import_tracking26.useSignals)();
|
|
2526
|
+
try {
|
|
2527
|
+
return /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Root, {
|
|
2528
|
+
value,
|
|
2529
|
+
onValueChange
|
|
2530
|
+
}, /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
2531
|
+
variant: "ghost",
|
|
2532
|
+
classNames: "w-full !px-0"
|
|
2533
|
+
}), /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.ScrollUpButton, null), /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Viewport, null, Object.values(import_functions2.TriggerKind).map((kind) => /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Option, {
|
|
2534
|
+
key: kind,
|
|
2535
|
+
value: kind
|
|
2536
|
+
}, kind))), /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.ScrollDownButton, null), /* @__PURE__ */ import_react30.default.createElement(import_react_ui8.Select.Arrow, null))));
|
|
2537
|
+
} finally {
|
|
2538
|
+
_effect.f();
|
|
2539
|
+
}
|
|
2359
2540
|
};
|
|
2360
2541
|
var createTriggerSpec = (props) => {
|
|
2361
2542
|
const kind = props.triggerKind ?? import_functions2.TriggerKind.Email;
|
|
@@ -2423,100 +2604,105 @@ var createGptRealtime = (props) => createShape({
|
|
|
2423
2604
|
...props
|
|
2424
2605
|
});
|
|
2425
2606
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
const
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
direction: "sendrecv"
|
|
2447
|
-
}));
|
|
2448
|
-
const offer = await peerConnection.createOffer();
|
|
2449
|
-
await peerConnection.setLocalDescription(offer);
|
|
2450
|
-
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2451
|
-
const response = await fetch(aiServiceUrl, {
|
|
2452
|
-
method: "POST",
|
|
2453
|
-
body: offer.sdp,
|
|
2454
|
-
headers: {
|
|
2455
|
-
"Content-Type": "application/sdp"
|
|
2456
|
-
}
|
|
2457
|
-
});
|
|
2458
|
-
const answer = await response.text();
|
|
2459
|
-
await peerConnection.setRemoteDescription({
|
|
2460
|
-
sdp: answer,
|
|
2461
|
-
type: "answer"
|
|
2462
|
-
});
|
|
2463
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2464
|
-
const configureData = () => {
|
|
2465
|
-
import_log2.log.info("Configuring data channel", void 0, {
|
|
2466
|
-
F: __dxlog_file7,
|
|
2467
|
-
L: 87,
|
|
2468
|
-
S: void 0,
|
|
2469
|
-
C: (f, a) => f(...a)
|
|
2607
|
+
var _effect = (0, import_tracking27.useSignals)();
|
|
2608
|
+
try {
|
|
2609
|
+
const [isLive, setIsLive] = (0, import_react31.useState)(false);
|
|
2610
|
+
const [isReady, setIsReady] = (0, import_react31.useState)(false);
|
|
2611
|
+
const config = (0, import_react_client2.useConfig)();
|
|
2612
|
+
const start = async () => {
|
|
2613
|
+
setIsLive(true);
|
|
2614
|
+
try {
|
|
2615
|
+
const peerConnection = new RTCPeerConnection();
|
|
2616
|
+
peerConnection.ontrack = (event) => {
|
|
2617
|
+
const audioElement = document.createElement("audio");
|
|
2618
|
+
audioElement.srcObject = event.streams[0];
|
|
2619
|
+
audioElement.autoplay = true;
|
|
2620
|
+
audioElement.controls = false;
|
|
2621
|
+
audioElement.style.display = "none";
|
|
2622
|
+
document.body.appendChild(audioElement);
|
|
2623
|
+
setIsReady(true);
|
|
2624
|
+
};
|
|
2625
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2626
|
+
audio: true
|
|
2470
2627
|
});
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2628
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2629
|
+
direction: "sendrecv"
|
|
2630
|
+
}));
|
|
2631
|
+
const offer = await peerConnection.createOffer();
|
|
2632
|
+
await peerConnection.setLocalDescription(offer);
|
|
2633
|
+
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2634
|
+
const response = await fetch(aiServiceUrl, {
|
|
2635
|
+
method: "POST",
|
|
2636
|
+
body: offer.sdp,
|
|
2637
|
+
headers: {
|
|
2638
|
+
"Content-Type": "application/sdp"
|
|
2480
2639
|
}
|
|
2640
|
+
});
|
|
2641
|
+
const answer = await response.text();
|
|
2642
|
+
await peerConnection.setRemoteDescription({
|
|
2643
|
+
sdp: answer,
|
|
2644
|
+
type: "answer"
|
|
2645
|
+
});
|
|
2646
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
2647
|
+
const configureData = () => {
|
|
2648
|
+
import_log2.log.info("Configuring data channel", void 0, {
|
|
2649
|
+
F: __dxlog_file7,
|
|
2650
|
+
L: 87,
|
|
2651
|
+
S: void 0,
|
|
2652
|
+
C: (f, a) => f(...a)
|
|
2653
|
+
});
|
|
2654
|
+
const event = {
|
|
2655
|
+
type: "session.update",
|
|
2656
|
+
session: {
|
|
2657
|
+
modalities: [
|
|
2658
|
+
"text",
|
|
2659
|
+
"audio"
|
|
2660
|
+
],
|
|
2661
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2662
|
+
tools: []
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
dataChannel.send(JSON.stringify(event));
|
|
2481
2666
|
};
|
|
2482
|
-
dataChannel.
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2667
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
2668
|
+
import_log2.log.info("Opening data channel", {
|
|
2669
|
+
ev
|
|
2670
|
+
}, {
|
|
2671
|
+
F: __dxlog_file7,
|
|
2672
|
+
L: 100,
|
|
2673
|
+
S: void 0,
|
|
2674
|
+
C: (f, a) => f(...a)
|
|
2675
|
+
});
|
|
2676
|
+
configureData();
|
|
2677
|
+
});
|
|
2678
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
2679
|
+
const msg = JSON.parse(ev.data);
|
|
2680
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2683
|
+
} catch (error) {
|
|
2684
|
+
import_log2.log.error("Error in realtime session:", {
|
|
2685
|
+
error
|
|
2487
2686
|
}, {
|
|
2488
2687
|
F: __dxlog_file7,
|
|
2489
|
-
L:
|
|
2688
|
+
L: 140,
|
|
2490
2689
|
S: void 0,
|
|
2491
2690
|
C: (f, a) => f(...a)
|
|
2492
2691
|
});
|
|
2493
|
-
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
C: (f, a) => f(...a)
|
|
2508
|
-
});
|
|
2509
|
-
throw error;
|
|
2510
|
-
}
|
|
2511
|
-
};
|
|
2512
|
-
return /* @__PURE__ */ import_react31.default.createElement("div", {
|
|
2513
|
-
className: "flex w-full justify-center items-center"
|
|
2514
|
-
}, /* @__PURE__ */ import_react31.default.createElement(import_react_ui9.Icon, {
|
|
2515
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2516
|
-
size: 16,
|
|
2517
|
-
classNames: !isLive && "cursor-pointer",
|
|
2518
|
-
onClick: start
|
|
2519
|
-
}));
|
|
2692
|
+
throw error;
|
|
2693
|
+
}
|
|
2694
|
+
};
|
|
2695
|
+
return /* @__PURE__ */ import_react31.default.createElement("div", {
|
|
2696
|
+
className: "flex w-full justify-center items-center"
|
|
2697
|
+
}, /* @__PURE__ */ import_react31.default.createElement(import_react_ui9.Icon, {
|
|
2698
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2699
|
+
size: 16,
|
|
2700
|
+
classNames: !isLive && "cursor-pointer",
|
|
2701
|
+
onClick: start
|
|
2702
|
+
}));
|
|
2703
|
+
} finally {
|
|
2704
|
+
_effect.f();
|
|
2705
|
+
}
|
|
2520
2706
|
};
|
|
2521
2707
|
var gptRealtimeShape = {
|
|
2522
2708
|
type: "gpt-realtime",
|
|
@@ -2593,8 +2779,7 @@ var computeShapes = [
|
|
|
2593
2779
|
];
|
|
2594
2780
|
var ComputeShapeLayout = class extends import_react_ui_canvas_editor23.ShapeLayout {
|
|
2595
2781
|
constructor(_controller, registry2) {
|
|
2596
|
-
super(registry2);
|
|
2597
|
-
this._controller = _controller;
|
|
2782
|
+
super(registry2), this._controller = _controller;
|
|
2598
2783
|
}
|
|
2599
2784
|
// TODO(burdon): Doesn't update.
|
|
2600
2785
|
getAnchors(shape) {
|