@eyepop.ai/eyepop 1.14.4 → 1.15.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.
@@ -8997,7 +8997,6 @@ var UploadJob = class extends AbstractJob {
8997
8997
  const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
8998
8998
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=async&sourceId=${event.source_id}${videoModeQuery}`;
8999
8999
  if (this._params) {
9000
- this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
9001
9000
  const params = JSON.stringify(this._params);
9002
9001
  const paramBlob = new Blob([params], { type: "application/json" });
9003
9002
  const formData = new FormData();
@@ -9014,10 +9013,10 @@ var UploadJob = class extends AbstractJob {
9014
9013
  body: formData,
9015
9014
  signal: this._controller.signal,
9016
9015
  // @ts-ignore
9017
- duplex: "half"
9016
+ duplex: "half",
9017
+ eyepop: { responseStreaming: true }
9018
9018
  });
9019
9019
  } else {
9020
- this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
9021
9020
  const headers = {
9022
9021
  ...session.authenticationHeaders(),
9023
9022
  Accept: "application/jsonl",
@@ -9032,7 +9031,8 @@ var UploadJob = class extends AbstractJob {
9032
9031
  body: this._uploadStream,
9033
9032
  signal: this._controller.signal,
9034
9033
  // @ts-ignore
9035
- duplex: "half"
9034
+ duplex: "half",
9035
+ eyepop: { responseStreaming: true }
9036
9036
  });
9037
9037
  }
9038
9038
  request.then(async (value) => {
@@ -9041,8 +9041,6 @@ var UploadJob = class extends AbstractJob {
9041
9041
  }
9042
9042
  }).catch((reason) => {
9043
9043
  this._requestLogger.debug(`error ${reason} for POST ${postUrl}`);
9044
- }).finally(() => {
9045
- this._requestLogger.debug(`after POST ${postUrl}`);
9046
9044
  });
9047
9045
  }
9048
9046
  return Promise.resolve();
@@ -9059,20 +9057,18 @@ var UploadJob = class extends AbstractJob {
9059
9057
  ...session.authenticationHeaders(),
9060
9058
  Accept: "application/jsonl"
9061
9059
  };
9062
- this._requestLogger.debug(`before POST ${prepareUrl} to prepare full duplex upload`);
9063
9060
  response = await this._client.fetch(prepareUrl, {
9064
9061
  headers,
9065
9062
  method: "POST",
9066
9063
  signal: this._controller.signal,
9067
9064
  // @ts-ignore
9068
- duplex: "half"
9065
+ duplex: "half",
9066
+ eyepop: { responseStreaming: true }
9069
9067
  });
9070
- this._requestLogger.debug(`after POST ${prepareUrl} to prepare full duplex upload ${response.status} ${response.statusText}`);
9071
9068
  } else {
9072
9069
  const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
9073
9070
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync${videoModeQuery}`;
9074
9071
  if (this._params) {
9075
- this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
9076
9072
  const params = JSON.stringify(this._params);
9077
9073
  const paramBlob = new Blob([params], { type: "application/json" });
9078
9074
  const formData = new FormData();
@@ -9089,11 +9085,10 @@ var UploadJob = class extends AbstractJob {
9089
9085
  body: formData,
9090
9086
  signal: this._controller.signal,
9091
9087
  // @ts-ignore
9092
- duplex: "half"
9088
+ duplex: "half",
9089
+ eyepop: { responseStreaming: true }
9093
9090
  });
9094
- this._requestLogger.debug(`after POST ${postUrl} with multipart body because of params)`);
9095
9091
  } else {
9096
- this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
9097
9092
  const headers = {
9098
9093
  ...session.authenticationHeaders(),
9099
9094
  Accept: "application/jsonl",
@@ -9110,7 +9105,6 @@ var UploadJob = class extends AbstractJob {
9110
9105
  // @ts-ignore
9111
9106
  duplex: "half"
9112
9107
  });
9113
- this._requestLogger.debug(`after POST ${postUrl} with stream as body`);
9114
9108
  }
9115
9109
  }
9116
9110
  return response;
@@ -9140,15 +9134,14 @@ var LoadFromJob = class extends AbstractJob {
9140
9134
  "Content-Type": "application/json"
9141
9135
  };
9142
9136
  const patchUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync`;
9143
- this._requestLogger.debug("before PATCH %s with url %s as source", patchUrl, this._location);
9144
- const response = await this._client.fetch(patchUrl, {
9137
+ return await this._client.fetch(patchUrl, {
9145
9138
  headers,
9146
9139
  method: "PATCH",
9147
9140
  body: JSON.stringify(body),
9148
- signal: this._controller.signal
9141
+ signal: this._controller.signal,
9142
+ // @ts-ignore
9143
+ eyepop: { responseStreaming: true }
9149
9144
  });
9150
- this._requestLogger.debug("after PATCH %s with url %s as source", patchUrl, this._location);
9151
- return response;
9152
9145
  }
9153
9146
  };
9154
9147
  var LoadLiveIngressJob = class extends AbstractJob {
@@ -9175,15 +9168,14 @@ var LoadLiveIngressJob = class extends AbstractJob {
9175
9168
  "Content-Type": "application/json"
9176
9169
  };
9177
9170
  const patchUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=preempt&processing=sync`;
9178
- this._requestLogger.debug("before PATCH %s with url %s as source", patchUrl, this._ingressId);
9179
- const response = await this._client.fetch(patchUrl, {
9171
+ return await this._client.fetch(patchUrl, {
9180
9172
  headers,
9181
9173
  method: "PATCH",
9182
9174
  body: JSON.stringify(body),
9183
- signal: this._controller.signal
9175
+ signal: this._controller.signal,
9176
+ // @ts-ignore
9177
+ eyepop: { responseStreaming: true }
9184
9178
  });
9185
- this._requestLogger.debug("after PATCH %s with url %s as source", patchUrl, this._ingressId);
9186
- return response;
9187
9179
  }
9188
9180
  };
9189
9181
 
@@ -9241,7 +9233,6 @@ var WebrtcBase = class _WebrtcBase {
9241
9233
  await this._pc.setLocalDescription(offer);
9242
9234
  const session = await this._getSession();
9243
9235
  const ingressUrl = this.gresUrl(session);
9244
- this._requestLogger.debug(`before POST: ${ingressUrl}`);
9245
9236
  const headers = {
9246
9237
  ...session.authenticationHeaders(),
9247
9238
  "Content-Type": "application/sdp"
@@ -9251,7 +9242,6 @@ var WebrtcBase = class _WebrtcBase {
9251
9242
  method: "POST",
9252
9243
  body: offer.sdp
9253
9244
  });
9254
- this._requestLogger.debug(`after POST: ${ingressUrl} status: ${response.status}`);
9255
9245
  if (response.status != 201) {
9256
9246
  return Promise.reject(`unknown status code for POST '${ingressUrl}': ${response.status} (${response.statusText})`);
9257
9247
  }
@@ -9269,7 +9259,6 @@ var WebrtcBase = class _WebrtcBase {
9269
9259
  let urlPath = void 0;
9270
9260
  const session = await this._getSession();
9271
9261
  const ingressUrl = this.gresUrl(session, this._location);
9272
- this._requestLogger.debug("before PATCH: %s", ingressUrl);
9273
9262
  const headers = {
9274
9263
  ...session.authenticationHeaders(),
9275
9264
  "Content-Type": "application/trickle-ice-sdpfrag",
@@ -9451,7 +9440,6 @@ var WebrtcWhip = class extends WebrtcBase {
9451
9440
  async start() {
9452
9441
  const session = await this._getSession();
9453
9442
  const ingressUrl = this.gresUrl(session);
9454
- this._requestLogger.debug("before GET: %s", ingressUrl);
9455
9443
  const response = await this._client.fetch(ingressUrl, {
9456
9444
  headers: session.authenticationHeaders(),
9457
9445
  method: "GET"
@@ -9552,7 +9540,6 @@ var WebrtcWhep = class extends WebrtcBase {
9552
9540
  async start() {
9553
9541
  const session = await this._getSession();
9554
9542
  const egressUrl = this.gresUrl(session);
9555
- this._requestLogger.debug("before GET: %s", egressUrl);
9556
9543
  const response = await this._client.fetch(egressUrl, {
9557
9544
  headers: session.authenticationHeaders(),
9558
9545
  method: "GET"
@@ -9584,10 +9571,10 @@ var WebrtcWhep = class extends WebrtcBase {
9584
9571
  pc.addTransceiver("video", { direction });
9585
9572
  pc.onicecandidate = (evt) => this.onLocalCandidate(evt);
9586
9573
  this._pc = pc;
9587
- this._requestLogger.info("before", pc.iceConnectionState);
9574
+ this._requestLogger.info(`onIceServers ${pc.iceConnectionState}`);
9588
9575
  return new Promise(async (resolve, reject) => {
9589
9576
  pc.ontrack = (evt) => {
9590
- this._requestLogger.debug("new track:", evt.track.kind);
9577
+ this._requestLogger.debug(`new track: ${evt.track.kind}`);
9591
9578
  this._stream = evt.streams[0];
9592
9579
  resolve(this);
9593
9580
  };
@@ -9595,11 +9582,11 @@ var WebrtcWhep = class extends WebrtcBase {
9595
9582
  switch (pc.iceConnectionState) {
9596
9583
  case "failed":
9597
9584
  case "disconnected":
9598
- this._requestLogger.debug("disconnected");
9585
+ this._requestLogger.debug("oniceconnectionstatechange disconnected");
9599
9586
  reject(`peer connection: ${pc.iceConnectionState}`);
9600
9587
  break;
9601
9588
  case "connected":
9602
- this._requestLogger.debug("connected");
9589
+ this._requestLogger.debug("oniceconnectionstatechange connected");
9603
9590
  break;
9604
9591
  }
9605
9592
  };
@@ -9614,88 +9601,6 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9614
9601
  resolvePath = async (source, logger) => {
9615
9602
  throw new DOMException("resolving a path to a file is not supported in browser");
9616
9603
  };
9617
- } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9618
- let RNFAName = "react-native-file-access";
9619
- let RNFA;
9620
- let RNFALoadError;
9621
- try {
9622
- RNFA = __require(RNFAName);
9623
- } catch (e) {
9624
- RNFALoadError = e;
9625
- }
9626
- let EFSName = "expo-file-system";
9627
- let EFS;
9628
- let EFSLoadError;
9629
- try {
9630
- EFS = __require(EFSName);
9631
- } catch (e) {
9632
- EFSLoadError = e;
9633
- }
9634
- resolvePath = async (source, logger) => {
9635
- if (RNFA?.FileSystem?.readFileChunk !== void 0) {
9636
- logger.debug("Using react-native-file-access to read local file");
9637
- const bufferSize = 1024 * 1024;
9638
- let pos = 0;
9639
- const size = (await RNFA.FileSystem.stat(source.path)).size;
9640
- let eof = false;
9641
- const stream = new ReadableStream({
9642
- async pull(controller) {
9643
- if (eof) {
9644
- return;
9645
- }
9646
- const chunkSize = Math.min(bufferSize, size - pos);
9647
- const chunkAsB64 = await RNFA.FileSystem.readFileChunk(source.path, pos, chunkSize, "base64");
9648
- if (chunkAsB64.length > 0) {
9649
- const chunk = Buffer.from(chunkAsB64, "base64").subarray(0, chunkSize);
9650
- controller.enqueue(chunk);
9651
- pos += chunk.length;
9652
- } else {
9653
- eof = true;
9654
- controller.close();
9655
- }
9656
- }
9657
- });
9658
- return {
9659
- stream,
9660
- size,
9661
- mimeType: source.mimeType || "image/*"
9662
- };
9663
- }
9664
- if (EFS?.readAsStringAsync !== void 0) {
9665
- logger.debug("Using expo-file-system to read local file");
9666
- const bufferSize = 1024 * 1024;
9667
- const size = (await EFS.getInfoAsync(`file://${source.path}`)).size;
9668
- let pos = 0;
9669
- let eof = false;
9670
- const stream = new ReadableStream({
9671
- async pull(controller) {
9672
- if (eof) {
9673
- return;
9674
- }
9675
- const chunkSize = Math.min(bufferSize, size - pos);
9676
- const chunkAsB64 = await EFS.readAsStringAsync(`file://${source.path}`, {
9677
- length: chunkSize,
9678
- position: pos,
9679
- encoding: "base64"
9680
- });
9681
- if (chunkAsB64) {
9682
- const chunk = Buffer.from(chunkAsB64, "base64");
9683
- controller.enqueue(chunk);
9684
- pos += chunk.length;
9685
- } else {
9686
- eof = true;
9687
- controller.close();
9688
- }
9689
- }
9690
- });
9691
- return {
9692
- stream,
9693
- size,
9694
- mimeType: source.mimeType || "image/*"
9695
- };
9696
- }
9697
- 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()`);
9698
- };
9699
9604
  } else {
9700
9605
  let iteratorToStream = function(iterator) {
9701
9606
  return new ReadableStream({
@@ -9731,541 +9636,51 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9731
9636
  }
9732
9637
  var iteratorToStream2;
9733
9638
 
9734
- // shims/rn_http_header_parser.ts
9735
- var startLine = /^[A-Z_]+(\/\d\.\d)? /;
9736
- var requestLine = /^([A-Z_]+) (.+) [A-Z]+\/(\d)\.(\d)$/;
9737
- var statusLine = /^[A-Z]+\/(\d)\.(\d) (\d{3}) (.*)$/;
9738
- function parseHttpHeader(lines, onlyHeaders) {
9739
- var line = lines[0];
9740
- var match;
9741
- if (onlyHeaders && startLine.test(line)) {
9742
- return parseHeaders(lines);
9743
- } else if ((match = line.match(requestLine)) !== null) {
9744
- return {
9745
- method: match[1],
9746
- url: match[2],
9747
- version: { major: parseInt(match[3], 10), minor: parseInt(match[4], 10) },
9748
- headers: parseHeaders(lines)
9749
- };
9750
- } else if ((match = line.match(statusLine)) !== null) {
9751
- return {
9752
- version: { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) },
9753
- statusCode: parseInt(match[3], 10),
9754
- statusMessage: match[4],
9755
- headers: parseHeaders(lines)
9756
- };
9757
- } else {
9758
- return parseHeaders(lines);
9759
- }
9760
- }
9761
- function parseHeaders(lines) {
9762
- var headers = {};
9763
- var i = 0;
9764
- var line = lines[i];
9765
- var index, name, value;
9766
- if (startLine.test(line)) {
9767
- line = line[++i];
9768
- }
9769
- while (line) {
9770
- if (line[0] === " " || line[0] === " ") {
9771
- value += " " + line.trim();
9772
- i++;
9773
- if (i < lines.length) {
9774
- line = lines[i];
9775
- } else {
9776
- line = "";
9777
- }
9778
- continue;
9779
- }
9780
- if (name && value) {
9781
- addHeaderLine(name, value, headers);
9782
- }
9783
- index = line.indexOf(":");
9784
- name = line.substr(0, index);
9785
- value = line.substr(index + 1).trim();
9786
- i++;
9787
- if (i < lines.length) {
9788
- line = lines[i];
9789
- } else {
9790
- line = "";
9791
- }
9792
- }
9793
- if (name && value) {
9794
- addHeaderLine(name, value, headers);
9795
- }
9796
- return headers;
9797
- }
9798
- function addHeaderLine(field, value, dest) {
9799
- field = field.toLowerCase();
9800
- switch (field) {
9801
- // Array headers:
9802
- case "set-cookie":
9803
- if (dest[field] !== void 0) {
9804
- dest[field].push(value);
9805
- } else {
9806
- dest[field] = [value];
9807
- }
9808
- break;
9809
- // list is taken from:
9810
- // https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
9811
- case "content-type":
9812
- case "content-length":
9813
- case "user-agent":
9814
- case "referer":
9815
- case "host":
9816
- case "authorization":
9817
- case "proxy-authorization":
9818
- case "if-modified-since":
9819
- case "if-unmodified-since":
9820
- case "from":
9821
- case "location":
9822
- case "max-forwards":
9823
- case "retry-after":
9824
- case "etag":
9825
- case "last-modified":
9826
- case "server":
9827
- case "age":
9828
- case "expires":
9829
- if (dest[field] === void 0) dest[field] = value;
9830
- break;
9831
- default:
9832
- if (typeof dest[field] === "string") {
9833
- dest[field] += ", " + value;
9834
- } else {
9835
- dest[field] = value;
9836
- }
9837
- }
9838
- }
9839
-
9840
- // shims/rn_http_response_parser.ts
9841
- var ResponseParser = class {
9842
- constructor(logger, resolve, reject) {
9843
- this.responseChunkRemainder = 0;
9844
- this.logger = logger;
9845
- this.resolve = resolve;
9846
- this.reject = reject;
9847
- this.error = null;
9848
- this.responseReadBuffer = void 0;
9849
- this.responseState = 0 /* RECEIVING_HEADER */;
9850
- this.pullController = void 0;
9851
- this.pullResolve = void 0;
9852
- this.pullReject = void 0;
9853
- }
9854
- processResponseReadBuffer(data) {
9855
- if (this.error) {
9856
- this.logger.info(`RN http streamed response, received ${data.length} bytes in error mode`);
9857
- return false;
9858
- }
9859
- if (this.responseReadBuffer) {
9860
- this.responseReadBuffer = Buffer.concat([this.responseReadBuffer, data]);
9861
- } else {
9862
- this.responseReadBuffer = Buffer.from(data.subarray());
9863
- }
9864
- if (this.responseState === 3 /* RECEIVING_COMPLETED */) {
9865
- if (this.pullController) {
9866
- this.pullController.close();
9867
- if (this.pullResolve) {
9868
- this.pullResolve();
9869
- }
9870
- }
9871
- return false;
9872
- } else if (this.responseState === 0 /* RECEIVING_HEADER */) {
9873
- const headerEnd = this.responseReadBuffer.indexOf("\r\n\r\n");
9874
- if (headerEnd >= 0) {
9875
- let headerChunk = this.responseReadBuffer.subarray(0, headerEnd + 4);
9876
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(headerEnd + 4));
9877
- const maxHeaderLines = 128;
9878
- let responseHeaderLines = [];
9879
- const lineDecoder = new EyepopLineDecoder();
9880
- for (const line of lineDecoder.decode(headerChunk)) {
9881
- if (line.length > 0) {
9882
- responseHeaderLines.push(line);
9883
- if (responseHeaderLines.length > maxHeaderLines) {
9884
- this.error = `Response header exceeds ${maxHeaderLines} lines`;
9885
- this.reject(this.error);
9886
- return false;
9887
- }
9888
- }
9889
- }
9890
- let responseHeader = parseHttpHeader(responseHeaderLines, false);
9891
- if (responseHeader.statusCode === void 0) {
9892
- this.logger.warn(`Could not find status header in HTTP response ${JSON.stringify(responseHeader)}`);
9893
- this.reject("missing status header in HTTP response");
9894
- return false;
9895
- }
9896
- const headers = new Headers(responseHeader.headers);
9897
- if (headers.has("transfer-encoding")) {
9898
- if (headers.get("transfer-encoding")?.toLowerCase() === "chunked") {
9899
- this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
9900
- this.responseChunkRemainder = 0;
9901
- } else {
9902
- this.error = `Response with unsupported transfer-encoding '${headers.get("transfer-encoding")}'`;
9903
- this.reject(this.error);
9904
- return false;
9905
- }
9906
- } else if (headers.has("content-length")) {
9907
- this.responseState = 1 /* RECEIVING_BODY */;
9908
- this.responseChunkRemainder = parseInt(headers.get("content-length") || "-1");
9909
- } else {
9910
- this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
9911
- this.responseChunkRemainder = 0;
9912
- }
9913
- const responseBody = new ReadableStream({
9914
- pull: (controller) => {
9915
- if (this.error || this.responseState == 3 /* RECEIVING_COMPLETED */) {
9916
- return;
9917
- }
9918
- if (this.pull(controller)) {
9919
- return;
9920
- }
9921
- return new Promise((resolve, reject) => {
9922
- if (this.pullController) {
9923
- if (this.pullReject) {
9924
- this.pullReject("pull, we got a pending controller already");
9925
- }
9926
- }
9927
- this.pullController = controller;
9928
- this.pullResolve = resolve;
9929
- this.pullReject = reject;
9930
- });
9931
- },
9932
- cancel: (reason) => {
9933
- if (!this.error) {
9934
- this.error = `cancelled: ${reason}`;
9935
- this.reject(this.error);
9936
- }
9937
- }
9938
- });
9939
- this.resolve(new Response(responseBody, {
9940
- status: responseHeader.statusCode,
9941
- statusText: responseHeader.statusText,
9942
- headers
9943
- }));
9944
- }
9945
- } else if (this.pullController) {
9946
- if (this.pull(this.pullController)) {
9947
- this.pullController = void 0;
9948
- if (this.pullResolve) {
9949
- this.pullResolve();
9950
- }
9951
- this.pullResolve = void 0;
9952
- this.pullReject = void 0;
9953
- }
9954
- }
9955
- return true;
9956
- }
9957
- pull(controller) {
9958
- if (this.responseState == 3 /* RECEIVING_COMPLETED */) {
9959
- controller.close();
9960
- return false;
9961
- }
9962
- if (this.responseReadBuffer === void 0) {
9963
- return false;
9964
- }
9965
- if (this.responseState == 1 /* RECEIVING_BODY */) {
9966
- controller.enqueue(this.responseReadBuffer);
9967
- this.responseChunkRemainder -= this.responseReadBuffer.length;
9968
- this.responseReadBuffer = void 0;
9969
- if (this.responseChunkRemainder <= 0) {
9970
- this.responseState = 3 /* RECEIVING_COMPLETED */;
9971
- controller.close();
9972
- }
9973
- return true;
9974
- } else if (this.responseState == 2 /* RECEIVING_BODY_CHUNKED */) {
9975
- while (this.responseReadBuffer.length > 1) {
9976
- if (this.responseChunkRemainder == 0) {
9977
- let chunkHeaderEnd = 0;
9978
- while (this.responseReadBuffer.length >= 2 && chunkHeaderEnd == 0) {
9979
- chunkHeaderEnd = this.responseReadBuffer.indexOf("\r\n");
9980
- if (chunkHeaderEnd == 0) {
9981
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(2));
9982
- }
9983
- }
9984
- if (chunkHeaderEnd > 0) {
9985
- this.responseChunkRemainder = parseInt(Buffer.from(this.responseReadBuffer, 0, chunkHeaderEnd).toString("utf8"), 16);
9986
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(chunkHeaderEnd + 2));
9987
- if (this.responseChunkRemainder <= 0) {
9988
- this.responseState = 3 /* RECEIVING_COMPLETED */;
9989
- controller.close();
9990
- return true;
9991
- }
9992
- } else if (this.responseReadBuffer.length > 64) {
9993
- this.error = "Cannot find chunked encoding header within 64 bytes, given up";
9994
- controller.error(this.error);
9995
- }
9996
- }
9997
- if (this.responseChunkRemainder > 0 && this.responseReadBuffer.length > 0) {
9998
- const chunk = Buffer.from(this.responseReadBuffer.subarray(0, this.responseChunkRemainder));
9999
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(this.responseChunkRemainder));
10000
- controller.enqueue(chunk);
10001
- this.responseChunkRemainder -= chunk.length;
10002
- return true;
10003
- } else {
10004
- break;
10005
- }
10006
- }
10007
- } else {
10008
- this.error = `Received more data in wrong state ${this.responseState}`;
10009
- controller.error(this.error);
10010
- }
10011
- return false;
10012
- }
10013
- };
10014
-
10015
- // shims/rn_streaming_fetch.ts
10016
- async function reactNativeStreamingFetch(url, method, headers, body, contentLength, sockets, logger) {
10017
- const isHttps = url.protocol == "https:";
10018
- const port = url.port ? parseInt(url.port) : isHttps ? 443 : 80;
10019
- return new Promise((resolve, reject) => {
10020
- const connectOptions = {
10021
- port,
10022
- host: url.hostname,
10023
- reuseAddress: true
10024
- };
10025
- const clientSocket = new sockets.Socket();
10026
- const client = isHttps ? new sockets.TLSSocket(clientSocket) : clientSocket;
10027
- let error;
10028
- const responseParser = new ResponseParser(logger, resolve, (reason) => {
10029
- error = reason;
10030
- reject(error);
10031
- client.destroy();
10032
- });
10033
- client.on("data", function(data) {
10034
- responseParser.processResponseReadBuffer(data);
10035
- });
10036
- client.on("error", function(err) {
10037
- logger.info(`error: ${err}`);
10038
- if (!error) {
10039
- error = err;
10040
- reject(error);
10041
- }
10042
- client.destroy();
10043
- });
10044
- client.on("close", function() {
10045
- if (!error) {
10046
- error = "socket closed";
10047
- reject(error);
10048
- }
10049
- });
10050
- client.connect(connectOptions, async () => {
10051
- const headerLines = [
10052
- `${method} ${url.pathname}${url.search} HTTP/1.1\r
10053
- `,
10054
- `Host: ${url.host}\r
10055
- `
10056
- ];
10057
- headers.forEach((value, key) => {
10058
- headerLines.push(`${key}: ${value}\r
10059
- `);
10060
- });
10061
- headerLines.push("\r\n");
10062
- const textEncoder = new TextEncoder();
10063
- const headerChunk = headerLines.join("");
10064
- const bodyReader = body ? body.getReader() : void 0;
10065
- let headerEnqueued = false;
10066
- let eof = false;
10067
- const readableHeaderChunkedBody = new ReadableStream({
10068
- async pull(controller) {
10069
- if (!headerEnqueued) {
10070
- controller.enqueue(headerChunk);
10071
- headerEnqueued = true;
10072
- return;
10073
- }
10074
- if (eof) {
10075
- controller.close();
10076
- return;
10077
- }
10078
- if (!bodyReader) {
10079
- controller.close();
10080
- return;
10081
- }
10082
- const chunk = await bodyReader.read();
10083
- if (chunk.value) {
10084
- let outputChunk;
10085
- if (contentLength) {
10086
- outputChunk = chunk.value;
10087
- } else {
10088
- outputChunk = Buffer.concat([
10089
- textEncoder.encode(`${chunk.value.length.toString(16)}\r
10090
- `),
10091
- chunk.value,
10092
- textEncoder.encode(`\r
10093
- `)
10094
- ]);
10095
- }
10096
- controller.enqueue(outputChunk);
10097
- } else if (chunk.done) {
10098
- if (!contentLength) {
10099
- controller.enqueue(Buffer.from(`0\r
10100
- \r
10101
- `, "utf8"));
10102
- }
10103
- eof = true;
10104
- }
10105
- }
10106
- });
10107
- const readableHeaderChunkedBodyReader = readableHeaderChunkedBody.getReader();
10108
- const pipeChunk = async () => {
10109
- while (true) {
10110
- try {
10111
- const chunk = await readableHeaderChunkedBodyReader.read();
10112
- if (chunk.value) {
10113
- if (!client.write(chunk.value)) {
10114
- break;
10115
- }
10116
- } else if (chunk.done) {
10117
- break;
10118
- }
10119
- } catch (e) {
10120
- logger.error(e);
10121
- break;
10122
- }
10123
- }
10124
- };
10125
- client.on("drain", pipeChunk);
10126
- await pipeChunk();
10127
- });
10128
- });
10129
- }
10130
-
10131
9639
  // shims/http_client.ts
10132
9640
  var createHttpClient;
9641
+ function logLineFromRequest(input, init) {
9642
+ const url = input instanceof Request ? input.url : input;
9643
+ const method = input instanceof Request ? input.method : init?.method || (init?.body !== void 0 ? "POST" : "GET");
9644
+ return `${method} ${url}`;
9645
+ }
10133
9646
  if ("document" in globalThis && "implementation" in globalThis.document) {
10134
9647
  class BrowserHttpClient {
10135
- constructor() {
10136
- }
10137
- async fetch(input, init) {
10138
- return await fetch(input, init);
10139
- }
10140
- async close() {
10141
- }
10142
- isFullDuplex() {
10143
- return false;
10144
- }
10145
- }
10146
- createHttpClient = async (logger) => {
10147
- logger.debug("Using browser fetch as http client");
10148
- return new BrowserHttpClient();
10149
- };
10150
- } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
10151
- let RNName = "react-native";
10152
- let RN;
10153
- let TcpSocketsName = "react-native-tcp-socket";
10154
- let TcpSockets;
10155
- let TcpSocketsError;
10156
- try {
10157
- RN = __require(RNName);
10158
- TcpSockets = __require(TcpSocketsName);
10159
- if (TcpSockets?.TLSSocket) {
10160
- if (!RN?.NativeModules?.TcpSockets) {
10161
- TcpSockets = void 0;
10162
- 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`);
10163
- }
10164
- }
10165
- } catch (e) {
10166
- TcpSocketsError = e;
10167
- }
10168
- class ReactNativeHttpClient {
10169
9648
  constructor(logger) {
10170
- this.logger = logger;
9649
+ this._logger = logger;
10171
9650
  }
10172
9651
  async fetch(input, init) {
10173
- init || (init = {});
10174
- let streamBody;
10175
- if (input instanceof Request) {
10176
- if (input.body instanceof ReadableStream) {
10177
- streamBody = input.body;
10178
- }
10179
- } else if (init?.body instanceof ReadableStream) {
10180
- streamBody = init.body;
10181
- } else if (typeof init?.body === "string") {
10182
- streamBody = new ReadableStream({
10183
- start: (controller) => {
10184
- controller.enqueue(Buffer.from(init?.body, "utf8"));
10185
- controller.close();
10186
- }
10187
- });
10188
- }
10189
- if (streamBody) {
10190
- if (TcpSockets?.TLSSocket !== void 0) {
10191
- let url;
10192
- let method;
10193
- let headers;
10194
- if (input instanceof Request) {
10195
- url = new URL(input.url);
10196
- method = input.method;
10197
- headers = input.headers;
10198
- } else {
10199
- if (input instanceof URL) {
10200
- url = input;
10201
- } else {
10202
- url = new URL(input);
10203
- }
10204
- method = init?.method || "POST";
10205
- headers = new Headers(init?.headers);
10206
- }
10207
- let contentLength = void 0;
10208
- if (headers.has("content-length")) {
10209
- contentLength = parseInt(headers.get("content-length") || "");
10210
- } else {
10211
- headers.append("Transfer-Encoding", "chunked");
10212
- }
10213
- return await reactNativeStreamingFetch(
10214
- url,
10215
- method,
10216
- headers,
10217
- streamBody,
10218
- contentLength,
10219
- TcpSockets,
10220
- this.logger
10221
- );
10222
- } else {
10223
- 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.`);
10224
- try {
10225
- const chunks = [];
10226
- const reader = streamBody.getReader();
10227
- while (true) {
10228
- const { done, value } = await reader.read();
10229
- if (done) {
10230
- break;
10231
- }
10232
- chunks.push(value);
10233
- }
10234
- if (input instanceof Request) {
10235
- input = new Request(input, { body: Buffer.concat(chunks) });
10236
- } else {
10237
- init.body = Buffer.concat(chunks);
10238
- }
10239
- } catch (e) {
10240
- return Promise.reject(e);
10241
- }
10242
- }
10243
- }
10244
- init.reactNative = { textStreaming: true };
10245
- return await fetch(input, init);
9652
+ const logLine = logLineFromRequest(input, init);
9653
+ this._logger.debug(`Browser fetch() BEFORE ${logLine}`);
9654
+ const response = await fetch(input, init);
9655
+ this._logger.debug(`AFTER ${logLine} -> ${response.status}`);
9656
+ return response;
10246
9657
  }
10247
9658
  async close() {
10248
9659
  }
10249
9660
  isFullDuplex() {
10250
- return true;
9661
+ return false;
10251
9662
  }
10252
9663
  }
10253
9664
  createHttpClient = async (logger) => {
10254
- 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.");
10255
- return new ReactNativeHttpClient(logger);
9665
+ return new BrowserHttpClient(logger);
10256
9666
  };
10257
9667
  } else {
10258
9668
  class NodeHttpClient {
10259
- constructor(agent) {
10260
- this.agent = agent;
9669
+ constructor(agent, logger) {
9670
+ this._agent = agent;
9671
+ this._logger = logger;
10261
9672
  }
10262
9673
  async fetch(input, init) {
10263
9674
  init || (init = {});
10264
- init.dispatcher = this.agent;
10265
- return await fetch(input, init);
9675
+ init.dispatcher = this._agent;
9676
+ const logLine = logLineFromRequest(input, init);
9677
+ this._logger.debug(`Node fetch() BEFORE ${logLine}`);
9678
+ const response = await fetch(input, init);
9679
+ this._logger.debug(`AFTER ${logLine} -> ${response.status}`);
9680
+ return response;
10266
9681
  }
10267
9682
  async close() {
10268
- return this.agent.close();
9683
+ return this._agent.close();
10269
9684
  }
10270
9685
  isFullDuplex() {
10271
9686
  return false;
@@ -10280,7 +9695,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
10280
9695
  pipelining: 0
10281
9696
  });
10282
9697
  logger.debug("Using node fetch with undici agent as http client");
10283
- return new NodeHttpClient(agent);
9698
+ return new NodeHttpClient(agent, logger);
10284
9699
  };
10285
9700
  }
10286
9701
 
@@ -10551,7 +9966,11 @@ var Endpoint = class {
10551
9966
  } else {
10552
9967
  return Promise.reject("option secretKey or environment variable EYEPOP_SECRET_KEY is required");
10553
9968
  }
10554
- this._client = await createHttpClient(this._logger);
9969
+ if (this._options.platformSupport?.createHttpClient !== void 0) {
9970
+ this._client = await this._options.platformSupport.createHttpClient(this._requestLogger);
9971
+ } else {
9972
+ this._client = await createHttpClient(this._requestLogger);
9973
+ }
10555
9974
  return await this.reconnect();
10556
9975
  }
10557
9976
  async disconnect(wait = true) {
@@ -10645,7 +10064,6 @@ var Endpoint = class {
10645
10064
  const body = { secret_key: secretKeyAuth.secretKey };
10646
10065
  const headers = { "Content-Type": "application/json" };
10647
10066
  const post_url = `${this.eyepopUrl()}/authentication/token`;
10648
- this._requestLogger.debug("before POST %s", post_url);
10649
10067
  const response = await this._client.fetch(post_url, {
10650
10068
  method: "POST",
10651
10069
  headers,
@@ -10655,7 +10073,6 @@ var Endpoint = class {
10655
10073
  const message = await response.text();
10656
10074
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10657
10075
  }
10658
- this._requestLogger.debug("after POST %s", post_url);
10659
10076
  const data = await response.json();
10660
10077
  const token = data;
10661
10078
  this._token = token.access_token;
@@ -10708,12 +10125,10 @@ var WorkerEndpoint = class extends Endpoint {
10708
10125
  const headers = {
10709
10126
  Authorization: await this.authorizationHeader()
10710
10127
  };
10711
- this._requestLogger.debug("before DELETE %s", deleteUrl);
10712
10128
  let response = await this._client?.fetch(deleteUrl, {
10713
10129
  method: "DELETE",
10714
10130
  headers
10715
10131
  });
10716
- this._requestLogger.debug("after DELETE %s", deleteUrl);
10717
10132
  if (response?.status != 204) {
10718
10133
  const message = await response?.text();
10719
10134
  this._logger.info(`stoppping pipeline failed, status ${response?.status}: ${message}`);
@@ -10724,12 +10139,10 @@ var WorkerEndpoint = class extends Endpoint {
10724
10139
  const headers = {
10725
10140
  Authorization: await this.authorizationHeader()
10726
10141
  };
10727
- this._requestLogger.debug("before DELETE %s", sandboxUrl);
10728
10142
  let response = await this._client?.fetch(sandboxUrl, {
10729
10143
  method: "DELETE",
10730
10144
  headers
10731
10145
  });
10732
- this._requestLogger.debug("after DELETE %s", sandboxUrl);
10733
10146
  if (response?.status != 204) {
10734
10147
  const message = await response?.text();
10735
10148
  this._logger.info(`disconnecting sandbox failed, status ${response?.status}: ${message}`);
@@ -10775,7 +10188,7 @@ var WorkerEndpoint = class extends Endpoint {
10775
10188
  const client = this._client;
10776
10189
  const baseUrl = this._baseUrl;
10777
10190
  if (!baseUrl || !client) {
10778
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10191
+ return Promise.reject("endpoint not connected, use connect()");
10779
10192
  }
10780
10193
  let response = await this.fetchWithRetry(async () => {
10781
10194
  const session = await this.session();
@@ -10784,7 +10197,6 @@ var WorkerEndpoint = class extends Endpoint {
10784
10197
  ...this._authenticationHeaders(session)
10785
10198
  };
10786
10199
  const patch_url = `${session.baseUrl}/pipelines/${session.pipelineId}/pop`;
10787
- this._requestLogger.debug("before PATCH %s - %s", patch_url, JSON.stringify(pop));
10788
10200
  return await client.fetch(patch_url, {
10789
10201
  method: "PATCH",
10790
10202
  body: JSON.stringify(pop),
@@ -10795,7 +10207,6 @@ var WorkerEndpoint = class extends Endpoint {
10795
10207
  const message = await response.text();
10796
10208
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10797
10209
  }
10798
- this._requestLogger.debug("after PATCH pop");
10799
10210
  if (this._pipeline) {
10800
10211
  this._pipeline.pop = pop;
10801
10212
  }
@@ -10820,7 +10231,7 @@ var WorkerEndpoint = class extends Endpoint {
10820
10231
  const client = this._client;
10821
10232
  const baseUrl = this._baseUrl;
10822
10233
  if (!baseUrl || !client) {
10823
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10234
+ return Promise.reject("endpoint not connected, use connect()");
10824
10235
  }
10825
10236
  const body = {
10826
10237
  pipeline: popComp,
@@ -10865,7 +10276,7 @@ var WorkerEndpoint = class extends Endpoint {
10865
10276
  const client = this._client;
10866
10277
  const baseUrl = this._baseUrl;
10867
10278
  if (!baseUrl || !client) {
10868
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10279
+ return Promise.reject("endpoint not connected, use connect()");
10869
10280
  }
10870
10281
  const body = {
10871
10282
  transform: postTransform
@@ -10904,7 +10315,7 @@ var WorkerEndpoint = class extends Endpoint {
10904
10315
  }
10905
10316
  async liveIngress(stream) {
10906
10317
  if (!this._baseUrl || !this._client) {
10907
- return Promise.reject("endpoint not connected, use connect() before ingress()");
10318
+ return Promise.reject("endpoint not connected, use connect()");
10908
10319
  }
10909
10320
  const whip = new WebrtcWhip(
10910
10321
  stream,
@@ -10918,7 +10329,7 @@ var WorkerEndpoint = class extends Endpoint {
10918
10329
  }
10919
10330
  async liveEgress(ingressId) {
10920
10331
  if (!this._baseUrl || !this._client) {
10921
- return Promise.reject("endpoint not connected, use connect() before ingress()");
10332
+ return Promise.reject("endpoint not connected, use connect()");
10922
10333
  }
10923
10334
  const whep = new WebrtcWhep(
10924
10335
  ingressId,
@@ -10978,7 +10389,7 @@ var WorkerEndpoint = class extends Endpoint {
10978
10389
  }
10979
10390
  async uploadFile(source, params) {
10980
10391
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10981
- return Promise.reject("endpoint not connected, use connect() before upload()");
10392
+ return Promise.reject("endpoint not connected, use connect()");
10982
10393
  }
10983
10394
  await this._limit.acquire();
10984
10395
  try {
@@ -11010,7 +10421,7 @@ var WorkerEndpoint = class extends Endpoint {
11010
10421
  }
11011
10422
  async uploadStream(source, params) {
11012
10423
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11013
- return Promise.reject("endpoint not connected, use connect() before upload()");
10424
+ return Promise.reject("endpoint not connected, use connect()");
11014
10425
  }
11015
10426
  await this._limit.acquire();
11016
10427
  try {
@@ -11042,12 +10453,17 @@ var WorkerEndpoint = class extends Endpoint {
11042
10453
  }
11043
10454
  async uploadPath(source, params) {
11044
10455
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11045
- throw new Error("endpoint not connected, use connect() before process()");
10456
+ throw new Error("endpoint not connected, use connect()");
11046
10457
  }
11047
10458
  await this._limit.acquire();
11048
10459
  try {
11049
10460
  this.updateState();
11050
- const streamSource = await resolvePath(source, this._logger);
10461
+ let streamSource;
10462
+ if (this._options.platformSupport?.resolvePath) {
10463
+ streamSource = await this._options.platformSupport.resolvePath(source, this._logger);
10464
+ } else {
10465
+ streamSource = await resolvePath(source, this._logger);
10466
+ }
11051
10467
  const job = new UploadJob(
11052
10468
  streamSource.stream,
11053
10469
  streamSource.mimeType,
@@ -11080,7 +10496,7 @@ var WorkerEndpoint = class extends Endpoint {
11080
10496
  }, params);
11081
10497
  }
11082
10498
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11083
- throw new Error("endpoint not connected, use connect() before loadFrom()");
10499
+ throw new Error("endpoint not connected, use connect()");
11084
10500
  }
11085
10501
  await this._limit.acquire();
11086
10502
  try {
@@ -11109,7 +10525,7 @@ var WorkerEndpoint = class extends Endpoint {
11109
10525
  }
11110
10526
  async loadLiveIngress(source, params) {
11111
10527
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11112
- throw new Error("endpoint not connected, use connect() before loadLiveIngress()");
10528
+ throw new Error("endpoint not connected, use connect()");
11113
10529
  }
11114
10530
  await this._limit.acquire();
11115
10531
  try {
@@ -11161,10 +10577,9 @@ var WorkerEndpoint = class extends Endpoint {
11161
10577
  Authorization: await this.authorizationHeader()
11162
10578
  };
11163
10579
  this.updateState("FetchConfig" /* FetchConfig */);
11164
- this._requestLogger.debug("before GET %s", config_url);
11165
10580
  let response = await this._client.fetch(config_url, { headers });
11166
10581
  if (response.status == 401) {
11167
- this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", config_url);
10582
+ this._requestLogger.debug("GET %s: 401, about to retry with fresh access token", config_url);
11168
10583
  this.statusHandler401(response.status);
11169
10584
  const headers2 = {
11170
10585
  Authorization: await this.authorizationHeader()
@@ -11184,7 +10599,6 @@ var WorkerEndpoint = class extends Endpoint {
11184
10599
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11185
10600
  }
11186
10601
  let config = await response.json();
11187
- this._requestLogger.debug("after GET %s", config_url);
11188
10602
  if (!config.base_url && this.options().autoStart) {
11189
10603
  const auto_start_config_url = `${this.eyepopUrl()}/pops/${this.options().popId}/config?auto_start=true`;
11190
10604
  this._requestLogger.debug("pop was not running, trying to autostart with: %s", auto_start_config_url);
@@ -11210,7 +10624,6 @@ var WorkerEndpoint = class extends Endpoint {
11210
10624
  Authorization: await this.authorizationHeader()
11211
10625
  };
11212
10626
  const createSandboxUrl = `${this._baseUrl}/sandboxes`;
11213
- this._requestLogger.debug("before POST %s", createSandboxUrl);
11214
10627
  const response3 = await this._client.fetch(createSandboxUrl, {
11215
10628
  method: "POST",
11216
10629
  headers: headers3
@@ -11220,7 +10633,6 @@ var WorkerEndpoint = class extends Endpoint {
11220
10633
  return Promise.reject(`Unexpected status ${response3.status}: ${message}`);
11221
10634
  }
11222
10635
  const responseJson = await response3.json();
11223
- this._requestLogger.debug("after POST %s", createSandboxUrl);
11224
10636
  if (responseJson) {
11225
10637
  this._sandboxId = responseJson;
11226
10638
  }
@@ -11240,7 +10652,6 @@ var WorkerEndpoint = class extends Endpoint {
11240
10652
  const headers2 = {
11241
10653
  Authorization: await this.authorizationHeader()
11242
10654
  };
11243
- this._requestLogger.debug("before GET %s", get_url);
11244
10655
  let response2 = await this._client.fetch(get_url, {
11245
10656
  method: "GET",
11246
10657
  headers: headers2
@@ -11249,7 +10660,6 @@ var WorkerEndpoint = class extends Endpoint {
11249
10660
  const message = await response2.text();
11250
10661
  return Promise.reject(`Unexpected status ${response2.status}: ${message}`);
11251
10662
  }
11252
- this._requestLogger.debug("after GET %s", get_url);
11253
10663
  this._pipeline = await response2.json();
11254
10664
  if (this.options().stopJobs) {
11255
10665
  const body = { sourceType: "NONE" };
@@ -11310,7 +10720,6 @@ var WorkerEndpoint = class extends Endpoint {
11310
10720
  "Content-Type": "application/json",
11311
10721
  Authorization: await this.authorizationHeader()
11312
10722
  };
11313
- this._requestLogger.debug("before POST %s", post_url);
11314
10723
  return client.fetch(post_url, {
11315
10724
  method: "POST",
11316
10725
  body: JSON.stringify(body),
@@ -11322,7 +10731,6 @@ var WorkerEndpoint = class extends Endpoint {
11322
10731
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11323
10732
  }
11324
10733
  const result = await response.json();
11325
- this._requestLogger.debug("after POST %s", post_url);
11326
10734
  return result["id"];
11327
10735
  }
11328
10736
  async manifest() {
@@ -11330,7 +10738,7 @@ var WorkerEndpoint = class extends Endpoint {
11330
10738
  const client = this._client;
11331
10739
  const baseUrl = this._baseUrl;
11332
10740
  if (!baseUrl || !client) {
11333
- return Promise.reject("endpoint not connected, use connect() before getManifest()");
10741
+ return Promise.reject("endpoint not connected, use connect()");
11334
10742
  }
11335
10743
  let get_path;
11336
10744
  if (this._sandboxId === null) {
@@ -11344,23 +10752,20 @@ var WorkerEndpoint = class extends Endpoint {
11344
10752
  ...this._authenticationHeaders(session),
11345
10753
  "Content-Type": "application/json"
11346
10754
  };
11347
- this._requestLogger.debug("before GET %s", get_path);
11348
10755
  return client.fetch(get_path, { headers });
11349
10756
  });
11350
10757
  if (!response.ok) {
11351
10758
  const message = await response.text();
11352
10759
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11353
10760
  }
11354
- const result = await response.json();
11355
- this._requestLogger.debug("after GET %s", get_path);
11356
- return result;
10761
+ return await response.json();
11357
10762
  }
11358
10763
  async models() {
11359
10764
  this._logger.warn("listModels for development use only");
11360
10765
  const client = this._client;
11361
10766
  const baseUrl = this._baseUrl;
11362
10767
  if (!baseUrl || !client) {
11363
- return Promise.reject("endpoint not connected, use connect() before listModels()");
10768
+ return Promise.reject("endpoint not connected, use connect()");
11364
10769
  }
11365
10770
  let get_path;
11366
10771
  if (this._sandboxId === null) {
@@ -11374,7 +10779,6 @@ var WorkerEndpoint = class extends Endpoint {
11374
10779
  ...this._authenticationHeaders(session),
11375
10780
  "Content-Type": "application/json"
11376
10781
  };
11377
- this._requestLogger.debug("before GET %s", get_path);
11378
10782
  return client.fetch(get_path, { headers });
11379
10783
  });
11380
10784
  if (!response.ok) {
@@ -11382,7 +10786,6 @@ var WorkerEndpoint = class extends Endpoint {
11382
10786
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11383
10787
  }
11384
10788
  const result = await response.json();
11385
- this._requestLogger.debug("after GET %s", get_path);
11386
10789
  return result;
11387
10790
  }
11388
10791
  async changeManifest(manifests) {
@@ -11390,7 +10793,7 @@ var WorkerEndpoint = class extends Endpoint {
11390
10793
  const client = this._client;
11391
10794
  const baseUrl = this._baseUrl;
11392
10795
  if (!baseUrl || !client) {
11393
- return Promise.reject("endpoint not connected, use connect() before setManifest()");
10796
+ return Promise.reject("endpoint not connected, use connect()");
11394
10797
  }
11395
10798
  let put_url;
11396
10799
  if (this._sandboxId === null) {
@@ -11404,7 +10807,6 @@ var WorkerEndpoint = class extends Endpoint {
11404
10807
  ...this._authenticationHeaders(session),
11405
10808
  "Content-Type": "application/json"
11406
10809
  };
11407
- this._requestLogger.debug("before PUT %s", put_url);
11408
10810
  return client.fetch(put_url, {
11409
10811
  method: "PUT",
11410
10812
  body: JSON.stringify(manifests),
@@ -11415,14 +10817,13 @@ var WorkerEndpoint = class extends Endpoint {
11415
10817
  const message = await response.text();
11416
10818
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11417
10819
  }
11418
- this._requestLogger.debug("after PUT %s", put_url);
11419
10820
  }
11420
10821
  async loadModel(model) {
11421
10822
  this._logger.warn("loadModel for development use only");
11422
10823
  const client = this._client;
11423
10824
  const baseUrl = this._baseUrl;
11424
10825
  if (!baseUrl || !client) {
11425
- return Promise.reject("endpoint not connected, use connect() before loadModel()");
10826
+ return Promise.reject("endpoint not connected, use connect()");
11426
10827
  }
11427
10828
  let post_url;
11428
10829
  if (this._sandboxId === null) {
@@ -11436,7 +10837,6 @@ var WorkerEndpoint = class extends Endpoint {
11436
10837
  ...this._authenticationHeaders(session),
11437
10838
  "Content-Type": "application/json"
11438
10839
  };
11439
- this._requestLogger.debug("before POST %s", post_url);
11440
10840
  return client.fetch(post_url, {
11441
10841
  method: "POST",
11442
10842
  body: JSON.stringify(model),
@@ -11447,16 +10847,14 @@ var WorkerEndpoint = class extends Endpoint {
11447
10847
  const message = await response.text();
11448
10848
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11449
10849
  }
11450
- const result = await response.json();
11451
- this._requestLogger.debug("after POST %s", post_url);
11452
- return result;
10850
+ return await response.json();
11453
10851
  }
11454
10852
  async unloadModel(modelId) {
11455
10853
  this._logger.warn("purgeModel for development use only");
11456
10854
  const client = this._client;
11457
10855
  const baseUrl = this._baseUrl;
11458
10856
  if (!baseUrl || !client) {
11459
- return Promise.reject("endpoint not connected, use connect() before unloadModel()");
10857
+ return Promise.reject("endpoint not connected, use connect()");
11460
10858
  }
11461
10859
  let delete_url;
11462
10860
  if (this._sandboxId === null) {
@@ -11470,14 +10868,12 @@ var WorkerEndpoint = class extends Endpoint {
11470
10868
  ...this._authenticationHeaders(session),
11471
10869
  "Content-Type": "application/json"
11472
10870
  };
11473
- this._requestLogger.debug("before DELETE %s", delete_url);
11474
10871
  return client.fetch(delete_url, { method: "DELETE", headers });
11475
10872
  });
11476
10873
  if (!response.ok) {
11477
10874
  const message = await response.text();
11478
10875
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11479
10876
  }
11480
- this._requestLogger.debug("after DELETE %s", delete_url);
11481
10877
  }
11482
10878
  };
11483
10879
 
@@ -11695,10 +11091,9 @@ var DataEndpoint = class extends Endpoint {
11695
11091
  Authorization: await this.authorizationHeader()
11696
11092
  };
11697
11093
  this.updateState("FetchConfig" /* FetchConfig */);
11698
- this._requestLogger.debug("before GET %s", config_url);
11699
11094
  let response = await this._client.fetch(config_url, { headers });
11700
11095
  if (response.status == 401) {
11701
- this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", config_url);
11096
+ this._requestLogger.debug("GET %s: 401, about to retry with fresh access token", config_url);
11702
11097
  this.statusHandler401(response.status);
11703
11098
  headers = {
11704
11099
  Authorization: await this.authorizationHeader()
@@ -11714,7 +11109,6 @@ var DataEndpoint = class extends Endpoint {
11714
11109
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11715
11110
  }
11716
11111
  let config = await response.json();
11717
- this._requestLogger.debug("after GET %s", config_url);
11718
11112
  const baseUrl = new URL(config.base_url, this.eyepopUrl());
11719
11113
  this._baseUrl = baseUrl.toString();
11720
11114
  if (this.options().disableWs) {