@oomol-lab/open-flow 0.1.0-alpha.9 → 0.1.0-beta.2

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.
Files changed (58) hide show
  1. package/README.md +5 -1
  2. package/dist/browser/createResourceDialog-BkZns-oZ.js +504 -0
  3. package/dist/browser/diagnostics-giPSzyMo.js +9346 -0
  4. package/dist/browser/{dist-DhsGR_K3.js → dist-3Mj8q8Pr.js} +27 -27
  5. package/dist/browser/{dist-n9WmBm5w.js → dist-BKuSVKCC.js} +1 -1
  6. package/dist/browser/{dist-DQVavPcf.js → dist-BMqL-qR5.js} +469 -903
  7. package/dist/browser/{dist-D5mdziGP.js → dist-BN4ZCyOB.js} +9 -9
  8. package/dist/browser/{dist-CVtP-E2c.js → dist-BpopSHwP.js} +1 -1
  9. package/dist/browser/{dist-B0Q2Mn0n.js → dist-CJpzJrLM.js} +191 -191
  10. package/dist/browser/{dist-DXgEYMFx.js → dist-CPuF50D9.js} +196 -196
  11. package/dist/browser/{dist-CUkceEvN.js → dist-CUSrALSX.js} +113 -113
  12. package/dist/browser/dist-CeSZ2xSM.js +444 -0
  13. package/dist/browser/{dist-Bc9TvHYl.js → dist-DUzA0Ukh.js} +20 -20
  14. package/dist/browser/{dist-DWzdGVm9.js → dist-DWADUsVB.js} +74 -74
  15. package/dist/browser/{esm-YIGXG-Js.js → esm-B_PbUobB.js} +13 -13
  16. package/dist/browser/flow-authoring-node.d.ts +4 -2
  17. package/dist/browser/flow-authoring.d.ts +2 -1
  18. package/dist/browser/flow-authoring.js +400 -100
  19. package/dist/browser/flow-change.d.ts +9 -4
  20. package/dist/browser/flow-change.js +49 -46
  21. package/dist/browser/{flowRunInputEditorStore-DXOyyY7o.js → flowRunInputEditorStore-BeyUSWpO.js} +1644 -908
  22. package/dist/browser/{flowWorkspace-D7-rBA1-.js → flowWorkspace-DAMLVMcF.js} +18416 -16444
  23. package/dist/browser/getPseudoElementBounds-ESJExRFX.js +7642 -0
  24. package/dist/browser/languages-DgJehE1g.js +62 -0
  25. package/dist/browser/lib-C5Ipyfps.js +7856 -0
  26. package/dist/browser/licenses.md +119 -1
  27. package/dist/browser/main-DmjVyuWr.js +76 -0
  28. package/dist/browser/{markdownContent-ColGUxHy.js → markdownContent-DdlIRN3_.js} +4811 -4795
  29. package/dist/browser/theme.css +63 -0
  30. package/dist/browser/theme.css.d.ts +1 -0
  31. package/dist/browser/typeScriptSession-mPCiA9sV.js +2579 -0
  32. package/dist/browser/workbench-contract.d.ts +2 -1
  33. package/dist/browser/workbench.css +1 -1
  34. package/dist/browser/workbench.d.ts +46 -1
  35. package/dist/browser/workbench.js +1132 -1474
  36. package/dist/browser/workbenchSelect-B2s1HV-Y.js +1374 -0
  37. package/dist/common/connector-action.d.ts +6 -0
  38. package/dist/common/connector-action.js +37 -29
  39. package/dist/common/control-api-conformance.js +80 -29
  40. package/dist/common/control-api-errors.d.ts +24 -0
  41. package/dist/common/control-api.d.ts +54 -7
  42. package/dist/common/control-api.js +226 -95
  43. package/dist/common/flow-encoding.d.ts +2 -2
  44. package/dist/common/flow-encoding.js +4 -1
  45. package/dist/common/flow-semantics.d.ts +3 -0
  46. package/dist/common/flow-semantics.js +939 -851
  47. package/dist/common/integration-trigger.d.ts +1 -0
  48. package/dist/common/licenses.md +1 -25
  49. package/dist/common/localization.d.ts +21 -0
  50. package/dist/common/localization.js +62 -0
  51. package/dist/common/provider-triggers.js +4 -1
  52. package/dist/common/scheduler.d.ts +5 -5
  53. package/dist/common/scheduler.js +250 -236
  54. package/package.json +10 -1
  55. package/dist/browser/addNodeOptions-DRndy4EK.js +0 -6910
  56. package/dist/browser/createLucideIcon-CqjqCezK.js +0 -5537
  57. package/dist/browser/createResourceDialog-A64dDFCG.js +0 -467
  58. package/dist/browser/field-CKGQHCIi.js +0 -312
@@ -1,16 +1,19 @@
1
+ import * as e from "effect/Effect";
2
+ import * as t from "effect/Exit";
3
+ import * as n from "effect/FiberSet";
1
4
  //#region src/flow/common/change.ts
2
- function e(e) {
3
- return Object.fromEntries(e.map((e) => [e.handle, e]));
5
+ function r(e) {
6
+ return Object.fromEntries(e.flatMap((e) => "handle" in e ? [[e.handle, e]] : []));
4
7
  }
5
8
  //#endregion
6
9
  //#region src/execution/common/scheduler.ts
7
- function t(e, t) {
10
+ function i(e, t) {
8
11
  return t?.(e) ?? {
9
12
  code: "node.failed",
10
13
  message: e instanceof Error ? e.message : String(e)
11
14
  };
12
15
  }
13
- var n = class {
16
+ var a = class {
14
17
  #e = [];
15
18
  #t = 0;
16
19
  get length() {
@@ -23,9 +26,9 @@ var n = class {
23
26
  let e = this.#e[this.#t];
24
27
  return this.#t += 1, this.#t >= 64 && this.#t * 2 >= this.#e.length && (this.#e.splice(0, this.#t), this.#t = 0), e;
25
28
  }
26
- }, r = class {
29
+ }, o = class {
27
30
  #e;
28
- #t = new n();
31
+ #t = new a();
29
32
  #n;
30
33
  #r;
31
34
  constructor(e, t, n) {
@@ -47,13 +50,13 @@ var n = class {
47
50
  take() {
48
51
  return this.#t.length > 0 ? this.#t.shift() : this.#r;
49
52
  }
50
- }, i = class {
53
+ }, s = class {
51
54
  #e;
52
55
  #t;
53
56
  #n;
54
57
  #r = !1;
55
58
  constructor(e, t, n) {
56
- this.#t = e, this.#n = new Map(Object.entries(n).map(([e, n]) => [e, new r(t, e, n)])), this.#e = [...this.#n.values()].some((e) => e.dynamic);
59
+ this.#t = e, this.#n = new Map(Object.entries(n).map(([e, n]) => [e, new o(t, e, n)])), this.#e = [...this.#n.values()].some((e) => e.dynamic);
57
60
  }
58
61
  get ready() {
59
62
  return (!this.#r || this.#e) && [...this.#n.values()].every((e) => e.ready);
@@ -72,15 +75,15 @@ var n = class {
72
75
  return this.#e || (this.#r = !0), Object.fromEntries([...this.#n].map(([e, t]) => [e, t.take()]));
73
76
  }
74
77
  };
75
- function a(t, n) {
76
- switch (n.kind) {
77
- case "condition": return { [n.input.handle]: n.input };
78
+ function c(e, t) {
79
+ switch (t.kind) {
80
+ case "condition": return { [t.input.handle]: t.input };
78
81
  case "value": return {};
79
- case "subflow": return e(t.subflows[n.subflowId].inputs);
80
- case "task": return e(n.task == null ? t.tasks[n.taskId].inputs : n.task.inputs);
82
+ case "subflow": return r(e.subflows[t.subflowId].inputs);
83
+ case "task": return r(t.task == null ? e.tasks[t.taskId].inputs : t.task.inputs);
81
84
  }
82
85
  }
83
- function o(e, t) {
86
+ function l(e, t) {
84
87
  if (t.name != null) return t.name;
85
88
  switch (t.kind) {
86
89
  case "condition": return;
@@ -89,17 +92,17 @@ function o(e, t) {
89
92
  case "task": return t.task == null ? e.tasks[t.taskId].name : t.task.name;
90
93
  }
91
94
  }
92
- function s(e, t) {
95
+ function u(e, t) {
93
96
  return t.kind == "task" ? t.task == null ? e.tasks[t.taskId].executor.kind : "javascript" : t.kind;
94
97
  }
95
- function c(e, t, n, r) {
98
+ function d(e, t, n, r) {
96
99
  let i = e.get(t) ?? /* @__PURE__ */ new Map(), a = i.get(n) ?? [];
97
100
  a.push(r), i.set(n, a), e.set(t, i);
98
101
  }
99
- function l(e, t, n) {
102
+ function f(e, t, n) {
100
103
  return e.get(t)?.get(n) ?? [];
101
104
  }
102
- function u(e) {
105
+ function p(e) {
103
106
  let t = new Map(Object.entries(e.nodes).map(([t, n]) => [t, new Set(Object.values(n.inputs).flatMap((t) => t.kind == "sources" ? t.sources.flatMap((t) => t.kind == "node" && e.nodes[t.nodeId] != null ? [t.nodeId] : []) : []))])), n = [];
104
107
  for (; t.size > 0;) {
105
108
  let e = [...t].filter(([, e]) => e.size == 0).map(([e]) => e).toSorted();
@@ -109,18 +112,18 @@ function u(e) {
109
112
  }
110
113
  return n;
111
114
  }
112
- function d(e, t) {
115
+ function m(e, t) {
113
116
  if (e === t) return !0;
114
117
  if (e == null || t == null || typeof e != "object" || typeof t != "object") return !1;
115
- if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) => d(e, t[n]));
118
+ if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) => m(e, t[n]));
116
119
  let n = Object.entries(e), r = Object.entries(t), i = t;
117
- return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) && d(t, i[e]));
120
+ return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) && m(t, i[e]));
118
121
  }
119
- function f(e, t, n) {
122
+ function h(e, t, n) {
120
123
  let r = Object.hasOwn(n, t.input) ? n[t.input] : null, i = t.value;
121
124
  switch (t.operator) {
122
- case "==": return i !== void 0 && d(r, i);
123
- case "!=": return i !== void 0 && !d(r, i);
125
+ case "==": return i !== void 0 && m(r, i);
126
+ case "!=": return i !== void 0 && !m(r, i);
124
127
  case ">": return typeof r == "number" && typeof i == "number" && r > i;
125
128
  case ">=": return typeof r == "number" && typeof i == "number" && r >= i;
126
129
  case "<": return typeof r == "number" && typeof i == "number" && r < i;
@@ -128,7 +131,7 @@ function f(e, t, n) {
128
131
  case "contains":
129
132
  case "notContains": {
130
133
  let e;
131
- return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => d(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
134
+ return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => m(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
132
135
  }
133
136
  case "startsWith": return typeof r == "string" && typeof i == "string" && r.startsWith(i);
134
137
  case "endsWith": return typeof r == "string" && typeof i == "string" && r.endsWith(i);
@@ -141,7 +144,7 @@ function f(e, t, n) {
141
144
  case "hasValue":
142
145
  case "notHasValue": {
143
146
  if (r == null || Array.isArray(r) || typeof r != "object" || i === void 0) return !1;
144
- let e = Object.values(r).some((e) => d(e, i));
147
+ let e = Object.values(r).some((e) => m(e, i));
145
148
  return t.operator == "hasValue" ? e : !e;
146
149
  }
147
150
  case "isEmpty":
@@ -155,230 +158,241 @@ function f(e, t, n) {
155
158
  case "isFalse": return r === !1;
156
159
  }
157
160
  }
158
- function p(e, t) {
161
+ function g(e, t) {
159
162
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Node "${t}" must return an object.`);
160
163
  return e;
161
164
  }
162
- function m(e) {
163
- return e.reason instanceof Error ? e.reason : /* @__PURE__ */ Error("Run canceled.");
164
- }
165
- function h(e, t) {
166
- return new Promise((n, r) => {
167
- let i = () => {
168
- t.removeEventListener("abort", i), r(m(t));
169
- };
170
- e.then((e) => {
171
- t.removeEventListener("abort", i), n(e);
172
- }, (e) => {
173
- t.removeEventListener("abort", i), r(e);
174
- }), t.aborted ? i() : t.addEventListener("abort", i, { once: !0 });
175
- });
176
- }
177
- async function g(n, r, d, m, _, y, b = {}, x, S) {
178
- _.throwIfAborted(), await n.emit({
179
- flowId: r.flowId,
180
- ...y == null ? {} : {
181
- parentJobId: y.jobId,
182
- parentRunId: y.runId
183
- },
184
- runId: d,
185
- type: "run.started"
186
- });
187
- let C = u(r.graph), w = C.length, T = new Map(Object.entries(r.graph.nodes).map(([e, t]) => [e, new i(e, t, a(n.prepared, t))])), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
188
- for (let [e, t] of Object.entries(r.graph.nodes)) for (let [n, r] of Object.entries(t.inputs)) if (r.kind == "sources") for (let t of r.sources) if (t.kind == "flow") {
189
- let r = E.get(t.input) ?? [];
190
- r.push({
165
+ function _(a, o, m, v, b, x = {}, S, C) {
166
+ return e.scoped(e.gen(function* () {
167
+ yield* a.emit({
168
+ flowId: o.flowId,
169
+ ...b == null ? {} : {
170
+ parentJobId: b.jobId,
171
+ parentRunId: b.runId
172
+ },
173
+ runId: m,
174
+ type: "run.started"
175
+ });
176
+ let w = p(o.graph), T = w.length, E = new Map(Object.entries(o.graph.nodes).map(([e, t]) => [e, new s(e, t, c(a.prepared, t))])), D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
177
+ for (let [e, t] of Object.entries(o.graph.nodes)) for (let [n, r] of Object.entries(t.inputs)) if (r.kind == "sources") for (let t of r.sources) if (t.kind == "binding") {
178
+ let r = O.get(t.bindingId) ?? [];
179
+ r.push({
180
+ handle: n,
181
+ nodeId: e
182
+ }), O.set(t.bindingId, r);
183
+ } else if (t.kind == "flow") {
184
+ let r = D.get(t.input) ?? [];
185
+ r.push({
186
+ handle: n,
187
+ nodeId: e
188
+ }), D.set(t.input, r);
189
+ } else t.kind == "node" && d(k, t.nodeId, t.output, {
191
190
  handle: n,
192
191
  nodeId: e
193
- }), E.set(t.input, r);
194
- } else t.kind == "node" && c(D, t.nodeId, t.output, {
195
- handle: n,
196
- nodeId: e
197
- });
198
- for (let [e, t] of Object.entries(r.outputs)) for (let n of t.sources) n.kind == "node" && c(O, n.nodeId, n.output, e);
199
- let k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Set(), F = new AbortController(), I = AbortSignal.any([_, F.signal]), L, R = !1, z, B = (e, t) => {
200
- F.signal.aborted || (T.get(e.nodeId).push(e.handle, t), z(e.nodeId));
201
- }, V = async (e, t, r, i) => {
202
- await n.emit({
203
- handle: r,
204
- jobId: t,
205
- nodeId: e,
206
- runId: d,
207
- type: "node.output",
208
- value: i
209
192
  });
210
- for (let t of l(D, e, r)) B(t, i);
211
- for (let t of l(O, e, r)) N.set(t, i), await x?.(t, i);
212
- }, H = async (t, r, i, a) => {
213
- let c = s(n.prepared, r), l = o(n.prepared, r);
214
- await n.emit({
215
- inputs: a,
216
- jobId: i,
217
- nodeId: t,
218
- nodeKind: c,
219
- ...l == null ? {} : { nodeTitle: l },
220
- runId: d,
221
- type: "node.started"
222
- });
223
- let u = r.timeoutMs == null ? void 0 : new AbortController(), m = u == null ? void 0 : setTimeout(() => u.abort(/* @__PURE__ */ Error(`Node "${t}" timed out.`)), r.timeoutMs), _ = u == null ? I : AbortSignal.any([I, u.signal]);
224
- try {
225
- let o;
226
- switch (r.kind) {
227
- case "condition": {
228
- let e = r.cases.find((e) => {
229
- if (e.expressions.length == 0) return !1;
230
- let t = e.expressions.map((e) => f(r, e, a));
231
- return e.relation == "all" ? t.every(Boolean) : t.some(Boolean);
232
- })?.output ?? r.defaultOutput;
233
- o = e == null ? {} : { [e]: a[r.input.handle] ?? null }, e != null && await V(t, i, e, o[e]);
234
- break;
235
- }
236
- case "value":
237
- o = Object.fromEntries(r.values.map((e) => [e.handle, e.value ?? null]));
238
- for (let [e, n] of Object.entries(o)) await V(t, i, e, n);
239
- break;
240
- case "subflow": {
241
- let s = n.prepared.subflows[r.subflowId];
242
- o = await h(g(n, {
243
- flowId: r.subflowId,
244
- graph: v(s.graph),
245
- inputs: e(s.inputs),
246
- kind: "subflow",
247
- outputs: e(s.outputs)
248
- }, n.createId(), a, _, {
249
- jobId: i,
250
- runId: d
251
- }, {}, (e, n) => V(t, i, e, n)), _);
252
- break;
193
+ for (let [e, t] of Object.entries(o.outputs)) for (let n of t.sources) n.kind == "node" && d(A, n.nodeId, n.output, e);
194
+ let j = /* @__PURE__ */ new Map(), M = yield* n.make(), N = yield* n.runtime(M)(), P = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Set(), R, z, B, V = (e, t) => {
195
+ R ?? (E.get(e.nodeId).push(e.handle, t), B(e.nodeId));
196
+ }, H = (t, n, r, i) => e.gen(function* () {
197
+ yield* a.emit({
198
+ handle: r,
199
+ jobId: n,
200
+ nodeId: t,
201
+ runId: m,
202
+ type: "node.output",
203
+ value: i
204
+ });
205
+ for (let e of f(k, t, r)) V(e, i);
206
+ for (let e of f(A, t, r)) I.set(e, i), S != null && (yield* S(e, i));
207
+ }), U = (t, n, i, o) => {
208
+ let s = e.gen(function* () {
209
+ let s = u(a.prepared, n), c = l(a.prepared, n), d = Object.fromEntries(Object.entries(o).filter(([e]) => {
210
+ let t = n.inputs[e];
211
+ return t?.kind != "sources" || t.sources.every((e) => e.kind != "binding");
212
+ }));
213
+ yield* a.emit({
214
+ inputs: d,
215
+ jobId: i,
216
+ nodeId: t,
217
+ nodeKind: s,
218
+ ...c == null ? {} : { nodeTitle: c },
219
+ runId: m,
220
+ type: "node.started"
221
+ });
222
+ let f;
223
+ switch (n.kind) {
224
+ case "condition": {
225
+ let e = n.cases.find((e) => {
226
+ if (e.expressions.length == 0) return !1;
227
+ let t = e.expressions.map((e) => h(n, e, o));
228
+ return e.relation == "all" ? t.every(Boolean) : t.some(Boolean);
229
+ })?.output ?? n.defaultOutput;
230
+ f = e == null ? {} : { [e]: o[n.input.handle] ?? null }, e != null && (yield* H(t, i, e, f[e]));
231
+ break;
232
+ }
233
+ case "value":
234
+ f = Object.fromEntries(n.values.map((e) => [e.handle, e.value ?? null]));
235
+ for (let [e, n] of Object.entries(f)) yield* H(t, i, e, n);
236
+ break;
237
+ case "subflow": {
238
+ let e = a.prepared.subflows[n.subflowId];
239
+ f = yield* _(a, {
240
+ flowId: n.subflowId,
241
+ graph: y(e.graph),
242
+ inputs: r(e.inputs),
243
+ kind: "subflow",
244
+ outputs: r(e.outputs)
245
+ }, a.createId(), o, {
246
+ jobId: i,
247
+ runId: m
248
+ }, {}, (e, n) => H(t, i, e, n));
249
+ break;
250
+ }
251
+ case "task": {
252
+ let r = yield* a.invokeTask({
253
+ input: o,
254
+ invocationId: a.createId(),
255
+ jobId: i,
256
+ nodeId: t,
257
+ runId: m,
258
+ ...n.task == null ? { taskId: n.taskId } : {
259
+ capabilities: n.task.capabilities ?? [],
260
+ moduleId: n.task.moduleId
261
+ }
262
+ });
263
+ f = yield* e.try({
264
+ try: () => g(r, t),
265
+ catch: (e) => e instanceof Error ? e : Error(String(e))
266
+ });
267
+ for (let [e, n] of Object.entries(f)) yield* H(t, i, e, n);
268
+ break;
269
+ }
253
270
  }
254
- case "task":
255
- o = p(await h(n.invokeTask({
256
- input: a,
257
- invocationId: n.createId(),
258
- jobId: i,
259
- nodeId: t,
260
- runId: d,
261
- signal: _,
262
- ...r.task == null ? { taskId: r.taskId } : {
263
- capabilities: r.task.capabilities ?? [],
264
- moduleId: r.task.moduleId
265
- }
266
- }), _), t);
267
- for (let [e, n] of Object.entries(o)) await V(t, i, e, n);
271
+ return yield* a.emit({
272
+ jobId: i,
273
+ nodeId: t,
274
+ runId: m,
275
+ type: "node.completed"
276
+ }), f;
277
+ });
278
+ return n.timeoutMs == null ? s : s.pipe(e.timeoutOrElse({
279
+ duration: n.timeoutMs,
280
+ orElse: () => e.fail(/* @__PURE__ */ Error(`Node "${t}" timed out.`))
281
+ }));
282
+ }, W = (t) => {
283
+ let n = o.graph.nodes[t], r = E.get(t).take(), s = a.createId(), c = F.get(t) ?? 0;
284
+ F.set(t, c + 1), j.set(t, (j.get(t) ?? 0) + 1), N(U(t, n, s, r).pipe(e.tap((n) => e.gen(function* () {
285
+ let e = P.get(t) ?? [];
286
+ e.push({
287
+ jobId: s,
288
+ order: c,
289
+ outputs: n
290
+ }), P.set(t, e), L.has(t) || (L.add(t), yield* a.emit({
291
+ ...b == null ? {} : {
292
+ parentJobId: b.jobId,
293
+ parentRunId: b.runId
294
+ },
295
+ progress: L.size / T * 100,
296
+ runId: m,
297
+ type: "run.progress"
298
+ }));
299
+ })), e.tapError((n) => e.gen(function* () {
300
+ R ?? (z ??= n);
301
+ let r = i(n, a.projectFailure);
302
+ yield* a.emit({
303
+ ...r,
304
+ jobId: s,
305
+ nodeId: t,
306
+ runId: m,
307
+ type: "node.failed"
308
+ }).pipe(e.ignore);
309
+ })), e.tapCause((t) => e.sync(() => {
310
+ R ??= t;
311
+ })), e.ensuring(e.sync(() => {
312
+ j.set(t, (j.get(t) ?? 1) - 1), B(t);
313
+ }))));
314
+ };
315
+ B = (e) => {
316
+ if (R != null) return;
317
+ let t = o.graph.nodes[e], n = E.get(e);
318
+ for (; n.ready && (j.get(e) ?? 0) < t.concurrency;) W(e);
319
+ };
320
+ for (let [e, t] of Object.entries(x)) {
321
+ let n = E.get(e);
322
+ if (n != null) for (let [e, r] of Object.entries(t)) n.launch(e, r);
323
+ }
324
+ for (let [t, n] of O) {
325
+ if (!Object.hasOwn(a.bindingValues, t)) return yield* e.fail(/* @__PURE__ */ Error(`Variable binding "${t}" is unresolved.`));
326
+ for (let e of n) V(e, a.bindingValues[t]);
327
+ }
328
+ for (let [e, t] of Object.entries(o.inputs)) {
329
+ let n = Object.hasOwn(v, e) ? v[e] : t.value;
330
+ if (n !== void 0) {
331
+ for (let t of Object.entries(o.outputs)) t[1].sources.some((t) => t.kind == "flow" && t.input == e) && (I.set(t[0], n), S != null && (yield* S(t[0], n)));
332
+ for (let t of D.get(e) ?? []) V(t, n);
268
333
  }
269
- return await n.emit({
270
- jobId: i,
271
- nodeId: t,
272
- runId: d,
273
- type: "node.completed"
274
- }), o;
275
- } finally {
276
- m != null && clearTimeout(m);
277
334
  }
278
- }, U = (e) => {
279
- let i = r.graph.nodes[e], a = T.get(e).take(), o = n.createId(), s = M.get(e) ?? 0;
280
- M.set(e, s + 1), k.set(e, (k.get(e) ?? 0) + 1);
281
- let c = Promise.resolve();
282
- c = H(e, i, o, a).then(async (t) => {
283
- let r = j.get(e) ?? [];
284
- r.push({
285
- jobId: o,
286
- order: s,
287
- outputs: t
288
- }), j.set(e, r), P.has(e) || (P.add(e), await n.emit({
289
- ...y == null ? {} : {
290
- parentJobId: y.jobId,
291
- parentRunId: y.runId
335
+ if (C != null) for (let e of f(k, C.nodeId, "payload")) V(e, C.payload);
336
+ for (let e of w) B(e);
337
+ let G = yield* e.raceFirst(n.awaitEmpty(M), n.join(M)).pipe(e.exit);
338
+ if (z != null) return yield* n.clear(M), yield* a.emit({
339
+ message: z.message,
340
+ runId: m,
341
+ type: "run.failed"
342
+ }).pipe(e.ignore), yield* e.fail(z);
343
+ if (R != null) return yield* n.clear(M), yield* e.failCause(R);
344
+ if (t.isFailure(G)) return yield* e.failCause(G.cause);
345
+ if (o.kind == "subflow") {
346
+ let e = Object.fromEntries(I);
347
+ return yield* a.emit({
348
+ result: {
349
+ kind: "function-outputs",
350
+ outputs: e,
351
+ target: "subflow"
292
352
  },
293
- progress: P.size / w * 100,
294
- runId: d,
295
- type: "run.progress"
296
- }));
297
- }).catch(async (r) => {
298
- R || (R = !0, L = r, F.abort(r));
299
- let i = t(r, n.projectFailure);
300
- await n.emit({
301
- ...i,
302
- jobId: o,
303
- nodeId: e,
304
- runId: d,
305
- type: "node.failed"
306
- }).catch(() => void 0);
307
- }).finally(() => {
308
- A.delete(c), k.set(e, (k.get(e) ?? 1) - 1), z(e);
309
- }), A.add(c);
310
- };
311
- z = (e) => {
312
- if (F.signal.aborted) return;
313
- let t = r.graph.nodes[e], n = T.get(e);
314
- for (; n.ready && (k.get(e) ?? 0) < t.concurrency;) U(e);
315
- };
316
- for (let [e, t] of Object.entries(b)) {
317
- let n = T.get(e);
318
- if (n != null) for (let [e, r] of Object.entries(t)) n.launch(e, r);
319
- }
320
- for (let [e, t] of Object.entries(r.inputs)) {
321
- let n = Object.hasOwn(m, e) ? m[e] : t.value;
322
- if (n !== void 0) {
323
- for (let t of Object.entries(r.outputs)) t[1].sources.some((t) => t.kind == "flow" && t.input == e) && (N.set(t[0], n), await x?.(t[0], n));
324
- for (let t of E.get(e) ?? []) B(t, n);
353
+ runId: m,
354
+ type: "run.completed"
355
+ }), e;
325
356
  }
326
- }
327
- if (S != null) for (let e of l(D, S.nodeId, "payload")) B(e, S.payload);
328
- for (let e of C) z(e);
329
- for (; A.size > 0;) await Promise.race(A);
330
- if (R) throw await n.emit({
331
- message: L instanceof Error ? L.message : String(L),
332
- runId: d,
333
- type: "run.failed"
334
- }).catch(() => void 0), L;
335
- if (I.throwIfAborted(), r.kind == "subflow") {
336
- let e = Object.fromEntries(N);
337
- return await n.emit({
338
- result: {
339
- kind: "function-outputs",
340
- outputs: e,
341
- target: "subflow"
342
- },
343
- runId: d,
357
+ let K = new Set(Object.values(o.graph.nodes).flatMap((e) => Object.values(e.inputs).flatMap((e) => e.kind == "sources" ? e.sources.filter((e) => e.kind == "node").map((e) => e.nodeId) : []))), q = {
358
+ kind: "node-results",
359
+ nodes: w.filter((e) => !K.has(e)).map((e) => ({
360
+ jobs: (P.get(e) ?? []).toSorted((e, t) => e.order - t.order).map(({ jobId: e, outputs: t }) => ({
361
+ jobId: e,
362
+ outputs: t
363
+ })),
364
+ nodeId: e
365
+ }))
366
+ };
367
+ return yield* a.emit({
368
+ result: q,
369
+ runId: m,
344
370
  type: "run.completed"
345
- }), e;
346
- }
347
- let W = new Set(Object.values(r.graph.nodes).flatMap((e) => Object.values(e.inputs).flatMap((e) => e.kind == "sources" ? e.sources.filter((e) => e.kind == "node").map((e) => e.nodeId) : []))), G = {
348
- kind: "node-results",
349
- nodes: C.filter((e) => !W.has(e)).map((e) => ({
350
- jobs: (j.get(e) ?? []).toSorted((e, t) => e.order - t.order).map(({ jobId: e, outputs: t }) => ({
351
- jobId: e,
352
- outputs: t
353
- })),
354
- nodeId: e
355
- }))
356
- };
357
- return await n.emit({
358
- result: G,
359
- runId: d,
360
- type: "run.completed"
361
- }), G;
371
+ }), q;
372
+ }));
362
373
  }
363
- async function _(e, t) {
364
- let n = async (e) => await t.emit?.(e), r = t.signal ?? new AbortController().signal, i = t.trigger == null ? void 0 : e.graph.nodes[t.trigger.nodeId];
365
- if (t.trigger != null && (i == null || "inputs" in i)) throw Error(`Node "${t.trigger.nodeId}" is not a TriggerNode in Flow "${t.flowId}".`);
366
- return await g({
367
- createId: t.createId,
368
- emit: n,
369
- invokeTask: t.invokeTask,
370
- prepared: e,
371
- projectFailure: t.projectFailure
372
- }, {
373
- flowId: t.flowId,
374
- graph: v(e.graph),
375
- inputs: {},
376
- kind: "flow",
377
- outputs: {}
378
- }, t.runId, {}, r, void 0, t.inputs, void 0, t.trigger);
374
+ function v(t, n) {
375
+ let r = n.emit ?? (() => e.void);
376
+ return e.gen(function* () {
377
+ let i = n.trigger == null ? void 0 : t.graph.nodes[n.trigger.nodeId];
378
+ return n.trigger != null && (i == null || "inputs" in i) ? yield* e.fail(/* @__PURE__ */ Error(`Node "${n.trigger.nodeId}" is not a TriggerNode in Flow "${n.flowId}".`)) : yield* _({
379
+ bindingValues: n.bindingValues ?? {},
380
+ createId: n.createId,
381
+ emit: r,
382
+ invokeTask: n.invokeTask,
383
+ prepared: t,
384
+ projectFailure: n.projectFailure
385
+ }, {
386
+ flowId: n.flowId,
387
+ graph: y(t.graph),
388
+ inputs: {},
389
+ kind: "flow",
390
+ outputs: {}
391
+ }, n.runId, {}, void 0, n.inputs, void 0, n.trigger);
392
+ });
379
393
  }
380
- function v(e) {
394
+ function y(e) {
381
395
  return { nodes: Object.fromEntries(Object.entries(e.nodes).filter((e) => "inputs" in e[1])) };
382
396
  }
383
397
  //#endregion
384
- export { _ as runFlow };
398
+ export { v as runFlow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,6 +37,10 @@
37
37
  "types": "./dist/common/integration-trigger.d.ts",
38
38
  "import": "./dist/common/integration-trigger.js"
39
39
  },
40
+ "./localization": {
41
+ "types": "./dist/common/localization.d.ts",
42
+ "import": "./dist/common/localization.js"
43
+ },
40
44
  "./poll-trigger": {
41
45
  "types": "./dist/common/poll-trigger.d.ts",
42
46
  "import": "./dist/common/poll-trigger.js"
@@ -88,6 +92,10 @@
88
92
  "./workbench.css": {
89
93
  "types": "./dist/browser/workbench.css.d.ts",
90
94
  "default": "./dist/browser/workbench.css"
95
+ },
96
+ "./theme.css": {
97
+ "types": "./dist/browser/theme.css.d.ts",
98
+ "default": "./dist/browser/theme.css"
91
99
  }
92
100
  },
93
101
  "files": [
@@ -97,6 +105,7 @@
97
105
  "LICENSE"
98
106
  ],
99
107
  "peerDependencies": {
108
+ "effect": "4.0.0-rc.112",
100
109
  "react": "^18.3.1 || ^19.0.0",
101
110
  "react-dom": "^18.3.1 || ^19.0.0"
102
111
  },