patron-oop 1.15.0 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/patron.cjs +376 -0
  3. package/dist/patron.cjs.map +1 -0
  4. package/dist/patron.d.ts +21 -27
  5. package/dist/patron.js +34 -48
  6. package/dist/patron.js.map +1 -1
  7. package/dist/patron.min.js +1 -1
  8. package/dist/patron.min.mjs +1 -1
  9. package/dist/patron.min.mjs.map +1 -1
  10. package/dist/patron.mjs +33 -30
  11. package/dist/patron.mjs.map +1 -1
  12. package/examples/elegant_objects.html +8 -8
  13. package/examples/reactive.html +6 -6
  14. package/package.json +1 -1
  15. package/rollup.config.js +6 -1
  16. package/src/Factory/Factory.test.ts +28 -26
  17. package/src/Factory/Factory.ts +15 -10
  18. package/src/Guest/Guest.test.ts +1 -1
  19. package/src/Guest/Guest.ts +6 -10
  20. package/src/Guest/GuestAware.test.ts +1 -1
  21. package/src/Guest/GuestAware.ts +2 -2
  22. package/src/Guest/GuestCast.test.ts +2 -2
  23. package/src/Guest/GuestCast.ts +3 -4
  24. package/src/Guest/GuestChain.test.ts +10 -10
  25. package/src/Guest/GuestChain.ts +7 -8
  26. package/src/Guest/GuestMiddle.test.ts +11 -11
  27. package/src/Guest/GuestMiddle.ts +4 -4
  28. package/src/Guest/GuestObject.test.ts +1 -1
  29. package/src/Guest/GuestObject.ts +3 -4
  30. package/src/Guest/GuestPool.test.ts +2 -2
  31. package/src/Guest/GuestPool.ts +5 -5
  32. package/src/Guest/GuestSync.test.ts +2 -2
  33. package/src/Guest/GuestSync.ts +1 -1
  34. package/src/Patron/Patron.test.ts +2 -2
  35. package/src/Patron/Patron.ts +2 -10
  36. package/src/Patron/PatronOnce.test.ts +4 -2
  37. package/src/Patron/PatronOnce.ts +2 -10
  38. package/src/Patron/PatronPool.test.ts +1 -1
  39. package/src/Patron/PatronPool.ts +6 -14
  40. package/src/Source/Source.test.ts +1 -1
  41. package/src/Source/Source.ts +3 -3
  42. package/src/Source/SourceEmpty.test.ts +3 -3
  43. package/src/Source/SourceEmpty.ts +4 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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.17.0](https://github.com/kosukhin/patron/compare/v1.16.0...v1.17.0) (2024-11-02)
6
+
7
+
8
+ ### Features
9
+
10
+ * **main:** исправить настройку роллап ([d699b15](https://github.com/kosukhin/patron/commit/d699b15df9be703461b3de0c13a34956f3008d71))
11
+
12
+ ## [1.16.0](https://github.com/kosukhin/patron/compare/v1.15.0...v1.16.0) (2024-11-02)
13
+
14
+
15
+ ### Features
16
+
17
+ * **main:** переименовать receive-receiving в give-value ([02c5eb7](https://github.com/kosukhin/patron/commit/02c5eb70c2305a304a96c5772ddce1b309772457))
18
+
5
19
  ## [1.15.0](https://github.com/kosukhin/patron/compare/v1.14.0...v1.15.0) (2024-11-01)
6
20
 
7
21
 
@@ -0,0 +1,376 @@
1
+ 'use strict';
2
+
3
+ class GuestAware {
4
+ constructor(guestReceiver) {
5
+ this.guestReceiver = guestReceiver;
6
+ }
7
+ value(guest) {
8
+ this.guestReceiver(guest);
9
+ return guest;
10
+ }
11
+ }
12
+
13
+ function give(data, guest, options) {
14
+ if (typeof guest === "function") {
15
+ guest(data, options);
16
+ } else {
17
+ guest.give(data, options);
18
+ }
19
+ }
20
+ class Guest {
21
+ constructor(receiver) {
22
+ this.receiver = receiver;
23
+ }
24
+ give(value, options) {
25
+ this.receiver(value, options);
26
+ return this;
27
+ }
28
+ }
29
+
30
+ class GuestCast {
31
+ constructor(sourceGuest, targetGuest) {
32
+ this.sourceGuest = sourceGuest;
33
+ this.targetGuest = targetGuest;
34
+ }
35
+ introduction() {
36
+ if (typeof this.sourceGuest === "function") {
37
+ return "guest";
38
+ }
39
+ if (!this.sourceGuest.introduction) {
40
+ return "guest";
41
+ }
42
+ return this.sourceGuest.introduction();
43
+ }
44
+ give(value, options) {
45
+ give(value, this.targetGuest, options);
46
+ return this;
47
+ }
48
+ }
49
+
50
+ var __defProp$5 = Object.defineProperty;
51
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
53
+ const poolSets = /* @__PURE__ */ new Map();
54
+ const removePatronFromPools = (patron) => {
55
+ poolSets.forEach((pool) => {
56
+ pool.delete(patron);
57
+ });
58
+ };
59
+ class PatronPool {
60
+ constructor(initiator) {
61
+ this.initiator = initiator;
62
+ __publicField$5(this, "patrons", /* @__PURE__ */ new Set());
63
+ __publicField$5(this, "give");
64
+ poolSets.set(this, this.patrons);
65
+ let lastMicrotask = null;
66
+ const doReceive = (value, options) => {
67
+ this.patrons.forEach((target) => {
68
+ this.sendValueToGuest(value, target, options);
69
+ });
70
+ };
71
+ this.give = (value, options) => {
72
+ const currentMicroTask = () => {
73
+ if (currentMicroTask === lastMicrotask) {
74
+ doReceive(value, options);
75
+ }
76
+ };
77
+ lastMicrotask = currentMicroTask;
78
+ queueMicrotask(currentMicroTask);
79
+ return this;
80
+ };
81
+ }
82
+ add(shouldBePatron) {
83
+ if (typeof shouldBePatron !== "function" && shouldBePatron.introduction && shouldBePatron.introduction() === "patron") {
84
+ this.patrons.add(shouldBePatron);
85
+ }
86
+ return this;
87
+ }
88
+ remove(patron) {
89
+ this.patrons.delete(patron);
90
+ return this;
91
+ }
92
+ distribute(receiving, possiblePatron) {
93
+ this.add(possiblePatron);
94
+ this.sendValueToGuest(receiving, possiblePatron, {});
95
+ return this;
96
+ }
97
+ sendValueToGuest(value, guest, options) {
98
+ give(value, guest, {
99
+ ...options,
100
+ data: {
101
+ ...options?.data ?? {},
102
+ initiator: this.initiator,
103
+ pool: this
104
+ }
105
+ });
106
+ }
107
+ }
108
+
109
+ var __defProp$4 = Object.defineProperty;
110
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
111
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
112
+ class GuestPool {
113
+ constructor(initiator) {
114
+ __publicField$4(this, "guests", /* @__PURE__ */ new Set());
115
+ __publicField$4(this, "patronPool");
116
+ this.patronPool = new PatronPool(initiator);
117
+ }
118
+ give(value, options) {
119
+ this.deliverToGuests(value, options);
120
+ this.patronPool.give(value, options);
121
+ return this;
122
+ }
123
+ add(guest) {
124
+ if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
125
+ this.guests.add(guest);
126
+ }
127
+ this.patronPool.add(guest);
128
+ return this;
129
+ }
130
+ remove(patron) {
131
+ this.guests.delete(patron);
132
+ this.patronPool.remove(patron);
133
+ return this;
134
+ }
135
+ distribute(receiving, possiblePatron) {
136
+ this.add(possiblePatron);
137
+ this.give(receiving);
138
+ return this;
139
+ }
140
+ deliverToGuests(value, options) {
141
+ this.guests.forEach((target) => {
142
+ give(value, target, options);
143
+ });
144
+ this.guests.clear();
145
+ }
146
+ }
147
+
148
+ class GuestMiddle {
149
+ constructor(baseGuest, middleFn) {
150
+ this.baseGuest = baseGuest;
151
+ this.middleFn = middleFn;
152
+ }
153
+ introduction() {
154
+ if (typeof this.baseGuest === "function" || !this.baseGuest.introduction) {
155
+ return "guest";
156
+ }
157
+ return this.baseGuest.introduction();
158
+ }
159
+ give(value, options) {
160
+ this.middleFn(value, options);
161
+ return this;
162
+ }
163
+ }
164
+
165
+ var __defProp$3 = Object.defineProperty;
166
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
167
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
168
+ class Source {
169
+ constructor(sourceDocument) {
170
+ this.sourceDocument = sourceDocument;
171
+ __publicField$3(this, "pool", new PatronPool(this));
172
+ }
173
+ give(value) {
174
+ this.sourceDocument = value;
175
+ this.pool.give(this.sourceDocument);
176
+ return this;
177
+ }
178
+ value(guest) {
179
+ if (typeof guest === "function") {
180
+ this.pool.distribute(this.sourceDocument, new Guest(guest));
181
+ } else {
182
+ this.pool.distribute(this.sourceDocument, guest);
183
+ }
184
+ return this;
185
+ }
186
+ }
187
+
188
+ class GuestObject {
189
+ constructor(baseGuest) {
190
+ this.baseGuest = baseGuest;
191
+ }
192
+ give(value, options) {
193
+ let guest = this.baseGuest;
194
+ if (typeof guest === "function") {
195
+ guest = new Guest(guest);
196
+ }
197
+ guest.give(value, options);
198
+ return this;
199
+ }
200
+ introduction() {
201
+ if (typeof this.baseGuest === "function" || !this.baseGuest.introduction) {
202
+ return "guest";
203
+ }
204
+ return this.baseGuest.introduction();
205
+ }
206
+ }
207
+
208
+ var __defProp$2 = Object.defineProperty;
209
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
210
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
211
+ class GuestChain {
212
+ constructor() {
213
+ __publicField$2(this, "theChain");
214
+ __publicField$2(this, "keysKnown", /* @__PURE__ */ new Set());
215
+ __publicField$2(this, "keysFilled", /* @__PURE__ */ new Set());
216
+ __publicField$2(this, "filledChainPool", new GuestPool(this));
217
+ this.theChain = new Source({});
218
+ }
219
+ resultArray(guest) {
220
+ const guestObject = new GuestObject(guest);
221
+ this.filledChainPool.add(
222
+ new GuestMiddle(
223
+ guestObject,
224
+ (value) => Object.values(value)
225
+ )
226
+ );
227
+ if (this.isChainFilled()) {
228
+ this.theChain.value(
229
+ new Guest((chain) => {
230
+ this.filledChainPool.give(Object.values(chain));
231
+ })
232
+ );
233
+ }
234
+ return this;
235
+ }
236
+ result(guest) {
237
+ const guestObject = new GuestObject(guest);
238
+ if (this.isChainFilled()) {
239
+ this.filledChainPool.add(guestObject);
240
+ this.theChain.value(
241
+ new Guest((chain) => {
242
+ this.filledChainPool.give(chain);
243
+ })
244
+ );
245
+ } else {
246
+ this.filledChainPool.add(guestObject);
247
+ }
248
+ return this;
249
+ }
250
+ receiveKey(key) {
251
+ this.keysKnown.add(key);
252
+ return new Guest((value) => {
253
+ queueMicrotask(() => {
254
+ this.theChain.value(
255
+ new Guest((chain) => {
256
+ this.keysFilled.add(key);
257
+ const lastChain = {
258
+ ...chain,
259
+ [key]: value
260
+ };
261
+ this.theChain.give(lastChain);
262
+ if (this.isChainFilled()) {
263
+ this.filledChainPool.give(lastChain);
264
+ }
265
+ })
266
+ );
267
+ });
268
+ });
269
+ }
270
+ isChainFilled() {
271
+ return this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size;
272
+ }
273
+ }
274
+
275
+ class GuestSync {
276
+ constructor(theValue) {
277
+ this.theValue = theValue;
278
+ }
279
+ give(value) {
280
+ this.theValue = value;
281
+ return this;
282
+ }
283
+ value() {
284
+ return this.theValue;
285
+ }
286
+ }
287
+
288
+ class Patron {
289
+ constructor(willBePatron) {
290
+ this.willBePatron = willBePatron;
291
+ }
292
+ introduction() {
293
+ return "patron";
294
+ }
295
+ give(value, options) {
296
+ give(value, this.willBePatron, options);
297
+ return this;
298
+ }
299
+ }
300
+
301
+ var __defProp$1 = Object.defineProperty;
302
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
303
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
304
+ class PatronOnce {
305
+ constructor(baseGuest) {
306
+ this.baseGuest = baseGuest;
307
+ __publicField$1(this, "received", false);
308
+ }
309
+ introduction() {
310
+ return "patron";
311
+ }
312
+ give(value, options) {
313
+ if (!this.received) {
314
+ give(value, this.baseGuest, options);
315
+ }
316
+ const data = options?.data;
317
+ if (data?.pool) {
318
+ data.pool.remove(this);
319
+ }
320
+ return this;
321
+ }
322
+ }
323
+
324
+ var __defProp = Object.defineProperty;
325
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
326
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
327
+ class SourceEmpty {
328
+ constructor() {
329
+ __publicField(this, "baseSource", new Source(null));
330
+ }
331
+ value(guest) {
332
+ this.baseSource.value(
333
+ new GuestMiddle(guest, (value) => {
334
+ if (value !== null) {
335
+ give(value, guest);
336
+ }
337
+ })
338
+ );
339
+ return this;
340
+ }
341
+ give(value) {
342
+ this.baseSource.give(value);
343
+ return this;
344
+ }
345
+ }
346
+
347
+ class Factory {
348
+ constructor(constructorFn, factories = {}) {
349
+ this.constructorFn = constructorFn;
350
+ this.factories = factories;
351
+ }
352
+ create(...args) {
353
+ return new this.constructorFn(
354
+ ...args,
355
+ this.factories
356
+ );
357
+ }
358
+ }
359
+
360
+ exports.Factory = Factory;
361
+ exports.Guest = Guest;
362
+ exports.GuestAware = GuestAware;
363
+ exports.GuestCast = GuestCast;
364
+ exports.GuestChain = GuestChain;
365
+ exports.GuestMiddle = GuestMiddle;
366
+ exports.GuestObject = GuestObject;
367
+ exports.GuestPool = GuestPool;
368
+ exports.GuestSync = GuestSync;
369
+ exports.Patron = Patron;
370
+ exports.PatronOnce = PatronOnce;
371
+ exports.PatronPool = PatronPool;
372
+ exports.Source = Source;
373
+ exports.SourceEmpty = SourceEmpty;
374
+ exports.give = give;
375
+ exports.removePatronFromPools = removePatronFromPools;
376
+ //# sourceMappingURL=patron.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patron.cjs","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,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WAAA,GAAA;AACL,IAAQ,aAAA,CAAA,IAAA,EAAA,YAAA,EAAa,IAAI,MAAA,CAAiB,IAAI,CAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAEvC,MAAM,KAAqB,EAAA;AAChC,IAAA,IAAA,CAAK,UAAW,CAAA,KAAA;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,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;;;;;;;;;;;;;;;;;;;"}
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 };