@module-federation/sdk 0.4.0 → 0.5.0

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
@@ -441,8 +441,12 @@ function createScript(info) {
441
441
  if (createScriptRes instanceof HTMLScriptElement) {
442
442
  script = createScriptRes;
443
443
  } else if (typeof createScriptRes === 'object') {
444
- if (createScriptRes.script) script = createScriptRes.script;
445
- if (createScriptRes.timeout) timeout = createScriptRes.timeout;
444
+ if ('script' in createScriptRes && createScriptRes.script) {
445
+ script = createScriptRes.script;
446
+ }
447
+ if ('timeout' in createScriptRes && createScriptRes.timeout) {
448
+ timeout = createScriptRes.timeout;
449
+ }
446
450
  }
447
451
  }
448
452
  const attrs = info.attrs;
package/dist/index.esm.js CHANGED
@@ -437,8 +437,12 @@ function createScript(info) {
437
437
  if (createScriptRes instanceof HTMLScriptElement) {
438
438
  script = createScriptRes;
439
439
  } else if (typeof createScriptRes === 'object') {
440
- if (createScriptRes.script) script = createScriptRes.script;
441
- if (createScriptRes.timeout) timeout = createScriptRes.timeout;
440
+ if ('script' in createScriptRes && createScriptRes.script) {
441
+ script = createScriptRes.script;
442
+ }
443
+ if ('timeout' in createScriptRes && createScriptRes.timeout) {
444
+ timeout = createScriptRes.timeout;
445
+ }
442
446
  }
443
447
  }
444
448
  const attrs = info.attrs;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
package/dist/src/dom.d.ts CHANGED
@@ -1,15 +1,12 @@
1
+ import { CreateScriptHookDom } from './types';
1
2
  export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
2
3
  export declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
3
- export type CreateScriptHookReturn = HTMLScriptElement | {
4
- script?: HTMLScriptElement;
5
- timeout?: number;
6
- } | void;
7
4
  export declare function createScript(info: {
8
5
  url: string;
9
6
  cb?: (value: void | PromiseLike<void>) => void;
10
7
  attrs?: Record<string, any>;
11
8
  needDeleteScript?: boolean;
12
- createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
9
+ createScriptHook?: CreateScriptHookDom;
13
10
  }): {
14
11
  script: HTMLScriptElement;
15
12
  needAttach: boolean;
@@ -26,5 +23,5 @@ export declare function createLink(info: {
26
23
  };
27
24
  export declare function loadScript(url: string, info: {
28
25
  attrs?: Record<string, any>;
29
- createScriptHook?: (url: string, attrs?: Record<string, any>) => CreateScriptHookReturn;
26
+ createScriptHook?: CreateScriptHookDom;
30
27
  }): Promise<void>;
@@ -1,5 +1,6 @@
1
- export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => any | void): void;
1
+ import { CreateScriptHookNode } from './types';
2
+ export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: CreateScriptHookNode): void;
2
3
  export declare function loadScriptNode(url: string, info: {
3
4
  attrs?: Record<string, any>;
4
- createScriptHook?: (url: string) => void;
5
+ createScriptHook?: CreateScriptHookNode;
5
6
  }): Promise<void>;
@@ -0,0 +1,11 @@
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;
@@ -3,3 +3,4 @@ export * from './manifest';
3
3
  export * from './stats';
4
4
  export * from './snapshot';
5
5
  export * from './plugins';
6
+ export * from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [