patron-oop 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +2 -0
- package/dist/patron.d.ts +1 -74
- package/dist/patron.js +6 -3
- package/dist/patron.js.map +1 -1
- package/dist/patron.min.js +1 -1
- package/dist/patron.mjs +7 -1
- package/dist/patron.mjs.map +1 -1
- package/examples/elegant_objects.html +3 -1
- package/package.json +1 -1
- package/src/index.ts +11 -3
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
### [1.5.1](https://github.com/kosukhin/patron/compare/v1.5.0...v1.5.1) (2024-10-20)
|
6
|
+
|
5
7
|
## [1.5.0](https://github.com/kosukhin/patron/compare/v1.4.0...v1.5.0) (2024-10-20)
|
6
8
|
|
7
9
|
|
package/dist/patron.d.ts
CHANGED
@@ -63,11 +63,6 @@ declare class PatronPool<T> implements PoolType<T> {
|
|
63
63
|
interface GuestAwareType<T = unknown> {
|
64
64
|
receiving(guest: GuestType<T>): unknown;
|
65
65
|
}
|
66
|
-
declare class GuestAware<T = unknown> implements GuestAwareType<T> {
|
67
|
-
private guestReceiver;
|
68
|
-
constructor(guestReceiver: (guest: GuestType<T>) => void);
|
69
|
-
receiving(guest: GuestType<T>): GuestType<T>;
|
70
|
-
}
|
71
66
|
|
72
67
|
type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;
|
73
68
|
declare class SourceOfValue<T> implements SourceType<T> {
|
@@ -78,72 +73,4 @@ declare class SourceOfValue<T> implements SourceType<T> {
|
|
78
73
|
receiving(guest: GuestType<T>): this;
|
79
74
|
}
|
80
75
|
|
81
|
-
|
82
|
-
private sourceGuest;
|
83
|
-
private targetGuest;
|
84
|
-
constructor(sourceGuest: GuestType<unknown>, targetGuest: GuestType<T>);
|
85
|
-
introduction(): "guest" | "patron";
|
86
|
-
receive(value: T, options?: ReceiveOptions): this;
|
87
|
-
}
|
88
|
-
|
89
|
-
declare class GuestInTheMiddle<T> implements GuestType<T> {
|
90
|
-
private baseGuest;
|
91
|
-
private middleFn;
|
92
|
-
constructor(baseGuest: GuestType<unknown>, middleFn: (value: T, options?: ReceiveOptions) => void);
|
93
|
-
introduction(): "guest" | "patron";
|
94
|
-
receive(value: T, options?: ReceiveOptions): this;
|
95
|
-
}
|
96
|
-
|
97
|
-
declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
|
98
|
-
private guests;
|
99
|
-
private patronPool;
|
100
|
-
constructor(initiator: unknown);
|
101
|
-
receive(value: T, options?: ReceiveOptions): this;
|
102
|
-
add(guest: GuestType<T>): this;
|
103
|
-
remove(patron: GuestType<T>): this;
|
104
|
-
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
105
|
-
private deliverToGuests;
|
106
|
-
}
|
107
|
-
|
108
|
-
declare class Guest {
|
109
|
-
callback<P>(receiver: GuestExecutorType<P>): GuestCallback<P>;
|
110
|
-
chain(): GuestChain<unknown>;
|
111
|
-
cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>): GuestCast<P>;
|
112
|
-
middleware<P>(baseGuest: GuestType<unknown>, middleFn: (value: P, options?: ReceiveOptions) => void): GuestInTheMiddle<P>;
|
113
|
-
pool(initiator: unknown): GuestPool<unknown>;
|
114
|
-
aware<P>(guestReceiver: (guest: GuestType<P>) => void): GuestAware<P>;
|
115
|
-
sync<P>(value: P): GuestSync<P>;
|
116
|
-
}
|
117
|
-
|
118
|
-
/**
|
119
|
-
* Патрон - это постоянный посетитель
|
120
|
-
*/
|
121
|
-
declare class PatronOfGuest<T> implements GuestType<T> {
|
122
|
-
private willBePatron;
|
123
|
-
constructor(willBePatron: GuestType<T>);
|
124
|
-
introduction(): "patron";
|
125
|
-
receive(value: T, options?: ReceiveOptions): this;
|
126
|
-
}
|
127
|
-
|
128
|
-
declare class PatronOnce<T> implements GuestType<T> {
|
129
|
-
private baseGuest;
|
130
|
-
private received;
|
131
|
-
constructor(baseGuest: GuestType<T>);
|
132
|
-
introduction(): "patron";
|
133
|
-
receive(value: T, options?: ReceiveOptions): this;
|
134
|
-
}
|
135
|
-
|
136
|
-
declare class Patron {
|
137
|
-
ofGuest<P>(willBePatron: GuestType<P>): PatronOfGuest<P>;
|
138
|
-
once<P>(baseGuest: GuestType<P>): PatronOnce<P>;
|
139
|
-
pool(initiator: unknown): PatronPool<unknown>;
|
140
|
-
}
|
141
|
-
|
142
|
-
declare class Source {
|
143
|
-
ofValue<P>(sourceDocument: P): SourceOfValue<P>;
|
144
|
-
applySources<P>(target: P, methodsSources: Record<string, unknown[]>): {
|
145
|
-
[k: string]: any;
|
146
|
-
};
|
147
|
-
}
|
148
|
-
|
149
|
-
export { type ChainType, Guest, GuestCallback, GuestChain, type GuestExecutorType, GuestSync, type GuestType, type GuestValueType, Patron, PatronPool, type PoolType, type ReceiveOptions, Source, SourceOfValue, type SourceType, removePatronFromPools };
|
76
|
+
export { type ChainType, GuestCallback, GuestChain, type GuestExecutorType, GuestSync, type GuestType, type GuestValueType, PatronPool, type PoolType, type ReceiveOptions, SourceOfValue, type SourceType, removePatronFromPools };
|
package/dist/patron.js
CHANGED
@@ -352,13 +352,16 @@ class Source {
|
|
352
352
|
}
|
353
353
|
}
|
354
354
|
|
355
|
-
|
355
|
+
if (window) {
|
356
|
+
window["guest"] = new Guest();
|
357
|
+
window["patron"] = new Patron();
|
358
|
+
window["source"] = new Source();
|
359
|
+
}
|
360
|
+
|
356
361
|
exports.GuestCallback = GuestCallback;
|
357
362
|
exports.GuestChain = GuestChain;
|
358
363
|
exports.GuestSync = GuestSync;
|
359
|
-
exports.Patron = Patron;
|
360
364
|
exports.PatronPool = PatronPool;
|
361
|
-
exports.Source = Source;
|
362
365
|
exports.SourceOfValue = SourceOfValue;
|
363
366
|
exports.removePatronFromPools = removePatronFromPools;
|
364
367
|
//# sourceMappingURL=patron.js.map
|
package/dist/patron.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"patron.js","sources":["../src/Guest/GuestCallback.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestInTheMiddle.ts","../src/Source/SourceOfValue.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestCast.ts","../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Patron/PatronOfGuest.ts","../src/Patron/PatronOnce.ts","../src/Patron/Patron.ts","../src/Source/SourcesApplied.ts","../src/Source/Source.ts"],"sourcesContent":["type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface ReceiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;\n\nexport interface GuestType<T = unknown> {\n receive(value: T, options?: ReceiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport class GuestCallback<T> implements GuestType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\nconst poolSets = new Map<PoolType, Set<GuestType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestType<T> {\n add(guest: GuestType<T>): this;\n distribute(receiving: T, possiblePatron: GuestType<T>): this;\n remove(patron: GuestType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n guest.receive(value, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestPool<T> implements GuestType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (!guest.introduction || guest.introduction() === \"guest\") {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n target.receive(value, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestInTheMiddle<T> implements GuestType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (!this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;\n\nexport class SourceOfValue<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n this.pool.distribute(this.sourceDocument, guest);\n return this;\n }\n}\n","import { GuestCallback, GuestType } from \"./GuestCallback\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { SourceOfValue } from \"../Source/SourceOfValue\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestType<T>): this;\n resultArray(guest: GuestType<T>): this;\n receiveKey<R>(key: string): GuestType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: SourceOfValue<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 SourceOfValue<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n this.filledChainPool.add(\n new GuestInTheMiddle(guest, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n if (this.isChainFilled()) {\n this.filledChainPool.add(guest);\n this.theChain.receiving(\n new GuestCallback((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guest);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestType<R> {\n this.keysKnown.add(key);\n return new GuestCallback((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestValueType<T = unknown> extends GuestType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestCast<T> implements GuestType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.targetGuest.receive(value, options);\n return this;\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestAwareType<T = unknown> {\n receiving(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","import {\n GuestCallback,\n GuestExecutorType,\n GuestType,\n ReceiveOptions,\n} from \"./GuestCallback\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestAware } from \"./GuestAware\";\nimport { GuestSync } from \"./GuestSync\";\n\nexport class Guest {\n public callback<P>(receiver: GuestExecutorType<P>) {\n return new GuestCallback(receiver);\n }\n\n public chain() {\n return new GuestChain();\n }\n\n public cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>) {\n return new GuestCast(sourceGuest, targetGuest);\n }\n\n public middleware<P>(\n baseGuest: GuestType<unknown>,\n middleFn: (value: P, options?: ReceiveOptions) => void,\n ) {\n return new GuestInTheMiddle(baseGuest, middleFn);\n }\n\n public pool(initiator: unknown) {\n return new GuestPool(initiator);\n }\n\n public aware<P>(guestReceiver: (guest: GuestType<P>) => void) {\n return new GuestAware(guestReceiver);\n }\n\n public sync<P>(value: P) {\n return new GuestSync(value);\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class PatronOfGuest<T> implements GuestType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.willBePatron.receive(value, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n this.baseGuest.receive(value, options);\n }\n\n const data = options?.data as PoolAware;\n\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { PatronOfGuest } from \"./PatronOfGuest\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronOnce } from \"./PatronOnce\";\nimport { PatronPool } from \"./PatronPool\";\n\nexport class Patron {\n public ofGuest<P>(willBePatron: GuestType<P>) {\n return new PatronOfGuest(willBePatron);\n }\n\n public once<P>(baseGuest: GuestType<P>) {\n return new PatronOnce(baseGuest);\n }\n\n public pool(initiator: unknown) {\n return new PatronPool(initiator);\n }\n}\n","type TupleSplit<\n T,\n N extends number,\n O extends readonly any[] = readonly [],\n> = O[\"length\"] extends N\n ? [O, T]\n : T extends readonly [infer F, ...infer R]\n ? TupleSplit<readonly [...R], N, readonly [...O, F]>\n : [O, T];\n\ntype SkipFirst<T extends readonly any[], N extends number> = TupleSplit<\n T,\n N\n>[1];\n\nexport const sourcesApplied = <T>(\n target: T,\n methodsSources: Record<string, unknown[]>,\n) => {\n return Object.fromEntries(\n Object.entries(target as object).map(([key, value]) => {\n if (value instanceof Function && methodsSources[key]) {\n const methodArgs = methodsSources[key];\n return [\n key,\n new Proxy(value, {\n apply(target: Function, thisArg: any, argArray: any[]): any {\n return target.apply(thisArg, [\n ...methodsSources[key],\n ...argArray,\n ]);\n },\n }) as (...args: Parameters<typeof value>) => ReturnType<typeof value>,\n ];\n }\n\n return [key, value];\n }),\n );\n};\n","import { SourceOfValue } from \"./SourceOfValue\";\nimport { sourcesApplied } from \"./SourcesApplied\";\n\nexport class Source {\n public ofValue<P>(sourceDocument: P) {\n return new SourceOfValue(sourceDocument);\n }\n\n public applySources<P>(target: P, methodsSources: Record<string, unknown[]>) {\n return sourcesApplied(target, methodsSources);\n }\n}\n"],"names":["__publicField","target"],"mappings":";;AAaO,MAAM,aAAyC,CAAA;AAAA,EAC7C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,OAAA,CAAQ,OAAU,OAA0B,EAAA;AACjD,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,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"file":"patron.js","sources":["../src/Guest/GuestCallback.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestInTheMiddle.ts","../src/Source/SourceOfValue.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestCast.ts","../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Patron/PatronOfGuest.ts","../src/Patron/PatronOnce.ts","../src/Patron/Patron.ts","../src/Source/SourcesApplied.ts","../src/Source/Source.ts","../src/index.ts"],"sourcesContent":["type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface ReceiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;\n\nexport interface GuestType<T = unknown> {\n receive(value: T, options?: ReceiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport class GuestCallback<T> implements GuestType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\nconst poolSets = new Map<PoolType, Set<GuestType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestType<T> {\n add(guest: GuestType<T>): this;\n distribute(receiving: T, possiblePatron: GuestType<T>): this;\n remove(patron: GuestType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n guest.receive(value, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestPool<T> implements GuestType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (!guest.introduction || guest.introduction() === \"guest\") {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n target.receive(value, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestInTheMiddle<T> implements GuestType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (!this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;\n\nexport class SourceOfValue<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n this.pool.distribute(this.sourceDocument, guest);\n return this;\n }\n}\n","import { GuestCallback, GuestType } from \"./GuestCallback\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { SourceOfValue } from \"../Source/SourceOfValue\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestType<T>): this;\n resultArray(guest: GuestType<T>): this;\n receiveKey<R>(key: string): GuestType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: SourceOfValue<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 SourceOfValue<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n this.filledChainPool.add(\n new GuestInTheMiddle(guest, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n if (this.isChainFilled()) {\n this.filledChainPool.add(guest);\n this.theChain.receiving(\n new GuestCallback((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guest);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestType<R> {\n this.keysKnown.add(key);\n return new GuestCallback((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestValueType<T = unknown> extends GuestType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestCast<T> implements GuestType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.targetGuest.receive(value, options);\n return this;\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestAwareType<T = unknown> {\n receiving(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","import {\n GuestCallback,\n GuestExecutorType,\n GuestType,\n ReceiveOptions,\n} from \"./GuestCallback\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestAware } from \"./GuestAware\";\nimport { GuestSync } from \"./GuestSync\";\n\nexport class Guest {\n public callback<P>(receiver: GuestExecutorType<P>) {\n return new GuestCallback(receiver);\n }\n\n public chain() {\n return new GuestChain();\n }\n\n public cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>) {\n return new GuestCast(sourceGuest, targetGuest);\n }\n\n public middleware<P>(\n baseGuest: GuestType<unknown>,\n middleFn: (value: P, options?: ReceiveOptions) => void,\n ) {\n return new GuestInTheMiddle(baseGuest, middleFn);\n }\n\n public pool(initiator: unknown) {\n return new GuestPool(initiator);\n }\n\n public aware<P>(guestReceiver: (guest: GuestType<P>) => void) {\n return new GuestAware(guestReceiver);\n }\n\n public sync<P>(value: P) {\n return new GuestSync(value);\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class PatronOfGuest<T> implements GuestType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.willBePatron.receive(value, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n this.baseGuest.receive(value, options);\n }\n\n const data = options?.data as PoolAware;\n\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { PatronOfGuest } from \"./PatronOfGuest\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronOnce } from \"./PatronOnce\";\nimport { PatronPool } from \"./PatronPool\";\n\nexport class Patron {\n public ofGuest<P>(willBePatron: GuestType<P>) {\n return new PatronOfGuest(willBePatron);\n }\n\n public once<P>(baseGuest: GuestType<P>) {\n return new PatronOnce(baseGuest);\n }\n\n public pool(initiator: unknown) {\n return new PatronPool(initiator);\n }\n}\n","type TupleSplit<\n T,\n N extends number,\n O extends readonly any[] = readonly [],\n> = O[\"length\"] extends N\n ? [O, T]\n : T extends readonly [infer F, ...infer R]\n ? TupleSplit<readonly [...R], N, readonly [...O, F]>\n : [O, T];\n\ntype SkipFirst<T extends readonly any[], N extends number> = TupleSplit<\n T,\n N\n>[1];\n\nexport const sourcesApplied = <T>(\n target: T,\n methodsSources: Record<string, unknown[]>,\n) => {\n return Object.fromEntries(\n Object.entries(target as object).map(([key, value]) => {\n if (value instanceof Function && methodsSources[key]) {\n const methodArgs = methodsSources[key];\n return [\n key,\n new Proxy(value, {\n apply(target: Function, thisArg: any, argArray: any[]): any {\n return target.apply(thisArg, [\n ...methodsSources[key],\n ...argArray,\n ]);\n },\n }) as (...args: Parameters<typeof value>) => ReturnType<typeof value>,\n ];\n }\n\n return [key, value];\n }),\n );\n};\n","import { SourceOfValue } from \"./SourceOfValue\";\nimport { sourcesApplied } from \"./SourcesApplied\";\n\nexport class Source {\n public ofValue<P>(sourceDocument: P) {\n return new SourceOfValue(sourceDocument);\n }\n\n public applySources<P>(target: P, methodsSources: Record<string, unknown[]>) {\n return sourcesApplied(target, methodsSources);\n }\n}\n","export * from \"./Guest/GuestCallback\";\nexport * from \"./Guest/GuestChain\";\nexport * from \"./Guest/GuestSync\";\nexport * from \"./Patron/PatronPool\";\nexport * from \"./Source/SourceOfValue\";\n\nimport { Guest } from \"./Guest/Guest\";\nimport { Patron } from \"./Patron/Patron\";\nimport { Source } from \"./Source/Source\";\n\ndeclare var window: any;\n\nif (window) {\n window[\"guest\"] = new Guest();\n window[\"patron\"] = new Patron();\n window[\"source\"] = new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AACF,CAAA;;ACpCO,MAAM,MAAO,CAAA;AAAA,EACX,QAAW,cAAmB,EAAA;AACnC,IAAO,OAAA,IAAI,cAAc,cAAc,CAAA,CAAA;AAAA,GACzC;AAAA,EAEO,YAAA,CAAgB,QAAW,cAA2C,EAAA;AAC3E,IAAO,OAAA,cAAA,CAAe,QAAQ,cAAc,CAAA,CAAA;AAAA,GAC9C;AACF;;ACCA,IAAI,MAAQ,EAAA;AACV,EAAO,MAAA,CAAA,OAAO,CAAI,GAAA,IAAI,KAAM,EAAA,CAAA;AAC5B,EAAO,MAAA,CAAA,QAAQ,CAAI,GAAA,IAAI,MAAO,EAAA,CAAA;AAC9B,EAAO,MAAA,CAAA,QAAQ,CAAI,GAAA,IAAI,MAAO,EAAA,CAAA;AAChC;;;;;;;;;"}
|
package/dist/patron.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e){"use strict";class t{constructor(e){this.receiver=e}receive(e,t){return this.receiver(e,t),this}}var i=Object.defineProperty,s=(e,t,s)=>((e,t,s)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);const r=new Map;class n{constructor(e){this.initiator=e,s(this,"patrons",new Set),s(this,"receive"),r.set(this,this.patrons);let t=null;const i=(e,t)=>{this.patrons.forEach((i=>{this.sendValueToGuest(e,i,t)}))};this.receive=(e,s)=>{const r=()=>{r===t&&i(e,s)};return t=r,queueMicrotask(r),this}}add(e){return 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,i){t.receive(e,{...i,data:{...i?.data??{},initiator:this.initiator,pool:this}})}}var o=Object.defineProperty,u=(e,t,i)=>((e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class a{constructor(e){u(this,"guests",new Set),u(this,"patronPool"),this.patronPool=new n(e)}receive(e,t){return this.deliverToGuests(e,t),this.patronPool.receive(e,t),this}add(e){return e.introduction&&"guest"!==e.introduction()||this.guests.add(e),this.patronPool.add(e),this}remove(e){return this.guests.delete(e),this.patronPool.remove(e),this}distribute(e,t){return this.add(t),this.receive(e),this}deliverToGuests(e,t){this.guests.forEach((i=>{i.receive(e,t)})),this.guests.clear()}}class c{constructor(e,t){this.baseGuest=e,this.middleFn=t}introduction(){return this.baseGuest.introduction?this.baseGuest.introduction():"guest"}receive(e,t){return this.middleFn(e,t),this}}var h=Object.defineProperty,l=(e,t,i)=>((e,t,i)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class d{constructor(e){this.sourceDocument=e,l(this,"pool",new n(this))}receive(e){return this.sourceDocument=e,this.pool.receive(this.sourceDocument),this}receiving(e){return this.pool.distribute(this.sourceDocument,e),this}}var v=Object.defineProperty,w=(e,t,i)=>((e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class
|
1
|
+
!function(e){"use strict";class t{constructor(e){this.receiver=e}receive(e,t){return this.receiver(e,t),this}}var i=Object.defineProperty,s=(e,t,s)=>((e,t,s)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);const r=new Map;class n{constructor(e){this.initiator=e,s(this,"patrons",new Set),s(this,"receive"),r.set(this,this.patrons);let t=null;const i=(e,t)=>{this.patrons.forEach((i=>{this.sendValueToGuest(e,i,t)}))};this.receive=(e,s)=>{const r=()=>{r===t&&i(e,s)};return t=r,queueMicrotask(r),this}}add(e){return 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,i){t.receive(e,{...i,data:{...i?.data??{},initiator:this.initiator,pool:this}})}}var o=Object.defineProperty,u=(e,t,i)=>((e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class a{constructor(e){u(this,"guests",new Set),u(this,"patronPool"),this.patronPool=new n(e)}receive(e,t){return this.deliverToGuests(e,t),this.patronPool.receive(e,t),this}add(e){return e.introduction&&"guest"!==e.introduction()||this.guests.add(e),this.patronPool.add(e),this}remove(e){return this.guests.delete(e),this.patronPool.remove(e),this}distribute(e,t){return this.add(t),this.receive(e),this}deliverToGuests(e,t){this.guests.forEach((i=>{i.receive(e,t)})),this.guests.clear()}}class c{constructor(e,t){this.baseGuest=e,this.middleFn=t}introduction(){return this.baseGuest.introduction?this.baseGuest.introduction():"guest"}receive(e,t){return this.middleFn(e,t),this}}var h=Object.defineProperty,l=(e,t,i)=>((e,t,i)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class d{constructor(e){this.sourceDocument=e,l(this,"pool",new n(this))}receive(e){return this.sourceDocument=e,this.pool.receive(this.sourceDocument),this}receiving(e){return this.pool.distribute(this.sourceDocument,e),this}}var v=Object.defineProperty,w=(e,t,i)=>((e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class p{constructor(){w(this,"theChain"),w(this,"keysKnown",new Set),w(this,"keysFilled",new Set),w(this,"filledChainPool",new a(this)),this.theChain=new d({})}resultArray(e){return this.filledChainPool.add(new c(e,(e=>Object.values(e)))),this.isChainFilled()&&this.theChain.receiving(new t((e=>{this.filledChainPool.receive(Object.values(e))}))),this}result(e){return this.isChainFilled()?(this.filledChainPool.add(e),this.theChain.receiving(new t((e=>{this.filledChainPool.receive(e)})))):this.filledChainPool.add(e),this}receiveKey(e){return this.keysKnown.add(e),new t((i=>{queueMicrotask((()=>{this.theChain.receiving(new t((t=>{this.keysFilled.add(e);const s={...t,[e]:i};this.theChain.receive(s),this.isChainFilled()&&this.filledChainPool.receive(s)})))}))}))}isChainFilled(){return this.keysFilled.size>0&&this.keysFilled.size===this.keysKnown.size}}class b{constructor(e){this.theValue=e}receive(e){return this.theValue=e,this}value(){return this.theValue}}class f{constructor(e,t){this.sourceGuest=e,this.targetGuest=t}introduction(){return this.sourceGuest.introduction?this.sourceGuest.introduction():"guest"}receive(e,t){return this.targetGuest.receive(e,t),this}}class y{constructor(e){this.guestReceiver=e}receiving(e){return this.guestReceiver(e),e}}class P{callback(e){return new t(e)}chain(){return new p}cast(e,t){return new f(e,t)}middleware(e,t){return new c(e,t)}pool(e){return new a(e)}aware(e){return new y(e)}sync(e){return new b(e)}}class g{constructor(e){this.willBePatron=e}introduction(){return"patron"}receive(e,t){return this.willBePatron.receive(e,t),this}}var m=Object.defineProperty,C=(e,t,i)=>((e,t,i)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,t+"",i);class G{constructor(e){this.baseGuest=e,C(this,"received",!1)}introduction(){return"patron"}receive(e,t){this.received||this.baseGuest.receive(e,t);const i=t?.data;return i?.pool&&i.pool.remove(this),this}}class F{ofGuest(e){return new g(e)}once(e){return new G(e)}pool(e){return new n(e)}}class k{ofValue(e){return new d(e)}applySources(e,t){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,i])=>i instanceof Function&&t[e]?(t[e],[e,new Proxy(i,{apply:(i,s,r)=>i.apply(s,[...t[e],...r])})]):[e,i]))))(e,t)}}window&&(window.guest=new P,window.patron=new F,window.source=new k),e.GuestCallback=t,e.GuestChain=p,e.GuestSync=b,e.PatronPool=n,e.SourceOfValue=d,e.removePatronFromPools=e=>{r.forEach((t=>{t.delete(e)}))}}({});
|
package/dist/patron.mjs
CHANGED
@@ -350,5 +350,11 @@ class Source {
|
|
350
350
|
}
|
351
351
|
}
|
352
352
|
|
353
|
-
|
353
|
+
if (window) {
|
354
|
+
window["guest"] = new Guest();
|
355
|
+
window["patron"] = new Patron();
|
356
|
+
window["source"] = new Source();
|
357
|
+
}
|
358
|
+
|
359
|
+
export { GuestCallback, GuestChain, GuestSync, PatronPool, SourceOfValue, removePatronFromPools };
|
354
360
|
//# sourceMappingURL=patron.mjs.map
|
package/dist/patron.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"patron.mjs","sources":["../src/Guest/GuestCallback.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestInTheMiddle.ts","../src/Source/SourceOfValue.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestCast.ts","../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Patron/PatronOfGuest.ts","../src/Patron/PatronOnce.ts","../src/Patron/Patron.ts","../src/Source/SourcesApplied.ts","../src/Source/Source.ts"],"sourcesContent":["type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface ReceiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;\n\nexport interface GuestType<T = unknown> {\n receive(value: T, options?: ReceiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport class GuestCallback<T> implements GuestType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\nconst poolSets = new Map<PoolType, Set<GuestType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestType<T> {\n add(guest: GuestType<T>): this;\n distribute(receiving: T, possiblePatron: GuestType<T>): this;\n remove(patron: GuestType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n guest.receive(value, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestPool<T> implements GuestType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (!guest.introduction || guest.introduction() === \"guest\") {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n target.receive(value, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestInTheMiddle<T> implements GuestType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (!this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;\n\nexport class SourceOfValue<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n this.pool.distribute(this.sourceDocument, guest);\n return this;\n }\n}\n","import { GuestCallback, GuestType } from \"./GuestCallback\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { SourceOfValue } from \"../Source/SourceOfValue\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestType<T>): this;\n resultArray(guest: GuestType<T>): this;\n receiveKey<R>(key: string): GuestType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: SourceOfValue<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 SourceOfValue<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n this.filledChainPool.add(\n new GuestInTheMiddle(guest, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n if (this.isChainFilled()) {\n this.filledChainPool.add(guest);\n this.theChain.receiving(\n new GuestCallback((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guest);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestType<R> {\n this.keysKnown.add(key);\n return new GuestCallback((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestValueType<T = unknown> extends GuestType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestCast<T> implements GuestType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.targetGuest.receive(value, options);\n return this;\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestAwareType<T = unknown> {\n receiving(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","import {\n GuestCallback,\n GuestExecutorType,\n GuestType,\n ReceiveOptions,\n} from \"./GuestCallback\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestAware } from \"./GuestAware\";\nimport { GuestSync } from \"./GuestSync\";\n\nexport class Guest {\n public callback<P>(receiver: GuestExecutorType<P>) {\n return new GuestCallback(receiver);\n }\n\n public chain() {\n return new GuestChain();\n }\n\n public cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>) {\n return new GuestCast(sourceGuest, targetGuest);\n }\n\n public middleware<P>(\n baseGuest: GuestType<unknown>,\n middleFn: (value: P, options?: ReceiveOptions) => void,\n ) {\n return new GuestInTheMiddle(baseGuest, middleFn);\n }\n\n public pool(initiator: unknown) {\n return new GuestPool(initiator);\n }\n\n public aware<P>(guestReceiver: (guest: GuestType<P>) => void) {\n return new GuestAware(guestReceiver);\n }\n\n public sync<P>(value: P) {\n return new GuestSync(value);\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class PatronOfGuest<T> implements GuestType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.willBePatron.receive(value, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n this.baseGuest.receive(value, options);\n }\n\n const data = options?.data as PoolAware;\n\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { PatronOfGuest } from \"./PatronOfGuest\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronOnce } from \"./PatronOnce\";\nimport { PatronPool } from \"./PatronPool\";\n\nexport class Patron {\n public ofGuest<P>(willBePatron: GuestType<P>) {\n return new PatronOfGuest(willBePatron);\n }\n\n public once<P>(baseGuest: GuestType<P>) {\n return new PatronOnce(baseGuest);\n }\n\n public pool(initiator: unknown) {\n return new PatronPool(initiator);\n }\n}\n","type TupleSplit<\n T,\n N extends number,\n O extends readonly any[] = readonly [],\n> = O[\"length\"] extends N\n ? [O, T]\n : T extends readonly [infer F, ...infer R]\n ? TupleSplit<readonly [...R], N, readonly [...O, F]>\n : [O, T];\n\ntype SkipFirst<T extends readonly any[], N extends number> = TupleSplit<\n T,\n N\n>[1];\n\nexport const sourcesApplied = <T>(\n target: T,\n methodsSources: Record<string, unknown[]>,\n) => {\n return Object.fromEntries(\n Object.entries(target as object).map(([key, value]) => {\n if (value instanceof Function && methodsSources[key]) {\n const methodArgs = methodsSources[key];\n return [\n key,\n new Proxy(value, {\n apply(target: Function, thisArg: any, argArray: any[]): any {\n return target.apply(thisArg, [\n ...methodsSources[key],\n ...argArray,\n ]);\n },\n }) as (...args: Parameters<typeof value>) => ReturnType<typeof value>,\n ];\n }\n\n return [key, value];\n }),\n );\n};\n","import { SourceOfValue } from \"./SourceOfValue\";\nimport { sourcesApplied } from \"./SourcesApplied\";\n\nexport class Source {\n public ofValue<P>(sourceDocument: P) {\n return new SourceOfValue(sourceDocument);\n }\n\n public applySources<P>(target: P, methodsSources: Record<string, unknown[]>) {\n return sourcesApplied(target, methodsSources);\n }\n}\n"],"names":["__publicField","target"],"mappings":"AAaO,MAAM,aAAyC,CAAA;AAAA,EAC7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C,IAAO,OAAA,IAAI,cAAc,cAAc,CAAA,CAAA;AAAA,GACzC;AAAA,EAEO,YAAA,CAAgB,QAAW,cAA2C,EAAA;AAC3E,IAAO,OAAA,cAAA,CAAe,QAAQ,cAAc,CAAA,CAAA;AAAA,GAC9C;AACF;;;;"}
|
1
|
+
{"version":3,"file":"patron.mjs","sources":["../src/Guest/GuestCallback.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestInTheMiddle.ts","../src/Source/SourceOfValue.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestCast.ts","../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Patron/PatronOfGuest.ts","../src/Patron/PatronOnce.ts","../src/Patron/Patron.ts","../src/Source/SourcesApplied.ts","../src/Source/Source.ts","../src/index.ts"],"sourcesContent":["type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface ReceiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;\n\nexport interface GuestType<T = unknown> {\n receive(value: T, options?: ReceiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport class GuestCallback<T> implements GuestType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\nconst poolSets = new Map<PoolType, Set<GuestType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport interface PoolType<T = unknown> extends GuestType<T> {\n add(guest: GuestType<T>): this;\n distribute(receiving: T, possiblePatron: GuestType<T>): this;\n remove(patron: GuestType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n guest.receive(value, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestPool<T> implements GuestType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (!guest.introduction || guest.introduction() === \"guest\") {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n target.receive(value, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestInTheMiddle<T> implements GuestType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (!this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;\n\nexport class SourceOfValue<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n this.pool.distribute(this.sourceDocument, guest);\n return this;\n }\n}\n","import { GuestCallback, GuestType } from \"./GuestCallback\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { SourceOfValue } from \"../Source/SourceOfValue\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestType<T>): this;\n resultArray(guest: GuestType<T>): this;\n receiveKey<R>(key: string): GuestType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: SourceOfValue<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 SourceOfValue<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n this.filledChainPool.add(\n new GuestInTheMiddle(guest, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n if (this.isChainFilled()) {\n this.filledChainPool.add(guest);\n this.theChain.receiving(\n new GuestCallback((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guest);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestType<R> {\n this.keysKnown.add(key);\n return new GuestCallback((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new GuestCallback((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestValueType<T = unknown> extends GuestType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestCallback\";\n\nexport class GuestCast<T> implements GuestType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.targetGuest.receive(value, options);\n return this;\n }\n}\n","import { GuestType } from \"./GuestCallback\";\n\nexport interface GuestAwareType<T = unknown> {\n receiving(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","import {\n GuestCallback,\n GuestExecutorType,\n GuestType,\n ReceiveOptions,\n} from \"./GuestCallback\";\nimport { GuestChain } from \"./GuestChain\";\nimport { GuestCast } from \"./GuestCast\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestAware } from \"./GuestAware\";\nimport { GuestSync } from \"./GuestSync\";\n\nexport class Guest {\n public callback<P>(receiver: GuestExecutorType<P>) {\n return new GuestCallback(receiver);\n }\n\n public chain() {\n return new GuestChain();\n }\n\n public cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>) {\n return new GuestCast(sourceGuest, targetGuest);\n }\n\n public middleware<P>(\n baseGuest: GuestType<unknown>,\n middleFn: (value: P, options?: ReceiveOptions) => void,\n ) {\n return new GuestInTheMiddle(baseGuest, middleFn);\n }\n\n public pool(initiator: unknown) {\n return new GuestPool(initiator);\n }\n\n public aware<P>(guestReceiver: (guest: GuestType<P>) => void) {\n return new GuestAware(guestReceiver);\n }\n\n public sync<P>(value: P) {\n return new GuestSync(value);\n }\n}\n","import { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class PatronOfGuest<T> implements GuestType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.willBePatron.receive(value, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { GuestType, ReceiveOptions } from \"../Guest/GuestCallback\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n this.baseGuest.receive(value, options);\n }\n\n const data = options?.data as PoolAware;\n\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { PatronOfGuest } from \"./PatronOfGuest\";\nimport { GuestType } from \"../Guest/GuestCallback\";\nimport { PatronOnce } from \"./PatronOnce\";\nimport { PatronPool } from \"./PatronPool\";\n\nexport class Patron {\n public ofGuest<P>(willBePatron: GuestType<P>) {\n return new PatronOfGuest(willBePatron);\n }\n\n public once<P>(baseGuest: GuestType<P>) {\n return new PatronOnce(baseGuest);\n }\n\n public pool(initiator: unknown) {\n return new PatronPool(initiator);\n }\n}\n","type TupleSplit<\n T,\n N extends number,\n O extends readonly any[] = readonly [],\n> = O[\"length\"] extends N\n ? [O, T]\n : T extends readonly [infer F, ...infer R]\n ? TupleSplit<readonly [...R], N, readonly [...O, F]>\n : [O, T];\n\ntype SkipFirst<T extends readonly any[], N extends number> = TupleSplit<\n T,\n N\n>[1];\n\nexport const sourcesApplied = <T>(\n target: T,\n methodsSources: Record<string, unknown[]>,\n) => {\n return Object.fromEntries(\n Object.entries(target as object).map(([key, value]) => {\n if (value instanceof Function && methodsSources[key]) {\n const methodArgs = methodsSources[key];\n return [\n key,\n new Proxy(value, {\n apply(target: Function, thisArg: any, argArray: any[]): any {\n return target.apply(thisArg, [\n ...methodsSources[key],\n ...argArray,\n ]);\n },\n }) as (...args: Parameters<typeof value>) => ReturnType<typeof value>,\n ];\n }\n\n return [key, value];\n }),\n );\n};\n","import { SourceOfValue } from \"./SourceOfValue\";\nimport { sourcesApplied } from \"./SourcesApplied\";\n\nexport class Source {\n public ofValue<P>(sourceDocument: P) {\n return new SourceOfValue(sourceDocument);\n }\n\n public applySources<P>(target: P, methodsSources: Record<string, unknown[]>) {\n return sourcesApplied(target, methodsSources);\n }\n}\n","export * from \"./Guest/GuestCallback\";\nexport * from \"./Guest/GuestChain\";\nexport * from \"./Guest/GuestSync\";\nexport * from \"./Patron/PatronPool\";\nexport * from \"./Source/SourceOfValue\";\n\nimport { Guest } from \"./Guest/Guest\";\nimport { Patron } from \"./Patron/Patron\";\nimport { Source } from \"./Source/Source\";\n\ndeclare var window: any;\n\nif (window) {\n window[\"guest\"] = new Guest();\n window[\"patron\"] = new Patron();\n window[\"source\"] = new Source();\n}\n"],"names":["__publicField","target"],"mappings":"AAaO,MAAM,aAAyC,CAAA;AAAA,EAC7C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,OAAA,CAAQ,OAAU,OAA0B,EAAA;AACjD,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;;;;AClBA,MAAM,QAAA,uBAAe,GAA8B,EAAA,CAAA;AAKtC,MAAA,qBAAA,GAAwB,CAAC,MAAsB,KAAA;AAC1D,EAAS,QAAA,CAAA,OAAA,CAAQ,CAAC,IAAS,KAAA;AACzB,IAAA,IAAA,CAAK,OAAO,MAAM,CAAA,CAAA;AAAA,GACnB,CAAA,CAAA;AACH,EAAA;AAQO,MAAM,UAAqC,CAAA;AAAA,EAKzC,YAAoB,SAAoB,EAAA;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAJ3B,IAAQA,eAAA,CAAA,IAAA,EAAA,SAAA,sBAAc,GAAkB,EAAA,CAAA,CAAA;AAExC,IAAOA,eAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAGL,IAAS,QAAA,CAAA,GAAA,CAAI,IAAM,EAAA,IAAA,CAAK,OAAO,CAAA,CAAA;AAE/B,IAAA,IAAI,aAAqC,GAAA,IAAA,CAAA;AACzC,IAAM,MAAA,SAAA,GAAY,CAAC,KAAA,EAAU,OAA6B,KAAA;AACxD,MAAK,IAAA,CAAA,OAAA,CAAQ,OAAQ,CAAA,CAAC,MAAW,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,GAAG,CAAA;AAAA,gBACrB,GAAG,QAAA;AAAA,eACJ,CAAA,CAAA;AAAA,aACH;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAEA,MAAO,OAAA,CAAC,KAAK,KAAK,CAAA,CAAA;AAAA,KACnB,CAAA;AAAA,GACH,CAAA;AACF,CAAA;;ACpCO,MAAM,MAAO,CAAA;AAAA,EACX,QAAW,cAAmB,EAAA;AACnC,IAAO,OAAA,IAAI,cAAc,cAAc,CAAA,CAAA;AAAA,GACzC;AAAA,EAEO,YAAA,CAAgB,QAAW,cAA2C,EAAA;AAC3E,IAAO,OAAA,cAAA,CAAe,QAAQ,cAAc,CAAA,CAAA;AAAA,GAC9C;AACF;;ACCA,IAAI,MAAQ,EAAA;AACV,EAAO,MAAA,CAAA,OAAO,CAAI,GAAA,IAAI,KAAM,EAAA,CAAA;AAC5B,EAAO,MAAA,CAAA,QAAQ,CAAI,GAAA,IAAI,MAAO,EAAA,CAAA;AAC9B,EAAO,MAAA,CAAA,QAAQ,CAAI,GAAA,IAAI,MAAO,EAAA,CAAA;AAChC;;;;"}
|
@@ -29,7 +29,9 @@
|
|
29
29
|
result = <b class="result"></b>
|
30
30
|
</div>
|
31
31
|
<script type="module">
|
32
|
-
import {Guest, Source, Patron
|
32
|
+
import {Guest, Source, Patron} from 'https://cdn.jsdelivr.net/npm/patron-oop@1.5.0/dist/patron.mjs';
|
33
|
+
|
34
|
+
|
33
35
|
|
34
36
|
// Presentation of text in document
|
35
37
|
class TextInDocument {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -4,6 +4,14 @@ export * from "./Guest/GuestSync";
|
|
4
4
|
export * from "./Patron/PatronPool";
|
5
5
|
export * from "./Source/SourceOfValue";
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
import { Guest } from "./Guest/Guest";
|
8
|
+
import { Patron } from "./Patron/Patron";
|
9
|
+
import { Source } from "./Source/Source";
|
10
|
+
|
11
|
+
declare var window: any;
|
12
|
+
|
13
|
+
if (window) {
|
14
|
+
window["guest"] = new Guest();
|
15
|
+
window["patron"] = new Patron();
|
16
|
+
window["source"] = new Source();
|
17
|
+
}
|