Update helpers.js to include .dlete

This commit is contained in:
Jeremy Kruid 2025-07-31 15:40:59 -05:00
parent 8dc4ad3ff3
commit 3dec85df71

View File

@ -397,3 +397,16 @@ Module['matFromImageData'] = function(imageData) {
mat.data.set(imageData.data);
return mat;
};
// Add Symbol.dispose support for using declaration in TypeScript 5.2+ and future JS
if (
typeof Symbol !== "undefined" &&
Symbol.dispose &&
typeof cv !== "undefined" &&
cv.Mat &&
typeof cv.Mat.prototype.delete === "function"
) {
cv.Mat.prototype[Symbol.dispose] = cv.Mat.prototype.delete;
// Optionally repeat for other types that require manual cleanup:
if (cv.UMat) cv.UMat.prototype[Symbol.dispose] = cv.UMat.prototype.delete;
// Add more as OpenCV gains new manual-cleanup classes
}