diff --git a/typescript/catalogs/iframe/CHANGELOG.md b/typescript/catalogs/iframe/CHANGELOG.md index bcda24ab58..44d013d7a9 100644 --- a/typescript/catalogs/iframe/CHANGELOG.md +++ b/typescript/catalogs/iframe/CHANGELOG.md @@ -2,7 +2,8 @@ ## Unreleased -- Add the `@a2ui/catalog-iframe` package: the sandbox proxy asset with its configuration - (`configureSandbox`, `resolveSandboxUrl`), the `FrameHost` interface and the `WebAppFrameBridge` - host bridge with allowlist validation, data model sync, function calls and sizing. - [#2797](https://github.com/a2ui-project/a2ui/pull/2797) +- Add the `@a2ui/catalog-iframe` package: `iframeCatalog` with the `WebAppFrameUrl` and + `WebAppFrameSrcdoc` universal components, which render a web app inside the sandbox proxy and + connect it to the surface through `WebAppFrameBridge`. Hosts serve the sandbox asset and locate + it with `configureSandbox`. [#2797](https://github.com/a2ui-project/a2ui/pull/2797) + [#2798](https://github.com/a2ui-project/a2ui/pull/2798) diff --git a/typescript/catalogs/iframe/README.md b/typescript/catalogs/iframe/README.md index 88158d7a17..70924739f1 100644 --- a/typescript/catalogs/iframe/README.md +++ b/typescript/catalogs/iframe/README.md @@ -5,26 +5,136 @@ application or an external web app, inside a sandboxed frame that talks to the h the `a2ui_*` message protocol defined in the [WebApp iframe component specification](../../../catalogs/iframe/web_app_frame_specification.md). -This release contains the building blocks the frame components are made of: +The package contains: +- `iframeCatalog`, with the two universal components of the catalog, `WebAppFrameUrl` and + `WebAppFrameSrcdoc`; - the sandbox proxy asset (`sandbox/` in the published package) and the configuration of where the host serves it; - `WebAppFrameBridge`, the host side of the protocol: `MessagePort` handshake, two-way data model sync for `data.paths`, `allowedEvents`, `allowedFunctions` and `mutableData` allowlists with JSON Schema validation, function calls, resize requests and host context updates; -- the zod schemas of the wire messages and the `FrameHost` interface a renderer adapts its component - context to. - -The `WebAppFrameUrl` and `WebAppFrameSrcdoc` components that use them are added in a following -release, together with the catalog registration. +- `SandboxedFrameElement` and `ComponentContextFrameHost`, the base class and the host adapter the + components are built on, for catalogs that add their own sandboxed frame components. ## Installation ```bash -npm install @a2ui/catalog-iframe +npm install @a2ui/catalog-iframe @a2ui/web_core lit +``` + +`@a2ui/web_core` and `lit` are peer dependencies: the components are universal components built on +`A2uiLitElement` from `@a2ui/web_core/v1_0`. The package also depends on `zod` and `ajv` +and expects a browser environment. + +## Usage + +The components are custom elements that any renderer able to host universal components can render. +Register the catalog with the `MessageProcessor` next to the catalogs you already use, and serve the +sandbox asset (next section): + +```ts +import {basicCatalog, MessageProcessor} from '@a2ui/web_core/v1_0'; +import {iframeCatalog} from '@a2ui/catalog-iframe'; + +const processor = new MessageProcessor([basicCatalog, iframeCatalog]); +``` + +A surface resolves components through its default catalog, the `catalogId` of its +`createSurface` message, unless a component names another registered catalog with its own +`catalogId`. A payload that mixes frames with basic components therefore creates the surface with +the basic catalog id and marks the frame component: + +```json +{ + "id": "counter_app", + "component": "WebAppFrameSrcdoc", + "catalogId": "https://a2ui.org/specification/v1_0/catalogs/iframe/catalog.json", + "height": 160, + "htmlContent": "..." +} ``` -The package depends on `zod` and `ajv` and expects a browser environment. +A frame's `allowedFunctions` resolve against the frame component's own catalog first and then +the surface default, so a frame on such a surface can call the basic catalog's functions. + +## Components + +Both components render one `