Skip to content

About

Official SDK for BAP dual-mode components

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

BAP Component SDK

English | 简体中文

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.

Quick start

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.

MVP API

  • 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 over postMessage.
  • ComponentRuntime: lifecycle (start, pause, resume, stop) and configuration APIs.

BAP 0.2.0 extension support

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.

About

Official SDK for BAP dual-mode components

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages