@module-federation/sdk 0.8.6 → 0.8.8
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.js
CHANGED
|
@@ -470,8 +470,14 @@ function createScript(info) {
|
|
|
470
470
|
}
|
|
471
471
|
const onScriptComplete = async (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
472
472
|
event)=>{
|
|
473
|
-
var _info_cb;
|
|
474
473
|
clearTimeout(timeoutId);
|
|
474
|
+
const onScriptCompleteCallback = ()=>{
|
|
475
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
476
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
477
|
+
} else {
|
|
478
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
479
|
+
}
|
|
480
|
+
};
|
|
475
481
|
// Prevent memory leaks in IE.
|
|
476
482
|
if (script) {
|
|
477
483
|
script.onerror = null;
|
|
@@ -483,19 +489,17 @@ function createScript(info) {
|
|
|
483
489
|
}
|
|
484
490
|
});
|
|
485
491
|
if (prev && typeof prev === 'function') {
|
|
486
|
-
var _info_cb1;
|
|
487
492
|
const result = prev(event);
|
|
488
493
|
if (result instanceof Promise) {
|
|
489
|
-
var _info_cb2;
|
|
490
494
|
const res = await result;
|
|
491
|
-
|
|
495
|
+
onScriptCompleteCallback();
|
|
492
496
|
return res;
|
|
493
497
|
}
|
|
494
|
-
|
|
498
|
+
onScriptCompleteCallback();
|
|
495
499
|
return result;
|
|
496
500
|
}
|
|
497
501
|
}
|
|
498
|
-
|
|
502
|
+
onScriptCompleteCallback();
|
|
499
503
|
};
|
|
500
504
|
script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
501
505
|
script.onload = onScriptComplete.bind(null, script.onload);
|
|
@@ -544,6 +548,13 @@ function createLink(info) {
|
|
|
544
548
|
}
|
|
545
549
|
const onLinkComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
546
550
|
event)=>{
|
|
551
|
+
const onLinkCompleteCallback = ()=>{
|
|
552
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
553
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
554
|
+
} else {
|
|
555
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
556
|
+
}
|
|
557
|
+
};
|
|
547
558
|
// Prevent memory leaks in IE.
|
|
548
559
|
if (link) {
|
|
549
560
|
link.onerror = null;
|
|
@@ -557,11 +568,11 @@ function createLink(info) {
|
|
|
557
568
|
if (prev) {
|
|
558
569
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
559
570
|
const res = prev(event);
|
|
560
|
-
|
|
571
|
+
onLinkCompleteCallback();
|
|
561
572
|
return res;
|
|
562
573
|
}
|
|
563
574
|
}
|
|
564
|
-
|
|
575
|
+
onLinkCompleteCallback();
|
|
565
576
|
};
|
|
566
577
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
567
578
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
@@ -572,10 +583,11 @@ function createLink(info) {
|
|
|
572
583
|
}
|
|
573
584
|
function loadScript(url, info) {
|
|
574
585
|
const { attrs = {}, createScriptHook } = info;
|
|
575
|
-
return new Promise((resolve,
|
|
586
|
+
return new Promise((resolve, reject)=>{
|
|
576
587
|
const { script, needAttach } = createScript({
|
|
577
588
|
url,
|
|
578
589
|
cb: resolve,
|
|
590
|
+
onErrorCallback: reject,
|
|
579
591
|
attrs: polyfills._extends({
|
|
580
592
|
fetchpriority: 'high'
|
|
581
593
|
}, attrs),
|
package/dist/index.esm.mjs
CHANGED
|
@@ -468,8 +468,14 @@ function createScript(info) {
|
|
|
468
468
|
}
|
|
469
469
|
const onScriptComplete = async (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
470
470
|
event)=>{
|
|
471
|
-
var _info_cb;
|
|
472
471
|
clearTimeout(timeoutId);
|
|
472
|
+
const onScriptCompleteCallback = ()=>{
|
|
473
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
474
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
475
|
+
} else {
|
|
476
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
477
|
+
}
|
|
478
|
+
};
|
|
473
479
|
// Prevent memory leaks in IE.
|
|
474
480
|
if (script) {
|
|
475
481
|
script.onerror = null;
|
|
@@ -481,19 +487,17 @@ function createScript(info) {
|
|
|
481
487
|
}
|
|
482
488
|
});
|
|
483
489
|
if (prev && typeof prev === 'function') {
|
|
484
|
-
var _info_cb1;
|
|
485
490
|
const result = prev(event);
|
|
486
491
|
if (result instanceof Promise) {
|
|
487
|
-
var _info_cb2;
|
|
488
492
|
const res = await result;
|
|
489
|
-
|
|
493
|
+
onScriptCompleteCallback();
|
|
490
494
|
return res;
|
|
491
495
|
}
|
|
492
|
-
|
|
496
|
+
onScriptCompleteCallback();
|
|
493
497
|
return result;
|
|
494
498
|
}
|
|
495
499
|
}
|
|
496
|
-
|
|
500
|
+
onScriptCompleteCallback();
|
|
497
501
|
};
|
|
498
502
|
script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
499
503
|
script.onload = onScriptComplete.bind(null, script.onload);
|
|
@@ -542,6 +546,13 @@ function createLink(info) {
|
|
|
542
546
|
}
|
|
543
547
|
const onLinkComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
544
548
|
event)=>{
|
|
549
|
+
const onLinkCompleteCallback = ()=>{
|
|
550
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
551
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
552
|
+
} else {
|
|
553
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
554
|
+
}
|
|
555
|
+
};
|
|
545
556
|
// Prevent memory leaks in IE.
|
|
546
557
|
if (link) {
|
|
547
558
|
link.onerror = null;
|
|
@@ -555,11 +566,11 @@ function createLink(info) {
|
|
|
555
566
|
if (prev) {
|
|
556
567
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
557
568
|
const res = prev(event);
|
|
558
|
-
|
|
569
|
+
onLinkCompleteCallback();
|
|
559
570
|
return res;
|
|
560
571
|
}
|
|
561
572
|
}
|
|
562
|
-
|
|
573
|
+
onLinkCompleteCallback();
|
|
563
574
|
};
|
|
564
575
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
565
576
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
@@ -570,10 +581,11 @@ function createLink(info) {
|
|
|
570
581
|
}
|
|
571
582
|
function loadScript(url, info) {
|
|
572
583
|
const { attrs = {}, createScriptHook } = info;
|
|
573
|
-
return new Promise((resolve,
|
|
584
|
+
return new Promise((resolve, reject)=>{
|
|
574
585
|
const { script, needAttach } = createScript({
|
|
575
586
|
url,
|
|
576
587
|
cb: resolve,
|
|
588
|
+
onErrorCallback: reject,
|
|
577
589
|
attrs: _extends({
|
|
578
590
|
fetchpriority: 'high'
|
|
579
591
|
}, attrs),
|
package/dist/src/dom.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function isStaticResourcesEqual(url1: string, url2: string): bool
|
|
|
4
4
|
export declare function createScript(info: {
|
|
5
5
|
url: string;
|
|
6
6
|
cb?: (value: void | PromiseLike<void>) => void;
|
|
7
|
+
onErrorCallback?: (error: Error) => void;
|
|
7
8
|
attrs?: Record<string, any>;
|
|
8
9
|
needDeleteScript?: boolean;
|
|
9
10
|
createScriptHook?: CreateScriptHookDom;
|
|
@@ -13,7 +14,8 @@ export declare function createScript(info: {
|
|
|
13
14
|
};
|
|
14
15
|
export declare function createLink(info: {
|
|
15
16
|
url: string;
|
|
16
|
-
cb
|
|
17
|
+
cb?: (value: void | PromiseLike<void>) => void;
|
|
18
|
+
onErrorCallback?: (error: Error) => void;
|
|
17
19
|
attrs: Record<string, string>;
|
|
18
20
|
needDeleteLink?: boolean;
|
|
19
21
|
createLinkHook?: (url: string, attrs?: Record<string, any>) => HTMLLinkElement | void;
|