Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export interface for VideoDeviceInfo #210

Open
qidulak opened this issue Sep 12, 2024 · 4 comments
Open

Export interface for VideoDeviceInfo #210

qidulak opened this issue Sep 12, 2024 · 4 comments

Comments

@qidulak
Copy link

qidulak commented Sep 12, 2024

Interface VideoDeviceInfo that is returned by BarcodeScanner.getAllCameras() is not publicly exported, so I need to define it on my own, If I want to make some logic and further process this data. I believe, that Interfaces returned by all public methods should be exported for strongly typped app.

@Keillion
Copy link
Collaborator

Keillion commented Sep 12, 2024

We will consider your suggestion carefully.

Currently, you can simply implement your needs in this way.

let videoInfos: ReturnType<typeof BarcodeScanner.getAllCameras> = null;
let videoInfo: ReturnType<typeof BarcodeScanner.getAllCameras>[0] = null;
// assign later

@Keillion
Copy link
Collaborator

I tested, at least in [email protected] or [email protected], VideoDeviceInfo is exported.

import { VideoDeviceInfo } from 'dynamsoft-camera-enhancer';
// or
import { VideoDeviceInfo } from 'dynamsoft-barcode-reader-bundle';

@Keillion
Copy link
Collaborator

Keillion commented Sep 12, 2024

Oh, I know you use dynamsoft-javascript-barcode@9.

In [email protected], VideoDeviceInfo is exported.

You can consider upgrading to the latest version 9, which is mainly adapted for the latest iOS to improve camera selection.

@dobripet
Copy link

dobripet commented Sep 13, 2024

I did check [email protected] dbr.d.ts file. VideoDeviceInfo is declared there but missing in exports. So it cannot be referenced via import.

image

The workaround by return type needs to be tweaked as it is promise and that is kind of messy.

type VideoDeviceInfo = Awaited<ReturnType<BarcodeScanner['getAllCameras']>>[number];

But as you said VideoDeviceInfo import works for dynamsoft-camera-enhancer which comes with dynamsoft-javascript-barcode so I guess its fine to import it from there, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants