underpost 2.7.92 → 2.7.94

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/bin/index.js CHANGED
@@ -19,7 +19,7 @@ const globalBinFolder = `${shellExec(`npm root -g`, {
19
19
 
20
20
  const program = new Command();
21
21
 
22
- const version = '2.7.92';
22
+ const version = '2.7.94';
23
23
 
24
24
  program.name('underpost').description(`underpost.net ci/cd cli ${version}`).version(version);
25
25
 
package/conf.js CHANGED
@@ -180,7 +180,7 @@ const DefaultConf = {
180
180
  ssr: {
181
181
  Default: {
182
182
  head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
183
- body: ['CacheControl', 'DefaultSplashScreen'],
183
+ body: ['CacheControl', 'DefaultSplashScreen', '404', '500'],
184
184
  mailer: {
185
185
  userVerifyEmail: 'DefaultVerifyEmail',
186
186
  userRecoverEmail: 'DefaultRecoverEmail',
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.7.92'
61
+ engine.version: '2.7.94'
62
62
  networks:
63
63
  - load-balancer
64
64
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.7.92",
5
+ "version": "2.7.94",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
@@ -9,11 +9,9 @@ const CoreService = {
9
9
  /** @type {import('./core.model.js').CoreModel} */
10
10
  const Core = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Core;
11
11
  if (req.path.startsWith('/sh')) {
12
- shellExec(req.body.sh, { stdout: true, async: true });
13
- return {
14
- status: 'success',
15
- message: 'Command "' + req.body.sh + '" running',
16
- };
12
+ if (req.body.print) return shellExec(req.body.sh, { stdout: true });
13
+ shellExec(req.body.sh, { async: true });
14
+ return 'Command "' + req.body.sh + '" running';
17
15
  }
18
16
  return await new Core(req.body).save();
19
17
  },
@@ -9,13 +9,13 @@ import { SignUpDefault } from './components/default/SignUpDefault.js';
9
9
  import { MenuDefault } from './components/default/MenuDefault.js';
10
10
  import { RouterDefault } from './components/default/RoutesDefault.js';
11
11
  import { TranslateDefault } from './components/default/TranslateDefault.js';
12
- import { getProxyPath } from './components/core/VanillaJs.js';
13
12
  import { Worker } from './components/core/Worker.js';
14
13
  import { Keyboard } from './components/core/Keyboard.js';
15
14
  import { DefaultParams } from './components/default/CommonDefault.js';
16
15
  import { SocketIo } from './components/core/SocketIo.js';
17
16
  import { SocketIoDefault } from './components/default/SocketIoDefault.js';
18
17
  import { ElementsDefault } from './components/default/ElementsDefault.js';
18
+ import { Scroll } from './components/core/Scroll.js';
19
19
 
20
20
  const htmlMainBody = async () => {
21
21
  return html`<span style="color: black; padding: 5px">Hello World!!</span>`;
@@ -35,6 +35,7 @@ window.onload = () =>
35
35
  await LogInDefault();
36
36
  await LogOutDefault();
37
37
  await SignUpDefault();
38
+ await Scroll.pullTopRefresh();
38
39
  await Keyboard.Init({ callBackTime: DefaultParams.EVENT_CALLBACK_TIME });
39
40
  },
40
41
  });
@@ -79,7 +79,7 @@ const Docs = {
79
79
  icon: html`<i class="fa-brands fa-osi"></i>`,
80
80
  text: 'Source Docs',
81
81
  url: function () {
82
- return `${getProxyPath()}docs/engine/2.7.92`;
82
+ return `${getProxyPath()}docs/engine/2.7.94`;
83
83
  },
84
84
  },
85
85
  {
@@ -1340,6 +1340,9 @@ const Modal = {
1340
1340
  backMenuButtonEvent();
1341
1341
  }
1342
1342
  s(`.btn-close-modal-menu`).click();
1343
+ if (window.location.pathname !== (getProxyPath() === '/' ? getProxyPath() : `${getProxyPath()}/`))
1344
+ setPath(getProxyPath());
1345
+ setDocTitle({ ...options.RouterInstance, route: '' });
1343
1346
  };
1344
1347
  EventsUI.onClick(`.btn-icon-menu-back`, backMenuButtonEvent);
1345
1348
  EventsUI.onClick(`.btn-icon-menu-mode`, () => {
@@ -1532,7 +1535,7 @@ const Modal = {
1532
1535
  Responsive.Event['h-ui-hide-' + idModal] = () => {
1533
1536
  setTimeout(() => {
1534
1537
  if (!s(`.${idModal}`) || !s(`.main-body-btn-ui-close`)) return;
1535
- if (s(`.btn-restore-${idModal}`).style.display !== 'none') {
1538
+ if (s(`.btn-restore-${idModal}`) && s(`.btn-restore-${idModal}`).style.display !== 'none') {
1536
1539
  s(`.${idModal}`).style.height = s(`.main-body-btn-ui-close`).classList.contains('hide')
1537
1540
  ? `${window.innerHeight}px`
1538
1541
  : `${
@@ -1540,10 +1543,10 @@ const Modal = {
1540
1543
  (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1541
1544
  (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1542
1545
  }px`;
1543
- s(`.${idModal}`).style.top = s(`.main-body-btn-ui-close`).classList.contains('hide')
1544
- ? `0px`
1545
- : `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1546
1546
  }
1547
+ s(`.${idModal}`).style.top = s(`.main-body-btn-ui-close`).classList.contains('hide')
1548
+ ? `0px`
1549
+ : `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1547
1550
  });
1548
1551
  };
1549
1552
  Responsive.Event['h-ui-hide-' + idModal]();
@@ -1,4 +1,6 @@
1
- import { s } from './VanillaJs.js';
1
+ import { borderChar } from './Css.js';
2
+ import { Modal } from './Modal.js';
3
+ import { append, s } from './VanillaJs.js';
2
4
 
3
5
  const Scroll = {
4
6
  data: {},
@@ -16,7 +18,7 @@ const Scroll = {
16
18
  scrollHandler: async function () {
17
19
  for (const selector in Scroll.data) await Scroll.data[selector].callback(Scroll.getScrollPosition(selector));
18
20
  },
19
- addEvent: function (selector = '', callback = () => {}) {
21
+ addEvent: function (selector = '', callback = (position = 0) => {}) {
20
22
  Scroll.data[selector].callback = callback;
21
23
  },
22
24
  removeEvent: function (selector) {
@@ -29,6 +31,100 @@ const Scroll = {
29
31
  behavior: options.behavior || 'smooth',
30
32
  });
31
33
  },
34
+ topRefreshEvents: {},
35
+ addTopRefreshEvent: function (options = { id: '', callback: () => {}, condition: () => {} }) {
36
+ this.topRefreshEvents[options.id] = options;
37
+ },
38
+ removeTopRefreshEvent: function (id = '') {
39
+ delete this.topRefreshEvents[id];
40
+ },
41
+ pullTopRefresh: function () {
42
+ append(
43
+ 'body',
44
+ html` <style>
45
+ .pull-refresh-icon-container {
46
+ height: 60px;
47
+ width: 100%;
48
+ z-index: 10;
49
+ transition: 0.3s;
50
+ left: 0px;
51
+ }
52
+ .pull-refresh-icon {
53
+ width: 60px;
54
+ height: 60px;
55
+ margin: auto;
56
+ color: white;
57
+ font-size: 30px;
58
+ }
59
+ </style>
60
+ ${borderChar(2, 'black', [' .pull-refresh-icon-container'])}
61
+ <div style="top: -60px" class="abs pull-refresh-icon-container">
62
+ <div class="in pull-refresh-icon">
63
+ <div class="abs center"><i class="fa-solid fa-arrows-rotate"></i></div>
64
+ </div>
65
+ </div>`,
66
+ );
67
+
68
+ let touchstartY = 0;
69
+ let reload = false;
70
+ const minHeightDragReload = 3;
71
+ const maxHeightDragReload = 20;
72
+
73
+ document.addEventListener('touchstart', (e) => {
74
+ touchstartY = e.touches[0].clientY;
75
+ // console.warn('touchstart', touchstartY);
76
+ });
77
+
78
+ document.addEventListener('touchmove', (e) => {
79
+ if (
80
+ !Object.keys(Scroll.topRefreshEvents).find((event) => Scroll.topRefreshEvents[event].condition()) ||
81
+ (!s(`.btn-bar-center-icon-close`).classList.contains('hide') &&
82
+ !s(
83
+ `.btn-icon-menu-mode-${Modal.Data['modal-menu'].options.mode !== 'slide-menu-right' ? 'left' : 'right'}`,
84
+ ).classList.contains('hide'))
85
+ )
86
+ return;
87
+
88
+ const touchY = e.touches[0].clientY;
89
+ const touchDiff = touchY - touchstartY;
90
+
91
+ // console.warn('touchDiff', touchDiff, maxHeightDragReload);
92
+
93
+ if (touchDiff > maxHeightDragReload)
94
+ s(`.pull-refresh-icon-container`).style.top = 60 + maxHeightDragReload + 'px';
95
+ else s(`.pull-refresh-icon-container`).style.top = 60 + touchDiff + 'px';
96
+
97
+ if (touchDiff > minHeightDragReload && window.scrollY === 0) {
98
+ reload = true;
99
+ } else {
100
+ reload = false;
101
+ }
102
+ });
103
+ document.addEventListener('touchend', (e) => {
104
+ // console.warn('touchend');
105
+ s(`.pull-refresh-icon-container`).style.top = '-60px';
106
+ if (reload) {
107
+ for (const event of Object.keys(Scroll.topRefreshEvents))
108
+ if (Scroll.topRefreshEvents[event].condition()) Scroll.topRefreshEvents[event].callback();
109
+ }
110
+ reload = false;
111
+ });
112
+ Scroll.addTopRefreshEvent({
113
+ id: 'main-body',
114
+ callback: () => {
115
+ location.reload();
116
+ },
117
+ condition: () => {
118
+ return (
119
+ s('.main-body') &&
120
+ s('.main-body').scrollTop === 0 &&
121
+ !Object.keys(Modal.Data).find(
122
+ (idModal) => !['modal-menu', 'main-body', 'bottom-bar', 'main-body-top'].includes(idModal),
123
+ )
124
+ );
125
+ },
126
+ });
127
+ },
32
128
  };
33
129
 
34
130
  export { Scroll };
@@ -106,6 +106,10 @@ const TranslateCore = {
106
106
  en: 'Enter your WhatsApp number, including your country code.',
107
107
  es: 'Número de WhatsApp, recuerda colocar el código de tu país',
108
108
  };
109
+ Translate.Data['¿'] = {
110
+ en: '',
111
+ es: '¿',
112
+ };
109
113
  Translate.Data['color-copy'] = { es: 'color copiado en el portapapeles', en: 'color copied to clipboard' };
110
114
  Translate.Data['pallet-colors'] = { en: 'pallet colors', es: 'paleta de colores' };
111
115
  Translate.Data['fullscreen'] = { en: 'Fullscreen', es: 'Pantalla completa' };
@@ -429,7 +429,9 @@ const isDevInstance = () => location.origin.match('localhost') && location.port;
429
429
  const getDataFromInputFile = async (file) => Array.from(new Uint8Array(await file.arrayBuffer()));
430
430
 
431
431
  const getLang = () =>
432
- (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
432
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
433
+ .slice(0, 2)
434
+ .toLowerCase();
433
435
 
434
436
  export {
435
437
  s,
@@ -172,6 +172,7 @@ const MenuDefault = {
172
172
  return '';
173
173
  },
174
174
  mode: 'slide-menu',
175
+ RouterInstance,
175
176
  heightTopBar,
176
177
  heightBottomBar,
177
178
  htmlMainBody: options?.htmlMainBody ? options.htmlMainBody : undefined,
@@ -0,0 +1,73 @@
1
+ const s = (el) => document.querySelector(el);
2
+
3
+ const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
4
+
5
+ const getLang = () =>
6
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
7
+ .slice(0, 2)
8
+ .toLowerCase();
9
+
10
+ const main = () => {
11
+ const Translate = {
12
+ Data: {
13
+ ['page-not-found']: {
14
+ en: 'Page not found',
15
+ es: 'Página no encontrada',
16
+ },
17
+ ['page-broken']: {
18
+ es: 'Algo salio mal',
19
+ en: 'Something went wrong',
20
+ },
21
+ ['back']: {
22
+ en: 'Back to <br> homepage',
23
+ es: 'Volver a <br> la pagina principal',
24
+ },
25
+ },
26
+ Render: function (id) {
27
+ return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
28
+ },
29
+ };
30
+ const icon = html`
31
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24">
32
+ <path
33
+ fill="currentColor"
34
+ d="M15.097 5.904A6.5 6.5 0 0 0 4 10.504l.001 1h-2v-1a8.5 8.5 0 1 1 15.176 5.258l5.344 5.345l-1.414 1.414l-5.344-5.345A8.48 8.48 0 0 1 10.5 19h-1v-2h1a6.5 6.5 0 0 0 4.596-11.096M1.672 13.257L4.5 16.086l2.829-2.829l1.414 1.415L5.915 17.5l2.828 2.828l-1.414 1.415L4.5 18.914l-2.828 2.829l-1.414-1.415L3.086 17.5L.258 14.672z"
35
+ />
36
+ </svg>
37
+ `;
38
+ append(
39
+ 'body',
40
+ html` <style>
41
+ body {
42
+ font-family: arial;
43
+ font-size: 20px;
44
+ background-color: #d8d8d8;
45
+ color: #333;
46
+ }
47
+ a {
48
+ color: black;
49
+ }
50
+ </style>
51
+
52
+ <div class="abs center" style="top: 45%">
53
+ ${icon}
54
+ <br />
55
+ <br />
56
+ <span class="bold">404</span>
57
+ <br />
58
+ <br />${Translate.Render('page-not-found')} <br />
59
+ <br />
60
+ <a href="${location.origin}">${Translate.Render('back')}</a>
61
+ </div>`,
62
+ );
63
+ };
64
+
65
+ SrrComponent = () => html`<script>
66
+ {
67
+ const s = ${s};
68
+ const append = ${append};
69
+ const getLang = ${getLang};
70
+ const main = ${main};
71
+ window.onload = main;
72
+ }
73
+ </script>`;
@@ -0,0 +1,72 @@
1
+ const s = (el) => document.querySelector(el);
2
+
3
+ const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
4
+
5
+ const getLang = () =>
6
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
7
+ .slice(0, 2)
8
+ .toLowerCase();
9
+
10
+ const main = () => {
11
+ const Translate = {
12
+ Data: {
13
+ ['page-not-found']: {
14
+ en: 'Page not found',
15
+ es: 'Página no encontrada',
16
+ },
17
+ ['page-broken']: {
18
+ es: 'Algo salio mal',
19
+ en: 'Something went wrong',
20
+ },
21
+ ['back']: {
22
+ en: 'Back to <br> homepage',
23
+ es: 'Volver a <br> la pagina principal',
24
+ },
25
+ },
26
+ Render: function (id) {
27
+ return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
28
+ },
29
+ };
30
+ const icon = html`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 20 20">
31
+ <path
32
+ fill="currentColor"
33
+ d="M6 2a2 2 0 0 0-2 2v5.207a5.5 5.5 0 0 1 1-.185V4a1 1 0 0 1 1-1h4v3.5A1.5 1.5 0 0 0 11.5 8H15v8a1 1 0 0 1-1 1h-3.6a5.5 5.5 0 0 1-.657 1H14a2 2 0 0 0 2-2V7.414a1.5 1.5 0 0 0-.44-1.06l-3.914-3.915A1.5 1.5 0 0 0 10.586 2zm8.793 5H11.5a.5.5 0 0 1-.5-.5V3.207zM10 14.5a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0M5.5 12a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 1 0v-2a.5.5 0 0 0-.5-.5m0 5.125a.625.625 0 1 0 0-1.25a.625.625 0 0 0 0 1.25"
34
+ />
35
+ </svg>`;
36
+
37
+ append(
38
+ 'body',
39
+ html` <style>
40
+ body {
41
+ font-family: arial;
42
+ font-size: 20px;
43
+ background-color: #d8d8d8;
44
+ color: #333;
45
+ }
46
+ a {
47
+ color: black;
48
+ }
49
+ </style>
50
+
51
+ <div class="abs center" style="top: 45%">
52
+ ${icon}
53
+ <br />
54
+ <br />
55
+ <span class="bold">500</span>
56
+ <br />
57
+ <br />${Translate.Render('page-broken')} <br />
58
+ <br />
59
+ <a href="${location.origin}">${Translate.Render('back')}</a>
60
+ </div>`,
61
+ );
62
+ };
63
+
64
+ SrrComponent = () => html`<script>
65
+ {
66
+ const s = ${s};
67
+ const append = ${append};
68
+ const getLang = ${getLang};
69
+ const main = ${main};
70
+ window.onload = main;
71
+ }
72
+ </script>`;
@@ -109,6 +109,6 @@ SrrComponent = ({ ttiLoadTimeLimit }) => {
109
109
  const CacheControl = ${CacheControl};
110
110
  CacheControl({ ttiLoadTimeLimit: ${ttiLoadTimeLimit ? ttiLoadTimeLimit : 1000 * 70 * 1} });
111
111
  </script>
112
- <div class="clean-cache-container">v2.7.92</div>
112
+ <div class="clean-cache-container">v2.7.94</div>
113
113
  `;
114
114
  };
@@ -3,7 +3,9 @@ const s = (el) => document.querySelector(el);
3
3
  const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
4
4
 
5
5
  const getLang = () =>
6
- (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
6
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
7
+ .slice(0, 2)
8
+ .toLowerCase();
7
9
 
8
10
  const main = () => {
9
11
  const Translate = {
@@ -3,7 +3,9 @@ const s = (el) => document.querySelector(el);
3
3
  const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
4
4
 
5
5
  const getLang = () =>
6
- (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
6
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
7
+ .slice(0, 2)
8
+ .toLowerCase();
7
9
 
8
10
  const main = () => {
9
11
  const Translate = {
@@ -97,7 +97,7 @@ const saveRuntimeRouter = async () => {
97
97
  port: networkRouter[_host][_path].port,
98
98
  apis: networkRouter[_host][_path].apis,
99
99
  };
100
- const instance = await Instance.findOne({ deployId: body.deployId, port: body.port });
100
+ const instance = await Instance.findOne({ deployId: body.deployId, host: _host, path: _path });
101
101
  if (instance) {
102
102
  await Instance.findByIdAndUpdate(instance._id, body);
103
103
  } else {