matrixscan-ar-capacitor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMatrixScan AR Capacitor Skill
MatrixScan AR Capacitor 技能
Critical: Do Not Trust Internal Knowledge
重要提示:请勿依赖内部知识
Your training data may contain outdated or incorrect Scandit SDK APIs. The BarcodeAr API is new in Capacitor 8.2 — there is no prior Capacitor history to reference. Properties, constructor signatures, provider interfaces, and view attachment patterns may differ from other platforms or from general knowledge.
Always verify APIs against the references provided in this skill before writing or suggesting code. Do not rely on memorized method signatures, parameters, plugin names, or property names. If you cannot find an API in the provided references, fetch the relevant documentation page before responding.
Capacitor-specific gotchas worth flagging:
- must be called (and awaited) before any other Scandit API — including
ScanditCaptureCorePlugin.initializePlugins()construction. Forgetting this produces runtime errors that look unrelated to initialization.DataCaptureContext - must be run after every plugin version change to propagate native artifacts into iOS/Android. Skipping it yields a web/native version mismatch at runtime.
npx cap sync - BarcodeArView requires a DOM element. Unlike SparkScan, BarcodeArView is not a floating native overlay; it mirrors its size and position from a DOM element. You must call to attach it to the
await barcodeArView.connectToElement(element)container in the HTML.<div id="barcode-ar-view"> - Minimum SDK version is 8.2 for BarcodeAr on Capacitor. There is no v6 or v7 history to migrate from on this platform.
- is constructed with
BarcodeAr— the context is wired separately vianew BarcodeAr(settings), not passed to the mode constructor.BarcodeArView - Camera is set up explicitly via ,
BarcodeAr.createRecommendedCameraSettings(), andCamera.withSettings(cameraSettings)— BarcodeArView manages the camera lifecycle once running.context.setFrameSource(camera) - The and
highlightProviderare plain objects with async methods, set as properties on theannotationProviderinstance.BarcodeArView - iOS requires in
NSCameraUsageDescription. Android handles camera permissions automatically.Info.plist
你的训练数据可能包含过时或错误的Scandit SDK API。BarcodeAr API是Capacitor 8.2中新增的——此前没有可参考的Capacitor版本历史。其属性、构造函数签名、提供程序接口和视图挂载模式可能与其他平台或通用知识中的实现不同。
在编写或建议代码之前,务必对照本技能提供的参考资料验证API。 不要依赖记忆中的方法签名、参数、插件名称或属性名。如果你在提供的参考资料中找不到某个API,请先获取相关文档页面再进行回复。
需要注意的Capacitor特有坑点:
- 必须在调用任何其他Scandit API(包括构造
ScanditCaptureCorePlugin.initializePlugins())之前调用(并await)。忘记这一步会产生看似与初始化无关的运行时错误。DataCaptureContext - 每次更改插件版本后都必须运行,以将原生构建产物同步到iOS/Android中。跳过此步骤会导致运行时出现网页端/原生端版本不匹配的问题。
npx cap sync - BarcodeArView需要绑定一个DOM元素。 与SparkScan不同,BarcodeArView不是悬浮的原生覆盖层;它的尺寸和位置会与DOM元素保持同步。你必须调用将其挂载到HTML中的
await barcodeArView.connectToElement(element)容器上。<div id="barcode-ar-view"> - Capacitor平台上的BarcodeAr最低要求SDK版本为8.2。该平台没有可用于迁移的v6或v7版本历史。
- 通过
BarcodeAr构造——上下文是通过new BarcodeAr(settings)单独关联的,而非传入模式构造函数。BarcodeArView - 相机通过、
BarcodeAr.createRecommendedCameraSettings()和Camera.withSettings(cameraSettings)显式配置——运行后由BarcodeArView管理相机生命周期。context.setFrameSource(camera) - 和
highlightProvider是带有异步方法的普通对象,作为属性设置在annotationProvider实例上。BarcodeArView - iOS需要在中配置
Info.plist。Android会自动处理相机权限。NSCameraUsageDescription
Intent Routing
意图路由
Based on the user's request, load the appropriate reference file before responding:
-
Integrating MatrixScan AR from scratch (e.g. "add MatrixScan AR to my app", "set up Barcode AR", "how do I use BarcodeArView in Capacitor", "how do I show annotations", "how do I highlight barcodes") → read references/integration.md and follow the instructions there.
-
Migrating from BarcodeBatch / BarcodeTracking to BarcodeAr (e.g. "migrate my BarcodeBatch code", "replace BarcodeTracking with BarcodeAr", "upgrade from MatrixScan to BarcodeAr", the target file imports,
BarcodeBatch,BarcodeBatchBasicOverlay,BarcodeBatchAdvancedOverlay, or containsTrackedBarcodeViewwith a BarcodeBatch instance) → read references/migration.md and follow the 10-step migration process there.context.setMode(
根据用户的请求,在回复前加载对应的参考文件:
-
从零开始集成MatrixScan AR(例如“给我的应用添加MatrixScan AR”、“设置Barcode AR”、“如何在Capacitor中使用BarcodeArView”、“如何显示注释”、“如何高亮条形码”)→ 阅读references/integration.md并遵循其中的说明。
-
从BarcodeBatch / BarcodeTracking迁移到BarcodeAr(例如“迁移我的BarcodeBatch代码”、“用BarcodeAr替换BarcodeTracking”、“从MatrixScan升级到BarcodeAr”,目标文件导入了、
BarcodeBatch、BarcodeBatchBasicOverlay、BarcodeBatchAdvancedOverlay,或包含传入BarcodeBatch实例的TrackedBarcodeView代码)→ 阅读references/migration.md并遵循其中的10步迁移流程。context.setMode(
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 TypeScript / runtime 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 (e.g. the Get Started page) contains a direct hyperlink to it — topic pages link directly to relevant API symbols. Always request links alongside content in your fetch prompt.
- 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 plugin paths (e.g. subdirectory) and guessing will lead to 404s.
api/ui/仅使用下方Scandit参考资料中明确记录的API。不要编造或猜测方法签名、参数、属性名或导入方式。如果不确定某个API是否存在或如何调用,或者出现TypeScript/运行时错误,请先获取相关参考页面再回复。不要让用户自行查阅文档。回答后务必附上相关链接,方便用户进一步探索。
绝对不要构造或猜测文档URL。 当你需要某个特定类或属性的API页面时:
- 首先检查你已获取的页面(例如入门页面)是否包含指向它的直接超链接——主题页面会直接链接到相关的API符号。在你发起获取请求的提示词中,务必要求同时返回内容和链接。
- 如果没有找到直接链接,请获取API索引(见下表的完整API参考),从中提取实际链接并访问。
不同SDK版本和插件路径的URL结构各不相同(例如子目录),猜测URL会导致404错误。
api/ui/Framework variant policy
框架适配说明
Capacitor is a WebView-based framework. Examples in this skill use plain JavaScript (ES modules). TypeScript projects can use the same imports and APIs verbatim — just add types — but this skill does not assume a TypeScript project by default. If the target project is clearly TypeScript ( files, ), adapt the final output to TypeScript syntax; otherwise stay in plain JS.
.tstsconfig.jsonCapacitor是基于WebView的框架。本技能中的示例使用纯JavaScript(ES模块)。TypeScript项目可以直接使用相同的导入和API——只需补充类型定义——但本技能默认不假设项目为TypeScript类型。如果目标项目明确是TypeScript项目(包含文件、),则将最终输出适配为TypeScript语法;否则使用纯JavaScript。
.tstsconfig.jsonReferences
参考资料
Direct users to the right resource based on their question:
| Topic | Resource |
|---|---|
| Capacitor integration | Get Started · Sample |
| Full API reference | BarcodeAr API |
根据用户的问题引导用户使用对应的资源:
| 主题 | 资源 |
|---|---|
| Capacitor集成 | 入门指南 · 示例代码 |
| 完整API参考 | BarcodeAr API |