@modern-js/plugin-garfish 2.34.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.
@@ -88,16 +88,16 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
88
88
  }
89
89
  };
90
90
  if (masterApp) {
91
- var _useConfig_server, _useConfig, _router_historyOptions, _router, _router1;
91
+ var _useConfig_server, _router_historyOptions;
92
92
  const useConfig = useConfigContext();
93
- const baseUrl = (_useConfig = useConfig) === null || _useConfig === void 0 ? void 0 : (_useConfig_server = _useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
93
+ const baseUrl = useConfig === null || useConfig === void 0 ? void 0 : (_useConfig_server = useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
94
94
  if (Array.isArray(baseUrl)) {
95
95
  throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
96
96
  }
97
97
  (0, _utils1.setRuntimeConfig)(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? {
98
98
  ...masterApp
99
99
  } : {}, {
100
- 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) || "/"
100
+ 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) || "/"
101
101
  }));
102
102
  }
103
103
  (0, _util.logger)(`resolvedConfig`, {
@@ -148,12 +148,12 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
148
148
  }
149
149
  },
150
150
  rspack: (config2) => {
151
- var _resolveOptions_deploy, _resolveOptions;
151
+ var _resolveOptions_deploy;
152
152
  var _config;
153
153
  var _builtins;
154
154
  (_builtins = (_config = config2).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
155
155
  const resolveOptions = useResolvedConfigContext();
156
- 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) {
156
+ if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
157
157
  config2.externalsType = "commonjs";
158
158
  }
159
159
  const banner = config2.builtins.banner || [];
@@ -167,12 +167,12 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
167
167
  ];
168
168
  },
169
169
  bundlerChain: (chain, { env, CHAIN_ID }) => {
170
- var _resolveOptions_deploy, _resolveOptions, _resolveConfig_resolve;
170
+ var _resolveOptions_deploy, _resolveConfig_resolve;
171
171
  const resolveOptions = useResolvedConfigContext();
172
- if ((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
173
- var _useConfig_dev, _resolveOptions_server, _resolveOptions1, _resolveOptions_deploy1;
172
+ if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
173
+ var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
174
174
  chain.output.libraryTarget("umd");
175
- 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") {
175
+ 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") {
176
176
  chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
177
177
  }
178
178
  const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend);
@@ -278,9 +278,9 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
278
278
  };
279
279
  },
280
280
  modifyEntryRenderFunction({ entrypoint, code }) {
281
- var _config_deploy, _config;
281
+ var _config_deploy;
282
282
  const config = useResolvedConfigContext();
283
- if (!((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
283
+ if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
284
284
  return {
285
285
  entrypoint,
286
286
  code
@@ -294,10 +294,10 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
294
294
  };
295
295
  },
296
296
  modifyAsyncEntry({ entrypoint, code }) {
297
- var _config_deploy, _config, _config_source, _config1;
297
+ var _config_deploy, _config_source;
298
298
  const config = useResolvedConfigContext();
299
299
  let finalCode = code;
300
- 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)) {
300
+ 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)) {
301
301
  finalCode = (0, _utils1.generateAsyncEntry)(code);
302
302
  return {
303
303
  entrypoint,
@@ -310,9 +310,9 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
310
310
  };
311
311
  },
312
312
  modifyEntryExport({ entrypoint, exportStatement }) {
313
- var _config_deploy, _config;
313
+ var _config_deploy;
314
314
  const config = useResolvedConfigContext();
315
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
315
+ if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
316
316
  const exportStatementCode = (0, _utils1.makeProvider)();
317
317
  (0, _util.logger)("exportStatement", exportStatementCode);
318
318
  return {
@@ -115,20 +115,20 @@ const makeRenderFunction = (code) => {
115
115
  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");
116
116
  };
117
117
  function getRuntimeConfig(config) {
118
- var _config_runtime, _config, _config1;
119
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
120
- var _config_runtime1, _config2;
121
- return (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config_runtime1 = _config2.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
118
+ var _config_runtime;
119
+ if (config === null || config === void 0 ? void 0 : (_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
120
+ var _config_runtime1;
121
+ return config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
122
122
  }
123
- return ((_config1 = config) === null || _config1 === void 0 ? void 0 : _config1.runtime) || {};
123
+ return (config === null || config === void 0 ? void 0 : config.runtime) || {};
124
124
  }
125
125
  function setRuntimeConfig(config, key, value) {
126
- var _config_runtime, _config, _config_runtime1, _config1, _config2, _config3;
127
- 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])) {
126
+ var _config_runtime, _config_runtime1;
127
+ 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])) {
128
128
  config.runtime.features[key] = value;
129
129
  return void 0;
130
130
  }
131
- if (((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.runtime) && ((_config3 = config) === null || _config3 === void 0 ? void 0 : _config3.runtime[key])) {
131
+ if ((config === null || config === void 0 ? void 0 : config.runtime) && (config === null || config === void 0 ? void 0 : config.runtime[key])) {
132
132
  config.runtime[key] = value;
133
133
  return void 0;
134
134
  }
@@ -19,7 +19,7 @@ const DEFAULT_LOADABLE = {
19
19
  function Loadable(WrapComponent) {
20
20
  return function(defaultLoadable) {
21
21
  return function Lodable(props) {
22
- var _props_loadable, _state;
22
+ var _props_loadable;
23
23
  const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
24
24
  let delayTimer = null;
25
25
  let timeoutTimer = null;
@@ -99,7 +99,7 @@ function Loadable(WrapComponent) {
99
99
  isLoading: state.isLoading,
100
100
  pastDelay: state.pastDelay,
101
101
  timedOut: state.timedOut,
102
- error: (_state = state) === null || _state === void 0 ? void 0 : _state.error,
102
+ error: state === null || state === void 0 ? void 0 : state.error,
103
103
  retry
104
104
  }),
105
105
  /* @__PURE__ */ (0, _jsxruntime.jsx)(WrapComponent, {
@@ -25,19 +25,16 @@ const _setExternal = /* @__PURE__ */ _interop_require_default._(require("./utils
25
25
  const _MApp = require("./utils/MApp");
26
26
  const _apps = require("./utils/apps");
27
27
  async function initOptions(manifest = {}, options) {
28
- var _manifest, _manifest1, _window_modern_manifest, _window, _window_modern_manifest1, _window1;
28
+ var _window_modern_manifest, _window, _window_modern_manifest1, _window1;
29
29
  let apps = options.apps || [];
30
- if ((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.modules) {
31
- var _manifest2;
32
- if (((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.modules.length) > 0) {
33
- var _manifest3;
34
- apps = (_manifest3 = manifest) === null || _manifest3 === void 0 ? void 0 : _manifest3.modules;
30
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
31
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
32
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
35
33
  }
36
34
  (0, _util.logger)("manifest modules", apps);
37
35
  }
38
- if ((_manifest1 = manifest) === null || _manifest1 === void 0 ? void 0 : _manifest1.getAppList) {
39
- var _manifest4;
40
- const getAppList = await ((_manifest4 = manifest) === null || _manifest4 === void 0 ? void 0 : _manifest4.getAppList(manifest));
36
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList) {
37
+ const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
41
38
  if (getAppList.length > 0) {
42
39
  apps = getAppList;
43
40
  }
@@ -16,7 +16,6 @@ const _garfish = /* @__PURE__ */ _interop_require_default._(require("garfish"));
16
16
  const _util = require("../../util");
17
17
  const _loadable = require("../loadable");
18
18
  function generateMApp(options, manifest) {
19
- var _manifest;
20
19
  class MApp extends _react.default.Component {
21
20
  componentDidMount() {
22
21
  const { domId } = this.state;
@@ -28,7 +27,6 @@ function generateMApp(options, manifest) {
28
27
  const garfishOptions = {
29
28
  domGetter: `#${domId}`,
30
29
  beforeLoad(appInfo, ...args) {
31
- var _beforeLoad;
32
30
  (0, _util.logger)("MApp beforeLoad", [
33
31
  appInfo
34
32
  ]);
@@ -38,52 +36,47 @@ function generateMApp(options, manifest) {
38
36
  error: null
39
37
  });
40
38
  }
41
- return (_beforeLoad = beforeLoad) === null || _beforeLoad === void 0 ? void 0 : _beforeLoad(appInfo, ...args);
39
+ return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
42
40
  },
43
41
  beforeMount(appInfo, ...args) {
44
- var _beforeMount;
45
42
  (0, _util.logger)("MApp beforeMount", args);
46
43
  if (appInfo.activeWhen) {
47
44
  setLoadingState({
48
45
  isLoading: false
49
46
  });
50
47
  }
51
- return (_beforeMount = beforeMount) === null || _beforeMount === void 0 ? void 0 : _beforeMount(appInfo, ...args);
48
+ return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
52
49
  },
53
50
  errorLoadApp(error, appInfo, ...args) {
54
- var _errorLoadApp;
55
51
  (0, _util.logger)("MApp errorLoadApp", error, args);
56
52
  if (appInfo.activeWhen) {
57
53
  setLoadingState({
58
54
  error
59
55
  });
60
56
  }
61
- return (_errorLoadApp = errorLoadApp) === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp(error, appInfo, ...args);
57
+ return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
62
58
  },
63
59
  errorMountApp(error, appInfo, ...args) {
64
- var _errorMountApp;
65
60
  (0, _util.logger)("MApp errorMountApp", error, args);
66
61
  if (appInfo.activeWhen) {
67
62
  setLoadingState({
68
63
  error
69
64
  });
70
65
  }
71
- return (_errorMountApp = errorMountApp) === null || _errorMountApp === void 0 ? void 0 : _errorMountApp(error, appInfo, ...args);
66
+ return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
72
67
  },
73
68
  errorUnmountApp(error, appInfo, ...args) {
74
- var _errorUnmountApp;
75
69
  (0, _util.logger)("MApp errorUnmountApp", error, args);
76
70
  if (appInfo.activeWhen) {
77
71
  setLoadingState({
78
72
  error
79
73
  });
80
74
  }
81
- return (_errorUnmountApp = errorUnmountApp) === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp(error, appInfo, ...args);
75
+ return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
82
76
  },
83
77
  customLoader: (provider) => {
84
- var _manifest2;
85
78
  const { render, destroy, SubModuleComponent, jupiter_submodule_app_key } = provider;
86
- const componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
79
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
87
80
  return {
88
81
  mount: (appInfo) => {
89
82
  const transferProps = this.filterTransferProps();
@@ -97,15 +90,13 @@ function generateMApp(options, manifest) {
97
90
  });
98
91
  return void 0;
99
92
  } else {
100
- var _render;
101
93
  (0, _util.logger)("MicroApp customer render", appInfo);
102
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, [
94
+ return render === null || render === void 0 ? void 0 : render.apply(provider, [
103
95
  appInfo
104
96
  ]);
105
97
  }
106
98
  },
107
99
  unmount: (appInfo) => {
108
- var _destroy;
109
100
  const transferProps = this.filterTransferProps();
110
101
  appInfo.props = {
111
102
  ...appInfo.props,
@@ -115,7 +106,7 @@ function generateMApp(options, manifest) {
115
106
  return void 0;
116
107
  }
117
108
  (0, _util.logger)("MicroApp customer destroy", appInfo);
118
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, [
109
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
119
110
  appInfo
120
111
  ]);
121
112
  }
@@ -158,5 +149,5 @@ function generateMApp(options, manifest) {
158
149
  });
159
150
  }
160
151
  }
161
- return (0, _loadable.Loadable)(MApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
152
+ return (0, _loadable.Loadable)(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
162
153
  }
@@ -43,18 +43,17 @@ function pathJoin(...args) {
43
43
  return res || "/";
44
44
  }
45
45
  function getAppInstance(options, appInfo, manifest) {
46
- var _manifest;
47
46
  let locationHref = "";
48
47
  function MicroApp(props) {
49
- var _context_router_useRouteMatch, _context_router, _context, _context_router_useMatches, _context_router1, _context1, _context_router_useLocation, _context_router2, _context2, _options;
48
+ var _context_router_useRouteMatch, _context_router, _context_router_useMatches, _context_router1, _context_router_useLocation, _context_router2;
50
49
  const appRef = (0, _react.useRef)(null);
51
50
  const domId = (0, _util.generateSubAppContainerKey)(appInfo);
52
51
  const [SubModuleComponent, setSubModuleComponent] = (0, _react.useState)();
53
52
  const context = (0, _react.useContext)(_runtime.RuntimeReactContext);
54
- 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);
55
- 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);
56
- 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);
57
- let basename = ((_options = options) === null || _options === void 0 ? void 0 : _options.basename) || "/";
53
+ 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);
54
+ 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);
55
+ 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);
56
+ let basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
58
57
  if (matchs && matchs.length > 0) {
59
58
  const matchItem = {
60
59
  ...matchs[matchs.length - 1]
@@ -64,8 +63,7 @@ function getAppInstance(options, appInfo, manifest) {
64
63
  }
65
64
  basename = pathJoin(basename, matchItem.pathname || "/");
66
65
  } else if (match) {
67
- var _match;
68
- basename = pathJoin(basename, ((_match = match) === null || _match === void 0 ? void 0 : _match.path) || "/");
66
+ basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
69
67
  }
70
68
  (0, _react.useEffect)(() => {
71
69
  if (location && locationHref !== location.pathname && !_garfish.default.running) {
@@ -94,27 +92,24 @@ function getAppInstance(options, appInfo, manifest) {
94
92
  ...userProps
95
93
  },
96
94
  customLoader: (provider) => {
97
- var _manifest2;
98
95
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
99
- const componetRenderMode = ((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
96
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
100
97
  return {
101
98
  mount: (...props2) => {
102
99
  if (componetRenderMode) {
103
100
  setSubModuleComponent(SubModuleComponent2);
104
101
  return void 0;
105
102
  } else {
106
- var _render;
107
103
  (0, _util.logger)("MicroApp customer render", props2);
108
- return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, props2);
104
+ return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
109
105
  }
110
106
  },
111
107
  unmount(...props2) {
112
- var _destroy;
113
108
  if (componetRenderMode) {
114
109
  return void 0;
115
110
  }
116
111
  (0, _util.logger)("MicroApp customer destroy", props2);
117
- return (_destroy = destroy) === null || _destroy === void 0 ? void 0 : _destroy.apply(provider, props2);
112
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
118
113
  }
119
114
  };
120
115
  }
@@ -137,19 +132,17 @@ function getAppInstance(options, appInfo, manifest) {
137
132
  isLoading: false
138
133
  });
139
134
  if (appInstance.mounted && appInstance.appInfo.cache) {
140
- var _appInstance;
141
135
  (0, _util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
142
136
  appInfo: appInstance.appInfo,
143
137
  appInstance
144
138
  });
145
- await ((_appInstance = appInstance) === null || _appInstance === void 0 ? void 0 : _appInstance.show());
139
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.show());
146
140
  } else {
147
- var _appInstance1;
148
141
  (0, _util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
149
142
  appInfo: appInstance.appInfo,
150
143
  appInstance
151
144
  });
152
- await ((_appInstance1 = appInstance) === null || _appInstance1 === void 0 ? void 0 : _appInstance1.mount());
145
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
153
146
  }
154
147
  } catch (error) {
155
148
  setLoadingState({
@@ -181,7 +174,7 @@ function getAppInstance(options, appInfo, manifest) {
181
174
  })
182
175
  });
183
176
  }
184
- return (0, _loadable.Loadable)(MicroApp)((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.loadable);
177
+ return (0, _loadable.Loadable)(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
185
178
  }
186
179
  function generateApps(options, manifest) {
187
180
  var _options_apps;
package/dist/cjs/util.js CHANGED
@@ -25,6 +25,5 @@ const _debug = /* @__PURE__ */ _interop_require_default._(require("debug"));
25
25
  const logger = (0, _debug.default)("modern-js:plugin-garfish");
26
26
  const SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
27
27
  function generateSubAppContainerKey(moduleInfo) {
28
- var _moduleInfo;
29
- return moduleInfo ? `modern_sub_app_container_${decodeURIComponent((_moduleInfo = moduleInfo) === null || _moduleInfo === void 0 ? void 0 : _moduleInfo.name)}` : "modern_sub_app_container";
28
+ return moduleInfo ? `modern_sub_app_container_${decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)}` : "modern_sub_app_container";
30
29
  }
@@ -62,7 +62,7 @@ export var garfishPlugin = function() {
62
62
  },
63
63
  resolvedConfig: function() {
64
64
  var _ref2 = _async_to_generator(function(config) {
65
- var resolved, _getRuntimeConfig, masterApp, router, nConfig, _useConfig_server, _useConfig, _router_historyOptions, _router, _router1, useConfig, baseUrl;
65
+ var resolved, _getRuntimeConfig, masterApp, router, nConfig, _useConfig_server, _router_historyOptions, useConfig, baseUrl;
66
66
  return _ts_generator(this, function(_state) {
67
67
  resolved = config.resolved;
68
68
  _getRuntimeConfig = getRuntimeConfig(resolved), masterApp = _getRuntimeConfig.masterApp, router = _getRuntimeConfig.router;
@@ -72,12 +72,12 @@ export var garfishPlugin = function() {
72
72
  if (masterApp) {
73
73
  ;
74
74
  useConfig = useConfigContext();
75
- baseUrl = (_useConfig = useConfig) === null || _useConfig === void 0 ? void 0 : (_useConfig_server = _useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
75
+ baseUrl = useConfig === null || useConfig === void 0 ? void 0 : (_useConfig_server = useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
76
76
  if (Array.isArray(baseUrl)) {
77
77
  throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
78
78
  }
79
79
  setRuntimeConfig(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? _object_spread({}, masterApp) : {}, {
80
- 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) || "/"
80
+ 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) || "/"
81
81
  }));
82
82
  }
83
83
  logger("resolvedConfig", {
@@ -137,12 +137,12 @@ export var garfishPlugin = function() {
137
137
  }
138
138
  },
139
139
  rspack: function(config3) {
140
- var _resolveOptions_deploy, _resolveOptions;
140
+ var _resolveOptions_deploy;
141
141
  var _config;
142
142
  var _builtins;
143
143
  (_builtins = (_config = config3).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
144
144
  var resolveOptions = useResolvedConfigContext();
145
- if (((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config3.externalsType) {
145
+ if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config3.externalsType) {
146
146
  config3.externalsType = "commonjs";
147
147
  }
148
148
  var banner = config3.builtins.banner || [];
@@ -156,12 +156,12 @@ export var garfishPlugin = function() {
156
156
  },
157
157
  bundlerChain: function(chain, param2) {
158
158
  var env = param2.env, CHAIN_ID = param2.CHAIN_ID;
159
- var _resolveOptions_deploy, _resolveOptions, _resolveConfig_resolve;
159
+ var _resolveOptions_deploy, _resolveConfig_resolve;
160
160
  var resolveOptions = useResolvedConfigContext();
161
- if ((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
162
- var _useConfig_dev, _resolveOptions_server, _resolveOptions1, _resolveOptions_deploy1;
161
+ if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
162
+ var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
163
163
  chain.output.libraryTarget("umd");
164
- 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") {
164
+ 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") {
165
165
  chain.output.publicPath("//localhost:".concat(resolveOptions.server.port, "/"));
166
166
  }
167
167
  var _getDefaultMicroFrontedConfig = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend), enableHtmlEntry2 = _getDefaultMicroFrontedConfig.enableHtmlEntry, externalBasicLibrary = _getDefaultMicroFrontedConfig.externalBasicLibrary;
@@ -270,9 +270,9 @@ export var garfishPlugin = function() {
270
270
  },
271
271
  modifyEntryRenderFunction: function modifyEntryRenderFunction(param2) {
272
272
  var entrypoint = param2.entrypoint, code = param2.code;
273
- var _config_deploy, _config;
273
+ var _config_deploy;
274
274
  var config = useResolvedConfigContext();
275
- if (!((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
275
+ if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
276
276
  return {
277
277
  entrypoint: entrypoint,
278
278
  code: code
@@ -287,10 +287,10 @@ export var garfishPlugin = function() {
287
287
  },
288
288
  modifyAsyncEntry: function modifyAsyncEntry(param2) {
289
289
  var entrypoint = param2.entrypoint, code = param2.code;
290
- var _config_deploy, _config, _config_source, _config1;
290
+ var _config_deploy, _config_source;
291
291
  var config = useResolvedConfigContext();
292
292
  var finalCode = code;
293
- 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)) {
293
+ 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)) {
294
294
  finalCode = generateAsyncEntry(code);
295
295
  return {
296
296
  entrypoint: entrypoint,
@@ -304,9 +304,9 @@ export var garfishPlugin = function() {
304
304
  },
305
305
  modifyEntryExport: function modifyEntryExport(param2) {
306
306
  var entrypoint = param2.entrypoint, exportStatement = param2.exportStatement;
307
- var _config_deploy, _config;
307
+ var _config_deploy;
308
308
  var config = useResolvedConfigContext();
309
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
309
+ if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
310
310
  var exportStatementCode = makeProvider();
311
311
  logger("exportStatement", exportStatementCode);
312
312
  return {
@@ -6,20 +6,20 @@ export var makeRenderFunction = function(code) {
6
6
  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");
7
7
  };
8
8
  export function getRuntimeConfig(config) {
9
- var _config_runtime, _config, _config1;
10
- if ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
11
- var _config_runtime1, _config2;
12
- return (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config_runtime1 = _config2.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
9
+ var _config_runtime;
10
+ if (config === null || config === void 0 ? void 0 : (_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
11
+ var _config_runtime1;
12
+ return config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
13
13
  }
14
- return ((_config1 = config) === null || _config1 === void 0 ? void 0 : _config1.runtime) || {};
14
+ return (config === null || config === void 0 ? void 0 : config.runtime) || {};
15
15
  }
16
16
  export function setRuntimeConfig(config, key, value) {
17
- var _config_runtime, _config, _config_runtime1, _config1, _config2, _config3;
18
- 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])) {
17
+ var _config_runtime, _config_runtime1;
18
+ 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])) {
19
19
  config.runtime.features[key] = value;
20
20
  return void 0;
21
21
  }
22
- if (((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.runtime) && ((_config3 = config) === null || _config3 === void 0 ? void 0 : _config3.runtime[key])) {
22
+ if ((config === null || config === void 0 ? void 0 : config.runtime) && (config === null || config === void 0 ? void 0 : config.runtime[key])) {
23
23
  config.runtime[key] = value;
24
24
  return void 0;
25
25
  }
@@ -13,7 +13,7 @@ var DEFAULT_LOADABLE = {
13
13
  export function Loadable(WrapComponent) {
14
14
  return function(defaultLoadable) {
15
15
  return function Lodable(props) {
16
- var _props_loadable, _state;
16
+ var _props_loadable;
17
17
  var _props_loadable1 = props.loadable, loadable = _props_loadable1 === void 0 ? defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE : _props_loadable1, otherProps = _object_without_properties(props, [
18
18
  "loadable"
19
19
  ]);
@@ -93,7 +93,7 @@ export function Loadable(WrapComponent) {
93
93
  isLoading: state.isLoading,
94
94
  pastDelay: state.pastDelay,
95
95
  timedOut: state.timedOut,
96
- error: (_state = state) === null || _state === void 0 ? void 0 : _state.error,
96
+ error: state === null || state === void 0 ? void 0 : state.error,
97
97
  retry: retry
98
98
  }),
99
99
  /* @__PURE__ */ _jsx(WrapComponent, _object_spread({
@@ -24,29 +24,27 @@ function initOptions() {
24
24
  }
25
25
  function _initOptions() {
26
26
  _initOptions = _async_to_generator(function() {
27
- var manifest, options, _manifest, _manifest1, _window_modern_manifest, _window, _window_modern_manifest1, _window1, apps, _manifest2, _manifest3, _manifest4, getAppList, _window_modern_manifest2, _window2;
27
+ var manifest, options, _window_modern_manifest, _window, _window_modern_manifest1, _window1, apps, getAppList, _window_modern_manifest2, _window2;
28
28
  var _arguments = arguments;
29
29
  return _ts_generator(this, function(_state) {
30
30
  switch (_state.label) {
31
31
  case 0:
32
32
  manifest = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, options = _arguments.length > 1 ? _arguments[1] : void 0;
33
33
  apps = options.apps || [];
34
- if ((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.modules) {
35
- ;
36
- if (((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.modules.length) > 0) {
37
- ;
38
- apps = (_manifest3 = manifest) === null || _manifest3 === void 0 ? void 0 : _manifest3.modules;
34
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
35
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
36
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
39
37
  }
40
38
  logger("manifest modules", apps);
41
39
  }
42
- if (!((_manifest1 = manifest) === null || _manifest1 === void 0 ? void 0 : _manifest1.getAppList))
40
+ if (!(manifest === null || manifest === void 0 ? void 0 : manifest.getAppList))
43
41
  return [
44
42
  3,
45
43
  2
46
44
  ];
47
45
  return [
48
46
  4,
49
- (_manifest4 = manifest) === null || _manifest4 === void 0 ? void 0 : _manifest4.getAppList(manifest)
47
+ manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest)
50
48
  ];
51
49
  case 1:
52
50
  getAppList = _state.sent();