silentium-components 0.0.26 → 0.0.28
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 +34 -0
- package/dist/silentium-components.cjs +570 -342
- package/dist/silentium-components.cjs.map +1 -1
- package/dist/silentium-components.d.ts +169 -30
- package/dist/silentium-components.js +546 -319
- package/dist/silentium-components.js.map +1 -1
- package/dist/silentium-components.min.js +1 -1
- package/dist/silentium-components.min.mjs +1 -1
- package/dist/silentium-components.min.mjs.map +1 -1
- package/dist/silentium-components.mjs +546 -319
- package/dist/silentium-components.mjs.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/Branch._main.test.ts +22 -0
- package/src/behaviors/Branch.branchesDontAffectResult.test.ts +11 -11
- package/src/behaviors/Branch.dontRespondAfterRespond.test.ts +15 -17
- package/src/behaviors/Branch.ts +28 -21
- package/src/behaviors/{Deadline.test.ts → Deadline._main.test.ts} +5 -5
- package/src/behaviors/Deadline._value.test.ts +6 -6
- package/src/behaviors/Deadline.ts +45 -41
- package/src/behaviors/Deferred.test.ts +14 -14
- package/src/behaviors/Deferred.ts +21 -15
- package/src/behaviors/Dirty.test.ts +8 -8
- package/src/behaviors/Dirty.ts +43 -35
- package/src/behaviors/Loading.test.ts +8 -8
- package/src/behaviors/Loading.ts +24 -14
- package/src/behaviors/Lock.test.ts +14 -14
- package/src/behaviors/Lock.ts +21 -14
- package/src/behaviors/Memo.test.ts +16 -14
- package/src/behaviors/Memo.ts +20 -12
- package/src/behaviors/OnlyChanged.test.ts +7 -7
- package/src/behaviors/OnlyChanged.ts +22 -15
- package/src/behaviors/Path._main.test.ts +14 -0
- package/src/behaviors/Path.index.test.ts +4 -4
- package/src/behaviors/Path.nested.test.ts +4 -4
- package/src/behaviors/Path.ts +27 -22
- package/src/behaviors/Shot._main.test.ts +29 -0
- package/src/behaviors/Shot._onlyChanged.test.ts +15 -13
- package/src/behaviors/Shot.ts +24 -15
- package/src/behaviors/Sync.test.ts +10 -0
- package/src/behaviors/Sync.ts +38 -15
- package/src/behaviors/Tick.test.ts +8 -8
- package/src/behaviors/Tick.ts +20 -12
- package/src/boolean/And.test.ts +12 -12
- package/src/boolean/And.ts +18 -14
- package/src/boolean/Bool.ts +11 -2
- package/src/boolean/Not.test.ts +6 -6
- package/src/boolean/Not.ts +15 -10
- package/src/boolean/Or.test.ts +12 -12
- package/src/boolean/Or.ts +18 -14
- package/src/boolean/index.ts +1 -0
- package/src/formats/FromJson.test.ts +11 -0
- package/src/formats/FromJson.ts +22 -15
- package/src/formats/ToJson.test.ts +11 -0
- package/src/formats/ToJson.ts +23 -16
- package/src/lists/First.test.ts +4 -4
- package/src/lists/First.ts +11 -6
- package/src/navigation/Router.test.ts +13 -13
- package/src/navigation/Router.ts +36 -29
- package/src/strings/Concatenated.test.ts +6 -6
- package/src/strings/Concatenated.ts +18 -14
- package/src/structures/HashTable.test.ts +7 -7
- package/src/structures/HashTable.ts +17 -11
- package/src/structures/Record._main.test.ts +28 -0
- package/src/structures/Record.concatenated.test.ts +17 -15
- package/src/structures/Record.nested.test.ts +10 -10
- package/src/structures/RecordOf.ts +29 -0
- package/src/structures/index.ts +1 -1
- package/src/system/RegexpMatch._group.test.ts +9 -6
- package/src/system/RegexpMatch._main.test.ts +16 -0
- package/src/system/RegexpMatch.ts +20 -17
- package/src/system/RegexpMatched.test.ts +6 -6
- package/src/system/RegexpMatched.ts +19 -16
- package/src/system/RegexpReplaced.test.ts +10 -6
- package/src/system/RegexpReplaced.ts +25 -18
- package/src/system/Set.test.ts +6 -6
- package/src/system/Set.ts +20 -17
- package/src/behaviors/Branch.test.ts +0 -22
- package/src/behaviors/Path.test.ts +0 -14
- package/src/behaviors/Shot.test.ts +0 -29
- package/src/structures/Record.test.ts +0 -28
- package/src/structures/Record.ts +0 -22
- package/src/system/RegexpMatch.test.ts +0 -13
|
@@ -1,96 +1,138 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TheInformation, Late, Applied, All, From, Shared, Filtered, isFilled, Of, Any, Chain } from 'silentium';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
var __defProp$1 = Object.defineProperty;
|
|
4
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
|
|
6
|
+
class Dirty extends TheInformation {
|
|
7
|
+
constructor(baseEntitySource, alwaysKeep = [], excludeKeys = []) {
|
|
8
|
+
super([baseEntitySource]);
|
|
9
|
+
this.baseEntitySource = baseEntitySource;
|
|
10
|
+
this.alwaysKeep = alwaysKeep;
|
|
11
|
+
this.excludeKeys = excludeKeys;
|
|
12
|
+
__publicField$1(this, "comparingSrc", new Late());
|
|
13
|
+
}
|
|
14
|
+
value(o) {
|
|
15
|
+
const comparingDetached = new Applied(
|
|
16
|
+
this.comparingSrc,
|
|
17
|
+
(value) => JSON.parse(JSON.stringify(value))
|
|
18
|
+
);
|
|
19
|
+
const allSrc = new All(comparingDetached, this.baseEntitySource).value(
|
|
20
|
+
new From(([comparing, base]) => {
|
|
21
|
+
if (!comparing) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
o.give(
|
|
25
|
+
Object.fromEntries(
|
|
26
|
+
Object.entries(comparing).filter(([key, value]) => {
|
|
27
|
+
if (this.alwaysKeep.includes(key)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (this.excludeKeys.includes(key)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return value !== base[key];
|
|
34
|
+
})
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
this.addDep(allSrc);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
owner() {
|
|
43
|
+
return this.comparingSrc.owner();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
class Loading extends TheInformation {
|
|
48
|
+
constructor(loadingStartSrc, loadingFinishSrc) {
|
|
49
|
+
super(loadingFinishSrc, loadingStartSrc);
|
|
50
|
+
this.loadingStartSrc = loadingStartSrc;
|
|
51
|
+
this.loadingFinishSrc = loadingFinishSrc;
|
|
52
|
+
}
|
|
53
|
+
value(o) {
|
|
54
|
+
this.loadingStartSrc.value(
|
|
55
|
+
new From(() => {
|
|
56
|
+
o.give(true);
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
this.loadingFinishSrc.value(
|
|
60
|
+
new From(() => {
|
|
61
|
+
o.give(false);
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
45
67
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
68
|
+
class Path extends TheInformation {
|
|
69
|
+
constructor(baseSrc, keySrc) {
|
|
70
|
+
super(baseSrc, keySrc);
|
|
71
|
+
this.baseSrc = baseSrc;
|
|
72
|
+
this.keySrc = keySrc;
|
|
73
|
+
}
|
|
74
|
+
value(o) {
|
|
75
|
+
const allSrc = new All(this.baseSrc, this.keySrc).value(
|
|
76
|
+
new From(([base, key]) => {
|
|
77
|
+
const keyChunks = key.split(".");
|
|
78
|
+
let value = base;
|
|
79
|
+
keyChunks.forEach((keyChunk) => {
|
|
80
|
+
value = value[keyChunk];
|
|
81
|
+
});
|
|
82
|
+
if (value !== void 0 && value !== base) {
|
|
83
|
+
o.give(value);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
this.addDep(allSrc);
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
class Deadline extends TheInformation {
|
|
93
|
+
constructor(error, baseSrc, timeoutSrc) {
|
|
94
|
+
super([error, baseSrc, timeoutSrc]);
|
|
95
|
+
this.error = error;
|
|
96
|
+
this.baseSrc = baseSrc;
|
|
97
|
+
this.timeoutSrc = timeoutSrc;
|
|
98
|
+
}
|
|
99
|
+
value(o) {
|
|
100
|
+
let timerHead = null;
|
|
101
|
+
const s = new Shared(this.baseSrc, true);
|
|
102
|
+
this.addDep(s);
|
|
103
|
+
this.timeoutSrc.value(
|
|
104
|
+
new From((timeout) => {
|
|
105
|
+
if (timerHead) {
|
|
106
|
+
clearTimeout(timerHead);
|
|
76
107
|
}
|
|
77
|
-
timeoutReached =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
let timeoutReached = false;
|
|
109
|
+
timerHead = setTimeout(() => {
|
|
110
|
+
if (timeoutReached) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
timeoutReached = true;
|
|
114
|
+
this.error.give(new Error("Timeout reached in Deadline class"));
|
|
115
|
+
}, timeout);
|
|
116
|
+
const f = new Filtered(s, () => !timeoutReached);
|
|
117
|
+
this.addDep(f);
|
|
118
|
+
f.value(o);
|
|
119
|
+
s.value(
|
|
120
|
+
new From(() => {
|
|
121
|
+
timeoutReached = true;
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
91
129
|
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
class Tick extends TheInformation {
|
|
131
|
+
constructor(baseSrc) {
|
|
132
|
+
super(baseSrc);
|
|
133
|
+
this.baseSrc = baseSrc;
|
|
134
|
+
}
|
|
135
|
+
value(o) {
|
|
94
136
|
let microtaskScheduled = false;
|
|
95
137
|
let lastValue = null;
|
|
96
138
|
const scheduleMicrotask = () => {
|
|
@@ -98,266 +140,451 @@ const tick = (baseSrc) => {
|
|
|
98
140
|
queueMicrotask(() => {
|
|
99
141
|
microtaskScheduled = false;
|
|
100
142
|
if (lastValue !== null) {
|
|
101
|
-
o(lastValue);
|
|
143
|
+
o.give(lastValue);
|
|
102
144
|
lastValue = null;
|
|
103
145
|
}
|
|
104
146
|
});
|
|
105
147
|
};
|
|
106
|
-
baseSrc(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
148
|
+
this.baseSrc.value(
|
|
149
|
+
new From((v) => {
|
|
150
|
+
lastValue = v;
|
|
151
|
+
if (!microtaskScheduled) {
|
|
152
|
+
scheduleMicrotask();
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
114
159
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
160
|
+
var __defProp = Object.defineProperty;
|
|
161
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
162
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
163
|
+
class Sync extends TheInformation {
|
|
164
|
+
constructor(baseSrc) {
|
|
165
|
+
super(baseSrc);
|
|
166
|
+
this.baseSrc = baseSrc;
|
|
167
|
+
__publicField(this, "theValue");
|
|
168
|
+
__publicField(this, "isInit", false);
|
|
169
|
+
}
|
|
170
|
+
value(o) {
|
|
171
|
+
this.baseSrc.value(o);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
valueExisted() {
|
|
175
|
+
this.initOwner();
|
|
176
|
+
return isFilled(this.theValue);
|
|
177
|
+
}
|
|
178
|
+
valueSync() {
|
|
179
|
+
this.initOwner();
|
|
180
|
+
if (!isFilled(this.theValue)) {
|
|
181
|
+
throw new Error("no value in sync");
|
|
182
|
+
}
|
|
183
|
+
return this.theValue;
|
|
184
|
+
}
|
|
185
|
+
initOwner() {
|
|
186
|
+
if (!this.isInit) {
|
|
187
|
+
this.isInit = true;
|
|
188
|
+
this.value(
|
|
189
|
+
new From((v) => {
|
|
190
|
+
this.theValue = v;
|
|
191
|
+
})
|
|
192
|
+
);
|
|
126
193
|
}
|
|
127
|
-
|
|
128
|
-
}
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
129
197
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
198
|
+
class Deferred extends TheInformation {
|
|
199
|
+
constructor(baseSrc, triggerSrc) {
|
|
200
|
+
super();
|
|
201
|
+
this.baseSrc = baseSrc;
|
|
202
|
+
this.triggerSrc = triggerSrc;
|
|
203
|
+
}
|
|
204
|
+
value(o) {
|
|
205
|
+
const baseSync = new Sync(this.baseSrc).initOwner();
|
|
206
|
+
this.triggerSrc.value(
|
|
207
|
+
new From(() => {
|
|
208
|
+
if (isFilled(baseSync.valueSync())) {
|
|
209
|
+
o.give(baseSync.valueSync());
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
140
216
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
217
|
+
class Branch extends TheInformation {
|
|
218
|
+
constructor(conditionSrc, leftSrc, rightSrc) {
|
|
219
|
+
super([conditionSrc, leftSrc, rightSrc]);
|
|
220
|
+
this.conditionSrc = conditionSrc;
|
|
221
|
+
this.leftSrc = leftSrc;
|
|
222
|
+
this.rightSrc = rightSrc;
|
|
223
|
+
}
|
|
224
|
+
value(o) {
|
|
225
|
+
const leftSync = new Sync(this.leftSrc).initOwner();
|
|
144
226
|
let rightSync;
|
|
145
|
-
if (
|
|
146
|
-
rightSync =
|
|
227
|
+
if (this.rightSrc !== void 0) {
|
|
228
|
+
rightSync = new Sync(this.rightSrc).initOwner();
|
|
147
229
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
230
|
+
this.conditionSrc.value(
|
|
231
|
+
new From((v) => {
|
|
232
|
+
if (v) {
|
|
233
|
+
o.give(leftSync.valueSync());
|
|
234
|
+
} else if (rightSync) {
|
|
235
|
+
o.give(rightSync.valueSync());
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
);
|
|
239
|
+
return this;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
157
242
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
baseSrc
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
243
|
+
class Memo extends TheInformation {
|
|
244
|
+
constructor(baseSrc) {
|
|
245
|
+
super(baseSrc);
|
|
246
|
+
this.baseSrc = baseSrc;
|
|
247
|
+
}
|
|
248
|
+
value(o) {
|
|
249
|
+
let lastValue = null;
|
|
250
|
+
this.baseSrc.value(
|
|
251
|
+
new From((v) => {
|
|
252
|
+
if (v !== lastValue) {
|
|
253
|
+
o.give(v);
|
|
254
|
+
lastValue = v;
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
return this;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
169
261
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
lockSrc
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
262
|
+
class Lock extends TheInformation {
|
|
263
|
+
constructor(baseSrc, lockSrc) {
|
|
264
|
+
super(baseSrc, lockSrc);
|
|
265
|
+
this.baseSrc = baseSrc;
|
|
266
|
+
this.lockSrc = lockSrc;
|
|
267
|
+
}
|
|
268
|
+
value(o) {
|
|
269
|
+
let locked = false;
|
|
270
|
+
this.lockSrc.value(
|
|
271
|
+
new From((newLock) => {
|
|
272
|
+
locked = newLock;
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
const i = new Filtered(this.baseSrc, () => !locked);
|
|
276
|
+
this.addDep(i);
|
|
277
|
+
i.value(o);
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
180
281
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
282
|
+
class Shot extends TheInformation {
|
|
283
|
+
constructor(targetSrc, triggerSrc) {
|
|
284
|
+
super(targetSrc, triggerSrc);
|
|
285
|
+
this.targetSrc = targetSrc;
|
|
286
|
+
this.triggerSrc = triggerSrc;
|
|
287
|
+
}
|
|
288
|
+
value(o) {
|
|
289
|
+
const targetSync = new Sync(this.targetSrc);
|
|
290
|
+
targetSync.initOwner();
|
|
291
|
+
this.triggerSrc.value(
|
|
292
|
+
new From(() => {
|
|
293
|
+
if (targetSync.valueExisted()) {
|
|
294
|
+
o.give(targetSync.valueSync());
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
return this;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
191
301
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
baseSrc
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
302
|
+
class OnlyChanged extends TheInformation {
|
|
303
|
+
constructor(baseSrc) {
|
|
304
|
+
super(baseSrc);
|
|
305
|
+
this.baseSrc = baseSrc;
|
|
306
|
+
}
|
|
307
|
+
value(o) {
|
|
308
|
+
let firstValue = false;
|
|
309
|
+
this.baseSrc.value(
|
|
310
|
+
new From((v) => {
|
|
311
|
+
if (firstValue === false) {
|
|
312
|
+
firstValue = true;
|
|
313
|
+
} else {
|
|
314
|
+
o.give(v);
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
204
321
|
|
|
205
|
-
|
|
206
|
-
|
|
322
|
+
class HashTable extends TheInformation {
|
|
323
|
+
constructor(baseSrc) {
|
|
324
|
+
super(baseSrc);
|
|
325
|
+
this.baseSrc = baseSrc;
|
|
326
|
+
}
|
|
327
|
+
value(o) {
|
|
207
328
|
const record = {};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
329
|
+
this.baseSrc.value(
|
|
330
|
+
new From(([key, value]) => {
|
|
331
|
+
record[key] = value;
|
|
332
|
+
o.give(record);
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
214
338
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
339
|
+
class RecordOf extends TheInformation {
|
|
340
|
+
constructor(recordSrc) {
|
|
341
|
+
super(...Object.values(recordSrc));
|
|
342
|
+
this.recordSrc = recordSrc;
|
|
343
|
+
}
|
|
344
|
+
value(o) {
|
|
345
|
+
const keys = Object.keys(this.recordSrc);
|
|
346
|
+
new All(...Object.values(this.recordSrc)).value(
|
|
347
|
+
new From((entries) => {
|
|
348
|
+
const record = {};
|
|
349
|
+
entries.forEach((entry, index) => {
|
|
350
|
+
record[keys[index]] = entry;
|
|
351
|
+
});
|
|
352
|
+
o.give(record);
|
|
353
|
+
})
|
|
354
|
+
);
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
227
358
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
359
|
+
class Concatenated extends TheInformation {
|
|
360
|
+
constructor(sources, joinPartSrc = new Of("")) {
|
|
361
|
+
super(...sources, joinPartSrc);
|
|
362
|
+
this.sources = sources;
|
|
363
|
+
this.joinPartSrc = joinPartSrc;
|
|
364
|
+
}
|
|
365
|
+
value(o) {
|
|
366
|
+
new All(this.joinPartSrc, ...this.sources).value(
|
|
367
|
+
new From(([joinPart, ...strings]) => {
|
|
368
|
+
o.give(strings.join(joinPart));
|
|
369
|
+
})
|
|
370
|
+
);
|
|
371
|
+
return this;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
238
374
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
patternSrc,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
375
|
+
class RegexpMatched extends TheInformation {
|
|
376
|
+
constructor(patternSrc, valueSrc, flagsSrc = new Of("")) {
|
|
377
|
+
super(patternSrc, valueSrc, flagsSrc);
|
|
378
|
+
this.patternSrc = patternSrc;
|
|
379
|
+
this.valueSrc = valueSrc;
|
|
380
|
+
this.flagsSrc = flagsSrc;
|
|
381
|
+
}
|
|
382
|
+
value(o) {
|
|
383
|
+
new All(this.patternSrc, this.valueSrc, this.flagsSrc).value(
|
|
384
|
+
new From(([pattern, value, flags]) => {
|
|
385
|
+
o.give(new RegExp(pattern, flags).test(value));
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
248
391
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
392
|
+
class RegexpReplaced extends TheInformation {
|
|
393
|
+
constructor(valueSrc, patternSrc, replaceValueSrc, flagsSrc = new Of("")) {
|
|
394
|
+
super(valueSrc, patternSrc, replaceValueSrc, flagsSrc);
|
|
395
|
+
this.valueSrc = valueSrc;
|
|
396
|
+
this.patternSrc = patternSrc;
|
|
397
|
+
this.replaceValueSrc = replaceValueSrc;
|
|
398
|
+
this.flagsSrc = flagsSrc;
|
|
399
|
+
}
|
|
400
|
+
value(o) {
|
|
401
|
+
new All(
|
|
402
|
+
this.patternSrc,
|
|
403
|
+
this.valueSrc,
|
|
404
|
+
this.replaceValueSrc,
|
|
405
|
+
this.flagsSrc
|
|
406
|
+
).value(
|
|
407
|
+
new From(([pattern, value, replaceValue, flags]) => {
|
|
408
|
+
o.give(String(value).replace(new RegExp(pattern, flags), replaceValue));
|
|
409
|
+
})
|
|
410
|
+
);
|
|
411
|
+
return this;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
268
414
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
patternSrc,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
flagsSrc
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
415
|
+
class RegexpMatch extends TheInformation {
|
|
416
|
+
constructor(patternSrc, valueSrc, flagsSrc = new Of("")) {
|
|
417
|
+
super(patternSrc, valueSrc, flagsSrc);
|
|
418
|
+
this.patternSrc = patternSrc;
|
|
419
|
+
this.valueSrc = valueSrc;
|
|
420
|
+
this.flagsSrc = flagsSrc;
|
|
421
|
+
}
|
|
422
|
+
value(o) {
|
|
423
|
+
new All(this.patternSrc, this.valueSrc, this.flagsSrc).value(
|
|
424
|
+
new From(([pattern, value, flags]) => {
|
|
425
|
+
const result = new RegExp(pattern, flags).exec(value);
|
|
426
|
+
o.give(result ?? []);
|
|
427
|
+
})
|
|
428
|
+
);
|
|
429
|
+
return this;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
279
432
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
433
|
+
class Set extends TheInformation {
|
|
434
|
+
constructor(baseSrc, keySrc, valueSrc) {
|
|
435
|
+
super(baseSrc, keySrc, valueSrc);
|
|
436
|
+
this.baseSrc = baseSrc;
|
|
437
|
+
this.keySrc = keySrc;
|
|
438
|
+
this.valueSrc = valueSrc;
|
|
439
|
+
}
|
|
440
|
+
value(o) {
|
|
441
|
+
new All(this.baseSrc, this.keySrc, this.valueSrc).value(
|
|
442
|
+
new From(([base, key, value]) => {
|
|
443
|
+
base[key] = value;
|
|
444
|
+
o.give(base);
|
|
445
|
+
})
|
|
446
|
+
);
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
290
450
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
451
|
+
class Router extends TheInformation {
|
|
452
|
+
constructor(urlSrc, routesSrc, defaultSrc) {
|
|
453
|
+
super(urlSrc, routesSrc, defaultSrc);
|
|
454
|
+
this.urlSrc = urlSrc;
|
|
455
|
+
this.routesSrc = routesSrc;
|
|
456
|
+
this.defaultSrc = defaultSrc;
|
|
457
|
+
}
|
|
458
|
+
value(o) {
|
|
459
|
+
this.routesSrc.value(
|
|
460
|
+
new From((routes) => {
|
|
461
|
+
new Any(
|
|
462
|
+
new Chain(this.urlSrc, this.defaultSrc),
|
|
463
|
+
...routes.map((r) => {
|
|
464
|
+
return new Branch(
|
|
465
|
+
new RegexpMatched(
|
|
466
|
+
new Of(r.pattern),
|
|
467
|
+
this.urlSrc,
|
|
468
|
+
r.patternFlags ? new Of(r.patternFlags) : void 0
|
|
469
|
+
),
|
|
470
|
+
r.template instanceof TheInformation ? r.template : new Of(r.template)
|
|
471
|
+
);
|
|
472
|
+
})
|
|
473
|
+
).value(o);
|
|
474
|
+
})
|
|
475
|
+
);
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
303
479
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
480
|
+
class And extends TheInformation {
|
|
481
|
+
constructor(oneSrc, twoSrc) {
|
|
482
|
+
super(oneSrc, twoSrc);
|
|
483
|
+
this.oneSrc = oneSrc;
|
|
484
|
+
this.twoSrc = twoSrc;
|
|
485
|
+
}
|
|
486
|
+
value(o) {
|
|
487
|
+
new All(this.oneSrc, this.twoSrc).value(
|
|
488
|
+
new From(([one, two]) => {
|
|
489
|
+
o.give(one && two);
|
|
490
|
+
})
|
|
491
|
+
);
|
|
492
|
+
return this;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
314
495
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
496
|
+
class Or extends TheInformation {
|
|
497
|
+
constructor(oneSrc, twoSrc) {
|
|
498
|
+
super(oneSrc, twoSrc);
|
|
499
|
+
this.oneSrc = oneSrc;
|
|
500
|
+
this.twoSrc = twoSrc;
|
|
501
|
+
}
|
|
502
|
+
value(o) {
|
|
503
|
+
new All(this.oneSrc, this.twoSrc).value(
|
|
504
|
+
new From(([one, two]) => {
|
|
505
|
+
o.give(one || two);
|
|
506
|
+
})
|
|
507
|
+
);
|
|
508
|
+
return this;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
325
511
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
baseSrc
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
512
|
+
class Not extends TheInformation {
|
|
513
|
+
constructor(baseSrc) {
|
|
514
|
+
super(baseSrc);
|
|
515
|
+
this.baseSrc = baseSrc;
|
|
516
|
+
}
|
|
517
|
+
value(o) {
|
|
518
|
+
this.baseSrc.value(
|
|
519
|
+
new From((v) => {
|
|
520
|
+
o.give(!v);
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
333
526
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
527
|
+
class Bool extends TheInformation {
|
|
528
|
+
constructor(baseSrc) {
|
|
529
|
+
super(baseSrc);
|
|
530
|
+
this.baseSrc = baseSrc;
|
|
531
|
+
}
|
|
532
|
+
value(o) {
|
|
533
|
+
new Applied(this.baseSrc, Boolean).value(o);
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
345
537
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
538
|
+
class FromJson extends TheInformation {
|
|
539
|
+
constructor(jsonSrc, errorOwner) {
|
|
540
|
+
super(jsonSrc);
|
|
541
|
+
this.jsonSrc = jsonSrc;
|
|
542
|
+
this.errorOwner = errorOwner;
|
|
543
|
+
}
|
|
544
|
+
value(o) {
|
|
545
|
+
this.jsonSrc.value(
|
|
546
|
+
new From((json) => {
|
|
547
|
+
try {
|
|
548
|
+
o.give(JSON.parse(json));
|
|
549
|
+
} catch (error) {
|
|
550
|
+
this.errorOwner?.give(new Error(`Failed to parse JSON: ${error}`));
|
|
551
|
+
}
|
|
552
|
+
})
|
|
553
|
+
);
|
|
554
|
+
return this;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
class ToJson extends TheInformation {
|
|
559
|
+
constructor(dataSrc, errorOwner) {
|
|
560
|
+
super(dataSrc);
|
|
561
|
+
this.dataSrc = dataSrc;
|
|
562
|
+
this.errorOwner = errorOwner;
|
|
563
|
+
}
|
|
564
|
+
value(o) {
|
|
565
|
+
this.dataSrc.value(
|
|
566
|
+
new From((data) => {
|
|
567
|
+
try {
|
|
568
|
+
o.give(JSON.stringify(data));
|
|
569
|
+
} catch {
|
|
570
|
+
this.errorOwner?.give(new Error("Failed to convert to JSON"));
|
|
571
|
+
}
|
|
572
|
+
})
|
|
573
|
+
);
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
357
577
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
578
|
+
class First extends TheInformation {
|
|
579
|
+
constructor(baseSrc) {
|
|
580
|
+
super(baseSrc);
|
|
581
|
+
this.baseSrc = baseSrc;
|
|
582
|
+
}
|
|
583
|
+
value(o) {
|
|
584
|
+
new Applied(this.baseSrc, (a) => a[0]).value(o);
|
|
585
|
+
return this;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
361
588
|
|
|
362
|
-
export {
|
|
589
|
+
export { And, Bool, Branch, Concatenated, Deadline, Deferred, Dirty, First, FromJson, HashTable, Loading, Lock, Memo, Not, OnlyChanged, Or, Path, RecordOf, RegexpMatch, RegexpMatched, RegexpReplaced, Router, Set, Shot, Tick, ToJson };
|
|
363
590
|
//# sourceMappingURL=silentium-components.mjs.map
|