@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,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.patchStrictSandbox = patchStrictSandbox;
7
+ var _utils = require("../../../utils");
8
+ var _common = require("../../common");
9
+ var _common2 = require("./common");
10
+ /**
11
+ * @author Kuitos
12
+ * @since 2020-10-13
13
+ */
14
+
15
+ // Get native global window with a sandbox disgusted way, thus we could share it between qiankun instances🤪
16
+ Object.defineProperty(_utils.nativeGlobal, '__proxyAttachContainerConfigMap__', {
17
+ enumerable: false,
18
+ writable: true
19
+ });
20
+ // Share proxyAttachContainerConfigMap between multiple qiankun instance, thus they could access the same record
21
+ _utils.nativeGlobal.__proxyAttachContainerConfigMap__ = _utils.nativeGlobal.__proxyAttachContainerConfigMap__ || new WeakMap();
22
+ var proxyAttachContainerConfigMap = _utils.nativeGlobal.__proxyAttachContainerConfigMap__;
23
+ var elementAttachContainerConfigMap = new WeakMap();
24
+ var docCreatePatchedMap = new WeakMap();
25
+ function patchDocumentCreateElement() {
26
+ var docCreateElementFnBeforeOverwrite = docCreatePatchedMap.get(document.createElement);
27
+ if (!docCreateElementFnBeforeOverwrite) {
28
+ var rawDocumentCreateElement = document.createElement;
29
+ Document.prototype.createElement = function createElement(tagName, options) {
30
+ var element = rawDocumentCreateElement.call(this, tagName, options);
31
+ if ((0, _common2.isHijackingTag)(tagName)) {
32
+ var _ref = (0, _common.getCurrentRunningApp)() || {},
33
+ currentRunningSandboxProxy = _ref.window;
34
+ if (currentRunningSandboxProxy) {
35
+ var proxyContainerConfig = proxyAttachContainerConfigMap.get(currentRunningSandboxProxy);
36
+ if (proxyContainerConfig) {
37
+ elementAttachContainerConfigMap.set(element, proxyContainerConfig);
38
+ }
39
+ }
40
+ }
41
+ return element;
42
+ };
43
+ // It means it have been overwritten while createElement is an own property of document
44
+ if (document.hasOwnProperty('createElement')) {
45
+ document.createElement = Document.prototype.createElement;
46
+ }
47
+ docCreatePatchedMap.set(Document.prototype.createElement, rawDocumentCreateElement);
48
+ }
49
+ return function unpatch() {
50
+ if (docCreateElementFnBeforeOverwrite) {
51
+ Document.prototype.createElement = docCreateElementFnBeforeOverwrite;
52
+ document.createElement = docCreateElementFnBeforeOverwrite;
53
+ }
54
+ };
55
+ }
56
+ var bootstrappingPatchCount = 0;
57
+ var mountingPatchCount = 0;
58
+ function patchStrictSandbox(appName, appWrapperGetter, proxy) {
59
+ var mounting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
60
+ var scopedCSS = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
61
+ var excludeAssetFilter = arguments.length > 5 ? arguments[5] : undefined;
62
+ var containerConfig = proxyAttachContainerConfigMap.get(proxy);
63
+ if (!containerConfig) {
64
+ containerConfig = {
65
+ appName: appName,
66
+ proxy: proxy,
67
+ appWrapperGetter: appWrapperGetter,
68
+ dynamicStyleSheetElements: [],
69
+ strictGlobal: true,
70
+ excludeAssetFilter: excludeAssetFilter,
71
+ scopedCSS: scopedCSS
72
+ };
73
+ proxyAttachContainerConfigMap.set(proxy, containerConfig);
74
+ }
75
+ // all dynamic style sheets are stored in proxy container
76
+ var _containerConfig = containerConfig,
77
+ dynamicStyleSheetElements = _containerConfig.dynamicStyleSheetElements;
78
+ var unpatchDocumentCreate = patchDocumentCreateElement();
79
+ var unpatchDynamicAppendPrototypeFunctions = (0, _common2.patchHTMLDynamicAppendPrototypeFunctions)(function (element) {
80
+ return elementAttachContainerConfigMap.has(element);
81
+ }, function (element) {
82
+ return elementAttachContainerConfigMap.get(element);
83
+ });
84
+ if (!mounting) bootstrappingPatchCount++;
85
+ if (mounting) mountingPatchCount++;
86
+ return function free() {
87
+ // bootstrap patch just called once but its freer will be called multiple times
88
+ if (!mounting && bootstrappingPatchCount !== 0) bootstrappingPatchCount--;
89
+ if (mounting) mountingPatchCount--;
90
+ var allMicroAppUnmounted = mountingPatchCount === 0 && bootstrappingPatchCount === 0;
91
+ // release the overwrite prototype after all the micro apps unmounted
92
+ if (allMicroAppUnmounted) {
93
+ unpatchDynamicAppendPrototypeFunctions();
94
+ unpatchDocumentCreate();
95
+ }
96
+ (0, _common2.recordStyledComponentsCSSRules)(dynamicStyleSheetElements);
97
+ // As now the sub app content all wrapped with a special id container,
98
+ // the dynamic style sheet would be removed automatically while unmoutting
99
+ return function rebuild() {
100
+ (0, _common2.rebuildCSSRules)(dynamicStyleSheetElements, function (stylesheetElement) {
101
+ var appWrapper = appWrapperGetter();
102
+ if (!appWrapper.contains(stylesheetElement)) {
103
+ _common2.rawHeadAppendChild.call(appWrapper, stylesheetElement);
104
+ return true;
105
+ }
106
+ return false;
107
+ });
108
+ };
109
+ };
110
+ }
@@ -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,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "patchLooseSandbox", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _forLooseSandbox.patchLooseSandbox;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "patchStrictSandbox", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _forStrictSandbox.patchStrictSandbox;
16
+ }
17
+ });
18
+ var _forLooseSandbox = require("./forLooseSandbox");
19
+ var _forStrictSandbox = require("./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,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = patch;
8
+ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
9
+ var _noop2 = _interopRequireDefault(require("lodash/noop"));
10
+ /**
11
+ * @author Kuitos
12
+ * @since 2019-04-11
13
+ */
14
+
15
+ function patch() {
16
+ // FIXME umi unmount feature request
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
+ var rawHistoryListen = function rawHistoryListen(_) {
19
+ return _noop2.default;
20
+ };
21
+ var historyListeners = [];
22
+ var historyUnListens = [];
23
+ if (window.g_history && (0, _isFunction2.default)(window.g_history.listen)) {
24
+ rawHistoryListen = window.g_history.listen.bind(window.g_history);
25
+ window.g_history.listen = function (listener) {
26
+ historyListeners.push(listener);
27
+ var unListen = rawHistoryListen(listener);
28
+ historyUnListens.push(unListen);
29
+ return function () {
30
+ unListen();
31
+ historyUnListens.splice(historyUnListens.indexOf(unListen), 1);
32
+ historyListeners.splice(historyListeners.indexOf(listener), 1);
33
+ };
34
+ };
35
+ }
36
+ return function free() {
37
+ var rebuild = _noop2.default;
38
+ /*
39
+ 还存在余量 listener 表明未被卸载,存在两种情况
40
+ 1. 应用在 unmout 时未正确卸载 listener
41
+ 2. listener 是应用 mount 之前绑定的,
42
+ 第二种情况下应用在下次 mount 之前需重新绑定该 listener
43
+ */
44
+ if (historyListeners.length) {
45
+ rebuild = function rebuild() {
46
+ // 必须使用 window.g_history.listen 的方式重新绑定 listener,从而能保证 rebuild 这部分也能被捕获到,否则在应用卸载后无法正确的移除这部分副作用
47
+ historyListeners.forEach(function (listener) {
48
+ return window.g_history.listen(listener);
49
+ });
50
+ };
51
+ }
52
+ // 卸载余下的 listener
53
+ historyUnListens.forEach(function (unListen) {
54
+ return unListen();
55
+ });
56
+ // restore
57
+ if (window.g_history && (0, _isFunction2.default)(window.g_history.listen)) {
58
+ window.g_history.listen = rawHistoryListen;
59
+ }
60
+ return rebuild;
61
+ };
62
+ }
@@ -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,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.css = void 0;
9
+ exports.patchAtBootstrapping = patchAtBootstrapping;
10
+ exports.patchAtMounting = patchAtMounting;
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _interfaces = require("../../interfaces");
13
+ var css = _interopRequireWildcard(require("./css"));
14
+ exports.css = css;
15
+ var _dynamicAppend = require("./dynamicAppend");
16
+ var _historyListener = _interopRequireDefault(require("./historyListener"));
17
+ var _interval = _interopRequireDefault(require("./interval"));
18
+ var _windowListener = _interopRequireDefault(require("./windowListener"));
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
+ /**
21
+ * @author Kuitos
22
+ * @since 2019-04-11
23
+ */
24
+
25
+ function patchAtMounting(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
26
+ var _a;
27
+ var basePatchers = [function () {
28
+ return (0, _interval.default)(sandbox.proxy);
29
+ }, function () {
30
+ return (0, _windowListener.default)(sandbox.proxy);
31
+ }, function () {
32
+ return (0, _historyListener.default)();
33
+ }];
34
+ var patchersInSandbox = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _interfaces.SandBoxType.LegacyProxy, [].concat(basePatchers, [function () {
35
+ return (0, _dynamicAppend.patchLooseSandbox)(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
36
+ }])), _interfaces.SandBoxType.Proxy, [].concat(basePatchers, [function () {
37
+ return (0, _dynamicAppend.patchStrictSandbox)(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
38
+ }])), _interfaces.SandBoxType.Snapshot, [].concat(basePatchers, [function () {
39
+ return (0, _dynamicAppend.patchLooseSandbox)(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
40
+ }]));
41
+ return (_a = patchersInSandbox[sandbox.type]) === null || _a === void 0 ? void 0 : _a.map(function (patch) {
42
+ return patch();
43
+ });
44
+ }
45
+ function patchAtBootstrapping(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
46
+ var _a;
47
+ var patchersInSandbox = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _interfaces.SandBoxType.LegacyProxy, [function () {
48
+ return (0, _dynamicAppend.patchLooseSandbox)(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
49
+ }]), _interfaces.SandBoxType.Proxy, [function () {
50
+ return (0, _dynamicAppend.patchStrictSandbox)(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
51
+ }]), _interfaces.SandBoxType.Snapshot, [function () {
52
+ return (0, _dynamicAppend.patchLooseSandbox)(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
53
+ }]);
54
+ return (_a = patchersInSandbox[sandbox.type]) === null || _a === void 0 ? void 0 : _a.map(function (patch) {
55
+ return patch();
56
+ });
57
+ }
@@ -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,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = patch;
8
+ var _noop2 = _interopRequireDefault(require("lodash/noop"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ /* eslint-disable no-param-reassign */
11
+ /**
12
+ * @author Kuitos
13
+ * @since 2019-04-11
14
+ */
15
+
16
+ var rawWindowInterval = window.setInterval;
17
+ var rawWindowClearInterval = window.clearInterval;
18
+ function patch(global) {
19
+ var intervals = [];
20
+ global.clearInterval = function (intervalId) {
21
+ intervals = intervals.filter(function (id) {
22
+ return id !== intervalId;
23
+ });
24
+ return rawWindowClearInterval.call(window, intervalId);
25
+ };
26
+ global.setInterval = function (handler, timeout) {
27
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
28
+ args[_key - 2] = arguments[_key];
29
+ }
30
+ var intervalId = rawWindowInterval.apply(void 0, [handler, timeout].concat(args));
31
+ intervals = [].concat((0, _toConsumableArray2.default)(intervals), [intervalId]);
32
+ return intervalId;
33
+ };
34
+ return function free() {
35
+ intervals.forEach(function (id) {
36
+ return global.clearInterval(id);
37
+ });
38
+ global.setInterval = rawWindowInterval;
39
+ global.clearInterval = rawWindowClearInterval;
40
+ return _noop2.default;
41
+ };
42
+ }
@@ -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,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = patch;
8
+ var _noop2 = _interopRequireDefault(require("lodash/noop"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ /* eslint-disable no-param-reassign */
11
+ /**
12
+ * @author Kuitos
13
+ * @since 2019-04-11
14
+ */
15
+
16
+ var rawAddEventListener = window.addEventListener;
17
+ var rawRemoveEventListener = window.removeEventListener;
18
+ function patch(global) {
19
+ var listenerMap = new Map();
20
+ global.addEventListener = function (type, listener, options) {
21
+ var listeners = listenerMap.get(type) || [];
22
+ listenerMap.set(type, [].concat((0, _toConsumableArray2.default)(listeners), [listener]));
23
+ return rawAddEventListener.call(window, type, listener, options);
24
+ };
25
+ global.removeEventListener = function (type, listener, options) {
26
+ var storedTypeListeners = listenerMap.get(type);
27
+ if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
28
+ storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
29
+ }
30
+ return rawRemoveEventListener.call(window, type, listener, options);
31
+ };
32
+ return function free() {
33
+ listenerMap.forEach(function (listeners, type) {
34
+ return (0, _toConsumableArray2.default)(listeners).forEach(function (listener) {
35
+ return global.removeEventListener(type, listener);
36
+ });
37
+ });
38
+ global.addEventListener = rawAddEventListener;
39
+ global.removeEventListener = rawRemoveEventListener;
40
+ return _noop2.default;
41
+ };
42
+ }
@@ -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
+ }