BlinkID / blinkid-in-browser

BlinkID In-browser SDK for WebAssembly-enabled browsers.
https://microblink.com/blinkid
59 stars 30 forks source link

Feature request: Allow declaring path of every file for WasmSDKLoadSettings #80

Open icopp opened 2 years ago

icopp commented 2 years ago

Currently you can set engineLocation and workerLocation, but this still basically requires dumping all the contents of resources into a static path.

If it was possible to set an individual path for each required file, it would be possible to include the entire thing in an appropriately build process, such as with Webpack's resource loaders or Next.js's use of URL and import.meta.url for importing resource files.

vjekoart commented 2 years ago

Hi @icopp,

Thanks for the feedback.

Regarding your use case, we already have an individual path for the workerLocation property. Does that suit your needs? For example, you can use workerLocation property in the following manner: loadSettings.workerLocation = "/my-path/BlinkIDWasmSDK.worker.min.js".

If not, could you provide an example of how you'd like to set properties for workerLocation and engineLocation properties?

Furthermore, exposing all necessary files in resources/ folder is not straightforward with the current implementation. Right now, a worker script will load a JS script from the resources/ folder, which will in turn load WebAssembly module. That means that tool like Webpack may be able to include JS script from the resources/ folder in the final bundle, but it won't have any knowledge about the WebAssembly module and related .data file.

Also, we dynamically choose which WebAssembly bundle from the resources/ folder should be used based on the browser features. For example, in older web browsers subfolder resources/basic/ will be used, while in most modern web browsers folder resources/advanced/ will be used.

Sincerely, Vjekoslav