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.
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.157](https://github.com/silentium-lab/silentium/compare/v0.0.156...v0.0.157) (2025-11-25)
6
+
7
+
8
+ ### Features
9
+
10
+ * **main:** empty component ([e82516f](https://github.com/silentium-lab/silentium/commit/e82516fe6b8e536c475e5cbc1c560900d29cf9b8))
11
+
12
+ ### [0.0.156](https://github.com/silentium-lab/silentium/compare/v0.0.155...v0.0.156) (2025-11-25)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **main:** message simplification and shared schema ([9951aa5](https://github.com/silentium-lab/silentium/commit/9951aa522efe6564598f143cb2b3c556366a39b9))
18
+
5
19
  ### [0.0.155](https://github.com/silentium-lab/silentium/compare/v0.0.154...v0.0.155) (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,146 +82,6 @@ class Rejections {
82
82
  }
83
83
  }
84
84
 
85
- var __defProp$4 = Object.defineProperty;
86
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(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$4(this, "rejections", new Rejections());
95
- __publicField$4(this, "lateR", null);
96
- __publicField$4(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$3 = Object.defineProperty;
128
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
129
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(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$3(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$2 = Object.defineProperty;
165
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
166
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
167
- function Shared($base, source) {
168
- return new SharedImpl($base, source);
169
- }
170
- class SharedImpl {
171
- constructor($base, source) {
172
- this.$base = $base;
173
- this.source = source;
174
- __publicField$2(this, "resolver", (v) => {
175
- this.lastV = v;
176
- this.resolvers.forEach((r) => {
177
- r(v);
178
- });
179
- });
180
- __publicField$2(this, "lastV");
181
- __publicField$2(this, "resolvers", /* @__PURE__ */ new Set());
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, 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,36 +93,26 @@ function ensureMessage(v, label) {
233
93
  }
234
94
  }
235
95
 
236
- var __defProp$1 = Object.defineProperty;
237
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
238
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
239
99
  function Message(executor) {
240
100
  return new MessageRx(executor);
241
101
  }
242
102
  class MessageRx {
243
103
  constructor(executor) {
244
104
  this.executor = executor;
245
- __publicField$1(this, "rejections", new Rejections());
246
- __publicField$1(this, "dc", DestroyContainer());
105
+ __publicField$5(this, "rejections", new Rejections());
106
+ __publicField$5(this, "dc", DestroyContainer());
247
107
  ensureFunction(executor, "Message: executor");
248
108
  }
249
109
  then(resolve) {
250
- const thenResult = LateShared();
251
110
  try {
252
- const proxyResolve = (v) => {
253
- const result = resolve(v);
254
- this.dc.add(result);
255
- if (isMessage(result)) {
256
- thenResult.chain(result);
257
- } else {
258
- thenResult.use(v);
259
- }
260
- };
261
- this.dc.add(this.executor(proxyResolve, this.rejections.reject));
111
+ this.dc.add(this.executor(resolve, this.rejections.reject));
262
112
  } catch (e) {
263
113
  this.rejections.reject(e);
264
114
  }
265
- return thenResult;
115
+ return this;
266
116
  }
267
117
  catch(rejected) {
268
118
  this.rejections.catch(rejected);
@@ -313,16 +163,16 @@ function Local(_base) {
313
163
  });
314
164
  }
315
165
 
316
- var __defProp = Object.defineProperty;
317
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
318
- var __publicField = (obj, key, value) => __defNormalProp(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);
319
169
  function MessageSource(messageExecutor, sourceExecutor) {
320
170
  return new MessageSourceImpl(messageExecutor, sourceExecutor);
321
171
  }
322
172
  class MessageSourceImpl {
323
173
  constructor(messageExecutor, sourceExecutor) {
324
174
  this.sourceExecutor = sourceExecutor;
325
- __publicField(this, "message");
175
+ __publicField$4(this, "message");
326
176
  this.message = Message(messageExecutor);
327
177
  }
328
178
  use(value) {
@@ -399,6 +249,48 @@ function AppliedDestructured($base, applier) {
399
249
  });
400
250
  }
401
251
 
252
+ var __defProp$3 = Object.defineProperty;
253
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
254
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(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$3(this, "rejections", new Rejections());
262
+ __publicField$3(this, "lateR", null);
263
+ __publicField$3(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
+
402
294
  function Catch($base) {
403
295
  const rejections = new Rejections();
404
296
  $base.catch(rejections.reject);
@@ -469,6 +361,104 @@ function ContextChain(base) {
469
361
  };
470
362
  }
471
363
 
364
+ var __defProp$2 = Object.defineProperty;
365
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
366
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(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$2(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$1 = Object.defineProperty;
402
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
403
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(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$1(this, "resolver", (v) => {
411
+ this.lastV = v;
412
+ this.resolvers.forEach((r) => {
413
+ r(v);
414
+ });
415
+ });
416
+ __publicField$1(this, "lastV");
417
+ __publicField$1(this, "resolvers", /* @__PURE__ */ new Set());
418
+ __publicField$1(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
+
472
462
  function ContextOf(transport) {
473
463
  const $msg = LateShared();
474
464
  Context.transport.set(transport, $msg.use.bind($msg));
@@ -477,12 +467,6 @@ function ContextOf(transport) {
477
467
  });
478
468
  }
479
469
 
480
- function ExecutorApplied($base, applier) {
481
- return Message(function ExecutorAppliedImpl(r) {
482
- $base.then(applier(r));
483
- });
484
- }
485
-
486
470
  function Filtered(base, predicate, defaultValue) {
487
471
  const $base = ActualMessage(base);
488
472
  return Message(function FilteredImpl(r) {
@@ -496,6 +480,37 @@ function Filtered(base, predicate, defaultValue) {
496
480
  });
497
481
  }
498
482
 
483
+ var __defProp = Object.defineProperty;
484
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
485
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
486
+ const Nothing = Symbol("nothing");
487
+ function Empty($base) {
488
+ return new EmptyImpl($base);
489
+ }
490
+ class EmptyImpl {
491
+ constructor($base) {
492
+ this.$base = $base;
493
+ __publicField(this, "$empty", LateShared());
494
+ }
495
+ message() {
496
+ Shared(this.$base).then((v) => {
497
+ if (v === Nothing) {
498
+ this.$empty.use(true);
499
+ }
500
+ });
501
+ return Filtered(this.$base, (v) => v !== Nothing);
502
+ }
503
+ empty() {
504
+ return this.$empty;
505
+ }
506
+ }
507
+
508
+ function ExecutorApplied($base, applier) {
509
+ return Message(function ExecutorAppliedImpl(r) {
510
+ $base.then(applier(r));
511
+ });
512
+ }
513
+
499
514
  function FromEvent(emitter, eventName, subscribeMethod, unsubscribeMethod) {
500
515
  const $emitter = ActualMessage(emitter);
501
516
  const $eventName = ActualMessage(eventName);
@@ -620,6 +635,8 @@ exports.DestroyContainer = DestroyContainer;
620
635
  exports.DestroyContainerImpl = DestroyContainerImpl;
621
636
  exports.Destroyable = Destroyable;
622
637
  exports.DestroyableImpl = DestroyableImpl;
638
+ exports.Empty = Empty;
639
+ exports.EmptyImpl = EmptyImpl;
623
640
  exports.ExecutorApplied = ExecutorApplied;
624
641
  exports.Filtered = Filtered;
625
642
  exports.FromEvent = FromEvent;
@@ -633,6 +650,7 @@ exports.MessageRx = MessageRx;
633
650
  exports.MessageSource = MessageSource;
634
651
  exports.MessageSourceImpl = MessageSourceImpl;
635
652
  exports.New = New;
653
+ exports.Nothing = Nothing;
636
654
  exports.Of = Of;
637
655
  exports.Once = Once;
638
656
  exports.Primitive = Primitive;