silentium 0.0.156 → 0.0.158

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,20 @@
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.158](https://github.com/silentium-lab/silentium/compare/v0.0.157...v0.0.158) (2025-11-25)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **main:** message shared by default ([31337ea](https://github.com/silentium-lab/silentium/commit/31337ea75025b189b33598a6ed4a685774ea3de3))
11
+
12
+ ### [0.0.157](https://github.com/silentium-lab/silentium/compare/v0.0.156...v0.0.157) (2025-11-25)
13
+
14
+
15
+ ### Features
16
+
17
+ * **main:** empty component ([e82516f](https://github.com/silentium-lab/silentium/commit/e82516fe6b8e536c475e5cbc1c560900d29cf9b8))
18
+
5
19
  ### [0.0.156](https://github.com/silentium-lab/silentium/compare/v0.0.155...v0.0.156) (2025-11-25)
6
20
 
7
21
 
@@ -34,15 +34,15 @@ class DestroyableImpl {
34
34
  }
35
35
  }
36
36
 
37
- var __defProp$6 = Object.defineProperty;
38
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
39
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
37
+ var __defProp$7 = Object.defineProperty;
38
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
39
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
40
40
  function DestroyContainer() {
41
41
  return new DestroyContainerImpl();
42
42
  }
43
43
  class DestroyContainerImpl {
44
44
  constructor() {
45
- __publicField$6(this, "destructors", []);
45
+ __publicField$7(this, "destructors", []);
46
46
  }
47
47
  add(e) {
48
48
  this.destructors.push(Destroyable(e));
@@ -55,14 +55,14 @@ class DestroyContainerImpl {
55
55
  }
56
56
  }
57
57
 
58
- var __defProp$5 = Object.defineProperty;
59
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
60
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
58
+ var __defProp$6 = Object.defineProperty;
59
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
60
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
61
61
  class Rejections {
62
62
  constructor() {
63
- __publicField$5(this, "catchers", []);
64
- __publicField$5(this, "lastRejectReason", null);
65
- __publicField$5(this, "reject", (reason) => {
63
+ __publicField$6(this, "catchers", []);
64
+ __publicField$6(this, "lastRejectReason", null);
65
+ __publicField$6(this, "reject", (reason) => {
66
66
  this.lastRejectReason = reason;
67
67
  this.catchers.forEach((catcher) => {
68
68
  catcher(reason);
@@ -82,6 +82,146 @@ 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
+
85
225
  function ensureFunction(v, label) {
86
226
  if (typeof v !== "function") {
87
227
  throw new Error(`${label}: is not function`);
@@ -93,22 +233,37 @@ function ensureMessage(v, label) {
93
233
  }
94
234
  }
95
235
 
96
- var __defProp$4 = Object.defineProperty;
97
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
98
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
99
- function Message(executor) {
100
- return new MessageRx(executor);
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);
101
241
  }
102
242
  class MessageRx {
103
- constructor(executor) {
243
+ constructor(executor, everyThenCallsExecutor = false) {
104
244
  this.executor = executor;
105
- __publicField$4(this, "rejections", new Rejections());
106
- __publicField$4(this, "dc", DestroyContainer());
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());
107
250
  ensureFunction(executor, "Message: executor");
108
251
  }
109
252
  then(resolve) {
110
253
  try {
111
- this.dc.add(this.executor(resolve, this.rejections.reject));
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
+ }
112
267
  } catch (e) {
113
268
  this.rejections.reject(e);
114
269
  }
@@ -163,16 +318,16 @@ function Local(_base) {
163
318
  });
164
319
  }
165
320
 
166
- var __defProp$3 = Object.defineProperty;
167
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
168
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
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);
169
324
  function MessageSource(messageExecutor, sourceExecutor) {
170
325
  return new MessageSourceImpl(messageExecutor, sourceExecutor);
171
326
  }
172
327
  class MessageSourceImpl {
173
328
  constructor(messageExecutor, sourceExecutor) {
174
329
  this.sourceExecutor = sourceExecutor;
175
- __publicField$3(this, "message");
330
+ __publicField$1(this, "message");
176
331
  this.message = Message(messageExecutor);
177
332
  }
178
333
  use(value) {
@@ -192,7 +347,7 @@ class MessageSourceImpl {
192
347
  function New(construct) {
193
348
  return Message(function NewImpl(resolve) {
194
349
  resolve(construct());
195
- });
350
+ }, true);
196
351
  }
197
352
 
198
353
  function Void() {
@@ -249,48 +404,6 @@ function AppliedDestructured($base, applier) {
249
404
  });
250
405
  }
251
406
 
252
- var __defProp$2 = Object.defineProperty;
253
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
254
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
255
- function Late(v) {
256
- return new LateImpl(v);
257
- }
258
- class LateImpl {
259
- constructor(v) {
260
- this.v = v;
261
- __publicField$2(this, "rejections", new Rejections());
262
- __publicField$2(this, "lateR", null);
263
- __publicField$2(this, "notify", () => {
264
- if (isFilled(this.v) && this.lateR) {
265
- try {
266
- this.lateR(this.v);
267
- } catch (e) {
268
- this.rejections.reject(e);
269
- }
270
- }
271
- });
272
- }
273
- then(r) {
274
- if (this.lateR) {
275
- throw new Error(
276
- "Late component gets new resolver, when another was already connected!"
277
- );
278
- }
279
- this.lateR = r;
280
- this.notify();
281
- return this;
282
- }
283
- use(value) {
284
- this.v = value;
285
- this.notify();
286
- return this;
287
- }
288
- catch(rejected) {
289
- this.rejections.catch(rejected);
290
- return this;
291
- }
292
- }
293
-
294
407
  function Catch($base) {
295
408
  const rejections = new Rejections();
296
409
  $base.catch(rejections.reject);
@@ -361,104 +474,6 @@ function ContextChain(base) {
361
474
  };
362
475
  }
363
476
 
364
- var __defProp$1 = Object.defineProperty;
365
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
366
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
367
- function Primitive($base, theValue = null) {
368
- return new PrimitiveImpl($base, theValue);
369
- }
370
- class PrimitiveImpl {
371
- constructor($base, theValue = null) {
372
- this.$base = $base;
373
- this.theValue = theValue;
374
- __publicField$1(this, "touched", false);
375
- }
376
- ensureTouched() {
377
- if (!this.touched) {
378
- this.$base.then((v) => {
379
- this.theValue = v;
380
- });
381
- }
382
- this.touched = true;
383
- }
384
- [Symbol.toPrimitive]() {
385
- this.ensureTouched();
386
- return this.theValue;
387
- }
388
- primitive() {
389
- this.ensureTouched();
390
- return this.theValue;
391
- }
392
- primitiveWithException() {
393
- this.ensureTouched();
394
- if (this.theValue === null) {
395
- throw new Error("Primitive value is null");
396
- }
397
- return this.theValue;
398
- }
399
- }
400
-
401
- var __defProp = Object.defineProperty;
402
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
403
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
404
- function Shared($base) {
405
- return new SharedImpl($base);
406
- }
407
- class SharedImpl {
408
- constructor($base) {
409
- this.$base = $base;
410
- __publicField(this, "resolver", (v) => {
411
- this.lastV = v;
412
- this.resolvers.forEach((r) => {
413
- r(v);
414
- });
415
- });
416
- __publicField(this, "lastV");
417
- __publicField(this, "resolvers", /* @__PURE__ */ new Set());
418
- __publicField(this, "source");
419
- if (isSource($base)) {
420
- this.source = $base;
421
- }
422
- }
423
- then(resolved) {
424
- this.resolvers.add(resolved);
425
- if (this.resolvers.size === 1) {
426
- this.$base.then(this.resolver);
427
- } else if (isFilled(this.lastV)) {
428
- resolved(this.lastV);
429
- }
430
- return this;
431
- }
432
- use(value) {
433
- if (this.source) {
434
- this.source.use(value);
435
- } else {
436
- this.resolver(value);
437
- }
438
- return this;
439
- }
440
- catch(rejected) {
441
- this.$base.catch(rejected);
442
- return this;
443
- }
444
- destroy() {
445
- this.resolvers.clear();
446
- return this;
447
- }
448
- value() {
449
- return Primitive(this);
450
- }
451
- chain(m) {
452
- m.then(this.use.bind(this));
453
- return this;
454
- }
455
- }
456
-
457
- function LateShared(value) {
458
- const l = Late(value);
459
- return Shared(l);
460
- }
461
-
462
477
  function ContextOf(transport) {
463
478
  const $msg = LateShared();
464
479
  Context.transport.set(transport, $msg.use.bind($msg));
@@ -467,12 +482,6 @@ function ContextOf(transport) {
467
482
  });
468
483
  }
469
484
 
470
- function ExecutorApplied($base, applier) {
471
- return Message(function ExecutorAppliedImpl(r) {
472
- $base.then(applier(r));
473
- });
474
- }
475
-
476
485
  function Filtered(base, predicate, defaultValue) {
477
486
  const $base = ActualMessage(base);
478
487
  return Message(function FilteredImpl(r) {
@@ -486,6 +495,37 @@ function Filtered(base, predicate, defaultValue) {
486
495
  });
487
496
  }
488
497
 
498
+ var __defProp = Object.defineProperty;
499
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
500
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
501
+ const Nothing = Symbol("nothing");
502
+ function Empty($base) {
503
+ return new EmptyImpl($base);
504
+ }
505
+ class EmptyImpl {
506
+ constructor($base) {
507
+ this.$base = $base;
508
+ __publicField(this, "$empty", LateShared());
509
+ }
510
+ message() {
511
+ Shared(this.$base).then((v) => {
512
+ if (v === Nothing) {
513
+ this.$empty.use(true);
514
+ }
515
+ });
516
+ return Filtered(this.$base, (v) => v !== Nothing);
517
+ }
518
+ empty() {
519
+ return this.$empty;
520
+ }
521
+ }
522
+
523
+ function ExecutorApplied($base, applier) {
524
+ return Message(function ExecutorAppliedImpl(r) {
525
+ $base.then(applier(r));
526
+ });
527
+ }
528
+
489
529
  function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
490
530
  const $emitter = ActualMessage(emitter);
491
531
  const $eventName = ActualMessage(eventName);
@@ -610,6 +650,8 @@ exports.DestroyContainer = DestroyContainer;
610
650
  exports.DestroyContainerImpl = DestroyContainerImpl;
611
651
  exports.Destroyable = Destroyable;
612
652
  exports.DestroyableImpl = DestroyableImpl;
653
+ exports.Empty = Empty;
654
+ exports.EmptyImpl = EmptyImpl;
613
655
  exports.ExecutorApplied = ExecutorApplied;
614
656
  exports.Filtered = Filtered;
615
657
  exports.FromEvent = FromEvent;
@@ -623,6 +665,7 @@ exports.MessageRx = MessageRx;
623
665
  exports.MessageSource = MessageSource;
624
666
  exports.MessageSourceImpl = MessageSourceImpl;
625
667
  exports.New = New;
668
+ exports.Nothing = Nothing;
626
669
  exports.Of = Of;
627
670
  exports.Once = Once;
628
671
  exports.Primitive = Primitive;