mrousavy / vision-camera-image-labeler

VisionCamera Frame Processor Plugin to label images using MLKit Vision
https://github.com/mrousavy/react-native-vision-camera
MIT License
119 stars 28 forks source link

doubts: where does this come from, and where should this log appear? #8

Closed rodgomesc closed 3 years ago

rodgomesc commented 3 years ago

https://github.com/mrousavy/vision-camera-image-labeler/blob/cbf88a545e2aabcbc97aaf2717617ef1e0a69aa9/example/src/App.tsx#L25

mrousavy commented 3 years ago

declare + comment in VisionCamera :

/**
 * A native logging function (outputs to Xcode console/Android Logcat)
 */
declare var _log: (message: string) => void | undefined;

implementation from Reanimated:

  auto callback = [](
                     jsi::Runtime &rt,
                     const jsi::Value &thisValue,
                     const jsi::Value *args,
                     size_t count
                     ) -> jsi::Value {
    const jsi::Value *value = &args[0];
    if (value->isString()) {
      Logger::log(value->getString(rt).utf8(rt).c_str());
    } else if (value->isNumber()) {
      Logger::log(value->getNumber());
    } else if (value->isUndefined()) {
      Logger::log("undefined");
    } else {
      Logger::log("unsupported value type");
    }
    return jsi::Value::undefined();
  };
  jsi::Value log = jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
  rt.global().setProperty(rt, "_log", log);
mrousavy commented 3 years ago

This is outdated since VisionCamera supports console.log since https://github.com/mrousavy/react-native-vision-camera/pull/297.

rodgomesc commented 3 years ago

thanks, for the quick feedback