Summary: This diff makes flipper-server stand-alone servable as a single package. It basically works as follows: - (default) plugins are build as usually into static folder - static folder is copied into flipper-server/static (as far as relevant) - `flipper-server/src/index.tsx` is bundled into `flipper-server/dist/index.js` - `flipper-ui-browser/src/index.tsx` is bundled into `flipper-server/static/bundle.js` If flipper-server is started without the `--bundler` config, the `bundle.js` will be served statically, rather than starting up the Metro bundler with all the typical transforms (in a distributed version of the package those all wouldn't resolve) Things to be done in next diffs: * make sure plugins actually load in the non bundled setup * make sure flipper-server gets published properly * make sure build is created as part of CI At the end of this stack, running `npx flipper-server` on any machine should basically be a viable approach to get flipper up and running locally :) Reviewed By: nikoant Differential Revision: D33171107 fbshipit-source-id: 4af8ac2699467a0b55283fe084640482700744c2
127 lines
3.2 KiB
HTML
127 lines
3.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="style.css">
|
|
<link id="flipper-theme-import" rel="stylesheet">
|
|
<title>Flipper</title>
|
|
<script>
|
|
window.flipperConfig = {
|
|
theme: 'light',
|
|
entryPoint: 'bundle.js',
|
|
debug: false,
|
|
}
|
|
</script>
|
|
<style>
|
|
|
|
#loading {
|
|
-webkit-app-region: drag;
|
|
z-index: 999999;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
bottom: 0;
|
|
right: 0;
|
|
padding: 50px;
|
|
overflow: auto;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 20px;
|
|
color: #525252;
|
|
text-align: center;
|
|
}
|
|
|
|
.__infinity-dev-box-error {
|
|
background-color: red;
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
z-index: 10;
|
|
bottom: 0;
|
|
left: 0;
|
|
position: absolute;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root">
|
|
<div id="loading">
|
|
Loading...
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="__infinity-dev-box __infinity-dev-box-error" hidden>
|
|
|
|
</div>
|
|
|
|
<script src="/socket.io/socket.io.js"></script>
|
|
|
|
<script>
|
|
(function() {
|
|
// FIXME: needed to make Metro work
|
|
window.global = window;
|
|
let suppressErrors = false;
|
|
|
|
const socket = io(location.origin);
|
|
|
|
socket.on('refresh', () => {
|
|
location.reload();
|
|
});
|
|
|
|
socket.on('hasErrors', (html) => {
|
|
openError(html);
|
|
suppressErrors = true;
|
|
});
|
|
|
|
|
|
function openError(text) {
|
|
if (suppressErrors) {
|
|
return;
|
|
}
|
|
|
|
const box = document.querySelector('.__infinity-dev-box-error');
|
|
box.removeAttribute('hidden');
|
|
box.textContent = text;
|
|
box.appendChild(closeButton);
|
|
}
|
|
window.flipperShowError = openError;
|
|
window.flipperHideError = () => {
|
|
const box = document.querySelector('.__infinity-dev-box-error');
|
|
box.setAttribute('hidden', true);
|
|
}
|
|
|
|
const closeButton = document.createElement('button');
|
|
closeButton.addEventListener('click', window.flipperHideError);
|
|
closeButton.textContent = 'X';
|
|
|
|
// load correct theme (n.b. this doesn't handle system value specifically, will assume light in such cases)
|
|
try {
|
|
if (window.flipperConfig.theme === 'dark') {
|
|
document.getElementById('flipper-theme-import').href="themes/dark.css";
|
|
} else {
|
|
document.getElementById('flipper-theme-import').href="themes/light.css";
|
|
}
|
|
} catch(e) {
|
|
console.error("Failed to initialize theme", e);
|
|
document.getElementById('flipper-theme-import').href="themes/light.css";
|
|
}
|
|
|
|
function init() {
|
|
const script = document.createElement('script');
|
|
script.src = window.flipperConfig.entryPoint;
|
|
|
|
script.onerror = (e) => {
|
|
openError('Script failure. Check Chrome console for more info.');
|
|
};
|
|
|
|
document.body.appendChild(script);
|
|
}
|
|
init();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|