patron-oop 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +4 -0
- package/CHANGELOG.md +14 -0
- package/dist/patron.d.ts +7 -1
- package/dist/patron.js +79 -75
- package/dist/patron.js.map +1 -1
- package/dist/patron.min.js +1 -1
- package/dist/patron.min.mjs +2 -0
- package/dist/patron.min.mjs.map +1 -0
- package/dist/patron.mjs +79 -76
- package/dist/patron.mjs.map +1 -1
- package/package.json +1 -1
- package/rollup.config.js +6 -0
- package/src/Source/SourceEmpty.test.ts +20 -0
- package/src/Source/SourceEmpty.ts +23 -0
- package/src/index.ts +1 -36
    
        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.15.0](https://github.com/kosukhin/patron/compare/v1.14.0...v1.15.0) (2024-11-01)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
             | 
| 8 | 
            +
            ### Features
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            * **main:** исправление путей импортов для SourceEmpty ([609cae1](https://github.com/kosukhin/patron/commit/609cae1506abf9ba7f073316814f2008d7e9f53d))
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ## [1.14.0](https://github.com/kosukhin/patron/compare/v1.13.0...v1.14.0) (2024-11-01)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
            ### Features
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            * **main:** новый класс SourceEmpty ([184232c](https://github.com/kosukhin/patron/commit/184232cf30a88c7902b2d6be5d6f6f378905e57f))
         | 
| 18 | 
            +
             | 
| 5 19 | 
             
            ## [1.13.0](https://github.com/kosukhin/patron/compare/v1.12.0...v1.13.0) (2024-10-30)
         | 
| 6 20 |  | 
| 7 21 |  | 
    
        package/dist/patron.d.ts
    CHANGED
    
    | @@ -125,6 +125,12 @@ declare class Source<T> implements SourceType<T> { | |
| 125 125 | 
             
                receiving(guest: GuestType<T>): this;
         | 
| 126 126 | 
             
            }
         | 
| 127 127 |  | 
| 128 | 
            +
            declare class SourceEmpty<T> implements SourceType<T> {
         | 
| 129 | 
            +
                private baseSource;
         | 
| 130 | 
            +
                receiving(guest: GuestType<T>): this;
         | 
| 131 | 
            +
                receive(value: T): this;
         | 
| 132 | 
            +
            }
         | 
| 133 | 
            +
             | 
| 128 134 | 
             
            declare class GuestObject<T> implements GuestObjectType<T> {
         | 
| 129 135 | 
             
                private baseGuest;
         | 
| 130 136 | 
             
                constructor(baseGuest: GuestType<T>);
         | 
| @@ -145,4 +151,4 @@ declare class Factory<T> implements FactoryType<T> { | |
| 145 151 | 
             
                create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
         | 
| 146 152 | 
             
            }
         | 
| 147 153 |  | 
| 148 | 
            -
            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, type SourceType, give, removePatronFromPools };
         | 
| 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 };
         | 
    
        package/dist/patron.js
    CHANGED
    
    | @@ -1,5 +1,15 @@ | |
| 1 1 | 
             
            'use strict';
         | 
| 2 2 |  | 
| 3 | 
            +
            class GuestAware {
         | 
| 4 | 
            +
              constructor(guestReceiver) {
         | 
| 5 | 
            +
                this.guestReceiver = guestReceiver;
         | 
| 6 | 
            +
              }
         | 
| 7 | 
            +
              receiving(guest) {
         | 
| 8 | 
            +
                this.guestReceiver(guest);
         | 
| 9 | 
            +
                return guest;
         | 
| 10 | 
            +
              }
         | 
| 11 | 
            +
            }
         | 
| 12 | 
            +
             | 
| 3 13 | 
             
            function give(data, guest, options) {
         | 
| 4 14 | 
             
              if (typeof guest === "function") {
         | 
| 5 15 | 
             
                guest(data, options);
         | 
| @@ -17,9 +27,29 @@ class Guest { | |
| 17 27 | 
             
              }
         | 
| 18 28 | 
             
            }
         | 
| 19 29 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 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 | 
            +
              receive(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);
         | 
| 23 53 | 
             
            const poolSets = /* @__PURE__ */ new Map();
         | 
| 24 54 | 
             
            const removePatronFromPools = (patron) => {
         | 
| 25 55 | 
             
              poolSets.forEach((pool) => {
         | 
| @@ -29,8 +59,8 @@ const removePatronFromPools = (patron) => { | |
| 29 59 | 
             
            class PatronPool {
         | 
| 30 60 | 
             
              constructor(initiator) {
         | 
| 31 61 | 
             
                this.initiator = initiator;
         | 
| 32 | 
            -
                __publicField$ | 
| 33 | 
            -
                __publicField$ | 
| 62 | 
            +
                __publicField$5(this, "patrons", /* @__PURE__ */ new Set());
         | 
| 63 | 
            +
                __publicField$5(this, "receive");
         | 
| 34 64 | 
             
                poolSets.set(this, this.patrons);
         | 
| 35 65 | 
             
                let lastMicrotask = null;
         | 
| 36 66 | 
             
                const doReceive = (value, options) => {
         | 
| @@ -76,43 +106,13 @@ class PatronPool { | |
| 76 106 | 
             
              }
         | 
| 77 107 | 
             
            }
         | 
| 78 108 |  | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
              }
         | 
| 83 | 
            -
              receiving(guest) {
         | 
| 84 | 
            -
                this.guestReceiver(guest);
         | 
| 85 | 
            -
                return guest;
         | 
| 86 | 
            -
              }
         | 
| 87 | 
            -
            }
         | 
| 88 | 
            -
             | 
| 89 | 
            -
            class GuestCast {
         | 
| 90 | 
            -
              constructor(sourceGuest, targetGuest) {
         | 
| 91 | 
            -
                this.sourceGuest = sourceGuest;
         | 
| 92 | 
            -
                this.targetGuest = targetGuest;
         | 
| 93 | 
            -
              }
         | 
| 94 | 
            -
              introduction() {
         | 
| 95 | 
            -
                if (typeof this.sourceGuest === "function") {
         | 
| 96 | 
            -
                  return "guest";
         | 
| 97 | 
            -
                }
         | 
| 98 | 
            -
                if (!this.sourceGuest.introduction) {
         | 
| 99 | 
            -
                  return "guest";
         | 
| 100 | 
            -
                }
         | 
| 101 | 
            -
                return this.sourceGuest.introduction();
         | 
| 102 | 
            -
              }
         | 
| 103 | 
            -
              receive(value, options) {
         | 
| 104 | 
            -
                give(value, this.targetGuest, options);
         | 
| 105 | 
            -
                return this;
         | 
| 106 | 
            -
              }
         | 
| 107 | 
            -
            }
         | 
| 108 | 
            -
             | 
| 109 | 
            -
            var __defProp$3 = Object.defineProperty;
         | 
| 110 | 
            -
            var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 111 | 
            -
            var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
         | 
| 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 112 | 
             
            class GuestPool {
         | 
| 113 113 | 
             
              constructor(initiator) {
         | 
| 114 | 
            -
                __publicField$ | 
| 115 | 
            -
                __publicField$ | 
| 114 | 
            +
                __publicField$4(this, "guests", /* @__PURE__ */ new Set());
         | 
| 115 | 
            +
                __publicField$4(this, "patronPool");
         | 
| 116 116 | 
             
                this.patronPool = new PatronPool(initiator);
         | 
| 117 117 | 
             
              }
         | 
| 118 118 | 
             
              receive(value, options) {
         | 
| @@ -162,13 +162,13 @@ class GuestMiddle { | |
| 162 162 | 
             
              }
         | 
| 163 163 | 
             
            }
         | 
| 164 164 |  | 
| 165 | 
            -
            var __defProp$ | 
| 166 | 
            -
            var __defNormalProp$ | 
| 167 | 
            -
            var __publicField$ | 
| 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 168 | 
             
            class Source {
         | 
| 169 169 | 
             
              constructor(sourceDocument) {
         | 
| 170 170 | 
             
                this.sourceDocument = sourceDocument;
         | 
| 171 | 
            -
                __publicField$ | 
| 171 | 
            +
                __publicField$3(this, "pool", new PatronPool(this));
         | 
| 172 172 | 
             
              }
         | 
| 173 173 | 
             
              receive(value) {
         | 
| 174 174 | 
             
                this.sourceDocument = value;
         | 
| @@ -205,15 +205,15 @@ class GuestObject { | |
| 205 205 | 
             
              }
         | 
| 206 206 | 
             
            }
         | 
| 207 207 |  | 
| 208 | 
            -
            var __defProp$ | 
| 209 | 
            -
            var __defNormalProp$ | 
| 210 | 
            -
            var __publicField$ | 
| 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 211 | 
             
            class GuestChain {
         | 
| 212 212 | 
             
              constructor() {
         | 
| 213 | 
            -
                __publicField$ | 
| 214 | 
            -
                __publicField$ | 
| 215 | 
            -
                __publicField$ | 
| 216 | 
            -
                __publicField$ | 
| 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 217 | 
             
                this.theChain = new Source({});
         | 
| 218 218 | 
             
              }
         | 
| 219 219 | 
             
              resultArray(guest) {
         | 
| @@ -298,13 +298,13 @@ class Patron { | |
| 298 298 | 
             
              }
         | 
| 299 299 | 
             
            }
         | 
| 300 300 |  | 
| 301 | 
            -
            var __defProp = Object.defineProperty;
         | 
| 302 | 
            -
            var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 303 | 
            -
            var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
         | 
| 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 304 | 
             
            class PatronOnce {
         | 
| 305 305 | 
             
              constructor(baseGuest) {
         | 
| 306 306 | 
             
                this.baseGuest = baseGuest;
         | 
| 307 | 
            -
                __publicField(this, "received", false);
         | 
| 307 | 
            +
                __publicField$1(this, "received", false);
         | 
| 308 308 | 
             
              }
         | 
| 309 309 | 
             
              introduction() {
         | 
| 310 310 | 
             
                return "patron";
         | 
| @@ -321,6 +321,29 @@ class PatronOnce { | |
| 321 321 | 
             
              }
         | 
| 322 322 | 
             
            }
         | 
| 323 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 | 
            +
              receiving(guest) {
         | 
| 332 | 
            +
                this.baseSource.receiving(
         | 
| 333 | 
            +
                  new GuestMiddle(guest, (value) => {
         | 
| 334 | 
            +
                    if (value !== null) {
         | 
| 335 | 
            +
                      give(value, guest);
         | 
| 336 | 
            +
                    }
         | 
| 337 | 
            +
                  })
         | 
| 338 | 
            +
                );
         | 
| 339 | 
            +
                return this;
         | 
| 340 | 
            +
              }
         | 
| 341 | 
            +
              receive(value) {
         | 
| 342 | 
            +
                this.baseSource.receive(value);
         | 
| 343 | 
            +
                return this;
         | 
| 344 | 
            +
              }
         | 
| 345 | 
            +
            }
         | 
| 346 | 
            +
             | 
| 324 347 | 
             
            class Factory {
         | 
| 325 348 | 
             
              constructor(constructorFn, factories = {}) {
         | 
| 326 349 | 
             
                this.constructorFn = constructorFn;
         | 
| @@ -331,26 +354,6 @@ class Factory { | |
| 331 354 | 
             
              }
         | 
| 332 355 | 
             
            }
         | 
| 333 356 |  | 
| 334 | 
            -
            if (globalThis) {
         | 
| 335 | 
            -
              globalThis["GUEST_LIBRARY"] = {
         | 
| 336 | 
            -
                give,
         | 
| 337 | 
            -
                removePatronFromPools,
         | 
| 338 | 
            -
                GuestAware,
         | 
| 339 | 
            -
                Guest,
         | 
| 340 | 
            -
                GuestCast,
         | 
| 341 | 
            -
                GuestChain,
         | 
| 342 | 
            -
                GuestMiddle,
         | 
| 343 | 
            -
                GuestPool,
         | 
| 344 | 
            -
                GuestSync,
         | 
| 345 | 
            -
                GuestObject,
         | 
| 346 | 
            -
                Patron,
         | 
| 347 | 
            -
                PatronOnce,
         | 
| 348 | 
            -
                PatronPool,
         | 
| 349 | 
            -
                Source,
         | 
| 350 | 
            -
                Factory
         | 
| 351 | 
            -
              };
         | 
| 352 | 
            -
            }
         | 
| 353 | 
            -
             | 
| 354 357 | 
             
            exports.Factory = Factory;
         | 
| 355 358 | 
             
            exports.Guest = Guest;
         | 
| 356 359 | 
             
            exports.GuestAware = GuestAware;
         | 
| @@ -364,6 +367,7 @@ exports.Patron = Patron; | |
| 364 367 | 
             
            exports.PatronOnce = PatronOnce;
         | 
| 365 368 | 
             
            exports.PatronPool = PatronPool;
         | 
| 366 369 | 
             
            exports.Source = Source;
         | 
| 370 | 
            +
            exports.SourceEmpty = SourceEmpty;
         | 
| 367 371 | 
             
            exports.give = give;
         | 
| 368 372 | 
             
            exports.removePatronFromPools = removePatronFromPools;
         | 
| 369 373 | 
             
            //# sourceMappingURL=patron.js.map
         | 
    
        package/dist/patron.js.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"patron.js","sources":["../src/Guest/Guest.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestAware.ts","../src/Guest/GuestCast.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/Factory/Factory.ts","../src/index.ts"],"sourcesContent":["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 {\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 { 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","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 { 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","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","import { give, Guest } from \"./Guest/Guest\";\nimport { PatronPool, removePatronFromPools } from \"./Patron/PatronPool\";\nimport { GuestAware } from \"./Guest/GuestAware\";\nimport { GuestCast } from \"./Guest/GuestCast\";\nimport { GuestChain } from \"./Guest/GuestChain\";\nimport { GuestMiddle } from \"./Guest/GuestMiddle\";\nimport { GuestPool } from \"./Guest/GuestPool\";\nimport { GuestSync } from \"./Guest/GuestSync\";\nimport { GuestObject } from \"./Guest/GuestObject\";\nimport { Patron } from \"./Patron/Patron\";\nimport { PatronOnce } from \"./Patron/PatronOnce\";\nimport { Source } from \"./Source/Source\";\nimport { Factory } from \"./Factory/Factory\";\n\nexport * from \"./Guest/GuestAware\";\nexport * from \"./Guest/Guest\";\nexport * from \"./Guest/GuestCast\";\nexport * from \"./Guest/GuestChain\";\nexport * from \"./Guest/GuestMiddle\";\nexport * from \"./Guest/GuestPool\";\nexport * from \"./Guest/GuestSync\";\nexport * from \"./Patron/Patron\";\nexport * from \"./Patron/PatronOnce\";\nexport * from \"./Patron/PatronPool\";\nexport * from \"./Source/Source\";\nexport * from \"./Guest/GuestObject\";\nexport * from \"./Factory/Factory\";\n\ndeclare var globalThis: any;\n\nif (globalThis) {\n  globalThis[\"GUEST_LIBRARY\"] = {\n    give,\n    removePatronFromPools,\n    GuestAware,\n    Guest,\n    GuestCast,\n    GuestChain,\n    GuestMiddle,\n    GuestPool,\n    GuestSync,\n    GuestObject,\n    Patron,\n    PatronOnce,\n    PatronPool,\n    Source,\n    Factory,\n  };\n}\n"],"names":["__publicField"],"mappings":";;AAkBgB,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;;;;;AC9BA,MAAM,QAAA,uBAAe,GAAoC,EAAA,CAAA;AAK5C,MAAA,qBAAA,GAAwB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AA,EAAW,OAAO,CAAA,CAAA;AAAA,KACrC;AAEA,IAAA,MAAM,OAAO,OAAS,EAAA,IAAA,CAAA;AAEtB,IAAA,IAAI,MAAM,IAAM,EAAA;AACd,MAAK,IAAA,CAAA,IAAA,CAAK,OAAO,IAAI,CAAA,CAAA;AAAA,KACvB;AAEA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACtBO,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;;ACSA,IAAI,UAAY,EAAA;AACd,EAAA,UAAA,CAAW,eAAe,CAAI,GAAA;AAAA,IAC5B,IAAA;AAAA,IACA,qBAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACF;;;;;;;;;;;;;;;;;;"}
         | 
| 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,CAA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AAA,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;;;;;;;;;;;;;;;;;;;"}
         | 
    
        package/dist/patron.min.js
    CHANGED
    
    | @@ -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  | 
| 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)}))}}({});
         | 
| @@ -0,0 +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};
         | 
| 2 | 
            +
            //# sourceMappingURL=patron.min.mjs.map
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"version":3,"file":"patron.min.mjs","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":["GuestAware","constructor","guestReceiver","this","receiving","guest","give","data","options","receive","Guest","receiver","value","GuestCast","sourceGuest","targetGuest","introduction","poolSets","Map","removePatronFromPools","patron","forEach","pool","delete","PatronPool","initiator","__publicField","Set","set","patrons","lastMicrotask","doReceive","target","sendValueToGuest","currentMicroTask","queueMicrotask","add","shouldBePatron","remove","distribute","possiblePatron","GuestPool","patronPool","deliverToGuests","guests","clear","GuestMiddle","baseGuest","middleFn","Source","sourceDocument","GuestObject","GuestChain","theChain","resultArray","guestObject","filledChainPool","Object","values","isChainFilled","chain","result","receiveKey","key","keysKnown","keysFilled","lastChain","size","GuestSync","theValue","Patron","willBePatron","PatronOnce","received","SourceEmpty","baseSource","Factory","constructorFn","factories","create","args"],"mappings":"AAMO,MAAMA,EACJ,WAAAC,CAAoBC,GAAAC,KAAAD,cAAAA,CAA+C,CAEnE,SAAAE,CAAUC,GAER,OADPF,KAAKD,cAAc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,MAAA,QACT,CAEO,OAAAP,CAAQG,EAAUJ,GAClBL,KAAKsE,UACHnE,EAAAM,EAAOT,KAAK4C,UAAWvC,GAG9B,MAAMD,EAAOC,GAASD,KAMf,OAJHA,GAAMe,MACHf,EAAAe,KAAKgB,OAAOnC,MAGZA,IACT,uIC7BK,MAAMuE,EAAN,WAAAzE,GACGyB,EAAAvB,KAAA,aAAa,IAAI8C,EAAiB,MAAI,CAEvC,SAAA7C,CAAUC,GAQR,OAPPF,KAAKwE,WAAWvE,UACd,IAAI0C,EAAYzC,GAAqBO,IACrB,OAAVA,GACFN,EAAKM,EAAOP,EACd,KAGGF,IACT,CAEO,OAAAM,CAAQG,GAEN,OADFT,KAAAwE,WAAWlE,QAAQG,GACjBT,IACT,ECTK,MAAMyE,EACF,WAAA3E,CACK4E,EACAC,EAAqC,IADrC3E,KAAA0E,cAAAA,EACA1E,KAAA2E,UAAAA,CACR,CAEG,MAAAC,IAA0CC,GAC7C,OAAO,IAAK7E,KAAK0E,iBAAsCG,EAAM7E,KAAK2E,UACtE"}
         | 
    
        package/dist/patron.mjs
    CHANGED
    
    | @@ -1,3 +1,13 @@ | |
| 1 | 
            +
            class GuestAware {
         | 
| 2 | 
            +
              constructor(guestReceiver) {
         | 
| 3 | 
            +
                this.guestReceiver = guestReceiver;
         | 
| 4 | 
            +
              }
         | 
| 5 | 
            +
              receiving(guest) {
         | 
| 6 | 
            +
                this.guestReceiver(guest);
         | 
| 7 | 
            +
                return guest;
         | 
| 8 | 
            +
              }
         | 
| 9 | 
            +
            }
         | 
| 10 | 
            +
             | 
| 1 11 | 
             
            function give(data, guest, options) {
         | 
| 2 12 | 
             
              if (typeof guest === "function") {
         | 
| 3 13 | 
             
                guest(data, options);
         | 
| @@ -15,9 +25,29 @@ class Guest { | |
| 15 25 | 
             
              }
         | 
| 16 26 | 
             
            }
         | 
| 17 27 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 28 | 
            +
            class GuestCast {
         | 
| 29 | 
            +
              constructor(sourceGuest, targetGuest) {
         | 
| 30 | 
            +
                this.sourceGuest = sourceGuest;
         | 
| 31 | 
            +
                this.targetGuest = targetGuest;
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
              introduction() {
         | 
| 34 | 
            +
                if (typeof this.sourceGuest === "function") {
         | 
| 35 | 
            +
                  return "guest";
         | 
| 36 | 
            +
                }
         | 
| 37 | 
            +
                if (!this.sourceGuest.introduction) {
         | 
| 38 | 
            +
                  return "guest";
         | 
| 39 | 
            +
                }
         | 
| 40 | 
            +
                return this.sourceGuest.introduction();
         | 
| 41 | 
            +
              }
         | 
| 42 | 
            +
              receive(value, options) {
         | 
| 43 | 
            +
                give(value, this.targetGuest, options);
         | 
| 44 | 
            +
                return this;
         | 
| 45 | 
            +
              }
         | 
| 46 | 
            +
            }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            var __defProp$5 = Object.defineProperty;
         | 
| 49 | 
            +
            var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 50 | 
            +
            var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
         | 
| 21 51 | 
             
            const poolSets = /* @__PURE__ */ new Map();
         | 
| 22 52 | 
             
            const removePatronFromPools = (patron) => {
         | 
| 23 53 | 
             
              poolSets.forEach((pool) => {
         | 
| @@ -27,8 +57,8 @@ const removePatronFromPools = (patron) => { | |
| 27 57 | 
             
            class PatronPool {
         | 
| 28 58 | 
             
              constructor(initiator) {
         | 
| 29 59 | 
             
                this.initiator = initiator;
         | 
| 30 | 
            -
                __publicField$ | 
| 31 | 
            -
                __publicField$ | 
| 60 | 
            +
                __publicField$5(this, "patrons", /* @__PURE__ */ new Set());
         | 
| 61 | 
            +
                __publicField$5(this, "receive");
         | 
| 32 62 | 
             
                poolSets.set(this, this.patrons);
         | 
| 33 63 | 
             
                let lastMicrotask = null;
         | 
| 34 64 | 
             
                const doReceive = (value, options) => {
         | 
| @@ -74,43 +104,13 @@ class PatronPool { | |
| 74 104 | 
             
              }
         | 
| 75 105 | 
             
            }
         | 
| 76 106 |  | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
              }
         | 
| 81 | 
            -
              receiving(guest) {
         | 
| 82 | 
            -
                this.guestReceiver(guest);
         | 
| 83 | 
            -
                return guest;
         | 
| 84 | 
            -
              }
         | 
| 85 | 
            -
            }
         | 
| 86 | 
            -
             | 
| 87 | 
            -
            class GuestCast {
         | 
| 88 | 
            -
              constructor(sourceGuest, targetGuest) {
         | 
| 89 | 
            -
                this.sourceGuest = sourceGuest;
         | 
| 90 | 
            -
                this.targetGuest = targetGuest;
         | 
| 91 | 
            -
              }
         | 
| 92 | 
            -
              introduction() {
         | 
| 93 | 
            -
                if (typeof this.sourceGuest === "function") {
         | 
| 94 | 
            -
                  return "guest";
         | 
| 95 | 
            -
                }
         | 
| 96 | 
            -
                if (!this.sourceGuest.introduction) {
         | 
| 97 | 
            -
                  return "guest";
         | 
| 98 | 
            -
                }
         | 
| 99 | 
            -
                return this.sourceGuest.introduction();
         | 
| 100 | 
            -
              }
         | 
| 101 | 
            -
              receive(value, options) {
         | 
| 102 | 
            -
                give(value, this.targetGuest, options);
         | 
| 103 | 
            -
                return this;
         | 
| 104 | 
            -
              }
         | 
| 105 | 
            -
            }
         | 
| 106 | 
            -
             | 
| 107 | 
            -
            var __defProp$3 = Object.defineProperty;
         | 
| 108 | 
            -
            var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 109 | 
            -
            var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
         | 
| 107 | 
            +
            var __defProp$4 = Object.defineProperty;
         | 
| 108 | 
            +
            var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 109 | 
            +
            var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
         | 
| 110 110 | 
             
            class GuestPool {
         | 
| 111 111 | 
             
              constructor(initiator) {
         | 
| 112 | 
            -
                __publicField$ | 
| 113 | 
            -
                __publicField$ | 
| 112 | 
            +
                __publicField$4(this, "guests", /* @__PURE__ */ new Set());
         | 
| 113 | 
            +
                __publicField$4(this, "patronPool");
         | 
| 114 114 | 
             
                this.patronPool = new PatronPool(initiator);
         | 
| 115 115 | 
             
              }
         | 
| 116 116 | 
             
              receive(value, options) {
         | 
| @@ -160,13 +160,13 @@ class GuestMiddle { | |
| 160 160 | 
             
              }
         | 
| 161 161 | 
             
            }
         | 
| 162 162 |  | 
| 163 | 
            -
            var __defProp$ | 
| 164 | 
            -
            var __defNormalProp$ | 
| 165 | 
            -
            var __publicField$ | 
| 163 | 
            +
            var __defProp$3 = Object.defineProperty;
         | 
| 164 | 
            +
            var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 165 | 
            +
            var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
         | 
| 166 166 | 
             
            class Source {
         | 
| 167 167 | 
             
              constructor(sourceDocument) {
         | 
| 168 168 | 
             
                this.sourceDocument = sourceDocument;
         | 
| 169 | 
            -
                __publicField$ | 
| 169 | 
            +
                __publicField$3(this, "pool", new PatronPool(this));
         | 
| 170 170 | 
             
              }
         | 
| 171 171 | 
             
              receive(value) {
         | 
| 172 172 | 
             
                this.sourceDocument = value;
         | 
| @@ -203,15 +203,15 @@ class GuestObject { | |
| 203 203 | 
             
              }
         | 
| 204 204 | 
             
            }
         | 
| 205 205 |  | 
| 206 | 
            -
            var __defProp$ | 
| 207 | 
            -
            var __defNormalProp$ | 
| 208 | 
            -
            var __publicField$ | 
| 206 | 
            +
            var __defProp$2 = Object.defineProperty;
         | 
| 207 | 
            +
            var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 208 | 
            +
            var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
         | 
| 209 209 | 
             
            class GuestChain {
         | 
| 210 210 | 
             
              constructor() {
         | 
| 211 | 
            -
                __publicField$ | 
| 212 | 
            -
                __publicField$ | 
| 213 | 
            -
                __publicField$ | 
| 214 | 
            -
                __publicField$ | 
| 211 | 
            +
                __publicField$2(this, "theChain");
         | 
| 212 | 
            +
                __publicField$2(this, "keysKnown", /* @__PURE__ */ new Set());
         | 
| 213 | 
            +
                __publicField$2(this, "keysFilled", /* @__PURE__ */ new Set());
         | 
| 214 | 
            +
                __publicField$2(this, "filledChainPool", new GuestPool(this));
         | 
| 215 215 | 
             
                this.theChain = new Source({});
         | 
| 216 216 | 
             
              }
         | 
| 217 217 | 
             
              resultArray(guest) {
         | 
| @@ -296,13 +296,13 @@ class Patron { | |
| 296 296 | 
             
              }
         | 
| 297 297 | 
             
            }
         | 
| 298 298 |  | 
| 299 | 
            -
            var __defProp = Object.defineProperty;
         | 
| 300 | 
            -
            var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 301 | 
            -
            var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
         | 
| 299 | 
            +
            var __defProp$1 = Object.defineProperty;
         | 
| 300 | 
            +
            var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 301 | 
            +
            var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
         | 
| 302 302 | 
             
            class PatronOnce {
         | 
| 303 303 | 
             
              constructor(baseGuest) {
         | 
| 304 304 | 
             
                this.baseGuest = baseGuest;
         | 
| 305 | 
            -
                __publicField(this, "received", false);
         | 
| 305 | 
            +
                __publicField$1(this, "received", false);
         | 
| 306 306 | 
             
              }
         | 
| 307 307 | 
             
              introduction() {
         | 
| 308 308 | 
             
                return "patron";
         | 
| @@ -319,6 +319,29 @@ class PatronOnce { | |
| 319 319 | 
             
              }
         | 
| 320 320 | 
             
            }
         | 
| 321 321 |  | 
| 322 | 
            +
            var __defProp = Object.defineProperty;
         | 
| 323 | 
            +
            var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
         | 
| 324 | 
            +
            var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
         | 
| 325 | 
            +
            class SourceEmpty {
         | 
| 326 | 
            +
              constructor() {
         | 
| 327 | 
            +
                __publicField(this, "baseSource", new Source(null));
         | 
| 328 | 
            +
              }
         | 
| 329 | 
            +
              receiving(guest) {
         | 
| 330 | 
            +
                this.baseSource.receiving(
         | 
| 331 | 
            +
                  new GuestMiddle(guest, (value) => {
         | 
| 332 | 
            +
                    if (value !== null) {
         | 
| 333 | 
            +
                      give(value, guest);
         | 
| 334 | 
            +
                    }
         | 
| 335 | 
            +
                  })
         | 
| 336 | 
            +
                );
         | 
| 337 | 
            +
                return this;
         | 
| 338 | 
            +
              }
         | 
| 339 | 
            +
              receive(value) {
         | 
| 340 | 
            +
                this.baseSource.receive(value);
         | 
| 341 | 
            +
                return this;
         | 
| 342 | 
            +
              }
         | 
| 343 | 
            +
            }
         | 
| 344 | 
            +
             | 
| 322 345 | 
             
            class Factory {
         | 
| 323 346 | 
             
              constructor(constructorFn, factories = {}) {
         | 
| 324 347 | 
             
                this.constructorFn = constructorFn;
         | 
| @@ -329,25 +352,5 @@ class Factory { | |
| 329 352 | 
             
              }
         | 
| 330 353 | 
             
            }
         | 
| 331 354 |  | 
| 332 | 
            -
             | 
| 333 | 
            -
              globalThis["GUEST_LIBRARY"] = {
         | 
| 334 | 
            -
                give,
         | 
| 335 | 
            -
                removePatronFromPools,
         | 
| 336 | 
            -
                GuestAware,
         | 
| 337 | 
            -
                Guest,
         | 
| 338 | 
            -
                GuestCast,
         | 
| 339 | 
            -
                GuestChain,
         | 
| 340 | 
            -
                GuestMiddle,
         | 
| 341 | 
            -
                GuestPool,
         | 
| 342 | 
            -
                GuestSync,
         | 
| 343 | 
            -
                GuestObject,
         | 
| 344 | 
            -
                Patron,
         | 
| 345 | 
            -
                PatronOnce,
         | 
| 346 | 
            -
                PatronPool,
         | 
| 347 | 
            -
                Source,
         | 
| 348 | 
            -
                Factory
         | 
| 349 | 
            -
              };
         | 
| 350 | 
            -
            }
         | 
| 351 | 
            -
             | 
| 352 | 
            -
            export { Factory, Guest, GuestAware, GuestCast, GuestChain, GuestMiddle, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Source, give, removePatronFromPools };
         | 
| 355 | 
            +
            export { Factory, Guest, GuestAware, GuestCast, GuestChain, GuestMiddle, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Source, SourceEmpty, give, removePatronFromPools };
         | 
| 353 356 | 
             
            //# sourceMappingURL=patron.mjs.map
         | 
    
        package/dist/patron.mjs.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"patron.mjs","sources":["../src/Guest/Guest.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestAware.ts","../src/Guest/GuestCast.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/Factory/Factory.ts","../src/index.ts"],"sourcesContent":["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 {\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 { 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","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 { 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","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","import { give, Guest } from \"./Guest/Guest\";\nimport { PatronPool, removePatronFromPools } from \"./Patron/PatronPool\";\nimport { GuestAware } from \"./Guest/GuestAware\";\nimport { GuestCast } from \"./Guest/GuestCast\";\nimport { GuestChain } from \"./Guest/GuestChain\";\nimport { GuestMiddle } from \"./Guest/GuestMiddle\";\nimport { GuestPool } from \"./Guest/GuestPool\";\nimport { GuestSync } from \"./Guest/GuestSync\";\nimport { GuestObject } from \"./Guest/GuestObject\";\nimport { Patron } from \"./Patron/Patron\";\nimport { PatronOnce } from \"./Patron/PatronOnce\";\nimport { Source } from \"./Source/Source\";\nimport { Factory } from \"./Factory/Factory\";\n\nexport * from \"./Guest/GuestAware\";\nexport * from \"./Guest/Guest\";\nexport * from \"./Guest/GuestCast\";\nexport * from \"./Guest/GuestChain\";\nexport * from \"./Guest/GuestMiddle\";\nexport * from \"./Guest/GuestPool\";\nexport * from \"./Guest/GuestSync\";\nexport * from \"./Patron/Patron\";\nexport * from \"./Patron/PatronOnce\";\nexport * from \"./Patron/PatronPool\";\nexport * from \"./Source/Source\";\nexport * from \"./Guest/GuestObject\";\nexport * from \"./Factory/Factory\";\n\ndeclare var globalThis: any;\n\nif (globalThis) {\n  globalThis[\"GUEST_LIBRARY\"] = {\n    give,\n    removePatronFromPools,\n    GuestAware,\n    Guest,\n    GuestCast,\n    GuestChain,\n    GuestMiddle,\n    GuestPool,\n    GuestSync,\n    GuestObject,\n    Patron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AAA,GAC/E;AACJ;;ACSA,IAAI,UAAY,EAAA;AACd,EAAA,UAAA,CAAW,eAAe,CAAI,GAAA;AAAA,IAC5B,IAAA;AAAA,IACA,qBAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACF;;;;"}
         | 
| 1 | 
            +
            {"version":3,"file":"patron.mjs","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;A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IAAI,MAAA,CAAiB,IAAI,CAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAEvC,UAAU,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;;;;"}
         | 
    
        package/package.json
    CHANGED
    
    
    
        package/rollup.config.js
    CHANGED
    
    
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            import { SourceEmpty } from "./SourceEmpty";
         | 
| 2 | 
            +
            import { expect, test } from "vitest";
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            test("source", () => {
         | 
| 5 | 
            +
              const source = new SourceEmpty<number>();
         | 
| 6 | 
            +
              let accumulator = 0;
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              // Не вызывается потому что нет значения
         | 
| 9 | 
            +
              source.receiving(() => {
         | 
| 10 | 
            +
                accumulator += 100;
         | 
| 11 | 
            +
              });
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              // Вызывается после прихода значения
         | 
| 14 | 
            +
              source.receive(200);
         | 
| 15 | 
            +
              source.receiving((value) => {
         | 
| 16 | 
            +
                accumulator += value;
         | 
| 17 | 
            +
              });
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              expect(accumulator).toBe(200);
         | 
| 20 | 
            +
            });
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            import { give, GuestType } from "./../Guest/Guest";
         | 
| 2 | 
            +
            import { GuestMiddle } from "./../Guest/GuestMiddle";
         | 
| 3 | 
            +
            import { Source, SourceType } from "./Source";
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            export class SourceEmpty<T> implements SourceType<T> {
         | 
| 6 | 
            +
              private baseSource = new Source<T | null>(null);
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              public receiving(guest: GuestType<T>) {
         | 
| 9 | 
            +
                this.baseSource.receiving(
         | 
| 10 | 
            +
                  new GuestMiddle(guest as GuestType, (value) => {
         | 
| 11 | 
            +
                    if (value !== null) {
         | 
| 12 | 
            +
                      give(value, guest);
         | 
| 13 | 
            +
                    }
         | 
| 14 | 
            +
                  }),
         | 
| 15 | 
            +
                );
         | 
| 16 | 
            +
                return this;
         | 
| 17 | 
            +
              }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              public receive(value: T): this {
         | 
| 20 | 
            +
                this.baseSource.receive(value);
         | 
| 21 | 
            +
                return this;
         | 
| 22 | 
            +
              }
         | 
| 23 | 
            +
            }
         | 
    
        package/src/index.ts
    CHANGED
    
    | @@ -1,17 +1,3 @@ | |
| 1 | 
            -
            import { give, Guest } from "./Guest/Guest";
         | 
| 2 | 
            -
            import { PatronPool, removePatronFromPools } from "./Patron/PatronPool";
         | 
| 3 | 
            -
            import { GuestAware } from "./Guest/GuestAware";
         | 
| 4 | 
            -
            import { GuestCast } from "./Guest/GuestCast";
         | 
| 5 | 
            -
            import { GuestChain } from "./Guest/GuestChain";
         | 
| 6 | 
            -
            import { GuestMiddle } from "./Guest/GuestMiddle";
         | 
| 7 | 
            -
            import { GuestPool } from "./Guest/GuestPool";
         | 
| 8 | 
            -
            import { GuestSync } from "./Guest/GuestSync";
         | 
| 9 | 
            -
            import { GuestObject } from "./Guest/GuestObject";
         | 
| 10 | 
            -
            import { Patron } from "./Patron/Patron";
         | 
| 11 | 
            -
            import { PatronOnce } from "./Patron/PatronOnce";
         | 
| 12 | 
            -
            import { Source } from "./Source/Source";
         | 
| 13 | 
            -
            import { Factory } from "./Factory/Factory";
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            export * from "./Guest/GuestAware";
         | 
| 16 2 | 
             
            export * from "./Guest/Guest";
         | 
| 17 3 | 
             
            export * from "./Guest/GuestCast";
         | 
| @@ -23,27 +9,6 @@ export * from "./Patron/Patron"; | |
| 23 9 | 
             
            export * from "./Patron/PatronOnce";
         | 
| 24 10 | 
             
            export * from "./Patron/PatronPool";
         | 
| 25 11 | 
             
            export * from "./Source/Source";
         | 
| 12 | 
            +
            export * from "./Source/SourceEmpty";
         | 
| 26 13 | 
             
            export * from "./Guest/GuestObject";
         | 
| 27 14 | 
             
            export * from "./Factory/Factory";
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            declare var globalThis: any;
         | 
| 30 | 
            -
             | 
| 31 | 
            -
            if (globalThis) {
         | 
| 32 | 
            -
              globalThis["GUEST_LIBRARY"] = {
         | 
| 33 | 
            -
                give,
         | 
| 34 | 
            -
                removePatronFromPools,
         | 
| 35 | 
            -
                GuestAware,
         | 
| 36 | 
            -
                Guest,
         | 
| 37 | 
            -
                GuestCast,
         | 
| 38 | 
            -
                GuestChain,
         | 
| 39 | 
            -
                GuestMiddle,
         | 
| 40 | 
            -
                GuestPool,
         | 
| 41 | 
            -
                GuestSync,
         | 
| 42 | 
            -
                GuestObject,
         | 
| 43 | 
            -
                Patron,
         | 
| 44 | 
            -
                PatronOnce,
         | 
| 45 | 
            -
                PatronPool,
         | 
| 46 | 
            -
                Source,
         | 
| 47 | 
            -
                Factory,
         | 
| 48 | 
            -
              };
         | 
| 49 | 
            -
            }
         |