Official SDK version 0.2.0 for building dual-mode BAP components. It implements Core 0.1.0 and supports the versioned composition, configuration, and presentation extensions. A component can run independently in Standalone Mode or inside a compatible host through an Embedded iframe.
import { StandaloneShell } from '@backdrop-augmentation-protocol/component-sdk';
const manifest = {
protocol: { name: 'bap', version: '0.1.0', profile: 'core' },
id: 'example.clock', name: 'Example Clock', version: '0.1.0',
role: 'component', capabilities: [], modes: ['standalone', 'embedded'],
entrypoints: {
default: './component.js',
embedded: './component.js',
standalone: './component.js'
}
};
new StandaloneShell({ manifest, render(root, runtime) {
root.textContent = runtime.getConfig('label') ?? 'Hello BAP';
} }).start();The official Standalone Shell is an optional convenience. The protocol only requires that Standalone Mode can run as a real component entry point.
validateManifest/assertManifest: runtime manifest validation.createEmbeddedEntry: creates a component runtime for a Host-provided iframe.createStandaloneEntry: creates a minimal standalone runtime without a shell.StandaloneShell: optional minimal document shell for examples and development.PostMessageClient: request/response and event messaging overpostMessage.ComponentRuntime: lifecycle (start,pause,resume,stop) and configuration APIs.
Embedded components may explicitly offer optional extensions. Only exact Host/Component version intersections are selected; Core-only Hosts remain supported.
const entry = createEmbeddedEntry({ manifest, extensions: [
{ id: 'org.bap.composition', versions: ['0.1.0'] },
{ id: 'org.bap.component-config', versions: ['0.1.0'] },
{ id: 'org.bap.presentation', versions: ['0.1.0'] }
] });
entry.runtime.onConfigChange(config => renderConfig(config));
entry.runtime.onPresentationChange(state => setVisible(state.visible));When composition is selected, runtime.instanceId is the Host-provided opaque routing context. It is not an authentication or origin claim. Host configuration events replace the complete effective snapshot only when their instance ID matches and their revision is newer. Presentation events are likewise instance-scoped.
Run tests with npm test. Run the minimal example with npm run example, then open http://localhost:4173.