@ecopages/dev-toolbar

中文文档
0.7.1发布于 2026/11/13MITTypeScriptES Module构建来源已验证近 30 天下载 2686

Development toolbar for Ecopages

原始使用文档
文档目录5 节
  1. Install
  2. Built-in apps
  3. Bring your own dev toolbar
  4. Reference-toolbar internals
  5. Package layout

@ecopages/dev-toolbar

Development-only browser toolbar for Ecopages. Mounts during ecopages dev and does not ship to production builds.

User-facing docs: Dev toolbar (enablement, manifest, built-in apps).

Install

Add the package to your app and opt in from config:

import { defineConfig } from '@ecopages/core/config';
import { devToolbar } from '@ecopages/dev-toolbar/config';

export default defineConfig({ devToolbar: devToolbar() });
pnpm add -D @ecopages/dev-toolbar

During ecopages dev, core bundles your configured package to /_dev_toolbar.js and injects the dev manifest for the Deps panel. Restart the dev server after toolbar client changes.

@ecopages/dev-toolbar mirrors the core manifest contract locally for browser bundling (src/api/manifest-contract.ts); keep it in sync via manifest-contract.test.ts.

Disable per project with devToolbar: { enabled: false }, or per process with ECOPAGES_DEV_TOOLBAR=false.

Built-in apps

  • Build errors — opens automatically on HMR errors, reveals stealth mode, lists distinct messages as text, and shows an error count badge; any non-error HMR event clears messages and the badge
  • Navigation — route timing archive, initial load, client navigation latency, HMR status, and page Integration (the current owner reported by core's navigation coordinator); writes #__ECO_DEV_NAV_TELEMETRY__ in document.head (with data-eco-persist) and exposes window.__ECO_DEV_NAV_TELEMETRY__ for machine/AI debug
  • Deps — Page Browser Graph entry/chunk assets, vendor URLs, lazy-load hints
  • Islands — inspect island hosts stamped with data-eco-island, including SSR-emitted React <eco-island> hosts; repeated component instances are shown independently and hydration status reports hydrated (via data-eco-hydrated or verified component update completion), registered (for defined custom elements awaiting update completion), or ssr-only
  • A11y — axe-core audit (with built-in fallback checks) and in-page highlights
  • Settings — dock placement (top, bottom, left, right), stealth mode, and documentation link

Bring your own dev toolbar

Core delivers the configured client at /_dev_toolbar.js and injects #__ECO_DEV_MANIFEST__ per page. Your package owns the dock UI and panels.

To replace this reference toolbar:

  1. Create a client package that exports a browser bootstrap module (same layout as @ecopages/dev-toolbar).
  2. Set devToolbar.package in eco.config.ts (use defineDevTool from @ecopages/core/client for BYO packages).
  3. Fork or copy this package if you want Radiant panels, manifest readers, and stealth dock behavior.

@ecopages/dev-toolbar is the reference implementation.

Custom clients can claim the HMR runtime's cancelable ecopages:build-error window event (detail: { message: string }) with synchronous preventDefault() to suppress the in-page fallback. Listen for ecopages:build-error-clear to reset errors. After registering listeners, dispatch ecopages:build-error-request to replay active messages if mounting late. Core exports the names and payload type from @ecopages/core/client; the reference client mirrors the event names locally for browser bundling. Unclaimed errors still use the fallback. Remove listeners when unmounting.

Reference-toolbar internals

window.__ECO_DEV_TOOLBAR_APPS__ is an optional registry used inside this package for experimental extra dock apps. It is not a supported Ecopages extension API — app authors should replace devToolbar.package instead.

Package layout

  • src/bootstrap.ts — injects toolbar CSS into document.head, boots navigation telemetry, and mounts eco-dev-toolbar; reload-safe telemetry ownership prevents HMR bundle re-evaluation from adding duplicate document listeners
  • src/runtime/navigation-events.ts — shares core's navigation lifecycle event names and one DOM listener across toolbar apps, removing it when the final subscriber unmounts
  • src/runtime/navigation-telemetry.ts — reads the current owner from getOwnerState() so browser and React router ownership is reported consistently
  • src/shell/eco-dev-toolbar.tsx — Radiant light-DOM host (JSX render(), no shadow root); panel positioning is pure CSS
  • src/shell/motion.ts — WAAPI motion for stealth dock reveal only; panel show/hide is CSS
  • src/apps/*-panel.tsx — Radiant JSX panels (navigation, deps, islands, a11y, settings)
  • src/api/manifest-contract.ts — browser-local mirror of the core dev manifest contract
  • src/api/build-error-contract.ts — browser-local event names checked against the public core build error contract
  • src/api/dev-manifest.ts — internal DOM read/write for #__ECO_DEV_MANIFEST__
  • src/api/types.ts — toolbar app host contracts
  • src/shell/ — custom element host, SVG icons, styles, and ensureDevToolbarStyles() (optional CSS override for BYO toolbars)

版本与发布记录

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

版本发布日期距今
0.7.1latest2026/11/13今天
0.7.02026/11/094 天前
0.6.12026/10/3014 天前
0.6.02026/10/2915 天前
0.5.02026/10/2420 天前
0.4.02026/10/2222 天前

其他发布通道:beta → 0.2.0-beta.43,rc → 0.2.0-rc.14。

关于 @ecopages/dev-toolbar 的常见问题

@ecopages/dev-toolbar 是什么?

Development toolbar for Ecopages

如何安装 @ecopages/dev-toolbar?

在项目目录运行 npm install @ecopages/dev-toolbar,或使用 pnpm add / yarn add / bun add。

@ecopages/dev-toolbar 支持 TypeScript 吗?

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

@ecopages/dev-toolbar 支持 ESM 还是 CommonJS?

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

@ecopages/dev-toolbar 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^24.22.0 || >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ecopages/dev-toolbar 可以商用吗?

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

@ecopages/dev-toolbar 的下载量有多少?

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

@ecopages/dev-toolbar 还在维护吗?

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