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