silentium 0.0.155 → 0.0.157

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.
@@ -32,15 +32,15 @@ class DestroyableImpl {
32
32
  }
33
33
  }
34
34
 
35
- var __defProp$6 = Object.defineProperty;
36
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
37
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
35
+ var __defProp$7 = Object.defineProperty;
36
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
37
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
38
38
  function DestroyContainer() {
39
39
  return new DestroyContainerImpl();
40
40
  }
41
41
  class DestroyContainerImpl {
42
42
  constructor() {
43
- __publicField$6(this, "destructors", []);
43
+ __publicField$7(this, "destructors", []);
44
44
  }
45
45
  add(e) {
46
46
  this.destructors.push(Destroyable(e));
@@ -53,14 +53,14 @@ class DestroyContainerImpl {
53
53
  }
54
54
  }
55
55
 
56
- var __defProp$5 = Object.defineProperty;
57
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
58
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
56
+ var __defProp$6 = Object.defineProperty;
57
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
58
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
59
59
  class Rejections {
60
60
  constructor() {
61
- __publicField$5(this, "catchers", []);
62
- __publicField$5(this, "lastRejectReason", null);
63
- __publicField$5(this, "reject", (reason) => {
61
+ __publicField$6(this, "catchers", []);
62
+ __publicField$6(this, "lastRejectReason", null);
63
+ __publicField$6(this, "reject", (reason) => {
64
64
  this.lastRejectReason = reason;
65
65
  this.catchers.forEach((catcher) => {
66
66
  catcher(reason);
@@ -80,146 +80,6 @@ class Rejections {
80
80
  }
81
81
  }
82
82
 
83
- var __defProp$4 = Object.defineProperty;
84
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
85
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
86
- function Late(v) {
87
- return new LateImpl(v);
88
- }
89
- class LateImpl {
90
- constructor(v) {
91
- this.v = v;
92
- __publicField$4(this, "rejections", new Rejections());
93
- __publicField$4(this, "lateR", null);
94
- __publicField$4(this, "notify", () => {
95
- if (isFilled(this.v) && this.lateR) {
96
- try {
97
- this.lateR(this.v);
98
- } catch (e) {
99
- this.rejections.reject(e);
100
- }
101
- }
102
- });
103
- }
104
- then(r) {
105
- if (this.lateR) {
106
- throw new Error(
107
- "Late component gets new resolver, when another was already connected!"
108
- );
109
- }
110
- this.lateR = r;
111
- this.notify();
112
- return this;
113
- }
114
- use(value) {
115
- this.v = value;
116
- this.notify();
117
- return this;
118
- }
119
- catch(rejected) {
120
- this.rejections.catch(rejected);
121
- return this;
122
- }
123
- }
124
-
125
- var __defProp$3 = Object.defineProperty;
126
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
127
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
128
- function Primitive($base, theValue = null) {
129
- return new PrimitiveImpl($base, theValue);
130
- }
131
- class PrimitiveImpl {
132
- constructor($base, theValue = null) {
133
- this.$base = $base;
134
- this.theValue = theValue;
135
- __publicField$3(this, "touched", false);
136
- }
137
- ensureTouched() {
138
- if (!this.touched) {
139
- this.$base.then((v) => {
140
- this.theValue = v;
141
- });
142
- }
143
- this.touched = true;
144
- }
145
- [Symbol.toPrimitive]() {
146
- this.ensureTouched();
147
- return this.theValue;
148
- }
149
- primitive() {
150
- this.ensureTouched();
151
- return this.theValue;
152
- }
153
- primitiveWithException() {
154
- this.ensureTouched();
155
- if (this.theValue === null) {
156
- throw new Error("Primitive value is null");
157
- }
158
- return this.theValue;
159
- }
160
- }
161
-
162
- var __defProp$2 = Object.defineProperty;
163
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
164
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
165
- function Shared($base, source) {
166
- return new SharedImpl($base, source);
167
- }
168
- class SharedImpl {
169
- constructor($base, source) {
170
- this.$base = $base;
171
- this.source = source;
172
- __publicField$2(this, "resolver", (v) => {
173
- this.lastV = v;
174
- this.resolvers.forEach((r) => {
175
- r(v);
176
- });
177
- });
178
- __publicField$2(this, "lastV");
179
- __publicField$2(this, "resolvers", /* @__PURE__ */ new Set());
180
- if (isSource($base)) {
181
- this.source = $base;
182
- }
183
- }
184
- then(resolved) {
185
- this.resolvers.add(resolved);
186
- if (this.resolvers.size === 1) {
187
- this.$base.then(this.resolver);
188
- } else if (isFilled(this.lastV)) {
189
- resolved(this.lastV);
190
- }
191
- return this;
192
- }
193
- use(value) {
194
- if (this.source) {
195
- this.source.use(value);
196
- } else {
197
- this.resolver(value);
198
- }
199
- return this;
200
- }
201
- catch(rejected) {
202
- this.$base.catch(rejected);
203
- return this;
204
- }
205
- destroy() {
206
- this.resolvers.clear();
207
- return this;
208
- }
209
- value() {
210
- return Primitive(this);
211
- }
212
- chain(m) {
213
- m.then(this.use.bind(this));
214
- return this;
215
- }
216
- }
217
-
218
- function LateShared(value) {
219
- const l = Late(value);
220
- return Shared(l, l);
221
- }
222
-
223
83
  function ensureFunction(v, label) {
224
84
  if (typeof v !== "function") {
225
85
  throw new Error(`${label}: is not function`);
@@ -231,36 +91,26 @@ function ensureMessage(v, label) {
231
91
  }
232
92
  }
233
93
 
234
- var __defProp$1 = Object.defineProperty;
235
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
236
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
94
+ var __defProp$5 = Object.defineProperty;
95
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
96
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
237
97
  function Message(executor) {
238
98
  return new MessageRx(executor);
239
99
  }
240
100
  class MessageRx {
241
101
  constructor(executor) {
242
102
  this.executor = executor;
243
- __publicField$1(this, "rejections", new Rejections());
244
- __publicField$1(this, "dc", DestroyContainer());
103
+ __publicField$5(this, "rejections", new Rejections());
104
+ __publicField$5(this, "dc", DestroyContainer());
245
105
  ensureFunction(executor, "Message: executor");
246
106
  }
247
107
  then(resolve) {
248
- const thenResult = LateShared();
249
108
  try {
250
- const proxyResolve = (v) => {
251
- const result = resolve(v);
252
- this.dc.add(result);
253
- if (isMessage(result)) {
254
- thenResult.chain(result);
255
- } else {
256
- thenResult.use(v);
257
- }
258
- };
259
- this.dc.add(this.executor(proxyResolve, this.rejections.reject));
109
+ this.dc.add(this.executor(resolve, this.rejections.reject));
260
110
  } catch (e) {
261
111
  this.rejections.reject(e);
262
112
  }
263
- return thenResult;
113
+ return this;
264
114
  }
265
115
  catch(rejected) {
266
116
  this.rejections.catch(rejected);
@@ -311,16 +161,16 @@ function Local(_base) {
311
161
  });
312
162
  }
313
163
 
314
- var __defProp = Object.defineProperty;
315
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
316
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
164
+ var __defProp$4 = Object.defineProperty;
165
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
166
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
317
167
  function MessageSource(messageExecutor, sourceExecutor) {
318
168
  return new MessageSourceImpl(messageExecutor, sourceExecutor);
319
169
  }
320
170
  class MessageSourceImpl {
321
171
  constructor(messageExecutor, sourceExecutor) {
322
172
  this.sourceExecutor = sourceExecutor;
323
- __publicField(this, "message");
173
+ __publicField$4(this, "message");
324
174
  this.message = Message(messageExecutor);
325
175
  }
326
176
  use(value) {
@@ -397,6 +247,48 @@ function AppliedDestructured($base, applier) {
397
247
  });
398
248
  }
399
249
 
250
+ var __defProp$3 = Object.defineProperty;
251
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
252
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
253
+ function Late(v) {
254
+ return new LateImpl(v);
255
+ }
256
+ class LateImpl {
257
+ constructor(v) {
258
+ this.v = v;
259
+ __publicField$3(this, "rejections", new Rejections());
260
+ __publicField$3(this, "lateR", null);
261
+ __publicField$3(this, "notify", () => {
262
+ if (isFilled(this.v) && this.lateR) {
263
+ try {
264
+ this.lateR(this.v);
265
+ } catch (e) {
266
+ this.rejections.reject(e);
267
+ }
268
+ }
269
+ });
270
+ }
271
+ then(r) {
272
+ if (this.lateR) {
273
+ throw new Error(
274
+ "Late component gets new resolver, when another was already connected!"
275
+ );
276
+ }
277
+ this.lateR = r;
278
+ this.notify();
279
+ return this;
280
+ }
281
+ use(value) {
282
+ this.v = value;
283
+ this.notify();
284
+ return this;
285
+ }
286
+ catch(rejected) {
287
+ this.rejections.catch(rejected);
288
+ return this;
289
+ }
290
+ }
291
+
400
292
  function Catch($base) {
401
293
  const rejections = new Rejections();
402
294
  $base.catch(rejections.reject);
@@ -467,6 +359,104 @@ function ContextChain(base) {
467
359
  };
468
360
  }
469
361
 
362
+ var __defProp$2 = Object.defineProperty;
363
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
364
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
365
+ function Primitive($base, theValue = null) {
366
+ return new PrimitiveImpl($base, theValue);
367
+ }
368
+ class PrimitiveImpl {
369
+ constructor($base, theValue = null) {
370
+ this.$base = $base;
371
+ this.theValue = theValue;
372
+ __publicField$2(this, "touched", false);
373
+ }
374
+ ensureTouched() {
375
+ if (!this.touched) {
376
+ this.$base.then((v) => {
377
+ this.theValue = v;
378
+ });
379
+ }
380
+ this.touched = true;
381
+ }
382
+ [Symbol.toPrimitive]() {
383
+ this.ensureTouched();
384
+ return this.theValue;
385
+ }
386
+ primitive() {
387
+ this.ensureTouched();
388
+ return this.theValue;
389
+ }
390
+ primitiveWithException() {
391
+ this.ensureTouched();
392
+ if (this.theValue === null) {
393
+ throw new Error("Primitive value is null");
394
+ }
395
+ return this.theValue;
396
+ }
397
+ }
398
+
399
+ var __defProp$1 = Object.defineProperty;
400
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
401
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
402
+ function Shared($base) {
403
+ return new SharedImpl($base);
404
+ }
405
+ class SharedImpl {
406
+ constructor($base) {
407
+ this.$base = $base;
408
+ __publicField$1(this, "resolver", (v) => {
409
+ this.lastV = v;
410
+ this.resolvers.forEach((r) => {
411
+ r(v);
412
+ });
413
+ });
414
+ __publicField$1(this, "lastV");
415
+ __publicField$1(this, "resolvers", /* @__PURE__ */ new Set());
416
+ __publicField$1(this, "source");
417
+ if (isSource($base)) {
418
+ this.source = $base;
419
+ }
420
+ }
421
+ then(resolved) {
422
+ this.resolvers.add(resolved);
423
+ if (this.resolvers.size === 1) {
424
+ this.$base.then(this.resolver);
425
+ } else if (isFilled(this.lastV)) {
426
+ resolved(this.lastV);
427
+ }
428
+ return this;
429
+ }
430
+ use(value) {
431
+ if (this.source) {
432
+ this.source.use(value);
433
+ } else {
434
+ this.resolver(value);
435
+ }
436
+ return this;
437
+ }
438
+ catch(rejected) {
439
+ this.$base.catch(rejected);
440
+ return this;
441
+ }
442
+ destroy() {
443
+ this.resolvers.clear();
444
+ return this;
445
+ }
446
+ value() {
447
+ return Primitive(this);
448
+ }
449
+ chain(m) {
450
+ m.then(this.use.bind(this));
451
+ return this;
452
+ }
453
+ }
454
+
455
+ function LateShared(value) {
456
+ const l = Late(value);
457
+ return Shared(l);
458
+ }
459
+
470
460
  function ContextOf(transport) {
471
461
  const $msg = LateShared();
472
462
  Context.transport.set(transport, $msg.use.bind($msg));
@@ -475,12 +465,6 @@ function ContextOf(transport) {
475
465
  });
476
466
  }
477
467
 
478
- function ExecutorApplied($base, applier) {
479
- return Message(function ExecutorAppliedImpl(r) {
480
- $base.then(applier(r));
481
- });
482
- }
483
-
484
468
  function Filtered(base, predicate, defaultValue) {
485
469
  const $base = ActualMessage(base);
486
470
  return Message(function FilteredImpl(r) {
@@ -494,6 +478,37 @@ function Filtered(base, predicate, defaultValue) {
494
478
  });
495
479
  }
496
480
 
481
+ var __defProp = Object.defineProperty;
482
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
483
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
484
+ const Nothing = Symbol("nothing");
485
+ function Empty($base) {
486
+ return new EmptyImpl($base);
487
+ }
488
+ class EmptyImpl {
489
+ constructor($base) {
490
+ this.$base = $base;
491
+ __publicField(this, "$empty", LateShared());
492
+ }
493
+ message() {
494
+ Shared(this.$base).then((v) => {
495
+ if (v === Nothing) {
496
+ this.$empty.use(true);
497
+ }
498
+ });
499
+ return Filtered(this.$base, (v) => v !== Nothing);
500
+ }
501
+ empty() {
502
+ return this.$empty;
503
+ }
504
+ }
505
+
506
+ function ExecutorApplied($base, applier) {
507
+ return Message(function ExecutorAppliedImpl(r) {
508
+ $base.then(applier(r));
509
+ });
510
+ }
511
+
497
512
  function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
498
513
  const $emitter = ActualMessage(emitter);
499
514
  const $eventName = ActualMessage(eventName);
@@ -602,5 +617,5 @@ function Stream(base) {
602
617
  });
603
618
  }
604
619
 
605
- export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Context, ContextChain, ContextOf, DestroyContainer, DestroyContainerImpl, Destroyable, DestroyableImpl, ExecutorApplied, Filtered, FromEvent, Late, LateImpl, LateShared, Local, Map$1 as Map, Message, MessageRx, MessageSource, MessageSourceImpl, New, Of, Once, Primitive, PrimitiveImpl, Process, Rejections, Sequence, Shared, SharedImpl, Stream, Void, ensureFunction, ensureMessage, isDestroyable, isDestroyed, isFilled, isMessage, isSource };
620
+ export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Context, ContextChain, ContextOf, DestroyContainer, DestroyContainerImpl, Destroyable, DestroyableImpl, Empty, EmptyImpl, ExecutorApplied, Filtered, FromEvent, Late, LateImpl, LateShared, Local, Map$1 as Map, Message, MessageRx, MessageSource, MessageSourceImpl, New, Nothing, Of, Once, Primitive, PrimitiveImpl, Process, Rejections, Sequence, Shared, SharedImpl, Stream, Void, ensureFunction, ensureMessage, isDestroyable, isDestroyed, isFilled, isMessage, isSource };
606
621
  //# sourceMappingURL=silentium.mjs.map