#![warn(clippy::all, rust_2018_idioms)]#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]// hide console window on Windows in release// When compiling natively:#[cfg(not(target_arch = "wasm32"))]fnmain()->eframe::Result<()>{env_logger::init();// Log to stderr (if you run with `RUST_LOG=debug`).let native_options =eframe::NativeOptions::default();eframe::run_native("demo app",// `eframe template` to `demo app`native_options,Box::new(|cc|Box::new(demo_app::TemplateApp::new(cc))),// `eframe_template::TemplateApp` to `demo_app::TemplateApp`)}// When compiling to web using trunk:#[cfg(target_arch = "wasm32")]fnmain(){// Redirect `log` message to `console.log` and friends:eframe::WebLogger::init(log::LevelFilter::Debug).ok();let web_options =eframe::WebOptions::default();wasm_bindgen_futures::spawn_local(async{eframe::WebRunner::new().start("the_canvas_id",// hardcode itweb_options,Box::new(|cc|Box::new(demo_app::TemplateApp::new(cc))),// `eframe_template::TemplateApp` to `demo_app::TemplateApp`).await.expect("failed to start eframe");});}
var cacheName ='egui-template-pwa';var filesToCache =['./','./index.html','./demo_app.js','./demo_app_bg.wasm',];/* Start the service worker and cache all of the app's content */
self.addEventListener('install',function(e){e.waitUntil(caches.open(cacheName).then(function(cache){return cache.addAll(filesToCache);}));});/* Serve cached content when offline */
self.addEventListener('fetch',function(e){e.respondWith(caches.match(e.request).then(function(response){return response ||fetch(e.request);}));});