@bridge-ds/toolbar

中文文档
0.8.2发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 2002

The Bridge toolbar for a product built with the Bridge design system: opened from Bridge Studio with ?bridge=, it flips the real product between before and after and shows what changed.

原始使用文档

@bridge-ds/toolbar

The Bridge toolbar for a product built with the Bridge design system. Bridge Studio opens the product with ?bridge=<change> ("Try it in the product"); the toolbar then lets anyone browse the real product and flip between Live product (before) and This change (after), with Show what changed.

  • Code changes (an exploration in the product's repository, a feature branch): Before is the product in production, After is the branch's preview. Flipping keeps the screen and the scroll position. Production is another origin, so the toolbar cannot measure the difference: the change marks each new or changed area of the UI with data-bridge-change="<short plain label>" on its outermost element (Bridge tells Claude to, in every exploration). On This change those areas are outlined, counted ("1 changed", "1 / 3 changed") and stepped through like token changes, with Isolate, and the Changes list names them. On Live product the bar says how many wait on This change ("1 changed on This change"). A change that marks nothing says so.

    <div role="status" data-bridge-change="Orders waiting to ship alert">30 orders are waiting to ship</div>
    
  • Token changes of the design system: the live tokens swap in without a reload. As soon as the toolbar is open, every surface that differs is outlined and counted in the bar ("13 changed", then "2 / 13 changed"). Previous and Next scroll to each one in reading order and outline it stronger than the others; Isolate dims the rest of the page (Esc turns it off). The outlines, the position and Isolate hold when you flip to Live product, since both sides are the same page.

Keyboard: B flips Live product and This change on the same screen and scroll position, C turns the outlines off and on, Esc ends Isolate. None of them fires while you type in a field.

Without ?bridge= (or the session that remembers it) it renders nothing and loads nothing: the toolbar and its styles are one lazy chunk.

The toolbar is Bridge's chrome and looks the same on any product, whatever its design system, tokens or global CSS: its chunk carries the Bridge components it renders (class names of their own, bridge-tb_*) and the Bridge token values, scoped to the toolbar's own elements. It never reads the page's tokens for its own look.

Mount it

npm i @bridge-ds/toolbar

One line at the root of the app, inside the design system's ThemeProvider:

import { BridgeToolbar } from '@bridge-ds/toolbar';

<BridgeToolbar ds="acme/design-system" product="checkout" />

ds is the design system repository and product the product's key in its bridge.config.json products[]. When Studio opens the page, the toolbar reads that config from GitHub once per session: the product's repository (where its explorations are pull requests), production (Before of a code change), preview (the branch preview template, the only hosts allowed to hand over to production) and production Studio (previews.production.docs, the way back and the live tokens). bridge connect prints this line with your values.

{ "key": "checkout", "name": "Checkout", "repo": "acme/checkout", "framework": "react",
  "preview": "https://checkout-git-{branch}-acme.vercel.app", "production": "https://checkout.acme.com" }

Options

PropWhat it does
studio, production, previewOverride what the config says (for example a staging URL as Before).
deployEnv"production" or "preview" when your build knows it (Vercel: VERCEL_ENV). Optional: on other hosts (Cloudflare Pages, Netlify) a page whose host matches the preview template counts as a preview.
buildEvery fact at once, read at build time: no config read at run time.
scopeA hook returning { theme, brand, density, shop, set } when your app keeps theme and shop in state. Default: the data-theme, data-brand and data-density attributes ThemeProvider asRoot puts on <html>.
shops{ id, name, brand }[] of a multi-brand product, for the screens list and "Switch to ".
togetherA loader of the latest library's token files (togetherBase from @bridge-ds/toolbar/together), so Studio's "Try them together" runs on your production.
proxyBridge's origin, whose read proxy serves the toolbar's GitHub reads. Default https://bridge.floriangouloubi.com; null reads GitHub directly.

Reads go through Bridge's read proxy (<proxy>/api/contribute?repo=<ds>&gh=<path>: allow-listed, cached, read-only on the server), so visitors never meet GitHub's limit of 60 anonymous reads an hour. Bridge serves a public design system and the public product repositories its bridge.config.json lists, to the origins that config names (production and preview of each product, and localhost). When Bridge refuses or cannot be reached, the toolbar reads GitHub directly (anonymous, public repositories): at most a few API reads per change and session.

版本与发布记录

@bridge-ds/toolbar 共发布 11 个版本,首次发布于 2026/10/31;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.8.2latest2026/11/08今天
0.8.12026/11/035 天前
0.7.02026/11/026 天前
0.6.02026/11/026 天前
0.5.02026/11/027 天前
0.4.12026/10/318 天前

关于 @bridge-ds/toolbar 的常见问题

@bridge-ds/toolbar 是什么?

The Bridge toolbar for a product built with the Bridge design system: opened from Bridge Studio with ?bridge=, it flips the real product between before and after and shows what changed.

如何安装 @bridge-ds/toolbar?

在项目目录运行 npm install @bridge-ds/toolbar,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bridge-ds/toolbar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bridge-ds/toolbar 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bridge-ds/toolbar 可以商用吗?

@bridge-ds/toolbar 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bridge-ds/toolbar 的下载量有多少?

根据 npm 官方下载统计,@bridge-ds/toolbar 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,002 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bridge-ds/toolbar 还在维护吗?

最新版本 0.8.2 发布于 2026/11/08(今天);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。