hunk.code_window: import android.app.Activity;
   import android.content.Context;
   import android.content.Intent;
   import android.net.Uri;
   import android.os.Bundle;
   import androidx.core.content.FileProvider;
  
hunk.labels: keep keep keep add keep keep keep keep
hunk.after_edit: import android.content.pm.PackageManager;
   import android.content.pm.ResolveInfo;
  
hunk.file_path: android/versioned-abis/expoview-abi39_0_0/src/main/java/abi39_0_0/expo/modules/sharing/SharingModule.java
hunk.type: add
file: {"version":3,"file":"useWebQRScanner.js","sourceRoot":"","sources":["../src/useWebQRScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAa,EAAO,EAAE;IACjE,oCAAoC;IACpC,MAAM,OAAO,GAAI,IAAY,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;QACtD,iBAAiB,EAAE,YAAY;KAChC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,GAAG,OAAO,CAAC;KAClB;IAED,IAAI,MAAM,EAAE,IAAI,EAAE;QAChB,MAAM,WAAW,GAA0B;YACzC,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;QACF,IAAI,MAAM,CAAC,QAAQ,EAAE;YACnB,WAAW,CAAC,YAAY,GAAG;gBACzB,MAAM,CAAC,QAAQ,CAAC,aAAa;gBAC7B,MAAM,CAAC,QAAQ,CAAC,gBAAgB;gBAChC,MAAM,CAAC,QAAQ,CAAC,cAAc;gBAC9B,MAAM,CAAC,QAAQ,CAAC,iBAAiB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AG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YAChE,gEAAgE;YAChE,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAChC,SAAS,EAAE,CAAC;YACd,CAAC,EAAE,aAAa,CAAC,CAAC;SACnB;IACH,CAAC;IAED,SAAS,IAAI;QACX,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;YACzB,SAAS,EAAE,CAAC;SACb;aAAM;YACL,IAAI,EAAE,CAAC;SACR;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,CAAC;YACP,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import { useWorker } from '@koale/useworker';\nimport * as React from 'react';\n\nimport { CameraPictureOptions } from './Camera';\nimport { BarCodeScanningResult, MountErrorListener } from './Camera.types';\nimport { captureImageData } from './WebCameraUtils';\n\nconst qrWorkerMethod = ({ data, width, height }: ImageData): any => {\n  // eslint-disable-next-line no-undef\n  const decoded = (self as any).jsQR(data, width, height, {\n    inversionAttempts: 'dontInvert',\n  });\n\n  let parsed;\n  try {\n    parsed = JSON.parse(decoded);\n  } catch (err) {\n    parsed = decoded;\n  }\n\n  if (parsed?.data) {\n    const nativeEvent: BarCodeScanningResult = {\n      type: 'qr',\n      data: parsed.data,\n    };\n    if (parsed.location) {\n      nativeEvent.cornerPoints = [\n        parsed.location.topLeftCorner,\n        parsed.location.bottomLeftCorner,\n        parsed.location.topRightCorner,\n        parsed.location.bottomRightCorner,\n      ];\n    }\n    return nativeEvent;\n  }\n  return parsed;\n};\n\nfunction useRemoteJsQR() {\n  return useWorker(qrWorkerMethod, {\n    remoteDependencies: ['https://cdn.jsdelivr.net/npm/jsqr@1.2.0/dist/jsQR.min.js'],\n    timeout: 5000,\n  });\n}\n\nexport function useWebQRScanner(\n  video: React.MutableRefObject<HTMLVideoElement | null>,\n  {\n    isEnabled,\n    captureOptions,\n    interval,\n    onScanned,\n    onError,\n  }: {\n    isEnabled: boolean;\n    captureOptions: Pick<CameraPictureOptions, 'scale' | 'isImageMirror'>;\n    interval?: number;\n    onScanned?: (scanningResult: { nativeEvent: BarCodeScanningResult }) => void;\n    onError?: MountErrorListener;\n  }\n) {\n  const isRunning = React.useRef<boolean>(false);\n  const timeout = React.useRef<number | undefined>(undefined);\n\n  const [decode, clearWorker] = useRemoteJsQR();\n\n  async function scanAsync() {\n    // If interval is 0 then only scan once.\n    if (!isRunning.current || !onScanned) {\n      stop();\n      return;\n    }\n    try {\n      const data = captureImageData(video.current, captureOptions);\n\n      if (data) {\n        const nativeEvent: BarCodeScanningResult | any = await decode(data);\n        if (nativeEvent?.data) {\n          onScanned({\n            nativeEvent,\n          });\n        }\n      }\n    } catch (error) {\n      if (onError) {\n        onError({ nativeEvent: error });\n      }\n    } finally {\n      // If interval is 0 then only scan once.\n      if (interval === 0) {\n        stop();\n        return;\n      }\n      const intervalToUse = !interval || interval < 0 ? 16 : interval;\n      // @ts-ignore: Type 'Timeout' is not assignable to type 'number'\n      timeout.current = setTimeout(() => {\n        scanAsync();\n      }, intervalToUse);\n    }\n  }\n\n  function stop() {\n    isRunning.current = false;\n    clearTimeout(timeout.current);\n  }\n\n  React.useEffect(() => {\n    if (isEnabled) {\n      isRunning.current = true;\n      scanAsync();\n    } else {\n      stop();\n    }\n  }, [isEnabled]);\n\n  React.useEffect(() => {\n    return () => {\n      stop();\n      clearWorker.kill();\n    };\n  }, []);\n}\n"]}