@module-federation/sdk 0.0.0-next-20240815093707 → 0.0.0-next-20240815094326
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 +7 -13
- package/dist/index.esm.js +7 -13
- package/dist/package.json +1 -1
- package/dist/src/dom.d.ts +7 -4
- package/dist/src/node.d.ts +2 -3
- package/dist/src/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/src/types/hooks.d.ts +0 -11
package/dist/index.cjs.js
CHANGED
|
@@ -435,22 +435,17 @@ function createScript(info) {
|
|
|
435
435
|
script = document.createElement('script');
|
|
436
436
|
script.type = 'text/javascript';
|
|
437
437
|
script.src = info.url;
|
|
438
|
-
let createScriptRes = undefined;
|
|
439
438
|
if (info.createScriptHook) {
|
|
440
|
-
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
439
|
+
const createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
441
440
|
if (createScriptRes instanceof HTMLScriptElement) {
|
|
442
441
|
script = createScriptRes;
|
|
443
442
|
} else if (typeof createScriptRes === 'object') {
|
|
444
|
-
if (
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
if ('timeout' in createScriptRes && createScriptRes.timeout) {
|
|
448
|
-
timeout = createScriptRes.timeout;
|
|
449
|
-
}
|
|
443
|
+
if (createScriptRes.script) script = createScriptRes.script;
|
|
444
|
+
if (createScriptRes.timeout) timeout = createScriptRes.timeout;
|
|
450
445
|
}
|
|
451
446
|
}
|
|
452
447
|
const attrs = info.attrs;
|
|
453
|
-
if (attrs
|
|
448
|
+
if (attrs) {
|
|
454
449
|
Object.keys(attrs).forEach((name)=>{
|
|
455
450
|
if (script) {
|
|
456
451
|
if (name === 'async' || name === 'defer') {
|
|
@@ -516,15 +511,14 @@ function createLink(info) {
|
|
|
516
511
|
if (!link) {
|
|
517
512
|
link = document.createElement('link');
|
|
518
513
|
link.setAttribute('href', info.url);
|
|
519
|
-
let createLinkRes = undefined;
|
|
520
|
-
const attrs = info.attrs;
|
|
521
514
|
if (info.createLinkHook) {
|
|
522
|
-
createLinkRes = info.createLinkHook(info.url
|
|
515
|
+
const createLinkRes = info.createLinkHook(info.url);
|
|
523
516
|
if (createLinkRes instanceof HTMLLinkElement) {
|
|
524
517
|
link = createLinkRes;
|
|
525
518
|
}
|
|
526
519
|
}
|
|
527
|
-
|
|
520
|
+
const attrs = info.attrs;
|
|
521
|
+
if (attrs) {
|
|
528
522
|
Object.keys(attrs).forEach((name)=>{
|
|
529
523
|
if (link && !link.getAttribute(name)) {
|
|
530
524
|
link.setAttribute(name, attrs[name]);
|
package/dist/index.esm.js
CHANGED
|
@@ -431,22 +431,17 @@ function createScript(info) {
|
|
|
431
431
|
script = document.createElement('script');
|
|
432
432
|
script.type = 'text/javascript';
|
|
433
433
|
script.src = info.url;
|
|
434
|
-
let createScriptRes = undefined;
|
|
435
434
|
if (info.createScriptHook) {
|
|
436
|
-
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
435
|
+
const createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
437
436
|
if (createScriptRes instanceof HTMLScriptElement) {
|
|
438
437
|
script = createScriptRes;
|
|
439
438
|
} else if (typeof createScriptRes === 'object') {
|
|
440
|
-
if (
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
if ('timeout' in createScriptRes && createScriptRes.timeout) {
|
|
444
|
-
timeout = createScriptRes.timeout;
|
|
445
|
-
}
|
|
439
|
+
if (createScriptRes.script) script = createScriptRes.script;
|
|
440
|
+
if (createScriptRes.timeout) timeout = createScriptRes.timeout;
|
|
446
441
|
}
|
|
447
442
|
}
|
|
448
443
|
const attrs = info.attrs;
|
|
449
|
-
if (attrs
|
|
444
|
+
if (attrs) {
|
|
450
445
|
Object.keys(attrs).forEach((name)=>{
|
|
451
446
|
if (script) {
|
|
452
447
|
if (name === 'async' || name === 'defer') {
|
|
@@ -512,15 +507,14 @@ function createLink(info) {
|
|
|
512
507
|
if (!link) {
|
|
513
508
|
link = document.createElement('link');
|
|
514
509
|
link.setAttribute('href', info.url);
|
|
515
|
-
let createLinkRes = undefined;
|
|
516
|
-
const attrs = info.attrs;
|
|
517
510
|
if (info.createLinkHook) {
|
|
518
|
-
createLinkRes = info.createLinkHook(info.url
|
|
511
|
+
const createLinkRes = info.createLinkHook(info.url);
|
|
519
512
|
if (createLinkRes instanceof HTMLLinkElement) {
|
|
520
513
|
link = createLinkRes;
|
|
521
514
|
}
|
|
522
515
|
}
|
|
523
|
-
|
|
516
|
+
const attrs = info.attrs;
|
|
517
|
+
if (attrs) {
|
|
524
518
|
Object.keys(attrs).forEach((name)=>{
|
|
525
519
|
if (link && !link.getAttribute(name)) {
|
|
526
520
|
link.setAttribute(name, attrs[name]);
|
package/dist/package.json
CHANGED
package/dist/src/dom.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { CreateScriptHookDom } from './types';
|
|
2
1
|
export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
|
|
3
2
|
export declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
|
|
3
|
+
export type CreateScriptHookReturn = HTMLScriptElement | {
|
|
4
|
+
script?: HTMLScriptElement;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
} | void;
|
|
4
7
|
export declare function createScript(info: {
|
|
5
8
|
url: string;
|
|
6
9
|
cb?: (value: void | PromiseLike<void>) => void;
|
|
7
10
|
attrs?: Record<string, any>;
|
|
8
11
|
needDeleteScript?: boolean;
|
|
9
|
-
createScriptHook?:
|
|
12
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
10
13
|
}): {
|
|
11
14
|
script: HTMLScriptElement;
|
|
12
15
|
needAttach: boolean;
|
|
@@ -16,12 +19,12 @@ export declare function createLink(info: {
|
|
|
16
19
|
cb: (value: void | PromiseLike<void>) => void;
|
|
17
20
|
attrs: Record<string, string>;
|
|
18
21
|
needDeleteLink?: boolean;
|
|
19
|
-
createLinkHook?: (url: string
|
|
22
|
+
createLinkHook?: (url: string) => HTMLLinkElement | void;
|
|
20
23
|
}): {
|
|
21
24
|
link: HTMLLinkElement;
|
|
22
25
|
needAttach: boolean;
|
|
23
26
|
};
|
|
24
27
|
export declare function loadScript(url: string, info: {
|
|
25
28
|
attrs?: Record<string, any>;
|
|
26
|
-
createScriptHook?:
|
|
29
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
27
30
|
}): Promise<void>;
|
package/dist/src/node.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: CreateScriptHookNode): void;
|
|
1
|
+
export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => any | void): void;
|
|
3
2
|
export declare function loadScriptNode(url: string, info: {
|
|
4
3
|
attrs?: Record<string, any>;
|
|
5
|
-
createScriptHook?:
|
|
4
|
+
createScriptHook?: (url: string) => void;
|
|
6
5
|
}): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type CreateScriptHookReturnNode = {
|
|
2
|
-
url: string;
|
|
3
|
-
} | void;
|
|
4
|
-
export type CreateScriptHookReturnDom = HTMLScriptElement | {
|
|
5
|
-
script?: HTMLScriptElement;
|
|
6
|
-
timeout?: number;
|
|
7
|
-
} | void;
|
|
8
|
-
export type CreateScriptHookReturn = CreateScriptHookReturnNode | CreateScriptHookReturnDom;
|
|
9
|
-
export type CreateScriptHookNode = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnNode;
|
|
10
|
-
export type CreateScriptHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnDom;
|
|
11
|
-
export type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|