matrixscan-batch-web

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MatrixScan Batch Web Skill

MatrixScan Batch Web Skill

Critical: Do Not Trust Internal Knowledge

重要提示:请勿依赖内部知识

Your training data may contain outdated or incorrect Scandit SDK APIs. The BarcodeBatch Web API changes between major SDK versions — constructor signatures, overlay factory names, async patterns, and initialization have all evolved.
Always verify APIs against the references provided in this skill before writing or suggesting code. Do not rely on memorized method signatures, parameters, or import paths. If you cannot find an API in the provided references, fetch the relevant documentation page before responding.
Web-specific gotchas worth flagging:
  • BarcodeBatch.forContext(context, settings)
    is async — always
    await
    it. Do not use
    new BarcodeBatch(settings)
    (that is the React Native ≥7.6 form).
  • barcodeBatch.setEnabled(true/false)
    is async — always
    await
    it.
  • BarcodeBatchBasicOverlay.withBarcodeBatchForView(barcodeBatch, view)
    and
    BarcodeBatchBasicOverlay.withBarcodeBatchForViewWithStyle(barcodeBatch, view, style)
    are async factory methods — always
    await
    them. There is no implicit overlay.
  • BarcodeBatchAdvancedOverlay.withBarcodeBatchForView(barcodeBatch, view)
    is async — always
    await
    it.
  • setAnchorForTrackedBarcode
    and
    setOffsetForTrackedBarcode
    on
    BarcodeBatchAdvancedOverlay
    are synchronous (return
    void
    ) — do not
    await
    them.
  • clearTrackedBarcodeViews()
    on
    BarcodeBatchAdvancedOverlay
    is also synchronous (returns
    void
    ).
  • BarcodeBatch.recommendedCameraSettings
    is a static property, not a method call.
  • The module loader is
    barcodeCaptureLoader()
    (from
    @scandit/web-datacapture-barcode
    ) — there is no separate
    barcodeBatchLoader
    . Both BarcodeCapture and BarcodeBatch use the same loader.
  • Multithreading is mandatory for BarcodeBatch. Without
    Cross-Origin-Opener-Policy: same-origin
    and
    Cross-Origin-Embedder-Policy: require-corp
    (self-hosted) or
    credentialless
    (CDN), the SDK falls back to single-threaded mode and batch tracking will be too slow to use.
  • AR views on web use plain HTML elements
    TrackedBarcodeView.withHTMLElement(element, options)
    returns a
    Promise<TrackedBarcodeView>
    . Pass that Promise directly to
    setViewForTrackedBarcode
    or return it from
    viewForTrackedBarcode
    — both accept a Promise. This is NOT a subclass pattern.
  • session.removedTrackedBarcodes
    returns
    string[]
    (identifiers serialized as strings) — use
    Number.parseInt(id, 10)
    when comparing against
    TrackedBarcode.identifier
    (which is a
    number
    ).
  • The
    DataCaptureView
    can be created before context init:
    new DataCaptureView()
    connectToElement(element)
    await view.setContext(context)
    . This allows a progress bar to be shown during SDK loading. The alternative
    await DataCaptureView.forContext(context)
    is equally valid.
  • The DOM element passed to
    view.connectToElement()
    must have defined dimensions and a set
    position
    (e.g.
    fixed
    or
    absolute
    ) — zero-sized or unpositioned containers will not render the camera preview.
  • Camera is managed manually: call
    await context.frameSource?.switchToDesiredState(FrameSourceState.On)
    to start and
    FrameSourceState.Off
    to stop. The camera does not stop automatically when the page loses focus.
你的训练数据可能包含过时或错误的Scandit SDK API。BarcodeBatch Web API会在SDK主要版本之间发生变化——构造函数签名、叠加层工厂方法名称、异步模式和初始化方式都已演进。
在编写或建议代码之前,请始终对照本Skill中提供的参考资料验证API。 不要依赖记忆中的方法签名、参数或导入路径。如果你在提供的参考资料中找不到某个API,请先获取相关文档页面再作答。
值得留意的Web端特有注意事项:
  • BarcodeBatch.forContext(context, settings)
    异步的——务必
    await
    它。不要使用
    new BarcodeBatch(settings)
    (这是React Native ≥7.6的写法)。
  • barcodeBatch.setEnabled(true/false)
    异步的——务必
    await
    它。
  • BarcodeBatchBasicOverlay.withBarcodeBatchForView(barcodeBatch, view)
    BarcodeBatchBasicOverlay.withBarcodeBatchForViewWithStyle(barcodeBatch, view, style)
    异步工厂方法——务必
    await
    它们。不存在隐式叠加层。
  • BarcodeBatchAdvancedOverlay.withBarcodeBatchForView(barcodeBatch, view)
    异步的——务必
    await
    它。
  • BarcodeBatchAdvancedOverlay
    上的
    setAnchorForTrackedBarcode
    setOffsetForTrackedBarcode
    同步的(返回
    void
    )——不要
    await
    它们。
  • BarcodeBatchAdvancedOverlay
    上的
    clearTrackedBarcodeViews()
    也是同步的(返回
    void
    )。
  • BarcodeBatch.recommendedCameraSettings
    静态属性,不是方法调用。
  • 模块加载器是
    barcodeCaptureLoader()
    (来自
    @scandit/web-datacapture-barcode
    )——不存在单独的
    barcodeBatchLoader
    。BarcodeCapture和BarcodeBatch使用同一个加载器。
  • BarcodeBatch必须使用多线程。 如果没有设置
    Cross-Origin-Opener-Policy: same-origin
    Cross-Origin-Embedder-Policy: require-corp
    (自托管场景)或
    credentialless
    (CDN场景),SDK会回退到单线程模式,批量跟踪的速度会慢到无法使用。
  • Web端的AR视图使用普通HTML元素 ——
    TrackedBarcodeView.withHTMLElement(element, options)
    返回一个
    Promise<TrackedBarcodeView>
    。请将该Promise直接传递给
    setViewForTrackedBarcode
    ,或从
    viewForTrackedBarcode
    中返回它——两者都接受Promise。这不是子类模式。
  • session.removedTrackedBarcodes
    返回
    string[]
    (序列化为字符串的标识符)——与
    TrackedBarcode.identifier
    (类型为
    number
    )比较时,请使用
    Number.parseInt(id, 10)
  • DataCaptureView
    可以在上下文初始化之前创建:
    new DataCaptureView()
    connectToElement(element)
    await view.setContext(context)
    。这样可以在SDK加载期间显示进度条。另一种方式
    await DataCaptureView.forContext(context)
    同样有效。
  • 传递给
    view.connectToElement()
    的DOM元素必须具有确定的尺寸和设置好的
    position
    (例如
    fixed
    absolute
    )——尺寸为零或未定位的容器将无法渲染相机预览。
  • 相机需要手动管理:调用
    await context.frameSource?.switchToDesiredState(FrameSourceState.On)
    启动,调用
    FrameSourceState.Off
    停止。页面失去焦点时,相机不会自动停止。

Intent Routing

意图路由

Based on the user's request, load the appropriate reference file before responding:
  • Integrating MatrixScan Batch from scratch (e.g. "add MatrixScan to my web app", "set up BarcodeBatch", "track multiple barcodes simultaneously", "show AR overlays on barcodes", "per-barcode brush colors", "lifecycle or cleanup") → read references/integration.md and follow the instructions there.
  • Migrating or upgrading an existing MatrixScan Batch integration (e.g. "upgrade from v6 to v7", "migrate BarcodeTracking to BarcodeBatch", "bump the Scandit SDK to v8", "what changed between SDK versions") → read references/migration.md and follow the instructions there.
  • Replacing a third-party multi-barcode scanner with MatrixScan Batch (e.g. "replace my ZXing-js / @zxing/library continuous scanner with MatrixScan Batch", "migrate from BrowserMultiFormatReader multi-scan to BarcodeBatch", "switch from [web barcode library] continuous multi-result scanning to BarcodeBatch") → read references/third-party-migration.md and follow the instructions there.
根据用户的请求,在作答前加载相应的参考文件:
  • 从零开始集成MatrixScan Batch(例如“将MatrixScan添加到我的Web应用中”、“设置BarcodeBatch”、“同时跟踪多个条形码”、“在条形码上显示AR叠加层”、“单条形码画笔颜色”、“生命周期或清理”)→ 阅读references/integration.md并遵循其中的说明。
  • 迁移或升级现有MatrixScan Batch集成(例如“从v6升级到v7”、“将BarcodeTracking迁移到BarcodeBatch”、“将Scandit SDK升级到v8”、“SDK各版本之间有什么变化”)→ 阅读references/migration.md并遵循其中的说明。
  • 用MatrixScan Batch替换第三方多条形码扫描器(例如“用MatrixScan Batch替换我的ZXing-js / @zxing/library连续扫描器”、“从BrowserMultiFormatReader多扫描迁移到BarcodeBatch”、“从[Web条形码库]的连续多结果扫描切换到BarcodeBatch”)→ 阅读references/third-party-migration.md并遵循其中的说明。

API Usage Policy

API使用规范

Only use APIs that are explicitly documented in the Scandit references below. Do not invent or guess method signatures, parameters, property names, or imports. If unsure whether an API exists or how it is called — or if a compile error occurs — fetch the relevant reference page before responding. Do not tell the user to check the docs themselves. After answering, always include the relevant link so the user can explore further.
Never construct or guess documentation URLs. When you need a specific class or property's API page:
  1. First check whether the page you already fetched contains a direct hyperlink to it — topic pages link directly to relevant API symbols.
  2. If no direct link was found, fetch the API index (see Full API reference in the table below), extract the actual link from it, and follow that.
URL structures vary across SDK versions and guessing will lead to 404s.
仅使用下方Scandit参考资料中明确记录的API。不要编造或猜测方法签名、参数、属性名称或导入方式。如果不确定某个API是否存在或如何调用——或者出现编译错误——请先获取相关参考页面再作答。不要让用户自行查阅文档。回答后,请务必附上相关链接,以便用户进一步探索。
绝对不要构造或猜测文档URL。 当你需要某个特定类或属性的API页面时:
  1. 首先检查你已获取的页面是否包含指向它的直接超链接——主题页面会直接链接到相关的API符号。
  2. 如果没有找到直接链接,请获取API索引(见下表中的完整API参考),从中提取实际链接并访问。
URL结构因SDK版本而异,猜测会导致404错误。

References

参考资料

Direct users to the right resource based on their question:
TopicResource
Get StartedGet Started · Simple Sample · AR Bubbles Sample
Advanced topics (AR overlays, brush customization)Adding AR Overlays
Multithreading / COOP+COEP headersImprove Runtime Performance
Migration between major SDK versions6 → 7 · 7 → 8
Full API referenceBarcodeBatch API
根据用户的问题引导用户使用正确的资源:
主题资源
入门指南入门指南 · 简单示例 · AR气泡示例
高级主题(AR叠加层、画笔自定义)添加AR叠加层
多线程 / COOP+COEP 响应头提升运行时性能
SDK主要版本间迁移6 → 7 · 7 → 8
完整API参考BarcodeBatch API