[Cashtab] Move extension-specific functions to conditionally loaded component
Summary:
Depends on D14989
Add extension-specific logic to its own component. Load this component if env var is for building the extension.
Initially I tried to split this into several diffs, as there are multiple changes required to maintain extension functionality with only one App.js file. However, it's not practical to test these incremental changes, and each one in isolation would break either the prod app or the extension App.js.
So, this diff does "one thing" -- make the extension and the Cashtab web app build from a single App.js file, depending on the presence of an env var at build time.
To do this one thing,
If extension env var is present at build time...
- Include extension-specific css rules with new <ExtensionFrame/> component
- Include extension-specific address sharing logic with new <Extension/> component
If extension env var is NOT PRESENT at build time...
- Include routes to Swap page (extension cannot support this as it relies on external code)
- Support desktop-only easter egg
- Include webapp service worker, <ServiceWorkerWrapper />
extension/src/App.js is deleted. The script extension.sh is modified so that only manifest.json is exchanged at build time.
For this file -- it makes sense to maintain two files because they really are totally different. chrome has manifest.json rules specific to chrome extensions (specifying things like required permission, published version number, manifest version which determines which chrome APIs are available) and react apps have their own rules (for Cashtab, this file is really just specifying the favicon and PWA icon). Changing one version of the manifest.json file does not imply any need to maintain or change the other version at the same time (unlike App.js). Arguably the build script could be optimized so we don't need to move files around at build time, but this should be done in another diff.
Test Plan:
Test that webapp functionality is preserved
npm start
Confirm swap components are present
Test that extension functionality is preserved
npm run extension
Confirm the extension opens with expected dimensions
Confirm you can click the top right "open" logo and it opens in a new tab at the page that was active
Navigate to components.cashtab.com and use the "Get Address" component to confirm the address is still available from the extension
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14990