@oya-ai/browser 1.0.195 → 1.0.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -851,14 +851,22 @@ var configApi = (http) => ({
851
851
 
852
852
  // src/api/ready.ts
853
853
  var ENDED = ["failed", "stopped", "unknown_outcome"];
854
+ var pollPause = (deadline) => {
855
+ const left = deadline - Date.now();
856
+ return left <= 0 ? Promise.resolve() : new Promise((r) => setTimeout(r, Math.min(READY_POLL_MS, left)));
857
+ };
858
+ var notReady = (id, timeoutMs) => new OyaError(
859
+ `Browser ${id} did not come up within ${Math.round(timeoutMs / MS_PER_SECOND)}s`,
860
+ Status.GATEWAY_TIMEOUT,
861
+ null
862
+ );
854
863
  async function waitUntilConnected(checks, id, timeoutMs) {
855
864
  const deadline = Date.now() + timeoutMs;
856
- while (Date.now() < deadline) {
865
+ for (; ; ) {
857
866
  if (await isUp(checks, id)) return;
858
- await new Promise((r) => setTimeout(r, READY_POLL_MS));
867
+ if (Date.now() >= deadline) throw notReady(id, timeoutMs);
868
+ await pollPause(deadline);
859
869
  }
860
- const seconds = Math.round(timeoutMs / MS_PER_SECOND);
861
- throw new OyaError(`Browser ${id} did not come up within ${seconds}s`, Status.GATEWAY_TIMEOUT, null);
862
870
  }
863
871
  async function isUp(checks, id) {
864
872
  const all = await checks.list();
@@ -921,15 +929,18 @@ function openLink(link) {
921
929
  });
922
930
  child.unref();
923
931
  }
932
+ var desktopTimeout = (link) => {
933
+ const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
934
+ return new OyaError(`The Oya desktop app did not connect. ${how}`, Status.GATEWAY_TIMEOUT, { link });
935
+ };
924
936
  async function waitForDesktop(list, link, timeoutMs, persona) {
925
937
  const deadline = Date.now() + timeoutMs;
926
- while (Date.now() < deadline) {
938
+ for (; ; ) {
927
939
  const found = desktopOf(await list(), persona);
928
940
  if (found) return found;
929
- await new Promise((r) => setTimeout(r, READY_POLL_MS));
941
+ if (Date.now() >= deadline) throw desktopTimeout(link);
942
+ await pollPause(deadline);
930
943
  }
931
- const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
932
- throw new OyaError(`The Oya desktop app did not connect. ${how}`, Status.GATEWAY_TIMEOUT, { link });
933
944
  }
934
945
  async function handleOn(http, id) {
935
946
  const found = await http.request("GET", `/api/browsers/${segment(id)}`);
package/dist/index.js CHANGED
@@ -819,14 +819,22 @@ var configApi = (http) => ({
819
819
 
820
820
  // src/api/ready.ts
821
821
  var ENDED = ["failed", "stopped", "unknown_outcome"];
822
+ var pollPause = (deadline) => {
823
+ const left = deadline - Date.now();
824
+ return left <= 0 ? Promise.resolve() : new Promise((r) => setTimeout(r, Math.min(READY_POLL_MS, left)));
825
+ };
826
+ var notReady = (id, timeoutMs) => new OyaError(
827
+ `Browser ${id} did not come up within ${Math.round(timeoutMs / MS_PER_SECOND)}s`,
828
+ Status.GATEWAY_TIMEOUT,
829
+ null
830
+ );
822
831
  async function waitUntilConnected(checks, id, timeoutMs) {
823
832
  const deadline = Date.now() + timeoutMs;
824
- while (Date.now() < deadline) {
833
+ for (; ; ) {
825
834
  if (await isUp(checks, id)) return;
826
- await new Promise((r) => setTimeout(r, READY_POLL_MS));
835
+ if (Date.now() >= deadline) throw notReady(id, timeoutMs);
836
+ await pollPause(deadline);
827
837
  }
828
- const seconds = Math.round(timeoutMs / MS_PER_SECOND);
829
- throw new OyaError(`Browser ${id} did not come up within ${seconds}s`, Status.GATEWAY_TIMEOUT, null);
830
838
  }
831
839
  async function isUp(checks, id) {
832
840
  const all = await checks.list();
@@ -889,15 +897,18 @@ function openLink(link) {
889
897
  });
890
898
  child.unref();
891
899
  }
900
+ var desktopTimeout = (link) => {
901
+ const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
902
+ return new OyaError(`The Oya desktop app did not connect. ${how}`, Status.GATEWAY_TIMEOUT, { link });
903
+ };
892
904
  async function waitForDesktop(list, link, timeoutMs, persona) {
893
905
  const deadline = Date.now() + timeoutMs;
894
- while (Date.now() < deadline) {
906
+ for (; ; ) {
895
907
  const found = desktopOf(await list(), persona);
896
908
  if (found) return found;
897
- await new Promise((r) => setTimeout(r, READY_POLL_MS));
909
+ if (Date.now() >= deadline) throw desktopTimeout(link);
910
+ await pollPause(deadline);
898
911
  }
899
- const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
900
- throw new OyaError(`The Oya desktop app did not connect. ${how}`, Status.GATEWAY_TIMEOUT, { link });
901
912
  }
902
913
  async function handleOn(http, id) {
903
914
  const found = await http.request("GET", `/api/browsers/${segment(id)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oya-ai/browser",
3
- "version": "1.0.195",
3
+ "version": "1.0.197",
4
4
  "description": "Rotate thousands of browsers behind one API, personas, proxies, stealth, CAPTCHA and MFA.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://oyabrowser.com",