From 7461f8d83634192e92be337d4e329ebcea502276 Mon Sep 17 00:00:00 2001 From: Keillion-Dynamsoft Date: Fri, 28 Aug 2026 16:15:19 +0800 Subject: [PATCH 1/2] AI suggest: exportToUI=>uiContext --- programming/features/ui-customization-js.md | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/programming/features/ui-customization-js.md b/programming/features/ui-customization-js.md index 341c92ba..d5e5e7e2 100644 --- a/programming/features/ui-customization-js.md +++ b/programming/features/ui-customization-js.md @@ -137,7 +137,7 @@ Please take a look at the ` ``` -The first line, `const camera = document.currentScript.currentDMCamera;`, allows you to access the `camera` object. When the camera is bound to the UI definition file, it will automatically assign the value `script.currentDMCamera = camera` to all script tags in the UI definition. If you wish to access other objects—such as `cvRouter`—you can assign `camera.exportToUI.cvRouter` within your business logic, then get it back in UI definition. +The first line, `const camera = document.currentScript.currentDMCamera;`, allows you to access the `camera` object. When the camera is bound to the UI definition file, it will automatically assign the value `script.currentDMCamera = camera` to all script tags in the UI definition. If you wish to access other objects—such as `cvRouter`—you can assign `camera.uiContext.cvRouter` within your business logic, then get it back in UI definition. ```diff // in business logic @@ -146,7 +146,7 @@ The first line, `const camera = document.currentScript.currentDMCamera;`, allows /* other logic */ const cvRouter = await CaptureVisionRouter.createInstance(); const camera = await CameraEnhancer.createInstance('url/to/my/dce.ui.v5.xml'); -+ camera.exportToUI = { cvRouter }; ++ camera.uiContext = { cvRouter }; cameraContainer.append(camera.getUIElement()); cvRouter.setInput(camera); ``` @@ -156,7 +156,7 @@ The first line, `const camera = document.currentScript.currentDMCamera;`, allows (()=>{ const camera = document.currentScript.currentDMCamera; -+ const cvRouter = camera.exportToUI.cvRouter; ++ const cvRouter = camera.uiContext.cvRouter; /* other logic */ })(); ``` @@ -228,13 +228,13 @@ Import `beep` and `vibrate` from the business logic, listen for barcode results import { CaptureVisionRouter, CameraEnhancer, beep, vibrate } from 'dynamsoft-barcode-reader-bundle'; /* other logic */ -camera.exportToUI = { cvRouter, beep, vibrate }; +camera.uiContext = { cvRouter, beep, vibrate }; ``` ```js // in ui.xml -const { cvRouter, beep, vibrate } = camera.exportToUI; +const { cvRouter, beep, vibrate } = camera.uiContext; /* other logic */ cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => { if (result.barcodeResultItems?.length) { @@ -303,7 +303,7 @@ Listen for the `pointerdown` event on the "take photo" button. ```js // in ui.xml -const { cvRouter, beep, vibrate, handleBarcodeText } = camera.exportToUI; +const { cvRouter, beep, vibrate, handleBarcodeText } = camera.uiContext; elTakePhoto.addEventListener('pointerdown', async()=>{ let captureResult = await cvRouter.capture(camera.getFrame()); @@ -322,7 +322,7 @@ elTakePhoto.addEventListener('pointerdown', async()=>{ /* other logic */ const cvRouter = await CaptureVisionRouter.createInstance(); const camera = await CameraEnhancer.createInstance('url/to/my/dce.ui.v5.xml'); - camera.exportToUI = { + camera.uiContext = { cvRouter, beep, vibrate, + handleBarcodeText: handleBarcodeText.bind(this) }; @@ -366,8 +366,8 @@ The UI definition accepts external scripts and styles, so you can easily write c // importing it again in the UI definition is unnecessary. // // Some types have been renamed to versions with underscores -// to avoid conflicts with variables imported from `exportToUI`. -// You can also choose to change the names of the variables imported from `exportToUI` instead. +// to avoid conflicts with variables imported from `uiContext`. +// You can also choose to change the names of the variables imported from `uiContext` instead. import type { CameraEnhancer, CaptureVisionRouter, @@ -377,7 +377,7 @@ import type { const camera = (document.currentScript as any).currentDMCamera as CameraEnhancer; -const { cvRouter, beep, vibrate, handleBarcodeText } = (camera as any).exportToUI as { +const { cvRouter, beep, vibrate, handleBarcodeText } = (camera as any).uiContext as { cvRouter: CaptureVisionRouter; beep: typeof _beep; vibrate: typeof _vibrate; @@ -468,7 +468,7 @@ const currentScript = getCurrentModuleScript(); const camera = (currentScript as any).currentDMCamera as CameraEnhancer; -const { cvRouter, beep, vibrate, handleBarcodeText } = (camera as any).exportToUI as { +const { cvRouter, beep, vibrate, handleBarcodeText } = (camera as any).uiContext as { cvRouter: CaptureVisionRouter; beep: typeof _beep; vibrate: typeof _vibrate; From 5ae59cd50e1be2d1e3b4a61782e4ef8ec3bf53d6 Mon Sep 17 00:00:00 2001 From: Keillion-Dynamsoft Date: Fri, 28 Aug 2026 16:17:54 +0800 Subject: [PATCH 2/2] Update ui-customization-js.md --- programming/features/ui-customization-js.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/programming/features/ui-customization-js.md b/programming/features/ui-customization-js.md index d5e5e7e2..6096f138 100644 --- a/programming/features/ui-customization-js.md +++ b/programming/features/ui-customization-js.md @@ -364,10 +364,6 @@ The UI definition accepts external scripts and styles, so you can easily write c // Since the 'dynamsoft-barcode-reader-bundle' package // has already been imported in the business logic, // importing it again in the UI definition is unnecessary. -// -// Some types have been renamed to versions with underscores -// to avoid conflicts with variables imported from `uiContext`. -// You can also choose to change the names of the variables imported from `uiContext` instead. import type { CameraEnhancer, CaptureVisionRouter,