silentium-components 0.0.4 → 0.0.6

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/silentium-components.cjs +134 -483
  3. package/dist/silentium-components.cjs.map +1 -1
  4. package/dist/silentium-components.d.ts +8 -190
  5. package/dist/silentium-components.js +130 -467
  6. package/dist/silentium-components.js.map +1 -1
  7. package/dist/silentium-components.min.js +1 -1
  8. package/dist/silentium-components.min.mjs +1 -1
  9. package/dist/silentium-components.min.mjs.map +1 -1
  10. package/dist/silentium-components.mjs +130 -467
  11. package/dist/silentium-components.mjs.map +1 -1
  12. package/docs/assets/js/index.mjs +3 -3
  13. package/docs/build.sh +3 -4
  14. package/docs/index.html +3 -3
  15. package/docs/pages/behaviors/deadline.html +60 -0
  16. package/docs/pages/behaviors/dirty.html +4 -4
  17. package/docs/pages/behaviors/loading.html +6 -6
  18. package/docs/pages/behaviors.html +5 -0
  19. package/docs/pages/structures/hash-table.html +4 -4
  20. package/docs/routes.json +1 -1
  21. package/eslint.config.mjs +1 -0
  22. package/package.json +7 -5
  23. package/src/behaviors/Deadline._value.test.ts +27 -0
  24. package/src/behaviors/Deadline.test.ts +28 -0
  25. package/src/behaviors/Deadline.ts +49 -0
  26. package/src/behaviors/Dirty.test.ts +5 -5
  27. package/src/behaviors/Dirty.ts +48 -54
  28. package/src/behaviors/Loading.test.ts +8 -8
  29. package/src/behaviors/Loading.ts +21 -31
  30. package/src/behaviors/Path.index.test.ts +5 -5
  31. package/src/behaviors/Path.nested.test.ts +5 -5
  32. package/src/behaviors/Path.test.ts +5 -5
  33. package/src/behaviors/Path.ts +26 -30
  34. package/src/behaviors/index.ts +1 -1
  35. package/src/controls/GroupActiveClass.test.ts +16 -13
  36. package/src/controls/GroupActiveClass.ts +19 -22
  37. package/src/controls/index.ts +0 -5
  38. package/src/index.ts +0 -2
  39. package/src/navigation/Router.test.ts +47 -0
  40. package/src/navigation/Router.ts +43 -111
  41. package/src/navigation/index.ts +0 -6
  42. package/src/structures/HashTable.test.ts +5 -5
  43. package/src/structures/HashTable.ts +14 -25
  44. package/src/system/RegexpMatched.test.ts +14 -0
  45. package/src/system/RegexpMatched.ts +17 -0
  46. package/src/system/index.ts +1 -0
  47. package/dist/patron-components.cjs +0 -372
  48. package/dist/patron-components.cjs.map +0 -1
  49. package/dist/patron-components.d.ts +0 -158
  50. package/dist/patron-components.js +0 -358
  51. package/dist/patron-components.js.map +0 -1
  52. package/dist/patron-components.min.js +0 -1
  53. package/dist/patron-components.min.mjs +0 -2
  54. package/dist/patron-components.min.mjs.map +0 -1
  55. package/dist/patron-components.mjs +0 -358
  56. package/dist/patron-components.mjs.map +0 -1
  57. package/src/behaviors/Touched.ts +0 -1
  58. package/src/controls/ComputedElement.ts +0 -51
  59. package/src/controls/Input.ts +0 -40
  60. package/src/controls/Link.ts +0 -53
  61. package/src/controls/Text.ts +0 -16
  62. package/src/controls/Visible.ts +0 -16
  63. package/src/jsdom/JSDomDocument.ts +0 -15
  64. package/src/jsdom/JSDomElement.ts +0 -28
  65. package/src/jsdom/JSDomQuerySelector.ts +0 -28
  66. package/src/navigation/CurrentPage.ts +0 -27
  67. package/src/navigation/Navigation.default.test.ts +0 -53
  68. package/src/navigation/Navigation.main.test.ts +0 -46
  69. package/src/navigation/Navigation.ts +0 -92
  70. package/src/navigation/Navigation.wildcard.test.ts +0 -52
  71. package/src/navigation/PageFetchTransport.ts +0 -26
  72. package/src/navigation/RouteDisplay.ts +0 -18
  73. package/src/navigation/RoutePageType.ts +0 -3
  74. package/src/page/EntryPointPage.ts +0 -20
  75. package/src/page/Page.ts +0 -12
  76. package/src/page/PageFake.ts +0 -8
  77. package/src/page/index.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
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.6](https://github.com/silentium-lab/silentium-components/compare/v0.0.5...v0.0.6) (2025-05-02)
6
+
7
+
8
+ ### Features
9
+
10
+ * **1-issue:** done deadline class ([1f4b785](https://github.com/silentium-lab/silentium-components/commit/1f4b785c6dc4241e71f8ec5fd2b4782f02adc58f))
11
+ * **1-issue:** moving to procedures ([83e85a9](https://github.com/silentium-lab/silentium-components/commit/83e85a9da06dbf8aece637801f1a116e016d2492))
12
+ * **main:** deadline to procedures ([087d4e6](https://github.com/silentium-lab/silentium-components/commit/087d4e689cd940c72364310b67f5da406055a0bc))
13
+ * **main:** deps updated ([6140111](https://github.com/silentium-lab/silentium-components/commit/61401111ef0e7bb7530aaa489f8210b56462fd4e))
14
+ * **main:** dirty to procedure ([c4291ca](https://github.com/silentium-lab/silentium-components/commit/c4291ca2aa3d499d8c4087b92798aff899530ff8))
15
+ * **main:** hashtable path and loading moved to procedures ([4edde10](https://github.com/silentium-lab/silentium-components/commit/4edde1001ab75dd9cbd1076fc16e7175ea9acafb))
16
+ * **main:** remove unneeded classes ([aafea7a](https://github.com/silentium-lab/silentium-components/commit/aafea7a7719d2b0561cff45edaa9e9efb01abbf2))
17
+ * **main:** router done ([c9f0648](https://github.com/silentium-lab/silentium-components/commit/c9f06482987c9421ae9c98165cf3f44af36edeaf))
18
+
19
+ ### [0.0.5](https://github.com/silentium-lab/silentium-components/compare/v0.0.4...v0.0.5) (2025-04-19)
20
+
21
+
22
+ ### Features
23
+
24
+ * **main:** fix source changeable renaming ([66fe284](https://github.com/silentium-lab/silentium-components/commit/66fe28421a4f6c0331c7eee8470cb2ccedb0c79e))
25
+ * **main:** release ([6f7d7d3](https://github.com/silentium-lab/silentium-components/commit/6f7d7d36590dc7e7fa4d65f3d56e00bc23cd79b3))
26
+
5
27
  ### [0.0.4](https://github.com/silentium-lab/silentium-components/compare/v0.0.3...v0.0.4) (2025-04-17)
6
28
 
7
29
 
@@ -1,498 +1,149 @@
1
1
  'use strict';
2
2
 
3
3
  var silentium = require('silentium');
4
- var silentiumWebApi = require('silentium-web-api');
5
4
 
6
- class PageFetchTransport {
7
- constructor(basePath, template) {
8
- this.basePath = basePath;
9
- this.template = template;
10
- }
11
- content(guest) {
12
- fetch(this.basePath + "/" + this.template).then((result) => {
13
- return result.text();
14
- }).then((result) => {
15
- silentium.give(result, guest);
16
- });
17
- }
18
- }
19
-
20
- class Navigation {
21
- constructor(loading, basePath, currentPage, display, pageTransport) {
22
- this.loading = loading;
23
- this.basePath = basePath;
24
- this.currentPage = currentPage;
25
- this.display = display;
26
- this.pageTransport = pageTransport;
27
- }
28
- routes(routes) {
29
- const defaultRoute = routes.find((route) => route.default);
30
- const all = new silentium.SourceAll();
31
- silentium.value(this.basePath, new silentium.Patron(all.guestKey("basePath")));
32
- silentium.value(this.currentPage, new silentium.Patron(all.guestKey("currentPage")));
33
- all.value(
34
- new silentium.Patron(({ basePath, currentPage }) => {
35
- const urlWithoutBasePath = currentPage.replace(basePath, "");
36
- const routeMatchedToAlias = routes.find(
37
- (route2) => route2.aliases && (route2.aliases.includes(currentPage) || route2.aliases.includes(urlWithoutBasePath))
38
- );
39
- if (routeMatchedToAlias) {
40
- const correctUrl = basePath + routeMatchedToAlias.url;
41
- if (correctUrl !== currentPage) {
42
- silentium.give(correctUrl, this.currentPage);
43
- return;
44
- }
5
+ const groupActiveClass = (activeClassSrc, activeElementSrc, groupElementsSrc) => {
6
+ silentium.value(
7
+ silentium.sourceAll([activeClassSrc, activeElementSrc, groupElementsSrc]),
8
+ silentium.patron(([activeClass, activeElement, groupElements]) => {
9
+ groupElements.forEach((el) => {
10
+ if (el.classList) {
11
+ el.classList.remove(activeClass);
45
12
  }
46
- let route = routes.find((route2) => {
47
- if (route2.url.indexOf("*") >= 0) {
48
- const regexp = new RegExp(
49
- route2.url.replaceAll("*", ".*").replaceAll("/", "/")
50
- );
51
- return regexp.test(urlWithoutBasePath);
52
- }
53
- return route2.url.replaceAll("*", "") === urlWithoutBasePath;
54
- });
55
- if (!route && defaultRoute) {
56
- route = defaultRoute;
57
- }
58
- if (route) {
59
- const basePathWithoutHash = basePath.replace("/#", "").replace("#", "").replace(/[^/]+\.html$/, "");
60
- silentium.give(true, this.loading);
61
- this.pageTransport.get(basePathWithoutHash, route.template).content((templateContent) => {
62
- this.display.display(templateContent);
63
- route.page.mounted();
64
- silentium.give(false, this.loading);
65
- });
66
- } else {
67
- throw new Error("No matching route in Navigation");
68
- }
69
- })
70
- );
71
- }
72
- }
73
-
74
- class RouteDisplay {
75
- constructor(selector) {
76
- this.selector = selector;
77
- }
78
- display(content) {
79
- const contentEl = document.querySelector(this.selector);
80
- if (contentEl) {
81
- contentEl.innerHTML = content;
82
- }
83
- }
84
- }
85
-
86
- var __defProp$3 = Object.defineProperty;
87
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
88
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
89
- class CurrentPage {
90
- constructor() {
91
- __publicField$3(this, "source");
92
- const correctUrl = location.href.replace(location.origin, "");
93
- this.source = new silentium.SourceWithPool(correctUrl);
94
- }
95
- give(value) {
96
- this.source.give(value);
97
- return this;
98
- }
99
- value(guest) {
100
- this.source.value(guest);
101
- return guest;
102
- }
103
- pool() {
104
- return this.source.pool();
105
- }
106
- }
107
-
108
- class Input {
109
- constructor(source, selector) {
110
- this.source = source;
111
- const el = document.querySelector(selector);
112
- this.source.value(
113
- new silentium.Patron((value) => {
114
- el.value = String(value);
115
- })
116
- );
117
- el.addEventListener("keyup", () => {
118
- this.give(el.value);
119
- });
120
- el.addEventListener("change", () => {
121
- this.give(el.value);
122
- });
123
- }
124
- value(guest) {
125
- this.source.value(guest);
126
- return this;
127
- }
128
- give(value) {
129
- this.source.give(value);
130
- return this;
131
- }
132
- pool() {
133
- return this.source.pool();
134
- }
135
- }
136
-
137
- class Visible {
138
- constructor(selector) {
139
- this.selector = selector;
140
- }
141
- give(isVisible) {
142
- const el = document.querySelector(this.selector);
143
- if (el) {
144
- el.style.display = isVisible ? "block" : "none";
145
- }
146
- return this;
147
- }
148
- }
149
-
150
- class Text {
151
- constructor(selector) {
152
- this.selector = selector;
153
- }
154
- give(value) {
155
- const element = document.querySelector(this.selector);
156
- if (element) {
157
- element.innerText = String(value);
158
- }
159
- return this;
160
- }
161
- }
162
-
163
- class Link {
164
- constructor(linkSource, basePath) {
165
- this.linkSource = linkSource;
166
- this.basePath = basePath;
167
- }
168
- watchClick(selector, subselector) {
169
- const wrapperEl = document.querySelectorAll(selector);
170
- if (wrapperEl.length) {
171
- wrapperEl.forEach((theElement) => {
172
- theElement.addEventListener("click", (e) => {
173
- if (subselector) {
174
- theElement.querySelectorAll(subselector).forEach((theSubElement) => {
175
- if (e?.target === theSubElement || e?.currentTarget === theSubElement) {
176
- this.handleClick({
177
- preventDefault: e.preventDefault.bind(e),
178
- target: theSubElement
179
- });
180
- }
181
- });
182
- } else {
183
- this.handleClick(e);
184
- }
185
- });
186
13
  });
187
- } else {
188
- throw new Error(`Link wrapper not found for selector ${selector}`);
189
- }
190
- }
191
- handleClick(e) {
192
- let href = e?.target?.getAttribute("href");
193
- if (!href) {
194
- href = e?.currentTarget?.getAttribute("href");
195
- }
196
- if (href && href.indexOf("http") !== 0) {
197
- e.preventDefault();
198
- silentium.value(this.basePath, (basePath) => {
199
- this.linkSource.give(basePath + href);
200
- });
201
- }
202
- }
203
- }
204
-
205
- class ComputedElement {
206
- constructor(sources, selectorTemplate) {
207
- this.sources = sources;
208
- this.selectorTemplate = selectorTemplate;
209
- }
210
- element(guest) {
211
- const chain = new silentium.SourceAll();
212
- this.sources.forEach((source) => {
213
- source.source.value(
214
- new silentium.GuestCast(guest, chain.guestKey(source.placeholder))
215
- );
216
- });
217
- chain.value(
218
- new silentium.GuestCast(
219
- guest,
220
- (placeholders) => {
221
- let selectorTemplate = this.selectorTemplate;
222
- Object.entries(placeholders).map((entry) => {
223
- selectorTemplate = selectorTemplate.replaceAll(entry[0], entry[1]);
224
- });
225
- const element = document.querySelector(
226
- selectorTemplate
227
- );
228
- if (element) {
229
- silentium.give(element, guest);
14
+ activeElement.classList.add(activeClass);
15
+ })
16
+ );
17
+ return groupElementsSrc;
18
+ };
19
+
20
+ const dirty = (baseEntitySource, becomePatronAuto = false, alwaysKeep = [], excludeKeys = []) => {
21
+ const comparingSrc = silentium.sourceOf();
22
+ const all = silentium.sourceAll([comparingSrc, baseEntitySource]);
23
+ const result = {
24
+ give(value2) {
25
+ silentium.give(JSON.parse(JSON.stringify(value2)), comparingSrc);
26
+ return result;
27
+ },
28
+ value(guest) {
29
+ silentium.value(
30
+ all,
31
+ silentium.guestCast(guest, ([comparing, base]) => {
32
+ if (!comparing) {
33
+ return;
230
34
  }
231
- }
232
- )
233
- );
234
- }
235
- }
236
-
237
- class GroupActiveClass {
238
- constructor(activeClass, groupSelector, document) {
239
- this.activeClass = activeClass;
240
- this.groupSelector = groupSelector;
241
- this.document = document;
242
- }
243
- give(element) {
244
- silentium.value(
245
- this.document,
246
- new silentium.PatronOnce((document) => {
247
- document.querySelectorAll(this.groupSelector).forEach((el) => {
248
- el.classList.remove(this.activeClass);
249
- });
250
- element.classList.add(this.activeClass);
251
- })
252
- );
253
- return this;
254
- }
255
- }
256
-
257
- class Router {
258
- constructor(loaderSelector, navigationResultSelector, menuSelector) {
259
- this.loaderSelector = loaderSelector;
260
- this.navigationResultSelector = navigationResultSelector;
261
- this.menuSelector = menuSelector;
262
- }
263
- routes(routes, currentPage, basePathSource, afterPageLoaded) {
264
- if (!currentPage) {
265
- currentPage = new CurrentPage();
266
- }
267
- currentPage.value(new silentium.Patron(new silentiumWebApi.HistoryNewPage()));
268
- const [basePath] = location.href.replace(location.origin, "").split("#");
269
- if (!basePathSource) {
270
- basePathSource = new silentium.SourceWithPool(
271
- `${basePath}#`.replace("index.html", "").replace("//", "/")
272
- );
273
- }
274
- const pageLoading = new silentium.SourceWithPool(false);
275
- pageLoading.value(new silentium.Patron(new Visible(this.loaderSelector)));
276
- const historyPoppedPage = new silentiumWebApi.HistoryPoppedPage(currentPage);
277
- historyPoppedPage.watchPop();
278
- const navigation = new Navigation(
279
- pageLoading,
280
- basePathSource,
281
- currentPage,
282
- new RouteDisplay(this.navigationResultSelector),
283
- new silentium.PrivateClass(PageFetchTransport)
284
- );
285
- navigation.routes(routes);
286
- const link = new Link(currentPage, basePathSource);
287
- link.watchClick(this.menuSelector);
288
- const urlChain = new silentium.SourceAll();
289
- basePathSource.value(new silentium.Patron(urlChain.guestKey("basePath")));
290
- currentPage.value(new silentium.Patron(urlChain.guestKey("page")));
291
- const url = new silentium.Source((guest) => {
292
- urlChain.value(
293
- new silentium.GuestCast(guest, ({ basePath: basePath2, page }) => {
294
- silentium.give(page.replace(basePath2, ""), guest);
35
+ silentium.give(
36
+ Object.fromEntries(
37
+ Object.entries(comparing).filter(([key, value2]) => {
38
+ if (alwaysKeep.includes(key)) {
39
+ return true;
40
+ }
41
+ if (excludeKeys.includes(key)) {
42
+ return false;
43
+ }
44
+ return value2 !== base[key];
45
+ })
46
+ ),
47
+ guest
48
+ );
295
49
  })
296
50
  );
297
- });
298
- const activeLink = new ComputedElement(
299
- [{ source: url, placeholder: "{url}" }],
300
- `${this.menuSelector} a[href="{url}"]`
301
- );
302
- activeLink.element(
303
- new silentium.Patron(
304
- new GroupActiveClass(
305
- "active",
306
- `${this.menuSelector} a`,
307
- silentium.sourceOf(document)
308
- )
309
- )
310
- );
311
- pageLoading.value(
312
- new silentium.Patron((isInLoading) => {
313
- if (isInLoading) {
314
- return;
315
- }
316
- if (afterPageLoaded) {
317
- afterPageLoaded();
318
- }
319
- const divDestination = document.querySelector(
320
- this.navigationResultSelector
321
- );
322
- if (divDestination) {
323
- divDestination.querySelectorAll("script").forEach((x) => {
324
- const sc = document.createElement("script");
325
- sc.setAttribute("type", "module");
326
- sc.appendChild(document.createTextNode(x.innerText));
327
- divDestination.appendChild(sc);
328
- });
329
- }
330
- })
331
- );
332
- }
333
- }
334
-
335
- class Page {
336
- constructor(title) {
337
- this.title = title;
338
- }
339
- mounted() {
340
- document.title = this.title;
341
- }
342
- }
343
-
344
- class EntryPointPage {
345
- constructor(title, entryPointUrl) {
346
- this.title = title;
347
- this.entryPointUrl = entryPointUrl;
348
- }
349
- mounted() {
350
- document.title = this.title;
351
- import(this.entryPointUrl).then((module) => {
352
- if (module.main) {
353
- module.main();
354
- }
355
- });
356
- }
357
- }
358
-
359
- var __defProp$2 = Object.defineProperty;
360
- var __defNormalProp$2 = (obj, key, value2) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
361
- var __publicField$2 = (obj, key, value2) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value2);
362
- class Dirty {
363
- constructor(baseEntitySource, alwaysKeep = [], excludeKeys = [], becomePatronAuto = false) {
364
- this.alwaysKeep = alwaysKeep;
365
- this.excludeKeys = excludeKeys;
366
- __publicField$2(this, "comparingSource", new silentium.SourceWithPool());
367
- __publicField$2(this, "all", new silentium.SourceAll());
368
- this.comparingSource.value(new silentium.Patron(this.all.guestKey("comparing")));
369
- silentium.value(baseEntitySource, new silentium.Patron(this.all.guestKey("base")));
370
- if (becomePatronAuto) {
371
- silentium.value(baseEntitySource, new silentium.PatronOnce(this));
51
+ return result;
372
52
  }
373
- }
374
- give(value2) {
375
- silentium.give(JSON.parse(JSON.stringify(value2)), this.comparingSource);
376
- return this;
377
- }
378
- value(guest) {
379
- this.all.value(
380
- new silentium.GuestCast(guest, ({ comparing, base }) => {
381
- if (!comparing) {
382
- return;
383
- }
384
- silentium.give(
385
- Object.fromEntries(
386
- Object.entries(comparing).filter(([key, value2]) => {
387
- if (this.alwaysKeep.includes(key)) {
388
- return true;
389
- }
390
- if (this.excludeKeys.includes(key)) {
391
- return false;
392
- }
393
- return value2 !== base[key];
394
- })
395
- ),
396
- guest
397
- );
398
- })
399
- );
400
- return this;
401
- }
402
- }
403
-
404
- var __defProp$1 = Object.defineProperty;
405
- var __defNormalProp$1 = (obj, key, value2) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
406
- var __publicField$1 = (obj, key, value2) => __defNormalProp$1(obj, key + "" , value2);
407
- class Loading {
408
- constructor(loadingStartSource, loadingFinishSource) {
409
- this.loadingStartSource = loadingStartSource;
410
- this.loadingFinishSource = loadingFinishSource;
411
- __publicField$1(this, "loadingSource", new silentium.SourceWithPool());
412
- }
413
- value(guest) {
414
- silentium.value(
415
- this.loadingStartSource,
416
- new silentium.GuestCast(guest, () => {
417
- this.loadingSource.give(true);
418
- })
419
- );
53
+ };
54
+ if (becomePatronAuto) {
55
+ silentium.value(baseEntitySource, silentium.patronOnce(result));
56
+ }
57
+ return result;
58
+ };
59
+
60
+ const loading = (loadingStartSource, loadingFinishSource) => {
61
+ const loadingSrc = silentium.sourceOf();
62
+ silentium.subSourceMany(loadingSrc, [loadingStartSource, loadingFinishSource]);
63
+ silentium.value(
64
+ loadingStartSource,
65
+ silentium.patron(() => {
66
+ loadingSrc.give(true);
67
+ })
68
+ );
69
+ silentium.value(
70
+ loadingFinishSource,
71
+ silentium.patron(() => {
72
+ loadingSrc.give(false);
73
+ })
74
+ );
75
+ return loadingSrc.value;
76
+ };
77
+
78
+ const path = (baseSrc, keySrc) => {
79
+ const pathSrc = silentium.sourceOf();
80
+ silentium.subSourceMany(pathSrc, [baseSrc, keySrc]);
81
+ silentium.value(
82
+ silentium.sourceAll([baseSrc, keySrc]),
83
+ silentium.patron(([base, key]) => {
84
+ const keyChunks = key.split(".");
85
+ let value2 = base;
86
+ keyChunks.forEach((keyChunk) => {
87
+ value2 = value2[keyChunk];
88
+ });
89
+ if (value2 !== void 0 && value2 !== base) {
90
+ silentium.give(value2, pathSrc);
91
+ }
92
+ })
93
+ );
94
+ return pathSrc.value;
95
+ };
96
+
97
+ const deadline = (error, baseSrc, timeoutSrc) => {
98
+ let timerHead = null;
99
+ return (g) => {
420
100
  silentium.value(
421
- this.loadingFinishSource,
422
- new silentium.GuestCast(guest, () => {
423
- this.loadingSource.give(false);
424
- })
425
- );
426
- this.loadingSource.value(guest);
427
- return this;
428
- }
429
- }
430
-
431
- class Touched {
432
- }
433
-
434
- class Path {
435
- constructor(baseSource, keyType) {
436
- this.baseSource = baseSource;
437
- this.keyType = keyType;
438
- }
439
- value(guest) {
440
- const all = new silentium.SourceAll(["base", "key"]);
441
- silentium.value(this.baseSource, new silentium.GuestCast(guest, all.guestKey("base")));
442
- silentium.value(this.keyType, new silentium.GuestCast(guest, all.guestKey("key")));
443
- all.value(
444
- new silentium.GuestCast(guest, ({ base, key }) => {
445
- const keyChunks = key.split(".");
446
- let value2 = base;
447
- keyChunks.forEach((keyChunk) => {
448
- value2 = value2[keyChunk];
449
- });
450
- if (value2 !== void 0 && value2 !== base) {
451
- silentium.give(value2, guest);
101
+ timeoutSrc,
102
+ silentium.guestCast(g, (timeout) => {
103
+ if (timerHead) {
104
+ clearTimeout(timerHead);
452
105
  }
106
+ let timeoutReached = false;
107
+ timerHead = setTimeout(() => {
108
+ if (timeoutReached) {
109
+ return;
110
+ }
111
+ timeoutReached = true;
112
+ silentium.give(new Error("Timeout reached in Deadline class"), error);
113
+ }, timeout);
114
+ silentium.value(
115
+ silentium.sourceFiltered(baseSrc, () => !timeoutReached),
116
+ g
117
+ );
118
+ silentium.value(
119
+ baseSrc,
120
+ silentium.patronOnce(() => {
121
+ timeoutReached = true;
122
+ })
123
+ );
453
124
  })
454
125
  );
455
- return this;
456
- }
457
- }
458
-
459
- var __defProp = Object.defineProperty;
460
- var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
461
- var __publicField = (obj, key, value2) => __defNormalProp(obj, key + "" , value2);
462
- class HashTable {
463
- constructor(baseSource) {
464
- __publicField(this, "source", new silentium.SourceWithPool({}));
465
- silentium.value(
466
- baseSource,
467
- new silentium.Patron(([key, value2]) => {
468
- this.source.value((lastRecord) => {
469
- lastRecord[key] = value2;
470
- });
471
- })
472
- );
473
- }
474
- value(guest) {
475
- silentium.value(this.source, guest);
476
- return this;
477
- }
478
- }
479
-
480
- exports.ComputedElement = ComputedElement;
481
- exports.CurrentPage = CurrentPage;
482
- exports.Dirty = Dirty;
483
- exports.EntryPointPage = EntryPointPage;
484
- exports.GroupActiveClass = GroupActiveClass;
485
- exports.HashTable = HashTable;
486
- exports.Input = Input;
487
- exports.Link = Link;
488
- exports.Loading = Loading;
489
- exports.Navigation = Navigation;
490
- exports.Page = Page;
491
- exports.PageFetchTransport = PageFetchTransport;
492
- exports.Path = Path;
493
- exports.RouteDisplay = RouteDisplay;
494
- exports.Router = Router;
495
- exports.Text = Text;
496
- exports.Touched = Touched;
497
- exports.Visible = Visible;
126
+ };
127
+ };
128
+
129
+ const hashTable = (baseSource) => {
130
+ const result = silentium.sourceOf({});
131
+ silentium.subSource(result, baseSource);
132
+ silentium.value(
133
+ baseSource,
134
+ silentium.patron(([key, value2]) => {
135
+ result.value((lastRecord) => {
136
+ lastRecord[key] = value2;
137
+ });
138
+ })
139
+ );
140
+ return result.value;
141
+ };
142
+
143
+ exports.deadline = deadline;
144
+ exports.dirty = dirty;
145
+ exports.groupActiveClass = groupActiveClass;
146
+ exports.hashTable = hashTable;
147
+ exports.loading = loading;
148
+ exports.path = path;
498
149
  //# sourceMappingURL=silentium-components.cjs.map