underpost 2.8.87 → 2.8.88

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 (99) hide show
  1. package/.env.development +35 -3
  2. package/.env.production +39 -4
  3. package/.env.test +35 -3
  4. package/.github/workflows/ghpkg.ci.yml +1 -1
  5. package/.github/workflows/npmpkg.ci.yml +1 -1
  6. package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -5
  7. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  8. package/.github/workflows/release.cd.yml +3 -3
  9. package/README.md +56 -2
  10. package/bin/build.js +4 -0
  11. package/bin/deploy.js +62 -8
  12. package/bin/file.js +3 -2
  13. package/cli.md +8 -2
  14. package/conf.js +30 -4
  15. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  16. package/manifests/deployment/dd-test-development/deployment.yaml +174 -0
  17. package/manifests/deployment/dd-test-development/proxy.yaml +51 -0
  18. package/package.json +6 -5
  19. package/src/api/core/core.router.js +2 -1
  20. package/src/api/default/default.controller.js +6 -1
  21. package/src/api/default/default.router.js +6 -2
  22. package/src/api/default/default.service.js +10 -1
  23. package/src/api/document/document.controller.js +66 -0
  24. package/src/api/document/document.model.js +51 -0
  25. package/src/api/document/document.router.js +24 -0
  26. package/src/api/document/document.service.js +125 -0
  27. package/src/api/file/file.controller.js +15 -1
  28. package/src/api/file/file.router.js +2 -1
  29. package/src/api/test/test.router.js +1 -1
  30. package/src/api/user/postman_collection.json +216 -0
  31. package/src/api/user/user.controller.js +25 -60
  32. package/src/api/user/user.model.js +29 -7
  33. package/src/api/user/user.router.js +9 -3
  34. package/src/api/user/user.service.js +84 -32
  35. package/src/cli/baremetal.js +33 -3
  36. package/src/cli/cloud-init.js +11 -0
  37. package/src/cli/cron.js +0 -1
  38. package/src/cli/deploy.js +46 -23
  39. package/src/cli/index.js +5 -0
  40. package/src/cli/lxd.js +7 -0
  41. package/src/cli/repository.js +42 -6
  42. package/src/cli/run.js +45 -13
  43. package/src/cli/ssh.js +20 -6
  44. package/src/client/Default.index.js +42 -1
  45. package/src/client/components/core/Account.js +10 -2
  46. package/src/client/components/core/AgGrid.js +30 -8
  47. package/src/client/components/core/Auth.js +99 -56
  48. package/src/client/components/core/BtnIcon.js +3 -2
  49. package/src/client/components/core/CalendarCore.js +2 -3
  50. package/src/client/components/core/CommonJs.js +1 -2
  51. package/src/client/components/core/Content.js +15 -12
  52. package/src/client/components/core/Css.js +2 -1
  53. package/src/client/components/core/CssCore.js +6 -1
  54. package/src/client/components/core/Docs.js +5 -5
  55. package/src/client/components/core/FileExplorer.js +3 -3
  56. package/src/client/components/core/Input.js +22 -17
  57. package/src/client/components/core/JoyStick.js +2 -2
  58. package/src/client/components/core/LoadingAnimation.js +2 -2
  59. package/src/client/components/core/LogIn.js +16 -23
  60. package/src/client/components/core/LogOut.js +5 -1
  61. package/src/client/components/core/Logger.js +4 -1
  62. package/src/client/components/core/Modal.js +82 -53
  63. package/src/client/components/core/ObjectLayerEngineModal.js +2 -1
  64. package/src/client/components/core/Pagination.js +207 -0
  65. package/src/client/components/core/Panel.js +10 -10
  66. package/src/client/components/core/PanelForm.js +130 -33
  67. package/src/client/components/core/Recover.js +2 -2
  68. package/src/client/components/core/Router.js +210 -34
  69. package/src/client/components/core/SignUp.js +1 -2
  70. package/src/client/components/core/Stream.js +1 -1
  71. package/src/client/components/core/VanillaJs.js +3 -84
  72. package/src/client/components/core/Worker.js +2 -2
  73. package/src/client/components/default/LogInDefault.js +0 -6
  74. package/src/client/components/default/LogOutDefault.js +0 -16
  75. package/src/client/components/default/MenuDefault.js +97 -44
  76. package/src/client/components/default/RoutesDefault.js +5 -2
  77. package/src/client/services/core/core.service.js +8 -20
  78. package/src/client/services/default/default.management.js +115 -18
  79. package/src/client/services/default/default.service.js +13 -4
  80. package/src/client/services/document/document.service.js +97 -0
  81. package/src/client/services/file/file.service.js +2 -0
  82. package/src/client/services/test/test.service.js +3 -0
  83. package/src/client/services/user/user.management.js +6 -0
  84. package/src/client/services/user/user.service.js +15 -4
  85. package/src/client/ssr/Render.js +1 -1
  86. package/src/client/ssr/head/DefaultScripts.js +3 -0
  87. package/src/client/ssr/head/Seo.js +1 -0
  88. package/src/index.js +24 -2
  89. package/src/runtime/lampp/Lampp.js +89 -2
  90. package/src/runtime/xampp/Xampp.js +48 -1
  91. package/src/server/auth.js +519 -155
  92. package/src/server/backup.js +2 -2
  93. package/src/server/conf.js +66 -8
  94. package/src/server/process.js +2 -1
  95. package/src/server/runtime.js +135 -286
  96. package/src/server/ssl.js +1 -2
  97. package/src/server/ssr.js +85 -0
  98. package/src/server/start.js +2 -2
  99. package/src/server/valkey.js +2 -1
@@ -1,21 +1,131 @@
1
+ /**
2
+ * Router module for handling routing in a PWA application.
3
+ * @module src/client/components/core/Router.js
4
+ * @namespace PwaRouter
5
+ */
6
+
1
7
  import { titleFormatted } from './CommonJs.js';
2
8
  import { loggerFactory } from './Logger.js';
3
- import { getProxyPath, getQueryParams, htmls, s, setPath } from './VanillaJs.js';
9
+ import { htmls, s } from './VanillaJs.js';
4
10
  import { Modal } from './Modal.js';
5
11
  import { Worker } from './Worker.js';
6
12
 
7
- // Router
13
+ const logger = loggerFactory(import.meta, { trace: true });
8
14
 
15
+ /**
16
+ * @type {Object.<string, function>}
17
+ * @description Holds event listeners for router changes.
18
+ * @memberof PwaRouter
19
+ */
9
20
  const RouterEvents = {};
21
+
22
+ /**
23
+ * @type {string[]}
24
+ * @description Array of core UI component IDs that should not trigger modal close route changes.
25
+ * @memberof PwaRouter
26
+ */
27
+ const coreUI = ['modal-menu', 'main-body', 'main-body-top', 'bottom-bar', 'board-notification'];
28
+ /**
29
+ * @type {Object.<string, function>}
30
+ * @description Holds event listeners for route changes that should close a modal.
31
+ * @memberof PwaRouter
32
+ */
10
33
  const closeModalRouteChangeEvents = {};
11
34
 
12
- const logger = loggerFactory(import.meta);
35
+ /**
36
+ * Determines the base path for the application, often used for routing within a sub-directory.
37
+ * It checks the current URL's pathname and `window.Routes` to return the appropriate proxy path.
38
+ *
39
+ * @returns {string} The calculated proxy path. Returns `/<first-segment>/` if a segment exists,
40
+ * otherwise `/`. If `window.Routes` indicates the path is a root route, it returns `/`.
41
+ * @memberof PwaRouter
42
+ */
43
+ const getProxyPath = () => {
44
+ let path = location.pathname.split('/')[1] ? `/${location.pathname.split('/')[1]}/` : '/';
45
+ if (window.Routes && path !== '/' && path.slice(0, -1) in window.Routes()) path = '/';
46
+ return path;
47
+ };
48
+
49
+ /**
50
+ * Sets the browser's path using the History API. It sanitizes the path, handles query strings and hashes,
51
+ * and prevents pushing the same state twice.
52
+ * @param {string} [path='/'] - The new path to set. Can include query strings and hashes.
53
+ * @param {object} [options={ removeSearch: false, removeHash: false }] - Options for path manipulation.
54
+ * @param {boolean} [options.removeSearch=false] - If true, removes the search part of the URL.
55
+ * @param {boolean} [options.removeHash=false] - If true, removes the hash part of the URL. Defaults to `false`.
56
+ * @param {object} [stateStorage={}] - State object to associate with the history entry.
57
+ * @param {string} [title=''] - The title for the new history entry.
58
+ * @memberof PwaRouter
59
+ * @returns {void | undefined} Returns `undefined` if the new path is the same as the current path, otherwise `void` (result of `history.pushState`).
60
+ */
61
+ const setPath = (path = '/', options = { removeSearch: false, removeHash: false }, stateStorage = {}, title = '') => {
62
+ logger.warn(`Set path input`, `${path}`);
63
+ if (!path) path = '/';
64
+
65
+ let [inputPath, inputSearchHash] = `${path}`.split('?');
66
+ let [inputSearch, inputHash] = inputSearchHash ? inputSearchHash.split('#') : [];
13
67
 
68
+ let sanitizedPath = (inputPath[0] !== '/' ? `/${inputPath}` : inputPath)
69
+ .trim()
70
+ .replaceAll('//', '/')
71
+ .replaceAll(`\\`, '/');
72
+
73
+ if (sanitizedPath.length > 1 && sanitizedPath[sanitizedPath.length - 1] === '/')
74
+ sanitizedPath = sanitizedPath.slice(0, -1);
75
+
76
+ const newFullPath = `${sanitizedPath}${inputSearch && !options.removeSearch ? `?${inputSearch}` : ''}${
77
+ inputHash && !options.removeHash ? `#${inputHash}` : ''
78
+ }`;
79
+ const currentFullPath = `${window.location.pathname}${location.search}${location.hash}`;
80
+ logger.warn(`Set path output`, {
81
+ inputPath: inputPath,
82
+ inputSearch: inputSearch,
83
+ inputHash: inputHash,
84
+ sanitizedPath: sanitizedPath,
85
+ currentLocationSearch: location.search,
86
+ currentLocationHash: location.hash,
87
+ currentFullPath,
88
+ newFullPath,
89
+ });
90
+ if (currentFullPath === newFullPath) {
91
+ logger.warn('Prevent overwriting same path', { currentFullPath, newFullPath });
92
+ return;
93
+ }
94
+ return history.pushState.call(history, stateStorage, title, newFullPath);
95
+ };
96
+
97
+ /**
98
+ * Extracts query parameters from the current URL's search string and returns them as an object.
99
+ * @returns An object containing the query parameters from the current URL is being returned.
100
+ * @memberof PwaRouter
101
+ */
102
+ const getQueryParams = () => {
103
+ const params = new URLSearchParams(window.location.search);
104
+ let queries = {};
105
+ for (const param of params) {
106
+ queries[param[0]] = param[1];
107
+ }
108
+ return queries;
109
+ };
110
+
111
+ /**
112
+ * Sanitizes a route string for use in CSS classes or other identifiers.
113
+ * Defaults to 'home' for empty, '/', or '\' routes.
114
+ * @param {string} route - The route string to sanitize.
115
+ * @returns {string} The sanitized route string.
116
+ * @memberof PwaRouter
117
+ */
14
118
  const sanitizeRoute = (route) =>
15
119
  !route || route === '/' || route === `\\`
16
120
  ? 'home'
17
121
  : route.toLowerCase().replaceAll('/', '').replaceAll(`\\`, '').replaceAll(' ', '-');
18
122
 
123
+ /**
124
+ * Sets the document title and updates the active state of the main menu button corresponding to the route.
125
+ * The title is formatted and appended with the main application title from `Worker.title` if it's not already present.
126
+ * @param {string} route - The current route string.
127
+ * @memberof PwaRouter
128
+ */
19
129
  const setDocTitle = (route) => {
20
130
  const _route = sanitizeRoute(route);
21
131
  // logger.warn('setDocTitle', _route);
@@ -27,6 +137,14 @@ const setDocTitle = (route) => {
27
137
  }
28
138
  };
29
139
 
140
+ /**
141
+ * Main router function. It matches the current URL path against the provided routes configuration
142
+ * and renders the corresponding component. It also fires registered router events.
143
+ * @param {object} [options={ Routes: () => {}, e: new PopStateEvent() }] - The router options.
144
+ * @param {function} options.Routes - A function that returns the routes object.
145
+ * @param {PopStateEvent} options.e - The popstate event object.
146
+ * @memberof PwaRouter
147
+ */
30
148
  const Router = function (options = { Routes: () => {}, e: new PopStateEvent() }) {
31
149
  const { e, Routes } = options;
32
150
  const proxyPath = getProxyPath();
@@ -50,20 +168,43 @@ const Router = function (options = { Routes: () => {}, e: new PopStateEvent() })
50
168
  }
51
169
  };
52
170
 
171
+ /**
172
+ * Initializes the router and sets up the `onpopstate` event listener to handle browser
173
+ * back/forward navigation.
174
+ * @param {object} RouterInstance - The router instance configuration, including the `Routes` function.
175
+ * @memberof PwaRouter
176
+ */
53
177
  const LoadRouter = function (RouterInstance) {
54
178
  Router(RouterInstance);
55
179
  window.onpopstate = (e) => Router({ ...RouterInstance, e });
56
180
  };
57
181
 
182
+ /**
183
+ * Sets the URL path with a specific query parameter, commonly used for content IDs.
184
+ * This function constructs a new URI based on the proxy path, a given path, and an optional query parameter.
185
+ * @param {object} [options={ path: '', queryPath: '' }] - The path options.
186
+ * @param {string} [options.path=''] - The base path segment.
187
+ * @memberof PwaRouter
188
+ */
58
189
  const setQueryPath = (options = { path: '', queryPath: '' }, queryKey = 'cid') => {
59
190
  const { queryPath, path } = options;
60
191
  const newUri = `${getProxyPath()}${path === 'home' ? '' : `${path}/`}${
61
- typeof queryPath === 'string' ? `?${queryKey}=${queryPath}` : ''
192
+ typeof queryPath === 'string' && queryPath ? `?${queryKey}=${queryPath}` : ''
62
193
  }`;
63
194
  const currentUri = `${window.location.pathname}${location.search}`;
64
- if (currentUri !== newUri && currentUri !== `${newUri}/`) setPath(newUri);
195
+ if (currentUri !== newUri && currentUri !== `${newUri}/`) setPath(newUri, {}, '');
65
196
  };
66
197
 
198
+ /**
199
+ * Registers a listener for route changes that specifically watches for a `queryKey` parameter
200
+ * on a matching `routeId`. The provided event callback is triggered with the query parameter's value.
201
+ * @param {object} options - The listener options.
202
+ * @param {string} options.id - A unique ID for the listener.
203
+ * @param {string} options.routeId - The route ID to listen for.
204
+ * @param {function(string): void} options.event - The callback function to execute with the query path value (or an empty string if not found).
205
+ * @param {string} [queryKey='cid'] - The query parameter key to look for.
206
+ * @memberof PwaRouter
207
+ */
67
208
  const listenQueryPathInstance = ({ id, routeId, event }, queryKey = 'cid') => {
68
209
  RouterEvents[id] = ({ path, pushPath, proxyPath, route }) => {
69
210
  if ((route === '' && routeId === 'home') || (route && routeId && route === routeId)) {
@@ -80,38 +221,43 @@ const listenQueryPathInstance = ({ id, routeId, event }, queryKey = 'cid') => {
80
221
  });
81
222
  };
82
223
 
83
- const triggerCloseModalRouteChangeEvents = (newPath) => {
84
- console.warn('[closeModalRouteChangeEvent]', newPath);
85
- for (const event of Object.keys(closeModalRouteChangeEvents)) closeModalRouteChangeEvents[event](newPath);
86
- };
87
-
224
+ /**
225
+ * Handles the logic for changing the route when a modal is closed. It determines the next URL
226
+ * based on the remaining open modals or falls back to a home URL.
227
+ * @param {object} [options={}] - Options for the modal close event.
228
+ * @param {string} options.closedId - The ID of the modal that was just closed.
229
+ * @memberof PwaRouter
230
+ */
88
231
  const closeModalRouteChangeEvent = (options = {}) => {
89
- const { route, RouterInstance, homeCid } = options;
90
- if (!route) return;
232
+ logger.warn('closeModalRouteChangeEvent', options);
233
+ const { closedId } = options;
234
+ if (!closedId) return;
235
+ if (coreUI.find((id) => closedId.startsWith(id))) {
236
+ logger.warn('prevent core ui component close');
237
+ return;
238
+ }
91
239
 
92
- let path = window.location.pathname;
93
- if (path[path.length - 1] !== '/') path = `${path}/`;
94
- let newPath = `${getProxyPath()}`;
240
+ const remainingModals = Object.keys(Modal.Data).filter(
241
+ (id) => id !== closedId && (Modal.Data[id]?.options?.route || Modal.Data[id]?.options?.query),
242
+ );
95
243
 
96
- if (path !== newPath) {
97
- for (const subIdModal of Object.keys(Modal.Data).reverse()) {
98
- if (Modal.Data[subIdModal]?.options?.route) {
99
- newPath = `${newPath}${Modal.Data[subIdModal].options.route}`;
100
- triggerCloseModalRouteChangeEvents(newPath);
101
- setPath(newPath);
102
- setDocTitle(newPath);
103
- Modal.setTopModalCallback(subIdModal);
104
- }
105
- }
106
- newPath = `${newPath}${homeCid ? `?cid=${homeCid}` : ''}`;
107
- triggerCloseModalRouteChangeEvents(newPath);
108
- setPath(newPath);
109
- setDocTitle(newPath);
110
- }
244
+ const topModalId = remainingModals.reverse().find((id) => Modal.Data[id]);
245
+
246
+ for (const event of Object.keys(closeModalRouteChangeEvents)) closeModalRouteChangeEvents[event]();
247
+ if (topModalId) Modal.setTopModalCallback(topModalId);
248
+ setPath(`${getProxyPath()}${Modal.Data[topModalId]?.options?.route ?? ''}`);
249
+ setDocTitle(Modal.Data[topModalId]?.options?.route ?? '');
111
250
  };
112
251
 
113
- const handleModalViewRoute = (options = {}) => {
114
- const { route, RouterInstance } = options;
252
+ /**
253
+ * Handles routing for modals that are meant to be displayed as a "view" (e.g., a full-page modal).
254
+ * It updates the URL to reflect the modal's route.
255
+ * @param {object} [options={ route: 'home' }] - The options for handling the modal view route.
256
+ * @param {string} options.route - The route associated with the modal view.
257
+ * @memberof PwaRouter
258
+ */
259
+ const handleModalViewRoute = (options = { route: '' }) => {
260
+ const { route } = options;
115
261
  if (!route) return;
116
262
 
117
263
  let path = window.location.pathname;
@@ -125,14 +271,44 @@ const handleModalViewRoute = (options = {}) => {
125
271
  }
126
272
  };
127
273
 
274
+ /**
275
+ * Sets or updates query parameters in the URL.
276
+ * It preserves the existing path, hash, and other query parameters.
277
+ *
278
+ * @param {Object.<string, string|number>} newParams - An object of query parameters to set or update.
279
+ * If a value is `null` or `undefined`, the parameter will be removed.
280
+ * @param {object} [options={ replace: true }] - Options for history manipulation.
281
+ * @param {boolean} [options.replace=true] - If true, uses `history.replaceState` instead of `history.pushState`.
282
+ * @memberof PwaRouter
283
+ */
284
+ const setQueryParams = (newParams, options = { replace: true }) => {
285
+ const url = new URL(window.location.href);
286
+ Object.entries(newParams).forEach(([key, value]) => {
287
+ if (value === null || value === undefined) {
288
+ url.searchParams.delete(key);
289
+ } else {
290
+ url.searchParams.set(key, value);
291
+ }
292
+ });
293
+
294
+ const newPath = url.pathname + url.search + url.hash;
295
+
296
+ history.pushState(history.state, '', newPath);
297
+ };
298
+
128
299
  export {
300
+ RouterEvents,
301
+ closeModalRouteChangeEvents,
302
+ coreUI,
129
303
  Router,
130
304
  setDocTitle,
131
305
  LoadRouter,
132
- RouterEvents,
133
306
  setQueryPath,
134
307
  listenQueryPathInstance,
135
308
  closeModalRouteChangeEvent,
136
309
  handleModalViewRoute,
137
- closeModalRouteChangeEvents,
310
+ getQueryParams,
311
+ getProxyPath,
312
+ setPath,
313
+ setQueryParams,
138
314
  };
@@ -53,8 +53,7 @@ const SignUp = {
53
53
  status: result.status,
54
54
  });
55
55
  if (result.status === 'success') {
56
- await Auth.sessionOut();
57
- await Auth.signUpToken(result);
56
+ await Auth.sessionIn(result);
58
57
  s(`.btn-close-${options.idModal}`).click();
59
58
  }
60
59
  });
@@ -1,5 +1,5 @@
1
1
  import { loggerFactory } from './Logger.js';
2
- import { getProxyPath } from './VanillaJs.js';
2
+ import { getProxyPath } from './Router.js';
3
3
 
4
4
  // https://peerjs.com/docs/
5
5
 
@@ -132,72 +132,6 @@ const copyData = (data) =>
132
132
  */
133
133
  const pasteData = () => new Promise((resolve) => navigator.clipboard.readText().then((clipText) => resolve(clipText)));
134
134
 
135
- /**
136
- * The setPath function in JavaScript updates the browser's history with a new path, state, and title.
137
- * @param path - The `path` parameter is a string that represents the URL path where you want to
138
- * navigate or update in the browser history. It is the first parameter in the `setPath` function and
139
- * has a default value of `'/'`.
140
- * @param stateStorage - The `stateStorage` parameter in the `setPath` function is an object that
141
- * represents the state object associated with the new history entry. It is used to store data related
142
- * to the state of the application when navigating to a new path using `history.pushState()`. This data
143
- * can be accessed later
144
- * @param title - The `title` parameter in the `setPath` function is a string that represents the
145
- * title of the new history entry. It is used as the title of the new history entry in the browser's
146
- * history.
147
- * @memberof VanillaJS
148
- */
149
- const setPath = (path = '/', stateStorage = {}, title = '') => {
150
- if (!path) path = '/';
151
-
152
- const [inputPath, inputSearch] = `${path}`.split('?');
153
-
154
- let sanitizedPath = (inputPath[0] !== '/' ? `/${inputPath}` : inputPath)
155
- .trim()
156
- .replaceAll('//', '/')
157
- .replaceAll(`\\`, '/');
158
-
159
- if (sanitizedPath.length > 1 && sanitizedPath[sanitizedPath.length - 1] === '/')
160
- sanitizedPath = sanitizedPath.slice(0, -1);
161
-
162
- if (window.location.pathname === sanitizedPath && (!inputSearch || inputSearch === location.search)) {
163
- console.warn('Prevent overwriting same path', {
164
- inputPath: inputPath,
165
- inputSearch: inputSearch,
166
- sanitizedPath: sanitizedPath,
167
- currentLocationSearch: location.search,
168
- currentLocationHash: location.hash,
169
- });
170
- return;
171
- }
172
- console.warn('Set path', {
173
- inputPath: inputPath,
174
- inputSearch: inputSearch,
175
- sanitizedPath: sanitizedPath,
176
- currentLocationSearch: location.search,
177
- currentLocationHash: location.hash,
178
- });
179
- return history.pushState(
180
- stateStorage,
181
- title,
182
- `${sanitizedPath}${inputSearch ? `?${inputSearch}` : ''}${location.hash ?? ''}`,
183
- );
184
- };
185
-
186
- /**
187
- * The function `getQueryParams` extracts query parameters from the current URL and returns them as an
188
- * object.
189
- * @returns An object containing the query parameters from the current URL is being returned.
190
- * @memberof VanillaJS
191
- */
192
- const getQueryParams = () => {
193
- const params = new URLSearchParams(window.location.search);
194
- let queries = {};
195
- for (const param of params) {
196
- queries[param[0]] = param[1];
197
- }
198
- return queries;
199
- };
200
-
201
135
  /**
202
136
  * The `preHTML` function in JavaScript replaces special characters like &, <, and > with their
203
137
  * corresponding HTML entities.
@@ -375,21 +309,6 @@ const getBlobFromUint8ArrayFile = (data = [[]], mimetype = 'application/octet-st
375
309
  return new Blob([new Uint8Array(data)], { type: mimetype });
376
310
  };
377
311
 
378
- // Router
379
- /**
380
- * The function `getProxyPath` returns a proxy path based on the current location pathname.
381
- * @returns The `getProxyPath` function returns the path based on the current location. If the first
382
- * segment of the pathname is not empty, it returns `/<first-segment>/`, otherwise it returns `/`. If
383
- * the `window.Routes` object exists and the path is not `/` and the path without the trailing slash is
384
- * a key in the `window.Routes` object, it returns `/`.
385
- * @memberof VanillaJS
386
- */
387
- const getProxyPath = () => {
388
- let path = location.pathname.split('/')[1] ? `/${location.pathname.split('/')[1]}/` : '/';
389
- if (window.Routes && path !== '/' && path.slice(0, -1) in window.Routes()) path = '/';
390
- return path;
391
- };
392
-
393
312
  /**
394
313
  * The function `isNavigator` checks if the user agent string contains a specified name.
395
314
  * @param name - The `name` parameter is a string that represents the name of a browser or device to
@@ -470,6 +389,8 @@ function hexToRgbA(hex) {
470
389
  throw new Error('Invalid Hex');
471
390
  }
472
391
 
392
+ const htmlStrSanitize = (str) => (str ? str.replace(/<\/?[^>]+(>|$)/g, '').trim() : '');
393
+
473
394
  export {
474
395
  s,
475
396
  htmls,
@@ -478,8 +399,6 @@ export {
478
399
  sa,
479
400
  copyData,
480
401
  pasteData,
481
- setPath,
482
- getQueryParams,
483
402
  preHTML,
484
403
  disableOptionsClick,
485
404
  checkFullScreen,
@@ -488,7 +407,6 @@ export {
488
407
  getResponsiveData,
489
408
  isElement,
490
409
  downloadFile,
491
- getProxyPath,
492
410
  getRawContentFile,
493
411
  getBlobFromUint8ArrayFile,
494
412
  isNavigator,
@@ -500,4 +418,5 @@ export {
500
418
  getDataFromInputFile,
501
419
  getLang,
502
420
  hexToRgbA,
421
+ htmlStrSanitize,
503
422
  };
@@ -5,8 +5,8 @@ import { LoadingAnimation } from './LoadingAnimation.js';
5
5
  import { loggerFactory } from './Logger.js';
6
6
  import { LoadRouter } from './Router.js';
7
7
  import { Translate } from './Translate.js';
8
- import { getProxyPath, htmls, s } from './VanillaJs.js';
9
-
8
+ import { s } from './VanillaJs.js';
9
+ import { getProxyPath } from './Router.js';
10
10
  const logger = loggerFactory(import.meta);
11
11
 
12
12
  const Worker = {
@@ -1,17 +1,11 @@
1
- import { UserService } from '../../services/user/user.service.js';
2
1
  import { Auth } from '../core/Auth.js';
3
2
  import { LogIn } from '../core/LogIn.js';
4
- import { s } from '../core/VanillaJs.js';
5
3
  import { ElementsDefault } from './ElementsDefault.js';
6
4
 
7
5
  const LogInDefault = async function () {
8
6
  LogIn.Event['LogInDefault'] = async (options) => {
9
7
  const { token, user } = options;
10
8
  ElementsDefault.Data.user.main.model.user = user;
11
- s(`.main-btn-log-in`).style.display = 'none';
12
- s(`.main-btn-sign-up`).style.display = 'none';
13
- s(`.main-btn-log-out`).style.display = null;
14
- s(`.main-btn-account`).style.display = null;
15
9
  };
16
10
  const { user } = await Auth.sessionIn();
17
11
  ElementsDefault.Data.user.main.model.user = user;
@@ -1,25 +1,9 @@
1
- import { Auth } from '../core/Auth.js';
2
1
  import { LogOut } from '../core/LogOut.js';
3
- import { NotificationManager } from '../core/NotificationManager.js';
4
- import { Translate } from '../core/Translate.js';
5
- import { s } from '../core/VanillaJs.js';
6
2
  import { ElementsDefault } from './ElementsDefault.js';
7
3
 
8
4
  const LogOutDefault = async function () {
9
5
  LogOut.Event['LogOutDefault'] = async (result = { user: { _id: '' } }) => {
10
6
  ElementsDefault.Data.user.main.model.user = result.user;
11
-
12
- s(`.main-btn-log-out`).style.display = 'none';
13
- s(`.main-btn-account`).style.display = 'none';
14
- s(`.main-btn-log-in`).style.display = null;
15
- s(`.main-btn-sign-up`).style.display = null;
16
- if (s(`.modal-log-out`)) s(`.btn-close-modal-log-out`).click();
17
- if (s(`.modal-account`)) s(`.btn-close-modal-account`).click();
18
-
19
- NotificationManager.Push({
20
- html: Translate.Render(`success-logout`),
21
- status: 'success',
22
- });
23
7
  };
24
8
  };
25
9