@eyepop.ai/react-native-eyepop 1.15.1

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.
Files changed (61) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +33 -0
  3. package/lib/commonjs/index.js +52 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/package.json +1 -0
  6. package/lib/commonjs/rn_http_client.js +113 -0
  7. package/lib/commonjs/rn_http_client.js.map +1 -0
  8. package/lib/commonjs/rn_http_header_parser.js +135 -0
  9. package/lib/commonjs/rn_http_header_parser.js.map +1 -0
  10. package/lib/commonjs/rn_http_response_parser.js +199 -0
  11. package/lib/commonjs/rn_http_response_parser.js.map +1 -0
  12. package/lib/commonjs/rn_local_file.js +38 -0
  13. package/lib/commonjs/rn_local_file.js.map +1 -0
  14. package/lib/commonjs/rn_streaming_fetch.js +111 -0
  15. package/lib/commonjs/rn_streaming_fetch.js.map +1 -0
  16. package/lib/module/index.js +48 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/module/rn_http_client.js +109 -0
  20. package/lib/module/rn_http_client.js.map +1 -0
  21. package/lib/module/rn_http_header_parser.js +131 -0
  22. package/lib/module/rn_http_header_parser.js.map +1 -0
  23. package/lib/module/rn_http_response_parser.js +194 -0
  24. package/lib/module/rn_http_response_parser.js.map +1 -0
  25. package/lib/module/rn_local_file.js +34 -0
  26. package/lib/module/rn_local_file.js.map +1 -0
  27. package/lib/module/rn_streaming_fetch.js +107 -0
  28. package/lib/module/rn_streaming_fetch.js.map +1 -0
  29. package/lib/typescript/commonjs/package.json +1 -0
  30. package/lib/typescript/commonjs/src/index.d.ts +8 -0
  31. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/src/rn_http_client.d.ts +19 -0
  33. package/lib/typescript/commonjs/src/rn_http_client.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/src/rn_http_header_parser.d.ts +2 -0
  35. package/lib/typescript/commonjs/src/rn_http_header_parser.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/src/rn_http_response_parser.d.ts +21 -0
  37. package/lib/typescript/commonjs/src/rn_http_response_parser.d.ts.map +1 -0
  38. package/lib/typescript/commonjs/src/rn_local_file.d.ts +5 -0
  39. package/lib/typescript/commonjs/src/rn_local_file.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/src/rn_streaming_fetch.d.ts +7 -0
  41. package/lib/typescript/commonjs/src/rn_streaming_fetch.d.ts.map +1 -0
  42. package/lib/typescript/module/package.json +1 -0
  43. package/lib/typescript/module/src/index.d.ts +8 -0
  44. package/lib/typescript/module/src/index.d.ts.map +1 -0
  45. package/lib/typescript/module/src/rn_http_client.d.ts +19 -0
  46. package/lib/typescript/module/src/rn_http_client.d.ts.map +1 -0
  47. package/lib/typescript/module/src/rn_http_header_parser.d.ts +2 -0
  48. package/lib/typescript/module/src/rn_http_header_parser.d.ts.map +1 -0
  49. package/lib/typescript/module/src/rn_http_response_parser.d.ts +21 -0
  50. package/lib/typescript/module/src/rn_http_response_parser.d.ts.map +1 -0
  51. package/lib/typescript/module/src/rn_local_file.d.ts +5 -0
  52. package/lib/typescript/module/src/rn_local_file.d.ts.map +1 -0
  53. package/lib/typescript/module/src/rn_streaming_fetch.d.ts +7 -0
  54. package/lib/typescript/module/src/rn_streaming_fetch.d.ts.map +1 -0
  55. package/package.json +202 -0
  56. package/src/index.ts +48 -0
  57. package/src/rn_http_client.ts +134 -0
  58. package/src/rn_http_header_parser.ts +138 -0
  59. package/src/rn_http_response_parser.ts +248 -0
  60. package/src/rn_local_file.ts +43 -0
  61. package/src/rn_streaming_fetch.ts +131 -0
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ import 'react-native-polyfill-globals/auto';
4
+ import { ReadableStream } from 'web-streams-polyfill/ponyfill/es6';
5
+ import { FileSystem } from 'react-native-file-access';
6
+ export async function resolvePathRN(source, _) {
7
+ const bufferSize = 1024 * 1024;
8
+ let pos = 0;
9
+ const size = (await FileSystem.stat(source.path)).size;
10
+ let eof = false;
11
+ const stream = new ReadableStream({
12
+ async pull(controller) {
13
+ if (eof) {
14
+ return;
15
+ }
16
+ const chunkSize = Math.min(bufferSize, size - pos);
17
+ const chunkAsB64 = await FileSystem.readFileChunk(source.path, pos, chunkSize, 'base64');
18
+ if (chunkAsB64.length > 0) {
19
+ const chunk = Buffer.from(chunkAsB64, 'base64').subarray(0, chunkSize);
20
+ controller.enqueue(chunk);
21
+ pos += chunk.length;
22
+ } else {
23
+ eof = true;
24
+ controller.close();
25
+ }
26
+ }
27
+ });
28
+ return {
29
+ stream: stream,
30
+ size: size,
31
+ mimeType: source.mimeType || 'image/*'
32
+ };
33
+ }
34
+ //# sourceMappingURL=rn_local_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ReadableStream","FileSystem","resolvePathRN","source","_","bufferSize","pos","size","stat","path","eof","stream","pull","controller","chunkSize","Math","min","chunkAsB64","readFileChunk","length","chunk","Buffer","from","subarray","enqueue","close","mimeType"],"sourceRoot":"../../src","sources":["rn_local_file.ts"],"mappings":";;AAAA,OAAO,oCAAoC;AAG3C,SAASA,cAAc,QAAQ,mCAAmC;AAElE,SAASC,UAAU,QAAQ,0BAA0B;AAErD,OAAO,eAAeC,aAAaA,CACjCC,MAAkB,EAClBC,CAAS,EACc;EACvB,MAAMC,UAAU,GAAG,IAAI,GAAG,IAAI;EAC9B,IAAIC,GAAG,GAAG,CAAC;EACX,MAAMC,IAAI,GAAG,CAAC,MAAMN,UAAU,CAACO,IAAI,CAACL,MAAM,CAACM,IAAI,CAAC,EAAEF,IAAI;EACtD,IAAIG,GAAG,GAAG,KAAK;EACf,MAAMC,MAAM,GAAG,IAAIX,cAAc,CAAC;IAChC,MAAMY,IAAIA,CAACC,UAAe,EAAE;MAC1B,IAAIH,GAAG,EAAE;QACP;MACF;MACA,MAAMI,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACX,UAAU,EAAEE,IAAI,GAAGD,GAAG,CAAC;MAClD,MAAMW,UAAU,GAAG,MAAMhB,UAAU,CAACiB,aAAa,CAC/Cf,MAAM,CAACM,IAAI,EACXH,GAAG,EACHQ,SAAS,EACT,QACF,CAAC;MACD,IAAIG,UAAU,CAACE,MAAM,GAAG,CAAC,EAAE;QACzB,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACL,UAAU,EAAE,QAAQ,CAAC,CAACM,QAAQ,CAAC,CAAC,EAAET,SAAS,CAAC;QACtED,UAAU,CAACW,OAAO,CAACJ,KAAK,CAAC;QACzBd,GAAG,IAAIc,KAAK,CAACD,MAAM;MACrB,CAAC,MAAM;QACLT,GAAG,GAAG,IAAI;QACVG,UAAU,CAACY,KAAK,CAAC,CAAC;MACpB;IACF;EACF,CAAC,CAAC;EACF,OAAO;IACLd,MAAM,EAAEA,MAAM;IACdJ,IAAI,EAAEA,IAAI;IACVmB,QAAQ,EAAEvB,MAAM,CAACuB,QAAQ,IAAI;EAC/B,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ import 'react-native-polyfill-globals/auto';
4
+ import { ResponseParser } from "./rn_http_response_parser.js";
5
+ import { ReadableStream } from 'web-streams-polyfill/ponyfill/es6';
6
+ export async function reactNativeStreamingFetch(url, method, headers, body, contentLength, sockets, logger) {
7
+ const isHttps = url.protocol === 'https:';
8
+ const port = url.port ? parseInt(url.port, 10) : isHttps ? 443 : 80;
9
+ return new Promise((resolve, reject) => {
10
+ const connectOptions = {
11
+ port: port,
12
+ host: url.hostname,
13
+ reuseAddress: true
14
+ };
15
+ const clientSocket = new sockets.Socket();
16
+ const client = isHttps ? new sockets.TLSSocket(clientSocket) : clientSocket;
17
+ let error;
18
+ const responseParser = new ResponseParser(logger, resolve, reason => {
19
+ error = reason;
20
+ reject(error);
21
+ client.destroy();
22
+ });
23
+ client.on('data', function (data) {
24
+ responseParser.processResponseReadBuffer(data);
25
+ });
26
+ client.on('error', function (err) {
27
+ logger.info(`error: ${err}`);
28
+ if (!error) {
29
+ error = err;
30
+ reject(error);
31
+ }
32
+ client.destroy();
33
+ });
34
+ client.on('close', function () {
35
+ if (!error) {
36
+ error = 'socket closed';
37
+ reject(error);
38
+ }
39
+ });
40
+ client.connect(connectOptions, async () => {
41
+ const headerLines = [`${method} ${url.pathname}${url.search} HTTP/1.1\r\n`, `Host: ${url.host}\r\n`];
42
+ headers.forEach((value, key) => {
43
+ headerLines.push(`${key}: ${value}\r\n`);
44
+ });
45
+ headerLines.push('\r\n');
46
+ const textEncoder = new TextEncoder();
47
+ const headerChunk = headerLines.join('');
48
+ const bodyReader = body ? body.getReader() : undefined;
49
+ let headerEnqueued = false;
50
+ let eof = false;
51
+ const readableHeaderChunkedBody = new ReadableStream({
52
+ async pull(controller) {
53
+ if (!headerEnqueued) {
54
+ controller.enqueue(headerChunk);
55
+ headerEnqueued = true;
56
+ return;
57
+ }
58
+ if (eof) {
59
+ controller.close();
60
+ return;
61
+ }
62
+ if (!bodyReader) {
63
+ controller.close();
64
+ return;
65
+ }
66
+ const chunk = await bodyReader.read();
67
+ if (chunk.value) {
68
+ let outputChunk;
69
+ if (contentLength) {
70
+ outputChunk = chunk.value;
71
+ } else {
72
+ outputChunk = Buffer.concat([textEncoder.encode(`${chunk.value.length.toString(16)}\r\n`), chunk.value, textEncoder.encode(`\r\n`)]);
73
+ }
74
+ controller.enqueue(outputChunk);
75
+ } else if (chunk.done) {
76
+ if (!contentLength) {
77
+ controller.enqueue(Buffer.from(`0\r\n\r\n`, 'utf8'));
78
+ }
79
+ eof = true;
80
+ }
81
+ }
82
+ });
83
+ const readableHeaderChunkedBodyReader = readableHeaderChunkedBody.getReader();
84
+ const pipeChunk = async () => {
85
+ while (true) {
86
+ try {
87
+ const chunk = await readableHeaderChunkedBodyReader.read();
88
+ if (chunk.value) {
89
+ if (!client.write(chunk.value)) {
90
+ // interrupt this loop and wait for "drain" event
91
+ break;
92
+ }
93
+ } else if (chunk.done) {
94
+ break;
95
+ }
96
+ } catch (e) {
97
+ logger.error(e);
98
+ break;
99
+ }
100
+ }
101
+ };
102
+ client.on('drain', pipeChunk);
103
+ await pipeChunk();
104
+ });
105
+ });
106
+ }
107
+ //# sourceMappingURL=rn_streaming_fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ResponseParser","ReadableStream","reactNativeStreamingFetch","url","method","headers","body","contentLength","sockets","logger","isHttps","protocol","port","parseInt","Promise","resolve","reject","connectOptions","host","hostname","reuseAddress","clientSocket","Socket","client","TLSSocket","error","responseParser","reason","destroy","on","data","processResponseReadBuffer","err","info","connect","headerLines","pathname","search","forEach","value","key","push","textEncoder","TextEncoder","headerChunk","join","bodyReader","getReader","undefined","headerEnqueued","eof","readableHeaderChunkedBody","pull","controller","enqueue","close","chunk","read","outputChunk","Buffer","concat","encode","length","toString","done","from","readableHeaderChunkedBodyReader","pipeChunk","write","e"],"sourceRoot":"../../src","sources":["rn_streaming_fetch.ts"],"mappings":";;AAAA,OAAO,oCAAoC;AAG3C,SAASA,cAAc,QAAQ,8BAA2B;AAC1D,SAASC,cAAc,QAAQ,mCAAmC;AAElE,OAAO,eAAeC,yBAAyBA,CAC7CC,GAAQ,EACRC,MAAc,EACdC,OAAgB,EAChBC,IAA4C,EAC5CC,aAAiC,EACjCC,OAAY,EACZC,MAAc,EACK;EACnB,MAAMC,OAAO,GAAGP,GAAG,CAACQ,QAAQ,KAAK,QAAQ;EACzC,MAAMC,IAAI,GAAGT,GAAG,CAACS,IAAI,GAAGC,QAAQ,CAACV,GAAG,CAACS,IAAI,EAAE,EAAE,CAAC,GAAGF,OAAO,GAAG,GAAG,GAAG,EAAE;EACnE,OAAO,IAAII,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,MAAMC,cAAc,GAAG;MACrBL,IAAI,EAAEA,IAAI;MACVM,IAAI,EAAEf,GAAG,CAACgB,QAAQ;MAClBC,YAAY,EAAE;IAChB,CAAC;IACD,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IAAI,EAAE;YACrB,IAAI,CAACzD,aAAa,EAAE;cAClB8C,UAAU,CAACC,OAAO,CAACK,MAAM,CAACM,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACtD;YACAf,GAAG,GAAG,IAAI;UACZ;QACF;MACF,CAAC,CAAC;MAEF,MAAMgB,+BAA+B,GACnCf,yBAAyB,CAACJ,SAAS,CAAC,CAAC;MACvC,MAAMoB,SAAS,GAAG,MAAAA,CAAA,KAAY;QAC5B,OAAO,IAAI,EAAE;UACX,IAAI;YACF,MAAMX,KAAK,GAAG,MAAMU,+BAA+B,CAACT,IAAI,CAAC,CAAC;YAC1D,IAAID,KAAK,CAACjB,KAAK,EAAE;cACf,IAAI,CAAChB,MAAM,CAAC6C,KAAK,CAACZ,KAAK,CAACjB,KAAK,CAAC,EAAE;gBAC9B;gBACA;cACF;YACF,CAAC,MAAM,IAAIiB,KAAK,CAACQ,IAAI,EAAE;cACrB;YACF;UACF,CAAC,CAAC,OAAOK,CAAC,EAAE;YACV5D,MAAM,CAACgB,KAAK,CAAC4C,CAAC,CAAC;YACf;UACF;QACF;MACF,CAAC;MACD9C,MAAM,CAACM,EAAE,CAAC,OAAO,EAAEsC,SAAS,CAAC;MAC7B,MAAMA,SAAS,CAAC,CAAC;IACnB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,8 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import '@azure/core-asynciterator-polyfill';
3
+ import { DataEndpoint, DataOptions, WorkerEndpoint, WorkerOptions } from '@eyepop.ai/eyepop';
4
+ export declare namespace EyePop {
5
+ function workerEndpoint(opts?: WorkerOptions): WorkerEndpoint;
6
+ function dataEndpoint(opts?: DataOptions): DataEndpoint;
7
+ }
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAG5C,OAAO,oCAAoC,CAAC;AAU5C,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC;AAI3B,yBAAiB,MAAM,CAAC;IACtB,SAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,cAAc,CAUnE;IAED,SAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,CAU7D;CACF"}
@@ -0,0 +1,19 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import { Logger } from 'pino';
3
+ import { HttpClient } from '@eyepop.ai/eyepop';
4
+ /** HTTP client that will work around the RN fetch implementation and truly stream request and response bodies.
5
+ *
6
+ * While '{ textStreaming: true }' helps somewhat for the response body, it does not truly stream the response
7
+ * body, instead it keeps a large buffer and does not stream bytes to the consumer as they come in.
8
+ * Additionally, it does not support streaming request bodies which forces the consumer to load large files
9
+ * into memory w/o any possibility to avoid OOMs.
10
+ *
11
+ * This implementation implements selected HTTP interactions by using TCP sockets directly. The implementation
12
+ * is minimal and far from complete, e.g. no redirect support. For that reason, EyePop wil prefer to use the
13
+ * built-in fetch() except for cases when (a) the request requires a ReadableStream request body, or
14
+ * (b) the response is supposed to truly stream as indicated by the proprietary init parameter
15
+ * '{ eyepop: { responseStreaming: true} }'.
16
+ *
17
+ * */
18
+ export declare function createHttpClientRN(logger: Logger): Promise<HttpClient>;
19
+ //# sourceMappingURL=rn_http_client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_client.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_client.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C;;;;;;;;;;;;;KAaK;AACL,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoG5E"}
@@ -0,0 +1,2 @@
1
+ export declare function parseHttpHeader(lines: string[], onlyHeaders: boolean): {};
2
+ //# sourceMappingURL=rn_http_header_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_header_parser.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_header_parser.ts"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,MA6BpE"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="react-native" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import 'react-native-polyfill-globals/auto';
5
+ import { Logger } from 'pino';
6
+ export declare class ResponseParser {
7
+ private error;
8
+ private readonly logger;
9
+ private readonly resolve;
10
+ private readonly reject;
11
+ private responseChunkRemainder;
12
+ private responseReadBuffer;
13
+ private responseState;
14
+ private pullController;
15
+ private pullResolve;
16
+ private pullReject;
17
+ constructor(logger: Logger, resolve: (value: Response | PromiseLike<Response>) => void, reject: (reason?: any) => void);
18
+ processResponseReadBuffer(data: Buffer): boolean;
19
+ private pull;
20
+ }
21
+ //# sourceMappingURL=rn_http_response_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_response_parser.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_response_parser.ts"],"names":[],"mappings":";;;AAAA,OAAO,oCAAoC,CAAC;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAa9B,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoD;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,sBAAsB,CAAK;IACnC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,UAAU,CAAuC;gBAGvD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,IAAI,EAC1D,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI;IAazB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IA4HvD,OAAO,CAAC,IAAI;CA6Eb"}
@@ -0,0 +1,5 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import { PathSource, StreamSource } from '@eyepop.ai/eyepop';
3
+ import { Logger } from 'pino';
4
+ export declare function resolvePathRN(source: PathSource, _: Logger): Promise<StreamSource>;
5
+ //# sourceMappingURL=rn_local_file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_local_file.d.ts","sourceRoot":"","sources":["../../../../src/rn_local_file.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,wBAAsB,aAAa,CACjC,MAAM,EAAE,UAAU,EAClB,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,YAAY,CAAC,CAgCvB"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react-native" />
2
+ /// <reference types="node" />
3
+ import 'react-native-polyfill-globals/auto';
4
+ import { Logger } from 'pino';
5
+ import { ReadableStream } from 'web-streams-polyfill/ponyfill/es6';
6
+ export declare function reactNativeStreamingFetch(url: URL, method: string, headers: Headers, body: ReadableStream<Uint8Array> | undefined, contentLength: number | undefined, sockets: any, logger: Logger): Promise<Response>;
7
+ //# sourceMappingURL=rn_streaming_fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_streaming_fetch.d.ts","sourceRoot":"","sources":["../../../../src/rn_streaming_fetch.ts"],"names":[],"mappings":";;AAAA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,SAAS,EAC5C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAoHnB"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,8 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import '@azure/core-asynciterator-polyfill';
3
+ import { DataEndpoint, DataOptions, WorkerEndpoint, WorkerOptions } from '@eyepop.ai/eyepop';
4
+ export declare namespace EyePop {
5
+ function workerEndpoint(opts?: WorkerOptions): WorkerEndpoint;
6
+ function dataEndpoint(opts?: DataOptions): DataEndpoint;
7
+ }
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAG5C,OAAO,oCAAoC,CAAC;AAU5C,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC;AAI3B,yBAAiB,MAAM,CAAC;IACtB,SAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,aAAa,GAAG,cAAc,CAUnE;IAED,SAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,CAU7D;CACF"}
@@ -0,0 +1,19 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import { Logger } from 'pino';
3
+ import { HttpClient } from '@eyepop.ai/eyepop';
4
+ /** HTTP client that will work around the RN fetch implementation and truly stream request and response bodies.
5
+ *
6
+ * While '{ textStreaming: true }' helps somewhat for the response body, it does not truly stream the response
7
+ * body, instead it keeps a large buffer and does not stream bytes to the consumer as they come in.
8
+ * Additionally, it does not support streaming request bodies which forces the consumer to load large files
9
+ * into memory w/o any possibility to avoid OOMs.
10
+ *
11
+ * This implementation implements selected HTTP interactions by using TCP sockets directly. The implementation
12
+ * is minimal and far from complete, e.g. no redirect support. For that reason, EyePop wil prefer to use the
13
+ * built-in fetch() except for cases when (a) the request requires a ReadableStream request body, or
14
+ * (b) the response is supposed to truly stream as indicated by the proprietary init parameter
15
+ * '{ eyepop: { responseStreaming: true} }'.
16
+ *
17
+ * */
18
+ export declare function createHttpClientRN(logger: Logger): Promise<HttpClient>;
19
+ //# sourceMappingURL=rn_http_client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_client.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_client.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C;;;;;;;;;;;;;KAaK;AACL,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoG5E"}
@@ -0,0 +1,2 @@
1
+ export declare function parseHttpHeader(lines: string[], onlyHeaders: boolean): {};
2
+ //# sourceMappingURL=rn_http_header_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_header_parser.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_header_parser.ts"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,MA6BpE"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="react-native" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import 'react-native-polyfill-globals/auto';
5
+ import { Logger } from 'pino';
6
+ export declare class ResponseParser {
7
+ private error;
8
+ private readonly logger;
9
+ private readonly resolve;
10
+ private readonly reject;
11
+ private responseChunkRemainder;
12
+ private responseReadBuffer;
13
+ private responseState;
14
+ private pullController;
15
+ private pullResolve;
16
+ private pullReject;
17
+ constructor(logger: Logger, resolve: (value: Response | PromiseLike<Response>) => void, reject: (reason?: any) => void);
18
+ processResponseReadBuffer(data: Buffer): boolean;
19
+ private pull;
20
+ }
21
+ //# sourceMappingURL=rn_http_response_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_http_response_parser.d.ts","sourceRoot":"","sources":["../../../../src/rn_http_response_parser.ts"],"names":[],"mappings":";;;AAAA,OAAO,oCAAoC,CAAC;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAa9B,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoD;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,sBAAsB,CAAK;IACnC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,UAAU,CAAuC;gBAGvD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,IAAI,EAC1D,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI;IAazB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IA4HvD,OAAO,CAAC,IAAI;CA6Eb"}
@@ -0,0 +1,5 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ import { PathSource, StreamSource } from '@eyepop.ai/eyepop';
3
+ import { Logger } from 'pino';
4
+ export declare function resolvePathRN(source: PathSource, _: Logger): Promise<StreamSource>;
5
+ //# sourceMappingURL=rn_local_file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_local_file.d.ts","sourceRoot":"","sources":["../../../../src/rn_local_file.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,wBAAsB,aAAa,CACjC,MAAM,EAAE,UAAU,EAClB,CAAC,EAAE,MAAM,GACR,OAAO,CAAC,YAAY,CAAC,CAgCvB"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react-native" />
2
+ /// <reference types="node" />
3
+ import 'react-native-polyfill-globals/auto';
4
+ import { Logger } from 'pino';
5
+ import { ReadableStream } from 'web-streams-polyfill/ponyfill/es6';
6
+ export declare function reactNativeStreamingFetch(url: URL, method: string, headers: Headers, body: ReadableStream<Uint8Array> | undefined, contentLength: number | undefined, sockets: any, logger: Logger): Promise<Response>;
7
+ //# sourceMappingURL=rn_streaming_fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rn_streaming_fetch.d.ts","sourceRoot":"","sources":["../../../../src/rn_streaming_fetch.ts"],"names":[],"mappings":";;AAAA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,SAAS,EAC5C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAoHnB"}
package/package.json ADDED
@@ -0,0 +1,202 @@
1
+ {
2
+ "name": "@eyepop.ai/react-native-eyepop",
3
+ "version": "1.15.1",
4
+ "description": "The official Typescript library for EyePop.ai's inference API for React Native",
5
+ "source": "./src/index.ts",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./lib/typescript/module/src/index.d.ts",
13
+ "default": "./lib/module/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
17
+ "default": "./lib/commonjs/index.js"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "**/expo-module.config.json",
23
+ "src",
24
+ "lib",
25
+ "android",
26
+ "ios",
27
+ "cpp",
28
+ "*.podspec",
29
+ "react-native.config.js",
30
+ "!ios/build",
31
+ "!android/build",
32
+ "!android/gradle",
33
+ "!android/gradlew",
34
+ "!android/gradlew.bat",
35
+ "!android/local.properties",
36
+ "!**/__tests__",
37
+ "!**/__fixtures__",
38
+ "!**/__mocks__",
39
+ "!**/.*"
40
+ ],
41
+ "scripts": {
42
+ "example": "yarn workspace react-native-eyepop-example",
43
+ "test": "jest",
44
+ "typecheck": "tsc",
45
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
46
+ "clean": "del-cli lib",
47
+ "build": "bob build",
48
+ "release": "release-it"
49
+ },
50
+ "keywords": [
51
+ "react-native",
52
+ "ios",
53
+ "android"
54
+ ],
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/eyepop-ai/eyepop-sdk-node.git"
58
+ },
59
+ "author": "EyePop.ai <info@eyepop.ai> (https://github.com/eyepop-ai)",
60
+ "license": "MIT",
61
+ "bugs": {
62
+ "url": "https://github.com/eyepop-ai/eyepop-sdk-node/issues"
63
+ },
64
+ "homepage": "https://github.com/eyepop-ai/eyepop-sdk-node#readme",
65
+ "publishConfig": {
66
+ "registry": "https://registry.npmjs.org/"
67
+ },
68
+ "dependencies": {
69
+ "@azure/core-asynciterator-polyfill": "^1.0.2",
70
+ "@eyepop.ai/eyepop": "1.15.0",
71
+ "@eyepop.ai/eyepop-render-2d": "1.15.0",
72
+ "@types/react-native-canvas": "^0.1.14",
73
+ "buffer": "^6.0.3",
74
+ "react": "^18.3.1",
75
+ "react-native": "^0.76.7",
76
+ "react-native-polyfill-globals": "^3.1.0",
77
+ "web-streams-polyfill": "^3.3.3"
78
+ },
79
+ "peerDependencies": {
80
+ "react-native-canvas": "^0.1.40",
81
+ "react-native-file-access": "3.1.1",
82
+ "react-native-tcp-socket": "^6.2.0",
83
+ "react-native-webrtc": "^124.0.5"
84
+ },
85
+ "devDependencies": {
86
+ "@commitlint/config-conventional": "^19.6.0",
87
+ "@evilmartians/lefthook": "^1.5.0",
88
+ "@react-native/eslint-config": "^0.73.1",
89
+ "@release-it/conventional-changelog": "^9.0.2",
90
+ "@types/jest": "^29.5.5",
91
+ "@types/react": "^18.2.44",
92
+ "commitlint": "^19.6.1",
93
+ "del-cli": "^5.1.0",
94
+ "eslint": "^8.51.0",
95
+ "eslint-config-prettier": "^9.0.0",
96
+ "eslint-plugin-prettier": "^5.0.1",
97
+ "jest": "^29.7.0",
98
+ "prettier": "^3.0.3",
99
+ "react": "18.3.1",
100
+ "react-native": "0.76.7",
101
+ "react-native-builder-bob": "^0.38.0",
102
+ "release-it": "^17.10.0",
103
+ "typescript": "^5.2.2"
104
+ },
105
+ "resolutions": {
106
+ "@types/react": "^18.2.44"
107
+ },
108
+ "workspaces": [
109
+ "example"
110
+ ],
111
+ "jest": {
112
+ "preset": "react-native",
113
+ "modulePathIgnorePatterns": [
114
+ "<rootDir>/lib/"
115
+ ]
116
+ },
117
+ "commitlint": {
118
+ "extends": [
119
+ "@commitlint/config-conventional"
120
+ ]
121
+ },
122
+ "release-it": {
123
+ "git": {
124
+ "commitMessage": "chore: release ${version}",
125
+ "tagName": "v${version}"
126
+ },
127
+ "npm": {
128
+ "publish": true
129
+ },
130
+ "github": {
131
+ "release": true
132
+ },
133
+ "plugins": {
134
+ "@release-it/conventional-changelog": {
135
+ "preset": {
136
+ "name": "angular"
137
+ }
138
+ }
139
+ }
140
+ },
141
+ "eslintConfig": {
142
+ "root": true,
143
+ "extends": [
144
+ "@react-native",
145
+ "prettier"
146
+ ],
147
+ "rules": {
148
+ "react/react-in-jsx-scope": "off",
149
+ "prettier/prettier": [
150
+ "error",
151
+ {
152
+ "quoteProps": "consistent",
153
+ "singleQuote": true,
154
+ "tabWidth": 2,
155
+ "trailingComma": "es5",
156
+ "useTabs": false
157
+ }
158
+ ]
159
+ }
160
+ },
161
+ "eslintIgnore": [
162
+ "node_modules/",
163
+ "lib/"
164
+ ],
165
+ "prettier": {
166
+ "quoteProps": "consistent",
167
+ "singleQuote": true,
168
+ "tabWidth": 2,
169
+ "trailingComma": "es5",
170
+ "useTabs": false
171
+ },
172
+ "react-native-builder-bob": {
173
+ "source": "src",
174
+ "output": "lib",
175
+ "targets": [
176
+ [
177
+ "commonjs",
178
+ {
179
+ "esm": true
180
+ }
181
+ ],
182
+ [
183
+ "module",
184
+ {
185
+ "esm": true
186
+ }
187
+ ],
188
+ [
189
+ "typescript",
190
+ {
191
+ "project": "tsconfig.build.json",
192
+ "esm": true
193
+ }
194
+ ]
195
+ ]
196
+ },
197
+ "create-react-native-library": {
198
+ "languages": "js",
199
+ "type": "library",
200
+ "version": "0.48.5"
201
+ }
202
+ }
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ import 'react-native-polyfill-globals/auto';
2
+ globalThis.Buffer = require('buffer').Buffer;
3
+
4
+ import '@azure/core-asynciterator-polyfill';
5
+
6
+ import { RTCPeerConnection, RTCSessionDescription } from 'react-native-webrtc';
7
+ // @ts-ignore
8
+ globalThis.RTCPeerConnection = RTCPeerConnection;
9
+ // @ts-ignore
10
+ globalThis.RTCSessionDescription = RTCSessionDescription;
11
+
12
+ import { pino } from 'pino';
13
+
14
+ import {
15
+ DataEndpoint,
16
+ DataOptions,
17
+ EyePop as _EyePop,
18
+ WorkerEndpoint,
19
+ WorkerOptions,
20
+ } from '@eyepop.ai/eyepop';
21
+ import { resolvePathRN } from './rn_local_file';
22
+ import { createHttpClientRN } from './rn_http_client'
23
+
24
+ export namespace EyePop {
25
+ export function workerEndpoint(opts?: WorkerOptions): WorkerEndpoint {
26
+ opts = opts || {};
27
+ if (opts.logger === undefined) {
28
+ opts.logger = pino({ level: 'debug', name: 'eyepop' });
29
+ }
30
+ opts.platformSupport = {
31
+ resolvePath: resolvePathRN,
32
+ createHttpClient: createHttpClientRN,
33
+ };
34
+ return _EyePop.workerEndpoint(opts);
35
+ }
36
+
37
+ export function dataEndpoint(opts?: DataOptions): DataEndpoint {
38
+ opts = opts || {};
39
+ if (opts.logger === undefined) {
40
+ opts.logger = pino({ level: 'debug', name: 'eyepop' });
41
+ }
42
+ opts.platformSupport = {
43
+ resolvePath: resolvePathRN,
44
+ createHttpClient: createHttpClientRN,
45
+ };
46
+ return _EyePop.dataEndpoint(opts);
47
+ }
48
+ }