underpost 2.7.1 → 2.7.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 (214) hide show
  1. package/.dockerignore +13 -13
  2. package/.env.development +7 -7
  3. package/.env.production +7 -7
  4. package/.env.test +7 -7
  5. package/.github/workflows/publish.yml +26 -0
  6. package/.github/workflows/test.yml +80 -0
  7. package/.nycrc +9 -9
  8. package/.prettierignore +12 -12
  9. package/.prettierrc +9 -9
  10. package/.vscode/extensions.json +72 -72
  11. package/.vscode/settings.json +100 -99
  12. package/Dockerfile +89 -89
  13. package/LICENSE +21 -21
  14. package/README.md +96 -96
  15. package/bin/db.js +172 -119
  16. package/bin/deploy.js +607 -661
  17. package/bin/file.js +93 -92
  18. package/bin/index.js +76 -53
  19. package/bin/ssl.js +55 -64
  20. package/bin/util.js +182 -182
  21. package/bin/vs.js +35 -35
  22. package/conf.js +251 -249
  23. package/docker-compose.yml +67 -67
  24. package/jsconfig.json +7 -7
  25. package/jsdoc.json +32 -32
  26. package/nodemon.json +6 -6
  27. package/package.json +137 -132
  28. package/prometheus.yml +36 -36
  29. package/setup.sh +24 -24
  30. package/src/api/core/core.controller.js +69 -69
  31. package/src/api/core/core.model.js +11 -11
  32. package/src/api/core/core.router.js +23 -23
  33. package/src/api/core/core.service.js +29 -29
  34. package/src/api/crypto/crypto.controller.js +51 -51
  35. package/src/api/crypto/crypto.model.js +23 -23
  36. package/src/api/crypto/crypto.router.js +20 -20
  37. package/src/api/crypto/crypto.service.js +64 -64
  38. package/src/api/default/default.controller.js +69 -69
  39. package/src/api/default/default.model.js +20 -20
  40. package/src/api/default/default.router.js +23 -23
  41. package/src/api/default/default.service.js +31 -31
  42. package/src/api/file/file.controller.js +53 -51
  43. package/src/api/file/file.model.js +19 -19
  44. package/src/api/file/file.router.js +21 -20
  45. package/src/api/file/file.service.js +76 -70
  46. package/src/api/instance/instance.controller.js +69 -69
  47. package/src/api/instance/instance.model.js +36 -36
  48. package/src/api/instance/instance.router.js +33 -33
  49. package/src/api/instance/instance.service.js +48 -48
  50. package/src/api/test/test.controller.js +59 -59
  51. package/src/api/test/test.model.js +14 -14
  52. package/src/api/test/test.router.js +21 -21
  53. package/src/api/test/test.service.js +35 -35
  54. package/src/api/user/user.build.js +16 -0
  55. package/src/api/user/user.controller.js +70 -70
  56. package/src/api/user/user.model.js +65 -65
  57. package/src/api/user/user.router.js +345 -345
  58. package/src/api/user/user.service.js +479 -479
  59. package/src/api.js +23 -23
  60. package/src/client/Default.index.js +40 -40
  61. package/src/client/components/core/Account.js +290 -290
  62. package/src/client/components/core/AgGrid.js +160 -160
  63. package/src/client/components/core/Auth.js +19 -19
  64. package/src/client/components/core/Badge.js +32 -32
  65. package/src/client/components/core/{BlockChain.js → Blockchain.js} +41 -41
  66. package/src/client/components/core/Blog.js +9 -9
  67. package/src/client/components/core/BtnIcon.js +101 -94
  68. package/src/client/components/core/CalendarCore.js +458 -319
  69. package/src/client/components/core/Chat.js +64 -64
  70. package/src/client/components/core/ColorPalette.js +5267 -5267
  71. package/src/client/components/core/CommonJs.js +735 -732
  72. package/src/client/components/core/Content.js +193 -49
  73. package/src/client/components/core/Css.js +1064 -1027
  74. package/src/client/components/core/CssCore.js +817 -796
  75. package/src/client/components/core/D3Chart.js +44 -44
  76. package/src/client/components/core/Docs.js +229 -229
  77. package/src/client/components/core/DropDown.js +164 -164
  78. package/src/client/components/core/EventsUI.js +46 -54
  79. package/src/client/components/core/FileExplorer.js +699 -624
  80. package/src/client/components/core/FullScreen.js +45 -45
  81. package/src/client/components/core/Input.js +346 -259
  82. package/src/client/components/core/JoyStick.js +77 -77
  83. package/src/client/components/core/Keyboard.js +73 -73
  84. package/src/client/components/core/LoadingAnimation.js +179 -157
  85. package/src/client/components/core/LogIn.js +187 -181
  86. package/src/client/components/core/LogOut.js +58 -52
  87. package/src/client/components/core/Logger.js +26 -26
  88. package/src/client/components/core/Modal.js +1612 -1596
  89. package/src/client/components/core/NotificationManager.js +84 -84
  90. package/src/client/components/core/Panel.js +613 -413
  91. package/src/client/components/core/PanelForm.js +468 -0
  92. package/src/client/components/core/Polyhedron.js +162 -162
  93. package/src/client/components/core/Recover.js +204 -204
  94. package/src/client/components/core/Responsive.js +53 -53
  95. package/src/client/components/core/RichText.js +51 -27
  96. package/src/client/components/core/Router.js +76 -77
  97. package/src/client/components/core/Scroll.js +34 -0
  98. package/src/client/components/core/SignUp.js +125 -125
  99. package/src/client/components/core/SocketIo.js +72 -72
  100. package/src/client/components/core/Stream.js +113 -113
  101. package/src/client/components/core/ToggleSwitch.js +87 -87
  102. package/src/client/components/core/ToolTip.js +26 -26
  103. package/src/client/components/core/Translate.js +437 -408
  104. package/src/client/components/core/Validator.js +100 -100
  105. package/src/client/components/core/VanillaJs.js +460 -457
  106. package/src/client/components/core/Wallet.js +106 -106
  107. package/src/client/components/core/Webhook.js +25 -25
  108. package/src/client/components/core/Worker.js +272 -272
  109. package/src/client/components/default/CommonDefault.js +29 -29
  110. package/src/client/components/default/CssDefault.js +13 -13
  111. package/src/client/components/default/ElementsDefault.js +38 -38
  112. package/src/client/components/default/LogInDefault.js +41 -41
  113. package/src/client/components/default/LogOutDefault.js +28 -28
  114. package/src/client/components/default/MenuDefault.js +389 -389
  115. package/src/client/components/default/RoutesDefault.js +48 -48
  116. package/src/client/components/default/SettingsDefault.js +16 -16
  117. package/src/client/components/default/SignUpDefault.js +9 -9
  118. package/src/client/components/default/SocketIoDefault.js +54 -54
  119. package/src/client/components/default/TranslateDefault.js +7 -7
  120. package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
  121. package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
  122. package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
  123. package/src/client/public/default/browserconfig.xml +11 -11
  124. package/src/client/public/default/manifest.webmanifest +68 -68
  125. package/src/client/public/default/plantuml/client-conf.svg +1 -0
  126. package/src/client/public/default/plantuml/client-schema.svg +1 -0
  127. package/src/client/public/default/plantuml/cron-conf.svg +1 -0
  128. package/src/client/public/default/plantuml/cron-schema.svg +1 -0
  129. package/src/client/public/default/plantuml/server-conf.svg +1 -0
  130. package/src/client/public/default/plantuml/server-schema.svg +1 -0
  131. package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
  132. package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
  133. package/src/client/public/default/sitemap +147 -147
  134. package/src/client/public/default/yandex-browser-manifest.json +8 -8
  135. package/src/client/public/doc/sitemap +147 -147
  136. package/src/client/public/test/sitemap +147 -147
  137. package/src/client/services/core/core.service.js +170 -152
  138. package/src/client/services/crypto/crypto.service.js +70 -70
  139. package/src/client/services/default/default.management.js +345 -345
  140. package/src/client/services/default/default.service.js +89 -89
  141. package/src/client/services/file/file.service.js +70 -70
  142. package/src/client/services/instance/instance.management.js +74 -74
  143. package/src/client/services/instance/instance.service.js +89 -89
  144. package/src/client/services/test/test.service.js +70 -70
  145. package/src/client/services/user/user.management.js +50 -50
  146. package/src/client/services/user/user.service.js +89 -89
  147. package/src/client/ssr/Render.js +16 -16
  148. package/src/client/ssr/body-components/CacheControl.js +114 -113
  149. package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
  150. package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
  151. package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
  152. package/src/client/ssr/head-components/Css.js +241 -241
  153. package/src/client/ssr/head-components/DefaultScripts.js +3 -3
  154. package/src/client/ssr/head-components/Microdata.js +11 -11
  155. package/src/client/ssr/head-components/Production.js +1 -1
  156. package/src/client/ssr/head-components/PwaDefault.js +59 -59
  157. package/src/client/ssr/head-components/Seo.js +14 -14
  158. package/src/client/sw/default.sw.js +201 -201
  159. package/src/client/sw/template.sw.js +84 -84
  160. package/src/client.build.js +22 -22
  161. package/src/client.dev.js +21 -21
  162. package/src/cron.js +25 -25
  163. package/src/db/DataBaseProvider.js +34 -34
  164. package/src/db/mariadb/MariaDB.js +33 -33
  165. package/src/db/mongo/MongooseDB.js +137 -46
  166. package/src/dns.js +22 -22
  167. package/src/index.js +42 -29
  168. package/src/mailer/EmailRender.js +69 -69
  169. package/src/mailer/MailerProvider.js +96 -96
  170. package/src/proxy.js +22 -22
  171. package/src/runtime/lampp/Lampp.js +115 -44
  172. package/src/runtime/nginx/Nginx.js +3 -3
  173. package/src/runtime/xampp/Xampp.js +49 -49
  174. package/src/server/auth.js +235 -204
  175. package/src/server/backup.js +101 -94
  176. package/src/server/client-build-live.js +72 -72
  177. package/src/server/client-build.js +699 -699
  178. package/src/server/client-dev-server.js +60 -58
  179. package/src/server/client-formatted.js +48 -48
  180. package/src/server/client-icons.js +149 -150
  181. package/src/server/conf.js +860 -611
  182. package/src/server/dns.js +98 -98
  183. package/src/server/downloader.js +42 -42
  184. package/src/server/logger.js +190 -180
  185. package/src/server/network.js +122 -122
  186. package/src/server/peer.js +33 -33
  187. package/src/server/process.js +66 -66
  188. package/src/server/prompt-optimizer.js +28 -28
  189. package/src/server/proxy.js +118 -118
  190. package/src/server/runtime.js +444 -393
  191. package/src/server/ssl.js +120 -107
  192. package/src/server.js +25 -25
  193. package/src/ws/IoInterface.js +45 -45
  194. package/src/ws/IoServer.js +39 -39
  195. package/src/ws/core/channels/core.ws.chat.js +23 -23
  196. package/src/ws/core/channels/core.ws.mailer.js +35 -35
  197. package/src/ws/core/channels/core.ws.stream.js +31 -31
  198. package/src/ws/core/core.ws.connection.js +28 -28
  199. package/src/ws/core/core.ws.emit.js +14 -14
  200. package/src/ws/core/core.ws.server.js +24 -24
  201. package/src/ws/core/management/core.ws.chat.js +8 -8
  202. package/src/ws/core/management/core.ws.mailer.js +16 -16
  203. package/src/ws/core/management/core.ws.stream.js +8 -8
  204. package/src/ws/default/channels/default.ws.main.js +16 -16
  205. package/src/ws/default/default.ws.connection.js +22 -22
  206. package/src/ws/default/default.ws.emit.js +14 -14
  207. package/src/ws/default/default.ws.server.js +20 -20
  208. package/src/ws/default/management/default.ws.main.js +8 -8
  209. package/startup.js +11 -11
  210. package/supervisord-openssh-server.conf +4 -4
  211. package/test/api.test.js +60 -60
  212. package/bin/dns.js +0 -1
  213. package/bin/install.js +0 -357
  214. package/bin/shortcut.js +0 -44
@@ -1,44 +1,44 @@
1
- import { connectedScatterplotChart } from '../chart/connectedScatterplotChart.js';
2
-
3
- // https://takanori-fujiwara.github.io/d3-gallery-javascript/
4
-
5
- const D3Chart = {
6
- Render: async function () {
7
- setTimeout(async () => {
8
- const driving = await d3.csv('/data/driving.csv', d3.autoType);
9
-
10
- const button = d3.select('.chart-panel').append('div').append('button').attr('type', 'button').text('Replay');
11
-
12
- const play = () => {
13
- const chart = connectedScatterplotChart(driving, {
14
- svgId: 'connected-scatterplot',
15
- x: (d) => d.miles,
16
- y: (d) => d.gas,
17
- title: (d) => d.year,
18
- orient: (d) => d.side,
19
- yFormat: '.2f',
20
- xLabel: 'Miles driven (per capita per year) →',
21
- yLabel: '↑ Price of gas (per gallon, adjusted average $)',
22
- width: 1000,
23
- height: 720,
24
- duration: 5000, // for the intro animation; 0 to disable
25
- });
26
- d3.select('#connected-scatterplot').remove();
27
- d3.select('.chart-container').append(() => chart);
28
- };
29
-
30
- play();
31
-
32
- // replay
33
- button.on('click', () => {
34
- play();
35
- });
36
- });
37
- return html`
38
- <div class="in chart-container"></div>
39
- <div class="in chart-panel"></div>
40
- `;
41
- },
42
- };
43
-
44
- export { D3Chart };
1
+ import { connectedScatterplotChart } from '../chart/connectedScatterplotChart.js';
2
+
3
+ // https://takanori-fujiwara.github.io/d3-gallery-javascript/
4
+
5
+ const D3Chart = {
6
+ Render: async function () {
7
+ setTimeout(async () => {
8
+ const driving = await d3.csv('/data/driving.csv', d3.autoType);
9
+
10
+ const button = d3.select('.chart-panel').append('div').append('button').attr('type', 'button').text('Replay');
11
+
12
+ const play = () => {
13
+ const chart = connectedScatterplotChart(driving, {
14
+ svgId: 'connected-scatterplot',
15
+ x: (d) => d.miles,
16
+ y: (d) => d.gas,
17
+ title: (d) => d.year,
18
+ orient: (d) => d.side,
19
+ yFormat: '.2f',
20
+ xLabel: 'Miles driven (per capita per year) →',
21
+ yLabel: '↑ Price of gas (per gallon, adjusted average $)',
22
+ width: 1000,
23
+ height: 720,
24
+ duration: 5000, // for the intro animation; 0 to disable
25
+ });
26
+ d3.select('#connected-scatterplot').remove();
27
+ d3.select('.chart-container').append(() => chart);
28
+ };
29
+
30
+ play();
31
+
32
+ // replay
33
+ button.on('click', () => {
34
+ play();
35
+ });
36
+ });
37
+ return html`
38
+ <div class="in chart-container"></div>
39
+ <div class="in chart-panel"></div>
40
+ `;
41
+ },
42
+ };
43
+
44
+ export { D3Chart };
@@ -1,229 +1,229 @@
1
- import { BtnIcon } from './BtnIcon.js';
2
- import { rgbToHex } from './CommonJs.js';
3
- import { Css, darkTheme, dynamicCol, renderCssAttr, ThemeEvents, Themes } from './Css.js';
4
- import { DropDown } from './DropDown.js';
5
- import { Modal, renderMenuLabel, renderViewTitle } from './Modal.js';
6
- import { listenQueryPathInstance, setQueryPath } from './Router.js';
7
- import { Translate } from './Translate.js';
8
- import { getProxyPath, getQueryParams, htmls, s } from './VanillaJs.js';
9
-
10
- // https://mintlify.com/docs/quickstart
11
-
12
- const umlTypes = ['server', 'cron', 'client', 'ssr'];
13
-
14
- const Docs = {
15
- RenderModal: async function (type, modalOptions) {
16
- const docData = this.Data.find((d) => d.type === type);
17
- const ModalId = `modal-docs-${docData.type}`;
18
- const { barConfig } = await Themes[Css.currentTheme]();
19
- barConfig.buttons.close.onClick = () => {
20
- setQueryPath({ path: 'docs' });
21
- Modal.removeModal(ModalId);
22
- };
23
- await Modal.Render({
24
- barConfig,
25
- title: renderViewTitle(docData),
26
- id: ModalId,
27
- html: async () => {
28
- if (docData.renderHtml) return await docData.renderHtml();
29
- return html`
30
- <iframe
31
- class="in iframe-${ModalId}"
32
- style="width: 100%; border: none; background: white"
33
- src="${docData.url()}"
34
- >
35
- </iframe>
36
- `;
37
- },
38
- maximize: true,
39
- mode: 'view',
40
- slideMenu: 'modal-menu',
41
- observer: true,
42
- barMode: 'top-bottom-bar',
43
- ...modalOptions,
44
- });
45
- Modal.Data[ModalId].onObserverListener[ModalId] = () => {
46
- if (s(`.iframe-${ModalId}`))
47
- s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - Modal.headerTitleHeight}px`;
48
- };
49
- Modal.Data[ModalId].onObserverListener[ModalId]();
50
- },
51
- Data: [
52
- {
53
- type: 'repo',
54
- icon: html`<i class="fab fa-github"></i>`,
55
- text: `Last Release`,
56
- url: function () {
57
- return `https://github.com/underpostnet/engine/`;
58
- },
59
- },
60
- {
61
- type: 'src',
62
- icon: html`<i class="fa-brands fa-osi"></i>`,
63
- text: 'Source Docs',
64
- url: function () {
65
- return `${getProxyPath()}docs/engine/2.7.1`;
66
- },
67
- },
68
- {
69
- type: 'api',
70
- icon: html`<i class="fa-solid fa-arrows-turn-to-dots"></i>`,
71
- text: `Api Docs`,
72
- url: function () {
73
- return `${getProxyPath()}api-docs`;
74
- },
75
- },
76
- {
77
- type: 'coverage',
78
- icon: html`<img height="20" width="20" class="doc-icon-coverage" />`,
79
- text: `Coverage report`,
80
- url: function () {
81
- return `${getProxyPath()}docs/coverage`;
82
- },
83
- themeEvent: () => {
84
- s(`.doc-icon-coverage`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
85
- window.getComputedStyle(s('html')).color,
86
- )}`;
87
- },
88
- },
89
- {
90
- type: 'coverage-link',
91
- icon: html`<img height="20" width="20" class="doc-icon-coverage-link" />`,
92
- text: `Coverage`,
93
- url: function () {
94
- return `https://coveralls.io/github/underpostnet/engine`;
95
- },
96
- themeEvent: () => {
97
- s(`.doc-icon-coverage-link`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
98
- window.getComputedStyle(s('html')).color,
99
- )}`;
100
- },
101
- },
102
- ].concat(
103
- umlTypes.map((umlType) => {
104
- const umlId = `uml-${umlType}`;
105
- return {
106
- type: umlId,
107
- icon: html`<i class="fas fa-sitemap"></i>`,
108
- text: Translate.Render(`${umlType} config uml`),
109
- renderHtml: function () {
110
- return html` <div class="in section-mp">
111
- <div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Schema</div>
112
- </div>
113
- <div class="in section-mp">
114
- <a href="${getProxyPath()}docs/plantuml/${umlType}-schema.svg" target="_blank"
115
- ><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-schema.svg"
116
- /></a>
117
- </div>
118
- <div class="in section-mp">
119
- <div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Instance example</div>
120
- </div>
121
- <div class="in section-mp">
122
- <a href="${getProxyPath()}docs/plantuml/${umlType}-conf.svg" target="_blank"
123
- ><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-conf.svg"
124
- /></a>
125
- </div>`;
126
- },
127
- };
128
- }),
129
- ),
130
- Init: async function (options) {
131
- const { idModal } = options;
132
- setTimeout(() => {
133
- s(`.btn-docs-src`).onclick = async () => {
134
- setTimeout(() => setQueryPath({ path: 'docs', queryPath: 'src' }));
135
- await this.RenderModal('src', options.modalOptions);
136
- };
137
- s(`.btn-docs-api`).onclick = async () => {
138
- setTimeout(() => setQueryPath({ path: 'docs', queryPath: 'api' }));
139
- await this.RenderModal('api', options.modalOptions);
140
- };
141
- s(`.btn-docs-coverage`).onclick = async () => {
142
- setTimeout(() => setQueryPath({ path: 'docs', queryPath: 'coverage' }));
143
- await this.RenderModal('coverage', options.modalOptions);
144
- };
145
-
146
- s(`.btn-docs-coverage-link`).onclick = () => {
147
- const docData = this.Data.find((d) => d.type === 'coverage-link');
148
- location.href = docData.url();
149
- };
150
- s(`.btn-docs-repo`).onclick = () => {
151
- const docData = this.Data.find((d) => d.type === 'repo');
152
- location.href = docData.url();
153
- };
154
-
155
- for (const umlType of umlTypes) {
156
- const umlId = `uml-${umlType}`;
157
- s(`.btn-docs-${umlId}`).onclick = async () => {
158
- setTimeout(() => setQueryPath({ path: 'docs', queryPath: umlId }));
159
- await this.RenderModal(umlId, { ...options.modalOptions, handleType: 'bar' });
160
- };
161
- }
162
-
163
- // if (!getQueryParams().p) s(`.btn-docs-src`).click();
164
- listenQueryPathInstance({
165
- id: options.idModal,
166
- routeId: 'docs',
167
- event: (path) => {
168
- if (s(`.btn-docs-${path}`)) s(`.btn-docs-${path}`).click();
169
- },
170
- });
171
- });
172
- let docMenuRender = '';
173
- for (const docData of this.Data) {
174
- if (docData.themeEvent) {
175
- ThemeEvents[`doc-icon-${docData.type}`] = docData.themeEvent;
176
- setTimeout(ThemeEvents[`doc-icon-${docData.type}`]);
177
- }
178
- let tabHref, style, labelStyle;
179
- switch (docData.type) {
180
- case 'repo':
181
- case 'coverage-link':
182
- tabHref = docData.url();
183
- style = renderCssAttr({ style: { height: '45px' } });
184
- labelStyle = renderCssAttr({ style: { top: '8px', left: '9px' } });
185
- break;
186
-
187
- default:
188
- break;
189
- }
190
- docMenuRender += html` <div class="in">
191
- ${await BtnIcon.Render({
192
- class: `inl section-mp btn-custom btn-docs-${docData.type}`,
193
- label: html`${docData.icon} ${docData.text}`,
194
- tabHref,
195
- style,
196
- labelStyle,
197
- })}
198
- </div>`;
199
- }
200
- return html` <div class="in section-mp">${docMenuRender}</div>`;
201
- return html` <div class="in section-mp">
202
- ${await DropDown.Render({
203
- id: 'dropdown-docs',
204
- disableClose: true,
205
- disableSelectLabel: true,
206
- disableSelectOptionsLabel: true,
207
- disableSearchBox: true,
208
- open: true,
209
- lastSelectClass: 'hover-active',
210
- label: renderMenuLabel({
211
- icon: html`<i class="fas fa-book"></i>`,
212
- text: html`${Translate.Render('docs')}`,
213
- }),
214
- containerClass: '',
215
- data: this.Data.map((docTypeData) => {
216
- return {
217
- display: docTypeData.label,
218
- value: docTypeData.type,
219
- onClick: async () => {
220
- console.warn(this.viewUrl[docTypeData.type]());
221
- },
222
- };
223
- }),
224
- })}
225
- </div>`;
226
- },
227
- };
228
-
229
- export { Docs };
1
+ import { BtnIcon } from './BtnIcon.js';
2
+ import { rgbToHex } from './CommonJs.js';
3
+ import { Css, darkTheme, dynamicCol, renderCssAttr, ThemeEvents, Themes } from './Css.js';
4
+ import { DropDown } from './DropDown.js';
5
+ import { Modal, renderMenuLabel, renderViewTitle } from './Modal.js';
6
+ import { listenQueryPathInstance, setQueryPath } from './Router.js';
7
+ import { Translate } from './Translate.js';
8
+ import { getProxyPath, getQueryParams, htmls, s } from './VanillaJs.js';
9
+
10
+ // https://mintlify.com/docs/quickstart
11
+
12
+ const umlTypes = ['server', 'cron', 'client', 'ssr'];
13
+
14
+ const Docs = {
15
+ RenderModal: async function (type, modalOptions) {
16
+ const docData = this.Data.find((d) => d.type === type);
17
+ const ModalId = `modal-docs-${docData.type}`;
18
+ const { barConfig } = await Themes[Css.currentTheme]();
19
+ barConfig.buttons.close.onClick = () => {
20
+ setQueryPath({ path: 'docs' });
21
+ Modal.removeModal(ModalId);
22
+ };
23
+ await Modal.Render({
24
+ barConfig,
25
+ title: renderViewTitle(docData),
26
+ id: ModalId,
27
+ html: async () => {
28
+ if (docData.renderHtml) return await docData.renderHtml();
29
+ return html`
30
+ <iframe
31
+ class="in iframe-${ModalId}"
32
+ style="width: 100%; border: none; background: white"
33
+ src="${docData.url()}"
34
+ >
35
+ </iframe>
36
+ `;
37
+ },
38
+ maximize: true,
39
+ mode: 'view',
40
+ slideMenu: 'modal-menu',
41
+ observer: true,
42
+ barMode: 'top-bottom-bar',
43
+ query: true,
44
+ ...modalOptions,
45
+ });
46
+ Modal.Data[ModalId].onObserverListener[ModalId] = () => {
47
+ if (s(`.iframe-${ModalId}`))
48
+ s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - Modal.headerTitleHeight}px`;
49
+ };
50
+ Modal.Data[ModalId].onObserverListener[ModalId]();
51
+ },
52
+ Data: [
53
+ {
54
+ type: 'repo',
55
+ icon: html`<i class="fab fa-github"></i>`,
56
+ text: `Last Release`,
57
+ url: function () {
58
+ return `https://github.com/underpostnet/engine/`;
59
+ },
60
+ },
61
+ {
62
+ type: 'src',
63
+ icon: html`<i class="fa-brands fa-osi"></i>`,
64
+ text: 'Source Docs',
65
+ url: function () {
66
+ return `${getProxyPath()}docs/engine/2.7.3`;
67
+ },
68
+ },
69
+ {
70
+ type: 'api',
71
+ icon: html`<i class="fa-solid fa-arrows-turn-to-dots"></i>`,
72
+ text: `Api Docs`,
73
+ url: function () {
74
+ return `${getProxyPath()}api-docs`;
75
+ },
76
+ },
77
+ {
78
+ type: 'coverage',
79
+ icon: html`<img height="20" width="20" class="doc-icon-coverage" />`,
80
+ text: `Coverage report`,
81
+ url: function () {
82
+ return `${getProxyPath()}docs/coverage`;
83
+ },
84
+ themeEvent: () => {
85
+ s(`.doc-icon-coverage`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
86
+ window.getComputedStyle(s('html')).color,
87
+ )}`;
88
+ },
89
+ },
90
+ {
91
+ type: 'coverage-link',
92
+ icon: html`<img height="20" width="20" class="doc-icon-coverage-link" />`,
93
+ text: `Coverage`,
94
+ url: function () {
95
+ return `https://coveralls.io/github/underpostnet/engine`;
96
+ },
97
+ themeEvent: () => {
98
+ s(`.doc-icon-coverage-link`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
99
+ window.getComputedStyle(s('html')).color,
100
+ )}`;
101
+ },
102
+ },
103
+ ].concat(
104
+ umlTypes.map((umlType) => {
105
+ const umlId = `uml-${umlType}`;
106
+ return {
107
+ type: umlId,
108
+ icon: html`<i class="fas fa-sitemap"></i>`,
109
+ text: Translate.Render(`${umlType} config uml`),
110
+ renderHtml: function () {
111
+ return html` <div class="in section-mp">
112
+ <div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Schema</div>
113
+ </div>
114
+ <div class="in section-mp">
115
+ <a href="${getProxyPath()}docs/plantuml/${umlType}-schema.svg" target="_blank"
116
+ ><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-schema.svg"
117
+ /></a>
118
+ </div>
119
+ <div class="in section-mp">
120
+ <div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Instance example</div>
121
+ </div>
122
+ <div class="in section-mp">
123
+ <a href="${getProxyPath()}docs/plantuml/${umlType}-conf.svg" target="_blank"
124
+ ><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-conf.svg"
125
+ /></a>
126
+ </div>`;
127
+ },
128
+ };
129
+ }),
130
+ ),
131
+ Init: async function (options) {
132
+ const { idModal } = options;
133
+ setTimeout(() => {
134
+ s(`.btn-docs-src`).onclick = async () => {
135
+ setQueryPath({ path: 'docs', queryPath: 'src' });
136
+ await this.RenderModal('src', options.modalOptions);
137
+ };
138
+ s(`.btn-docs-api`).onclick = async () => {
139
+ setQueryPath({ path: 'docs', queryPath: 'api' });
140
+ await this.RenderModal('api', options.modalOptions);
141
+ };
142
+ s(`.btn-docs-coverage`).onclick = async () => {
143
+ setQueryPath({ path: 'docs', queryPath: 'coverage' });
144
+ await this.RenderModal('coverage', options.modalOptions);
145
+ };
146
+
147
+ s(`.btn-docs-coverage-link`).onclick = () => {
148
+ const docData = this.Data.find((d) => d.type === 'coverage-link');
149
+ location.href = docData.url();
150
+ };
151
+ s(`.btn-docs-repo`).onclick = () => {
152
+ const docData = this.Data.find((d) => d.type === 'repo');
153
+ location.href = docData.url();
154
+ };
155
+
156
+ for (const umlType of umlTypes) {
157
+ const umlId = `uml-${umlType}`;
158
+ s(`.btn-docs-${umlId}`).onclick = async () => {
159
+ setQueryPath({ path: 'docs', queryPath: umlId });
160
+ await this.RenderModal(umlId, { ...options.modalOptions, handleType: 'bar' });
161
+ };
162
+ }
163
+
164
+ listenQueryPathInstance({
165
+ id: options.idModal,
166
+ routeId: 'docs',
167
+ event: (path) => {
168
+ if (s(`.btn-docs-${path}`)) s(`.btn-docs-${path}`).click();
169
+ },
170
+ });
171
+ });
172
+ let docMenuRender = '';
173
+ for (const docData of this.Data) {
174
+ if (docData.themeEvent) {
175
+ ThemeEvents[`doc-icon-${docData.type}`] = docData.themeEvent;
176
+ setTimeout(ThemeEvents[`doc-icon-${docData.type}`]);
177
+ }
178
+ let tabHref, style, labelStyle;
179
+ switch (docData.type) {
180
+ case 'repo':
181
+ case 'coverage-link':
182
+ tabHref = docData.url();
183
+ style = renderCssAttr({ style: { height: '45px' } });
184
+ labelStyle = renderCssAttr({ style: { top: '8px', left: '9px' } });
185
+ break;
186
+
187
+ default:
188
+ break;
189
+ }
190
+ docMenuRender += html` <div class="in">
191
+ ${await BtnIcon.Render({
192
+ class: `inl section-mp btn-custom btn-docs-${docData.type}`,
193
+ label: html`${docData.icon} ${docData.text}`,
194
+ tabHref,
195
+ style,
196
+ labelStyle,
197
+ })}
198
+ </div>`;
199
+ }
200
+ return html` <div class="in section-mp">${docMenuRender}</div>`;
201
+ return html` <div class="in section-mp">
202
+ ${await DropDown.Render({
203
+ id: 'dropdown-docs',
204
+ disableClose: true,
205
+ disableSelectLabel: true,
206
+ disableSelectOptionsLabel: true,
207
+ disableSearchBox: true,
208
+ open: true,
209
+ lastSelectClass: 'hover-active',
210
+ label: renderMenuLabel({
211
+ icon: html`<i class="fas fa-book"></i>`,
212
+ text: html`${Translate.Render('docs')}`,
213
+ }),
214
+ containerClass: '',
215
+ data: this.Data.map((docTypeData) => {
216
+ return {
217
+ display: docTypeData.label,
218
+ value: docTypeData.type,
219
+ onClick: async () => {
220
+ console.warn(this.viewUrl[docTypeData.type]());
221
+ },
222
+ };
223
+ }),
224
+ })}
225
+ </div>`;
226
+ },
227
+ };
228
+
229
+ export { Docs };