Skip to content

Commit 1e851e6

Browse files
committed
fix(core): module guard checks
1 parent eb6f3b3 commit 1e851e6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/mlkit-core/index.ios.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,37 +220,39 @@ export class MLKitView extends MLKitViewBase {
220220
}
221221

222222
#setupDetectors() {
223-
if (TEXT_RECOGNITION_SUPPORTED() && !this.#textRecognizer && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
224-
this.#textRecognizer = MLKTextRecognizer.textRecognizer();
225-
this.#mlkitHelper.textRecognizer = this.#textRecognizer;
223+
if (!this.#textRecognizer && (this.detectionType === DetectionType.Text || this.detectionType === DetectionType.All)) {
224+
if (TEXT_RECOGNITION_SUPPORTED()) {
225+
this.#textRecognizer = MLKTextRecognizer.textRecognizer();
226+
this.#mlkitHelper.textRecognizer = this.#textRecognizer;
227+
}
226228
}
227229

228-
if (BARCODE_SCANNER_SUPPORTED() && !this.#barcodeScanner && (this.detectionType === DetectionType.Barcode || this.detectionType === DetectionType.All)) {
230+
if (!this.#barcodeScanner && (this.detectionType === DetectionType.Barcode || this.detectionType === DetectionType.All)) {
229231
this.#setupBarcodeScanner(this.barcodeFormats);
230232
}
231233

232234
// TODO
233-
if (DIGITALINK_RECOGNITION_SUPPORTED() && !this.#digitalInkRecognizer && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
235+
if (!this.#digitalInkRecognizer && (this.detectionType === DetectionType.DigitalInk || this.detectionType === DetectionType.All)) {
234236
// MLKDigitalInkRecognizer.digitalInkRecognizerWithOptions()
235237
}
236238

237-
if (FACE_DETECTION_SUPPORTED() && !this.#faceDetector && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
239+
if (!this.#faceDetector && (this.detectionType === DetectionType.Face || this.detectionType === DetectionType.All)) {
238240
this.#setupFaceDetector();
239241
}
240242

241-
if (IMAGE_LABELING_SUPPORTED() && !this.#imageLabeler && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
243+
if (!this.#imageLabeler && (this.detectionType === DetectionType.Image || this.detectionType === DetectionType.All)) {
242244
this.#setImageLabeler();
243245
}
244246

245-
if (OBJECT_DETECTION_SUPPORTED() && !this.#objectDetector && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
247+
if (!this.#objectDetector && (this.detectionType === DetectionType.Object || this.detectionType === DetectionType.All)) {
246248
this.#setupObjectDetection();
247249
}
248250

249-
if (POSE_DETECTION_SUPPORTED() && !this.#poseDetector && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
251+
if (!this.#poseDetector && (this.detectionType === DetectionType.Pose || this.detectionType === DetectionType.All)) {
250252
this.#setPoseDetection();
251253
}
252254

253-
if (SELFIE_SEGMENTATION_SUPPORTED() && !this.#selfieSegmentor && (this.detectionType === DetectionType.Selfie || this.detectionType === DetectionType.All)) {
255+
if (!this.#selfieSegmentor && (this.detectionType === DetectionType.Selfie || this.detectionType === DetectionType.All)) {
254256
this.#setSelfieSegmentation();
255257
}
256258
}
@@ -394,7 +396,7 @@ export class MLKitView extends MLKitViewBase {
394396
}
395397

396398
#setupObjectDetection() {
397-
if (!OBJECT_DETECTION_SUPPORTED) {
399+
if (!OBJECT_DETECTION_SUPPORTED()) {
398400
return;
399401
}
400402
if (!this.#objectDetectionOptions) {
@@ -411,7 +413,7 @@ export class MLKitView extends MLKitViewBase {
411413
}
412414

413415
#setPoseDetection() {
414-
if (!POSE_DETECTION_SUPPORTED) {
416+
if (!POSE_DETECTION_SUPPORTED()) {
415417
return;
416418
}
417419
if (!this.#poseDetectionOptions) {

0 commit comments

Comments
 (0)