silentium 0.0.158 → 0.0.161

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.161](https://github.com/silentium-lab/silentium/compare/v0.0.160...v0.0.161) (2025-11-26)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **main:** rejections and freeze component ([e43952f](https://github.com/silentium-lab/silentium/commit/e43952fc051a0fec1bfa24cb76d4c043c67f2de8))
11
+
12
+ ### [0.0.160](https://github.com/silentium-lab/silentium/compare/v0.0.159...v0.0.160) (2025-11-25)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **main:** fix lint ([550d1df](https://github.com/silentium-lab/silentium/commit/550d1dfe3fc1902fe2633c5ae35ce754d7ef993a))
18
+
19
+ ### [0.0.159](https://github.com/silentium-lab/silentium/compare/v0.0.158...v0.0.159) (2025-11-25)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **main:** revert back msg ([308aae8](https://github.com/silentium-lab/silentium/commit/308aae8ec0e520ae2ccb8a258a8997d4bd387556))
25
+
5
26
  ### [0.0.158](https://github.com/silentium-lab/silentium/compare/v0.0.157...v0.0.158) (2025-11-25)
6
27
 
7
28
 
@@ -82,146 +82,6 @@ class Rejections {
82
82
  }
83
83
  }
84
84
 
85
- var __defProp$5 = Object.defineProperty;
86
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
88
- function Late(v) {
89
- return new LateImpl(v);
90
- }
91
- class LateImpl {
92
- constructor(v) {
93
- this.v = v;
94
- __publicField$5(this, "rejections", new Rejections());
95
- __publicField$5(this, "lateR", null);
96
- __publicField$5(this, "notify", () => {
97
- if (isFilled(this.v) && this.lateR) {
98
- try {
99
- this.lateR(this.v);
100
- } catch (e) {
101
- this.rejections.reject(e);
102
- }
103
- }
104
- });
105
- }
106
- then(r) {
107
- if (this.lateR) {
108
- throw new Error(
109
- "Late component gets new resolver, when another was already connected!"
110
- );
111
- }
112
- this.lateR = r;
113
- this.notify();
114
- return this;
115
- }
116
- use(value) {
117
- this.v = value;
118
- this.notify();
119
- return this;
120
- }
121
- catch(rejected) {
122
- this.rejections.catch(rejected);
123
- return this;
124
- }
125
- }
126
-
127
- var __defProp$4 = Object.defineProperty;
128
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
130
- function Primitive($base, theValue = null) {
131
- return new PrimitiveImpl($base, theValue);
132
- }
133
- class PrimitiveImpl {
134
- constructor($base, theValue = null) {
135
- this.$base = $base;
136
- this.theValue = theValue;
137
- __publicField$4(this, "touched", false);
138
- }
139
- ensureTouched() {
140
- if (!this.touched) {
141
- this.$base.then((v) => {
142
- this.theValue = v;
143
- });
144
- }
145
- this.touched = true;
146
- }
147
- [Symbol.toPrimitive]() {
148
- this.ensureTouched();
149
- return this.theValue;
150
- }
151
- primitive() {
152
- this.ensureTouched();
153
- return this.theValue;
154
- }
155
- primitiveWithException() {
156
- this.ensureTouched();
157
- if (this.theValue === null) {
158
- throw new Error("Primitive value is null");
159
- }
160
- return this.theValue;
161
- }
162
- }
163
-
164
- var __defProp$3 = Object.defineProperty;
165
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
166
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
167
- function Shared($base) {
168
- return new SharedImpl($base);
169
- }
170
- class SharedImpl {
171
- constructor($base) {
172
- this.$base = $base;
173
- __publicField$3(this, "resolver", (v) => {
174
- this.lastV = v;
175
- this.resolvers.forEach((r) => {
176
- r(v);
177
- });
178
- });
179
- __publicField$3(this, "lastV");
180
- __publicField$3(this, "resolvers", /* @__PURE__ */ new Set());
181
- __publicField$3(this, "source");
182
- if (isSource($base)) {
183
- this.source = $base;
184
- }
185
- }
186
- then(resolved) {
187
- this.resolvers.add(resolved);
188
- if (this.resolvers.size === 1) {
189
- this.$base.then(this.resolver);
190
- } else if (isFilled(this.lastV)) {
191
- resolved(this.lastV);
192
- }
193
- return this;
194
- }
195
- use(value) {
196
- if (this.source) {
197
- this.source.use(value);
198
- } else {
199
- this.resolver(value);
200
- }
201
- return this;
202
- }
203
- catch(rejected) {
204
- this.$base.catch(rejected);
205
- return this;
206
- }
207
- destroy() {
208
- this.resolvers.clear();
209
- return this;
210
- }
211
- value() {
212
- return Primitive(this);
213
- }
214
- chain(m) {
215
- m.then(this.use.bind(this));
216
- return this;
217
- }
218
- }
219
-
220
- function LateShared(value) {
221
- const l = Late(value);
222
- return Shared(l);
223
- }
224
-
225
85
  function ensureFunction(v, label) {
226
86
  if (typeof v !== "function") {
227
87
  throw new Error(`${label}: is not function`);
@@ -233,37 +93,22 @@ function ensureMessage(v, label) {
233
93
  }
234
94
  }
235
95
 
236
- var __defProp$2 = Object.defineProperty;
237
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
238
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
239
- function Message(executor, everyThenCallsExecutor = false) {
240
- return new MessageRx(executor, everyThenCallsExecutor);
96
+ var __defProp$5 = Object.defineProperty;
97
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
98
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
99
+ function Message(executor) {
100
+ return new MessageRx(executor);
241
101
  }
242
102
  class MessageRx {
243
- constructor(executor, everyThenCallsExecutor = false) {
103
+ constructor(executor) {
244
104
  this.executor = executor;
245
- this.everyThenCallsExecutor = everyThenCallsExecutor;
246
- __publicField$2(this, "rejections", new Rejections());
247
- __publicField$2(this, "dc", DestroyContainer());
248
- __publicField$2(this, "executed", false);
249
- __publicField$2(this, "late", LateShared());
105
+ __publicField$5(this, "rejections", new Rejections());
106
+ __publicField$5(this, "dc", DestroyContainer());
250
107
  ensureFunction(executor, "Message: executor");
251
108
  }
252
109
  then(resolve) {
253
110
  try {
254
- if (this.everyThenCallsExecutor) {
255
- this.dc.add(this.executor(resolve, this.rejections.reject));
256
- } else if (!this.executed) {
257
- this.executed = true;
258
- this.late.then(resolve);
259
- this.dc.add(
260
- this.executor((v) => {
261
- this.late.use(v);
262
- }, this.rejections.reject)
263
- );
264
- } else {
265
- this.late.then(resolve);
266
- }
111
+ this.dc.add(this.executor(resolve, this.rejections.reject));
267
112
  } catch (e) {
268
113
  this.rejections.reject(e);
269
114
  }
@@ -318,16 +163,16 @@ function Local(_base) {
318
163
  });
319
164
  }
320
165
 
321
- var __defProp$1 = Object.defineProperty;
322
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
323
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
166
+ var __defProp$4 = Object.defineProperty;
167
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
168
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
324
169
  function MessageSource(messageExecutor, sourceExecutor) {
325
170
  return new MessageSourceImpl(messageExecutor, sourceExecutor);
326
171
  }
327
172
  class MessageSourceImpl {
328
173
  constructor(messageExecutor, sourceExecutor) {
329
174
  this.sourceExecutor = sourceExecutor;
330
- __publicField$1(this, "message");
175
+ __publicField$4(this, "message");
331
176
  this.message = Message(messageExecutor);
332
177
  }
333
178
  use(value) {
@@ -347,7 +192,7 @@ class MessageSourceImpl {
347
192
  function New(construct) {
348
193
  return Message(function NewImpl(resolve) {
349
194
  resolve(construct());
350
- }, true);
195
+ });
351
196
  }
352
197
 
353
198
  function Void() {
@@ -360,20 +205,21 @@ const isAllFilled = (keysFilled, keysKnown) => {
360
205
  };
361
206
  function All(...messages) {
362
207
  const $messages = messages.map(ActualMessage);
363
- return Message(function AllImpl(r) {
208
+ return Message(function AllImpl(resolve, reject) {
364
209
  const known = new Set(Object.keys(messages));
365
210
  const filled = /* @__PURE__ */ new Set();
366
211
  const result = [];
367
212
  if (known.size === 0) {
368
- r([]);
213
+ resolve([]);
369
214
  return;
370
215
  }
371
216
  $messages.map((m, key) => {
217
+ m.catch(reject);
372
218
  m.then((v) => {
373
219
  filled.add(key.toString());
374
220
  result[key] = v;
375
221
  if (isAllFilled(filled, known)) {
376
- r(result);
222
+ resolve(result);
377
223
  }
378
224
  });
379
225
  });
@@ -382,18 +228,20 @@ function All(...messages) {
382
228
 
383
229
  function Any(...messages) {
384
230
  const $messages = messages.map(ActualMessage);
385
- return Message(function AnyImpl(r) {
231
+ return Message(function AnyImpl(resolve, reject) {
386
232
  $messages.forEach((message) => {
387
- message.then(r);
233
+ message.catch(reject);
234
+ message.then(resolve);
388
235
  });
389
236
  });
390
237
  }
391
238
 
392
239
  function Applied(base, applier) {
393
240
  const $base = ActualMessage(base);
394
- return Message(function AppliedImpl(r) {
241
+ return Message(function AppliedImpl(resolve, reject) {
242
+ $base.catch(reject);
395
243
  $base.then((v) => {
396
- r(applier(v));
244
+ resolve(applier(v));
397
245
  });
398
246
  });
399
247
  }
@@ -404,6 +252,48 @@ function AppliedDestructured($base, applier) {
404
252
  });
405
253
  }
406
254
 
255
+ var __defProp$3 = Object.defineProperty;
256
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
257
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
258
+ function Late(v) {
259
+ return new LateImpl(v);
260
+ }
261
+ class LateImpl {
262
+ constructor(v) {
263
+ this.v = v;
264
+ __publicField$3(this, "rejections", new Rejections());
265
+ __publicField$3(this, "lateR", null);
266
+ __publicField$3(this, "notify", () => {
267
+ if (isFilled(this.v) && this.lateR) {
268
+ try {
269
+ this.lateR(this.v);
270
+ } catch (e) {
271
+ this.rejections.reject(e);
272
+ }
273
+ }
274
+ });
275
+ }
276
+ then(r) {
277
+ if (this.lateR) {
278
+ throw new Error(
279
+ "Late component gets new resolver, when another was already connected!"
280
+ );
281
+ }
282
+ this.lateR = r;
283
+ this.notify();
284
+ return this;
285
+ }
286
+ use(value) {
287
+ this.v = value;
288
+ this.notify();
289
+ return this;
290
+ }
291
+ catch(rejected) {
292
+ this.rejections.catch(rejected);
293
+ return this;
294
+ }
295
+ }
296
+
407
297
  function Catch($base) {
408
298
  const rejections = new Rejections();
409
299
  $base.catch(rejections.reject);
@@ -416,28 +306,31 @@ function Catch($base) {
416
306
 
417
307
  function Chain(...messages) {
418
308
  const $messages = messages.map(ActualMessage);
419
- return Message(function ChainImpl(r) {
420
- let $latest;
421
- const handleMessage = (index) => {
422
- const message = $messages[index];
423
- const next = $messages[index + 1];
424
- message.then((v) => {
425
- oneMessage(v, next, index);
426
- });
427
- };
428
- function oneMessage(v, next, index) {
429
- if (!next) {
430
- $latest = v;
431
- }
432
- if ($latest) {
433
- r($latest);
434
- }
435
- if (next && !$latest) {
436
- handleMessage(index + 1);
309
+ return Message(
310
+ function ChainImpl(resolve, reject) {
311
+ let $latest;
312
+ const handleMessage = (index) => {
313
+ const message = $messages[index];
314
+ message.catch(reject);
315
+ const next = $messages[index + 1];
316
+ message.then((v) => {
317
+ oneMessage(v, next, index);
318
+ });
319
+ };
320
+ function oneMessage(v, next, index) {
321
+ if (!next) {
322
+ $latest = v;
323
+ }
324
+ if ($latest) {
325
+ resolve($latest);
326
+ }
327
+ if (next && !$latest) {
328
+ handleMessage(index + 1);
329
+ }
437
330
  }
331
+ handleMessage(0);
438
332
  }
439
- handleMessage(0);
440
- });
333
+ );
441
334
  }
442
335
 
443
336
  Context.transport = /* @__PURE__ */ new Map();
@@ -474,22 +367,122 @@ function ContextChain(base) {
474
367
  };
475
368
  }
476
369
 
370
+ var __defProp$2 = Object.defineProperty;
371
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
372
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
373
+ function Primitive($base, theValue = null) {
374
+ return new PrimitiveImpl($base, theValue);
375
+ }
376
+ class PrimitiveImpl {
377
+ constructor($base, theValue = null) {
378
+ this.$base = $base;
379
+ this.theValue = theValue;
380
+ __publicField$2(this, "touched", false);
381
+ }
382
+ ensureTouched() {
383
+ if (!this.touched) {
384
+ this.$base.then((v) => {
385
+ this.theValue = v;
386
+ });
387
+ }
388
+ this.touched = true;
389
+ }
390
+ [Symbol.toPrimitive]() {
391
+ this.ensureTouched();
392
+ return this.theValue;
393
+ }
394
+ primitive() {
395
+ this.ensureTouched();
396
+ return this.theValue;
397
+ }
398
+ primitiveWithException() {
399
+ this.ensureTouched();
400
+ if (this.theValue === null) {
401
+ throw new Error("Primitive value is null");
402
+ }
403
+ return this.theValue;
404
+ }
405
+ }
406
+
407
+ var __defProp$1 = Object.defineProperty;
408
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
409
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
410
+ function Shared($base) {
411
+ return new SharedImpl($base);
412
+ }
413
+ class SharedImpl {
414
+ constructor($base) {
415
+ this.$base = $base;
416
+ __publicField$1(this, "resolver", (v) => {
417
+ this.lastV = v;
418
+ this.resolvers.forEach((r) => {
419
+ r(v);
420
+ });
421
+ });
422
+ __publicField$1(this, "lastV");
423
+ __publicField$1(this, "resolvers", /* @__PURE__ */ new Set());
424
+ __publicField$1(this, "source");
425
+ if (isSource($base)) {
426
+ this.source = $base;
427
+ }
428
+ }
429
+ then(resolved) {
430
+ this.resolvers.add(resolved);
431
+ if (this.resolvers.size === 1) {
432
+ this.$base.then(this.resolver);
433
+ } else if (isFilled(this.lastV)) {
434
+ resolved(this.lastV);
435
+ }
436
+ return this;
437
+ }
438
+ use(value) {
439
+ if (this.source) {
440
+ this.source.use(value);
441
+ } else {
442
+ this.resolver(value);
443
+ }
444
+ return this;
445
+ }
446
+ catch(rejected) {
447
+ this.$base.catch(rejected);
448
+ return this;
449
+ }
450
+ destroy() {
451
+ this.resolvers.clear();
452
+ return this;
453
+ }
454
+ value() {
455
+ return Primitive(this);
456
+ }
457
+ chain(m) {
458
+ m.then(this.use.bind(this));
459
+ return this;
460
+ }
461
+ }
462
+
463
+ function LateShared(value) {
464
+ const l = Late(value);
465
+ return Shared(l);
466
+ }
467
+
477
468
  function ContextOf(transport) {
478
469
  const $msg = LateShared();
479
470
  Context.transport.set(transport, $msg.use.bind($msg));
480
- return Message((t) => {
481
- $msg.then(t);
471
+ return Message((resolve, reject) => {
472
+ $msg.catch(reject);
473
+ $msg.then(resolve);
482
474
  });
483
475
  }
484
476
 
485
477
  function Filtered(base, predicate, defaultValue) {
486
478
  const $base = ActualMessage(base);
487
- return Message(function FilteredImpl(r) {
479
+ return Message(function FilteredImpl(resolve, reject) {
480
+ $base.catch(reject);
488
481
  $base.then((v) => {
489
482
  if (predicate(v)) {
490
- r(v);
483
+ resolve(v);
491
484
  } else if (defaultValue !== void 0) {
492
- r(defaultValue);
485
+ resolve(defaultValue);
493
486
  }
494
487
  });
495
488
  });
@@ -521,8 +514,9 @@ class EmptyImpl {
521
514
  }
522
515
 
523
516
  function ExecutorApplied($base, applier) {
524
- return Message(function ExecutorAppliedImpl(r) {
525
- $base.then(applier(r));
517
+ return Message(function ExecutorAppliedImpl(resolve, reject) {
518
+ $base.catch(reject);
519
+ $base.then(applier(resolve));
526
520
  });
527
521
  }
528
522
 
@@ -531,7 +525,11 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
531
525
  const $eventName = ActualMessage(eventName);
532
526
  const $subscribeMethod = ActualMessage(subscribeMethod);
533
527
  const $unsubscribeMethod = ActualMessage(unsubscribeMethod);
534
- return Message((r) => {
528
+ return Message((resolve, reject) => {
529
+ $emitter.catch(reject);
530
+ $eventName.catch(reject);
531
+ $subscribeMethod.catch(reject);
532
+ $unsubscribeMethod.catch(reject);
535
533
  let lastR = null;
536
534
  const handler = (v) => {
537
535
  if (lastR) {
@@ -540,7 +538,7 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
540
538
  };
541
539
  All($emitter, $eventName, $subscribeMethod).then(
542
540
  ([emitter2, eventName2, subscribe]) => {
543
- lastR = r;
541
+ lastR = resolve;
544
542
  if (!emitter2?.[subscribe]) {
545
543
  return;
546
544
  }
@@ -563,7 +561,8 @@ function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
563
561
 
564
562
  function Map$1(base, target) {
565
563
  const $base = ActualMessage(base);
566
- return Message((r) => {
564
+ return Message((resolve, reject) => {
565
+ $base.catch(reject);
567
566
  const infos = [];
568
567
  const dc = DestroyContainer();
569
568
  $base.then((v) => {
@@ -577,18 +576,19 @@ function Map$1(base, target) {
577
576
  dc.add(info);
578
577
  infos.push(info);
579
578
  });
580
- All(...infos).then(r);
579
+ All(...infos).then(resolve);
581
580
  });
582
581
  });
583
582
  }
584
583
 
585
584
  function Once($base) {
586
- return Message((r) => {
585
+ return Message((resolve, reject) => {
587
586
  let isFilled = false;
587
+ $base.catch(reject);
588
588
  $base.then((v) => {
589
589
  if (!isFilled) {
590
590
  isFilled = true;
591
- r(v);
591
+ resolve(v);
592
592
  }
593
593
  });
594
594
  });
@@ -614,21 +614,23 @@ function Process($base, builder) {
614
614
  }
615
615
 
616
616
  function Sequence($base) {
617
- return Message((r) => {
617
+ return Message((resolve, reject) => {
618
618
  const result = [];
619
+ $base.catch(reject);
619
620
  $base.then((v) => {
620
621
  result.push(v);
621
- r(result);
622
+ resolve(result);
622
623
  });
623
624
  });
624
625
  }
625
626
 
626
627
  function Stream(base) {
627
628
  const $base = ActualMessage(base);
628
- return Message((r) => {
629
+ return Message((resolve, reject) => {
630
+ $base.catch(reject);
629
631
  $base.then((v) => {
630
632
  v.forEach((cv) => {
631
- r(cv);
633
+ resolve(cv);
632
634
  });
633
635
  });
634
636
  });