@dpuse/dpuse-tool-file-previewer

中文文档
1.0.136发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 4140

A library that wraps file-type and jschardet to identify a file's format and encoding from its first bytes, and return a decoded sample of its text.

原始使用文档
文档目录15 节
  1. About DPUse
  2. Introduction
  3. Usage
  4. Dependency Licenses
  5. Dependency Tree
  6. Bundle Analysis
  7. Quality & Security
  8. Testing
  9. Code Quality
  10. Security Analysis
  11. Dependencies
  12. OpenSSF 🚧
  13. Reporting Vulnerabilities
  14. Contributing
  15. License

DPUse File Previewer Tool

License: MIT DPUse version npm version CI

A library that wraps file-type and jschardet to identify a file's format and encoding from its first bytes, and return a decoded sample of its text.

Report a Vulnerability · Open an Issue

About DPUse

DPUse (Data Positioning & Use) is an in-browser application that positions your data for use through three core activities: sourcing, contextualising, and publishing.

Sourcing uses a library of Connectors to establish Connections to applications, databases, file stores, and curated datasets; these connections are subsequently used to configure structured Data Views from the underlying sources.

Contextualising extracts chronological events from those Data Views and maps them into comprehensive Context Models. This gives the DPUse Engine the structural framework needed to generate deterministic transactions, facts, or observations.

Publishing uses a library of Presenters to render standard Presentations immediately using the contextualised data; additionally, Cookbooks of Recipes let you build Data Apps using your preferred tools.

In addition, DPUse provides Tools used by the application, and you can use them to construct connectors and presenters.

Introduction

The File Previewer Tool reads the start of a file and identifies its format and encoding, so a connector can show a preview before the file is parsed. It recognises binary data formats such as Parquet, Arrow, Avro, Excel, OpenDocument and SQLite, decodes text using its byte order mark, its XML declaration or detection from its content, and tells JSON, JSON Lines, markdown and delimited text apart.

Usage

This package is available on npm. Install it with:

npm install @dpuse/dpuse-tool-file-previewer

To work on the source instead, clone this repository.

git clone https://github.com/dpuse/dpuse-tool-file-previewer.git
cd dpuse-tool-file-previewer
npm install

Requires Node.js 24 or later, npm 12 or later, and TypeScript 6.0.3 or later.

This repository is managed using the common set of actions provided by @dpuse/dpuse-development. See the scripts block in package.json for details.

Dependency Licenses

License data is updated each time npm run document is run, using license-checker. The following table lists every package whose code, styles or assets are included in this project's build, as recorded by the build itself. Modules loaded at run time are not included; each documents its own. These dependencies have been checked and confirmed to use 0BSD or MIT, all of which allow commercial use. All are used unmodified, so any licence conditions that apply only to modified versions are not triggered. Developers cloning this repository should independently verify development dependencies.

DependencyVersionLicense(s)Document
@borewit/text-codec0.2.3MITLICENSE
@dpuse/dpuse-shared1.0.211MITLICENSE
@tokenizer/inflate0.6.0MITLICENSE
debug4.4.3MITLICENSE
file-type22.3.0MITLICENSE
jschardet4.1.00BSDLICENSE
ms2.1.3MITLICENSE
strtok310.7.0MITLICENSE
token-types6.2.0MITLICENSE
uint8array-extras1.6.0MITLICENSE
valibot1.5.0MITLICENSE

Dependency Tree

The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.

Bundle Analysis

This report is updated with each release, from the bundle the release builds, using Sonda, which analyses final source maps to reveal the actual effects of tree-shaking and minification rather than relying on pre-build estimates.

Note: Sonda's Vite reports currently exclude CSS files, since Vite does not generate source maps for CSS.

Chunk/Module/FileComposition
dist/dpuse-tool-file-previewer.es.js1263.6 kB · gzip 724.5 kB · 100.0% of the build
    jschardet → dist/jschardet.esm.min.js██████████████████░░ 89.6% · 1132.0 kB
    file-type → source/index.js + 7 more█░░░░░░░░░░░░░░░░░░░ 3.4% · 42.9 kB
        ↳ 8 smaller files▒░░░░░░░░░░░░░░░░░░░ 3.4% · 42.9 kB
    @dpuse/dpuse-shared → dist/dpuse-shared.es.js░░░░░░░░░░░░░░░░░░░░ 1.8% · 22.5 kB
    strtok3 → lib/TokenizerView.js + 15 more░░░░░░░░░░░░░░░░░░░░ 1.1% · 13.8 kB
        ↳ 16 smaller files░░░░░░░░░░░░░░░░░░░░ 1.1% · 13.8 kB
    @tokenizer/inflate → lib/ZipHandler.js + 3 more░░░░░░░░░░░░░░░░░░░░ 0.8% · 10.2 kB
        ↳ 4 smaller files░░░░░░░░░░░░░░░░░░░░ 0.8% · 10.2 kB
    src → index.ts + 2 more░░░░░░░░░░░░░░░░░░░░ 0.6% · 7.7 kB
        ↳ 3 smaller files░░░░░░░░░░░░░░░░░░░░ 0.6% · 7.7 kB
    debug → src/browser.js + 1 more░░░░░░░░░░░░░░░░░░░░ 0.4% · 5.1 kB
        ↳ 2 smaller files░░░░░░░░░░░░░░░░░░░░ 0.4% · 5.1 kB
    @borewit/text-codec → lib/index.js░░░░░░░░░░░░░░░░░░░░ 0.4% · 4.9 kB
    ms → index.js░░░░░░░░░░░░░░░░░░░░ 0.1% · 1.6 kB
    token-types → dist/lib/index.js░░░░░░░░░░░░░░░░░░░░ 0.1% · 1.2 kB
    uint8array-extras → index.js░░░░░░░░░░░░░░░░░░░░ 0.1% · 1.2 kB
    (bundler output, whitespace & JSON)░░░░░░░░░░░░░░░░░░░░ 1.6% · 20.7 kB

Bars show each row's share of its output file. ↳ rows are part of the row above.

  • n more = the row also holds n more files from the same package or folder, each no larger than the one named. A package can appear under several output files, each holding different files, never the same file twice.

(bundler output, whitespace & JSON) = bytes Sonda can't trace to a source file: whitespace (indentation and line breaks), code the bundler generates (region comments, the combined import/export lines, its small runtime helper and wrappers), and imported JSON such as config.json, which the bundler doesn't map. The JSON and the generated code are real bytes that ship; the whitespace mostly disappears once compressed.

Quality & Security

This section is updated each time npm run document is run. Settings come from the repository's workflow files and GitHub. Test coverage and the Fallow score are measured at the same time.

Testing

CheckStatusWhat it does
Unit tests✅ OnVitest runs the unit tests. Part of the CI workflow on every push and pull request to main.
Property-based tests❌ Offfast-check runs many random inputs per test to find edge cases, alongside the unit tests.
Test coverage✅ OnCoverage Vitest's V8 coverage measures the share of source lines the unit tests run. The target is 80%.

Code Quality

CheckStatusWhat it does
Code analysis❌ OffSonarCloud checks every push for bugs, code smells and vulnerabilities.
Linting✅ OnESLint checks the code for errors and style problems. Part of the CI workflow on every push and pull request to main.

Security Analysis

CheckStatusWhat it does
Push protection✅ OnGitHub push protection blocks pushes that contain credentials.
Static analysis✅ OnCodeQL CodeQL scans GitHub Actions and JavaScript/TypeScript for security vulnerabilities, using the extended security queries, on every push and pull request to main and weekly.
Secret scanning✅ OnGitHub secret scanning detects credentials, such as API keys and tokens, committed to the repository.

Dependencies

CheckStatusWhat it does
Vulnerability audit✅ Onnpm audit fails when a shipped dependency has any known vulnerability, or a development dependency has a high or critical one. Part of the CI workflow on every push and pull request to main.
Supply chain risk✅ OnSocket flags malicious packages, typosquatting and suspicious behaviour that may not yet have a CVE.
Security alerts✅ OnDependabot alerts when a dependency has a known vulnerability, using the GitHub Advisory Database.
Security updates❌ OffDependabot opens pull requests that update vulnerable dependencies. These are handled manually.
Version updates❌ OffDependabot opens pull requests for new dependency versions. These are handled manually.

OpenSSF 🚧

OpenSSF Scorecard

This project is working towards the OpenSSF Best Practices Passing badge, a self-certification covering security policy, vulnerability reporting, build processes, code quality, and more. Currently the OpenSSF Scorecard provides an independent automated assessment of the project's security practices and is an ongoing area of improvement.

Reporting Vulnerabilities

Please do not open public GitHub issues for security vulnerabilities. Use GitHub private vulnerability reporting instead. See SECURITY.md for the full disclosure policy, contact details, and expected response times.

Contributing

This repository is maintained solely by its owner and does not, at present, accept external contributions into the canonical repo. Its source is published openly under the MIT License — every DPUse project is fully open source except DPUse Engine, which remains closed and proprietary.

For security vulnerabilities, see Reporting Vulnerabilities. For bugs, inconsistencies, or other feedback, open a GitHub issue — feedback is read, but responses and fixes are at the maintainer's discretion.

License

This project is licensed under the MIT License, permitting free use, modification, and distribution.

MIT © 2026 Jonathan Terrell

版本与发布记录

@dpuse/dpuse-tool-file-previewer 共发布 34 个版本,首次发布于 2026/08/02;过去 12 个月发布了 34 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.136latest2026/11/121 天前
1.0.1352026/11/112 天前
1.0.1342026/11/112 天前
1.0.1332026/11/112 天前
1.0.1312026/11/103 天前
1.0.1302026/11/058 天前

关于 @dpuse/dpuse-tool-file-previewer 的常见问题

@dpuse/dpuse-tool-file-previewer 是什么?

A library that wraps file-type and jschardet to identify a file's format and encoding from its first bytes, and return a decoded sample of its text.

如何安装 @dpuse/dpuse-tool-file-previewer?

在项目目录运行 npm install @dpuse/dpuse-tool-file-previewer,或使用 pnpm add / yarn add / bun add。

@dpuse/dpuse-tool-file-previewer 支持 TypeScript 吗?

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

@dpuse/dpuse-tool-file-previewer 支持 ESM 还是 CommonJS?

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

@dpuse/dpuse-tool-file-previewer 需要什么版本的 Node.js?

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

@dpuse/dpuse-tool-file-previewer 可以商用吗?

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

@dpuse/dpuse-tool-file-previewer 的下载量有多少?

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

@dpuse/dpuse-tool-file-previewer 还在维护吗?

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