first commit -push

This commit is contained in:
dungtt
2025-10-15 15:15:53 +07:00
parent 674ae395be
commit a9577c5756
885 changed files with 74595 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"System.Net.Http.HttpClient": "Warning",
"Microsoft.AspNetCore": "Warning"
}
},
"Local": {
"Authority": "https://localhost:7061",
"ClientId": "robotnet-webapp",
"ResponseType": "code",
"DefaultScopes": [
"openid",
"profile",
"email",
"roles",
"robotnet-script-api",
"robotnet-robot-api",
"robotnet-map-api"
],
"RedirectUri": "https://localhost:7035/authentication/login-callback",
"PostLogoutRedirectUri": "https://localhost:7035/authentication/logout-callback"
},
"ScriptManager": {
"BaseAddress": "https://localhost:7102"
},
"RobotManager": {
"BaseAddress": "https://localhost:7179"
},
"MapManager": {
"BaseAddress": "https://localhost:7177"
},
"Logs": [
{
"Name": "RobotManager",
"Url": "https://localhost:7179/api/RobotManagerLogger"
},
{
"Name": "MapManager",
"Url": "https://localhost:7177/api/MapDesignerLogger"
},
{
"Name": "ScriptManager",
"Url": "https://localhost:7102/api/ScriptManagerLogger"
}
]
}

View File

@@ -0,0 +1,147 @@
html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
width: 100vw;
height: 100vh;
}
#app {
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: row;
}
.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}
.invalid {
outline: 1px solid red;
}
.validation-message {
color: red;
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
.blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after {
content: "An error has occurred."
}
.loading-progress {
position: relative;
display: block;
width: 8rem;
height: 8rem;
margin: 20vh auto 1rem auto;
}
.loading-progress circle {
fill: none;
stroke: #e0e0e0;
stroke-width: 0.6rem;
transform-origin: 50% 50%;
transform: rotate(-90deg);
}
.loading-progress circle:last-child {
stroke: #1b6ec2;
stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
position: absolute;
text-align: center;
font-weight: bold;
inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
}
code {
color: #c02d76;
}
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
color: var(--bs-secondary-color);
text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
text-align: start;
}
.mdi-btn-medium {
width: 28px;
height: 28px;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.mdi-btn-medium > span.mdi {
font-size: 30px;
}
main {
flex-grow: 1;
height: 100%;
position: relative;
overflow: hidden;
}
main > div {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
}
:root {
--dashboard-card-background-color: linear-gradient(0deg, #404040, #303030);
--dashboard-text-common-color: #29a3ff;
--dashboard-text-green-color: #00cc00;
--dashboard-text-red-color: #ff0000;
--dashboard-text-orange-color: #ff6600;
--dashboard-text-bluesky-color: #29a3ff;
--dashboard-text-font-family: 'Roboto', sans-serif;
--dashboard-text-white-color: #d6d6db;
--edge-stroke-width: 0.15px;
--edge-direction-stroke-width: 0.3px;
--node-r: 0.1px;
--origin-vector-stroke-width: 0.35px;
}

View File

@@ -0,0 +1,81 @@
/* cyrillic-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmZiArmlw.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmQiArmlw.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmYiArmlw.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmXiArmlw.woff2) format('woff2');
unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
/* math */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVnoiArmlw.woff2) format('woff2');
unicode-range: U+0302-0303, U+0305, U+0307-0308, U+0310, U+0312, U+0315, U+031A, U+0326-0327, U+032C, U+032F-0330, U+0332-0333, U+0338, U+033A, U+0346, U+034D, U+0391-03A1, U+03A3-03A9, U+03B1-03C9, U+03D1, U+03D5-03D6, U+03F0-03F1, U+03F4-03F5, U+2016-2017, U+2034-2038, U+203C, U+2040, U+2043, U+2047, U+2050, U+2057, U+205F, U+2070-2071, U+2074-208E, U+2090-209C, U+20D0-20DC, U+20E1, U+20E5-20EF, U+2100-2112, U+2114-2115, U+2117-2121, U+2123-214F, U+2190, U+2192, U+2194-21AE, U+21B0-21E5, U+21F1-21F2, U+21F4-2211, U+2213-2214, U+2216-22FF, U+2308-230B, U+2310, U+2319, U+231C-2321, U+2336-237A, U+237C, U+2395, U+239B-23B7, U+23D0, U+23DC-23E1, U+2474-2475, U+25AF, U+25B3, U+25B7, U+25BD, U+25C1, U+25CA, U+25CC, U+25FB, U+266D-266F, U+27C0-27FF, U+2900-2AFF, U+2B0E-2B11, U+2B30-2B4C, U+2BFE, U+3030, U+FF5B, U+FF5D, U+1D400-1D7FF, U+1EE00-1EEFF;
}
/* symbols */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVn6iArmlw.woff2) format('woff2');
unicode-range: U+0001-000C, U+000E-001F, U+007F-009F, U+20DD-20E0, U+20E2-20E4, U+2150-218F, U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3, U+2218-2219, U+2299, U+22C4-22C6, U+2300-243F, U+2440-244A, U+2460-24FF, U+25A0-27BF, U+2800-28FF, U+2921-2922, U+2981, U+29BF, U+29EB, U+2B00-2BFF, U+4DC0-4DFF, U+FFF9-FFFB, U+10140-1018E, U+10190-1019C, U+101A0, U+101D0-101FD, U+102E0-102FB, U+10E60-10E7E, U+1D2C0-1D2D3, U+1D2E0-1D37F, U+1F000-1F0FF, U+1F100-1F1AD, U+1F1E6-1F1FF, U+1F30D-1F30F, U+1F315, U+1F31C, U+1F31E, U+1F320-1F32C, U+1F336, U+1F378, U+1F37D, U+1F382, U+1F393-1F39F, U+1F3A7-1F3A8, U+1F3AC-1F3AF, U+1F3C2, U+1F3C4-1F3C6, U+1F3CA-1F3CE, U+1F3D4-1F3E0, U+1F3ED, U+1F3F1-1F3F3, U+1F3F5-1F3F7, U+1F408, U+1F415, U+1F41F, U+1F426, U+1F43F, U+1F441-1F442, U+1F444, U+1F446-1F449, U+1F44C-1F44E, U+1F453, U+1F46A, U+1F47D, U+1F4A3, U+1F4B0, U+1F4B3, U+1F4B9, U+1F4BB, U+1F4BF, U+1F4C8-1F4CB, U+1F4D6, U+1F4DA, U+1F4DF, U+1F4E3-1F4E6, U+1F4EA-1F4ED, U+1F4F7, U+1F4F9-1F4FB, U+1F4FD-1F4FE, U+1F503, U+1F507-1F50B, U+1F50D, U+1F512-1F513, U+1F53E-1F54A, U+1F54F-1F5FA, U+1F610, U+1F650-1F67F, U+1F687, U+1F68D, U+1F691, U+1F694, U+1F698, U+1F6AD, U+1F6B2, U+1F6B9-1F6BA, U+1F6BC, U+1F6C6-1F6CF, U+1F6D3-1F6D7, U+1F6E0-1F6EA, U+1F6F0-1F6F3, U+1F6F7-1F6FC, U+1F700-1F7FF, U+1F800-1F80B, U+1F810-1F847, U+1F850-1F859, U+1F860-1F887, U+1F890-1F8AD, U+1F8B0-1F8BB, U+1F8C0-1F8C1, U+1F900-1F90B, U+1F93B, U+1F946, U+1F984, U+1F996, U+1F9E9, U+1FA00-1FA6F, U+1FA70-1FA7C, U+1FA80-1FA89, U+1FA8F-1FAC6, U+1FACE-1FADC, U+1FADF-1FAE9, U+1FAF0-1FAF8, U+1FB00-1FBFF;
}
/* vietnamese */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmbiArmlw.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmaiArmlw.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmUiAo.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

View File

@@ -0,0 +1,5 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path d="M31.81,1.79,21.29,14.32l-2.48-3a2.6,2.6,0,0,1,0-3.34l4.45-5.31a2.64,2.64,0,0,1,2-.93Z" fill="#e06e2e"/>
<path d="M.19,1.8,10.71,14.34l2.48-2.95a2.6,2.6,0,0,0,0-3.34L8.75,2.74a2.66,2.66,0,0,0-2-.94Z" fill="#e06e2e"/>
<path d="M32,30.21H25.36a2.61,2.61,0,0,1-2-.92L16.5,21.1a.65.65,0,0,0-1,0L8.63,29.29a2.58,2.58,0,0,1-2,.92H0L12.07,15.83,14,13.57a2.67,2.67,0,0,1,4.08,0l1.89,2.26Z" fill="#233871"/>
</svg>

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

View File

@@ -0,0 +1,10 @@
<svg
id="Layer_1"
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 32 32"
>
<path d="M31.81,1.79,21.29,14.32l-2.48-3a2.6,2.6,0,0,1,0-3.34l4.45-5.31a2.64,2.64,0,0,1,2-.93Z" fill="#e06e2e"/>
<path d="M.19,1.8,10.71,14.34l2.48-2.95a2.6,2.6,0,0,0,0-3.34L8.75,2.74a2.66,2.66,0,0,0-2-.94Z" fill="#e06e2e"/>
<path d="M32,30.21H25.36a2.61,2.61,0,0,1-2-.92L16.5,21.1a.65.65,0,0,0-1,0L8.63,29.29a2.58,2.58,0,0,1-2,.92H0L12.07,15.83,14,13.57a2.67,2.67,0,0,1,4.08,0l1.89,2.26Z" fill="#233871"/>
</svg>

After

Width:  |  Height:  |  Size: 522 B

View File

@@ -0,0 +1,48 @@
<svg
id="Layer_1"
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 370.84 59.64"
>
<path
d="M66.68,0,44.62,26.28,39.43,20.1a5.45,5.45,0,0,1,0-7L48.75,2A5.53,5.53,0,0,1,53,0Z"
fill="#e06e2e"
/>
<path
d="M.4,0,22.46,26.31l5.19-6.18a5.45,5.45,0,0,0,0-7L18.33,2a5.53,5.53,0,0,0-4.22-2Z"
fill="#e06e2e"
/>
<path
d="M67.08,59.59H53.15A5.44,5.44,0,0,1,49,57.65L34.58,40.49a1.36,1.36,0,0,0-2.09,0L18.09,57.65a5.46,5.46,0,0,1-4.17,1.94H0L25.31,29.43l4-4.72a5.57,5.57,0,0,1,8.54,0l4,4.72Z"
fill="#ffffff"
/>
<path
d="M98.34,24.3A12.87,12.87,0,0,1,104,42.84a12.29,12.29,0,0,1-5.61,4.56A21.47,21.47,0,0,1,89.74,49H81.17v7.93a2.72,2.72,0,0,1-2.72,2.73H74.13V22.72H89.74a21.64,21.64,0,0,1,8.6,1.58m-1.93,17a6.52,6.52,0,0,0,2.39-5.43,6.54,6.54,0,0,0-2.39-5.43q-2.39-1.91-7-1.9H81.17V43.18h8.25q4.6,0,7-1.9"
fill="#ffffff"
/>
<path
d="M145.86,25.44V56.91a2.72,2.72,0,0,1-2.72,2.73h-4.33V43.81H119.18V59.64h-4.32a2.73,2.73,0,0,1-2.73-2.73V25.44a2.72,2.72,0,0,1,2.73-2.72h4.32V38h19.63V22.72h4.33a2.72,2.72,0,0,1,2.72,2.72"
fill="#ffffff"
/>
<path
d="M183,56.58v3h-24.8a3.6,3.6,0,0,1-3.6-3.6V26.36a3.6,3.6,0,0,1,3.6-3.6h24.05v3a2.73,2.73,0,0,1-2.73,2.73H161.62v9.57h18.29V43.7H161.62V53.86h18.65A2.72,2.72,0,0,1,183,56.58"
fill="#ffffff"
/>
<path
d="M222.73,22.76V59.59h-4.52a2.71,2.71,0,0,1-2.09-1l-20.06-24V59.59h-7V22.76h4.51a2.72,2.72,0,0,1,2.09,1l20.07,24V22.76Z"
fill="#ffffff"
/>
<rect x="231.85" y="22.76" width="7.03" height="36.83" fill="#ffffff" />
<path
d="M261,44.18l-6,6v9.42h-7V22.76h7V41.65L273,23.57a2.71,2.71,0,0,1,1.93-.81h6.77L265.75,39.23l16.88,20.36h-7a2.72,2.72,0,0,1-2.06-.94Z"
fill="#ffffff"
/>
<path
d="M315.59,51.07H296.65l-3,6.89a2.74,2.74,0,0,1-2.5,1.63h-5.47l16.08-34.74A3.6,3.6,0,0,1,305,22.76h2.32a3.61,3.61,0,0,1,3.27,2.08l16.13,34.75h-5.59A2.72,2.72,0,0,1,318.66,58Zm-2.33-5.37-7.14-16.1L299,45.7Z"
fill="#ffffff"
/>
<path
d="M359.69,51.07H340.76l-3,6.89a2.71,2.71,0,0,1-2.49,1.63h-5.47l16.07-34.74a3.62,3.62,0,0,1,3.27-2.09h2.33a3.59,3.59,0,0,1,3.26,2.08l16.13,34.75h-5.59A2.7,2.7,0,0,1,362.77,58Zm-2.32-5.37-7.14-16.1-7.09,16.1Z"
fill="#ffffff"
/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RobotNet.WebApp</title>
<base href="/" />
<link rel="stylesheet" href="css/app.css" />
<link href="manifest.webmanifest" rel="manifest" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
<link rel="apple-touch-icon" sizes="192x192" href="icon-192.png" />
<link rel="stylesheet" href="lib/mdi/font/css/materialdesignicons.min.css" />
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="lib/monaco-editor/min/vs/editor/editor.main.css" type="text/css" data-name="vs/editor/editor.main">
<link rel="stylesheet" href="css/mud/fonts.googleapis.com.css" />
<link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="_content/MudBlazor/MudBlazor.min.css" />
<link rel="stylesheet" href="RobotNet.WebApp.styles.css" />
</head>
<body>
<div id="app" class="w-100 h-100">
<div class="d-flex w-100 h-100 justify-content-center align-items-center">
<img src="images/logoDark.svg" alt="Logo" style="width: 200px; height:200px">
</div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
<script src="js/chart.umd.js"></script>
<script src="js/chartjs-plugin-datalabels.js"></script>
<script src="js/robonet.chart.js"></script>
<script src="lib/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<script>
var require = { paths: { vs: 'lib/monaco-editor/min/vs' } };
</script>
<script src="lib/monaco-editor/min/vs/loader.js"></script>
<script src="lib/monaco-editor/min/vs/editor/editor.main.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="js/script.js"></script>
<script src="js/robot-design.js"></script>
<script src="js/map.js"></script>
<script src="js/app.js"></script>
</body>
</html>

View File

@@ -0,0 +1,42 @@
function downloadFile(fileName, content, contentType) {
const blob = new Blob([content], { type: contentType });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}
function setFullscreen(isFull) {
const sidebar = document.querySelector('.sidebar');
const mainContent = document.querySelector('main');
if (sidebar && mainContent) {
if (!isFull) {
sidebar.classList.remove('hidden');
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
} else {
sidebar.classList.add('hidden');
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
}
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,256 @@
window.InputClick = (elementId) => {
document.getElementById(elementId).click();
}
window.DownloadImage = (url, fileName) => {
const link = document.createElement('a');
link.href = url;
link.download = fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
window.DownloadImageBase64 = (base64Data, fileName) => {
// Chuyển đổi Base64 thành Blob
const byteCharacters = atob(base64Data.split(',')[1]);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
const blob = new Blob([byteArray], { type: 'image/png' }); // Thay đổi type nếu cần
// Tạo Object URL từ Blob
const url = URL.createObjectURL(blob);
// Tạo thẻ `<a>` để tải về
const link = document.createElement('a');
link.href = url;
link.download = fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Giải phóng bộ nhớ
URL.revokeObjectURL(url);
}
window.setCssVariable = (variable, value) => {
document.documentElement.style.setProperty(variable, value);
localStorage.setItem(variable, value);
};
window.getCssVariable = (variable) => {
return localStorage.getItem(variable);
};
window.DOMCssLoaded = () => {
const width = localStorage.getItem('--edge-stroke-width');
if (width) {
document.documentElement.style.setProperty('--edge-stroke-width', width);
}
else {
document.documentElement.style.setProperty('--edge-stroke-width', "0.15px");
}
const directionwidth = localStorage.getItem('--edge-direction-stroke-width');
if (directionwidth) {
document.documentElement.style.setProperty('--edge-direction-stroke-width', directionwidth);
}
else {
document.documentElement.style.setProperty('--edge-direction-stroke-width', "0.3px");
}
const radius = localStorage.getItem('--node-r');
if (radius) {
document.documentElement.style.setProperty('--node-r', radius);
}
else {
document.documentElement.style.setProperty('--node-r', "0.1px");
}
const originwidth = localStorage.getItem('--origin-vector-stroke-width');
if (originwidth) {
document.documentElement.style.setProperty('--origin-vector-stroke-width', originwidth);
}
else {
document.documentElement.style.setProperty('--origin-vector-stroke-width', "0.35px");
}
};
window.UpdateViewContainerRect = async (dotnetRef, divElement, funcName) => {
var rect = divElement.getBoundingClientRect();
await dotnetRef.invokeMethodAsync(funcName, rect.x, rect.y, rect.width, rect.height, rect.top, rect.right, rect.bottom, rect.left);
};
window.ResizeObserverRegister = (dotnetRef, divElement, funcName) => {
const resizeObserver = new ResizeObserver(async (entries) => {
await window.UpdateViewContainerRect(dotnetRef, divElement, funcName);
});
resizeObserver.observe(divElement);
};
window.AddEventListener = (dotnetRef, element, eventName, funcName, stopPropagation = true) => {
element.addEventListener(eventName, async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName);
})
};
window.AddMouseMoveEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mousemove", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.clientX, ev.clientY, ev.buttons, ev.ctrlKey, ev.movementX, ev.movementY);
})
};
window.AddKeyUpEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("keyup", async (ev) => {
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.code, ev.key, ev.altKey, ev.ctrlKey, ev.shiftKey);
})
};
window.AddMouseWheelEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mousewheel", async (ev) => {
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.deltaY, ev.offsetX, ev.offsetY);
}, { passive: true })
};
window.AddMouseUpEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mouseup", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.button, ev.altKey, ev.ctrlKey, ev.shiftKey);
})
};
window.AddMouseDownEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mousedown", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.button, ev.altKey, ev.ctrlKey, ev.shiftKey);
})
};
window.SetMapSvgConfig = (element, width, height, originX, originY) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "svg") {
element.setAttribute("width", width );
element.setAttribute("height", height );
element.setAttribute("viewBox", `${originX} ${originY} ${width} ${height}`);
}
};
window.SetMapSvgRect = (element, width, height) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "svg") {
element.setAttribute("width", width);
element.setAttribute("height", height);
}
};
window.SetImageAttribute = (element, width, height, originX, originY, href) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "image") {
element.setAttribute("width", width );
element.setAttribute("height", height );
element.setAttribute("x", originX);
element.setAttribute("y", originY);
element.setAttribute("href", href);
}
};
window.SetMapMovement = (element, top, left) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "div") {
element.setAttribute("style", `top: ${top}px; left: ${left}px;`);
}
};
window.SetMapScale = (element, scale) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "div") {
element.setAttribute("style", `transform: scale(${scale });`);
}
};
window.SetNodePosition = (circleRef, textRef, x, y) => {
if (circleRef && circleRef.setAttribute) {
circleRef.setAttribute("cx", x);
circleRef.setAttribute("cy", y);
}
if (textRef && textRef.setAttribute) {
const radius = parseFloat(localStorage.getItem('--node-r'));
if (!radius) {
radius = 0.1;
}
textRef.setAttribute("x", x);
textRef.setAttribute("y", - y - radius - 0.08);
}
};
window.AddSelected = (element) => {
element.classList.add("active");
};
window.RemoveSelected = (element) => {
element.classList.remove("active");
};
window.ElementSetAttribute = (element, attr, value) => {
if (element && element.setAttribute) element.setAttribute(attr, value);
}
window.AddTouchMoveEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
let lastX = 0, lastY = 0;
element.addEventListener("touchmove", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
const touch = ev.touches[0];
const movementX = touch.clientX - lastX;
const movementY = touch.clientY - lastY;
lastX = touch.clientX;
lastY = touch.clientY;
await dotnetRef.invokeMethodAsync(funcName, touch.clientX, touch.clientY, ev.touches.length, movementX, movementY);
});
element.addEventListener("touchstart", (ev) => {
const touch = ev.touches[0];
lastX = touch.clientX;
lastY = touch.clientY;
});
};
window.DownloadMap = async (filename, content) => {
const arrayBuffer = await content.arrayBuffer();
const blob = new Blob([arrayBuffer]);
const url = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = filename;
anchor.click();
URL.revokeObjectURL(url);
}
window.SetElementPosition = (robotRef, nameRef, x, y, theta, originX, originY) => {
if (robotRef && robotRef.setAttribute) {
robotRef.setAttribute("x", x + originX);
robotRef.setAttribute("y", y + originY);
robotRef.setAttribute("transform", `rotate(${theta} ${x} ${y})`);
}
if (nameRef && nameRef.setAttribute) {
nameRef.setAttribute("x", x);
nameRef.setAttribute("y", -y);
}
}
window.ScrollToBottom = (objDiv) => {
if (objDiv.scrollTop != objDiv.scrollHeight) {
objDiv.scrollTop = objDiv.scrollHeight;
}
}

View File

@@ -0,0 +1,176 @@
if (!window.blazorChart) {
window.blazorChart = {};
}
window.blazorChart = {
addDatasetData: (elementId, dataLabel, data) => {
let chart = window.blazorChart.get(elementId);
if (chart) {
const chartData = chart.data;
const chartDatasetData = data;
if (!chartData.labels.includes(dataLabel))
chartData.labels.push(dataLabel);
const chartDatasets = chartData.datasets;
if (chartDatasets.length > 0) {
let datasetIndex = chartDatasets.findIndex(dataset => dataset.label === chartDatasetData.datasetLabel);
if (datasetIndex > -1) {
chartDatasets[datasetIndex].data.push(chartDatasetData.data);
chart.update();
}
}
}
},
addDatasetsData: (elementId, dataLabel, data) => {
let chart = window.blazorChart.get(elementId);
if (chart && data) {
const chartData = chart.data;
if (!chartData.labels.includes(dataLabel)) {
chartData.labels.push(dataLabel);
if (chartData.datasets.length > 0 && chartData.datasets.length === data.length) {
data.forEach(chartDatasetData => {
let datasetIndex = chartData.datasets.findIndex(dataset => dataset.label === chartDatasetData.datasetLabel);
chartData.datasets[datasetIndex].data.push(chartDatasetData.data);
});
chart.update();
}
}
}
},
addDataset: (elementId, newDataset) => {
let chart = window.blazorChart.get(elementId);
if (chart) {
chart.data.datasets.push(newDataset);
chart.update();
}
},
create: (elementId, type, data, options) => {
let chartEl = document.getElementById(elementId);
let _plugins = [];
_plugins.push(ChartDataLabels);
const config = {
type: type,
data: data,
options: options,
plugins: _plugins
};
if (type === 'line') {
const tooltipLine = {
id: 'tooltipLine',
beforeDraw: chart => {
if (chart.tooltip?._active && chart.tooltip?._active.length) {
const ctx = chart.ctx;
ctx.save();
const activePoint = chart.tooltip._active[0];
ctx.beginPath();
ctx.setLineDash([5, 5]);
ctx.moveTo(activePoint.element.x, chart.chartArea.top);
ctx.lineTo(activePoint.element.x, activePoint.element.y);
ctx.linewidth = 2;
ctx.strokeStyle = 'grey';
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.setLineDash([5, 5]);
ctx.moveTo(activePoint.element.x, activePoint.element.y);
ctx.lineTo(activePoint.element.x, chart.chartArea.bottom);
ctx.linewidth = 2;
ctx.strokeStyle = 'grey';
ctx.stroke();
ctx.restore();
}
},
};
config.plugins.push(tooltipLine);
}
const chart = new Chart(
chartEl,
config
);
},
get: (elementId) => {
let chart;
Chart.helpers.each(Chart.instances, function (instance) {
if (instance.canvas.id === elementId) {
chart = instance;
}
});
return chart;
},
initialize: (elementId, type, data, options) => {
let chart = window.blazorChart.get(elementId);
if (chart) return;
else
window.blazorChart.create(elementId, type, data, options);
},
resize: (elementId, width, height) => {
let chart = window.blazorChart.get(elementId);
if (chart) {
chart.canvas.parentNode.style.height = height;
chart.canvas.parentNode.style.width = width;
}
},
update: (elementId, data, options) => {
let chart = window.blazorChart.get(elementId);
if (chart) {
chart.data = data;
chart.options = options;
chart.update();
}
else {
console.warn(`The chart is not initialized. Initialize it and then call update.`);
}
},
updateData: (elementId, data) => {
let chart = window.blazorChart.get(elementId);
if (chart) {
window.blazorChart.mergeDatasets(chart.data.datasets, data.datasets);
window.blazorChart.mergeLabels(chart.data, data);
chart.update();
}
},
mergeDatasets(oldDatasets, newDatasets) {
for (let i = oldDatasets.length - 1; i >= 0; i--) {
let sameDatasetInNewConfig = newDatasets.find(newD => newD.label === oldDatasets[i].label);
if (sameDatasetInNewConfig === undefined) {
oldDatasets.splice(i, 1);
}
else {
oldDatasets[i].data = sameDatasetInNewConfig.data;
}
}
let currentIds = oldDatasets.map(dataset => dataset.label);
newDatasets.filter(newDataset => !currentIds.includes(newDataset.label)).forEach(newDataset => oldDatasets.push(newDataset));
},
mergeLabels(oldChartData, newChartData) {
const innerFunc = (oldLabels, newLabels) => {
if (newLabels == null || newLabels.length === 0) {
if (oldLabels) {
oldLabels.length = 0;
}
return oldLabels;
}
if (oldLabels == null) {
return newLabels;
}
oldLabels.length = 0;
for (var i = 0; i < newLabels.length; i++) {
oldLabels.push(newLabels[i]);
}
return oldLabels;
};
oldChartData.labels = innerFunc(oldChartData.labels, newChartData.labels);
},
}

View File

@@ -0,0 +1,119 @@
window.ElementSetAttribute = (element, attr, value) => {
if (element && element.setAttribute) element.setAttribute(attr, value);
}
window.SetImageAttribute = (element, width, height, originX, originY, href) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "image") {
element.setAttribute("width", width);
element.setAttribute("height", height);
element.setAttribute("x", originX);
element.setAttribute("y", originY);
element.setAttribute("href", href);
}
};
window.SetRobotPosition = (robotRef, nameRef, x, y, theta, originX, originY) => {
if (robotRef && robotRef.setAttribute) {
robotRef.setAttribute("x", x + originX);
robotRef.setAttribute("y", y + originY);
robotRef.setAttribute("transform", `rotate(${theta} ${x} ${y})`);
}
if (nameRef && nameRef.setAttribute) {
nameRef.setAttribute("x", x);
nameRef.setAttribute("y", -y);
}
}
window.SetNodePosition = (circleRef, textRef, x, y) => {
if (circleRef && circleRef.setAttribute) {
circleRef.setAttribute("cx", x);
circleRef.setAttribute("cy", y);
}
if (textRef && textRef.setAttribute) {
const radius = parseFloat(localStorage.getItem('--node-r'));
if (!radius) {
radius = 0.1;
}
textRef.setAttribute("x", x);
textRef.setAttribute("y", - y - radius - 0.08);
}
};
window.UpdateViewContainerRect = async (dotnetRef, divElement, funcName) => {
var rect = divElement.getBoundingClientRect();
await dotnetRef.invokeMethodAsync(funcName, rect.x, rect.y, rect.width, rect.height, rect.top, rect.right, rect.bottom, rect.left);
};
window.ResizeObserverRegister = (dotnetRef, divElement, funcName) => {
const resizeObserver = new ResizeObserver(async (entries) => {
await window.UpdateViewContainerRect(dotnetRef, divElement, funcName);
});
resizeObserver.observe(divElement);
};
window.AddEventListener = (dotnetRef, element, eventName, funcName, stopPropagation = true) => {
element.addEventListener(eventName, async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName);
})
};
window.AddMouseMoveEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mousemove", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.clientX, ev.clientY, ev.buttons, ev.ctrlKey, ev.movementX, ev.movementY);
})
};
window.AddMouseWheelEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
element.addEventListener("mousewheel", async (ev) => {
if (stopPropagation) ev.stopPropagation();
await dotnetRef.invokeMethodAsync(funcName, ev.deltaY, ev.offsetX, ev.offsetY);
}, { passive: true })
};
window.AddTouchMoveEventListener = (dotnetRef, element, funcName, stopPropagation = true) => {
let lastX = 0, lastY = 0;
element.addEventListener("touchmove", async (ev) => {
ev.preventDefault();
if (stopPropagation) ev.stopPropagation();
const touch = ev.touches[0];
const movementX = touch.clientX - lastX;
const movementY = touch.clientY - lastY;
lastX = touch.clientX;
lastY = touch.clientY;
await dotnetRef.invokeMethodAsync(funcName, touch.clientX, touch.clientY, ev.touches.length, movementX, movementY);
});
element.addEventListener("touchstart", (ev) => {
const touch = ev.touches[0];
lastX = touch.clientX;
lastY = touch.clientY;
});
};
window.SetMapSvgConfig = (element, width, height, originX, originY) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "svg") {
element.setAttribute("width", width);
element.setAttribute("height", height);
element.setAttribute("viewBox", `${originX} ${originY} ${width} ${height}`);
}
};
window.SetMapMovement = (element, top, left) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "div") {
element.setAttribute("style", `top: ${top}px; left: ${left}px;`);
}
};
window.SetMapSvgRect = (element, width, height) => {
if (element && element.nodeName && element.nodeName.toLowerCase() === "svg") {
element.setAttribute("width", width);
element.setAttribute("height", height);
}
};

View File

@@ -0,0 +1,76 @@
window.monaco = monaco;
window.MonacoRuntime = {
OnCodeEditorDidChangeModelContent: (codeEditor, dotnetRef, method) => {
codeEditor.onDidChangeModelContent(function (e) {
dotnetRef.invokeMethodAsync(method, e);
});
},
CSharpLanguageRegisterCompletionItemProvider: (dotnetRef, getCompletionMethod) => {
return monaco.languages.registerCompletionItemProvider("csharp", {
triggerCharacters: ["."],
//resolveCompletionItem: (model, position, item) => {
// return this.resolveCompletionItem(item, dotnetHelper)
//},
provideCompletionItems: async (model, position, context, token) => {
return await dotnetRef.invokeMethodAsync(getCompletionMethod, position.lineNumber, position.column, context.triggerKind, context.triggerCharacter);
}
});
},
CSharpLanguageRegisterSignatureHelpProvider: (dotnetRef, getSignatureHelpMethod) => {
return monaco.languages.registerSignatureHelpProvider("csharp", {
signatureHelpTriggerCharacters: ['('],
provideSignatureHelp: async (model, position, token, context) => {
let signature = await dotnetRef.invokeMethodAsync(getSignatureHelpMethod, position.lineNumber, position.column);
if (!signature) {
return undefined;
}
return {
value: signature.value,
dispose: () => { },
}
}
});
},
CSharpLanguageRegisterHoverProvider: (dotnetRef, getHoverProviderMethod) => {
return monaco.languages.registerHoverProvider("csharp", {
provideHover: async (model, position, token, context) => {
var mess = await dotnetRef.invokeMethodAsync(getHoverProviderMethod, position.lineNumber, position.column);
return {
contents: [
{
value: mess
}
]
}
}
});
}
}
window.addEventListener("keydown", function (e) {
if ((e.key === 's' || e.key == 'S') && e.ctrlKey) {
e.preventDefault();
e.stopPropagation();
}
}, false);
window.addEventListener("contextmenu", function (e) {
e.preventDefault();
e.stopPropagation();
}, false);
window.SetRadioChecked = function (id) {
document.getElementById(id).checked = true;
};
window.UncheckRadioAll = function (name) {
const radios = document.querySelectorAll(`input[type="radio"][name="${name}"]`);
radios.forEach(radio => radio.checked = false);
};
window.ScrollToBottom = (element) => {
if (element) {
element.scrollTop = element.scrollHeight;
}
};

View File

@@ -0,0 +1,22 @@
{
"name": "RobotNet.WebApp",
"short_name": "RobotNet.WebApp",
"id": "./",
"start_url": "./",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#03173d",
"prefer_related_applications": false,
"icons": [
{
"src": "icon-512.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "icon-192.png",
"type": "image/png",
"sizes": "192x192"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,4 @@
// In development, always fetch from the network and do not enable offline support.
// This is because caching would make development more difficult (changes would not
// be reflected on the first load after each change).
self.addEventListener('fetch', () => { });

View File

@@ -0,0 +1,55 @@
// Caution! Be sure you understand the caveats before publishing an application with
// offline support. See https://aka.ms/blazor-offline-considerations
self.importScripts('./service-worker-assets.js');
self.addEventListener('install', event => event.waitUntil(onInstall(event)));
self.addEventListener('activate', event => event.waitUntil(onActivate(event)));
self.addEventListener('fetch', event => event.respondWith(onFetch(event)));
const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`;
const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ];
const offlineAssetsExclude = [ /^service-worker\.js$/ ];
// Replace with your base path if you are hosting on a subfolder. Ensure there is a trailing '/'.
const base = "/";
const baseUrl = new URL(base, self.origin);
const manifestUrlList = self.assetsManifest.assets.map(asset => new URL(asset.url, baseUrl).href);
async function onInstall(event) {
console.info('Service worker: Install');
// Fetch and cache all matching items from the assets manifest
const assetsRequests = self.assetsManifest.assets
.filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url)))
.filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url)))
.map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' }));
await caches.open(cacheName).then(cache => cache.addAll(assetsRequests));
}
async function onActivate(event) {
console.info('Service worker: Activate');
// Delete unused caches
const cacheKeys = await caches.keys();
await Promise.all(cacheKeys
.filter(key => key.startsWith(cacheNamePrefix) && key !== cacheName)
.map(key => caches.delete(key)));
}
async function onFetch(event) {
let cachedResponse = null;
if (event.request.method === 'GET') {
// For all navigation requests, try to serve index.html from cache,
// unless that request is for an offline resource.
// If you need some URLs to be server-rendered, edit the following check to exclude those URLs
const shouldServeIndexHtml = event.request.mode === 'navigate'
&& !manifestUrlList.some(url => url === event.request.url);
const request = shouldServeIndexHtml ? 'index.html' : event.request;
const cache = await caches.open(cacheName);
cachedResponse = await cache.match(request);
}
return cachedResponse || fetch(event.request);
}