brass-runtime 1.13.8 → 1.15.0

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 (49) hide show
  1. package/README.md +6 -3
  2. package/dist/agent/cli/main.cjs +44 -43
  3. package/dist/agent/cli/main.js +5 -4
  4. package/dist/agent/cli/main.mjs +5 -4
  5. package/dist/agent/index.cjs +4 -3
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -2
  8. package/dist/agent/index.mjs +3 -2
  9. package/dist/{chunk-3R7ZYRK2.mjs → chunk-3QMOKAS5.js} +9 -7
  10. package/dist/{chunk-ATHSSDUF.js → chunk-4NHES7VK.mjs} +113 -31
  11. package/dist/chunk-AR22SXML.js +1043 -0
  12. package/dist/chunk-BDF4AMWX.mjs +3773 -0
  13. package/dist/chunk-BDYEENHT.js +224 -0
  14. package/dist/chunk-BMH5AV44.js +3773 -0
  15. package/dist/chunk-ELOOF35R.mjs +131 -0
  16. package/dist/chunk-JFPU5GQI.mjs +1043 -0
  17. package/dist/{chunk-INZBKOHY.js → chunk-K6M7MDZ4.mjs} +9 -7
  18. package/dist/chunk-MS34J5LY.cjs +224 -0
  19. package/dist/{chunk-XNOTJSMZ.mjs → chunk-PPUXIH5R.js} +113 -31
  20. package/dist/chunk-R3R2FVLG.cjs +131 -0
  21. package/dist/{chunk-ZTDK2DLG.cjs → chunk-STVLQ3XD.cjs} +169 -87
  22. package/dist/chunk-TGIFUAK4.cjs +3773 -0
  23. package/dist/chunk-TO7IKXYT.js +131 -0
  24. package/dist/chunk-UMAZLXAB.mjs +224 -0
  25. package/dist/{chunk-XDINDYNA.cjs → chunk-VEZNF5GZ.cjs} +136 -134
  26. package/dist/chunk-XPZNXSVN.cjs +1043 -0
  27. package/dist/core/index.cjs +216 -0
  28. package/dist/core/index.d.ts +673 -0
  29. package/dist/core/index.js +216 -0
  30. package/dist/core/index.mjs +216 -0
  31. package/dist/{effect-ISvXPLgc.d.ts → effect-CMOQKX8y.d.ts} +202 -31
  32. package/dist/http/index.cjs +3177 -187
  33. package/dist/http/index.d.ts +1692 -9
  34. package/dist/http/index.js +3164 -174
  35. package/dist/http/index.mjs +3164 -174
  36. package/dist/index.cjs +936 -219
  37. package/dist/index.d.ts +313 -36
  38. package/dist/index.js +830 -113
  39. package/dist/index.mjs +830 -113
  40. package/dist/{stream-BvukHxCv.d.ts → stream-FQm9h4Mg.d.ts} +12 -4
  41. package/dist/tracing-DNT9jEbr.d.ts +106 -0
  42. package/package.json +11 -3
  43. package/wasm/pkg/brass_runtime_wasm_engine.d.ts +95 -16
  44. package/wasm/pkg/brass_runtime_wasm_engine.js +715 -15
  45. package/wasm/pkg/brass_runtime_wasm_engine_bg.wasm +0 -0
  46. package/wasm/pkg/brass_runtime_wasm_engine_bg.wasm.d.ts +78 -7
  47. package/dist/chunk-2P4PD6D7.cjs +0 -2557
  48. package/dist/chunk-7F2R7A2V.mjs +0 -2557
  49. package/dist/chunk-L6KKKM66.js +0 -2557
@@ -0,0 +1,131 @@
1
+ import {
2
+ asyncEffect
3
+ } from "./chunk-BDF4AMWX.mjs";
4
+
5
+ // src/core/stream/structuredConcurrency.ts
6
+ function race(left, right, parentScope) {
7
+ return asyncEffect((env, cb) => {
8
+ const scope = parentScope.subScope();
9
+ let done = false;
10
+ const onResult = (exit) => {
11
+ if (done) return;
12
+ done = true;
13
+ scope.close(exit);
14
+ cb(exit);
15
+ };
16
+ const fiberLeft = scope.fork(left);
17
+ const fiberRight = scope.fork(right);
18
+ fiberLeft.join(onResult);
19
+ fiberRight.join(onResult);
20
+ });
21
+ }
22
+ function zipPar(left, right, parentScope) {
23
+ return asyncEffect((env, cb) => {
24
+ const scope = parentScope.subScope();
25
+ let leftExit = null;
26
+ let rightExit = null;
27
+ let done = false;
28
+ const checkDone = () => {
29
+ if (!leftExit || !rightExit || done) return;
30
+ done = true;
31
+ if (leftExit._tag === "Success" && rightExit._tag === "Success") {
32
+ scope.close({ _tag: "Success", value: void 0 });
33
+ cb({
34
+ _tag: "Success",
35
+ value: [leftExit.value, rightExit.value]
36
+ });
37
+ return;
38
+ }
39
+ let cause;
40
+ if (leftExit._tag === "Failure") {
41
+ cause = leftExit.cause;
42
+ } else if (rightExit._tag === "Failure") {
43
+ cause = rightExit.cause;
44
+ } else {
45
+ throw new Error("zipPar: unreachable state (no Failure exit)");
46
+ }
47
+ const errExit = {
48
+ _tag: "Failure",
49
+ cause
50
+ };
51
+ scope.close(errExit);
52
+ cb(errExit);
53
+ };
54
+ const f1 = scope.fork(left);
55
+ const f2 = scope.fork(right);
56
+ f1.join((exit) => {
57
+ leftExit = exit;
58
+ checkDone();
59
+ });
60
+ f2.join((exit) => {
61
+ rightExit = exit;
62
+ checkDone();
63
+ });
64
+ });
65
+ }
66
+ function collectAllPar(effects, parentScope) {
67
+ return asyncEffect((env, cb) => {
68
+ const scope = parentScope.subScope();
69
+ const results = new Array(effects.length);
70
+ let completed = 0;
71
+ let done = false;
72
+ effects.forEach((eff, i) => {
73
+ const f = scope.fork(eff);
74
+ f.join((exit) => {
75
+ if (done) return;
76
+ if (exit._tag === "Failure") {
77
+ done = true;
78
+ const errExit = {
79
+ _tag: "Failure",
80
+ cause: exit.cause
81
+ };
82
+ scope.close(errExit);
83
+ cb(errExit);
84
+ return;
85
+ }
86
+ results[i] = exit.value;
87
+ completed++;
88
+ if (completed === effects.length) {
89
+ done = true;
90
+ const successExit = {
91
+ _tag: "Success",
92
+ value: results
93
+ };
94
+ scope.close({ _tag: "Success", value: void 0 });
95
+ cb(successExit);
96
+ }
97
+ });
98
+ });
99
+ });
100
+ }
101
+ function raceWith(left, right, parentScope, onLeft, onRight) {
102
+ return asyncEffect((env, cb) => {
103
+ const scope = parentScope.subScope();
104
+ let done = false;
105
+ const fiberLeft = scope.fork(left);
106
+ const fiberRight = scope.fork(right);
107
+ const finish = (next) => {
108
+ scope.fork(next).join((exitNext) => {
109
+ scope.close(exitNext);
110
+ cb(exitNext);
111
+ });
112
+ };
113
+ fiberLeft.join((exitL) => {
114
+ if (done) return;
115
+ done = true;
116
+ finish(onLeft(exitL, fiberRight, scope));
117
+ });
118
+ fiberRight.join((exitR) => {
119
+ if (done) return;
120
+ done = true;
121
+ finish(onRight(exitR, fiberLeft, scope));
122
+ });
123
+ });
124
+ }
125
+
126
+ export {
127
+ race,
128
+ zipPar,
129
+ collectAllPar,
130
+ raceWith
131
+ };