patron-oop 1.43.0 → 1.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/patron.cjs +295 -275
  3. package/dist/patron.cjs.map +1 -1
  4. package/dist/patron.d.ts +181 -155
  5. package/dist/patron.js +283 -268
  6. package/dist/patron.js.map +1 -1
  7. package/dist/patron.min.js +1 -1
  8. package/dist/patron.min.mjs +1 -1
  9. package/dist/patron.min.mjs.map +1 -1
  10. package/dist/patron.mjs +283 -268
  11. package/dist/patron.mjs.map +1 -1
  12. package/package.json +1 -1
  13. package/src/Guest/Guest.test.ts +11 -6
  14. package/src/Guest/Guest.ts +7 -14
  15. package/src/Guest/GuestApplied.test.ts +13 -0
  16. package/src/Guest/GuestApplied.ts +16 -0
  17. package/src/Guest/GuestCast.test.ts +4 -5
  18. package/src/Guest/GuestCast.ts +3 -10
  19. package/src/Guest/GuestDisposable.test.ts +13 -17
  20. package/src/Guest/GuestDisposable.ts +3 -3
  21. package/src/Guest/GuestExecutorApplied.test.ts +27 -0
  22. package/src/Guest/GuestExecutorApplied.ts +23 -0
  23. package/src/Guest/GuestObject.test.ts +6 -6
  24. package/src/Guest/GuestObject.ts +3 -3
  25. package/src/Guest/GuestPool.test.ts +5 -22
  26. package/src/Guest/GuestPool.ts +7 -8
  27. package/src/Guest/GuestSync.test.ts +2 -2
  28. package/src/Patron/Patron.test.ts +4 -5
  29. package/src/Patron/Patron.ts +11 -3
  30. package/src/Patron/PatronOnce.sourceEmpty.test.ts +2 -2
  31. package/src/Patron/PatronOnce.test.ts +2 -2
  32. package/src/Patron/PatronOnce.ts +3 -9
  33. package/src/Patron/PatronPool.test.ts +2 -1
  34. package/src/Patron/PatronPool.ts +22 -27
  35. package/src/Private/PrivateClass.modules.test.ts +11 -8
  36. package/src/Private/PrivateClass.test.ts +7 -6
  37. package/src/Source/Source.test.ts +9 -5
  38. package/src/Source/Source.ts +46 -30
  39. package/src/Source/SourceActive.test.ts +13 -0
  40. package/src/Source/SourceActive.ts +41 -0
  41. package/src/Source/SourceAll._asArray.test.ts +22 -0
  42. package/src/Source/SourceAll._twoValuesAfter.test.ts +19 -0
  43. package/src/Source/SourceAll._twoValuesBefore.test.ts +19 -0
  44. package/src/Source/SourceAll._withPatron.test.ts +25 -0
  45. package/src/{Guest/GuestAwareAll.ts → Source/SourceAll.ts} +11 -11
  46. package/src/Source/SourceApplied.test.ts +14 -0
  47. package/src/Source/SourceApplied.ts +23 -0
  48. package/src/Source/SourceDynamic.ofSource.test.ts +12 -12
  49. package/src/Source/SourceDynamic.test.ts +9 -9
  50. package/src/Source/SourceDynamic.ts +7 -7
  51. package/src/Source/SourceExecutorApplied.test.ts +30 -0
  52. package/src/Source/SourceExecutorApplied.ts +22 -0
  53. package/src/Source/SourceMap.defered.test.ts +46 -0
  54. package/src/Source/SourceMap.fn.test.ts +27 -0
  55. package/src/Source/SourceMap.test.ts +32 -0
  56. package/src/Source/SourceMap.ts +48 -0
  57. package/src/Source/SourceOnce.notcalled.test.ts +13 -0
  58. package/src/Source/SourceOnce.test.ts +10 -0
  59. package/src/Source/SourceOnce.ts +31 -0
  60. package/src/Source/SourceRace.test.ts +46 -0
  61. package/src/Source/SourceRace.ts +30 -0
  62. package/src/Source/SourceSequence.defered.test.ts +53 -0
  63. package/src/Source/SourceSequence.test.ts +30 -0
  64. package/src/{Guest/GuestAwareSequence.ts → Source/SourceSequence.ts} +14 -19
  65. package/src/Source/SourceWithPool.empty.test.ts +14 -0
  66. package/src/Source/SourceWithPool.test.ts +10 -0
  67. package/src/Source/SourceWithPool.ts +58 -0
  68. package/src/index.ts +9 -7
  69. package/test-utils/debounce.ts +11 -0
  70. package/test-utils/id.ts +1 -0
  71. package/test-utils/wait.ts +6 -3
  72. package/src/Guest/GuestAware.test.ts +0 -13
  73. package/src/Guest/GuestAware.ts +0 -59
  74. package/src/Guest/GuestAwareActive.test.ts +0 -12
  75. package/src/Guest/GuestAwareActive.ts +0 -42
  76. package/src/Guest/GuestAwareAll._asArray.test.ts +0 -19
  77. package/src/Guest/GuestAwareAll._twoValuesAfter.test.ts +0 -16
  78. package/src/Guest/GuestAwareAll._twoValuesBefore.test.ts +0 -16
  79. package/src/Guest/GuestAwareAll._withPatron.test.ts +0 -22
  80. package/src/Guest/GuestAwareMap.defered.test.ts +0 -46
  81. package/src/Guest/GuestAwareMap.fn.test.ts +0 -27
  82. package/src/Guest/GuestAwareMap.test.ts +0 -29
  83. package/src/Guest/GuestAwareMap.ts +0 -48
  84. package/src/Guest/GuestAwareRace.test.ts +0 -46
  85. package/src/Guest/GuestAwareRace.ts +0 -33
  86. package/src/Guest/GuestAwareSequence.defered.test.ts +0 -58
  87. package/src/Guest/GuestAwareSequence.test.ts +0 -30
  88. package/src/Source/SourceEmpty.test.ts +0 -20
  89. package/src/Source/SourceEmpty.ts +0 -31
package/dist/patron.mjs CHANGED
@@ -1,36 +1,4 @@
1
- function value(guestAware, guest) {
2
- if (guestAware === void 0) {
3
- throw new Error("value didnt receive guestAware argument");
4
- }
5
- if (guest === void 0) {
6
- throw new Error("value didnt receive guest argument");
7
- }
8
- if (typeof guestAware === "function") {
9
- return guestAware(guest);
10
- } else {
11
- return guestAware.value(guest);
12
- }
13
- }
14
- function isGuestAware(mbGuestAware) {
15
- if (mbGuestAware === void 0) {
16
- throw new Error("isGuestAware didnt receive mbGuestAware argument");
17
- }
18
- return typeof mbGuestAware === "function" || typeof mbGuestAware?.value === "function";
19
- }
20
- class GuestAware {
21
- constructor(guestAware) {
22
- this.guestAware = guestAware;
23
- if (guestAware === void 0) {
24
- throw new Error("GuestAware constructor didnt receive executor function");
25
- }
26
- }
27
- value(guest) {
28
- value(this.guestAware, guest);
29
- return guest;
30
- }
31
- }
32
-
33
- function give(data, guest, options) {
1
+ function give(data, guest) {
34
2
  if (data === void 0) {
35
3
  throw new Error("give didnt receive data argument");
36
4
  }
@@ -38,9 +6,9 @@ function give(data, guest, options) {
38
6
  throw new Error("give didnt receive guest argument");
39
7
  }
40
8
  if (typeof guest === "function") {
41
- guest(data, options);
9
+ guest(data);
42
10
  } else {
43
- guest.give(data, options);
11
+ guest.give(data);
44
12
  }
45
13
  }
46
14
  function isGuest(mbGuest) {
@@ -56,42 +24,12 @@ class Guest {
56
24
  throw new Error("reseiver function was not passed to Guest constructor");
57
25
  }
58
26
  }
59
- give(value, options) {
60
- this.receiver(value, options);
27
+ give(value) {
28
+ this.receiver(value);
61
29
  return this;
62
30
  }
63
31
  }
64
32
 
65
- var __defProp$6 = Object.defineProperty;
66
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
67
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
68
- class PatronOnce {
69
- constructor(baseGuest) {
70
- this.baseGuest = baseGuest;
71
- __publicField$6(this, "received", false);
72
- if (baseGuest === void 0) {
73
- throw new Error("PatronOnce didnt receive baseGuest argument");
74
- }
75
- }
76
- introduction() {
77
- return "patron";
78
- }
79
- give(value, options) {
80
- if (!this.received) {
81
- this.received = true;
82
- give(value, this.baseGuest, options);
83
- }
84
- return this;
85
- }
86
- disposed(value) {
87
- if (this.received) {
88
- return true;
89
- }
90
- const maybeDisposable = this.baseGuest;
91
- return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
92
- }
93
- }
94
-
95
33
  class GuestCast {
96
34
  constructor(sourceGuest, targetGuest) {
97
35
  this.sourceGuest = sourceGuest;
@@ -112,14 +50,8 @@ class GuestCast {
112
50
  }
113
51
  return this.sourceGuest.introduction();
114
52
  }
115
- give(value, options) {
116
- give(value, this.targetGuest, {
117
- ...options,
118
- data: {
119
- ...options?.data ?? {},
120
- castedGuest: options?.data?.castedGuest ?? this
121
- }
122
- });
53
+ give(value) {
54
+ give(value, this.targetGuest);
123
55
  return this;
124
56
  }
125
57
  disposed(value) {
@@ -128,10 +60,19 @@ class GuestCast {
128
60
  }
129
61
  }
130
62
 
131
- var __defProp$5 = Object.defineProperty;
132
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
133
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
63
+ var __defProp$6 = Object.defineProperty;
64
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
65
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
134
66
  const poolSets = /* @__PURE__ */ new Map();
67
+ const patronPools = (patron) => {
68
+ const pools = [];
69
+ poolSets.forEach((pool, poolInstance) => {
70
+ if (pool.has(patron)) {
71
+ pools.push(poolInstance);
72
+ }
73
+ });
74
+ return pools;
75
+ };
135
76
  const removePatronFromPools = (patron) => {
136
77
  if (patron === void 0) {
137
78
  throw new Error("removePatronFromPools didnt receive patron argument");
@@ -155,24 +96,17 @@ const isPatronInPools = (patron) => {
155
96
  class PatronPool {
156
97
  constructor(initiator) {
157
98
  this.initiator = initiator;
158
- __publicField$5(this, "patrons");
159
- __publicField$5(this, "give");
99
+ __publicField$6(this, "patrons");
100
+ __publicField$6(this, "give");
160
101
  this.patrons = /* @__PURE__ */ new Set();
161
102
  poolSets.set(this, this.patrons);
162
- let lastMicrotask = null;
163
- const doReceive = (value, options) => {
103
+ const doReceive = (value) => {
164
104
  this.patrons.forEach((target) => {
165
- this.sendValueToGuest(value, target, options);
105
+ this.sendValueToGuest(value, target);
166
106
  });
167
107
  };
168
- this.give = (value, options) => {
169
- const currentMicroTask = () => {
170
- if (currentMicroTask === lastMicrotask) {
171
- doReceive(value, options);
172
- }
173
- };
174
- lastMicrotask = currentMicroTask;
175
- queueMicrotask(currentMicroTask);
108
+ this.give = (value) => {
109
+ doReceive(value);
176
110
  return this;
177
111
  };
178
112
  }
@@ -194,20 +128,13 @@ class PatronPool {
194
128
  }
195
129
  distribute(receiving, possiblePatron) {
196
130
  this.add(possiblePatron);
197
- this.sendValueToGuest(receiving, possiblePatron, {});
131
+ this.sendValueToGuest(receiving, possiblePatron);
198
132
  return this;
199
133
  }
200
- sendValueToGuest(value, guest, options) {
134
+ sendValueToGuest(value, guest) {
201
135
  const isDisposed = this.guestDisposed(value, guest);
202
136
  if (!isDisposed) {
203
- give(value, guest, {
204
- ...options,
205
- data: {
206
- ...options?.data ?? {},
207
- initiator: this.initiator,
208
- pool: this
209
- }
210
- });
137
+ give(value, guest);
211
138
  }
212
139
  }
213
140
  guestDisposed(value, guest) {
@@ -219,58 +146,61 @@ class PatronPool {
219
146
  }
220
147
  }
221
148
 
222
- var __defProp$4 = Object.defineProperty;
223
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
225
- class Source {
226
- constructor(sourceDocument) {
227
- this.sourceDocument = sourceDocument;
228
- __publicField$4(this, "thePool", new PatronPool(this));
229
- if (sourceDocument === void 0) {
230
- throw new Error("Source didnt receive sourceDocument argument");
231
- }
232
- }
233
- pool() {
234
- return this.thePool;
149
+ var __defProp$5 = Object.defineProperty;
150
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
151
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
152
+ class GuestPool {
153
+ constructor(initiator) {
154
+ __publicField$5(this, "guests", /* @__PURE__ */ new Set());
155
+ __publicField$5(this, "patronPool");
156
+ this.patronPool = new PatronPool(initiator);
235
157
  }
236
158
  give(value) {
237
- this.sourceDocument = value;
238
- this.thePool.give(this.sourceDocument);
159
+ this.deliverToGuests(value);
160
+ this.patronPool.give(value);
239
161
  return this;
240
162
  }
241
- value(guest) {
242
- if (typeof guest === "function") {
243
- this.thePool.distribute(this.sourceDocument, new Guest(guest));
244
- } else {
245
- this.thePool.distribute(this.sourceDocument, guest);
163
+ add(guest) {
164
+ if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
165
+ this.guests.add(guest);
246
166
  }
167
+ this.patronPool.add(guest);
247
168
  return this;
248
169
  }
249
- }
250
-
251
- var __defProp$3 = Object.defineProperty;
252
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
253
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
254
- class SourceEmpty {
255
- constructor() {
256
- __publicField$3(this, "baseSource", new Source(null));
170
+ remove(patron) {
171
+ this.guests.delete(patron);
172
+ this.patronPool.remove(patron);
173
+ return this;
257
174
  }
258
- value(guest) {
259
- this.baseSource.value(
260
- new GuestCast(guest, (value, options) => {
261
- if (value !== null) {
262
- give(value, guest, options);
263
- }
264
- })
265
- );
175
+ distribute(receiving, possiblePatron) {
176
+ this.add(possiblePatron);
177
+ this.give(receiving);
266
178
  return this;
267
179
  }
180
+ size() {
181
+ return this.patronPool.size() + this.guests.size;
182
+ }
183
+ deliverToGuests(value) {
184
+ this.guests.forEach((target) => {
185
+ give(value, target);
186
+ });
187
+ this.guests.clear();
188
+ }
189
+ }
190
+
191
+ class GuestSync {
192
+ constructor(theValue) {
193
+ this.theValue = theValue;
194
+ if (theValue === void 0) {
195
+ throw new Error("GuestSync didnt receive theValue argument");
196
+ }
197
+ }
268
198
  give(value) {
269
- this.baseSource.give(value);
199
+ this.theValue = value;
270
200
  return this;
271
201
  }
272
- pool() {
273
- return this.baseSource.pool();
202
+ value() {
203
+ return this.theValue;
274
204
  }
275
205
  }
276
206
 
@@ -281,12 +211,12 @@ class GuestObject {
281
211
  throw new Error("GuestObject didnt receive baseGuest argument");
282
212
  }
283
213
  }
284
- give(value, options) {
214
+ give(value) {
285
215
  let guest = this.baseGuest;
286
216
  if (typeof guest === "function") {
287
217
  guest = new Guest(guest);
288
218
  }
289
- guest.give(value, options);
219
+ guest.give(value);
290
220
  return this;
291
221
  }
292
222
  introduction() {
@@ -301,58 +231,138 @@ class GuestObject {
301
231
  }
302
232
  }
303
233
 
304
- var __defProp$2 = Object.defineProperty;
305
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
306
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
307
- class GuestPool {
308
- constructor(initiator) {
309
- __publicField$2(this, "guests", /* @__PURE__ */ new Set());
310
- __publicField$2(this, "patronPool");
311
- this.patronPool = new PatronPool(initiator);
234
+ class GuestDisposable {
235
+ constructor(guest, disposeCheck) {
236
+ this.guest = guest;
237
+ this.disposeCheck = disposeCheck;
238
+ if (guest === void 0) {
239
+ throw new Error("GuestDisposable didnt receive guest argument");
240
+ }
241
+ if (disposeCheck === void 0) {
242
+ throw new Error("GuestDisposable didnt receive disposeCheck argument");
243
+ }
312
244
  }
313
- give(value, options) {
314
- this.deliverToGuests(value, options);
315
- this.patronPool.give(value, options);
245
+ disposed(value) {
246
+ return this.disposeCheck(value);
247
+ }
248
+ give(value) {
249
+ give(value, this.guest);
316
250
  return this;
317
251
  }
318
- add(guest) {
319
- if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
320
- this.guests.add(guest);
252
+ }
253
+
254
+ class GuestApplied {
255
+ constructor(baseGuest, applier) {
256
+ this.baseGuest = baseGuest;
257
+ this.applier = applier;
258
+ }
259
+ give(value) {
260
+ give(this.applier(value), this.baseGuest);
261
+ return this;
262
+ }
263
+ }
264
+
265
+ class Patron {
266
+ constructor(willBePatron) {
267
+ this.willBePatron = willBePatron;
268
+ if (willBePatron === void 0) {
269
+ throw new Error("Patron didnt receive willBePatron argument");
321
270
  }
322
- this.patronPool.add(guest);
271
+ }
272
+ introduction() {
273
+ return "patron";
274
+ }
275
+ give(value) {
276
+ give(value, this.willBePatron);
323
277
  return this;
324
278
  }
325
- remove(patron) {
326
- this.guests.delete(patron);
327
- this.patronPool.remove(patron);
279
+ disposed(value) {
280
+ const maybeDisposable = this.willBePatron;
281
+ return maybeDisposable?.disposed?.(value) || false;
282
+ }
283
+ }
284
+ const isPatron = (guest) => typeof guest === "object" && guest !== null && guest?.introduction?.() === "patron";
285
+
286
+ var __defProp$4 = Object.defineProperty;
287
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
288
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
289
+ class PatronOnce {
290
+ constructor(baseGuest) {
291
+ this.baseGuest = baseGuest;
292
+ __publicField$4(this, "received", false);
293
+ if (baseGuest === void 0) {
294
+ throw new Error("PatronOnce didnt receive baseGuest argument");
295
+ }
296
+ }
297
+ introduction() {
298
+ return "patron";
299
+ }
300
+ give(value) {
301
+ if (!this.received) {
302
+ this.received = true;
303
+ give(value, this.baseGuest);
304
+ }
328
305
  return this;
329
306
  }
330
- distribute(receiving, possiblePatron) {
331
- this.add(possiblePatron);
332
- this.give(receiving);
307
+ disposed(value) {
308
+ if (this.received) {
309
+ return true;
310
+ }
311
+ const maybeDisposable = this.baseGuest;
312
+ return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
313
+ }
314
+ }
315
+
316
+ var __defProp$3 = Object.defineProperty;
317
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
318
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
319
+ class SourceWithPool {
320
+ constructor(sourceDocument) {
321
+ this.sourceDocument = sourceDocument;
322
+ __publicField$3(this, "thePool", new PatronPool(this));
323
+ __publicField$3(this, "theEmptyPool", new PatronPool(this));
324
+ __publicField$3(this, "isEmpty");
325
+ this.isEmpty = sourceDocument === void 0;
326
+ }
327
+ pool() {
328
+ return this.thePool;
329
+ }
330
+ give(value) {
331
+ this.isEmpty = false;
332
+ this.sourceDocument = value;
333
+ this.thePool.give(this.sourceDocument);
334
+ this.theEmptyPool.give(this.sourceDocument);
333
335
  return this;
334
336
  }
335
- size() {
336
- return this.patronPool.size() + this.guests.size;
337
+ value(guest) {
338
+ if (this.isEmpty) {
339
+ if (isPatron(guest)) {
340
+ this.theEmptyPool.add(guest);
341
+ }
342
+ return this;
343
+ }
344
+ if (typeof guest === "function") {
345
+ this.thePool.distribute(this.sourceDocument, new Guest(guest));
346
+ } else {
347
+ this.thePool.distribute(this.sourceDocument, guest);
348
+ }
349
+ return this;
337
350
  }
338
- deliverToGuests(value, options) {
339
- this.guests.forEach((target) => {
340
- give(value, target, options);
341
- });
342
- this.guests.clear();
351
+ filled() {
352
+ return !this.isEmpty;
343
353
  }
344
354
  }
345
355
 
346
- var __defProp$1 = Object.defineProperty;
347
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
348
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
349
- class GuestAwareAll {
356
+ var __defProp$2 = Object.defineProperty;
357
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
358
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
359
+ class SourceAll {
350
360
  constructor(initialKnownKeys = []) {
351
- __publicField$1(this, "theAll");
352
- __publicField$1(this, "keysKnown");
353
- __publicField$1(this, "keysFilled", /* @__PURE__ */ new Set());
354
- __publicField$1(this, "filledAllPool", new GuestPool(this));
355
- this.theAll = new Source({});
361
+ __publicField$2(this, "theAll");
362
+ __publicField$2(this, "keysKnown");
363
+ __publicField$2(this, "keysFilled", /* @__PURE__ */ new Set());
364
+ __publicField$2(this, "filledAllPool", new GuestPool(this));
365
+ this.theAll = new SourceWithPool({});
356
366
  this.keysKnown = new Set(initialKnownKeys);
357
367
  }
358
368
  valueArray(guest) {
@@ -408,20 +418,53 @@ class GuestAwareAll {
408
418
  }
409
419
  }
410
420
 
411
- class GuestAwareSequence {
421
+ function value(source, guest) {
422
+ if (source === void 0) {
423
+ throw new Error("value didnt receive source argument");
424
+ }
425
+ if (guest === void 0) {
426
+ throw new Error("value didnt receive guest argument");
427
+ }
428
+ if (typeof source === "function") {
429
+ return source(guest);
430
+ } else {
431
+ return source.value(guest);
432
+ }
433
+ }
434
+ function isSource(mbSource) {
435
+ if (mbSource === void 0) {
436
+ throw new Error("isSource didnt receive mbSource argument");
437
+ }
438
+ return typeof mbSource === "function" || typeof mbSource?.value === "function";
439
+ }
440
+ class Source {
441
+ constructor(source) {
442
+ this.source = source;
443
+ if (source === void 0) {
444
+ throw new Error("Source constructor didnt receive executor function");
445
+ }
446
+ }
447
+ value(guest) {
448
+ value(this.source, guest);
449
+ return guest;
450
+ }
451
+ }
452
+ const sourceOf = (value2) => new Source((g) => give(value2, g));
453
+
454
+ class SourceSequence {
412
455
  constructor(baseSource, targetSource) {
413
456
  this.baseSource = baseSource;
414
457
  this.targetSource = targetSource;
415
458
  if (baseSource === void 0) {
416
- throw new Error("GuestAwareSequence didnt receive baseSource argument");
459
+ throw new Error("SourceSequence didnt receive baseSource argument");
417
460
  }
418
461
  if (targetSource === void 0) {
419
- throw new Error("GuestAwareSequence didnt receive targetSource argument");
462
+ throw new Error("SourceSequence didnt receive targetSource argument");
420
463
  }
421
464
  }
422
465
  value(guest) {
423
- const all = new GuestAwareAll();
424
- const sequenceSource = new SourceEmpty();
466
+ const all = new SourceAll();
467
+ const sequenceSource = new SourceWithPool();
425
468
  const targetSource = this.targetSource.get(sequenceSource);
426
469
  value(
427
470
  this.baseSource,
@@ -438,7 +481,7 @@ class GuestAwareSequence {
438
481
  function handle() {
439
482
  sequenceSource.give(null);
440
483
  const nextValue = theValue[index];
441
- if (isGuestAware(nextValue)) {
484
+ if (isSource(nextValue)) {
442
485
  value(
443
486
  nextValue,
444
487
  new PatronOnce((theNextValue) => {
@@ -464,24 +507,24 @@ class GuestAwareSequence {
464
507
  }
465
508
  }
466
509
 
467
- class GuestAwareMap {
510
+ class SourceMap {
468
511
  constructor(baseSource, targetSource) {
469
512
  this.baseSource = baseSource;
470
513
  this.targetSource = targetSource;
471
514
  if (baseSource === void 0) {
472
- throw new Error("GuestAwareMap didnt receive baseSource argument");
515
+ throw new Error("SourceMap didnt receive baseSource argument");
473
516
  }
474
517
  if (targetSource === void 0) {
475
- throw new Error("GuestAwareMap didnt receive targetSource argument");
518
+ throw new Error("SourceMap didnt receive targetSource argument");
476
519
  }
477
520
  }
478
521
  value(guest) {
479
- const all = new GuestAwareAll();
522
+ const all = new SourceAll();
480
523
  value(
481
524
  this.baseSource,
482
525
  new GuestCast(guest, (theValue) => {
483
526
  theValue.forEach((val, index) => {
484
- const valueSource = isGuestAware(val) ? val : new GuestAware((innerGuest) => {
527
+ const valueSource = isSource(val) ? val : new Source((innerGuest) => {
485
528
  give(val, innerGuest);
486
529
  });
487
530
  const targetSource = this.targetSource.get(valueSource);
@@ -494,22 +537,22 @@ class GuestAwareMap {
494
537
  }
495
538
  }
496
539
 
497
- class GuestAwareRace {
498
- constructor(guestAwares) {
499
- this.guestAwares = guestAwares;
500
- if (guestAwares === void 0) {
501
- throw new Error("GuestAwareRace didnt receive guestAwares argument");
540
+ class SourceRace {
541
+ constructor(sources) {
542
+ this.sources = sources;
543
+ if (sources === void 0) {
544
+ throw new Error("SourceRace didnt receive sources argument");
502
545
  }
503
546
  }
504
547
  value(guest) {
505
- let connectedWithGuestAware = null;
506
- this.guestAwares.forEach((guestAware) => {
548
+ let connectedWithSource = null;
549
+ this.sources.forEach((source) => {
507
550
  value(
508
- guestAware,
551
+ source,
509
552
  new GuestCast(guest, (value2) => {
510
- if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {
553
+ if (!connectedWithSource || connectedWithSource === source) {
511
554
  give(value2, guest);
512
- connectedWithGuestAware = guestAware;
555
+ connectedWithSource = source;
513
556
  }
514
557
  })
515
558
  );
@@ -518,16 +561,16 @@ class GuestAwareRace {
518
561
  }
519
562
  }
520
563
 
521
- var __defProp = Object.defineProperty;
522
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
523
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
524
- class GuestAwareActive {
564
+ var __defProp$1 = Object.defineProperty;
565
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
566
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
567
+ class SourceActive {
525
568
  constructor(configExecutor) {
526
569
  this.configExecutor = configExecutor;
527
- __publicField(this, "source", new SourceEmpty());
570
+ __publicField$1(this, "source", new SourceWithPool());
528
571
  if (configExecutor === void 0) {
529
572
  throw new Error(
530
- "GuestAwareActive constructor didnt receive executor function"
573
+ "SourceActive constructor didnt receive executor function"
531
574
  );
532
575
  }
533
576
  }
@@ -541,75 +584,19 @@ class GuestAwareActive {
541
584
  }
542
585
  }
543
586
 
544
- class GuestSync {
545
- constructor(theValue) {
546
- this.theValue = theValue;
547
- if (theValue === void 0) {
548
- throw new Error("GuestSync didnt receive theValue argument");
549
- }
550
- }
551
- give(value) {
552
- this.theValue = value;
553
- return this;
554
- }
555
- value() {
556
- return this.theValue;
557
- }
558
- }
559
-
560
- class GuestDisposable {
561
- constructor(guest, disposeCheck) {
562
- this.guest = guest;
563
- this.disposeCheck = disposeCheck;
564
- if (guest === void 0) {
565
- throw new Error("GuestDisposable didnt receive guest argument");
566
- }
567
- if (disposeCheck === void 0) {
568
- throw new Error("GuestDisposable didnt receive disposeCheck argument");
569
- }
570
- }
571
- disposed(value) {
572
- return this.disposeCheck(value);
573
- }
574
- give(value, options) {
575
- give(value, this.guest, options);
576
- return this;
577
- }
578
- }
579
-
580
- class Patron {
581
- constructor(willBePatron) {
582
- this.willBePatron = willBePatron;
583
- if (willBePatron === void 0) {
584
- throw new Error("Patron didnt receive willBePatron argument");
585
- }
586
- }
587
- introduction() {
588
- return "patron";
589
- }
590
- give(value, options) {
591
- give(value, this.willBePatron, options);
592
- return this;
593
- }
594
- disposed(value) {
595
- const maybeDisposable = this.willBePatron;
596
- return maybeDisposable?.disposed?.(value) || false;
597
- }
598
- }
599
-
600
587
  class SourceDynamic {
601
- constructor(baseGuest, baseGuestAware) {
588
+ constructor(baseGuest, baseSource) {
602
589
  this.baseGuest = baseGuest;
603
- this.baseGuestAware = baseGuestAware;
590
+ this.baseSource = baseSource;
604
591
  if (baseGuest === void 0) {
605
592
  throw new Error("SourceDynamic didnt receive baseGuest argument");
606
593
  }
607
- if (baseGuestAware === void 0) {
608
- throw new Error("SourceDynamic didnt receive baseGuestAware argument");
594
+ if (baseSource === void 0) {
595
+ throw new Error("SourceDynamic didnt receive baseSource argument");
609
596
  }
610
597
  }
611
598
  value(guest) {
612
- value(this.baseGuestAware, guest);
599
+ value(this.baseSource, guest);
613
600
  return this;
614
601
  }
615
602
  give(value2) {
@@ -621,6 +608,34 @@ class SourceDynamic {
621
608
  }
622
609
  }
623
610
 
611
+ class SourceApplied {
612
+ constructor(baseSource, applier) {
613
+ this.baseSource = baseSource;
614
+ this.applier = applier;
615
+ }
616
+ value(g) {
617
+ value(
618
+ this.baseSource,
619
+ new GuestCast(g, (v) => {
620
+ give(this.applier(v), g);
621
+ })
622
+ );
623
+ return this;
624
+ }
625
+ }
626
+
627
+ var __defProp = Object.defineProperty;
628
+ var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
629
+ var __publicField = (obj, key, value2) => __defNormalProp(obj, key + "" , value2);
630
+ class SourceExecutorApplied {
631
+ constructor(source, applier) {
632
+ __publicField(this, "value");
633
+ this.value = applier((g) => {
634
+ value(source, g);
635
+ });
636
+ }
637
+ }
638
+
624
639
  class PrivateClass {
625
640
  constructor(constructorFn, modules = {}) {
626
641
  this.constructorFn = constructorFn;
@@ -649,5 +664,5 @@ class Private {
649
664
  }
650
665
  }
651
666
 
652
- export { Guest, GuestAware, GuestAwareActive, GuestAwareAll, GuestAwareMap, GuestAwareRace, GuestAwareSequence, GuestCast, GuestDisposable, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Private, PrivateClass, Source, SourceDynamic, SourceEmpty, give, isGuest, isGuestAware, isPatronInPools, removePatronFromPools, value };
667
+ export { Guest, GuestApplied, GuestCast, GuestDisposable, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Private, PrivateClass, Source, SourceActive, SourceAll, SourceApplied, SourceDynamic, SourceExecutorApplied, SourceMap, SourceRace, SourceSequence, SourceWithPool, give, isGuest, isPatron, isPatronInPools, isSource, patronPools, removePatronFromPools, sourceOf, value };
653
668
  //# sourceMappingURL=patron.mjs.map