Initial commit
This commit is contained in:
commit
85de1237f4
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
/packages/
|
||||||
|
riderModule.iml
|
||||||
|
/_ReSharper.Caches/
|
13
.idea/.idea.pac-man-board-game/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.pac-man-board-game/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/.idea.pac-man-board-game.iml
|
||||||
|
/modules.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/contentModel.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
4
.idea/.idea.pac-man-board-game/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.pac-man-board-game/.idea/encodings.xml
generated
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
16
pac-man-board-game.sln
Normal file
16
pac-man-board-game.sln
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pac-man-board-game", "pac-man-board-game\pac-man-board-game.csproj", "{60072632-A16F-4007-8A97-AC74B7E6703B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{60072632-A16F-4007-8A97-AC74B7E6703B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{60072632-A16F-4007-8A97-AC74B7E6703B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{60072632-A16F-4007-8A97-AC74B7E6703B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{60072632-A16F-4007-8A97-AC74B7E6703B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
232
pac-man-board-game/.gitignore
vendored
Normal file
232
pac-man-board-game/.gitignore
vendored
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
build/
|
||||||
|
bld/
|
||||||
|
bin/
|
||||||
|
Bin/
|
||||||
|
obj/
|
||||||
|
Obj/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
/wwwroot/dist/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Microsoft Azure ApplicationInsights config file
|
||||||
|
ApplicationInsights.config
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
1
pac-man-board-game/ClientApp/.env
Normal file
1
pac-man-board-game/ClientApp/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
BROWSER=none
|
3
pac-man-board-game/ClientApp/.env.development
Normal file
3
pac-man-board-game/ClientApp/.env.development
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PORT=44435
|
||||||
|
HTTPS=true
|
||||||
|
|
21
pac-man-board-game/ClientApp/.gitignore
vendored
Normal file
21
pac-man-board-game/ClientApp/.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
2228
pac-man-board-game/ClientApp/README.md
Normal file
2228
pac-man-board-game/ClientApp/README.md
Normal file
File diff suppressed because it is too large
Load Diff
33
pac-man-board-game/ClientApp/aspnetcore-https.js
Normal file
33
pac-man-board-game/ClientApp/aspnetcore-https.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// This script sets up HTTPS for the application using the ASP.NET Core HTTPS certificate
|
||||||
|
const fs = require('fs');
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const baseFolder =
|
||||||
|
process.env.APPDATA !== undefined && process.env.APPDATA !== ''
|
||||||
|
? `${process.env.APPDATA}/ASP.NET/https`
|
||||||
|
: `${process.env.HOME}/.aspnet/https`;
|
||||||
|
|
||||||
|
const certificateArg = process.argv.map(arg => arg.match(/--name=(?<value>.+)/i)).filter(Boolean)[0];
|
||||||
|
const certificateName = certificateArg ? certificateArg.groups.value : process.env.npm_package_name;
|
||||||
|
|
||||||
|
if (!certificateName) {
|
||||||
|
console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<<app>> explicitly.')
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
|
||||||
|
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
|
||||||
|
|
||||||
|
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
|
||||||
|
spawn('dotnet', [
|
||||||
|
'dev-certs',
|
||||||
|
'https',
|
||||||
|
'--export-path',
|
||||||
|
certFilePath,
|
||||||
|
'--format',
|
||||||
|
'Pem',
|
||||||
|
'--no-password',
|
||||||
|
], { stdio: 'inherit', })
|
||||||
|
.on('exit', (code) => process.exit(code));
|
||||||
|
}
|
55
pac-man-board-game/ClientApp/aspnetcore-react.js
Normal file
55
pac-man-board-game/ClientApp/aspnetcore-react.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// This script configures the .env.development.local file with additional environment variables to configure HTTPS using the ASP.NET Core
|
||||||
|
// development certificate in the webpack development proxy.
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const baseFolder =
|
||||||
|
process.env.APPDATA !== undefined && process.env.APPDATA !== ''
|
||||||
|
? `${process.env.APPDATA}/ASP.NET/https`
|
||||||
|
: `${process.env.HOME}/.aspnet/https`;
|
||||||
|
|
||||||
|
const certificateArg = process.argv.map(arg => arg.match(/--name=(?<value>.+)/i)).filter(Boolean)[0];
|
||||||
|
const certificateName = certificateArg ? certificateArg.groups.value : process.env.npm_package_name;
|
||||||
|
|
||||||
|
if (!certificateName) {
|
||||||
|
console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<<app>> explicitly.')
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
|
||||||
|
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
|
||||||
|
|
||||||
|
if (!fs.existsSync('.env.development.local')) {
|
||||||
|
fs.writeFileSync(
|
||||||
|
'.env.development.local',
|
||||||
|
`SSL_CRT_FILE=${certFilePath}
|
||||||
|
SSL_KEY_FILE=${keyFilePath}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let lines = fs.readFileSync('.env.development.local')
|
||||||
|
.toString()
|
||||||
|
.split('\n');
|
||||||
|
|
||||||
|
let hasCert, hasCertKey = false;
|
||||||
|
for (const line of lines) {
|
||||||
|
if (/SSL_CRT_FILE=.*/i.test(line)) {
|
||||||
|
hasCert = true;
|
||||||
|
}
|
||||||
|
if (/SSL_KEY_FILE=.*/i.test(line)) {
|
||||||
|
hasCertKey = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasCert) {
|
||||||
|
fs.appendFileSync(
|
||||||
|
'.env.development.local',
|
||||||
|
`\nSSL_CRT_FILE=${certFilePath}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!hasCertKey) {
|
||||||
|
fs.appendFileSync(
|
||||||
|
'.env.development.local',
|
||||||
|
`\nSSL_KEY_FILE=${keyFilePath}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
19442
pac-man-board-game/ClientApp/package-lock.json
generated
Normal file
19442
pac-man-board-game/ClientApp/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
80
pac-man-board-game/ClientApp/package.json
Normal file
80
pac-man-board-game/ClientApp/package.json
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"name": "pac_man_board_game",
|
||||||
|
"version": "0.1-Testing",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"bootstrap": "^5.2.0",
|
||||||
|
"http-proxy-middleware": "^2.0.6",
|
||||||
|
"jquery": "^3.6.0",
|
||||||
|
"merge": "^2.1.1",
|
||||||
|
"oidc-client": "^1.11.5",
|
||||||
|
"process": "^0.11.10",
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react-router-bootstrap": "^0.26.2",
|
||||||
|
"react-router-dom": "^6.3.0",
|
||||||
|
"react-scripts": "^5.0.1",
|
||||||
|
"reactstrap": "^9.1.3",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"web-vitals": "^2.1.4",
|
||||||
|
"workbox-background-sync": "^6.5.4",
|
||||||
|
"workbox-broadcast-update": "^6.5.4",
|
||||||
|
"workbox-cacheable-response": "^6.5.4",
|
||||||
|
"workbox-core": "^6.5.4",
|
||||||
|
"workbox-expiration": "^6.5.4",
|
||||||
|
"workbox-google-analytics": "^6.5.4",
|
||||||
|
"workbox-navigation-preload": "^6.5.4",
|
||||||
|
"workbox-precaching": "^6.5.4",
|
||||||
|
"workbox-range-requests": "^6.5.4",
|
||||||
|
"workbox-routing": "^6.5.4",
|
||||||
|
"workbox-strategies": "^6.5.4",
|
||||||
|
"workbox-streams": "^6.5.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jest": "^29.5.1",
|
||||||
|
"@types/react": "^18.2.6",
|
||||||
|
"@types/react-dom": "^18.2.4",
|
||||||
|
"ajv": "^8.11.0",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"eslint": "^8.22.0",
|
||||||
|
"eslint-config-react-app": "^7.0.1",
|
||||||
|
"eslint-plugin-flowtype": "^8.0.3",
|
||||||
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
|
"eslint-plugin-react": "^7.30.1",
|
||||||
|
"nan": "^2.16.0",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"autoprefixer": "10.4.5"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"css-what": "^5.0.1",
|
||||||
|
"nth-check": "^3.0.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prestart": "node aspnetcore-https && node aspnetcore-react",
|
||||||
|
"start": "rimraf ./build && react-scripts start",
|
||||||
|
"build": "react-scripts build",
|
||||||
|
"test": "cross-env CI=true react-scripts test --env=jsdom",
|
||||||
|
"eject": "react-scripts eject",
|
||||||
|
"lint": "eslint ./src/"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": [
|
||||||
|
"react-app"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
BIN
pac-man-board-game/ClientApp/public/favicon.ico
Normal file
BIN
pac-man-board-game/ClientApp/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
41
pac-man-board-game/ClientApp/public/index.html
Normal file
41
pac-man-board-game/ClientApp/public/index.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="theme-color" content="#000000">
|
||||||
|
<base href="%PUBLIC_URL%/" />
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is added to the
|
||||||
|
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||||
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
<!--
|
||||||
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>pac_man_board_game</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
You need to enable JavaScript to run this app.
|
||||||
|
</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
15
pac-man-board-game/ClientApp/public/manifest.json
Normal file
15
pac-man-board-game/ClientApp/public/manifest.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"short_name": "pac_man_board_game",
|
||||||
|
"name": "pac_man_board_game",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "favicon.ico",
|
||||||
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "./index.html",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
14
pac-man-board-game/ClientApp/src/App.test.tsx
Normal file
14
pac-man-board-game/ClientApp/src/App.test.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import {App} from './App';
|
||||||
|
|
||||||
|
it('renders without crashing', async () => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
const root = createRoot(div);
|
||||||
|
root.render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<App />
|
||||||
|
</MemoryRouter>);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
});
|
16
pac-man-board-game/ClientApp/src/App.tsx
Normal file
16
pac-man-board-game/ClientApp/src/App.tsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import React from "react";
|
||||||
|
import {Route, Routes} from "react-router-dom";
|
||||||
|
import {Layout} from "./components/Layout";
|
||||||
|
import AppRoutes from "./AppRoutes";
|
||||||
|
import "./custom.css";
|
||||||
|
|
||||||
|
export const App = () => (
|
||||||
|
<Layout>
|
||||||
|
<Routes>
|
||||||
|
{AppRoutes.map((route, index) => {
|
||||||
|
const {element, ...rest} = route;
|
||||||
|
return <Route key={index} {...rest} element={element}/>;
|
||||||
|
})}
|
||||||
|
</Routes>
|
||||||
|
</Layout>
|
||||||
|
);
|
21
pac-man-board-game/ClientApp/src/AppRoutes.tsx
Normal file
21
pac-man-board-game/ClientApp/src/AppRoutes.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Counter } from "./components/Counter";
|
||||||
|
import { FetchData } from "./components/FetchData";
|
||||||
|
import { Home } from "./components/Home";
|
||||||
|
|
||||||
|
const AppRoutes = [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
element: <Home />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/counter',
|
||||||
|
element: <Counter />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/fetch-data',
|
||||||
|
element: <FetchData />
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default AppRoutes;
|
22
pac-man-board-game/ClientApp/src/components/Counter.tsx
Normal file
22
pac-man-board-game/ClientApp/src/components/Counter.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const Counter = () => {
|
||||||
|
|
||||||
|
const [currentCount, setCurrentCount] = React.useState(0);
|
||||||
|
|
||||||
|
function incrementCounter() {
|
||||||
|
setCurrentCount(currentCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Counter</h1>
|
||||||
|
|
||||||
|
<p>This is a simple example of a React component.</p>
|
||||||
|
|
||||||
|
<p aria-live="polite">Current count: <strong>{currentCount}</strong></p>
|
||||||
|
|
||||||
|
<button className="btn btn-primary" onClick={incrementCounter}>Increment</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
45
pac-man-board-game/ClientApp/src/components/FetchData.tsx
Normal file
45
pac-man-board-game/ClientApp/src/components/FetchData.tsx
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const FetchData = () => {
|
||||||
|
|
||||||
|
const [forecasts, setForecasts] = React.useState<any>([]);
|
||||||
|
const [loading, setLoading] = React.useState(true);
|
||||||
|
|
||||||
|
async function populateWeatherData() {
|
||||||
|
const response = await fetch("api/WeatherForecast");
|
||||||
|
const data = await response.json();
|
||||||
|
setForecasts(data);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
populateWeatherData().then(null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <>
|
||||||
|
{
|
||||||
|
loading ?
|
||||||
|
<p><em>Loading...</em></p> :
|
||||||
|
<table className="table table-striped" aria-labelledby="tableLabel">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Temp. (C)</th>
|
||||||
|
<th>Temp. (F)</th>
|
||||||
|
<th>Summary</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{forecasts.map((forecast: any) =>
|
||||||
|
<tr key={forecast.date}>
|
||||||
|
<td>{forecast.date}</td>
|
||||||
|
<td>{forecast.temperatureC}</td>
|
||||||
|
<td>{forecast.temperatureF}</td>
|
||||||
|
<td>{forecast.summary}</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
}</>;
|
||||||
|
};
|
34
pac-man-board-game/ClientApp/src/components/Home.tsx
Normal file
34
pac-man-board-game/ClientApp/src/components/Home.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const Home = () =>
|
||||||
|
(
|
||||||
|
<div>
|
||||||
|
<h1>Hello, world!</h1>
|
||||||
|
<p>Welcome to your new single-page application, built with:</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://get.asp.net/">ASP.NET Core</a> and <a
|
||||||
|
href="https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx">C#</a> for cross-platform server-side
|
||||||
|
code
|
||||||
|
</li>
|
||||||
|
<li><a href="https://facebook.github.io/react/">React</a> for client-side code</li>
|
||||||
|
<li><a href="http://getbootstrap.com/">Bootstrap</a> for layout and styling</li>
|
||||||
|
</ul>
|
||||||
|
<p>To help you get started, we have also set up:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Client-side navigation</strong>. For example, click <em>Counter</em> then <em>Back</em> to
|
||||||
|
return here.
|
||||||
|
</li>
|
||||||
|
<li><strong>Development server integration</strong>. In development mode, the development server
|
||||||
|
from <code>create-react-app</code> runs in the background automatically, so your client-side
|
||||||
|
resources are dynamically built on demand and the page refreshes when you modify any file.
|
||||||
|
</li>
|
||||||
|
<li><strong>Efficient production builds</strong>. In production mode, development-time features are
|
||||||
|
disabled, and your <code>dotnet publish</code> configuration produces minified, efficiently bundled
|
||||||
|
JavaScript files.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>The <code>ClientApp</code> subdirectory is a standard React application based on
|
||||||
|
the <code>create-react-app</code> template. If you open a command prompt in that directory, you can
|
||||||
|
run <code>npm</code> commands such as <code>npm test</code> or <code>npm install</code>.</p>
|
||||||
|
</div>
|
||||||
|
);
|
12
pac-man-board-game/ClientApp/src/components/Layout.tsx
Normal file
12
pac-man-board-game/ClientApp/src/components/Layout.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import React, {Component, JSX} from "react";
|
||||||
|
import {Container} from "reactstrap";
|
||||||
|
import {NavMenu} from "./NavMenu";
|
||||||
|
|
||||||
|
export const Layout = ({children}: { children: JSX.Element }) => (
|
||||||
|
<div>
|
||||||
|
<NavMenu/>
|
||||||
|
<Container tag="main">
|
||||||
|
{children}
|
||||||
|
</Container>
|
||||||
|
</div>
|
||||||
|
);
|
19
pac-man-board-game/ClientApp/src/components/NavMenu.css
Normal file
19
pac-man-board-game/ClientApp/src/components/NavMenu.css
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
a.navbar-brand {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-shadow {
|
||||||
|
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||||
|
}
|
37
pac-man-board-game/ClientApp/src/components/NavMenu.tsx
Normal file
37
pac-man-board-game/ClientApp/src/components/NavMenu.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import React from "react";
|
||||||
|
import {Collapse, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink} from "reactstrap";
|
||||||
|
import {Link} from "react-router-dom";
|
||||||
|
import "./NavMenu.css";
|
||||||
|
|
||||||
|
export const NavMenu = () => {
|
||||||
|
|
||||||
|
const [collapsed, setCollapsed] = React.useState(true);
|
||||||
|
|
||||||
|
function toggleNavbar() {
|
||||||
|
setCollapsed(!collapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header>
|
||||||
|
<Navbar className="navbar-expand-sm navbar-toggleable-sm ng-white border-bottom box-shadow mb-3"
|
||||||
|
container light>
|
||||||
|
<NavbarBrand tag={Link} to="/">pac_man_board_game</NavbarBrand>
|
||||||
|
<NavbarToggler onClick={toggleNavbar} className="mr-2"/>
|
||||||
|
<Collapse className="d-sm-inline-flex flex-sm-row-reverse" isOpen={!collapsed}
|
||||||
|
navbar>
|
||||||
|
<ul className="navbar-nav flex-grow">
|
||||||
|
<NavItem>
|
||||||
|
<NavLink tag={Link} className="text-dark" to="/">Home</NavLink>
|
||||||
|
</NavItem>
|
||||||
|
<NavItem>
|
||||||
|
<NavLink tag={Link} className="text-dark" to="/counter">Counter</NavLink>
|
||||||
|
</NavItem>
|
||||||
|
<NavItem>
|
||||||
|
<NavLink tag={Link} className="text-dark" to="/fetch-data">Fetch data</NavLink>
|
||||||
|
</NavItem>
|
||||||
|
</ul>
|
||||||
|
</Collapse>
|
||||||
|
</Navbar>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
};
|
18
pac-man-board-game/ClientApp/src/custom.css
Normal file
18
pac-man-board-game/ClientApp/src/custom.css
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* Provide sufficient contrast against white background */
|
||||||
|
a {
|
||||||
|
color: #0366d6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
|
||||||
|
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
color: #E01A76;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
29
pac-man-board-game/ClientApp/src/index.tsx
Normal file
29
pac-man-board-game/ClientApp/src/index.tsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import 'bootstrap/dist/css/bootstrap.css';
|
||||||
|
import {createRoot} from 'react-dom/client';
|
||||||
|
import {BrowserRouter} from 'react-router-dom';
|
||||||
|
import {App} from './App';
|
||||||
|
// @ts-ignore
|
||||||
|
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
||||||
|
// @ts-ignore
|
||||||
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
|
||||||
|
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href');
|
||||||
|
const rootElement = document.getElementById('root');
|
||||||
|
// @ts-ignore
|
||||||
|
const root = createRoot(rootElement);
|
||||||
|
|
||||||
|
root.render(
|
||||||
|
<BrowserRouter basename={baseUrl ?? undefined}>
|
||||||
|
<App/>
|
||||||
|
</BrowserRouter>);
|
||||||
|
|
||||||
|
// If you want your app to work offline and load faster, you can change
|
||||||
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
|
// Learn more about service workers: https://cra.link/PWA
|
||||||
|
serviceWorkerRegistration.unregister();
|
||||||
|
|
||||||
|
// If you want to start measuring performance in your app, pass a function
|
||||||
|
// to log results (for example: reportWebVitals(console.log))
|
||||||
|
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||||
|
reportWebVitals();
|
13
pac-man-board-game/ClientApp/src/reportWebVitals.js
Normal file
13
pac-man-board-game/ClientApp/src/reportWebVitals.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const reportWebVitals = (onPerfEntry) => {
|
||||||
|
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||||
|
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||||
|
getCLS(onPerfEntry);
|
||||||
|
getFID(onPerfEntry);
|
||||||
|
getFCP(onPerfEntry);
|
||||||
|
getLCP(onPerfEntry);
|
||||||
|
getTTFB(onPerfEntry);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reportWebVitals;
|
72
pac-man-board-game/ClientApp/src/service-worker.js
Normal file
72
pac-man-board-game/ClientApp/src/service-worker.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/* eslint-disable no-restricted-globals */
|
||||||
|
|
||||||
|
// This service worker can be customized!
|
||||||
|
// See https://developers.google.com/web/tools/workbox/modules
|
||||||
|
// for the list of available Workbox modules, or add any other
|
||||||
|
// code you'd like.
|
||||||
|
// You can also remove this file if you'd prefer not to use a
|
||||||
|
// service worker, and the Workbox build step will be skipped.
|
||||||
|
|
||||||
|
import { clientsClaim } from 'workbox-core';
|
||||||
|
import { ExpirationPlugin } from 'workbox-expiration';
|
||||||
|
import { precacheAndRoute, createHandlerBoundToURL } from 'workbox-precaching';
|
||||||
|
import { registerRoute } from 'workbox-routing';
|
||||||
|
import { StaleWhileRevalidate } from 'workbox-strategies';
|
||||||
|
|
||||||
|
clientsClaim();
|
||||||
|
|
||||||
|
// Precache all of the assets generated by your build process.
|
||||||
|
// Their URLs are injected into the manifest variable below.
|
||||||
|
// This variable must be present somewhere in your service worker file,
|
||||||
|
// even if you decide not to use precaching. See https://cra.link/PWA
|
||||||
|
precacheAndRoute(self.__WB_MANIFEST);
|
||||||
|
|
||||||
|
// Set up App Shell-style routing, so that all navigation requests
|
||||||
|
// are fulfilled with your index.html shell. Learn more at
|
||||||
|
// https://developers.google.com/web/fundamentals/architecture/app-shell
|
||||||
|
const fileExtensionRegexp = new RegExp('/[^/?]+\\.[^/]+$');
|
||||||
|
registerRoute(
|
||||||
|
// Return false to exempt requests from being fulfilled by index.html.
|
||||||
|
({ request, url }) => {
|
||||||
|
// If this isn't a navigation, skip.
|
||||||
|
if (request.mode !== 'navigate') {
|
||||||
|
return false;
|
||||||
|
} // If this is a URL that starts with /_, skip.
|
||||||
|
|
||||||
|
if (url.pathname.startsWith('/_')) {
|
||||||
|
return false;
|
||||||
|
} // If this looks like a URL for a resource, because it contains // a file extension, skip.
|
||||||
|
|
||||||
|
if (url.pathname.match(fileExtensionRegexp)) {
|
||||||
|
return false;
|
||||||
|
} // Return true to signal that we want to use the handler.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
createHandlerBoundToURL(process.env.PUBLIC_URL + '/index.html')
|
||||||
|
);
|
||||||
|
|
||||||
|
// An example runtime caching route for requests that aren't handled by the
|
||||||
|
// precache, in this case same-origin .png requests like those from in public/
|
||||||
|
registerRoute(
|
||||||
|
// Add in any other file extensions or routing criteria as needed.
|
||||||
|
({ url }) => url.origin === self.location.origin && url.pathname.endsWith('.png'), // Customize this strategy as needed, e.g., by changing to CacheFirst.
|
||||||
|
new StaleWhileRevalidate({
|
||||||
|
cacheName: 'images',
|
||||||
|
plugins: [
|
||||||
|
// Ensure that once this runtime cache reaches a maximum size the
|
||||||
|
// least-recently used images are removed.
|
||||||
|
new ExpirationPlugin({ maxEntries: 50 }),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// This allows the web app to trigger skipWaiting via
|
||||||
|
// registration.waiting.postMessage({type: 'SKIP_WAITING'})
|
||||||
|
self.addEventListener('message', (event) => {
|
||||||
|
if (event.data && event.data.type === 'SKIP_WAITING') {
|
||||||
|
self.skipWaiting();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Any other custom service worker logic can go here.
|
137
pac-man-board-game/ClientApp/src/serviceWorkerRegistration.js
Normal file
137
pac-man-board-game/ClientApp/src/serviceWorkerRegistration.js
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
// This optional code is used to register a service worker.
|
||||||
|
// register() is not called by default.
|
||||||
|
|
||||||
|
// This lets the app load faster on subsequent visits in production, and gives
|
||||||
|
// it offline capabilities. However, it also means that developers (and users)
|
||||||
|
// will only see deployed updates on subsequent visits to a page, after all the
|
||||||
|
// existing tabs open on the page have been closed, since previously cached
|
||||||
|
// resources are updated in the background.
|
||||||
|
|
||||||
|
// To learn more about the benefits of this model and instructions on how to
|
||||||
|
// opt-in, read https://cra.link/PWA
|
||||||
|
|
||||||
|
const isLocalhost = Boolean(
|
||||||
|
window.location.hostname === 'localhost' ||
|
||||||
|
// [::1] is the IPv6 localhost address.
|
||||||
|
window.location.hostname === '[::1]' ||
|
||||||
|
// 127.0.0.0/8 are considered localhost for IPv4.
|
||||||
|
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
|
||||||
|
);
|
||||||
|
|
||||||
|
export function register(config) {
|
||||||
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
|
// The URL constructor is available in all browsers that support SW.
|
||||||
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||||
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
|
// from what our page is served on. This might happen if a CDN is used to
|
||||||
|
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
|
if (isLocalhost) {
|
||||||
|
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||||
|
checkValidServiceWorker(swUrl, config);
|
||||||
|
|
||||||
|
// Add some additional logging to localhost, pointing developers to the
|
||||||
|
// service worker/PWA documentation.
|
||||||
|
navigator.serviceWorker.ready.then(() => {
|
||||||
|
console.log(
|
||||||
|
'This web app is being served cache-first by a service ' +
|
||||||
|
'worker. To learn more, visit https://cra.link/PWA'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Is not localhost. Just register service worker
|
||||||
|
registerValidSW(swUrl, config);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerValidSW(swUrl, config) {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.register(swUrl)
|
||||||
|
.then((registration) => {
|
||||||
|
registration.onupdatefound = () => {
|
||||||
|
const installingWorker = registration.installing;
|
||||||
|
if (installingWorker == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
installingWorker.onstatechange = () => {
|
||||||
|
if (installingWorker.state === 'installed') {
|
||||||
|
if (navigator.serviceWorker.controller) {
|
||||||
|
// At this point, the updated precached content has been fetched,
|
||||||
|
// but the previous service worker will still serve the older
|
||||||
|
// content until all client tabs are closed.
|
||||||
|
console.log(
|
||||||
|
'New content is available and will be used when all ' +
|
||||||
|
'tabs for this page are closed. See https://cra.link/PWA.'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Execute callback
|
||||||
|
if (config && config.onUpdate) {
|
||||||
|
config.onUpdate(registration);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// At this point, everything has been precached.
|
||||||
|
// It's the perfect time to display a
|
||||||
|
// "Content is cached for offline use." message.
|
||||||
|
console.log('Content is cached for offline use.');
|
||||||
|
|
||||||
|
// Execute callback
|
||||||
|
if (config && config.onSuccess) {
|
||||||
|
config.onSuccess(registration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error during service worker registration:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValidServiceWorker(swUrl, config) {
|
||||||
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
|
fetch(swUrl, {
|
||||||
|
headers: { 'Service-Worker': 'script' },
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
|
const contentType = response.headers.get('content-type');
|
||||||
|
if (
|
||||||
|
response.status === 404 ||
|
||||||
|
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||||
|
) {
|
||||||
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
|
registration.unregister().then(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Service worker found. Proceed as normal.
|
||||||
|
registerValidSW(swUrl, config);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log('No internet connection found. App is running in offline mode.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unregister() {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.ready
|
||||||
|
.then((registration) => {
|
||||||
|
registration.unregister();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
30
pac-man-board-game/ClientApp/src/setupProxy.js
Normal file
30
pac-man-board-game/ClientApp/src/setupProxy.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const {createProxyMiddleware} = require('http-proxy-middleware');
|
||||||
|
const {env} = require('process');
|
||||||
|
|
||||||
|
const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` :
|
||||||
|
env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'http://localhost:47130';
|
||||||
|
|
||||||
|
const context = [
|
||||||
|
"/api",
|
||||||
|
];
|
||||||
|
|
||||||
|
const onError = (err, req, resp, target) => {
|
||||||
|
console.error(`${err.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function (app) {
|
||||||
|
const appProxy = createProxyMiddleware(context, {
|
||||||
|
target: target,
|
||||||
|
// Handle errors to prevent the proxy middleware from crashing when
|
||||||
|
// the ASP NET Core webserver is unavailable
|
||||||
|
onError: onError,
|
||||||
|
secure: false,
|
||||||
|
// Uncomment this line to add support for proxying websockets
|
||||||
|
//ws: true,
|
||||||
|
headers: {
|
||||||
|
Connection: 'Keep-Alive'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(appProxy);
|
||||||
|
};
|
17
pac-man-board-game/ClientApp/tsconfig.json
Normal file
17
pac-man-board-game/ClientApp/tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"compileOnSave": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noEmitOnError": true,
|
||||||
|
"removeComments": false,
|
||||||
|
"sourceMap": true,
|
||||||
|
"target": "es5",
|
||||||
|
"outDir": "wwwroot/js",
|
||||||
|
"jsx": "react",
|
||||||
|
"strict": true,
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"/**/*"
|
||||||
|
]
|
||||||
|
}
|
32
pac-man-board-game/Controllers/WeatherForecastController.cs
Normal file
32
pac-man-board-game/Controllers/WeatherForecastController.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace pac_man_board_game.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class WeatherForecastController : ControllerBase
|
||||||
|
{
|
||||||
|
private static readonly string[] Summaries =
|
||||||
|
{
|
||||||
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly ILogger<WeatherForecastController> _logger;
|
||||||
|
|
||||||
|
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IEnumerable<WeatherForecast> Get()
|
||||||
|
{
|
||||||
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||||
|
{
|
||||||
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||||
|
TemperatureC = Random.Shared.Next(-20, 55),
|
||||||
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
26
pac-man-board-game/Pages/Error.cshtml
Normal file
26
pac-man-board-game/Pages/Error.cshtml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@page
|
||||||
|
@model ErrorModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
25
pac-man-board-game/Pages/Error.cshtml.cs
Normal file
25
pac-man-board-game/Pages/Error.cshtml.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
|
||||||
|
namespace pac_man_board_game.Pages;
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public class ErrorModel : PageModel
|
||||||
|
{
|
||||||
|
private readonly ILogger<ErrorModel> _logger;
|
||||||
|
|
||||||
|
public ErrorModel(ILogger<ErrorModel> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||||
|
}
|
||||||
|
}
|
3
pac-man-board-game/Pages/_ViewImports.cshtml
Normal file
3
pac-man-board-game/Pages/_ViewImports.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@using pac_man_board_game
|
||||||
|
@namespace pac_man_board_game.Pages
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
27
pac-man-board-game/Program.cs
Normal file
27
pac-man-board-game/Program.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
|
||||||
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseWebSockets();
|
||||||
|
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.MapFallbackToFile("index.html");
|
||||||
|
|
||||||
|
app.Run();
|
29
pac-man-board-game/Properties/launchSettings.json
Normal file
29
pac-man-board-game/Properties/launchSettings.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:47130",
|
||||||
|
"sslPort": 44354
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"pac_man_board_game": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7095;http://localhost:5164",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
pac-man-board-game/WeatherForecast.cs
Normal file
12
pac-man-board-game/WeatherForecast.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace pac_man_board_game;
|
||||||
|
|
||||||
|
public class WeatherForecast
|
||||||
|
{
|
||||||
|
public DateOnly Date { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureC { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||||
|
|
||||||
|
public string? Summary { get; set; }
|
||||||
|
}
|
10
pac-man-board-game/appsettings.Development.json
Normal file
10
pac-man-board-game/appsettings.Development.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.AspNetCore.SpaProxy": "Information",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
pac-man-board-game/appsettings.json
Normal file
10
pac-man-board-game/appsettings.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
57
pac-man-board-game/pac-man-board-game.csproj
Normal file
57
pac-man-board-game/pac-man-board-game.csproj
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
|
||||||
|
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<SpaRoot>ClientApp\</SpaRoot>
|
||||||
|
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
|
||||||
|
<SpaProxyServerUrl>https://localhost:44435</SpaProxyServerUrl>
|
||||||
|
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
|
||||||
|
<RootNamespace>pac_man_board_game</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="7.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- Don't publish the SPA source files, but do show them in the project files list -->
|
||||||
|
<Content Remove="$(SpaRoot)**" />
|
||||||
|
<None Remove="$(SpaRoot)**" />
|
||||||
|
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
||||||
|
<!-- Ensure Node.js is installed -->
|
||||||
|
<Exec Command="node --version" ContinueOnError="true">
|
||||||
|
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
|
||||||
|
</Exec>
|
||||||
|
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
|
||||||
|
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
|
||||||
|
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
|
||||||
|
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
|
||||||
|
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
|
||||||
|
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
|
||||||
|
|
||||||
|
<!-- Include the newly-built files in the publish output -->
|
||||||
|
<ItemGroup>
|
||||||
|
<DistFiles Include="$(SpaRoot)build\**" />
|
||||||
|
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
|
||||||
|
<RelativePath>wwwroot\%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
</ResolvedFileToPublish>
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user