@shajara/kernel 0.1.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 (226) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +67 -0
  3. package/dist/.vite/license.md +27 -0
  4. package/dist/contracts/context-key.d.ts +10 -0
  5. package/dist/contracts/context-key.d.ts.map +1 -0
  6. package/dist/contracts/failure.d.ts +5 -0
  7. package/dist/contracts/failure.d.ts.map +1 -0
  8. package/dist/contracts/future-key.d.ts +16 -0
  9. package/dist/contracts/future-key.d.ts.map +1 -0
  10. package/dist/contracts/index.d.ts +11 -0
  11. package/dist/contracts/index.d.ts.map +1 -0
  12. package/dist/contracts/message-key.d.ts +10 -0
  13. package/dist/contracts/message-key.d.ts.map +1 -0
  14. package/dist/contracts/process.d.ts +7 -0
  15. package/dist/contracts/process.d.ts.map +1 -0
  16. package/dist/contracts/scope.d.ts +7 -0
  17. package/dist/contracts/scope.d.ts.map +1 -0
  18. package/dist/contracts/sigil.d.ts +7 -0
  19. package/dist/contracts/sigil.d.ts.map +1 -0
  20. package/dist/contracts/suppressor.d.ts +4 -0
  21. package/dist/contracts/suppressor.d.ts.map +1 -0
  22. package/dist/contracts/token.d.ts +4 -0
  23. package/dist/contracts/token.d.ts.map +1 -0
  24. package/dist/contracts/wisp.d.ts +19 -0
  25. package/dist/contracts/wisp.d.ts.map +1 -0
  26. package/dist/executor/autonomy.d.ts +24 -0
  27. package/dist/executor/autonomy.d.ts.map +1 -0
  28. package/dist/executor/domain-interpreter.d.ts +15 -0
  29. package/dist/executor/domain-interpreter.d.ts.map +1 -0
  30. package/dist/executor/domains/domain.d.ts +14 -0
  31. package/dist/executor/domains/domain.d.ts.map +1 -0
  32. package/dist/executor/domains/index.d.ts +4 -0
  33. package/dist/executor/domains/index.d.ts.map +1 -0
  34. package/dist/executor/domains/reaper.d.ts +26 -0
  35. package/dist/executor/domains/reaper.d.ts.map +1 -0
  36. package/dist/executor/domains/scheduler.d.ts +15 -0
  37. package/dist/executor/domains/scheduler.d.ts.map +1 -0
  38. package/dist/executor/execution-scope.d.ts +7 -0
  39. package/dist/executor/execution-scope.d.ts.map +1 -0
  40. package/dist/executor/executor-driver.d.ts +14 -0
  41. package/dist/executor/executor-driver.d.ts.map +1 -0
  42. package/dist/executor/executor.d.ts +13 -0
  43. package/dist/executor/executor.d.ts.map +1 -0
  44. package/dist/executor/fault-sink.d.ts +12 -0
  45. package/dist/executor/fault-sink.d.ts.map +1 -0
  46. package/dist/executor/index.d.ts +8 -0
  47. package/dist/executor/index.d.ts.map +1 -0
  48. package/dist/executor/launch-handle.d.ts +33 -0
  49. package/dist/executor/launch-handle.d.ts.map +1 -0
  50. package/dist/executor/pacer.d.ts +9 -0
  51. package/dist/executor/pacer.d.ts.map +1 -0
  52. package/dist/executor/primitives/autonomy.d.ts +4 -0
  53. package/dist/executor/primitives/autonomy.d.ts.map +1 -0
  54. package/dist/executor/primitives/index.d.ts +2 -0
  55. package/dist/executor/primitives/index.d.ts.map +1 -0
  56. package/dist/executor/processor.d.ts +9 -0
  57. package/dist/executor/processor.d.ts.map +1 -0
  58. package/dist/executor/round-limit-reaper.d.ts +11 -0
  59. package/dist/executor/round-limit-reaper.d.ts.map +1 -0
  60. package/dist/failures/canceled.d.ts +6 -0
  61. package/dist/failures/canceled.d.ts.map +1 -0
  62. package/dist/failures/external.d.ts +7 -0
  63. package/dist/failures/external.d.ts.map +1 -0
  64. package/dist/failures/index.d.ts +10 -0
  65. package/dist/failures/index.d.ts.map +1 -0
  66. package/dist/failures/interrupted.d.ts +7 -0
  67. package/dist/failures/interrupted.d.ts.map +1 -0
  68. package/dist/failures/scope.d.ts +19 -0
  69. package/dist/failures/scope.d.ts.map +1 -0
  70. package/dist/index.cjs +1 -0
  71. package/dist/index.d.ts +5 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +1986 -0
  74. package/dist/internal/fp/index.d.ts +6 -0
  75. package/dist/internal/fp/index.d.ts.map +1 -0
  76. package/dist/internal/fp/lifting.d.ts +21 -0
  77. package/dist/internal/fp/lifting.d.ts.map +1 -0
  78. package/dist/internal/fp/sigil.d.ts +11 -0
  79. package/dist/internal/fp/sigil.d.ts.map +1 -0
  80. package/dist/internal/fp/wisp-either.d.ts +53 -0
  81. package/dist/internal/fp/wisp-either.d.ts.map +1 -0
  82. package/dist/internal/fp/wisp-option.d.ts +52 -0
  83. package/dist/internal/fp/wisp-option.d.ts.map +1 -0
  84. package/dist/internal/fp/wisp.d.ts +37 -0
  85. package/dist/internal/fp/wisp.d.ts.map +1 -0
  86. package/dist/interpreter/index.d.ts +4 -0
  87. package/dist/interpreter/index.d.ts.map +1 -0
  88. package/dist/interpreter/interpreter.d.ts +48 -0
  89. package/dist/interpreter/interpreter.d.ts.map +1 -0
  90. package/dist/interpreter/process-step.d.ts +21 -0
  91. package/dist/interpreter/process-step.d.ts.map +1 -0
  92. package/dist/interpreter/runtime-future.d.ts +14 -0
  93. package/dist/interpreter/runtime-future.d.ts.map +1 -0
  94. package/dist/interpreter/runtime-process/handle.d.ts +9 -0
  95. package/dist/interpreter/runtime-process/handle.d.ts.map +1 -0
  96. package/dist/interpreter/runtime-process/index.d.ts +5 -0
  97. package/dist/interpreter/runtime-process/index.d.ts.map +1 -0
  98. package/dist/interpreter/runtime-process/keeper.d.ts +39 -0
  99. package/dist/interpreter/runtime-process/keeper.d.ts.map +1 -0
  100. package/dist/interpreter/runtime-process/process.d.ts +54 -0
  101. package/dist/interpreter/runtime-process/process.d.ts.map +1 -0
  102. package/dist/interpreter/runtime-process/runner.d.ts +45 -0
  103. package/dist/interpreter/runtime-process/runner.d.ts.map +1 -0
  104. package/dist/interpreter/runtime-process/stepper.d.ts +9 -0
  105. package/dist/interpreter/runtime-process/stepper.d.ts.map +1 -0
  106. package/dist/interpreter/runtime-scope/index.d.ts +2 -0
  107. package/dist/interpreter/runtime-scope/index.d.ts.map +1 -0
  108. package/dist/interpreter/runtime-scope/runtime-mailbox.d.ts +11 -0
  109. package/dist/interpreter/runtime-scope/runtime-mailbox.d.ts.map +1 -0
  110. package/dist/interpreter/runtime-scope/runtime-scope.d.ts +58 -0
  111. package/dist/interpreter/runtime-scope/runtime-scope.d.ts.map +1 -0
  112. package/dist/interpreter/runtime-scope/scope-failure-draft.d.ts +12 -0
  113. package/dist/interpreter/runtime-scope/scope-failure-draft.d.ts.map +1 -0
  114. package/dist/interpreter/scope-zone.d.ts +6 -0
  115. package/dist/interpreter/scope-zone.d.ts.map +1 -0
  116. package/dist/primitives/all.d.ts +7 -0
  117. package/dist/primitives/all.d.ts.map +1 -0
  118. package/dist/primitives/bind.d.ts +3 -0
  119. package/dist/primitives/bind.d.ts.map +1 -0
  120. package/dist/primitives/cancel.d.ts +3 -0
  121. package/dist/primitives/cancel.d.ts.map +1 -0
  122. package/dist/primitives/cede.d.ts +3 -0
  123. package/dist/primitives/cede.d.ts.map +1 -0
  124. package/dist/primitives/defer.d.ts +3 -0
  125. package/dist/primitives/defer.d.ts.map +1 -0
  126. package/dist/primitives/enclose.d.ts +4 -0
  127. package/dist/primitives/enclose.d.ts.map +1 -0
  128. package/dist/primitives/future.d.ts +3 -0
  129. package/dist/primitives/future.d.ts.map +1 -0
  130. package/dist/primitives/guard.d.ts +6 -0
  131. package/dist/primitives/guard.d.ts.map +1 -0
  132. package/dist/primitives/halt.d.ts +3 -0
  133. package/dist/primitives/halt.d.ts.map +1 -0
  134. package/dist/primitives/index.d.ts +21 -0
  135. package/dist/primitives/index.d.ts.map +1 -0
  136. package/dist/primitives/lookup.d.ts +4 -0
  137. package/dist/primitives/lookup.d.ts.map +1 -0
  138. package/dist/primitives/park.d.ts +3 -0
  139. package/dist/primitives/park.d.ts.map +1 -0
  140. package/dist/primitives/poll.d.ts +4 -0
  141. package/dist/primitives/poll.d.ts.map +1 -0
  142. package/dist/primitives/race.d.ts +8 -0
  143. package/dist/primitives/race.d.ts.map +1 -0
  144. package/dist/primitives/resource.d.ts +5 -0
  145. package/dist/primitives/resource.d.ts.map +1 -0
  146. package/dist/primitives/resumable.d.ts +3 -0
  147. package/dist/primitives/resumable.d.ts.map +1 -0
  148. package/dist/primitives/self.d.ts +5 -0
  149. package/dist/primitives/self.d.ts.map +1 -0
  150. package/dist/primitives/settle.d.ts +3 -0
  151. package/dist/primitives/settle.d.ts.map +1 -0
  152. package/dist/primitives/spawn.d.ts +3 -0
  153. package/dist/primitives/spawn.d.ts.map +1 -0
  154. package/dist/primitives/unbind.d.ts +3 -0
  155. package/dist/primitives/unbind.d.ts.map +1 -0
  156. package/dist/primitives/wait.d.ts +3 -0
  157. package/dist/primitives/wait.d.ts.map +1 -0
  158. package/dist/primitives-kit/index.d.ts +3 -0
  159. package/dist/primitives-kit/index.d.ts.map +1 -0
  160. package/dist/primitives-kit/process.d.ts +7 -0
  161. package/dist/primitives-kit/process.d.ts.map +1 -0
  162. package/dist/primitives-kit/resumable.d.ts +9 -0
  163. package/dist/primitives-kit/resumable.d.ts.map +1 -0
  164. package/dist/primitives.d.ts +2 -0
  165. package/dist/primitives.d.ts.map +1 -0
  166. package/dist/sigils/bind.d.ts +9 -0
  167. package/dist/sigils/bind.d.ts.map +1 -0
  168. package/dist/sigils/branch.d.ts +17 -0
  169. package/dist/sigils/branch.d.ts.map +1 -0
  170. package/dist/sigils/cancel.d.ts +7 -0
  171. package/dist/sigils/cancel.d.ts.map +1 -0
  172. package/dist/sigils/cede.d.ts +7 -0
  173. package/dist/sigils/cede.d.ts.map +1 -0
  174. package/dist/sigils/defer.d.ts +8 -0
  175. package/dist/sigils/defer.d.ts.map +1 -0
  176. package/dist/sigils/future.d.ts +7 -0
  177. package/dist/sigils/future.d.ts.map +1 -0
  178. package/dist/sigils/halt.d.ts +8 -0
  179. package/dist/sigils/halt.d.ts.map +1 -0
  180. package/dist/sigils/index.d.ts +34 -0
  181. package/dist/sigils/index.d.ts.map +1 -0
  182. package/dist/sigils/lookup.d.ts +9 -0
  183. package/dist/sigils/lookup.d.ts.map +1 -0
  184. package/dist/sigils/poll.d.ts +9 -0
  185. package/dist/sigils/poll.d.ts.map +1 -0
  186. package/dist/sigils/receive.d.ts +8 -0
  187. package/dist/sigils/receive.d.ts.map +1 -0
  188. package/dist/sigils/self.d.ts +11 -0
  189. package/dist/sigils/self.d.ts.map +1 -0
  190. package/dist/sigils/send.d.ts +10 -0
  191. package/dist/sigils/send.d.ts.map +1 -0
  192. package/dist/sigils/settle.d.ts +9 -0
  193. package/dist/sigils/settle.d.ts.map +1 -0
  194. package/dist/sigils/spawn.d.ts +13 -0
  195. package/dist/sigils/spawn.d.ts.map +1 -0
  196. package/dist/sigils/unbind.d.ts +8 -0
  197. package/dist/sigils/unbind.d.ts.map +1 -0
  198. package/dist/sigils/wait.d.ts +8 -0
  199. package/dist/sigils/wait.d.ts.map +1 -0
  200. package/dist/sigils.cjs +1 -0
  201. package/dist/sigils.d.ts +2 -0
  202. package/dist/sigils.d.ts.map +1 -0
  203. package/dist/sigils.js +125 -0
  204. package/dist/utils/disposer.d.ts +2 -0
  205. package/dist/utils/disposer.d.ts.map +1 -0
  206. package/dist/utils/either.d.ts +2 -0
  207. package/dist/utils/either.d.ts.map +1 -0
  208. package/dist/utils/iife.d.ts +2 -0
  209. package/dist/utils/iife.d.ts.map +1 -0
  210. package/dist/utils/index.d.ts +8 -0
  211. package/dist/utils/index.d.ts.map +1 -0
  212. package/dist/utils/narrow.d.ts +4 -0
  213. package/dist/utils/narrow.d.ts.map +1 -0
  214. package/dist/utils/noop.d.ts +2 -0
  215. package/dist/utils/noop.d.ts.map +1 -0
  216. package/dist/utils/option.d.ts +2 -0
  217. package/dist/utils/option.d.ts.map +1 -0
  218. package/dist/utils/unreachable.d.ts +2 -0
  219. package/dist/utils/unreachable.d.ts.map +1 -0
  220. package/dist/utils-O8j9DzUQ.cjs +1 -0
  221. package/dist/utils-PwEUjNtC.js +327 -0
  222. package/dist/utils.cjs +1 -0
  223. package/dist/utils.d.ts +2 -0
  224. package/dist/utils.d.ts.map +1 -0
  225. package/dist/utils.js +2 -0
  226. package/package.json +73 -0
@@ -0,0 +1,6 @@
1
+ import { FailureShape } from '../contracts';
2
+ export declare const canceledFailure: CanceledFailure;
3
+ export interface CanceledFailure extends FailureShape {
4
+ readonly kind: "canceled";
5
+ }
6
+ //# sourceMappingURL=canceled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canceled.d.ts","sourceRoot":"","sources":["../../src/failures/canceled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,eAAe,EAAE,eAG7B,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B"}
@@ -0,0 +1,7 @@
1
+ import { FailureShape } from '../contracts';
2
+ export declare function externalFailure(raw: unknown, message: string): ExternalFailure;
3
+ export interface ExternalFailure extends FailureShape {
4
+ readonly kind: "external";
5
+ readonly raw: unknown;
6
+ }
7
+ //# sourceMappingURL=external.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/failures/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAM9E;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1,10 @@
1
+ import { CanceledFailure } from './canceled';
2
+ import { ExternalFailure } from './external';
3
+ import { InterruptedFailure } from './interrupted';
4
+ import { ScopeFailure } from './scope';
5
+ export * from './canceled';
6
+ export * from './external';
7
+ export * from './interrupted';
8
+ export * from './scope';
9
+ export type Failure = CanceledFailure | ExternalFailure | InterruptedFailure | ScopeFailure;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/failures/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AAExB,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG,kBAAkB,GAAG,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { FailureShape } from '../contracts';
2
+ export declare function interruptedFailure(cause: unknown): InterruptedFailure;
3
+ export interface InterruptedFailure extends FailureShape {
4
+ readonly cause: unknown;
5
+ readonly kind: "interrupted";
6
+ }
7
+ //# sourceMappingURL=interrupted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interrupted.d.ts","sourceRoot":"","sources":["../../src/failures/interrupted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAMrE;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B"}
@@ -0,0 +1,19 @@
1
+ import { FailureShape, ProcessRef, ScopeRef } from '../contracts';
2
+ export declare function scopeFailure(cause: ScopeFailureCause, suppressed: readonly FailureShape[]): ScopeFailure;
3
+ export interface ScopeFailure extends FailureShape {
4
+ readonly cause: ScopeFailureCause;
5
+ readonly suppressed: readonly FailureShape[];
6
+ readonly kind: "scope";
7
+ }
8
+ export type ScopeFailureCause = ProcessCause | ScopeCause;
9
+ export interface ProcessCause {
10
+ readonly failure: FailureShape;
11
+ readonly kind: "process";
12
+ readonly process: ProcessRef<unknown>;
13
+ }
14
+ export interface ScopeCause {
15
+ readonly failure: FailureShape;
16
+ readonly kind: "scope";
17
+ readonly scope: ScopeRef<unknown>;
18
+ }
19
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/failures/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,UAAU,EAAE,SAAS,YAAY,EAAE,GAClC,YAAY,CAOd;AAED,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CACnC"}
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utils-O8j9DzUQ.cjs`),t=require(`./sigils.cjs`);function n(e,t){return{bearing:`stirring`,resonate:t,sigil:e}}function r(e){return{bearing:`resting`,relic:e}}function i(e){return n(e,r)}function a(){return{}}function o(){return{}}var s=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},c=e.B,l=e.W,u=function(e){return function(t){return s(s([],t,!0),[e],!1)}};e.G,e.U,e.V,e.K;var d=function(e){return e.length===0},f=l,p=u,m=function(t,n,r){return e.X(t,ee(n,r))},h=function(){return ne},g=function(e){return function(t){return t.map(function(t){return e(t)})}},ee=function(e,t){return te(e,function(e,n,r){return t(n,r)})},te=function(e,t){return function(n){for(var r=n.length,i=e,a=0;a<r;a++)i=t(a,i,n[a]);return i}},_=function(t){return function(n){return m(n,t.of(h()),function(n,r){return t.ap(t.map(n,function(t){return function(n){return e.X(t,p(n))}}),r)})}},ne=c;e.V;function re(t){return e.Y(e.k,t.of)}function ie(t){return e.Y(e.E,t.of)}function ae(t){return function(n){return t.map(n,e.k)}}function oe(t){return function(n){return t.map(n,e.E)}}function v(t){return function(n){return e.Y(e.x(n),t.of)}}function se(t){var n=v(t);return function(t){var r=n(t);return function(t){return e.Y(t,r)}}}function ce(e){var t=de(e),n=se(e);return function(e){var r=n(e);return function(e){return t(r(e))}}}function le(t){return e.R(t,e._)}function ue(t){return e.z(t,e.g)}function de(e){var t=fe(e);return function(e){return function(n){return t(n,e)}}}function fe(t){return function(n,r){return t.chain(n,function(n){return e.w(n)?t.of(n):r(n.right)})}}function pe(t){return function(n){return function(r){return t.chain(r,function(r){return e.w(r)?n():t.of(r)})}}}function me(e){var t=he(e);return function(e,n){return function(r){return t(r,e,n)}}}function he(t){return function(n,r,i){return t.map(n,e.v(r,i))}}function ge(e){var t=_e(e);return function(e){return function(n){return t(n,e)}}}function _e(t){return function(n,r){return t.map(n,e.D(r))}}function ve(t){return function(n,r){return function(i){return t.map(i,e.O(n,r))}}}function ye(t){return function(n,r){return function(i){return t.chain(i,e.O(n,r))}}}function be(t){return function(n){return function(r){return t.chain(r,e.O(n,t.of))}}}function y(t){return function(n){return function(r){return t.chain(r,function(r){return e.w(r)?n(r.left):t.of(r)})}}}function xe(e){var t=Se(e);return function(e){return function(n){return t(n,e)}}}function Se(t){var n=y(t);return function(r,i){return e.X(r,n(function(n){return t.map(i(n),function(t){return e.w(t)?t:e.E(n)})}))}}function Ce(t){return function(n){return function(r){return t.chain(r,e.O(function(r){return t.map(n(r),e.E)},function(n){return t.of(e.k(n))}))}}}function we(t){return function(n){return t.map(n,e.A)}}function Te(t){return function(n){return t.map(n,e.j)}}function b(t,n){return function(r){var i=e.Y(r,t.fromIO);return function(e){return n.chain(e,i)}}}function x(e,t){var n=Ee(e,t);return function(e){return function(t){return n(t,e)}}}function Ee(t,n){var r=e.F(n);return function(n,i){return r(n,e.Y(i,t.fromIO))}}var S=function(e,t){return function(){return t(e())}},De=function(e,t){return function(){return e()(t())}},Oe=e.q,ke=e.J(2,function(e,t){return function(){return t(e())()}}),C={URI:`IO`,map:S};e.J(2,e.I(C)),e.L(C);var Ae={URI:`IO`,map:S,ap:De,chain:ke};e.F(Ae);var je=Oe(e.V);e.B;function w(t){return e.Y(e.d,t.of)}function T(t){return e.q(t.of(e.u))}function Me(t){return function(n){return t.map(n,e.d)}}function E(t){return e.Y(e.a,t.of)}function Ne(t){var n=E(t);return function(t){return e.Y(t,n)}}function Pe(e){var t=D(e),n=Ne(e);return function(e){return t(n(e))}}function Fe(t){return function(n){return e.Y(n,t.of)}}function Ie(e){var t=D(e),n=Fe(e);return function(e){return t(n(e))}}function Le(t){return function(n){return function(r){return t.of(e.o(n)(r))}}}function Re(t){return e.Y(e.i,t.of)}function ze(t){return function(n,r){return function(i){return t.map(i,e.l(n,r))}}}function Be(t){return function(n,r){return function(i){return t.chain(i,e.l(n,r))}}}function Ve(t){return function(n){return function(r){return t.chain(r,e.l(n,t.of))}}}function He(t){return e.R(t,e.r)}function Ue(t){return e.z(t,e.n)}function D(e){var t=We(e);return function(e){return function(n){return t(n,e)}}}function We(t){var n=T(t);return function(r,i){return t.chain(r,e.l(function(){return n()},i))}}function Ge(t){var n=w(t);return function(r){return function(i){return t.chain(i,e.l(r,n))}}}function Ke(e){return function(t){return function(n){return e.map(n,t)}}}function qe(e){return function(t){return function(n){return e.ap(n,t)}}}function O(e){return function(t){return function(n){return e.chain(n,t)}}}var k=function(e){return e.size===0},A;(function(t){function n(t){let n=O(t);return r=>n(e.Y(r,t.liftF))}t.chainF=n;function r(t){let n=e.P(t);return r=>n(e.Y(r,t.liftF))}t.chainFirstF=r;function i(t){let n=e.N(t);return(r,i)=>n(r,e.Y(i,t.liftF))}t.bindF=i})(A||={});var j;(function(t){let a=t.URI=`Wisp`,o=t.Pointed={URI:a,of:r},s=t.Functor={URI:a,map:(e,t)=>e.bearing===`resting`?r(t(e.relic)):n(e.sigil,n=>s.map(e.resonate(n),t))},c=t.Apply={URI:a,ap:(e,t)=>e.bearing===`resting`?s.map(t,e.relic):n(e.sigil,n=>c.ap(e.resonate(n),t)),map:s.map},l=t.Applicative={URI:a,ap:c.ap,map:s.map,of:o.of},u=t.Chain={URI:a,ap:c.ap,chain:(e,t)=>e.bearing===`resting`?t(e.relic):n(e.sigil,n=>u.chain(e.resonate(n),t)),map:s.map};t.Monad={URI:a,ap:c.ap,chain:u.chain,map:s.map,of:o.of},t.Do=r(null);let d=t.Lifting={URI:a,ap:c.ap,chain:u.chain,liftF:i,map:s.map},f=t.FromIO={URI:a,fromIO:e=>o.of(e())},{of:p}=o;t.of=p,t.map=Ke(s),t.ap=qe(c),t.chain=O(u),t.bind=e.N(u),t.chainFirst=e.P(u),t.sequence=_(l);let{liftF:m}=d;t.liftF=m,t.bindF=A.bindF(d),t.chainF=A.chainF(d),t.chainFirstF=A.chainFirstF(d);let{fromIO:h}=f;t.fromIO=h,t.chainFirstIOK=x(f,u),t.chainIOK=b(f,u)})(j||={});var M;(function(t){let n=t.URI=`WispEither`;t.left=ie(j.Pointed);let r=t.right=re(j.Pointed),i=t.map=le(j.Functor),a=t.ap=ue(j.Apply),o=t.chain=de(j.Monad);t.leftWisp=oe(j.Functor);let s=t.rightWisp=ae(j.Functor),c=t.Pointed={URI:n,of:r},l=t.Functor={URI:n,map:(e,t)=>i(t)(e)},u=t.Apply={URI:n,ap:(e,t)=>a(t)(e),map:l.map},d=t.Applicative={URI:n,ap:u.ap,map:l.map,of:c.of},f=t.Chain={URI:n,ap:u.ap,chain:(e,t)=>o(t)(e),map:l.map};t.Monad={URI:n,ap:u.ap,chain:f.chain,map:l.map,of:c.of};let p=t.Lifting={URI:n,ap:u.ap,chain:f.chain,liftF:e.Y(j.liftF,s),map:l.map},m=t.FromIO={URI:n,fromIO:e=>c.of(e())};t.bind=e.N(f),t.chainFirst=e.P(f),t.sequence=_(d);let{liftF:h}=p;t.liftF=h,t.bindF=A.bindF(p),t.chainF=A.chainF(p),t.chainFirstF=A.chainFirstF(p);let{fromIO:g}=m;t.fromIO=g,t.chainFirstIOK=x(m,f),t.chainIOK=b(m,f),t.alt=pe(j.Monad),t.bimap=me(j.Monad),t.chainNullableK=ce(j.Monad),t.fromNullable=v(j.Pointed),t.getOrElse=be(j.Monad),t.mapLeft=ge(j.Functor),t.match=ve(j.Chain),t.matchE=ye(j.Chain),t.orElse=y(j.Monad),t.orElseFirst=xe(j.Monad),t.orLeft=Ce(j.Monad),t.swap=we(j.Functor),t.toUnion=Te(j.Functor)})(M||={});var Je;(function(t){let n=t.URI=`WispOption`,r=t.some=w(j.Pointed),i=t.map=He(j.Functor),a=t.ap=Ue(j.Apply),o=t.chain=D(j.Monad),s=t.fromWisp=Me(j.Functor),c=t.Pointed={URI:n,of:r},l=t.Functor={URI:n,map:(e,t)=>i(t)(e)},u=t.Apply={URI:n,ap:(e,t)=>a(t)(e),map:l.map},d=t.Applicative={URI:n,ap:u.ap,map:l.map,of:c.of},f=t.Chain={URI:n,ap:u.ap,chain:(e,t)=>o(t)(e),map:l.map};t.Monad={URI:n,ap:u.ap,chain:f.chain,map:l.map,of:c.of};let p=t.Lifting={URI:n,ap:u.ap,chain:f.chain,liftF:e.Y(j.liftF,s),map:l.map},m=t.FromIO={URI:n,fromIO:e=>c.of(e())};t.bind=e.N(f),t.chainFirst=e.P(f),t.sequence=_(d);let{liftF:h}=p;t.liftF=h,t.bindF=A.bindF(p),t.chainF=A.chainF(p),t.chainFirstF=A.chainFirstF(p);let{fromIO:g}=m;t.fromIO=g,t.chainFirstIOK=x(m,f),t.chainIOK=b(m,f),t.alt=Ge(j.Monad),t.chainNullableK=Pe(j.Monad),t.chainOptionK=Ie(j.Monad),t.fromEither=Re(j.Pointed),t.fromNullable=E(j.Pointed),t.fromPredicate=Le(j.Pointed),t.getOrElse=Ve(j.Monad),t.match=ze(j.Functor),t.matchE=Be(j.Chain),t.zero=T(j.Pointed)})(Je||={});var Ye;(function(e){e.URI=`Sigil`})(Ye||={});function Xe(n){return e.X(t.wait(n.exitFuture),j.liftF,j.map(e.m()),j.map(({right:e})=>e))}var N=o(),P=a();function Ze(n){return e.X(t.spawn(Qe(n)),j.liftF,j.map(e=>e.exitFuture))}function Qe(n){return()=>e.X(n,g(e.Y(t.spawn,j.liftF)),j.sequence,j.map(g(Xe)),j.chain(j.sequence),j.map(e.p()))}function $e(e){return j.liftF(t.wait(e))}function et(e,n){return j.liftF(t.bind(e,n))}function F(){return j.liftF(t.cancel())}function tt(){return j.liftF(t.cede())}function nt(e){return j.liftF(t.defer(e))}function rt(n){return e.X(t.spawn(n),j.liftF,j.map(e=>e.exitFuture))}function it(){return j.liftF(t.future())}function I(e){return j.liftF(t.halt(e))}function at(e){return j.liftF(t.lookup(e))}function ot(e){return j.liftF(t.poll(e))}function L(){return j.liftF(t.receive(st))}var st=a();function ct(n){return e.X(t.future(),j.liftF,j.chainFirstF(([,e])=>t.branch(lt(n,e))),j.map(([e])=>e))}function lt(n,r){return()=>e.X(n,g(n=>e.X(t.spawn(ut(n,r)),j.liftF)),j.sequence)}function ut(n,r){return()=>e.X(n(),j.chainF(n=>t.settle(r,e.k(n))),j.chainF(t.cancel))}function dt(n){return e.X(t.future(),j.liftF,j.chainFirstF(([,e])=>t.spawn(ft(n,e))),j.map(([e])=>e))}function ft(n,r){return()=>n(n=>e.X(t.settle(r,e.k(n)),j.liftF,j.chain(L)))}function pt(n){return e.X(t.branch(n,{failureMode:`contain`}),j.liftF,j.chainF(({scope:e})=>t.spawn(mt(e.exitFuture))),j.map(({exitFuture:e})=>e))}function mt(n){return()=>e.X(t.wait(n),j.liftF,M.orElse(n=>e.X(t.lookup(N),j.liftF,j.map(e.S(()=>n)),M.map(e=>({delegateScope:e})),M.bindF(`resolver`,()=>t.future()),M.chainFirstF(({resolver:[,e],delegateScope:r})=>t.send(r,P,{failure:n,recoverySettle:e})),M.chainF(({resolver:[e]})=>t.wait(e)),j.map(e.b))),M.getOrElse(e.Y(t.halt,j.liftF)))}function ht(n,r){return e.X(t.branch(gt(n,r)),j.liftF,j.map(({scope:e})=>e.exitFuture))}function gt(n,r){return()=>e.X(t.self(),j.liftF,j.chainF(({scope:e})=>t.bind(N,e)),j.chainF(()=>t.spawn(_t(r),{completionMode:`detached`})),j.chain(n))}function _t(n){return function r(){return e.X(t.receive(P),j.liftF,j.chainF(e=>t.spawn(vt(e,n))),j.chain(r))}}function vt(n,r){return()=>e.X(r(n.failure),j.chainF(e=>t.settle(n.recoverySettle,e)))}function yt(n){return e.X(t.branch(n,{failureMode:`contain`}),j.liftF,j.chainF(({scope:e})=>t.wait(e.exitFuture)))}function bt(){return j.liftF(t.self())}function R(e,n){return j.liftF(t.settle(e,n))}function xt(e){return j.liftF(t.unbind(e))}var z={kind:`canceled`,message:`Canceled before completion`};function B(e,t){return{kind:`external`,message:t,raw:e}}function V(e){return{cause:e,kind:`interrupted`,message:`Scope progression was interrupted by an out-of-band failure`}}function H(e,t){return{cause:e,kind:`scope`,message:`Scope failed during closing`,suppressed:t}}var U=class e{static*domains(e){yield e;for(let t of e.#t)yield*this.domains(t)}static sentinel(){return e.#e}constructor(e){this.parent=e}close(){this.parent.removeChild(this)}addChild(e){this.#t.add(e)}removeChild(e){this.#t.delete(e)}get isRoot(){return this.parent===e.#e}static#e=null;#t=new Set},St=class e extends U{static root(t){return new e(e.sentinel(),t)}nest(t){let n=new e(this,t);return super.addChild(n),n}setScopeRoot(e){this.#e=e,this.addLeafScope(e)}addLeafScope(e){this.#n.add(e)}removeLeafScope(e){this.#n.delete(e)}trackScope(e,t){t.status===`closing`?this.#t.add(e):k(this.#t)||this.#t.delete(e)}*createWorkers(e){for(let t of this.#n)e(t).status===`closing`&&(yield{scope:t,worker:()=>this.reaper.adjudicate(t)})}close(){this.#t.clear(),this.#n.clear(),super.close()}get hasClosingScope(){return!k(this.#t)}get scopeRoot(){return this.#e}constructor(e,t){super(e),this.reaper=t}#e;#t=new Set;#n=new Set},Ct=class e extends U{static root(t,n){return new e(e.sentinel(),t,n)}nest(t,n){let r=new e(this,t,n);return super.addChild(r),r}admitProcess(e,t){t.status===`open`&&t.activity===`running`&&this.scheduler.assign(e).admit(this.createTask(e))}constructor(e,t,n){super(e),this.scheduler=t,this.createTask=n}},W=class{constructor(e){this.message=e}capture(e){this.#e.push(e)}drain(){let t=this.#e;switch(this.#e=[],t.length){case 0:return e.u;case 1:return e.d(t[0]);default:return e.d(AggregateError(t,this.message))}}throwIfAny(){let t=this.drain();if(e.c(t))throw t.value}[Symbol.dispose](){this.throwIfAny()}#e=[]};function G(){return{disposition:`waiting`}}function wt(){return{disposition:`ceded`}}function K(){return{disposition:`interpreted`}}function Tt(){return{disposition:`resonated`}}function q(e){return{disposition:`exited`,result:e}}var J=class{poll(){return this.#t?e.d(this.#t):e.u}wait(t){if(this.#t)return e.t();let n=[t];return this.#e.add(n),()=>{this.#e.delete(n)}}settle(e){return this.#t?()=>[]:(this.#t=e,t=>{for(let[n]of this.#e)n(e,t);this.#e.clear()})}handle(){return[this,this]}#e=new Set;#t=null},Et=class{current(){switch(this.#t.status){case`echo`:{let{wisp:e}=this.#t;return{accept:t=>{this.#e(e,t)},kind:`echo`,sigil:this.#t.wisp.sigil}}case`relic`:return{kind:`relic`,relic:this.#t.relic};case`resonate`:return e.t()}}next(){switch(this.#t.status){case`echo`:{let{wisp:e}=this.#t;return{accept:t=>{this.#e(e,t)},kind:`echo`,sigil:this.#t.wisp.sigil}}case`relic`:return{kind:`relic`,relic:this.#t.relic};case`resonate`:{let e=this.#t.resonate();return e.bearing===`resting`?(this.#t={relic:e.relic,status:`relic`},{kind:`relic`,relic:e.relic}):(this.#t={status:`echo`,wisp:e},{kind:`resonate`,sigil:this.#t.wisp.sigil})}}}constructor(e){this.#t={resonate:e,status:`resonate`}}#e(e,t){this.#t={resonate:()=>e.resonate(t),status:`resonate`}}#t},Dt=class t{static create(e,n,r){return new t(e,n,r)}selfHandle(){return{process:this,scope:this.scopeRef}}runner(){return this}keeper(){return this}stateAs(e){return this.#i}resume(e){let t=this.stateAs(`waiting`);t.stepper.current().accept(e),this.#i=Ot(t.stepper)}wait(e){this.#i={dispose:e,status:`waiting`,stepper:this.stateAs(`running`).stepper}}complete(t){return this.#t(),this.#i={result:t,status:`completed`},this.#e(e.k(t))}fail(t){return this.#t(),this.#i={failure:t,status:`failed`},this.#e(e.E(t))}cancel(){return this.#t(),this.#i={status:`canceled`},this.#e(e.E(z))}defer(e){this.#r.push(e)}get exitFuture(){return this.#n}get descriptor(){return this.processDescriptor}get scopeRef(){return this.scopeReference}get status(){return this.#i.status}get isClosed(){switch(this.status){case`running`:case`waiting`:return!1;case`completed`:case`canceled`:case`failed`:return!0}}constructor(e,t,n){this.scopeReference=e,this.processDescriptor=n,this.#i=Ot(new Et(t))}#e(e){let t=this.#r;return this.#r=[],{cleanups:t,notification:this.#n.settle(e)}}#t(){this.#i.status===`waiting`&&this.#i.dispose()}#n=new J;#r=[];#i};function Ot(e){return{next:()=>e.next(),status:`running`,stepper:e}}var kt=class{tryReceive(t){let n=this.#n.get(t);if(n)switch(n.length){case 0:this.#n.delete(t);break;case 1:return this.#n.delete(t),e.d(n[0]);default:{let t=n.shift();return e.d(t)}}return e.u}enqueueReceiver(e,t){this.#i.getOrInsertComputed(e,()=>new Set).add(t),this.#r.getOrInsertComputed(t,()=>[]).push(e)}send(e,t){let n=this.#r.get(e);if(n)switch(n.length){case 0:this.#r.delete(e);break;case 1:{this.#r.delete(e);let[t]=n;return t}default:return n.shift()}return this.#t(e,t),null}cancelReceiver(e){let t=this.#i.get(e);if(t){for(let n of t)this.#e(n,e);this.#i.delete(e)}}clear(){this.#n.clear(),this.#r.clear(),this.#i.clear()}#e(e,t){let n=this.#r.get(e);if(!n)return;let r=n.filter(e=>e!==t);d(r)?this.#r.delete(e):n.splice(0,n.length,...r)}#t(e,t){this.#n.getOrInsertComputed(e,()=>[]).push(t)}#n=new Map;#r=new Map;#i=new Map},Y=class{constructor(e,t){this.cause=e,this.resolveFailure=t}capture(e){this.#e.push(e)}build(){return H({...this.cause,failure:this.resolveFailure()},this.#e)}#e=[]},At=class t{static root(e,n,r,i){let a=new t(e,n,t.#w,r);return r.trackProcess(a.entryProcess,i),r.trackScope(a,i),a}complete(e,t,n){let r=e.complete(t);this.#p(e).delete(e),this.#m(r.cleanups,n),this.scopeZone.trackProcess(e,n),this.#e([r.notification],n)}halt(t,n,r){let i=`failed`,a=t.fail(n);this.#p(t).delete(t);let o=()=>this.#m(a.cleanups,r);this.scopeZone.trackProcess(t,r);let s=[a.notification],c=this.#D;if(c.status===`failing`){e.h(()=>{c.draft.capture(t.stateAs(i).failure),this.#i(c.draft,o,s,{propagateFailure:this.#S},r)});return}this.#i(new Y({kind:`process`,process:t},()=>t.stateAs(i).failure),o,s,{propagateFailure:this.#S},r)}cancel(t){this.#D.status===`failing`?this.#i(this.#D.draft,e.f,[],{propagateFailure:!1},t):this.#r(t)}branch(e,n,r,i){let a=new t(e,n,this,r);return this.#k.add(a),r.trackProcess(a.entryProcess,i),r.trackScope(a,i),a}spawn(e,t,n){let r=e(this,t);return this.#p(r).add(r),this.scopeZone.trackProcess(r,n),r}createFuture(){let e=new J;return this.#j.add(e),e.wait(()=>{this.#j.delete(e)}),e}wait(e,t,n){let r=t.wait((t,n)=>{e.resume(t),this.scopeZone.trackProcess(e,n)});e.wait(r),this.scopeZone.trackProcess(e,n)}send(e,t,n,r){e.#f(t,n,r)}receive(e,t,n){this.#A.enqueueReceiver(e,t),e.wait(()=>{this.#A.cancelReceiver(e)}),this.scopeZone.trackProcess(e,n)}tryReceive(e){return this.#A.tryReceive(e)}lookup(t){return this.#P.has(t)?e.d(this.#P.get(t)):this.#C?e.u:this.parentScope.lookup(t)}bind(e,t){this.#P.set(e,t)}unbind(e){this.#P.delete(e)}forceFailed(t,n){let r=new Y({kind:`scope`,scope:this},()=>t);for(this.#D.status===`failing`&&r.capture(this.#D.draft.build()),this.#i(r,e.f,[],{propagateFailure:this.#S},n);this.#D.status===`failing`;)this.#i(this.#D.draft,e.f,[],{propagateFailure:!1},n)}get descriptor(){return this.scopeDescriptor}get entryProcess(){return this.#E}get zone(){return this.scopeZone}get parent(){return this.#C?null:this.parentScope}get children(){return[...this.#k]}get exitFuture(){return this.#T}get status(){return this.#D.status}get isClosed(){switch(this.status){case`running`:case`closing`:case`canceling`:case`failing`:return!1;case`completed`:case`canceled`:case`failed`:return!0}}constructor(e,t,n,r){this.scopeDescriptor=t,this.parentScope=n,this.scopeZone=r,this.#T=new J;let i=e(this,{completionMode:`structural`});this.#p(i).add(i),this.#E=i}#e(t,n){switch(this.#D.status){case`running`:this.#t(t,n);return;case`closing`:this.#a(t,n);return;case`canceling`:this.#o(t,n);return;case`failing`:this.#s(this.#D.draft,t,n);return;case`canceled`:case`completed`:case`failed`:return e.t()}}#t(e,t){if(this.#b){this.#n(e,t);return}X(e,t)}#n(e,t){using n=this.#v();this.#c({status:`closing`},e,t),this.#a([],t)}#r(e){using t=this.#v();this.#c({status:`canceling`},[],e),this.#o([],e)}#i(e,t,n,r,i){using a=this.#v();this.#c({draft:e,status:`failing`},n,i),t(),r.propagateFailure&&this.parentScope.#y(jt)&&this.parentScope.#h(this,i),this.#s(e,[],i)}#a(e,t){if(this.#x){let{result:n}=this.#E.stateAs(`completed`);this.#c({result:n,status:`completed`},e,t),!this.#C&&this.parentScope.#y(Z)&&this.parentScope.#e([],t);return}X(e,t)}#o(e,t){if(this.#x){this.#c({status:`canceled`},e,t),!this.#C&&this.parentScope.#y(Z)&&this.parentScope.#e([],t);return}X(e,t)}#s(e,t,n){if(this.#x){this.#c({failure:e.build(),status:`failed`},t,n),!this.#C&&this.parentScope.#y(Z)&&this.parentScope.#e([],n);return}X(t,n)}#c(t,n,r){switch(this.#D=t,t.status){case`running`:return e.t();case`closing`:n.push(...this.#u(r));break;case`canceling`:case`failing`:n.push(...this.#l(r));break;case`canceled`:n.push(...this.#d(e.E(z)));break;case`completed`:n.push(...this.#d(e.k(t.result)));break;case`failed`:n.push(...this.#d(e.E(t.failure)));break}X(n,r),this.scopeZone.trackScope(this,r)}#l(e){let t=[...this.#M,...this.#N],n=[...this.#k];this.#M.clear(),this.#N.clear();let r=[];for(let n of t){let t=n.cancel();this.#m(t.cleanups,e),this.scopeZone.trackProcess(n,e),r.push(t.notification)}for(let t of n)t.#y(Mt)&&t.cancel(e);return r}#u(e){let t=[...this.#N];this.#N.clear();let n=[];for(let r of t){let t=r.cancel();this.#m(t.cleanups,e),this.scopeZone.trackProcess(r,e),n.push(t.notification)}return n}#d(t){this.#C||this.parentScope.#g(this),this.#A.clear();let n=e.E(z);return[...Array.from(this.#j,e=>e.settle(n)),this.#T.settle(t)]}#f(e,t,n){let r=this.#A.send(e,t);r&&(r.resume(t),this.scopeZone.trackProcess(r,n))}#p(e){return e.descriptor.completionMode===`structural`?this.#M:this.#N}#m(e,t){let n=e=>{this.spawn(e,{completionMode:`structural`},t)};for(let t of e)t(n)}#h(t,n){if(this.#D.status===`failing`){this.#i(this.#D.draft,e.f,[],{propagateFailure:this.#S},n);return}this.#i(new Y({kind:`scope`,scope:t},()=>t.#_(`failed`).failure),e.f,[],{propagateFailure:this.#S},n)}#g(e){this.#D.status===`failing`&&e.status===`failed`&&e.descriptor.failureMode===`propagate`&&this.#D.draft.capture(e.#_(e.status).failure),this.#k.delete(e)}#_(e){return this.#D}#v(){let e=this.#O;return this.#O=!0,{[Symbol.dispose]:()=>{this.#O=e}}}#y(e){return!this.#O||!e(this.status)}get#b(){return k(this.#M)&&k(this.#k)}get#x(){return this.#b&&k(this.#N)}get#S(){return this.scopeDescriptor.failureMode===`propagate`}get#C(){return this.parentScope===t.#w}static#w=null;#T;#E;#D={status:`running`};#O=!1;#k=new Set;#A=new kt;#j=new Set;#M=new Set;#N=new Set;#P=new Map};function X(e,t){for(let n of e)n(t)}function jt(e){return e===`failing`}function Z(e){return!0}function Mt(e){return e===`canceling`||e===`failing`}var Nt=class t{static create(e,n){let r=new t(e,n);return r.initialize(),r}step(t,n){let r=this.#r(t),i=r.runner();switch(i.status){case`waiting`:return G();case`completed`:return q(e.k(i.stateAs(i.status).result));case`canceled`:return q(e.E(z));case`failed`:return q(e.E(i.stateAs(i.status).failure));case`running`:{let t;try{t=i.stateAs(i.status).next()}catch(t){return Bt(this.#r(r.scopeRef),r.keeper(),V(t),n),q(e.E(i.stateAs(`failed`).failure))}switch(t.kind){case`echo`:return this.#e(r,t,n);case`resonate`:return Tt();case`relic`:return this.#r(r.scopeRef).complete(r.keeper(),t.relic,n),q(e.k(t.relic))}}}}spawn(e,t,n){return this.#r(e).spawn(this.#t(t),{completionMode:`structural`},n)}lookup(e,t){return this.#r(e).lookup(t)}poll(e){return this.#r(e).poll()}wait(e,t){return this.#r(e).wait(t)}forceFailed(e,t,n){this.#r(e).forceFailed(t,n)}scopeState(e){let t=this.#r(e);switch(t.status){case`running`:return{...Q(t),status:`open`};case`closing`:return{...Q(t),status:`closing`};case`canceling`:return{...Q(t),status:`closing`};case`failing`:return{...Q(t),status:`closing`};case`canceled`:case`completed`:case`failed`:return{...Q(t),status:`closed`}}}processState(e){switch(this.#r(e).runner().status){case`running`:return{activity:`running`,status:`open`};case`waiting`:return{activity:`waiting`,status:`open`};case`completed`:case`canceled`:case`failed`:return{status:`closed`}}}scope(e){return this.#r(e).scopeRef}get scopeRoot(){return this.#i}get processRoot(){return this.#i.entryProcess}get isClosed(){return this.#i.isClosed}constructor(e,t){this.entry=e,this.zoneRoot=t}scopeBranch(e,t,n,r,i){let a=It(this.#r(e),this.#t(t),n,r,i);return this.#n(a),a}initialize(){this.#i=At.root(this.#t(this.entry),{failureMode:`contain`},this.zoneRoot,{capture:e.t}),this.#n(this.#i)}#e(t,n,r){let i=this.#r(t.scopeRef),a=t.runner(),[o,s,c]=Pt(n);switch(o){case`bind`:return Ft(i,s.key,s.value),c($),K();case`branch`:{let e=this.scopeBranch(i,s.entry,s.descriptor,i.zone,r),t=this.#r(e);return c({process:t.entryProcess,scope:t}),K()}case`cede`:return c($),wt();case`cancel`:return Rt(i,r),q(e.E(z));case`defer`:return Lt(a,e=>{e(this.#t(s.cleanup))}),c($),K();case`future`:{let e=zt(i);return this.#n(e),c(e.handle()),K()}case`halt`:return Bt(i,t.keeper(),s.failure,r),q(e.E(a.stateAs(`failed`).failure));case`lookup`:return c(Ut(i,s.key)),K();case`poll`:return c(Wt(this.#r(s.future))),K();case`self`:return c(Gt(a)),K();case`settle`:return Vt(this.#r(s.futureSettle),s.result,r),c($),K();case`spawn`:return c(Ht(i,this.#t(s.worker),s.descriptor,r)),K();case`unbind`:return Jt(i,s.key),c($),K();case`wait`:{let n=this.#r(s.future),a=Kt(n);return e.c(a)?(c(a.value),K()):(qt(i,t.keeper(),n,r),G())}case`receive`:{let n=Yt(i,s.messageKey);return e.c(n)?(c(n.value),K()):(Xt(i,t.keeper(),s.messageKey,r),G())}case`send`:return Zt(i,this.#r(s.scope),s.messageKey,s.value,r),c($),K()}}#t(e){return(t,n)=>{let r=Dt.create(t,e,n);return this.#n(r),r.keeper()}}#n(e){}#r(e){return e}#i};function Pt(e){return[e.sigil.kind,e.sigil,e.accept]}function Ft(e,t,n){e.bind(t,n)}function It(e,t,n,r,i){return e.branch(t,n,r,i)}function Lt(e,t){e.defer(t)}function Rt(e,t){e.cancel(t)}function zt(e){return e.createFuture()}function Bt(e,t,n,r){e.halt(t,n,r)}function Vt(e,t,n){e.settle(t)(n)}function Ht(e,t,n,r){return e.spawn(t,n,r)}function Ut(e,t){return e.lookup(t)}function Wt(e){return e.poll()}function Gt(e){return e.selfHandle()}function Kt(e){return e.poll()}function qt(e,t,n,r){e.wait(t,n,r)}function Jt(e,t){e.unbind(t)}function Yt(e,t){return e.tryReceive(t)}function Xt(e,t,n,r){e.receive(t,n,r)}function Zt(e,t,n,r,i){e.send(t,n,r,i)}function Q(e){return{children:e.children,descriptor:e.descriptor,parent:e.parent,zone:e.zone}}var $=void 0;function Qt(e){return{autonomy:e,failureMode:`propagate`}}function $t(e){return en(e)?e.autonomy:null}function en(e){return`autonomy`in e}var tn=class t extends Nt{static createByAutonomy(e,n){let r=new t(e,n);return r.initialize(),r}*startReaperTasks(t){for(let n of St.domains(this.#s))if(n.hasClosingScope)for(let{scope:r,worker:i}of n.createWorkers(e=>this.scopeState(e))){using a=new W(`Out-of-band failures occurred while spawning a reaper adjudication process`);let o=this.spawn(n.scopeRoot,i,a),s=a.drain();if(e.c(s)){this.forceFailed(r,V(s.value),t);continue}yield[r,o]}}constructor(e,t){let n=Ct.root(t.scheduler,e=>this.#a(e)),r=St.root(t.reaper);super(e,{reaperDomain:r,schedulerDomain:n,trackProcess:e=>{n.admitProcess(e,this.processState(e))},trackScope:e=>{r.trackScope(e,this.scopeState(e))}}),this.#s=r}initialize(){super.initialize(),this.#s.setScopeRoot(this.scopeRoot)}scopeBranch(e,t,n,r,i){let a=nn(r),o=$t(n),s=o?this.#r(a,o):rn(a),c=s.zone,l=super.scopeBranch(e,t,n,c,i);return this.#i(l)?(s.rollback(),l):(this.#e(a.reaperDomain,c.reaperDomain,e,l),this.#n(a.schedulerDomain,c.schedulerDomain,l),l)}#e(e,t,n,r){if(t===e){this.#t(e,n,r);return}t.setScopeRoot(r),this.wait(r.exitFuture,()=>{t.close(),this.#o(e,n)})}#t(e,t,n){e.removeLeafScope(t),e.addLeafScope(n),this.wait(n.exitFuture,()=>{e.removeLeafScope(n),this.#o(e,t)})}#n(e,t,n){t!==e&&this.wait(n.exitFuture,()=>{t.close()})}#r(e,t){let n=`scheduler`in t?e.schedulerDomain.nest(t.scheduler,e=>this.#a(e)):e.schedulerDomain,r=`reaper`in t?e.reaperDomain.nest(t.reaper):e.reaperDomain,i=`scheduler`in t?(e,t)=>{try{n.admitProcess(e,this.processState(e))}catch(n){this.forceFailed(this.scope(e),V(n),t)}}:e.trackProcess,a=`reaper`in t?e=>{r.trackScope(e,this.scopeState(e))}:e.trackScope;function o(){n!==e.schedulerDomain&&n.close(),r!==e.reaperDomain&&r.close()}return{rollback:o,zone:{reaperDomain:r,schedulerDomain:n,trackProcess:i,trackScope:a}}}#i(e){return this.scopeState(e).status===`closed`}#a(e){return{step:t=>{switch(this.step(e,t).disposition){case`waiting`:return`waiting`;case`exited`:return`exited`;case`ceded`:return`cede`;case`interpreted`:case`resonated`:return`ready`}}}}#o(e,t){let n=this.scopeState(t);n.status===`closed`||f(n.children)||e.addLeafScope(t)}#s};function nn(e){return e}function rn(e){return{rollback:()=>{},zone:e}}var an=class{stop(){this.#i=!0}driveSyncUnsafely(e){for(;;){let t=this.stepProcess(e);switch(t.disposition){case`interpreted`:case`resonated`:continue;case`ceded`:case`waiting`:case`exited`:return t}}}constructor(e,t){this.pacer=e,this.stepProcess=t}get processor(){return this.#s}#e(){this.#i||this.#a||!this.#r||(this.#a=!0,this.pacer.continueLater(()=>{if(this.#i){this.#a=!1;return}try{this.#t()}finally{this.#a=!1,this.#e()}}))}#t(){let e=this.pacer.beginSlice();for(;this.#r&&!e.shouldYield();)this.#n()}#n(){let[e]=this.#o;for(;;){using t=new W(`Out-of-band failures occurred while processing executor work`);switch(e.step(t)){case`ready`:continue;case`cede`:this.#o.shift(),this.#o.push(e);return;case`waiting`:case`exited`:this.#o.shift();return}}}get#r(){return f(this.#o)}#i=!1;#a=!1;#o=[];#s={admit:e=>{this.#o.push(e),this.#e()}}},on=class{constructor(e){this.roundLimit=e}adjudicate(t){let n=this.#t.getOrInsertComputed(t,()=>({round:0})),{round:r}=n;return n.round+=1,r>=this.roundLimit?j.of(e.d(this.#e(r))):j.of(e.u)}#e(e){return B({round:e,roundLimit:this.roundLimit},`Scope did not finish closing within the executor reaper round limit`)}#t=new WeakMap},sn=class{onSettled(e){return this.lifecycle.onSettled(this.executionScope,e)}constructor(e,t){this.executionScope=e,this.lifecycle=t}get scope(){return this.executionScope}get status(){return this.lifecycle.status(this.executionScope)}};function cn(e){return new ln(e)}var ln=class{constructor(t){this.#s=new an(t(()=>{this.#e()}),t=>this.#c.step(t,{capture:e.t})),this.#c=tn.createByAutonomy(L,{reaper:new on(fn),scheduler:{assign:()=>this.#s.processor}}),this.#l=this.#a(this.#c.scopeRoot),this.#c.wait(this.#l.exitFuture,()=>{this.#s.stop()})}launch(t,n){if(!this.#t(t))return e.u;using r=new W(`Out-of-band failures occurred while spawning a launched scope`);let i=this.#c.spawn(t,un(n),r),a=r.drain();if(e.c(a))return this.#n(t,a.value),e.u;let o=this.#s.driveSyncUnsafely(i).result.right,s=this.#a(o);return e.d(new sn(s,{onSettled:(e,t)=>this.#r(e,t),status:e=>this.#i(e)}))}settle(t,n){return e.c(this.#c.poll(t))?!1:(this.#c.spawn(this.scope,()=>R(t,n),{capture:e.t}),!0)}cancel(t){if(!this.#t(t))return!1;using n=new W(`Out-of-band failures occurred while spawning a cancellation process`);this.#c.spawn(t,F,n);let r=n.drain();return e.c(r)?(this.#n(t,r.value),!1):!0}onSettled(e){return this.#r(this.#l,e)}get scope(){return this.#l}get status(){return this.#i(this.#l)}#e(){using t=new W(`Out-of-band failures occurred while starting a reaper round`);for(let[n,r]of this.#c.startReaperTasks(t))this.#c.wait(r.exitFuture,(t,r)=>{this.#c.scopeState(n).status!==`closed`&&e.X(t,e.y(e.l(()=>e.k(je),t=>e.E(t))),e.C(e=>()=>{this.#c.spawn(n,()=>I(e),r)}),e=>e())})}#t(e){return this.#o(e)&&this.#c.scopeState(e).status===`open`}#n(e,t){using n=new W(`Out-of-band failures occurred while force failing a scope`);this.#c.forceFailed(e,V(t),n)}#r(t,n){let r=this.#c.poll(t.exitFuture);return e.c(r)?(n(dn(r.value)),e.f):this.#c.wait(t.exitFuture,(e,t)=>{try{n(dn(e))}catch(e){t.capture(e)}})}#i(e){return this.#c.scopeState(e).status}#a(e){return this.#u.add(e),e}#o(e){return this.#u.has(e)}#s;#c;#l;#u=new WeakSet};function un(n){return()=>e.X(t.branch(n,{failureMode:`contain`}),j.liftF,j.map(({scope:e})=>e))}function dn(t){return e.w(t)?t.left===z?{kind:`canceled`}:{failure:t.left,kind:`failure`}:{kind:`success`,result:t.right}}var fn=2;function pn(n,r){return e.X(t.branch(n,Qt(r)),j.liftF,j.map(({scope:e})=>e.exitFuture))}exports.all=Ze,exports.autonomy=pn,exports.bind=et,exports.cancel=F,exports.canceledFailure=z,exports.cede=tt,exports.contextKey=o,exports.createExecutor=cn,exports.defer=nt,exports.enclose=yt,exports.evoke=i,exports.externalFailure=B,exports.future=it,exports.guard=ht,exports.halt=I,exports.interruptedFailure=V,exports.lookup=at,exports.messageKey=a,exports.park=L,exports.poll=ot,exports.race=ct,exports.resource=dt,exports.restingWisp=r,exports.resumable=pt,exports.scopeFailure=H,exports.self=bt,exports.settle=R,exports.spawn=rt,exports.stirringWisp=n,exports.unbind=xt,exports.wait=$e;
@@ -0,0 +1,5 @@
1
+ export * from './contracts';
2
+ export * from './executor';
3
+ export * from './failures';
4
+ export * from './primitives';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}