silentium 0.0.35 → 0.0.37
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/.github/workflows/node.js.yml +31 -0
- package/CHANGELOG.md +19 -0
- package/README.md +32 -2
- package/dist/silentium.cjs +118 -75
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +16 -7
- package/dist/silentium.js +118 -76
- package/dist/silentium.js.map +1 -1
- package/dist/silentium.min.js +1 -1
- package/dist/silentium.min.mjs +1 -1
- package/dist/silentium.min.mjs.map +1 -1
- package/dist/silentium.mjs +118 -76
- package/dist/silentium.mjs.map +1 -1
- package/docs/build.sh +1 -1
- package/docs/buildRoutes.sh +1 -1
- package/docs/index-dev.html +2 -2
- package/docs/index.html +3 -3
- package/docs/pages/compatibility/dip.html +3 -3
- package/docs/pages/en/compatibility/dip.html +3 -3
- package/docs/pages/en/guest/guest-applied.html +1 -1
- package/docs/pages/en/guest/guest-cast.html +1 -1
- package/docs/pages/en/guest/guest-disposable.html +1 -1
- package/docs/pages/en/guest/guest-executor-applied.html +1 -1
- package/docs/pages/en/guest/guest-sync.html +1 -1
- package/docs/pages/en/guest/index.html +3 -3
- package/docs/pages/en/guest.html +3 -3
- package/docs/pages/en/patron/index.html +1 -1
- package/docs/pages/en/patron/patron-applied.html +1 -1
- package/docs/pages/en/patron/patron-executor-applied.html +1 -1
- package/docs/pages/en/patron/patron-once.html +1 -1
- package/docs/pages/en/patron/patron-pool.html +1 -1
- package/docs/pages/en/patron.html +1 -1
- package/docs/pages/en/philosofy.html +2 -2
- package/docs/pages/en/source/index.html +2 -2
- package/docs/pages/en/source/source-all.html +1 -1
- package/docs/pages/en/source/source-applied.html +1 -1
- package/docs/pages/en/source/source-changeable.html +1 -1
- package/docs/pages/en/source/source-dynamic.html +3 -3
- package/docs/pages/en/source/source-executor-applied.html +1 -1
- package/docs/pages/en/source/source-filtered.html +1 -1
- package/docs/pages/en/source/source-map.html +1 -1
- package/docs/pages/en/source/source-once.html +1 -1
- package/docs/pages/en/source/source-race.html +1 -1
- package/docs/pages/en/source/source-sequence.html +1 -1
- package/docs/pages/en/source/source-sync.html +1 -1
- package/docs/pages/en/source/source.html +2 -2
- package/docs/pages/en/source.html +2 -2
- package/docs/pages/en/terminology/introduction.html +1 -1
- package/docs/pages/en/terminology/source.html +2 -2
- package/docs/pages/en/utils/give.html +2 -2
- package/docs/pages/en/utils/is-guest-aware.html +1 -1
- package/docs/pages/en/utils/is-guest.html +1 -1
- package/docs/pages/en/utils/is-patron-in-pools.html +1 -1
- package/docs/pages/en/utils/is-source.html +1 -1
- package/docs/pages/en/utils/private.html +2 -2
- package/docs/pages/en/utils/remove-patron-from-pools.html +1 -1
- package/docs/pages/en/utils/source-of.html +1 -1
- package/docs/pages/en/utils/value.html +2 -2
- package/docs/pages/guest/guest-applied.html +2 -4
- package/docs/pages/guest/guest-cast.html +1 -1
- package/docs/pages/guest/guest-disposable.html +1 -1
- package/docs/pages/guest/guest-executor-applied.html +1 -1
- package/docs/pages/guest/guest-sync.html +1 -1
- package/docs/pages/guest/index.html +3 -3
- package/docs/pages/guest.html +3 -3
- package/docs/pages/patron/index.html +1 -1
- package/docs/pages/patron/patron-applied.html +1 -1
- package/docs/pages/patron/patron-executor-applied.html +1 -1
- package/docs/pages/patron/patron-once.html +1 -1
- package/docs/pages/patron/patron-pool.html +1 -1
- package/docs/pages/patron.html +1 -1
- package/docs/pages/philosofy.html +2 -2
- package/docs/pages/source/index.html +2 -2
- package/docs/pages/source/source-all.html +1 -1
- package/docs/pages/source/source-applied.html +1 -1
- package/docs/pages/source/source-changeable.html +1 -1
- package/docs/pages/source/source-dynamic.html +3 -3
- package/docs/pages/source/source-executor-applied.html +1 -1
- package/docs/pages/source/source-filtered.html +1 -1
- package/docs/pages/source/source-map.html +1 -1
- package/docs/pages/source/source-once.html +1 -1
- package/docs/pages/source/source-race.html +1 -1
- package/docs/pages/source/source-sequence.html +1 -1
- package/docs/pages/source/source-sync.html +1 -1
- package/docs/pages/source/source.html +2 -2
- package/docs/pages/source.html +2 -2
- package/docs/pages/terminology/introduction.html +1 -1
- package/docs/pages/terminology/source.html +2 -2
- package/docs/pages/utils/give.html +2 -2
- package/docs/pages/utils/is-guest-aware.html +1 -1
- package/docs/pages/utils/is-guest.html +1 -1
- package/docs/pages/utils/is-patron-in-pools.html +1 -1
- package/docs/pages/utils/is-source.html +1 -1
- package/docs/pages/utils/private.html +2 -2
- package/docs/pages/utils/remove-patron-from-pools.html +1 -1
- package/docs/pages/utils/source-of.html +1 -1
- package/docs/pages/utils/value.html +2 -2
- package/docs/routes.json +1 -1
- package/docs/template.html +2 -2
- package/package.json +1 -1
- package/src/Guest/Guest.firstVisit.test.ts +16 -0
- package/src/Guest/Guest.ts +16 -0
- package/src/Source/SourceAll.ts +27 -18
- package/src/Source/SourceAny.ts +10 -3
- package/src/Source/SourceChain.ts +24 -17
- package/src/Source/SourceDynamic._ofSource.test.ts +1 -1
- package/src/Source/SourceLazy.ts +27 -14
- package/src/Source/SourceMap.ts +25 -20
- package/src/Source/SourceResettable.test.ts +3 -2
- package/src/Source/SourceResettable.ts +15 -10
- package/src/Source/SourceSync.ts +1 -1
- package/docs/assets/js/lib/StyleFetched.mjs +0 -19
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "main" ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [18.x, 20.x, 22.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
cache: 'npm'
|
|
29
|
+
- run: npm ci
|
|
30
|
+
- run: npm run build --if-present
|
|
31
|
+
- run: npm test
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.37](https://github.com/silentium-lab/silentium/compare/v0.0.36...v0.0.37) (2025-05-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **49-sourcedetached:** firstVisit done and applied ([d596990](https://github.com/silentium-lab/silentium/commit/d596990daf05b0136e3860bbc6793950fb6ccaf2))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **49-sourcedetached:** fix tests ([e054cd6](https://github.com/silentium-lab/silentium/commit/e054cd6c63caa9b436212fc1e1e2db5e82622197))
|
|
16
|
+
|
|
17
|
+
### [0.0.36](https://github.com/silentium-lab/silentium/compare/v0.0.35...v0.0.36) (2025-05-31)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **47-sourcelazy-component:** source lazy done ([ed97056](https://github.com/silentium-lab/silentium/commit/ed9705603913451e22ed6994005f6a5b656dacde))
|
|
23
|
+
|
|
5
24
|
### [0.0.35](https://github.com/silentium-lab/silentium/compare/v0.0.34...v0.0.35) (2025-05-25)
|
|
6
25
|
|
|
7
26
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://silentium-lab.github.io/silentium/#/en/" target="_blank" rel="noopener noreferrer" style="display:flex">
|
|
3
|
+
<img width="180" src="https://silentium-lab.github.io/silentium/assets/img/logo.svg" alt="logo">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">Silentium</h1>
|
|
7
|
+
<br/>
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://npmjs.com/package/silentium"><img src="https://img.shields.io/npm/v/silentium.svg" alt="npm package"></a>
|
|
10
|
+
<a href="https://github.com/silentium-lab/silentium/actions/workflows/node.js.yml"><img src="https://github.com/silentium-lab/silentium/actions/workflows/node.js.yml/badge.svg?branch=main" alt="build status"></a>
|
|
11
|
+
</p>
|
|
12
|
+
<br/>
|
|
2
13
|
|
|
3
|
-
[
|
|
14
|
+
[Documentation](https://silentium-lab.github.io/silentium/#/en/)
|
|
15
|
+
|
|
16
|
+
To install the library you can use the command.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install silentium
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The library helps you create abstractions for information in your system. Instead of working with data abstractions and operations abstractions, you can combine them into a common information abstraction. The approach in which we combine data and operations under information abstractions is object-oriented programming.
|
|
23
|
+
|
|
24
|
+
The idea for the project was born from the ideas of eolang and was inspired by this paper, 𝜑-calculus:
|
|
25
|
+
https://arxiv.org/pdf/2111.13384
|
|
26
|
+
|
|
27
|
+
## Difference from eolang
|
|
28
|
+
|
|
29
|
+
Unlike eolang, where the program starts working at the moment when some method receives data, which is called dataization, Silentium starts executing the program at the moment when a guest comes to the information source, requesting data, this difference allows the Silentium library to work on top of JavaScript events, creating abstractions of information around some event models.
|
|
30
|
+
|
|
31
|
+
## Is silentium reactive?
|
|
32
|
+
|
|
33
|
+
Silentium is not a reactive programming library, chains of objects only interact with each other through message passing, but due to the fact that Silentium is developed with the idea of working on top of events, it allows for easy integration with any reactive library or framework, transferring event sources to the reactive mechanisms of the required frameworks.
|
package/dist/silentium.cjs
CHANGED
|
@@ -63,6 +63,15 @@ const guest = (receiver) => {
|
|
|
63
63
|
};
|
|
64
64
|
return result;
|
|
65
65
|
};
|
|
66
|
+
const firstVisit = (afterFirstVisit) => {
|
|
67
|
+
let isVisited = false;
|
|
68
|
+
return () => {
|
|
69
|
+
if (!isVisited) {
|
|
70
|
+
afterFirstVisit();
|
|
71
|
+
}
|
|
72
|
+
isVisited = true;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
66
75
|
|
|
67
76
|
const guestCast = (sourceGuest, targetGuest) => {
|
|
68
77
|
if (sourceGuest === void 0) {
|
|
@@ -448,26 +457,29 @@ const sourceAll = (sources) => {
|
|
|
448
457
|
};
|
|
449
458
|
const theAll = sourceOf({});
|
|
450
459
|
const patrons = [];
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
460
|
+
const visited = firstVisit(() => {
|
|
461
|
+
Object.entries(sources).forEach(([key, source]) => {
|
|
462
|
+
subSource(theAll, source);
|
|
463
|
+
keysKnown.add(key);
|
|
464
|
+
const keyPatron = patron((v) => {
|
|
465
|
+
theAll.value(
|
|
466
|
+
guest((all) => {
|
|
467
|
+
keysFilled.add(key);
|
|
468
|
+
const lastAll = {
|
|
469
|
+
...all,
|
|
470
|
+
[key]: v
|
|
471
|
+
};
|
|
472
|
+
theAll.give(lastAll);
|
|
473
|
+
})
|
|
474
|
+
);
|
|
475
|
+
});
|
|
476
|
+
patrons.push(keyPatron);
|
|
477
|
+
value(source, keyPatron);
|
|
465
478
|
});
|
|
466
|
-
patrons.push(keyPatron);
|
|
467
|
-
value(source, keyPatron);
|
|
468
479
|
});
|
|
469
480
|
return {
|
|
470
481
|
value(guest2) {
|
|
482
|
+
visited();
|
|
471
483
|
const mbPatron = guestCast(guest2, (value2) => {
|
|
472
484
|
if (isAllFilled()) {
|
|
473
485
|
give(Object.values(value2), guest2);
|
|
@@ -545,25 +557,30 @@ const sourceMap = (baseSource, targetSource) => {
|
|
|
545
557
|
throw new Error("SourceMap didn't receive targetSource argument");
|
|
546
558
|
}
|
|
547
559
|
const result = sourceOf();
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
560
|
+
const visited = firstVisit(() => {
|
|
561
|
+
value(
|
|
562
|
+
baseSource,
|
|
563
|
+
patron((theValue) => {
|
|
564
|
+
const sources = [];
|
|
565
|
+
theValue.forEach((val) => {
|
|
566
|
+
const source = targetSource.get(val);
|
|
567
|
+
subSource(source, baseSource);
|
|
568
|
+
sources.push(source);
|
|
569
|
+
});
|
|
570
|
+
value(
|
|
571
|
+
sourceAll(sources),
|
|
572
|
+
patronOnce((v) => {
|
|
573
|
+
destroy(...sources);
|
|
574
|
+
give(v, result);
|
|
575
|
+
})
|
|
576
|
+
);
|
|
577
|
+
})
|
|
578
|
+
);
|
|
579
|
+
});
|
|
580
|
+
return (g) => {
|
|
581
|
+
visited();
|
|
582
|
+
result.value(g);
|
|
583
|
+
};
|
|
567
584
|
};
|
|
568
585
|
|
|
569
586
|
const sourceRace = (sources) => {
|
|
@@ -590,21 +607,26 @@ const sourceChain = (...sources) => {
|
|
|
590
607
|
const resultSrc = sourceOf();
|
|
591
608
|
const respondedSources = /* @__PURE__ */ new Set();
|
|
592
609
|
let lastSourceValue = null;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
610
|
+
const visited = firstVisit(() => {
|
|
611
|
+
sources.forEach((source, index) => {
|
|
612
|
+
value(
|
|
613
|
+
source,
|
|
614
|
+
patron((value2) => {
|
|
615
|
+
respondedSources.add(index);
|
|
616
|
+
if (index === sources.length - 1) {
|
|
617
|
+
lastSourceValue = value2;
|
|
618
|
+
}
|
|
619
|
+
if (respondedSources.size === sources.length && lastSourceValue !== null) {
|
|
620
|
+
resultSrc.give(lastSourceValue);
|
|
621
|
+
}
|
|
622
|
+
})
|
|
623
|
+
);
|
|
624
|
+
});
|
|
606
625
|
});
|
|
607
|
-
return
|
|
626
|
+
return (g) => {
|
|
627
|
+
visited();
|
|
628
|
+
resultSrc.value(g);
|
|
629
|
+
};
|
|
608
630
|
};
|
|
609
631
|
|
|
610
632
|
const sourceDynamic = (baseGuest, baseSource) => {
|
|
@@ -691,48 +713,68 @@ const sourceCombined = (...sources) => (source) => {
|
|
|
691
713
|
|
|
692
714
|
const sourceResettable = (baseSrc, resettableSrc) => {
|
|
693
715
|
const result = sourceOf();
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
716
|
+
const visited = firstVisit(() => {
|
|
717
|
+
value(
|
|
718
|
+
resettableSrc,
|
|
719
|
+
patron(() => {
|
|
720
|
+
give(null, result);
|
|
721
|
+
})
|
|
722
|
+
);
|
|
723
|
+
value(baseSrc, patron(result));
|
|
724
|
+
subSource(result, baseSrc);
|
|
725
|
+
});
|
|
726
|
+
return (g) => {
|
|
727
|
+
visited();
|
|
728
|
+
result.value(g);
|
|
729
|
+
};
|
|
703
730
|
};
|
|
704
731
|
|
|
705
732
|
const sourceAny = (sources) => {
|
|
706
733
|
const lastSrc = sourceOf();
|
|
707
|
-
|
|
708
|
-
|
|
734
|
+
const visited = firstVisit(() => {
|
|
735
|
+
sources.forEach((source) => {
|
|
736
|
+
value(source, patron(lastSrc));
|
|
737
|
+
});
|
|
709
738
|
});
|
|
710
|
-
return
|
|
739
|
+
return (g) => {
|
|
740
|
+
visited();
|
|
741
|
+
lastSrc.value(g);
|
|
742
|
+
};
|
|
711
743
|
};
|
|
712
744
|
|
|
713
|
-
const sourceLazy = (lazySrc, args,
|
|
745
|
+
const sourceLazy = (lazySrc, args, destroySrc) => {
|
|
714
746
|
let instance = null;
|
|
715
747
|
const result = sourceOf();
|
|
716
|
-
const resultResettable = sourceResettable(result,
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}
|
|
724
|
-
})
|
|
725
|
-
);
|
|
726
|
-
if (resetSrc) {
|
|
748
|
+
const resultResettable = sourceResettable(result, destroySrc ?? sourceOf());
|
|
749
|
+
let wasInstantiated = false;
|
|
750
|
+
const instantiate = () => {
|
|
751
|
+
if (wasInstantiated) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
wasInstantiated = true;
|
|
727
755
|
value(
|
|
728
|
-
|
|
756
|
+
sourceAll(args),
|
|
757
|
+
patron(() => {
|
|
758
|
+
if (!instance) {
|
|
759
|
+
instance = lazySrc.get(...args);
|
|
760
|
+
value(instance, patron(result));
|
|
761
|
+
}
|
|
762
|
+
})
|
|
763
|
+
);
|
|
764
|
+
};
|
|
765
|
+
if (destroySrc) {
|
|
766
|
+
value(
|
|
767
|
+
destroySrc,
|
|
729
768
|
patron(() => {
|
|
730
769
|
destroy(instance);
|
|
731
770
|
instance = null;
|
|
732
771
|
})
|
|
733
772
|
);
|
|
734
773
|
}
|
|
735
|
-
return
|
|
774
|
+
return (g) => {
|
|
775
|
+
instantiate();
|
|
776
|
+
value(resultResettable, g);
|
|
777
|
+
};
|
|
736
778
|
};
|
|
737
779
|
|
|
738
780
|
const sourceDestroyable = (source) => {
|
|
@@ -778,6 +820,7 @@ const lazy = (buildingFn) => {
|
|
|
778
820
|
|
|
779
821
|
exports.PatronPool = PatronPool;
|
|
780
822
|
exports.destroy = destroy;
|
|
823
|
+
exports.firstVisit = firstVisit;
|
|
781
824
|
exports.give = give;
|
|
782
825
|
exports.guest = guest;
|
|
783
826
|
exports.guestApplied = guestApplied;
|