@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,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,59 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import { SandBoxType } from '../interfaces';
4
+ function iter(obj, callbackFn) {
5
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
6
+ for (var prop in obj) {
7
+ // patch for clearInterval for compatible reason, see #1490
8
+ if (obj.hasOwnProperty(prop) || prop === 'clearInterval') {
9
+ callbackFn(prop);
10
+ }
11
+ }
12
+ }
13
+ /**
14
+ * 基于 diff 方式实现的沙箱,用于不支持 Proxy 的低版本浏览器
15
+ */
16
+ var SnapshotSandbox = /*#__PURE__*/function () {
17
+ function SnapshotSandbox(name) {
18
+ _classCallCheck(this, SnapshotSandbox);
19
+ this.sandboxRunning = true;
20
+ this.modifyPropsMap = {};
21
+ this.name = name;
22
+ this.proxy = window;
23
+ this.type = SandBoxType.Snapshot;
24
+ }
25
+ return _createClass(SnapshotSandbox, [{
26
+ key: "active",
27
+ value: function active() {
28
+ var _this = this;
29
+ // 记录当前快照
30
+ this.windowSnapshot = {};
31
+ iter(window, function (prop) {
32
+ _this.windowSnapshot[prop] = window[prop];
33
+ });
34
+ // 恢复之前的变更
35
+ Object.keys(this.modifyPropsMap).forEach(function (p) {
36
+ window[p] = _this.modifyPropsMap[p];
37
+ });
38
+ this.sandboxRunning = true;
39
+ }
40
+ }, {
41
+ key: "inactive",
42
+ value: function inactive() {
43
+ var _this2 = this;
44
+ this.modifyPropsMap = {};
45
+ iter(window, function (prop) {
46
+ if (window[prop] !== _this2.windowSnapshot[prop]) {
47
+ // 记录变更,恢复环境
48
+ _this2.modifyPropsMap[prop] = window[prop];
49
+ window[prop] = _this2.windowSnapshot[prop];
50
+ }
51
+ });
52
+ if (process.env.NODE_ENV === 'development') {
53
+ console.info("[qiankun:sandbox] ".concat(this.name, " origin window restore..."), Object.keys(this.modifyPropsMap));
54
+ }
55
+ this.sandboxRunning = false;
56
+ }
57
+ }]);
58
+ }();
59
+ export { SnapshotSandbox as default };
package/es/utils.d.ts ADDED
@@ -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;
package/es/utils.js ADDED
@@ -0,0 +1,215 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _isFunction from "lodash/isFunction";
5
+ import _once from "lodash/once";
6
+ import _snakeCase from "lodash/snakeCase";
7
+ /**
8
+ * @author Kuitos
9
+ * @since 2019-05-15
10
+ */
11
+ import { version } from './version';
12
+ export function toArray(array) {
13
+ return Array.isArray(array) ? array : [array];
14
+ }
15
+ export function sleep(ms) {
16
+ return new Promise(function (resolve) {
17
+ return setTimeout(resolve, ms);
18
+ });
19
+ }
20
+ // Promise.then might be synchronized in Zone.js context, we need to use setTimeout instead to mock next tick.
21
+ var nextTick = typeof window.Zone === 'function' ? setTimeout : function (cb) {
22
+ return Promise.resolve().then(cb);
23
+ };
24
+ var globalTaskPending = false;
25
+ /**
26
+ * Run a callback before next task executing, and the invocation is idempotent in every singular task
27
+ * That means even we called nextTask multi times in one task, only the first callback will be pushed to nextTick to be invoked.
28
+ * @param cb
29
+ */
30
+ export function nextTask(cb) {
31
+ if (!globalTaskPending) {
32
+ globalTaskPending = true;
33
+ nextTick(function () {
34
+ cb();
35
+ globalTaskPending = false;
36
+ });
37
+ }
38
+ }
39
+ var fnRegexCheckCacheMap = new WeakMap();
40
+ export function isConstructable(fn) {
41
+ // prototype methods might be changed while code running, so we need check it every time
42
+ var hasPrototypeMethods = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1;
43
+ if (hasPrototypeMethods) return true;
44
+ if (fnRegexCheckCacheMap.has(fn)) {
45
+ return fnRegexCheckCacheMap.get(fn);
46
+ }
47
+ /*
48
+ 1. 有 prototype 并且 prototype 上有定义一系列非 constructor 属性
49
+ 2. 函数名大写开头
50
+ 3. class 函数
51
+ 满足其一则可认定为构造函数
52
+ */
53
+ var constructable = hasPrototypeMethods;
54
+ if (!constructable) {
55
+ // fn.toString has a significant performance overhead, if hasPrototypeMethods check not passed, we will check the function string with regex
56
+ var fnString = fn.toString();
57
+ var constructableFunctionRegex = /^function\b\s[A-Z].*/;
58
+ var classRegex = /^class\b/;
59
+ constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString);
60
+ }
61
+ fnRegexCheckCacheMap.set(fn, constructable);
62
+ return constructable;
63
+ }
64
+ /**
65
+ * in safari
66
+ * typeof document.all === 'undefined' // true
67
+ * typeof document.all === 'function' // true
68
+ * We need to discriminate safari for better performance
69
+ */
70
+ var naughtySafari = typeof document.all === 'function' && typeof document.all === 'undefined';
71
+ var callableFnCacheMap = new WeakMap();
72
+ export var isCallable = function isCallable(fn) {
73
+ if (callableFnCacheMap.has(fn)) {
74
+ return true;
75
+ }
76
+ var callable = naughtySafari ? typeof fn === 'function' && typeof fn !== 'undefined' : typeof fn === 'function';
77
+ if (callable) {
78
+ callableFnCacheMap.set(fn, callable);
79
+ }
80
+ return callable;
81
+ };
82
+ var boundedMap = new WeakMap();
83
+ export function isBoundedFunction(fn) {
84
+ if (boundedMap.has(fn)) {
85
+ return boundedMap.get(fn);
86
+ }
87
+ /*
88
+ indexOf is faster than startsWith
89
+ see https://jsperf.com/string-startswith/72
90
+ */
91
+ var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
92
+ boundedMap.set(fn, bounded);
93
+ return bounded;
94
+ }
95
+ export function getDefaultTplWrapper(name) {
96
+ return function (tpl) {
97
+ return "<div id=\"".concat(getWrapperId(name), "\" data-name=\"").concat(name, "\" data-version=\"").concat(version, "\">").concat(tpl, "</div>");
98
+ };
99
+ }
100
+ export function getWrapperId(name) {
101
+ return "__qiankun_microapp_wrapper_for_".concat(_snakeCase(name), "__");
102
+ }
103
+ export var nativeGlobal = new Function('return this')();
104
+ var getGlobalAppInstanceMap = _once(function () {
105
+ if (!nativeGlobal.hasOwnProperty('__app_instance_name_map__')) {
106
+ Object.defineProperty(nativeGlobal, '__app_instance_name_map__', {
107
+ enumerable: false,
108
+ configurable: true,
109
+ writable: true,
110
+ value: {}
111
+ });
112
+ }
113
+ return nativeGlobal.__app_instance_name_map__;
114
+ });
115
+ /**
116
+ * Get app instance name with the auto-increment approach
117
+ * @param appName
118
+ */
119
+ export var genAppInstanceIdByName = function genAppInstanceIdByName(appName) {
120
+ var globalAppInstanceMap = getGlobalAppInstanceMap();
121
+ if (!(appName in globalAppInstanceMap)) {
122
+ nativeGlobal.__app_instance_name_map__[appName] = 0;
123
+ return appName;
124
+ }
125
+ globalAppInstanceMap[appName]++;
126
+ return "".concat(appName, "_").concat(globalAppInstanceMap[appName]);
127
+ };
128
+ /** 校验子应用导出的 生命周期 对象是否正确 */
129
+ export function validateExportLifecycle(exports) {
130
+ var _ref = exports !== null && exports !== void 0 ? exports : {},
131
+ bootstrap = _ref.bootstrap,
132
+ mount = _ref.mount,
133
+ unmount = _ref.unmount;
134
+ return _isFunction(bootstrap) && _isFunction(mount) && _isFunction(unmount);
135
+ }
136
+ export var Deferred = /*#__PURE__*/_createClass(function Deferred() {
137
+ var _this = this;
138
+ _classCallCheck(this, Deferred);
139
+ this.promise = new Promise(function (resolve, reject) {
140
+ _this.resolve = resolve;
141
+ _this.reject = reject;
142
+ });
143
+ });
144
+ var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function' && typeof performance.getEntriesByName === 'function';
145
+ export function performanceGetEntriesByName(markName, type) {
146
+ var marks = null;
147
+ if (supportsUserTiming) {
148
+ marks = performance.getEntriesByName(markName, type);
149
+ }
150
+ return marks;
151
+ }
152
+ export function performanceMark(markName) {
153
+ if (supportsUserTiming) {
154
+ performance.mark(markName);
155
+ }
156
+ }
157
+ export function performanceMeasure(measureName, markName) {
158
+ if (supportsUserTiming && performance.getEntriesByName(markName, 'mark').length) {
159
+ performance.measure(measureName, markName);
160
+ performance.clearMarks(markName);
161
+ performance.clearMeasures(measureName);
162
+ }
163
+ }
164
+ export function isEnableScopedCSS(sandbox) {
165
+ if (_typeof(sandbox) !== 'object') {
166
+ return false;
167
+ }
168
+ if (sandbox.strictStyleIsolation) {
169
+ return false;
170
+ }
171
+ return !!sandbox.experimentalStyleIsolation;
172
+ }
173
+ /**
174
+ * copy from https://developer.mozilla.org/zh-CN/docs/Using_XPath
175
+ * @param el
176
+ * @param document
177
+ */
178
+ export function getXPathForElement(el, document) {
179
+ // not support that if el not existed in document yet(such as it not append to document before it mounted)
180
+ if (!document.body.contains(el)) {
181
+ return undefined;
182
+ }
183
+ var xpath = '';
184
+ var pos;
185
+ var tmpEle;
186
+ var element = el;
187
+ while (element !== document.documentElement) {
188
+ pos = 0;
189
+ tmpEle = element;
190
+ while (tmpEle) {
191
+ if (tmpEle.nodeType === 1 && tmpEle.nodeName === element.nodeName) {
192
+ // If it is ELEMENT_NODE of the same name
193
+ pos += 1;
194
+ }
195
+ tmpEle = tmpEle.previousSibling;
196
+ }
197
+ xpath = "*[name()='".concat(element.nodeName, "'][").concat(pos, "]/").concat(xpath);
198
+ element = element.parentNode;
199
+ }
200
+ xpath = "/*[name()='".concat(document.documentElement.nodeName, "']/").concat(xpath);
201
+ xpath = xpath.replace(/\/$/, '');
202
+ return xpath;
203
+ }
204
+ export function getContainer(container) {
205
+ return typeof container === 'string' ? document.querySelector(container) : container;
206
+ }
207
+ export function getContainerXPath(container) {
208
+ if (container) {
209
+ var containerElement = getContainer(container);
210
+ if (containerElement) {
211
+ return getXPathForElement(containerElement, document);
212
+ }
213
+ }
214
+ return undefined;
215
+ }
@@ -0,0 +1 @@
1
+ export declare const version = " 2.6.3-beta-5";
package/es/version.js ADDED
@@ -0,0 +1 @@
1
+ export var 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,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getAddOn;
7
+ var _tslib = require("tslib");
8
+ 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 }; })(); }
9
+ 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); } /**
10
+ * @author Kuitos
11
+ * @since 2020-05-15
12
+ */
13
+ function getAddOn(global) {
14
+ return {
15
+ beforeLoad: function beforeLoad() {
16
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
17
+ return _regenerator().w(function (_context) {
18
+ while (1) switch (_context.n) {
19
+ case 0:
20
+ // eslint-disable-next-line no-param-reassign
21
+ global.__POWERED_BY_QIANKUN__ = true;
22
+ case 1:
23
+ return _context.a(2);
24
+ }
25
+ }, _callee);
26
+ }));
27
+ },
28
+ beforeMount: function beforeMount() {
29
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
30
+ return _regenerator().w(function (_context2) {
31
+ while (1) switch (_context2.n) {
32
+ case 0:
33
+ // eslint-disable-next-line no-param-reassign
34
+ global.__POWERED_BY_QIANKUN__ = true;
35
+ case 1:
36
+ return _context2.a(2);
37
+ }
38
+ }, _callee2);
39
+ }));
40
+ },
41
+ beforeUnmount: function beforeUnmount() {
42
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
43
+ return _regenerator().w(function (_context3) {
44
+ while (1) switch (_context3.n) {
45
+ case 0:
46
+ // eslint-disable-next-line no-param-reassign
47
+ delete global.__POWERED_BY_QIANKUN__;
48
+ case 1:
49
+ return _context3.a(2);
50
+ }
51
+ }, _callee3);
52
+ }));
53
+ }
54
+ };
55
+ }
@@ -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,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = getAddOns;
8
+ var _concat2 = _interopRequireDefault(require("lodash/concat"));
9
+ var _mergeWith2 = _interopRequireDefault(require("lodash/mergeWith"));
10
+ var _runtimePublicPath = _interopRequireDefault(require("./runtimePublicPath"));
11
+ var _engineFlag = _interopRequireDefault(require("./engineFlag"));
12
+ /**
13
+ * @author Kuitos
14
+ * @since 2020-03-02
15
+ */
16
+
17
+ function getAddOns(global, publicPath) {
18
+ return (0, _mergeWith2.default)({}, (0, _engineFlag.default)(global), (0, _runtimePublicPath.default)(global, publicPath), function (v1, v2) {
19
+ return (0, _concat2.default)(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
20
+ });
21
+ }
@@ -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,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getAddOn;
7
+ var _tslib = require("tslib");
8
+ 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 }; })(); }
9
+ 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); }
10
+ var rawPublicPath = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
11
+ function getAddOn(global) {
12
+ var publicPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
13
+ var hasMountedOnce = false;
14
+ return {
15
+ beforeLoad: function beforeLoad() {
16
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
17
+ return _regenerator().w(function (_context) {
18
+ while (1) switch (_context.n) {
19
+ case 0:
20
+ // eslint-disable-next-line no-param-reassign
21
+ global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
22
+ case 1:
23
+ return _context.a(2);
24
+ }
25
+ }, _callee);
26
+ }));
27
+ },
28
+ beforeMount: function beforeMount() {
29
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
30
+ return _regenerator().w(function (_context2) {
31
+ while (1) switch (_context2.n) {
32
+ case 0:
33
+ if (hasMountedOnce) {
34
+ // eslint-disable-next-line no-param-reassign
35
+ global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
36
+ }
37
+ case 1:
38
+ return _context2.a(2);
39
+ }
40
+ }, _callee2);
41
+ }));
42
+ },
43
+ beforeUnmount: function beforeUnmount() {
44
+ return (0, _tslib.__awaiter)(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
45
+ return _regenerator().w(function (_context3) {
46
+ while (1) switch (_context3.n) {
47
+ case 0:
48
+ if (rawPublicPath === undefined) {
49
+ // eslint-disable-next-line no-param-reassign
50
+ delete global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
51
+ } else {
52
+ // eslint-disable-next-line no-param-reassign
53
+ global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = rawPublicPath;
54
+ }
55
+ hasMountedOnce = true;
56
+ case 1:
57
+ return _context3.a(2);
58
+ }
59
+ }, _callee3);
60
+ }));
61
+ }
62
+ };
63
+ }
package/lib/apis.d.ts ADDED
@@ -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;