diff --git a/composition-go/Makefile b/composition-go/Makefile new file mode 100644 index 0000000000..eeb3fd748b --- /dev/null +++ b/composition-go/Makefile @@ -0,0 +1,5 @@ +test: + go test -v ./... + go test -v -tags=wg_composition_v8 ./... + +.PHONY: test \ No newline at end of file diff --git a/composition-go/composition_test.go b/composition-go/composition_test.go index abd5f8f346..d0bfdaa00f 100644 --- a/composition-go/composition_test.go +++ b/composition-go/composition_test.go @@ -35,6 +35,7 @@ var subgraphs = []*Subgraph{ name: String }`, SubscriptionProtocol: "ws", + URL: "https://example.com/subgraph-a", }, { Name: "B", @@ -58,6 +59,7 @@ var subgraphs = []*Subgraph{ age: Int @authenticated }`, SubscriptionProtocol: "ws", + URL: "https://example.com/subgraph-b", }, } diff --git a/composition-go/index.global.js b/composition-go/index.global.js index 202a19726f..2986f5aaef 100644 --- a/composition-go/index.global.js +++ b/composition-go/index.global.js @@ -10,6 +10,10 @@ class URL { this[prop] = result[prop] } } + + static canParse(url, base = undefined) { + return urlCanParse(url, base || ''); + } } "use strict";var shim=(()=>{var tJ=Object.create;var yd=Object.defineProperty,nJ=Object.defineProperties,rJ=Object.getOwnPropertyDescriptor,iJ=Object.getOwnPropertyDescriptors,aJ=Object.getOwnPropertyNames,bA=Object.getOwnPropertySymbols,sJ=Object.getPrototypeOf,AA=Object.prototype.hasOwnProperty,oJ=Object.prototype.propertyIsEnumerable;var nn=Math.pow,yy=(e,t,n)=>t in e?yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))AA.call(t,n)&&yy(e,n,t[n]);if(bA)for(var n of bA(t))oJ.call(t,n)&&yy(e,n,t[n]);return e},Y=(e,t)=>nJ(e,iJ(t));var wu=(e,t)=>()=>(e&&(t=e(e=0)),t);var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),am=(e,t)=>{for(var n in t)yd(e,n,{get:t[n],enumerable:!0})},RA=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of aJ(t))!AA.call(e,i)&&i!==n&&yd(e,i,{get:()=>t[i],enumerable:!(r=rJ(t,i))||r.enumerable});return e};var ss=(e,t,n)=>(n=e!=null?tJ(sJ(e)):{},RA(t||!e||!e.__esModule?yd(n,"default",{value:e,enumerable:!0}):n,e)),sm=e=>RA(yd({},"__esModule",{value:!0}),e);var _=(e,t,n)=>(yy(e,typeof t!="symbol"?t+"":t,n),n);var vi=(e,t,n)=>new Promise((r,i)=>{var a=l=>{try{c(n.next(l))}catch(p){i(p)}},o=l=>{try{c(n.throw(l))}catch(p){i(p)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(a,o);c((n=n.apply(e,t)).next())});var m=wu(()=>{"use strict"});var O={};am(O,{_debugEnd:()=>ER,_debugProcess:()=>TR,_events:()=>LR,_eventsCount:()=>CR,_exiting:()=>WA,_fatalExceptions:()=>pR,_getActiveHandles:()=>tR,_getActiveRequests:()=>eR,_kill:()=>rR,_linkedBinding:()=>HA,_maxListeners:()=>wR,_preload_modules:()=>RR,_rawDebug:()=>YA,_startProfilerIdleNotifier:()=>hR,_stopProfilerIdleNotifier:()=>yR,_tickCallback:()=>NR,abort:()=>vR,addListener:()=>BR,allowedNodeEnvironmentFlags:()=>cR,arch:()=>CA,argv:()=>kA,argv0:()=>AR,assert:()=>lR,binding:()=>jA,chdir:()=>$A,config:()=>XA,cpuUsage:()=>cm,cwd:()=>GA,debugPort:()=>bR,default:()=>GR,dlopen:()=>ZA,domain:()=>zA,emit:()=>qR,emitWarning:()=>VA,env:()=>UA,execArgv:()=>MA,execPath:()=>DR,exit:()=>oR,features:()=>dR,hasUncaughtExceptionCaptureCallback:()=>mR,hrtime:()=>um,kill:()=>sR,listeners:()=>KR,memoryUsage:()=>aR,moduleLoadList:()=>JA,nextTick:()=>FA,off:()=>kR,on:()=>us,once:()=>UR,openStdin:()=>uR,pid:()=>SR,platform:()=>BA,ppid:()=>OR,prependListener:()=>VR,prependOnceListener:()=>jR,reallyExit:()=>nR,release:()=>QA,removeAllListeners:()=>xR,removeListener:()=>MR,resourceUsage:()=>iR,setSourceMapsEnabled:()=>PR,setUncaughtExceptionCaptureCallback:()=>fR,stderr:()=>gR,stdin:()=>_R,stdout:()=>IR,title:()=>LA,umask:()=>KA,uptime:()=>FR,version:()=>xA,versions:()=>qA});function _y(e){throw new Error("Node.js process "+e+" is not supported by JSPM core outside of Node.js")}function uJ(){!Qc||!Lu||(Qc=!1,Lu.length?os=Lu.concat(os):om=-1,os.length&&PA())}function PA(){if(!Qc){var e=setTimeout(uJ,0);Qc=!0;for(var t=os.length;t;){for(Lu=os,os=[];++om1)for(var n=1;n{"use strict";m();T();N();os=[],Qc=!1,om=-1;wA.prototype.run=function(){this.fun.apply(null,this.array)};LA="browser",CA="x64",BA="browser",UA={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},kA=["/usr/bin/node"],MA=[],xA="v16.8.0",qA={},VA=function(e,t){console.warn((t?t+": ":"")+e)},jA=function(e){_y("binding")},KA=function(e){return 0},GA=function(){return"/"},$A=function(e){},QA={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};YA=hr,JA=[];zA={},WA=!1,XA={};nR=hr,rR=hr,cm=function(){return{}},iR=cm,aR=cm,sR=hr,oR=hr,uR=hr,cR={};dR={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},pR=hr,fR=hr;NR=hr,TR=hr,ER=hr,hR=hr,yR=hr,IR=void 0,gR=void 0,_R=void 0,vR=hr,SR=2,OR=1,DR="/bin/usr/node",bR=9229,AR="node",RR=[],PR=hr,Yo={now:typeof performance!="undefined"?performance.now.bind(performance):void 0,timing:typeof performance!="undefined"?performance.timing:void 0};Yo.now===void 0&&(Iy=Date.now(),Yo.timing&&Yo.timing.navigationStart&&(Iy=Yo.timing.navigationStart),Yo.now=()=>Date.now()-Iy);gy=1e9;um.bigint=function(e){var t=um(e);return typeof BigInt=="undefined"?t[0]*gy+t[1]:BigInt(t[0]*gy)+BigInt(t[1])};wR=10,LR={},CR=0;BR=us,UR=us,kR=us,MR=us,xR=us,qR=hr,VR=us,jR=us;GR={version:xA,versions:qA,arch:CA,platform:BA,release:QA,_rawDebug:YA,moduleLoadList:JA,binding:jA,_linkedBinding:HA,_events:LR,_eventsCount:CR,_maxListeners:wR,on:us,addListener:BR,once:UR,off:kR,removeListener:MR,removeAllListeners:xR,emit:qR,prependListener:VR,prependOnceListener:jR,listeners:KR,domain:zA,_exiting:WA,config:XA,dlopen:ZA,uptime:FR,_getActiveRequests:eR,_getActiveHandles:tR,reallyExit:nR,_kill:rR,cpuUsage:cm,resourceUsage:iR,memoryUsage:aR,kill:sR,exit:oR,openStdin:uR,allowedNodeEnvironmentFlags:cR,assert:lR,features:dR,_fatalExceptions:pR,setUncaughtExceptionCaptureCallback:fR,hasUncaughtExceptionCaptureCallback:mR,emitWarning:VA,nextTick:FA,_tickCallback:NR,_debugProcess:TR,_debugEnd:ER,_startProfilerIdleNotifier:hR,_stopProfilerIdleNotifier:yR,stdout:IR,stdin:_R,stderr:gR,abort:vR,umask:KA,chdir:$A,cwd:GA,env:UA,title:LA,argv:kA,execArgv:MA,pid:SR,ppid:OR,execPath:DR,debugPort:bR,hrtime:um,argv0:AR,_preload_modules:RR,setSourceMapsEnabled:PR}});var N=wu(()=>{"use strict";$R()});function cJ(){if(QR)return Id;QR=!0,Id.byteLength=c,Id.toByteArray=p,Id.fromByteArray=g;for(var e=[],t=[],n=typeof Uint8Array!="undefined"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=r.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");var k=v.indexOf("=");k===-1&&(k=F);var K=k===F?0:4-k%4;return[k,K]}function c(v){var F=o(v),k=F[0],K=F[1];return(k+K)*3/4-K}function l(v,F,k){return(F+k)*3/4-k}function p(v){var F,k=o(v),K=k[0],$=k[1],ne=new n(l(v,K,$)),z=0,Te=$>0?K-4:K,pe;for(pe=0;pe>16&255,ne[z++]=F>>8&255,ne[z++]=F&255;return $===2&&(F=t[v.charCodeAt(pe)]<<2|t[v.charCodeAt(pe+1)]>>4,ne[z++]=F&255),$===1&&(F=t[v.charCodeAt(pe)]<<10|t[v.charCodeAt(pe+1)]<<4|t[v.charCodeAt(pe+2)]>>2,ne[z++]=F>>8&255,ne[z++]=F&255),ne}function f(v){return e[v>>18&63]+e[v>>12&63]+e[v>>6&63]+e[v&63]}function y(v,F,k){for(var K,$=[],ne=F;neTe?Te:z+ne));return K===1?(F=v[k-1],$.push(e[F>>2]+e[F<<4&63]+"==")):K===2&&(F=(v[k-2]<<8)+v[k-1],$.push(e[F>>10]+e[F>>4&63]+e[F<<2&63]+"=")),$.join("")}return Id}function lJ(){if(YR)return lm;YR=!0;return lm.read=function(e,t,n,r,i){var a,o,c=i*8-r-1,l=(1<>1,f=-7,y=n?i-1:0,g=n?-1:1,v=e[t+y];for(y+=g,a=v&(1<<-f)-1,v>>=-f,f+=c;f>0;a=a*256+e[t+y],y+=g,f-=8);for(o=a&(1<<-f)-1,a>>=-f,f+=r;f>0;o=o*256+e[t+y],y+=g,f-=8);if(a===0)a=1-p;else{if(a===l)return o?NaN:(v?-1:1)*(1/0);o=o+Math.pow(2,r),a=a-p}return(v?-1:1)*o*Math.pow(2,a-r)},lm.write=function(e,t,n,r,i,a){var o,c,l,p=a*8-i-1,f=(1<>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=r?0:a-1,F=r?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+y>=1?t+=g/l:t+=g*Math.pow(2,1-y),t*l>=2&&(o++,l/=2),o+y>=f?(c=0,o=f):o+y>=1?(c=(t*l-1)*Math.pow(2,i),o=o+y):(c=t*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;e[n+v]=c&255,v+=F,c/=256,i-=8);for(o=o<0;e[n+v]=o&255,v+=F,o/=256,p-=8);e[n+v-F]|=k*128},lm}function dJ(){if(JR)return Cu;JR=!0;let e=cJ(),t=lJ(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Cu.Buffer=o,Cu.SlowBuffer=$,Cu.INSPECT_MAX_BYTES=50;let r=2147483647;Cu.kMaxLength=r,o.TYPED_ARRAY_SUPPORT=i(),!o.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{let A=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(A,h),A.foo()===42}catch(A){return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function a(A){if(A>r)throw new RangeError('The value "'+A+'" is invalid for option "size"');let h=new Uint8Array(A);return Object.setPrototypeOf(h,o.prototype),h}function o(A,h,I){if(typeof A=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return f(A)}return c(A,h,I)}o.poolSize=8192;function c(A,h,I){if(typeof A=="string")return y(A,h);if(ArrayBuffer.isView(A))return v(A);if(A==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof A);if(xt(A,ArrayBuffer)||A&&xt(A.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(xt(A,SharedArrayBuffer)||A&&xt(A.buffer,SharedArrayBuffer)))return F(A,h,I);if(typeof A=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let C=A.valueOf&&A.valueOf();if(C!=null&&C!==A)return o.from(C,h,I);let G=k(A);if(G)return G;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof A[Symbol.toPrimitive]=="function")return o.from(A[Symbol.toPrimitive]("string"),h,I);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof A)}o.from=function(A,h,I){return c(A,h,I)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function l(A){if(typeof A!="number")throw new TypeError('"size" argument must be of type number');if(A<0)throw new RangeError('The value "'+A+'" is invalid for option "size"')}function p(A,h,I){return l(A),A<=0?a(A):h!==void 0?typeof I=="string"?a(A).fill(h,I):a(A).fill(h):a(A)}o.alloc=function(A,h,I){return p(A,h,I)};function f(A){return l(A),a(A<0?0:K(A)|0)}o.allocUnsafe=function(A){return f(A)},o.allocUnsafeSlow=function(A){return f(A)};function y(A,h){if((typeof h!="string"||h==="")&&(h="utf8"),!o.isEncoding(h))throw new TypeError("Unknown encoding: "+h);let I=ne(A,h)|0,C=a(I),G=C.write(A,h);return G!==I&&(C=C.slice(0,G)),C}function g(A){let h=A.length<0?0:K(A.length)|0,I=a(h);for(let C=0;C=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return A|0}function $(A){return+A!=A&&(A=0),o.alloc(+A)}o.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==o.prototype},o.compare=function(h,I){if(xt(h,Uint8Array)&&(h=o.from(h,h.offset,h.byteLength)),xt(I,Uint8Array)&&(I=o.from(I,I.offset,I.byteLength)),!o.isBuffer(h)||!o.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===I)return 0;let C=h.length,G=I.length;for(let re=0,le=Math.min(C,G);reG.length?(o.isBuffer(le)||(le=o.from(le)),le.copy(G,re)):Uint8Array.prototype.set.call(G,le,re);else if(o.isBuffer(le))le.copy(G,re);else throw new TypeError('"list" argument must be an Array of Buffers');re+=le.length}return G};function ne(A,h){if(o.isBuffer(A))return A.length;if(ArrayBuffer.isView(A)||xt(A,ArrayBuffer))return A.byteLength;if(typeof A!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof A);let I=A.length,C=arguments.length>2&&arguments[2]===!0;if(!C&&I===0)return 0;let G=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return za(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I*2;case"hex":return I>>>1;case"base64":return pr(A).length;default:if(G)return C?-1:za(A).length;h=(""+h).toLowerCase(),G=!0}}o.byteLength=ne;function z(A,h,I){let C=!1;if((h===void 0||h<0)&&(h=0),h>this.length||((I===void 0||I>this.length)&&(I=this.length),I<=0)||(I>>>=0,h>>>=0,I<=h))return"";for(A||(A="utf8");;)switch(A){case"hex":return Rr(this,h,I);case"utf8":case"utf-8":return Wt(this,h,I);case"ascii":return dn(this,h,I);case"latin1":case"binary":return Ar(this,h,I);case"base64":return zt(this,h,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Un(this,h,I);default:if(C)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),C=!0}}o.prototype._isBuffer=!0;function Te(A,h,I){let C=A[h];A[h]=A[I],A[I]=C}o.prototype.swap16=function(){let h=this.length;if(h%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let I=0;II&&(h+=" ... "),""},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(h,I,C,G,re){if(xt(h,Uint8Array)&&(h=o.from(h,h.offset,h.byteLength)),!o.isBuffer(h))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(I===void 0&&(I=0),C===void 0&&(C=h?h.length:0),G===void 0&&(G=0),re===void 0&&(re=this.length),I<0||C>h.length||G<0||re>this.length)throw new RangeError("out of range index");if(G>=re&&I>=C)return 0;if(G>=re)return-1;if(I>=C)return 1;if(I>>>=0,C>>>=0,G>>>=0,re>>>=0,this===h)return 0;let le=re-G,ft=C-I,pn=Math.min(le,ft),tn=this.slice(G,re),hn=h.slice(I,C);for(let Xt=0;Xt2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),I=+I,fr(I)&&(I=G?0:A.length-1),I<0&&(I=A.length+I),I>=A.length){if(G)return-1;I=A.length-1}else if(I<0)if(G)I=0;else return-1;if(typeof h=="string"&&(h=o.from(h,C)),o.isBuffer(h))return h.length===0?-1:Fe(A,h,I,C,G);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?G?Uint8Array.prototype.indexOf.call(A,h,I):Uint8Array.prototype.lastIndexOf.call(A,h,I):Fe(A,[h],I,C,G);throw new TypeError("val must be string, number or Buffer")}function Fe(A,h,I,C,G){let re=1,le=A.length,ft=h.length;if(C!==void 0&&(C=String(C).toLowerCase(),C==="ucs2"||C==="ucs-2"||C==="utf16le"||C==="utf-16le")){if(A.length<2||h.length<2)return-1;re=2,le/=2,ft/=2,I/=2}function pn(hn,Xt){return re===1?hn[Xt]:hn.readUInt16BE(Xt*re)}let tn;if(G){let hn=-1;for(tn=I;tnle&&(I=le-ft),tn=I;tn>=0;tn--){let hn=!0;for(let Xt=0;XtG&&(C=G)):C=G;let re=h.length;C>re/2&&(C=re/2);let le;for(le=0;le>>0,isFinite(C)?(C=C>>>0,G===void 0&&(G="utf8")):(G=C,C=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let re=this.length-I;if((C===void 0||C>re)&&(C=re),h.length>0&&(C<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");G||(G="utf8");let le=!1;for(;;)switch(G){case"hex":return Ve(this,h,I,C);case"utf8":case"utf-8":return et(this,h,I,C);case"ascii":case"latin1":case"binary":return X(this,h,I,C);case"base64":return ve(this,h,I,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gt(this,h,I,C);default:if(le)throw new TypeError("Unknown encoding: "+G);G=(""+G).toLowerCase(),le=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function zt(A,h,I){return h===0&&I===A.length?e.fromByteArray(A):e.fromByteArray(A.slice(h,I))}function Wt(A,h,I){I=Math.min(A.length,I);let C=[],G=h;for(;G239?4:re>223?3:re>191?2:1;if(G+ft<=I){let pn,tn,hn,Xt;switch(ft){case 1:re<128&&(le=re);break;case 2:pn=A[G+1],(pn&192)===128&&(Xt=(re&31)<<6|pn&63,Xt>127&&(le=Xt));break;case 3:pn=A[G+1],tn=A[G+2],(pn&192)===128&&(tn&192)===128&&(Xt=(re&15)<<12|(pn&63)<<6|tn&63,Xt>2047&&(Xt<55296||Xt>57343)&&(le=Xt));break;case 4:pn=A[G+1],tn=A[G+2],hn=A[G+3],(pn&192)===128&&(tn&192)===128&&(hn&192)===128&&(Xt=(re&15)<<18|(pn&63)<<12|(tn&63)<<6|hn&63,Xt>65535&&Xt<1114112&&(le=Xt))}}le===null?(le=65533,ft=1):le>65535&&(le-=65536,C.push(le>>>10&1023|55296),le=56320|le&1023),C.push(le),G+=ft}return Vt(C)}let Dn=4096;function Vt(A){let h=A.length;if(h<=Dn)return String.fromCharCode.apply(String,A);let I="",C=0;for(;CC)&&(I=C);let G="";for(let re=h;reC&&(h=C),I<0?(I+=C,I<0&&(I=0)):I>C&&(I=C),II)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(h,I,C){h=h>>>0,I=I>>>0,C||$t(h,I,this.length);let G=this[h],re=1,le=0;for(;++le>>0,I=I>>>0,C||$t(h,I,this.length);let G=this[h+--I],re=1;for(;I>0&&(re*=256);)G+=this[h+--I]*re;return G},o.prototype.readUint8=o.prototype.readUInt8=function(h,I){return h=h>>>0,I||$t(h,1,this.length),this[h]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(h,I){return h=h>>>0,I||$t(h,2,this.length),this[h]|this[h+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(h,I){return h=h>>>0,I||$t(h,2,this.length),this[h]<<8|this[h+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(h,I){return h=h>>>0,I||$t(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(h,I){return h=h>>>0,I||$t(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},o.prototype.readBigUInt64LE=ya(function(h){h=h>>>0,tt(h,"offset");let I=this[h],C=this[h+7];(I===void 0||C===void 0)&&At(h,this.length-8);let G=I+this[++h]*nn(2,8)+this[++h]*nn(2,16)+this[++h]*nn(2,24),re=this[++h]+this[++h]*nn(2,8)+this[++h]*nn(2,16)+C*nn(2,24);return BigInt(G)+(BigInt(re)<>>0,tt(h,"offset");let I=this[h],C=this[h+7];(I===void 0||C===void 0)&&At(h,this.length-8);let G=I*nn(2,24)+this[++h]*nn(2,16)+this[++h]*nn(2,8)+this[++h],re=this[++h]*nn(2,24)+this[++h]*nn(2,16)+this[++h]*nn(2,8)+C;return(BigInt(G)<>>0,I=I>>>0,C||$t(h,I,this.length);let G=this[h],re=1,le=0;for(;++le=re&&(G-=Math.pow(2,8*I)),G},o.prototype.readIntBE=function(h,I,C){h=h>>>0,I=I>>>0,C||$t(h,I,this.length);let G=I,re=1,le=this[h+--G];for(;G>0&&(re*=256);)le+=this[h+--G]*re;return re*=128,le>=re&&(le-=Math.pow(2,8*I)),le},o.prototype.readInt8=function(h,I){return h=h>>>0,I||$t(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},o.prototype.readInt16LE=function(h,I){h=h>>>0,I||$t(h,2,this.length);let C=this[h]|this[h+1]<<8;return C&32768?C|4294901760:C},o.prototype.readInt16BE=function(h,I){h=h>>>0,I||$t(h,2,this.length);let C=this[h+1]|this[h]<<8;return C&32768?C|4294901760:C},o.prototype.readInt32LE=function(h,I){return h=h>>>0,I||$t(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},o.prototype.readInt32BE=function(h,I){return h=h>>>0,I||$t(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},o.prototype.readBigInt64LE=ya(function(h){h=h>>>0,tt(h,"offset");let I=this[h],C=this[h+7];(I===void 0||C===void 0)&&At(h,this.length-8);let G=this[h+4]+this[h+5]*nn(2,8)+this[h+6]*nn(2,16)+(C<<24);return(BigInt(G)<>>0,tt(h,"offset");let I=this[h],C=this[h+7];(I===void 0||C===void 0)&&At(h,this.length-8);let G=(I<<24)+this[++h]*nn(2,16)+this[++h]*nn(2,8)+this[++h];return(BigInt(G)<>>0,I||$t(h,4,this.length),t.read(this,h,!0,23,4)},o.prototype.readFloatBE=function(h,I){return h=h>>>0,I||$t(h,4,this.length),t.read(this,h,!1,23,4)},o.prototype.readDoubleLE=function(h,I){return h=h>>>0,I||$t(h,8,this.length),t.read(this,h,!0,52,8)},o.prototype.readDoubleBE=function(h,I){return h=h>>>0,I||$t(h,8,this.length),t.read(this,h,!1,52,8)};function bn(A,h,I,C,G,re){if(!o.isBuffer(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>G||hA.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(h,I,C,G){if(h=+h,I=I>>>0,C=C>>>0,!G){let ft=Math.pow(2,8*C)-1;bn(this,h,I,C,ft,0)}let re=1,le=0;for(this[I]=h&255;++le>>0,C=C>>>0,!G){let ft=Math.pow(2,8*C)-1;bn(this,h,I,C,ft,0)}let re=C-1,le=1;for(this[I+re]=h&255;--re>=0&&(le*=256);)this[I+re]=h/le&255;return I+C},o.prototype.writeUint8=o.prototype.writeUInt8=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,1,255,0),this[I]=h&255,I+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,2,65535,0),this[I]=h&255,this[I+1]=h>>>8,I+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,2,65535,0),this[I]=h>>>8,this[I+1]=h&255,I+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,4,4294967295,0),this[I+3]=h>>>24,this[I+2]=h>>>16,this[I+1]=h>>>8,this[I]=h&255,I+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,4,4294967295,0),this[I]=h>>>24,this[I+1]=h>>>16,this[I+2]=h>>>8,this[I+3]=h&255,I+4};function oe(A,h,I,C,G){Lt(h,C,G,A,I,7);let re=Number(h&BigInt(4294967295));A[I++]=re,re=re>>8,A[I++]=re,re=re>>8,A[I++]=re,re=re>>8,A[I++]=re;let le=Number(h>>BigInt(32)&BigInt(4294967295));return A[I++]=le,le=le>>8,A[I++]=le,le=le>>8,A[I++]=le,le=le>>8,A[I++]=le,I}function De(A,h,I,C,G){Lt(h,C,G,A,I,7);let re=Number(h&BigInt(4294967295));A[I+7]=re,re=re>>8,A[I+6]=re,re=re>>8,A[I+5]=re,re=re>>8,A[I+4]=re;let le=Number(h>>BigInt(32)&BigInt(4294967295));return A[I+3]=le,le=le>>8,A[I+2]=le,le=le>>8,A[I+1]=le,le=le>>8,A[I]=le,I+8}o.prototype.writeBigUInt64LE=ya(function(h,I=0){return oe(this,h,I,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=ya(function(h,I=0){return De(this,h,I,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(h,I,C,G){if(h=+h,I=I>>>0,!G){let pn=Math.pow(2,8*C-1);bn(this,h,I,C,pn-1,-pn)}let re=0,le=1,ft=0;for(this[I]=h&255;++re>0)-ft&255;return I+C},o.prototype.writeIntBE=function(h,I,C,G){if(h=+h,I=I>>>0,!G){let pn=Math.pow(2,8*C-1);bn(this,h,I,C,pn-1,-pn)}let re=C-1,le=1,ft=0;for(this[I+re]=h&255;--re>=0&&(le*=256);)h<0&&ft===0&&this[I+re+1]!==0&&(ft=1),this[I+re]=(h/le>>0)-ft&255;return I+C},o.prototype.writeInt8=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,1,127,-128),h<0&&(h=255+h+1),this[I]=h&255,I+1},o.prototype.writeInt16LE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,2,32767,-32768),this[I]=h&255,this[I+1]=h>>>8,I+2},o.prototype.writeInt16BE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,2,32767,-32768),this[I]=h>>>8,this[I+1]=h&255,I+2},o.prototype.writeInt32LE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,4,2147483647,-2147483648),this[I]=h&255,this[I+1]=h>>>8,this[I+2]=h>>>16,this[I+3]=h>>>24,I+4},o.prototype.writeInt32BE=function(h,I,C){return h=+h,I=I>>>0,C||bn(this,h,I,4,2147483647,-2147483648),h<0&&(h=4294967295+h+1),this[I]=h>>>24,this[I+1]=h>>>16,this[I+2]=h>>>8,this[I+3]=h&255,I+4},o.prototype.writeBigInt64LE=ya(function(h,I=0){return oe(this,h,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=ya(function(h,I=0){return De(this,h,I,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _e(A,h,I,C,G,re){if(I+C>A.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function Le(A,h,I,C,G){return h=+h,I=I>>>0,G||_e(A,h,I,4),t.write(A,h,I,C,23,4),I+4}o.prototype.writeFloatLE=function(h,I,C){return Le(this,h,I,!0,C)},o.prototype.writeFloatBE=function(h,I,C){return Le(this,h,I,!1,C)};function _t(A,h,I,C,G){return h=+h,I=I>>>0,G||_e(A,h,I,8),t.write(A,h,I,C,52,8),I+8}o.prototype.writeDoubleLE=function(h,I,C){return _t(this,h,I,!0,C)},o.prototype.writeDoubleBE=function(h,I,C){return _t(this,h,I,!1,C)},o.prototype.copy=function(h,I,C,G){if(!o.isBuffer(h))throw new TypeError("argument should be a Buffer");if(C||(C=0),!G&&G!==0&&(G=this.length),I>=h.length&&(I=h.length),I||(I=0),G>0&&G=this.length)throw new RangeError("Index out of range");if(G<0)throw new RangeError("sourceEnd out of bounds");G>this.length&&(G=this.length),h.length-I>>0,C=C===void 0?this.length:C>>>0,h||(h=0);let re;if(typeof h=="number")for(re=I;renn(2,32)?G=xe(String(I)):typeof I=="bigint"&&(G=String(I),(I>nn(BigInt(2),BigInt(32))||I<-nn(BigInt(2),BigInt(32)))&&(G=xe(G)),G+="n"),C+=` It must be ${h}. Received ${G}`,C},RangeError);function xe(A){let h="",I=A.length,C=A[0]==="-"?1:0;for(;I>=C+4;I-=3)h=`_${A.slice(I-3,I)}${h}`;return`${A.slice(0,I)}${h}`}function Qe(A,h,I){tt(h,"offset"),(A[h]===void 0||A[h+I]===void 0)&&At(h,A.length-(I+1))}function Lt(A,h,I,C,G,re){if(A>I||A3?h===0||h===BigInt(0)?ft=`>= 0${le} and < 2${le} ** ${(re+1)*8}${le}`:ft=`>= -(2${le} ** ${(re+1)*8-1}${le}) and < 2 ** ${(re+1)*8-1}${le}`:ft=`>= ${h}${le} and <= ${I}${le}`,new J.ERR_OUT_OF_RANGE("value",ft,A)}Qe(C,G,re)}function tt(A,h){if(typeof A!="number")throw new J.ERR_INVALID_ARG_TYPE(h,"number",A)}function At(A,h,I){throw Math.floor(A)!==A?(tt(A,I),new J.ERR_OUT_OF_RANGE(I||"offset","an integer",A)):h<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(I||"offset",`>= ${I?1:0} and <= ${h}`,A)}let Ha=/[^+/0-9A-Za-z-_]/g;function xr(A){if(A=A.split("=")[0],A=A.trim().replace(Ha,""),A.length<2)return"";for(;A.length%4!==0;)A=A+"=";return A}function za(A,h){h=h||1/0;let I,C=A.length,G=null,re=[];for(let le=0;le55295&&I<57344){if(!G){if(I>56319){(h-=3)>-1&&re.push(239,191,189);continue}else if(le+1===C){(h-=3)>-1&&re.push(239,191,189);continue}G=I;continue}if(I<56320){(h-=3)>-1&&re.push(239,191,189),G=I;continue}I=(G-55296<<10|I-56320)+65536}else G&&(h-=3)>-1&&re.push(239,191,189);if(G=null,I<128){if((h-=1)<0)break;re.push(I)}else if(I<2048){if((h-=2)<0)break;re.push(I>>6|192,I&63|128)}else if(I<65536){if((h-=3)<0)break;re.push(I>>12|224,I>>6&63|128,I&63|128)}else if(I<1114112){if((h-=4)<0)break;re.push(I>>18|240,I>>12&63|128,I>>6&63|128,I&63|128)}else throw new Error("Invalid code point")}return re}function wc(A){let h=[];for(let I=0;I>8,G=I%256,re.push(G),re.push(C);return re}function pr(A){return e.toByteArray(xr(A))}function ni(A,h,I,C){let G;for(G=0;G=h.length||G>=A.length);++G)h[G+I]=A[G];return G}function xt(A,h){return A instanceof h||A!=null&&A.constructor!=null&&A.constructor.name!=null&&A.constructor.name===h.name}function fr(A){return A!==A}let gu=function(){let A="0123456789abcdef",h=new Array(256);for(let I=0;I<16;++I){let C=I*16;for(let G=0;G<16;++G)h[C+G]=A[I]+A[G]}return h}();function ya(A){return typeof BigInt=="undefined"?_u:A}function _u(){throw new Error("BigInt not supported")}return Cu}var Id,QR,lm,YR,Cu,JR,Bu,D,Rde,Pde,HR=wu(()=>{"use strict";m();T();N();Id={},QR=!1;lm={},YR=!1;Cu={},JR=!1;Bu=dJ();Bu.Buffer;Bu.SlowBuffer;Bu.INSPECT_MAX_BYTES;Bu.kMaxLength;D=Bu.Buffer,Rde=Bu.INSPECT_MAX_BYTES,Pde=Bu.kMaxLength});var T=wu(()=>{"use strict";HR()});var zR=w(Yc=>{"use strict";m();T();N();Object.defineProperty(Yc,"__esModule",{value:!0});Yc.versionInfo=Yc.version=void 0;var pJ="16.9.0";Yc.version=pJ;var fJ=Object.freeze({major:16,minor:9,patch:0,preReleaseTag:null});Yc.versionInfo=fJ});var Lr=w(vy=>{"use strict";m();T();N();Object.defineProperty(vy,"__esModule",{value:!0});vy.devAssert=mJ;function mJ(e,t){if(!!!e)throw new Error(t)}});var dm=w(Sy=>{"use strict";m();T();N();Object.defineProperty(Sy,"__esModule",{value:!0});Sy.isPromise=NJ;function NJ(e){return typeof(e==null?void 0:e.then)=="function"}});var va=w(Oy=>{"use strict";m();T();N();Object.defineProperty(Oy,"__esModule",{value:!0});Oy.isObjectLike=TJ;function TJ(e){return typeof e=="object"&&e!==null}});var yr=w(Dy=>{"use strict";m();T();N();Object.defineProperty(Dy,"__esModule",{value:!0});Dy.invariant=EJ;function EJ(e,t){if(!!!e)throw new Error(t!=null?t:"Unexpected invariant triggered.")}});var pm=w(by=>{"use strict";m();T();N();Object.defineProperty(by,"__esModule",{value:!0});by.getLocation=IJ;var hJ=yr(),yJ=/\r\n|[\n\r]/g;function IJ(e,t){let n=0,r=1;for(let i of e.body.matchAll(yJ)){if(typeof i.index=="number"||(0,hJ.invariant)(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}});var Ay=w(fm=>{"use strict";m();T();N();Object.defineProperty(fm,"__esModule",{value:!0});fm.printLocation=_J;fm.printSourceLocation=XR;var gJ=pm();function _J(e){return XR(e.source,(0,gJ.getLocation)(e.source,e.start))}function XR(e,t){let n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,a=e.locationOffset.line-1,o=t.line+a,c=t.line===1?n:0,l=t.column+c,p=`${e.name}:${o}:${l} `,f=r.split(/\r\n|[\n\r]/g),y=f[i];if(y.length>120){let g=Math.floor(l/80),v=l%80,F=[];for(let k=0;k["|",k]),["|","^".padStart(v)],["|",F[g+1]]])}return p+WR([[`${o-1} |`,f[i-1]],[`${o} |`,y],["|","^".padStart(l)],[`${o+1} |`,f[i+1]]])}function WR(e){let t=e.filter(([r,i])=>i!==void 0),n=Math.max(...t.map(([r])=>r.length));return t.map(([r,i])=>r.padStart(n)+(i?" "+i:"")).join(` diff --git a/composition-go/polyfill.go b/composition-go/polyfill.go index b6a9910061..d53dc31659 100644 --- a/composition-go/polyfill.go +++ b/composition-go/polyfill.go @@ -62,3 +62,8 @@ func urlParse(rawURL string, base string) (*urlShim, error) { Username: u.User.Username(), }, nil } + +func urlCanParse(rawURL string, base string) bool { + _, err := urlParse(rawURL, base) + return err == nil +} diff --git a/composition-go/shim/src/polyfill.js b/composition-go/shim/src/polyfill.js index 50de708991..eea4140ac7 100644 --- a/composition-go/shim/src/polyfill.js +++ b/composition-go/shim/src/polyfill.js @@ -10,4 +10,8 @@ class URL { this[prop] = result[prop] } } + + static canParse(url, base = undefined) { + return urlCanParse(url, base || ''); + } } diff --git a/composition-go/vm_goja.go b/composition-go/vm_goja.go index 6e93b4b4be..6e911dd9c8 100644 --- a/composition-go/vm_goja.go +++ b/composition-go/vm_goja.go @@ -76,6 +76,10 @@ func newVM() (*gojaVm, error) { if err := runtime.Set("urlParse", urlParse); err != nil { return nil, err } + if err := runtime.Set("urlCanParse", urlCanParse); err != nil { + return nil, err + } + return &gojaVm{ runtime: runtime, federateSubgraphs: federateSubgraphs, diff --git a/composition-go/vm_v8.go b/composition-go/vm_v8.go index 89fae7b8f1..b90496d412 100644 --- a/composition-go/vm_v8.go +++ b/composition-go/vm_v8.go @@ -239,6 +239,20 @@ func urlParseV8(info *v8.FunctionCallbackInfo) *v8.Value { return value } +func urlCanParseV8(info *v8.FunctionCallbackInfo) *v8.Value { + isolate := info.Context().Isolate() + args := info.Args() + url := args[0].String() + base := args[1].String() + + result := urlCanParse(url, base) + value, err := v8.NewValue(isolate, result) + if err != nil { + panic(err) + } + return value +} + func newVM() (*v8Vm, error) { isolate := v8.NewIsolate() @@ -254,6 +268,11 @@ func newVM() (*v8Vm, error) { return nil, err } + urlCanParse := v8.NewFunctionTemplate(isolate, urlCanParseV8) + if err := global.Set("urlCanParse", urlCanParse, v8.ReadOnly); err != nil { + return nil, err + } + ctx := v8.NewContext(isolate, global) if _, err := ctx.RunScript(jsPrelude, "prelude.js"); err != nil {