silentium-components 0.0.65 → 0.0.67

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 (92) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/silentium-components.cjs +215 -215
  3. package/dist/silentium-components.cjs.map +1 -1
  4. package/dist/silentium-components.d.ts +47 -47
  5. package/dist/silentium-components.js +181 -181
  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 +181 -181
  11. package/dist/silentium-components.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/src/behaviors/Branch._main.test.ts +7 -7
  14. package/src/behaviors/Branch.branchesDontAffectResult.test.ts +7 -7
  15. package/src/behaviors/Branch.dontRespondAfterRespond.test.ts +7 -7
  16. package/src/behaviors/Branch.ts +9 -9
  17. package/src/behaviors/BranchLazy._main.test.ts +7 -7
  18. package/src/behaviors/BranchLazy.ts +9 -9
  19. package/src/behaviors/Const.test.ts +4 -4
  20. package/src/behaviors/Const.ts +5 -5
  21. package/src/behaviors/Deadline._main.test.ts +4 -4
  22. package/src/behaviors/Deadline._value.test.ts +4 -4
  23. package/src/behaviors/Deadline.ts +8 -8
  24. package/src/behaviors/Deferred.test.ts +6 -6
  25. package/src/behaviors/Deferred.ts +8 -8
  26. package/src/behaviors/Detached.test.ts +4 -4
  27. package/src/behaviors/Detached.ts +4 -4
  28. package/src/behaviors/Dirty.test.ts +4 -4
  29. package/src/behaviors/Dirty.ts +9 -9
  30. package/src/behaviors/Loading.test.ts +5 -5
  31. package/src/behaviors/Loading.ts +7 -7
  32. package/src/behaviors/Lock.test.ts +6 -6
  33. package/src/behaviors/Lock.ts +7 -7
  34. package/src/behaviors/Memo.test.ts +4 -4
  35. package/src/behaviors/Memo.ts +5 -5
  36. package/src/behaviors/OnlyChanged.test.ts +4 -4
  37. package/src/behaviors/OnlyChanged.ts +4 -4
  38. package/src/behaviors/Part.test.ts +5 -5
  39. package/src/behaviors/Part.ts +10 -14
  40. package/src/behaviors/Path._main.test.ts +3 -3
  41. package/src/behaviors/Path.index.test.ts +3 -3
  42. package/src/behaviors/Path.nested.test.ts +3 -3
  43. package/src/behaviors/Path.ts +8 -12
  44. package/src/behaviors/Polling.test.ts +4 -4
  45. package/src/behaviors/Polling.ts +5 -5
  46. package/src/behaviors/Shot._main.test.ts +5 -5
  47. package/src/behaviors/Shot._onlyChanged.test.ts +6 -6
  48. package/src/behaviors/Shot.ts +8 -8
  49. package/src/behaviors/Task.ts +7 -7
  50. package/src/behaviors/Tick.test.ts +5 -5
  51. package/src/behaviors/Tick.ts +5 -5
  52. package/src/boolean/And.test.ts +5 -5
  53. package/src/boolean/And.ts +7 -7
  54. package/src/boolean/Bool.test.ts +3 -3
  55. package/src/boolean/Bool.ts +6 -6
  56. package/src/boolean/Not.test.ts +4 -4
  57. package/src/boolean/Not.ts +4 -4
  58. package/src/boolean/Or.test.ts +5 -5
  59. package/src/boolean/Or.ts +7 -7
  60. package/src/formats/FromJson.test.ts +4 -4
  61. package/src/formats/FromJson.ts +5 -5
  62. package/src/formats/ToJson.test.ts +4 -4
  63. package/src/formats/ToJson.ts +5 -5
  64. package/src/lists/First.test.ts +3 -3
  65. package/src/lists/First.ts +7 -7
  66. package/src/navigation/Router._main.test.ts +9 -9
  67. package/src/navigation/Router._nested.test.ts +20 -20
  68. package/src/navigation/Router.ts +23 -23
  69. package/src/strings/Concatenated.test.ts +5 -5
  70. package/src/strings/Concatenated.ts +9 -9
  71. package/src/strings/Template._main.test.ts +11 -11
  72. package/src/strings/Template._place.test.ts +4 -4
  73. package/src/strings/Template.ts +19 -19
  74. package/src/structures/HashTable.test.ts +4 -4
  75. package/src/structures/HashTable.ts +5 -5
  76. package/src/structures/Record._main.test.ts +6 -6
  77. package/src/structures/Record.concatenated.test.ts +10 -10
  78. package/src/structures/Record.nested.test.ts +9 -9
  79. package/src/structures/RecordOf.ts +8 -8
  80. package/src/system/RegexpMatch._group.test.ts +5 -5
  81. package/src/system/RegexpMatch._main.test.ts +5 -5
  82. package/src/system/RegexpMatch.ts +9 -9
  83. package/src/system/RegexpMatched.test.ts +4 -4
  84. package/src/system/RegexpMatched.ts +8 -8
  85. package/src/system/RegexpReplaced.test.ts +4 -4
  86. package/src/system/RegexpReplaced.ts +8 -8
  87. package/src/system/Set.test.ts +4 -4
  88. package/src/system/Set.ts +7 -7
  89. package/docs/assets/js/components/linkDynamic.mjs +0 -14
  90. package/docs/assets/js/components/linkReloadable.mjs +0 -17
  91. package/docs/assets/js/components.mjs +0 -2
  92. package/docs/assets/js/index.mjs +0 -271
@@ -1,17 +1,17 @@
1
- import { late, of, shared } from "silentium";
2
- import { concatenated } from "../strings";
3
- import { recordOf } from "../structures/RecordOf";
1
+ import { Late, Of, Shared } from "silentium";
2
+ import { Concatenated } from "../strings";
3
+ import { RecordOf } from "../structures/RecordOf";
4
4
  import { expect, test, vi } from "vitest";
5
5
 
6
6
  test("Record.concatenated.test", () => {
7
- const three = of<string>("three");
8
- const concatPart = late<string>("part");
9
- const r = shared(
10
- recordOf({
11
- one: of("one"),
12
- two: of("two"),
7
+ const three = Of<string>("three");
8
+ const concatPart = Late<string>("part");
9
+ const r = Shared(
10
+ RecordOf({
11
+ one: Of("one"),
12
+ two: Of("two"),
13
13
  three,
14
- nested: concatenated([of("one"), concatPart.event]),
14
+ nested: Concatenated([Of("one"), concatPart.event]),
15
15
  }),
16
16
  );
17
17
  const g = vi.fn();
@@ -1,16 +1,16 @@
1
- import { of } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { recordOf } from "./RecordOf";
3
+ import { RecordOf } from "./RecordOf";
4
4
 
5
5
  test("Record.nested.test", () => {
6
- const three = of<string>("three");
7
- const recordSrc = recordOf({
8
- one: of("one"),
9
- two: of("two"),
6
+ const three = Of<string>("three");
7
+ const recordSrc = RecordOf({
8
+ one: Of("one"),
9
+ two: Of("two"),
10
10
  three,
11
- nested: recordOf({
12
- four: of("four"),
13
- five: of("five"),
11
+ nested: RecordOf({
12
+ four: Of("four"),
13
+ five: Of("five"),
14
14
  }),
15
15
  });
16
16
  const g = vi.fn();
@@ -1,22 +1,22 @@
1
- import { all, EventType } from "silentium";
1
+ import { All, EventType } from "silentium";
2
2
 
3
3
  type UnInformation<T> = T extends EventType<infer U> ? U : never;
4
4
 
5
5
  /**
6
- * Returns record of data from record of sources
6
+ * Returns record Of data from record Of sources
7
7
  * https://silentium-lab.github.io/silentium-components/#/structures/record
8
8
  */
9
- export const recordOf = <T extends EventType>(
9
+ export function RecordOf<T extends EventType>(
10
10
  recordSrc: Record<string, T>,
11
- ): EventType<Record<string, UnInformation<T>>> => {
12
- return (u) => {
11
+ ): EventType<Record<string, UnInformation<T>>> {
12
+ return (user) => {
13
13
  const keys = Object.keys(recordSrc);
14
- all(...Object.values(recordSrc))((entries) => {
14
+ All(...Object.values(recordSrc))((entries) => {
15
15
  const record: Record<string, any> = {};
16
16
  entries.forEach((entry, index) => {
17
17
  record[keys[index]] = entry;
18
18
  });
19
- u(record);
19
+ user(record);
20
20
  });
21
21
  };
22
- };
22
+ }
@@ -1,11 +1,11 @@
1
- import { of } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { path } from "../behaviors";
4
- import { regexpMatch } from "./RegexpMatch";
3
+ import { Path } from "../behaviors";
4
+ import { RegexpMatch } from "./RegexpMatch";
5
5
 
6
6
  test("RegexpMatch._group.test", () => {
7
- const urlSrc = of<string>("http://domain.com/some/url/");
8
- const matchedSrc = path(regexpMatch(of("/(s\\w+)/"), urlSrc), of("1"));
7
+ const urlSrc = Of<string>("http://domain.com/some/url/");
8
+ const matchedSrc = Path(RegexpMatch(Of("/(s\\w+)/"), urlSrc), Of("1"));
9
9
  const g = vi.fn();
10
10
  matchedSrc(g);
11
11
 
@@ -1,11 +1,11 @@
1
- import { of } from "silentium";
1
+ import { Of } from "silentium";
2
2
  import { expect, test, vi } from "vitest";
3
- import { path } from "../behaviors";
4
- import { regexpMatch } from "./RegexpMatch";
3
+ import { Path } from "../behaviors";
4
+ import { RegexpMatch } from "./RegexpMatch";
5
5
 
6
6
  test("RegexpMatch._main.test", () => {
7
- const urlSrc = of<string>("http://domain.com/some/url/");
8
- const matchedSrc = path(regexpMatch(of("/(s\\w+)/"), urlSrc), of("0"));
7
+ const urlSrc = Of<string>("http://domain.com/some/url/");
8
+ const matchedSrc = Path(RegexpMatch(Of("/(s\\w+)/"), urlSrc), Of("0"));
9
9
  const g = vi.fn();
10
10
  matchedSrc(g);
11
11
 
@@ -1,22 +1,22 @@
1
- import { all, EventType, of } from "silentium";
1
+ import { All, EventType, Of } from "silentium";
2
2
 
3
3
  /**
4
- * First match of regexp
4
+ * First match Of regexp
5
5
  * https://silentium-lab.github.io/silentium-components/#/system/regexp-matched
6
6
  */
7
- export const regexpMatch = (
7
+ export function RegexpMatch(
8
8
  patternSrc: EventType<string>,
9
9
  valueSrc: EventType<string>,
10
- flagsSrc: EventType<string> = of(""),
11
- ): EventType<string[]> => {
12
- return (u) => {
13
- all(
10
+ flagsSrc: EventType<string> = Of(""),
11
+ ): EventType<string[]> {
12
+ return (user) => {
13
+ All(
14
14
  patternSrc,
15
15
  valueSrc,
16
16
  flagsSrc,
17
17
  )(([pattern, value, flags]) => {
18
18
  const result = new RegExp(pattern, flags).exec(value);
19
- u(result ?? []);
19
+ user(result ?? []);
20
20
  });
21
21
  };
22
- };
22
+ }
@@ -1,10 +1,10 @@
1
- import { late, of } from "silentium";
2
- import { regexpMatched } from "../system/RegexpMatched";
1
+ import { Late, Of } from "silentium";
2
+ import { RegexpMatched } from "../system/RegexpMatched";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("RegexpMatched.test", () => {
6
- const urlI = late<string>("http://domain.com/some/url/");
7
- const matchedSrc = regexpMatched(of("/some/url"), urlI.event);
6
+ const urlI = Late<string>("http://domain.com/some/url/");
7
+ const matchedSrc = RegexpMatched(Of("/some/url"), urlI.event);
8
8
  const g = vi.fn();
9
9
  matchedSrc(g);
10
10
 
@@ -1,21 +1,21 @@
1
- import { all, EventType, of } from "silentium";
1
+ import { All, EventType, Of } from "silentium";
2
2
 
3
3
  /**
4
4
  * Boolean source what checks what string matches pattern
5
5
  * https://silentium-lab.github.io/silentium-components/#/system/regexp-matched
6
6
  */
7
- export const regexpMatched = (
7
+ export function RegexpMatched(
8
8
  patternSrc: EventType<string>,
9
9
  valueSrc: EventType<string>,
10
- flagsSrc: EventType<string> = of(""),
11
- ): EventType<boolean> => {
12
- return (u) => {
13
- all(
10
+ flagsSrc: EventType<string> = Of(""),
11
+ ): EventType<boolean> {
12
+ return (user) => {
13
+ All(
14
14
  patternSrc,
15
15
  valueSrc,
16
16
  flagsSrc,
17
17
  )(([pattern, value, flags]) => {
18
- u(new RegExp(pattern, flags).test(value));
18
+ user(new RegExp(pattern, flags).test(value));
19
19
  });
20
20
  };
21
- };
21
+ }
@@ -1,10 +1,10 @@
1
- import { late, of } from "silentium";
2
- import { regexpReplaced } from "../system/RegexpReplaced";
1
+ import { Late, Of } from "silentium";
2
+ import { RegexpReplaced } from "../system/RegexpReplaced";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("RegexpReplaced.test", () => {
6
- const urlSrc = late<string>("http://domain.com/some/url/");
7
- const matchedSrc = regexpReplaced(urlSrc.event, of("some/url/"), of(""));
6
+ const urlSrc = Late<string>("http://domain.com/some/url/");
7
+ const matchedSrc = RegexpReplaced(urlSrc.event, Of("some/url/"), Of(""));
8
8
  const g = vi.fn();
9
9
  matchedSrc(g);
10
10
 
@@ -1,23 +1,23 @@
1
- import { all, EventType, of } from "silentium";
1
+ import { All, EventType, Of } from "silentium";
2
2
 
3
3
  /**
4
4
  * Returns string replaced by regular expression pattern
5
5
  * https://silentium-lab.github.io/silentium-components/#/system/regexp-replaced
6
6
  */
7
- export const regexpReplaced = (
7
+ export function RegexpReplaced(
8
8
  valueSrc: EventType<string>,
9
9
  patternSrc: EventType<string>,
10
10
  replaceValueSrc: EventType<string>,
11
- flagsSrc: EventType<string> = of(""),
12
- ): EventType<string> => {
13
- return (u) => {
14
- all(
11
+ flagsSrc: EventType<string> = Of(""),
12
+ ): EventType<string> {
13
+ return (user) => {
14
+ All(
15
15
  patternSrc,
16
16
  valueSrc,
17
17
  replaceValueSrc,
18
18
  flagsSrc,
19
19
  )(([pattern, value, replaceValue, flags]) => {
20
- u(String(value).replace(new RegExp(pattern, flags), replaceValue));
20
+ user(String(value).replace(new RegExp(pattern, flags), replaceValue));
21
21
  });
22
22
  };
23
- };
23
+ }
@@ -1,13 +1,13 @@
1
- import { late, of } from "silentium";
2
- import { set } from "../system/Set";
1
+ import { Late, Of } from "silentium";
2
+ import { Set } from "../system/Set";
3
3
  import { expect, test, vi } from "vitest";
4
4
 
5
5
  test("Set.test", () => {
6
- const value = late<string>();
6
+ const value = Late<string>();
7
7
  const object = {
8
8
  value: "hello",
9
9
  };
10
- const obj = set(of(object), of("value"), value.event);
10
+ const obj = Set(Of(object), Of("value"), value.event);
11
11
  const g = vi.fn();
12
12
  obj(g);
13
13
 
package/src/system/Set.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { all, EventType } from "silentium";
1
+ import { All, EventType } from "silentium";
2
2
 
3
3
  /**
4
4
  * Ability to mutate some object, helpful when integrate to procedure systems
5
5
  * https://silentium-lab.github.io/silentium-components/#/system/set
6
6
  */
7
- export const set = <T extends Record<string, unknown>>(
7
+ export function Set<T extends Record<string, unknown>>(
8
8
  baseSrc: EventType<T>,
9
9
  keySrc: EventType<string>,
10
10
  valueSrc: EventType<unknown>,
11
- ): EventType<T> => {
12
- return (u) => {
13
- all(
11
+ ): EventType<T> {
12
+ return (user) => {
13
+ All(
14
14
  baseSrc,
15
15
  keySrc,
16
16
  valueSrc,
17
17
  )(([base, key, value]) => {
18
18
  (base as Record<string, unknown>)[key] = value;
19
- u(base);
19
+ user(base);
20
20
  });
21
21
  };
22
- };
22
+ }
@@ -1,14 +0,0 @@
1
- window.customElements.define(
2
- "link-dynamic",
3
- class extends HTMLElement {
4
- constructor() {
5
- super();
6
- const href = this.getAttribute("href");
7
- const content = this.innerHTML;
8
- this.innerHTML = `<a
9
- class="inline-block whitespace-nowrap rounded-[0.27rem] bg-primary-100 px-[0.65em] pb-[0.25em] pt-[0.35em] text-center align-baseline text-[0.75em] font-bold leading-none text-white bg-slate-900 dynamic-navigation"
10
- href="#${href}"
11
- >${content}</a>`;
12
- }
13
- },
14
- );
@@ -1,17 +0,0 @@
1
- window.customElements.define(
2
- "link-reloadable",
3
- class extends HTMLElement {
4
- constructor() {
5
- super();
6
- const href = this.getAttribute("href");
7
- const target =
8
- this.getAttribute("target-blank") !== null ? 'target="_blank"' : "";
9
- const content = this.innerHTML;
10
- this.innerHTML = `<a
11
- class="inline-block whitespace-nowrap rounded-[0.27rem] bg-primary-100 px-[0.65em] pb-[0.25em] pt-[0.35em] text-center align-baseline text-[0.75em] font-bold leading-none text-white bg-slate-900"
12
- href="${href}"
13
- ${target}
14
- >${content}</a>`;
15
- }
16
- },
17
- );
@@ -1,2 +0,0 @@
1
- import "./components/linkDynamic.mjs";
2
- import "./components/linkReloadable.mjs";
@@ -1,271 +0,0 @@
1
- import {
2
- lazy,
3
- lazyClass,
4
- patron,
5
- sourceAny,
6
- sourceApplied,
7
- sourceChain,
8
- sourceMap,
9
- sourceMemoOf,
10
- sourceOf,
11
- sourceSync,
12
- value,
13
- } from "silentium";
14
- import {
15
- branch,
16
- concatenated,
17
- deferred,
18
- loading,
19
- memo,
20
- moment,
21
- not,
22
- onlyChanged,
23
- path,
24
- record,
25
- regexpMatch,
26
- regexpReplaced,
27
- router,
28
- set,
29
- shot,
30
- tick
31
- } from "silentium-components";
32
- import {
33
- attribute,
34
- classRemoved,
35
- element,
36
- elements,
37
- fetched,
38
- historyNewPate,
39
- historyPoppedPage,
40
- html,
41
- link,
42
- log,
43
- styleInstalled,
44
- visible,
45
- } from "silentium-web-api";
46
- import "./components.mjs";
47
-
48
- // Initializing components with predefined values
49
- const nativeHistoryUrl = historyNewPate.bind(null, window.history);
50
- const nativeElement = element.bind(
51
- null,
52
- lazyClass(window.MutationObserver),
53
- window.document,
54
- );
55
- const nativeElements = elements.bind(
56
- null,
57
- lazyClass(window.MutationObserver),
58
- window.document,
59
- );
60
- const nativeLog = log.bind(null, window.console);
61
-
62
- const nativeFetched = fetched.bind(null, {
63
- fetch: window.fetch.bind(window),
64
- });
65
-
66
- // Internationalization
67
- const defaultLang = "ru";
68
- const langFromUrlSrc = sourceAny([
69
- "ru",
70
- path(regexpMatch("/(\\w{2})/", window.location.hash), "1"),
71
- ]);
72
- window.langSrc = sourceMemoOf(langFromUrlSrc);
73
- set(nativeElement(".lang-select"), "value", window.langSrc);
74
- const isDefaultLangSrc = sourceApplied(
75
- window.langSrc,
76
- (l) => l === defaultLang,
77
- );
78
-
79
- // Url source
80
- const basePath = concatenated([
81
- window.location.origin,
82
- regexpReplaced(window.location.pathname, "index(-dev)?\\.html", ""),
83
- ]);
84
- window.basePath = basePath;
85
-
86
- const urlSrc = regexpReplaced(
87
- sourceAny([
88
- historyPoppedPage(window, sourceOf()),
89
- window.location.href,
90
- concatenated([
91
- window.location.origin,
92
- window.location.pathname,
93
- link(nativeElement("body"), ".dynamic-navigation"),
94
- ]),
95
- ]),
96
- concatenated(["#/", window.langSrc, "/"]),
97
- "#/",
98
- );
99
-
100
- window.urlSrc = urlSrc;
101
-
102
- const langUrlPartSrc = branch(
103
- isDefaultLangSrc,
104
- "/",
105
- concatenated(["/", window.langSrc, "/"]),
106
- );
107
-
108
- nativeHistoryUrl(
109
- regexpReplaced(urlSrc, "#/", concatenated(["#", langUrlPartSrc])),
110
- );
111
-
112
- // Loading main styles and remove loading class on body after styles loaded
113
- const bodyStylesReady = sourceChain(
114
- styleInstalled(
115
- window.document,
116
- nativeFetched(
117
- record({
118
- method: "get",
119
- url: "https://raw.githubusercontent.com/kosukhin/patorn-design-system/refs/heads/main/dist/assets/index.css",
120
- }),
121
- ),
122
- ),
123
- window.document.body,
124
- );
125
- classRemoved(bodyStylesReady, "body-loading");
126
-
127
- // All errors collected here
128
- const errors = sourceOf();
129
- nativeLog("ERROR: ", errors);
130
-
131
- // Building routes of SPA
132
- const routesRequestSrc = record({
133
- method: "get",
134
- url: concatenated([basePath, "routes.json"]),
135
- });
136
- const routesSrc = sourceApplied(
137
- sourceMap(
138
- sourceApplied(nativeFetched(routesRequestSrc, errors), JSON.parse),
139
- lazy((route) =>
140
- record({
141
- pattern: regexpReplaced(route, "pages/(.+).html", "#/$1/?$"),
142
- template: regexpReplaced(route, "pages/", ""),
143
- }),
144
- ),
145
- ),
146
- Array.prototype.concat.bind([
147
- {
148
- pattern: "/$",
149
- template: "index.html",
150
- },
151
- {
152
- pattern: "#/$",
153
- template: "index.html",
154
- },
155
- {
156
- pattern: "\\.html$",
157
- template: "index.html",
158
- },
159
- ]),
160
- );
161
-
162
- const layoutContentSrc = nativeFetched(
163
- record({
164
- method: "get",
165
- url: tick(
166
- sourceAny([
167
- concatenated([basePath, sourceChain(urlSrc, "layouts/default.html")]),
168
- ]),
169
- ),
170
- }),
171
- );
172
- html(nativeElement("article.container .page-area"), layoutContentSrc);
173
-
174
- const templateUrlSrc = deferred(urlSrc, layoutContentSrc);
175
-
176
- const templateLangUrlPartSrc = deferred(langUrlPartSrc, layoutContentSrc);
177
-
178
- // Template content fetching
179
- const templateSrc = tick(router(templateUrlSrc, routesSrc, "404.html"));
180
-
181
- const templateRequestSrc = record({
182
- method: "get",
183
- url: memo(
184
- concatenated([basePath, "pages", templateLangUrlPartSrc, templateSrc]),
185
- ),
186
- });
187
-
188
- const templateContentSrc = nativeFetched(templateRequestSrc, errors);
189
- window.urlChanged = shot(urlSrc, onlyChanged(urlSrc));
190
-
191
- // Template loading visualization
192
- const templateContentLoadingSrc = loading(urlSrc, layoutContentSrc);
193
- visible(templateContentLoadingSrc, nativeElement("article.container .loader"));
194
- visible(
195
- not(templateContentLoadingSrc),
196
- nativeElement("article.container .page-area"),
197
- );
198
- html(
199
- nativeElement(sourceChain(layoutContentSrc, ".layout-content")),
200
- templateContentSrc,
201
- );
202
-
203
- // Template title
204
- value(
205
- path(
206
- nativeElement(sourceChain(templateContentSrc, ".page-title")),
207
- "textContent",
208
- ),
209
- patron((v) => (window.document.title = v)),
210
- );
211
-
212
- // chunks rendering
213
- const chunkError = sourceOf();
214
- value(chunkError, patron(errors));
215
- sourceSync(
216
- sourceMap(
217
- sourceChain(templateContentSrc, nativeElements(".chunk")),
218
- lazy((el) => {
219
- return html(
220
- el,
221
- sourceAny([
222
- sourceChain(chunkError, "ChunkError!"),
223
- nativeFetched(
224
- record({
225
- method: "get",
226
- url: concatenated([
227
- basePath,
228
- "chunks",
229
- moment(langUrlPartSrc),
230
- attribute("data-url", el),
231
- ]),
232
- }),
233
- chunkError,
234
- ),
235
- ]),
236
- );
237
- }),
238
- ),
239
- );
240
-
241
- // scripts alive on new loaded page
242
- value(
243
- templateContentSrc,
244
- patron(() => {
245
- window.setTimeout(() => {
246
- window.hljs.highlightAll();
247
- }, 0);
248
- const destination = window.document.querySelector(
249
- "article.container .page-area",
250
- );
251
- destination.querySelectorAll("script").forEach((x) => {
252
- if (x.getAttribute("type") === "text/template") {
253
- return;
254
- }
255
-
256
- if (x.getAttribute("data-listing")) {
257
- const listingEl = window.document.querySelector(
258
- x.getAttribute("data-listing"),
259
- );
260
- if (listingEl) {
261
- listingEl.textContent = x.innerText.trim();
262
- }
263
- }
264
-
265
- const sc = window.document.createElement("script");
266
- sc.setAttribute("type", "module");
267
- sc.appendChild(window.document.createTextNode(x.innerText));
268
- destination.appendChild(sc);
269
- });
270
- }),
271
- );