@brftech/filex

中文文档
0.59.0发布于 2026/11/07MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3226

filex Web Component - drop-in custom element (Vue 3 runtime bundled)

原始使用文档
文档目录12 节
  1. Install
  2. npm
  3. CDN (no build step)
  4. Styles
  5. Use
  6. Plain HTML
  7. Inside a non-Vue framework
  8. <filex-connections> - reaching the server without a browser
  9. Attributes
  10. Events
  11. Build
  12. License
filex logo

@brftech/filex

Drop-in <filex-explorer> Web Component for the filex file manager. Wraps the Vue 3 <FileExplorer> SFC from @brftech/filex-core and ships with the Vue runtime bundled in - load it from any CDN, embed in any framework, no peers required.

Install

npm

npm i @brftech/filex
// Side-effect import registers the element.
import '@brftech/filex';

CDN (no build step)

<script type="module" src="https://cdn.jsdelivr.net/npm/@brftech/filex/dist/filex.js"></script>

⚠ @brftech/filex 0.55 needs a filex 0.55 server. Which files open for editing (edit_kinds), the input limits (limits) and the version line (release, commit, built) come from the server's /api/files/capabilities; the package keeps no list of its own to fall back on, so against an older server nothing is offered Edit and nothing opens as an office document. Update the server with the package (API.md).

⚠ An app that prints (ui.print, filex 0.55) prints from filex's own print page, which the explorer frames in your page. Only filex, its desktop app and the server's FILEX_FRAME_ANCESTORS may frame that page, so on another site list your page's origin there - otherwise the app is told printing is unavailable (CONFIGURATION.md → Security headers and framing).

Styles

No CSS import, no <link>. The bundle carries the explorer's stylesheet inside the JavaScript and appends it to <head> once, the first time an element mounts - so the two lines above are all a page needs, whether they come from a CDN or a bundler. It is @brftech/filex-core's sheet byte for byte, which is what keeps this distribution and the Vue one looking the same.

A style.css is published as well, for a host that would rather serve the sheet itself:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@brftech/filex/dist/style.css">

The look is the --fe-* custom properties; set them on any scope above the element (:root, a wrapper div) and the explorer follows. The element deliberately has no shadow root for exactly this reason - the host page's tokens, dark mode and fonts reach inside. The consequence is that a host cannot fill a slot in it either, so the product mark in the top bar comes from config.brand ({ name, markUrl }).

Use

Plain HTML

<filex-explorer
  api-base="https://files.example.com"
  locale="tr"
  theme="auto"
></filex-explorer>

<script type="module">
  const el = document.querySelector('filex-explorer');
  // ⚠ Configure BEFORE the element is registered. A static `import` would be
  // hoisted above these lines, mount the explorer with no credentials and
  // spend its first listing on a request that can only fail.
  el.config = {
    apiBase: 'https://files.example.com',
    auth: { kind: 'bearer', token: '<jwt>' },
    rootPath: 'main://projects/acme',
  };
  // ⚠ The payload is e.detail[0] - see Events below.
  el.addEventListener('error', (e) => console.error(e.detail[0].message));
  el.addEventListener('share-created', (e) => navigator.clipboard.writeText(e.detail[0].url));
  await import('@brftech/filex');   // registers <filex-explorer>
</script>

Inside a non-Vue framework

The element is just a normal DOM custom element - Angular, Svelte, plain JS, no problem.

<filex-connections> - reaching the server without a browser

The package registers a second element. filex can be spoken to as S3, SFTP, FTPS, NFSv3 and WebDAV, and mounted with filex mount; this is where a user mints the credential each protocol takes and reads instructions built from that deployment rather than a template with angle brackets in it. It is the same component the filex admin panel and the filex desktop app render - there is no second set of instructions anywhere.

Since v0.43.0 this element is the "how to connect" surface only. The initial-tab attribute and the changed event are gone with the Storages tab: it does not create, edit or delete a storage. Storages are managed in the filex admin panel.

<filex-connections></filex-connections>

<script type="module">
  import '@brftech/filex';
  const el = document.querySelector('filex-connections');
  el.setAttribute('closable', '');     // show a close button, emits `close`
  el.config = {
    apiBase: 'https://files.example.com',
    auth: { kind: 'bearer', token: '<jwt>' },
    locale: 'tr',
  };
  el.addEventListener('error', (e) => console.error(e.detail));
</script>

⚠⚠ Configure it through the config property, not attributes - el.config = { ...el.config, locale: 'tr' }. buildConfig merges {...attributes, ...config} and the config object wins, so an attribute is only ever a fallback for a key the config does not carry. That exact mistake shipped in v0.19.0: the shell went Turkish while the file list stayed English, and the element reported locale === 'tr' the whole time.

See docs/PROTOCOLS.md.

Attributes

Simple attributes are auto-parsed into the underlying config prop:

AttributeMaps to
api-baseconfig.apiBase
endpointconfig.endpoint (legacy Vuefinder-compat)
localeconfig.locale - en, tr, or any language the server has a language pack for (es, de, fr, …). It is the element's default: the language a visitor picked in the explorer's ⋯ → Language (kept in their browser), their account's language when the credential is theirs, and their browser's languages come first (Language). A right-to-left language lays this element out right to left, from its own locale rather than the host page's.
themeconfig.theme (light / dark / auto)
trash-visibleconfig.trashVisible
sidenavconfig.sideNav - the navigation panel (the "+ New" menu · Home / Shared with me / My shares / Recent / Starred / Trash · your tags in two groups, personal and team · an Apps section, one row per installed app's own page · the storages this caller can reach). Present or ="true" is on, ="false" off; absent keeps the default, which is on.
connectionsconfig.connections - the panel's "Connections" (the connection guides; "How to connect" before 0.57) and "API keys" entries. Default on, except under ui-profile="simple" where it is off. ⚠ "API keys" is additionally dropped when the caller is an app token - see config.callerKind below.
ui-profileconfig.uiProfile - "standard" (default) or "simple" (one pane, list/grid only, no tab strip, no split pane, "Connections"/"API keys" off). Two values, no third: any other string resolves to "standard" and logs one console line naming it, so the "drive" profile that was removed after v0.40.0 no longer reduces anything - pass "simple" instead. ⚠⚠ It does not decide the look: the "+ New" menu, the one wide header search field with its ⌘K chip, the Type/Owner/Modified/Size filter row, the Folders/Files sections in grid (replaced by date headings while sorted by Modified), Details/Activity in the info panel and the storage line are what every embed draws now, with no string passed.

For anything richer (auth, custom endpoints, share base, …) set the config JS property after element creation. Properties merge on top of attributes.

config.callerKind - "user" (a person) or "app" (an integration: a host app's proxy, a bot). "app" leaves out the surfaces that belong to one identity: API keys, Recent, Starred, Shared with me. Upload, the storages, Trash and "Connections" stay, so an embed is still an embed. Omit it and the element asks the server (GET /api/files/capabilities → caller_kind), which is authoritative because only the server knows a token's kind; set it when your page already knows, to spare the moment before that answer lands. ⚠ Proxying every visitor with one shared API token IS the "app" case - see docs/MCP.md.

Events

Native CustomEvents - listen with addEventListener. ⚠ The SFC payload is event.detail[0], not event.detail: Vue dispatches a custom element's emit as new CustomEvent(name, { detail: args }), where args is the emit's argument list. event.detail.url is therefore undefined, and for selection-change - whose payload is itself an array - event.detail.length is always 1.

EventPayload - event.detail[0]
error{ message, context? }
share-created{ path, url, pin }
file-opened{ path, basename }
upload-progress{ uploadId, percent, done }
selection-changeArray<{ path, basename, type }>
open-app-store(none) - the navigation panel's App store row was pressed. Drawn only with config.appStorePage: true (you have the store screen) when the server shows the person the screen (GET /api/app-store → visible)

Build

pnpm build      # vue-tsc + vite lib build → dist/filex.js + dist/style.css

⚠⚠ sideEffects in package.json has to keep matching every file the build emits (./dist/*.js, ./dist/*.cjs), not a list of names. The entry is only a re-export: customElements.define and the stylesheet injection live in the hashed chunk beside it, and a list that does not cover the chunk lets a bundler drop it - the element is then never registered, the sheet never injected, and a React or Vite host renders an empty page with no error anywhere. web/tests/deploy/packageLook.test.ts is the guard.

License

MIT

版本与发布记录

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

版本发布日期距今
0.59.0latest2026/11/071 天前
0.58.22026/11/062 天前
0.58.02026/11/044 天前
0.57.72026/10/318 天前
0.57.62026/10/2712 天前
0.57.52026/10/2118 天前

关于 @brftech/filex 的常见问题

@brftech/filex 是什么?

filex Web Component - drop-in custom element (Vue 3 runtime bundled)

如何安装 @brftech/filex?

在项目目录运行 npm install @brftech/filex,或使用 pnpm add / yarn add / bun add。

@brftech/filex 支持 TypeScript 吗?

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

@brftech/filex 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@brftech/filex 可以商用吗?

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

@brftech/filex 的下载量有多少?

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

@brftech/filex 还在维护吗?

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