BundleSource
Bundle source for managing multiple bundle versions.
Bundle source for managing multiple bundle versions.
A source manages bundles in two directories:
- builtin: Bundles shipped with the app (read-only, fallback)
- remote: Downloaded bundles (takes priority)
The source automatically handles version selection, with remote bundles taking priority over builtin ones.
Constructor
new BundleSource(config: BundleSourceConfig);Prop
Type
Methods
Prop
Type
Examples
const source = new BundleSource({
builtinDir: './bundles/builtin',
remoteDir: './bundles/remote',
});
// List all bundles
const bundles = await source.listBundles();
// Load current version
const version = await source.loadVersion('app');
// Fetch bundle
const bundle = await source.fetch('app');constructor
const source = new BundleSource({
builtinDir: './builtin',
remoteDir: './remote',
});fetchBundle
const bundle = await source.fetchBundle('app');
const html = bundle.getData('/index.html');fetchDescriptor
const descriptor = await source.fetchDescriptor('app');
const index = descriptor.index();
console.log(`Files: ${Object.keys(index.entries()).length}`);listBundles
const bundles = await source.listBundles();
for (const bundle of bundles) {
console.log(`${bundle.name}@${bundle.version} (${bundle.type})`);
}loadDescriptor
const loaded = await source.loadDescriptor('app');
const html = await loaded.getData('/index.html');loadVersion
const version = await source.loadVersion('app');
if (version) {
console.log(`Current version: ${version.version} (${version.type})`);
}resolveFilepath
const path = await source.resolveFilepath('app');
console.log(`Bundle at: ${path}`);updateRemoteVersion
await source.updateRemoteVersion('app', '1.2.0');writeRemoteBundle
await source.writeRemoteBundle('app', '1.2.0', bundle, {
integrity: 'sha3-384-...',
etag: 'abc123',
});