diff --git a/nokhwajs/nokhwa.d.ts b/nokhwajs/nokhwa.d.ts index bac6606..74c5646 100644 --- a/nokhwajs/nokhwa.d.ts +++ b/nokhwajs/nokhwa.d.ts @@ -806,11 +806,11 @@ export interface InitOutput { readonly __wbindgen_malloc: (a: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; readonly __wbindgen_export_2: WebAssembly.Table; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h34bdc8cc85c4eb6b: (a: number, b: number, c: number) => void; + readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb819b4606ac1b551: (a: number, b: number, c: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_free: (a: number, b: number) => void; readonly __wbindgen_exn_store: (a: number) => void; - readonly wasm_bindgen__convert__closures__invoke2_mut__h138614ba43225cc0: (a: number, b: number, c: number, d: number) => void; + readonly wasm_bindgen__convert__closures__invoke2_mut__h4d505d8c21e259a2: (a: number, b: number, c: number, d: number) => void; } /** diff --git a/nokhwajs/nokhwa.js b/nokhwajs/nokhwa.js index 9217551..c867ba4 100644 --- a/nokhwajs/nokhwa.js +++ b/nokhwajs/nokhwa.js @@ -211,7 +211,7 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } function __wbg_adapter_26(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h34bdc8cc85c4eb6b(arg0, arg1, addHeapObject(arg2)); + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb819b4606ac1b551(arg0, arg1, addHeapObject(arg2)); } /** @@ -279,7 +279,7 @@ function passArray8ToWasm0(arg, malloc) { return ptr; } function __wbg_adapter_240(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h138614ba43225cc0(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); + wasm.wasm_bindgen__convert__closures__invoke2_mut__h4d505d8c21e259a2(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); } /** @@ -1839,6 +1839,10 @@ async function init(input) { imports.wbg.__wbg_setsrcObject_340bcd93145a797b = function(arg0, arg1) { getObject(arg0).srcObject = getObject(arg1); }; + imports.wbg.__wbg_mediaDevices_b3973ebf40387065 = function() { return handleError(function (arg0) { + var ret = getObject(arg0).mediaDevices; + return addHeapObject(ret); + }, arguments) }; imports.wbg.__wbg_instanceof_HtmlCanvasElement_fd3cbbe3906d7792 = function(arg0) { var ret = getObject(arg0) instanceof HTMLCanvasElement; return ret; @@ -1860,10 +1864,13 @@ async function init(input) { getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }, arguments) }; - imports.wbg.__wbg_mediaDevices_b3973ebf40387065 = function() { return handleError(function (arg0) { - var ret = getObject(arg0).mediaDevices; - return addHeapObject(ret); - }, arguments) }; + imports.wbg.__wbg_data_315524ada7b563f4 = function(arg0, arg1) { + var ret = getObject(arg1).data; + var ptr0 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; imports.wbg.__wbg_instanceof_HtmlVideoElement_acfaf2202e3e0d29 = function(arg0) { var ret = getObject(arg0) instanceof HTMLVideoElement; return ret; @@ -1874,13 +1881,6 @@ async function init(input) { imports.wbg.__wbg_setheight_6a5930569b122df0 = function(arg0, arg1) { getObject(arg0).height = arg1 >>> 0; }; - imports.wbg.__wbg_data_315524ada7b563f4 = function(arg0, arg1) { - var ret = getObject(arg1).data; - var ptr0 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; - }; imports.wbg.__wbg_label_21de6784a6632e75 = function(arg0, arg1) { var ret = getObject(arg1).label; var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); @@ -2033,7 +2033,7 @@ async function init(input) { throw takeObject(arg0); }; imports.wbg.__wbindgen_closure_wrapper761 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 65, __wbg_adapter_26); + var ret = makeMutClosure(arg0, arg1, 64, __wbg_adapter_26); return addHeapObject(ret); }; diff --git a/nokhwajs/nokhwa_bg.js b/nokhwajs/nokhwa_bg.js index e80d729..bab4a27 100644 --- a/nokhwajs/nokhwa_bg.js +++ b/nokhwajs/nokhwa_bg.js @@ -47,6 +47,26 @@ function takeObject(idx) { return ret; } +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachegetFloat64Memory0 = null; +function getFloat64Memory0() { + if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { + cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachegetFloat64Memory0; +} + +let cachegetInt32Memory0 = null; +function getInt32Memory0() { + if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { + cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachegetInt32Memory0; +} + let WASM_VECTOR_LEN = 0; const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; @@ -104,18 +124,6 @@ function passStringToWasm0(arg, malloc, realloc) { return ptr; } -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - function debugString(val) { // primitive types const type = typeof val; @@ -205,8 +213,8 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } -function __wbg_adapter_24(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hcf34bb914ec8dc3e(arg0, arg1, addHeapObject(arg2)); +function __wbg_adapter_26(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha79fab5af65c7d0b(arg0, arg1, addHeapObject(arg2)); } /** @@ -215,7 +223,7 @@ function __wbg_adapter_24(arg0, arg1, arg2) { * This will error if there is no valid web context or the web API is not supported * # JS-WASM * In exported JS bindings, the name of the function is `requestPermissions`. It may throw an exception. -* @returns {Promise} +* @returns {any} */ export function requestPermissions() { var ret = wasm.requestPermissions(); @@ -255,14 +263,6 @@ function _assertClass(instance, klass) { return instance.ptr; } -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - function getArrayU8FromWasm0(ptr, len) { return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); } @@ -281,8 +281,8 @@ function passArray8ToWasm0(arg, malloc) { WASM_VECTOR_LEN = arg.length; return ptr; } -function __wbg_adapter_204(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h2c139c16959e39a8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +function __wbg_adapter_240(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__hf03b20e2f7b10743(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); } /** @@ -349,894 +349,848 @@ export class CameraConstraints { const ptr = this.__destroy_into_raw(); wasm.__wbg_cameraconstraints_free(ptr); } -} -/** -* A builder that builds a [`JSCameraConstraints`] that is used to construct a [`JSCamera`]. -* See More: [`Constraints MDN`](https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API/Constraints), [`Properties of Media Tracks MDN`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) -* # JS-WASM -* This is exported as `CameraConstraintsBuilder`. -*/ -export class CameraConstraintsBuilder { - - static __wrap(ptr) { - const obj = Object.create(CameraConstraintsBuilder.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_cameraconstraintsbuilder_free(ptr); + /** + * Gets the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) + * # JS-WASM + * This is exported as `get_MediaStreamConstraints`. + * @returns {any} + */ + get MediaStreamConstraints() { + var ret = wasm.cameraconstraints_media_constraints(this.ptr); + return takeObject(ret); } -} -/** -* Information about a Camera e.g. its name. -* `description` amd `misc` may contain information that may differ from backend to backend. Refer to each backend for details. -* `index` is a camera's index given to it by (usually) the OS usually in the order it is known to the system. -* # JS-WASM -* This is exported as a `CameraInfo`. -*/ -export class CameraInfo { - - static __wrap(ptr) { - const obj = Object.create(CameraInfo.prototype); - obj.ptr = ptr; - - return obj; + /** + * Gets the minimum [`Resolution`]. + * # JS-WASM + * This is exported as `get_MinResolution`. + * @returns {Resolution | undefined} + */ + get MinResolution() { + var ret = wasm.cameraconstraints_min_resolution(this.ptr); + return ret === 0 ? undefined : Resolution.__wrap(ret); } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; + /** + * Gets the minimum [`Resolution`]. + * # JS-WASM + * This is exported as `set_MinResolution`. + * @param {Resolution} min_resolution + */ + set MinResolution(min_resolution) { + _assertClass(min_resolution, Resolution); + var ptr0 = min_resolution.ptr; + min_resolution.ptr = 0; + wasm.cameraconstraints_set_min_resolution(this.ptr, ptr0); } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_camerainfo_free(ptr); + /** + * Gets the internal [`Resolution`] + * # JS-WASM + * This is exported as `get_Resolution`. + * @returns {Resolution} + */ + get Resolution() { + var ret = wasm.cameraconstraints_resolution(this.ptr); + return Resolution.__wrap(ret); } /** - * Create a new [`CameraInfo`]. + * Sets the internal [`Resolution`] + * Note that this doesn't affect the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) until you call + * [`apply_constraints()`](crate::js_camera::JSCameraConstraints::apply_constraints) * # JS-WASM - * This is exported as a constructor for [`CameraInfo`]. - * @param {string} human_name - * @param {string} description - * @param {string} misc - * @param {number} index + * This is exported as `set_Resolution`. + * @param {Resolution} preferred_resolution */ - constructor(human_name, description, misc, index) { - var ptr0 = passStringToWasm0(human_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - var ptr1 = passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - var ptr2 = passStringToWasm0(misc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len2 = WASM_VECTOR_LEN; - var ret = wasm.camerainfo_new(ptr0, len0, ptr1, len1, ptr2, len2, index); - return CameraInfo.__wrap(ret); + set Resolution(preferred_resolution) { + _assertClass(preferred_resolution, Resolution); + var ptr0 = preferred_resolution.ptr; + preferred_resolution.ptr = 0; + wasm.cameraconstraints_set_resolution(this.ptr, ptr0); } /** - * Get a reference to the device info's human readable name. + * Gets the maximum [`Resolution`]. * # JS-WASM - * This is exported as a `get_HumanReadableName`. - * @returns {string} + * This is exported as `get_MaxResolution`. + * @returns {Resolution | undefined} */ - get HumanReadableName() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.camerainfo_HumanReadableName(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } + get MaxResolution() { + var ret = wasm.cameraconstraints_max_resolution(this.ptr); + return ret === 0 ? undefined : Resolution.__wrap(ret); } /** - * Set the device info's human name. + * Gets the maximum [`Resolution`]. * # JS-WASM - * This is exported as a `set_HumanReadableName`. - * @param {string} human_name + * This is exported as `set_MaxResolution`. + * @param {Resolution} max_resolution */ - set HumanReadableName(human_name) { - var ptr0 = passStringToWasm0(human_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.camerainfo_set_HumanReadableName(this.ptr, ptr0, len0); + set MaxResolution(max_resolution) { + _assertClass(max_resolution, Resolution); + var ptr0 = max_resolution.ptr; + max_resolution.ptr = 0; + wasm.cameraconstraints_set_max_resolution(this.ptr, ptr0); } /** - * Get a reference to the device info's description. + * Gets the internal resolution exact. * # JS-WASM - * This is exported as a `get_Description`. - * @returns {string} + * This is exported as `get_ResolutionExact`. + * @returns {boolean} */ - get Description() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.camerainfo_Description(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } + get ResolutionExact() { + var ret = wasm.cameraconstraints_resolution_exact(this.ptr); + return ret !== 0; } /** - * Set the device info's description. + * Sets the internal resolution exact. + * Note that this doesn't affect the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) until you call + * [`apply_constraints()`](crate::js_camera::JSCameraConstraints::apply_constraints) * # JS-WASM - * This is exported as a `set_Description`. - * @param {string} description + * This is exported as `set_ResolutionExact`. + * @param {boolean} resolution_exact */ - set Description(description) { - var ptr0 = passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.camerainfo_set_Description(this.ptr, ptr0, len0); + set ResolutionExact(resolution_exact) { + wasm.cameraconstraints_set_resolution_exact(this.ptr, resolution_exact); } /** - * Get a reference to the device info's misc. + * Gets the minimum aspect ratio of the [`JSCameraConstraints`]. * # JS-WASM - * This is exported as a `get_MiscString`. - * @returns {string} + * This is exported as `get_MinAspectRatio`. + * @returns {number | undefined} */ - get MiscString() { + get MinAspectRatio() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.camerainfo_MiscString(retptr, this.ptr); + wasm.cameraconstraints_min_aspect_ratio(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); + var r1 = getFloat64Memory0()[retptr / 8 + 1]; + return r0 === 0 ? undefined : r1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); } } /** - * Set the device info's misc. + * Sets the minimum aspect ratio of the [`JSCameraConstraints`]. * # JS-WASM - * This is exported as a `set_MiscString`. - * @param {string} misc + * This is exported as `set_MinAspectRatio`. + * @param {number} min_aspect_ratio */ - set MiscString(misc) { - var ptr0 = passStringToWasm0(misc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.camerainfo_set_MiscString(this.ptr, ptr0, len0); + set MinAspectRatio(min_aspect_ratio) { + wasm.cameraconstraints_set_min_aspect_ratio(this.ptr, min_aspect_ratio); } /** - * Get a reference to the device info's index. + * Gets the internal aspect ratio. * # JS-WASM - * This is exported as a `get_Index`. + * This is exported as `get_AspectRatio`. * @returns {number} */ - get Index() { - var ret = wasm.camerainfo_Index(this.ptr); - return ret >>> 0; + get AspectRatio() { + var ret = wasm.cameraconstraints_aspect_ratio(this.ptr); + return ret; } /** - * Set the device info's index. + * Sets the internal aspect ratio. + * Note that this doesn't affect the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) until you call + * [`apply_constraints()`](crate::js_camera::JSCameraConstraints::apply_constraints) * # JS-WASM - * This is exported as a `set_Index`. - * @param {number} index + * This is exported as `set_AspectRatio`. + * @param {number} aspect_ratio */ - set Index(index) { - wasm.camerainfo_set_Index(this.ptr, index); - } -} - -export class JSCamera { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jscamera_free(ptr); + set AspectRatio(aspect_ratio) { + wasm.cameraconstraints_set_aspect_ratio(this.ptr, aspect_ratio); } /** - * Creates a new [`JSCamera`] using [`JSCameraConstraints`]. - * - * # Errors - * This may error if permission is not granted, or the constraints are invalid. + * Gets the maximum aspect ratio. * # JS-WASM - * This is the constructor for `NOKCamera`. It returns a promise and may throw an error. - * @param {CameraConstraints} constraints + * This is exported as `get_MaxAspectRatio`. + * @returns {number | undefined} */ - constructor(constraints) { - _assertClass(constraints, CameraConstraints); - var ptr0 = constraints.ptr; - constraints.ptr = 0; - var ret = wasm.jscamera_js_new(ptr0); - return takeObject(ret); + get MaxAspectRatio() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.cameraconstraints_max_aspect_ratio(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getFloat64Memory0()[retptr / 8 + 1]; + return r0 === 0 ? undefined : r1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } } /** - * Gets the internal [`JSCameraConstraints`]. - * Most likely, you will edit this value by taking ownership of it, then feed it back into [`set_constraints`](crate::js_camera::JSCamera::set_constraints). + * Sets the maximum internal aspect ratio. + * Note that this doesn't affect the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) until you call + * [`apply_constraints()`](crate::js_camera::JSCameraConstraints::apply_constraints) * # JS-WASM - * This is exported as `get_Constraints`. - * @returns {CameraConstraints} + * This is exported as `set_MaxAspectRatio`. + * @param {number} max_aspect_ratio */ - get Constraints() { - var ret = wasm.jscamera_Constraints(this.ptr); - return CameraConstraints.__wrap(ret); + set MaxAspectRatio(max_aspect_ratio) { + wasm.cameraconstraints_set_max_aspect_ratio(this.ptr, max_aspect_ratio); } /** - * Sets the JSCameraConstraints. This calls [`apply_constraints`](crate::js_camera::JSCamera::apply_constraints) internally. - * - * # Errors - * See [`apply_constraints`](crate::js_camera::JSCamera::apply_constraints). + * Gets the internal aspect ratio exact. * # JS-WASM - * This is exported as `set_Constraints`. It may throw an error. - * @param {CameraConstraints} constraints + * This is exported as `get_AspectRatioExact`. + * @returns {boolean} */ - set Constraints(constraints) { - _assertClass(constraints, CameraConstraints); - var ptr0 = constraints.ptr; - constraints.ptr = 0; - wasm.jscamera_set_Constraints(this.ptr, ptr0); + get AspectRatioExact() { + var ret = wasm.cameraconstraints_aspect_ratio_exact(this.ptr); + return ret !== 0; } /** - * Gets the internal [`Resolution`]. - * - * Note: This value is only updated after you call [`measure_resolution`](crate::js_camera::JSCamera::measure_resolution) + * Sets the internal aspect ratio exact. + * Note that this doesn't affect the internal [`MediaStreamConstraints`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.MediaStreamConstraints.html) until you call + * [`apply_constraints()`](crate::js_camera::JSCameraConstraints::apply_constraints) * # JS-WASM - * This is exported as `get_Resolution`. - * @returns {Resolution} + * This is exported as `set_AspectRatioExact`. + * @param {boolean} aspect_ratio_exact */ - get Resolution() { - var ret = wasm.jscamera_Resolution(this.ptr); - return Resolution.__wrap(ret); + set AspectRatioExact(aspect_ratio_exact) { + wasm.cameraconstraints_set_aspect_ratio_exact(this.ptr, aspect_ratio_exact); } /** - * Measures the [`Resolution`] of the internal stream. You usually do not need to call this. - * - * # Errors - * If the camera fails to attach to the created `