@eyepop.ai/eyepop 1.13.1 → 1.14.0
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/README.md +13 -2
- package/dist/eyepop.index.d.mts +27 -7
- package/dist/eyepop.index.d.ts +27 -7
- package/dist/eyepop.index.js +657 -92
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +656 -92
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.mjs
CHANGED
|
@@ -8818,6 +8818,65 @@ function readableStreamAsyncIterable(stream) {
|
|
|
8818
8818
|
};
|
|
8819
8819
|
}
|
|
8820
8820
|
|
|
8821
|
+
// worker/worker_types.ts
|
|
8822
|
+
var VideoMode = /* @__PURE__ */ ((VideoMode2) => {
|
|
8823
|
+
VideoMode2["STREAM"] = "stream";
|
|
8824
|
+
VideoMode2["BUFFER"] = "buffer";
|
|
8825
|
+
return VideoMode2;
|
|
8826
|
+
})(VideoMode || {});
|
|
8827
|
+
var ModelFormat = /* @__PURE__ */ ((ModelFormat2) => {
|
|
8828
|
+
ModelFormat2["TensorFlowLite"] = "TensorFlowLite";
|
|
8829
|
+
ModelFormat2["TensorFlowGraphDef"] = "TensorFlowGraphDef";
|
|
8830
|
+
ModelFormat2["ONNX"] = "ONNX";
|
|
8831
|
+
ModelFormat2["TorchScript"] = "TorchScript";
|
|
8832
|
+
ModelFormat2["TorchScriptCpu"] = "TorchScriptCpu";
|
|
8833
|
+
ModelFormat2["TorchScriptCuda"] = "TorchScriptCuda";
|
|
8834
|
+
return ModelFormat2;
|
|
8835
|
+
})(ModelFormat || {});
|
|
8836
|
+
var ModelPrecisionType = /* @__PURE__ */ ((ModelPrecisionType2) => {
|
|
8837
|
+
ModelPrecisionType2["float32"] = "float32";
|
|
8838
|
+
ModelPrecisionType2["float16"] = "float16";
|
|
8839
|
+
ModelPrecisionType2["int32"] = "int32";
|
|
8840
|
+
ModelPrecisionType2["int8"] = "int8";
|
|
8841
|
+
ModelPrecisionType2["uint8"] = "uint8";
|
|
8842
|
+
return ModelPrecisionType2;
|
|
8843
|
+
})(ModelPrecisionType || {});
|
|
8844
|
+
var PopComponentType = /* @__PURE__ */ ((PopComponentType2) => {
|
|
8845
|
+
PopComponentType2["FORWARD"] = "forward";
|
|
8846
|
+
PopComponentType2["INFERENCE"] = "inference";
|
|
8847
|
+
PopComponentType2["TRACING"] = "tracing";
|
|
8848
|
+
PopComponentType2["CONTOUR_FINDER"] = "contour_finder";
|
|
8849
|
+
PopComponentType2["COMPONENT_FINDER"] = "component_finder";
|
|
8850
|
+
return PopComponentType2;
|
|
8851
|
+
})(PopComponentType || {});
|
|
8852
|
+
var ForwardOperatorType = /* @__PURE__ */ ((ForwardOperatorType2) => {
|
|
8853
|
+
ForwardOperatorType2["FULL"] = "full";
|
|
8854
|
+
ForwardOperatorType2["CROP"] = "crop";
|
|
8855
|
+
ForwardOperatorType2["CROP_WITH_FULL_FALLBACK"] = "crop_with_full_fallback";
|
|
8856
|
+
return ForwardOperatorType2;
|
|
8857
|
+
})(ForwardOperatorType || {});
|
|
8858
|
+
var InferenceType = /* @__PURE__ */ ((InferenceType2) => {
|
|
8859
|
+
InferenceType2["IMAGE_CLASSIFICATION"] = "image_classification";
|
|
8860
|
+
InferenceType2["OBJECT_DETECTION"] = "object_detection";
|
|
8861
|
+
InferenceType2["KEY_POINTS"] = "key_points";
|
|
8862
|
+
InferenceType2["OCR"] = "ocr";
|
|
8863
|
+
InferenceType2["MESH"] = "mesh";
|
|
8864
|
+
InferenceType2["FEATURE_VECTOR"] = "feature_vector";
|
|
8865
|
+
InferenceType2["SEMANTIC_SEGMENTATION"] = "semantic_segmentation";
|
|
8866
|
+
InferenceType2["SEGMENTATION"] = "segmentation";
|
|
8867
|
+
return InferenceType2;
|
|
8868
|
+
})(InferenceType || {});
|
|
8869
|
+
var ContourType = /* @__PURE__ */ ((ContourType2) => {
|
|
8870
|
+
ContourType2["ALL_PIXELS"] = "all_pixels";
|
|
8871
|
+
ContourType2["POLYGON"] = "polygon";
|
|
8872
|
+
ContourType2["CONVEX_HULL"] = "convex_hull";
|
|
8873
|
+
ContourType2["HOUGH_CIRCLES"] = "hough_circles";
|
|
8874
|
+
ContourType2["CIRCLE"] = "circle";
|
|
8875
|
+
ContourType2["TRIANGLE"] = "triangle";
|
|
8876
|
+
ContourType2["RECTANGLE"] = "rectangle";
|
|
8877
|
+
return ContourType2;
|
|
8878
|
+
})(ContourType || {});
|
|
8879
|
+
|
|
8821
8880
|
// worker/jobs.ts
|
|
8822
8881
|
var AbstractJob = class {
|
|
8823
8882
|
constructor(params, getSession, client, requestLogger) {
|
|
@@ -8869,7 +8928,7 @@ var AbstractJob = class {
|
|
|
8869
8928
|
reject(`upload error ${response.status}: ${await response.text()}`);
|
|
8870
8929
|
break;
|
|
8871
8930
|
} else if (!response.body) {
|
|
8872
|
-
reject(
|
|
8931
|
+
reject("response body is empty");
|
|
8873
8932
|
break;
|
|
8874
8933
|
} else {
|
|
8875
8934
|
resolve(response.body);
|
|
@@ -8903,12 +8962,13 @@ var UploadJob = class extends AbstractJob {
|
|
|
8903
8962
|
get [Symbol.toStringTag]() {
|
|
8904
8963
|
return "uploadJob";
|
|
8905
8964
|
}
|
|
8906
|
-
constructor(stream, mimeType, videoMode, params, getSession, client, requestLogger) {
|
|
8965
|
+
constructor(stream, mimeType, size, videoMode, params, getSession, client, requestLogger) {
|
|
8907
8966
|
super(params, getSession, client, requestLogger);
|
|
8908
8967
|
this._uploadStream = stream;
|
|
8909
8968
|
this._mimeType = mimeType;
|
|
8969
|
+
this._size = size;
|
|
8910
8970
|
this._videoMode = videoMode;
|
|
8911
|
-
this._needsFullDuplex = !client.isFullDuplex() && mimeType.startsWith("video/")
|
|
8971
|
+
this._needsFullDuplex = !client.isFullDuplex() && mimeType.startsWith("video/") && videoMode == "stream" /* STREAM */;
|
|
8912
8972
|
}
|
|
8913
8973
|
async onEvent(event) {
|
|
8914
8974
|
if (event.type == "prepared") {
|
|
@@ -8923,7 +8983,7 @@ var UploadJob = class extends AbstractJob {
|
|
|
8923
8983
|
const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
|
|
8924
8984
|
const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=async&sourceId=${event.source_id}${videoModeQuery}`;
|
|
8925
8985
|
if (this._params) {
|
|
8926
|
-
this._requestLogger.debug(
|
|
8986
|
+
this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
|
|
8927
8987
|
const params = JSON.stringify(this._params);
|
|
8928
8988
|
const paramBlob = new Blob([params], { type: "application/json" });
|
|
8929
8989
|
const formData = new FormData();
|
|
@@ -8943,12 +9003,15 @@ var UploadJob = class extends AbstractJob {
|
|
|
8943
9003
|
duplex: "half"
|
|
8944
9004
|
});
|
|
8945
9005
|
} else {
|
|
8946
|
-
this._requestLogger.debug(
|
|
9006
|
+
this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
|
|
8947
9007
|
const headers = {
|
|
8948
9008
|
...session.authenticationHeaders(),
|
|
8949
9009
|
Accept: "application/jsonl",
|
|
8950
9010
|
"Content-Type": this._mimeType
|
|
8951
9011
|
};
|
|
9012
|
+
if (this._size) {
|
|
9013
|
+
headers["Content-Length"] = `${this._size}`;
|
|
9014
|
+
}
|
|
8952
9015
|
request = this._client.fetch(postUrl, {
|
|
8953
9016
|
headers,
|
|
8954
9017
|
method: "POST",
|
|
@@ -8960,12 +9023,12 @@ var UploadJob = class extends AbstractJob {
|
|
|
8960
9023
|
}
|
|
8961
9024
|
request.then(async (value) => {
|
|
8962
9025
|
if (value.status != 204) {
|
|
8963
|
-
this._requestLogger.debug(
|
|
9026
|
+
this._requestLogger.debug(`unexpected status ${value.status} (${await value.text()}) for POST ${postUrl}`);
|
|
8964
9027
|
}
|
|
8965
9028
|
}).catch((reason) => {
|
|
8966
|
-
this._requestLogger.debug(
|
|
9029
|
+
this._requestLogger.debug(`error ${reason} for POST ${postUrl}`);
|
|
8967
9030
|
}).finally(() => {
|
|
8968
|
-
this._requestLogger.debug(
|
|
9031
|
+
this._requestLogger.debug(`after POST ${postUrl}`);
|
|
8969
9032
|
});
|
|
8970
9033
|
}
|
|
8971
9034
|
return Promise.resolve();
|
|
@@ -8973,7 +9036,7 @@ var UploadJob = class extends AbstractJob {
|
|
|
8973
9036
|
async startJob() {
|
|
8974
9037
|
const session = await this._getSession();
|
|
8975
9038
|
if (!session.baseUrl) {
|
|
8976
|
-
return Promise.reject("session.baseUrl must not
|
|
9039
|
+
return Promise.reject("session.baseUrl must not be null");
|
|
8977
9040
|
}
|
|
8978
9041
|
let response;
|
|
8979
9042
|
if (this._needsFullDuplex) {
|
|
@@ -8982,7 +9045,7 @@ var UploadJob = class extends AbstractJob {
|
|
|
8982
9045
|
...session.authenticationHeaders(),
|
|
8983
9046
|
Accept: "application/jsonl"
|
|
8984
9047
|
};
|
|
8985
|
-
this._requestLogger.debug(
|
|
9048
|
+
this._requestLogger.debug(`before POST ${prepareUrl} to prepare full duplex upload`);
|
|
8986
9049
|
response = await this._client.fetch(prepareUrl, {
|
|
8987
9050
|
headers,
|
|
8988
9051
|
method: "POST",
|
|
@@ -8990,12 +9053,12 @@ var UploadJob = class extends AbstractJob {
|
|
|
8990
9053
|
// @ts-ignore
|
|
8991
9054
|
duplex: "half"
|
|
8992
9055
|
});
|
|
8993
|
-
this._requestLogger.debug(
|
|
9056
|
+
this._requestLogger.debug(`after POST ${prepareUrl} to prepare full duplex upload ${response.status} ${response.statusText}`);
|
|
8994
9057
|
} else {
|
|
8995
9058
|
const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
|
|
8996
9059
|
const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync${videoModeQuery}`;
|
|
8997
9060
|
if (this._params) {
|
|
8998
|
-
this._requestLogger.debug(
|
|
9061
|
+
this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
|
|
8999
9062
|
const params = JSON.stringify(this._params);
|
|
9000
9063
|
const paramBlob = new Blob([params], { type: "application/json" });
|
|
9001
9064
|
const formData = new FormData();
|
|
@@ -9014,14 +9077,17 @@ var UploadJob = class extends AbstractJob {
|
|
|
9014
9077
|
// @ts-ignore
|
|
9015
9078
|
duplex: "half"
|
|
9016
9079
|
});
|
|
9017
|
-
this._requestLogger.debug(
|
|
9080
|
+
this._requestLogger.debug(`after POST ${postUrl} with multipart body because of params)`);
|
|
9018
9081
|
} else {
|
|
9019
|
-
this._requestLogger.debug(
|
|
9082
|
+
this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
|
|
9020
9083
|
const headers = {
|
|
9021
9084
|
...session.authenticationHeaders(),
|
|
9022
9085
|
Accept: "application/jsonl",
|
|
9023
9086
|
"Content-Type": this._mimeType
|
|
9024
9087
|
};
|
|
9088
|
+
if (this._size) {
|
|
9089
|
+
headers["Content-Length"] = `${this._size}`;
|
|
9090
|
+
}
|
|
9025
9091
|
response = await this._client.fetch(postUrl, {
|
|
9026
9092
|
headers,
|
|
9027
9093
|
method: "POST",
|
|
@@ -9030,7 +9096,7 @@ var UploadJob = class extends AbstractJob {
|
|
|
9030
9096
|
// @ts-ignore
|
|
9031
9097
|
duplex: "half"
|
|
9032
9098
|
});
|
|
9033
|
-
this._requestLogger.debug(
|
|
9099
|
+
this._requestLogger.debug(`after POST ${postUrl} with stream as body`);
|
|
9034
9100
|
}
|
|
9035
9101
|
}
|
|
9036
9102
|
return response;
|
|
@@ -9532,17 +9598,85 @@ var WebrtcWhep = class extends WebrtcBase {
|
|
|
9532
9598
|
// shims/local_file.ts
|
|
9533
9599
|
var resolvePath;
|
|
9534
9600
|
if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
9535
|
-
resolvePath = async (source) => {
|
|
9601
|
+
resolvePath = async (source, logger) => {
|
|
9536
9602
|
throw new DOMException("resolving a path to a file is not supported in browser");
|
|
9537
9603
|
};
|
|
9538
9604
|
} else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9605
|
+
let RNFSName = "react-native-fs";
|
|
9606
|
+
let RNFS;
|
|
9607
|
+
let RNFSLoadError;
|
|
9608
|
+
try {
|
|
9609
|
+
RNFS = __require(RNFSName);
|
|
9610
|
+
} catch (e) {
|
|
9611
|
+
RNFSLoadError = e;
|
|
9612
|
+
}
|
|
9613
|
+
let EFSName = "expo-file-system";
|
|
9614
|
+
let EFS;
|
|
9615
|
+
let EFSLoadError;
|
|
9616
|
+
try {
|
|
9617
|
+
EFS = __require(EFSName);
|
|
9618
|
+
} catch (e) {
|
|
9619
|
+
EFSLoadError = e;
|
|
9620
|
+
}
|
|
9621
|
+
resolvePath = async (source, logger) => {
|
|
9622
|
+
if (RNFS?.read !== void 0) {
|
|
9623
|
+
logger.debug("Using react-native-fs to read local file");
|
|
9624
|
+
const bufferSize = 1024 * 1024;
|
|
9625
|
+
let pos = 0;
|
|
9626
|
+
let eof = false;
|
|
9627
|
+
const stream = new ReadableStream({
|
|
9628
|
+
async pull(controller) {
|
|
9629
|
+
if (eof) {
|
|
9630
|
+
return;
|
|
9631
|
+
}
|
|
9632
|
+
const chunkAsB64 = await RNFS.read(source.path, bufferSize, pos, "base64");
|
|
9633
|
+
if (chunkAsB64.length > 0) {
|
|
9634
|
+
const chunk = Buffer.from(chunkAsB64, "base64");
|
|
9635
|
+
controller.enqueue(chunk);
|
|
9636
|
+
pos += chunk.length;
|
|
9637
|
+
} else {
|
|
9638
|
+
eof = true;
|
|
9639
|
+
controller.close();
|
|
9640
|
+
}
|
|
9641
|
+
}
|
|
9642
|
+
});
|
|
9643
|
+
return {
|
|
9644
|
+
stream,
|
|
9645
|
+
size: (await RNFS.stat(source.path)).size,
|
|
9646
|
+
mimeType: source.mimeType || "image/*"
|
|
9647
|
+
};
|
|
9648
|
+
} else if (EFS?.readAsStringAsync !== void 0) {
|
|
9649
|
+
logger.debug("Using expo-file-system to read local file");
|
|
9650
|
+
const bufferSize = 1024 * 1024;
|
|
9651
|
+
let pos = 0;
|
|
9652
|
+
let eof = false;
|
|
9653
|
+
const stream = new ReadableStream({
|
|
9654
|
+
async pull(controller) {
|
|
9655
|
+
if (eof) {
|
|
9656
|
+
return;
|
|
9657
|
+
}
|
|
9658
|
+
const chunkAsB64 = await EFS.readAsStringAsync(`file://${source.path}`, {
|
|
9659
|
+
length: bufferSize,
|
|
9660
|
+
position: pos,
|
|
9661
|
+
encoding: "base64"
|
|
9662
|
+
});
|
|
9663
|
+
if (chunkAsB64) {
|
|
9664
|
+
const chunk = Buffer.from(chunkAsB64, "base64");
|
|
9665
|
+
controller.enqueue(chunk);
|
|
9666
|
+
pos += chunk.length;
|
|
9667
|
+
} else {
|
|
9668
|
+
eof = true;
|
|
9669
|
+
controller.close();
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
});
|
|
9673
|
+
return {
|
|
9674
|
+
stream,
|
|
9675
|
+
size: (await EFS.getInfoAsync(`file://${source.path}`)).size,
|
|
9676
|
+
mimeType: source.mimeType || "image/*"
|
|
9677
|
+
};
|
|
9678
|
+
}
|
|
9679
|
+
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.`);
|
|
9546
9680
|
};
|
|
9547
9681
|
} else {
|
|
9548
9682
|
let iteratorToStream = function(iterator) {
|
|
@@ -9563,7 +9697,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9563
9697
|
yield chunk;
|
|
9564
9698
|
}
|
|
9565
9699
|
}
|
|
9566
|
-
resolvePath = async (source) => {
|
|
9700
|
+
resolvePath = async (source, logger) => {
|
|
9567
9701
|
const mime = require_mime_types();
|
|
9568
9702
|
const filehandle = __require("node:fs/promises");
|
|
9569
9703
|
const fd = await filehandle.open(source.path, "r");
|
|
@@ -9579,6 +9713,403 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9579
9713
|
}
|
|
9580
9714
|
var iteratorToStream2;
|
|
9581
9715
|
|
|
9716
|
+
// shims/rn_http_header_parser.ts
|
|
9717
|
+
var startLine = /^[A-Z_]+(\/\d\.\d)? /;
|
|
9718
|
+
var requestLine = /^([A-Z_]+) (.+) [A-Z]+\/(\d)\.(\d)$/;
|
|
9719
|
+
var statusLine = /^[A-Z]+\/(\d)\.(\d) (\d{3}) (.*)$/;
|
|
9720
|
+
function parseHttpHeader(lines, onlyHeaders) {
|
|
9721
|
+
var line = lines[0];
|
|
9722
|
+
var match;
|
|
9723
|
+
if (onlyHeaders && startLine.test(line)) {
|
|
9724
|
+
return parseHeaders(lines);
|
|
9725
|
+
} else if ((match = line.match(requestLine)) !== null) {
|
|
9726
|
+
return {
|
|
9727
|
+
method: match[1],
|
|
9728
|
+
url: match[2],
|
|
9729
|
+
version: { major: parseInt(match[3], 10), minor: parseInt(match[4], 10) },
|
|
9730
|
+
headers: parseHeaders(lines)
|
|
9731
|
+
};
|
|
9732
|
+
} else if ((match = line.match(statusLine)) !== null) {
|
|
9733
|
+
return {
|
|
9734
|
+
version: { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) },
|
|
9735
|
+
statusCode: parseInt(match[3], 10),
|
|
9736
|
+
statusMessage: match[4],
|
|
9737
|
+
headers: parseHeaders(lines)
|
|
9738
|
+
};
|
|
9739
|
+
} else {
|
|
9740
|
+
return parseHeaders(lines);
|
|
9741
|
+
}
|
|
9742
|
+
}
|
|
9743
|
+
function parseHeaders(lines) {
|
|
9744
|
+
var headers = {};
|
|
9745
|
+
var i = 0;
|
|
9746
|
+
var line = lines[i];
|
|
9747
|
+
var index, name, value;
|
|
9748
|
+
if (startLine.test(line)) {
|
|
9749
|
+
line = line[++i];
|
|
9750
|
+
}
|
|
9751
|
+
while (line) {
|
|
9752
|
+
if (line[0] === " " || line[0] === " ") {
|
|
9753
|
+
value += " " + line.trim();
|
|
9754
|
+
i++;
|
|
9755
|
+
if (i < lines.length) {
|
|
9756
|
+
line = lines[i];
|
|
9757
|
+
} else {
|
|
9758
|
+
line = "";
|
|
9759
|
+
}
|
|
9760
|
+
continue;
|
|
9761
|
+
}
|
|
9762
|
+
if (name && value) {
|
|
9763
|
+
addHeaderLine(name, value, headers);
|
|
9764
|
+
}
|
|
9765
|
+
index = line.indexOf(":");
|
|
9766
|
+
name = line.substr(0, index);
|
|
9767
|
+
value = line.substr(index + 1).trim();
|
|
9768
|
+
i++;
|
|
9769
|
+
if (i < lines.length) {
|
|
9770
|
+
line = lines[i];
|
|
9771
|
+
} else {
|
|
9772
|
+
line = "";
|
|
9773
|
+
}
|
|
9774
|
+
}
|
|
9775
|
+
if (name && value) {
|
|
9776
|
+
addHeaderLine(name, value, headers);
|
|
9777
|
+
}
|
|
9778
|
+
return headers;
|
|
9779
|
+
}
|
|
9780
|
+
function addHeaderLine(field, value, dest) {
|
|
9781
|
+
field = field.toLowerCase();
|
|
9782
|
+
switch (field) {
|
|
9783
|
+
// Array headers:
|
|
9784
|
+
case "set-cookie":
|
|
9785
|
+
if (dest[field] !== void 0) {
|
|
9786
|
+
dest[field].push(value);
|
|
9787
|
+
} else {
|
|
9788
|
+
dest[field] = [value];
|
|
9789
|
+
}
|
|
9790
|
+
break;
|
|
9791
|
+
// list is taken from:
|
|
9792
|
+
// https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
|
|
9793
|
+
case "content-type":
|
|
9794
|
+
case "content-length":
|
|
9795
|
+
case "user-agent":
|
|
9796
|
+
case "referer":
|
|
9797
|
+
case "host":
|
|
9798
|
+
case "authorization":
|
|
9799
|
+
case "proxy-authorization":
|
|
9800
|
+
case "if-modified-since":
|
|
9801
|
+
case "if-unmodified-since":
|
|
9802
|
+
case "from":
|
|
9803
|
+
case "location":
|
|
9804
|
+
case "max-forwards":
|
|
9805
|
+
case "retry-after":
|
|
9806
|
+
case "etag":
|
|
9807
|
+
case "last-modified":
|
|
9808
|
+
case "server":
|
|
9809
|
+
case "age":
|
|
9810
|
+
case "expires":
|
|
9811
|
+
if (dest[field] === void 0) dest[field] = value;
|
|
9812
|
+
break;
|
|
9813
|
+
default:
|
|
9814
|
+
if (typeof dest[field] === "string") {
|
|
9815
|
+
dest[field] += ", " + value;
|
|
9816
|
+
} else {
|
|
9817
|
+
dest[field] = value;
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
|
|
9822
|
+
// shims/rn_http_response_parser.ts
|
|
9823
|
+
var ResponseParser = class {
|
|
9824
|
+
constructor(logger, resolve, reject) {
|
|
9825
|
+
this.responseChunkRemainder = 0;
|
|
9826
|
+
this.logger = logger;
|
|
9827
|
+
this.resolve = resolve;
|
|
9828
|
+
this.reject = reject;
|
|
9829
|
+
this.error = null;
|
|
9830
|
+
this.responseReadBuffer = void 0;
|
|
9831
|
+
this.responseState = 0 /* RECEIVING_HEADER */;
|
|
9832
|
+
this.pullController = void 0;
|
|
9833
|
+
this.pullResolve = void 0;
|
|
9834
|
+
this.pullReject = void 0;
|
|
9835
|
+
}
|
|
9836
|
+
processResponseReadBuffer(data) {
|
|
9837
|
+
if (this.error) {
|
|
9838
|
+
this.logger.info(`RN http streamed response, received ${data.length} bytes in error mode`);
|
|
9839
|
+
return false;
|
|
9840
|
+
}
|
|
9841
|
+
if (this.responseReadBuffer) {
|
|
9842
|
+
this.responseReadBuffer = Buffer.concat([this.responseReadBuffer, data]);
|
|
9843
|
+
} else {
|
|
9844
|
+
this.responseReadBuffer = Buffer.from(data.subarray());
|
|
9845
|
+
}
|
|
9846
|
+
if (this.responseState === 3 /* RECEIVING_COMPLETED */) {
|
|
9847
|
+
if (this.pullController) {
|
|
9848
|
+
this.pullController.close();
|
|
9849
|
+
if (this.pullResolve) {
|
|
9850
|
+
this.pullResolve();
|
|
9851
|
+
}
|
|
9852
|
+
}
|
|
9853
|
+
return false;
|
|
9854
|
+
} else if (this.responseState === 0 /* RECEIVING_HEADER */) {
|
|
9855
|
+
const headerEnd = this.responseReadBuffer.indexOf("\r\n\r\n");
|
|
9856
|
+
if (headerEnd >= 0) {
|
|
9857
|
+
let headerChunk = this.responseReadBuffer.subarray(0, headerEnd + 4);
|
|
9858
|
+
this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(headerEnd + 4));
|
|
9859
|
+
const maxHeaderLines = 128;
|
|
9860
|
+
let responseHeaderLines = [];
|
|
9861
|
+
const lineDecoder = new EyepopLineDecoder();
|
|
9862
|
+
for (const line of lineDecoder.decode(headerChunk)) {
|
|
9863
|
+
if (line.length > 0) {
|
|
9864
|
+
responseHeaderLines.push(line);
|
|
9865
|
+
if (responseHeaderLines.length > maxHeaderLines) {
|
|
9866
|
+
this.error = `Response header exceeds ${maxHeaderLines} lines`;
|
|
9867
|
+
this.reject(this.error);
|
|
9868
|
+
return false;
|
|
9869
|
+
}
|
|
9870
|
+
}
|
|
9871
|
+
}
|
|
9872
|
+
let responseHeader = parseHttpHeader(responseHeaderLines, false);
|
|
9873
|
+
if (responseHeader.statusCode === void 0) {
|
|
9874
|
+
this.logger.warn(`Could not find status header in HTTP response ${JSON.stringify(responseHeader)}`);
|
|
9875
|
+
this.reject("missing status header in HTTP response");
|
|
9876
|
+
return false;
|
|
9877
|
+
}
|
|
9878
|
+
const headers = new Headers(responseHeader.headers);
|
|
9879
|
+
if (headers.has("transfer-encoding")) {
|
|
9880
|
+
if (headers.get("transfer-encoding")?.toLowerCase() === "chunked") {
|
|
9881
|
+
this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
|
|
9882
|
+
this.responseChunkRemainder = 0;
|
|
9883
|
+
} else {
|
|
9884
|
+
this.error = `Response with unsupported transfer-encoding '${headers.get("transfer-encoding")}'`;
|
|
9885
|
+
this.reject(this.error);
|
|
9886
|
+
return false;
|
|
9887
|
+
}
|
|
9888
|
+
} else if (headers.has("content-length")) {
|
|
9889
|
+
this.responseState = 1 /* RECEIVING_BODY */;
|
|
9890
|
+
this.responseChunkRemainder = parseInt(headers.get("content-length") || "-1");
|
|
9891
|
+
} else {
|
|
9892
|
+
this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
|
|
9893
|
+
this.responseChunkRemainder = 0;
|
|
9894
|
+
}
|
|
9895
|
+
const responseBody = new ReadableStream({
|
|
9896
|
+
pull: (controller) => {
|
|
9897
|
+
if (this.error || this.responseState == 3 /* RECEIVING_COMPLETED */) {
|
|
9898
|
+
return;
|
|
9899
|
+
}
|
|
9900
|
+
if (this.pull(controller)) {
|
|
9901
|
+
return;
|
|
9902
|
+
}
|
|
9903
|
+
return new Promise((resolve, reject) => {
|
|
9904
|
+
if (this.pullController) {
|
|
9905
|
+
if (this.pullReject) {
|
|
9906
|
+
this.pullReject("pull, we got a pending controller already");
|
|
9907
|
+
}
|
|
9908
|
+
}
|
|
9909
|
+
this.pullController = controller;
|
|
9910
|
+
this.pullResolve = resolve;
|
|
9911
|
+
this.pullReject = reject;
|
|
9912
|
+
});
|
|
9913
|
+
},
|
|
9914
|
+
cancel: (reason) => {
|
|
9915
|
+
if (!this.error) {
|
|
9916
|
+
this.error = `cancelled: ${reason}`;
|
|
9917
|
+
this.reject(this.error);
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9920
|
+
});
|
|
9921
|
+
this.resolve(new Response(responseBody, {
|
|
9922
|
+
status: responseHeader.statusCode,
|
|
9923
|
+
statusText: responseHeader.statusText,
|
|
9924
|
+
headers
|
|
9925
|
+
}));
|
|
9926
|
+
}
|
|
9927
|
+
} else if (this.pullController) {
|
|
9928
|
+
if (this.pull(this.pullController)) {
|
|
9929
|
+
this.pullController = void 0;
|
|
9930
|
+
if (this.pullResolve) {
|
|
9931
|
+
this.pullResolve();
|
|
9932
|
+
}
|
|
9933
|
+
this.pullResolve = void 0;
|
|
9934
|
+
this.pullReject = void 0;
|
|
9935
|
+
}
|
|
9936
|
+
}
|
|
9937
|
+
return true;
|
|
9938
|
+
}
|
|
9939
|
+
pull(controller) {
|
|
9940
|
+
if (this.responseState == 3 /* RECEIVING_COMPLETED */) {
|
|
9941
|
+
controller.close();
|
|
9942
|
+
return false;
|
|
9943
|
+
}
|
|
9944
|
+
if (this.responseReadBuffer === void 0) {
|
|
9945
|
+
return false;
|
|
9946
|
+
}
|
|
9947
|
+
if (this.responseState == 1 /* RECEIVING_BODY */) {
|
|
9948
|
+
controller.enqueue(this.responseReadBuffer);
|
|
9949
|
+
this.responseChunkRemainder -= this.responseReadBuffer.length;
|
|
9950
|
+
this.responseReadBuffer = void 0;
|
|
9951
|
+
if (this.responseChunkRemainder <= 0) {
|
|
9952
|
+
this.responseState = 3 /* RECEIVING_COMPLETED */;
|
|
9953
|
+
controller.close();
|
|
9954
|
+
}
|
|
9955
|
+
return true;
|
|
9956
|
+
} else if (this.responseState == 2 /* RECEIVING_BODY_CHUNKED */) {
|
|
9957
|
+
while (this.responseReadBuffer.length > 1) {
|
|
9958
|
+
if (this.responseChunkRemainder == 0) {
|
|
9959
|
+
let chunkHeaderEnd = 0;
|
|
9960
|
+
while (this.responseReadBuffer.length >= 2 && chunkHeaderEnd == 0) {
|
|
9961
|
+
chunkHeaderEnd = this.responseReadBuffer.indexOf("\r\n");
|
|
9962
|
+
if (chunkHeaderEnd == 0) {
|
|
9963
|
+
this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(2));
|
|
9964
|
+
}
|
|
9965
|
+
}
|
|
9966
|
+
if (chunkHeaderEnd > 0) {
|
|
9967
|
+
this.responseChunkRemainder = parseInt(Buffer.from(this.responseReadBuffer, 0, chunkHeaderEnd).toString("utf8"), 16);
|
|
9968
|
+
this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(chunkHeaderEnd + 2));
|
|
9969
|
+
if (this.responseChunkRemainder <= 0) {
|
|
9970
|
+
this.responseState = 3 /* RECEIVING_COMPLETED */;
|
|
9971
|
+
controller.close();
|
|
9972
|
+
return true;
|
|
9973
|
+
}
|
|
9974
|
+
} else if (this.responseReadBuffer.length > 64) {
|
|
9975
|
+
this.error = "Cannot find chunked encoding header within 64 bytes, given up";
|
|
9976
|
+
controller.error(this.error);
|
|
9977
|
+
}
|
|
9978
|
+
}
|
|
9979
|
+
if (this.responseChunkRemainder > 0 && this.responseReadBuffer.length > 0) {
|
|
9980
|
+
const chunk = Buffer.from(this.responseReadBuffer.subarray(0, this.responseChunkRemainder));
|
|
9981
|
+
this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(this.responseChunkRemainder));
|
|
9982
|
+
controller.enqueue(chunk);
|
|
9983
|
+
this.responseChunkRemainder -= chunk.length;
|
|
9984
|
+
return true;
|
|
9985
|
+
} else {
|
|
9986
|
+
break;
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9989
|
+
} else {
|
|
9990
|
+
this.error = `Received more data in wrong state ${this.responseState}`;
|
|
9991
|
+
controller.error(this.error);
|
|
9992
|
+
}
|
|
9993
|
+
return false;
|
|
9994
|
+
}
|
|
9995
|
+
};
|
|
9996
|
+
|
|
9997
|
+
// shims/rn_streaming_fetch.ts
|
|
9998
|
+
async function reactNativeStreamingFetch(url, method, headers, body, contentLength, sockets, logger) {
|
|
9999
|
+
const isHttps = url.protocol == "https:";
|
|
10000
|
+
const port = url.port ? parseInt(url.port) : isHttps ? 443 : 80;
|
|
10001
|
+
return new Promise((resolve, reject) => {
|
|
10002
|
+
const connectOptions = {
|
|
10003
|
+
port,
|
|
10004
|
+
host: url.hostname,
|
|
10005
|
+
reuseAddress: true
|
|
10006
|
+
};
|
|
10007
|
+
const clientSocket = new sockets.Socket();
|
|
10008
|
+
const client = isHttps ? new sockets.TLSSocket(clientSocket) : clientSocket;
|
|
10009
|
+
let error;
|
|
10010
|
+
const responseParser = new ResponseParser(logger, resolve, (reason) => {
|
|
10011
|
+
error = reason;
|
|
10012
|
+
reject(error);
|
|
10013
|
+
client.destroy();
|
|
10014
|
+
});
|
|
10015
|
+
client.on("data", function(data) {
|
|
10016
|
+
responseParser.processResponseReadBuffer(data);
|
|
10017
|
+
});
|
|
10018
|
+
client.on("error", function(err) {
|
|
10019
|
+
logger.info(`error: ${err}`);
|
|
10020
|
+
if (!error) {
|
|
10021
|
+
error = err;
|
|
10022
|
+
reject(error);
|
|
10023
|
+
}
|
|
10024
|
+
client.destroy();
|
|
10025
|
+
});
|
|
10026
|
+
client.on("close", function() {
|
|
10027
|
+
if (!error) {
|
|
10028
|
+
error = "socket closed";
|
|
10029
|
+
reject(error);
|
|
10030
|
+
}
|
|
10031
|
+
});
|
|
10032
|
+
client.connect(connectOptions, async () => {
|
|
10033
|
+
const headerLines = [
|
|
10034
|
+
`${method} ${url.pathname}${url.search} HTTP/1.1\r
|
|
10035
|
+
`,
|
|
10036
|
+
`Host: ${url.host}\r
|
|
10037
|
+
`
|
|
10038
|
+
];
|
|
10039
|
+
headers.forEach((value, key) => {
|
|
10040
|
+
headerLines.push(`${key}: ${value}\r
|
|
10041
|
+
`);
|
|
10042
|
+
});
|
|
10043
|
+
headerLines.push("\r\n");
|
|
10044
|
+
const textEncoder = new TextEncoder();
|
|
10045
|
+
const headerChunk = headerLines.join("");
|
|
10046
|
+
const bodyReader = body ? body.getReader() : void 0;
|
|
10047
|
+
let headerEnqueued = false;
|
|
10048
|
+
let eof = false;
|
|
10049
|
+
const readableHeaderChunkedBody = new ReadableStream({
|
|
10050
|
+
async pull(controller) {
|
|
10051
|
+
if (!headerEnqueued) {
|
|
10052
|
+
controller.enqueue(headerChunk);
|
|
10053
|
+
headerEnqueued = true;
|
|
10054
|
+
return;
|
|
10055
|
+
}
|
|
10056
|
+
if (eof) {
|
|
10057
|
+
controller.close();
|
|
10058
|
+
return;
|
|
10059
|
+
}
|
|
10060
|
+
if (!bodyReader) {
|
|
10061
|
+
controller.close();
|
|
10062
|
+
return;
|
|
10063
|
+
}
|
|
10064
|
+
const chunk = await bodyReader.read();
|
|
10065
|
+
if (chunk.value) {
|
|
10066
|
+
let outputChunk;
|
|
10067
|
+
if (contentLength) {
|
|
10068
|
+
outputChunk = chunk.value;
|
|
10069
|
+
} else {
|
|
10070
|
+
outputChunk = Buffer.concat([
|
|
10071
|
+
textEncoder.encode(`${chunk.value.length.toString(16)}\r
|
|
10072
|
+
`),
|
|
10073
|
+
chunk.value,
|
|
10074
|
+
textEncoder.encode(`\r
|
|
10075
|
+
`)
|
|
10076
|
+
]);
|
|
10077
|
+
}
|
|
10078
|
+
controller.enqueue(outputChunk);
|
|
10079
|
+
} else if (chunk.done) {
|
|
10080
|
+
if (!contentLength) {
|
|
10081
|
+
controller.enqueue(Buffer.from(`0\r
|
|
10082
|
+
\r
|
|
10083
|
+
`, "utf8"));
|
|
10084
|
+
}
|
|
10085
|
+
eof = true;
|
|
10086
|
+
}
|
|
10087
|
+
}
|
|
10088
|
+
});
|
|
10089
|
+
const readableHeaderChunkedBodyReader = readableHeaderChunkedBody.getReader();
|
|
10090
|
+
const pipeChunk = async () => {
|
|
10091
|
+
while (true) {
|
|
10092
|
+
try {
|
|
10093
|
+
const chunk = await readableHeaderChunkedBodyReader.read();
|
|
10094
|
+
if (chunk.value) {
|
|
10095
|
+
if (!client.write(chunk.value)) {
|
|
10096
|
+
break;
|
|
10097
|
+
}
|
|
10098
|
+
} else if (chunk.done) {
|
|
10099
|
+
break;
|
|
10100
|
+
}
|
|
10101
|
+
} catch (e) {
|
|
10102
|
+
logger.error(e);
|
|
10103
|
+
break;
|
|
10104
|
+
}
|
|
10105
|
+
}
|
|
10106
|
+
};
|
|
10107
|
+
client.on("drain", pipeChunk);
|
|
10108
|
+
await pipeChunk();
|
|
10109
|
+
});
|
|
10110
|
+
});
|
|
10111
|
+
}
|
|
10112
|
+
|
|
9582
10113
|
// shims/http_client.ts
|
|
9583
10114
|
var createHttpClient;
|
|
9584
10115
|
if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
@@ -9594,15 +10125,97 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9594
10125
|
return false;
|
|
9595
10126
|
}
|
|
9596
10127
|
}
|
|
9597
|
-
createHttpClient = async () => {
|
|
10128
|
+
createHttpClient = async (logger) => {
|
|
10129
|
+
logger.debug("Using browser fetch as http client");
|
|
9598
10130
|
return new BrowserHttpClient();
|
|
9599
10131
|
};
|
|
9600
10132
|
} else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
10133
|
+
let RNName = "react-native";
|
|
10134
|
+
let RN;
|
|
10135
|
+
let TcpSocketsName = "react-native-tcp-socket";
|
|
10136
|
+
let TcpSockets;
|
|
10137
|
+
let TcpSocketsError;
|
|
10138
|
+
try {
|
|
10139
|
+
RN = __require(RNName);
|
|
10140
|
+
TcpSockets = __require(TcpSocketsName);
|
|
10141
|
+
if (TcpSockets?.TLSSocket) {
|
|
10142
|
+
if (!RN?.NativeModules?.TcpSockets) {
|
|
10143
|
+
TcpSockets = void 0;
|
|
10144
|
+
throw Error(`'${TcpSocketsName}' but not symbol NativeModules?.TcpSockets, native sockets not available when running 'npx expo start', use 'npx expo run:android' or 'npx expo run:ios' instead`);
|
|
10145
|
+
}
|
|
10146
|
+
}
|
|
10147
|
+
} catch (e) {
|
|
10148
|
+
TcpSocketsError = e;
|
|
10149
|
+
}
|
|
9601
10150
|
class ReactNativeHttpClient {
|
|
9602
|
-
constructor() {
|
|
10151
|
+
constructor(logger) {
|
|
10152
|
+
this.logger = logger;
|
|
9603
10153
|
}
|
|
9604
10154
|
async fetch(input, init) {
|
|
9605
10155
|
init || (init = {});
|
|
10156
|
+
let streamBody;
|
|
10157
|
+
if (input instanceof Request) {
|
|
10158
|
+
if (input.body instanceof ReadableStream) {
|
|
10159
|
+
streamBody = input.body;
|
|
10160
|
+
}
|
|
10161
|
+
} else if (init?.body instanceof ReadableStream) {
|
|
10162
|
+
streamBody = init.body;
|
|
10163
|
+
}
|
|
10164
|
+
if (streamBody) {
|
|
10165
|
+
if (TcpSockets?.TLSSocket !== void 0) {
|
|
10166
|
+
let url;
|
|
10167
|
+
let method;
|
|
10168
|
+
let headers;
|
|
10169
|
+
if (input instanceof Request) {
|
|
10170
|
+
url = new URL(input.url);
|
|
10171
|
+
method = input.method;
|
|
10172
|
+
headers = input.headers;
|
|
10173
|
+
} else {
|
|
10174
|
+
if (input instanceof URL) {
|
|
10175
|
+
url = input;
|
|
10176
|
+
} else {
|
|
10177
|
+
url = new URL(input);
|
|
10178
|
+
}
|
|
10179
|
+
method = init?.method || "POST";
|
|
10180
|
+
headers = new Headers(init?.headers);
|
|
10181
|
+
}
|
|
10182
|
+
let contentLength = void 0;
|
|
10183
|
+
if (headers.has("content-length")) {
|
|
10184
|
+
contentLength = parseInt(headers.get("content-length") || "");
|
|
10185
|
+
} else {
|
|
10186
|
+
headers.append("Transfer-Encoding", "chunked");
|
|
10187
|
+
}
|
|
10188
|
+
return await reactNativeStreamingFetch(
|
|
10189
|
+
url,
|
|
10190
|
+
method,
|
|
10191
|
+
headers,
|
|
10192
|
+
streamBody,
|
|
10193
|
+
contentLength,
|
|
10194
|
+
TcpSockets,
|
|
10195
|
+
this.logger
|
|
10196
|
+
);
|
|
10197
|
+
} else {
|
|
10198
|
+
this.logger.warn(`[${TcpSockets}] Could not load '${TcpSocketsName}' (reason" ${TcpSocketsError}), include this package in your application to enable streamed uploads; without this package local files have to be loaded into memory uploading and this will cause Out-Of-Memory errors for large files.`);
|
|
10199
|
+
try {
|
|
10200
|
+
const chunks = [];
|
|
10201
|
+
const reader = streamBody.getReader();
|
|
10202
|
+
while (true) {
|
|
10203
|
+
const { done, value } = await reader.read();
|
|
10204
|
+
if (done) {
|
|
10205
|
+
break;
|
|
10206
|
+
}
|
|
10207
|
+
chunks.push(value);
|
|
10208
|
+
}
|
|
10209
|
+
if (input instanceof Request) {
|
|
10210
|
+
input = new Request(input, { body: Buffer.concat(chunks) });
|
|
10211
|
+
} else {
|
|
10212
|
+
init.body = Buffer.concat(chunks);
|
|
10213
|
+
}
|
|
10214
|
+
} catch (e) {
|
|
10215
|
+
return Promise.reject(e);
|
|
10216
|
+
}
|
|
10217
|
+
}
|
|
10218
|
+
}
|
|
9606
10219
|
init.reactNative = { textStreaming: true };
|
|
9607
10220
|
return await fetch(input, init);
|
|
9608
10221
|
}
|
|
@@ -9612,8 +10225,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9612
10225
|
return true;
|
|
9613
10226
|
}
|
|
9614
10227
|
}
|
|
9615
|
-
createHttpClient = async () => {
|
|
9616
|
-
|
|
10228
|
+
createHttpClient = async (logger) => {
|
|
10229
|
+
logger.debug("using React Native fetch and will attempt direct sockets communication for uploads to workaround the missing request body streaming support in React Native.");
|
|
10230
|
+
return new ReactNativeHttpClient(logger);
|
|
9617
10231
|
};
|
|
9618
10232
|
} else {
|
|
9619
10233
|
class NodeHttpClient {
|
|
@@ -9632,7 +10246,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9632
10246
|
return false;
|
|
9633
10247
|
}
|
|
9634
10248
|
}
|
|
9635
|
-
createHttpClient = async () => {
|
|
10249
|
+
createHttpClient = async (logger) => {
|
|
9636
10250
|
const undici = __require("undici");
|
|
9637
10251
|
const agent = new undici.Agent({
|
|
9638
10252
|
keepAliveTimeout: 1e4,
|
|
@@ -9640,6 +10254,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9640
10254
|
// two parallel streaming requests to the same host seem to deadlock with pipelining > 0
|
|
9641
10255
|
pipelining: 0
|
|
9642
10256
|
});
|
|
10257
|
+
logger.debug("Using node fetch with undici agent as http client");
|
|
9643
10258
|
return new NodeHttpClient(agent);
|
|
9644
10259
|
};
|
|
9645
10260
|
}
|
|
@@ -9809,7 +10424,10 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
|
|
|
9809
10424
|
popId: workerOptions.popId,
|
|
9810
10425
|
baseUrl: void 0,
|
|
9811
10426
|
pipelineId: void 0,
|
|
9812
|
-
sandboxId: void 0
|
|
10427
|
+
sandboxId: void 0,
|
|
10428
|
+
authenticationHeaders: () => {
|
|
10429
|
+
return { Authorization: `Bearer ${accessToken}` };
|
|
10430
|
+
}
|
|
9813
10431
|
};
|
|
9814
10432
|
session = workerSession;
|
|
9815
10433
|
} else {
|
|
@@ -9908,7 +10526,7 @@ var Endpoint = class {
|
|
|
9908
10526
|
} else {
|
|
9909
10527
|
return Promise.reject("option secretKey or environment variable EYEPOP_SECRET_KEY is required");
|
|
9910
10528
|
}
|
|
9911
|
-
this._client = await createHttpClient();
|
|
10529
|
+
this._client = await createHttpClient(this._logger);
|
|
9912
10530
|
return await this.reconnect();
|
|
9913
10531
|
}
|
|
9914
10532
|
async disconnect(wait = true) {
|
|
@@ -10343,6 +10961,7 @@ var WorkerEndpoint = class extends Endpoint {
|
|
|
10343
10961
|
const job = new UploadJob(
|
|
10344
10962
|
source.file.stream(),
|
|
10345
10963
|
source.file.type,
|
|
10964
|
+
source.file.size,
|
|
10346
10965
|
source.videoMode,
|
|
10347
10966
|
params,
|
|
10348
10967
|
async () => {
|
|
@@ -10374,6 +10993,7 @@ var WorkerEndpoint = class extends Endpoint {
|
|
|
10374
10993
|
const job = new UploadJob(
|
|
10375
10994
|
source.stream,
|
|
10376
10995
|
source.mimeType,
|
|
10996
|
+
source.size,
|
|
10377
10997
|
source.videoMode,
|
|
10378
10998
|
params,
|
|
10379
10999
|
async () => {
|
|
@@ -10402,10 +11022,11 @@ var WorkerEndpoint = class extends Endpoint {
|
|
|
10402
11022
|
await this._limit.acquire();
|
|
10403
11023
|
try {
|
|
10404
11024
|
this.updateState();
|
|
10405
|
-
const streamSource = await resolvePath(source);
|
|
11025
|
+
const streamSource = await resolvePath(source, this._logger);
|
|
10406
11026
|
const job = new UploadJob(
|
|
10407
11027
|
streamSource.stream,
|
|
10408
11028
|
streamSource.mimeType,
|
|
11029
|
+
streamSource.size,
|
|
10409
11030
|
source.videoMode,
|
|
10410
11031
|
params,
|
|
10411
11032
|
async () => {
|
|
@@ -10608,7 +11229,8 @@ var WorkerEndpoint = class extends Endpoint {
|
|
|
10608
11229
|
if (this.options().stopJobs) {
|
|
10609
11230
|
const body = { sourceType: "NONE" };
|
|
10610
11231
|
const headers3 = {
|
|
10611
|
-
Authorization: await this.authorizationHeader()
|
|
11232
|
+
Authorization: await this.authorizationHeader(),
|
|
11233
|
+
"Content-Type": "application/json"
|
|
10612
11234
|
};
|
|
10613
11235
|
const stop_url = `${this._baseUrl}/pipelines/${this._pipeline.id}/source?mode=preempt&processing=sync`;
|
|
10614
11236
|
let response3 = await this._client.fetch(stop_url, {
|
|
@@ -11520,65 +12142,6 @@ var DataEndpoint = class extends Endpoint {
|
|
|
11520
12142
|
}
|
|
11521
12143
|
};
|
|
11522
12144
|
|
|
11523
|
-
// worker/worker_types.ts
|
|
11524
|
-
var VideoMode = /* @__PURE__ */ ((VideoMode2) => {
|
|
11525
|
-
VideoMode2["STREAM"] = "stream";
|
|
11526
|
-
VideoMode2["BUFFER"] = "buffer";
|
|
11527
|
-
return VideoMode2;
|
|
11528
|
-
})(VideoMode || {});
|
|
11529
|
-
var ModelFormat = /* @__PURE__ */ ((ModelFormat2) => {
|
|
11530
|
-
ModelFormat2["TensorFlowLite"] = "TensorFlowLite";
|
|
11531
|
-
ModelFormat2["TensorFlowGraphDef"] = "TensorFlowGraphDef";
|
|
11532
|
-
ModelFormat2["ONNX"] = "ONNX";
|
|
11533
|
-
ModelFormat2["TorchScript"] = "TorchScript";
|
|
11534
|
-
ModelFormat2["TorchScriptCpu"] = "TorchScriptCpu";
|
|
11535
|
-
ModelFormat2["TorchScriptCuda"] = "TorchScriptCuda";
|
|
11536
|
-
return ModelFormat2;
|
|
11537
|
-
})(ModelFormat || {});
|
|
11538
|
-
var ModelPrecisionType = /* @__PURE__ */ ((ModelPrecisionType2) => {
|
|
11539
|
-
ModelPrecisionType2["float32"] = "float32";
|
|
11540
|
-
ModelPrecisionType2["float16"] = "float16";
|
|
11541
|
-
ModelPrecisionType2["int32"] = "int32";
|
|
11542
|
-
ModelPrecisionType2["int8"] = "int8";
|
|
11543
|
-
ModelPrecisionType2["uint8"] = "uint8";
|
|
11544
|
-
return ModelPrecisionType2;
|
|
11545
|
-
})(ModelPrecisionType || {});
|
|
11546
|
-
var PopComponentType = /* @__PURE__ */ ((PopComponentType2) => {
|
|
11547
|
-
PopComponentType2["FORWARD"] = "forward";
|
|
11548
|
-
PopComponentType2["INFERENCE"] = "inference";
|
|
11549
|
-
PopComponentType2["TRACING"] = "tracing";
|
|
11550
|
-
PopComponentType2["CONTOUR_FINDER"] = "contour_finder";
|
|
11551
|
-
PopComponentType2["COMPONENT_FINDER"] = "component_finder";
|
|
11552
|
-
return PopComponentType2;
|
|
11553
|
-
})(PopComponentType || {});
|
|
11554
|
-
var ForwardOperatorType = /* @__PURE__ */ ((ForwardOperatorType2) => {
|
|
11555
|
-
ForwardOperatorType2["FULL"] = "full";
|
|
11556
|
-
ForwardOperatorType2["CROP"] = "crop";
|
|
11557
|
-
ForwardOperatorType2["CROP_WITH_FULL_FALLBACK"] = "crop_with_full_fallback";
|
|
11558
|
-
return ForwardOperatorType2;
|
|
11559
|
-
})(ForwardOperatorType || {});
|
|
11560
|
-
var InferenceType = /* @__PURE__ */ ((InferenceType2) => {
|
|
11561
|
-
InferenceType2["IMAGE_CLASSIFICATION"] = "image_classification";
|
|
11562
|
-
InferenceType2["OBJECT_DETECTION"] = "object_detection";
|
|
11563
|
-
InferenceType2["KEY_POINTS"] = "key_points";
|
|
11564
|
-
InferenceType2["OCR"] = "ocr";
|
|
11565
|
-
InferenceType2["MESH"] = "mesh";
|
|
11566
|
-
InferenceType2["FEATURE_VECTOR"] = "feature_vector";
|
|
11567
|
-
InferenceType2["SEMANTIC_SEGMENTATION"] = "semantic_segmentation";
|
|
11568
|
-
InferenceType2["SEGMENTATION"] = "segmentation";
|
|
11569
|
-
return InferenceType2;
|
|
11570
|
-
})(InferenceType || {});
|
|
11571
|
-
var ContourType = /* @__PURE__ */ ((ContourType2) => {
|
|
11572
|
-
ContourType2["ALL_PIXELS"] = "all_pixels";
|
|
11573
|
-
ContourType2["POLYGON"] = "polygon";
|
|
11574
|
-
ContourType2["CONVEX_HULL"] = "convex_hull";
|
|
11575
|
-
ContourType2["HOUGH_CIRCLES"] = "hough_circles";
|
|
11576
|
-
ContourType2["CIRCLE"] = "circle";
|
|
11577
|
-
ContourType2["TRIANGLE"] = "triangle";
|
|
11578
|
-
ContourType2["RECTANGLE"] = "rectangle";
|
|
11579
|
-
return ContourType2;
|
|
11580
|
-
})(ContourType || {});
|
|
11581
|
-
|
|
11582
12145
|
// index.ts
|
|
11583
12146
|
var readEnv = (env) => {
|
|
11584
12147
|
if (typeof process !== "undefined") {
|
|
@@ -11707,6 +12270,7 @@ export {
|
|
|
11707
12270
|
EndpointState,
|
|
11708
12271
|
ExportedBy,
|
|
11709
12272
|
EyePop,
|
|
12273
|
+
EyepopLineDecoder,
|
|
11710
12274
|
ForwardOperatorType,
|
|
11711
12275
|
InferenceType,
|
|
11712
12276
|
LoadFromJob,
|