oops first commit
This commit is contained in:
commit
c457dfe7da
17 changed files with 7509 additions and 0 deletions
92
.gitignore
vendored
Normal file
92
.gitignore
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
.DS_Store
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Webpack
|
||||
.webpack/
|
||||
|
||||
# Vite
|
||||
.vite/
|
||||
|
||||
# Electron-Forge
|
||||
out/
|
48
forge.config.js
Normal file
48
forge.config.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
module.exports = {
|
||||
packagerConfig: {},
|
||||
rebuildConfig: {},
|
||||
makers: [
|
||||
{
|
||||
name: '@electron-forge/maker-squirrel',
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-zip',
|
||||
platforms: ['darwin'],
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-deb',
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-rpm',
|
||||
config: {},
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
{
|
||||
name: '@electron-forge/plugin-vite',
|
||||
config: {
|
||||
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
|
||||
// If you are familiar with Vite configuration, it will look really familiar.
|
||||
build: [
|
||||
{
|
||||
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
|
||||
entry: 'src/main.js',
|
||||
config: 'vite.main.config.mjs',
|
||||
},
|
||||
{
|
||||
entry: 'src/preload.js',
|
||||
config: 'vite.preload.config.mjs',
|
||||
},
|
||||
],
|
||||
renderer: [
|
||||
{
|
||||
name: 'main_window',
|
||||
config: 'vite.renderer.config.mjs',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
72
index.html
Normal file
72
index.html
Normal file
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>ED Safari v0.0.1</title>
|
||||
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" crossorigin="anonymous">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- CURRENT LOCATION -->
|
||||
<div class="container-fluid">
|
||||
<div class="row separator align-items-center">
|
||||
<div class="col"><hr class="separator"></div>
|
||||
<div class="col-auto">Current Location</div>
|
||||
<div class="col"><hr class="separator"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- table header -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 separator">
|
||||
<div class="col-3 text-center">Name</div>
|
||||
<div class="col">Type</div>
|
||||
<div class="col-auto text-center">Distance</div>
|
||||
<div class="col-1 text-center">Details</div>
|
||||
<div class="col-2 text-center">Mapped Value</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- system name -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1">
|
||||
<div id="currentLocation" :class="['col', 'system', {charted: currentLocation !== 'Unknown', highlighted: currentLocation === 'Unknown', 'text-center': currentLocation === 'Unknown'}]">
|
||||
{{ currentLocation }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- high-value scans -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 align-items-center"></div>
|
||||
</div>
|
||||
<!-- low-value scans -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 align-items-center"></div>
|
||||
</div>
|
||||
<!-- NAV ROUTE -->
|
||||
<div class="container-fluid">
|
||||
<div class="row separator align-items-center">
|
||||
<div class="col"><hr class="separator"></div>
|
||||
<div class="col-auto">Nav Route</div>
|
||||
<div class="col"><hr class="separator"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- table header -->
|
||||
<div class="container-fluid">
|
||||
<div class="row ml-1 mr-1 separator">
|
||||
<div class="col-1 text-right">LY</div>
|
||||
<div class="col-3 text-center">Name</div>
|
||||
<div class="col">Type</div>
|
||||
<div class="col-2 text-center">Mapped Value</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row separator align-items-center">
|
||||
<div class="col"><hr class="seperator"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/src/renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
30
journal examples.txt
Normal file
30
journal examples.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
COMPLETED SYSTEM DISCOVERY SCAN
|
||||
{ "timestamp":"2023-05-08T19:08:58Z", "event":"FSSDiscoveryScan", "Progress":1.000000, "BodyCount":22, "NonBodyCount":42, "SystemName":"LHS 112", "SystemAddress":7267487327649 }
|
||||
|
||||
COMPLETED SYSTEM FSS SCAN
|
||||
{ "timestamp":"2023-05-08T19:18:56Z", "event":"FSSAllBodiesFound", "SystemName":"LHS 551", "SystemAddress":22660650050977, "Count":7 }
|
||||
|
||||
UNCOMPLETE DISCOVERY SCAN
|
||||
{ "timestamp":"2023-05-08T19:17:44Z", "event":"FSSDiscoveryScan", "Progress":0.239641, "BodyCount":7, "NonBodyCount":17, "SystemName":"LHS 551", "SystemAddress":22660650050977 }
|
||||
|
||||
AUTO SCAN
|
||||
{ "timestamp":"2023-05-08T19:13:58Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"LHS 119 A", "BodyID":1, "Parents":[ {"Null":0} ], "StarSystem":"LHS 119", "SystemAddress":18262603605409, "DistanceFromArrivalLS":0.000000, "StarType":"M", "Subclass":4, "StellarMass":0.214844, "Radius":267243648.000000, "AbsoluteMagnitude":11.148788, "Age_MY":11724, "SurfaceTemperature":2175.000000, "Luminosity":"V", "SemiMajorAxis":3448964357376.098633, "Eccentricity":0.010115, "OrbitalInclination":-105.666674, "Periapsis":272.289207, "OrbitalPeriod":18957803249.359131, "AscendingNode":-65.823206, "MeanAnomaly":326.300292, "RotationPeriod":131207.524554, "AxialTilt":0.000000, "WasDiscovered":true, "WasMapped":false }
|
||||
|
||||
DISCOVERY SCAN - DISCOVERED STAR
|
||||
{ "timestamp":"2023-05-08T19:16:19Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"V439 Andromedae B", "BodyID":2, "Parents":[ {"Null":0} ], "StarSystem":"V439 Andromedae", "SystemAddress":2282808677074, "DistanceFromArrivalLS":9823.421969, "StarType":"G", "Subclass":4, "StellarMass":0.894531, "Radius":641376256.000000, "AbsoluteMagnitude":5.081848, "Age_MY":8408, "SurfaceTemperature":5678.000000, "Luminosity":"Vab", "SemiMajorAxis":1226380169391.632080, "Eccentricity":0.205087, "OrbitalInclination":42.869302, "Periapsis":318.335747, "OrbitalPeriod":1559399366.378784, "AscendingNode":108.884004, "MeanAnomaly":170.879935, "RotationPeriod":461309.851688, "AxialTilt":0.000000, "WasDiscovered":true, "WasMapped":false }
|
||||
|
||||
FSS SCAN - DISCOVERED BODY
|
||||
{ "timestamp":"2023-05-08T19:18:10Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"LHS 551 3", "BodyID":3, "Parents":[ {"Star":0} ], "StarSystem":"LHS 551", "SystemAddress":22660650050977, "DistanceFromArrivalLS":1145.828346, "TidalLock":false, "TerraformState":"", "PlanetClass":"Icy body", "Atmosphere":"neon rich atmosphere", "AtmosphereType":"NeonRich", "AtmosphereComposition":[ { "Name":"Helium", "Percent":97.112808 }, { "Name":"Neon", "Percent":2.887197 } ], "Volcanism":"minor ammonia magma volcanism", "MassEM":0.786165, "Radius":7230740.000000, "SurfaceGravity":5.993182, "SurfaceTemperature":40.704479, "SurfacePressure":15131.975586, "Landable":false, "Composition":{ "Ice":0.682992, "Rock":0.211345, "Metal":0.105663 }, "SemiMajorAxis":343500107526.779175, "Eccentricity":0.004332, "OrbitalInclination":0.041314, "Periapsis":315.505986, "OrbitalPeriod":217869794.368744, "AscendingNode":1.173041, "MeanAnomaly":90.159583, "RotationPeriod":49998.912442, "AxialTilt":-0.036086, "WasDiscovered":true, "WasMapped":true }
|
||||
|
||||
DETAILED SURFACE SCAN - MAPPED BODY
|
||||
{ "timestamp":"2023-05-08T19:22:20Z", "event":"SAAScanComplete", "BodyName":"LHS 551 1", "SystemAddress":22660650050977, "BodyID":1, "ProbesUsed":8, "EfficiencyTarget":8 }
|
||||
{ "timestamp":"2023-05-08T19:22:21Z", "event":"Scan", "ScanType":"Detailed", "BodyName":"LHS 551 1", "BodyID":1, "Parents":[ {"Star":0} ], "StarSystem":"LHS 551", "SystemAddress":22660650050977, "DistanceFromArrivalLS":578.392122, "TidalLock":false, "TerraformState":"", "PlanetClass":"Rocky ice body", "Atmosphere":"helium atmosphere", "AtmosphereType":"Helium", "AtmosphereComposition":[ { "Name":"Helium", "Percent":89.334976 }, { "Name":"Hydrogen", "Percent":8.427828 }, { "Name":"Neon", "Percent":2.237205 } ], "Volcanism":"major water geysers volcanism", "MassEM":4.158691, "Radius":10698825.000000, "SurfaceGravity":14.480845, "SurfaceTemperature":58.117901, "SurfacePressure":67337.343750, "Landable":false, "Composition":{ "Ice":0.403397, "Rock":0.397748, "Metal":0.198856 }, "SemiMajorAxis":173410028219.223022, "Eccentricity":0.000081, "OrbitalInclination":-0.013599, "Periapsis":290.186625, "OrbitalPeriod":78148038.387299, "AscendingNode":-3.343060, "MeanAnomaly":332.810795, "RotationPeriod":157634.536311, "AxialTilt":0.224570, "WasDiscovered":true, "WasMapped":true }
|
||||
|
||||
START HYPERSPACE JUMP
|
||||
{ "timestamp":"2023-05-08T19:11:12Z", "event":"StartJump", "JumpType":"Hyperspace", "StarSystem":"LHS 6427", "SystemAddress":22660650116513, "StarClass":"M" }
|
||||
|
||||
COMPLETE HYPERSPACE JUMP - POPULATED SYSTEM
|
||||
{ "timestamp":"2023-05-08T19:11:30Z", "event":"FSDJump", "Taxi":false, "Multicrew":false, "StarSystem":"LHS 6427", "SystemAddress":22660650116513, "StarPos":[-33.25000,-19.78125,-9.53125], "SystemAllegiance":"Independent", "SystemEconomy":"$economy_Refinery;", "SystemEconomy_Localised":"Refinery", "SystemSecondEconomy":"$economy_Industrial;", "SystemSecondEconomy_Localised":"Industrial", "SystemGovernment":"$government_Cooperative;", "SystemGovernment_Localised":"Cooperative", "SystemSecurity":"$SYSTEM_SECURITY_high;", "SystemSecurity_Localised":"High Security", "Population":12393389, "Body":"LHS 6427 A", "BodyID":1, "BodyType":"Star", "JumpDist":5.919, "FuelUsed":0.354367, "FuelLevel":127.645630, "Factions":[ { "Name":"People's LHS 6427 Free", "FactionState":"None", "Government":"Democracy", "Influence":0.092092, "Allegiance":"Federation", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 }, { "Name":"LHS 6427 Constitution Party", "FactionState":"None", "Government":"Dictatorship", "Influence":0.038038, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 }, { "Name":"LHS 6427 Industry", "FactionState":"Boom", "Government":"Corporate", "Influence":0.219219, "Allegiance":"Federation", "Happiness":"$Faction_HappinessBand1;", "Happiness_Localised":"Elated", "MyReputation":0.000000, "RecoveringStates":[ { "State":"PirateAttack", "Trend":0 } ], "ActiveStates":[ { "State":"Boom" }, { "State":"CivilLiberty" } ] }, { "Name":"Bureau of LHS 6427 Autocracy", "FactionState":"None", "Government":"Dictatorship", "Influence":0.055055, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 }, { "Name":"LHS 6427 Universal Partners", "FactionState":"None", "Government":"Corporate", "Influence":0.072072, "Allegiance":"Federation", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 }, { "Name":"Teaka Elite Altruists Bagging Cooperative", "FactionState":"None", "Government":"Cooperative", "Influence":0.493493, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 }, { "Name":"Sneak Squadron", "FactionState":"None", "Government":"Dictatorship", "Influence":0.030030, "Allegiance":"Independent", "Happiness":"$Faction_HappinessBand2;", "Happiness_Localised":"Happy", "MyReputation":0.000000 } ], "SystemFaction":{ "Name":"Teaka Elite Altruists Bagging Cooperative" } }
|
||||
|
||||
COMPLETE HYPERSPACE JUMP - UNPOPULATED SYSTEM
|
||||
{ "timestamp":"2023-05-08T19:13:52Z", "event":"FSDJump", "Taxi":false, "Multicrew":false, "StarSystem":"LHS 119", "SystemAddress":18262603605409, "StarPos":[-30.15625,-21.87500,-17.25000], "SystemAllegiance":"", "SystemEconomy":"$economy_None;", "SystemEconomy_Localised":"None", "SystemSecondEconomy":"$economy_None;", "SystemSecondEconomy_Localised":"None", "SystemGovernment":"$government_None;", "SystemGovernment_Localised":"None", "SystemSecurity":"$GAlAXY_MAP_INFO_state_anarchy;", "SystemSecurity_Localised":"Anarchy", "Population":0, "Body":"LHS 119 A", "BodyID":1, "BodyType":"Star", "JumpDist":8.575, "FuelUsed":0.982384, "FuelLevel":127.017616 }
|
6866
package-lock.json
generated
Normal file
6866
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
37
package.json
Normal file
37
package.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "ed-safari",
|
||||
"productName": "ed-safari",
|
||||
"version": "1.0.0",
|
||||
"description": "My Electron application description",
|
||||
"main": ".vite/build/main.js",
|
||||
"scripts": {
|
||||
"start": "electron-forge start",
|
||||
"package": "electron-forge package",
|
||||
"make": "electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "echo \"No linting configured\""
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
"name": "punkfairie",
|
||||
"email": "marleyrae1997@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.1.1",
|
||||
"@electron-forge/maker-deb": "^6.1.1",
|
||||
"@electron-forge/maker-rpm": "^6.1.1",
|
||||
"@electron-forge/maker-squirrel": "^6.1.1",
|
||||
"@electron-forge/maker-zip": "^6.1.1",
|
||||
"@electron-forge/plugin-vite": "^6.1.1",
|
||||
"electron": "24.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chokidar": "^3.5.3",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"glob": "^10.2.2",
|
||||
"lodash": "^4.17.21",
|
||||
"reverse-line-reader": "^0.2.6",
|
||||
"tail": "^2.2.6"
|
||||
}
|
||||
}
|
BIN
src/Eurostile-Roman.woff
Normal file
BIN
src/Eurostile-Roman.woff
Normal file
Binary file not shown.
BIN
src/Eurostile-Roman.woff2
Normal file
BIN
src/Eurostile-Roman.woff2
Normal file
Binary file not shown.
144
src/index.css
Normal file
144
src/index.css
Normal file
|
@ -0,0 +1,144 @@
|
|||
@font-face {
|
||||
font-family: 'Eurostile-Roman';
|
||||
src: local('Eurostile-Roman'),
|
||||
url('Eurostile-Roman.woff2') format('woff2'),
|
||||
url('Eurostile-Roman.woff') format('woff');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color:black;
|
||||
font: 20px Eurostile, sans-serif;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.system {
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
padding-left: 10px;
|
||||
text-shadow: 0px 0px 3px;
|
||||
margin-left: 1px;
|
||||
margin-right: 1px;
|
||||
}
|
||||
.charted {
|
||||
color: #9f9f9f;
|
||||
background: #333333;
|
||||
}
|
||||
.uncharted {
|
||||
color: #EAA529;
|
||||
background: #370C03;
|
||||
}
|
||||
|
||||
.hyperspace {
|
||||
color: #0026FF;
|
||||
}
|
||||
.statusInfo {
|
||||
color: #EAA529;
|
||||
background: #370C03;
|
||||
}
|
||||
.inactive {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.ring {
|
||||
font-size: smaller;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.ring-separator {
|
||||
font-size: smaller;
|
||||
padding: 0px;
|
||||
position: relative;
|
||||
top: -3px;
|
||||
}
|
||||
|
||||
div.highlighted b.active {
|
||||
color: #000000;
|
||||
}
|
||||
div.highlighted b.inactive {
|
||||
color: #F5A804;
|
||||
}
|
||||
div.uncharted b.active {
|
||||
color: #EAA529;
|
||||
}
|
||||
div.uncharted b.inactive {
|
||||
color: #370C03;
|
||||
}
|
||||
div.charted b.active {
|
||||
color: #9f9f9f;
|
||||
}
|
||||
div.charted b.inactive {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.highlighted {
|
||||
color: #370C03;
|
||||
background: #F5A804;
|
||||
}
|
||||
|
||||
div b.active.landable {
|
||||
color:#4CE0E1;
|
||||
}
|
||||
|
||||
.currentSystemHighlight {
|
||||
background: #17EFF9;
|
||||
}
|
||||
|
||||
.current_location {
|
||||
border-style: dotted;
|
||||
border-color: #17EFF9;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.latest-scan {
|
||||
border-style: dotted;
|
||||
border-color: #F5A804;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.separator {
|
||||
color: #F5A804;
|
||||
border-color: #F5A804;
|
||||
border-width: 1px 0px 1px 0px;
|
||||
text-shadow: 0px 0px 3px;
|
||||
}
|
||||
|
||||
.next-system {
|
||||
color: #17EFF9;
|
||||
}
|
||||
|
||||
.next-system hr {
|
||||
border-color: #17EFF9;
|
||||
}
|
||||
|
||||
.alert {
|
||||
top: 1em;
|
||||
bottom: 1em;
|
||||
}
|
||||
|
||||
.gravity-indicator {
|
||||
background-color: #000;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.gravity-good {
|
||||
color: #0F0;
|
||||
}
|
||||
|
||||
.gravity-alert {
|
||||
color: #F00;
|
||||
}
|
||||
|
||||
.gravity-warning {
|
||||
color: #F60;
|
||||
}
|
||||
|
||||
.gravity-hidden {
|
||||
color: #00000000;
|
||||
background-color: #00000000;
|
||||
}
|
18
src/interfaces/EDSMInterface.js
Normal file
18
src/interfaces/EDSMInterface.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
class EDSM {
|
||||
constructor() {
|
||||
this.data = {}
|
||||
this.dataError = false
|
||||
}
|
||||
|
||||
request(url) {
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('HTTP error' + response.status)
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.then(json => this.data = json)
|
||||
.catch(() => this.dataError = true)
|
||||
}
|
||||
}
|
83
src/interfaces/JournalInterface.js
Normal file
83
src/interfaces/JournalInterface.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
const EventEmitter = require('events')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const max = require('lodash/max')
|
||||
const { globSync } = require('glob')
|
||||
const os = require('os')
|
||||
const lineReader = require('reverse-line-reader')
|
||||
const chokidar = require('chokidar')
|
||||
const Tail = require('tail').Tail
|
||||
|
||||
export class JournalInterface extends EventEmitter {
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
// this.journalDir = os.homedir() + 'Saved Games\\Frontier Developments\\Elite Dangerous'
|
||||
this.journalDir = "/mnt/c/Users/marle/Saved\ Games/Frontier\ Developments/Elite\ Dangerous/"
|
||||
this.journalPattern = this.journalDir + "Journal.*.log"
|
||||
|
||||
this.current = this.getLatestJournal()
|
||||
|
||||
this.currentLocation = null
|
||||
|
||||
console.log('JournalInterface initialized. Attempting to find current location.')
|
||||
this.getCurrentLocation()
|
||||
}
|
||||
|
||||
async getCurrentLocation() {
|
||||
lineReader.eachLine(this.current, (raw, last) => {
|
||||
if (raw) {
|
||||
const line = JSON.parse(raw)
|
||||
|
||||
if (line.event === 'FSDJump') {
|
||||
this.currentLocation = line.StarSystem
|
||||
return false
|
||||
} else if (last) {
|
||||
console.log('Error: unable to find last hyperspace jump. Current location unknown.')
|
||||
return false
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
this.emit('FSDJump')
|
||||
console.log(`Current location set to ${this.currentLocation}.`)
|
||||
})
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/15696218/get-the-most-recent-file-in-a-directory-node-js
|
||||
getLatestJournal() {
|
||||
const journals = globSync(this.journalPattern)
|
||||
|
||||
return max(journals, file => {
|
||||
const fullPath = path.join(this.journalDir, file)
|
||||
return fs.statSync(fullPath).mtime
|
||||
})
|
||||
|
||||
console.log('New journal file found, now watching ' + path.basename(this.current))
|
||||
}
|
||||
|
||||
watchDirectory() {
|
||||
const watcher = chokidar.watch(this.journalPattern, {usePolling: true, persistent: true})
|
||||
|
||||
watcher.on('add', newFile => this.current = this.getLatestJournal())
|
||||
|
||||
console.log('Watching journal folder for changes...')
|
||||
}
|
||||
|
||||
parseLine(raw) {
|
||||
const line = JSON.parse(raw)
|
||||
|
||||
if (line.event === 'FSDJump') {
|
||||
this.currentLocation = line.StarSystem
|
||||
this.emit('FSDJump')
|
||||
}
|
||||
}
|
||||
|
||||
watch() {
|
||||
const tail = new Tail(this.current, {useWatchFile: true})
|
||||
|
||||
console.log(`Watching ${path.basename(this.current)}...`)
|
||||
|
||||
tail.on('line', data => this.parseLine(data))
|
||||
tail.on('error', err => console.log(err))
|
||||
}
|
||||
}
|
55
src/main.js
Normal file
55
src/main.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1000,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
||||
mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
|
||||
} else {
|
||||
mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));
|
||||
}
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
};
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and import them here.
|
2
src/preload.js
Normal file
2
src/preload.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
// See the Electron documentation for details on how to use preload scripts:
|
||||
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
50
src/renderer.js
Normal file
50
src/renderer.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* This file will automatically be loaded by vite and run in the "renderer" context.
|
||||
* To learn more about the differences between the "main" and the "renderer" context in
|
||||
* Electron, visit:
|
||||
*
|
||||
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
|
||||
*
|
||||
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
|
||||
* in a renderer process, please be aware of potential security implications. You can read
|
||||
* more about security risks here:
|
||||
*
|
||||
* https://electronjs.org/docs/tutorial/security
|
||||
*
|
||||
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
|
||||
* flag:
|
||||
*
|
||||
* ```
|
||||
* // Create the browser window.
|
||||
* mainWindow = new BrowserWindow({
|
||||
* width: 800,
|
||||
* height: 600,
|
||||
* webPreferences: {
|
||||
* nodeIntegration: true
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
|
||||
import './index.css'
|
||||
|
||||
import { createApp, ref } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
|
||||
|
||||
import { JournalInterface } from './interfaces/JournalInterface'
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
const journal = new JournalInterface
|
||||
|
||||
journal.watchDirectory()
|
||||
journal.watch()
|
||||
|
||||
const currentLocation = ref('Unknown')
|
||||
|
||||
journal.on('FSDJump', () => currentLocation.value = journal.currentLocation)
|
||||
|
||||
return {
|
||||
currentLocation
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
4
vite.main.config.mjs
Normal file
4
vite.main.config.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { defineConfig } from 'vite';
|
||||
|
||||
// https://vitejs.dev/config
|
||||
export default defineConfig({});
|
4
vite.preload.config.mjs
Normal file
4
vite.preload.config.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { defineConfig } from 'vite';
|
||||
|
||||
// https://vitejs.dev/config
|
||||
export default defineConfig({});
|
4
vite.renderer.config.mjs
Normal file
4
vite.renderer.config.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { defineConfig } from 'vite';
|
||||
|
||||
// https://vitejs.dev/config
|
||||
export default defineConfig({});
|
Loading…
Reference in a new issue