@datalayer/reactor-manager

中文文档
1.3.5发布于 2026/11/07BSD-3-ClauseTypeScriptES Module构建来源已验证近 30 天下载 3896

The plugins manager for a Datalayer Reactor platform — lists every plugin and switches each one on and off while the application runs.

原始使用文档
文档目录7 节
  1. Why it is a plugin
  2. What it draws
  3. Using it
  4. Hiding an implementation detail
  5. Plugins the manager cannot find
  6. The actions slot
  7. Mounting the view directly

Datalayer

🔌 @datalayer/reactor-manager

Lists every plugin in a @datalayer/reactor platform and switches each one on and off while the application runs.

Why it is a plugin

A sidebar that manages plugins is the one surface whose whole job is the plugin system itself. Every host that offered one had written its own, which meant every host answered the same questions slightly differently — and each of them hard-coded whatever else belonged beside the list.

This one depends on no other plugin and knows none of them by name. It reads the platform through the Reactor API that every plugin already has, which is why it can list plugins written long after it.

What it draws

  • A filter across name, identifier and description.
  • A row per plugin: emoji, display name, description.
  • A switch per row, calling reactor.enable / reactor.disable. switchSize ('small' by default, or 'medium') sets how large it is.
  • Whatever other plugins contribute to manager-actions, above the list.

Using it

import { buildReactorFromPlugins, configurePlugin } from '@datalayer/reactor';
import { ReactorSlot, useReactor } from '@datalayer/reactor/react';
import { PluginsManagerPlugin } from '@datalayer/reactor-manager';

const reactor = buildReactorFromPlugins([
  configurePlugin(PluginsManagerPlugin, {
    // Anything the application would break without. The manager protects
    // itself by default; naming your own replaces that, so include it unless
    // you mean to allow switching the sidebar off.
    protected: ['@datalayer/reactor-manager', '@your/shell'],
  }),
  /* your own */
]);

export function App() {
  useReactor(reactor);
  // Whatever you pass reaches the plugins contributing to `manager-actions`.
  return <ReactorSlot slot="sidebar" props={{ showingGraph, onToggleGraph }} />;
}

Hiding an implementation detail

A thin adapter and the generic plugin it depends on are one feature to the person reading the sidebar, and two switches for one feature is a question they cannot answer. hidden (config) or hiddenPlugins (prop) leaves one out:

configurePlugin(PluginsManagerPlugin, {
  hidden: ['@datalayer/reactor-graph'], // the adapter is the switch that matters
});

A host's decision rather than something inferred from the dependency graph. A dependency is often worth switching on its own — the music example asks you to try exactly that — so hiding every one of them would remove the point.

Plugins the manager cannot find

The reactor in this browser is not always the whole system. An application with plugins on the other side of a wire has a second set to manage, and a person should not have to learn two controls because of where a plugin happens to run.

A plugin contributes a source: a heading and a component that renders its own rows with PluginList — the same one the manager uses — and keeps whatever fetching its tier needs to itself.

contribution(ManagerPluginSource, {
  title: 'Backend plugins (Python)',
  order: 100,                      // after the browser's own, which are 0
  Component: BackendPluginSource,
});

function BackendPluginSource({ query, switchSize }: PluginSourceProps) {
  const { plugins, toggle } = useBackendPlugins();
  return (
    <PluginList
      plugins={plugins.map(toManagedPlugin)}
      query={query}
      switchSize={switchSize}
      onToggle={(name, next) => void toggle(name, next)}
    />
  );
}

A component rather than a list, because the manager would otherwise be calling somebody else's hook — which it cannot do conditionally, and the set of sources changes as plugins are switched.

The actions slot

A plugin that wants a control in the sidebar contributes to MANAGER_ACTIONS_SLOT rather than asking the host to draw one:

build: () => ({
  components: [
    { slot: MANAGER_ACTIONS_SLOT, id: 'my-toggle', Component: MyToggle },
  ],
}),

It receives the props the host gave the manager, unchanged. The manager has no idea what your control needs in order to navigate, and no business inventing one — but the control appears and disappears with the plugin that owns it, which is the point.

Mounting the view directly

A host that would rather place the list itself can render PluginsManagerView and pass protectedPlugins, skipping the plugin and its config.

版本与发布记录

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

版本发布日期距今
1.3.5latest2026/11/074 天前
1.3.42026/10/2814 天前
1.3.22026/10/2220 天前
1.3.12026/10/1725 天前
1.3.02026/10/1230 天前
1.2.02026/10/1230 天前

关于 @datalayer/reactor-manager 的常见问题

@datalayer/reactor-manager 是什么?

The plugins manager for a Datalayer Reactor platform — lists every plugin and switches each one on and off while the application runs.

如何安装 @datalayer/reactor-manager?

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

@datalayer/reactor-manager 支持 TypeScript 吗?

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

@datalayer/reactor-manager 支持 ESM 还是 CommonJS?

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

@datalayer/reactor-manager 可以商用吗?

@datalayer/reactor-manager 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@datalayer/reactor-manager 的下载量有多少?

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

@datalayer/reactor-manager 还在维护吗?

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