patron-oop 1.15.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.16.0](https://github.com/kosukhin/patron/compare/v1.15.0...v1.16.0) (2024-11-02)
6
+
7
+
8
+ ### Features
9
+
10
+ * **main:** переименовать receive-receiving в give-value ([02c5eb7](https://github.com/kosukhin/patron/commit/02c5eb70c2305a304a96c5772ddce1b309772457))
11
+
5
12
  ## [1.15.0](https://github.com/kosukhin/patron/compare/v1.14.0...v1.15.0) (2024-11-01)
6
13
 
7
14
 
package/dist/patron.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  type GuestIntroduction = "guest" | "patron";
2
- interface ReceiveOptions {
2
+ interface GiveOptions {
3
3
  data?: unknown;
4
4
  }
5
- type GuestExecutorType<T = unknown> = (value: T, options?: ReceiveOptions) => void;
5
+ type GuestExecutorType<T = unknown> = (value: T, options?: GiveOptions) => void;
6
6
  interface GuestObjectType<T = unknown> {
7
- receive(value: T, options?: ReceiveOptions): this;
7
+ give(value: T, options?: GiveOptions): this;
8
8
  introduction?(): GuestIntroduction;
9
9
  }
10
10
  type GuestType<T = unknown> = GuestExecutorType<T> | GuestObjectType<T>;
11
- declare function give<T>(data: T, guest: GuestType<T>, options?: ReceiveOptions): void;
11
+ declare function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions): void;
12
12
  declare class Guest<T> implements GuestObjectType<T> {
13
13
  private receiver;
14
14
  constructor(receiver: GuestExecutorType<T>);
15
- receive(value: T, options?: ReceiveOptions): this;
15
+ give(value: T, options?: GiveOptions): this;
16
16
  }
17
17
 
18
18
  interface GuestAwareType<T = unknown> {
19
- receiving(guest: GuestType<T>): unknown;
19
+ value(guest: GuestType<T>): unknown;
20
20
  }
21
21
  declare class GuestAware<T = unknown> implements GuestAwareType<T> {
22
22
  private guestReceiver;
23
23
  constructor(guestReceiver: (guest: GuestType<T>) => void);
24
- receiving(guest: GuestType<T>): GuestType<T>;
24
+ value(guest: GuestType<T>): GuestType<T>;
25
25
  }
26
26
 
27
27
  declare class GuestCast<T> implements GuestObjectType<T> {
@@ -29,7 +29,7 @@ declare class GuestCast<T> implements GuestObjectType<T> {
29
29
  private targetGuest;
30
30
  constructor(sourceGuest: GuestType<unknown>, targetGuest: GuestType<T>);
31
31
  introduction(): "guest" | "patron";
32
- receive(value: T, options?: ReceiveOptions): this;
32
+ give(value: T, options?: GiveOptions): this;
33
33
  }
34
34
 
35
35
  interface ChainType<T = unknown> {
@@ -52,14 +52,11 @@ declare class GuestChain<T> implements ChainType<T> {
52
52
  declare class GuestMiddle<T> implements GuestObjectType<T> {
53
53
  private baseGuest;
54
54
  private middleFn;
55
- constructor(baseGuest: GuestType<unknown>, middleFn: (value: T, options?: ReceiveOptions) => void);
55
+ constructor(baseGuest: GuestType<unknown>, middleFn: (value: T, options?: GiveOptions) => void);
56
56
  introduction(): "guest" | "patron";
57
- receive(value: T, options?: ReceiveOptions): this;
57
+ give(value: T, options?: GiveOptions): this;
58
58
  }
59
59
 
60
- /**
61
- * Удалить патрон из всех пулов
62
- */
63
60
  declare const removePatronFromPools: (patron: GuestObjectType) => void;
64
61
  interface PoolType<T = unknown> extends GuestObjectType<T> {
65
62
  add(guest: GuestObjectType<T>): this;
@@ -69,7 +66,7 @@ interface PoolType<T = unknown> extends GuestObjectType<T> {
69
66
  declare class PatronPool<T> implements PoolType<T> {
70
67
  private initiator;
71
68
  private patrons;
72
- receive: (value: T, options?: ReceiveOptions) => this;
69
+ give: (value: T, options?: GiveOptions) => this;
73
70
  constructor(initiator: unknown);
74
71
  add(shouldBePatron: GuestType<T>): this;
75
72
  remove(patron: GuestObjectType<T>): this;
@@ -81,7 +78,7 @@ declare class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {
81
78
  private guests;
82
79
  private patronPool;
83
80
  constructor(initiator: unknown);
84
- receive(value: T, options?: ReceiveOptions): this;
81
+ give(value: T, options?: GiveOptions): this;
85
82
  add(guest: GuestType<T>): this;
86
83
  remove(patron: GuestObjectType<T>): this;
87
84
  distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;
@@ -94,18 +91,15 @@ interface GuestValueType<T = unknown> extends GuestObjectType<T> {
94
91
  declare class GuestSync<T> implements GuestValueType<T> {
95
92
  private theValue;
96
93
  constructor(theValue: T);
97
- receive(value: T): this;
94
+ give(value: T): this;
98
95
  value(): T;
99
96
  }
100
97
 
101
- /**
102
- * Патрон - это постоянный посетитель
103
- */
104
98
  declare class Patron<T> implements GuestObjectType<T> {
105
99
  private willBePatron;
106
100
  constructor(willBePatron: GuestType<T>);
107
101
  introduction(): "patron";
108
- receive(value: T, options?: ReceiveOptions): this;
102
+ give(value: T, options?: GiveOptions): this;
109
103
  }
110
104
 
111
105
  declare class PatronOnce<T> implements GuestObjectType<T> {
@@ -113,7 +107,7 @@ declare class PatronOnce<T> implements GuestObjectType<T> {
113
107
  private received;
114
108
  constructor(baseGuest: GuestType<T>);
115
109
  introduction(): "patron";
116
- receive(value: T, options?: ReceiveOptions): this;
110
+ give(value: T, options?: GiveOptions): this;
117
111
  }
118
112
 
119
113
  type SourceType<T = unknown> = GuestAwareType<T> & GuestObjectType<T>;
@@ -121,20 +115,20 @@ declare class Source<T> implements SourceType<T> {
121
115
  private sourceDocument;
122
116
  private pool;
123
117
  constructor(sourceDocument: T);
124
- receive(value: T): this;
125
- receiving(guest: GuestType<T>): this;
118
+ give(value: T): this;
119
+ value(guest: GuestType<T>): this;
126
120
  }
127
121
 
128
122
  declare class SourceEmpty<T> implements SourceType<T> {
129
123
  private baseSource;
130
- receiving(guest: GuestType<T>): this;
131
- receive(value: T): this;
124
+ value(guest: GuestType<T>): this;
125
+ give(value: T): this;
132
126
  }
133
127
 
134
128
  declare class GuestObject<T> implements GuestObjectType<T> {
135
129
  private baseGuest;
136
130
  constructor(baseGuest: GuestType<T>);
137
- receive(value: T, options?: ReceiveOptions): this;
131
+ give(value: T, options?: GiveOptions): this;
138
132
  introduction(): "guest" | "patron";
139
133
  }
140
134
 
@@ -151,4 +145,4 @@ declare class Factory<T> implements FactoryType<T> {
151
145
  create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
152
146
  }
153
147
 
154
- export { type ChainType, Factory, type FactoryType, Guest, GuestAware, type GuestAwareType, GuestCast, GuestChain, type GuestExecutorType, GuestMiddle, GuestObject, type GuestObjectType, GuestPool, GuestSync, type GuestType, type GuestValueType, Patron, PatronOnce, PatronPool, type PoolType, type ReceiveOptions, Source, SourceEmpty, type SourceType, give, removePatronFromPools };
148
+ export { type ChainType, Factory, type FactoryType, type GiveOptions, Guest, GuestAware, type GuestAwareType, GuestCast, GuestChain, type GuestExecutorType, GuestMiddle, GuestObject, type GuestObjectType, GuestPool, GuestSync, type GuestType, type GuestValueType, Patron, PatronOnce, PatronPool, type PoolType, Source, SourceEmpty, type SourceType, give, removePatronFromPools };
package/dist/patron.js CHANGED
@@ -4,7 +4,7 @@ class GuestAware {
4
4
  constructor(guestReceiver) {
5
5
  this.guestReceiver = guestReceiver;
6
6
  }
7
- receiving(guest) {
7
+ value(guest) {
8
8
  this.guestReceiver(guest);
9
9
  return guest;
10
10
  }
@@ -14,14 +14,14 @@ function give(data, guest, options) {
14
14
  if (typeof guest === "function") {
15
15
  guest(data, options);
16
16
  } else {
17
- guest.receive(data, options);
17
+ guest.give(data, options);
18
18
  }
19
19
  }
20
20
  class Guest {
21
21
  constructor(receiver) {
22
22
  this.receiver = receiver;
23
23
  }
24
- receive(value, options) {
24
+ give(value, options) {
25
25
  this.receiver(value, options);
26
26
  return this;
27
27
  }
@@ -41,7 +41,7 @@ class GuestCast {
41
41
  }
42
42
  return this.sourceGuest.introduction();
43
43
  }
44
- receive(value, options) {
44
+ give(value, options) {
45
45
  give(value, this.targetGuest, options);
46
46
  return this;
47
47
  }
@@ -60,7 +60,7 @@ class PatronPool {
60
60
  constructor(initiator) {
61
61
  this.initiator = initiator;
62
62
  __publicField$5(this, "patrons", /* @__PURE__ */ new Set());
63
- __publicField$5(this, "receive");
63
+ __publicField$5(this, "give");
64
64
  poolSets.set(this, this.patrons);
65
65
  let lastMicrotask = null;
66
66
  const doReceive = (value, options) => {
@@ -68,7 +68,7 @@ class PatronPool {
68
68
  this.sendValueToGuest(value, target, options);
69
69
  });
70
70
  };
71
- this.receive = (value, options) => {
71
+ this.give = (value, options) => {
72
72
  const currentMicroTask = () => {
73
73
  if (currentMicroTask === lastMicrotask) {
74
74
  doReceive(value, options);
@@ -115,9 +115,9 @@ class GuestPool {
115
115
  __publicField$4(this, "patronPool");
116
116
  this.patronPool = new PatronPool(initiator);
117
117
  }
118
- receive(value, options) {
118
+ give(value, options) {
119
119
  this.deliverToGuests(value, options);
120
- this.patronPool.receive(value, options);
120
+ this.patronPool.give(value, options);
121
121
  return this;
122
122
  }
123
123
  add(guest) {
@@ -134,7 +134,7 @@ class GuestPool {
134
134
  }
135
135
  distribute(receiving, possiblePatron) {
136
136
  this.add(possiblePatron);
137
- this.receive(receiving);
137
+ this.give(receiving);
138
138
  return this;
139
139
  }
140
140
  deliverToGuests(value, options) {
@@ -156,7 +156,7 @@ class GuestMiddle {
156
156
  }
157
157
  return this.baseGuest.introduction();
158
158
  }
159
- receive(value, options) {
159
+ give(value, options) {
160
160
  this.middleFn(value, options);
161
161
  return this;
162
162
  }
@@ -170,12 +170,12 @@ class Source {
170
170
  this.sourceDocument = sourceDocument;
171
171
  __publicField$3(this, "pool", new PatronPool(this));
172
172
  }
173
- receive(value) {
173
+ give(value) {
174
174
  this.sourceDocument = value;
175
- this.pool.receive(this.sourceDocument);
175
+ this.pool.give(this.sourceDocument);
176
176
  return this;
177
177
  }
178
- receiving(guest) {
178
+ value(guest) {
179
179
  if (typeof guest === "function") {
180
180
  this.pool.distribute(this.sourceDocument, new Guest(guest));
181
181
  } else {
@@ -189,12 +189,12 @@ class GuestObject {
189
189
  constructor(baseGuest) {
190
190
  this.baseGuest = baseGuest;
191
191
  }
192
- receive(value, options) {
192
+ give(value, options) {
193
193
  let guest = this.baseGuest;
194
194
  if (typeof guest === "function") {
195
195
  guest = new Guest(guest);
196
196
  }
197
- guest.receive(value, options);
197
+ guest.give(value, options);
198
198
  return this;
199
199
  }
200
200
  introduction() {
@@ -225,9 +225,9 @@ class GuestChain {
225
225
  )
226
226
  );
227
227
  if (this.isChainFilled()) {
228
- this.theChain.receiving(
228
+ this.theChain.value(
229
229
  new Guest((chain) => {
230
- this.filledChainPool.receive(Object.values(chain));
230
+ this.filledChainPool.give(Object.values(chain));
231
231
  })
232
232
  );
233
233
  }
@@ -237,9 +237,9 @@ class GuestChain {
237
237
  const guestObject = new GuestObject(guest);
238
238
  if (this.isChainFilled()) {
239
239
  this.filledChainPool.add(guestObject);
240
- this.theChain.receiving(
240
+ this.theChain.value(
241
241
  new Guest((chain) => {
242
- this.filledChainPool.receive(chain);
242
+ this.filledChainPool.give(chain);
243
243
  })
244
244
  );
245
245
  } else {
@@ -251,16 +251,16 @@ class GuestChain {
251
251
  this.keysKnown.add(key);
252
252
  return new Guest((value) => {
253
253
  queueMicrotask(() => {
254
- this.theChain.receiving(
254
+ this.theChain.value(
255
255
  new Guest((chain) => {
256
256
  this.keysFilled.add(key);
257
257
  const lastChain = {
258
258
  ...chain,
259
259
  [key]: value
260
260
  };
261
- this.theChain.receive(lastChain);
261
+ this.theChain.give(lastChain);
262
262
  if (this.isChainFilled()) {
263
- this.filledChainPool.receive(lastChain);
263
+ this.filledChainPool.give(lastChain);
264
264
  }
265
265
  })
266
266
  );
@@ -276,7 +276,7 @@ class GuestSync {
276
276
  constructor(theValue) {
277
277
  this.theValue = theValue;
278
278
  }
279
- receive(value) {
279
+ give(value) {
280
280
  this.theValue = value;
281
281
  return this;
282
282
  }
@@ -292,7 +292,7 @@ class Patron {
292
292
  introduction() {
293
293
  return "patron";
294
294
  }
295
- receive(value, options) {
295
+ give(value, options) {
296
296
  give(value, this.willBePatron, options);
297
297
  return this;
298
298
  }
@@ -309,7 +309,7 @@ class PatronOnce {
309
309
  introduction() {
310
310
  return "patron";
311
311
  }
312
- receive(value, options) {
312
+ give(value, options) {
313
313
  if (!this.received) {
314
314
  give(value, this.baseGuest, options);
315
315
  }
@@ -328,8 +328,8 @@ class SourceEmpty {
328
328
  constructor() {
329
329
  __publicField(this, "baseSource", new Source(null));
330
330
  }
331
- receiving(guest) {
332
- this.baseSource.receiving(
331
+ value(guest) {
332
+ this.baseSource.value(
333
333
  new GuestMiddle(guest, (value) => {
334
334
  if (value !== null) {
335
335
  give(value, guest);
@@ -338,8 +338,8 @@ class SourceEmpty {
338
338
  );
339
339
  return this;
340
340
  }
341
- receive(value) {
342
- this.baseSource.receive(value);
341
+ give(value) {
342
+ this.baseSource.give(value);
343
343
  return this;
344
344
  }
345
345
  }
@@ -350,7 +350,10 @@ class Factory {
350
350
  this.factories = factories;
351
351
  }
352
352
  create(...args) {
353
- return new this.constructorFn(...args, this.factories);
353
+ return new this.constructorFn(
354
+ ...args,
355
+ this.factories
356
+ );
354
357
  }
355
358
  }
356
359
 
@@ -1 +1 @@
1
- {"version":3,"file":"patron.js","sources":["../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Guest/GuestCast.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestMiddle.ts","../src/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceEmpty.ts","../src/Factory/Factory.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport interface GuestAwareType<T = unknown> {\n receiving(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface ReceiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = unknown> = (\n value: T,\n options?: ReceiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = unknown> {\n receive(value: T, options?: ReceiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = unknown> = GuestExecutorType<T> | GuestObjectType<T>;\n\nexport function give<T>(\n data: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.receive(data, options);\n }\n}\n\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, ReceiveOptions } from \"./Guest\";\n\nexport class GuestCast<T> implements GuestObjectType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n}\n","import {\n give,\n GuestObjectType,\n GuestType,\n ReceiveOptions,\n} from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestObjectType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n give(value, guest, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, ReceiveOptions } from \"./Guest\";\n\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestObjectType, GuestType, ReceiveOptions } from \"./Guest\";\n\nexport class GuestMiddle<T> implements GuestObjectType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestObjectType<T>;\n\nexport class Source<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.pool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.pool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import { Guest, GuestObjectType, GuestType, ReceiveOptions } from \"./Guest\";\n\nexport class GuestObject<T> implements GuestObjectType<T> {\n public constructor(private baseGuest: GuestType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.receive(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n\n return this.baseGuest.introduction();\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestMiddle } from \"./GuestMiddle\";\nimport { Source } from \"../Source/Source\";\nimport { GuestObject } from \"./GuestObject\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: Source<Record<string, unknown>>;\n\n private keysKnown = new Set();\n\n private keysFilled = new Set();\n\n private filledChainPool = new GuestPool(this);\n\n public constructor() {\n this.theChain = new Source<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledChainPool.add(\n new GuestMiddle(guestObject, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.receiving(\n new Guest((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = unknown> extends GuestObjectType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import {\n give,\n GuestObjectType,\n GuestType,\n ReceiveOptions,\n} from \"../Guest/Guest\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class Patron<T> implements GuestObjectType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport {\n give,\n GuestObjectType,\n GuestType,\n ReceiveOptions,\n} from \"../Guest/Guest\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestObjectType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n\n const data = options?.data as PoolAware;\n\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { give, GuestType } from \"./../Guest/Guest\";\nimport { GuestMiddle } from \"./../Guest/GuestMiddle\";\nimport { Source, SourceType } from \"./Source\";\n\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public receiving(guest: GuestType<T>) {\n this.baseSource.receiving(\n new GuestMiddle(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public receive(value: T): this {\n this.baseSource.receive(value);\n return this;\n }\n}\n","interface Constructable<T> {\n new(...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T\n}\n\nexport interface FactoryType<T> {\n create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;\n}\n\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) { }\n\n public create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(...args, this.factories) as CT extends null ? T : CT;\n }\n}\n"],"names":["__publicField"],"mappings":";;AAMO,MAAM,UAAqD,CAAA;AAAA,EACzD,YAAoB,aAA8C,EAAA;AAA9C,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AAAA,GAA+C;AAAA,EAEnE,UAAU,KAAmC,EAAA;AAClD,IAAA,IAAA,CAAK,cAAc,KAAK,CAAA,CAAA;AACxB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;ACKgB,SAAA,IAAA,CACd,IACA,EAAA,KAAA,EACA,OACA,EAAA;AACA,EAAI,IAAA,OAAO,UAAU,UAAY,EAAA;AAC/B,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAAA,GACd,MAAA;AACL,IAAM,KAAA,CAAA,OAAA,CAAQ,MAAM,OAAO,CAAA,CAAA;AAAA,GAC7B;AACF,CAAA;AAEO,MAAM,KAAuC,CAAA;AAAA,EAC3C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,OAAA,CAAQ,OAAU,OAA0B,EAAA;AACjD,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACnCO,MAAM,SAA2C,CAAA;AAAA,EAC/C,WAAA,CACG,aACA,WACR,EAAA;AAFQ,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA,CAAA;AACA,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA,CAAA;AAAA,GACP;AAAA,EAEH,YAAe,GAAA;AACb,IAAI,IAAA,OAAO,IAAK,CAAA,WAAA,KAAgB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AAU,KAAqB,EAAA;AACpC,IAAA,IAAA,CAAK,UAAW,CAAA,SAAA;AAAA,MACd,IAAI,WAAA,CAAY,KAAoB,EAAA,CAAC,KAAU,KAAA;AAC7C,QAAA,IAAI,UAAU,IAAM,EAAA;AAClB,UAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAAA,SACnB;AAAA,OACD,CAAA;AAAA,KACH,CAAA;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEO,QAAQ,KAAgB,EAAA;AAC7B,IAAK,IAAA,CAAA,UAAA,CAAW,QAAQ,KAAK,CAAA,CAAA;AAC7B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACVO,MAAM,OAAqC,CAAA;AAAA,EACvC,WACK,CAAA,aAAA,EACA,SAAqC,GAAA,EAC/C,EAAA;AAFU,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GACR;AAAA,EAEG,UAA0C,IAAmC,EAAA;AAChF,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA,CAAmC,GAAG,IAAA,EAAM,KAAK,SAAS,CAAA,CAAA;AAAA,GAC/E;AACJ;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"patron.js","sources":["../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Guest/GuestCast.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestMiddle.ts","../src/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceEmpty.ts","../src/Factory/Factory.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport interface GuestAwareType<T = unknown> {\n value(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public value(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = unknown> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = unknown> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = unknown> = GuestExecutorType<T> | GuestObjectType<T>;\n\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestCast<T> implements GuestObjectType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n// remove patron from all pools\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestObjectType<T>>();\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: GiveOptions,\n ) {\n give(value, guest, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestMiddle<T> implements GuestObjectType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: GiveOptions) => void,\n ) {}\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestObjectType<T>;\n\nexport class Source<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.pool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.pool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.pool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import { Guest, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestObject<T> implements GuestObjectType<T> {\n public constructor(private baseGuest: GuestType<T>) {}\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestMiddle } from \"./GuestMiddle\";\nimport { Source } from \"../Source/Source\";\nimport { GuestObject } from \"./GuestObject\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: Source<Record<string, unknown>>;\n\n private keysKnown = new Set();\n\n private keysFilled = new Set();\n\n private filledChainPool = new GuestPool(this);\n\n public constructor() {\n this.theChain = new Source<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledChainPool.add(\n new GuestMiddle(guestObject, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.give(Object.values(chain));\n }),\n );\n }\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.value(\n new Guest((chain) => {\n this.filledChainPool.give(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.give(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.give(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = unknown> extends GuestObjectType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nexport class Patron<T> implements GuestObjectType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestObjectType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n}\n","import { give, GuestType } from \"./../Guest/Guest\";\nimport { GuestMiddle } from \"./../Guest/GuestMiddle\";\nimport { Source, SourceType } from \"./Source\";\n\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestMiddle(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n}\n","interface Constructable<T> {\n new (...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T;\n}\n\nexport interface FactoryType<T> {\n create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;\n}\n\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) {}\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n"],"names":["__publicField"],"mappings":";;AAMO,MAAM,UAAqD,CAAA;AAAA,EACzD,YAAoB,aAA8C,EAAA;AAA9C,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AAAA,GAA+C;AAAA,EAEnE,MAAM,KAAmC,EAAA;AAC9C,IAAA,IAAA,CAAK,cAAc,KAAK,CAAA,CAAA;AACxB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;ACKgB,SAAA,IAAA,CAAQ,IAAS,EAAA,KAAA,EAAqB,OAAuB,EAAA;AAC3E,EAAI,IAAA,OAAO,UAAU,UAAY,EAAA;AAC/B,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAAA,GACd,MAAA;AACL,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,OAAO,CAAA,CAAA;AAAA,GAC1B;AACF,CAAA;AAEO,MAAM,KAAuC,CAAA;AAAA,EAC3C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,IAAA,CAAK,OAAU,OAAuB,EAAA;AAC3C,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;AC/BO,MAAM,SAA2C,CAAA;AAAA,EAC/C,WAAA,CACG,aACA,WACR,EAAA;AAFQ,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA,CAAA;AACA,IAAA,IAAA,CAAA,WAAA,GAAA,WAAA,CAAA;AAAA,GACP;AAAA,EAEI,YAAe,GAAA;AACpB,IAAI,IAAA,OAAO,IAAK,CAAA,WAAA,KAAgB,UAAY,EAAA;AAC1C,MAAO,OAAA,OAAA,CAAA;AAAA,KACT;AACA,IAAI,IAAA,CAAC,IAA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C,KAAU,KAAA;AAC7C,QAAA,IAAI,UAAU,IAAM,EAAA;AAClB,UAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAAA,SACnB;AAAA,OACD,CAAA;AAAA,KACH,CAAA;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEO,KAAK,KAAgB,EAAA;AAC1B,IAAK,IAAA,CAAA,UAAA,CAAW,KAAK,KAAK,CAAA,CAAA;AAC1B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACVO,MAAM,OAAqC,CAAA;AAAA,EACzC,WACG,CAAA,aAAA,EACA,SAAqC,GAAA,EAC7C,EAAA;AAFQ,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GACP;AAAA,EAEI,UACF,IACuB,EAAA;AAC1B,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAK,CAAA,SAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- !function(e){"use strict";function t(e,t,i){"function"==typeof t?t(e,i):t.receive(e,i)}class i{constructor(e){this.receiver=e}receive(e,t){return this.receiver(e,t),this}}var s=Object.defineProperty,r=(e,t,i)=>((e,t,i)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const n=new Map;class o{constructor(e){this.initiator=e,r(this,"patrons",new Set),r(this,"receive"),n.set(this,this.patrons);let t=null;const i=(e,t)=>{this.patrons.forEach((i=>{this.sendValueToGuest(e,i,t)}))};this.receive=(e,s)=>{const r=()=>{r===t&&i(e,s)};return t=r,queueMicrotask(r),this}}add(e){return"function"!=typeof e&&e.introduction&&"patron"===e.introduction()&&this.patrons.add(e),this}remove(e){return this.patrons.delete(e),this}distribute(e,t){return this.add(t),this.sendValueToGuest(e,t,{}),this}sendValueToGuest(e,i,s){t(e,i,{...s,data:{...s?.data??{},initiator:this.initiator,pool:this}})}}var u=Object.defineProperty,c=(e,t,i)=>((e,t,i)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class h{constructor(e){c(this,"guests",new Set),c(this,"patronPool"),this.patronPool=new o(e)}receive(e,t){return this.deliverToGuests(e,t),this.patronPool.receive(e,t),this}add(e){return"function"!=typeof e&&e.introduction&&"guest"!==e.introduction()||this.guests.add(e),this.patronPool.add(e),this}remove(e){return this.guests.delete(e),this.patronPool.remove(e),this}distribute(e,t){return this.add(t),this.receive(e),this}deliverToGuests(e,i){this.guests.forEach((s=>{t(e,s,i)})),this.guests.clear()}}class a{constructor(e,t){this.baseGuest=e,this.middleFn=t}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}receive(e,t){return this.middleFn(e,t),this}}var l=Object.defineProperty,d=(e,t,i)=>((e,t,i)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class v{constructor(e){this.sourceDocument=e,d(this,"pool",new o(this))}receive(e){return this.sourceDocument=e,this.pool.receive(this.sourceDocument),this}receiving(e){return"function"==typeof e?this.pool.distribute(this.sourceDocument,new i(e)):this.pool.distribute(this.sourceDocument,e),this}}class b{constructor(e){this.baseGuest=e}receive(e,t){let s=this.baseGuest;return"function"==typeof s&&(s=new i(s)),s.receive(e,t),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}}var f=Object.defineProperty,p=(e,t,i)=>((e,t,i)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);var w=Object.defineProperty,y=(e,t,i)=>((e,t,i)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);var G=Object.defineProperty,g=(e,t,i)=>((e,t,i)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);e.Factory=class{constructor(e,t={}){this.constructorFn=e,this.factories=t}create(...e){return new this.constructorFn(...e,this.factories)}},e.Guest=i,e.GuestAware=class{constructor(e){this.guestReceiver=e}receiving(e){return this.guestReceiver(e),e}},e.GuestCast=class{constructor(e,t){this.sourceGuest=e,this.targetGuest=t}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}receive(e,i){return t(e,this.targetGuest,i),this}},e.GuestChain=class{constructor(){p(this,"theChain"),p(this,"keysKnown",new Set),p(this,"keysFilled",new Set),p(this,"filledChainPool",new h(this)),this.theChain=new v({})}resultArray(e){const t=new b(e);return this.filledChainPool.add(new a(t,(e=>Object.values(e)))),this.isChainFilled()&&this.theChain.receiving(new i((e=>{this.filledChainPool.receive(Object.values(e))}))),this}result(e){const t=new b(e);return this.isChainFilled()?(this.filledChainPool.add(t),this.theChain.receiving(new i((e=>{this.filledChainPool.receive(e)})))):this.filledChainPool.add(t),this}receiveKey(e){return this.keysKnown.add(e),new i((t=>{queueMicrotask((()=>{this.theChain.receiving(new i((i=>{this.keysFilled.add(e);const s={...i,[e]:t};this.theChain.receive(s),this.isChainFilled()&&this.filledChainPool.receive(s)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}},e.GuestMiddle=a,e.GuestObject=b,e.GuestPool=h,e.GuestSync=class{constructor(e){this.theValue=e}receive(e){return this.theValue=e,this}value(){return this.theValue}},e.Patron=class{constructor(e){this.willBePatron=e}introduction(){return"patron"}receive(e,i){return t(e,this.willBePatron,i),this}},e.PatronOnce=class{constructor(e){this.baseGuest=e,y(this,"received",!1)}introduction(){return"patron"}receive(e,i){this.received||t(e,this.baseGuest,i);const s=i?.data;return s?.pool&&s.pool.remove(this),this}},e.PatronPool=o,e.Source=v,e.SourceEmpty=class{constructor(){g(this,"baseSource",new v(null))}receiving(e){return this.baseSource.receiving(new a(e,(i=>{null!==i&&t(i,e)}))),this}receive(e){return this.baseSource.receive(e),this}},e.give=t,e.removePatronFromPools=e=>{n.forEach((t=>{t.delete(e)}))}}({});
1
+ !function(t){"use strict";function e(t,e,s){"function"==typeof e?e(t,s):e.give(t,s)}class s{constructor(t){this.receiver=t}give(t,e){return this.receiver(t,e),this}}var i=Object.defineProperty,r=(t,e,s)=>((t,e,s)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);const n=new Map;class o{constructor(t){this.initiator=t,r(this,"patrons",new Set),r(this,"give"),n.set(this,this.patrons);let e=null;const s=(t,e)=>{this.patrons.forEach((s=>{this.sendValueToGuest(t,s,e)}))};this.give=(t,i)=>{const r=()=>{r===e&&s(t,i)};return e=r,queueMicrotask(r),this}}add(t){return"function"!=typeof t&&t.introduction&&"patron"===t.introduction()&&this.patrons.add(t),this}remove(t){return this.patrons.delete(t),this}distribute(t,e){return this.add(e),this.sendValueToGuest(t,e,{}),this}sendValueToGuest(t,s,i){e(t,s,{...i,data:{...i?.data??{},initiator:this.initiator,pool:this}})}}var u=Object.defineProperty,h=(t,e,s)=>((t,e,s)=>e in t?u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class a{constructor(t){h(this,"guests",new Set),h(this,"patronPool"),this.patronPool=new o(t)}give(t,e){return this.deliverToGuests(t,e),this.patronPool.give(t,e),this}add(t){return"function"!=typeof t&&t.introduction&&"guest"!==t.introduction()||this.guests.add(t),this.patronPool.add(t),this}remove(t){return this.guests.delete(t),this.patronPool.remove(t),this}distribute(t,e){return this.add(e),this.give(t),this}deliverToGuests(t,s){this.guests.forEach((i=>{e(t,i,s)})),this.guests.clear()}}class c{constructor(t,e){this.baseGuest=t,this.middleFn=e}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}give(t,e){return this.middleFn(t,e),this}}var l=Object.defineProperty,d=(t,e,s)=>((t,e,s)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class v{constructor(t){this.sourceDocument=t,d(this,"pool",new o(this))}give(t){return this.sourceDocument=t,this.pool.give(this.sourceDocument),this}value(t){return"function"==typeof t?this.pool.distribute(this.sourceDocument,new s(t)):this.pool.distribute(this.sourceDocument,t),this}}class b{constructor(t){this.baseGuest=t}give(t,e){let i=this.baseGuest;return"function"==typeof i&&(i=new s(i)),i.give(t,e),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}}var f=Object.defineProperty,g=(t,e,s)=>((t,e,s)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);var p=Object.defineProperty,w=(t,e,s)=>((t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);var y=Object.defineProperty,G=(t,e,s)=>((t,e,s)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);t.Factory=class{constructor(t,e={}){this.constructorFn=t,this.factories=e}create(...t){return new this.constructorFn(...t,this.factories)}},t.Guest=s,t.GuestAware=class{constructor(t){this.guestReceiver=t}value(t){return this.guestReceiver(t),t}},t.GuestCast=class{constructor(t,e){this.sourceGuest=t,this.targetGuest=e}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(t,s){return e(t,this.targetGuest,s),this}},t.GuestChain=class{constructor(){g(this,"theChain"),g(this,"keysKnown",new Set),g(this,"keysFilled",new Set),g(this,"filledChainPool",new a(this)),this.theChain=new v({})}resultArray(t){const e=new b(t);return this.filledChainPool.add(new c(e,(t=>Object.values(t)))),this.isChainFilled()&&this.theChain.value(new s((t=>{this.filledChainPool.give(Object.values(t))}))),this}result(t){const e=new b(t);return this.isChainFilled()?(this.filledChainPool.add(e),this.theChain.value(new s((t=>{this.filledChainPool.give(t)})))):this.filledChainPool.add(e),this}receiveKey(t){return this.keysKnown.add(t),new s((e=>{queueMicrotask((()=>{this.theChain.value(new s((s=>{this.keysFilled.add(t);const i={...s,[t]:e};this.theChain.give(i),this.isChainFilled()&&this.filledChainPool.give(i)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}},t.GuestMiddle=c,t.GuestObject=b,t.GuestPool=a,t.GuestSync=class{constructor(t){this.theValue=t}give(t){return this.theValue=t,this}value(){return this.theValue}},t.Patron=class{constructor(t){this.willBePatron=t}introduction(){return"patron"}give(t,s){return e(t,this.willBePatron,s),this}},t.PatronOnce=class{constructor(t){this.baseGuest=t,w(this,"received",!1)}introduction(){return"patron"}give(t,s){this.received||e(t,this.baseGuest,s);const i=s?.data;return i?.pool&&i.pool.remove(this),this}},t.PatronPool=o,t.Source=v,t.SourceEmpty=class{constructor(){G(this,"baseSource",new v(null))}value(t){return this.baseSource.value(new c(t,(s=>{null!==s&&e(s,t)}))),this}give(t){return this.baseSource.give(t),this}},t.give=e,t.removePatronFromPools=t=>{n.forEach((e=>{e.delete(t)}))}}({});
@@ -1,2 +1,2 @@
1
- class e{constructor(e){this.guestReceiver=e}receiving(e){return this.guestReceiver(e),e}}function t(e,t,i){"function"==typeof t?t(e,i):t.receive(e,i)}class i{constructor(e){this.receiver=e}receive(e,t){return this.receiver(e,t),this}}class s{constructor(e,t){this.sourceGuest=e,this.targetGuest=t}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}receive(e,i){return t(e,this.targetGuest,i),this}}var r=Object.defineProperty,n=(e,t,i)=>((e,t,i)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const o=new Map,u=e=>{o.forEach((t=>{t.delete(e)}))};class c{constructor(e){this.initiator=e,n(this,"patrons",new Set),n(this,"receive"),o.set(this,this.patrons);let t=null;const i=(e,t)=>{this.patrons.forEach((i=>{this.sendValueToGuest(e,i,t)}))};this.receive=(e,s)=>{const r=()=>{r===t&&i(e,s)};return t=r,queueMicrotask(r),this}}add(e){return"function"!=typeof e&&e.introduction&&"patron"===e.introduction()&&this.patrons.add(e),this}remove(e){return this.patrons.delete(e),this}distribute(e,t){return this.add(t),this.sendValueToGuest(e,t,{}),this}sendValueToGuest(e,i,s){t(e,i,{...s,data:{...s?.data??{},initiator:this.initiator,pool:this}})}}var h=Object.defineProperty,a=(e,t,i)=>((e,t,i)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class l{constructor(e){a(this,"guests",new Set),a(this,"patronPool"),this.patronPool=new c(e)}receive(e,t){return this.deliverToGuests(e,t),this.patronPool.receive(e,t),this}add(e){return"function"!=typeof e&&e.introduction&&"guest"!==e.introduction()||this.guests.add(e),this.patronPool.add(e),this}remove(e){return this.guests.delete(e),this.patronPool.remove(e),this}distribute(e,t){return this.add(t),this.receive(e),this}deliverToGuests(e,i){this.guests.forEach((s=>{t(e,s,i)})),this.guests.clear()}}class d{constructor(e,t){this.baseGuest=e,this.middleFn=t}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}receive(e,t){return this.middleFn(e,t),this}}var v=Object.defineProperty,b=(e,t,i)=>((e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class f{constructor(e){this.sourceDocument=e,b(this,"pool",new c(this))}receive(e){return this.sourceDocument=e,this.pool.receive(this.sourceDocument),this}receiving(e){return"function"==typeof e?this.pool.distribute(this.sourceDocument,new i(e)):this.pool.distribute(this.sourceDocument,e),this}}class p{constructor(e){this.baseGuest=e}receive(e,t){let s=this.baseGuest;return"function"==typeof s&&(s=new i(s)),s.receive(e,t),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}}var w=Object.defineProperty,y=(e,t,i)=>((e,t,i)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class g{constructor(){y(this,"theChain"),y(this,"keysKnown",new Set),y(this,"keysFilled",new Set),y(this,"filledChainPool",new l(this)),this.theChain=new f({})}resultArray(e){const t=new p(e);return this.filledChainPool.add(new d(t,(e=>Object.values(e)))),this.isChainFilled()&&this.theChain.receiving(new i((e=>{this.filledChainPool.receive(Object.values(e))}))),this}result(e){const t=new p(e);return this.isChainFilled()?(this.filledChainPool.add(t),this.theChain.receiving(new i((e=>{this.filledChainPool.receive(e)})))):this.filledChainPool.add(t),this}receiveKey(e){return this.keysKnown.add(e),new i((t=>{queueMicrotask((()=>{this.theChain.receiving(new i((i=>{this.keysFilled.add(e);const s={...i,[e]:t};this.theChain.receive(s),this.isChainFilled()&&this.filledChainPool.receive(s)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}class G{constructor(e){this.theValue=e}receive(e){return this.theValue=e,this}value(){return this.theValue}}class m{constructor(e){this.willBePatron=e}introduction(){return"patron"}receive(e,i){return t(e,this.willBePatron,i),this}}var P=Object.defineProperty,C=(e,t,i)=>((e,t,i)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class F{constructor(e){this.baseGuest=e,C(this,"received",!1)}introduction(){return"patron"}receive(e,i){this.received||t(e,this.baseGuest,i);const s=i?.data;return s?.pool&&s.pool.remove(this),this}}var k=Object.defineProperty,j=(e,t,i)=>((e,t,i)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class O{constructor(){j(this,"baseSource",new f(null))}receiving(e){return this.baseSource.receiving(new d(e,(i=>{null!==i&&t(i,e)}))),this}receive(e){return this.baseSource.receive(e),this}}class S{constructor(e,t={}){this.constructorFn=e,this.factories=t}create(...e){return new this.constructorFn(...e,this.factories)}}export{S as Factory,i as Guest,e as GuestAware,s as GuestCast,g as GuestChain,d as GuestMiddle,p as GuestObject,l as GuestPool,G as GuestSync,m as Patron,F as PatronOnce,c as PatronPool,f as Source,O as SourceEmpty,t as give,u as removePatronFromPools};
1
+ class t{constructor(t){this.guestReceiver=t}value(t){return this.guestReceiver(t),t}}function e(t,e,i){"function"==typeof e?e(t,i):e.give(t,i)}class i{constructor(t){this.receiver=t}give(t,e){return this.receiver(t,e),this}}class s{constructor(t,e){this.sourceGuest=t,this.targetGuest=e}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(t,i){return e(t,this.targetGuest,i),this}}var r=Object.defineProperty,n=(t,e,i)=>((t,e,i)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);const o=new Map,u=t=>{o.forEach((e=>{e.delete(t)}))};class h{constructor(t){this.initiator=t,n(this,"patrons",new Set),n(this,"give"),o.set(this,this.patrons);let e=null;const i=(t,e)=>{this.patrons.forEach((i=>{this.sendValueToGuest(t,i,e)}))};this.give=(t,s)=>{const r=()=>{r===e&&i(t,s)};return e=r,queueMicrotask(r),this}}add(t){return"function"!=typeof t&&t.introduction&&"patron"===t.introduction()&&this.patrons.add(t),this}remove(t){return this.patrons.delete(t),this}distribute(t,e){return this.add(e),this.sendValueToGuest(t,e,{}),this}sendValueToGuest(t,i,s){e(t,i,{...s,data:{...s?.data??{},initiator:this.initiator,pool:this}})}}var a=Object.defineProperty,l=(t,e,i)=>((t,e,i)=>e in t?a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);class c{constructor(t){l(this,"guests",new Set),l(this,"patronPool"),this.patronPool=new h(t)}give(t,e){return this.deliverToGuests(t,e),this.patronPool.give(t,e),this}add(t){return"function"!=typeof t&&t.introduction&&"guest"!==t.introduction()||this.guests.add(t),this.patronPool.add(t),this}remove(t){return this.guests.delete(t),this.patronPool.remove(t),this}distribute(t,e){return this.add(e),this.give(t),this}deliverToGuests(t,i){this.guests.forEach((s=>{e(t,s,i)})),this.guests.clear()}}class d{constructor(t,e){this.baseGuest=t,this.middleFn=e}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}give(t,e){return this.middleFn(t,e),this}}var v=Object.defineProperty,b=(t,e,i)=>((t,e,i)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,e+"",i);class f{constructor(t){this.sourceDocument=t,b(this,"pool",new h(this))}give(t){return this.sourceDocument=t,this.pool.give(this.sourceDocument),this}value(t){return"function"==typeof t?this.pool.distribute(this.sourceDocument,new i(t)):this.pool.distribute(this.sourceDocument,t),this}}class g{constructor(t){this.baseGuest=t}give(t,e){let s=this.baseGuest;return"function"==typeof s&&(s=new i(s)),s.give(t,e),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}}var p=Object.defineProperty,w=(t,e,i)=>((t,e,i)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);class y{constructor(){w(this,"theChain"),w(this,"keysKnown",new Set),w(this,"keysFilled",new Set),w(this,"filledChainPool",new c(this)),this.theChain=new f({})}resultArray(t){const e=new g(t);return this.filledChainPool.add(new d(e,(t=>Object.values(t)))),this.isChainFilled()&&this.theChain.value(new i((t=>{this.filledChainPool.give(Object.values(t))}))),this}result(t){const e=new g(t);return this.isChainFilled()?(this.filledChainPool.add(e),this.theChain.value(new i((t=>{this.filledChainPool.give(t)})))):this.filledChainPool.add(e),this}receiveKey(t){return this.keysKnown.add(t),new i((e=>{queueMicrotask((()=>{this.theChain.value(new i((i=>{this.keysFilled.add(t);const s={...i,[t]:e};this.theChain.give(s),this.isChainFilled()&&this.filledChainPool.give(s)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}class G{constructor(t){this.theValue=t}give(t){return this.theValue=t,this}value(){return this.theValue}}class m{constructor(t){this.willBePatron=t}introduction(){return"patron"}give(t,i){return e(t,this.willBePatron,i),this}}var P=Object.defineProperty,C=(t,e,i)=>((t,e,i)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,e+"",i);class F{constructor(t){this.baseGuest=t,C(this,"received",!1)}introduction(){return"patron"}give(t,i){this.received||e(t,this.baseGuest,i);const s=i?.data;return s?.pool&&s.pool.remove(this),this}}var k=Object.defineProperty,j=(t,e,i)=>((t,e,i)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,e+"",i);class O{constructor(){j(this,"baseSource",new f(null))}value(t){return this.baseSource.value(new d(t,(i=>{null!==i&&e(i,t)}))),this}give(t){return this.baseSource.give(t),this}}class S{constructor(t,e={}){this.constructorFn=t,this.factories=e}create(...t){return new this.constructorFn(...t,this.factories)}}export{S as Factory,i as Guest,t as GuestAware,s as GuestCast,y as GuestChain,d as GuestMiddle,g as GuestObject,c as GuestPool,G as GuestSync,m as Patron,F as PatronOnce,h as PatronPool,f as Source,O as SourceEmpty,e as give,u as removePatronFromPools};
2
2
  //# sourceMappingURL=patron.min.mjs.map