@flywheel-io/extension

中文文档
0.14.10发布于 2026/10/30MITTypeScriptCommonJS近 30 天下载 2637

Create extension applications for the Flywheel web UI

原始使用文档
文档目录8 节
  1. Getting Started
  2. Install with NPM
  3. Load the UMD Module
  4. Registering Your Application
  5. Extension Interface
  6. Extension Scope
  7. Close Button
  8. Data Models

Flywheel Extension SDK

Extend the Flywheel UI with custom applications.

Getting Started

Install with NPM

npm install @flywheel-io/extension

Initialize the extension and connect to Flywheel.

import { initExtension } from '@flywheel-io/extension';

initExtension().then(extension => {
  console.log('Container Type:', extension.container.container_type);
  console.log('Container ID:', extension.container._id);
  console.log('File Name:', extension.file.name);
});

Load the UMD Module

As an alternative to bundling with NPM, the SDK can be loaded via script tag. The library is available on the Flywheel global variable.

<body>
  <pre id="content"></pre>
  <script src="https://cdn.flywheel.io/sdk/extension/flywheel-extension-0.14.10.min.js"></script>
  <script>
    Flywheel.initExtension().then(extension => {
      return extension.getFileText(extension.container, extension.file);
    }).then(text => {
      document.getElementById('content').innerText = text;
    });
  </script>
</body>

Registering Your Application

A Flywheel site admin can register an extension application on the Admin -> Applications page. Click the Register New Application button to associate container or file types to your application. The URL can point to a local development server until your app is ready and published to a public location.

Learn more about application registration in the Flywheel Docs.

Extension Interface

The Extension instance establishes the user, container, and file context of the extension. It also provides methods that interact with Flywheel to get containers in the hierarchy, retrieve file data, or save data back to Flywheel. Most of these methods return Promises, but some methods that are more involved (e.g. the uploadFile method) return an Observable that can be subscribed to.

extension.getContainer('session', extension.container.parents.session).then(session => {
  extension.uploadFile(session, fileInput.files[0]).subscribe({
    next: event => {
      if (event.type === 'progress') {
        console.log('uploaded', event.loaded, '/', event.total, 'bytes');
      }
      if (event.type === 'response') {
        console.log('upload complete');
        console.dir(event.file);
      }
    }
  });
});

Extension Scope

When initializing the extension and connecting to a Flywheel instance, your application is set to ReadOnly scope by default. This means that you're able to read data from Flywheel but cannot write data, such as setting custom information or uploading files. If you want to opt into write functionality, pass the ReadWrite scope option, along with a validateOrigin function, into initExtension. The validateOrigin function receives the origin of a connecting Flywheel instance and determines it as trusted or not.

initExtension({ scope: 'ReadWrite', validateOrigin: origin => origin.endsWith('flywheel.io') }).then(extension => {
  return extension.updateContainerInfo(extension.container, {
    set: {
      ProjectPolicy: {
        owner: '[email protected]',
        writable: true,
      }
    }
  })
});

Close Button

Flywheel draws a close button over the extension frame. To hide it, pass the hideCloseButton option into initExtension and call extension.close() from your application's own close control.

initExtension({ hideCloseButton: true }).then(extension => {
  document.getElementById('exit').addEventListener('click', () => extension.close());
});

Data Models

Models for Flywheel objects are described in the documentation. The most commonly-used of these are:

When this package is installed via NPM in a TypeScript project, these definitions are made available in your project's environment.

版本与发布记录

@flywheel-io/extension 共发布 15 个版本,首次发布于 2021/06/10;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.14.10latest2026/10/3016 天前
0.14.92026/05/305 个月前
0.14.82026/03/317 个月前
0.14.42025/06/271.4 年前
0.14.32024/10/302 年前
0.14.22024/04/112 年前

关于 @flywheel-io/extension 的常见问题

@flywheel-io/extension 是什么?

Create extension applications for the Flywheel web UI

如何安装 @flywheel-io/extension?

在项目目录运行 npm install @flywheel-io/extension,或使用 pnpm add / yarn add / bun add。

@flywheel-io/extension 支持 TypeScript 吗?

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

@flywheel-io/extension 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@flywheel-io/extension 可以商用吗?

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

@flywheel-io/extension 的下载量有多少?

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

@flywheel-io/extension 还在维护吗?

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