breautek edited a comment on issue #398:
URL: https://github.com/apache/cordova-windows/issues/398#issuecomment-951482318


   > why is the most core functionality (loading an html file with 1 image) not 
consistent with the browser and the way web apps are served?
   
   It is consistent. Cordova doesn't handle file paths, it just tells the 
underlying webview what file path to load. If you're loading a filepath from 
the `file://` protocol then the "root" directory is always relative to the 
filesystem, which in windows case, it's the drive's root. If you wanted to load 
an image file, you'd either need the full absolute path to that image, or a 
relative path relative to the HTML document.
   
   > maybe I am naïve here, but this seems like a major oversight in 
design/principles 
   
   I'll admit that I'm not all that familiar with the windows platform 
specifically. iOS platform implements an iOS-specific API called 
[WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler?language=objc),
 and our android platform implements something called 
[WebViewAssetLoader](https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader),
 which essentially makes the web app origin `app://localhost` and 
`https://localhost` respectfully, which is sounds like what you're asking for 
the windows platform (because the absolute paths will be relative to the origin 
`https://localhost`), but afaik Windows underlying webview does not provide any 
equivalent API. 
   
   I actually had a [brief 
discussion](https://github.com/apache/cordova-android/pull/1137#issuecomment-736788006)
 on routing when talking about the Android platform when the WebViewAssetLoader 
was implemented but it was decided that URL rewriting/routing is an application 
detail and not something Cordova should be responsible for.
   
   > cordova's main use case is packaging web apps into cross platform native 
apps.
   
   Yes, meaning that you can use web technologies to write a functional 
application and for it to be deployed through the native app stores. It doesn't 
mean an app can simply be copied from a hosted web server into a cordova 
container and for it to work out the box. For simple applications this may 
work, but for most applications this you probably won't get very far without 
writing many cordova-app specific code.
   
   > Lastly, do you know of any plugins/competing technologies that may handle 
route translation on the device side? 
   
   No I'm not aware of any plugins. if you use the History API to fake the url 
path for a particular route, if the webview tries to reload that page it will 
fail. That's why hash-bash routing is recommended for Cordova apps, so the 
filepath can remain as your main/physical index.html file. There is no "server 
side logic" when it comes to serving HTML in cordova apps.
   
   Last tid bit of insider knowledge... it hasn't been announced on our blog 
yet, but the Windows platform (as well as OSX) are both going to become 
deprecated with the electron platform as it's replacement -- but I don't think 
electron platform has a solution that you're looking for either unfortunately.
   
   Edit: I guess the electron platform does have scheme support provided in 
https://github.com/apache/cordova-electron/pull/154


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to