@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.
@@ -9062,7 +9062,6 @@ var UploadJob = class extends AbstractJob {
9062
9062
  const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
9063
9063
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=async&sourceId=${event.source_id}${videoModeQuery}`;
9064
9064
  if (this._params) {
9065
- this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
9066
9065
  const params = JSON.stringify(this._params);
9067
9066
  const paramBlob = new Blob([params], { type: "application/json" });
9068
9067
  const formData = new FormData();
@@ -9079,10 +9078,10 @@ var UploadJob = class extends AbstractJob {
9079
9078
  body: formData,
9080
9079
  signal: this._controller.signal,
9081
9080
  // @ts-ignore
9082
- duplex: "half"
9081
+ duplex: "half",
9082
+ eyepop: { responseStreaming: true }
9083
9083
  });
9084
9084
  } else {
9085
- this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
9086
9085
  const headers = {
9087
9086
  ...session.authenticationHeaders(),
9088
9087
  Accept: "application/jsonl",
@@ -9097,7 +9096,8 @@ var UploadJob = class extends AbstractJob {
9097
9096
  body: this._uploadStream,
9098
9097
  signal: this._controller.signal,
9099
9098
  // @ts-ignore
9100
- duplex: "half"
9099
+ duplex: "half",
9100
+ eyepop: { responseStreaming: true }
9101
9101
  });
9102
9102
  }
9103
9103
  request.then(async (value) => {
@@ -9106,8 +9106,6 @@ var UploadJob = class extends AbstractJob {
9106
9106
  }
9107
9107
  }).catch((reason) => {
9108
9108
  this._requestLogger.debug(`error ${reason} for POST ${postUrl}`);
9109
- }).finally(() => {
9110
- this._requestLogger.debug(`after POST ${postUrl}`);
9111
9109
  });
9112
9110
  }
9113
9111
  return Promise.resolve();
@@ -9124,20 +9122,18 @@ var UploadJob = class extends AbstractJob {
9124
9122
  ...session.authenticationHeaders(),
9125
9123
  Accept: "application/jsonl"
9126
9124
  };
9127
- this._requestLogger.debug(`before POST ${prepareUrl} to prepare full duplex upload`);
9128
9125
  response = await this._client.fetch(prepareUrl, {
9129
9126
  headers,
9130
9127
  method: "POST",
9131
9128
  signal: this._controller.signal,
9132
9129
  // @ts-ignore
9133
- duplex: "half"
9130
+ duplex: "half",
9131
+ eyepop: { responseStreaming: true }
9134
9132
  });
9135
- this._requestLogger.debug(`after POST ${prepareUrl} to prepare full duplex upload ${response.status} ${response.statusText}`);
9136
9133
  } else {
9137
9134
  const videoModeQuery = this._videoMode ? `&videoMode=${this._videoMode}` : "";
9138
9135
  const postUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync${videoModeQuery}`;
9139
9136
  if (this._params) {
9140
- this._requestLogger.debug(`before POST ${postUrl} with multipart body because of params`);
9141
9137
  const params = JSON.stringify(this._params);
9142
9138
  const paramBlob = new Blob([params], { type: "application/json" });
9143
9139
  const formData = new FormData();
@@ -9154,11 +9150,10 @@ var UploadJob = class extends AbstractJob {
9154
9150
  body: formData,
9155
9151
  signal: this._controller.signal,
9156
9152
  // @ts-ignore
9157
- duplex: "half"
9153
+ duplex: "half",
9154
+ eyepop: { responseStreaming: true }
9158
9155
  });
9159
- this._requestLogger.debug(`after POST ${postUrl} with multipart body because of params)`);
9160
9156
  } else {
9161
- this._requestLogger.debug(`before POST ${postUrl} with stream as body`);
9162
9157
  const headers = {
9163
9158
  ...session.authenticationHeaders(),
9164
9159
  Accept: "application/jsonl",
@@ -9175,7 +9170,6 @@ var UploadJob = class extends AbstractJob {
9175
9170
  // @ts-ignore
9176
9171
  duplex: "half"
9177
9172
  });
9178
- this._requestLogger.debug(`after POST ${postUrl} with stream as body`);
9179
9173
  }
9180
9174
  }
9181
9175
  return response;
@@ -9205,15 +9199,14 @@ var LoadFromJob = class extends AbstractJob {
9205
9199
  "Content-Type": "application/json"
9206
9200
  };
9207
9201
  const patchUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=queue&processing=sync`;
9208
- this._requestLogger.debug("before PATCH %s with url %s as source", patchUrl, this._location);
9209
- const response = await this._client.fetch(patchUrl, {
9202
+ return await this._client.fetch(patchUrl, {
9210
9203
  headers,
9211
9204
  method: "PATCH",
9212
9205
  body: JSON.stringify(body),
9213
- signal: this._controller.signal
9206
+ signal: this._controller.signal,
9207
+ // @ts-ignore
9208
+ eyepop: { responseStreaming: true }
9214
9209
  });
9215
- this._requestLogger.debug("after PATCH %s with url %s as source", patchUrl, this._location);
9216
- return response;
9217
9210
  }
9218
9211
  };
9219
9212
  var LoadLiveIngressJob = class extends AbstractJob {
@@ -9240,15 +9233,14 @@ var LoadLiveIngressJob = class extends AbstractJob {
9240
9233
  "Content-Type": "application/json"
9241
9234
  };
9242
9235
  const patchUrl = `${session.baseUrl.replace(/\/+$/, "")}/pipelines/${session.pipelineId}/source?mode=preempt&processing=sync`;
9243
- this._requestLogger.debug("before PATCH %s with url %s as source", patchUrl, this._ingressId);
9244
- const response = await this._client.fetch(patchUrl, {
9236
+ return await this._client.fetch(patchUrl, {
9245
9237
  headers,
9246
9238
  method: "PATCH",
9247
9239
  body: JSON.stringify(body),
9248
- signal: this._controller.signal
9240
+ signal: this._controller.signal,
9241
+ // @ts-ignore
9242
+ eyepop: { responseStreaming: true }
9249
9243
  });
9250
- this._requestLogger.debug("after PATCH %s with url %s as source", patchUrl, this._ingressId);
9251
- return response;
9252
9244
  }
9253
9245
  };
9254
9246
 
@@ -9306,7 +9298,6 @@ var WebrtcBase = class _WebrtcBase {
9306
9298
  await this._pc.setLocalDescription(offer);
9307
9299
  const session = await this._getSession();
9308
9300
  const ingressUrl = this.gresUrl(session);
9309
- this._requestLogger.debug(`before POST: ${ingressUrl}`);
9310
9301
  const headers = {
9311
9302
  ...session.authenticationHeaders(),
9312
9303
  "Content-Type": "application/sdp"
@@ -9316,7 +9307,6 @@ var WebrtcBase = class _WebrtcBase {
9316
9307
  method: "POST",
9317
9308
  body: offer.sdp
9318
9309
  });
9319
- this._requestLogger.debug(`after POST: ${ingressUrl} status: ${response.status}`);
9320
9310
  if (response.status != 201) {
9321
9311
  return Promise.reject(`unknown status code for POST '${ingressUrl}': ${response.status} (${response.statusText})`);
9322
9312
  }
@@ -9334,7 +9324,6 @@ var WebrtcBase = class _WebrtcBase {
9334
9324
  let urlPath = void 0;
9335
9325
  const session = await this._getSession();
9336
9326
  const ingressUrl = this.gresUrl(session, this._location);
9337
- this._requestLogger.debug("before PATCH: %s", ingressUrl);
9338
9327
  const headers = {
9339
9328
  ...session.authenticationHeaders(),
9340
9329
  "Content-Type": "application/trickle-ice-sdpfrag",
@@ -9516,7 +9505,6 @@ var WebrtcWhip = class extends WebrtcBase {
9516
9505
  async start() {
9517
9506
  const session = await this._getSession();
9518
9507
  const ingressUrl = this.gresUrl(session);
9519
- this._requestLogger.debug("before GET: %s", ingressUrl);
9520
9508
  const response = await this._client.fetch(ingressUrl, {
9521
9509
  headers: session.authenticationHeaders(),
9522
9510
  method: "GET"
@@ -9617,7 +9605,6 @@ var WebrtcWhep = class extends WebrtcBase {
9617
9605
  async start() {
9618
9606
  const session = await this._getSession();
9619
9607
  const egressUrl = this.gresUrl(session);
9620
- this._requestLogger.debug("before GET: %s", egressUrl);
9621
9608
  const response = await this._client.fetch(egressUrl, {
9622
9609
  headers: session.authenticationHeaders(),
9623
9610
  method: "GET"
@@ -9649,10 +9636,10 @@ var WebrtcWhep = class extends WebrtcBase {
9649
9636
  pc.addTransceiver("video", { direction });
9650
9637
  pc.onicecandidate = (evt) => this.onLocalCandidate(evt);
9651
9638
  this._pc = pc;
9652
- this._requestLogger.info("before", pc.iceConnectionState);
9639
+ this._requestLogger.info(`onIceServers ${pc.iceConnectionState}`);
9653
9640
  return new Promise(async (resolve, reject) => {
9654
9641
  pc.ontrack = (evt) => {
9655
- this._requestLogger.debug("new track:", evt.track.kind);
9642
+ this._requestLogger.debug(`new track: ${evt.track.kind}`);
9656
9643
  this._stream = evt.streams[0];
9657
9644
  resolve(this);
9658
9645
  };
@@ -9660,11 +9647,11 @@ var WebrtcWhep = class extends WebrtcBase {
9660
9647
  switch (pc.iceConnectionState) {
9661
9648
  case "failed":
9662
9649
  case "disconnected":
9663
- this._requestLogger.debug("disconnected");
9650
+ this._requestLogger.debug("oniceconnectionstatechange disconnected");
9664
9651
  reject(`peer connection: ${pc.iceConnectionState}`);
9665
9652
  break;
9666
9653
  case "connected":
9667
- this._requestLogger.debug("connected");
9654
+ this._requestLogger.debug("oniceconnectionstatechange connected");
9668
9655
  break;
9669
9656
  }
9670
9657
  };
@@ -9679,88 +9666,6 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9679
9666
  resolvePath = async (source, logger) => {
9680
9667
  throw new DOMException("resolving a path to a file is not supported in browser");
9681
9668
  };
9682
- } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
9683
- let RNFAName = "react-native-file-access";
9684
- let RNFA;
9685
- let RNFALoadError;
9686
- try {
9687
- RNFA = require(RNFAName);
9688
- } catch (e) {
9689
- RNFALoadError = e;
9690
- }
9691
- let EFSName = "expo-file-system";
9692
- let EFS;
9693
- let EFSLoadError;
9694
- try {
9695
- EFS = require(EFSName);
9696
- } catch (e) {
9697
- EFSLoadError = e;
9698
- }
9699
- resolvePath = async (source, logger) => {
9700
- if (RNFA?.FileSystem?.readFileChunk !== void 0) {
9701
- logger.debug("Using react-native-file-access to read local file");
9702
- const bufferSize = 1024 * 1024;
9703
- let pos = 0;
9704
- const size = (await RNFA.FileSystem.stat(source.path)).size;
9705
- let eof = false;
9706
- const stream = new ReadableStream({
9707
- async pull(controller) {
9708
- if (eof) {
9709
- return;
9710
- }
9711
- const chunkSize = Math.min(bufferSize, size - pos);
9712
- const chunkAsB64 = await RNFA.FileSystem.readFileChunk(source.path, pos, chunkSize, "base64");
9713
- if (chunkAsB64.length > 0) {
9714
- const chunk = Buffer.from(chunkAsB64, "base64").subarray(0, chunkSize);
9715
- controller.enqueue(chunk);
9716
- pos += chunk.length;
9717
- } else {
9718
- eof = true;
9719
- controller.close();
9720
- }
9721
- }
9722
- });
9723
- return {
9724
- stream,
9725
- size,
9726
- mimeType: source.mimeType || "image/*"
9727
- };
9728
- }
9729
- if (EFS?.readAsStringAsync !== void 0) {
9730
- logger.debug("Using expo-file-system to read local file");
9731
- const bufferSize = 1024 * 1024;
9732
- const size = (await EFS.getInfoAsync(`file://${source.path}`)).size;
9733
- let pos = 0;
9734
- let eof = false;
9735
- const stream = new ReadableStream({
9736
- async pull(controller) {
9737
- if (eof) {
9738
- return;
9739
- }
9740
- const chunkSize = Math.min(bufferSize, size - pos);
9741
- const chunkAsB64 = await EFS.readAsStringAsync(`file://${source.path}`, {
9742
- length: chunkSize,
9743
- position: pos,
9744
- encoding: "base64"
9745
- });
9746
- if (chunkAsB64) {
9747
- const chunk = Buffer.from(chunkAsB64, "base64");
9748
- controller.enqueue(chunk);
9749
- pos += chunk.length;
9750
- } else {
9751
- eof = true;
9752
- controller.close();
9753
- }
9754
- }
9755
- });
9756
- return {
9757
- stream,
9758
- size,
9759
- mimeType: source.mimeType || "image/*"
9760
- };
9761
- }
9762
- 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()`);
9763
- };
9764
9669
  } else {
9765
9670
  let iteratorToStream = function(iterator) {
9766
9671
  return new ReadableStream({
@@ -9796,541 +9701,51 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9796
9701
  }
9797
9702
  var iteratorToStream2;
9798
9703
 
9799
- // shims/rn_http_header_parser.ts
9800
- var startLine = /^[A-Z_]+(\/\d\.\d)? /;
9801
- var requestLine = /^([A-Z_]+) (.+) [A-Z]+\/(\d)\.(\d)$/;
9802
- var statusLine = /^[A-Z]+\/(\d)\.(\d) (\d{3}) (.*)$/;
9803
- function parseHttpHeader(lines, onlyHeaders) {
9804
- var line = lines[0];
9805
- var match;
9806
- if (onlyHeaders && startLine.test(line)) {
9807
- return parseHeaders(lines);
9808
- } else if ((match = line.match(requestLine)) !== null) {
9809
- return {
9810
- method: match[1],
9811
- url: match[2],
9812
- version: { major: parseInt(match[3], 10), minor: parseInt(match[4], 10) },
9813
- headers: parseHeaders(lines)
9814
- };
9815
- } else if ((match = line.match(statusLine)) !== null) {
9816
- return {
9817
- version: { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) },
9818
- statusCode: parseInt(match[3], 10),
9819
- statusMessage: match[4],
9820
- headers: parseHeaders(lines)
9821
- };
9822
- } else {
9823
- return parseHeaders(lines);
9824
- }
9825
- }
9826
- function parseHeaders(lines) {
9827
- var headers = {};
9828
- var i = 0;
9829
- var line = lines[i];
9830
- var index, name, value;
9831
- if (startLine.test(line)) {
9832
- line = line[++i];
9833
- }
9834
- while (line) {
9835
- if (line[0] === " " || line[0] === " ") {
9836
- value += " " + line.trim();
9837
- i++;
9838
- if (i < lines.length) {
9839
- line = lines[i];
9840
- } else {
9841
- line = "";
9842
- }
9843
- continue;
9844
- }
9845
- if (name && value) {
9846
- addHeaderLine(name, value, headers);
9847
- }
9848
- index = line.indexOf(":");
9849
- name = line.substr(0, index);
9850
- value = line.substr(index + 1).trim();
9851
- i++;
9852
- if (i < lines.length) {
9853
- line = lines[i];
9854
- } else {
9855
- line = "";
9856
- }
9857
- }
9858
- if (name && value) {
9859
- addHeaderLine(name, value, headers);
9860
- }
9861
- return headers;
9862
- }
9863
- function addHeaderLine(field, value, dest) {
9864
- field = field.toLowerCase();
9865
- switch (field) {
9866
- // Array headers:
9867
- case "set-cookie":
9868
- if (dest[field] !== void 0) {
9869
- dest[field].push(value);
9870
- } else {
9871
- dest[field] = [value];
9872
- }
9873
- break;
9874
- // list is taken from:
9875
- // https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
9876
- case "content-type":
9877
- case "content-length":
9878
- case "user-agent":
9879
- case "referer":
9880
- case "host":
9881
- case "authorization":
9882
- case "proxy-authorization":
9883
- case "if-modified-since":
9884
- case "if-unmodified-since":
9885
- case "from":
9886
- case "location":
9887
- case "max-forwards":
9888
- case "retry-after":
9889
- case "etag":
9890
- case "last-modified":
9891
- case "server":
9892
- case "age":
9893
- case "expires":
9894
- if (dest[field] === void 0) dest[field] = value;
9895
- break;
9896
- default:
9897
- if (typeof dest[field] === "string") {
9898
- dest[field] += ", " + value;
9899
- } else {
9900
- dest[field] = value;
9901
- }
9902
- }
9903
- }
9904
-
9905
- // shims/rn_http_response_parser.ts
9906
- var ResponseParser = class {
9907
- constructor(logger, resolve, reject) {
9908
- this.responseChunkRemainder = 0;
9909
- this.logger = logger;
9910
- this.resolve = resolve;
9911
- this.reject = reject;
9912
- this.error = null;
9913
- this.responseReadBuffer = void 0;
9914
- this.responseState = 0 /* RECEIVING_HEADER */;
9915
- this.pullController = void 0;
9916
- this.pullResolve = void 0;
9917
- this.pullReject = void 0;
9918
- }
9919
- processResponseReadBuffer(data) {
9920
- if (this.error) {
9921
- this.logger.info(`RN http streamed response, received ${data.length} bytes in error mode`);
9922
- return false;
9923
- }
9924
- if (this.responseReadBuffer) {
9925
- this.responseReadBuffer = Buffer.concat([this.responseReadBuffer, data]);
9926
- } else {
9927
- this.responseReadBuffer = Buffer.from(data.subarray());
9928
- }
9929
- if (this.responseState === 3 /* RECEIVING_COMPLETED */) {
9930
- if (this.pullController) {
9931
- this.pullController.close();
9932
- if (this.pullResolve) {
9933
- this.pullResolve();
9934
- }
9935
- }
9936
- return false;
9937
- } else if (this.responseState === 0 /* RECEIVING_HEADER */) {
9938
- const headerEnd = this.responseReadBuffer.indexOf("\r\n\r\n");
9939
- if (headerEnd >= 0) {
9940
- let headerChunk = this.responseReadBuffer.subarray(0, headerEnd + 4);
9941
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(headerEnd + 4));
9942
- const maxHeaderLines = 128;
9943
- let responseHeaderLines = [];
9944
- const lineDecoder = new EyepopLineDecoder();
9945
- for (const line of lineDecoder.decode(headerChunk)) {
9946
- if (line.length > 0) {
9947
- responseHeaderLines.push(line);
9948
- if (responseHeaderLines.length > maxHeaderLines) {
9949
- this.error = `Response header exceeds ${maxHeaderLines} lines`;
9950
- this.reject(this.error);
9951
- return false;
9952
- }
9953
- }
9954
- }
9955
- let responseHeader = parseHttpHeader(responseHeaderLines, false);
9956
- if (responseHeader.statusCode === void 0) {
9957
- this.logger.warn(`Could not find status header in HTTP response ${JSON.stringify(responseHeader)}`);
9958
- this.reject("missing status header in HTTP response");
9959
- return false;
9960
- }
9961
- const headers = new Headers(responseHeader.headers);
9962
- if (headers.has("transfer-encoding")) {
9963
- if (headers.get("transfer-encoding")?.toLowerCase() === "chunked") {
9964
- this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
9965
- this.responseChunkRemainder = 0;
9966
- } else {
9967
- this.error = `Response with unsupported transfer-encoding '${headers.get("transfer-encoding")}'`;
9968
- this.reject(this.error);
9969
- return false;
9970
- }
9971
- } else if (headers.has("content-length")) {
9972
- this.responseState = 1 /* RECEIVING_BODY */;
9973
- this.responseChunkRemainder = parseInt(headers.get("content-length") || "-1");
9974
- } else {
9975
- this.responseState = 2 /* RECEIVING_BODY_CHUNKED */;
9976
- this.responseChunkRemainder = 0;
9977
- }
9978
- const responseBody = new ReadableStream({
9979
- pull: (controller) => {
9980
- if (this.error || this.responseState == 3 /* RECEIVING_COMPLETED */) {
9981
- return;
9982
- }
9983
- if (this.pull(controller)) {
9984
- return;
9985
- }
9986
- return new Promise((resolve, reject) => {
9987
- if (this.pullController) {
9988
- if (this.pullReject) {
9989
- this.pullReject("pull, we got a pending controller already");
9990
- }
9991
- }
9992
- this.pullController = controller;
9993
- this.pullResolve = resolve;
9994
- this.pullReject = reject;
9995
- });
9996
- },
9997
- cancel: (reason) => {
9998
- if (!this.error) {
9999
- this.error = `cancelled: ${reason}`;
10000
- this.reject(this.error);
10001
- }
10002
- }
10003
- });
10004
- this.resolve(new Response(responseBody, {
10005
- status: responseHeader.statusCode,
10006
- statusText: responseHeader.statusText,
10007
- headers
10008
- }));
10009
- }
10010
- } else if (this.pullController) {
10011
- if (this.pull(this.pullController)) {
10012
- this.pullController = void 0;
10013
- if (this.pullResolve) {
10014
- this.pullResolve();
10015
- }
10016
- this.pullResolve = void 0;
10017
- this.pullReject = void 0;
10018
- }
10019
- }
10020
- return true;
10021
- }
10022
- pull(controller) {
10023
- if (this.responseState == 3 /* RECEIVING_COMPLETED */) {
10024
- controller.close();
10025
- return false;
10026
- }
10027
- if (this.responseReadBuffer === void 0) {
10028
- return false;
10029
- }
10030
- if (this.responseState == 1 /* RECEIVING_BODY */) {
10031
- controller.enqueue(this.responseReadBuffer);
10032
- this.responseChunkRemainder -= this.responseReadBuffer.length;
10033
- this.responseReadBuffer = void 0;
10034
- if (this.responseChunkRemainder <= 0) {
10035
- this.responseState = 3 /* RECEIVING_COMPLETED */;
10036
- controller.close();
10037
- }
10038
- return true;
10039
- } else if (this.responseState == 2 /* RECEIVING_BODY_CHUNKED */) {
10040
- while (this.responseReadBuffer.length > 1) {
10041
- if (this.responseChunkRemainder == 0) {
10042
- let chunkHeaderEnd = 0;
10043
- while (this.responseReadBuffer.length >= 2 && chunkHeaderEnd == 0) {
10044
- chunkHeaderEnd = this.responseReadBuffer.indexOf("\r\n");
10045
- if (chunkHeaderEnd == 0) {
10046
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(2));
10047
- }
10048
- }
10049
- if (chunkHeaderEnd > 0) {
10050
- this.responseChunkRemainder = parseInt(Buffer.from(this.responseReadBuffer, 0, chunkHeaderEnd).toString("utf8"), 16);
10051
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(chunkHeaderEnd + 2));
10052
- if (this.responseChunkRemainder <= 0) {
10053
- this.responseState = 3 /* RECEIVING_COMPLETED */;
10054
- controller.close();
10055
- return true;
10056
- }
10057
- } else if (this.responseReadBuffer.length > 64) {
10058
- this.error = "Cannot find chunked encoding header within 64 bytes, given up";
10059
- controller.error(this.error);
10060
- }
10061
- }
10062
- if (this.responseChunkRemainder > 0 && this.responseReadBuffer.length > 0) {
10063
- const chunk = Buffer.from(this.responseReadBuffer.subarray(0, this.responseChunkRemainder));
10064
- this.responseReadBuffer = Buffer.from(this.responseReadBuffer.subarray(this.responseChunkRemainder));
10065
- controller.enqueue(chunk);
10066
- this.responseChunkRemainder -= chunk.length;
10067
- return true;
10068
- } else {
10069
- break;
10070
- }
10071
- }
10072
- } else {
10073
- this.error = `Received more data in wrong state ${this.responseState}`;
10074
- controller.error(this.error);
10075
- }
10076
- return false;
10077
- }
10078
- };
10079
-
10080
- // shims/rn_streaming_fetch.ts
10081
- async function reactNativeStreamingFetch(url, method, headers, body, contentLength, sockets, logger) {
10082
- const isHttps = url.protocol == "https:";
10083
- const port = url.port ? parseInt(url.port) : isHttps ? 443 : 80;
10084
- return new Promise((resolve, reject) => {
10085
- const connectOptions = {
10086
- port,
10087
- host: url.hostname,
10088
- reuseAddress: true
10089
- };
10090
- const clientSocket = new sockets.Socket();
10091
- const client = isHttps ? new sockets.TLSSocket(clientSocket) : clientSocket;
10092
- let error;
10093
- const responseParser = new ResponseParser(logger, resolve, (reason) => {
10094
- error = reason;
10095
- reject(error);
10096
- client.destroy();
10097
- });
10098
- client.on("data", function(data) {
10099
- responseParser.processResponseReadBuffer(data);
10100
- });
10101
- client.on("error", function(err) {
10102
- logger.info(`error: ${err}`);
10103
- if (!error) {
10104
- error = err;
10105
- reject(error);
10106
- }
10107
- client.destroy();
10108
- });
10109
- client.on("close", function() {
10110
- if (!error) {
10111
- error = "socket closed";
10112
- reject(error);
10113
- }
10114
- });
10115
- client.connect(connectOptions, async () => {
10116
- const headerLines = [
10117
- `${method} ${url.pathname}${url.search} HTTP/1.1\r
10118
- `,
10119
- `Host: ${url.host}\r
10120
- `
10121
- ];
10122
- headers.forEach((value, key) => {
10123
- headerLines.push(`${key}: ${value}\r
10124
- `);
10125
- });
10126
- headerLines.push("\r\n");
10127
- const textEncoder = new TextEncoder();
10128
- const headerChunk = headerLines.join("");
10129
- const bodyReader = body ? body.getReader() : void 0;
10130
- let headerEnqueued = false;
10131
- let eof = false;
10132
- const readableHeaderChunkedBody = new ReadableStream({
10133
- async pull(controller) {
10134
- if (!headerEnqueued) {
10135
- controller.enqueue(headerChunk);
10136
- headerEnqueued = true;
10137
- return;
10138
- }
10139
- if (eof) {
10140
- controller.close();
10141
- return;
10142
- }
10143
- if (!bodyReader) {
10144
- controller.close();
10145
- return;
10146
- }
10147
- const chunk = await bodyReader.read();
10148
- if (chunk.value) {
10149
- let outputChunk;
10150
- if (contentLength) {
10151
- outputChunk = chunk.value;
10152
- } else {
10153
- outputChunk = Buffer.concat([
10154
- textEncoder.encode(`${chunk.value.length.toString(16)}\r
10155
- `),
10156
- chunk.value,
10157
- textEncoder.encode(`\r
10158
- `)
10159
- ]);
10160
- }
10161
- controller.enqueue(outputChunk);
10162
- } else if (chunk.done) {
10163
- if (!contentLength) {
10164
- controller.enqueue(Buffer.from(`0\r
10165
- \r
10166
- `, "utf8"));
10167
- }
10168
- eof = true;
10169
- }
10170
- }
10171
- });
10172
- const readableHeaderChunkedBodyReader = readableHeaderChunkedBody.getReader();
10173
- const pipeChunk = async () => {
10174
- while (true) {
10175
- try {
10176
- const chunk = await readableHeaderChunkedBodyReader.read();
10177
- if (chunk.value) {
10178
- if (!client.write(chunk.value)) {
10179
- break;
10180
- }
10181
- } else if (chunk.done) {
10182
- break;
10183
- }
10184
- } catch (e) {
10185
- logger.error(e);
10186
- break;
10187
- }
10188
- }
10189
- };
10190
- client.on("drain", pipeChunk);
10191
- await pipeChunk();
10192
- });
10193
- });
10194
- }
10195
-
10196
9704
  // shims/http_client.ts
10197
9705
  var createHttpClient;
9706
+ function logLineFromRequest(input, init) {
9707
+ const url = input instanceof Request ? input.url : input;
9708
+ const method = input instanceof Request ? input.method : init?.method || (init?.body !== void 0 ? "POST" : "GET");
9709
+ return `${method} ${url}`;
9710
+ }
10198
9711
  if ("document" in globalThis && "implementation" in globalThis.document) {
10199
9712
  class BrowserHttpClient {
10200
- constructor() {
10201
- }
10202
- async fetch(input, init) {
10203
- return await fetch(input, init);
10204
- }
10205
- async close() {
10206
- }
10207
- isFullDuplex() {
10208
- return false;
10209
- }
10210
- }
10211
- createHttpClient = async (logger) => {
10212
- logger.debug("Using browser fetch as http client");
10213
- return new BrowserHttpClient();
10214
- };
10215
- } else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
10216
- let RNName = "react-native";
10217
- let RN;
10218
- let TcpSocketsName = "react-native-tcp-socket";
10219
- let TcpSockets;
10220
- let TcpSocketsError;
10221
- try {
10222
- RN = require(RNName);
10223
- TcpSockets = require(TcpSocketsName);
10224
- if (TcpSockets?.TLSSocket) {
10225
- if (!RN?.NativeModules?.TcpSockets) {
10226
- TcpSockets = void 0;
10227
- 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`);
10228
- }
10229
- }
10230
- } catch (e) {
10231
- TcpSocketsError = e;
10232
- }
10233
- class ReactNativeHttpClient {
10234
9713
  constructor(logger) {
10235
- this.logger = logger;
9714
+ this._logger = logger;
10236
9715
  }
10237
9716
  async fetch(input, init) {
10238
- init || (init = {});
10239
- let streamBody;
10240
- if (input instanceof Request) {
10241
- if (input.body instanceof ReadableStream) {
10242
- streamBody = input.body;
10243
- }
10244
- } else if (init?.body instanceof ReadableStream) {
10245
- streamBody = init.body;
10246
- } else if (typeof init?.body === "string") {
10247
- streamBody = new ReadableStream({
10248
- start: (controller) => {
10249
- controller.enqueue(Buffer.from(init?.body, "utf8"));
10250
- controller.close();
10251
- }
10252
- });
10253
- }
10254
- if (streamBody) {
10255
- if (TcpSockets?.TLSSocket !== void 0) {
10256
- let url;
10257
- let method;
10258
- let headers;
10259
- if (input instanceof Request) {
10260
- url = new URL(input.url);
10261
- method = input.method;
10262
- headers = input.headers;
10263
- } else {
10264
- if (input instanceof URL) {
10265
- url = input;
10266
- } else {
10267
- url = new URL(input);
10268
- }
10269
- method = init?.method || "POST";
10270
- headers = new Headers(init?.headers);
10271
- }
10272
- let contentLength = void 0;
10273
- if (headers.has("content-length")) {
10274
- contentLength = parseInt(headers.get("content-length") || "");
10275
- } else {
10276
- headers.append("Transfer-Encoding", "chunked");
10277
- }
10278
- return await reactNativeStreamingFetch(
10279
- url,
10280
- method,
10281
- headers,
10282
- streamBody,
10283
- contentLength,
10284
- TcpSockets,
10285
- this.logger
10286
- );
10287
- } else {
10288
- 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.`);
10289
- try {
10290
- const chunks = [];
10291
- const reader = streamBody.getReader();
10292
- while (true) {
10293
- const { done, value } = await reader.read();
10294
- if (done) {
10295
- break;
10296
- }
10297
- chunks.push(value);
10298
- }
10299
- if (input instanceof Request) {
10300
- input = new Request(input, { body: Buffer.concat(chunks) });
10301
- } else {
10302
- init.body = Buffer.concat(chunks);
10303
- }
10304
- } catch (e) {
10305
- return Promise.reject(e);
10306
- }
10307
- }
10308
- }
10309
- init.reactNative = { textStreaming: true };
10310
- return await fetch(input, init);
9717
+ const logLine = logLineFromRequest(input, init);
9718
+ this._logger.debug(`Browser fetch() BEFORE ${logLine}`);
9719
+ const response = await fetch(input, init);
9720
+ this._logger.debug(`AFTER ${logLine} -> ${response.status}`);
9721
+ return response;
10311
9722
  }
10312
9723
  async close() {
10313
9724
  }
10314
9725
  isFullDuplex() {
10315
- return true;
9726
+ return false;
10316
9727
  }
10317
9728
  }
10318
9729
  createHttpClient = async (logger) => {
10319
- 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.");
10320
- return new ReactNativeHttpClient(logger);
9730
+ return new BrowserHttpClient(logger);
10321
9731
  };
10322
9732
  } else {
10323
9733
  class NodeHttpClient {
10324
- constructor(agent) {
10325
- this.agent = agent;
9734
+ constructor(agent, logger) {
9735
+ this._agent = agent;
9736
+ this._logger = logger;
10326
9737
  }
10327
9738
  async fetch(input, init) {
10328
9739
  init || (init = {});
10329
- init.dispatcher = this.agent;
10330
- return await fetch(input, init);
9740
+ init.dispatcher = this._agent;
9741
+ const logLine = logLineFromRequest(input, init);
9742
+ this._logger.debug(`Node fetch() BEFORE ${logLine}`);
9743
+ const response = await fetch(input, init);
9744
+ this._logger.debug(`AFTER ${logLine} -> ${response.status}`);
9745
+ return response;
10331
9746
  }
10332
9747
  async close() {
10333
- return this.agent.close();
9748
+ return this._agent.close();
10334
9749
  }
10335
9750
  isFullDuplex() {
10336
9751
  return false;
@@ -10345,7 +9760,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
10345
9760
  pipelining: 0
10346
9761
  });
10347
9762
  logger.debug("Using node fetch with undici agent as http client");
10348
- return new NodeHttpClient(agent);
9763
+ return new NodeHttpClient(agent, logger);
10349
9764
  };
10350
9765
  }
10351
9766
 
@@ -10616,7 +10031,11 @@ var Endpoint = class {
10616
10031
  } else {
10617
10032
  return Promise.reject("option secretKey or environment variable EYEPOP_SECRET_KEY is required");
10618
10033
  }
10619
- this._client = await createHttpClient(this._logger);
10034
+ if (this._options.platformSupport?.createHttpClient !== void 0) {
10035
+ this._client = await this._options.platformSupport.createHttpClient(this._requestLogger);
10036
+ } else {
10037
+ this._client = await createHttpClient(this._requestLogger);
10038
+ }
10620
10039
  return await this.reconnect();
10621
10040
  }
10622
10041
  async disconnect(wait = true) {
@@ -10710,7 +10129,6 @@ var Endpoint = class {
10710
10129
  const body = { secret_key: secretKeyAuth.secretKey };
10711
10130
  const headers = { "Content-Type": "application/json" };
10712
10131
  const post_url = `${this.eyepopUrl()}/authentication/token`;
10713
- this._requestLogger.debug("before POST %s", post_url);
10714
10132
  const response = await this._client.fetch(post_url, {
10715
10133
  method: "POST",
10716
10134
  headers,
@@ -10720,7 +10138,6 @@ var Endpoint = class {
10720
10138
  const message = await response.text();
10721
10139
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10722
10140
  }
10723
- this._requestLogger.debug("after POST %s", post_url);
10724
10141
  const data = await response.json();
10725
10142
  const token = data;
10726
10143
  this._token = token.access_token;
@@ -10773,12 +10190,10 @@ var WorkerEndpoint = class extends Endpoint {
10773
10190
  const headers = {
10774
10191
  Authorization: await this.authorizationHeader()
10775
10192
  };
10776
- this._requestLogger.debug("before DELETE %s", deleteUrl);
10777
10193
  let response = await this._client?.fetch(deleteUrl, {
10778
10194
  method: "DELETE",
10779
10195
  headers
10780
10196
  });
10781
- this._requestLogger.debug("after DELETE %s", deleteUrl);
10782
10197
  if (response?.status != 204) {
10783
10198
  const message = await response?.text();
10784
10199
  this._logger.info(`stoppping pipeline failed, status ${response?.status}: ${message}`);
@@ -10789,12 +10204,10 @@ var WorkerEndpoint = class extends Endpoint {
10789
10204
  const headers = {
10790
10205
  Authorization: await this.authorizationHeader()
10791
10206
  };
10792
- this._requestLogger.debug("before DELETE %s", sandboxUrl);
10793
10207
  let response = await this._client?.fetch(sandboxUrl, {
10794
10208
  method: "DELETE",
10795
10209
  headers
10796
10210
  });
10797
- this._requestLogger.debug("after DELETE %s", sandboxUrl);
10798
10211
  if (response?.status != 204) {
10799
10212
  const message = await response?.text();
10800
10213
  this._logger.info(`disconnecting sandbox failed, status ${response?.status}: ${message}`);
@@ -10840,7 +10253,7 @@ var WorkerEndpoint = class extends Endpoint {
10840
10253
  const client = this._client;
10841
10254
  const baseUrl = this._baseUrl;
10842
10255
  if (!baseUrl || !client) {
10843
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10256
+ return Promise.reject("endpoint not connected, use connect()");
10844
10257
  }
10845
10258
  let response = await this.fetchWithRetry(async () => {
10846
10259
  const session = await this.session();
@@ -10849,7 +10262,6 @@ var WorkerEndpoint = class extends Endpoint {
10849
10262
  ...this._authenticationHeaders(session)
10850
10263
  };
10851
10264
  const patch_url = `${session.baseUrl}/pipelines/${session.pipelineId}/pop`;
10852
- this._requestLogger.debug("before PATCH %s - %s", patch_url, JSON.stringify(pop));
10853
10265
  return await client.fetch(patch_url, {
10854
10266
  method: "PATCH",
10855
10267
  body: JSON.stringify(pop),
@@ -10860,7 +10272,6 @@ var WorkerEndpoint = class extends Endpoint {
10860
10272
  const message = await response.text();
10861
10273
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10862
10274
  }
10863
- this._requestLogger.debug("after PATCH pop");
10864
10275
  if (this._pipeline) {
10865
10276
  this._pipeline.pop = pop;
10866
10277
  }
@@ -10885,7 +10296,7 @@ var WorkerEndpoint = class extends Endpoint {
10885
10296
  const client = this._client;
10886
10297
  const baseUrl = this._baseUrl;
10887
10298
  if (!baseUrl || !client) {
10888
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10299
+ return Promise.reject("endpoint not connected, use connect()");
10889
10300
  }
10890
10301
  const body = {
10891
10302
  pipeline: popComp,
@@ -10930,7 +10341,7 @@ var WorkerEndpoint = class extends Endpoint {
10930
10341
  const client = this._client;
10931
10342
  const baseUrl = this._baseUrl;
10932
10343
  if (!baseUrl || !client) {
10933
- return Promise.reject("endpoint not connected, use connect() before changePopComp()");
10344
+ return Promise.reject("endpoint not connected, use connect()");
10934
10345
  }
10935
10346
  const body = {
10936
10347
  transform: postTransform
@@ -10969,7 +10380,7 @@ var WorkerEndpoint = class extends Endpoint {
10969
10380
  }
10970
10381
  async liveIngress(stream) {
10971
10382
  if (!this._baseUrl || !this._client) {
10972
- return Promise.reject("endpoint not connected, use connect() before ingress()");
10383
+ return Promise.reject("endpoint not connected, use connect()");
10973
10384
  }
10974
10385
  const whip = new WebrtcWhip(
10975
10386
  stream,
@@ -10983,7 +10394,7 @@ var WorkerEndpoint = class extends Endpoint {
10983
10394
  }
10984
10395
  async liveEgress(ingressId) {
10985
10396
  if (!this._baseUrl || !this._client) {
10986
- return Promise.reject("endpoint not connected, use connect() before ingress()");
10397
+ return Promise.reject("endpoint not connected, use connect()");
10987
10398
  }
10988
10399
  const whep = new WebrtcWhep(
10989
10400
  ingressId,
@@ -11043,7 +10454,7 @@ var WorkerEndpoint = class extends Endpoint {
11043
10454
  }
11044
10455
  async uploadFile(source, params) {
11045
10456
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11046
- return Promise.reject("endpoint not connected, use connect() before upload()");
10457
+ return Promise.reject("endpoint not connected, use connect()");
11047
10458
  }
11048
10459
  await this._limit.acquire();
11049
10460
  try {
@@ -11075,7 +10486,7 @@ var WorkerEndpoint = class extends Endpoint {
11075
10486
  }
11076
10487
  async uploadStream(source, params) {
11077
10488
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11078
- return Promise.reject("endpoint not connected, use connect() before upload()");
10489
+ return Promise.reject("endpoint not connected, use connect()");
11079
10490
  }
11080
10491
  await this._limit.acquire();
11081
10492
  try {
@@ -11107,12 +10518,17 @@ var WorkerEndpoint = class extends Endpoint {
11107
10518
  }
11108
10519
  async uploadPath(source, params) {
11109
10520
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11110
- throw new Error("endpoint not connected, use connect() before process()");
10521
+ throw new Error("endpoint not connected, use connect()");
11111
10522
  }
11112
10523
  await this._limit.acquire();
11113
10524
  try {
11114
10525
  this.updateState();
11115
- const streamSource = await resolvePath(source, this._logger);
10526
+ let streamSource;
10527
+ if (this._options.platformSupport?.resolvePath) {
10528
+ streamSource = await this._options.platformSupport.resolvePath(source, this._logger);
10529
+ } else {
10530
+ streamSource = await resolvePath(source, this._logger);
10531
+ }
11116
10532
  const job = new UploadJob(
11117
10533
  streamSource.stream,
11118
10534
  streamSource.mimeType,
@@ -11145,7 +10561,7 @@ var WorkerEndpoint = class extends Endpoint {
11145
10561
  }, params);
11146
10562
  }
11147
10563
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11148
- throw new Error("endpoint not connected, use connect() before loadFrom()");
10564
+ throw new Error("endpoint not connected, use connect()");
11149
10565
  }
11150
10566
  await this._limit.acquire();
11151
10567
  try {
@@ -11174,7 +10590,7 @@ var WorkerEndpoint = class extends Endpoint {
11174
10590
  }
11175
10591
  async loadLiveIngress(source, params) {
11176
10592
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
11177
- throw new Error("endpoint not connected, use connect() before loadLiveIngress()");
10593
+ throw new Error("endpoint not connected, use connect()");
11178
10594
  }
11179
10595
  await this._limit.acquire();
11180
10596
  try {
@@ -11226,10 +10642,9 @@ var WorkerEndpoint = class extends Endpoint {
11226
10642
  Authorization: await this.authorizationHeader()
11227
10643
  };
11228
10644
  this.updateState("FetchConfig" /* FetchConfig */);
11229
- this._requestLogger.debug("before GET %s", config_url);
11230
10645
  let response = await this._client.fetch(config_url, { headers });
11231
10646
  if (response.status == 401) {
11232
- this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", config_url);
10647
+ this._requestLogger.debug("GET %s: 401, about to retry with fresh access token", config_url);
11233
10648
  this.statusHandler401(response.status);
11234
10649
  const headers2 = {
11235
10650
  Authorization: await this.authorizationHeader()
@@ -11249,7 +10664,6 @@ var WorkerEndpoint = class extends Endpoint {
11249
10664
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11250
10665
  }
11251
10666
  let config = await response.json();
11252
- this._requestLogger.debug("after GET %s", config_url);
11253
10667
  if (!config.base_url && this.options().autoStart) {
11254
10668
  const auto_start_config_url = `${this.eyepopUrl()}/pops/${this.options().popId}/config?auto_start=true`;
11255
10669
  this._requestLogger.debug("pop was not running, trying to autostart with: %s", auto_start_config_url);
@@ -11275,7 +10689,6 @@ var WorkerEndpoint = class extends Endpoint {
11275
10689
  Authorization: await this.authorizationHeader()
11276
10690
  };
11277
10691
  const createSandboxUrl = `${this._baseUrl}/sandboxes`;
11278
- this._requestLogger.debug("before POST %s", createSandboxUrl);
11279
10692
  const response3 = await this._client.fetch(createSandboxUrl, {
11280
10693
  method: "POST",
11281
10694
  headers: headers3
@@ -11285,7 +10698,6 @@ var WorkerEndpoint = class extends Endpoint {
11285
10698
  return Promise.reject(`Unexpected status ${response3.status}: ${message}`);
11286
10699
  }
11287
10700
  const responseJson = await response3.json();
11288
- this._requestLogger.debug("after POST %s", createSandboxUrl);
11289
10701
  if (responseJson) {
11290
10702
  this._sandboxId = responseJson;
11291
10703
  }
@@ -11305,7 +10717,6 @@ var WorkerEndpoint = class extends Endpoint {
11305
10717
  const headers2 = {
11306
10718
  Authorization: await this.authorizationHeader()
11307
10719
  };
11308
- this._requestLogger.debug("before GET %s", get_url);
11309
10720
  let response2 = await this._client.fetch(get_url, {
11310
10721
  method: "GET",
11311
10722
  headers: headers2
@@ -11314,7 +10725,6 @@ var WorkerEndpoint = class extends Endpoint {
11314
10725
  const message = await response2.text();
11315
10726
  return Promise.reject(`Unexpected status ${response2.status}: ${message}`);
11316
10727
  }
11317
- this._requestLogger.debug("after GET %s", get_url);
11318
10728
  this._pipeline = await response2.json();
11319
10729
  if (this.options().stopJobs) {
11320
10730
  const body = { sourceType: "NONE" };
@@ -11375,7 +10785,6 @@ var WorkerEndpoint = class extends Endpoint {
11375
10785
  "Content-Type": "application/json",
11376
10786
  Authorization: await this.authorizationHeader()
11377
10787
  };
11378
- this._requestLogger.debug("before POST %s", post_url);
11379
10788
  return client.fetch(post_url, {
11380
10789
  method: "POST",
11381
10790
  body: JSON.stringify(body),
@@ -11387,7 +10796,6 @@ var WorkerEndpoint = class extends Endpoint {
11387
10796
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11388
10797
  }
11389
10798
  const result = await response.json();
11390
- this._requestLogger.debug("after POST %s", post_url);
11391
10799
  return result["id"];
11392
10800
  }
11393
10801
  async manifest() {
@@ -11395,7 +10803,7 @@ var WorkerEndpoint = class extends Endpoint {
11395
10803
  const client = this._client;
11396
10804
  const baseUrl = this._baseUrl;
11397
10805
  if (!baseUrl || !client) {
11398
- return Promise.reject("endpoint not connected, use connect() before getManifest()");
10806
+ return Promise.reject("endpoint not connected, use connect()");
11399
10807
  }
11400
10808
  let get_path;
11401
10809
  if (this._sandboxId === null) {
@@ -11409,23 +10817,20 @@ var WorkerEndpoint = class extends Endpoint {
11409
10817
  ...this._authenticationHeaders(session),
11410
10818
  "Content-Type": "application/json"
11411
10819
  };
11412
- this._requestLogger.debug("before GET %s", get_path);
11413
10820
  return client.fetch(get_path, { headers });
11414
10821
  });
11415
10822
  if (!response.ok) {
11416
10823
  const message = await response.text();
11417
10824
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11418
10825
  }
11419
- const result = await response.json();
11420
- this._requestLogger.debug("after GET %s", get_path);
11421
- return result;
10826
+ return await response.json();
11422
10827
  }
11423
10828
  async models() {
11424
10829
  this._logger.warn("listModels for development use only");
11425
10830
  const client = this._client;
11426
10831
  const baseUrl = this._baseUrl;
11427
10832
  if (!baseUrl || !client) {
11428
- return Promise.reject("endpoint not connected, use connect() before listModels()");
10833
+ return Promise.reject("endpoint not connected, use connect()");
11429
10834
  }
11430
10835
  let get_path;
11431
10836
  if (this._sandboxId === null) {
@@ -11439,7 +10844,6 @@ var WorkerEndpoint = class extends Endpoint {
11439
10844
  ...this._authenticationHeaders(session),
11440
10845
  "Content-Type": "application/json"
11441
10846
  };
11442
- this._requestLogger.debug("before GET %s", get_path);
11443
10847
  return client.fetch(get_path, { headers });
11444
10848
  });
11445
10849
  if (!response.ok) {
@@ -11447,7 +10851,6 @@ var WorkerEndpoint = class extends Endpoint {
11447
10851
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11448
10852
  }
11449
10853
  const result = await response.json();
11450
- this._requestLogger.debug("after GET %s", get_path);
11451
10854
  return result;
11452
10855
  }
11453
10856
  async changeManifest(manifests) {
@@ -11455,7 +10858,7 @@ var WorkerEndpoint = class extends Endpoint {
11455
10858
  const client = this._client;
11456
10859
  const baseUrl = this._baseUrl;
11457
10860
  if (!baseUrl || !client) {
11458
- return Promise.reject("endpoint not connected, use connect() before setManifest()");
10861
+ return Promise.reject("endpoint not connected, use connect()");
11459
10862
  }
11460
10863
  let put_url;
11461
10864
  if (this._sandboxId === null) {
@@ -11469,7 +10872,6 @@ var WorkerEndpoint = class extends Endpoint {
11469
10872
  ...this._authenticationHeaders(session),
11470
10873
  "Content-Type": "application/json"
11471
10874
  };
11472
- this._requestLogger.debug("before PUT %s", put_url);
11473
10875
  return client.fetch(put_url, {
11474
10876
  method: "PUT",
11475
10877
  body: JSON.stringify(manifests),
@@ -11480,14 +10882,13 @@ var WorkerEndpoint = class extends Endpoint {
11480
10882
  const message = await response.text();
11481
10883
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11482
10884
  }
11483
- this._requestLogger.debug("after PUT %s", put_url);
11484
10885
  }
11485
10886
  async loadModel(model) {
11486
10887
  this._logger.warn("loadModel for development use only");
11487
10888
  const client = this._client;
11488
10889
  const baseUrl = this._baseUrl;
11489
10890
  if (!baseUrl || !client) {
11490
- return Promise.reject("endpoint not connected, use connect() before loadModel()");
10891
+ return Promise.reject("endpoint not connected, use connect()");
11491
10892
  }
11492
10893
  let post_url;
11493
10894
  if (this._sandboxId === null) {
@@ -11501,7 +10902,6 @@ var WorkerEndpoint = class extends Endpoint {
11501
10902
  ...this._authenticationHeaders(session),
11502
10903
  "Content-Type": "application/json"
11503
10904
  };
11504
- this._requestLogger.debug("before POST %s", post_url);
11505
10905
  return client.fetch(post_url, {
11506
10906
  method: "POST",
11507
10907
  body: JSON.stringify(model),
@@ -11512,16 +10912,14 @@ var WorkerEndpoint = class extends Endpoint {
11512
10912
  const message = await response.text();
11513
10913
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11514
10914
  }
11515
- const result = await response.json();
11516
- this._requestLogger.debug("after POST %s", post_url);
11517
- return result;
10915
+ return await response.json();
11518
10916
  }
11519
10917
  async unloadModel(modelId) {
11520
10918
  this._logger.warn("purgeModel for development use only");
11521
10919
  const client = this._client;
11522
10920
  const baseUrl = this._baseUrl;
11523
10921
  if (!baseUrl || !client) {
11524
- return Promise.reject("endpoint not connected, use connect() before unloadModel()");
10922
+ return Promise.reject("endpoint not connected, use connect()");
11525
10923
  }
11526
10924
  let delete_url;
11527
10925
  if (this._sandboxId === null) {
@@ -11535,14 +10933,12 @@ var WorkerEndpoint = class extends Endpoint {
11535
10933
  ...this._authenticationHeaders(session),
11536
10934
  "Content-Type": "application/json"
11537
10935
  };
11538
- this._requestLogger.debug("before DELETE %s", delete_url);
11539
10936
  return client.fetch(delete_url, { method: "DELETE", headers });
11540
10937
  });
11541
10938
  if (!response.ok) {
11542
10939
  const message = await response.text();
11543
10940
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11544
10941
  }
11545
- this._requestLogger.debug("after DELETE %s", delete_url);
11546
10942
  }
11547
10943
  };
11548
10944
 
@@ -11760,10 +11156,9 @@ var DataEndpoint = class extends Endpoint {
11760
11156
  Authorization: await this.authorizationHeader()
11761
11157
  };
11762
11158
  this.updateState("FetchConfig" /* FetchConfig */);
11763
- this._requestLogger.debug("before GET %s", config_url);
11764
11159
  let response = await this._client.fetch(config_url, { headers });
11765
11160
  if (response.status == 401) {
11766
- this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", config_url);
11161
+ this._requestLogger.debug("GET %s: 401, about to retry with fresh access token", config_url);
11767
11162
  this.statusHandler401(response.status);
11768
11163
  headers = {
11769
11164
  Authorization: await this.authorizationHeader()
@@ -11779,7 +11174,6 @@ var DataEndpoint = class extends Endpoint {
11779
11174
  return Promise.reject(`Unexpected status ${response.status}: ${message}`);
11780
11175
  }
11781
11176
  let config = await response.json();
11782
- this._requestLogger.debug("after GET %s", config_url);
11783
11177
  const baseUrl = new URL(config.base_url, this.eyepopUrl());
11784
11178
  this._baseUrl = baseUrl.toString();
11785
11179
  if (this.options().disableWs) {