1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

WebViewPluginDemo: Add demo of WebBrowserComponent with a React GUI

This commit is contained in:
attila 2023-09-16 19:20:41 +02:00 committed by Anthony Nicholls
parent ee0aac2c75
commit bc6295d7b5
12 changed files with 2147 additions and 32 deletions

View file

@ -86,11 +86,26 @@ inline File getExamplesDirectory() noexcept
#endif
}
inline std::unique_ptr<InputStream> createAssetInputStream (const char* resourcePath)
enum class AssertAssetExists
{
no,
yes
};
inline std::unique_ptr<InputStream> createAssetInputStream (const char* resourcePath,
[[maybe_unused]] AssertAssetExists assertExists = AssertAssetExists::yes)
{
#if JUCE_ANDROID
ZipFile apkZip (File::getSpecialLocation (File::invokedExecutableFile));
return std::unique_ptr<InputStream> (apkZip.createStreamForEntry (apkZip.getIndexOfFileName ("assets/" + String (resourcePath))));
const auto fileIndex = apkZip.getIndexOfFileName ("assets/" + String (resourcePath));
if (fileIndex == -1)
{
jassert (assertExists == AssertAssetExists::no);
return {};
}
return std::unique_ptr<InputStream> (apkZip.createStreamForEntry (fileIndex));
#else
#if JUCE_IOS
auto assetsDir = File::getSpecialLocation (File::currentExecutableFile)
@ -106,7 +121,12 @@ inline std::unique_ptr<InputStream> createAssetInputStream (const char* resource
#endif
auto resourceFile = assetsDir.getChildFile (resourcePath);
jassert (resourceFile.existsAsFile());
if (! resourceFile.existsAsFile())
{
jassert (assertExists == AssertAssetExists::no);
return {};
}
return resourceFile.createInputStream();
#endif

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>WebViewPluginDemo</title>
<style type="text/css">
body {
background-color: white;
}
</style>
</head>
<body>
<h1>WebViewPluginDemo</h1>
<p>
This document is a placeholder for the GUI component of the
WebViewPluginDemo.
</p>
<p>
To build the fully fledged user interface you need to install
<a href="https://nodejs.org">node.js</a>
</p>
<p>
Then navigate into the
<code>examples/GUI/WebViewPluginDemoGUI</code> directory inside your JUCE
directory, and issue the following commands.
</p>
<pre>
npm install
npm run build
npm run zip
</pre
>
<p>
This will build the full GUI package and place it in the
<code>Assets</code> directory.
</p>
<p>After this, rebuild and restart this demo.</p>
</body>
</html>