patron-oop 1.34.0 → 1.35.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"patron.js","sources":["../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Guest/GuestCast.ts","../src/Patron/PatronPool.ts","../src/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestChain.ts","../src/Source/SourceEmpty.ts","../src/Guest/GuestAwareSequence.ts","../src/Guest/GuestAwareMap.ts","../src/Guest/GuestAwareRace.ts","../src/Guest/GuestAwareActive.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestDisposable.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceDynamic.ts","../src/Factory/Factory.ts","../src/Factory/Module.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport type GuestAwareExecutorType<T> = (guest: GuestType<T>) => unknown;\n\nexport interface GuestAwareObjectType<T> {\n value: GuestAwareExecutorType<T>\n}\n\nexport type GuestAwareType<T = any> = GuestAwareExecutorType<T> | GuestAwareObjectType<T>\n\nexport function value<T>(guestAware: GuestAwareType<T>, guest: GuestType<T>) {\n if (typeof guestAware === 'function') {\n return guestAware(guest);\n } else {\n return guestAware.value(guest);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware\n */\nexport class GuestAware<T = any> implements GuestAwareObjectType<T> {\n public constructor(private guestAware: GuestAwareType<T>) { }\n\n public value(guest: GuestType<T>): GuestType<T> {\n value(this.guestAware, guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = any> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = any> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = any> = GuestExecutorType<T> | GuestObjectType<T>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/give\n */\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest\n */\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) { }\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-cast\n */\nexport class GuestCast<T> implements GuestDisposableType<T> {\n public constructor(\n private sourceGuest: GuestType<any>,\n private targetGuest: GuestType<T>,\n ) { }\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.sourceGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/remove-patron-from-pools\n */\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/is-patron-in-pools\n */\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n};\n\nexport interface PoolType<T = any> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n size(): number;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-pool\n */\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public size(): number {\n return this.patrons.size;\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (!shouldBePatron) {\n throw new Error(\"PatronPool add method received nothing!\");\n }\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: GiveOptions,\n ) {\n const isDisposed = this.guestDisposed(value, guest);\n\n if (!isDisposed) {\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\n private guestDisposed(value: T, guest: GuestType<T>) {\n if ((guest as GuestDisposableType).disposed?.(value)) {\n this.remove(guest as GuestObjectType);\n return true;\n }\n\n return false;\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareObjectType } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport interface PoolAware<T = any> {\n pool(): PatronPool<T>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source\n */\nexport type SourceType<T = any> = GuestAwareObjectType<T> &\n GuestObjectType<T> &\n PoolAware<T>;\n\nexport class Source<T> implements SourceType<T> {\n private thePool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) { }\n\n public pool() {\n return this.thePool;\n }\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.thePool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.thePool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.thePool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { GiveOptions, Guest, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-object\n */\nexport class GuestObject<T> implements GuestDisposableType<T> {\n public constructor(private baseGuest: GuestType<T>) { }\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-pool\n */\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n public size() {\n return this.patronPool.size() + this.guests.size;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestCast } from \"./GuestCast\";\nimport { Source } from \"../Source/Source\";\nimport { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestObject } from \"./GuestObject\";\nimport { GuestPool } from \"./GuestPool\";\n\nexport interface ChainType<T = any> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-chain\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 GuestCast(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }),\n );\n if (this.isChainFilled()) {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.give(Object.values(chain));\n }),\n );\n }\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.value(\n new Guest((chain) => {\n this.filledChainPool.give(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.give(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.give(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { GuestCast } from \"../Guest/GuestCast\";\nimport { give, GuestType } from \"./../Guest/Guest\";\nimport { Source, SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source/source-empty\n */\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestCast(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n\n public pool(): PatronPool<T> {\n return this.baseSource.pool();\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestType } from \"./Guest\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-sequence\n */\nexport class GuestAwareSequence<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const chain = new GuestChain<TG[]>();\n const sequenceSource = new SourceEmpty();\n const targetSource = this.targetSourceFactory.create(\n sequenceSource\n )\n\n value(\n this.baseSource,\n new GuestCast(guest, (theValue) => {\n let index = 0;\n\n const nextItemHandle = () => {\n if (theValue[index + 1] !== undefined) {\n index = index + 1;\n handle();\n } else {\n chain.resultArray(guest);\n }\n }\n\n function handle() {\n sequenceSource.give(theValue[index]);\n value(targetSource, chain.receiveKey('' + index));\n value(targetSource, nextItemHandle);\n }\n\n if (theValue[index] !== undefined) {\n handle();\n } else {\n give([], guest);\n }\n })\n );\n return this;\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAware } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-map\n */\nexport class GuestAwareMap<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const chain = new GuestChain();\n value(\n this.baseSource,\n new GuestCast(<GuestType>guest, (theValue) => {\n theValue.forEach((val, index) => {\n const targetSource = this.targetSourceFactory.create(\n new GuestAware((innerGuest) => {\n give(val, innerGuest);\n })\n )\n value(targetSource, chain.receiveKey('' + index));\n });\n })\n )\n chain.resultArray(<GuestType>guest);\n return this;\n }\n}\n","import { give, GuestType } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-race\n */\nexport class GuestAwareRace<T> implements GuestAwareObjectType<T> {\n public constructor(private guestAwares: GuestAwareType<T>[]) { }\n\n public value(guest: GuestType<T>): this {\n let connectedWithGuestAware: GuestAwareType | null = null;\n this.guestAwares.forEach(guestAware => {\n value(\n guestAware,\n new GuestCast(<GuestType>guest, (value) => {\n if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {\n give(value as T, guest);\n connectedWithGuestAware = guestAware\n }\n })\n );\n });\n return this;\n }\n}\n","import { SourceType } from \"../Source/Source\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAwareObjectType } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/action-type\n */\nexport interface ActionType<P = any> {\n do(config: P): this;\n}\n\nexport interface GuestAwareAcitveType<R = unknown, T = unknown> extends GuestAwareObjectType<T>, ActionType<R> {\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-active\n */\nexport class GuestAwareActive<R, T> implements GuestAwareAcitveType<R, T> {\n private source = new SourceEmpty<T>();\n\n public constructor(private configExecutor: (config: R, source: SourceType<T>) => void) { }\n\n public do(config: R): this {\n this.configExecutor(config, this.source);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n this.source.value(guest);\n return this;\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = any> extends GuestObjectType<T> {\n value(): T;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-sync\n */\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) { }\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GiveOptions, GuestObjectType, GuestType } from \"./Guest\";\n\nexport interface GuestDisposableType<T = any> extends GuestObjectType<T> {\n disposed(value: T | null): boolean;\n}\n\nexport type MaybeDisposableType<T = any> = Partial<GuestDisposableType<T>>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-disposable\n */\nexport class GuestDisposable<T> implements GuestDisposableType<T> {\n public constructor(\n private guest: GuestType,\n private disposeCheck: (value: T | null) => boolean,\n ) { }\n\n public disposed(value: T | null): boolean {\n return this.disposeCheck(value);\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.guest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"../Guest/Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron\n */\nexport class Patron<T> implements GuestDisposableType<T> {\n public constructor(private willBePatron: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.willBePatron as GuestDisposableType;\n return maybeDisposable?.disposed?.(value) || false;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestType, GiveOptions } from \"../Guest/Guest\";\nimport {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"../Guest/GuestDisposable\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-once\n */\nexport class PatronOnce<T> implements GuestDisposableType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { give, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareType, value } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\nimport { SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source-dynamic\n */\nexport class SourceDynamic<T = unknown> implements SourceType<T> {\n public constructor(\n private baseGuest: GuestType<T>,\n private baseGuestAware: GuestAwareType<T>,\n ) { }\n\n public value(guest: GuestType<T>) {\n value(this.baseGuestAware, guest);\n return this;\n }\n\n public give(value: T) {\n give(value, this.baseGuest);\n return this;\n }\n\n public pool(): PatronPool<T> {\n throw Error('No pool in SourceDynamic');\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\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/factory\n */\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) { }\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./Factory\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/module\n */\nexport class Module<T> implements FactoryType<T> {\n public constructor(private buildingFn: (...args: any[]) => T) { }\n\n public create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT {\n return this.buildingFn(...args) as CT extends null ? T : CT;\n }\n}\n"],"names":["__publicField","value"],"mappings":"AAUgB,SAAA,KAAA,CAAS,YAA+B,KAAqB,EAAA;AAC3E,EAAI,IAAA,OAAO,eAAe,UAAY,EAAA;AACpC,IAAA,OAAO,WAAW,KAAK,CAAA,CAAA;AAAA,GAClB,MAAA;AACL,IAAO,OAAA,UAAA,CAAW,MAAM,KAAK,CAAA,CAAA;AAAA,GAC/B;AACF,CAAA;AAK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A,GAAA,SAAA,CAAA;AAAA,GACN;AAAA,EAEG,UACF,IACuB,EAAA;AAC1B,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAK,CAAA,SAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF;;ACxBO,MAAM,MAAoC,CAAA;AAAA,EACxC,YAAoB,UAAmC,EAAA;AAAnC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AAAA,GAAqC;AAAA,EAEzD,UAA0C,IAAmC,EAAA;AAClF,IAAO,OAAA,IAAA,CAAK,UAAW,CAAA,GAAG,IAAI,CAAA,CAAA;AAAA,GAChC;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/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestAwareAll.ts","../src/Source/SourceEmpty.ts","../src/Guest/GuestAwareSequence.ts","../src/Guest/GuestAwareMap.ts","../src/Guest/GuestAwareRace.ts","../src/Guest/GuestAwareActive.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestDisposable.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceDynamic.ts","../src/Factory/Factory.ts","../src/Factory/Module.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport type GuestAwareExecutorType<T> = (guest: GuestType<T>) => unknown;\n\nexport interface GuestAwareObjectType<T> {\n value: GuestAwareExecutorType<T>\n}\n\nexport type GuestAwareType<T = any> = GuestAwareExecutorType<T> | GuestAwareObjectType<T>\n\nexport function value<T>(guestAware: GuestAwareType<T>, guest: GuestType<T>) {\n if (typeof guestAware === 'function') {\n return guestAware(guest);\n } else {\n return guestAware.value(guest);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware\n */\nexport class GuestAware<T = any> implements GuestAwareObjectType<T> {\n public constructor(private guestAware: GuestAwareType<T>) { }\n\n public value(guest: GuestType<T>): GuestType<T> {\n value(this.guestAware, guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = any> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = any> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = any> = GuestExecutorType<T> | GuestObjectType<T>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/give\n */\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest\n */\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) { }\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-cast\n */\nexport class GuestCast<T> implements GuestDisposableType<T> {\n public constructor(\n private sourceGuest: GuestType<any>,\n private targetGuest: GuestType<T>,\n ) { }\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.sourceGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/remove-patron-from-pools\n */\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/is-patron-in-pools\n */\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n};\n\nexport interface PoolType<T = any> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n size(): number;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-pool\n */\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public size(): number {\n return this.patrons.size;\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (!shouldBePatron) {\n throw new Error(\"PatronPool add method received nothing!\");\n }\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: GiveOptions,\n ) {\n const isDisposed = this.guestDisposed(value, guest);\n\n if (!isDisposed) {\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\n private guestDisposed(value: T, guest: GuestType<T>) {\n if ((guest as GuestDisposableType).disposed?.(value)) {\n this.remove(guest as GuestObjectType);\n return true;\n }\n\n return false;\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareObjectType } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport interface PoolAware<T = any> {\n pool(): PatronPool<T>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source\n */\nexport type SourceType<T = any> = GuestAwareObjectType<T> &\n GuestObjectType<T> &\n PoolAware<T>;\n\nexport class Source<T> implements SourceType<T> {\n private thePool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) { }\n\n public pool() {\n return this.thePool;\n }\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.thePool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.thePool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.thePool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { GiveOptions, Guest, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-object\n */\nexport class GuestObject<T> implements GuestDisposableType<T> {\n public constructor(private baseGuest: GuestType<T>) { }\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-pool\n */\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n public size() {\n return this.patronPool.size() + this.guests.size;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestAwareObjectType } from \"src/Guest/GuestAware\";\nimport { Source } from \"../Source/Source\";\nimport { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestObject } from \"./GuestObject\";\nimport { GuestPool } from \"./GuestPool\";\n\nexport interface GuestAwareAllType<T = any> extends GuestAwareObjectType<T> {\n valueArray(guest: GuestObjectType<T>): this;\n guestKey<R>(key: string): GuestObjectType<R>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-all\n */\nexport class GuestAwareAll<T> implements GuestAwareAllType<T> {\n private theAll: Source<Record<string, unknown>>;\n\n private keysKnown = new Set();\n\n private keysFilled = new Set();\n\n private filledAllPool = new GuestPool(this);\n\n public constructor() {\n this.theAll = new Source<Record<string, unknown>>({});\n }\n\n public valueArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledAllPool.add(\n new GuestCast(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }),\n );\n if (this.isAllFilled()) {\n this.theAll.value(\n new Guest((all: Record<string, unknown>) => {\n this.filledAllPool.give(Object.values(all));\n }),\n );\n }\n return this;\n }\n\n public value(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isAllFilled()) {\n this.filledAllPool.add(guestObject);\n this.theAll.value(\n new Guest((all) => {\n this.filledAllPool.give(all);\n }),\n );\n } else {\n this.filledAllPool.add(guestObject);\n }\n return this;\n }\n\n public guestKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theAll.value(\n new Guest((all: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastAll = {\n ...all,\n [key]: value,\n };\n this.theAll.give(lastAll);\n if (this.isAllFilled()) {\n this.filledAllPool.give(lastAll);\n }\n }),\n );\n });\n });\n }\n\n private isAllFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { GuestCast } from \"../Guest/GuestCast\";\nimport { give, GuestType } from \"./../Guest/Guest\";\nimport { Source, SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source/source-empty\n */\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestCast(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n\n public pool(): PatronPool<T> {\n return this.baseSource.pool();\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestAwareAll } from \"./GuestAwareAll\";\nimport { GuestType } from \"./Guest\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-sequence\n */\nexport class GuestAwareSequence<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const all = new GuestAwareAll<TG[]>();\n const sequenceSource = new SourceEmpty();\n const targetSource = this.targetSourceFactory.create(\n sequenceSource\n )\n\n value(\n this.baseSource,\n new GuestCast(guest, (theValue) => {\n let index = 0;\n\n const nextItemHandle = () => {\n if (theValue[index + 1] !== undefined) {\n index = index + 1;\n handle();\n } else {\n all.valueArray(guest);\n }\n }\n\n function handle() {\n sequenceSource.give(theValue[index]);\n value(targetSource, all.guestKey(index.toString()));\n value(targetSource, nextItemHandle);\n }\n\n if (theValue[index] !== undefined) {\n handle();\n } else {\n give([], guest);\n }\n })\n );\n return this;\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestAwareAll } from \"./GuestAwareAll\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAware } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-map\n */\nexport class GuestAwareMap<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const all = new GuestAwareAll();\n value(\n this.baseSource,\n new GuestCast(<GuestType>guest, (theValue) => {\n theValue.forEach((val, index) => {\n const targetSource = this.targetSourceFactory.create(\n new GuestAware((innerGuest) => {\n give(val, innerGuest);\n })\n )\n value(targetSource, all.guestKey(index.toString()));\n });\n })\n )\n all.valueArray(<GuestType>guest);\n return this;\n }\n}\n","import { give, GuestType } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-race\n */\nexport class GuestAwareRace<T> implements GuestAwareObjectType<T> {\n public constructor(private guestAwares: GuestAwareType<T>[]) { }\n\n public value(guest: GuestType<T>): this {\n let connectedWithGuestAware: GuestAwareType | null = null;\n this.guestAwares.forEach(guestAware => {\n value(\n guestAware,\n new GuestCast(<GuestType>guest, (value) => {\n if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {\n give(value as T, guest);\n connectedWithGuestAware = guestAware\n }\n })\n );\n });\n return this;\n }\n}\n","import { SourceType } from \"../Source/Source\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAwareObjectType } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/action-type\n */\nexport interface ActionType<P = any> {\n do(config: P): this;\n}\n\nexport interface GuestAwareAcitveType<R = unknown, T = unknown> extends GuestAwareObjectType<T>, ActionType<R> {\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-active\n */\nexport class GuestAwareActive<R, T> implements GuestAwareAcitveType<R, T> {\n private source = new SourceEmpty<T>();\n\n public constructor(private configExecutor: (config: R, source: SourceType<T>) => void) { }\n\n public do(config: R): this {\n this.configExecutor(config, this.source);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n this.source.value(guest);\n return this;\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = any> extends GuestObjectType<T> {\n value(): T;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-sync\n */\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) { }\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GiveOptions, GuestObjectType, GuestType } from \"./Guest\";\n\nexport interface GuestDisposableType<T = any> extends GuestObjectType<T> {\n disposed(value: T | null): boolean;\n}\n\nexport type MaybeDisposableType<T = any> = Partial<GuestDisposableType<T>>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-disposable\n */\nexport class GuestDisposable<T> implements GuestDisposableType<T> {\n public constructor(\n private guest: GuestType,\n private disposeCheck: (value: T | null) => boolean,\n ) { }\n\n public disposed(value: T | null): boolean {\n return this.disposeCheck(value);\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.guest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"../Guest/Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron\n */\nexport class Patron<T> implements GuestDisposableType<T> {\n public constructor(private willBePatron: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.willBePatron as GuestDisposableType;\n return maybeDisposable?.disposed?.(value) || false;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestType, GiveOptions } from \"../Guest/Guest\";\nimport {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"../Guest/GuestDisposable\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-once\n */\nexport class PatronOnce<T> implements GuestDisposableType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { give, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareType, value } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\nimport { SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source-dynamic\n */\nexport class SourceDynamic<T = unknown> implements SourceType<T> {\n public constructor(\n private baseGuest: GuestType<T>,\n private baseGuestAware: GuestAwareType<T>,\n ) { }\n\n public value(guest: GuestType<T>) {\n value(this.baseGuestAware, guest);\n return this;\n }\n\n public give(value: T) {\n give(value, this.baseGuest);\n return this;\n }\n\n public pool(): PatronPool<T> {\n throw Error('No pool in SourceDynamic');\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\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/factory\n */\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) { }\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./Factory\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/module\n */\nexport class Module<T> implements FactoryType<T> {\n public constructor(private buildingFn: (...args: any[]) => T) { }\n\n public create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT {\n return this.buildingFn(...args) as CT extends null ? T : CT;\n }\n}\n"],"names":["__publicField","value"],"mappings":"AAUgB,SAAA,KAAA,CAAS,YAA+B,KAAqB,EAAA;AAC3E,EAAI,IAAA,OAAO,eAAe,UAAY,EAAA;AACpC,IAAA,OAAO,WAAW,KAAK,CAAA,CAAA;AAAA,GAClB,MAAA;AACL,IAAO,OAAA,UAAA,CAAW,MAAM,KAAK,CAAA,CAAA;AAAA,GAC/B;AACF,CAAA;AAKO,MAAM,UAAuD,CAAA;AAAA,EAC3D,YAAoB,UAA+B,EAAA;AAA/B,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,MAAM,KAAmC,EAAA;AAC9C,IAAM,KAAA,CAAA,IAAA,CAAK,YAAY,KAAK,CAAA,CAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;ACPgB,SAAA,IAAA,CAAQ,IAAS,EAAA,KAAA,EAAqB,OAAuB,EAAA;AAC3E,EAAI,IAAA,OAAO,UAAU,UAAY,EAAA;AAC/B,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAAA,GACd,MAAA;AACL,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,OAAO,CAAA,CAAA;AAAA,GAC1B;AACF,CAAA;AAKO,MAAM,KAAuC,CAAA;AAAA,EAC3C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAkC;AAAA,EAEtD,IAAA,CAAK,OAAU,OAAuB,EAAA;AAC3C,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;AC9BO,MA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IAAA,CAAA;AAAA,GACT;AAAA,EAEO,KAAKC,MAAU,EAAA;AACpB,IAAKA,IAAAA,CAAAA,MAAAA,EAAO,KAAK,SAAS,CAAA,CAAA;AAC1B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEO,IAAsB,GAAA;AAC3B,IAAA,MAAM,MAAM,0BAA0B,CAAA,CAAA;AAAA,GACxC;AACF;;ACZO,MAAM,OAAqC,CAAA;AAAA,EACzC,WACG,CAAA,aAAA,EACA,SAAqC,GAAA,EAC7C,EAAA;AAFQ,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GACN;AAAA,EAEG,UACF,IACuB,EAAA;AAC1B,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAK,CAAA,SAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF;;ACxBO,MAAM,MAAoC,CAAA;AAAA,EACxC,YAAoB,UAAmC,EAAA;AAAnC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA,CAAA;AAAA,GAAqC;AAAA,EAEzD,UAA0C,IAAmC,EAAA;AAClF,IAAO,OAAA,IAAA,CAAK,UAAW,CAAA,GAAG,IAAI,CAAA,CAAA;AAAA,GAChC;AACF;;;;"}
@@ -1 +1 @@
1
- !function(e){"use strict";function t(e,t){return"function"==typeof e?e(t):e.value(t)}class s{constructor(e){this.guestAware=e}value(e){return t(this.guestAware,e),e}}function i(e,t,s){"function"==typeof t?t(e,s):t.give(e,s)}class r{constructor(e){this.receiver=e}give(e,t){return this.receiver(e,t),this}}class o{constructor(e,t){this.sourceGuest=e,this.targetGuest=t}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(e,t){return i(e,this.targetGuest,t),this}disposed(e){const t=this.sourceGuest;return!!t.disposed&&t.disposed(e)}}var n=Object.defineProperty,u=(e,t,s)=>((e,t,s)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);const a=new Map;class h{constructor(e){this.initiator=e,u(this,"patrons"),u(this,"give"),this.patrons=new Set,a.set(this,this.patrons);let t=null;const s=(e,t)=>{this.patrons.forEach((s=>{this.sendValueToGuest(e,s,t)}))};this.give=(e,i)=>{const r=()=>{r===t&&s(e,i)};return t=r,queueMicrotask(r),this}}size(){return this.patrons.size}add(e){if(!e)throw new Error("PatronPool add method received nothing!");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,t,s){this.guestDisposed(e,t)||i(e,t,{...s,data:{...s?.data??{},initiator:this.initiator,pool:this}})}guestDisposed(e,t){return!!t.disposed?.(e)&&(this.remove(t),!0)}}var c=Object.defineProperty,l=(e,t,s)=>((e,t,s)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,t+"",s);class d{constructor(e){this.sourceDocument=e,l(this,"thePool",new h(this))}pool(){return this.thePool}give(e){return this.sourceDocument=e,this.thePool.give(this.sourceDocument),this}value(e){return"function"==typeof e?this.thePool.distribute(this.sourceDocument,new r(e)):this.thePool.distribute(this.sourceDocument,e),this}}class v{constructor(e){this.baseGuest=e}give(e,t){let s=this.baseGuest;return"function"==typeof s&&(s=new r(s)),s.give(e,t),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}disposed(e){const t=this.baseGuest;return!!t.disposed&&t.disposed(e)}}var p=Object.defineProperty,b=(e,t,s)=>((e,t,s)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class g{constructor(e){b(this,"guests",new Set),b(this,"patronPool"),this.patronPool=new h(e)}give(e,t){return this.deliverToGuests(e,t),this.patronPool.give(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.give(e),this}size(){return this.patronPool.size()+this.guests.size}deliverToGuests(e,t){this.guests.forEach((s=>{i(e,s,t)})),this.guests.clear()}}var w=Object.defineProperty,f=(e,t,s)=>((e,t,s)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class y{constructor(){f(this,"theChain"),f(this,"keysKnown",new Set),f(this,"keysFilled",new Set),f(this,"filledChainPool",new g(this)),this.theChain=new d({})}resultArray(e){const t=new v(e);return this.filledChainPool.add(new o(t,(e=>{t.give(Object.values(e))}))),this.isChainFilled()&&this.theChain.value(new r((e=>{this.filledChainPool.give(Object.values(e))}))),this}result(e){const t=new v(e);return this.isChainFilled()?(this.filledChainPool.add(t),this.theChain.value(new r((e=>{this.filledChainPool.give(e)})))):this.filledChainPool.add(t),this}receiveKey(e){return this.keysKnown.add(e),new r((t=>{queueMicrotask((()=>{this.theChain.value(new r((s=>{this.keysFilled.add(e);const i={...s,[e]:t};this.theChain.give(i),this.isChainFilled()&&this.filledChainPool.give(i)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}var P=Object.defineProperty,G=(e,t,s)=>((e,t,s)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,t+"",s);class m{constructor(){G(this,"baseSource",new d(null))}value(e){return this.baseSource.value(new o(e,(t=>{null!==t&&i(t,e)}))),this}give(e){return this.baseSource.give(e),this}pool(){return this.baseSource.pool()}}var S=Object.defineProperty,C=(e,t,s)=>((e,t,s)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,t+"",s);var F=Object.defineProperty,A=(e,t,s)=>((e,t,s)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,t+"",s);e.Factory=class{constructor(e,t={}){this.constructorFn=e,this.factories=t}create(...e){return new this.constructorFn(...e,this.factories)}},e.Guest=r,e.GuestAware=s,e.GuestAwareActive=class{constructor(e){this.configExecutor=e,C(this,"source",new m)}do(e){return this.configExecutor(e,this.source),this}value(e){return this.source.value(e),this}},e.GuestAwareMap=class{constructor(e,t){this.baseSource=e,this.targetSourceFactory=t}value(e){const r=new y;return t(this.baseSource,new o(e,(e=>{e.forEach(((e,o)=>{t(this.targetSourceFactory.create(new s((t=>{i(e,t)}))),r.receiveKey(""+o))}))}))),r.resultArray(e),this}},e.GuestAwareRace=class{constructor(e){this.guestAwares=e}value(e){let s=null;return this.guestAwares.forEach((r=>{t(r,new o(e,(t=>{s&&s!==r||(i(t,e),s=r)})))})),this}},e.GuestAwareSequence=class{constructor(e,t){this.baseSource=e,this.targetSourceFactory=t}value(e){const s=new y,r=new m,n=this.targetSourceFactory.create(r);return t(this.baseSource,new o(e,(o=>{let u=0;const a=()=>{void 0!==o[u+1]?(u+=1,h()):s.resultArray(e)};function h(){r.give(o[u]),t(n,s.receiveKey(""+u)),t(n,a)}void 0!==o[u]?h():i([],e)}))),this}},e.GuestCast=o,e.GuestChain=y,e.GuestDisposable=class{constructor(e,t){this.guest=e,this.disposeCheck=t}disposed(e){return this.disposeCheck(e)}give(e,t){return i(e,this.guest,t),this}},e.GuestObject=v,e.GuestPool=g,e.GuestSync=class{constructor(e){this.theValue=e}give(e){return this.theValue=e,this}value(){return this.theValue}},e.Module=class{constructor(e){this.buildingFn=e}create(...e){return this.buildingFn(...e)}},e.Patron=class{constructor(e){this.willBePatron=e}introduction(){return"patron"}give(e,t){return i(e,this.willBePatron,t),this}disposed(e){const t=this.willBePatron;return t?.disposed?.(e)||!1}},e.PatronOnce=class{constructor(e){this.baseGuest=e,A(this,"received",!1)}introduction(){return"patron"}give(e,t){this.received||i(e,this.baseGuest,t);const s=t?.data;return s?.pool&&s.pool.remove(this),this}disposed(e){const t=this.baseGuest;return!!t.disposed&&t.disposed(e)}},e.PatronPool=h,e.Source=d,e.SourceDynamic=class{constructor(e,t){this.baseGuest=e,this.baseGuestAware=t}value(e){return t(this.baseGuestAware,e),this}give(e){return i(e,this.baseGuest),this}pool(){throw Error("No pool in SourceDynamic")}},e.SourceEmpty=m,e.give=i,e.isPatronInPools=e=>{let t=!1;return a.forEach((s=>{t||(t=s.has(e))})),t},e.removePatronFromPools=e=>{a.forEach((t=>{t.delete(e)}))},e.value=t}({});
1
+ !function(t){"use strict";function e(t,e){return"function"==typeof t?t(e):t.value(e)}class s{constructor(t){this.guestAware=t}value(t){return e(this.guestAware,t),t}}function i(t,e,s){"function"==typeof e?e(t,s):e.give(t,s)}class r{constructor(t){this.receiver=t}give(t,e){return this.receiver(t,e),this}}class o{constructor(t,e){this.sourceGuest=t,this.targetGuest=e}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(t,e){return i(t,this.targetGuest,e),this}disposed(t){const e=this.sourceGuest;return!!e.disposed&&e.disposed(t)}}var n=Object.defineProperty,u=(t,e,s)=>((t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);const l=new Map;class a{constructor(t){this.initiator=t,u(this,"patrons"),u(this,"give"),this.patrons=new Set,l.set(this,this.patrons);let e=null;const s=(t,e)=>{this.patrons.forEach((s=>{this.sendValueToGuest(t,s,e)}))};this.give=(t,i)=>{const r=()=>{r===e&&s(t,i)};return e=r,queueMicrotask(r),this}}size(){return this.patrons.size}add(t){if(!t)throw new Error("PatronPool add method received nothing!");return"function"!=typeof t&&t.introduction&&"patron"===t.introduction()&&this.patrons.add(t),this}remove(t){return this.patrons.delete(t),this}distribute(t,e){return this.add(e),this.sendValueToGuest(t,e,{}),this}sendValueToGuest(t,e,s){this.guestDisposed(t,e)||i(t,e,{...s,data:{...s?.data??{},initiator:this.initiator,pool:this}})}guestDisposed(t,e){return!!e.disposed?.(t)&&(this.remove(e),!0)}}var c=Object.defineProperty,h=(t,e,s)=>((t,e,s)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class d{constructor(t){this.sourceDocument=t,h(this,"thePool",new a(this))}pool(){return this.thePool}give(t){return this.sourceDocument=t,this.thePool.give(this.sourceDocument),this}value(t){return"function"==typeof t?this.thePool.distribute(this.sourceDocument,new r(t)):this.thePool.distribute(this.sourceDocument,t),this}}class v{constructor(t){this.baseGuest=t}give(t,e){let s=this.baseGuest;return"function"==typeof s&&(s=new r(s)),s.give(t,e),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}}var g=Object.defineProperty,p=(t,e,s)=>((t,e,s)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class b{constructor(t){p(this,"guests",new Set),p(this,"patronPool"),this.patronPool=new a(t)}give(t,e){return this.deliverToGuests(t,e),this.patronPool.give(t,e),this}add(t){return"function"!=typeof t&&t.introduction&&"guest"!==t.introduction()||this.guests.add(t),this.patronPool.add(t),this}remove(t){return this.guests.delete(t),this.patronPool.remove(t),this}distribute(t,e){return this.add(e),this.give(t),this}size(){return this.patronPool.size()+this.guests.size}deliverToGuests(t,e){this.guests.forEach((s=>{i(t,s,e)})),this.guests.clear()}}var w=Object.defineProperty,f=(t,e,s)=>((t,e,s)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class y{constructor(){f(this,"theAll"),f(this,"keysKnown",new Set),f(this,"keysFilled",new Set),f(this,"filledAllPool",new b(this)),this.theAll=new d({})}valueArray(t){const e=new v(t);return this.filledAllPool.add(new o(e,(t=>{e.give(Object.values(t))}))),this.isAllFilled()&&this.theAll.value(new r((t=>{this.filledAllPool.give(Object.values(t))}))),this}value(t){const e=new v(t);return this.isAllFilled()?(this.filledAllPool.add(e),this.theAll.value(new r((t=>{this.filledAllPool.give(t)})))):this.filledAllPool.add(e),this}guestKey(t){return this.keysKnown.add(t),new r((e=>{queueMicrotask((()=>{this.theAll.value(new r((s=>{this.keysFilled.add(t);const i={...s,[t]:e};this.theAll.give(i),this.isAllFilled()&&this.filledAllPool.give(i)})))}))}))}isAllFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}var P=Object.defineProperty,G=(t,e,s)=>((t,e,s)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class A{constructor(){G(this,"baseSource",new d(null))}value(t){return this.baseSource.value(new o(t,(e=>{null!==e&&i(e,t)}))),this}give(t){return this.baseSource.give(t),this}pool(){return this.baseSource.pool()}}var m=Object.defineProperty,S=(t,e,s)=>((t,e,s)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);var F=Object.defineProperty,k=(t,e,s)=>((t,e,s)=>e in t?F(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);t.Factory=class{constructor(t,e={}){this.constructorFn=t,this.factories=e}create(...t){return new this.constructorFn(...t,this.factories)}},t.Guest=r,t.GuestAware=s,t.GuestAwareActive=class{constructor(t){this.configExecutor=t,S(this,"source",new A)}do(t){return this.configExecutor(t,this.source),this}value(t){return this.source.value(t),this}},t.GuestAwareAll=y,t.GuestAwareMap=class{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(t){const r=new y;return e(this.baseSource,new o(t,(t=>{t.forEach(((t,o)=>{e(this.targetSourceFactory.create(new s((e=>{i(t,e)}))),r.guestKey(o.toString()))}))}))),r.valueArray(t),this}},t.GuestAwareRace=class{constructor(t){this.guestAwares=t}value(t){let s=null;return this.guestAwares.forEach((r=>{e(r,new o(t,(e=>{s&&s!==r||(i(e,t),s=r)})))})),this}},t.GuestAwareSequence=class{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(t){const s=new y,r=new A,n=this.targetSourceFactory.create(r);return e(this.baseSource,new o(t,(o=>{let u=0;const l=()=>{void 0!==o[u+1]?(u+=1,a()):s.valueArray(t)};function a(){r.give(o[u]),e(n,s.guestKey(u.toString())),e(n,l)}void 0!==o[u]?a():i([],t)}))),this}},t.GuestCast=o,t.GuestDisposable=class{constructor(t,e){this.guest=t,this.disposeCheck=e}disposed(t){return this.disposeCheck(t)}give(t,e){return i(t,this.guest,e),this}},t.GuestObject=v,t.GuestPool=b,t.GuestSync=class{constructor(t){this.theValue=t}give(t){return this.theValue=t,this}value(){return this.theValue}},t.Module=class{constructor(t){this.buildingFn=t}create(...t){return this.buildingFn(...t)}},t.Patron=class{constructor(t){this.willBePatron=t}introduction(){return"patron"}give(t,e){return i(t,this.willBePatron,e),this}disposed(t){const e=this.willBePatron;return e?.disposed?.(t)||!1}},t.PatronOnce=class{constructor(t){this.baseGuest=t,k(this,"received",!1)}introduction(){return"patron"}give(t,e){this.received||i(t,this.baseGuest,e);const s=e?.data;return s?.pool&&s.pool.remove(this),this}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}},t.PatronPool=a,t.Source=d,t.SourceDynamic=class{constructor(t,e){this.baseGuest=t,this.baseGuestAware=e}value(t){return e(this.baseGuestAware,t),this}give(t){return i(t,this.baseGuest),this}pool(){throw Error("No pool in SourceDynamic")}},t.SourceEmpty=A,t.give=i,t.isPatronInPools=t=>{let e=!1;return l.forEach((s=>{e||(e=s.has(t))})),e},t.removePatronFromPools=t=>{l.forEach((e=>{e.delete(t)}))},t.value=e}({});
@@ -1,2 +1,2 @@
1
- function t(t,e){return"function"==typeof t?t(e):t.value(e)}class e{constructor(t){this.guestAware=t}value(e){return t(this.guestAware,e),e}}function s(t,e,s){"function"==typeof e?e(t,s):e.give(t,s)}class i{constructor(t){this.receiver=t}give(t,e){return this.receiver(t,e),this}}class r{constructor(t,e){this.sourceGuest=t,this.targetGuest=e}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(t,e){return s(t,this.targetGuest,e),this}disposed(t){const e=this.sourceGuest;return!!e.disposed&&e.disposed(t)}}var o=Object.defineProperty,n=(t,e,s)=>((t,e,s)=>e in t?o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);const u=new Map,h=t=>{u.forEach((e=>{e.delete(t)}))},a=t=>{let e=!1;return u.forEach((s=>{e||(e=s.has(t))})),e};class c{constructor(t){this.initiator=t,n(this,"patrons"),n(this,"give"),this.patrons=new Set,u.set(this,this.patrons);let e=null;const s=(t,e)=>{this.patrons.forEach((s=>{this.sendValueToGuest(t,s,e)}))};this.give=(t,i)=>{const r=()=>{r===e&&s(t,i)};return e=r,queueMicrotask(r),this}}size(){return this.patrons.size}add(t){if(!t)throw new Error("PatronPool add method received nothing!");return"function"!=typeof t&&t.introduction&&"patron"===t.introduction()&&this.patrons.add(t),this}remove(t){return this.patrons.delete(t),this}distribute(t,e){return this.add(e),this.sendValueToGuest(t,e,{}),this}sendValueToGuest(t,e,i){this.guestDisposed(t,e)||s(t,e,{...i,data:{...i?.data??{},initiator:this.initiator,pool:this}})}guestDisposed(t,e){return!!e.disposed?.(t)&&(this.remove(e),!0)}}var l=Object.defineProperty,d=(t,e,s)=>((t,e,s)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class v{constructor(t){this.sourceDocument=t,d(this,"thePool",new c(this))}pool(){return this.thePool}give(t){return this.sourceDocument=t,this.thePool.give(this.sourceDocument),this}value(t){return"function"==typeof t?this.thePool.distribute(this.sourceDocument,new i(t)):this.thePool.distribute(this.sourceDocument,t),this}}class g{constructor(t){this.baseGuest=t}give(t,e){let s=this.baseGuest;return"function"==typeof s&&(s=new i(s)),s.give(t,e),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}}var p=Object.defineProperty,b=(t,e,s)=>((t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class f{constructor(t){b(this,"guests",new Set),b(this,"patronPool"),this.patronPool=new c(t)}give(t,e){return this.deliverToGuests(t,e),this.patronPool.give(t,e),this}add(t){return"function"!=typeof t&&t.introduction&&"guest"!==t.introduction()||this.guests.add(t),this.patronPool.add(t),this}remove(t){return this.guests.delete(t),this.patronPool.remove(t),this}distribute(t,e){return this.add(e),this.give(t),this}size(){return this.patronPool.size()+this.guests.size}deliverToGuests(t,e){this.guests.forEach((i=>{s(t,i,e)})),this.guests.clear()}}var w=Object.defineProperty,y=(t,e,s)=>((t,e,s)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class P{constructor(){y(this,"theChain"),y(this,"keysKnown",new Set),y(this,"keysFilled",new Set),y(this,"filledChainPool",new f(this)),this.theChain=new v({})}resultArray(t){const e=new g(t);return this.filledChainPool.add(new r(e,(t=>{e.give(Object.values(t))}))),this.isChainFilled()&&this.theChain.value(new i((t=>{this.filledChainPool.give(Object.values(t))}))),this}result(t){const e=new g(t);return this.isChainFilled()?(this.filledChainPool.add(e),this.theChain.value(new i((t=>{this.filledChainPool.give(t)})))):this.filledChainPool.add(e),this}receiveKey(t){return this.keysKnown.add(t),new i((e=>{queueMicrotask((()=>{this.theChain.value(new i((s=>{this.keysFilled.add(t);const i={...s,[t]:e};this.theChain.give(i),this.isChainFilled()&&this.filledChainPool.give(i)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}var G=Object.defineProperty,m=(t,e,s)=>((t,e,s)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class C{constructor(){m(this,"baseSource",new v(null))}value(t){return this.baseSource.value(new r(t,(e=>{null!==e&&s(e,t)}))),this}give(t){return this.baseSource.give(t),this}pool(){return this.baseSource.pool()}}class S{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(e){const i=new P,o=new C,n=this.targetSourceFactory.create(o);return t(this.baseSource,new r(e,(r=>{let u=0;const h=()=>{void 0!==r[u+1]?(u+=1,a()):i.resultArray(e)};function a(){o.give(r[u]),t(n,i.receiveKey(""+u)),t(n,h)}void 0!==r[u]?a():s([],e)}))),this}}class F{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(i){const o=new P;return t(this.baseSource,new r(i,(i=>{i.forEach(((i,r)=>{t(this.targetSourceFactory.create(new e((t=>{s(i,t)}))),o.receiveKey(""+r))}))}))),o.resultArray(i),this}}class k{constructor(t){this.guestAwares=t}value(e){let i=null;return this.guestAwares.forEach((o=>{t(o,new r(e,(t=>{i&&i!==o||(s(t,e),i=o)})))})),this}}var E=Object.defineProperty,j=(t,e,s)=>((t,e,s)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class A{constructor(t){this.configExecutor=t,j(this,"source",new C)}do(t){return this.configExecutor(t,this.source),this}value(t){return this.source.value(t),this}}class O{constructor(t){this.theValue=t}give(t){return this.theValue=t,this}value(){return this.theValue}}class z{constructor(t,e){this.guest=t,this.disposeCheck=e}disposed(t){return this.disposeCheck(t)}give(t,e){return s(t,this.guest,e),this}}class D{constructor(t){this.willBePatron=t}introduction(){return"patron"}give(t,e){return s(t,this.willBePatron,e),this}disposed(t){const e=this.willBePatron;return e?.disposed?.(t)||!1}}var K=Object.defineProperty,V=(t,e,s)=>((t,e,s)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class T{constructor(t){this.baseGuest=t,V(this,"received",!1)}introduction(){return"patron"}give(t,e){this.received||s(t,this.baseGuest,e);const i=e?.data;return i?.pool&&i.pool.remove(this),this}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}}class x{constructor(t,e){this.baseGuest=t,this.baseGuestAware=e}value(e){return t(this.baseGuestAware,e),this}give(t){return s(t,this.baseGuest),this}pool(){throw Error("No pool in SourceDynamic")}}class B{constructor(t,e={}){this.constructorFn=t,this.factories=e}create(...t){return new this.constructorFn(...t,this.factories)}}class M{constructor(t){this.buildingFn=t}create(...t){return this.buildingFn(...t)}}export{B as Factory,i as Guest,e as GuestAware,A as GuestAwareActive,F as GuestAwareMap,k as GuestAwareRace,S as GuestAwareSequence,r as GuestCast,P as GuestChain,z as GuestDisposable,g as GuestObject,f as GuestPool,O as GuestSync,M as Module,D as Patron,T as PatronOnce,c as PatronPool,v as Source,x as SourceDynamic,C as SourceEmpty,s as give,a as isPatronInPools,h as removePatronFromPools,t as value};
1
+ function t(t,e){return"function"==typeof t?t(e):t.value(e)}class e{constructor(t){this.guestAware=t}value(e){return t(this.guestAware,e),e}}function s(t,e,s){"function"==typeof e?e(t,s):e.give(t,s)}class i{constructor(t){this.receiver=t}give(t,e){return this.receiver(t,e),this}}class r{constructor(t,e){this.sourceGuest=t,this.targetGuest=e}introduction(){return"function"==typeof this.sourceGuest?"guest":this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}give(t,e){return s(t,this.targetGuest,e),this}disposed(t){const e=this.sourceGuest;return!!e.disposed&&e.disposed(t)}}var o=Object.defineProperty,n=(t,e,s)=>((t,e,s)=>e in t?o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);const u=new Map,l=t=>{u.forEach((e=>{e.delete(t)}))},h=t=>{let e=!1;return u.forEach((s=>{e||(e=s.has(t))})),e};class a{constructor(t){this.initiator=t,n(this,"patrons"),n(this,"give"),this.patrons=new Set,u.set(this,this.patrons);let e=null;const s=(t,e)=>{this.patrons.forEach((s=>{this.sendValueToGuest(t,s,e)}))};this.give=(t,i)=>{const r=()=>{r===e&&s(t,i)};return e=r,queueMicrotask(r),this}}size(){return this.patrons.size}add(t){if(!t)throw new Error("PatronPool add method received nothing!");return"function"!=typeof t&&t.introduction&&"patron"===t.introduction()&&this.patrons.add(t),this}remove(t){return this.patrons.delete(t),this}distribute(t,e){return this.add(e),this.sendValueToGuest(t,e,{}),this}sendValueToGuest(t,e,i){this.guestDisposed(t,e)||s(t,e,{...i,data:{...i?.data??{},initiator:this.initiator,pool:this}})}guestDisposed(t,e){return!!e.disposed?.(t)&&(this.remove(e),!0)}}var c=Object.defineProperty,d=(t,e,s)=>((t,e,s)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class v{constructor(t){this.sourceDocument=t,d(this,"thePool",new a(this))}pool(){return this.thePool}give(t){return this.sourceDocument=t,this.thePool.give(this.sourceDocument),this}value(t){return"function"==typeof t?this.thePool.distribute(this.sourceDocument,new i(t)):this.thePool.distribute(this.sourceDocument,t),this}}class g{constructor(t){this.baseGuest=t}give(t,e){let s=this.baseGuest;return"function"==typeof s&&(s=new i(s)),s.give(t,e),this}introduction(){return"function"!=typeof this.baseGuest&&this.baseGuest.introduction?this.baseGuest.introduction():"guest"}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}}var p=Object.defineProperty,b=(t,e,s)=>((t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class f{constructor(t){b(this,"guests",new Set),b(this,"patronPool"),this.patronPool=new a(t)}give(t,e){return this.deliverToGuests(t,e),this.patronPool.give(t,e),this}add(t){return"function"!=typeof t&&t.introduction&&"guest"!==t.introduction()||this.guests.add(t),this.patronPool.add(t),this}remove(t){return this.guests.delete(t),this.patronPool.remove(t),this}distribute(t,e){return this.add(e),this.give(t),this}size(){return this.patronPool.size()+this.guests.size}deliverToGuests(t,e){this.guests.forEach((i=>{s(t,i,e)})),this.guests.clear()}}var w=Object.defineProperty,y=(t,e,s)=>((t,e,s)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class P{constructor(){y(this,"theAll"),y(this,"keysKnown",new Set),y(this,"keysFilled",new Set),y(this,"filledAllPool",new f(this)),this.theAll=new v({})}valueArray(t){const e=new g(t);return this.filledAllPool.add(new r(e,(t=>{e.give(Object.values(t))}))),this.isAllFilled()&&this.theAll.value(new i((t=>{this.filledAllPool.give(Object.values(t))}))),this}value(t){const e=new g(t);return this.isAllFilled()?(this.filledAllPool.add(e),this.theAll.value(new i((t=>{this.filledAllPool.give(t)})))):this.filledAllPool.add(e),this}guestKey(t){return this.keysKnown.add(t),new i((e=>{queueMicrotask((()=>{this.theAll.value(new i((s=>{this.keysFilled.add(t);const i={...s,[t]:e};this.theAll.give(i),this.isAllFilled()&&this.filledAllPool.give(i)})))}))}))}isAllFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}var A=Object.defineProperty,G=(t,e,s)=>((t,e,s)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class m{constructor(){G(this,"baseSource",new v(null))}value(t){return this.baseSource.value(new r(t,(e=>{null!==e&&s(e,t)}))),this}give(t){return this.baseSource.give(t),this}pool(){return this.baseSource.pool()}}class S{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(e){const i=new P,o=new m,n=this.targetSourceFactory.create(o);return t(this.baseSource,new r(e,(r=>{let u=0;const l=()=>{void 0!==r[u+1]?(u+=1,h()):i.valueArray(e)};function h(){o.give(r[u]),t(n,i.guestKey(u.toString())),t(n,l)}void 0!==r[u]?h():s([],e)}))),this}}class F{constructor(t,e){this.baseSource=t,this.targetSourceFactory=e}value(i){const o=new P;return t(this.baseSource,new r(i,(i=>{i.forEach(((i,r)=>{t(this.targetSourceFactory.create(new e((t=>{s(i,t)}))),o.guestKey(r.toString()))}))}))),o.valueArray(i),this}}class k{constructor(t){this.guestAwares=t}value(e){let i=null;return this.guestAwares.forEach((o=>{t(o,new r(e,(t=>{i&&i!==o||(s(t,e),i=o)})))})),this}}var E=Object.defineProperty,j=(t,e,s)=>((t,e,s)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class O{constructor(t){this.configExecutor=t,j(this,"source",new m)}do(t){return this.configExecutor(t,this.source),this}value(t){return this.source.value(t),this}}class z{constructor(t){this.theValue=t}give(t){return this.theValue=t,this}value(){return this.theValue}}class D{constructor(t,e){this.guest=t,this.disposeCheck=e}disposed(t){return this.disposeCheck(t)}give(t,e){return s(t,this.guest,e),this}}class K{constructor(t){this.willBePatron=t}introduction(){return"patron"}give(t,e){return s(t,this.willBePatron,e),this}disposed(t){const e=this.willBePatron;return e?.disposed?.(t)||!1}}var V=Object.defineProperty,T=(t,e,s)=>((t,e,s)=>e in t?V(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class x{constructor(t){this.baseGuest=t,T(this,"received",!1)}introduction(){return"patron"}give(t,e){this.received||s(t,this.baseGuest,e);const i=e?.data;return i?.pool&&i.pool.remove(this),this}disposed(t){const e=this.baseGuest;return!!e.disposed&&e.disposed(t)}}class B{constructor(t,e){this.baseGuest=t,this.baseGuestAware=e}value(e){return t(this.baseGuestAware,e),this}give(t){return s(t,this.baseGuest),this}pool(){throw Error("No pool in SourceDynamic")}}class M{constructor(t,e={}){this.constructorFn=t,this.factories=e}create(...t){return new this.constructorFn(...t,this.factories)}}class q{constructor(t){this.buildingFn=t}create(...t){return this.buildingFn(...t)}}export{M as Factory,i as Guest,e as GuestAware,O as GuestAwareActive,P as GuestAwareAll,F as GuestAwareMap,k as GuestAwareRace,S as GuestAwareSequence,r as GuestCast,D as GuestDisposable,g as GuestObject,f as GuestPool,z as GuestSync,q as Module,K as Patron,x as PatronOnce,a as PatronPool,v as Source,B as SourceDynamic,m as SourceEmpty,s as give,h as isPatronInPools,l as removePatronFromPools,t as value};
2
2
  //# sourceMappingURL=patron.min.mjs.map
@@ -1 +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/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestChain.ts","../src/Source/SourceEmpty.ts","../src/Guest/GuestAwareSequence.ts","../src/Guest/GuestAwareMap.ts","../src/Guest/GuestAwareRace.ts","../src/Guest/GuestAwareActive.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestDisposable.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceDynamic.ts","../src/Factory/Factory.ts","../src/Factory/Module.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport type GuestAwareExecutorType<T> = (guest: GuestType<T>) => unknown;\n\nexport interface GuestAwareObjectType<T> {\n value: GuestAwareExecutorType<T>\n}\n\nexport type GuestAwareType<T = any> = GuestAwareExecutorType<T> | GuestAwareObjectType<T>\n\nexport function value<T>(guestAware: GuestAwareType<T>, guest: GuestType<T>) {\n if (typeof guestAware === 'function') {\n return guestAware(guest);\n } else {\n return guestAware.value(guest);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware\n */\nexport class GuestAware<T = any> implements GuestAwareObjectType<T> {\n public constructor(private guestAware: GuestAwareType<T>) { }\n\n public value(guest: GuestType<T>): GuestType<T> {\n value(this.guestAware, guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = any> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = any> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = any> = GuestExecutorType<T> | GuestObjectType<T>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/give\n */\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest\n */\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) { }\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-cast\n */\nexport class GuestCast<T> implements GuestDisposableType<T> {\n public constructor(\n private sourceGuest: GuestType<any>,\n private targetGuest: GuestType<T>,\n ) { }\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.sourceGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/remove-patron-from-pools\n */\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/is-patron-in-pools\n */\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n};\n\nexport interface PoolType<T = any> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n size(): number;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-pool\n */\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public size(): number {\n return this.patrons.size;\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (!shouldBePatron) {\n throw new Error(\"PatronPool add method received nothing!\");\n }\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: GiveOptions,\n ) {\n const isDisposed = this.guestDisposed(value, guest);\n\n if (!isDisposed) {\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\n private guestDisposed(value: T, guest: GuestType<T>) {\n if ((guest as GuestDisposableType).disposed?.(value)) {\n this.remove(guest as GuestObjectType);\n return true;\n }\n\n return false;\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareObjectType } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport interface PoolAware<T = any> {\n pool(): PatronPool<T>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source\n */\nexport type SourceType<T = any> = GuestAwareObjectType<T> &\n GuestObjectType<T> &\n PoolAware<T>;\n\nexport class Source<T> implements SourceType<T> {\n private thePool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) { }\n\n public pool() {\n return this.thePool;\n }\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.thePool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.thePool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.thePool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { GiveOptions, Guest, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-object\n */\nexport class GuestObject<T> implements GuestDisposableType<T> {\n public constructor(private baseGuest: GuestType<T>) { }\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-pool\n */\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n public size() {\n return this.patronPool.size() + this.guests.size;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestCast } from \"./GuestCast\";\nimport { Source } from \"../Source/Source\";\nimport { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestObject } from \"./GuestObject\";\nimport { GuestPool } from \"./GuestPool\";\n\nexport interface ChainType<T = any> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-chain\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 GuestCast(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }),\n );\n if (this.isChainFilled()) {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.give(Object.values(chain));\n }),\n );\n }\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.value(\n new Guest((chain) => {\n this.filledChainPool.give(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.give(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.give(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { GuestCast } from \"../Guest/GuestCast\";\nimport { give, GuestType } from \"./../Guest/Guest\";\nimport { Source, SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source/source-empty\n */\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestCast(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n\n public pool(): PatronPool<T> {\n return this.baseSource.pool();\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestType } from \"./Guest\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-sequence\n */\nexport class GuestAwareSequence<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const chain = new GuestChain<TG[]>();\n const sequenceSource = new SourceEmpty();\n const targetSource = this.targetSourceFactory.create(\n sequenceSource\n )\n\n value(\n this.baseSource,\n new GuestCast(guest, (theValue) => {\n let index = 0;\n\n const nextItemHandle = () => {\n if (theValue[index + 1] !== undefined) {\n index = index + 1;\n handle();\n } else {\n chain.resultArray(guest);\n }\n }\n\n function handle() {\n sequenceSource.give(theValue[index]);\n value(targetSource, chain.receiveKey('' + index));\n value(targetSource, nextItemHandle);\n }\n\n if (theValue[index] !== undefined) {\n handle();\n } else {\n give([], guest);\n }\n })\n );\n return this;\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAware } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-map\n */\nexport class GuestAwareMap<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const chain = new GuestChain();\n value(\n this.baseSource,\n new GuestCast(<GuestType>guest, (theValue) => {\n theValue.forEach((val, index) => {\n const targetSource = this.targetSourceFactory.create(\n new GuestAware((innerGuest) => {\n give(val, innerGuest);\n })\n )\n value(targetSource, chain.receiveKey('' + index));\n });\n })\n )\n chain.resultArray(<GuestType>guest);\n return this;\n }\n}\n","import { give, GuestType } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-race\n */\nexport class GuestAwareRace<T> implements GuestAwareObjectType<T> {\n public constructor(private guestAwares: GuestAwareType<T>[]) { }\n\n public value(guest: GuestType<T>): this {\n let connectedWithGuestAware: GuestAwareType | null = null;\n this.guestAwares.forEach(guestAware => {\n value(\n guestAware,\n new GuestCast(<GuestType>guest, (value) => {\n if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {\n give(value as T, guest);\n connectedWithGuestAware = guestAware\n }\n })\n );\n });\n return this;\n }\n}\n","import { SourceType } from \"../Source/Source\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAwareObjectType } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/action-type\n */\nexport interface ActionType<P = any> {\n do(config: P): this;\n}\n\nexport interface GuestAwareAcitveType<R = unknown, T = unknown> extends GuestAwareObjectType<T>, ActionType<R> {\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-active\n */\nexport class GuestAwareActive<R, T> implements GuestAwareAcitveType<R, T> {\n private source = new SourceEmpty<T>();\n\n public constructor(private configExecutor: (config: R, source: SourceType<T>) => void) { }\n\n public do(config: R): this {\n this.configExecutor(config, this.source);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n this.source.value(guest);\n return this;\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = any> extends GuestObjectType<T> {\n value(): T;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-sync\n */\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) { }\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GiveOptions, GuestObjectType, GuestType } from \"./Guest\";\n\nexport interface GuestDisposableType<T = any> extends GuestObjectType<T> {\n disposed(value: T | null): boolean;\n}\n\nexport type MaybeDisposableType<T = any> = Partial<GuestDisposableType<T>>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-disposable\n */\nexport class GuestDisposable<T> implements GuestDisposableType<T> {\n public constructor(\n private guest: GuestType,\n private disposeCheck: (value: T | null) => boolean,\n ) { }\n\n public disposed(value: T | null): boolean {\n return this.disposeCheck(value);\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.guest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"../Guest/Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron\n */\nexport class Patron<T> implements GuestDisposableType<T> {\n public constructor(private willBePatron: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.willBePatron as GuestDisposableType;\n return maybeDisposable?.disposed?.(value) || false;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestType, GiveOptions } from \"../Guest/Guest\";\nimport {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"../Guest/GuestDisposable\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-once\n */\nexport class PatronOnce<T> implements GuestDisposableType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { give, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareType, value } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\nimport { SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source-dynamic\n */\nexport class SourceDynamic<T = unknown> implements SourceType<T> {\n public constructor(\n private baseGuest: GuestType<T>,\n private baseGuestAware: GuestAwareType<T>,\n ) { }\n\n public value(guest: GuestType<T>) {\n value(this.baseGuestAware, guest);\n return this;\n }\n\n public give(value: T) {\n give(value, this.baseGuest);\n return this;\n }\n\n public pool(): PatronPool<T> {\n throw Error('No pool in SourceDynamic');\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\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/factory\n */\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) { }\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./Factory\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/module\n */\nexport class Module<T> implements FactoryType<T> {\n public constructor(private buildingFn: (...args: any[]) => T) { }\n\n public create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT {\n return this.buildingFn(...args) as CT extends null ? T : CT;\n }\n}\n"],"names":["value","guestAware","guest","GuestAware","constructor","this","give","data","options","Guest","receiver","GuestCast","sourceGuest","targetGuest","introduction","disposed","maybeDisposable","poolSets","Map","removePatronFromPools","patron","forEach","pool","delete","isPatronInPools","inPool","has","PatronPool","initiator","__publicField","patrons","Set","set","lastMicrotask","doReceive","target","sendValueToGuest","currentMicroTask","queueMicrotask","size","add","shouldBePatron","Error","remove","distribute","receiving","possiblePatron","guestDisposed","Source","sourceDocument","thePool","GuestObject","baseGuest","GuestPool","patronPool","deliverToGuests","guests","clear","GuestChain","theChain","resultArray","guestObject","filledChainPool","Object","values","isChainFilled","chain","result","receiveKey","key","keysKnown","keysFilled","lastChain","SourceEmpty","baseSource","GuestAwareSequence","targetSourceFactory","sequenceSource","targetSource","create","theValue","index","nextItemHandle","handle","GuestAwareMap","val","innerGuest","GuestAwareRace","guestAwares","connectedWithGuestAware","GuestAwareActive","configExecutor","config","source","GuestSync","GuestDisposable","disposeCheck","Patron","willBePatron","PatronOnce","received","SourceDynamic","baseGuestAware","Factory","constructorFn","factories","args","Module","buildingFn"],"mappings":"AAUgB,SAAAA,EAASC,EAA+BC,GAClD,MAAsB,mBAAfD,EACFA,EAAWC,GAEXD,EAAWD,MAAME,EAE5B,CAKO,MAAMC,EACJ,WAAAC,CAAoBH,GAAAI,KAAAJ,WAAAA,CAAiC,CAErD,KAAAD,CAAME,GAEJ,OADDF,EAAAK,KAAKJ,WAAYC,GAChBA,CACT,ECNc,SAAAI,EAAQC,EAASL,EAAqBM,GAC/B,mBAAVN,EACTA,EAAMK,EAAMC,GAENN,EAAAI,KAAKC,EAAMC,EAErB,CAKO,MAAMC,EACJ,WAAAL,CAAoBM,GAAAL,KAAAK,SAAAA,CAAkC,CAEtD,IAAAJ,CAAKN,EAAUQ,GAEb,OADFH,KAAAK,SAASV,EAAOQ,GACdH,IACT,EC7BK,MAAMM,EACJ,WAAAP,CACGQ,EACAC,GADAR,KAAAO,YAAAA,EACAP,KAAAQ,YAAAA,CACN,CAEG,YAAAC,GACD,MAA4B,mBAArBT,KAAKO,YACP,QAEJP,KAAKO,YAAYE,aAGfT,KAAKO,YAAYE,eAFf,OAGX,CAEO,IAAAR,CAAKN,EAAUQ,GAEb,OADFF,EAAAN,EAAOK,K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N,CAEG,KAAAtG,CAAME,GAEJ,OADDF,EAAAK,KAAKiG,eAAgBpG,GACpBG,IACT,CAEO,IAAAC,CAAKN,GAEH,OADFA,EAAAA,EAAOK,KAAK+C,WACV/C,IACT,CAEO,IAAAiB,GACL,MAAMoB,MAAM,2BACd,ECXK,MAAM6D,EACJ,WAAAnG,CACGoG,EACAC,EAAqC,IADrCpG,KAAAmG,cAAAA,EACAnG,KAAAoG,UAAAA,CACN,CAEG,MAAA1B,IACF2B,GAEH,OAAO,IAAKrG,KAAKmG,iBACZE,EACHrG,KAAKoG,UAET,ECvBK,MAAME,EACJ,WAAAvG,CAAoBwG,GAAAvG,KAAAuG,WAAAA,CAAqC,CAEzD,MAAA7B,IAA0C2B,GACxC,OAAArG,KAAKuG,cAAcF,EAC5B"}
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/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestAwareAll.ts","../src/Source/SourceEmpty.ts","../src/Guest/GuestAwareSequence.ts","../src/Guest/GuestAwareMap.ts","../src/Guest/GuestAwareRace.ts","../src/Guest/GuestAwareActive.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestDisposable.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceDynamic.ts","../src/Factory/Factory.ts","../src/Factory/Module.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport type GuestAwareExecutorType<T> = (guest: GuestType<T>) => unknown;\n\nexport interface GuestAwareObjectType<T> {\n value: GuestAwareExecutorType<T>\n}\n\nexport type GuestAwareType<T = any> = GuestAwareExecutorType<T> | GuestAwareObjectType<T>\n\nexport function value<T>(guestAware: GuestAwareType<T>, guest: GuestType<T>) {\n if (typeof guestAware === 'function') {\n return guestAware(guest);\n } else {\n return guestAware.value(guest);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware\n */\nexport class GuestAware<T = any> implements GuestAwareObjectType<T> {\n public constructor(private guestAware: GuestAwareType<T>) { }\n\n public value(guest: GuestType<T>): GuestType<T> {\n value(this.guestAware, guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = any> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = any> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = any> = GuestExecutorType<T> | GuestObjectType<T>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/give\n */\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest\n */\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) { }\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-cast\n */\nexport class GuestCast<T> implements GuestDisposableType<T> {\n public constructor(\n private sourceGuest: GuestType<any>,\n private targetGuest: GuestType<T>,\n ) { }\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.sourceGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/remove-patron-from-pools\n */\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/is-patron-in-pools\n */\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n};\n\nexport interface PoolType<T = any> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n size(): number;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-pool\n */\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public size(): number {\n return this.patrons.size;\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (!shouldBePatron) {\n throw new Error(\"PatronPool add method received nothing!\");\n }\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: GiveOptions,\n ) {\n const isDisposed = this.guestDisposed(value, guest);\n\n if (!isDisposed) {\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\n private guestDisposed(value: T, guest: GuestType<T>) {\n if ((guest as GuestDisposableType).disposed?.(value)) {\n this.remove(guest as GuestObjectType);\n return true;\n }\n\n return false;\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareObjectType } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport interface PoolAware<T = any> {\n pool(): PatronPool<T>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source\n */\nexport type SourceType<T = any> = GuestAwareObjectType<T> &\n GuestObjectType<T> &\n PoolAware<T>;\n\nexport class Source<T> implements SourceType<T> {\n private thePool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) { }\n\n public pool() {\n return this.thePool;\n }\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.thePool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.thePool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.thePool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"./GuestDisposable\";\nimport { GiveOptions, Guest, GuestType } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-object\n */\nexport class GuestObject<T> implements GuestDisposableType<T> {\n public constructor(private baseGuest: GuestType<T>) { }\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-pool\n */\nexport class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n public size() {\n return this.patronPool.size() + this.guests.size;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestAwareObjectType } from \"src/Guest/GuestAware\";\nimport { Source } from \"../Source/Source\";\nimport { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestObject } from \"./GuestObject\";\nimport { GuestPool } from \"./GuestPool\";\n\nexport interface GuestAwareAllType<T = any> extends GuestAwareObjectType<T> {\n valueArray(guest: GuestObjectType<T>): this;\n guestKey<R>(key: string): GuestObjectType<R>;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-all\n */\nexport class GuestAwareAll<T> implements GuestAwareAllType<T> {\n private theAll: Source<Record<string, unknown>>;\n\n private keysKnown = new Set();\n\n private keysFilled = new Set();\n\n private filledAllPool = new GuestPool(this);\n\n public constructor() {\n this.theAll = new Source<Record<string, unknown>>({});\n }\n\n public valueArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledAllPool.add(\n new GuestCast(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }),\n );\n if (this.isAllFilled()) {\n this.theAll.value(\n new Guest((all: Record<string, unknown>) => {\n this.filledAllPool.give(Object.values(all));\n }),\n );\n }\n return this;\n }\n\n public value(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isAllFilled()) {\n this.filledAllPool.add(guestObject);\n this.theAll.value(\n new Guest((all) => {\n this.filledAllPool.give(all);\n }),\n );\n } else {\n this.filledAllPool.add(guestObject);\n }\n return this;\n }\n\n public guestKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theAll.value(\n new Guest((all: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastAll = {\n ...all,\n [key]: value,\n };\n this.theAll.give(lastAll);\n if (this.isAllFilled()) {\n this.filledAllPool.give(lastAll);\n }\n }),\n );\n });\n });\n }\n\n private isAllFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { GuestCast } from \"../Guest/GuestCast\";\nimport { give, GuestType } from \"./../Guest/Guest\";\nimport { Source, SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source/source-empty\n */\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestCast(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n\n public pool(): PatronPool<T> {\n return this.baseSource.pool();\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestAwareAll } from \"./GuestAwareAll\";\nimport { GuestType } from \"./Guest\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-sequence\n */\nexport class GuestAwareSequence<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const all = new GuestAwareAll<TG[]>();\n const sequenceSource = new SourceEmpty();\n const targetSource = this.targetSourceFactory.create(\n sequenceSource\n )\n\n value(\n this.baseSource,\n new GuestCast(guest, (theValue) => {\n let index = 0;\n\n const nextItemHandle = () => {\n if (theValue[index + 1] !== undefined) {\n index = index + 1;\n handle();\n } else {\n all.valueArray(guest);\n }\n }\n\n function handle() {\n sequenceSource.give(theValue[index]);\n value(targetSource, all.guestKey(index.toString()));\n value(targetSource, nextItemHandle);\n }\n\n if (theValue[index] !== undefined) {\n handle();\n } else {\n give([], guest);\n }\n })\n );\n return this;\n }\n}\n","import { FactoryType } from \"../Factory/Factory\";\nimport { give } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestAwareAll } from \"./GuestAwareAll\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAware } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-map\n */\nexport class GuestAwareMap<T, TG> implements GuestAwareObjectType<TG[]> {\n public constructor(\n private baseSource: GuestAwareType<T[]>,\n private targetSourceFactory: FactoryType<GuestAwareType<TG>>\n ) { }\n\n public value(guest: GuestType<TG[]>) {\n const all = new GuestAwareAll();\n value(\n this.baseSource,\n new GuestCast(<GuestType>guest, (theValue) => {\n theValue.forEach((val, index) => {\n const targetSource = this.targetSourceFactory.create(\n new GuestAware((innerGuest) => {\n give(val, innerGuest);\n })\n )\n value(targetSource, all.guestKey(index.toString()));\n });\n })\n )\n all.valueArray(<GuestType>guest);\n return this;\n }\n}\n","import { give, GuestType } from \"./Guest\";\nimport { GuestAwareObjectType, GuestAwareType, value } from \"./GuestAware\";\nimport { GuestCast } from \"./GuestCast\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-race\n */\nexport class GuestAwareRace<T> implements GuestAwareObjectType<T> {\n public constructor(private guestAwares: GuestAwareType<T>[]) { }\n\n public value(guest: GuestType<T>): this {\n let connectedWithGuestAware: GuestAwareType | null = null;\n this.guestAwares.forEach(guestAware => {\n value(\n guestAware,\n new GuestCast(<GuestType>guest, (value) => {\n if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {\n give(value as T, guest);\n connectedWithGuestAware = guestAware\n }\n })\n );\n });\n return this;\n }\n}\n","import { SourceType } from \"../Source/Source\";\nimport { SourceEmpty } from \"../Source/SourceEmpty\";\nimport { GuestType } from \"./Guest\";\nimport { GuestAwareObjectType } from \"./GuestAware\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/action-type\n */\nexport interface ActionType<P = any> {\n do(config: P): this;\n}\n\nexport interface GuestAwareAcitveType<R = unknown, T = unknown> extends GuestAwareObjectType<T>, ActionType<R> {\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-aware-active\n */\nexport class GuestAwareActive<R, T> implements GuestAwareAcitveType<R, T> {\n private source = new SourceEmpty<T>();\n\n public constructor(private configExecutor: (config: R, source: SourceType<T>) => void) { }\n\n public do(config: R): this {\n this.configExecutor(config, this.source);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n this.source.value(guest);\n return this;\n }\n}\n","import { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = any> extends GuestObjectType<T> {\n value(): T;\n}\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-sync\n */\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) { }\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GiveOptions, GuestObjectType, GuestType } from \"./Guest\";\n\nexport interface GuestDisposableType<T = any> extends GuestObjectType<T> {\n disposed(value: T | null): boolean;\n}\n\nexport type MaybeDisposableType<T = any> = Partial<GuestDisposableType<T>>;\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/guest/guest-disposable\n */\nexport class GuestDisposable<T> implements GuestDisposableType<T> {\n public constructor(\n private guest: GuestType,\n private disposeCheck: (value: T | null) => boolean,\n ) { }\n\n public disposed(value: T | null): boolean {\n return this.disposeCheck(value);\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.guest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"../Guest/Guest\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron\n */\nexport class Patron<T> implements GuestDisposableType<T> {\n public constructor(private willBePatron: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.willBePatron as GuestDisposableType;\n return maybeDisposable?.disposed?.(value) || false;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestType, GiveOptions } from \"../Guest/Guest\";\nimport {\n GuestDisposableType,\n MaybeDisposableType,\n} from \"../Guest/GuestDisposable\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/patron/patron-once\n */\nexport class PatronOnce<T> implements GuestDisposableType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) { }\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.baseGuest as MaybeDisposableType;\n return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;\n }\n}\n","import { give, GuestType } from \"../Guest/Guest\";\nimport { GuestAwareType, value } from \"../Guest/GuestAware\";\nimport { PatronPool } from \"../Patron/PatronPool\";\nimport { SourceType } from \"./Source\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/source-dynamic\n */\nexport class SourceDynamic<T = unknown> implements SourceType<T> {\n public constructor(\n private baseGuest: GuestType<T>,\n private baseGuestAware: GuestAwareType<T>,\n ) { }\n\n public value(guest: GuestType<T>) {\n value(this.baseGuestAware, guest);\n return this;\n }\n\n public give(value: T) {\n give(value, this.baseGuest);\n return this;\n }\n\n public pool(): PatronPool<T> {\n throw Error('No pool in SourceDynamic');\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\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/factory\n */\nexport class Factory<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) { }\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./Factory\";\n\n/**\n * @url https://kosukhin.github.io/patron.site/#/utils/module\n */\nexport class Module<T> implements FactoryType<T> {\n public constructor(private buildingFn: (...args: any[]) => T) { }\n\n public create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT {\n return this.buildingFn(...args) as CT extends null ? T : CT;\n }\n}\n"],"names":["value","guestAware","guest","GuestAware","constructor","this","give","data","options","Guest","receiver","GuestCast","sourceGuest","targetGuest","introduction","disposed","maybeDisposable","poolSets","Map","removePatronFromPools","patron","forEach","pool","delete","isPatronInPools","inPool","has","PatronPool","initiator","__publicField","patrons","Set","set","lastMicrotask","doReceive","target","sendValueToGuest","currentMicroTask","queueMicrotask","size","add","shouldBePatron","Error","remove","distribute","receiving","possiblePatron","guestDisposed","Source","sourceDocument","thePool","GuestObject","baseGuest","GuestPool","patronPool","deliverToGuests","guests","clear","GuestAwareAll","theAll","valueArray","guestObject","filledAllPool","Object","values","isAllFilled","all","guestKey","key","keysKnown","keysFilled","lastAll","SourceEmpty","baseSource","GuestAwareSequence","targetSourceFactory","sequenceSource","targetSource","create","theValue","index","nextItemHandle","handle","toString","GuestAwareMap","val","innerGuest","GuestAwareRace","guestAwares","connectedWithGuestAware","GuestAwareActive","configExecutor","config","source","GuestSync","GuestDisposable","disposeCheck","Patron","willBePatron","PatronOnce","received","SourceDynamic","baseGuestAware","Factory","constructorFn","factories","args","Module","buildingFn"],"mappings":"AAUgB,SAAAA,EAASC,EAA+BC,GAClD,MAAsB,mBAAfD,EACFA,EAAWC,GAEXD,EAAWD,MAAME,EAE5B,CAKO,MAAMC,EACJ,WAAAC,CAAoBH,GAAAI,KAAAJ,WAAAA,CAAiC,CAErD,KAAAD,CAAME,GAEJ,OADDF,EAAAK,KAAKJ,WAAYC,GAChBA,CACT,ECNc,SAAAI,EAAQC,EAASL,EAAqBM,GAC/B,mBAAVN,EACTA,EAAMK,EAAMC,GAENN,EAAAI,KAAKC,EAAM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