@based/opts
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -1,1 +0,1 @@ | ||
var v=Object.create;var l=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of w(t))!x.call(e,r)&&r!==n&&l(e,r,{get:()=>t[r],enumerable:!(s=k(t,r))||s.enumerable});return e};var B=(e,t,n)=>(n=e!=null?v(C(e)):{},g(t||!e||!e.__esModule?l(n,"default",{value:e,enumerable:!0}):n,e)),S=e=>g(l({},"__esModule",{value:!0}),e);var D={};O(D,{default:()=>R,getServicePort:()=>h});module.exports=S(D);var f=B(require("cross-fetch")),c=require("@saulx/utils");var P=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);let s=t>>>0;for(;s>65535;)s=s/10;return Math.round(s)},h=(e,t,n,s,r="allServices",i=0)=>P(`${r}-${e}-${t}-${n}-${s}-${i}`);var K=Array.from(Array(10)).map((e,t)=>String(t)),U=["localhost","based.io","@based","/env-hub","admin","hub","-",",",".","?"],y=e=>e||"@based/env-hub",{encode:M}=(0,c.createEncoder)(U,K),j=e=>{let t={name:y(e.name)};e.key&&e.optionalKey?t.optionalKey=e.key:e.key&&(t.key=e.key);let n=t.optionalKey?`${t.name},${t.key}?`:t.key?`${t.name},${t.key}`:t.name;return M(n)},q=async(e,t,n)=>{try{let s=await(0,f.default)(`${e}/status`,{headers:{"sequence-id":j(t),...t.headers}});if(s.ok){let r=s.headers.get("x-request-id");if(!r)return 1;let{decode:i}=(0,c.createEncoder)(F,r.slice(0,6).split("")),o=i(r.slice(6)).split(","),u=[];for(let a=0;a<Math.floor(o.length/2);a++)u.push([o[a],encodeURIComponent(o[o.length-1-a])]);let[d,p]=u[~~(Math.random()*u.length)];return n?`${/^https/.test(e)?"https":"http"}://${d}`:`${/^https/.test(e)?"wss":"ws"}://${d}/${p}`}else return!1}catch{return!1}},m=/^ws/,A=e=>[e.cluster?e.cluster==="local"?`http://localhost:${h(e.org,e.project,e.env,y(e.name).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`:`https://${e.org}-${e.project}-${e.env}-${e.cluster}.based.io`:`https://${e.org}-${e.project}-${e.env}.based.io`],b=async(e,t=!1,n=0)=>{if(e.url){let r;return typeof e.url=="function"?r=await e.url():r=e.url,t&&r&&m.test(r)?r.replace(m,"http"):r}let s=e.discoveryUrls||A(e);for(let r=0;r<s.length;r++){let i=s[r],o=await Promise.race([q(i,e,t),(0,c.wait)(3e3)]);if(o===1||!o&&r===s.length-1)return await(0,c.wait)(Math.min(n*n*50+500,5e3)),b(e,t,++n);if(o)return o}},F=[",",".based.io","localhost:","localhost","based.io","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],$=b;var R=async(e,t)=>$(e,t);0&&(module.exports={getServicePort}); | ||
var v=Object.create;var l=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of w(t))!x.call(e,r)&&r!==n&&l(e,r,{get:()=>t[r],enumerable:!(s=k(t,r))||s.enumerable});return e};var B=(e,t,n)=>(n=e!=null?v(C(e)):{},g(t||!e||!e.__esModule?l(n,"default",{value:e,enumerable:!0}):n,e)),S=e=>g(l({},"__esModule",{value:!0}),e);var D={};O(D,{default:()=>R,getServicePort:()=>h});module.exports=S(D);var f=B(require("cross-fetch")),a=require("@saulx/utils");var P=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);let s=t>>>0;for(;s>65535;)s=s/10;return Math.round(s)},h=(e,t,n,s,r="allServices",c=0)=>P(`${r}-${e}-${t}-${n}-${s}-${c}`);var K=Array.from(Array(10)).map((e,t)=>String(t)),U=["localhost","based.io","@based","/env-hub","admin","hub","-",",",".","?"],y=e=>e||"@based/env-hub",{encode:M}=(0,a.createEncoder)(U,K),j=e=>{let t={name:y(e.name)};e.key&&e.optionalKey?t.optionalKey=e.key:e.key&&(t.key=e.key);let n=t.optionalKey?`${t.name},${t.key}?`:t.key?`${t.name},${t.key}`:t.name;return M(n)},q=async(e,t,n)=>{try{let s=await(0,f.default)(`${e}/status`,{headers:{"sequence-id":j(t),...t.headers}});if(s.ok){let r=s.headers.get("x-request-id");if(!r)return 1;let{decode:c}=(0,a.createEncoder)(F,r.slice(0,6).split("")),o=c(r.slice(6)).split(","),u=[];for(let i=0;i<Math.floor(o.length/2);i++)u.push([o[i],encodeURIComponent(o[o.length-1-i])]);let[d,p]=u[~~(Math.random()*u.length)];return n?`${/^https/.test(e)?"https":"http"}://${d}`:`${/^https/.test(e)?"wss":"ws"}://${d}/${p}`}else return!1}catch{return!1}},m=/^ws/,A=e=>[e.cluster?e.cluster==="local"?`http://localhost:${h(e.org,e.project,e.env,y(e.name).includes("env-")?"@based/env-hub-discovery":"@based/hub-discovery","allServices")}`:`https://${e.org}-${e.project}-${e.env}-${e.cluster}.based.io`:`https://${e.org}-${e.project}-${e.env}.based.io`],b=async(e,t=!1,n=0)=>{if(e.url){let r;return typeof e.url=="function"?r=await e.url():r=e.url,t&&r&&m.test(r)?r.replace(m,"http"):r}let s=e.discoveryUrls||A(e);for(let r=0;r<s.length;r++){let c=s[r],o=await Promise.race([q(c,e,t),(0,a.wait)(3e3)]);if(o===1||!o&&r===s.length-1)return await(0,a.wait)(Math.min(n*n*50+500,5e3)),b(e,t,++n);if(o)return o}},F=[",",".based.io","localhost:","localhost","based.io","@based","/env-hub","admin","hub","900","90","443","80",":","%","/","=","<","?","."],$=b;var R=async(e,t)=>$(e,t);0&&(module.exports={getServicePort}); |
{ | ||
"name": "@based/opts", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"main": "dist/index.js", | ||
@@ -12,3 +12,3 @@ "public": true, | ||
"dependencies": { | ||
"@saulx/utils": "3.2.1", | ||
"@saulx/utils": "^3.2.2", | ||
"cross-fetch": "^3.1.5" | ||
@@ -15,0 +15,0 @@ }, |
3195
+ Added@saulx/utils@3.5.3(transitive)
- Removed@saulx/utils@3.2.1(transitive)
Updated@saulx/utils@^3.2.2