@zstackui/qiankun 2.6.3-beta-5

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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +116 -0
  3. package/dist/index.umd.js +8681 -0
  4. package/dist/index.umd.js.map +1 -0
  5. package/dist/index.umd.min.js +4 -0
  6. package/dist/index.umd.min.js.map +1 -0
  7. package/dist/src/__tests__/globalState.test.d.ts +5 -0
  8. package/dist/src/__tests__/utils.test.d.ts +1 -0
  9. package/dist/src/addons/engineFlag.d.ts +6 -0
  10. package/dist/src/addons/index.d.ts +6 -0
  11. package/dist/src/addons/runtimePublicPath.d.ts +6 -0
  12. package/dist/src/apis.d.ts +7 -0
  13. package/dist/src/effects.d.ts +3 -0
  14. package/dist/src/error.d.ts +3 -0
  15. package/dist/src/errorHandler.d.ts +7 -0
  16. package/dist/src/globalState.d.ts +7 -0
  17. package/dist/src/index.d.ts +11 -0
  18. package/dist/src/interfaces.d.ts +107 -0
  19. package/dist/src/loader.d.ts +8 -0
  20. package/dist/src/prefetch.d.ts +14 -0
  21. package/dist/src/sandbox/__tests__/common.test.d.ts +5 -0
  22. package/dist/src/sandbox/__tests__/proxySandbox.test.d.ts +10 -0
  23. package/dist/src/sandbox/common.d.ts +21 -0
  24. package/dist/src/sandbox/index.d.ts +40 -0
  25. package/dist/src/sandbox/legacy/__tests__/sandbox.test.d.ts +5 -0
  26. package/dist/src/sandbox/legacy/sandbox.d.ts +28 -0
  27. package/dist/src/sandbox/patchers/__tests__/css.test.d.ts +5 -0
  28. package/dist/src/sandbox/patchers/__tests__/interval.test.d.ts +5 -0
  29. package/dist/src/sandbox/patchers/css.d.ts +17 -0
  30. package/dist/src/sandbox/patchers/dynamicAppend/__tests__/common.test.d.ts +1 -0
  31. package/dist/src/sandbox/patchers/dynamicAppend/common.d.ts +22 -0
  32. package/dist/src/sandbox/patchers/dynamicAppend/forLooseSandbox.d.ts +17 -0
  33. package/dist/src/sandbox/patchers/dynamicAppend/forStrictSandbox.d.ts +12 -0
  34. package/dist/src/sandbox/patchers/dynamicAppend/index.d.ts +6 -0
  35. package/dist/src/sandbox/patchers/historyListener.d.ts +5 -0
  36. package/dist/src/sandbox/patchers/index.d.ts +9 -0
  37. package/dist/src/sandbox/patchers/interval.d.ts +5 -0
  38. package/dist/src/sandbox/patchers/windowListener.d.ts +5 -0
  39. package/dist/src/sandbox/proxySandbox.d.ts +23 -0
  40. package/dist/src/sandbox/snapshotSandbox.d.ts +20 -0
  41. package/dist/src/utils.d.ts +44 -0
  42. package/dist/src/version.d.ts +1 -0
  43. package/es/addons/engineFlag.d.ts +6 -0
  44. package/es/addons/engineFlag.js +50 -0
  45. package/es/addons/index.d.ts +6 -0
  46. package/es/addons/index.js +13 -0
  47. package/es/addons/runtimePublicPath.d.ts +6 -0
  48. package/es/addons/runtimePublicPath.js +57 -0
  49. package/es/apis.d.ts +7 -0
  50. package/es/apis.js +278 -0
  51. package/es/effects.d.ts +3 -0
  52. package/es/effects.js +33 -0
  53. package/es/error.d.ts +3 -0
  54. package/es/error.js +16 -0
  55. package/es/errorHandler.d.ts +7 -0
  56. package/es/errorHandler.js +13 -0
  57. package/es/globalState.d.ts +7 -0
  58. package/es/globalState.js +101 -0
  59. package/es/index.d.ts +11 -0
  60. package/es/index.js +11 -0
  61. package/es/interfaces.d.ts +107 -0
  62. package/es/interfaces.js +8 -0
  63. package/es/loader.d.ts +8 -0
  64. package/es/loader.js +600 -0
  65. package/es/prefetch.d.ts +14 -0
  66. package/es/prefetch.js +125 -0
  67. package/es/sandbox/common.d.ts +21 -0
  68. package/es/sandbox/common.js +157 -0
  69. package/es/sandbox/index.d.ts +40 -0
  70. package/es/sandbox/index.js +105 -0
  71. package/es/sandbox/legacy/sandbox.d.ts +28 -0
  72. package/es/sandbox/legacy/sandbox.js +142 -0
  73. package/es/sandbox/patchers/css.d.ts +17 -0
  74. package/es/sandbox/patchers/css.js +186 -0
  75. package/es/sandbox/patchers/dynamicAppend/common.d.ts +22 -0
  76. package/es/sandbox/patchers/dynamicAppend/common.js +306 -0
  77. package/es/sandbox/patchers/dynamicAppend/forLooseSandbox.d.ts +17 -0
  78. package/es/sandbox/patchers/dynamicAppend/forLooseSandbox.js +77 -0
  79. package/es/sandbox/patchers/dynamicAppend/forStrictSandbox.d.ts +12 -0
  80. package/es/sandbox/patchers/dynamicAppend/forStrictSandbox.js +103 -0
  81. package/es/sandbox/patchers/dynamicAppend/index.d.ts +6 -0
  82. package/es/sandbox/patchers/dynamicAppend/index.js +6 -0
  83. package/es/sandbox/patchers/historyListener.d.ts +5 -0
  84. package/es/sandbox/patchers/historyListener.js +54 -0
  85. package/es/sandbox/patchers/index.d.ts +9 -0
  86. package/es/sandbox/patchers/index.js +45 -0
  87. package/es/sandbox/patchers/interval.d.ts +5 -0
  88. package/es/sandbox/patchers/interval.js +34 -0
  89. package/es/sandbox/patchers/windowListener.d.ts +5 -0
  90. package/es/sandbox/patchers/windowListener.js +34 -0
  91. package/es/sandbox/proxySandbox.d.ts +23 -0
  92. package/es/sandbox/proxySandbox.js +315 -0
  93. package/es/sandbox/snapshotSandbox.d.ts +20 -0
  94. package/es/sandbox/snapshotSandbox.js +59 -0
  95. package/es/utils.d.ts +44 -0
  96. package/es/utils.js +215 -0
  97. package/es/version.d.ts +1 -0
  98. package/es/version.js +1 -0
  99. package/lib/addons/engineFlag.d.ts +6 -0
  100. package/lib/addons/engineFlag.js +55 -0
  101. package/lib/addons/index.d.ts +6 -0
  102. package/lib/addons/index.js +21 -0
  103. package/lib/addons/runtimePublicPath.d.ts +6 -0
  104. package/lib/addons/runtimePublicPath.js +63 -0
  105. package/lib/apis.d.ts +7 -0
  106. package/lib/apis.js +288 -0
  107. package/lib/effects.d.ts +3 -0
  108. package/lib/effects.js +42 -0
  109. package/lib/error.d.ts +3 -0
  110. package/lib/error.js +23 -0
  111. package/lib/errorHandler.d.ts +7 -0
  112. package/lib/errorHandler.js +33 -0
  113. package/lib/globalState.d.ts +7 -0
  114. package/lib/globalState.js +110 -0
  115. package/lib/index.d.ts +11 -0
  116. package/lib/index.js +89 -0
  117. package/lib/interfaces.d.ts +107 -0
  118. package/lib/interfaces.js +14 -0
  119. package/lib/loader.d.ts +8 -0
  120. package/lib/loader.js +606 -0
  121. package/lib/prefetch.d.ts +14 -0
  122. package/lib/prefetch.js +132 -0
  123. package/lib/sandbox/common.d.ts +21 -0
  124. package/lib/sandbox/common.js +169 -0
  125. package/lib/sandbox/index.d.ts +40 -0
  126. package/lib/sandbox/index.js +123 -0
  127. package/lib/sandbox/legacy/sandbox.d.ts +28 -0
  128. package/lib/sandbox/legacy/sandbox.js +148 -0
  129. package/lib/sandbox/patchers/css.d.ts +17 -0
  130. package/lib/sandbox/patchers/css.js +193 -0
  131. package/lib/sandbox/patchers/dynamicAppend/common.d.ts +22 -0
  132. package/lib/sandbox/patchers/dynamicAppend/common.js +322 -0
  133. package/lib/sandbox/patchers/dynamicAppend/forLooseSandbox.d.ts +17 -0
  134. package/lib/sandbox/patchers/dynamicAppend/forLooseSandbox.js +84 -0
  135. package/lib/sandbox/patchers/dynamicAppend/forStrictSandbox.d.ts +12 -0
  136. package/lib/sandbox/patchers/dynamicAppend/forStrictSandbox.js +110 -0
  137. package/lib/sandbox/patchers/dynamicAppend/index.d.ts +6 -0
  138. package/lib/sandbox/patchers/dynamicAppend/index.js +19 -0
  139. package/lib/sandbox/patchers/historyListener.d.ts +5 -0
  140. package/lib/sandbox/patchers/historyListener.js +62 -0
  141. package/lib/sandbox/patchers/index.d.ts +9 -0
  142. package/lib/sandbox/patchers/index.js +57 -0
  143. package/lib/sandbox/patchers/interval.d.ts +5 -0
  144. package/lib/sandbox/patchers/interval.js +42 -0
  145. package/lib/sandbox/patchers/windowListener.d.ts +5 -0
  146. package/lib/sandbox/patchers/windowListener.js +42 -0
  147. package/lib/sandbox/proxySandbox.d.ts +23 -0
  148. package/lib/sandbox/proxySandbox.js +321 -0
  149. package/lib/sandbox/snapshotSandbox.d.ts +20 -0
  150. package/lib/sandbox/snapshotSandbox.js +65 -0
  151. package/lib/utils.d.ts +44 -0
  152. package/lib/utils.js +240 -0
  153. package/lib/version.d.ts +1 -0
  154. package/lib/version.js +7 -0
  155. package/package.json +137 -0
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author dbkillerf6
3
+ * @since 2020-04-10
4
+ */
5
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-05-15
4
+ */
5
+ import type { FrameworkLifeCycles } from '../interfaces';
6
+ export default function getAddOn(global: Window): FrameworkLifeCycles<any>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-03-02
4
+ */
5
+ import type { FrameworkLifeCycles, ObjectType } from '../interfaces';
6
+ export default function getAddOns<T extends ObjectType>(global: Window, publicPath: string): FrameworkLifeCycles<T>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-11-12
4
+ */
5
+ import type { FrameworkLifeCycles } from '../interfaces';
6
+ export default function getAddOn(global: Window, publicPath?: string): FrameworkLifeCycles<any>;
@@ -0,0 +1,7 @@
1
+ import type { FrameworkConfiguration, FrameworkLifeCycles, LoadableApp, MicroApp, ObjectType, RegistrableApp } from './interfaces';
2
+ export declare let frameworkConfiguration: FrameworkConfiguration;
3
+ export declare function registerMicroApps<T extends ObjectType>(apps: Array<RegistrableApp<T>>, lifeCycles?: FrameworkLifeCycles<T>): void;
4
+ export declare function loadMicroApp<T extends ObjectType>(app: LoadableApp<T>, configuration?: FrameworkConfiguration & {
5
+ autoStart?: boolean;
6
+ }, lifeCycles?: FrameworkLifeCycles<T>): MicroApp;
7
+ export declare function start(opts?: FrameworkConfiguration): void;
@@ -0,0 +1,3 @@
1
+ export declare function setDefaultMountApp(defaultAppLink: string): void;
2
+ export declare function runDefaultMountEffects(defaultAppLink: string): void;
3
+ export declare function runAfterFirstMounted(effect: () => void): void;
@@ -0,0 +1,3 @@
1
+ export declare class QiankunError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-02-21
4
+ */
5
+ export { addErrorHandler, removeErrorHandler } from 'single-spa';
6
+ export declare function addGlobalUncaughtErrorHandler(errorHandler: OnErrorEventHandlerNonNull): void;
7
+ export declare function removeGlobalUncaughtErrorHandler(errorHandler: (...args: any[]) => any): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author dbkillerf6
3
+ * @since 2020-04-10
4
+ */
5
+ import type { MicroAppStateActions } from './interfaces';
6
+ export declare function initGlobalState(state?: Record<string, any>): MicroAppStateActions;
7
+ export declare function getMicroAppStateActions(id: string, isMaster?: boolean): MicroAppStateActions;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-25
4
+ */
5
+ export { loadMicroApp, registerMicroApps, start } from './apis';
6
+ export { initGlobalState } from './globalState';
7
+ export { getCurrentRunningApp as __internalGetCurrentRunningApp } from './sandbox';
8
+ export * from './errorHandler';
9
+ export * from './effects';
10
+ export * from './interfaces';
11
+ export { prefetchImmediately as prefetchApps } from './prefetch';
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @author kuitos
3
+ * @since 2019-05-16
4
+ */
5
+ import type { ImportEntryOpts } from 'import-html-entry';
6
+ import type { RegisterApplicationConfig, StartOpts, Parcel } from 'single-spa';
7
+ declare global {
8
+ interface Window {
9
+ __POWERED_BY_QIANKUN__?: boolean;
10
+ __INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string;
11
+ __QIANKUN_DEVELOPMENT__?: boolean;
12
+ Zone?: CallableFunction;
13
+ }
14
+ }
15
+ export type ObjectType = Record<string, any>;
16
+ export type Entry = string | {
17
+ scripts?: string[];
18
+ styles?: string[];
19
+ html?: string;
20
+ };
21
+ export type HTMLContentRender = (props: {
22
+ appContent: string;
23
+ loading: boolean;
24
+ }) => any;
25
+ export type AppMetadata = {
26
+ name: string;
27
+ entry: Entry;
28
+ };
29
+ export type LoadableApp<T extends ObjectType> = AppMetadata & {
30
+ props?: T;
31
+ } & ({
32
+ render: HTMLContentRender;
33
+ } | {
34
+ container: string | HTMLElement;
35
+ });
36
+ export type RegistrableApp<T extends ObjectType> = LoadableApp<T> & {
37
+ loader?: (loading: boolean) => void;
38
+ activeRule: RegisterApplicationConfig['activeWhen'];
39
+ };
40
+ export type PrefetchStrategy = boolean | 'all' | string[] | ((apps: AppMetadata[]) => {
41
+ criticalAppNames: string[];
42
+ minorAppsName: string[];
43
+ });
44
+ type QiankunSpecialOpts = {
45
+ /**
46
+ * @deprecated internal api, don't used it as normal, might be removed after next version
47
+ */
48
+ $$cacheLifecycleByAppName?: boolean;
49
+ prefetch?: PrefetchStrategy;
50
+ sandbox?: boolean | {
51
+ strictStyleIsolation?: boolean;
52
+ experimentalStyleIsolation?: boolean;
53
+ /**
54
+ * @deprecated We use strict mode by default
55
+ */
56
+ loose?: boolean;
57
+ patchers?: Patcher[];
58
+ };
59
+ singular?: boolean | ((app: LoadableApp<any>) => Promise<boolean>);
60
+ /**
61
+ * skip some scripts or links intercept, like JSONP
62
+ */
63
+ excludeAssetFilter?: (url: string) => boolean;
64
+ transformStorage?: boolean;
65
+ globalContext?: typeof window;
66
+ };
67
+ export type FrameworkConfiguration = QiankunSpecialOpts & ImportEntryOpts & StartOpts;
68
+ export type LifeCycleFn<T extends ObjectType> = (app: LoadableApp<T>, global: typeof window) => Promise<any>;
69
+ export type FrameworkLifeCycles<T extends ObjectType> = {
70
+ beforeLoad?: LifeCycleFn<T> | Array<LifeCycleFn<T>>;
71
+ beforeMount?: LifeCycleFn<T> | Array<LifeCycleFn<T>>;
72
+ afterMount?: LifeCycleFn<T> | Array<LifeCycleFn<T>>;
73
+ beforeUnmount?: LifeCycleFn<T> | Array<LifeCycleFn<T>>;
74
+ afterUnmount?: LifeCycleFn<T> | Array<LifeCycleFn<T>>;
75
+ };
76
+ export type MicroApp = Parcel;
77
+ export type Rebuilder = () => void;
78
+ export type Freer = () => Rebuilder;
79
+ export type Patcher = () => Freer;
80
+ export declare enum SandBoxType {
81
+ Proxy = "Proxy",
82
+ Snapshot = "Snapshot",
83
+ LegacyProxy = "LegacyProxy"
84
+ }
85
+ export type SandBox = {
86
+ /** 沙箱的名字 */
87
+ name: string;
88
+ /** 沙箱的类型 */
89
+ type: SandBoxType;
90
+ /** 沙箱导出的代理实体 */
91
+ proxy: WindowProxy;
92
+ /** 沙箱是否在运行中 */
93
+ sandboxRunning: boolean;
94
+ /** latest set property */
95
+ latestSetProp?: PropertyKey | null;
96
+ /** 启动沙箱 */
97
+ active: () => void;
98
+ /** 关闭沙箱 */
99
+ inactive: () => void;
100
+ };
101
+ export type OnGlobalStateChangeCallback = (state: Record<string, any>, prevState: Record<string, any>) => void;
102
+ export type MicroAppStateActions = {
103
+ onGlobalStateChange: (callback: OnGlobalStateChangeCallback, fireImmediately?: boolean) => void;
104
+ setGlobalState: (state: Record<string, any>) => boolean;
105
+ offGlobalStateChange: () => boolean;
106
+ };
107
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-04-01
4
+ */
5
+ import type { ParcelConfigObject } from 'single-spa';
6
+ import type { FrameworkConfiguration, FrameworkLifeCycles, LoadableApp, ObjectType } from './interfaces';
7
+ export type ParcelConfigObjectGetter = (remountContainer?: string | HTMLElement) => ParcelConfigObject;
8
+ export declare function loadApp<T extends ObjectType>(app: LoadableApp<T>, configuration?: FrameworkConfiguration, lifeCycles?: FrameworkLifeCycles<T>): Promise<ParcelConfigObjectGetter>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-02-26
4
+ */
5
+ import type { ImportEntryOpts } from 'import-html-entry';
6
+ import type { AppMetadata, PrefetchStrategy } from './interfaces';
7
+ declare global {
8
+ interface NetworkInformation {
9
+ saveData: boolean;
10
+ effectiveType: string;
11
+ }
12
+ }
13
+ export declare function prefetchImmediately(apps: AppMetadata[], opts?: ImportEntryOpts): void;
14
+ export declare function doPrefetchStrategy(apps: AppMetadata[], prefetchStrategy: PrefetchStrategy, importEntryOpts?: ImportEntryOpts): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2021-04-12
4
+ */
5
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-03-31
4
+ */
5
+ declare global {
6
+ interface Window extends Record<string, any> {
7
+ nonEnumerableValue: string;
8
+ }
9
+ }
10
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-04-13
4
+ */
5
+ type AppInstance = {
6
+ name: string;
7
+ window: WindowProxy;
8
+ };
9
+ /**
10
+ * get the app that running tasks at current tick
11
+ */
12
+ export declare function getCurrentRunningApp(): AppInstance | null;
13
+ export declare function setCurrentRunningApp(appInstance: {
14
+ name: string;
15
+ window: WindowProxy;
16
+ } | null): void;
17
+ export declare function getTargetValue(target: any, value: any): any;
18
+ export declare function getProxyPropertyValue(getter: CallableFunction): any;
19
+ export declare function getZsLocalStorage(_proxyName: string): any;
20
+ export declare function getZsSessionStorage(_proxyName: string): any;
21
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ import type { SandBox } from '../interfaces';
6
+ export { css } from './patchers';
7
+ export { getCurrentRunningApp } from './common';
8
+ /**
9
+ * 生成应用运行时沙箱
10
+ *
11
+ * 沙箱分两个类型:
12
+ * 1. app 环境沙箱
13
+ * app 环境沙箱是指应用初始化过之后,应用会在什么样的上下文环境运行。每个应用的环境沙箱只会初始化一次,因为子应用只会触发一次 bootstrap 。
14
+ * 子应用在切换时,实际上切换的是 app 环境沙箱。
15
+ * 2. render 沙箱
16
+ * 子应用在 app mount 开始前生成好的的沙箱。每次子应用切换过后,render 沙箱都会重现初始化。
17
+ *
18
+ * 这么设计的目的是为了保证每个子应用切换回来之后,还能运行在应用 bootstrap 之后的环境下。
19
+ *
20
+ * @param appName
21
+ * @param elementGetter
22
+ * @param scopedCSS
23
+ * @param useLooseSandbox
24
+ * @param excludeAssetFilter
25
+ * @param globalContext
26
+ * @param transformStorage
27
+ */
28
+ export declare function createSandboxContainer(appName: string, elementGetter: () => HTMLElement | ShadowRoot, scopedCSS: boolean, useLooseSandbox?: boolean, excludeAssetFilter?: (url: string) => boolean, globalContext?: typeof window, transformStorage?: boolean): {
29
+ instance: SandBox;
30
+ /**
31
+ * 沙箱被 mount
32
+ * 可能是从 bootstrap 状态进入的 mount
33
+ * 也可能是从 unmount 之后再次唤醒进入 mount
34
+ */
35
+ mount(): Promise<void>;
36
+ /**
37
+ * 恢复 global 状态,使其能回到应用加载之前的状态
38
+ */
39
+ unmount(): Promise<void>;
40
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2021-07-19
4
+ */
5
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ import type { SandBox } from '../../interfaces';
6
+ import { SandBoxType } from '../../interfaces';
7
+ /**
8
+ * 基于 Proxy 实现的沙箱
9
+ * TODO: 为了兼容性 singular 模式下依旧使用该沙箱,等新沙箱稳定之后再切换
10
+ */
11
+ export default class LegacySandbox implements SandBox {
12
+ /** 沙箱期间新增的全局变量 */
13
+ private addedPropsMapInSandbox;
14
+ /** 沙箱期间更新的全局变量 */
15
+ private modifiedPropsOriginalValueMapInSandbox;
16
+ /** 持续记录更新的(新增和修改的)全局变量的 map,用于在任意时刻做 snapshot */
17
+ private currentUpdatedPropsValueMap;
18
+ name: string;
19
+ proxy: WindowProxy;
20
+ globalContext: typeof window;
21
+ type: SandBoxType;
22
+ sandboxRunning: boolean;
23
+ latestSetProp: PropertyKey | null;
24
+ private setWindowProp;
25
+ active(): void;
26
+ inactive(): void;
27
+ constructor(name: string, globalContext?: Window & typeof globalThis);
28
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Saviio
3
+ * @since 2020-04-19
4
+ */
5
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-03-30
4
+ */
5
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @author Saviio
3
+ * @since 2020-4-19
4
+ */
5
+ export declare class ScopedCSS {
6
+ private static ModifiedTag;
7
+ private sheet;
8
+ private swapNode;
9
+ constructor();
10
+ process(styleNode: HTMLStyleElement, prefix?: string): void;
11
+ private rewrite;
12
+ private ruleStyle;
13
+ private ruleMedia;
14
+ private ruleSupport;
15
+ }
16
+ export declare const QiankunCSSRewriteAttr = "data-qiankun";
17
+ export declare const process: (appWrapper: HTMLElement, stylesheetElement: HTMLStyleElement | HTMLLinkElement, appName: string) => void;
@@ -0,0 +1,22 @@
1
+ export declare const rawHeadAppendChild: <T extends Node>(node: T) => T;
2
+ export declare function isHijackingTag(tagName?: string): boolean;
3
+ /**
4
+ * Check if a style element is a styled-component liked.
5
+ * A styled-components liked element is which not have textContext but keep the rules in its styleSheet.cssRules.
6
+ * Such as the style element generated by styled-components and emotion.
7
+ * @param element
8
+ */
9
+ export declare function isStyledComponentsLike(element: HTMLStyleElement): number | false | undefined;
10
+ export declare function recordStyledComponentsCSSRules(styleElements: HTMLStyleElement[]): void;
11
+ export declare function getStyledElementCSSRules(styledElement: HTMLStyleElement): CSSRuleList | undefined;
12
+ export type ContainerConfig = {
13
+ appName: string;
14
+ proxy: WindowProxy;
15
+ strictGlobal: boolean;
16
+ dynamicStyleSheetElements: HTMLStyleElement[];
17
+ appWrapperGetter: CallableFunction;
18
+ scopedCSS: boolean;
19
+ excludeAssetFilter?: CallableFunction;
20
+ };
21
+ export declare function patchHTMLDynamicAppendPrototypeFunctions(isInvokedByMicroApp: (element: HTMLElement) => boolean, containerConfigGetter: (element: HTMLElement) => ContainerConfig): () => void;
22
+ export declare function rebuildCSSRules(styleSheetElements: HTMLStyleElement[], reAppendElement: (stylesheetElement: HTMLStyleElement) => boolean): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-10-13
4
+ */
5
+ import type { Freer } from '../../../interfaces';
6
+ /**
7
+ * Just hijack dynamic head append, that could avoid accidentally hijacking the insertion of elements except in head.
8
+ * Such a case: ReactDOM.createPortal(<style>.test{color:blue}</style>, container),
9
+ * this could made we append the style element into app wrapper but it will cause an error while the react portal unmounting, as ReactDOM could not find the style in body children list.
10
+ * @param appName
11
+ * @param appWrapperGetter
12
+ * @param proxy
13
+ * @param mounting
14
+ * @param scopedCSS
15
+ * @param excludeAssetFilter
16
+ */
17
+ export declare function patchLooseSandbox(appName: string, appWrapperGetter: () => HTMLElement | ShadowRoot, proxy: Window, mounting?: boolean, scopedCSS?: boolean, excludeAssetFilter?: CallableFunction): Freer;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-10-13
4
+ */
5
+ import type { Freer } from '../../../interfaces';
6
+ import type { ContainerConfig } from './common';
7
+ declare global {
8
+ interface Window {
9
+ __proxyAttachContainerConfigMap__: WeakMap<WindowProxy, ContainerConfig>;
10
+ }
11
+ }
12
+ export declare function patchStrictSandbox(appName: string, appWrapperGetter: () => HTMLElement | ShadowRoot, proxy: Window, mounting?: boolean, scopedCSS?: boolean, excludeAssetFilter?: CallableFunction): Freer;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-10-13
4
+ */
5
+ export { patchLooseSandbox } from './forLooseSandbox';
6
+ export { patchStrictSandbox } from './forStrictSandbox';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ export default function patch(): () => (...args: any[]) => void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ import type { Freer, SandBox } from '../../interfaces';
6
+ import * as css from './css';
7
+ export declare function patchAtMounting(appName: string, elementGetter: () => HTMLElement | ShadowRoot, sandbox: SandBox, scopedCSS: boolean, excludeAssetFilter?: CallableFunction): Freer[];
8
+ export declare function patchAtBootstrapping(appName: string, elementGetter: () => HTMLElement | ShadowRoot, sandbox: SandBox, scopedCSS: boolean, excludeAssetFilter?: CallableFunction): Freer[];
9
+ export { css };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ export default function patch(global: Window): () => (...args: any[]) => void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-04-11
4
+ */
5
+ export default function patch(global: WindowProxy): () => (...args: any[]) => void;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-3-31
4
+ */
5
+ import type { SandBox } from '../interfaces';
6
+ import { SandBoxType } from '../interfaces';
7
+ /**
8
+ * 基于 Proxy 实现的沙箱
9
+ */
10
+ export default class ProxySandbox implements SandBox {
11
+ /** window 值变更记录 */
12
+ private updatedValueSet;
13
+ name: string;
14
+ type: SandBoxType;
15
+ proxy: WindowProxy;
16
+ globalContext: typeof window;
17
+ sandboxRunning: boolean;
18
+ latestSetProp: PropertyKey | null;
19
+ private registerRunningApp;
20
+ active(): void;
21
+ inactive(): void;
22
+ constructor(name: string, globalContext?: Window & typeof globalThis, transformStorage?: boolean);
23
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @author Hydrogen
3
+ * @since 2020-3-8
4
+ */
5
+ import type { SandBox } from '../interfaces';
6
+ import { SandBoxType } from '../interfaces';
7
+ /**
8
+ * 基于 diff 方式实现的沙箱,用于不支持 Proxy 的低版本浏览器
9
+ */
10
+ export default class SnapshotSandbox implements SandBox {
11
+ proxy: WindowProxy;
12
+ name: string;
13
+ type: SandBoxType;
14
+ sandboxRunning: boolean;
15
+ private windowSnapshot;
16
+ private modifyPropsMap;
17
+ constructor(name: string);
18
+ active(): void;
19
+ inactive(): void;
20
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2019-05-15
4
+ */
5
+ import type { FrameworkConfiguration } from './interfaces';
6
+ export declare function toArray<T>(array: T | T[]): T[];
7
+ export declare function sleep(ms: number): Promise<unknown>;
8
+ /**
9
+ * Run a callback before next task executing, and the invocation is idempotent in every singular task
10
+ * That means even we called nextTask multi times in one task, only the first callback will be pushed to nextTick to be invoked.
11
+ * @param cb
12
+ */
13
+ export declare function nextTask(cb: () => void): void;
14
+ export declare function isConstructable(fn: () => any | FunctionConstructor): any;
15
+ export declare const isCallable: (fn: any) => boolean;
16
+ export declare function isBoundedFunction(fn: CallableFunction): boolean | undefined;
17
+ export declare function getDefaultTplWrapper(name: string): (tpl: string) => string;
18
+ export declare function getWrapperId(name: string): string;
19
+ export declare const nativeGlobal: any;
20
+ /**
21
+ * Get app instance name with the auto-increment approach
22
+ * @param appName
23
+ */
24
+ export declare const genAppInstanceIdByName: (appName: string) => string;
25
+ /** 校验子应用导出的 生命周期 对象是否正确 */
26
+ export declare function validateExportLifecycle(exports: any): boolean;
27
+ export declare class Deferred<T> {
28
+ promise: Promise<T>;
29
+ resolve: (value: T | PromiseLike<T>) => void;
30
+ reject: (reason?: any) => void;
31
+ constructor();
32
+ }
33
+ export declare function performanceGetEntriesByName(markName: string, type?: string): PerformanceEntryList | null;
34
+ export declare function performanceMark(markName: string): void;
35
+ export declare function performanceMeasure(measureName: string, markName: string): void;
36
+ export declare function isEnableScopedCSS(sandbox: FrameworkConfiguration['sandbox']): boolean;
37
+ /**
38
+ * copy from https://developer.mozilla.org/zh-CN/docs/Using_XPath
39
+ * @param el
40
+ * @param document
41
+ */
42
+ export declare function getXPathForElement(el: Node, document: Document): string | void;
43
+ export declare function getContainer(container: string | HTMLElement): HTMLElement | null;
44
+ export declare function getContainerXPath(container?: string | HTMLElement): string | void;
@@ -0,0 +1 @@
1
+ export declare const version = " 2.6.3-beta-5";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-05-15
4
+ */
5
+ import type { FrameworkLifeCycles } from '../interfaces';
6
+ export default function getAddOn(global: Window): FrameworkLifeCycles<any>;
@@ -0,0 +1,50 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ /**
4
+ * @author Kuitos
5
+ * @since 2020-05-15
6
+ */
7
+ import { __awaiter } from "tslib";
8
+ export default function getAddOn(global) {
9
+ return {
10
+ beforeLoad: function beforeLoad() {
11
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
12
+ return _regenerator().w(function (_context) {
13
+ while (1) switch (_context.n) {
14
+ case 0:
15
+ // eslint-disable-next-line no-param-reassign
16
+ global.__POWERED_BY_QIANKUN__ = true;
17
+ case 1:
18
+ return _context.a(2);
19
+ }
20
+ }, _callee);
21
+ }));
22
+ },
23
+ beforeMount: function beforeMount() {
24
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
25
+ return _regenerator().w(function (_context2) {
26
+ while (1) switch (_context2.n) {
27
+ case 0:
28
+ // eslint-disable-next-line no-param-reassign
29
+ global.__POWERED_BY_QIANKUN__ = true;
30
+ case 1:
31
+ return _context2.a(2);
32
+ }
33
+ }, _callee2);
34
+ }));
35
+ },
36
+ beforeUnmount: function beforeUnmount() {
37
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
38
+ return _regenerator().w(function (_context3) {
39
+ while (1) switch (_context3.n) {
40
+ case 0:
41
+ // eslint-disable-next-line no-param-reassign
42
+ delete global.__POWERED_BY_QIANKUN__;
43
+ case 1:
44
+ return _context3.a(2);
45
+ }
46
+ }, _callee3);
47
+ }));
48
+ }
49
+ };
50
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author Kuitos
3
+ * @since 2020-03-02
4
+ */
5
+ import type { FrameworkLifeCycles, ObjectType } from '../interfaces';
6
+ export default function getAddOns<T extends ObjectType>(global: Window, publicPath: string): FrameworkLifeCycles<T>;
@@ -0,0 +1,13 @@
1
+ import _concat from "lodash/concat";
2
+ import _mergeWith from "lodash/mergeWith";
3
+ /**
4
+ * @author Kuitos
5
+ * @since 2020-03-02
6
+ */
7
+ import getRuntimePublicPathAddOn from './runtimePublicPath';
8
+ import getEngineFlagAddon from './engineFlag';
9
+ export default function getAddOns(global, publicPath) {
10
+ return _mergeWith({}, getEngineFlagAddon(global), getRuntimePublicPathAddOn(global, publicPath), function (v1, v2) {
11
+ return _concat(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
12
+ });
13
+ }