@modern-js/plugin-garfish 2.35.0 → 2.35.1

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.
@@ -13,7 +13,6 @@ import Garfish from "garfish";
13
13
  import { logger, generateSubAppContainerKey } from "../../util";
14
14
  import { Loadable } from "../loadable";
15
15
  export function generateMApp(options, manifest) {
16
- var _manifest;
17
16
  var MApp = /* @__PURE__ */ function(_React_Component) {
18
17
  "use strict";
19
18
  _inherits(MApp2, _React_Component);
@@ -44,7 +43,6 @@ export function generateMApp(options, manifest) {
44
43
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
45
44
  args[_key - 1] = arguments[_key];
46
45
  }
47
- var _beforeLoad;
48
46
  logger("MApp beforeLoad", [
49
47
  appInfo
50
48
  ]);
@@ -54,7 +52,7 @@ export function generateMApp(options, manifest) {
54
52
  error: null
55
53
  });
56
54
  }
57
- return (_beforeLoad = beforeLoad) === null || _beforeLoad === void 0 ? void 0 : _beforeLoad.apply(void 0, [
55
+ return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad.apply(void 0, [
58
56
  appInfo
59
57
  ].concat(_to_consumable_array(args)));
60
58
  },
@@ -62,14 +60,13 @@ export function generateMApp(options, manifest) {
62
60
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
63
61
  args[_key - 1] = arguments[_key];
64
62
  }
65
- var _beforeMount;
66
63
  logger("MApp beforeMount", args);
67
64
  if (appInfo.activeWhen) {
68
65
  setLoadingState({
69
66
  isLoading: false
70
67
  });
71
68
  }
72
- return (_beforeMount = beforeMount) === null || _beforeMount === void 0 ? void 0 : _beforeMount.apply(void 0, [
69
+ return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount.apply(void 0, [
73
70
  appInfo
74
71
  ].concat(_to_consumable_array(args)));
75
72
  },
@@ -77,14 +74,13 @@ export function generateMApp(options, manifest) {
77
74
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
78
75
  args[_key - 2] = arguments[_key];
79
76
  }
80
- var _errorLoadApp;
81
77
  logger("MApp errorLoadApp", error, args);
82
78
  if (appInfo.activeWhen) {
83
79
  setLoadingState({
84
80
  error: error
85
81
  });
86
82
  }
87
- return (_errorLoadApp = errorLoadApp) === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp.apply(void 0, [
83
+ return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp.apply(void 0, [
88
84
  error,
89
85
  appInfo
90
86
  ].concat(_to_consumable_array(args)));
@@ -93,14 +89,13 @@ export function generateMApp(options, manifest) {
93
89
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
94
90
  args[_key - 2] = arguments[_key];
95
91
  }
96
- var _errorMountApp;
97
92
  logger("MApp errorMountApp", error, args);
98
93
  if (appInfo.activeWhen) {
99
94
  setLoadingState({
100
95
  error: error
101
96
  });
102
97
  }
103
- return (_errorMountApp = errorMountApp) === null || _errorMountApp === void 0 ? void 0 : _errorMountApp.apply(void 0, [
98
+ return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp.apply(void 0, [
104
99
  error,
105
100
  appInfo
106
101
  ].concat(_to_consumable_array(args)));
@@ -109,22 +104,20 @@ export function generateMApp(options, manifest) {
109
104
  for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
110
105
  args[_key - 2] = arguments[_key];
111
106
  }
112
- var _errorUnmountApp;
113
107
  logger("MApp errorUnmountApp", error, args);
114
108
  if (appInfo.activeWhen) {
115
109
  setLoadingState({
116
110
  error: error
117
111
  });
118
112
  }
119
- return (_errorUnmountApp = errorUnmountApp) === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [
113
+ return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp.apply(void 0, [
120
114
  error,
121
115
  appInfo
122
116
  ].concat(_to_consumable_array(args)));
123
117
  },
124
118
  customLoader: function(provider) {
125
- var _manifest2;
126
119
  var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
127
- var componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
120
+ var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
128
121
  return {
129
122
  mount: function(appInfo) {
130
123
  var transferProps = _this.filterTransferProps();
@@ -135,22 +128,20 @@ export function generateMApp(options, manifest) {
135
128
  });
136
129
  return void 0;
137
130
  } else {
138
- var _render;
139
131
  logger("MicroApp customer render", appInfo);
140
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, [
132
+ return render === null || render === void 0 ? void 0 : render.apply(provider, [
141
133
  appInfo
142
134
  ]);
143
135
  }
144
136
  },
145
137
  unmount: function(appInfo) {
146
- var _destroy;
147
138
  var transferProps = _this.filterTransferProps();
148
139
  appInfo.props = _object_spread({}, appInfo.props, transferProps);
149
140
  if (componetRenderMode) {
150
141
  return void 0;
151
142
  }
152
143
  logger("MicroApp customer destroy", appInfo);
153
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, [
144
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
154
145
  appInfo
155
146
  ]);
156
147
  }
@@ -200,5 +191,5 @@ export function generateMApp(options, manifest) {
200
191
  ]);
201
192
  return MApp2;
202
193
  }(React.Component);
203
- return Loadable(MApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
194
+ return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
204
195
  }
@@ -33,15 +33,15 @@ export function pathJoin() {
33
33
  }
34
34
  function getAppInstance(options, appInfo, manifest) {
35
35
  var MicroApp = function MicroApp2(props) {
36
- var _context_router_useRouteMatch, _context_router, _context, _context_router_useMatches, _context_router1, _context1, _context_router_useLocation, _context_router2, _context2, _options;
36
+ var _context_router_useRouteMatch, _context_router, _context_router_useMatches, _context_router1, _context_router_useLocation, _context_router2;
37
37
  var appRef = useRef(null);
38
38
  var domId = generateSubAppContainerKey(appInfo);
39
39
  var _useState = _sliced_to_array(useState(), 2), SubModuleComponent = _useState[0], setSubModuleComponent = _useState[1];
40
40
  var context = useContext(RuntimeReactContext);
41
- var match = (_context = context) === null || _context === void 0 ? void 0 : (_context_router = _context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
42
- var matchs = (_context1 = context) === null || _context1 === void 0 ? void 0 : (_context_router1 = _context1.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
43
- var location = (_context2 = context) === null || _context2 === void 0 ? void 0 : (_context_router2 = _context2.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
44
- var basename = ((_options = options) === null || _options === void 0 ? void 0 : _options.basename) || "/";
41
+ var match = context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
42
+ var matchs = context === null || context === void 0 ? void 0 : (_context_router1 = context.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
43
+ var location = context === null || context === void 0 ? void 0 : (_context_router2 = context.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
44
+ var basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
45
45
  if (matchs && matchs.length > 0) {
46
46
  var matchItem = _object_spread({}, matchs[matchs.length - 1]);
47
47
  for (var key in matchItem.params) {
@@ -49,8 +49,7 @@ function getAppInstance(options, appInfo, manifest) {
49
49
  }
50
50
  basename = pathJoin(basename, matchItem.pathname || "/");
51
51
  } else if (match) {
52
- var _match;
53
- basename = pathJoin(basename, ((_match = match) === null || _match === void 0 ? void 0 : _match.path) || "/");
52
+ basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
54
53
  }
55
54
  useEffect(function() {
56
55
  if (location && locationHref !== location.pathname && !Garfish.running) {
@@ -76,9 +75,8 @@ function getAppInstance(options, appInfo, manifest) {
76
75
  cache: true,
77
76
  props: _object_spread({}, appInfo.props, userProps),
78
77
  customLoader: function(provider) {
79
- var _manifest2;
80
78
  var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
81
- var componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
79
+ var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
82
80
  return {
83
81
  mount: function() {
84
82
  for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -88,21 +86,19 @@ function getAppInstance(options, appInfo, manifest) {
88
86
  setSubModuleComponent(SubModuleComponent2);
89
87
  return void 0;
90
88
  } else {
91
- var _render;
92
89
  logger("MicroApp customer render", _$props);
93
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, _$props);
90
+ return render === null || render === void 0 ? void 0 : render.apply(provider, _$props);
94
91
  }
95
92
  },
96
93
  unmount: function unmount() {
97
94
  for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
98
95
  _$props[_key] = arguments[_key];
99
96
  }
100
- var _destroy;
101
97
  if (componetRenderMode) {
102
98
  return void 0;
103
99
  }
104
100
  logger("MicroApp customer destroy", _$props);
105
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, _$props);
101
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, _$props);
106
102
  }
107
103
  };
108
104
  }
@@ -119,7 +115,7 @@ function getAppInstance(options, appInfo, manifest) {
119
115
  }
120
116
  function _renderApp() {
121
117
  _renderApp = _async_to_generator(function() {
122
- var appInstance, _appInstance, _appInstance1, error;
118
+ var appInstance, error;
123
119
  return _ts_generator(this, function(_state) {
124
120
  switch (_state.label) {
125
121
  case 0:
@@ -153,7 +149,7 @@ function getAppInstance(options, appInfo, manifest) {
153
149
  });
154
150
  return [
155
151
  4,
156
- (_appInstance = appInstance) === null || _appInstance === void 0 ? void 0 : _appInstance.show()
152
+ appInstance === null || appInstance === void 0 ? void 0 : appInstance.show()
157
153
  ];
158
154
  case 2:
159
155
  _state.sent();
@@ -168,7 +164,7 @@ function getAppInstance(options, appInfo, manifest) {
168
164
  });
169
165
  return [
170
166
  4,
171
- (_appInstance1 = appInstance) === null || _appInstance1 === void 0 ? void 0 : _appInstance1.mount()
167
+ appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount()
172
168
  ];
173
169
  case 4:
174
170
  _state.sent();
@@ -220,9 +216,8 @@ function getAppInstance(options, appInfo, manifest) {
220
216
  })
221
217
  });
222
218
  };
223
- var _manifest;
224
219
  var locationHref = "";
225
- return Loadable(MicroApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
220
+ return Loadable(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
226
221
  }
227
222
  export function generateApps(options, manifest) {
228
223
  var _options_apps;
package/dist/esm/util.js CHANGED
@@ -2,6 +2,5 @@ import createDebug from "debug";
2
2
  export var logger = createDebug("modern-js:plugin-garfish");
3
3
  export var SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
4
4
  export function generateSubAppContainerKey(moduleInfo) {
5
- var _moduleInfo;
6
- return moduleInfo ? "modern_sub_app_container_".concat(decodeURIComponent((_moduleInfo = moduleInfo) === null || _moduleInfo === void 0 ? void 0 : _moduleInfo.name)) : "modern_sub_app_container";
5
+ return moduleInfo ? "modern_sub_app_container_".concat(decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)) : "modern_sub_app_container";
7
6
  }
@@ -63,16 +63,16 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
63
63
  }
64
64
  };
65
65
  if (masterApp) {
66
- var _useConfig_server, _useConfig, _router_historyOptions, _router, _router1;
66
+ var _useConfig_server, _router_historyOptions;
67
67
  const useConfig = useConfigContext();
68
- const baseUrl = (_useConfig = useConfig) === null || _useConfig === void 0 ? void 0 : (_useConfig_server = _useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
68
+ const baseUrl = useConfig === null || useConfig === void 0 ? void 0 : (_useConfig_server = useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
69
69
  if (Array.isArray(baseUrl)) {
70
70
  throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
71
71
  }
72
72
  setRuntimeConfig(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? {
73
73
  ...masterApp
74
74
  } : {}, {
75
- basename: baseUrl || ((_router = router) === null || _router === void 0 ? void 0 : (_router_historyOptions = _router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || ((_router1 = router) === null || _router1 === void 0 ? void 0 : _router1.basename) || "/"
75
+ basename: baseUrl || (router === null || router === void 0 ? void 0 : (_router_historyOptions = router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || (router === null || router === void 0 ? void 0 : router.basename) || "/"
76
76
  }));
77
77
  }
78
78
  logger(`resolvedConfig`, {
@@ -123,12 +123,12 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
123
123
  }
124
124
  },
125
125
  rspack: (config2) => {
126
- var _resolveOptions_deploy, _resolveOptions;
126
+ var _resolveOptions_deploy;
127
127
  var _config;
128
128
  var _builtins;
129
129
  (_builtins = (_config = config2).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
130
130
  const resolveOptions = useResolvedConfigContext();
131
- if (((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
131
+ if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
132
132
  config2.externalsType = "commonjs";
133
133
  }
134
134
  const banner = config2.builtins.banner || [];
@@ -142,12 +142,12 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
142
142
  ];
143
143
  },
144
144
  bundlerChain: (chain, { env, CHAIN_ID }) => {
145
- var _resolveOptions_deploy, _resolveOptions, _resolveConfig_resolve;
145
+ var _resolveOptions_deploy, _resolveConfig_resolve;
146
146
  const resolveOptions = useResolvedConfigContext();
147
- if ((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
148
- var _useConfig_dev, _resolveOptions_server, _resolveOptions1, _resolveOptions_deploy1;
147
+ if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
148
+ var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
149
149
  chain.output.libraryTarget("umd");
150
- if (!((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && ((_resolveOptions1 = resolveOptions) === null || _resolveOptions1 === void 0 ? void 0 : (_resolveOptions_server = _resolveOptions1.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
150
+ if (!((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_server = resolveOptions.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
151
151
  chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
152
152
  }
153
153
  const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend);
@@ -253,9 +253,9 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
253
253
  };
254
254
  },
255
255
  modifyEntryRenderFunction({ entrypoint, code }) {
256
- var _config_deploy, _config;
256
+ var _config_deploy;
257
257
  const config = useResolvedConfigContext();
258
- if (!((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
258
+ if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
259
259
  return {
260
260
  entrypoint,
261
261
  code
@@ -269,10 +269,10 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
269
269
  };
270
270
  },
271
271
  modifyAsyncEntry({ entrypoint, code }) {
272
- var _config_deploy, _config, _config_source, _config1;
272
+ var _config_deploy, _config_source;
273
273
  const config = useResolvedConfigContext();
274
274
  let finalCode = code;
275
- if (((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && ((_config1 = config) === null || _config1 === void 0 ? void 0 : (_config_source = _config1.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
275
+ if ((config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && (config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
276
276
  finalCode = generateAsyncEntry(code);
277
277
  return {
278
278
  entrypoint,
@@ -285,9 +285,9 @@ export const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtim
285
285
  };
286
286
  },
287
287
  modifyEntryExport({ entrypoint, exportStatement }) {
288
- var _config_deploy, _config;
288
+ var _config_deploy;
289
289
  const config = useResolvedConfigContext();
290
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
290
+ if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
291
291
  const exportStatementCode = makeProvider();
292
292
  logger("exportStatement", exportStatementCode);
293
293
  return {
@@ -87,20 +87,20 @@ export const makeRenderFunction = (code) => {
87
87
  return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace(/MOUNT_ID/g, "mountNode").replace(`createApp({`, "createApp({ props,").replace(`bootstrap(AppWrapper, mountNode, root`, "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null").replace(`customBootstrap(AppWrapper`, "customBootstrap(AppWrapper, mountNode");
88
88
  };
89
89
  export function getRuntimeConfig(config) {
90
- var _config_runtime, _config, _config1;
91
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
92
- var _config_runtime1, _config2;
93
- return (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config_runtime1 = _config2.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
90
+ var _config_runtime;
91
+ if (config === null || config === void 0 ? void 0 : (_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
92
+ var _config_runtime1;
93
+ return config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
94
94
  }
95
- return ((_config1 = config) === null || _config1 === void 0 ? void 0 : _config1.runtime) || {};
95
+ return (config === null || config === void 0 ? void 0 : config.runtime) || {};
96
96
  }
97
97
  export function setRuntimeConfig(config, key, value) {
98
- var _config_runtime, _config, _config_runtime1, _config1, _config2, _config3;
99
- if (((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) && ((_config1 = config) === null || _config1 === void 0 ? void 0 : (_config_runtime1 = _config1.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features[key])) {
98
+ var _config_runtime, _config_runtime1;
99
+ if ((config === null || config === void 0 ? void 0 : (_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features[key])) {
100
100
  config.runtime.features[key] = value;
101
101
  return void 0;
102
102
  }
103
- if (((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.runtime) && ((_config3 = config) === null || _config3 === void 0 ? void 0 : _config3.runtime[key])) {
103
+ if ((config === null || config === void 0 ? void 0 : config.runtime) && (config === null || config === void 0 ? void 0 : config.runtime[key])) {
104
104
  config.runtime[key] = value;
105
105
  return void 0;
106
106
  }
@@ -9,7 +9,7 @@ const DEFAULT_LOADABLE = {
9
9
  export function Loadable(WrapComponent) {
10
10
  return function(defaultLoadable) {
11
11
  return function Lodable(props) {
12
- var _props_loadable, _state;
12
+ var _props_loadable;
13
13
  const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
14
14
  let delayTimer = null;
15
15
  let timeoutTimer = null;
@@ -89,7 +89,7 @@ export function Loadable(WrapComponent) {
89
89
  isLoading: state.isLoading,
90
90
  pastDelay: state.pastDelay,
91
91
  timedOut: state.timedOut,
92
- error: (_state = state) === null || _state === void 0 ? void 0 : _state.error,
92
+ error: state === null || state === void 0 ? void 0 : state.error,
93
93
  retry
94
94
  }),
95
95
  /* @__PURE__ */ _jsx(WrapComponent, {
@@ -9,19 +9,16 @@ import setExternal from "./utils/setExternal";
9
9
  import { generateMApp } from "./utils/MApp";
10
10
  import { generateApps } from "./utils/apps";
11
11
  async function initOptions(manifest = {}, options) {
12
- var _manifest, _manifest1, _window_modern_manifest, _window, _window_modern_manifest1, _window1;
12
+ var _window_modern_manifest, _window, _window_modern_manifest1, _window1;
13
13
  let apps = options.apps || [];
14
- if ((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.modules) {
15
- var _manifest2;
16
- if (((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.modules.length) > 0) {
17
- var _manifest3;
18
- apps = (_manifest3 = manifest) === null || _manifest3 === void 0 ? void 0 : _manifest3.modules;
14
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
15
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
16
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
19
17
  }
20
18
  logger("manifest modules", apps);
21
19
  }
22
- if ((_manifest1 = manifest) === null || _manifest1 === void 0 ? void 0 : _manifest1.getAppList) {
23
- var _manifest4;
24
- const getAppList = await ((_manifest4 = manifest) === null || _manifest4 === void 0 ? void 0 : _manifest4.getAppList(manifest));
20
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList) {
21
+ const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
25
22
  if (getAppList.length > 0) {
26
23
  apps = getAppList;
27
24
  }
@@ -5,7 +5,6 @@ import Garfish from "garfish";
5
5
  import { logger, generateSubAppContainerKey } from "../../util";
6
6
  import { Loadable } from "../loadable";
7
7
  export function generateMApp(options, manifest) {
8
- var _manifest;
9
8
  class MApp extends React.Component {
10
9
  componentDidMount() {
11
10
  const { domId } = this.state;
@@ -17,7 +16,6 @@ export function generateMApp(options, manifest) {
17
16
  const garfishOptions = {
18
17
  domGetter: `#${domId}`,
19
18
  beforeLoad(appInfo, ...args) {
20
- var _beforeLoad;
21
19
  logger("MApp beforeLoad", [
22
20
  appInfo
23
21
  ]);
@@ -27,52 +25,47 @@ export function generateMApp(options, manifest) {
27
25
  error: null
28
26
  });
29
27
  }
30
- return (_beforeLoad = beforeLoad) === null || _beforeLoad === void 0 ? void 0 : _beforeLoad(appInfo, ...args);
28
+ return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
31
29
  },
32
30
  beforeMount(appInfo, ...args) {
33
- var _beforeMount;
34
31
  logger("MApp beforeMount", args);
35
32
  if (appInfo.activeWhen) {
36
33
  setLoadingState({
37
34
  isLoading: false
38
35
  });
39
36
  }
40
- return (_beforeMount = beforeMount) === null || _beforeMount === void 0 ? void 0 : _beforeMount(appInfo, ...args);
37
+ return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
41
38
  },
42
39
  errorLoadApp(error, appInfo, ...args) {
43
- var _errorLoadApp;
44
40
  logger("MApp errorLoadApp", error, args);
45
41
  if (appInfo.activeWhen) {
46
42
  setLoadingState({
47
43
  error
48
44
  });
49
45
  }
50
- return (_errorLoadApp = errorLoadApp) === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp(error, appInfo, ...args);
46
+ return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
51
47
  },
52
48
  errorMountApp(error, appInfo, ...args) {
53
- var _errorMountApp;
54
49
  logger("MApp errorMountApp", error, args);
55
50
  if (appInfo.activeWhen) {
56
51
  setLoadingState({
57
52
  error
58
53
  });
59
54
  }
60
- return (_errorMountApp = errorMountApp) === null || _errorMountApp === void 0 ? void 0 : _errorMountApp(error, appInfo, ...args);
55
+ return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
61
56
  },
62
57
  errorUnmountApp(error, appInfo, ...args) {
63
- var _errorUnmountApp;
64
58
  logger("MApp errorUnmountApp", error, args);
65
59
  if (appInfo.activeWhen) {
66
60
  setLoadingState({
67
61
  error
68
62
  });
69
63
  }
70
- return (_errorUnmountApp = errorUnmountApp) === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp(error, appInfo, ...args);
64
+ return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
71
65
  },
72
66
  customLoader: (provider) => {
73
- var _manifest2;
74
67
  const { render, destroy, SubModuleComponent, jupiter_submodule_app_key } = provider;
75
- const componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
68
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
76
69
  return {
77
70
  mount: (appInfo) => {
78
71
  const transferProps = this.filterTransferProps();
@@ -86,15 +79,13 @@ export function generateMApp(options, manifest) {
86
79
  });
87
80
  return void 0;
88
81
  } else {
89
- var _render;
90
82
  logger("MicroApp customer render", appInfo);
91
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, [
83
+ return render === null || render === void 0 ? void 0 : render.apply(provider, [
92
84
  appInfo
93
85
  ]);
94
86
  }
95
87
  },
96
88
  unmount: (appInfo) => {
97
- var _destroy;
98
89
  const transferProps = this.filterTransferProps();
99
90
  appInfo.props = {
100
91
  ...appInfo.props,
@@ -104,7 +95,7 @@ export function generateMApp(options, manifest) {
104
95
  return void 0;
105
96
  }
106
97
  logger("MicroApp customer destroy", appInfo);
107
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, [
98
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
108
99
  appInfo
109
100
  ]);
110
101
  }
@@ -147,5 +138,5 @@ export function generateMApp(options, manifest) {
147
138
  });
148
139
  }
149
140
  }
150
- return Loadable(MApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
141
+ return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
151
142
  }
@@ -22,18 +22,17 @@ export function pathJoin(...args) {
22
22
  return res || "/";
23
23
  }
24
24
  function getAppInstance(options, appInfo, manifest) {
25
- var _manifest;
26
25
  let locationHref = "";
27
26
  function MicroApp(props) {
28
- var _context_router_useRouteMatch, _context_router, _context, _context_router_useMatches, _context_router1, _context1, _context_router_useLocation, _context_router2, _context2, _options;
27
+ var _context_router_useRouteMatch, _context_router, _context_router_useMatches, _context_router1, _context_router_useLocation, _context_router2;
29
28
  const appRef = useRef(null);
30
29
  const domId = generateSubAppContainerKey(appInfo);
31
30
  const [SubModuleComponent, setSubModuleComponent] = useState();
32
31
  const context = useContext(RuntimeReactContext);
33
- const match = (_context = context) === null || _context === void 0 ? void 0 : (_context_router = _context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
34
- const matchs = (_context1 = context) === null || _context1 === void 0 ? void 0 : (_context_router1 = _context1.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
35
- const location = (_context2 = context) === null || _context2 === void 0 ? void 0 : (_context_router2 = _context2.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
36
- let basename = ((_options = options) === null || _options === void 0 ? void 0 : _options.basename) || "/";
32
+ const match = context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
33
+ const matchs = context === null || context === void 0 ? void 0 : (_context_router1 = context.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
34
+ const location = context === null || context === void 0 ? void 0 : (_context_router2 = context.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
35
+ let basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
37
36
  if (matchs && matchs.length > 0) {
38
37
  const matchItem = {
39
38
  ...matchs[matchs.length - 1]
@@ -43,8 +42,7 @@ function getAppInstance(options, appInfo, manifest) {
43
42
  }
44
43
  basename = pathJoin(basename, matchItem.pathname || "/");
45
44
  } else if (match) {
46
- var _match;
47
- basename = pathJoin(basename, ((_match = match) === null || _match === void 0 ? void 0 : _match.path) || "/");
45
+ basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
48
46
  }
49
47
  useEffect(() => {
50
48
  if (location && locationHref !== location.pathname && !Garfish.running) {
@@ -73,27 +71,24 @@ function getAppInstance(options, appInfo, manifest) {
73
71
  ...userProps
74
72
  },
75
73
  customLoader: (provider) => {
76
- var _manifest2;
77
74
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
78
- const componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
75
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
79
76
  return {
80
77
  mount: (...props2) => {
81
78
  if (componetRenderMode) {
82
79
  setSubModuleComponent(SubModuleComponent2);
83
80
  return void 0;
84
81
  } else {
85
- var _render;
86
82
  logger("MicroApp customer render", props2);
87
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, props2);
83
+ return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
88
84
  }
89
85
  },
90
86
  unmount(...props2) {
91
- var _destroy;
92
87
  if (componetRenderMode) {
93
88
  return void 0;
94
89
  }
95
90
  logger("MicroApp customer destroy", props2);
96
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, props2);
91
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
97
92
  }
98
93
  };
99
94
  }
@@ -116,19 +111,17 @@ function getAppInstance(options, appInfo, manifest) {
116
111
  isLoading: false
117
112
  });
118
113
  if (appInstance.mounted && appInstance.appInfo.cache) {
119
- var _appInstance;
120
114
  logger(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
121
115
  appInfo: appInstance.appInfo,
122
116
  appInstance
123
117
  });
124
- await ((_appInstance = appInstance) === null || _appInstance === void 0 ? void 0 : _appInstance.show());
118
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.show());
125
119
  } else {
126
- var _appInstance1;
127
120
  logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
128
121
  appInfo: appInstance.appInfo,
129
122
  appInstance
130
123
  });
131
- await ((_appInstance1 = appInstance) === null || _appInstance1 === void 0 ? void 0 : _appInstance1.mount());
124
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
132
125
  }
133
126
  } catch (error) {
134
127
  setLoadingState({
@@ -160,7 +153,7 @@ function getAppInstance(options, appInfo, manifest) {
160
153
  })
161
154
  });
162
155
  }
163
- return Loadable(MicroApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
156
+ return Loadable(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
164
157
  }
165
158
  export function generateApps(options, manifest) {
166
159
  var _options_apps;
@@ -2,6 +2,5 @@ import createDebug from "debug";
2
2
  export const logger = createDebug("modern-js:plugin-garfish");
3
3
  export const SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
4
4
  export function generateSubAppContainerKey(moduleInfo) {
5
- var _moduleInfo;
6
- return moduleInfo ? `modern_sub_app_container_${decodeURIComponent((_moduleInfo = moduleInfo) === null || _moduleInfo === void 0 ? void 0 : _moduleInfo.name)}` : "modern_sub_app_container";
5
+ return moduleInfo ? `modern_sub_app_container_${decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)}` : "modern_sub_app_container";
7
6
  }