@underpostnet/underpost 2.7.82

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 (290) hide show
  1. package/.dockerignore +14 -0
  2. package/.env.development +6 -0
  3. package/.env.production +6 -0
  4. package/.env.test +6 -0
  5. package/.github/workflows/ghpkg.yml +75 -0
  6. package/.github/workflows/publish.yml +84 -0
  7. package/.github/workflows/pwa-microservices-template.test.yml +30 -0
  8. package/.nycrc +9 -0
  9. package/.prettierignore +13 -0
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +72 -0
  12. package/.vscode/settings.json +100 -0
  13. package/AUTHORS.md +10 -0
  14. package/CHANGELOG.md +37 -0
  15. package/Dockerfile +90 -0
  16. package/LICENSE +21 -0
  17. package/README.md +96 -0
  18. package/bin/db.js +172 -0
  19. package/bin/deploy.js +674 -0
  20. package/bin/file.js +93 -0
  21. package/bin/index.js +82 -0
  22. package/bin/ssl.js +55 -0
  23. package/bin/util.js +182 -0
  24. package/bin/vs.js +35 -0
  25. package/conf.js +251 -0
  26. package/docker-compose.yml +67 -0
  27. package/jsconfig.json +7 -0
  28. package/jsdoc.json +32 -0
  29. package/nodemon.json +6 -0
  30. package/package.json +134 -0
  31. package/prometheus.yml +36 -0
  32. package/src/api/core/core.controller.js +69 -0
  33. package/src/api/core/core.model.js +11 -0
  34. package/src/api/core/core.router.js +23 -0
  35. package/src/api/core/core.service.js +29 -0
  36. package/src/api/crypto/crypto.controller.js +51 -0
  37. package/src/api/crypto/crypto.model.js +23 -0
  38. package/src/api/crypto/crypto.router.js +20 -0
  39. package/src/api/crypto/crypto.service.js +64 -0
  40. package/src/api/default/default.controller.js +69 -0
  41. package/src/api/default/default.model.js +20 -0
  42. package/src/api/default/default.router.js +23 -0
  43. package/src/api/default/default.service.js +31 -0
  44. package/src/api/file/file.controller.js +53 -0
  45. package/src/api/file/file.model.js +19 -0
  46. package/src/api/file/file.router.js +21 -0
  47. package/src/api/file/file.service.js +80 -0
  48. package/src/api/instance/instance.controller.js +69 -0
  49. package/src/api/instance/instance.model.js +36 -0
  50. package/src/api/instance/instance.router.js +33 -0
  51. package/src/api/instance/instance.service.js +48 -0
  52. package/src/api/test/test.controller.js +59 -0
  53. package/src/api/test/test.model.js +14 -0
  54. package/src/api/test/test.router.js +21 -0
  55. package/src/api/test/test.service.js +35 -0
  56. package/src/api/user/user.build.js +16 -0
  57. package/src/api/user/user.controller.js +70 -0
  58. package/src/api/user/user.model.js +65 -0
  59. package/src/api/user/user.router.js +345 -0
  60. package/src/api/user/user.service.js +479 -0
  61. package/src/api.js +23 -0
  62. package/src/client/Default.index.js +40 -0
  63. package/src/client/components/core/Account.js +290 -0
  64. package/src/client/components/core/AgGrid.js +160 -0
  65. package/src/client/components/core/Auth.js +19 -0
  66. package/src/client/components/core/Badge.js +32 -0
  67. package/src/client/components/core/Blockchain.js +41 -0
  68. package/src/client/components/core/Blog.js +9 -0
  69. package/src/client/components/core/BtnIcon.js +101 -0
  70. package/src/client/components/core/CalendarCore.js +458 -0
  71. package/src/client/components/core/Chat.js +64 -0
  72. package/src/client/components/core/ColorPalette.js +5267 -0
  73. package/src/client/components/core/CommonJs.js +742 -0
  74. package/src/client/components/core/Content.js +193 -0
  75. package/src/client/components/core/Css.js +846 -0
  76. package/src/client/components/core/CssCore.js +817 -0
  77. package/src/client/components/core/D3Chart.js +44 -0
  78. package/src/client/components/core/Docs.js +231 -0
  79. package/src/client/components/core/DropDown.js +164 -0
  80. package/src/client/components/core/EventsUI.js +46 -0
  81. package/src/client/components/core/FileExplorer.js +699 -0
  82. package/src/client/components/core/FullScreen.js +45 -0
  83. package/src/client/components/core/Input.js +346 -0
  84. package/src/client/components/core/JoyStick.js +77 -0
  85. package/src/client/components/core/Keyboard.js +73 -0
  86. package/src/client/components/core/LoadingAnimation.js +178 -0
  87. package/src/client/components/core/LogIn.js +187 -0
  88. package/src/client/components/core/LogOut.js +58 -0
  89. package/src/client/components/core/Logger.js +26 -0
  90. package/src/client/components/core/Modal.js +1612 -0
  91. package/src/client/components/core/NotificationManager.js +84 -0
  92. package/src/client/components/core/Panel.js +613 -0
  93. package/src/client/components/core/PanelForm.js +468 -0
  94. package/src/client/components/core/Polyhedron.js +162 -0
  95. package/src/client/components/core/Recover.js +204 -0
  96. package/src/client/components/core/Responsive.js +53 -0
  97. package/src/client/components/core/RichText.js +51 -0
  98. package/src/client/components/core/Router.js +76 -0
  99. package/src/client/components/core/Scroll.js +34 -0
  100. package/src/client/components/core/SignUp.js +125 -0
  101. package/src/client/components/core/SocketIo.js +72 -0
  102. package/src/client/components/core/Stream.js +113 -0
  103. package/src/client/components/core/ToggleSwitch.js +87 -0
  104. package/src/client/components/core/ToolTip.js +26 -0
  105. package/src/client/components/core/Translate.js +446 -0
  106. package/src/client/components/core/Validator.js +100 -0
  107. package/src/client/components/core/VanillaJs.js +463 -0
  108. package/src/client/components/core/Wallet.js +106 -0
  109. package/src/client/components/core/Webhook.js +25 -0
  110. package/src/client/components/core/Worker.js +282 -0
  111. package/src/client/components/default/CommonDefault.js +29 -0
  112. package/src/client/components/default/CssDefault.js +13 -0
  113. package/src/client/components/default/ElementsDefault.js +38 -0
  114. package/src/client/components/default/LogInDefault.js +41 -0
  115. package/src/client/components/default/LogOutDefault.js +28 -0
  116. package/src/client/components/default/MenuDefault.js +389 -0
  117. package/src/client/components/default/RoutesDefault.js +48 -0
  118. package/src/client/components/default/SettingsDefault.js +16 -0
  119. package/src/client/components/default/SignUpDefault.js +9 -0
  120. package/src/client/components/default/SocketIoDefault.js +54 -0
  121. package/src/client/components/default/TranslateDefault.js +7 -0
  122. package/src/client/public/default/android-chrome-144x144.png +0 -0
  123. package/src/client/public/default/android-chrome-192x192.png +0 -0
  124. package/src/client/public/default/android-chrome-256x256.png +0 -0
  125. package/src/client/public/default/android-chrome-36x36.png +0 -0
  126. package/src/client/public/default/android-chrome-384x384.png +0 -0
  127. package/src/client/public/default/android-chrome-48x48.png +0 -0
  128. package/src/client/public/default/android-chrome-512x512.png +0 -0
  129. package/src/client/public/default/android-chrome-72x72.png +0 -0
  130. package/src/client/public/default/android-chrome-96x96.png +0 -0
  131. package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
  132. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  133. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  134. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  135. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  136. package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
  137. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  138. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  139. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  140. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  141. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  142. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  143. package/src/client/public/default/apple-touch-icon.png +0 -0
  144. package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
  145. package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
  146. package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
  147. package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
  148. package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
  149. package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
  150. package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
  151. package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
  152. package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
  153. package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
  154. package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
  155. package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
  156. package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
  157. package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
  158. package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
  159. package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
  160. package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
  161. package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
  162. package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
  163. package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
  164. package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
  165. package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
  166. package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
  167. package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
  168. package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
  169. package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
  170. package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
  171. package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
  172. package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
  173. package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
  174. package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
  175. package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
  176. package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
  177. package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
  178. package/src/client/public/default/assets/background/white.jpg +0 -0
  179. package/src/client/public/default/assets/background/white0-min.jpg +0 -0
  180. package/src/client/public/default/assets/background/white0.jpg +0 -0
  181. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  182. package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
  183. package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
  184. package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
  185. package/src/client/public/default/browserconfig.xml +12 -0
  186. package/src/client/public/default/favicon-16x16.png +0 -0
  187. package/src/client/public/default/favicon-32x32.png +0 -0
  188. package/src/client/public/default/favicon-48x48.png +0 -0
  189. package/src/client/public/default/favicon.ico +0 -0
  190. package/src/client/public/default/manifest.webmanifest +69 -0
  191. package/src/client/public/default/mstile-144x144.png +0 -0
  192. package/src/client/public/default/mstile-150x150.png +0 -0
  193. package/src/client/public/default/mstile-310x150.png +0 -0
  194. package/src/client/public/default/mstile-310x310.png +0 -0
  195. package/src/client/public/default/mstile-70x70.png +0 -0
  196. package/src/client/public/default/plantuml/client-conf.svg +1 -0
  197. package/src/client/public/default/plantuml/client-schema.svg +1 -0
  198. package/src/client/public/default/plantuml/cron-conf.svg +1 -0
  199. package/src/client/public/default/plantuml/cron-schema.svg +1 -0
  200. package/src/client/public/default/plantuml/server-conf.svg +1 -0
  201. package/src/client/public/default/plantuml/server-schema.svg +1 -0
  202. package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
  203. package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
  204. package/src/client/public/default/sitemap +148 -0
  205. package/src/client/public/default/yandex-browser-50x50.png +0 -0
  206. package/src/client/public/default/yandex-browser-manifest.json +9 -0
  207. package/src/client/public/doc/favicon.ico +0 -0
  208. package/src/client/public/doc/sitemap +148 -0
  209. package/src/client/public/test/favicon.ico +0 -0
  210. package/src/client/public/test/sitemap +148 -0
  211. package/src/client/services/core/core.service.js +170 -0
  212. package/src/client/services/crypto/crypto.service.js +70 -0
  213. package/src/client/services/default/default.management.js +343 -0
  214. package/src/client/services/default/default.service.js +89 -0
  215. package/src/client/services/file/file.service.js +70 -0
  216. package/src/client/services/instance/instance.management.js +74 -0
  217. package/src/client/services/instance/instance.service.js +89 -0
  218. package/src/client/services/test/test.service.js +70 -0
  219. package/src/client/services/user/user.management.js +50 -0
  220. package/src/client/services/user/user.service.js +89 -0
  221. package/src/client/ssr/Render.js +237 -0
  222. package/src/client/ssr/common/Alert.js +75 -0
  223. package/src/client/ssr/common/SsrCore.js +91 -0
  224. package/src/client/ssr/common/Translate.js +26 -0
  225. package/src/client/ssr/common/Worker.js +28 -0
  226. package/src/client/ssr/components/body/CacheControl.js +114 -0
  227. package/src/client/ssr/components/body/DefaultSplashScreen.js +90 -0
  228. package/src/client/ssr/components/email/DefaultRecoverEmail.js +21 -0
  229. package/src/client/ssr/components/email/DefaultVerifyEmail.js +17 -0
  230. package/src/client/ssr/components/head/Css.js +241 -0
  231. package/src/client/ssr/components/head/DefaultScripts.js +3 -0
  232. package/src/client/ssr/components/head/PwaDefault.js +60 -0
  233. package/src/client/ssr/offline/default.index.js +31 -0
  234. package/src/client/ssr/pages/404.js +12 -0
  235. package/src/client/ssr/pages/500.js +12 -0
  236. package/src/client/sw/default.sw.js +203 -0
  237. package/src/client/sw/template.sw.js +84 -0
  238. package/src/client.build.js +22 -0
  239. package/src/client.dev.js +21 -0
  240. package/src/cron.js +30 -0
  241. package/src/db/DataBaseProvider.js +34 -0
  242. package/src/db/mariadb/MariaDB.js +33 -0
  243. package/src/db/mongo/MongooseDB.js +125 -0
  244. package/src/dns.js +22 -0
  245. package/src/index.js +43 -0
  246. package/src/mailer/EmailRender.js +69 -0
  247. package/src/mailer/MailerProvider.js +96 -0
  248. package/src/proxy.js +22 -0
  249. package/src/runtime/lampp/Lampp.js +115 -0
  250. package/src/runtime/nginx/Nginx.js +3 -0
  251. package/src/runtime/xampp/Xampp.js +49 -0
  252. package/src/server/auth.js +235 -0
  253. package/src/server/backup.js +108 -0
  254. package/src/server/client-build-live.js +98 -0
  255. package/src/server/client-build.js +821 -0
  256. package/src/server/client-dev-server.js +60 -0
  257. package/src/server/client-formatted.js +58 -0
  258. package/src/server/client-icons.js +151 -0
  259. package/src/server/conf.js +883 -0
  260. package/src/server/cron.js +35 -0
  261. package/src/server/dns.js +89 -0
  262. package/src/server/downloader.js +42 -0
  263. package/src/server/logger.js +190 -0
  264. package/src/server/network.js +122 -0
  265. package/src/server/peer.js +33 -0
  266. package/src/server/process.js +66 -0
  267. package/src/server/prompt-optimizer.js +28 -0
  268. package/src/server/proxy.js +118 -0
  269. package/src/server/runtime.js +461 -0
  270. package/src/server/ssl.js +120 -0
  271. package/src/server.js +25 -0
  272. package/src/ws/IoInterface.js +45 -0
  273. package/src/ws/IoServer.js +39 -0
  274. package/src/ws/core/channels/core.ws.chat.js +23 -0
  275. package/src/ws/core/channels/core.ws.mailer.js +35 -0
  276. package/src/ws/core/channels/core.ws.stream.js +31 -0
  277. package/src/ws/core/core.ws.connection.js +28 -0
  278. package/src/ws/core/core.ws.emit.js +14 -0
  279. package/src/ws/core/core.ws.server.js +24 -0
  280. package/src/ws/core/management/core.ws.chat.js +8 -0
  281. package/src/ws/core/management/core.ws.mailer.js +16 -0
  282. package/src/ws/core/management/core.ws.stream.js +8 -0
  283. package/src/ws/default/channels/default.ws.main.js +16 -0
  284. package/src/ws/default/default.ws.connection.js +22 -0
  285. package/src/ws/default/default.ws.emit.js +14 -0
  286. package/src/ws/default/default.ws.server.js +20 -0
  287. package/src/ws/default/management/default.ws.main.js +8 -0
  288. package/startup.js +11 -0
  289. package/supervisord-openssh-server.conf +5 -0
  290. package/test/api.test.js +60 -0
@@ -0,0 +1,45 @@
1
+ import { Responsive } from './Responsive.js';
2
+ import { ToggleSwitch } from './ToggleSwitch.js';
3
+ import { Translate } from './Translate.js';
4
+ import { checkFullScreen, fullScreenIn, fullScreenOut, s } from './VanillaJs.js';
5
+
6
+ const FullScreen = {
7
+ RenderSetting: async function () {
8
+ let fullScreenSwitch = checkFullScreen();
9
+ Responsive.Event['full-screen-settings'] = () => {
10
+ let fullScreenMode = checkFullScreen();
11
+ if ((fullScreenSwitch && !fullScreenMode) || (!fullScreenSwitch && fullScreenMode))
12
+ if (s('.fullscreen-toggle')) ToggleSwitch.Tokens[`fullscreen-toggle`].click();
13
+ };
14
+ setTimeout(
15
+ () => (s(`.toggle-form-container-fullscreen`).onclick = () => ToggleSwitch.Tokens[`fullscreen-toggle`].click()),
16
+ );
17
+ return html`<div class="in section-mp toggle-form-container toggle-form-container-fullscreen hover">
18
+ <div class="fl ">
19
+ <div class="in fll" style="width: 70%">
20
+ <div class="in"><i class="fa-solid fa-expand"></i> ${Translate.Render('fullscreen')}</div>
21
+ </div>
22
+ <div class="in fll" style="width: 30%">
23
+ ${await ToggleSwitch.Render({
24
+ id: 'fullscreen-toggle',
25
+ containerClass: 'inl',
26
+ disabledOnClick: true,
27
+ checked: fullScreenSwitch,
28
+ on: {
29
+ unchecked: () => {
30
+ fullScreenSwitch = false;
31
+ if (checkFullScreen()) fullScreenOut();
32
+ },
33
+ checked: () => {
34
+ fullScreenSwitch = true;
35
+ if (!checkFullScreen()) fullScreenIn();
36
+ },
37
+ },
38
+ })}
39
+ </div>
40
+ </div>
41
+ </div>`;
42
+ },
43
+ };
44
+
45
+ export { FullScreen };
@@ -0,0 +1,346 @@
1
+ import { AgGrid } from './AgGrid.js';
2
+ import { BtnIcon } from './BtnIcon.js';
3
+ import { darkTheme } from './Css.js';
4
+ import { loggerFactory } from './Logger.js';
5
+ import { RichText } from './RichText.js';
6
+ import { ToggleSwitch } from './ToggleSwitch.js';
7
+ import { Translate } from './Translate.js';
8
+ import { htmls, s } from './VanillaJs.js';
9
+ const logger = loggerFactory(import.meta);
10
+
11
+ const fileFormDataFactory = (e, extensions) => {
12
+ const form = new FormData();
13
+ for (const keyFile of Object.keys(e.target.files)) {
14
+ if (extensions && !extensions.includes(e.target.files[keyFile].type)) {
15
+ logger.error('Invalid file extension', e.target.files[keyFile]);
16
+ continue;
17
+ }
18
+ form.append(e.target.files[keyFile].name, e.target.files[keyFile]);
19
+ }
20
+ return form;
21
+ };
22
+
23
+ const getFileFromFileData = (fileData) => {
24
+ const blob = new Blob([new Uint8Array(fileData.data.data)], { type: fileData.mimetype });
25
+ return new File([blob], fileData.name, { type: fileData.mimetype });
26
+ };
27
+
28
+ const getSrcFromFileData = (fileData) => {
29
+ const file = getFileFromFileData(fileData);
30
+ return URL.createObjectURL(file);
31
+ };
32
+
33
+ const Input = {
34
+ Render: async function (options) {
35
+ const { id } = options;
36
+ options?.placeholder
37
+ ? options.placeholder === true
38
+ ? (options.placeholder = ' . . .')
39
+ : options.placeholder
40
+ : null;
41
+ setTimeout(() => {
42
+ if (!s(`.${id}`)) return;
43
+ s(`.input-container-${id}`).onclick = () => {
44
+ ['color', 'file'].includes(options.type) ? s(`.${id}`).click() : s(`.${id}`).focus();
45
+ ['datetime-local'].includes(options.type) ? s(`.${id}`).showPicker() : s(`.${id}`).focus();
46
+ };
47
+
48
+ if (s(`.btn-eye-${id}`))
49
+ s(`.btn-eye-${id}`).onclick = () => {
50
+ if (s(`.fa-eye-slash-${id}`).style.display === 'none') {
51
+ s(`.fa-eye-${id}`).style.display = 'none';
52
+ s(`.fa-eye-slash-${id}`).style.display = null;
53
+ s(`.${id}`).type = 'text';
54
+ return;
55
+ }
56
+ s(`.fa-eye-slash-${id}`).style.display = 'none';
57
+ s(`.fa-eye-${id}`).style.display = null;
58
+ s(`.${id}`).type = 'password';
59
+ };
60
+ });
61
+
62
+ const inputElement = html` <input
63
+ type="${options?.type ? options.type : 'text'}"
64
+ class="${options.inputClass ? options.inputClass : 'in wfa'} ${id}"
65
+ ${options?.min !== undefined ? `min="${options.min}"` : ''}
66
+ placeholder${options?.placeholder ? `="${options.placeholder}"` : ''}
67
+ ${options?.value !== undefined ? `value="${options.value}"` : ''}
68
+ ${options?.autocomplete ? `autocomplete="${options.autocomplete}"` : ''}
69
+ ${options?.disabled ? `disabled` : ''}
70
+ ${options?.name !== undefined ? `name="${options.name}"` : ''}
71
+ ${options?.pattern !== undefined ? `pattern="${options.pattern}"` : ''}
72
+ ${options?.pattern === undefined && options.type === 'tel' ? `pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"` : ''}
73
+ ${options?.required ? ` required ` : ''}
74
+ ${options?.accept ? `accept="${options.accept}"` : ''}
75
+ ${options?.multiple ? `multiple="multiple"` : ''}
76
+ />
77
+ <div class="${id}-input-extension input-info input-extension ${options?.extension ? '' : 'hide'}">
78
+ ${options?.extension ? await options.extension() : ''}
79
+ </div>`;
80
+
81
+ return html` <div class="${options?.containerClass ? options.containerClass + ' ' : ''} input-container-${id}">
82
+ <div class="in">
83
+ ${options?.label ? html`<div class="in input-label input-label-${id}">${options.label}</div>` : ''}
84
+ ${options.type === 'password' && !options.disabledEye
85
+ ? html`
86
+ <div class="fl input-row-${id}">
87
+ <div class="in fll" style="width: 80%;">${inputElement}</div>
88
+ <div class="in fll btn-eye-password btn-eye-${id}" style="width: 20%;">
89
+ <i class="fas fa-eye fa-eye-${id} eye-password"></i>
90
+ <i class="fas fa-eye-slash fa-eye-slash-${id} eye-password" style="display: none"></i>
91
+ </div>
92
+ </div>
93
+ `
94
+ : options?.placeholderIcon
95
+ ? html` <div class="fl input-row-${id}">${options.placeholderIcon} ${inputElement}</div> `
96
+ : inputElement}
97
+ <div class="in input-info input-info-${id}">&nbsp</div>
98
+ </div>
99
+ </div>`;
100
+ },
101
+ parseJsonEval: (selector) => {
102
+ try {
103
+ return JSON.parse(s(selector).value);
104
+ } catch (error) {
105
+ return s(selector).value;
106
+ }
107
+ },
108
+ getValues: function (formData) {
109
+ const obj = {};
110
+ for (const inputData of formData) {
111
+ if (inputData.disableRender) continue;
112
+ switch (inputData.inputType) {
113
+ case 'file':
114
+ obj[inputData.model] = s(`.${inputData.id}`).inputFiles;
115
+ continue;
116
+ case 'md':
117
+ obj[inputData.model] = RichText.Tokens[inputData.id].easyMDE.value();
118
+ break;
119
+ case 'checkbox':
120
+ case 'checkbox-on-off':
121
+ obj[inputData.model] = s(`.${inputData.id}-checkbox`).checked;
122
+ continue;
123
+
124
+ default:
125
+ break;
126
+ }
127
+
128
+ if (!s(`.${inputData.id}`) || !s(`.${inputData.id}`).value || s(`.${inputData.id}`).value === 'undefined')
129
+ continue;
130
+ if ('model' in inputData) {
131
+ obj[inputData.model] = s(`.${inputData.id}`).value;
132
+ }
133
+ }
134
+ return obj;
135
+ },
136
+ cleanValues: function (formData) {
137
+ const obj = {};
138
+ for (const inputData of formData) {
139
+ if (!s(`.${inputData.id}`)) continue;
140
+
141
+ switch (inputData.inputType) {
142
+ case 'file':
143
+ s(`.${inputData.id}`).inputFiles = undefined;
144
+ s(`.${inputData.id}`).value = null;
145
+
146
+ if (s(`.file-name-render-${inputData.id}`) && s(`.${inputData.id}`).fileNameInputExtDefaultContent)
147
+ htmls(`.file-name-render-${inputData.id}`, `${s(`.${inputData.id}`).fileNameInputExtDefaultContent}`);
148
+ continue;
149
+ break;
150
+ case 'md':
151
+ RichText.Tokens[inputData.id].easyMDE.value('');
152
+ continue;
153
+ break;
154
+ case 'checkbox':
155
+ case 'checkbox-on-off':
156
+ if (s(`.${inputData.id}-checkbox`).checked) ToggleSwitch.Tokens[inputData.id].click();
157
+ continue;
158
+ break;
159
+
160
+ default:
161
+ break;
162
+ }
163
+
164
+ if ('model' in inputData) {
165
+ if (!['dropdown'].includes(inputData.inputType)) s(`.${inputData.id}`).value = '';
166
+ }
167
+ if (s(`.input-info-${inputData.id}`)) htmls(`.input-info-${inputData.id}`, html`&nbsp`);
168
+ }
169
+ return obj;
170
+ },
171
+ setValues: function (formData, obj, originObj, fileObj) {
172
+ setTimeout(() => {
173
+ for (const inputData of formData) {
174
+ if (!s(`.${inputData.id}`)) continue;
175
+
176
+ switch (inputData.inputType) {
177
+ case 'file':
178
+ if (fileObj[inputData.model] && s(`.${inputData.id}`)) {
179
+ const dataTransfer = new DataTransfer();
180
+
181
+ if (fileObj[inputData.model].fileBlob)
182
+ dataTransfer.items.add(getFileFromFileData(fileObj[inputData.model].fileBlob));
183
+
184
+ if (fileObj[inputData.model].mdBlob)
185
+ dataTransfer.items.add(getFileFromFileData(fileObj[inputData.model].mdBlob));
186
+
187
+ if (dataTransfer.files.length) {
188
+ s(`.${inputData.id}`).files = dataTransfer.files;
189
+ s(`.${inputData.id}`).onchange({ target: s(`.${inputData.id}`) });
190
+ }
191
+ }
192
+
193
+ continue;
194
+ break;
195
+ case 'md':
196
+ RichText.Tokens[inputData.id].easyMDE.value(fileObj[inputData.model].mdPlain);
197
+ continue;
198
+ break;
199
+ case 'checkbox':
200
+ case 'checkbox-on-off':
201
+ if (
202
+ (obj[inputData.model] === true && !s(`.${inputData.id}-checkbox`).checked) ||
203
+ (!obj[inputData.model] && s(`.${inputData.id}-checkbox`).checked === true)
204
+ )
205
+ ToggleSwitch.Tokens[inputData.id].click();
206
+ continue;
207
+ break;
208
+ case 'datetime-local':
209
+ {
210
+ const date = new Date(originObj[inputData.model]);
211
+ date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
212
+ s(`.${inputData.id}`).value = date.toISOString().slice(0, 16);
213
+ }
214
+ continue;
215
+ break;
216
+ default:
217
+ break;
218
+ }
219
+
220
+ if ('model' in inputData) {
221
+ if (!['dropdown'].includes(inputData.inputType)) s(`.${inputData.id}`).value = obj[inputData.model];
222
+ }
223
+ if (s(`.input-info-${inputData.id}`)) htmls(`.input-info-${inputData.id}`, html`&nbsp`);
224
+ }
225
+ });
226
+ },
227
+ };
228
+
229
+ const InputFile = {
230
+ Render: async function ({ id, multiple }, on = { change: () => {}, clear: () => {} }) {
231
+ // drag drop multi file
232
+ const gridId = `ag-grid-input-file-${id}`;
233
+ setTimeout(() => {
234
+ s(`.btn-clear-input-file-${id}`).onclick = (e) => {
235
+ e.preventDefault();
236
+ s(`.${id}`).value = null;
237
+ AgGrid.grids[gridId].setGridOption('rowData', []);
238
+ if (on && typeof on.clear === 'function') on.clear();
239
+ };
240
+
241
+ ['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'].forEach(function (event) {
242
+ s(`.drop-zone-${id}`).addEventListener(event, function (e) {
243
+ e.preventDefault();
244
+ e.stopPropagation();
245
+ });
246
+ });
247
+ s(`.drop-zone-${id}`).addEventListener(
248
+ 'dragover',
249
+ function (e) {
250
+ this.classList.add('drop-hover-container');
251
+ },
252
+ false,
253
+ );
254
+
255
+ s(`.drop-zone-${id}`).addEventListener(
256
+ 'dragleave',
257
+ function (e) {
258
+ this.classList.remove('drop-hover-container');
259
+ },
260
+ false,
261
+ );
262
+ s(`.drop-zone-${id}`).addEventListener(
263
+ 'drop',
264
+ function (e) {
265
+ this.classList.remove('drop-hover-container');
266
+ const files = e.dataTransfer.files;
267
+ const dataTransfer = new DataTransfer();
268
+
269
+ let countFiles = 0;
270
+ Array.prototype.forEach.call(files, (file) => {
271
+ // logger.info(file);
272
+ if (!multiple && countFiles == 1) return;
273
+ dataTransfer.items.add(file);
274
+ countFiles++;
275
+ });
276
+
277
+ s(`.${id}`).files = dataTransfer.files;
278
+ s(`.${id}`).onchange({ target: s(`.${id}`) });
279
+ },
280
+ false,
281
+ );
282
+
283
+ s(`.drop-zone-${id}`).addEventListener('click', function (e) {
284
+ s(`.${id}`).click();
285
+ });
286
+
287
+ s(`.${id}`).onchange = (e) => {
288
+ // logger.info('e', e);
289
+ const fileGridData = [];
290
+ Object.keys(e.target.files).forEach((fileKey, index) => {
291
+ const file = e.target.files[fileKey];
292
+ logger.info('Load file', file);
293
+ // Get raw:
294
+ // const read = new FileReader();
295
+ // read.readAsBinaryString(file);
296
+ // read.onloadend = () => {
297
+ // console.log('Load File', e.target.files[fileKey], { fileKey, index }, read.result);
298
+ // };
299
+ fileGridData.push(file);
300
+ });
301
+ AgGrid.grids[gridId].setGridOption('rowData', fileGridData);
302
+ if (on && typeof on.change === 'function') on.change(e);
303
+ };
304
+ });
305
+ return html` <div class="fl">
306
+ <div class="in fll input-file-col">
307
+ <div class="in section-mp input-file-sub-col">
308
+ <input class="wfa ${id}" type="file" ${multiple ? `multiple="multiple"` : ''} />
309
+ <div class="in">
310
+ ${await BtnIcon.Render({
311
+ class: `wfa btn-clear-input-file-${id}`,
312
+ label: `<i class="fa-solid fa-broom"></i> ${Translate.Render('clear')}`,
313
+ })}
314
+ </div>
315
+ <div class="in">
316
+ ${await AgGrid.Render({
317
+ id: gridId,
318
+ darkTheme,
319
+ style: {
320
+ height: '200px',
321
+ },
322
+ gridOptions: {
323
+ rowData: [],
324
+ columnDefs: [
325
+ // { field: '_id', headerName: 'ID' },
326
+ { field: 'name', headerName: 'Name' },
327
+ { field: 'type', headerName: 'Type' },
328
+ ],
329
+ },
330
+ })}
331
+ </div>
332
+ </div>
333
+ </div>
334
+ <div class="in fll input-file-col">
335
+ <div class="in section-mp input-file-sub-col drop-zone-${id}">
336
+ <div class="abs center">
337
+ <i class="fas fa-cloud" style="font-size: 30px"></i><br />
338
+ ${Translate.Render('drop-file')}
339
+ </div>
340
+ </div>
341
+ </div>
342
+ </div>`;
343
+ },
344
+ };
345
+
346
+ export { Input, InputFile, fileFormDataFactory, getSrcFromFileData, getFileFromFileData };
@@ -0,0 +1,77 @@
1
+ import JoystickController from 'joystick-controller';
2
+ import { getDirection, getId } from './CommonJs.js';
3
+ import { loggerFactory } from './Logger.js';
4
+ import { append, getProxyPath, s } from './VanillaJs.js';
5
+
6
+ const logger = loggerFactory(import.meta);
7
+
8
+ const JoyStick = {
9
+ Tokens: {},
10
+ Render: async function (options = { id: '', callback: ({ joyDataSet }) => {}, callBackTime: 50 }) {
11
+ const { callback, callBackTime } = options;
12
+ const id = options.id ? options.id : getId(this.Tokens, 'joystick-');
13
+ this.Tokens[id] = { callback };
14
+ append(
15
+ 'body',
16
+ html`
17
+ <style>
18
+ .dynamic-joystick-container-${id} {
19
+ /* border: 2px solid red; */
20
+ left: 5px;
21
+ bottom: 5px;
22
+ height: 200px;
23
+ width: 200px;
24
+ z-index: 3;
25
+ }
26
+ .joy-img-background-${id} {
27
+ width: 93%;
28
+ height: 93%;
29
+ opacity: 0.8;
30
+ }
31
+ .dynamic-joystick-container-${id}:hover .joy-img-background-${id} {
32
+ width: 97%;
33
+ height: 97%;
34
+ opacity: 1;
35
+ }
36
+ </style>
37
+ <div class="abs dynamic-joystick-container-${id}">
38
+ <img class="abs center joy-img-background-${id}" src="${getProxyPath()}assets/joy/joy_alpha.png" />
39
+ </div>
40
+ `,
41
+ );
42
+
43
+ this.Tokens[id].instance = new JoystickController(
44
+ {
45
+ maxRange: 70,
46
+ level: 10,
47
+ radius: 70,
48
+ joystickRadius: 50,
49
+ opacity: 0.5,
50
+ // containerClass: 'joystick-container',
51
+ // controllerClass: 'joystick-controller',
52
+ // joystickClass: 'joystick',
53
+ distortion: true,
54
+ dynamicPosition: true,
55
+ dynamicPositionTarget: s(`.dynamic-joystick-container-${id}`),
56
+ mouseClickButton: 'ALL',
57
+ hideContextMenu: true,
58
+ // x: '120px',
59
+ // y: '120px',
60
+ },
61
+ (args = { x, y, leveledX, leveledY, distance, angle }) => {
62
+ const { angle } = args;
63
+ if (angle === 0) return (this.Tokens[id].joyDataSet = undefined);
64
+ const radians = parseFloat(angle);
65
+ const direction = getDirection({ radians });
66
+ this.Tokens[id].joyDataSet = { ...args, radians, direction };
67
+ // logger.info(this.Tokens[id].joyDataSet, id);
68
+ },
69
+ );
70
+ setInterval(() => {
71
+ if (!this.Tokens[id].joyDataSet || !this.Tokens[id].joyDataSet.direction) return;
72
+ this.Tokens[id].callback({ joyDataSet: this.Tokens[id].joyDataSet });
73
+ }, callBackTime);
74
+ },
75
+ };
76
+
77
+ export { JoyStick };
@@ -0,0 +1,73 @@
1
+ import { cap, getId } from './CommonJs.js';
2
+
3
+ const Keyboard = {
4
+ ActiveKey: {},
5
+ Event: {},
6
+ Init: async function (options = { callBackTime: 50 }) {
7
+ const { callBackTime } = options;
8
+ window.onkeydown = (e = new KeyboardEvent()) => {
9
+ this.ActiveKey[e.key] = true;
10
+ // e.composedPath()
11
+ // if (['Tab'].includes(e.key)) {
12
+ // e.preventDefault();
13
+ // e.stopPropagation();
14
+ // e.stopImmediatePropagation();
15
+ // }
16
+ };
17
+ window.onkeyup = (e = new KeyboardEvent()) => {
18
+ delete this.ActiveKey[e.key];
19
+ };
20
+ setInterval(() => {
21
+ Object.keys(this.Event).map((key) => {
22
+ Object.keys(this.ActiveKey).map((activeKey) => {
23
+ if (activeKey in this.Event[key]) this.Event[key][activeKey]();
24
+ });
25
+ });
26
+ }, callBackTime);
27
+ },
28
+ instanceMultiPressKeyTokens: {},
29
+ instanceMultiPressKey: (options = { keys: [], id, timePressDelay, eventCallBack: () => {} }) => {
30
+ if (typeof options.keys[0] === 'string') options.keys[0] = [options.keys[0]];
31
+ if (!options.id) options.id = getId(Keyboard.instanceMultiPressKeyTokens, 'key-press-');
32
+ if (!options.timePressDelay) options.timePressDelay = 500;
33
+ const { id, timePressDelay, keys, eventCallBack } = options;
34
+ Keyboard.instanceMultiPressKeyTokens[id] = { ...options };
35
+
36
+ let indexCombined = -1;
37
+ for (const combinedKeys of keys) {
38
+ indexCombined++;
39
+ const privateIndexCombined = indexCombined;
40
+ const multiPressKey = {};
41
+ const triggerMultiPressKey = () => {
42
+ for (const key of Object.keys(multiPressKey)) {
43
+ if (!multiPressKey[key].press) return;
44
+ }
45
+ eventCallBack();
46
+ };
47
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`] = {};
48
+ for (const key of combinedKeys) {
49
+ multiPressKey[key] = {
50
+ press: false,
51
+ trigger: function () {
52
+ if (!multiPressKey[key].press) {
53
+ multiPressKey[key].press = true;
54
+ triggerMultiPressKey();
55
+ setTimeout(() => {
56
+ multiPressKey[key].press = false;
57
+ }, timePressDelay);
58
+ }
59
+ },
60
+ };
61
+
62
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key] = multiPressKey[key].trigger;
63
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key.toLowerCase()] =
64
+ multiPressKey[key].trigger;
65
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key.toUpperCase()] =
66
+ multiPressKey[key].trigger;
67
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][cap(key)] = multiPressKey[key].trigger;
68
+ }
69
+ }
70
+ },
71
+ };
72
+
73
+ export { Keyboard };