Merge pull request #27613 from kruid9403:feature/symbol-dispose-support-26157

Support Symbol.dispose for using keyword in OpenCV.js (#26157)
This commit is contained in:
Alexander Smorkalov 2025-08-12 15:53:26 +03:00 committed by GitHub
commit d33999cb6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
}