gluworld: update for gluon 5.0

This commit is contained in:
CanadaHonk 2022-12-12 19:31:10 +00:00
parent 0a1241ca88
commit 879a2431e2
2 changed files with 76 additions and 14 deletions

View File

@ -6,23 +6,28 @@
<title>Gluworld</title> <title>Gluworld</title>
</head> </head>
<body> <body>
<h1> <h1 id="main">
Gluon <code id="gluon_version"></code> <br> Gluon <code id="gluon_version"></code> <br>
built with <code id="builder"></code> <br> <span id="built_with">built with <code id="builder"></code> <br></span>
running on <code id="product"></code> running on <code id="product"></code>
</h1> </h1>
<div id="versions"> <div id="versions">
<h2> <h2>
Chromium <br> <span id="engine_name"></span> <br>
<code id="chromium_version"></code> <br> <code id="browser_version"></code> <br>
<span>V8 <code id="chromium_v8"></code></span> <p><span id="js_engine_name"></span> <code id="browser_v8"></code></p>
</h2>
<h2 id="build">
Build Size <br>
<code id="build_size"></code>
</h2> </h2>
<h2> <h2>
Node <br> Node <br>
<code id="node_version"></code> <br> <code id="node_version"></code> <br>
<span>V8 <code id="node_v8"></code></span> <p>V8 <code id="node_v8"></code></p>
</h2> </h2>
</div> </div>
@ -59,7 +64,7 @@
font-size: 34px; font-size: 34px;
} }
h1 > code, h2 > span > code { h1 > code, h2 > p > code {
margin-left: 8px; margin-left: 8px;
} }
@ -68,7 +73,7 @@
font-size: 28px; font-size: 28px;
} }
h2 > span, h2 > span > code { h2 > p, h2 > p > code {
font-weight: 600; font-weight: 600;
font-size: 18px; font-size: 18px;
color: #bbb; color: #bbb;
@ -83,18 +88,49 @@
#versions { #versions {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
align-items: center;
width: 100%; width: 100%;
} }
#build, #built_with {
display: none;
}
</style> </style>
<script> <script> (async () => {
chromium_version.textContent = Gluon.versions.chromium; await new Promise(res => {
node_version.textContent = Gluon.versions.node; const check = () => {
if (!window.Gluon) return setTimeout(check, 100);
res();
};
check();
});
browser_version.textContent = Gluon.versions.browser;
node_version.textContent = `${Gluon.versions.embedded.node ? 'Embed' : 'System'} ${Gluon.versions.node}`;
gluon_version.textContent = Gluon.versions.gluon; gluon_version.textContent = Gluon.versions.gluon;
builder.textContent = Gluon.versions.builder; builder.textContent = Gluon.versions.builder;
product.textContent = Gluon.versions.product; product.textContent = Gluon.versions.product;
node_v8.textContent = Gluon.versions.v8.node; node_v8.textContent = Gluon.versions.js.node;
chromium_v8.textContent = Gluon.versions.v8.chromium; browser_v8.textContent = Gluon.versions.js.browser;
if (Gluon.versions.builder !== 'nothing') {
build.style.display = 'block';
built_with.style.display = 'block';
// main.innerHTML = main.innerHTML.replace(`built with <code id="builder">nothing</code> <br>`, '');
}
engine_name.textContent = Gluon.versions.product.startsWith('Firefox') ? 'Firefox' : 'Chromium';
js_engine_name.textContent = Gluon.versions.product.startsWith('Firefox') ? 'SpiderMonkey' : 'V8';
Gluon.ipc.on('build size', size => {
const kb = size / 1024;
const mb = kb / 1024;
build_size.textContent = mb > 0.1 ? `${mb.toFixed(2)}MB` : `${kb.toFixed(0)}KB`;
});
})();
</script> </script>
</body> </body>
</html> </html>

View File

@ -6,8 +6,34 @@ import { join, dirname } from 'path';
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename); const __dirname = dirname(__filename);
import { readdir, stat } from 'fs/promises';
const dirSize = async dir => {
const files = await readdir(dir, { withFileTypes: true });
const paths = files.map(async file => {
const path = join(dir, file.name);
if (file.isDirectory()) return await dirSize(path);
if (file.isFile()) return (await stat(path)).size;
return 0;
});
return (await Promise.all(paths)).flat(Infinity).reduce((acc, x) => acc + x, 0);
};
(async () => { (async () => {
const Chromium = await Gluon.open(pathToFileURL(join(__dirname, 'index.html')).href, { const Chromium = await Gluon.open(pathToFileURL(join(__dirname, 'index.html')).href, {
windowSize: [ 800, 500 ] windowSize: [ 800, 500 ],
forceBrowser: 'chrome_canary'
}); });
const Firefox = await Gluon.open(pathToFileURL(join(__dirname, 'index.html')).href, {
windowSize: [ 800, 500 ],
forceBrowser: 'firefox_nightly'
});
// const buildSize = await dirSize(__dirname);
// Chromium.ipc.send('build size', buildSize);
})(); })();