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.cjs CHANGED
@@ -1,38 +1,6 @@
1
1
  'use strict';
2
2
 
3
- function value(guestAware, guest) {
4
- if (guestAware === void 0) {
5
- throw new Error("value didnt receive guestAware argument");
6
- }
7
- if (guest === void 0) {
8
- throw new Error("value didnt receive guest argument");
9
- }
10
- if (typeof guestAware === "function") {
11
- return guestAware(guest);
12
- } else {
13
- return guestAware.value(guest);
14
- }
15
- }
16
- function isGuestAware(mbGuestAware) {
17
- if (mbGuestAware === void 0) {
18
- throw new Error("isGuestAware didnt receive mbGuestAware argument");
19
- }
20
- return typeof mbGuestAware === "function" || typeof mbGuestAware?.value === "function";
21
- }
22
- class GuestAware {
23
- constructor(guestAware) {
24
- this.guestAware = guestAware;
25
- if (guestAware === void 0) {
26
- throw new Error("GuestAware constructor didnt receive executor function");
27
- }
28
- }
29
- value(guest) {
30
- value(this.guestAware, guest);
31
- return guest;
32
- }
33
- }
34
-
35
- function give(data, guest, options) {
3
+ function give(data, guest) {
36
4
  if (data === void 0) {
37
5
  throw new Error("give didnt receive data argument");
38
6
  }
@@ -40,9 +8,9 @@ function give(data, guest, options) {
40
8
  throw new Error("give didnt receive guest argument");
41
9
  }
42
10
  if (typeof guest === "function") {
43
- guest(data, options);
11
+ guest(data);
44
12
  } else {
45
- guest.give(data, options);
13
+ guest.give(data);
46
14
  }
47
15
  }
48
16
  function isGuest(mbGuest) {
@@ -58,40 +26,10 @@ class Guest {
58
26
  throw new Error("reseiver function was not passed to Guest constructor");
59
27
  }
60
28
  }
61
- give(value, options) {
62
- this.receiver(value, options);
63
- return this;
64
- }
65
- }
66
-
67
- var __defProp$6 = Object.defineProperty;
68
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
70
- class PatronOnce {
71
- constructor(baseGuest) {
72
- this.baseGuest = baseGuest;
73
- __publicField$6(this, "received", false);
74
- if (baseGuest === void 0) {
75
- throw new Error("PatronOnce didnt receive baseGuest argument");
76
- }
77
- }
78
- introduction() {
79
- return "patron";
80
- }
81
- give(value, options) {
82
- if (!this.received) {
83
- this.received = true;
84
- give(value, this.baseGuest, options);
85
- }
29
+ give(value) {
30
+ this.receiver(value);
86
31
  return this;
87
32
  }
88
- disposed(value) {
89
- if (this.received) {
90
- return true;
91
- }
92
- const maybeDisposable = this.baseGuest;
93
- return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
94
- }
95
33
  }
96
34
 
97
35
  class GuestCast {
@@ -114,14 +52,8 @@ class GuestCast {
114
52
  }
115
53
  return this.sourceGuest.introduction();
116
54
  }
117
- give(value, options) {
118
- give(value, this.targetGuest, {
119
- ...options,
120
- data: {
121
- ...options?.data ?? {},
122
- castedGuest: options?.data?.castedGuest ?? this
123
- }
124
- });
55
+ give(value) {
56
+ give(value, this.targetGuest);
125
57
  return this;
126
58
  }
127
59
  disposed(value) {
@@ -130,10 +62,19 @@ class GuestCast {
130
62
  }
131
63
  }
132
64
 
133
- var __defProp$5 = Object.defineProperty;
134
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
135
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
65
+ var __defProp$a = Object.defineProperty;
66
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
67
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
136
68
  const poolSets = /* @__PURE__ */ new Map();
69
+ const patronPools = (patron) => {
70
+ const pools = [];
71
+ poolSets.forEach((pool, poolInstance) => {
72
+ if (pool.has(patron)) {
73
+ pools.push(poolInstance);
74
+ }
75
+ });
76
+ return pools;
77
+ };
137
78
  const removePatronFromPools = (patron) => {
138
79
  if (patron === void 0) {
139
80
  throw new Error("removePatronFromPools didnt receive patron argument");
@@ -157,24 +98,17 @@ const isPatronInPools = (patron) => {
157
98
  class PatronPool {
158
99
  constructor(initiator) {
159
100
  this.initiator = initiator;
160
- __publicField$5(this, "patrons");
161
- __publicField$5(this, "give");
101
+ __publicField$a(this, "patrons");
102
+ __publicField$a(this, "give");
162
103
  this.patrons = /* @__PURE__ */ new Set();
163
104
  poolSets.set(this, this.patrons);
164
- let lastMicrotask = null;
165
- const doReceive = (value, options) => {
105
+ const doReceive = (value) => {
166
106
  this.patrons.forEach((target) => {
167
- this.sendValueToGuest(value, target, options);
107
+ this.sendValueToGuest(value, target);
168
108
  });
169
109
  };
170
- this.give = (value, options) => {
171
- const currentMicroTask = () => {
172
- if (currentMicroTask === lastMicrotask) {
173
- doReceive(value, options);
174
- }
175
- };
176
- lastMicrotask = currentMicroTask;
177
- queueMicrotask(currentMicroTask);
110
+ this.give = (value) => {
111
+ doReceive(value);
178
112
  return this;
179
113
  };
180
114
  }
@@ -196,20 +130,13 @@ class PatronPool {
196
130
  }
197
131
  distribute(receiving, possiblePatron) {
198
132
  this.add(possiblePatron);
199
- this.sendValueToGuest(receiving, possiblePatron, {});
133
+ this.sendValueToGuest(receiving, possiblePatron);
200
134
  return this;
201
135
  }
202
- sendValueToGuest(value, guest, options) {
136
+ sendValueToGuest(value, guest) {
203
137
  const isDisposed = this.guestDisposed(value, guest);
204
138
  if (!isDisposed) {
205
- give(value, guest, {
206
- ...options,
207
- data: {
208
- ...options?.data ?? {},
209
- initiator: this.initiator,
210
- pool: this
211
- }
212
- });
139
+ give(value, guest);
213
140
  }
214
141
  }
215
142
  guestDisposed(value, guest) {
@@ -221,58 +148,61 @@ class PatronPool {
221
148
  }
222
149
  }
223
150
 
224
- var __defProp$4 = Object.defineProperty;
225
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
227
- class Source {
228
- constructor(sourceDocument) {
229
- this.sourceDocument = sourceDocument;
230
- __publicField$4(this, "thePool", new PatronPool(this));
231
- if (sourceDocument === void 0) {
232
- throw new Error("Source didnt receive sourceDocument argument");
233
- }
234
- }
235
- pool() {
236
- return this.thePool;
151
+ var __defProp$9 = Object.defineProperty;
152
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
153
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
154
+ class GuestPool {
155
+ constructor(initiator) {
156
+ __publicField$9(this, "guests", /* @__PURE__ */ new Set());
157
+ __publicField$9(this, "patronPool");
158
+ this.patronPool = new PatronPool(initiator);
237
159
  }
238
160
  give(value) {
239
- this.sourceDocument = value;
240
- this.thePool.give(this.sourceDocument);
161
+ this.deliverToGuests(value);
162
+ this.patronPool.give(value);
241
163
  return this;
242
164
  }
243
- value(guest) {
244
- if (typeof guest === "function") {
245
- this.thePool.distribute(this.sourceDocument, new Guest(guest));
246
- } else {
247
- this.thePool.distribute(this.sourceDocument, guest);
165
+ add(guest) {
166
+ if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
167
+ this.guests.add(guest);
248
168
  }
169
+ this.patronPool.add(guest);
249
170
  return this;
250
171
  }
251
- }
252
-
253
- var __defProp$3 = Object.defineProperty;
254
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
255
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
256
- class SourceEmpty {
257
- constructor() {
258
- __publicField$3(this, "baseSource", new Source(null));
172
+ remove(patron) {
173
+ this.guests.delete(patron);
174
+ this.patronPool.remove(patron);
175
+ return this;
259
176
  }
260
- value(guest) {
261
- this.baseSource.value(
262
- new GuestCast(guest, (value, options) => {
263
- if (value !== null) {
264
- give(value, guest, options);
265
- }
266
- })
267
- );
177
+ distribute(receiving, possiblePatron) {
178
+ this.add(possiblePatron);
179
+ this.give(receiving);
268
180
  return this;
269
181
  }
182
+ size() {
183
+ return this.patronPool.size() + this.guests.size;
184
+ }
185
+ deliverToGuests(value) {
186
+ this.guests.forEach((target) => {
187
+ give(value, target);
188
+ });
189
+ this.guests.clear();
190
+ }
191
+ }
192
+
193
+ class GuestSync {
194
+ constructor(theValue) {
195
+ this.theValue = theValue;
196
+ if (theValue === void 0) {
197
+ throw new Error("GuestSync didnt receive theValue argument");
198
+ }
199
+ }
270
200
  give(value) {
271
- this.baseSource.give(value);
201
+ this.theValue = value;
272
202
  return this;
273
203
  }
274
- pool() {
275
- return this.baseSource.pool();
204
+ value() {
205
+ return this.theValue;
276
206
  }
277
207
  }
278
208
 
@@ -283,12 +213,12 @@ class GuestObject {
283
213
  throw new Error("GuestObject didnt receive baseGuest argument");
284
214
  }
285
215
  }
286
- give(value, options) {
216
+ give(value) {
287
217
  let guest = this.baseGuest;
288
218
  if (typeof guest === "function") {
289
219
  guest = new Guest(guest);
290
220
  }
291
- guest.give(value, options);
221
+ guest.give(value);
292
222
  return this;
293
223
  }
294
224
  introduction() {
@@ -303,58 +233,182 @@ class GuestObject {
303
233
  }
304
234
  }
305
235
 
306
- var __defProp$2 = Object.defineProperty;
307
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
308
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
309
- class GuestPool {
310
- constructor(initiator) {
311
- __publicField$2(this, "guests", /* @__PURE__ */ new Set());
312
- __publicField$2(this, "patronPool");
313
- this.patronPool = new PatronPool(initiator);
236
+ class GuestDisposable {
237
+ constructor(guest, disposeCheck) {
238
+ this.guest = guest;
239
+ this.disposeCheck = disposeCheck;
240
+ if (guest === void 0) {
241
+ throw new Error("GuestDisposable didnt receive guest argument");
242
+ }
243
+ if (disposeCheck === void 0) {
244
+ throw new Error("GuestDisposable didnt receive disposeCheck argument");
245
+ }
314
246
  }
315
- give(value, options) {
316
- this.deliverToGuests(value, options);
317
- this.patronPool.give(value, options);
247
+ disposed(value) {
248
+ return this.disposeCheck(value);
249
+ }
250
+ give(value) {
251
+ give(value, this.guest);
318
252
  return this;
319
253
  }
320
- add(guest) {
321
- if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
322
- this.guests.add(guest);
254
+ }
255
+
256
+ class GuestApplied {
257
+ constructor(baseGuest, applier) {
258
+ this.baseGuest = baseGuest;
259
+ this.applier = applier;
260
+ }
261
+ give(value) {
262
+ give(this.applier(value), this.baseGuest);
263
+ return this;
264
+ }
265
+ }
266
+
267
+ var __defProp$8 = Object.defineProperty;
268
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
269
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
270
+ class GuestExecutorApplied {
271
+ constructor(baseGuest, applier) {
272
+ __publicField$8(this, "give");
273
+ this.give = applier((v) => give(v, baseGuest));
274
+ }
275
+ }
276
+
277
+ class Patron {
278
+ constructor(willBePatron) {
279
+ this.willBePatron = willBePatron;
280
+ if (willBePatron === void 0) {
281
+ throw new Error("Patron didnt receive willBePatron argument");
323
282
  }
324
- this.patronPool.add(guest);
283
+ }
284
+ introduction() {
285
+ return "patron";
286
+ }
287
+ give(value) {
288
+ give(value, this.willBePatron);
325
289
  return this;
326
290
  }
327
- remove(patron) {
328
- this.guests.delete(patron);
329
- this.patronPool.remove(patron);
291
+ disposed(value) {
292
+ const maybeDisposable = this.willBePatron;
293
+ return maybeDisposable?.disposed?.(value) || false;
294
+ }
295
+ }
296
+ const isPatron = (guest) => typeof guest === "object" && guest !== null && guest?.introduction?.() === "patron";
297
+
298
+ var __defProp$7 = Object.defineProperty;
299
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
300
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
301
+ class PatronOnce {
302
+ constructor(baseGuest) {
303
+ this.baseGuest = baseGuest;
304
+ __publicField$7(this, "received", false);
305
+ if (baseGuest === void 0) {
306
+ throw new Error("PatronOnce didnt receive baseGuest argument");
307
+ }
308
+ }
309
+ introduction() {
310
+ return "patron";
311
+ }
312
+ give(value) {
313
+ if (!this.received) {
314
+ this.received = true;
315
+ give(value, this.baseGuest);
316
+ }
330
317
  return this;
331
318
  }
332
- distribute(receiving, possiblePatron) {
333
- this.add(possiblePatron);
334
- this.give(receiving);
319
+ disposed(value) {
320
+ if (this.received) {
321
+ return true;
322
+ }
323
+ const maybeDisposable = this.baseGuest;
324
+ return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
325
+ }
326
+ }
327
+
328
+ var __defProp$6 = Object.defineProperty;
329
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
330
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
331
+ class PatronApplied {
332
+ constructor(baseGuest, applier) {
333
+ __publicField$6(this, "guestApplied");
334
+ this.guestApplied = new GuestApplied(baseGuest, applier);
335
+ }
336
+ give(value) {
337
+ this.guestApplied.give(value);
335
338
  return this;
336
339
  }
337
- size() {
338
- return this.patronPool.size() + this.guests.size;
340
+ introduction() {
341
+ return "patron";
339
342
  }
340
- deliverToGuests(value, options) {
341
- this.guests.forEach((target) => {
342
- give(value, target, options);
343
- });
344
- this.guests.clear();
343
+ }
344
+
345
+ var __defProp$5 = Object.defineProperty;
346
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
347
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, key + "" , value);
348
+ class PatronExecutorApplied {
349
+ constructor(baseGuest, applier) {
350
+ __publicField$5(this, "guestApplied");
351
+ this.guestApplied = new GuestExecutorApplied(baseGuest, applier);
352
+ }
353
+ give(value) {
354
+ this.guestApplied.give(value);
355
+ return this;
356
+ }
357
+ introduction() {
358
+ return "patron";
345
359
  }
346
360
  }
347
361
 
348
- var __defProp$1 = Object.defineProperty;
349
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
350
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
351
- class GuestAwareAll {
362
+ var __defProp$4 = Object.defineProperty;
363
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
364
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
365
+ class SourceWithPool {
366
+ constructor(sourceDocument) {
367
+ this.sourceDocument = sourceDocument;
368
+ __publicField$4(this, "thePool", new PatronPool(this));
369
+ __publicField$4(this, "theEmptyPool", new PatronPool(this));
370
+ __publicField$4(this, "isEmpty");
371
+ this.isEmpty = sourceDocument === void 0;
372
+ }
373
+ pool() {
374
+ return this.thePool;
375
+ }
376
+ give(value) {
377
+ this.isEmpty = false;
378
+ this.sourceDocument = value;
379
+ this.thePool.give(this.sourceDocument);
380
+ this.theEmptyPool.give(this.sourceDocument);
381
+ return this;
382
+ }
383
+ value(guest) {
384
+ if (this.isEmpty) {
385
+ if (isPatron(guest)) {
386
+ this.theEmptyPool.add(guest);
387
+ }
388
+ return this;
389
+ }
390
+ if (typeof guest === "function") {
391
+ this.thePool.distribute(this.sourceDocument, new Guest(guest));
392
+ } else {
393
+ this.thePool.distribute(this.sourceDocument, guest);
394
+ }
395
+ return this;
396
+ }
397
+ filled() {
398
+ return !this.isEmpty;
399
+ }
400
+ }
401
+
402
+ var __defProp$3 = Object.defineProperty;
403
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
404
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
405
+ class SourceAll {
352
406
  constructor(initialKnownKeys = []) {
353
- __publicField$1(this, "theAll");
354
- __publicField$1(this, "keysKnown");
355
- __publicField$1(this, "keysFilled", /* @__PURE__ */ new Set());
356
- __publicField$1(this, "filledAllPool", new GuestPool(this));
357
- this.theAll = new Source({});
407
+ __publicField$3(this, "theAll");
408
+ __publicField$3(this, "keysKnown");
409
+ __publicField$3(this, "keysFilled", /* @__PURE__ */ new Set());
410
+ __publicField$3(this, "filledAllPool", new GuestPool(this));
411
+ this.theAll = new SourceWithPool({});
358
412
  this.keysKnown = new Set(initialKnownKeys);
359
413
  }
360
414
  valueArray(guest) {
@@ -410,20 +464,53 @@ class GuestAwareAll {
410
464
  }
411
465
  }
412
466
 
413
- class GuestAwareSequence {
467
+ function value(source, guest) {
468
+ if (source === void 0) {
469
+ throw new Error("value didnt receive source argument");
470
+ }
471
+ if (guest === void 0) {
472
+ throw new Error("value didnt receive guest argument");
473
+ }
474
+ if (typeof source === "function") {
475
+ return source(guest);
476
+ } else {
477
+ return source.value(guest);
478
+ }
479
+ }
480
+ function isSource(mbSource) {
481
+ if (mbSource === void 0) {
482
+ throw new Error("isSource didnt receive mbSource argument");
483
+ }
484
+ return typeof mbSource === "function" || typeof mbSource?.value === "function";
485
+ }
486
+ class Source {
487
+ constructor(source) {
488
+ this.source = source;
489
+ if (source === void 0) {
490
+ throw new Error("Source constructor didnt receive executor function");
491
+ }
492
+ }
493
+ value(guest) {
494
+ value(this.source, guest);
495
+ return guest;
496
+ }
497
+ }
498
+ const sourceOf = (value2) => new Source((g) => give(value2, g));
499
+
500
+ class SourceSequence {
414
501
  constructor(baseSource, targetSource) {
415
502
  this.baseSource = baseSource;
416
503
  this.targetSource = targetSource;
417
504
  if (baseSource === void 0) {
418
- throw new Error("GuestAwareSequence didnt receive baseSource argument");
505
+ throw new Error("SourceSequence didnt receive baseSource argument");
419
506
  }
420
507
  if (targetSource === void 0) {
421
- throw new Error("GuestAwareSequence didnt receive targetSource argument");
508
+ throw new Error("SourceSequence didnt receive targetSource argument");
422
509
  }
423
510
  }
424
511
  value(guest) {
425
- const all = new GuestAwareAll();
426
- const sequenceSource = new SourceEmpty();
512
+ const all = new SourceAll();
513
+ const sequenceSource = new SourceWithPool();
427
514
  const targetSource = this.targetSource.get(sequenceSource);
428
515
  value(
429
516
  this.baseSource,
@@ -440,7 +527,7 @@ class GuestAwareSequence {
440
527
  function handle() {
441
528
  sequenceSource.give(null);
442
529
  const nextValue = theValue[index];
443
- if (isGuestAware(nextValue)) {
530
+ if (isSource(nextValue)) {
444
531
  value(
445
532
  nextValue,
446
533
  new PatronOnce((theNextValue) => {
@@ -466,24 +553,24 @@ class GuestAwareSequence {
466
553
  }
467
554
  }
468
555
 
469
- class GuestAwareMap {
556
+ class SourceMap {
470
557
  constructor(baseSource, targetSource) {
471
558
  this.baseSource = baseSource;
472
559
  this.targetSource = targetSource;
473
560
  if (baseSource === void 0) {
474
- throw new Error("GuestAwareMap didnt receive baseSource argument");
561
+ throw new Error("SourceMap didnt receive baseSource argument");
475
562
  }
476
563
  if (targetSource === void 0) {
477
- throw new Error("GuestAwareMap didnt receive targetSource argument");
564
+ throw new Error("SourceMap didnt receive targetSource argument");
478
565
  }
479
566
  }
480
567
  value(guest) {
481
- const all = new GuestAwareAll();
568
+ const all = new SourceAll();
482
569
  value(
483
570
  this.baseSource,
484
571
  new GuestCast(guest, (theValue) => {
485
572
  theValue.forEach((val, index) => {
486
- const valueSource = isGuestAware(val) ? val : new GuestAware((innerGuest) => {
573
+ const valueSource = isSource(val) ? val : new Source((innerGuest) => {
487
574
  give(val, innerGuest);
488
575
  });
489
576
  const targetSource = this.targetSource.get(valueSource);
@@ -496,22 +583,22 @@ class GuestAwareMap {
496
583
  }
497
584
  }
498
585
 
499
- class GuestAwareRace {
500
- constructor(guestAwares) {
501
- this.guestAwares = guestAwares;
502
- if (guestAwares === void 0) {
503
- throw new Error("GuestAwareRace didnt receive guestAwares argument");
586
+ class SourceRace {
587
+ constructor(sources) {
588
+ this.sources = sources;
589
+ if (sources === void 0) {
590
+ throw new Error("SourceRace didnt receive sources argument");
504
591
  }
505
592
  }
506
593
  value(guest) {
507
- let connectedWithGuestAware = null;
508
- this.guestAwares.forEach((guestAware) => {
594
+ let connectedWithSource = null;
595
+ this.sources.forEach((source) => {
509
596
  value(
510
- guestAware,
597
+ source,
511
598
  new GuestCast(guest, (value2) => {
512
- if (!connectedWithGuestAware || connectedWithGuestAware === guestAware) {
599
+ if (!connectedWithSource || connectedWithSource === source) {
513
600
  give(value2, guest);
514
- connectedWithGuestAware = guestAware;
601
+ connectedWithSource = source;
515
602
  }
516
603
  })
517
604
  );
@@ -520,16 +607,16 @@ class GuestAwareRace {
520
607
  }
521
608
  }
522
609
 
523
- var __defProp = Object.defineProperty;
524
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
525
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
526
- class GuestAwareActive {
610
+ var __defProp$2 = Object.defineProperty;
611
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
612
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
613
+ class SourceActive {
527
614
  constructor(configExecutor) {
528
615
  this.configExecutor = configExecutor;
529
- __publicField(this, "source", new SourceEmpty());
616
+ __publicField$2(this, "source", new SourceWithPool());
530
617
  if (configExecutor === void 0) {
531
618
  throw new Error(
532
- "GuestAwareActive constructor didnt receive executor function"
619
+ "SourceActive constructor didnt receive executor function"
533
620
  );
534
621
  }
535
622
  }
@@ -543,83 +630,78 @@ class GuestAwareActive {
543
630
  }
544
631
  }
545
632
 
546
- class GuestSync {
547
- constructor(theValue) {
548
- this.theValue = theValue;
549
- if (theValue === void 0) {
550
- throw new Error("GuestSync didnt receive theValue argument");
633
+ class SourceDynamic {
634
+ constructor(baseGuest, baseSource) {
635
+ this.baseGuest = baseGuest;
636
+ this.baseSource = baseSource;
637
+ if (baseGuest === void 0) {
638
+ throw new Error("SourceDynamic didnt receive baseGuest argument");
639
+ }
640
+ if (baseSource === void 0) {
641
+ throw new Error("SourceDynamic didnt receive baseSource argument");
551
642
  }
552
643
  }
553
- give(value) {
554
- this.theValue = value;
644
+ value(guest) {
645
+ value(this.baseSource, guest);
555
646
  return this;
556
647
  }
557
- value() {
558
- return this.theValue;
648
+ give(value2) {
649
+ give(value2, this.baseGuest);
650
+ return this;
651
+ }
652
+ pool() {
653
+ throw Error("No pool in SourceDynamic");
559
654
  }
560
655
  }
561
656
 
562
- class GuestDisposable {
563
- constructor(guest, disposeCheck) {
564
- this.guest = guest;
565
- this.disposeCheck = disposeCheck;
566
- if (guest === void 0) {
567
- throw new Error("GuestDisposable didnt receive guest argument");
568
- }
569
- if (disposeCheck === void 0) {
570
- throw new Error("GuestDisposable didnt receive disposeCheck argument");
571
- }
572
- }
573
- disposed(value) {
574
- return this.disposeCheck(value);
657
+ class SourceApplied {
658
+ constructor(baseSource, applier) {
659
+ this.baseSource = baseSource;
660
+ this.applier = applier;
575
661
  }
576
- give(value, options) {
577
- give(value, this.guest, options);
662
+ value(g) {
663
+ value(
664
+ this.baseSource,
665
+ new GuestCast(g, (v) => {
666
+ give(this.applier(v), g);
667
+ })
668
+ );
578
669
  return this;
579
670
  }
580
671
  }
581
672
 
582
- class Patron {
583
- constructor(willBePatron) {
584
- this.willBePatron = willBePatron;
585
- if (willBePatron === void 0) {
586
- throw new Error("Patron didnt receive willBePatron argument");
587
- }
588
- }
589
- introduction() {
590
- return "patron";
591
- }
592
- give(value, options) {
593
- give(value, this.willBePatron, options);
594
- return this;
595
- }
596
- disposed(value) {
597
- const maybeDisposable = this.willBePatron;
598
- return maybeDisposable?.disposed?.(value) || false;
673
+ var __defProp$1 = Object.defineProperty;
674
+ var __defNormalProp$1 = (obj, key, value2) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
675
+ var __publicField$1 = (obj, key, value2) => __defNormalProp$1(obj, key + "" , value2);
676
+ class SourceExecutorApplied {
677
+ constructor(source, applier) {
678
+ __publicField$1(this, "value");
679
+ this.value = applier((g) => {
680
+ value(source, g);
681
+ });
599
682
  }
600
683
  }
601
684
 
602
- class SourceDynamic {
603
- constructor(baseGuest, baseGuestAware) {
604
- this.baseGuest = baseGuest;
605
- this.baseGuestAware = baseGuestAware;
606
- if (baseGuest === void 0) {
607
- throw new Error("SourceDynamic didnt receive baseGuest argument");
608
- }
609
- if (baseGuestAware === void 0) {
610
- throw new Error("SourceDynamic didnt receive baseGuestAware argument");
611
- }
685
+ var __defProp = Object.defineProperty;
686
+ var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
687
+ var __publicField = (obj, key, value2) => __defNormalProp(obj, key + "" , value2);
688
+ class SourceOnce {
689
+ constructor(initialValue) {
690
+ __publicField(this, "source");
691
+ this.source = new SourceWithPool(initialValue);
612
692
  }
613
693
  value(guest) {
614
- value(this.baseGuestAware, guest);
694
+ value(this.source, guest);
615
695
  return this;
616
696
  }
617
697
  give(value2) {
618
- give(value2, this.baseGuest);
698
+ if (!this.source.filled()) {
699
+ this.source.give(value2);
700
+ }
619
701
  return this;
620
702
  }
621
703
  pool() {
622
- throw Error("No pool in SourceDynamic");
704
+ return this.source.pool();
623
705
  }
624
706
  }
625
707
 
@@ -652,29 +734,38 @@ class Private {
652
734
  }
653
735
 
654
736
  exports.Guest = Guest;
655
- exports.GuestAware = GuestAware;
656
- exports.GuestAwareActive = GuestAwareActive;
657
- exports.GuestAwareAll = GuestAwareAll;
658
- exports.GuestAwareMap = GuestAwareMap;
659
- exports.GuestAwareRace = GuestAwareRace;
660
- exports.GuestAwareSequence = GuestAwareSequence;
737
+ exports.GuestApplied = GuestApplied;
661
738
  exports.GuestCast = GuestCast;
662
739
  exports.GuestDisposable = GuestDisposable;
740
+ exports.GuestExecutorApplied = GuestExecutorApplied;
663
741
  exports.GuestObject = GuestObject;
664
742
  exports.GuestPool = GuestPool;
665
743
  exports.GuestSync = GuestSync;
666
744
  exports.Patron = Patron;
745
+ exports.PatronApplied = PatronApplied;
746
+ exports.PatronExecutorApplied = PatronExecutorApplied;
667
747
  exports.PatronOnce = PatronOnce;
668
748
  exports.PatronPool = PatronPool;
669
749
  exports.Private = Private;
670
750
  exports.PrivateClass = PrivateClass;
671
751
  exports.Source = Source;
752
+ exports.SourceActive = SourceActive;
753
+ exports.SourceAll = SourceAll;
754
+ exports.SourceApplied = SourceApplied;
672
755
  exports.SourceDynamic = SourceDynamic;
673
- exports.SourceEmpty = SourceEmpty;
756
+ exports.SourceExecutorApplied = SourceExecutorApplied;
757
+ exports.SourceMap = SourceMap;
758
+ exports.SourceOnce = SourceOnce;
759
+ exports.SourceRace = SourceRace;
760
+ exports.SourceSequence = SourceSequence;
761
+ exports.SourceWithPool = SourceWithPool;
674
762
  exports.give = give;
675
763
  exports.isGuest = isGuest;
676
- exports.isGuestAware = isGuestAware;
764
+ exports.isPatron = isPatron;
677
765
  exports.isPatronInPools = isPatronInPools;
766
+ exports.isSource = isSource;
767
+ exports.patronPools = patronPools;
678
768
  exports.removePatronFromPools = removePatronFromPools;
769
+ exports.sourceOf = sourceOf;
679
770
  exports.value = value;
680
771
  //# sourceMappingURL=patron.cjs.map