Today Canvas Kit
SDK packages

@todayai-labs/tck-bundle-server

Vite plugin + in-memory store for ingesting .tckb bundles during development. Powers tck-preview's drop-to-load shell.

Dev-only. A Vite plugin plus an in-memory bundle store that ingests .tckb files at HMR speed, routes their widget.mjs through Vite's transform pipeline, and serves them at a stable URL. Used by tck-preview and by host playgrounds that want drop-to-load or watch-mode bundle ingestion.

The structural primitives (unpack, hash, integrity) live in tck-bundle-format — this package adds the Vite glue (HTTP routes, watchers, the in-memory store). When tck-bundle-server and tck-bundle-format both expose a name (unpackTckb, UnpackedBundle), the server's version forwards to the format package and adds Vite-specific error shape (BundleUnpackError).

Surface

import { tckBundleServer } from '@todayai-labs/tck-bundle-server'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    tckBundleServer({
      watchGlobs: [{ source: 'workspace', glob: 'widgets/*/dist/*.tckb' }],
    }).plugin,
  ],
})

tckBundleServer(options) returns { plugin, store }. Pass plugin to Vite's plugins array; reach for store if the host wants to inspect or mutate the in-memory bundle index directly (rare; mostly used by tck-preview for cross-shell coordination). The watchGlobs option takes a WatchGroup[] — each entry pairs a source label (the sidebar groups bundles by this label) with the .tckb glob to watch.

ExportWhat it does
tckBundleServer(options)Returns { plugin, store }. The Vite plugin watches .tckb files, ingests on change, and serves them at BUNDLE_URL_PREFIX/<hash>.
BundleStoreThe in-memory store. Keyed by bundleHash. publicView() returns the consumer-safe entry shape.
BUNDLE_URL_PREFIX, parseBundleCssUrl, parseBundleWidgetUrlURL helpers — match the routes the plugin serves and parse hashes back out.
BundleUnpackErrorVite-side error shape. Wraps tck-bundle-format's TckbUnpackError.

Constraint

Vite-coupled. The peer dep is vite ^7 || ^8. Production hosts that need bundle ingestion without Vite use tck-bundle-format directly.

Source

On this page