@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20241212120314 to 0.0.0-next-20241212123451
@@ -425,3 +425,3 @@ 'use strict'; | ||
let needAttach = true; | ||
let timeout = 20000; | ||
let timeout = 60000; | ||
let timeoutId; | ||
@@ -474,4 +474,10 @@ const scripts = document.getElementsByTagName('script'); | ||
event)=>{ | ||
var _info_cb; | ||
clearTimeout(timeoutId); | ||
const onScriptCompleteCallback = ()=>{ | ||
if (event.type === 'error') { | ||
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event)); | ||
} else { | ||
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb()); | ||
} | ||
}; | ||
// Prevent memory leaks in IE. | ||
@@ -488,15 +494,13 @@ if (script) { | ||
if (prev && typeof prev === 'function') { | ||
var _info_cb1; | ||
const result = prev(event); | ||
if (result instanceof Promise) { | ||
var _info_cb2; | ||
const res = await result; | ||
info == null ? void 0 : (_info_cb2 = info.cb) == null ? void 0 : _info_cb2.call(info); | ||
onScriptCompleteCallback(); | ||
return res; | ||
} | ||
info == null ? void 0 : (_info_cb1 = info.cb) == null ? void 0 : _info_cb1.call(info); | ||
onScriptCompleteCallback(); | ||
return result; | ||
} | ||
} | ||
info == null ? void 0 : (_info_cb = info.cb) == null ? void 0 : _info_cb.call(info); | ||
onScriptCompleteCallback(); | ||
}; | ||
@@ -550,2 +554,9 @@ script.onerror = onScriptComplete.bind(null, script.onerror); | ||
event)=>{ | ||
const onLinkCompleteCallback = ()=>{ | ||
if (event.type === 'error') { | ||
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event)); | ||
} else { | ||
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb()); | ||
} | ||
}; | ||
// Prevent memory leaks in IE. | ||
@@ -564,7 +575,7 @@ if (link) { | ||
const res = prev(event); | ||
info.cb(); | ||
onLinkCompleteCallback(); | ||
return res; | ||
} | ||
} | ||
info.cb(); | ||
onLinkCompleteCallback(); | ||
}; | ||
@@ -580,6 +591,7 @@ link.onerror = onLinkComplete.bind(null, link.onerror); | ||
const { attrs = {}, createScriptHook } = info; | ||
return new Promise((resolve, _reject)=>{ | ||
return new Promise((resolve, reject)=>{ | ||
const { script, needAttach } = createScript({ | ||
url, | ||
cb: resolve, | ||
onErrorCallback: reject, | ||
attrs: polyfills._extends({ | ||
@@ -586,0 +598,0 @@ fetchpriority: 'high' |
@@ -7,2 +7,3 @@ import { CreateScriptHookDom } from './types'; | ||
cb?: (value: void | PromiseLike<void>) => void; | ||
onErrorCallback?: (error: Error) => void; | ||
attrs?: Record<string, any>; | ||
@@ -17,3 +18,4 @@ needDeleteScript?: boolean; | ||
url: string; | ||
cb: (value: void | PromiseLike<void>) => void; | ||
cb?: (value: void | PromiseLike<void>) => void; | ||
onErrorCallback?: (error: Error) => void; | ||
attrs: Record<string, string>; | ||
@@ -20,0 +22,0 @@ needDeleteLink?: boolean; |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20241212120314", | ||
"version": "0.0.0-next-20241212123451", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A sdk for support module federation", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104296
2637