Create inv web.build

This command will build a wheel, copy it in the web directory, and create a file `packageFile` with the name of the wheel. If the correct override param is given, bumble.js will read `packageFile` and load that package.
This commit is contained in:
Alan Rosenthal
2024-07-09 09:32:21 -04:00
committed by GitHub
parent 32a41a815d
commit c2c46e9ace
4 changed files with 43 additions and 4 deletions

View File

@@ -75,7 +75,6 @@ export class Bumble extends EventTarget {
}
// Load the Bumble module
bumblePackage ||= 'bumble';
console.log('Installing micropip');
this.log(`Installing ${bumblePackage}`)
await this.pyodide.loadPackage('micropip');
@@ -166,6 +165,20 @@ export class Bumble extends EventTarget {
}
}
async function getBumblePackage() {
const params = (new URL(document.location)).searchParams;
// First check the packageFile override param
if (params.has('packageFile')) {
return await (await fetch('/packageFile')).text()
}
// Then check the package override param
if (params.has('package')) {
return params.get('package')
}
// If no override params, default to the main package
return 'bumble'
}
export async function setupSimpleApp(appUrl, bumbleControls, log) {
// Load Bumble
log('Loading Bumble');
@@ -173,8 +186,7 @@ export async function setupSimpleApp(appUrl, bumbleControls, log) {
bumble.addEventListener('log', (event) => {
log(event.message);
})
const params = (new URL(document.location)).searchParams;
await bumble.loadRuntime(params.get('package'));
await bumble.loadRuntime(await getBumblePackage());
log('Bumble is ready!')
const app = await bumble.loadApp(appUrl);