@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.
- package/dist/eyepop.index.js +19 -14
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +19 -14
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.js
CHANGED
|
@@ -9681,13 +9681,13 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9681
9681
|
throw new DOMException("resolving a path to a file is not supported in browser");
|
|
9682
9682
|
};
|
|
9683
9683
|
} else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
9684
|
-
let
|
|
9685
|
-
let
|
|
9686
|
-
let
|
|
9684
|
+
let RNFAName = "react-native-file-access";
|
|
9685
|
+
let RNFA;
|
|
9686
|
+
let RNFALoadError;
|
|
9687
9687
|
try {
|
|
9688
|
-
|
|
9688
|
+
RNFA = require(RNFAName);
|
|
9689
9689
|
} catch (e) {
|
|
9690
|
-
|
|
9690
|
+
RNFALoadError = e;
|
|
9691
9691
|
}
|
|
9692
9692
|
let EFSName = "expo-file-system";
|
|
9693
9693
|
let EFS;
|
|
@@ -9698,19 +9698,21 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9698
9698
|
EFSLoadError = e;
|
|
9699
9699
|
}
|
|
9700
9700
|
resolvePath = async (source, logger) => {
|
|
9701
|
-
if (
|
|
9702
|
-
logger.debug("Using react-native-
|
|
9701
|
+
if (RNFA?.FileSystem?.readFileChunk !== void 0) {
|
|
9702
|
+
logger.debug("Using react-native-file-access to read local file");
|
|
9703
9703
|
const bufferSize = 1024 * 1024;
|
|
9704
9704
|
let pos = 0;
|
|
9705
|
+
const size = (await RNFA.FileSystem.stat(source.path)).size;
|
|
9705
9706
|
let eof = false;
|
|
9706
9707
|
const stream = new ReadableStream({
|
|
9707
9708
|
async pull(controller) {
|
|
9708
9709
|
if (eof) {
|
|
9709
9710
|
return;
|
|
9710
9711
|
}
|
|
9711
|
-
const
|
|
9712
|
+
const chunkSize = Math.min(bufferSize, size - pos);
|
|
9713
|
+
const chunkAsB64 = await RNFA.FileSystem.readFileChunk(source.path, pos, chunkSize, "base64");
|
|
9712
9714
|
if (chunkAsB64.length > 0) {
|
|
9713
|
-
const chunk = Buffer.from(chunkAsB64, "base64");
|
|
9715
|
+
const chunk = Buffer.from(chunkAsB64, "base64").subarray(0, chunkSize);
|
|
9714
9716
|
controller.enqueue(chunk);
|
|
9715
9717
|
pos += chunk.length;
|
|
9716
9718
|
} else {
|
|
@@ -9721,12 +9723,14 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9721
9723
|
});
|
|
9722
9724
|
return {
|
|
9723
9725
|
stream,
|
|
9724
|
-
size
|
|
9726
|
+
size,
|
|
9725
9727
|
mimeType: source.mimeType || "image/*"
|
|
9726
9728
|
};
|
|
9727
|
-
}
|
|
9729
|
+
}
|
|
9730
|
+
if (EFS?.readAsStringAsync !== void 0) {
|
|
9728
9731
|
logger.debug("Using expo-file-system to read local file");
|
|
9729
9732
|
const bufferSize = 1024 * 1024;
|
|
9733
|
+
const size = (await EFS.getInfoAsync(`file://${source.path}`)).size;
|
|
9730
9734
|
let pos = 0;
|
|
9731
9735
|
let eof = false;
|
|
9732
9736
|
const stream = new ReadableStream({
|
|
@@ -9734,8 +9738,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9734
9738
|
if (eof) {
|
|
9735
9739
|
return;
|
|
9736
9740
|
}
|
|
9741
|
+
const chunkSize = Math.min(bufferSize, size - pos);
|
|
9737
9742
|
const chunkAsB64 = await EFS.readAsStringAsync(`file://${source.path}`, {
|
|
9738
|
-
length:
|
|
9743
|
+
length: chunkSize,
|
|
9739
9744
|
position: pos,
|
|
9740
9745
|
encoding: "base64"
|
|
9741
9746
|
});
|
|
@@ -9751,11 +9756,11 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9751
9756
|
});
|
|
9752
9757
|
return {
|
|
9753
9758
|
stream,
|
|
9754
|
-
size
|
|
9759
|
+
size,
|
|
9755
9760
|
mimeType: source.mimeType || "image/*"
|
|
9756
9761
|
};
|
|
9757
9762
|
}
|
|
9758
|
-
|
|
9763
|
+
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()`);
|
|
9759
9764
|
};
|
|
9760
9765
|
} else {
|
|
9761
9766
|
let iteratorToStream = function(iterator) {
|