@eyepop.ai/eyepop 1.14.2 → 1.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9616,13 +9616,13 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9616
9616
  throw new DOMException("resolving a path to a file is not supported in browser");
9617
9617
  };
9618
9618
  } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9619
- let RNFSName = "react-native-fs";
9620
- let RNFS;
9621
- let RNFSLoadError;
9619
+ let RNFAName = "react-native-file-access";
9620
+ let RNFA;
9621
+ let RNFALoadError;
9622
9622
  try {
9623
- RNFS = __require(RNFSName);
9623
+ RNFA = __require(RNFAName);
9624
9624
  } catch (e) {
9625
- RNFSLoadError = e;
9625
+ RNFALoadError = e;
9626
9626
  }
9627
9627
  let EFSName = "expo-file-system";
9628
9628
  let EFS;
@@ -9633,19 +9633,21 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9633
9633
  EFSLoadError = e;
9634
9634
  }
9635
9635
  resolvePath = async (source, logger) => {
9636
- if (RNFS?.read !== void 0) {
9637
- logger.debug("Using react-native-fs to read local file");
9636
+ if (RNFA?.FileSystem?.readFileChunk !== void 0) {
9637
+ logger.debug("Using react-native-file-access to read local file");
9638
9638
  const bufferSize = 1024 * 1024;
9639
9639
  let pos = 0;
9640
+ const size = (await RNFA.FileSystem.stat(source.path)).size;
9640
9641
  let eof = false;
9641
9642
  const stream = new ReadableStream({
9642
9643
  async pull(controller) {
9643
9644
  if (eof) {
9644
9645
  return;
9645
9646
  }
9646
- const chunkAsB64 = await RNFS.read(source.path, bufferSize, pos, "base64");
9647
+ const chunkSize = Math.min(bufferSize, size - pos);
9648
+ const chunkAsB64 = await RNFA.FileSystem.readFileChunk(source.path, pos, chunkSize, "base64");
9647
9649
  if (chunkAsB64.length > 0) {
9648
- const chunk = Buffer.from(chunkAsB64, "base64");
9650
+ const chunk = Buffer.from(chunkAsB64, "base64").subarray(0, chunkSize);
9649
9651
  controller.enqueue(chunk);
9650
9652
  pos += chunk.length;
9651
9653
  } else {
@@ -9656,12 +9658,14 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9656
9658
  });
9657
9659
  return {
9658
9660
  stream,
9659
- size: (await RNFS.stat(source.path)).size,
9661
+ size,
9660
9662
  mimeType: source.mimeType || "image/*"
9661
9663
  };
9662
- } else if (EFS?.readAsStringAsync !== void 0) {
9664
+ }
9665
+ if (EFS?.readAsStringAsync !== void 0) {
9663
9666
  logger.debug("Using expo-file-system to read local file");
9664
9667
  const bufferSize = 1024 * 1024;
9668
+ const size = (await EFS.getInfoAsync(`file://${source.path}`)).size;
9665
9669
  let pos = 0;
9666
9670
  let eof = false;
9667
9671
  const stream = new ReadableStream({
@@ -9669,8 +9673,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9669
9673
  if (eof) {
9670
9674
  return;
9671
9675
  }
9676
+ const chunkSize = Math.min(bufferSize, size - pos);
9672
9677
  const chunkAsB64 = await EFS.readAsStringAsync(`file://${source.path}`, {
9673
- length: bufferSize,
9678
+ length: chunkSize,
9674
9679
  position: pos,
9675
9680
  encoding: "base64"
9676
9681
  });
@@ -9686,11 +9691,11 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9686
9691
  });
9687
9692
  return {
9688
9693
  stream,
9689
- size: (await EFS.getInfoAsync(`file://${source.path}`)).size,
9694
+ size,
9690
9695
  mimeType: source.mimeType || "image/*"
9691
9696
  };
9692
9697
  }
9693
- return Promise.reject(`Could not load '${RNFSName}' (reason" ${RNFSLoadError}) or '${EFSName}' (reason" ${EFSLoadError}), include either of those packages in your application to enable uploads via PathSource - or provide the stream itself via StreamSource.`);
9698
+ throw new Error(`Could not load '${RNFAName}' (reason" ${RNFALoadError}) or '${EFSName}' (reason" ${EFSLoadError}). Falling back to fetch() which might cause memory issues. Include either of those packages in your application to enable uploads via PathSource - or provide the stream itself via StreamSource.We will try to load file://${source.path} via fetch()`);
9694
9699
  };
9695
9700
  } else {
9696
9701
  let iteratorToStream = function(iterator) {