aprog 2.3.1 → 2.3.3

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 (3) hide show
  1. package/README.md +0 -19
  2. package/package.json +1 -1
  3. package/src/router.js +27 -5
package/README.md CHANGED
@@ -106,24 +106,6 @@ export default NamePage;
106
106
 
107
107
  ```
108
108
 
109
- Приклад використання методів дебагу:
110
-
111
- ```shell
112
-
113
- const int = 0;
114
- const array = [1,2,3,4];
115
- const boolean = true;
116
-
117
- // виводить всі змінні в одній групі вкладок
118
- dump(int, array, boolean);
119
-
120
- // or
121
-
122
- // виводить всі змінні в одній групі вкладок та зупиняє подальше виконання скрипту
123
- dd(int, array, boolean);
124
-
125
- ```
126
-
127
109
  Приклад використання gemini:
128
110
 
129
111
  у файл __.env__ потрібно додати api-ключ __VITE_GEMINI_KEY=you_api_gemini_key__
@@ -153,7 +135,6 @@ onInput: (event) => {
153
135
 
154
136
  Загальний список методів:
155
137
 
156
- - *dump(...args), dd(...args)*
157
138
  - *redirect(url, { newTab: bool, replace: bool }), reload(delaySeconds), validateEmail(email), validatePassword(password)*
158
139
  - *encrypt(str), decrypt(encryptedStr)*
159
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "Допоміжна JavaScript-бібліотека для проєктів",
5
5
  "main": "index.js",
6
6
  "exports": {
package/src/router.js CHANGED
@@ -2,6 +2,11 @@ import NotFound from "./NotFound.js";
2
2
 
3
3
  /**
4
4
  * Ініціалізація роутера.
5
+ * @param routes
6
+ * @param main
7
+ * @param message
8
+ * @param props
9
+ * @returns {Promise<void>}
5
10
  */
6
11
  export const router = async ({routes, main, message = "", props = {}}) => {
7
12
  const renderRoute = async () => {
@@ -13,9 +18,9 @@ export const router = async ({routes, main, message = "", props = {}}) => {
13
18
  }
14
19
 
15
20
  const component = await routeComponent({
21
+ message,
16
22
  ...props,
17
23
  ...routeProps,
18
- message,
19
24
  });
20
25
 
21
26
  main.appendChild(component);
@@ -29,6 +34,8 @@ export const router = async ({routes, main, message = "", props = {}}) => {
29
34
 
30
35
  /**
31
36
  * Перехід без рендеру.
37
+ * @param path
38
+ * @param props
32
39
  */
33
40
  export const navigateTo = (path, props = {}) => {
34
41
  window.history.pushState(props, "", path);
@@ -36,6 +43,9 @@ export const navigateTo = (path, props = {}) => {
36
43
 
37
44
  /**
38
45
  * Перехід + рендер.
46
+ * @param path
47
+ * @param props
48
+ * @returns {Promise<void>}
39
49
  */
40
50
  export const navi = async (path, props = {}) => {
41
51
  window.history.pushState(props, "", path);
@@ -59,6 +69,9 @@ export const navi = async (path, props = {}) => {
59
69
  * category_id: "15",
60
70
  * product_id: "128"
61
71
  * }
72
+ * @param routePath
73
+ * @param path
74
+ * @returns {*|null}
62
75
  */
63
76
  const matchRoute = (routePath, path) => {
64
77
  const keys = [];
@@ -84,19 +97,28 @@ const matchRoute = (routePath, path) => {
84
97
 
85
98
  /**
86
99
  * Знаходить поточний route.
100
+ * @param routes
101
+ * @returns {{routeComponent: ((function({colors?: {backgroundColor: string, numberColor: string, textColor: string}, message?: string}): HTMLDivElement)|*), props: {}}|{routeComponent: RTCIceComponent, props: {}}}
87
102
  */
88
103
  const useRoutes = (routes) => {
89
104
  const path = window.location.pathname;
90
105
 
91
106
  for (const route of routes) {
92
107
  const params = matchRoute(route.path, path);
108
+
93
109
  if (params !== null) {
110
+ const props = {
111
+ ...(window.history.state || {}),
112
+ ...params,
113
+ };
114
+
115
+ if (props.title) {
116
+ document.title = props.title;
117
+ }
118
+
94
119
  return {
95
120
  routeComponent: route.component,
96
- props: {
97
- ...(window.history.state || {}),
98
- ...params,
99
- },
121
+ props,
100
122
  };
101
123
  }
102
124
  }