matrixscan-batch-web
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMatrixScan 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:
- is async — always
BarcodeBatch.forContext(context, settings)it. Do not useawait(that is the React Native ≥7.6 form).new BarcodeBatch(settings) - is async — always
barcodeBatch.setEnabled(true/false)it.await - and
BarcodeBatchBasicOverlay.withBarcodeBatchForView(barcodeBatch, view)are async factory methods — alwaysBarcodeBatchBasicOverlay.withBarcodeBatchForViewWithStyle(barcodeBatch, view, style)them. There is no implicit overlay.await - is async — always
BarcodeBatchAdvancedOverlay.withBarcodeBatchForView(barcodeBatch, view)it.await - and
setAnchorForTrackedBarcodeonsetOffsetForTrackedBarcodeare synchronous (returnBarcodeBatchAdvancedOverlay) — do notvoidthem.await - on
clearTrackedBarcodeViews()is also synchronous (returnsBarcodeBatchAdvancedOverlay).void - is a static property, not a method call.
BarcodeBatch.recommendedCameraSettings - The module loader is (from
barcodeCaptureLoader()) — there is no separate@scandit/web-datacapture-barcode. Both BarcodeCapture and BarcodeBatch use the same loader.barcodeBatchLoader - Multithreading is mandatory for BarcodeBatch. Without and
Cross-Origin-Opener-Policy: same-origin(self-hosted) orCross-Origin-Embedder-Policy: require-corp(CDN), the SDK falls back to single-threaded mode and batch tracking will be too slow to use.credentialless - AR views on web use plain HTML elements — returns a
TrackedBarcodeView.withHTMLElement(element, options). Pass that Promise directly toPromise<TrackedBarcodeView>or return it fromsetViewForTrackedBarcode— both accept a Promise. This is NOT a subclass pattern.viewForTrackedBarcode - returns
session.removedTrackedBarcodes(identifiers serialized as strings) — usestring[]when comparing againstNumber.parseInt(id, 10)(which is aTrackedBarcode.identifier).number - The can be created before context init:
DataCaptureView→new DataCaptureView()→connectToElement(element). This allows a progress bar to be shown during SDK loading. The alternativeawait view.setContext(context)is equally valid.await DataCaptureView.forContext(context) - The DOM element passed to must have defined dimensions and a set
view.connectToElement()(e.g.positionorfixed) — zero-sized or unpositioned containers will not render the camera preview.absolute - Camera is managed manually: call to start and
await context.frameSource?.switchToDesiredState(FrameSourceState.On)to stop. The camera does not stop automatically when the page loses focus.FrameSourceState.Off
你的训练数据可能包含过时或错误的Scandit SDK API。BarcodeBatch Web API会在SDK主要版本之间发生变化——构造函数签名、叠加层工厂方法名称、异步模式和初始化方式都已演进。
在编写或建议代码之前,请始终对照本Skill中提供的参考资料验证API。 不要依赖记忆中的方法签名、参数或导入路径。如果你在提供的参考资料中找不到某个API,请先获取相关文档页面再作答。
值得留意的Web端特有注意事项:
- 是异步的——务必
BarcodeBatch.forContext(context, settings)它。不要使用await(这是React Native ≥7.6的写法)。new BarcodeBatch(settings) - 是异步的——务必
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。BarcodeCapture和BarcodeBatch使用同一个加载器。barcodeBatchLoader - BarcodeBatch必须使用多线程。 如果没有设置和
Cross-Origin-Opener-Policy: same-origin(自托管场景)或Cross-Origin-Embedder-Policy: require-corp(CDN场景),SDK会回退到单线程模式,批量跟踪的速度会慢到无法使用。credentialless - Web端的AR视图使用普通HTML元素 —— 返回一个
TrackedBarcodeView.withHTMLElement(element, options)。请将该Promise直接传递给Promise<TrackedBarcodeView>,或从setViewForTrackedBarcode中返回它——两者都接受Promise。这不是子类模式。viewForTrackedBarcode - 返回
session.removedTrackedBarcodes(序列化为字符串的标识符)——与string[](类型为TrackedBarcode.identifier)比较时,请使用number。Number.parseInt(id, 10) - 可以在上下文初始化之前创建:
DataCaptureView→new DataCaptureView()→connectToElement(element)。这样可以在SDK加载期间显示进度条。另一种方式await view.setContext(context)同样有效。await DataCaptureView.forContext(context) - 传递给的DOM元素必须具有确定的尺寸和设置好的
view.connectToElement()(例如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:
- First check whether the page you already fetched contains a direct hyperlink to it — topic pages link directly to relevant API symbols.
- 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页面时:
- 首先检查你已获取的页面是否包含指向它的直接超链接——主题页面会直接链接到相关的API符号。
- 如果没有找到直接链接,请获取API索引(见下表中的完整API参考),从中提取实际链接并访问。
URL结构因SDK版本而异,猜测会导致404错误。
References
参考资料
Direct users to the right resource based on their question:
| Topic | Resource |
|---|---|
| Get Started | Get Started · Simple Sample · AR Bubbles Sample |
| Advanced topics (AR overlays, brush customization) | Adding AR Overlays |
| Multithreading / COOP+COEP headers | Improve Runtime Performance |
| Migration between major SDK versions | 6 → 7 · 7 → 8 |
| Full API reference | BarcodeBatch API |