underpost 2.7.1 → 2.7.2
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/.dockerignore +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +582 -661
- package/bin/dns.js +1 -1
- package/bin/file.js +92 -92
- package/bin/index.js +53 -53
- package/bin/install.js +398 -357
- package/bin/shortcut.js +44 -44
- package/bin/ssl.js +65 -64
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -132
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/BlockChain.js +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +46 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -29
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +69 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -94
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +705 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -98
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +180 -180
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -28
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +109 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import nodemon from 'nodemon';
|
|
3
|
-
import { shellExec } from './process.js';
|
|
4
|
-
import { loggerFactory } from './logger.js';
|
|
5
|
-
|
|
6
|
-
const logger = loggerFactory(import.meta);
|
|
7
|
-
|
|
8
|
-
const createClientDevServer = () => {
|
|
9
|
-
// process.argv.slice(2).join(' ')
|
|
10
|
-
shellExec(`env-cmd -f .env.development node bin/deploy build-full-client ${process.argv.slice(2).join(' ')} l`);
|
|
11
|
-
shellExec(
|
|
12
|
-
`env-cmd -f .env.development node src/api ${process.argv[2]}${process.argv[5] ? ` ${process.argv[5]}` : ''}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import nodemon from 'nodemon';
|
|
3
|
+
import { shellExec } from './process.js';
|
|
4
|
+
import { loggerFactory } from './logger.js';
|
|
5
|
+
|
|
6
|
+
const logger = loggerFactory(import.meta);
|
|
7
|
+
|
|
8
|
+
const createClientDevServer = () => {
|
|
9
|
+
// process.argv.slice(2).join(' ')
|
|
10
|
+
shellExec(`env-cmd -f .env.development node bin/deploy build-full-client ${process.argv.slice(2).join(' ')} l`);
|
|
11
|
+
shellExec(
|
|
12
|
+
`env-cmd -f .env.development node src/api ${process.argv[2]}${process.argv[5] ? ` ${process.argv[5]}` : ''}${
|
|
13
|
+
process.argv.includes('static') ? ' static' : ''
|
|
14
|
+
}`,
|
|
15
|
+
{ async: true },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// https://github.com/remy/nodemon/blob/main/doc/events.md
|
|
19
|
+
|
|
20
|
+
// States
|
|
21
|
+
// start - child process has started
|
|
22
|
+
// crash - child process has crashed (nodemon will not emit exit)
|
|
23
|
+
// exit - child process has cleanly exited (ie. no crash)
|
|
24
|
+
// restart([ array of files triggering the restart ]) - child process has restarted
|
|
25
|
+
// config:update - nodemon's config has changed
|
|
26
|
+
|
|
27
|
+
if (fs.existsSync(`./tmp/client.build.json`)) fs.removeSync(`./tmp/client.build.json`);
|
|
28
|
+
|
|
29
|
+
let buildPathScope = [];
|
|
30
|
+
|
|
31
|
+
const nodemonOptions = { script: './src/client.build', args: process.argv.slice(2), watch: 'src/client' };
|
|
32
|
+
logger.info('nodemon option', { nodemonOptions });
|
|
33
|
+
nodemon(nodemonOptions)
|
|
34
|
+
.on('start', function (...args) {
|
|
35
|
+
logger.info(args, 'nodemon started');
|
|
36
|
+
})
|
|
37
|
+
.on('restart', function (...args) {
|
|
38
|
+
logger.info(args, 'nodemon restart');
|
|
39
|
+
const eventPath = args[0][0];
|
|
40
|
+
const indexPath = buildPathScope.findIndex((buildObjScope) => buildObjScope.path === eventPath);
|
|
41
|
+
const buildObj = {
|
|
42
|
+
timestamp: new Date().getTime(),
|
|
43
|
+
path: eventPath,
|
|
44
|
+
};
|
|
45
|
+
if (indexPath > -1) {
|
|
46
|
+
buildPathScope[indexPath].timestamp = buildObj.timestamp;
|
|
47
|
+
} else buildPathScope.push(buildObj);
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
buildPathScope = buildPathScope.filter((buildObjScope) => buildObjScope.timestamp !== buildObj.timestamp);
|
|
50
|
+
}, 2500);
|
|
51
|
+
const buildPathScopeBuild = buildPathScope.map((o) => o.path);
|
|
52
|
+
logger.info('buildPathScopeBuild', buildPathScopeBuild);
|
|
53
|
+
fs.writeFileSync(`./tmp/client.build.json`, JSON.stringify(buildPathScopeBuild, null, 4));
|
|
54
|
+
})
|
|
55
|
+
.on('crash', function (error) {
|
|
56
|
+
logger.error(error, error.message);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { createClientDevServer };
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const srcFormatted = (src) =>
|
|
4
|
-
src
|
|
5
|
-
.replaceAll(' html`', '`')
|
|
6
|
-
.replaceAll(' css`', '`')
|
|
7
|
-
.replaceAll('{html`', '{`')
|
|
8
|
-
.replaceAll('{css`', '{`')
|
|
9
|
-
.replaceAll('(html`', '(`')
|
|
10
|
-
.replaceAll('(css`', '(`')
|
|
11
|
-
.replaceAll('[html`', '[`')
|
|
12
|
-
.replaceAll('[css`', '[`');
|
|
13
|
-
|
|
14
|
-
const JSONweb = (data) => 'JSON.parse(`' + JSON.stringify(data) + '`)';
|
|
15
|
-
|
|
16
|
-
const componentFormatted = (src, module, dists, proxyPath, componentBasePath = '', baseHost = '') => {
|
|
17
|
-
dists.map(
|
|
18
|
-
(dist) =>
|
|
19
|
-
(src = src.replaceAll(
|
|
20
|
-
`from '${dist.import_name}'`,
|
|
21
|
-
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}` : ''}${dist.import_name_build}'`,
|
|
22
|
-
)),
|
|
23
|
-
);
|
|
24
|
-
return src
|
|
25
|
-
.replaceAll(
|
|
26
|
-
`from '../`,
|
|
27
|
-
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}${
|
|
28
|
-
componentBasePath === '' ? `` : `${componentBasePath}/`
|
|
29
|
-
}`,
|
|
30
|
-
)
|
|
31
|
-
.replaceAll(
|
|
32
|
-
`from './`,
|
|
33
|
-
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}${
|
|
34
|
-
componentBasePath === '' ? `` : `${componentBasePath}/`
|
|
35
|
-
}${module}/`,
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const viewFormatted = (src, dists, proxyPath, baseHost = '') => {
|
|
40
|
-
dists.map(
|
|
41
|
-
(dist) =>
|
|
42
|
-
(src = src.replaceAll(dist.import_name, `${proxyPath !== '/' ? `${proxyPath}` : ''}${dist.import_name_build}`)),
|
|
43
|
-
);
|
|
44
|
-
const componentFromFormatted = `from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}`;
|
|
45
|
-
return src.replaceAll(`from './`, componentFromFormatted).replaceAll(`from '../`, componentFromFormatted);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { srcFormatted, JSONweb, componentFormatted, viewFormatted };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const srcFormatted = (src) =>
|
|
4
|
+
src
|
|
5
|
+
.replaceAll(' html`', '`')
|
|
6
|
+
.replaceAll(' css`', '`')
|
|
7
|
+
.replaceAll('{html`', '{`')
|
|
8
|
+
.replaceAll('{css`', '{`')
|
|
9
|
+
.replaceAll('(html`', '(`')
|
|
10
|
+
.replaceAll('(css`', '(`')
|
|
11
|
+
.replaceAll('[html`', '[`')
|
|
12
|
+
.replaceAll('[css`', '[`');
|
|
13
|
+
|
|
14
|
+
const JSONweb = (data) => 'JSON.parse(`' + JSON.stringify(data) + '`)';
|
|
15
|
+
|
|
16
|
+
const componentFormatted = (src, module, dists, proxyPath, componentBasePath = '', baseHost = '') => {
|
|
17
|
+
dists.map(
|
|
18
|
+
(dist) =>
|
|
19
|
+
(src = src.replaceAll(
|
|
20
|
+
`from '${dist.import_name}'`,
|
|
21
|
+
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}` : ''}${dist.import_name_build}'`,
|
|
22
|
+
)),
|
|
23
|
+
);
|
|
24
|
+
return src
|
|
25
|
+
.replaceAll(
|
|
26
|
+
`from '../`,
|
|
27
|
+
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}${
|
|
28
|
+
componentBasePath === '' ? `` : `${componentBasePath}/`
|
|
29
|
+
}`,
|
|
30
|
+
)
|
|
31
|
+
.replaceAll(
|
|
32
|
+
`from './`,
|
|
33
|
+
`from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}${
|
|
34
|
+
componentBasePath === '' ? `` : `${componentBasePath}/`
|
|
35
|
+
}${module}/`,
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const viewFormatted = (src, dists, proxyPath, baseHost = '') => {
|
|
40
|
+
dists.map(
|
|
41
|
+
(dist) =>
|
|
42
|
+
(src = src.replaceAll(dist.import_name, `${proxyPath !== '/' ? `${proxyPath}` : ''}${dist.import_name_build}`)),
|
|
43
|
+
);
|
|
44
|
+
const componentFromFormatted = `from '${baseHost}${proxyPath !== '/' ? `${proxyPath}/` : '/'}`;
|
|
45
|
+
return src.replaceAll(`from './`, componentFromFormatted).replaceAll(`from '../`, componentFromFormatted);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { srcFormatted, JSONweb, componentFormatted, viewFormatted };
|
|
@@ -1,150 +1,149 @@
|
|
|
1
|
-
import { favicons } from 'favicons';
|
|
2
|
-
import textToImage from 'text-to-image';
|
|
3
|
-
import { loggerFactory } from './logger.js';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!
|
|
61
|
-
if (!
|
|
62
|
-
if (!
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
// -
|
|
103
|
-
// -
|
|
104
|
-
// *
|
|
105
|
-
// *
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// console.log(response.
|
|
133
|
-
// console.log(response.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
export { buildIcons, buildTextImg, defaultBaseTextImgOptions, faBase64Png, getBufferPngText };
|
|
1
|
+
import { favicons } from 'favicons';
|
|
2
|
+
import textToImage from 'text-to-image';
|
|
3
|
+
import { loggerFactory } from './logger.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { png3x } from 'font-awesome-assets';
|
|
6
|
+
import { getCapVariableName, s4 } from '../client/components/core/CommonJs.js';
|
|
7
|
+
|
|
8
|
+
const logger = loggerFactory(import.meta);
|
|
9
|
+
|
|
10
|
+
const faBase64Png = (faId = 'check', width = 100, height = 100, color = '#209e00') => {
|
|
11
|
+
const b64Src = png3x(faId, color, width, height);
|
|
12
|
+
return b64Src.split('src="data:image/png;base64,')[1].split('"')[0];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const defaultBaseTextImgOptions = {
|
|
16
|
+
debug: true,
|
|
17
|
+
fontFamily: 'Arial',
|
|
18
|
+
fontWeight: 'bold',
|
|
19
|
+
bgColor: 'black',
|
|
20
|
+
textColor: 'white',
|
|
21
|
+
debugFilename: 'src/client/public/text-image.png',
|
|
22
|
+
verticalAlign: 'center',
|
|
23
|
+
textAlign: 'center',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const defaultBaseTextImgOptionsSizes = {
|
|
27
|
+
'70x70': {
|
|
28
|
+
maxWidth: 70,
|
|
29
|
+
customHeight: 70,
|
|
30
|
+
fontSize: 25,
|
|
31
|
+
margin: 10,
|
|
32
|
+
},
|
|
33
|
+
'100x100': {
|
|
34
|
+
maxWidth: 100,
|
|
35
|
+
customHeight: 100,
|
|
36
|
+
fontSize: 30,
|
|
37
|
+
margin: 12,
|
|
38
|
+
},
|
|
39
|
+
'100x300': {
|
|
40
|
+
maxWidth: 300,
|
|
41
|
+
customHeight: 100,
|
|
42
|
+
fontSize: 30,
|
|
43
|
+
margin: 12,
|
|
44
|
+
},
|
|
45
|
+
'1200x1200': {
|
|
46
|
+
maxWidth: 1200,
|
|
47
|
+
customHeight: 1200,
|
|
48
|
+
fontSize: 500,
|
|
49
|
+
margin: 50,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const buildTextImg = async (text = 'APP', options, size = '1200x1200') => {
|
|
54
|
+
options = { ...defaultBaseTextImgOptions, ...defaultBaseTextImgOptionsSizes[size], ...options };
|
|
55
|
+
await textToImage.generate(text, options);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getBufferPngText = async ({ text, textColor, bgColor, size, debugFilename }) => {
|
|
59
|
+
if (!text) text = 'Hello World!';
|
|
60
|
+
if (!textColor) textColor = '#000000';
|
|
61
|
+
if (!bgColor) bgColor = '#ffffff';
|
|
62
|
+
if (!size) size = '100x300';
|
|
63
|
+
if (!debugFilename) debugFilename = `./${s4()}${s4()}${s4()}.png`;
|
|
64
|
+
await buildTextImg(text, { textColor, bgColor, size, debugFilename }, size);
|
|
65
|
+
const bufferImage = fs.readFileSync(debugFilename);
|
|
66
|
+
fs.removeSync(debugFilename);
|
|
67
|
+
return bufferImage;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const buildIcons = async ({
|
|
71
|
+
publicClientId,
|
|
72
|
+
metadata: { title, description, keywords, author, thumbnail, themeColor },
|
|
73
|
+
}) => {
|
|
74
|
+
const source = `src/client/public/${publicClientId}/assets/logo/base-icon.png`; // Source image(s). `string`, `buffer` or array of `string`
|
|
75
|
+
|
|
76
|
+
const configuration = {
|
|
77
|
+
path: '/', // Path for overriding default icons path. `string`
|
|
78
|
+
appName: title ? title : null, // Your application's name. `string`
|
|
79
|
+
appShortName: title ? title : null, // Your application's short_name. `string`. Optional. If not set, appName will be used
|
|
80
|
+
appDescription: description ? description : null, // Your application's description. `string`
|
|
81
|
+
developerName: author ? author : null, // Your (or your developer's) name. `string`
|
|
82
|
+
developerURL: author ? author : null, // Your (or your developer's) URL. `string`
|
|
83
|
+
cacheBustingQueryParam: null, // Query parameter added to all URLs that acts as a cache busting system. `string | null`
|
|
84
|
+
dir: 'auto', // Primary text direction for name, short_name, and description
|
|
85
|
+
lang: 'en-US', // Primary language for name and short_name
|
|
86
|
+
background: themeColor ? themeColor : '#fff', // Background colour for flattened icons. `string`
|
|
87
|
+
theme_color: themeColor ? themeColor : '#fff', // Theme color user for example in Android's task switcher. `string`
|
|
88
|
+
appleStatusBarStyle: 'black-translucent', // Style for Apple status bar: "black-translucent", "default", "black". `string`
|
|
89
|
+
display: 'standalone', // Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser". `string`
|
|
90
|
+
orientation: 'any', // Default orientation: "any", "natural", "portrait" or "landscape". `string`
|
|
91
|
+
scope: '/', // set of URLs that the browser considers within your app
|
|
92
|
+
start_url: '/?homescreen=1', // Start URL when launching the application from a device. `string`
|
|
93
|
+
preferRelatedApplications: false, // Should the browser prompt the user to install the native companion app. `boolean`
|
|
94
|
+
relatedApplications: undefined, // Information about the native companion apps. This will only be used if `preferRelatedApplications` is `true`. `Array<{ id: string, url: string, platform: string }>`
|
|
95
|
+
version: '1.0', // Your application's version string. `string`
|
|
96
|
+
pixel_art: false, // Keeps pixels "sharp" when scaling up, for pixel art. Only supported in offline mode.
|
|
97
|
+
loadManifestWithCredentials: true, // Browsers don't send cookies when fetching a manifest, enable this to fix that. `boolean`
|
|
98
|
+
manifestMaskable: true, // Maskable source image(s) for manifest.json. "true" to use default source. More information at https://web.dev/maskable-icon/. `boolean`, `string`, `buffer` or array of `string`
|
|
99
|
+
icons: {
|
|
100
|
+
// Platform Options:
|
|
101
|
+
// - offset - offset in percentage
|
|
102
|
+
// - background:
|
|
103
|
+
// * false - use default
|
|
104
|
+
// * true - force use default, e.g. set background for Android icons
|
|
105
|
+
// * color - set background for the specified icons
|
|
106
|
+
//
|
|
107
|
+
android: true, // Create Android homescreen icon. `boolean` or `{ offset, background }` or an array of sources
|
|
108
|
+
appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background }` or an array of sources
|
|
109
|
+
appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background }` or an array of sources
|
|
110
|
+
favicons: true, // Create regular favicons. `boolean` or `{ offset, background }` or an array of sources
|
|
111
|
+
windows: true, // Create Windows 8 tile icons. `boolean` or `{ offset, background }` or an array of sources
|
|
112
|
+
yandex: true, // Create Yandex browser icon. `boolean` or `{ offset, background }` or an array of sources
|
|
113
|
+
},
|
|
114
|
+
shortcuts: [
|
|
115
|
+
// Your applications's Shortcuts (see: https://developer.mozilla.org/docs/Web/Manifest/shortcuts)
|
|
116
|
+
// Array of shortcut objects:
|
|
117
|
+
// {
|
|
118
|
+
// name: 'View your Inbox', // The name of the shortcut. `string`
|
|
119
|
+
// short_name: 'inbox', // optionally, falls back to name. `string`
|
|
120
|
+
// description: 'View your inbox messages', // optionally, not used in any implemention yet. `string`
|
|
121
|
+
// url: '/inbox', // The URL this shortcut should lead to. `string`
|
|
122
|
+
// icon: 'test/inbox_shortcut.png', // source image(s) for that shortcut. `string`, `buffer` or array of `string`
|
|
123
|
+
// },
|
|
124
|
+
// more shortcuts objects
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const response = await favicons(source, configuration);
|
|
130
|
+
|
|
131
|
+
// console.log(response.images); // Array of { name: string, contents: <buffer> }
|
|
132
|
+
// console.log(response.files); // Array of { name: string, contents: <string> }
|
|
133
|
+
// console.log(response.html); // Array of strings (html elements)
|
|
134
|
+
|
|
135
|
+
for (const image of response.images)
|
|
136
|
+
fs.writeFileSync(`./src/client/public/${publicClientId}/${image.name}`, image.contents);
|
|
137
|
+
|
|
138
|
+
for (const file of response.files)
|
|
139
|
+
fs.writeFileSync(`./src/client/public/${publicClientId}/${file.name}`, file.contents, 'utf8');
|
|
140
|
+
|
|
141
|
+
const ssrPath = `./src/client/ssr/head-components/Pwa${getCapVariableName(publicClientId)}.js`;
|
|
142
|
+
if (!fs.existsSync(ssrPath))
|
|
143
|
+
fs.writeFileSync(ssrPath, 'SrrComponent = () => html`' + response.html.join(`\n`) + '`;', 'utf8');
|
|
144
|
+
} catch (error) {
|
|
145
|
+
logger.error(error.message); // Error description e.g. "An unknown error has occurred"
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { buildIcons, buildTextImg, defaultBaseTextImgOptions, faBase64Png, getBufferPngText };
|