reactor-core-ts 2.1.6 → 3.2.1

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 (269) hide show
  1. package/README.md +927 -658
  2. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.js +12 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPrimitive.js +14 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/toPropertyKey.js +9 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/typeof.js +11 -0
  6. package/dist/context/context-view.d.ts +31 -0
  7. package/dist/context/context-view.d.ts.map +1 -0
  8. package/dist/context/context-view.js +58 -0
  9. package/dist/context/context-view.js.map +1 -0
  10. package/dist/context/context.d.ts +46 -0
  11. package/dist/context/context.d.ts.map +1 -0
  12. package/dist/context/context.js +125 -0
  13. package/dist/context/context.js.map +1 -0
  14. package/dist/context/types.d.ts +7 -0
  15. package/dist/context/types.d.ts.map +1 -0
  16. package/dist/core/boolean-disposable.d.ts +19 -0
  17. package/dist/core/boolean-disposable.d.ts.map +1 -0
  18. package/dist/core/boolean-disposable.js +37 -0
  19. package/dist/core/boolean-disposable.js.map +1 -0
  20. package/dist/core/composite-disposable.d.ts +21 -0
  21. package/dist/core/composite-disposable.d.ts.map +1 -0
  22. package/dist/core/composite-disposable.js +64 -0
  23. package/dist/core/composite-disposable.js.map +1 -0
  24. package/dist/core/demand.d.ts +9 -0
  25. package/dist/core/demand.d.ts.map +1 -0
  26. package/dist/core/demand.js +21 -0
  27. package/dist/core/demand.js.map +1 -0
  28. package/dist/core/disposables.d.ts +12 -0
  29. package/dist/core/disposables.d.ts.map +1 -0
  30. package/dist/core/disposables.js +37 -0
  31. package/dist/core/disposables.js.map +1 -0
  32. package/dist/core/teardown.d.ts +4 -0
  33. package/dist/core/teardown.d.ts.map +1 -0
  34. package/dist/core/types.d.ts +14 -0
  35. package/dist/core/types.d.ts.map +1 -0
  36. package/dist/errors/classes.d.ts +37 -0
  37. package/dist/errors/classes.d.ts.map +1 -0
  38. package/dist/errors/classes.js +53 -0
  39. package/dist/errors/classes.js.map +1 -0
  40. package/dist/errors/exceptions.d.ts +15 -0
  41. package/dist/errors/exceptions.d.ts.map +1 -0
  42. package/dist/errors/helpers.d.ts +9 -0
  43. package/dist/errors/helpers.d.ts.map +1 -0
  44. package/dist/errors/helpers.js +18 -0
  45. package/dist/errors/helpers.js.map +1 -0
  46. package/dist/index.d.ts +17 -2556
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +8 -2
  49. package/dist/internal/abort.d.ts +5 -0
  50. package/dist/internal/abort.d.ts.map +1 -0
  51. package/dist/internal/abort.js +36 -0
  52. package/dist/internal/abort.js.map +1 -0
  53. package/dist/internal/async-queue.d.ts +48 -0
  54. package/dist/internal/async-queue.d.ts.map +1 -0
  55. package/dist/internal/async-queue.js +187 -0
  56. package/dist/internal/async-queue.js.map +1 -0
  57. package/dist/internal/iterable-terminal.d.ts +12 -0
  58. package/dist/internal/iterable-terminal.d.ts.map +1 -0
  59. package/dist/internal/iterable-terminal.js +49 -0
  60. package/dist/internal/iterable-terminal.js.map +1 -0
  61. package/dist/internal/iterable-transform.d.ts +24 -0
  62. package/dist/internal/iterable-transform.d.ts.map +1 -0
  63. package/dist/internal/iterable-transform.js +159 -0
  64. package/dist/internal/iterable-transform.js.map +1 -0
  65. package/dist/internal/iterable.d.ts +23 -0
  66. package/dist/internal/iterable.d.ts.map +1 -0
  67. package/dist/internal/iterable.js +81 -0
  68. package/dist/internal/iterable.js.map +1 -0
  69. package/dist/internal/microtask.d.ts +7 -0
  70. package/dist/internal/microtask.d.ts.map +1 -0
  71. package/dist/internal/microtask.js +19 -0
  72. package/dist/internal/microtask.js.map +1 -0
  73. package/dist/publisher/browser-sources.d.ts +15 -0
  74. package/dist/publisher/browser-sources.d.ts.map +1 -0
  75. package/dist/publisher/browser-sources.js +92 -0
  76. package/dist/publisher/browser-sources.js.map +1 -0
  77. package/dist/publisher/flux-entrypoint.d.ts +7 -0
  78. package/dist/publisher/flux-entrypoint.d.ts.map +1 -0
  79. package/dist/publisher/flux-entrypoint.js +11 -0
  80. package/dist/publisher/flux-entrypoint.js.map +1 -0
  81. package/dist/publisher/flux.d.ts +121 -0
  82. package/dist/publisher/flux.d.ts.map +1 -0
  83. package/dist/publisher/flux.js +697 -0
  84. package/dist/publisher/flux.js.map +1 -0
  85. package/dist/publisher/helpers.d.ts +19 -0
  86. package/dist/publisher/helpers.d.ts.map +1 -0
  87. package/dist/publisher/helpers.js +84 -0
  88. package/dist/publisher/helpers.js.map +1 -0
  89. package/dist/publisher/mono-entrypoint.d.ts +7 -0
  90. package/dist/publisher/mono-entrypoint.d.ts.map +1 -0
  91. package/dist/publisher/mono-entrypoint.js +11 -0
  92. package/dist/publisher/mono-entrypoint.js.map +1 -0
  93. package/dist/publisher/mono.d.ts +72 -0
  94. package/dist/publisher/mono.d.ts.map +1 -0
  95. package/dist/publisher/mono.js +373 -0
  96. package/dist/publisher/mono.js.map +1 -0
  97. package/dist/publisher/operators/aggregate.d.ts +35 -0
  98. package/dist/publisher/operators/aggregate.d.ts.map +1 -0
  99. package/dist/publisher/operators/aggregate.js +217 -0
  100. package/dist/publisher/operators/aggregate.js.map +1 -0
  101. package/dist/publisher/operators/compat/flux.d.ts +56 -0
  102. package/dist/publisher/operators/compat/flux.d.ts.map +1 -0
  103. package/dist/publisher/operators/compat/flux.js +156 -0
  104. package/dist/publisher/operators/compat/flux.js.map +1 -0
  105. package/dist/publisher/operators/compat/mono.d.ts +82 -0
  106. package/dist/publisher/operators/compat/mono.d.ts.map +1 -0
  107. package/dist/publisher/operators/compat/mono.js +125 -0
  108. package/dist/publisher/operators/compat/mono.js.map +1 -0
  109. package/dist/publisher/operators/coordination.d.ts +82 -0
  110. package/dist/publisher/operators/coordination.d.ts.map +1 -0
  111. package/dist/publisher/operators/coordination.js +345 -0
  112. package/dist/publisher/operators/coordination.js.map +1 -0
  113. package/dist/publisher/operators/error.d.ts +17 -0
  114. package/dist/publisher/operators/error.d.ts.map +1 -0
  115. package/dist/publisher/operators/error.js +48 -0
  116. package/dist/publisher/operators/error.js.map +1 -0
  117. package/dist/publisher/operators/flatten.d.ts +19 -0
  118. package/dist/publisher/operators/flatten.d.ts.map +1 -0
  119. package/dist/publisher/operators/flatten.js +127 -0
  120. package/dist/publisher/operators/flatten.js.map +1 -0
  121. package/dist/publisher/operators/lifecycle.d.ts +103 -0
  122. package/dist/publisher/operators/lifecycle.d.ts.map +1 -0
  123. package/dist/publisher/operators/lifecycle.js +237 -0
  124. package/dist/publisher/operators/lifecycle.js.map +1 -0
  125. package/dist/publisher/operators/mono-parity.d.ts +109 -0
  126. package/dist/publisher/operators/mono-parity.d.ts.map +1 -0
  127. package/dist/publisher/operators/mono-parity.js +144 -0
  128. package/dist/publisher/operators/mono-parity.js.map +1 -0
  129. package/dist/publisher/operators/mono.d.ts +30 -0
  130. package/dist/publisher/operators/mono.d.ts.map +1 -0
  131. package/dist/publisher/operators/mono.js +37 -0
  132. package/dist/publisher/operators/mono.js.map +1 -0
  133. package/dist/publisher/operators/register.d.ts +20 -0
  134. package/dist/publisher/operators/register.d.ts.map +1 -0
  135. package/dist/publisher/operators/register.js +23 -0
  136. package/dist/publisher/operators/register.js.map +1 -0
  137. package/dist/publisher/operators/selection.d.ts +25 -0
  138. package/dist/publisher/operators/selection.d.ts.map +1 -0
  139. package/dist/publisher/operators/selection.js +108 -0
  140. package/dist/publisher/operators/selection.js.map +1 -0
  141. package/dist/publisher/operators/side-effect.d.ts +15 -0
  142. package/dist/publisher/operators/side-effect.d.ts.map +1 -0
  143. package/dist/publisher/operators/side-effect.js +56 -0
  144. package/dist/publisher/operators/side-effect.js.map +1 -0
  145. package/dist/publisher/operators/terminal.d.ts +16 -0
  146. package/dist/publisher/operators/terminal.d.ts.map +1 -0
  147. package/dist/publisher/operators/terminal.js +47 -0
  148. package/dist/publisher/operators/terminal.js.map +1 -0
  149. package/dist/publisher/operators/time.d.ts +20 -0
  150. package/dist/publisher/operators/time.d.ts.map +1 -0
  151. package/dist/publisher/operators/time.js +92 -0
  152. package/dist/publisher/operators/time.js.map +1 -0
  153. package/dist/publisher/operators/transform.d.ts +31 -0
  154. package/dist/publisher/operators/transform.d.ts.map +1 -0
  155. package/dist/publisher/operators/transform.js +74 -0
  156. package/dist/publisher/operators/transform.js.map +1 -0
  157. package/dist/publisher/operators/windowing.d.ts +28 -0
  158. package/dist/publisher/operators/windowing.d.ts.map +1 -0
  159. package/dist/publisher/operators/windowing.js +148 -0
  160. package/dist/publisher/operators/windowing.js.map +1 -0
  161. package/dist/publisher/publisher.d.ts +11 -0
  162. package/dist/publisher/publisher.d.ts.map +1 -0
  163. package/dist/publisher/types.d.ts +51 -0
  164. package/dist/publisher/types.d.ts.map +1 -0
  165. package/dist/schedulers/animation-frame-scheduler.d.ts +11 -0
  166. package/dist/schedulers/animation-frame-scheduler.d.ts.map +1 -0
  167. package/dist/schedulers/animation-frame-scheduler.js +30 -0
  168. package/dist/schedulers/animation-frame-scheduler.js.map +1 -0
  169. package/dist/schedulers/base-scheduler.d.ts +28 -0
  170. package/dist/schedulers/base-scheduler.d.ts.map +1 -0
  171. package/dist/schedulers/base-scheduler.js +77 -0
  172. package/dist/schedulers/base-scheduler.js.map +1 -0
  173. package/dist/schedulers/basic-worker.d.ts +22 -0
  174. package/dist/schedulers/basic-worker.d.ts.map +1 -0
  175. package/dist/schedulers/basic-worker.js +71 -0
  176. package/dist/schedulers/basic-worker.js.map +1 -0
  177. package/dist/schedulers/delay-scheduler.d.ts +12 -0
  178. package/dist/schedulers/delay-scheduler.d.ts.map +1 -0
  179. package/dist/schedulers/delay-scheduler.js +17 -0
  180. package/dist/schedulers/delay-scheduler.js.map +1 -0
  181. package/dist/schedulers/disposed.d.ts +4 -0
  182. package/dist/schedulers/disposed.d.ts.map +1 -0
  183. package/dist/schedulers/disposed.js +14 -0
  184. package/dist/schedulers/disposed.js.map +1 -0
  185. package/dist/schedulers/duration.d.ts +8 -0
  186. package/dist/schedulers/duration.d.ts.map +1 -0
  187. package/dist/schedulers/duration.js +11 -0
  188. package/dist/schedulers/duration.js.map +1 -0
  189. package/dist/schedulers/executor-scheduler.d.ts +13 -0
  190. package/dist/schedulers/executor-scheduler.d.ts.map +1 -0
  191. package/dist/schedulers/executor-scheduler.js +43 -0
  192. package/dist/schedulers/executor-scheduler.js.map +1 -0
  193. package/dist/schedulers/immediate-scheduler.d.ts +15 -0
  194. package/dist/schedulers/immediate-scheduler.d.ts.map +1 -0
  195. package/dist/schedulers/immediate-scheduler.js +24 -0
  196. package/dist/schedulers/immediate-scheduler.js.map +1 -0
  197. package/dist/schedulers/index.d.ts +7 -0
  198. package/dist/schedulers/index.d.ts.map +1 -0
  199. package/dist/schedulers/index.js +2 -0
  200. package/dist/schedulers/interval-scheduler.d.ts +12 -0
  201. package/dist/schedulers/interval-scheduler.d.ts.map +1 -0
  202. package/dist/schedulers/interval-scheduler.js +17 -0
  203. package/dist/schedulers/interval-scheduler.js.map +1 -0
  204. package/dist/schedulers/macro-scheduler.d.ts +19 -0
  205. package/dist/schedulers/macro-scheduler.d.ts.map +1 -0
  206. package/dist/schedulers/macro-scheduler.js +30 -0
  207. package/dist/schedulers/macro-scheduler.js.map +1 -0
  208. package/dist/schedulers/microtask-scheduler.d.ts +11 -0
  209. package/dist/schedulers/microtask-scheduler.d.ts.map +1 -0
  210. package/dist/schedulers/microtask-scheduler.js +34 -0
  211. package/dist/schedulers/microtask-scheduler.js.map +1 -0
  212. package/dist/schedulers/schedulers.d.ts +39 -0
  213. package/dist/schedulers/schedulers.d.ts.map +1 -0
  214. package/dist/schedulers/schedulers.js +83 -0
  215. package/dist/schedulers/schedulers.js.map +1 -0
  216. package/dist/schedulers/timeout-scheduler.d.ts +11 -0
  217. package/dist/schedulers/timeout-scheduler.d.ts.map +1 -0
  218. package/dist/schedulers/types.d.ts +35 -0
  219. package/dist/schedulers/types.d.ts.map +1 -0
  220. package/dist/signal/signal-type.d.ts +26 -0
  221. package/dist/signal/signal-type.d.ts.map +1 -0
  222. package/dist/signal/signal-type.js +31 -0
  223. package/dist/signal/signal-type.js.map +1 -0
  224. package/dist/signal/signal.d.ts +33 -0
  225. package/dist/signal/signal.d.ts.map +1 -0
  226. package/dist/signal/signal.js +70 -0
  227. package/dist/signal/signal.js.map +1 -0
  228. package/dist/sinks/index.d.ts +7 -0
  229. package/dist/sinks/index.d.ts.map +1 -0
  230. package/dist/sinks/index.js +2 -0
  231. package/dist/sinks/many.d.ts +66 -0
  232. package/dist/sinks/many.d.ts.map +1 -0
  233. package/dist/sinks/many.js +193 -0
  234. package/dist/sinks/many.js.map +1 -0
  235. package/dist/sinks/one.d.ts +41 -0
  236. package/dist/sinks/one.d.ts.map +1 -0
  237. package/dist/sinks/one.js +144 -0
  238. package/dist/sinks/one.js.map +1 -0
  239. package/dist/sinks/specs.d.ts +25 -0
  240. package/dist/sinks/specs.d.ts.map +1 -0
  241. package/dist/sinks/specs.js +126 -0
  242. package/dist/sinks/specs.js.map +1 -0
  243. package/dist/sinks/subscribers.d.ts +16 -0
  244. package/dist/sinks/subscribers.d.ts.map +1 -0
  245. package/dist/sinks/subscribers.js +32 -0
  246. package/dist/sinks/subscribers.js.map +1 -0
  247. package/dist/sinks/types.d.ts +137 -0
  248. package/dist/sinks/types.d.ts.map +1 -0
  249. package/dist/sinks/types.js +58 -0
  250. package/dist/sinks/types.js.map +1 -0
  251. package/dist/subscription/core-subscriber.d.ts +12 -0
  252. package/dist/subscription/core-subscriber.d.ts.map +1 -0
  253. package/dist/subscription/iterable-subscription.d.ts +64 -0
  254. package/dist/subscription/iterable-subscription.d.ts.map +1 -0
  255. package/dist/subscription/iterable-subscription.js +281 -0
  256. package/dist/subscription/iterable-subscription.js.map +1 -0
  257. package/dist/subscription/reactive-streams.d.ts +8 -0
  258. package/dist/subscription/reactive-streams.d.ts.map +1 -0
  259. package/dist/subscription/reactive-streams.js +0 -0
  260. package/dist/subscription/subscriber.d.ts +17 -0
  261. package/dist/subscription/subscriber.d.ts.map +1 -0
  262. package/dist/subscription/subscription.d.ts +12 -0
  263. package/dist/subscription/subscription.d.ts.map +1 -0
  264. package/package.json +99 -33
  265. package/LICENSE.md +0 -56
  266. package/dist/index.d.mts +0 -2557
  267. package/dist/index.js.map +0 -1
  268. package/dist/index.mjs +0 -2
  269. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,64 @@
1
+ import type { Context } from "../context/context.js";
2
+ import type { Flux } from "../publisher/flux.js";
3
+ import type { Subscriber } from "./subscriber.js";
4
+ import type { Subscription } from "./subscription.js";
5
+ /** Subscription implementation that drains a Flux only when demand is requested. */
6
+ export declare class IterableSubscription<T> implements Subscription {
7
+ /** Abort controller used to cancel the active source iterator. */
8
+ private readonly controller;
9
+ /** Lazily created async iterator over the backing Flux. */
10
+ private asyncIterator;
11
+ /** Lazily created synchronous iterator over the backing Flux. */
12
+ private syncIterator;
13
+ /** Tracks whether the source iterator has been assembled. */
14
+ private started;
15
+ /** Stores a synchronous source assembly failure until it can be signalled. */
16
+ private startFailure;
17
+ /** Tracks whether source assembly failed synchronously. */
18
+ private hasStartFailure;
19
+ /** Prefetched async result used to detect completion with zero demand. */
20
+ private pendingAsyncNext;
21
+ /** Prefetched sync result used to detect completion with zero demand. */
22
+ private pendingSyncNext;
23
+ /** Outstanding downstream demand. */
24
+ private requested;
25
+ /** Guards against concurrent drain loops. */
26
+ private draining;
27
+ /** Tracks downstream cancellation. */
28
+ private cancelled;
29
+ /** Tracks terminal completion or failure delivery. */
30
+ private terminated;
31
+ /** Source Flux drained by this subscription. */
32
+ private readonly flux;
33
+ /** Downstream subscriber receiving signals. */
34
+ private readonly subscriber;
35
+ /** Context used for the source iteration. */
36
+ private readonly context;
37
+ /** Creates a subscription for the provided Flux and subscriber. */
38
+ constructor(flux: Flux<T>, subscriber: Subscriber<T>, context: Context);
39
+ /** Starts source assembly without pulling any values from it. */
40
+ start(): void;
41
+ /** Delivers a synchronous source assembly failure after `onSubscribe`. */
42
+ deliverStartFailure(): void;
43
+ /** Requests more values from the backing iterator. */
44
+ request(n: number): void;
45
+ /** Cancels iteration and closes upstream resources. */
46
+ cancel(): void;
47
+ /** Drains the source while there is outstanding demand. */
48
+ private drain;
49
+ /** Drains a synchronous source without per-item promise allocation. */
50
+ private drainSync;
51
+ /** Returns true after delivering a terminal result. */
52
+ private deliverResult;
53
+ /** Returns the pending prefetched async result or asks the async iterator for the next item. */
54
+ private nextAsyncResult;
55
+ /** Returns the pending prefetched sync result or asks the sync iterator for the next item. */
56
+ private nextSyncResult;
57
+ /** Prefetches one item to discover terminal completion without extra demand. */
58
+ private lookAheadForTermination;
59
+ /** Prefetches one synchronous item to discover terminal completion without extra demand. */
60
+ private lookAheadForSyncTermination;
61
+ /** Closes active iterators and ignores cleanup failures after cancellation. */
62
+ private closeIterators;
63
+ }
64
+ //# sourceMappingURL=iterable-subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable-subscription.d.ts","sourceRoot":"","sources":["../../src/subscription/iterable-subscription.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAGlD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAEjE,oFAAoF;AACpF,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,YAAY;IACxD,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,2DAA2D;IAC3D,OAAO,CAAC,aAAa,CAA+B;IACpD,iEAAiE;IACjE,OAAO,CAAC,YAAY,CAA0B;IAC9C,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAS;IACxB,8EAA8E;IAC9E,OA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../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/defineProperty.js";
2
+ import { doneResult, isAsyncIterable, resolvedDoneResult } from "../internal/iterable.js";
3
+ import { scheduleMicrotask } from "../internal/microtask.js";
4
+ import { addCap, normalizeRequest } from "../core/demand.js";
5
+ //#region src/subscription/iterable-subscription.ts
6
+ /**
7
+ * @packageDocumentation
8
+ * Reactive Streams subscription and subscriber contracts.
9
+ */
10
+ /** Subscription implementation that drains a Flux only when demand is requested. */
11
+ var IterableSubscription = class {
12
+ /** Creates a subscription for the provided Flux and subscriber. */
13
+ constructor(flux, subscriber, context) {
14
+ _defineProperty(
15
+ this,
16
+ /** Abort controller used to cancel the active source iterator. */
17
+ "controller",
18
+ new AbortController()
19
+ );
20
+ _defineProperty(
21
+ this,
22
+ /** Lazily created async iterator over the backing Flux. */
23
+ "asyncIterator",
24
+ void 0
25
+ );
26
+ _defineProperty(
27
+ this,
28
+ /** Lazily created synchronous iterator over the backing Flux. */
29
+ "syncIterator",
30
+ void 0
31
+ );
32
+ _defineProperty(
33
+ this,
34
+ /** Tracks whether the source iterator has been assembled. */
35
+ "started",
36
+ false
37
+ );
38
+ _defineProperty(
39
+ this,
40
+ /** Stores a synchronous source assembly failure until it can be signalled. */
41
+ "startFailure",
42
+ void 0
43
+ );
44
+ _defineProperty(
45
+ this,
46
+ /** Tracks whether source assembly failed synchronously. */
47
+ "hasStartFailure",
48
+ false
49
+ );
50
+ _defineProperty(
51
+ this,
52
+ /** Prefetched async result used to detect completion with zero demand. */
53
+ "pendingAsyncNext",
54
+ void 0
55
+ );
56
+ _defineProperty(
57
+ this,
58
+ /** Prefetched sync result used to detect completion with zero demand. */
59
+ "pendingSyncNext",
60
+ void 0
61
+ );
62
+ _defineProperty(
63
+ this,
64
+ /** Outstanding downstream demand. */
65
+ "requested",
66
+ 0
67
+ );
68
+ _defineProperty(
69
+ this,
70
+ /** Guards against concurrent drain loops. */
71
+ "draining",
72
+ false
73
+ );
74
+ _defineProperty(
75
+ this,
76
+ /** Tracks downstream cancellation. */
77
+ "cancelled",
78
+ false
79
+ );
80
+ _defineProperty(
81
+ this,
82
+ /** Tracks terminal completion or failure delivery. */
83
+ "terminated",
84
+ false
85
+ );
86
+ _defineProperty(
87
+ this,
88
+ /** Source Flux drained by this subscription. */
89
+ "flux",
90
+ void 0
91
+ );
92
+ _defineProperty(
93
+ this,
94
+ /** Downstream subscriber receiving signals. */
95
+ "subscriber",
96
+ void 0
97
+ );
98
+ _defineProperty(
99
+ this,
100
+ /** Context used for the source iteration. */
101
+ "context",
102
+ void 0
103
+ );
104
+ this.flux = flux;
105
+ this.subscriber = subscriber;
106
+ this.context = context;
107
+ }
108
+ /** Starts source assembly without pulling any values from it. */
109
+ start() {
110
+ if (this.started || this.cancelled || this.terminated) return;
111
+ this.started = true;
112
+ try {
113
+ const source = this.flux.iterate(this.controller.signal, this.context);
114
+ if (isAsyncIterable(source)) this.asyncIterator = source[Symbol.asyncIterator]();
115
+ else this.syncIterator = source[Symbol.iterator]();
116
+ } catch (error) {
117
+ this.startFailure = error;
118
+ this.hasStartFailure = true;
119
+ }
120
+ }
121
+ /** Delivers a synchronous source assembly failure after `onSubscribe`. */
122
+ deliverStartFailure() {
123
+ if (!this.hasStartFailure || this.cancelled || this.terminated) return;
124
+ this.hasStartFailure = false;
125
+ this.terminated = true;
126
+ this.subscriber.onError(this.startFailure);
127
+ }
128
+ /** Requests more values from the backing iterator. */
129
+ request(n) {
130
+ if (this.cancelled || this.terminated) return;
131
+ let request;
132
+ try {
133
+ request = normalizeRequest(n);
134
+ } catch (error) {
135
+ this.cancel();
136
+ this.subscriber.onError(error);
137
+ return;
138
+ }
139
+ this.requested = addCap(this.requested, request);
140
+ if (this.hasStartFailure) {
141
+ this.deliverStartFailure();
142
+ return;
143
+ }
144
+ this.drain();
145
+ }
146
+ /** Cancels iteration and closes upstream resources. */
147
+ cancel() {
148
+ if (this.cancelled || this.terminated) return;
149
+ this.cancelled = true;
150
+ this.controller.abort();
151
+ this.closeIterators();
152
+ }
153
+ /** Drains the source while there is outstanding demand. */
154
+ async drain() {
155
+ if (this.draining) return;
156
+ this.draining = true;
157
+ try {
158
+ this.start();
159
+ if (this.hasStartFailure) {
160
+ this.deliverStartFailure();
161
+ return;
162
+ }
163
+ if (this.syncIterator) {
164
+ this.drainSync();
165
+ return;
166
+ }
167
+ while (!this.cancelled && !this.terminated && this.requested > 0) {
168
+ const result = await this.nextAsyncResult();
169
+ if (this.cancelled || this.terminated) return;
170
+ if (this.deliverResult(result)) return;
171
+ }
172
+ } catch (error) {
173
+ if (!this.cancelled && !this.terminated) {
174
+ this.terminated = true;
175
+ this.subscriber.onError(error);
176
+ }
177
+ } finally {
178
+ this.draining = false;
179
+ if (!this.cancelled && !this.terminated && this.requested > 0) scheduleMicrotask(() => {
180
+ this.drain();
181
+ });
182
+ else if (!this.cancelled && !this.terminated && this.requested === 0) this.lookAheadForTermination();
183
+ }
184
+ }
185
+ /** Drains a synchronous source without per-item promise allocation. */
186
+ drainSync() {
187
+ while (!this.cancelled && !this.terminated && this.requested > 0) {
188
+ const result = this.nextSyncResult();
189
+ if (this.cancelled || this.terminated) return;
190
+ if (this.deliverResult(result)) return;
191
+ }
192
+ }
193
+ /** Returns true after delivering a terminal result. */
194
+ deliverResult(result) {
195
+ if (result.done) {
196
+ this.terminated = true;
197
+ this.subscriber.onComplete();
198
+ return true;
199
+ }
200
+ if (this.requested !== Number.POSITIVE_INFINITY) this.requested -= 1;
201
+ try {
202
+ this.subscriber.onNext(result.value);
203
+ } catch (error) {
204
+ this.cancel();
205
+ this.subscriber.onError(error);
206
+ return true;
207
+ }
208
+ return false;
209
+ }
210
+ /** Returns the pending prefetched async result or asks the async iterator for the next item. */
211
+ nextAsyncResult() {
212
+ if (this.pendingAsyncNext) {
213
+ const pending = this.pendingAsyncNext;
214
+ this.pendingAsyncNext = void 0;
215
+ return pending;
216
+ }
217
+ return this.asyncIterator?.next() ?? resolvedDoneResult();
218
+ }
219
+ /** Returns the pending prefetched sync result or asks the sync iterator for the next item. */
220
+ nextSyncResult() {
221
+ if (this.pendingSyncNext) {
222
+ const pending = this.pendingSyncNext;
223
+ this.pendingSyncNext = void 0;
224
+ return pending;
225
+ }
226
+ return this.syncIterator?.next() ?? doneResult();
227
+ }
228
+ /** Prefetches one item to discover terminal completion without extra demand. */
229
+ lookAheadForTermination() {
230
+ if (this.syncIterator) {
231
+ this.lookAheadForSyncTermination();
232
+ return;
233
+ }
234
+ if (!this.asyncIterator || this.pendingAsyncNext) return;
235
+ const pending = this.asyncIterator.next();
236
+ this.pendingAsyncNext = pending;
237
+ pending.then((result) => {
238
+ if (this.pendingAsyncNext !== pending || this.cancelled || this.terminated) return;
239
+ if (result.done) {
240
+ this.pendingAsyncNext = void 0;
241
+ this.terminated = true;
242
+ this.subscriber.onComplete();
243
+ }
244
+ }, (error) => {
245
+ if (this.pendingAsyncNext !== pending || this.cancelled || this.terminated) return;
246
+ this.pendingAsyncNext = void 0;
247
+ this.terminated = true;
248
+ this.subscriber.onError(error);
249
+ });
250
+ }
251
+ /** Prefetches one synchronous item to discover terminal completion without extra demand. */
252
+ lookAheadForSyncTermination() {
253
+ if (!this.syncIterator || this.pendingSyncNext) return;
254
+ try {
255
+ const result = this.syncIterator.next();
256
+ if (this.cancelled || this.terminated) return;
257
+ if (result.done) {
258
+ this.terminated = true;
259
+ this.subscriber.onComplete();
260
+ } else this.pendingSyncNext = result;
261
+ } catch (error) {
262
+ if (!this.cancelled && !this.terminated) {
263
+ this.terminated = true;
264
+ this.subscriber.onError(error);
265
+ }
266
+ }
267
+ }
268
+ /** Closes active iterators and ignores cleanup failures after cancellation. */
269
+ closeIterators() {
270
+ try {
271
+ this.asyncIterator?.return?.();
272
+ } catch {}
273
+ try {
274
+ this.syncIterator?.return?.();
275
+ } catch {}
276
+ }
277
+ };
278
+ //#endregion
279
+ export { IterableSubscription };
280
+
281
+ //# sourceMappingURL=iterable-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable-subscription.js","names":[],"sources":["../../src/subscription/iterable-subscription.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Reactive Streams subscription and subscriber contracts.\n */\nimport {addCap, normalizeRequest} from \"@/core/demand.js\";\nimport type {Context} from \"@/context/context.js\";\nimport {doneResult, isAsyncIterable, resolvedDoneResult} from \"@/internal/iterable.js\";\nimport {scheduleMicrotask} from \"@/internal/microtask.js\";\nimport type {Flux} from \"@/publisher/flux.js\";\nimport type {Subscriber} from \"@/subscription/subscriber.js\";\nimport type {Subscription} from \"@/subscription/subscription.js\";\n\n/** Subscription implementation that drains a Flux only when demand is requested. */\nexport class IterableSubscription<T> implements Subscription {\n /** Abort controller used to cancel the active source iterator. */\n private readonly controller = new AbortController();\n /** Lazily created async iterator over the backing Flux. */\n private asyncIterator: AsyncIterator<T> | undefined;\n /** Lazily created synchronous iterator over the backing Flux. */\n private syncIterator: Iterator<T> | undefined;\n /** Tracks whether the source iterator has been assembled. */\n private started = false;\n /** Stores a synchronous source assembly failure until it can be signalled. */\n private startFailure: unknown;\n /** Tracks whether source assembly failed synchronously. */\n private hasStartFailure = false;\n /** Prefetched async result used to detect completion with zero demand. */\n private pendingAsyncNext: Promise<IteratorResult<T>> | undefined;\n /** Prefetched sync result used to detect completion with zero demand. */\n private pendingSyncNext: IteratorResult<T> | undefined;\n /** Outstanding downstream demand. */\n private requested = 0;\n /** Guards against concurrent drain loops. */\n private draining = false;\n /** Tracks downstream cancellation. */\n private cancelled = false;\n /** Tracks terminal completion or failure delivery. */\n private terminated = false;\n /** Source Flux drained by this subscription. */\n private readonly flux: Flux<T>;\n /** Downstream subscriber receiving signals. */\n private readonly subscriber: Subscriber<T>;\n /** Context used for the source iteration. */\n private readonly context: Context;\n\n /** Creates a subscription for the provided Flux and subscriber. */\n public constructor(flux: Flux<T>, subscriber: Subscriber<T>, context: Context) {\n this.flux = flux;\n this.subscriber = subscriber;\n this.context = context;\n }\n\n /** Starts source assembly without pulling any values from it. */\n public start(): void {\n if (this.started || this.cancelled || this.terminated) {\n return;\n }\n this.started = true;\n try {\n const source = this.flux.iterate(this.controller.signal, this.context);\n if (isAsyncIterable<T>(source)) {\n this.asyncIterator = source[Symbol.asyncIterator]();\n } else {\n this.syncIterator = source[Symbol.iterator]();\n }\n } catch (error) {\n this.startFailure = error;\n this.hasStartFailure = true;\n }\n }\n\n /** Delivers a synchronous source assembly failure after `onSubscribe`. */\n public deliverStartFailure(): void {\n if (!this.hasStartFailure || this.cancelled || this.terminated) {\n return;\n }\n this.hasStartFailure = false;\n this.terminated = true;\n this.subscriber.onError(this.startFailure);\n }\n\n /** Requests more values from the backing iterator. */\n public request(n: number): void {\n if (this.cancelled || this.terminated) {\n return;\n }\n let request: number;\n try {\n request = normalizeRequest(n);\n } catch (error) {\n this.cancel();\n this.subscriber.onError(error);\n return;\n }\n this.requested = addCap(this.requested, request);\n if (this.hasStartFailure) {\n this.deliverStartFailure();\n return;\n }\n void this.drain();\n }\n\n /** Cancels iteration and closes upstream resources. */\n public cancel(): void {\n if (this.cancelled || this.terminated) {\n return;\n }\n this.cancelled = true;\n this.controller.abort();\n this.closeIterators();\n }\n\n /** Drains the source while there is outstanding demand. */\n private async drain(): Promise<void> {\n if (this.draining) {\n return;\n }\n this.draining = true;\n try {\n this.start();\n if (this.hasStartFailure) {\n this.deliverStartFailure();\n return;\n }\n if (this.syncIterator) {\n this.drainSync();\n return;\n }\n while (!this.cancelled && !this.terminated && this.requested > 0) {\n const result = await this.nextAsyncResult();\n if (this.cancelled || this.terminated) {\n return;\n }\n if (this.deliverResult(result)) {\n return;\n }\n }\n } catch (error) {\n if (!this.cancelled && !this.terminated) {\n this.terminated = true;\n this.subscriber.onError(error);\n }\n } finally {\n this.draining = false;\n if (!this.cancelled && !this.terminated && this.requested > 0) {\n scheduleMicrotask(() => {\n void this.drain();\n });\n } else if (!this.cancelled && !this.terminated && this.requested === 0) {\n this.lookAheadForTermination();\n }\n }\n }\n\n /** Drains a synchronous source without per-item promise allocation. */\n private drainSync(): void {\n while (!this.cancelled && !this.terminated && this.requested > 0) {\n const result = this.nextSyncResult();\n if (this.cancelled || this.terminated) {\n return;\n }\n if (this.deliverResult(result)) {\n return;\n }\n }\n }\n\n /** Returns true after delivering a terminal result. */\n private deliverResult(result: IteratorResult<T>): boolean {\n if (result.done) {\n this.terminated = true;\n this.subscriber.onComplete();\n return true;\n }\n if (this.requested !== Number.POSITIVE_INFINITY) {\n this.requested -= 1;\n }\n try {\n this.subscriber.onNext(result.value);\n } catch (error) {\n this.cancel();\n this.subscriber.onError(error);\n return true;\n }\n return false;\n }\n\n /** Returns the pending prefetched async result or asks the async iterator for the next item. */\n private nextAsyncResult(): Promise<IteratorResult<T>> {\n if (this.pendingAsyncNext) {\n const pending = this.pendingAsyncNext;\n this.pendingAsyncNext = undefined;\n return pending;\n }\n return this.asyncIterator?.next() ?? resolvedDoneResult<T>();\n }\n\n /** Returns the pending prefetched sync result or asks the sync iterator for the next item. */\n private nextSyncResult(): IteratorResult<T> {\n if (this.pendingSyncNext) {\n const pending = this.pendingSyncNext;\n this.pendingSyncNext = undefined;\n return pending;\n }\n return this.syncIterator?.next() ?? doneResult<T>();\n }\n\n /** Prefetches one item to discover terminal completion without extra demand. */\n private lookAheadForTermination(): void {\n if (this.syncIterator) {\n this.lookAheadForSyncTermination();\n return;\n }\n if (!this.asyncIterator || this.pendingAsyncNext) {\n return;\n }\n const pending = this.asyncIterator.next();\n this.pendingAsyncNext = pending;\n pending.then(\n result => {\n if (this.pendingAsyncNext !== pending || this.cancelled || this.terminated) {\n return;\n }\n if (result.done) {\n this.pendingAsyncNext = undefined;\n this.terminated = true;\n this.subscriber.onComplete();\n }\n },\n error => {\n if (this.pendingAsyncNext !== pending || this.cancelled || this.terminated) {\n return;\n }\n this.pendingAsyncNext = undefined;\n this.terminated = true;\n this.subscriber.onError(error);\n }\n );\n }\n\n /** Prefetches one synchronous item to discover terminal completion without extra demand. */\n private lookAheadForSyncTermination(): void {\n if (!this.syncIterator || this.pendingSyncNext) {\n return;\n }\n try {\n const result = this.syncIterator.next();\n if (this.cancelled || this.terminated) {\n return;\n }\n if (result.done) {\n this.terminated = true;\n this.subscriber.onComplete();\n } else {\n this.pendingSyncNext = result;\n }\n } catch (error) {\n if (!this.cancelled && !this.terminated) {\n this.terminated = true;\n this.subscriber.onError(error);\n }\n }\n }\n\n /** Closes active iterators and ignores cleanup failures after cancellation. */\n private closeIterators(): void {\n try {\n void this.asyncIterator?.return?.();\n } catch {\n // cancellation best-effort cleanup\n }\n try {\n this.syncIterator?.return?.();\n } catch {\n // cancellation best-effort cleanup\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,IAAa,uBAAb,MAA6D;;CAiCzD,YAAmB,MAAe,YAA2B,SAAkB;;;;GA/B/E;GAA8B,IAAI,gBAAgB;;;;;GAElD;;;;;;GAEA;;;;;;GAEA;GAAkB;;;;;GAElB;;;;;;GAEA;GAA0B;;;;;GAE1B;;;;;;GAEA;;;;;;GAEA;GAAoB;;;;;GAEpB;GAAmB;;;;;GAEnB;GAAoB;;;;;GAEpB;GAAqB;;;;;GAErB;;;;;;GAEA;;;;;;GAEA;;;EAII,KAAK,OAAO;EACZ,KAAK,aAAa;EAClB,KAAK,UAAU;CACnB;;CAGA,QAAqB;EACjB,IAAI,KAAK,WAAW,KAAK,aAAa,KAAK,YACvC;EAEJ,KAAK,UAAU;EACf,IAAI;GACA,MAAM,SAAS,KAAK,KAAK,QAAQ,KAAK,WAAW,QAAQ,KAAK,OAAO;GACrE,IAAI,gBAAmB,MAAM,GACzB,KAAK,gBAAgB,OAAO,OAAO,cAAc,CAAC;QAElD,KAAK,eAAe,OAAO,OAAO,SAAS,CAAC;EAEpD,SAAS,OAAO;GACZ,KAAK,eAAe;GACpB,KAAK,kBAAkB;EAC3B;CACJ;;CAGA,sBAAmC;EAC/B,IAAI,CAAC,KAAK,mBAAmB,KAAK,aAAa,KAAK,YAChD;EAEJ,KAAK,kBAAkB;EACvB,KAAK,aAAa;EAClB,KAAK,WA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K,aAAa;GAClB,KAAK,WAAW,QAAQ,KAAK;EACjC,CACJ;CACJ;;CAGA,8BAA4C;EACxC,IAAI,CAAC,KAAK,gBAAgB,KAAK,iBAC3B;EAEJ,IAAI;GACA,MAAM,SAAS,KAAK,aAAa,KAAK;GACtC,IAAI,KAAK,aAAa,KAAK,YACvB;GAEJ,IAAI,OAAO,MAAM;IACb,KAAK,aAAa;IAClB,KAAK,WAAW,WAAW;GAC/B,OACI,KAAK,kBAAkB;EAE/B,SAAS,OAAO;GACZ,IAAI,CAAC,KAAK,aAAa,CAAC,KAAK,YAAY;IACrC,KAAK,aAAa;IAClB,KAAK,WAAW,QAAQ,KAAK;GACjC;EACJ;CACJ;;CAGA,iBAA+B;EAC3B,IAAI;GACA,AAAK,KAAK,eAAe,SAAS;EACtC,QAAQ,CAER;EACA,IAAI;GACA,KAAK,cAAc,SAAS;EAChC,QAAQ,CAER;CACJ;AACJ"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Reactive Streams type-only public entrypoint.
4
+ */
5
+ export type { Publisher } from "../publisher/publisher.js";
6
+ export type { Subscriber } from "./subscriber.js";
7
+ export type { Subscription } from "./subscription.js";
8
+ //# sourceMappingURL=reactive-streams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-streams.d.ts","sourceRoot":"","sources":["../../src/subscription/reactive-streams.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAC7D,YAAY,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC"}
File without changes
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Reactive Streams subscriber contract.
4
+ */
5
+ import type { Subscription } from "./subscription.js";
6
+ /** Reactive Streams subscriber receiving subscription, data and terminal signals. */
7
+ export interface Subscriber<T> {
8
+ /** Called once with the upstream subscription before any other signal. */
9
+ onSubscribe(subscription: Subscription): void;
10
+ /** Called for each emitted item while demand is available. */
11
+ onNext(value: T): void;
12
+ /** Called once when the sequence fails. */
13
+ onError(error: unknown): void;
14
+ /** Called once when the sequence completes successfully. */
15
+ onComplete(): void;
16
+ }
17
+ //# sourceMappingURL=subscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../src/subscription/subscriber.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAEjE,qFAAqF;AACrF,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,0EAA0E;IAC1E,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAE9C,8DAA8D;IAC9D,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAEvB,2CAA2C;IAC3C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAE9B,4DAA4D;IAC5D,UAAU,IAAI,IAAI,CAAC;CACtB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Reactive Streams subscription contract.
4
+ */
5
+ /** Reactive Streams subscription used to signal demand and cancellation. */
6
+ export interface Subscription {
7
+ /** Requests a strictly positive amount of items from the upstream publisher. */
8
+ request(n: number): void;
9
+ /** Cancels the subscription and releases upstream resources. */
10
+ cancel(): void;
11
+ }
12
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/subscription/subscription.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IACzB,gFAAgF;IAChF,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,gEAAgE;IAChE,MAAM,IAAI,IAAI,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,24 +1,9 @@
1
1
  {
2
2
  "name": "reactor-core-ts",
3
- "version": "2.1.6",
4
- "description": "A TypeScript implementation of Reactive Streams, inspired by Project Reactor. Provides Flux and Mono publishers with full backpressure support, a suite of composable operators, programmable Sinks, and pluggable Schedulers.",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- },
15
- "scripts": {
16
- "build": "npm run test && tsup src/index.ts",
17
- "start": "tsx src/start.ts",
18
- "start:watch": "tsx watch src/start.ts",
19
- "test": "jest --config jest.config.ts",
20
- "test:watch": "jest --config jest.config.ts --watch"
21
- },
3
+ "version": "3.2.1",
4
+ "description": "Browser-first TypeScript implementation inspired by Project Reactor Core.",
5
+ "license": "LGPL-3.0-only",
6
+ "author": "CKATEPTb",
22
7
  "repository": {
23
8
  "type": "git",
24
9
  "url": "https://github.com/CKATEPTb/reactor-core-ts.git"
@@ -32,21 +17,102 @@
32
17
  "spring",
33
18
  "java",
34
19
  "typescript",
35
- "backpressure"
20
+ "backpressure",
21
+ "reactor",
22
+ "flux",
23
+ "mono",
24
+ "browser"
36
25
  ],
37
- "author": "CKATEPTb",
38
- "license": "LGPL-3.0-only",
39
- "devDependencies": {
40
- "@types/jest": "^29.5.14",
41
- "@types/node": "^22.15.17",
42
- "jest": "^29.7.0",
43
- "ts-jest": "^29.3.2",
44
- "ts-node": "^10.9.2",
45
- "tsup": "^8.4.0",
46
- "tsx": "^4.19.4",
47
- "typescript": "^5.8.3"
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "browser": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "browser": "./dist/index.js",
35
+ "import": "./dist/index.js",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "./flux": {
39
+ "types": "./dist/publisher/flux-entrypoint.d.ts",
40
+ "browser": "./dist/publisher/flux-entrypoint.js",
41
+ "import": "./dist/publisher/flux-entrypoint.js",
42
+ "default": "./dist/publisher/flux-entrypoint.js"
43
+ },
44
+ "./mono": {
45
+ "types": "./dist/publisher/mono-entrypoint.d.ts",
46
+ "browser": "./dist/publisher/mono-entrypoint.js",
47
+ "import": "./dist/publisher/mono-entrypoint.js",
48
+ "default": "./dist/publisher/mono-entrypoint.js"
49
+ },
50
+ "./sinks": {
51
+ "types": "./dist/sinks/index.d.ts",
52
+ "browser": "./dist/sinks/index.js",
53
+ "import": "./dist/sinks/index.js",
54
+ "default": "./dist/sinks/index.js"
55
+ },
56
+ "./schedulers": {
57
+ "types": "./dist/schedulers/index.d.ts",
58
+ "browser": "./dist/schedulers/index.js",
59
+ "import": "./dist/schedulers/index.js",
60
+ "default": "./dist/schedulers/index.js"
61
+ },
62
+ "./reactive-streams": {
63
+ "types": "./dist/subscription/reactive-streams.d.ts",
64
+ "browser": "./dist/subscription/reactive-streams.js",
65
+ "import": "./dist/subscription/reactive-streams.js",
66
+ "default": "./dist/subscription/reactive-streams.js"
67
+ },
68
+ "./package.json": "./package.json"
69
+ },
70
+ "typesVersions": {
71
+ "*": {
72
+ "flux": [
73
+ "dist/publisher/flux-entrypoint.d.ts"
74
+ ],
75
+ "mono": [
76
+ "dist/publisher/mono-entrypoint.d.ts"
77
+ ],
78
+ "schedulers": [
79
+ "dist/schedulers/index.d.ts"
80
+ ],
81
+ "sinks": [
82
+ "dist/sinks/index.d.ts"
83
+ ],
84
+ "reactive-streams": [
85
+ "dist/subscription/reactive-streams.d.ts"
86
+ ]
87
+ }
48
88
  },
49
89
  "files": [
50
- "dist"
51
- ]
90
+ "dist",
91
+ "README.md"
92
+ ],
93
+ "sideEffects": [
94
+ "./src/publisher/flux-entrypoint.ts",
95
+ "./src/publisher/mono-entrypoint.ts",
96
+ "./src/publisher/operators/register.ts",
97
+ "./src/publisher/operators/**/*.ts",
98
+ "./dist/index.js",
99
+ "./dist/publisher/flux-entrypoint.js",
100
+ "./dist/publisher/mono-entrypoint.js",
101
+ "./dist/publisher/operators/register.js",
102
+ "./dist/publisher/operators/**/*.js"
103
+ ],
104
+ "publishConfig": {
105
+ "access": "public"
106
+ },
107
+ "scripts": {
108
+ "build": "node scripts/clean-dist.mjs && vite build && tsc -p tsconfig.build.json --emitDeclarationOnly && node scripts/rewrite-dist-aliases.mjs && node scripts/check-browser-package.mjs",
109
+ "test": "tsc -p tsconfig.json && npm run build && vitest run && node scripts/java-oracle-matrix.mjs && node scripts/check-api-parity.mjs --fail && npm pack --dry-run --json",
110
+ "generate-fixtures": "npm run build && node scripts/java-oracle-matrix.mjs --refresh"
111
+ },
112
+ "devDependencies": {
113
+ "@types/node": "^26.1.1",
114
+ "typescript": "^7.0.2",
115
+ "vite": "^8.1.4",
116
+ "vitest": "^4.1.10"
117
+ }
52
118
  }
package/LICENSE.md DELETED
@@ -1,56 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
-
6
- Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
7
-
8
- This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
9
-
10
- 0. Additional Definitions.
11
- As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
12
-
13
- “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
14
-
15
- An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
16
-
17
- A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
18
-
19
- The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
20
-
21
- The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
22
-
23
- 1. Exception to Section 3 of the GNU GPL.
24
- You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
25
-
26
- 2. Conveying Modified Versions.
27
- If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
28
-
29
- a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
30
- b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
31
- 3. Object Code Incorporating Material from Library Header Files.
32
- The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
33
-
34
- a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
35
- b) Accompany the object code with a copy of the GNU GPL and this license document.
36
- 4. Combined Works.
37
- You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
38
-
39
- a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
40
- b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
41
- c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
42
- d) Do one of the following:
43
- 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
44
- 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
45
- e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
46
- 5. Combined Libraries.
47
- You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
48
-
49
- a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
50
- b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
51
- 6. Revised Versions of the GNU Lesser General Public License.
52
- The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
53
-
54
- Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
55
-
56
- If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.