@anyline/anyline-js

中文文档
56.6.0发布于 2026/10/28SEE LICENSE IN LICENSE.mdTypeScriptCommonJS零依赖近 30 天下载 1.2万

Anyline Web SDK

原始使用文档
文档目录9 节
  1. Supported Use Cases
  2. Installation
  3. Quick Start
  4. Self-Hosting Assets
  5. Documentation
  6. Try it Locally
  7. Package Contents
  8. Resources
  9. License

Anyline Web SDK

npm version License

Anyline Web SDK enables OCR and barcode scanning directly in the browser.

Live Demo | Documentation | API Reference

Supported Use Cases

  • Barcode - QR Code, Data Matrix, Aztec, PDF417, Code 128, EAN, UPC, and more
  • ID Scanning - MRZ (passports, ID cards) and driving licenses
  • Tire & Automotive - VIN, TIN, tire size, license plates
  • Meters - Analog, digital, and dial meters
  • OCR - Shipping containers and custom OCR

See the documentation for the full list of supported formats and regions.

Installation

npm install @anyline/anyline-js

Or via CDN:

<script src="https://cdn.jsdelivr.net/npm/@anyline/anyline-js/anyline.js"></script>

Quick Start

HTML:

<div id="scanner-root" style="width: 100%; height: 100vh;"></div>

TypeScript/JavaScript:

import { init } from '@anyline/anyline-js';

// Initialize the scanner
const anyline = init({
  // Your Anyline license key (obtain at anyline.com/request/contact)
  license: 'YOUR_LICENSE_KEY',
  // DOM element where the scanner will be mounted
  element: document.getElementById('scanner-root'),
  // Preset for the scan type (see documentation for all presets)
  preset: 'vin',
});

// Handle scan results
anyline.onResult = ({ result }) => {
  console.log('Scanned:', result);
};

// Start the camera and begin scanning
anyline.startScanning().catch((error) => {
  console.error('Failed to start:', error);
});

// Clean up resources when done
window.addEventListener('beforeunload', () => {
  anyline.dispose();
});

Note: Web SDK requires HTTPS (except localhost) and camera permissions. The browser will prompt the user to allow camera access.

For available presets and configuration options, see the Getting Started Guide.

Self-Hosting Assets

By default, the SDK loads assets from Anyline's CDN. To self-host these assets for better performance or to comply with network restrictions:

  1. Copy the anylinejs/ folder to your web server
  2. Set the anylinePath option to point to the folder location
const anyline = init({
  license: 'YOUR_LICENSE_KEY',
  element: document.getElementById('scanner-root'),
  preset: 'vin',
  anylinePath: '/path/to/anylinejs',
});

See Performance Optimization for CDN configuration and caching details.

Documentation

Try it Locally

The package includes a demo application. To run it:

  1. Request a test license for your domain
  2. Edit your hosts file to route your domain to localhost (licenses are domain-restricted)
  3. Run the demo:
npm run demo
  1. Visit http://yourdomain.com:8080/demo

For smartphone testing over the network (HTTPS on port 8443):

npm run demo:network

Open https://<your-ip>:8443/ on your phone and accept the self-signed certificate warning, then choose the demo folder for running demo.

Package Contents

  • anylinejs/ - Assets for self-hosting
  • anyline.d.ts - TypeScript type definitions
  • anyline.js - Main SDK library
  • LICENSE.md - Third-party license agreements

Resources

License

This SDK requires a commercial license from Anyline. Request a trial license to get started.

See LICENSE.md for third-party license agreements.

版本与发布记录

@anyline/anyline-js 共发布 72 个版本,首次发布于 2021/03/19;过去 12 个月发布了 8 个版本。

版本发布日期距今
56.6.0latest2026/10/2810 天前
56.1.32026/09/091 个月前
56.1.22026/07/223 个月前
56.1.12026/07/064 个月前
55.9.12026/02/198 个月前
55.9.02026/02/049 个月前

关于 @anyline/anyline-js 的常见问题

@anyline/anyline-js 是什么?

Anyline Web SDK

如何安装 @anyline/anyline-js?

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

@anyline/anyline-js 支持 TypeScript 吗?

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

@anyline/anyline-js 支持 ESM 还是 CommonJS?

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

@anyline/anyline-js 可以商用吗?

@anyline/anyline-js 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@anyline/anyline-js 的下载量有多少?

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

@anyline/anyline-js 还在维护吗?

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