patron-oop 1.44.1 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/patron.cjs +359 -268
  3. package/dist/patron.cjs.map +1 -1
  4. package/dist/patron.d.ts +215 -150
  5. package/dist/patron.js +343 -261
  6. package/dist/patron.js.map +1 -1
  7. package/dist/patron.min.js +1 -1
  8. package/dist/patron.min.mjs +1 -1
  9. package/dist/patron.min.mjs.map +1 -1
  10. package/dist/patron.mjs +343 -261
  11. package/dist/patron.mjs.map +1 -1
  12. package/docs/README.md +3 -0
  13. package/docs/assets/css/base.css +42 -0
  14. package/docs/assets/favicon/android-icon-144x144.png +0 -0
  15. package/docs/assets/favicon/android-icon-192x192.png +0 -0
  16. package/docs/assets/favicon/android-icon-36x36.png +0 -0
  17. package/docs/assets/favicon/android-icon-48x48.png +0 -0
  18. package/docs/assets/favicon/android-icon-72x72.png +0 -0
  19. package/docs/assets/favicon/android-icon-96x96.png +0 -0
  20. package/docs/assets/favicon/apple-icon-114x114.png +0 -0
  21. package/docs/assets/favicon/apple-icon-120x120.png +0 -0
  22. package/docs/assets/favicon/apple-icon-144x144.png +0 -0
  23. package/docs/assets/favicon/apple-icon-152x152.png +0 -0
  24. package/docs/assets/favicon/apple-icon-180x180.png +0 -0
  25. package/docs/assets/favicon/apple-icon-57x57.png +0 -0
  26. package/docs/assets/favicon/apple-icon-60x60.png +0 -0
  27. package/docs/assets/favicon/apple-icon-72x72.png +0 -0
  28. package/docs/assets/favicon/apple-icon-76x76.png +0 -0
  29. package/docs/assets/favicon/apple-icon-precomposed.png +0 -0
  30. package/docs/assets/favicon/apple-icon.png +0 -0
  31. package/docs/assets/favicon/browserconfig.xml +2 -0
  32. package/docs/assets/favicon/favicon-16x16.png +0 -0
  33. package/docs/assets/favicon/favicon-32x32.png +0 -0
  34. package/docs/assets/favicon/favicon-96x96.png +0 -0
  35. package/docs/assets/favicon/favicon.ico +0 -0
  36. package/docs/assets/favicon/manifest.json +41 -0
  37. package/docs/assets/favicon/ms-icon-144x144.png +0 -0
  38. package/docs/assets/favicon/ms-icon-150x150.png +0 -0
  39. package/docs/assets/favicon/ms-icon-310x310.png +0 -0
  40. package/docs/assets/favicon/ms-icon-70x70.png +0 -0
  41. package/docs/assets/img/404.jpg +0 -0
  42. package/docs/assets/img/angular_16.jpg +0 -0
  43. package/docs/assets/img/angular_32.jpg +0 -0
  44. package/docs/assets/img/eo_16.jpg +0 -0
  45. package/docs/assets/img/eo_big.png +0 -0
  46. package/docs/assets/img/github_16.jpg +0 -0
  47. package/docs/assets/img/logo.jpg +0 -0
  48. package/docs/assets/img/philosofy/observable.jpg +0 -0
  49. package/docs/assets/img/philosofy/responsible.jpg +0 -0
  50. package/docs/assets/img/philosofy/result.jpg +0 -0
  51. package/docs/assets/img/philosofy/tell.jpg +0 -0
  52. package/docs/assets/img/react_16.jpg +0 -0
  53. package/docs/assets/img/react_32.jpg +0 -0
  54. package/docs/assets/img/vue_16.jpg +0 -0
  55. package/docs/assets/img/vue_32.jpg +0 -0
  56. package/docs/assets/js/components/linkDynamic.mjs +11 -0
  57. package/docs/assets/js/components/linkReloadable.mjs +13 -0
  58. package/docs/assets/js/entrypoints/compatibility.mjs +31 -0
  59. package/docs/assets/js/entrypoints/components.mjs +2 -0
  60. package/docs/assets/js/entrypoints/examples.mjs +25 -0
  61. package/docs/assets/js/entrypoints/factory.mjs +20 -0
  62. package/docs/assets/js/entrypoints/guest.mjs +61 -0
  63. package/docs/assets/js/entrypoints/index.mjs +110 -0
  64. package/docs/assets/js/entrypoints/integrations.mjs +36 -0
  65. package/docs/assets/js/entrypoints/patron.mjs +46 -0
  66. package/docs/assets/js/entrypoints/source.mjs +76 -0
  67. package/docs/assets/js/entrypoints/terminology.mjs +51 -0
  68. package/docs/assets/js/entrypoints/utils.mjs +61 -0
  69. package/docs/assets/js/lib/StyleFetched.mjs +14 -0
  70. package/docs/assets/js/routing.mjs +110 -0
  71. package/docs/assets/schemes/dip.html +28 -0
  72. package/docs/favicon.ico +0 -0
  73. package/docs/index-dev.html +346 -0
  74. package/docs/index.html +346 -0
  75. package/docs/manifest.json +41 -0
  76. package/docs/pages/404.html +9 -0
  77. package/docs/pages/common/layout.html +17 -0
  78. package/docs/pages/compatibility/dip.html +82 -0
  79. package/docs/pages/compatibility/elegant-objects.html +373 -0
  80. package/docs/pages/compatibility/layout.html +17 -0
  81. package/docs/pages/examples/errors.html +167 -0
  82. package/docs/pages/examples/index.html +10 -0
  83. package/docs/pages/examples.html +41 -0
  84. package/docs/pages/factory/index.html +18 -0
  85. package/docs/pages/factory.html +36 -0
  86. package/docs/pages/guest/guest-applied.html +51 -0
  87. package/docs/pages/guest/guest-cast.html +219 -0
  88. package/docs/pages/guest/guest-disposable.html +147 -0
  89. package/docs/pages/guest/guest-executor-applied.html +65 -0
  90. package/docs/pages/guest/guest-object.html +101 -0
  91. package/docs/pages/guest/guest-pool.html +107 -0
  92. package/docs/pages/guest/guest-sync.html +66 -0
  93. package/docs/pages/guest/index.html +115 -0
  94. package/docs/pages/guest.html +59 -0
  95. package/docs/pages/index.html +72 -0
  96. package/docs/pages/integrations/angular.html +5 -0
  97. package/docs/pages/integrations/layout.html +17 -0
  98. package/docs/pages/integrations/react.html +7 -0
  99. package/docs/pages/integrations/vue.html +102 -0
  100. package/docs/pages/patron/index.html +140 -0
  101. package/docs/pages/patron/patron-applied.html +66 -0
  102. package/docs/pages/patron/patron-executor-applied.html +94 -0
  103. package/docs/pages/patron/patron-once.html +110 -0
  104. package/docs/pages/patron/patron-pool.html +99 -0
  105. package/docs/pages/patron.html +50 -0
  106. package/docs/pages/philosofy.html +210 -0
  107. package/docs/pages/source/index.html +167 -0
  108. package/docs/pages/source/source-active.html +113 -0
  109. package/docs/pages/source/source-all.html +129 -0
  110. package/docs/pages/source/source-applied.html +73 -0
  111. package/docs/pages/source/source-dynamic.html +93 -0
  112. package/docs/pages/source/source-executor-applied.html +64 -0
  113. package/docs/pages/source/source-map.html +192 -0
  114. package/docs/pages/source/source-once.html +73 -0
  115. package/docs/pages/source/source-race.html +171 -0
  116. package/docs/pages/source/source-sequence.html +160 -0
  117. package/docs/pages/source/source-with-pool.html +102 -0
  118. package/docs/pages/source/source.html +167 -0
  119. package/docs/pages/source.html +68 -0
  120. package/docs/pages/terminology/guest.html +14 -0
  121. package/docs/pages/terminology/index.html +6 -0
  122. package/docs/pages/terminology/introduction.html +25 -0
  123. package/docs/pages/terminology/patron.html +10 -0
  124. package/docs/pages/terminology/source.html +55 -0
  125. package/docs/pages/terminology/visitor.html +19 -0
  126. package/docs/pages/terminology.html +53 -0
  127. package/docs/pages/utils/give.html +47 -0
  128. package/docs/pages/utils/index.html +24 -0
  129. package/docs/pages/utils/is-guest-aware.html +22 -0
  130. package/docs/pages/utils/is-guest.html +21 -0
  131. package/docs/pages/utils/is-patron-in-pools.html +53 -0
  132. package/docs/pages/utils/private.html +44 -0
  133. package/docs/pages/utils/remove-patron-from-pools.html +57 -0
  134. package/docs/pages/utils/value.html +47 -0
  135. package/docs/pages/utils.html +61 -0
  136. package/eslint.config.mjs +6 -0
  137. package/package.json +1 -1
  138. package/src/Guest/Guest.test.ts +11 -6
  139. package/src/Guest/Guest.ts +7 -14
  140. package/src/Guest/GuestApplied.test.ts +13 -0
  141. package/src/Guest/GuestApplied.ts +16 -0
  142. package/src/Guest/GuestCast.test.ts +4 -5
  143. package/src/Guest/GuestCast.ts +3 -10
  144. package/src/Guest/GuestDisposable.test.ts +13 -17
  145. package/src/Guest/GuestDisposable.ts +3 -3
  146. package/src/Guest/GuestExecutorApplied.test.ts +27 -0
  147. package/src/Guest/GuestExecutorApplied.ts +23 -0
  148. package/src/Guest/GuestObject.test.ts +6 -6
  149. package/src/Guest/GuestObject.ts +3 -3
  150. package/src/Guest/GuestPool.test.ts +5 -22
  151. package/src/Guest/GuestPool.ts +7 -8
  152. package/src/Guest/GuestSync.test.ts +2 -2
  153. package/src/Patron/Patron.test.ts +4 -5
  154. package/src/Patron/Patron.ts +11 -3
  155. package/src/Patron/PatronApplied.ts +22 -0
  156. package/src/Patron/PatronExecutorApplied.ts +25 -0
  157. package/src/Patron/PatronOnce.sourceEmpty.test.ts +2 -2
  158. package/src/Patron/PatronOnce.test.ts +2 -2
  159. package/src/Patron/PatronOnce.ts +3 -9
  160. package/src/Patron/PatronPool.test.ts +2 -1
  161. package/src/Patron/PatronPool.ts +22 -27
  162. package/src/Private/PrivateClass.modules.test.ts +11 -8
  163. package/src/Private/PrivateClass.test.ts +7 -6
  164. package/src/Source/Source.test.ts +9 -5
  165. package/src/Source/Source.ts +46 -30
  166. package/src/Source/SourceActive.test.ts +13 -0
  167. package/src/Source/SourceActive.ts +41 -0
  168. package/src/Source/SourceAll._asArray.test.ts +22 -0
  169. package/src/Source/SourceAll._twoValuesAfter.test.ts +19 -0
  170. package/src/Source/SourceAll._twoValuesBefore.test.ts +19 -0
  171. package/src/Source/SourceAll._withPatron.test.ts +25 -0
  172. package/src/{Guest/GuestAwareAll.ts → Source/SourceAll.ts} +11 -11
  173. package/src/Source/SourceApplied.test.ts +14 -0
  174. package/src/Source/SourceApplied.ts +23 -0
  175. package/src/Source/SourceDynamic.ofSource.test.ts +12 -12
  176. package/src/Source/SourceDynamic.test.ts +9 -9
  177. package/src/Source/SourceDynamic.ts +7 -7
  178. package/src/Source/SourceExecutorApplied.test.ts +30 -0
  179. package/src/Source/SourceExecutorApplied.ts +22 -0
  180. package/src/Source/SourceMap.defered.test.ts +46 -0
  181. package/src/Source/SourceMap.fn.test.ts +27 -0
  182. package/src/Source/SourceMap.test.ts +32 -0
  183. package/src/Source/SourceMap.ts +48 -0
  184. package/src/Source/SourceOnce.notcalled.test.ts +4 -4
  185. package/src/Source/SourceOnce.test.ts +4 -5
  186. package/src/Source/SourceOnce.ts +7 -13
  187. package/src/Source/SourceRace.test.ts +46 -0
  188. package/src/Source/SourceRace.ts +30 -0
  189. package/src/Source/SourceSequence.defered.test.ts +53 -0
  190. package/src/Source/SourceSequence.test.ts +30 -0
  191. package/src/{Guest/GuestAwareSequence.ts → Source/SourceSequence.ts} +14 -19
  192. package/src/Source/SourceWithPool.empty.test.ts +14 -0
  193. package/src/Source/SourceWithPool.test.ts +10 -0
  194. package/src/Source/SourceWithPool.ts +58 -0
  195. package/src/index.ts +13 -7
  196. package/test-utils/debounce.ts +11 -0
  197. package/test-utils/id.ts +1 -0
  198. package/test-utils/wait.ts +6 -3
  199. package/src/Guest/GuestAware.test.ts +0 -13
  200. package/src/Guest/GuestAware.ts +0 -59
  201. package/src/Guest/GuestAwareActive.test.ts +0 -12
  202. package/src/Guest/GuestAwareActive.ts +0 -42
  203. package/src/Guest/GuestAwareAll._asArray.test.ts +0 -19
  204. package/src/Guest/GuestAwareAll._twoValuesAfter.test.ts +0 -16
  205. package/src/Guest/GuestAwareAll._twoValuesBefore.test.ts +0 -16
  206. package/src/Guest/GuestAwareAll._withPatron.test.ts +0 -22
  207. package/src/Guest/GuestAwareMap.defered.test.ts +0 -46
  208. package/src/Guest/GuestAwareMap.fn.test.ts +0 -27
  209. package/src/Guest/GuestAwareMap.test.ts +0 -29
  210. package/src/Guest/GuestAwareMap.ts +0 -48
  211. package/src/Guest/GuestAwareRace.test.ts +0 -46
  212. package/src/Guest/GuestAwareRace.ts +0 -33
  213. package/src/Guest/GuestAwareSequence.defered.test.ts +0 -58
  214. package/src/Guest/GuestAwareSequence.test.ts +0 -30
  215. package/src/Source/SourceEmpty.test.ts +0 -20
  216. package/src/Source/SourceEmpty.ts +0 -31
package/dist/patron.js CHANGED
@@ -1,36 +1,4 @@
1
- function value(guestAware, guest) {
2
- if (guestAware === void 0) {
3
- throw new Error("value didnt receive guestAware argument");
4
- }
5
- if (guest === void 0) {
6
- throw new Error("value didnt receive guest argument");
7
- }
8
- if (typeof guestAware === "function") {
9
- return guestAware(guest);
10
- } else {
11
- return guestAware.value(guest);
12
- }
13
- }
14
- function isGuestAware(mbGuestAware) {
15
- if (mbGuestAware === void 0) {
16
- throw new Error("isGuestAware didnt receive mbGuestAware argument");
17
- }
18
- return typeof mbGuestAware === "function" || typeof mbGuestAware?.value === "function";
19
- }
20
- class GuestAware {
21
- constructor(guestAware) {
22
- this.guestAware = guestAware;
23
- if (guestAware === void 0) {
24
- throw new Error("GuestAware constructor didnt receive executor function");
25
- }
26
- }
27
- value(guest) {
28
- value(this.guestAware, guest);
29
- return guest;
30
- }
31
- }
32
-
33
- function give(data, guest, options) {
1
+ function give(data, guest) {
34
2
  if (data === void 0) {
35
3
  throw new Error("give didnt receive data argument");
36
4
  }
@@ -38,9 +6,9 @@ function give(data, guest, options) {
38
6
  throw new Error("give didnt receive guest argument");
39
7
  }
40
8
  if (typeof guest === "function") {
41
- guest(data, options);
9
+ guest(data);
42
10
  } else {
43
- guest.give(data, options);
11
+ guest.give(data);
44
12
  }
45
13
  }
46
14
  function isGuest(mbGuest) {
@@ -56,40 +24,10 @@ class Guest {
56
24
  throw new Error("reseiver function was not passed to Guest constructor");
57
25
  }
58
26
  }
59
- give(value, options) {
60
- this.receiver(value, options);
61
- return this;
62
- }
63
- }
64
-
65
- var __defProp$6 = Object.defineProperty;
66
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
67
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
68
- class PatronOnce {
69
- constructor(baseGuest) {
70
- this.baseGuest = baseGuest;
71
- __publicField$6(this, "received", false);
72
- if (baseGuest === void 0) {
73
- throw new Error("PatronOnce didnt receive baseGuest argument");
74
- }
75
- }
76
- introduction() {
77
- return "patron";
78
- }
79
- give(value, options) {
80
- if (!this.received) {
81
- this.received = true;
82
- give(value, this.baseGuest, options);
83
- }
27
+ give(value) {
28
+ this.receiver(value);
84
29
  return this;
85
30
  }
86
- disposed(value) {
87
- if (this.received) {
88
- return true;
89
- }
90
- const maybeDisposable = this.baseGuest;
91
- return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
92
- }
93
31
  }
94
32
 
95
33
  class GuestCast {
@@ -112,14 +50,8 @@ class GuestCast {
112
50
  }
113
51
  return this.sourceGuest.introduction();
114
52
  }
115
- give(value, options) {
116
- give(value, this.targetGuest, {
117
- ...options,
118
- data: {
119
- ...options?.data ?? {},
120
- castedGuest: options?.data?.castedGuest ?? this
121
- }
122
- });
53
+ give(value) {
54
+ give(value, this.targetGuest);
123
55
  return this;
124
56
  }
125
57
  disposed(value) {
@@ -128,10 +60,19 @@ class GuestCast {
128
60
  }
129
61
  }
130
62
 
131
- var __defProp$5 = Object.defineProperty;
132
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
133
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
63
+ var __defProp$a = Object.defineProperty;
64
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
65
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
134
66
  const poolSets = /* @__PURE__ */ new Map();
67
+ const patronPools = (patron) => {
68
+ const pools = [];
69
+ poolSets.forEach((pool, poolInstance) => {
70
+ if (pool.has(patron)) {
71
+ pools.push(poolInstance);
72
+ }
73
+ });
74
+ return pools;
75
+ };
135
76
  const removePatronFromPools = (patron) => {
136
77
  if (patron === void 0) {
137
78
  throw new Error("removePatronFromPools didnt receive patron argument");
@@ -155,24 +96,17 @@ const isPatronInPools = (patron) => {
155
96
  class PatronPool {
156
97
  constructor(initiator) {
157
98
  this.initiator = initiator;
158
- __publicField$5(this, "patrons");
159
- __publicField$5(this, "give");
99
+ __publicField$a(this, "patrons");
100
+ __publicField$a(this, "give");
160
101
  this.patrons = /* @__PURE__ */ new Set();
161
102
  poolSets.set(this, this.patrons);
162
- let lastMicrotask = null;
163
- const doReceive = (value, options) => {
103
+ const doReceive = (value) => {
164
104
  this.patrons.forEach((target) => {
165
- this.sendValueToGuest(value, target, options);
105
+ this.sendValueToGuest(value, target);
166
106
  });
167
107
  };
168
- this.give = (value, options) => {
169
- const currentMicroTask = () => {
170
- if (currentMicroTask === lastMicrotask) {
171
- doReceive(value, options);
172
- }
173
- };
174
- lastMicrotask = currentMicroTask;
175
- queueMicrotask(currentMicroTask);
108
+ this.give = (value) => {
109
+ doReceive(value);
176
110
  return this;
177
111
  };
178
112
  }
@@ -194,20 +128,13 @@ class PatronPool {
194
128
  }
195
129
  distribute(receiving, possiblePatron) {
196
130
  this.add(possiblePatron);
197
- this.sendValueToGuest(receiving, possiblePatron, {});
131
+ this.sendValueToGuest(receiving, possiblePatron);
198
132
  return this;
199
133
  }
200
- sendValueToGuest(value, guest, options) {
134
+ sendValueToGuest(value, guest) {
201
135
  const isDisposed = this.guestDisposed(value, guest);
202
136
  if (!isDisposed) {
203
- give(value, guest, {
204
- ...options,
205
- data: {
206
- ...options?.data ?? {},
207
- initiator: this.initiator,
208
- pool: this
209
- }
210
- });
137
+ give(value, guest);
211
138
  }
212
139
  }
213
140
  guestDisposed(value, guest) {
@@ -219,58 +146,61 @@ class PatronPool {
219
146
  }
220
147
  }
221
148
 
222
- var __defProp$4 = Object.defineProperty;
223
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
225
- class Source {
226
- constructor(sourceDocument) {
227
- this.sourceDocument = sourceDocument;
228
- __publicField$4(this, "thePool", new PatronPool(this));
229
- if (sourceDocument === void 0) {
230
- throw new Error("Source didnt receive sourceDocument argument");
231
- }
232
- }
233
- pool() {
234
- return this.thePool;
149
+ var __defProp$9 = Object.defineProperty;
150
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
151
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
152
+ class GuestPool {
153
+ constructor(initiator) {
154
+ __publicField$9(this, "guests", /* @__PURE__ */ new Set());
155
+ __publicField$9(this, "patronPool");
156
+ this.patronPool = new PatronPool(initiator);
235
157
  }
236
158
  give(value) {
237
- this.sourceDocument = value;
238
- this.thePool.give(this.sourceDocument);
159
+ this.deliverToGuests(value);
160
+ this.patronPool.give(value);
239
161
  return this;
240
162
  }
241
- value(guest) {
242
- if (typeof guest === "function") {
243
- this.thePool.distribute(this.sourceDocument, new Guest(guest));
244
- } else {
245
- this.thePool.distribute(this.sourceDocument, guest);
163
+ add(guest) {
164
+ if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
165
+ this.guests.add(guest);
246
166
  }
167
+ this.patronPool.add(guest);
247
168
  return this;
248
169
  }
249
- }
250
-
251
- var __defProp$3 = Object.defineProperty;
252
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
253
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
254
- class SourceEmpty {
255
- constructor() {
256
- __publicField$3(this, "baseSource", new Source(null));
170
+ remove(patron) {
171
+ this.guests.delete(patron);
172
+ this.patronPool.remove(patron);
173
+ return this;
257
174
  }
258
- value(guest) {
259
- this.baseSource.value(
260
- new GuestCast(guest, (value, options) => {
261
- if (value !== null) {
262
- give(value, guest, options);
263
- }
264
- })
265
- );
175
+ distribute(receiving, possiblePatron) {
176
+ this.add(possiblePatron);
177
+ this.give(receiving);
266
178
  return this;
267
179
  }
180
+ size() {
181
+ return this.patronPool.size() + this.guests.size;
182
+ }
183
+ deliverToGuests(value) {
184
+ this.guests.forEach((target) => {
185
+ give(value, target);
186
+ });
187
+ this.guests.clear();
188
+ }
189
+ }
190
+
191
+ class GuestSync {
192
+ constructor(theValue) {
193
+ this.theValue = theValue;
194
+ if (theValue === void 0) {
195
+ throw new Error("GuestSync didnt receive theValue argument");
196
+ }
197
+ }
268
198
  give(value) {
269
- this.baseSource.give(value);
199
+ this.theValue = value;
270
200
  return this;
271
201
  }
272
- pool() {
273
- return this.baseSource.pool();
202
+ value() {
203
+ return this.theValue;
274
204
  }
275
205
  }
276
206
 
@@ -281,12 +211,12 @@ class GuestObject {
281
211
  throw new Error("GuestObject didnt receive baseGuest argument");
282
212
  }
283
213
  }
284
- give(value, options) {
214
+ give(value) {
285
215
  let guest = this.baseGuest;
286
216
  if (typeof guest === "function") {
287
217
  guest = new Guest(guest);
288
218
  }
289
- guest.give(value, options);
219
+ guest.give(value);
290
220
  return this;
291
221
  }
292
222
  introduction() {
@@ -301,58 +231,182 @@ class GuestObject {
301
231
  }
302
232
  }
303
233
 
304
- var __defProp$2 = Object.defineProperty;
305
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
306
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
307
- class GuestPool {
308
- constructor(initiator) {
309
- __publicField$2(this, "guests", /* @__PURE__ */ new Set());
310
- __publicField$2(this, "patronPool");
311
- this.patronPool = new PatronPool(initiator);
234
+ class GuestDisposable {
235
+ constructor(guest, disposeCheck) {
236
+ this.guest = guest;
237
+ this.disposeCheck = disposeCheck;
238
+ if (guest === void 0) {
239
+ throw new Error("GuestDisposable didnt receive guest argument");
240
+ }
241
+ if (disposeCheck === void 0) {
242
+ throw new Error("GuestDisposable didnt receive disposeCheck argument");
243
+ }
312
244
  }
313
- give(value, options) {
314
- this.deliverToGuests(value, options);
315
- this.patronPool.give(value, options);
245
+ disposed(value) {
246
+ return this.disposeCheck(value);
247
+ }
248
+ give(value) {
249
+ give(value, this.guest);
316
250
  return this;
317
251
  }
318
- add(guest) {
319
- if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
320
- this.guests.add(guest);
252
+ }
253
+
254
+ class GuestApplied {
255
+ constructor(baseGuest, applier) {
256
+ this.baseGuest = baseGuest;
257
+ this.applier = applier;
258
+ }
259
+ give(value) {
260
+ give(this.applier(value), this.baseGuest);
261
+ return this;
262
+ }
263
+ }
264
+
265
+ var __defProp$8 = Object.defineProperty;
266
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
267
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
268
+ class GuestExecutorApplied {
269
+ constructor(baseGuest, applier) {
270
+ __publicField$8(this, "give");
271
+ this.give = applier((v) => give(v, baseGuest));
272
+ }
273
+ }
274
+
275
+ class Patron {
276
+ constructor(willBePatron) {
277
+ this.willBePatron = willBePatron;
278
+ if (willBePatron === void 0) {
279
+ throw new Error("Patron didnt receive willBePatron argument");
321
280
  }
322
- this.patronPool.add(guest);
281
+ }
282
+ introduction() {
283
+ return "patron";
284
+ }
285
+ give(value) {
286
+ give(value, this.willBePatron);
323
287
  return this;
324
288
  }
325
- remove(patron) {
326
- this.guests.delete(patron);
327
- this.patronPool.remove(patron);
289
+ disposed(value) {
290
+ const maybeDisposable = this.willBePatron;
291
+ return maybeDisposable?.disposed?.(value) || false;
292
+ }
293
+ }
294
+ const isPatron = (guest) => typeof guest === "object" && guest !== null && guest?.introduction?.() === "patron";
295
+
296
+ var __defProp$7 = Object.defineProperty;
297
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
298
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
299
+ class PatronOnce {
300
+ constructor(baseGuest) {
301
+ this.baseGuest = baseGuest;
302
+ __publicField$7(this, "received", false);
303
+ if (baseGuest === void 0) {
304
+ throw new Error("PatronOnce didnt receive baseGuest argument");
305
+ }
306
+ }
307
+ introduction() {
308
+ return "patron";
309
+ }
310
+ give(value) {
311
+ if (!this.received) {
312
+ this.received = true;
313
+ give(value, this.baseGuest);
314
+ }
328
315
  return this;
329
316
  }
330
- distribute(receiving, possiblePatron) {
331
- this.add(possiblePatron);
332
- this.give(receiving);
317
+ disposed(value) {
318
+ if (this.received) {
319
+ return true;
320
+ }
321
+ const maybeDisposable = this.baseGuest;
322
+ return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
323
+ }
324
+ }
325
+
326
+ var __defProp$6 = Object.defineProperty;
327
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
328
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
329
+ class PatronApplied {
330
+ constructor(baseGuest, applier) {
331
+ __publicField$6(this, "guestApplied");
332
+ this.guestApplied = new GuestApplied(baseGuest, applier);
333
+ }
334
+ give(value) {
335
+ this.guestApplied.give(value);
333
336
  return this;
334
337
  }
335
- size() {
336
- return this.patronPool.size() + this.guests.size;
338
+ introduction() {
339
+ return "patron";
337
340
  }
338
- deliverToGuests(value, options) {
339
- this.guests.forEach((target) => {
340
- give(value, target, options);
341
- });
342
- this.guests.clear();
341
+ }
342
+
343
+ var __defProp$5 = Object.defineProperty;
344
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
345
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, key + "" , value);
346
+ class PatronExecutorApplied {
347
+ constructor(baseGuest, applier) {
348
+ __publicField$5(this, "guestApplied");
349
+ this.guestApplied = new GuestExecutorApplied(baseGuest, applier);
350
+ }
351
+ give(value) {
352
+ this.guestApplied.give(value);
353
+ return this;
354
+ }
355
+ introduction() {
356
+ return "patron";
343
357
  }
344
358
  }
345
359
 
346
- var __defProp$1 = Object.defineProperty;
347
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
348
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
349
- class GuestAwareAll {
360
+ var __defProp$4 = Object.defineProperty;
361
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
362
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
363
+ class SourceWithPool {
364
+ constructor(sourceDocument) {
365
+ this.sourceDocument = sourceDocument;
366
+ __publicField$4(this, "thePool", new PatronPool(this));
367
+ __publicField$4(this, "theEmptyPool", new PatronPool(this));
368
+ __publicField$4(this, "isEmpty");
369
+ this.isEmpty = sourceDocument === void 0;
370
+ }
371
+ pool() {
372
+ return this.thePool;
373
+ }
374
+ give(value) {
375
+ this.isEmpty = false;
376
+ this.sourceDocument = value;
377
+ this.thePool.give(this.sourceDocument);
378
+ this.theEmptyPool.give(this.sourceDocument);
379
+ return this;
380
+ }
381
+ value(guest) {
382
+ if (this.isEmpty) {
383
+ if (isPatron(guest)) {
384
+ this.theEmptyPool.add(guest);
385
+ }
386
+ return this;
387
+ }
388
+ if (typeof guest === "function") {
389
+ this.thePool.distribute(this.sourceDocument, new Guest(guest));
390
+ } else {
391
+ this.thePool.distribute(this.sourceDocument, guest);
392
+ }
393
+ return this;
394
+ }
395
+ filled() {
396
+ return !this.isEmpty;
397
+ }
398
+ }
399
+
400
+ var __defProp$3 = Object.defineProperty;
401
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
402
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
403
+ class SourceAll {
350
404
  constructor(initialKnownKeys = []) {
351
- __publicField$1(this, "theAll");
352
- __publicField$1(this, "keysKnown");
353
- __publicField$1(this, "keysFilled", /* @__PURE__ */ new Set());
354
- __publicField$1(this, "filledAllPool", new GuestPool(this));
355
- this.theAll = new Source({});
405
+ __publicField$3(this, "theAll");
406
+ __publicField$3(this, "keysKnown");
407
+ __publicField$3(this, "keysFilled", /* @__PURE__ */ new Set());
408
+ __publicField$3(this, "filledAllPool", new GuestPool(this));
409
+ this.theAll = new SourceWithPool({});
356
410
  this.keysKnown = new Set(initialKnownKeys);
357
411
  }
358
412
  valueArray(guest) {
@@ -408,20 +462,53 @@ class GuestAwareAll {
408
462
  }
409
463
  }
410
464
 
411
- class GuestAwareSequence {
465
+ function value(source, guest) {
466
+ if (source === void 0) {
467
+ throw new Error("value didnt receive source argument");
468
+ }
469
+ if (guest === void 0) {
470
+ throw new Error("value didnt receive guest argument");
471
+ }
472
+ if (typeof source === "function") {
473
+ return source(guest);
474
+ } else {
475
+ return source.value(guest);
476
+ }
477
+ }
478
+ function isSource(mbSource) {
479
+ if (mbSource === void 0) {
480
+ throw new Error("isSource didnt receive mbSource argument");
481
+ }
482
+ return typeof mbSource === "function" || typeof mbSource?.value === "function";
483
+ }
484
+ class Source {
485
+ constructor(source) {
486
+ this.source = source;
487
+ if (source === void 0) {
488
+ throw new Error("Source constructor didnt receive executor function");
489
+ }
490
+ }
491
+ value(guest) {
492
+ value(this.source, guest);
493
+ return guest;
494
+ }
495
+ }
496
+ const sourceOf = (value2) => new Source((g) => give(value2, g));
497
+
498
+ class SourceSequence {
412
499
  constructor(baseSource, targetSource) {
413
500
  this.baseSource = baseSource;
414
501
  this.targetSource = targetSource;
415
502
  if (baseSource === void 0) {
416
- throw new Error("GuestAwareSequence didnt receive baseSource argument");
503
+ throw new Error("SourceSequence didnt receive baseSource argument");
417
504
  }
418
505
  if (targetSource === void 0) {
419
- throw new Error("GuestAwareSequence didnt receive targetSource argument");
506
+ throw new Error("SourceSequence didnt receive targetSource argument");
420
507
  }
421
508
  }
422
509
  value(guest) {
423
- const all = new GuestAwareAll();
424
- const sequenceSource = new SourceEmpty();
510
+ const all = new SourceAll();
511
+ const sequenceSource = new SourceWithPool();
425
512
  const targetSource = this.targetSource.get(sequenceSource);
426
513
  value(
427
514
  this.baseSource,
@@ -438,7 +525,7 @@ class GuestAwareSequence {
438
525
  function handle() {
439
526
  sequenceSource.give(null);
440
527
  const nextValue = theValue[index];
441
- if (isGuestAware(nextValue)) {
528
+ if (isSource(nextValue)) {
442
529
  value(
443
530
  nextValue,
444
531
  new PatronOnce((theNextValue) => {
@@ -464,24 +551,24 @@ class GuestAwareSequence {
464
551
  }
465
552
  }
466
553
 
467
- class GuestAwareMap {
554
+ class SourceMap {
468
555
  constructor(baseSource, targetSource) {
469
556
  this.baseSource = baseSource;
470
557
  this.targetSource = targetSource;
471
558
  if (baseSource === void 0) {
472
- throw new Error("GuestAwareMap didnt receive baseSource argument");
559
+ throw new Error("SourceMap didnt receive baseSource argument");
473
560
  }
474
561
  if (targetSource === void 0) {
475
- throw new Error("GuestAwareMap didnt receive targetSource argument");
562
+ throw new Error("SourceMap didnt receive targetSource argument");
476
563
  }
477
564
  }
478
565
  value(guest) {
479
- const all = new GuestAwareAll();
566
+ const all = new SourceAll();
480
567
  value(
481
568
  this.baseSource,
482
569
  new GuestCast(guest, (theValue) => {
483
570
  theValue.forEach((val, index) => {
484
- const valueSource = isGuestAware(val) ? val : new GuestAware((innerGuest) => {
571
+ const valueSource = isSource(val) ? val : new Source((innerGuest) => {
485
572
  give(val, innerGuest);
486
573
  });
487
574
  const targetSource = this.targetSource.get(valueSource);
@@ -494,22 +581,22 @@ class GuestAwareMap {
494
581
  }
495
582
  }
496
583
 
497
- class GuestAwareRace {
498
- constructor(guestAwares) {
499
- this.guestAwares = guestAwares;
500
- if (guestAwares === void 0) {
501
- throw new Error("GuestAwareRace didnt receive guestAwares argument");
584
+ class SourceRace {
585
+ constructor(sources) {
586
+ this.sources = sources;
587
+ if (sources === void 0) {
588
+ throw new Error("SourceRace didnt receive sources argument");
502
589
  }
503
590
  }
504
591
  value(guest) {
505
- let connectedWithGuestAware = null;
506
- this.guestAwares.forEach((guestAware) => {
592
+ let connectedWithSource = null;
593
+ this.sources.forEach((source) => {
507
594
  value(
508
- guestAware,
595
+ source,
509
596
  new GuestCast(guest, (value2) => {
510
- if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {
597
+ if (!connectedWithSource || connectedWithSource === source) {
511
598
  give(value2, guest);
512
- connectedWithGuestAware = guestAware;
599
+ connectedWithSource = source;
513
600
  }
514
601
  })
515
602
  );
@@ -518,16 +605,16 @@ class GuestAwareRace {
518
605
  }
519
606
  }
520
607
 
521
- var __defProp = Object.defineProperty;
522
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
523
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
524
- class GuestAwareActive {
608
+ var __defProp$2 = Object.defineProperty;
609
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
610
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
611
+ class SourceActive {
525
612
  constructor(configExecutor) {
526
613
  this.configExecutor = configExecutor;
527
- __publicField(this, "source", new SourceEmpty());
614
+ __publicField$2(this, "source", new SourceWithPool());
528
615
  if (configExecutor === void 0) {
529
616
  throw new Error(
530
- "GuestAwareActive constructor didnt receive executor function"
617
+ "SourceActive constructor didnt receive executor function"
531
618
  );
532
619
  }
533
620
  }
@@ -541,83 +628,78 @@ class GuestAwareActive {
541
628
  }
542
629
  }
543
630
 
544
- class GuestSync {
545
- constructor(theValue) {
546
- this.theValue = theValue;
547
- if (theValue === void 0) {
548
- throw new Error("GuestSync didnt receive theValue argument");
631
+ class SourceDynamic {
632
+ constructor(baseGuest, baseSource) {
633
+ this.baseGuest = baseGuest;
634
+ this.baseSource = baseSource;
635
+ if (baseGuest === void 0) {
636
+ throw new Error("SourceDynamic didnt receive baseGuest argument");
637
+ }
638
+ if (baseSource === void 0) {
639
+ throw new Error("SourceDynamic didnt receive baseSource argument");
549
640
  }
550
641
  }
551
- give(value) {
552
- this.theValue = value;
642
+ value(guest) {
643
+ value(this.baseSource, guest);
553
644
  return this;
554
645
  }
555
- value() {
556
- return this.theValue;
646
+ give(value2) {
647
+ give(value2, this.baseGuest);
648
+ return this;
649
+ }
650
+ pool() {
651
+ throw Error("No pool in SourceDynamic");
557
652
  }
558
653
  }
559
654
 
560
- class GuestDisposable {
561
- constructor(guest, disposeCheck) {
562
- this.guest = guest;
563
- this.disposeCheck = disposeCheck;
564
- if (guest === void 0) {
565
- throw new Error("GuestDisposable didnt receive guest argument");
566
- }
567
- if (disposeCheck === void 0) {
568
- throw new Error("GuestDisposable didnt receive disposeCheck argument");
569
- }
570
- }
571
- disposed(value) {
572
- return this.disposeCheck(value);
655
+ class SourceApplied {
656
+ constructor(baseSource, applier) {
657
+ this.baseSource = baseSource;
658
+ this.applier = applier;
573
659
  }
574
- give(value, options) {
575
- give(value, this.guest, options);
660
+ value(g) {
661
+ value(
662
+ this.baseSource,
663
+ new GuestCast(g, (v) => {
664
+ give(this.applier(v), g);
665
+ })
666
+ );
576
667
  return this;
577
668
  }
578
669
  }
579
670
 
580
- class Patron {
581
- constructor(willBePatron) {
582
- this.willBePatron = willBePatron;
583
- if (willBePatron === void 0) {
584
- throw new Error("Patron didnt receive willBePatron argument");
585
- }
586
- }
587
- introduction() {
588
- return "patron";
589
- }
590
- give(value, options) {
591
- give(value, this.willBePatron, options);
592
- return this;
593
- }
594
- disposed(value) {
595
- const maybeDisposable = this.willBePatron;
596
- return maybeDisposable?.disposed?.(value) || false;
671
+ var __defProp$1 = Object.defineProperty;
672
+ var __defNormalProp$1 = (obj, key, value2) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
673
+ var __publicField$1 = (obj, key, value2) => __defNormalProp$1(obj, key + "" , value2);
674
+ class SourceExecutorApplied {
675
+ constructor(source, applier) {
676
+ __publicField$1(this, "value");
677
+ this.value = applier((g) => {
678
+ value(source, g);
679
+ });
597
680
  }
598
681
  }
599
682
 
600
- class SourceDynamic {
601
- constructor(baseGuest, baseGuestAware) {
602
- this.baseGuest = baseGuest;
603
- this.baseGuestAware = baseGuestAware;
604
- if (baseGuest === void 0) {
605
- throw new Error("SourceDynamic didnt receive baseGuest argument");
606
- }
607
- if (baseGuestAware === void 0) {
608
- throw new Error("SourceDynamic didnt receive baseGuestAware argument");
609
- }
683
+ var __defProp = Object.defineProperty;
684
+ var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
685
+ var __publicField = (obj, key, value2) => __defNormalProp(obj, key + "" , value2);
686
+ class SourceOnce {
687
+ constructor(initialValue) {
688
+ __publicField(this, "source");
689
+ this.source = new SourceWithPool(initialValue);
610
690
  }
611
691
  value(guest) {
612
- value(this.baseGuestAware, guest);
692
+ value(this.source, guest);
613
693
  return this;
614
694
  }
615
695
  give(value2) {
616
- give(value2, this.baseGuest);
696
+ if (!this.source.filled()) {
697
+ this.source.give(value2);
698
+ }
617
699
  return this;
618
700
  }
619
701
  pool() {
620
- throw Error("No pool in SourceDynamic");
702
+ return this.source.pool();
621
703
  }
622
704
  }
623
705
 
@@ -649,5 +731,5 @@ class Private {
649
731
  }
650
732
  }
651
733
 
652
- export { Guest, GuestAware, GuestAwareActive, GuestAwareAll, GuestAwareMap, GuestAwareRace, GuestAwareSequence, GuestCast, GuestDisposable, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Private, PrivateClass, Source, SourceDynamic, SourceEmpty, give, isGuest, isGuestAware, isPatronInPools, removePatronFromPools, value };
734
+ export { Guest, GuestApplied, GuestCast, GuestDisposable, GuestExecutorApplied, GuestObject, GuestPool, GuestSync, Patron, PatronApplied, PatronExecutorApplied, PatronOnce, PatronPool, Private, PrivateClass, Source, SourceActive, SourceAll, SourceApplied, SourceDynamic, SourceExecutorApplied, SourceMap, SourceOnce, SourceRace, SourceSequence, SourceWithPool, give, isGuest, isPatron, isPatronInPools, isSource, patronPools, removePatronFromPools, sourceOf, value };
653
735
  //# sourceMappingURL=patron.js.map