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,159 @@
1
+ import { isAsyncIterable } from "./iterable.js";
2
+ //#region src/internal/iterable-transform.ts
3
+ /**
4
+ * @packageDocumentation
5
+ * Internal iterable transformation helpers.
6
+ */
7
+ /** Maps an iterable, preserving synchronous iteration when possible. */
8
+ function mapIterable(source, mapper) {
9
+ if (isAsyncIterable(source)) return (async function* () {
10
+ for await (const value of source) yield mapper(value);
11
+ })();
12
+ return (function* () {
13
+ for (const value of source) yield mapper(value);
14
+ })();
15
+ }
16
+ /** Filters an iterable, preserving synchronous iteration when possible. */
17
+ function filterIterable(source, predicate) {
18
+ if (isAsyncIterable(source)) return (async function* () {
19
+ for await (const value of source) if (predicate(value)) yield value;
20
+ })();
21
+ return (function* () {
22
+ for (const value of source) if (predicate(value)) yield value;
23
+ })();
24
+ }
25
+ /** Takes values while a predicate returns true, preserving synchronous iteration when possible. */
26
+ function takeWhileIterable(source, predicate) {
27
+ if (isAsyncIterable(source)) return (async function* () {
28
+ for await (const value of source) {
29
+ if (!predicate(value)) return;
30
+ yield value;
31
+ }
32
+ })();
33
+ return (function* () {
34
+ for (const value of source) {
35
+ if (!predicate(value)) return;
36
+ yield value;
37
+ }
38
+ })();
39
+ }
40
+ /** Takes values until a predicate returns true, preserving synchronous iteration when possible. */
41
+ function takeUntilIterable(source, predicate) {
42
+ if (isAsyncIterable(source)) return (async function* () {
43
+ for await (const value of source) {
44
+ yield value;
45
+ if (predicate(value)) return;
46
+ }
47
+ })();
48
+ return (function* () {
49
+ for (const value of source) {
50
+ yield value;
51
+ if (predicate(value)) return;
52
+ }
53
+ })();
54
+ }
55
+ /** Skips a fixed number of values, preserving synchronous iteration when possible. */
56
+ function skipIterable(source, count) {
57
+ if (isAsyncIterable(source)) return (async function* () {
58
+ let skipped = 0;
59
+ for await (const value of source) if (skipped < count) skipped += 1;
60
+ else yield value;
61
+ })();
62
+ return (function* () {
63
+ let skipped = 0;
64
+ for (const value of source) if (skipped < count) skipped += 1;
65
+ else yield value;
66
+ })();
67
+ }
68
+ /** Skips values while a predicate returns true, preserving synchronous iteration when possible. */
69
+ function skipWhileIterable(source, predicate) {
70
+ if (isAsyncIterable(source)) return (async function* () {
71
+ let skipping = true;
72
+ for await (const value of source) {
73
+ if (skipping && predicate(value)) continue;
74
+ skipping = false;
75
+ yield value;
76
+ }
77
+ })();
78
+ return (function* () {
79
+ let skipping = true;
80
+ for (const value of source) {
81
+ if (skipping && predicate(value)) continue;
82
+ skipping = false;
83
+ yield value;
84
+ }
85
+ })();
86
+ }
87
+ /** Keeps the first value for every selected key, preserving synchronous iteration when possible. */
88
+ function distinctIterable(source, keySelector) {
89
+ if (isAsyncIterable(source)) return (async function* () {
90
+ const seen = /* @__PURE__ */ new Set();
91
+ for await (const value of source) {
92
+ const key = keySelector(value);
93
+ if (!seen.has(key)) {
94
+ seen.add(key);
95
+ yield value;
96
+ }
97
+ }
98
+ })();
99
+ return (function* () {
100
+ const seen = /* @__PURE__ */ new Set();
101
+ for (const value of source) {
102
+ const key = keySelector(value);
103
+ if (!seen.has(key)) {
104
+ seen.add(key);
105
+ yield value;
106
+ }
107
+ }
108
+ })();
109
+ }
110
+ /** Keeps values whose selected key differs from the previous key. */
111
+ function distinctUntilChangedIterable(source, keySelector) {
112
+ if (isAsyncIterable(source)) return (async function* () {
113
+ let hasPrevious = false;
114
+ let previous;
115
+ for await (const value of source) {
116
+ const key = keySelector(value);
117
+ if (!hasPrevious || !Object.is(previous, key)) {
118
+ hasPrevious = true;
119
+ previous = key;
120
+ yield value;
121
+ }
122
+ }
123
+ })();
124
+ return (function* () {
125
+ let hasPrevious = false;
126
+ let previous;
127
+ for (const value of source) {
128
+ const key = keySelector(value);
129
+ if (!hasPrevious || !Object.is(previous, key)) {
130
+ hasPrevious = true;
131
+ previous = key;
132
+ yield value;
133
+ }
134
+ }
135
+ })();
136
+ }
137
+ /** Emits a fallback value when the source is empty. */
138
+ function defaultIfEmptyIterable(source, defaultValue) {
139
+ if (isAsyncIterable(source)) return (async function* () {
140
+ let empty = true;
141
+ for await (const value of source) {
142
+ empty = false;
143
+ yield value;
144
+ }
145
+ if (empty) yield defaultValue;
146
+ })();
147
+ return (function* () {
148
+ let empty = true;
149
+ for (const value of source) {
150
+ empty = false;
151
+ yield value;
152
+ }
153
+ if (empty) yield defaultValue;
154
+ })();
155
+ }
156
+ //#endregion
157
+ export { defaultIfEmptyIterable, distinctIterable, distinctUntilChangedIterable, filterIterable, mapIterable, skipIterable, skipWhileIterable, takeUntilIterable, takeWhileIterable };
158
+
159
+ //# sourceMappingURL=iterable-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable-transform.js","names":[],"sources":["../../src/internal/iterable-transform.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Internal iterable transformation helpers.\n */\nimport {type AnyIterable, isAsyncIterable} from \"@/internal/iterable.js\";\n\n/** Maps an iterable, preserving synchronous iteration when possible. */\nexport function mapIterable<T, R>(source: AnyIterable<T>, mapper: (value: T) => R): AnyIterable<R> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n for await (const value of source) {\n yield mapper(value);\n }\n })();\n }\n return (function* () {\n for (const value of source) {\n yield mapper(value);\n }\n })();\n}\n\n/** Filters an iterable, preserving synchronous iteration when possible. */\nexport function filterIterable<T>(source: AnyIterable<T>, predicate: (value: T) => boolean): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n for await (const value of source) {\n if (predicate(value)) {\n yield value;\n }\n }\n })();\n }\n return (function* () {\n for (const value of source) {\n if (predicate(value)) {\n yield value;\n }\n }\n })();\n}\n\n/** Takes values while a predicate returns true, preserving synchronous iteration when possible. */\nexport function takeWhileIterable<T>(source: AnyIterable<T>, predicate: (value: T) => boolean): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n for await (const value of source) {\n if (!predicate(value)) {\n return;\n }\n yield value;\n }\n })();\n }\n return (function* () {\n for (const value of source) {\n if (!predicate(value)) {\n return;\n }\n yield value;\n }\n })();\n}\n\n/** Takes values until a predicate returns true, preserving synchronous iteration when possible. */\nexport function takeUntilIterable<T>(source: AnyIterable<T>, predicate: (value: T) => boolean): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n for await (const value of source) {\n yield value;\n if (predicate(value)) {\n return;\n }\n }\n })();\n }\n return (function* () {\n for (const value of source) {\n yield value;\n if (predicate(value)) {\n return;\n }\n }\n })();\n}\n\n/** Skips a fixed number of values, preserving synchronous iteration when possible. */\nexport function skipIterable<T>(source: AnyIterable<T>, count: number): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n let skipped = 0;\n for await (const value of source) {\n if (skipped < count) {\n skipped += 1;\n } else {\n yield value;\n }\n }\n })();\n }\n return (function* () {\n let skipped = 0;\n for (const value of source) {\n if (skipped < count) {\n skipped += 1;\n } else {\n yield value;\n }\n }\n })();\n}\n\n/** Skips values while a predicate returns true, preserving synchronous iteration when possible. */\nexport function skipWhileIterable<T>(source: AnyIterable<T>, predicate: (value: T) => boolean): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n let skipping = true;\n for await (const value of source) {\n if (skipping && predicate(value)) {\n continue;\n }\n skipping = false;\n yield value;\n }\n })();\n }\n return (function* () {\n let skipping = true;\n for (const value of source) {\n if (skipping && predicate(value)) {\n continue;\n }\n skipping = false;\n yield value;\n }\n })();\n}\n\n/** Keeps the first value for every selected key, preserving synchronous iteration when possible. */\nexport function distinctIterable<T, K>(source: AnyIterable<T>, keySelector: (value: T) => K): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n const seen = new Set<K>();\n for await (const value of source) {\n const key = keySelector(value);\n if (!seen.has(key)) {\n seen.add(key);\n yield value;\n }\n }\n })();\n }\n return (function* () {\n const seen = new Set<K>();\n for (const value of source) {\n const key = keySelector(value);\n if (!seen.has(key)) {\n seen.add(key);\n yield value;\n }\n }\n })();\n}\n\n/** Keeps values whose selected key differs from the previous key. */\nexport function distinctUntilChangedIterable<T, K>(\n source: AnyIterable<T>,\n keySelector: (value: T) => K\n): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n let hasPrevious = false;\n let previous: K | undefined;\n for await (const value of source) {\n const key = keySelector(value);\n if (!hasPrevious || !Object.is(previous, key)) {\n hasPrevious = true;\n previous = key;\n yield value;\n }\n }\n })();\n }\n return (function* () {\n let hasPrevious = false;\n let previous: K | undefined;\n for (const value of source) {\n const key = keySelector(value);\n if (!hasPrevious || !Object.is(previous, key)) {\n hasPrevious = true;\n previous = key;\n yield value;\n }\n }\n })();\n}\n\n/** Emits a fallback value when the source is empty. */\nexport function defaultIfEmptyIterable<T>(source: AnyIterable<T>, defaultValue: T): AnyIterable<T> {\n if (isAsyncIterable<T>(source)) {\n return (async function* () {\n let empty = true;\n for await (const value of source) {\n empty = false;\n yield value;\n }\n if (empty) {\n yield defaultValue;\n }\n })();\n }\n return (function* () {\n let empty = true;\n for (const value of source) {\n empty = false;\n yield value;\n }\n if (empty) {\n yield defaultValue;\n }\n })();\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,YAAkB,QAAwB,QAAyC;CAC/F,IAAI,gBAAmB,MAAM,GACzB,QAAQ,mBAAmB;EACvB,WAAW,MAAM,SAAS,QACtB,MAAM,OAAO,KAAK;CAE1B,EAAA,CAAG;CAEP,QAAQ,aAAa;EACjB,KAAK,MAAM,SAAS,QAChB,MAAM,OAAO,KAAK;CAE1B,EAAA,CAAG;AACP;;AAGA,SAAgB,eAAkB,QAAwB,WAA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IAAI,CAAC,eAAe,CAAC,OAAO,GAAG,UAAU,GAAG,GAAG;IAC3C,cAAc;IACd,WAAW;IACX,MAAM;GACV;EACJ;CACJ,EAAA,CAAG;AACP;;AAGA,SAAgB,uBAA0B,QAAwB,cAAiC;CAC/F,IAAI,gBAAmB,MAAM,GACzB,QAAQ,mBAAmB;EACvB,IAAI,QAAQ;EACZ,WAAW,MAAM,SAAS,QAAQ;GAC9B,QAAQ;GACR,MAAM;EACV;EACA,IAAI,OACA,MAAM;CAEd,EAAA,CAAG;CAEP,QAAQ,aAAa;EACjB,IAAI,QAAQ;EACZ,KAAK,MAAM,SAAS,QAAQ;GACxB,QAAQ;GACR,MAAM;EACV;EACA,IAAI,OACA,MAAM;CAEd,EAAA,CAAG;AACP"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Internal async iteration and cancellation utilities.
4
+ */
5
+ /** Source that can be consumed through either sync or async iteration. */
6
+ export type AnyIterable<T> = Iterable<T> | AsyncIterable<T>;
7
+ /** Shared empty iterable reused by stateless empty publishers. */
8
+ export declare const EMPTY_ITERABLE: Iterable<never>;
9
+ /** Returns true when `value` implements the async iterable protocol. */
10
+ export declare function isAsyncIterable<T>(value: unknown): value is AsyncIterable<T>;
11
+ /** Returns true when `value` implements the synchronous iterable protocol. */
12
+ export declare function isIterable<T>(value: unknown): value is Iterable<T>;
13
+ /** Returns a reusable completed iterator result when no return value is needed. */
14
+ export declare function doneResult<T>(): IteratorResult<T>;
15
+ /** Returns a reusable resolved completed iterator result promise. */
16
+ export declare function resolvedDoneResult<T>(): Promise<IteratorResult<T>>;
17
+ /** Returns an async iterable that stays pending until the signal is aborted. */
18
+ export declare function neverIterable(signal: AbortSignal): AsyncIterable<never>;
19
+ /** Closes an async iterator and ignores cleanup failures. */
20
+ export declare function closeAsyncIterator<T>(iterator: AsyncIterator<T>): Promise<void>;
21
+ /** Converts a synchronous or asynchronous iterable into an async iterator. */
22
+ export declare function toAsyncIterator<T>(source: AnyIterable<T>): AsyncIterator<T>;
23
+ //# sourceMappingURL=iterable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable.d.ts","sourceRoot":"","sources":["../../src/internal/iterable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0EAA0E;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAkB5D,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAkB,CAAC;AAE9D,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAE5E;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAElE;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAEjD;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAElE;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,CAUvE;AAED,6DAA6D;AAC7D,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CA2B3E"}
@@ -0,0 +1,81 @@
1
+ //#region src/internal/iterable.ts
2
+ /** Shared completed iterator result reused by internal iterators. */
3
+ var DONE_RESULT = Object.freeze({
4
+ done: true,
5
+ value: void 0
6
+ });
7
+ /** Shared resolved promise for completed iterator results. */
8
+ var DONE_PROMISE = Promise.resolve(DONE_RESULT);
9
+ /** Shared empty iterable reused by stateless empty publishers. */
10
+ var EMPTY_ITERABLE = Object.freeze({
11
+ /** Returns the shared completed iterator result. */
12
+ next: doneResult,
13
+ /** Returns this stateless iterator. */
14
+ [Symbol.iterator]() {
15
+ return this;
16
+ }
17
+ });
18
+ /** Returns true when `value` implements the async iterable protocol. */
19
+ function isAsyncIterable(value) {
20
+ return typeof value?.[Symbol.asyncIterator] === "function";
21
+ }
22
+ /** Returns true when `value` implements the synchronous iterable protocol. */
23
+ function isIterable(value) {
24
+ return typeof value?.[Symbol.iterator] === "function";
25
+ }
26
+ /** Returns a reusable completed iterator result when no return value is needed. */
27
+ function doneResult() {
28
+ return DONE_RESULT;
29
+ }
30
+ /** Returns a reusable resolved completed iterator result promise. */
31
+ function resolvedDoneResult() {
32
+ return DONE_PROMISE;
33
+ }
34
+ /** Returns an async iterable that stays pending until the signal is aborted. */
35
+ function neverIterable(signal) {
36
+ return (async function* () {
37
+ await new Promise((_resolve, reject) => {
38
+ if (signal.aborted) {
39
+ reject(signal.reason);
40
+ return;
41
+ }
42
+ signal.addEventListener("abort", () => reject(signal.reason), { once: true });
43
+ });
44
+ })();
45
+ }
46
+ /** Closes an async iterator and ignores cleanup failures. */
47
+ async function closeAsyncIterator(iterator) {
48
+ try {
49
+ await iterator.return?.();
50
+ } catch {}
51
+ }
52
+ /** Converts a synchronous or asynchronous iterable into an async iterator. */
53
+ function toAsyncIterator(source) {
54
+ if (isAsyncIterable(source)) return source[Symbol.asyncIterator]();
55
+ const iterator = source[Symbol.iterator]();
56
+ return {
57
+ /** Returns the next synchronous iterator value as a promise. */
58
+ next() {
59
+ return Promise.resolve(iterator.next());
60
+ },
61
+ /** Delegates return to the synchronous iterator when available. */
62
+ return(value) {
63
+ const returnFn = iterator.return;
64
+ if (returnFn) return Promise.resolve(returnFn.call(iterator, value));
65
+ return value === void 0 ? resolvedDoneResult() : Promise.resolve({
66
+ done: true,
67
+ value
68
+ });
69
+ },
70
+ /** Delegates throw to the synchronous iterator when available. */
71
+ throw(error) {
72
+ const throwFn = iterator.throw;
73
+ if (throwFn) return Promise.resolve(throwFn.call(iterator, error));
74
+ return Promise.reject(error);
75
+ }
76
+ };
77
+ }
78
+ //#endregion
79
+ export { EMPTY_ITERABLE, closeAsyncIterator, doneResult, isAsyncIterable, isIterable, neverIterable, resolvedDoneResult, toAsyncIterator };
80
+
81
+ //# sourceMappingURL=iterable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterable.js","names":[],"sources":["../../src/internal/iterable.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Internal async iteration and cancellation utilities.\n */\n/** Source that can be consumed through either sync or async iteration. */\nexport type AnyIterable<T> = Iterable<T> | AsyncIterable<T>;\n\n/** Shared completed iterator result reused by internal iterators. */\nconst DONE_RESULT: IteratorReturnResult<never> = Object.freeze({done: true, value: undefined as never});\n\n/** Shared resolved promise for completed iterator results. */\nconst DONE_PROMISE = Promise.resolve(DONE_RESULT);\n\n/** Shared empty iterator used by stateless empty publishers. */\nconst EMPTY_ITERATOR: Iterator<never> & Iterable<never> = Object.freeze({\n /** Returns the shared completed iterator result. */\n next: doneResult,\n /** Returns this stateless iterator. */\n [Symbol.iterator]() {\n return this;\n }\n});\n\n/** Shared empty iterable reused by stateless empty publishers. */\nexport const EMPTY_ITERABLE: Iterable<never> = EMPTY_ITERATOR;\n\n/** Returns true when `value` implements the async iterable protocol. */\nexport function isAsyncIterable<T>(value: unknown): value is AsyncIterable<T> {\n return typeof (value as { [Symbol.asyncIterator]?: unknown })?.[Symbol.asyncIterator] === \"function\";\n}\n\n/** Returns true when `value` implements the synchronous iterable protocol. */\nexport function isIterable<T>(value: unknown): value is Iterable<T> {\n return typeof (value as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] === \"function\";\n}\n\n/** Returns a reusable completed iterator result when no return value is needed. */\nexport function doneResult<T>(): IteratorResult<T> {\n return DONE_RESULT as IteratorResult<T>;\n}\n\n/** Returns a reusable resolved completed iterator result promise. */\nexport function resolvedDoneResult<T>(): Promise<IteratorResult<T>> {\n return DONE_PROMISE as Promise<IteratorResult<T>>;\n}\n\n/** Returns an async iterable that stays pending until the signal is aborted. */\nexport function neverIterable(signal: AbortSignal): AsyncIterable<never> {\n return (async function* () {\n await new Promise<void>((_resolve, reject) => {\n if (signal.aborted) {\n reject(signal.reason);\n return;\n }\n signal.addEventListener(\"abort\", () => reject(signal.reason), {once: true});\n });\n })();\n}\n\n/** Closes an async iterator and ignores cleanup failures. */\nexport async function closeAsyncIterator<T>(iterator: AsyncIterator<T>): Promise<void> {\n try {\n await iterator.return?.();\n } catch {\n // best-effort cleanup\n }\n}\n\n/** Converts a synchronous or asynchronous iterable into an async iterator. */\nexport function toAsyncIterator<T>(source: AnyIterable<T>): AsyncIterator<T> {\n if (isAsyncIterable<T>(source)) {\n return source[Symbol.asyncIterator]();\n }\n const iterator = source[Symbol.iterator]();\n return {\n /** Returns the next synchronous iterator value as a promise. */\n next() {\n return Promise.resolve(iterator.next());\n },\n /** Delegates return to the synchronous iterator when available. */\n return(value?: unknown) {\n const returnFn = iterator.return;\n if (returnFn) {\n return Promise.resolve(returnFn.call(iterator, value));\n }\n return value === undefined ? resolvedDoneResult<T>() : Promise.resolve({done: true, value: value as T});\n },\n /** Delegates throw to the synchronous iterator when available. */\n throw(error?: unknown) {\n const throwFn = iterator.throw;\n if (throwFn) {\n return Promise.resolve(throwFn.call(iterator, error));\n }\n return Promise.reject(error);\n }\n };\n}\n"],"mappings":";;AAQA,IAAM,cAA2C,OAAO,OAAO;CAAC,MAAM;CAAM,OAAO;AAAkB,CAAC;;AAGtG,IAAM,eAAe,QAAQ,QAAQ,WAAW;;AAahD,IAAa,iBAV6C,OAAO,OAAO;;CAEpE,MAAM;;CAEN,CAAC,OAAO,YAAY;EAChB,OAAO;CACX;AACJ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ities.
4
+ */
5
+ /** Schedules a task in the browser microtask queue with a small fallback. */
6
+ export declare function scheduleMicrotask(task: () => void): void;
7
+ //# sourceMappingURL=microtask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microtask.d.ts","sourceRoot":"","sources":["../../src/internal/microtask.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAMxD"}
@@ -0,0 +1,19 @@
1
+ //#region src/internal/microtask.ts
2
+ /**
3
+ * @packageDocumentation
4
+ * Internal browser task scheduling utilities.
5
+ */
6
+ /** Promise reused when a browser does not expose `queueMicrotask`. */
7
+ var resolvedMicrotask = Promise.resolve();
8
+ /** Schedules a task in the browser microtask queue with a small fallback. */
9
+ function scheduleMicrotask(task) {
10
+ if (typeof queueMicrotask === "function") {
11
+ queueMicrotask(task);
12
+ return;
13
+ }
14
+ resolvedMicrotask.then(task);
15
+ }
16
+ //#endregion
17
+ export { scheduleMicrotask };
18
+
19
+ //# sourceMappingURL=microtask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microtask.js","names":[],"sources":["../../src/internal/microtask.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Internal browser task scheduling utilities.\n */\n\n/** Promise reused when a browser does not expose `queueMicrotask`. */\nconst resolvedMicrotask = Promise.resolve();\n\n/** Schedules a task in the browser microtask queue with a small fallback. */\nexport function scheduleMicrotask(task: () => void): void {\n if (typeof queueMicrotask === \"function\") {\n queueMicrotask(task);\n return;\n }\n void resolvedMicrotask.then(task);\n}\n"],"mappings":";;;;;;AAMA,IAAM,oBAAoB,QAAQ,QAAQ;;AAG1C,SAAgB,kBAAkB,MAAwB;CACtD,IAAI,OAAO,mBAAmB,YAAY;EACtC,eAAe,IAAI;EACnB;CACJ;CACA,AAAK,kBAAkB,KAAK,IAAI;AACpC"}
@@ -0,0 +1,15 @@
1
+ import type { SourceFactory } from "./types.js";
2
+ /** Options used when creating a Flux from a browser WebSocket. */
3
+ export interface WebSocketFluxOptions {
4
+ /** Protocol or protocols passed to the browser WebSocket constructor when a URL is provided. */
5
+ readonly protocols?: string | string[];
6
+ /** Binary data format assigned to the socket before listening for messages. */
7
+ readonly binaryType?: BinaryType;
8
+ /** Closes the socket when the Flux subscription is cancelled. Defaults to true for URL-created sockets. */
9
+ readonly closeOnCancel?: boolean;
10
+ }
11
+ /** Creates a lazy source factory from browser events. */
12
+ export declare function eventSource<TEvent extends Event>(target: EventTarget, type: string, options?: boolean | AddEventListenerOptions): SourceFactory<TEvent>;
13
+ /** Creates a lazy source factory from browser WebSocket message events. */
14
+ export declare function webSocketSource<T>(input: WebSocket | string | URL, options?: string | string[] | WebSocketFluxOptions): SourceFactory<MessageEvent<T>>;
15
+ //# sourceMappingURL=browser-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-sources.d.ts","sourceRoot":"","sources":["../../src/publisher/browser-sources.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAExD,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACjC,gGAAgG;IAChG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,2GAA2G;IAC3G,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,MAAM,SAAS,KAAK,EAC5C,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC5C,aAAa,CAAC,MAAM,CAAC,CAkBvB;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,CAAC,EAC7B,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,GAAG,EAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,oBAAoB,GACnD,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CA0ChC"}
@@ -0,0 +1,92 @@
1
+ import { throwIfNullish } from "../errors/helpers.js";
2
+ import { AsyncQueue } from "../internal/async-queue.js";
3
+ //#region src/publisher/browser-sources.ts
4
+ /**
5
+ * @packageDocumentation
6
+ * Browser source adapters used by Flux static factories.
7
+ */
8
+ /** Creates a lazy source factory from browser events. */
9
+ function eventSource(target, type, options) {
10
+ throwIfNullish(target, "target");
11
+ throwIfNullish(type, "type");
12
+ return (signal) => {
13
+ const queue = new AsyncQueue(signal);
14
+ if (signal.aborted) return queue;
15
+ const listener = (event) => {
16
+ queue.push(event);
17
+ };
18
+ const cleanup = () => {
19
+ target.removeEventListener(type, listener, options);
20
+ };
21
+ target.addEventListener(type, listener, options);
22
+ signal.addEventListener("abort", cleanup, { once: true });
23
+ return queue;
24
+ };
25
+ }
26
+ /** Creates a lazy source factory from browser WebSocket message events. */
27
+ function webSocketSource(input, options) {
28
+ throwIfNullish(input, "input");
29
+ return (signal) => {
30
+ const queue = new AsyncQueue(signal);
31
+ if (signal.aborted) return queue;
32
+ const { closeOnCancel, socket } = webSocketFrom(input, options);
33
+ let cleaned = false;
34
+ const onMessage = (event) => {
35
+ queue.push(event);
36
+ };
37
+ const onError = (event) => {
38
+ cleanup(false);
39
+ queue.error(event);
40
+ };
41
+ const onClose = () => {
42
+ cleanup(false);
43
+ queue.complete();
44
+ };
45
+ const onAbort = () => {
46
+ cleanup(true);
47
+ };
48
+ function cleanup(cancelled) {
49
+ if (cleaned) return;
50
+ cleaned = true;
51
+ socket.removeEventListener("message", onMessage);
52
+ socket.removeEventListener("error", onError);
53
+ socket.removeEventListener("close", onClose);
54
+ signal.removeEventListener("abort", onAbort);
55
+ if (cancelled) closeWebSocket(socket, closeOnCancel);
56
+ }
57
+ socket.addEventListener("message", onMessage);
58
+ socket.addEventListener("error", onError);
59
+ socket.addEventListener("close", onClose);
60
+ signal.addEventListener("abort", onAbort, { once: true });
61
+ return queue;
62
+ };
63
+ }
64
+ /** Normalizes browser WebSocket options while keeping the common protocols-only shorthand. */
65
+ function webSocketOptions(options) {
66
+ return typeof options === "string" || Array.isArray(options) ? { protocols: options } : options ?? {};
67
+ }
68
+ /** Creates or reuses a browser WebSocket and returns its cancellation ownership policy. */
69
+ function webSocketFrom(input, options) {
70
+ const normalized = webSocketOptions(options);
71
+ const ownsSocket = typeof input === "string" || input instanceof URL;
72
+ const socket = ownsSocket ? openWebSocket(input, normalized.protocols) : input;
73
+ if (normalized.binaryType !== void 0) socket.binaryType = normalized.binaryType;
74
+ return {
75
+ closeOnCancel: normalized.closeOnCancel ?? ownsSocket,
76
+ socket
77
+ };
78
+ }
79
+ /** Opens a browser WebSocket or fails clearly when the runtime does not provide one. */
80
+ function openWebSocket(url, protocols) {
81
+ const WebSocketConstructor = globalThis.WebSocket;
82
+ if (typeof WebSocketConstructor !== "function") throw new TypeError("WebSocket is not available in this runtime");
83
+ return protocols === void 0 ? new WebSocketConstructor(url) : new WebSocketConstructor(url, protocols);
84
+ }
85
+ /** Closes a WebSocket when this Flux owns the socket or the caller requested close-on-cancel. */
86
+ function closeWebSocket(socket, closeOnCancel) {
87
+ if (closeOnCancel && socket.readyState < 2) socket.close();
88
+ }
89
+ //#endregion
90
+ export { eventSource, webSocketSource };
91
+
92
+ //# sourceMappingURL=browser-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-sources.js","names":[],"sources":["../../src/publisher/browser-sources.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Browser source adapters used by Flux static factories.\n */\nimport {throwIfNullish} from \"@/errors/helpers.js\";\nimport {AsyncQueue} from \"@/internal/async-queue.js\";\nimport type {SourceFactory} from \"@/publisher/types.js\";\n\n/** Options used when creating a Flux from a browser WebSocket. */\nexport interface WebSocketFluxOptions {\n /** Protocol or protocols passed to the browser WebSocket constructor when a URL is provided. */\n readonly protocols?: string | string[];\n /** Binary data format assigned to the socket before listening for messages. */\n readonly binaryType?: BinaryType;\n /** Closes the socket when the Flux subscription is cancelled. Defaults to true for URL-created sockets. */\n readonly closeOnCancel?: boolean;\n}\n\n/** Creates a lazy source factory from browser events. */\nexport function eventSource<TEvent extends Event>(\n target: EventTarget,\n type: string,\n options?: boolean | AddEventListenerOptions\n): SourceFactory<TEvent> {\n throwIfNullish(target, \"target\");\n throwIfNullish(type, \"type\");\n return signal => {\n const queue = new AsyncQueue<TEvent>(signal);\n if (signal.aborted) {\n return queue;\n }\n const listener = (event: Event) => {\n queue.push(event as TEvent);\n };\n const cleanup = () => {\n target.removeEventListener(type, listener, options);\n };\n target.addEventListener(type, listener, options);\n signal.addEventListener(\"abort\", cleanup, {once: true});\n return queue;\n };\n}\n\n/** Creates a lazy source factory from browser WebSocket message events. */\nexport function webSocketSource<T>(\n input: WebSocket | string | URL,\n options?: string | string[] | WebSocketFluxOptions\n): SourceFactory<MessageEvent<T>> {\n throwIfNullish(input, \"input\");\n return signal => {\n const queue = new AsyncQueue<MessageEvent<T>>(signal);\n if (signal.aborted) {\n return queue;\n }\n const {closeOnCancel, socket} = webSocketFrom(input, options);\n let cleaned = false;\n const onMessage = (event: MessageEvent) => {\n queue.push(event as MessageEvent<T>);\n };\n const onError = (event: Event) => {\n cleanup(false);\n queue.error(event);\n };\n const onClose = () => {\n cleanup(false);\n queue.complete();\n };\n const onAbort = () => {\n cleanup(true);\n };\n function cleanup(cancelled: boolean): void {\n if (cleaned) {\n return;\n }\n cleaned = true;\n socket.removeEventListener(\"message\", onMessage);\n socket.removeEventListener(\"error\", onError);\n socket.removeEventListener(\"close\", onClose);\n signal.removeEventListener(\"abort\", onAbort);\n if (cancelled) {\n closeWebSocket(socket, closeOnCancel);\n }\n }\n socket.addEventListener(\"message\", onMessage);\n socket.addEventListener(\"error\", onError);\n socket.addEventListener(\"close\", onClose);\n signal.addEventListener(\"abort\", onAbort, {once: true});\n return queue;\n };\n}\n\n/** Normalizes browser WebSocket options while keeping the common protocols-only shorthand. */\nfunction webSocketOptions(options?: string | string[] | WebSocketFluxOptions): WebSocketFluxOptions {\n return typeof options === \"string\" || Array.isArray(options) ? {protocols: options} : options ?? {};\n}\n\n/** Creates or reuses a browser WebSocket and returns its cancellation ownership policy. */\nfunction webSocketFrom(\n input: WebSocket | string | URL,\n options?: string | string[] | WebSocketFluxOptions\n): { readonly closeOnCancel: boolean; readonly socket: WebSocket } {\n const normalized = webSocketOptions(options);\n const ownsSocket = typeof input === \"string\" || input instanceof URL;\n const socket = ownsSocket ? openWebSocket(input, normalized.protocols) : input;\n if (normalized.binaryType !== undefined) {\n socket.binaryType = normalized.binaryType;\n }\n return {\n closeOnCancel: normalized.closeOnCancel ?? ownsSocket,\n socket\n };\n}\n\n/** Opens a browser WebSocket or fails clearly when the runtime does not provide one. */\nfunction openWebSocket(url: string | URL, protocols?: string | string[]): WebSocket {\n const WebSocketConstructor = globalThis.WebSocket;\n if (typeof WebSocketConstructor !== \"function\") {\n throw new TypeError(\"WebSocket is not available in this runtime\");\n }\n return protocols === undefined ? new WebSocketConstructor(url) : new WebSocketConstructor(url, protocols);\n}\n\n/** Closes a WebSocket when this Flux owns the socket or the caller requested close-on-cancel. */\nfunction closeWebSocket(socket: WebSocket, closeOnCancel: boolean): void {\n if (closeOnCancel && socket.readyState < 2) {\n socket.close();\n }\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,YACZ,QACA,MACA,SACqB;CACrB,eAAe,QAAQ,QAAQ;CAC/B,eAAe,MAAM,MAAM;CAC3B,QAAO,WAAU;EACb,MAAM,QAAQ,IAAI,WAAmB,MAAM;EAC3C,IAAI,OAAO,SACP,OAAO;EAEX,MAAM,YAAY,UAAiB;GAC/B,MAAM,KAAK,KAAe;EAC9B;EACA,MAAM,gBAAgB;GAClB,OAAO,oBAAoB,MAAM,UAAU,OAAO;EACtD;EACA,OAAO,iBAAiB,MAAM,UAAU,OAAO;EAC/C,OA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W,eAAe,QAC1B,OAAO,aAAa,WAAW;CAEnC,OAAO;EACH,eAAe,WAAW,iBAAiB;EAC3C;CACJ;AACJ;;AAGA,SAAS,cAAc,KAAmB,WAA0C;CAChF,MAAM,uBAAuB,WAAW;CACxC,IAAI,OAAO,yBAAyB,YAChC,MAAM,IAAI,UAAU,4CAA4C;CAEpE,OAAO,cAAc,SAAY,IAAI,qBAAqB,GAAG,IAAI,IAAI,qBAAqB,KAAK,SAAS;AAC5G;;AAGA,SAAS,eAAe,QAAmB,eAA8B;CACrE,IAAI,iBAAiB,OAAO,aAAa,GACrC,OAAO,MAAM;AAErB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Focused Flux public entrypoint.
4
+ */
5
+ import "./operators/register.js";
6
+ export { Flux } from "./flux.js";
7
+ //# sourceMappingURL=flux-entrypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flux-entrypoint.d.ts","sourceRoot":"","sources":["../../src/publisher/flux-entrypoint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,mCAAmC,CAAC;AAE3C,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Flux } from "./flux.js";
2
+ import "./operators/register.js";
3
+ //#region src/publisher/flux-entrypoint.ts
4
+ /**
5
+ * @packageDocumentation
6
+ * Focused Flux public entrypoint.
7
+ */
8
+ //#endregion
9
+ export { Flux };
10
+
11
+ //# sourceMappingURL=flux-entrypoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flux-entrypoint.js","names":[],"sources":["../../src/publisher/flux-entrypoint.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Focused Flux public entrypoint.\n */\nimport \"@/publisher/operators/register.js\";\n\nexport {Flux} from \"@/publisher/flux.js\";\n"],"mappings":""}
@@ -0,0 +1,121 @@
1
+ import type { Disposable } from "../core/types.js";
2
+ import { Context } from "../context/context.js";
3
+ import type { ContextView } from "../context/context-view.js";
4
+ import { type AnyIterable } from "../internal/iterable.js";
5
+ import { type WebSocketFluxOptions } from "./browser-sources.js";
6
+ import type { Publisher } from "./publisher.js";
7
+ import type { FluxSinkCallback, PublisherInput, SourceFactory } from "./types.js";
8
+ import type { DurationInput, Scheduler } from "../schedulers/types.js";
9
+ import type { Subscriber } from "../subscription/subscriber.js";
10
+ /** Multi-value Reactive Streams publisher with Reactor-style operators. */
11
+ export declare class Flux<T> implements Publisher<T>, AsyncIterable<T> {
12
+ /** Lazy source factory invoked for each subscription or async iteration. */
13
+ private readonly sourceFactory;
14
+ /** Creates a Flux from a lazy source factory. */
15
+ constructor(sourceFactory: SourceFactory<T>);
16
+ /** Creates a Flux that emits the provided values and then completes. */
17
+ static just<T>(...values: readonly T[]): Flux<T>;
18
+ /** Creates a Flux from an array-like readonly value list. */
19
+ static fromArray<T>(values: readonly T[]): Flux<T>;
20
+ /** Creates a Flux from a stream-like iterable or a lazy stream supplier. */
21
+ static fromStream<T>(stream: Iterable<T> | (() => Iterable<T>)): Flux<T>;
22
+ /** Creates a Flux from a JavaScript iterable. */
23
+ static fromIterable<T>(values: Iterable<T>): Flux<T>;
24
+ /** Creates a Flux from browser `Window` events and removes the listener on cancellation. */
25
+ static fromEvent<K extends keyof WindowEventMap>(target: Window, type: K, options?: boolean | AddEventListenerOptions): Flux<WindowEventMap[K]>;
26
+ /** Creates a Flux from browser `Document` events and removes the listener on cancellation. */
27
+ static fromEvent<K extends keyof DocumentEventMap>(target: Document, type: K, options?: boolean | AddEventListenerOptions): Flux<DocumentEventMap[K]>;
28
+ /** Creates a Flux from browser `HTMLElement` events and removes the listener on cancellation. */
29
+ static fromEvent<K extends keyof HTMLElementEventMap>(target: HTMLElement, type: K, options?: boolean | AddEventListenerOptions): Flux<HTMLElementEventMap[K]>;
30
+ /** Creates a Flux from any browser `EventTarget` and removes the listener on cancellation. */
31
+ static fromEvent<TEvent extends Event = Event>(target: EventTarget, type: string, options?: boolean | AddEventListenerOptions): Flux<TEvent>;
32
+ /** Creates a Flux from browser WebSocket message events. */
33
+ static fromWebSocket<T = unknown>(url: string | URL, options?: string | string[] | WebSocketFluxOptions): Flux<MessageEvent<T>>;
34
+ /** Creates a Flux from browser WebSocket message events. */
35
+ static fromWebSocket<T = unknown>(socket: WebSocket, options?: WebSocketFluxOptions): Flux<MessageEvent<T>>;
36
+ /** Adapts a publisher, iterable, async iterable or promise-like value to Flux. */
37
+ static from<T>(input: PublisherInput<T>): Flux<T>;
38
+ /** Creates a Flux that completes without emitting values. */
39
+ static empty<T = never>(): Flux<T>;
40
+ /** Creates a Flux that never emits or completes until cancelled. */
41
+ static never<T = never>(): Flux<T>;
42
+ /** Creates a Flux that terminates with the provided error. */
43
+ static error<T = never>(error: unknown | (() => unknown)): Flux<T>;
44
+ /** Defers source creation until subscription time. */
45
+ static defer<T>(supplier: () => PublisherInput<T>): Flux<T>;
46
+ /** Defers source creation and exposes the subscriber context. */
47
+ static deferContextual<T>(supplier: (context: ContextView) => PublisherInput<T>): Flux<T>;
48
+ /** Creates a Flux by bridging callback-style producers through a sink. */
49
+ static create<T>(callback: FluxSinkCallback<T>): Flux<T>;
50
+ /** Creates a Flux by bridging a single-threaded push-style producer through a sink. */
51
+ static push<T>(callback: FluxSinkCallback<T>): Flux<T>;
52
+ /** Creates a Flux by repeatedly invoking a synchronous generator callback. */
53
+ static generate<T>(generator: (sink: {
54
+ next(value: T): void;
55
+ complete(): void;
56
+ error(error: unknown): void;
57
+ }) => void): Flux<T>;
58
+ /** Creates a finite integer range. */
59
+ static range(start: number, count: number): Flux<number>;
60
+ /** Creates an interval Flux that emits incrementing numbers. */
61
+ static interval(period: DurationInput, scheduler?: Scheduler): Flux<number>;
62
+ /** Merges several publishers concurrently. */
63
+ static merge<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
64
+ /** Merges several publishers concurrently and delays failures until every source terminates. */
65
+ static mergeDelayError<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
66
+ /** Merges sources sequentially while subscribing to one source at a time. */
67
+ static mergeSequential<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
68
+ /** Merges sources sequentially and delays failures until every source has been consumed. */
69
+ static mergeSequentialDelayError<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
70
+ /** Merges finite sources and emits their values sorted by a comparator. */
71
+ static mergeComparing<T>(comparatorOrSource?: ((left: T, right: T) => number) | PublisherInput<T>, ...sources: readonly PublisherInput<T>[]): Flux<T>;
72
+ /** Merges finite sources, delays failures and emits their values sorted by a comparator. */
73
+ static mergeComparingDelayError<T>(comparatorOrSource?: ((left: T, right: T) => number) | PublisherInput<T>, ...sources: readonly PublisherInput<T>[]): Flux<T>;
74
+ /** Merges finite sources and emits their values in comparator order. */
75
+ static mergeOrdered<T>(comparatorOrSource?: ((left: T, right: T) => number) | PublisherInput<T>, ...sources: readonly PublisherInput<T>[]): Flux<T>;
76
+ /** Merges finite sources with priority ordering. */
77
+ static mergePriority<T>(comparatorOrSource?: ((left: T, right: T) => number) | PublisherInput<T>, ...sources: readonly PublisherInput<T>[]): Flux<T>;
78
+ /** Merges finite sources with priority ordering and delayed failures. */
79
+ static mergePriorityDelayError<T>(comparatorOrSource?: ((left: T, right: T) => number) | PublisherInput<T>, ...sources: readonly PublisherInput<T>[]): Flux<T>;
80
+ /** Concatenates several publishers sequentially. */
81
+ static concat<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
82
+ /** Concatenates several publishers sequentially and delays failures until every source has been consumed. */
83
+ static concatDelayError<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
84
+ /** Relays the first source that emits any signal. */
85
+ static first<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
86
+ /** Relays the first source that emits any signal. */
87
+ static firstWithSignal<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
88
+ /** Relays the first source that produces a value, ignoring empty completions. */
89
+ static firstWithValue<T>(...sources: readonly PublisherInput<T>[]): Flux<T>;
90
+ /** Zips publishers by combining one value from each source. */
91
+ static zip<T extends readonly unknown[], R = T>(sources: {
92
+ [K in keyof T]: PublisherInput<T[K]>;
93
+ }, combinator?: (values: T) => R): Flux<R>;
94
+ /** Combines the latest value from each source after all sources emitted once. */
95
+ static combineLatest<T extends readonly unknown[], R = T>(sources: {
96
+ [K in keyof T]: PublisherInput<T[K]>;
97
+ }, combinator?: (values: T) => R): Flux<R>;
98
+ /** Switches to the most recent publisher emitted by an outer publisher. */
99
+ static switchOnNext<T>(sources: PublisherInput<PublisherInput<T>>): Flux<T>;
100
+ /** Uses a resource for the duration of a derived publisher and cleans it up afterwards. */
101
+ static using<T, D>(resourceSupplier: () => D, sourceFactory: (resource: D) => PublisherInput<T>, resourceCleanup?: (resource: D) => void): Flux<T>;
102
+ /** Uses an asynchronously supplied resource and runs asynchronous cleanup publishers. */
103
+ static usingWhen<T, D>(resourceSupplier: PublisherInput<D>, sourceFactory: (resource: D) => PublisherInput<T>, asyncComplete?: (resource: D) => PublisherInput<unknown>, asyncError?: (resource: D, error: unknown) => PublisherInput<unknown>, asyncCancel?: (resource: D) => PublisherInput<unknown>): Flux<T>;
104
+ /** Subscribes a full Reactive Streams subscriber. */
105
+ subscribe(subscriber: Subscriber<T>): void;
106
+ /** Subscribes callbacks and requests unbounded demand. */
107
+ subscribe(onNext?: (value: T) => void, onError?: (error: unknown) => void, onComplete?: () => void): Disposable;
108
+ /** Subscribes a normalized Reactive Streams subscriber to this Flux. */
109
+ protected subscribeActual(subscriber: Subscriber<T>): void;
110
+ /** Returns the lazy iterable backing this Flux for internal operator composition. */
111
+ iterate(signal: AbortSignal, context?: Context): AnyIterable<T>;
112
+ /** Returns an async iterator over this Flux. */
113
+ [Symbol.asyncIterator](): AsyncIterator<T>;
114
+ /** Returns this Flux as an async iterable. */
115
+ toIterable(): AsyncIterable<T>;
116
+ /** Collects all values into an array. */
117
+ toArray(): Promise<T[]>;
118
+ /** Resolves to the last emitted value, or undefined for an empty source. */
119
+ toPromise(): Promise<T | undefined>;
120
+ }
121
+ //# sourceMappingURL=flux.d.ts.map