underpost 2.7.83 → 2.7.92
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/.github/workflows/ghpkg.yml +41 -1
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +64 -16
- package/bin/cron.js +47 -0
- package/bin/db.js +60 -7
- package/bin/deploy.js +358 -26
- package/bin/file.js +18 -1
- package/bin/hwt.js +59 -0
- package/bin/index.js +1 -1
- package/bin/util.js +31 -1
- package/conf.js +46 -8
- package/docker-compose.yml +1 -1
- package/package.json +133 -133
- package/src/api/core/core.router.js +9 -9
- package/src/api/core/core.service.js +12 -4
- package/src/api/default/default.service.js +4 -4
- package/src/api/file/file.service.js +3 -3
- package/src/api/user/user.service.js +10 -8
- package/src/client/components/core/404.js +20 -0
- package/src/client/components/core/500.js +20 -0
- package/src/client/{ssr/common → components/core}/Alert.js +13 -11
- package/src/client/components/core/CommonJs.js +3 -0
- package/src/client/components/core/CssCore.js +30 -3
- package/src/client/components/core/Docs.js +110 -10
- package/src/client/components/core/LoadingAnimation.js +4 -2
- package/src/client/components/core/Modal.js +223 -22
- package/src/client/components/core/Panel.js +1 -1
- package/src/client/components/core/PanelForm.js +2 -1
- package/src/client/components/core/Responsive.js +34 -5
- package/src/client/components/core/RichText.js +4 -2
- package/src/client/components/core/Translate.js +21 -5
- package/src/client/components/core/VanillaJs.js +2 -1
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Worker.js +15 -18
- package/src/client/components/default/MenuDefault.js +68 -0
- package/src/client/components/default/RoutesDefault.js +2 -0
- package/src/client/public/default/plantuml/client-conf.svg +1 -1
- package/src/client/public/default/plantuml/client-schema.svg +1 -1
- package/src/client/public/default/plantuml/cron-conf.svg +1 -1
- package/src/client/public/default/plantuml/cron-schema.svg +1 -1
- package/src/client/public/default/plantuml/server-conf.svg +1 -1
- package/src/client/public/default/plantuml/server-schema.svg +1 -1
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
- package/src/client/public/default/site.webmanifest +69 -0
- package/src/client/ssr/Render.js +1 -6
- package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
- package/src/client/ssr/head/Production.js +1 -0
- package/src/client/ssr/head/Pwa.js +146 -0
- package/src/client/ssr/head/Seo.js +14 -0
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
- package/src/client/ssr/pages/Test.js +196 -0
- package/src/client/ssr/pages/maintenance.js +14 -0
- package/src/client/ssr/pages/offline.js +21 -0
- package/src/client/sw/default.sw.js +44 -165
- package/src/db/DataBaseProvider.js +12 -1
- package/src/db/mongo/MongooseDB.js +0 -1
- package/src/mailer/EmailRender.js +2 -4
- package/src/mailer/MailerProvider.js +4 -1
- package/src/runtime/lampp/Lampp.js +9 -9
- package/src/server/backup.js +82 -70
- package/src/server/client-build.js +133 -155
- package/src/server/client-formatted.js +2 -4
- package/src/server/conf.js +114 -23
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +48 -16
- package/src/server/network.js +94 -7
- package/src/server/proxy.js +26 -28
- package/src/server/runtime.js +42 -12
- package/src/server/ssl.js +2 -2
- package/src/client/ssr/common/SsrCore.js +0 -91
- package/src/client/ssr/common/Translate.js +0 -26
- package/src/client/ssr/common/Worker.js +0 -28
- package/src/client/ssr/components/head/PwaDefault.js +0 -60
- package/src/client/ssr/offline/default.index.js +0 -31
- package/src/cron.js +0 -30
- package/src/server/cron.js +0 -35
- /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
- /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
- /package/src/client/ssr/{components/head → head}/Css.js +0 -0
- /package/src/client/ssr/{components/head → head}/DefaultScripts.js +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const s = (el) => document.querySelector(el);
|
|
2
|
+
|
|
3
|
+
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
4
|
+
|
|
5
|
+
const getLang = () =>
|
|
6
|
+
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
|
|
7
|
+
|
|
8
|
+
const main = () => {
|
|
9
|
+
const Translate = {
|
|
10
|
+
Data: {
|
|
11
|
+
['no-internet-connection']: {
|
|
12
|
+
en: 'No internet connection <br> verify your network',
|
|
13
|
+
es: 'Sin conexión a internet <br> verifica tu red',
|
|
14
|
+
},
|
|
15
|
+
['back']: {
|
|
16
|
+
en: 'Back to <br> homepage',
|
|
17
|
+
es: 'Volver a <br> la pagina principal',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
Render: function (id) {
|
|
21
|
+
return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const icon = html`
|
|
25
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 20 20">
|
|
26
|
+
<path
|
|
27
|
+
fill="currentColor"
|
|
28
|
+
d="M10 18q.128 0 .254-.004a5.5 5.5 0 0 1-.698-1.083c-.536-.207-1.098-.793-1.578-1.821A9.3 9.3 0 0 1 7.42 13.5h1.672q.096-.52.284-1h-2.17A15 15 0 0 1 7 10c0-.883.073-1.725.206-2.5h5.588c.092.541.156 1.115.186 1.713q.48-.138.992-.188a16 16 0 0 0-.165-1.525h2.733c.251.656.406 1.36.448 2.094q.543.276 1.008.66A8 8 0 1 0 10 18m0-15c.657 0 1.407.59 2.022 1.908c.217.466.406 1.002.559 1.592H7.419c.153-.59.342-1.126.56-1.592C8.592 3.59 9.342 3 10 3M7.072 4.485A10.5 10.5 0 0 0 6.389 6.5H3.936a7.02 7.02 0 0 1 3.778-3.118c-.241.33-.456.704-.642 1.103M6.192 7.5A16 16 0 0 0 6 10c0 .87.067 1.712.193 2.5H3.46A7 7 0 0 1 3 10c0-.88.163-1.724.46-2.5zm.197 6c.176.743.407 1.422.683 2.015c.186.399.401.773.642 1.103A7.02 7.02 0 0 1 3.936 13.5zm5.897-10.118A7.02 7.02 0 0 1 16.064 6.5H13.61a10.5 10.5 0 0 0-.683-2.015a6.6 6.6 0 0 0-.642-1.103M19 14.5a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0M14.5 12a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 1 0v-2a.5.5 0 0 0-.5-.5m0 5.125a.625.625 0 1 0 0-1.25a.625.625 0 0 0 0 1.25"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
|
31
|
+
`;
|
|
32
|
+
append(
|
|
33
|
+
'body',
|
|
34
|
+
html` <style>
|
|
35
|
+
body {
|
|
36
|
+
font-family: arial;
|
|
37
|
+
font-size: 20px;
|
|
38
|
+
background-color: #d8d8d8;
|
|
39
|
+
color: #333;
|
|
40
|
+
}
|
|
41
|
+
a {
|
|
42
|
+
color: black;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
45
|
+
|
|
46
|
+
<div class="abs center" style="top: 45%">
|
|
47
|
+
${icon}
|
|
48
|
+
<br />
|
|
49
|
+
<br />
|
|
50
|
+
<br />${Translate.Render('no-internet-connection')} <br />
|
|
51
|
+
<br />
|
|
52
|
+
<a href="${location.origin}">${Translate.Render('back')}</a>
|
|
53
|
+
</div>`,
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
SrrComponent = () => html`<script>
|
|
58
|
+
{
|
|
59
|
+
const s = ${s};
|
|
60
|
+
const append = ${append};
|
|
61
|
+
const getLang = ${getLang};
|
|
62
|
+
const main = ${main};
|
|
63
|
+
window.onload = main;
|
|
64
|
+
}
|
|
65
|
+
</script>`;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const s = (el) => document.querySelector(el);
|
|
2
|
+
|
|
3
|
+
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
4
|
+
|
|
5
|
+
const getLang = () =>
|
|
6
|
+
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
|
|
7
|
+
|
|
8
|
+
const main = () => {
|
|
9
|
+
const Translate = {
|
|
10
|
+
Data: {
|
|
11
|
+
['back']: {
|
|
12
|
+
en: 'Back to <br> homepage',
|
|
13
|
+
es: 'Volver a <br> la pagina principal',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
Render: function (id) {
|
|
17
|
+
return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const icon = html`
|
|
21
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 32 32">
|
|
22
|
+
<g fill="none">
|
|
23
|
+
<g filter="url(#f2465id5)">
|
|
24
|
+
<path fill="#A5D9FF" d="m21.066 4.43l6.992 6.992l-16.926 16.926a4.944 4.944 0 1 1-6.992-6.992z" />
|
|
25
|
+
</g>
|
|
26
|
+
<g filter="url(#f2465id6)"><path fill="#C6EFFF" d="m23.37 7.524l1.653 1.653L17 17.199l-1.653-1.652z" /></g>
|
|
27
|
+
<g filter="url(#f2465id7)">
|
|
28
|
+
<path fill="#D1F884" d="m26.112 13.368l-14.98 14.98a4.944 4.944 0 1 1-6.992-6.992l7.988-7.988z" />
|
|
29
|
+
<path fill="url(#f2465id0)" d="m26.112 13.368l-14.98 14.98a4.944 4.944 0 1 1-6.992-6.992l7.988-7.988z" />
|
|
30
|
+
</g>
|
|
31
|
+
<path fill="url(#f2465id1)" d="M14.761 10.735L13.6 11.897l2.093 2.092a.822.822 0 0 0 1.162-1.162z" />
|
|
32
|
+
<path fill="url(#f2465id2)" d="m9.097 16.398l1.162-1.162l2.085 2.085a.822.822 0 1 1-1.162 1.162z" />
|
|
33
|
+
<path fill="url(#f2465id3)" d="m4.589 20.907l1.162-1.162l2.084 2.084a.822.822 0 0 1-1.163 1.162z" />
|
|
34
|
+
<g filter="url(#f2465id8)">
|
|
35
|
+
<path
|
|
36
|
+
fill="#A9D8FF"
|
|
37
|
+
d="M19.55 2.617a1.47 1.47 0 0 0 0 2.079l8.242 8.242a1.47 1.47 0 0 0 2.078-2.079l-8.242-8.242a1.47 1.47 0 0 0-2.078 0"
|
|
38
|
+
/>
|
|
39
|
+
<path
|
|
40
|
+
fill="url(#f2465id4)"
|
|
41
|
+
d="M19.55 2.617a1.47 1.47 0 0 0 0 2.079l8.242 8.242a1.47 1.47 0 0 0 2.078-2.079l-8.242-8.242a1.47 1.47 0 0 0-2.078 0"
|
|
42
|
+
/>
|
|
43
|
+
</g>
|
|
44
|
+
<g filter="url(#f2465id9)"><path fill="#C4ECFF" d="m19.916 4.001l1.11-1.11l8.376 8.374l-1.111 1.111z" /></g>
|
|
45
|
+
<defs>
|
|
46
|
+
<linearGradient id="f2465id0" x1="25.761" x2="17.074" y1="13.875" y2="16.875" gradientUnits="userSpaceOnUse">
|
|
47
|
+
<stop offset=".203" stop-color="#E9EB7E" />
|
|
48
|
+
<stop offset="1" stop-color="#E9EB7E" stop-opacity="0" />
|
|
49
|
+
</linearGradient>
|
|
50
|
+
<linearGradient id="f2465id1" x1="16.761" x2="14.011" y1="14.063" y2="11.469" gradientUnits="userSpaceOnUse">
|
|
51
|
+
<stop stop-color="#138979" />
|
|
52
|
+
<stop offset="1" stop-color="#2E7B65" />
|
|
53
|
+
</linearGradient>
|
|
54
|
+
<linearGradient id="f2465id2" x1="12.252" x2="9.508" y1="18.557" y2="15.969" gradientUnits="userSpaceOnUse">
|
|
55
|
+
<stop stop-color="#138979" />
|
|
56
|
+
<stop offset="1" stop-color="#2E7B65" />
|
|
57
|
+
</linearGradient>
|
|
58
|
+
<linearGradient id="f2465id3" x1="7.743" x2="5" y1="23.065" y2="20.477" gradientUnits="userSpaceOnUse">
|
|
59
|
+
<stop stop-color="#138979" />
|
|
60
|
+
<stop offset="1" stop-color="#2E7B65" />
|
|
61
|
+
</linearGradient>
|
|
62
|
+
<linearGradient id="f2465id4" x1="28.786" x2="28.656" y1="13.521" y2="11.86" gradientUnits="userSpaceOnUse">
|
|
63
|
+
<stop stop-color="#A8C3FF" />
|
|
64
|
+
<stop offset="1" stop-color="#A8C3FF" stop-opacity="0" />
|
|
65
|
+
</linearGradient>
|
|
66
|
+
<filter
|
|
67
|
+
id="f2465id5"
|
|
68
|
+
width="25.366"
|
|
69
|
+
height="25.366"
|
|
70
|
+
x="2.692"
|
|
71
|
+
y="4.43"
|
|
72
|
+
color-interpolation-filters="sRGB"
|
|
73
|
+
filterUnits="userSpaceOnUse"
|
|
74
|
+
>
|
|
75
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
76
|
+
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
|
77
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
78
|
+
<feOffset />
|
|
79
|
+
<feGaussianBlur stdDeviation="1" />
|
|
80
|
+
<feComposite in2="hardAlpha" k2="-1" k3="1" operator="arithmetic" />
|
|
81
|
+
<feColorMatrix values="0 0 0 0 0.745098 0 0 0 0 0.85098 0 0 0 0 0.964706 0 0 0 1 0" />
|
|
82
|
+
<feBlend in2="shape" result="effect1_innerShadow_18_24902" />
|
|
83
|
+
</filter>
|
|
84
|
+
<filter
|
|
85
|
+
id="f2465id6"
|
|
86
|
+
width="13.675"
|
|
87
|
+
height="13.675"
|
|
88
|
+
x="13.347"
|
|
89
|
+
y="5.524"
|
|
90
|
+
color-interpolation-filters="sRGB"
|
|
91
|
+
filterUnits="userSpaceOnUse"
|
|
92
|
+
>
|
|
93
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
94
|
+
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
|
95
|
+
<feGaussianBlur result="effect1_foregroundBlur_18_24902" stdDeviation="1" />
|
|
96
|
+
</filter>
|
|
97
|
+
<filter
|
|
98
|
+
id="f2465id7"
|
|
99
|
+
width="26.42"
|
|
100
|
+
height="17.178"
|
|
101
|
+
x="2.692"
|
|
102
|
+
y="12.618"
|
|
103
|
+
color-interpolation-filters="sRGB"
|
|
104
|
+
filterUnits="userSpaceOnUse"
|
|
105
|
+
>
|
|
106
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
107
|
+
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
|
108
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
109
|
+
<feOffset dx="4" dy="-.75" />
|
|
110
|
+
<feGaussianBlur stdDeviation="1.5" />
|
|
111
|
+
<feComposite in2="hardAlpha" k2="-1" k3="1" operator="arithmetic" />
|
|
112
|
+
<feColorMatrix values="0 0 0 0 0.505882 0 0 0 0 0.811765 0 0 0 0 0.34902 0 0 0 1 0" />
|
|
113
|
+
<feBlend in2="shape" result="effect1_innerShadow_18_24902" />
|
|
114
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
115
|
+
<feOffset dy="-.4" />
|
|
116
|
+
<feGaussianBlur stdDeviation=".5" />
|
|
117
|
+
<feComposite in2="hardAlpha" k2="-1" k3="1" operator="arithmetic" />
|
|
118
|
+
<feColorMatrix values="0 0 0 0 0.788235 0 0 0 0 0.843137 0 0 0 0 0.898039 0 0 0 1 0" />
|
|
119
|
+
<feBlend in2="effect1_innerShadow_18_24902" result="effect2_innerShadow_18_24902" />
|
|
120
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
121
|
+
<feOffset dx=".4" dy="-.4" />
|
|
122
|
+
<feGaussianBlur stdDeviation=".5" />
|
|
123
|
+
<feComposite in2="hardAlpha" k2="-1" k3="1" operator="arithmetic" />
|
|
124
|
+
<feColorMatrix values="0 0 0 0 0.67451 0 0 0 0 0.839216 0 0 0 0 0.623529 0 0 0 1 0" />
|
|
125
|
+
<feBlend in2="effect2_innerShadow_18_24902" result="effect3_innerShadow_18_24902" />
|
|
126
|
+
</filter>
|
|
127
|
+
<filter
|
|
128
|
+
id="f2465id8"
|
|
129
|
+
width="11.181"
|
|
130
|
+
height="11.181"
|
|
131
|
+
x="19.12"
|
|
132
|
+
y="2.187"
|
|
133
|
+
color-interpolation-filters="sRGB"
|
|
134
|
+
filterUnits="userSpaceOnUse"
|
|
135
|
+
>
|
|
136
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
137
|
+
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
|
138
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
|
139
|
+
<feOffset />
|
|
140
|
+
<feGaussianBlur stdDeviation=".5" />
|
|
141
|
+
<feComposite in2="hardAlpha" k2="-1" k3="1" operator="arithmetic" />
|
|
142
|
+
<feColorMatrix values="0 0 0 0 0.658824 0 0 0 0 0.776471 0 0 0 0 0.937255 0 0 0 1 0" />
|
|
143
|
+
<feBlend in2="shape" result="effect1_innerShadow_18_24902" />
|
|
144
|
+
</filter>
|
|
145
|
+
<filter
|
|
146
|
+
id="f2465id9"
|
|
147
|
+
width="10.986"
|
|
148
|
+
height="10.986"
|
|
149
|
+
x="19.166"
|
|
150
|
+
y="2.14"
|
|
151
|
+
color-interpolation-filters="sRGB"
|
|
152
|
+
filterUnits="userSpaceOnUse"
|
|
153
|
+
>
|
|
154
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
155
|
+
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
|
156
|
+
<feGaussianBlur result="effect1_foregroundBlur_18_24902" stdDeviation=".375" />
|
|
157
|
+
</filter>
|
|
158
|
+
</defs>
|
|
159
|
+
</g>
|
|
160
|
+
</svg>
|
|
161
|
+
`;
|
|
162
|
+
append(
|
|
163
|
+
'body',
|
|
164
|
+
html` <style>
|
|
165
|
+
body {
|
|
166
|
+
font-family: arial;
|
|
167
|
+
font-size: 20px;
|
|
168
|
+
background-color: #d8d8d8;
|
|
169
|
+
color: #333;
|
|
170
|
+
}
|
|
171
|
+
a {
|
|
172
|
+
color: black;
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
175
|
+
|
|
176
|
+
<div class="abs center" style="top: 45%">
|
|
177
|
+
${icon}
|
|
178
|
+
<br />
|
|
179
|
+
<br />
|
|
180
|
+
<span class="bold">Test Page</span>
|
|
181
|
+
<br />
|
|
182
|
+
<br />
|
|
183
|
+
<a href="${location.origin}">${Translate.Render('back')}</a>
|
|
184
|
+
</div>`,
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
SrrComponent = () => html`<script>
|
|
189
|
+
{
|
|
190
|
+
const s = ${s};
|
|
191
|
+
const append = ${append};
|
|
192
|
+
const getLang = ${getLang};
|
|
193
|
+
const main = ${main};
|
|
194
|
+
window.onload = main;
|
|
195
|
+
}
|
|
196
|
+
</script>`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { htmls, loggerFactory } from '../common/SsrCore.js';
|
|
2
|
+
import { Alert } from '../common/Alert.js';
|
|
3
|
+
import { Translate } from '../common/Translate.js';
|
|
4
|
+
import { Worker } from '../common/Worker.js';
|
|
5
|
+
/*imports*/
|
|
6
|
+
|
|
7
|
+
const logger = loggerFactory({ url: location.toString() });
|
|
8
|
+
|
|
9
|
+
window.onload = () =>
|
|
10
|
+
Worker.instance({
|
|
11
|
+
render: async () => {
|
|
12
|
+
htmls(`.page-render`, html`${await Alert.maintenance({ Translate })}`);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { htmls, loggerFactory } from '../common/SsrCore.js';
|
|
2
|
+
import { Alert } from '../common/Alert.js';
|
|
3
|
+
import { Translate } from '../common/Translate.js';
|
|
4
|
+
import { Worker } from '../common/Worker.js';
|
|
5
|
+
/*imports*/
|
|
6
|
+
|
|
7
|
+
const logger = loggerFactory({ url: location.toString() });
|
|
8
|
+
|
|
9
|
+
window.onload = () =>
|
|
10
|
+
Worker.instance({
|
|
11
|
+
render: async () => {
|
|
12
|
+
window.ononline = async () => {
|
|
13
|
+
location.href = location.pathname.split('/')[1] ? `/${location.pathname.split('/')[1].split('.')[0]}` : '/';
|
|
14
|
+
};
|
|
15
|
+
window.onoffline = async () => {
|
|
16
|
+
htmls(`.page-render`, html`${await Alert.noInternet({ Translate })}`);
|
|
17
|
+
};
|
|
18
|
+
if (navigator.onLine && !location.hostname.match('localhost')) window.ononline();
|
|
19
|
+
else window.onoffline();
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -1,56 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
Copyright 2015, 2019 Google Inc. All Rights Reserved.
|
|
7
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
19
|
-
// https://web.dev/cache-api-quick-guide/
|
|
20
|
-
// https://developer.mozilla.org/en-US/docs/Web/API
|
|
21
|
-
// https://developer.mozilla.org/es/docs/Web/Progressive_web_apps/Re-engageable_Notifications_Push
|
|
22
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification
|
|
23
|
-
// https://github.com/GoogleChrome/samples/blob/9e4b3b77b091268d28e5438bb2fe8829091e9540/service-worker/basic/service-worker.js#L59
|
|
24
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
|
|
28
|
-
4 different ways to store data on client-side without using cookies:
|
|
29
|
-
|
|
30
|
-
- Local Storage (Session and Local key/value pairs)
|
|
31
|
-
- Web SQL (my favorite, it's a whole SQL Database, and it's NOT obsolete)
|
|
32
|
-
- IndexedDB (another Database with different structure and acceptance)
|
|
33
|
-
- Service Workers (Persistent background processing,
|
|
34
|
-
even while offline, can asynchronously save files and many other things)
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
const logger = loggerFactory(import.meta);
|
|
39
|
-
|
|
1
|
+
const PRE_CACHED_RESOURCES = [];
|
|
2
|
+
const CACHE_NAME = 'app-cache';
|
|
3
|
+
const PROXY_PATH = '/';
|
|
40
4
|
self.addEventListener('install', (event) => {
|
|
41
5
|
// Activate right away
|
|
42
6
|
self.skipWaiting();
|
|
43
7
|
|
|
44
8
|
event.waitUntil(
|
|
45
9
|
(async () => {
|
|
46
|
-
// const cache = await caches.open(CACHE_NAME);
|
|
47
|
-
// Setting {cache: 'reload'} in the new request will ensure that the response
|
|
48
|
-
// isn't fulfilled from the HTTP cache; i.e., it will be from the network.
|
|
49
|
-
// await cache.add(new Request(OFFLINE_URL, { cache: 'reload' }));
|
|
50
10
|
// Open the app's cache.
|
|
51
|
-
|
|
11
|
+
const cache = await caches.open(CACHE_NAME);
|
|
52
12
|
// Cache all static resources.
|
|
53
|
-
|
|
13
|
+
try {
|
|
14
|
+
await cache.addAll(PRE_CACHED_RESOURCES);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error(error);
|
|
17
|
+
}
|
|
18
|
+
// for (const cacheKey of PRE_CACHED_RESOURCES) {
|
|
19
|
+
// try {
|
|
20
|
+
// await cache.add(cacheKey);
|
|
21
|
+
// } catch (error) {
|
|
22
|
+
// console.error(error, cacheKey);
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
54
25
|
})(),
|
|
55
26
|
);
|
|
56
27
|
});
|
|
@@ -65,139 +36,47 @@ self.addEventListener('activate', (event) => {
|
|
|
65
36
|
}
|
|
66
37
|
})(),
|
|
67
38
|
);
|
|
68
|
-
|
|
69
39
|
// Tell the active service worker to take control of the page immediately.
|
|
70
40
|
self.clients.claim();
|
|
71
|
-
|
|
72
|
-
// event message
|
|
73
|
-
self.addEventListener('message', (event) => {
|
|
74
|
-
logger.info('Received event message', event.data);
|
|
75
|
-
|
|
76
|
-
switch (event.data.status) {
|
|
77
|
-
case 'skipWaiting':
|
|
78
|
-
return self.skipWaiting();
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
default:
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
clients.matchAll().then((clientList) => {
|
|
86
|
-
for (const client of clientList) {
|
|
87
|
-
logger.info('client', client);
|
|
88
|
-
client.postMessage({
|
|
89
|
-
title: 'Hello from SW event message',
|
|
90
|
-
});
|
|
91
|
-
// client -> document.visibilityState
|
|
92
|
-
// client.visibilityState
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
// broadcast message
|
|
97
|
-
const channel = new BroadcastChannel('sw-messages');
|
|
98
|
-
channel.addEventListener('message', (event) => {
|
|
99
|
-
logger.info('Received broadcast message', event.data);
|
|
100
|
-
channel.postMessage({ title: 'Hello from SW broadcast message' });
|
|
101
|
-
});
|
|
102
41
|
});
|
|
103
42
|
|
|
104
43
|
self.addEventListener('fetch', (event) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
(async () => {
|
|
120
|
-
// Get the client.
|
|
121
|
-
const client = await clients.get(event.clientId);
|
|
122
|
-
if (client)
|
|
123
|
-
client.postMessage({
|
|
124
|
-
status: 'loader',
|
|
125
|
-
path,
|
|
126
|
-
});
|
|
127
|
-
else logger.warn('client not found');
|
|
128
|
-
})();
|
|
44
|
+
// Cache-First Strategy
|
|
45
|
+
event.respondWith(
|
|
46
|
+
(async () => {
|
|
47
|
+
// First, try to use the navigation preload response if it's supported.
|
|
48
|
+
try {
|
|
49
|
+
const preloadResponse = await event.preloadResponse;
|
|
50
|
+
if (preloadResponse) return preloadResponse;
|
|
51
|
+
return await fetch(event.request);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('Fetch failed; returning offline page instead.', event.request.url, error);
|
|
54
|
+
// Fallback to the offline page.
|
|
55
|
+
const path = PRE_CACHED_RESOURCES.find((path) => event.request.url.match(path.replaceAll('/index.html', '')));
|
|
129
56
|
|
|
130
|
-
// We only want to call event.respondWith() if this is a navigation request
|
|
131
|
-
// for an HTML page.
|
|
132
|
-
if (path !== undefined || event.request.mode === 'navigate') {
|
|
133
|
-
event.respondWith(
|
|
134
|
-
(async () => {
|
|
135
57
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (preload) {
|
|
143
|
-
const preloadCache = await caches.has(path);
|
|
144
|
-
const cache = await caches.open(path);
|
|
145
|
-
const cacheResponse = await cache.match(path);
|
|
146
|
-
if (!preloadCache || !cacheResponse || cacheResponse.status !== 200) {
|
|
147
|
-
logger.warn('install', path);
|
|
148
|
-
// await cache.add(new Request(event.request.url, { cache: 'reload' }));
|
|
149
|
-
|
|
150
|
-
// Other option:
|
|
151
|
-
// The resource wasn't found in the cache, so fetch it from the network.
|
|
152
|
-
const fetchResponse = await fetch(event.request.url);
|
|
153
|
-
|
|
154
|
-
if (fetchResponse.status === 200) {
|
|
155
|
-
// Put the response in cache.
|
|
156
|
-
await cache.put(event.request.url, fetchResponse.clone());
|
|
157
|
-
// And return the response.
|
|
158
|
-
return fetchResponse;
|
|
159
|
-
} else {
|
|
160
|
-
await caches.delete(path);
|
|
161
|
-
throw new Error(await fetchResponse.text());
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// logger.info('cache response', path);
|
|
165
|
-
return cacheResponse;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const networkResponse = await fetch(event.request);
|
|
169
|
-
logger.warn('fetch response', event.request.url);
|
|
170
|
-
return networkResponse;
|
|
58
|
+
const cachedResponse = await caches.match(event.request);
|
|
59
|
+
if (cachedResponse) return cachedResponse;
|
|
60
|
+
const cache = await caches.open(CACHE_NAME);
|
|
61
|
+
const preCachedResponse = await cache.match(path);
|
|
62
|
+
if (!preCachedResponse) throw new Error(error.message);
|
|
63
|
+
return preCachedResponse;
|
|
171
64
|
} catch (error) {
|
|
172
|
-
|
|
173
|
-
// due to a network error.
|
|
174
|
-
// If fetch() returns a valid HTTP response with a response code in
|
|
175
|
-
// the 4xx or 5xx range, the catch() will NOT be called.
|
|
176
|
-
if (path) {
|
|
177
|
-
const preloadCache = await caches.has(path);
|
|
178
|
-
if (preloadCache) await caches.delete(path);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
logger.error('Fetch failed; returning offline page instead.', { error, path });
|
|
65
|
+
console.error('Error opening cache for pre cached page', event.request.url, error);
|
|
182
66
|
try {
|
|
183
|
-
const cache = await caches.open(
|
|
184
|
-
const
|
|
185
|
-
|
|
67
|
+
const cache = await caches.open(CACHE_NAME);
|
|
68
|
+
const preCachedResponse = await cache.match(`${PROXY_PATH === '/' ? '' : PROXY_PATH}/offline/index.html`);
|
|
69
|
+
if (!preCachedResponse) throw new Error(error.message);
|
|
70
|
+
return preCachedResponse;
|
|
186
71
|
} catch (error) {
|
|
187
|
-
|
|
188
|
-
const response = new Response(JSON.stringify({ status: 'error', message:
|
|
72
|
+
console.error('Error opening cache for offline page', event.request.url, error);
|
|
73
|
+
const response = new Response(JSON.stringify({ status: 'error', message: error.message }));
|
|
189
74
|
// response.status = 200;
|
|
190
75
|
response.headers.set('Content-Type', 'application/json');
|
|
191
76
|
return response;
|
|
192
77
|
}
|
|
193
78
|
}
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// If our if() condition is false, then this fetch handler won't intercept the
|
|
199
|
-
// request. If there are any other fetch handlers registered, they will get a
|
|
200
|
-
// chance to call event.respondWith(). If no fetch handlers call
|
|
201
|
-
// event.respondWith(), the request will be handled by the browser as if there
|
|
202
|
-
// were no service worker involvement.
|
|
79
|
+
}
|
|
80
|
+
})(),
|
|
81
|
+
);
|
|
203
82
|
});
|
|
@@ -18,7 +18,18 @@ const DataBaseProvider = {
|
|
|
18
18
|
case 'mongoose':
|
|
19
19
|
{
|
|
20
20
|
const conn = await MongooseDB.connect(db.host, db.name);
|
|
21
|
-
this.instance[`${host}${path}`][db.provider] =
|
|
21
|
+
this.instance[`${host}${path}`][db.provider] = {
|
|
22
|
+
models: await MongooseDB.loadModels({ conn, apis }),
|
|
23
|
+
connection: conn,
|
|
24
|
+
close: async () => {
|
|
25
|
+
return await new Promise((resolve) => {
|
|
26
|
+
DataBaseProvider.instance[`${host}${path}`][db.provider].connection.close().then(() => {
|
|
27
|
+
// logger.info('Mongoose connection is disconnected', db);
|
|
28
|
+
return resolve();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
22
33
|
}
|
|
23
34
|
break;
|
|
24
35
|
default:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import fs from 'fs-extra';
|
|
1
|
+
import { ssrFactory } from '../server/client-formatted.js';
|
|
3
2
|
|
|
4
3
|
const EmailRender = {
|
|
5
4
|
style: {
|
|
@@ -58,8 +57,7 @@ const EmailRender = {
|
|
|
58
57
|
const templates = {};
|
|
59
58
|
for (const templateKey of Object.keys(options.templates)) {
|
|
60
59
|
const ssrEmailComponent = options.templates[templateKey];
|
|
61
|
-
|
|
62
|
-
eval(await srcFormatted(fs.readFileSync(`./src/client/ssr/components/email/${ssrEmailComponent}.js`, 'utf8')));
|
|
60
|
+
const SrrComponent = await ssrFactory(`./src/client/ssr/mailer/${ssrEmailComponent}.js`);
|
|
63
61
|
templates[templateKey] = SrrComponent(this, options);
|
|
64
62
|
}
|
|
65
63
|
return templates;
|
|
@@ -90,17 +90,17 @@ const Lampp = {
|
|
|
90
90
|
`mkdir /www && \\` +
|
|
91
91
|
`ln -s /www /opt/lampp/htdocs`,
|
|
92
92
|
);
|
|
93
|
-
|
|
94
|
-
if (fs.existsSync(`/opt/lampp/logs/access_log`))
|
|
95
|
-
fs.copySync(`/opt/lampp/logs/access_log`, `/opt/lampp/logs/access.log`);
|
|
96
|
-
if (fs.existsSync(`/opt/lampp/logs/error_log`))
|
|
97
|
-
fs.copySync(`/opt/lampp/logs/error_log`, `/opt/lampp/logs/error.log`);
|
|
98
|
-
if (fs.existsSync(`/opt/lampp/logs/php_error_log`))
|
|
99
|
-
fs.copySync(`/opt/lampp/logs/php_error_log`, `/opt/lampp/logs/php_error.log`);
|
|
100
|
-
if (fs.existsSync(`/opt/lampp/logs/ssl_request_log`))
|
|
101
|
-
fs.copySync(`/opt/lampp/logs/ssl_request_log`, `/opt/lampp/logs/ssl_request.log`);
|
|
102
93
|
}
|
|
103
94
|
|
|
95
|
+
if (fs.existsSync(`/opt/lampp/logs/access_log`))
|
|
96
|
+
fs.copySync(`/opt/lampp/logs/access_log`, `/opt/lampp/logs/access.log`);
|
|
97
|
+
if (fs.existsSync(`/opt/lampp/logs/error_log`))
|
|
98
|
+
fs.copySync(`/opt/lampp/logs/error_log`, `/opt/lampp/logs/error.log`);
|
|
99
|
+
if (fs.existsSync(`/opt/lampp/logs/php_error_log`))
|
|
100
|
+
fs.copySync(`/opt/lampp/logs/php_error_log`, `/opt/lampp/logs/php_error.log`);
|
|
101
|
+
if (fs.existsSync(`/opt/lampp/logs/ssl_request_log`))
|
|
102
|
+
fs.copySync(`/opt/lampp/logs/ssl_request_log`, `/opt/lampp/logs/ssl_request.log`);
|
|
103
|
+
|
|
104
104
|
await Lampp.initService({ daemon: true });
|
|
105
105
|
}
|
|
106
106
|
|