Skip to content

Commit

Permalink
fix: peak finder fix
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Jan 2, 2025
1 parent 1b78de8 commit 04d9340
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
15 changes: 14 additions & 1 deletion app/assets/peakfinder/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<!doctype html><html><head><meta charset="UTF-8"/><meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/><script defer="defer" src="webapp.js"></script><link href="main.css" rel="stylesheet"></head><body><video id="video" autoplay playsinline></video><canvas id="canvas" class="canvas"></canvas><canvas id="canvas4" class="canvas"></canvas><div id="compass" onclick="webapp.stopEventPropagation(event);webapp.setAzimuth(0)"><div id="compass_slice"></div></div><div id="camera_button" onclick="webapp.stopEventPropagation(event);webapp.toggleCamera()" style="visibility:hidden;"></div></body></html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link href="main.css" rel="stylesheet"></head><body>
<video id="video" autoplay playsinline></video>
<canvas id="canvas" class="canvas"></canvas>
<canvas id="canvas4" class="canvas"></canvas>
<div id="compass" onclick="webapp.stopEventPropagation(event);webapp.setAzimuth(0)">
<div id="compass_slice"></div>
</div>
<div id="camera_button" onclick="webapp.stopEventPropagation(event);webapp.toggleCamera()" style="visibility:hidden;">
</button><script src="webapp.js"></script></body></html>
13 changes: 7 additions & 6 deletions app/components/peaks/PeakFinder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@
webView.nativeView.src = '~/assets/peakfinder/index.html';
}
}
let webViewLoaded = false;
function webviewLoaded(args: LoadEventData) {
const webview = args.object as AWebView;
webview.once(AWebView.loadFinishedEvent, (args: LoadFinishedEventData) => {
const startValues = {
terrarium,
secondsInDay,
setPosition: { ...position, altitude: currentAltitude },
setAzimuth: bearing
};
Expand All @@ -104,6 +105,7 @@
startValues[item.key || item['method']] = item.value as number;
});
args.object.executeJavaScript(`webapp.callMethods(${JSON.stringify(startValues)});`);
webViewLoaded = true;
});
webview.on('requestPermissions', async (args: any) => {
Expand Down Expand Up @@ -143,10 +145,10 @@
function callJSFunction(method: string, ...args) {
// if (DEV_LOG) {
// console.log('callJSFunction', method, `webapp.${method}(${args ? args.map((s) => (typeof s === 'string' ? `"${s}"` : s)).join(',') : ''})`);
// console.log('callJSFunction', method, `webapp.${method}(${args ? args.map((s) => (typeof s === 'string' ? `"${s}"` : s)).join(',') : ''})`, new Error().stack);
// }
const nView = webView?.nativeView;
if (!nView) {
if (!nView || !webViewLoaded) {
return;
}
try {
Expand Down Expand Up @@ -395,9 +397,8 @@
// Your logic here
return item.type;
}
$: {
callJSFunction('setDate', secondsInDay);
}
$: callJSFunction('setSettings', 'secondsInDay', secondsInDay);
$: currentAltitude = position.altitude;
$: updateElevation(currentAltitude);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@
"minisearch": "7.1.1",
"nativescript-social-share": "1.6.0",
"opening_hours": "3.8.0",
"postprocessing": "6.36.4",
"postprocessing": "6.23.3",
"push-it-to-the-limit": "2.0.1",
"stats.js": "0.17.0",
"stream": "0.0.3",
"suncalc": "^1.9.0",
"svelte-native": "1.0.29",
"three": "0.171.0",
"three": "0.135.0",
"timers": "0.1.1",
"xmldom": "^0.6.0"
},
Expand All @@ -136,7 +136,7 @@
"@types/geojson": "^7946.0.14",
"@types/offscreencanvas": "^2019.7.3",
"@types/suncalc": "^1.9.2",
"@types/three": "^0.170.0",
"@types/three": "^0.171.0",
"fast-xml-parser": "^4.5.0",
"merge-properties-files": "^1.1.6",
"mini-css-extract-plugin": "^2.9.2",
Expand Down
1 change: 1 addition & 0 deletions peakfinder/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ module.exports = (env = {}, params = {}) => {
}),
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin({
scriptLoading:'blocking',
template: path.resolve(__dirname, 'public/index.html')
})
],
Expand Down

0 comments on commit 04d9340

Please sign in to comment.