@modern-js/plugin-garfish 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/cli/index.js +224 -236
  3. package/dist/cjs/cli/utils.js +24 -48
  4. package/dist/cjs/deps/index.js +12 -35
  5. package/dist/cjs/index.js +26 -36
  6. package/dist/cjs/runtime/index.js +24 -44
  7. package/dist/cjs/runtime/loadable.js +46 -58
  8. package/dist/cjs/runtime/plugin.js +86 -82
  9. package/dist/cjs/runtime/useModuleApps.js +70 -56
  10. package/dist/cjs/runtime/utils/Context.js +18 -36
  11. package/dist/cjs/runtime/utils/MApp.js +88 -87
  12. package/dist/cjs/runtime/utils/apps.js +114 -94
  13. package/dist/cjs/runtime/utils/setExternal.js +23 -41
  14. package/dist/cjs/util.js +21 -40
  15. package/dist/esm/cli/index.js +409 -402
  16. package/dist/esm/cli/utils.js +25 -26
  17. package/dist/esm/deps/index.js +1 -2
  18. package/dist/esm/index.js +1 -2
  19. package/dist/esm/runtime/index.js +3 -4
  20. package/dist/esm/runtime/loadable.js +226 -210
  21. package/dist/esm/runtime/plugin.js +456 -426
  22. package/dist/esm/runtime/useModuleApps.js +49 -50
  23. package/dist/esm/runtime/utils/Context.js +1 -1
  24. package/dist/esm/runtime/utils/MApp.js +337 -316
  25. package/dist/esm/runtime/utils/apps.js +468 -442
  26. package/dist/esm/runtime/utils/setExternal.js +9 -9
  27. package/dist/esm/util.js +4 -5
  28. package/dist/esm-node/cli/index.js +209 -219
  29. package/dist/esm-node/cli/utils.js +15 -30
  30. package/dist/esm-node/deps/index.js +1 -4
  31. package/dist/esm-node/index.js +1 -4
  32. package/dist/esm-node/runtime/index.js +3 -10
  33. package/dist/esm-node/runtime/loadable.js +34 -31
  34. package/dist/esm-node/runtime/plugin.js +50 -33
  35. package/dist/esm-node/runtime/useModuleApps.js +12 -19
  36. package/dist/esm-node/runtime/utils/Context.js +2 -5
  37. package/dist/esm-node/runtime/utils/MApp.js +61 -40
  38. package/dist/esm-node/runtime/utils/apps.js +38 -44
  39. package/dist/esm-node/runtime/utils/setExternal.js +5 -5
  40. package/dist/esm-node/util.js +4 -9
  41. package/package.json +15 -12
@@ -1,352 +1,373 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
5
7
  }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ function _array_without_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return _array_like_to_array(arr);
8
11
  }
9
- function _assertThisInitialized(self) {
10
- if (self === void 0) {
11
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12
- }
13
- return self;
12
+ function _assert_this_initialized(self) {
13
+ if (self === void 0) {
14
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
15
+ }
16
+ return self;
14
17
  }
15
- function _classCallCheck(instance, Constructor) {
16
- if (!(instance instanceof Constructor)) {
17
- throw new TypeError("Cannot call a class as a function");
18
- }
18
+ function _class_call_check(instance, Constructor) {
19
+ if (!(instance instanceof Constructor)) {
20
+ throw new TypeError("Cannot call a class as a function");
21
+ }
19
22
  }
20
23
  function _defineProperties(target, props) {
21
- for(var i = 0; i < props.length; i++){
22
- var descriptor = props[i];
23
- descriptor.enumerable = descriptor.enumerable || false;
24
- descriptor.configurable = true;
25
- if ("value" in descriptor) descriptor.writable = true;
26
- Object.defineProperty(target, descriptor.key, descriptor);
27
- }
24
+ for (var i = 0; i < props.length; i++) {
25
+ var descriptor = props[i];
26
+ descriptor.enumerable = descriptor.enumerable || false;
27
+ descriptor.configurable = true;
28
+ if ("value" in descriptor)
29
+ descriptor.writable = true;
30
+ Object.defineProperty(target, descriptor.key, descriptor);
31
+ }
28
32
  }
29
- function _createClass(Constructor, protoProps, staticProps) {
30
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
31
- if (staticProps) _defineProperties(Constructor, staticProps);
32
- return Constructor;
33
+ function _create_class(Constructor, protoProps, staticProps) {
34
+ if (protoProps)
35
+ _defineProperties(Constructor.prototype, protoProps);
36
+ if (staticProps)
37
+ _defineProperties(Constructor, staticProps);
38
+ return Constructor;
33
39
  }
34
- function _defineProperty(obj, key, value) {
35
- if (key in obj) {
36
- Object.defineProperty(obj, key, {
37
- value: value,
38
- enumerable: true,
39
- configurable: true,
40
- writable: true
41
- });
42
- } else {
43
- obj[key] = value;
44
- }
45
- return obj;
40
+ function _define_property(obj, key, value) {
41
+ if (key in obj) {
42
+ Object.defineProperty(obj, key, {
43
+ value,
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true
47
+ });
48
+ } else {
49
+ obj[key] = value;
50
+ }
51
+ return obj;
46
52
  }
47
- function _getPrototypeOf(o) {
48
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
49
- return o.__proto__ || Object.getPrototypeOf(o);
50
- };
51
- return _getPrototypeOf(o);
53
+ function _get_prototype_of(o) {
54
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
55
+ return o2.__proto__ || Object.getPrototypeOf(o2);
56
+ };
57
+ return _get_prototype_of(o);
52
58
  }
53
59
  function _inherits(subClass, superClass) {
54
- if (typeof superClass !== "function" && superClass !== null) {
55
- throw new TypeError("Super expression must either be null or a function");
60
+ if (typeof superClass !== "function" && superClass !== null) {
61
+ throw new TypeError("Super expression must either be null or a function");
62
+ }
63
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
64
+ constructor: {
65
+ value: subClass,
66
+ writable: true,
67
+ configurable: true
56
68
  }
57
- subClass.prototype = Object.create(superClass && superClass.prototype, {
58
- constructor: {
59
- value: subClass,
60
- writable: true,
61
- configurable: true
62
- }
63
- });
64
- if (superClass) _setPrototypeOf(subClass, superClass);
69
+ });
70
+ if (superClass)
71
+ _set_prototype_of(subClass, superClass);
65
72
  }
66
- function _iterableToArray(iter) {
67
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
73
+ function _iterable_to_array(iter) {
74
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
75
+ return Array.from(iter);
68
76
  }
69
- function _nonIterableSpread() {
70
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
+ function _non_iterable_spread() {
78
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
79
  }
72
- function _objectSpread(target) {
73
- for(var i = 1; i < arguments.length; i++){
74
- var source = arguments[i] != null ? arguments[i] : {};
75
- var ownKeys = Object.keys(source);
76
- if (typeof Object.getOwnPropertySymbols === "function") {
77
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
78
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
79
- }));
80
- }
81
- ownKeys.forEach(function(key) {
82
- _defineProperty(target, key, source[key]);
83
- });
80
+ function _object_spread(target) {
81
+ for (var i = 1; i < arguments.length; i++) {
82
+ var source = arguments[i] != null ? arguments[i] : {};
83
+ var ownKeys = Object.keys(source);
84
+ if (typeof Object.getOwnPropertySymbols === "function") {
85
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
86
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
87
+ }));
84
88
  }
85
- return target;
89
+ ownKeys.forEach(function(key) {
90
+ _define_property(target, key, source[key]);
91
+ });
92
+ }
93
+ return target;
86
94
  }
87
- function _objectWithoutProperties(source, excluded) {
88
- if (source == null) return {};
89
- var target = _objectWithoutPropertiesLoose(source, excluded);
90
- var key, i;
91
- if (Object.getOwnPropertySymbols) {
92
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
93
- for(i = 0; i < sourceSymbolKeys.length; i++){
94
- key = sourceSymbolKeys[i];
95
- if (excluded.indexOf(key) >= 0) continue;
96
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
97
- target[key] = source[key];
98
- }
95
+ function _object_without_properties(source, excluded) {
96
+ if (source == null)
97
+ return {};
98
+ var target = _object_without_properties_loose(source, excluded);
99
+ var key, i;
100
+ if (Object.getOwnPropertySymbols) {
101
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
102
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
103
+ key = sourceSymbolKeys[i];
104
+ if (excluded.indexOf(key) >= 0)
105
+ continue;
106
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
107
+ continue;
108
+ target[key] = source[key];
99
109
  }
100
- return target;
110
+ }
111
+ return target;
101
112
  }
102
- function _objectWithoutPropertiesLoose(source, excluded) {
103
- if (source == null) return {};
104
- var target = {};
105
- var sourceKeys = Object.keys(source);
106
- var key, i;
107
- for(i = 0; i < sourceKeys.length; i++){
108
- key = sourceKeys[i];
109
- if (excluded.indexOf(key) >= 0) continue;
110
- target[key] = source[key];
111
- }
112
- return target;
113
+ function _object_without_properties_loose(source, excluded) {
114
+ if (source == null)
115
+ return {};
116
+ var target = {};
117
+ var sourceKeys = Object.keys(source);
118
+ var key, i;
119
+ for (i = 0; i < sourceKeys.length; i++) {
120
+ key = sourceKeys[i];
121
+ if (excluded.indexOf(key) >= 0)
122
+ continue;
123
+ target[key] = source[key];
124
+ }
125
+ return target;
113
126
  }
114
- function _possibleConstructorReturn(self, call) {
115
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
116
- return call;
117
- }
118
- return _assertThisInitialized(self);
127
+ function _possible_constructor_return(self, call) {
128
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
129
+ return call;
130
+ }
131
+ return _assert_this_initialized(self);
119
132
  }
120
- function _setPrototypeOf(o, p) {
121
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
122
- o.__proto__ = p;
123
- return o;
124
- };
125
- return _setPrototypeOf(o, p);
133
+ function _set_prototype_of(o, p) {
134
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
135
+ o2.__proto__ = p2;
136
+ return o2;
137
+ };
138
+ return _set_prototype_of(o, p);
126
139
  }
127
- function _toConsumableArray(arr) {
128
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
140
+ function _to_consumable_array(arr) {
141
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
129
142
  }
130
- var _typeof = function(obj) {
131
- "@swc/helpers - typeof";
132
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
133
- };
134
- function _unsupportedIterableToArray(o, minLen) {
135
- if (!o) return;
136
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
137
- var n = Object.prototype.toString.call(o).slice(8, -1);
138
- if (n === "Object" && o.constructor) n = o.constructor.name;
139
- if (n === "Map" || n === "Set") return Array.from(n);
140
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
143
+ function _type_of(obj) {
144
+ "@swc/helpers - typeof";
145
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
141
146
  }
142
- function _isNativeReflectConstruct() {
143
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
144
- if (Reflect.construct.sham) return false;
145
- if (typeof Proxy === "function") return true;
146
- try {
147
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
148
- return true;
149
- } catch (e) {
150
- return false;
151
- }
147
+ function _unsupported_iterable_to_array(o, minLen) {
148
+ if (!o)
149
+ return;
150
+ if (typeof o === "string")
151
+ return _array_like_to_array(o, minLen);
152
+ var n = Object.prototype.toString.call(o).slice(8, -1);
153
+ if (n === "Object" && o.constructor)
154
+ n = o.constructor.name;
155
+ if (n === "Map" || n === "Set")
156
+ return Array.from(n);
157
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
158
+ return _array_like_to_array(o, minLen);
152
159
  }
153
- function _createSuper(Derived) {
154
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
155
- return function _createSuperInternal() {
156
- var Super = _getPrototypeOf(Derived), result;
157
- if (hasNativeReflectConstruct) {
158
- var NewTarget = _getPrototypeOf(this).constructor;
159
- result = Reflect.construct(Super, arguments, NewTarget);
160
- } else {
161
- result = Super.apply(this, arguments);
162
- }
163
- return _possibleConstructorReturn(this, result);
164
- };
160
+ function _is_native_reflect_construct() {
161
+ if (typeof Reflect === "undefined" || !Reflect.construct)
162
+ return false;
163
+ if (Reflect.construct.sham)
164
+ return false;
165
+ if (typeof Proxy === "function")
166
+ return true;
167
+ try {
168
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
169
+ }));
170
+ return true;
171
+ } catch (e) {
172
+ return false;
173
+ }
174
+ }
175
+ function _create_super(Derived) {
176
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
177
+ return function _createSuperInternal() {
178
+ var Super = _get_prototype_of(Derived), result;
179
+ if (hasNativeReflectConstruct) {
180
+ var NewTarget = _get_prototype_of(this).constructor;
181
+ result = Reflect.construct(Super, arguments, NewTarget);
182
+ } else {
183
+ result = Super.apply(this, arguments);
184
+ }
185
+ return _possible_constructor_return(this, result);
186
+ };
165
187
  }
166
- import { jsx } from "react/jsx-runtime";
188
+ import { jsx as _jsx } from "react/jsx-runtime";
167
189
  import React from "react";
168
190
  import Garfish from "garfish";
169
191
  import { logger, generateSubAppContainerKey } from "../../util";
170
192
  import { Loadable } from "../loadable";
171
- function generateMApp(options, manifest) {
172
- var MApp = /*#__PURE__*/ function(_React_Component) {
173
- "use strict";
174
- _inherits(MApp, _React_Component);
175
- var _super = _createSuper(MApp);
176
- function MApp() {
177
- _classCallCheck(this, MApp);
178
- var _this;
179
- _this = _super.apply(this, arguments);
180
- _defineProperty(_assertThisInitialized(_this), "state", {
181
- domId: generateSubAppContainerKey()
182
- });
183
- return _this;
184
- }
185
- _createClass(MApp, [
186
- {
187
- key: "componentDidMount",
188
- value: function componentDidMount() {
189
- var _this = this;
190
- var domId = this.state.domId;
191
- var setLoadingState = this.props.setLoadingState;
192
- var beforeLoad = options.beforeLoad, beforeMount = options.beforeMount, errorLoadApp = options.errorLoadApp, errorMountApp = options.errorMountApp, errorUnmountApp = options.errorUnmountApp;
193
- Garfish.router.setRouterConfig({
194
- listening: true
195
- });
196
- var garfishOptions = {
197
- domGetter: "#".concat(domId),
198
- beforeLoad: function beforeLoad1(appInfo) {
199
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
200
- args[_key - 1] = arguments[_key];
201
- }
202
- logger("MApp beforeLoad", [
203
- appInfo
204
- ]);
205
- if (appInfo.activeWhen) {
206
- setLoadingState({
207
- isLoading: true,
208
- error: null
209
- });
210
- }
211
- return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad.apply(void 0, [
212
- appInfo
213
- ].concat(_toConsumableArray(args)));
214
- },
215
- beforeMount: function beforeMount1(appInfo) {
216
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
217
- args[_key - 1] = arguments[_key];
218
- }
219
- logger("MApp beforeMount", args);
220
- if (appInfo.activeWhen) {
221
- setLoadingState({
222
- isLoading: false
223
- });
224
- }
225
- return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount.apply(void 0, [
226
- appInfo
227
- ].concat(_toConsumableArray(args)));
228
- },
229
- errorLoadApp: function errorLoadApp1(error, appInfo) {
230
- for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
231
- args[_key - 2] = arguments[_key];
232
- }
233
- logger("MApp errorLoadApp", error, args);
234
- if (appInfo.activeWhen) {
235
- setLoadingState({
236
- error: error
237
- });
238
- }
239
- return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp.apply(void 0, [
240
- error,
241
- appInfo
242
- ].concat(_toConsumableArray(args)));
243
- },
244
- errorMountApp: function errorMountApp1(error, appInfo) {
245
- for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
246
- args[_key - 2] = arguments[_key];
247
- }
248
- logger("MApp errorMountApp", error, args);
249
- if (appInfo.activeWhen) {
250
- setLoadingState({
251
- error: error
252
- });
253
- }
254
- return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp.apply(void 0, [
255
- error,
256
- appInfo
257
- ].concat(_toConsumableArray(args)));
258
- },
259
- errorUnmountApp: function errorUnmountApp1(error, appInfo) {
260
- for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
261
- args[_key - 2] = arguments[_key];
262
- }
263
- logger("MApp errorUnmountApp", error, args);
264
- if (appInfo.activeWhen) {
265
- setLoadingState({
266
- error: error
267
- });
268
- }
269
- return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp.apply(void 0, [
270
- error,
271
- appInfo
272
- ].concat(_toConsumableArray(args)));
273
- },
274
- customLoader: function(provider) {
275
- var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
276
- var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
277
- return {
278
- mount: function(appInfo) {
279
- var transferProps = _this.filterTransferProps();
280
- appInfo.props = _objectSpread({}, appInfo.props, transferProps);
281
- if (componetRenderMode) {
282
- _this.setState({
283
- SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
284
- });
285
- return void 0;
286
- } else {
287
- logger("MicroApp customer render", appInfo);
288
- return render === null || render === void 0 ? void 0 : render.apply(provider, [
289
- appInfo
290
- ]);
291
- }
292
- },
293
- unmount: function(appInfo) {
294
- var transferProps = _this.filterTransferProps();
295
- appInfo.props = _objectSpread({}, appInfo.props, transferProps);
296
- if (componetRenderMode) {
297
- return void 0;
298
- }
299
- logger("MicroApp customer destroy", appInfo);
300
- return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
301
- appInfo
302
- ]);
303
- }
304
- };
305
- }
306
- };
307
- logger("MApp componentDidMount", {
308
- garfishRunning: Garfish.running,
309
- garfishOptions: garfishOptions
310
- });
311
- if (!Garfish.running) {
312
- Garfish.run(garfishOptions);
313
- }
314
- }
193
+ export function generateMApp(options, manifest) {
194
+ var MApp = /* @__PURE__ */ function(_React_Component) {
195
+ "use strict";
196
+ _inherits(MApp2, _React_Component);
197
+ var _super = _create_super(MApp2);
198
+ function MApp2() {
199
+ _class_call_check(this, MApp2);
200
+ var _this;
201
+ _this = _super.apply(this, arguments);
202
+ _define_property(_assert_this_initialized(_this), "state", {
203
+ domId: generateSubAppContainerKey()
204
+ });
205
+ return _this;
206
+ }
207
+ _create_class(MApp2, [
208
+ {
209
+ key: "componentDidMount",
210
+ value: function componentDidMount() {
211
+ var _this = this;
212
+ var domId = this.state.domId;
213
+ var setLoadingState = this.props.setLoadingState;
214
+ var beforeLoad = options.beforeLoad, beforeMount = options.beforeMount, errorLoadApp = options.errorLoadApp, errorMountApp = options.errorMountApp, errorUnmountApp = options.errorUnmountApp;
215
+ Garfish.router.setRouterConfig({
216
+ listening: true
217
+ });
218
+ var garfishOptions = {
219
+ domGetter: "#".concat(domId),
220
+ beforeLoad: function beforeLoad1(appInfo) {
221
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
222
+ args[_key - 1] = arguments[_key];
223
+ }
224
+ logger("MApp beforeLoad", [
225
+ appInfo
226
+ ]);
227
+ if (appInfo.activeWhen) {
228
+ setLoadingState({
229
+ isLoading: true,
230
+ error: null
231
+ });
232
+ }
233
+ return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad.apply(void 0, [
234
+ appInfo
235
+ ].concat(_to_consumable_array(args)));
315
236
  },
316
- {
317
- key: "componentWillUnmount",
318
- value: function componentWillUnmount() {
319
- Garfish.router.setRouterConfig({
320
- listening: false
321
- });
322
- logger("MApp componentWillUnmount");
323
- }
237
+ beforeMount: function beforeMount1(appInfo) {
238
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
239
+ args[_key - 1] = arguments[_key];
240
+ }
241
+ logger("MApp beforeMount", args);
242
+ if (appInfo.activeWhen) {
243
+ setLoadingState({
244
+ isLoading: false
245
+ });
246
+ }
247
+ return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount.apply(void 0, [
248
+ appInfo
249
+ ].concat(_to_consumable_array(args)));
324
250
  },
325
- {
326
- key: "filterTransferProps",
327
- value: function filterTransferProps() {
328
- var _this_props = this.props, style = _this_props.style, setLoadingState = _this_props.setLoadingState, others = _objectWithoutProperties(_this_props, [
329
- "style",
330
- "setLoadingState"
331
- ]);
332
- return others;
333
- }
251
+ errorLoadApp: function errorLoadApp1(error, appInfo) {
252
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
253
+ args[_key - 2] = arguments[_key];
254
+ }
255
+ logger("MApp errorLoadApp", error, args);
256
+ if (appInfo.activeWhen) {
257
+ setLoadingState({
258
+ error
259
+ });
260
+ }
261
+ return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp.apply(void 0, [
262
+ error,
263
+ appInfo
264
+ ].concat(_to_consumable_array(args)));
265
+ },
266
+ errorMountApp: function errorMountApp1(error, appInfo) {
267
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
268
+ args[_key - 2] = arguments[_key];
269
+ }
270
+ logger("MApp errorMountApp", error, args);
271
+ if (appInfo.activeWhen) {
272
+ setLoadingState({
273
+ error
274
+ });
275
+ }
276
+ return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp.apply(void 0, [
277
+ error,
278
+ appInfo
279
+ ].concat(_to_consumable_array(args)));
334
280
  },
335
- {
336
- key: "render",
337
- value: function render() {
338
- var style = this.props.style;
339
- var SubModuleComponent = this.state.SubModuleComponent;
340
- return /* @__PURE__ */ jsx("div", {
341
- style: _objectSpread({}, style),
342
- id: generateSubAppContainerKey(),
343
- children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
281
+ errorUnmountApp: function errorUnmountApp1(error, appInfo) {
282
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
283
+ args[_key - 2] = arguments[_key];
284
+ }
285
+ logger("MApp errorUnmountApp", error, args);
286
+ if (appInfo.activeWhen) {
287
+ setLoadingState({
288
+ error
289
+ });
290
+ }
291
+ return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp.apply(void 0, [
292
+ error,
293
+ appInfo
294
+ ].concat(_to_consumable_array(args)));
295
+ },
296
+ customLoader: function(provider) {
297
+ var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
298
+ var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
299
+ return {
300
+ mount: function(appInfo) {
301
+ var transferProps = _this.filterTransferProps();
302
+ appInfo.props = _object_spread({}, appInfo.props, transferProps);
303
+ if (componetRenderMode) {
304
+ _this.setState({
305
+ SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
344
306
  });
307
+ return void 0;
308
+ } else {
309
+ logger("MicroApp customer render", appInfo);
310
+ return render === null || render === void 0 ? void 0 : render.apply(provider, [
311
+ appInfo
312
+ ]);
313
+ }
314
+ },
315
+ unmount: function(appInfo) {
316
+ var transferProps = _this.filterTransferProps();
317
+ appInfo.props = _object_spread({}, appInfo.props, transferProps);
318
+ if (componetRenderMode) {
319
+ return void 0;
320
+ }
321
+ logger("MicroApp customer destroy", appInfo);
322
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
323
+ appInfo
324
+ ]);
345
325
  }
326
+ };
346
327
  }
347
- ]);
348
- return MApp;
349
- }(React.Component);
350
- return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
328
+ };
329
+ logger("MApp componentDidMount", {
330
+ garfishRunning: Garfish.running,
331
+ garfishOptions
332
+ });
333
+ if (!Garfish.running) {
334
+ Garfish.run(garfishOptions);
335
+ }
336
+ }
337
+ },
338
+ {
339
+ key: "componentWillUnmount",
340
+ value: function componentWillUnmount() {
341
+ Garfish.router.setRouterConfig({
342
+ listening: false
343
+ });
344
+ logger("MApp componentWillUnmount");
345
+ }
346
+ },
347
+ {
348
+ key: "filterTransferProps",
349
+ value: function filterTransferProps() {
350
+ var _this_props = this.props, style = _this_props.style, setLoadingState = _this_props.setLoadingState, others = _object_without_properties(_this_props, [
351
+ "style",
352
+ "setLoadingState"
353
+ ]);
354
+ return others;
355
+ }
356
+ },
357
+ {
358
+ key: "render",
359
+ value: function render() {
360
+ var style = this.props.style;
361
+ var SubModuleComponent = this.state.SubModuleComponent;
362
+ return /* @__PURE__ */ _jsx("div", {
363
+ style: _object_spread({}, style),
364
+ id: generateSubAppContainerKey(),
365
+ children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {})
366
+ });
367
+ }
368
+ }
369
+ ]);
370
+ return MApp2;
371
+ }(React.Component);
372
+ return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
351
373
  }
352
- export { generateMApp };