@dxos/react-ui-canvas-compute 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77
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 +178 -140
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +178 -140
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +12 -5
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +4 -4
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +2 -2
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -31
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -51
- package/src/compute.stories.tsx +13 -12
- package/src/graph/controller.ts +5 -4
- package/src/graph/node-defs.ts +3 -3
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +3 -2
- package/src/hooks/useGraphMonitor.ts +1 -1
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +2 -2
- package/src/shapes/Append.tsx +2 -2
- package/src/shapes/Array.tsx +2 -2
- package/src/shapes/Audio.tsx +3 -2
- package/src/shapes/Beacon.tsx +3 -2
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Chat.tsx +3 -2
- package/src/shapes/Constant.tsx +3 -2
- package/src/shapes/Database.tsx +1 -1
- package/src/shapes/Function.tsx +6 -5
- package/src/shapes/Gpt.tsx +6 -4
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +3 -2
- package/src/shapes/Logic.tsx +2 -2
- package/src/shapes/Queue.tsx +3 -2
- package/src/shapes/RNG.tsx +3 -2
- package/src/shapes/Scope.tsx +4 -3
- package/src/shapes/Surface.tsx +3 -2
- package/src/shapes/Switch.tsx +3 -2
- package/src/shapes/Table.tsx +2 -2
- package/src/shapes/Template.tsx +4 -3
- package/src/shapes/Text.tsx +4 -3
- package/src/shapes/TextToImage.tsx +1 -1
- package/src/shapes/Thread.tsx +2 -2
- package/src/shapes/Trigger.tsx +29 -31
- package/src/shapes/common/Box.tsx +1 -1
- package/src/shapes/common/FunctionBody.tsx +1 -1
|
@@ -7,88 +7,12 @@ import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
|
7
7
|
import { Resource } from "@dxos/context";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
9
|
|
|
10
|
-
// src/graph/node-defs.ts
|
|
11
|
-
import { NODE_INPUT, NODE_OUTPUT, registry, getTemplateInputSchema } from "@dxos/conductor";
|
|
12
|
-
import { raise } from "@dxos/debug";
|
|
13
|
-
import { ObjectId, toJsonSchema } from "@dxos/echo-schema";
|
|
14
|
-
import { invariant } from "@dxos/invariant";
|
|
15
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
16
|
-
var resolveComputeNode = async (node) => {
|
|
17
|
-
const impl = registry[node.type];
|
|
18
|
-
invariant(impl, `Unknown node type: ${node.type}`, {
|
|
19
|
-
F: __dxlog_file,
|
|
20
|
-
L: 22,
|
|
21
|
-
S: void 0,
|
|
22
|
-
A: [
|
|
23
|
-
"impl",
|
|
24
|
-
"`Unknown node type: ${node.type}`"
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
return impl;
|
|
28
|
-
};
|
|
29
|
-
var isValidComputeNode = (type) => {
|
|
30
|
-
return nodeFactory[type] !== void 0;
|
|
31
|
-
};
|
|
32
|
-
var createComputeNode = (shape) => {
|
|
33
|
-
const type = shape.type ?? raise(new Error("Type not specified"));
|
|
34
|
-
const factory = nodeFactory[type] ?? raise(new Error(`Unknown shape type: ${type}`));
|
|
35
|
-
return factory(shape);
|
|
36
|
-
};
|
|
37
|
-
var nodeFactory = {
|
|
38
|
-
// System.
|
|
39
|
-
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
40
|
-
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
41
|
-
// Extensions.
|
|
42
|
-
["text-to-image"]: () => createNode("text-to-image"),
|
|
43
|
-
["and"]: () => createNode("and"),
|
|
44
|
-
["append"]: () => createNode("append"),
|
|
45
|
-
["audio"]: () => createNode("audio"),
|
|
46
|
-
["beacon"]: () => createNode("beacon"),
|
|
47
|
-
["chat"]: () => createNode("chat"),
|
|
48
|
-
["constant"]: (shape) => createNode("constant", {
|
|
49
|
-
value: shape.value
|
|
50
|
-
}),
|
|
51
|
-
["make-queue"]: () => createNode("make-queue"),
|
|
52
|
-
["database"]: () => createNode("database"),
|
|
53
|
-
["gpt"]: () => createNode("gpt"),
|
|
54
|
-
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
55
|
-
["if"]: () => createNode("if"),
|
|
56
|
-
["if-else"]: () => createNode("if-else"),
|
|
57
|
-
["function"]: () => createNode("function"),
|
|
58
|
-
["json"]: () => createNode("json"),
|
|
59
|
-
["json-transform"]: () => createNode("json-transform"),
|
|
60
|
-
["not"]: () => createNode("not"),
|
|
61
|
-
["or"]: () => createNode("or"),
|
|
62
|
-
["queue"]: () => createNode("queue"),
|
|
63
|
-
["rng"]: () => createNode("rng"),
|
|
64
|
-
["reducer"]: () => createNode("reducer"),
|
|
65
|
-
["scope"]: () => createNode("scope"),
|
|
66
|
-
["surface"]: () => createNode("surface"),
|
|
67
|
-
["switch"]: () => createNode("switch"),
|
|
68
|
-
["template"]: (shape) => {
|
|
69
|
-
const node = createNode("template", {
|
|
70
|
-
valueType: shape.valueType,
|
|
71
|
-
value: shape.text
|
|
72
|
-
});
|
|
73
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
74
|
-
return node;
|
|
75
|
-
},
|
|
76
|
-
["text"]: () => createNode("text"),
|
|
77
|
-
["thread"]: () => createNode("thread"),
|
|
78
|
-
["trigger"]: () => createNode(NODE_INPUT)
|
|
79
|
-
};
|
|
80
|
-
var createNode = (type, props) => ({
|
|
81
|
-
id: ObjectId.random(),
|
|
82
|
-
type,
|
|
83
|
-
...props
|
|
84
|
-
});
|
|
85
|
-
|
|
86
10
|
// src/hooks/compute-context.ts
|
|
87
11
|
import { createContext, useContext } from "react";
|
|
88
|
-
import { raise
|
|
12
|
+
import { raise } from "@dxos/debug";
|
|
89
13
|
var ComputeContext = createContext(null);
|
|
90
14
|
var useComputeContext = () => {
|
|
91
|
-
return useContext(ComputeContext) ??
|
|
15
|
+
return useContext(ComputeContext) ?? raise(new Error("Missing ComputeContext"));
|
|
92
16
|
};
|
|
93
17
|
|
|
94
18
|
// src/hooks/useComputeGraphController.ts
|
|
@@ -144,13 +68,13 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
|
144
68
|
// src/hooks/useComputeNodeState.ts
|
|
145
69
|
import { Schema } from "effect";
|
|
146
70
|
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
147
|
-
import { invariant
|
|
148
|
-
var
|
|
71
|
+
import { invariant } from "@dxos/invariant";
|
|
72
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
149
73
|
var useComputeNodeState = (shape) => {
|
|
150
74
|
const { controller } = useComputeContext();
|
|
151
|
-
|
|
152
|
-
F:
|
|
153
|
-
L:
|
|
75
|
+
invariant(controller, void 0, {
|
|
76
|
+
F: __dxlog_file,
|
|
77
|
+
L: 34,
|
|
154
78
|
S: void 0,
|
|
155
79
|
A: [
|
|
156
80
|
"controller",
|
|
@@ -161,9 +85,9 @@ var useComputeNodeState = (shape) => {
|
|
|
161
85
|
useEffect2(() => {
|
|
162
86
|
let disposed = false;
|
|
163
87
|
queueMicrotask(async () => {
|
|
164
|
-
|
|
165
|
-
F:
|
|
166
|
-
L:
|
|
88
|
+
invariant(shape.node, "Node not specified", {
|
|
89
|
+
F: __dxlog_file,
|
|
90
|
+
L: 40,
|
|
167
91
|
S: void 0,
|
|
168
92
|
A: [
|
|
169
93
|
"shape.node",
|
|
@@ -218,16 +142,16 @@ var useComputeNodeState = (shape) => {
|
|
|
218
142
|
// src/hooks/useGraphMonitor.ts
|
|
219
143
|
import { useMemo } from "react";
|
|
220
144
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
221
|
-
import { ObjectId
|
|
222
|
-
import { invariant as
|
|
145
|
+
import { ObjectId, Ref } from "@dxos/echo-schema";
|
|
146
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
223
147
|
import { getSpace } from "@dxos/react-client/echo";
|
|
224
148
|
import { isNonNullable } from "@dxos/util";
|
|
225
|
-
var
|
|
149
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
226
150
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
227
151
|
const sourceNode = graph.findNode(source);
|
|
228
152
|
const targetNode = graph.findNode(target);
|
|
229
|
-
|
|
230
|
-
F:
|
|
153
|
+
invariant2(sourceNode?.node, void 0, {
|
|
154
|
+
F: __dxlog_file2,
|
|
231
155
|
L: 26,
|
|
232
156
|
S: void 0,
|
|
233
157
|
A: [
|
|
@@ -235,8 +159,8 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
235
159
|
""
|
|
236
160
|
]
|
|
237
161
|
});
|
|
238
|
-
|
|
239
|
-
F:
|
|
162
|
+
invariant2(targetNode?.node, void 0, {
|
|
163
|
+
F: __dxlog_file2,
|
|
240
164
|
L: 27,
|
|
241
165
|
S: void 0,
|
|
242
166
|
A: [
|
|
@@ -245,7 +169,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
245
169
|
]
|
|
246
170
|
});
|
|
247
171
|
return {
|
|
248
|
-
id:
|
|
172
|
+
id: ObjectId.random(),
|
|
249
173
|
source: sourceNode.node,
|
|
250
174
|
target: targetNode.node,
|
|
251
175
|
output,
|
|
@@ -259,8 +183,8 @@ var useGraphMonitor = (model) => {
|
|
|
259
183
|
if (!model) {
|
|
260
184
|
return;
|
|
261
185
|
}
|
|
262
|
-
|
|
263
|
-
F:
|
|
186
|
+
invariant2(node.type, void 0, {
|
|
187
|
+
F: __dxlog_file2,
|
|
264
188
|
L: 52,
|
|
265
189
|
S: void 0,
|
|
266
190
|
A: [
|
|
@@ -317,8 +241,8 @@ var createComputeGraph = (graph) => {
|
|
|
317
241
|
};
|
|
318
242
|
var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
319
243
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
320
|
-
|
|
321
|
-
F:
|
|
244
|
+
invariant2(functionTrigger, void 0, {
|
|
245
|
+
F: __dxlog_file2,
|
|
322
246
|
L: 115,
|
|
323
247
|
S: void 0,
|
|
324
248
|
A: [
|
|
@@ -342,7 +266,96 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
|
342
266
|
}
|
|
343
267
|
};
|
|
344
268
|
|
|
269
|
+
// src/graph/node-defs.ts
|
|
270
|
+
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
271
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
272
|
+
import { ObjectId as ObjectId2, toJsonSchema } from "@dxos/echo-schema";
|
|
273
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
274
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
275
|
+
var resolveComputeNode = async (node) => {
|
|
276
|
+
const impl = registry[node.type];
|
|
277
|
+
invariant3(impl, `Unknown node type: ${node.type}`, {
|
|
278
|
+
F: __dxlog_file3,
|
|
279
|
+
L: 22,
|
|
280
|
+
S: void 0,
|
|
281
|
+
A: [
|
|
282
|
+
"impl",
|
|
283
|
+
"`Unknown node type: ${node.type}`"
|
|
284
|
+
]
|
|
285
|
+
});
|
|
286
|
+
return impl;
|
|
287
|
+
};
|
|
288
|
+
var isValidComputeNode = (type) => {
|
|
289
|
+
return nodeFactory[type] !== void 0;
|
|
290
|
+
};
|
|
291
|
+
var createComputeNode = (shape) => {
|
|
292
|
+
const type = shape.type ?? raise2(new Error("Type not specified"));
|
|
293
|
+
const factory = nodeFactory[type] ?? raise2(new Error(`Unknown shape type: ${type}`));
|
|
294
|
+
return factory(shape);
|
|
295
|
+
};
|
|
296
|
+
var nodeFactory = {
|
|
297
|
+
// System.
|
|
298
|
+
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
299
|
+
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
300
|
+
// Extensions.
|
|
301
|
+
["text-to-image"]: () => createNode("text-to-image"),
|
|
302
|
+
["and"]: () => createNode("and"),
|
|
303
|
+
["append"]: () => createNode("append"),
|
|
304
|
+
["audio"]: () => createNode("audio"),
|
|
305
|
+
["beacon"]: () => createNode("beacon"),
|
|
306
|
+
["chat"]: () => createNode("chat"),
|
|
307
|
+
["constant"]: (shape) => createNode("constant", {
|
|
308
|
+
value: shape.value
|
|
309
|
+
}),
|
|
310
|
+
["make-queue"]: () => createNode("make-queue"),
|
|
311
|
+
["database"]: () => createNode("database"),
|
|
312
|
+
["gpt"]: () => createNode("gpt"),
|
|
313
|
+
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
314
|
+
["if"]: () => createNode("if"),
|
|
315
|
+
["if-else"]: () => createNode("if-else"),
|
|
316
|
+
["function"]: () => createNode("function"),
|
|
317
|
+
["json"]: () => createNode("json"),
|
|
318
|
+
["json-transform"]: () => createNode("json-transform"),
|
|
319
|
+
["not"]: () => createNode("not"),
|
|
320
|
+
["or"]: () => createNode("or"),
|
|
321
|
+
["queue"]: () => createNode("queue"),
|
|
322
|
+
["rng"]: () => createNode("rng"),
|
|
323
|
+
["reducer"]: () => createNode("reducer"),
|
|
324
|
+
["scope"]: () => createNode("scope"),
|
|
325
|
+
["surface"]: () => createNode("surface"),
|
|
326
|
+
["switch"]: () => createNode("switch"),
|
|
327
|
+
["template"]: (shape) => {
|
|
328
|
+
const node = createNode("template", {
|
|
329
|
+
valueType: shape.valueType,
|
|
330
|
+
value: shape.text
|
|
331
|
+
});
|
|
332
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
333
|
+
return node;
|
|
334
|
+
},
|
|
335
|
+
["text"]: () => createNode("text"),
|
|
336
|
+
["thread"]: () => createNode("thread"),
|
|
337
|
+
["trigger"]: () => createNode(NODE_INPUT)
|
|
338
|
+
};
|
|
339
|
+
var createNode = (type, props) => ({
|
|
340
|
+
id: ObjectId2.random(),
|
|
341
|
+
type,
|
|
342
|
+
...props
|
|
343
|
+
});
|
|
344
|
+
|
|
345
345
|
// src/graph/controller.ts
|
|
346
|
+
function _define_property(obj, key, value) {
|
|
347
|
+
if (key in obj) {
|
|
348
|
+
Object.defineProperty(obj, key, {
|
|
349
|
+
value,
|
|
350
|
+
enumerable: true,
|
|
351
|
+
configurable: true,
|
|
352
|
+
writable: true
|
|
353
|
+
});
|
|
354
|
+
} else {
|
|
355
|
+
obj[key] = value;
|
|
356
|
+
}
|
|
357
|
+
return obj;
|
|
358
|
+
}
|
|
346
359
|
function _ts_decorate(decorators, target, key, desc) {
|
|
347
360
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
348
361
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -365,11 +378,6 @@ var createComputeGraphController = (graph, serviceContainer) => {
|
|
|
365
378
|
};
|
|
366
379
|
};
|
|
367
380
|
var ComputeGraphController = class extends Resource {
|
|
368
|
-
constructor(_serviceContainer, _graph) {
|
|
369
|
-
super(), this._serviceContainer = _serviceContainer, this._graph = _graph, this._executor = new GraphExecutor({
|
|
370
|
-
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
371
|
-
}), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
|
|
372
|
-
}
|
|
373
381
|
toJSON() {
|
|
374
382
|
return {
|
|
375
383
|
graph: this._graph,
|
|
@@ -430,7 +438,8 @@ var ComputeGraphController = class extends Resource {
|
|
|
430
438
|
return this._runtimeStateOutputs[nodeId] ?? {};
|
|
431
439
|
}
|
|
432
440
|
setOutput(nodeId, property, value) {
|
|
433
|
-
|
|
441
|
+
var _this__forcedOutputs, _nodeId;
|
|
442
|
+
(_this__forcedOutputs = this._forcedOutputs)[_nodeId = nodeId] ?? (_this__forcedOutputs[_nodeId] = {});
|
|
434
443
|
this._forcedOutputs[nodeId][property] = value;
|
|
435
444
|
queueMicrotask(async () => {
|
|
436
445
|
try {
|
|
@@ -438,7 +447,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
438
447
|
} catch (err) {
|
|
439
448
|
log.catch(err, void 0, {
|
|
440
449
|
F: __dxlog_file4,
|
|
441
|
-
L:
|
|
450
|
+
L: 199,
|
|
442
451
|
S: this,
|
|
443
452
|
C: (f, a) => f(...a)
|
|
444
453
|
});
|
|
@@ -532,7 +541,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
532
541
|
event
|
|
533
542
|
}, {
|
|
534
543
|
F: __dxlog_file4,
|
|
535
|
-
L:
|
|
544
|
+
L: 335,
|
|
536
545
|
S: this,
|
|
537
546
|
C: (f, a) => f(...a)
|
|
538
547
|
});
|
|
@@ -555,11 +564,13 @@ var ComputeGraphController = class extends Resource {
|
|
|
555
564
|
this.events.emit(event);
|
|
556
565
|
}
|
|
557
566
|
_onInputComputed(nodeId, property, value) {
|
|
558
|
-
|
|
567
|
+
var _this__runtimeStateInputs, _nodeId;
|
|
568
|
+
(_this__runtimeStateInputs = this._runtimeStateInputs)[_nodeId = nodeId] ?? (_this__runtimeStateInputs[_nodeId] = {});
|
|
559
569
|
this._runtimeStateInputs[nodeId][property] = value;
|
|
560
570
|
}
|
|
561
571
|
_onOutputComputed(nodeId, property, value) {
|
|
562
|
-
|
|
572
|
+
var _this__runtimeStateOutputs, _nodeId;
|
|
573
|
+
(_this__runtimeStateOutputs = this._runtimeStateOutputs)[_nodeId = nodeId] ?? (_this__runtimeStateOutputs[_nodeId] = {});
|
|
563
574
|
this._runtimeStateOutputs[nodeId][property] = value;
|
|
564
575
|
this.output.emit({
|
|
565
576
|
nodeId,
|
|
@@ -567,6 +578,19 @@ var ComputeGraphController = class extends Resource {
|
|
|
567
578
|
value
|
|
568
579
|
});
|
|
569
580
|
}
|
|
581
|
+
constructor(_serviceContainer, _graph) {
|
|
582
|
+
super(), _define_property(this, "_serviceContainer", void 0), _define_property(this, "_graph", void 0), _define_property(this, "_executor", void 0), _define_property(this, "_diagnostics", void 0), /**
|
|
583
|
+
* Canvas force-sets outputs of those nodes.
|
|
584
|
+
*/
|
|
585
|
+
_define_property(this, "_forcedOutputs", void 0), /**
|
|
586
|
+
* Runtime state of the execution graph.
|
|
587
|
+
*/
|
|
588
|
+
_define_property(this, "_runtimeStateInputs", void 0), _define_property(this, "_runtimeStateOutputs", void 0), // TODO(burdon): Remove? Make state reactive?
|
|
589
|
+
_define_property(this, "update", void 0), /** Computed result. */
|
|
590
|
+
_define_property(this, "output", void 0), _define_property(this, "events", void 0), this._serviceContainer = _serviceContainer, this._graph = _graph, this._executor = new GraphExecutor({
|
|
591
|
+
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
592
|
+
}), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
|
|
593
|
+
}
|
|
570
594
|
};
|
|
571
595
|
_ts_decorate([
|
|
572
596
|
synchronized
|
|
@@ -685,7 +709,7 @@ import { SchemaAST as SchemaAST2 } from "effect";
|
|
|
685
709
|
import React2, { useRef, useState as useState3 } from "react";
|
|
686
710
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
687
711
|
import { useCanvasContext } from "@dxos/react-ui-canvas";
|
|
688
|
-
import {
|
|
712
|
+
import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-canvas-editor";
|
|
689
713
|
|
|
690
714
|
// src/shapes/defs.ts
|
|
691
715
|
import { Schema as Schema2, SchemaAST } from "effect";
|
|
@@ -1392,7 +1416,7 @@ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking
|
|
|
1392
1416
|
import { Schema as Schema11 } from "effect";
|
|
1393
1417
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1394
1418
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1395
|
-
import {
|
|
1419
|
+
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo-schema";
|
|
1396
1420
|
import { FunctionType, ScriptType } from "@dxos/functions";
|
|
1397
1421
|
import { useClient } from "@dxos/react-client";
|
|
1398
1422
|
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
@@ -1859,7 +1883,7 @@ import { Schema as Schema17 } from "effect";
|
|
|
1859
1883
|
import React18 from "react";
|
|
1860
1884
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1861
1885
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1862
|
-
import {
|
|
1886
|
+
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1863
1887
|
var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1864
1888
|
type: Schema17.Literal("scope")
|
|
1865
1889
|
}));
|
|
@@ -2061,7 +2085,7 @@ var tableShape = {
|
|
|
2061
2085
|
import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
|
|
2062
2086
|
import { Schema as Schema21 } from "effect";
|
|
2063
2087
|
import React22, { useRef as useRef5 } from "react";
|
|
2064
|
-
import { ComputeValueType as ComputeValueType3,
|
|
2088
|
+
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2065
2089
|
import { toJsonSchema as toJsonSchema2 } from "@dxos/echo-schema";
|
|
2066
2090
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2067
2091
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -2086,7 +2110,7 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
2086
2110
|
const handleTypeChange = (newType) => {
|
|
2087
2111
|
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2088
2112
|
F: __dxlog_file6,
|
|
2089
|
-
L:
|
|
2113
|
+
L: 59,
|
|
2090
2114
|
S: void 0,
|
|
2091
2115
|
A: [
|
|
2092
2116
|
"Schema.is(ComputeValueType)(newType)",
|
|
@@ -2310,17 +2334,18 @@ import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking
|
|
|
2310
2334
|
import { Schema as Schema25 } from "effect";
|
|
2311
2335
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2312
2336
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2337
|
+
import { Filter as Filter2, Obj, Query } from "@dxos/echo";
|
|
2313
2338
|
import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo-schema";
|
|
2314
|
-
import { EmailTriggerOutput, FunctionTrigger, QueueTriggerOutput,
|
|
2339
|
+
import { EmailTriggerOutput, FunctionTrigger, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, TriggerKinds, WebhookTriggerOutput } from "@dxos/functions";
|
|
2315
2340
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2316
|
-
import {
|
|
2341
|
+
import { useSpace } from "@dxos/react-client/echo";
|
|
2317
2342
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2318
2343
|
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2319
2344
|
type: Schema25.Literal("trigger"),
|
|
2320
2345
|
functionTrigger: Schema25.optional(Ref3(FunctionTrigger))
|
|
2321
2346
|
}));
|
|
2322
2347
|
var createTrigger = (props) => {
|
|
2323
|
-
const functionTrigger =
|
|
2348
|
+
const functionTrigger = Obj.make(FunctionTrigger, {
|
|
2324
2349
|
enabled: true,
|
|
2325
2350
|
spec: createTriggerSpec(props)
|
|
2326
2351
|
});
|
|
@@ -2342,7 +2367,7 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2342
2367
|
useEffect8(() => {
|
|
2343
2368
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2344
2369
|
functionTrigger.spec = createTriggerSpec({
|
|
2345
|
-
triggerKind:
|
|
2370
|
+
triggerKind: "email",
|
|
2346
2371
|
spaceId: space?.id
|
|
2347
2372
|
});
|
|
2348
2373
|
}
|
|
@@ -2351,7 +2376,7 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2351
2376
|
functionTrigger?.spec
|
|
2352
2377
|
]);
|
|
2353
2378
|
useEffect8(() => {
|
|
2354
|
-
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ??
|
|
2379
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2355
2380
|
}, [
|
|
2356
2381
|
functionTrigger?.spec?.kind
|
|
2357
2382
|
]);
|
|
@@ -2388,7 +2413,7 @@ var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
|
2388
2413
|
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2389
2414
|
variant: "ghost",
|
|
2390
2415
|
classNames: "w-full !px-0"
|
|
2391
|
-
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null,
|
|
2416
|
+
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, TriggerKinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
|
|
2392
2417
|
key: kind,
|
|
2393
2418
|
value: kind
|
|
2394
2419
|
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
@@ -2397,35 +2422,35 @@ var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
|
2397
2422
|
}
|
|
2398
2423
|
};
|
|
2399
2424
|
var createTriggerSpec = (props) => {
|
|
2400
|
-
const kind = props.triggerKind ??
|
|
2425
|
+
const kind = props.triggerKind ?? "email";
|
|
2401
2426
|
switch (kind) {
|
|
2402
|
-
case
|
|
2427
|
+
case "timer":
|
|
2403
2428
|
return {
|
|
2404
|
-
kind:
|
|
2429
|
+
kind: "timer",
|
|
2405
2430
|
cron: "*/10 * * * * *"
|
|
2406
2431
|
};
|
|
2407
|
-
case
|
|
2432
|
+
case "webhook":
|
|
2408
2433
|
return {
|
|
2409
|
-
kind:
|
|
2434
|
+
kind: "webhook",
|
|
2410
2435
|
method: "POST"
|
|
2411
2436
|
};
|
|
2412
|
-
case
|
|
2437
|
+
case "subscription":
|
|
2413
2438
|
return {
|
|
2414
|
-
kind:
|
|
2415
|
-
|
|
2439
|
+
kind: "subscription",
|
|
2440
|
+
query: Query.select(Filter2.nothing()).ast
|
|
2416
2441
|
};
|
|
2417
|
-
case
|
|
2442
|
+
case "email":
|
|
2418
2443
|
return {
|
|
2419
|
-
kind:
|
|
2444
|
+
kind: "email"
|
|
2420
2445
|
};
|
|
2421
|
-
case
|
|
2446
|
+
case "queue": {
|
|
2422
2447
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2423
2448
|
"data",
|
|
2424
2449
|
props.spaceId ?? SpaceId.random(),
|
|
2425
2450
|
ObjectId4.random()
|
|
2426
2451
|
]).toString();
|
|
2427
2452
|
return {
|
|
2428
|
-
kind:
|
|
2453
|
+
kind: "queue",
|
|
2429
2454
|
queue: dxn
|
|
2430
2455
|
};
|
|
2431
2456
|
}
|
|
@@ -2433,11 +2458,11 @@ var createTriggerSpec = (props) => {
|
|
|
2433
2458
|
};
|
|
2434
2459
|
var getOutputSchema = (kind) => {
|
|
2435
2460
|
const kindToSchema = {
|
|
2436
|
-
[
|
|
2437
|
-
[
|
|
2438
|
-
[
|
|
2439
|
-
[
|
|
2440
|
-
[
|
|
2461
|
+
["email"]: EmailTriggerOutput,
|
|
2462
|
+
["subscription"]: SubscriptionTriggerOutput,
|
|
2463
|
+
["timer"]: TimerTriggerOutput,
|
|
2464
|
+
["webhook"]: WebhookTriggerOutput,
|
|
2465
|
+
["queue"]: QueueTriggerOutput
|
|
2441
2466
|
};
|
|
2442
2467
|
return kindToSchema[kind];
|
|
2443
2468
|
};
|
|
@@ -2447,7 +2472,7 @@ var triggerShape = {
|
|
|
2447
2472
|
icon: "ph--lightning--regular",
|
|
2448
2473
|
component: TriggerComponent,
|
|
2449
2474
|
createShape: createTrigger,
|
|
2450
|
-
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ??
|
|
2475
|
+
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2451
2476
|
};
|
|
2452
2477
|
|
|
2453
2478
|
// src/shapes/GptRealtime.tsx
|
|
@@ -2650,10 +2675,20 @@ var computeShapes = [
|
|
|
2650
2675
|
import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
|
|
2651
2676
|
import { toEffectSchema } from "@dxos/echo-schema";
|
|
2652
2677
|
import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2678
|
+
function _define_property2(obj, key, value) {
|
|
2679
|
+
if (key in obj) {
|
|
2680
|
+
Object.defineProperty(obj, key, {
|
|
2681
|
+
value,
|
|
2682
|
+
enumerable: true,
|
|
2683
|
+
configurable: true,
|
|
2684
|
+
writable: true
|
|
2685
|
+
});
|
|
2686
|
+
} else {
|
|
2687
|
+
obj[key] = value;
|
|
2656
2688
|
}
|
|
2689
|
+
return obj;
|
|
2690
|
+
}
|
|
2691
|
+
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2657
2692
|
// TODO(burdon): Doesn't update.
|
|
2658
2693
|
getAnchors(shape) {
|
|
2659
2694
|
const shapeDef = this._registry.getShapeDef(shape.type);
|
|
@@ -2668,6 +2703,9 @@ var ComputeShapeLayout = class extends ShapeLayout {
|
|
|
2668
2703
|
}
|
|
2669
2704
|
return anchors;
|
|
2670
2705
|
}
|
|
2706
|
+
constructor(_controller, registry2) {
|
|
2707
|
+
super(registry2), _define_property2(this, "_controller", void 0), this._controller = _controller;
|
|
2708
|
+
}
|
|
2671
2709
|
};
|
|
2672
2710
|
export {
|
|
2673
2711
|
AndShape,
|