fix(core): update
This commit is contained in:
		| @@ -3,6 +3,6 @@ | ||||
|  */ | ||||
| export const commitinfo = { | ||||
|   name: '@pushrocks/webrequest', | ||||
|   version: '3.0.11', | ||||
|   version: '3.0.12', | ||||
|   description: 'securely request from browsers' | ||||
| } | ||||
|   | ||||
							
								
								
									
										27
									
								
								ts/index.ts
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								ts/index.ts
									
									
									
									
									
								
							| @@ -12,7 +12,8 @@ export class WebRequest { | ||||
|   private static neededPolyfillsLoadedDeferred = plugins.smartpromise.defer<{ | ||||
|     fetch: typeof fetch, | ||||
|     Response: typeof Response, | ||||
|     AbortController: typeof AbortController | ||||
|     AbortController?: typeof AbortController, | ||||
|     helixTimeout?: any, | ||||
|   }>(); | ||||
|   public static async loadNeededPolyfills() { | ||||
|     if (this.polyfillStatusEvaluated) { | ||||
| @@ -26,7 +27,7 @@ export class WebRequest { | ||||
|       this.neededPolyfillsLoadedDeferred.resolve({ | ||||
|         fetch: fetchMod.fetch, | ||||
|         Response: fetchMod.Response, | ||||
|         AbortController: fetchMod.AbortSignal | ||||
|         helixTimeout: fetchMod.timeoutSignal, | ||||
|       }); | ||||
|     } else { | ||||
|       this.neededPolyfillsLoadedDeferred.resolve({ | ||||
| @@ -115,12 +116,24 @@ export class WebRequest { | ||||
|       timeoutMs?: number; | ||||
|     } | ||||
|   ) { | ||||
|     optionsArg = { | ||||
|       timeoutMs: 60000, | ||||
|       useCache: false, | ||||
|       ...optionsArg, | ||||
|     } | ||||
|     const fetchObject = await WebRequest.neededPolyfillsLoadedDeferred.promise; | ||||
|     const controller = new fetchObject.AbortController(); | ||||
|     let controller: AbortController; | ||||
|     if (optionsArg.timeoutMs) { | ||||
|       plugins.smartdelay.delayFor(optionsArg.timeoutMs).then(() => { | ||||
|         controller.abort(); | ||||
|       }); | ||||
|       if (fetchObject.AbortController) { | ||||
|         controller = new fetchObject.AbortController(); | ||||
|         plugins.smartdelay.delayFor(optionsArg.timeoutMs).then(() => { | ||||
|           controller.abort(); | ||||
|         }); | ||||
|       } else { | ||||
|         controller = { | ||||
|           signal: fetchObject.helixTimeout(optionsArg.timeoutMs) | ||||
|         } as any; | ||||
|       } | ||||
|     } | ||||
|     let cachedResponseDeferred = plugins.smartpromise.defer<Response>(); | ||||
|     let cacheUsed = false; | ||||
| @@ -131,7 +144,7 @@ export class WebRequest { | ||||
|       cachedResponseDeferred.resolve(null); | ||||
|     } | ||||
|     let response: Response = await fetchObject.fetch(urlArg, { | ||||
|       signal: controller.signal, | ||||
|       signal: controller ? controller.signal : null, | ||||
|       method: optionsArg.method, | ||||
|       headers: { | ||||
|         'Content-Type': 'application/json', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user