@vectara/widget-sdk-types
v0.1.0
Published
TypeScript types for the Vectara widget renderer SDK.
Keywords
Readme
@vectara/widget-sdk-types
Types for the Vectara widget renderer SDK. Types only, no runtime code.
The SDK runs from Vectara's CDN as a plain ES module. This package exists so a renderer written in TypeScript typechecks against it.
Install
npm install --save-dev @vectara/widget-sdk-typesUsage
Import from the absolute CDN URL, not a bare specifier:
import { html, registerRenderer, widget } from "https://vectara-widgets.netlify.app/sdk/sdk.js";
await widget("popup-agent-chat");
registerRenderer("popup-agent-chat", "menuOptions", ({ closeMenu }) =>
html`<button type="button" role="menuitem" onClick=${closeMenu}>Help</button>`
);There is no @vectara/widget-sdk to import. The types are declared against
that exact URL string, so a bare specifier resolves to nothing, and adding one
would make your bundler ship a second copy of a runtime the browser already
loaded from the CDN.
Exports
| Export | Purpose |
| --- | --- |
| html | Tagged template, so a renderer needs no build step |
| ui | Shared components (Icon, FlexContainer, TextArea, ...) |
| widget(name) | Resolves that widget's WidgetHandle once it boots |
| theme(name) | Its CSS vars, for UI rendered outside the widget's shadow root |
| registerRenderer(widget, slot, component) | Replaces one of a widget's slots |
| React, createElement, hooks | The SDK's React instance. Use these, not your own |
Renderers run inside the widget's own tree, which is why its hooks and theme
resolve for them. WidgetHandle.components is keyed by whatever names each
widget publishes, so check that widget's docs for the names and their props.
Versioning
0.1.x tracks the always-latest SDK. There is no version pinning between this
package and the runtime it describes.
