@modern-js/plugin-garfish 2.15.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 +15 -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 -11
@@ -1,4 +1,4 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect, useCallback } from "react";
3
3
  import { logger } from "../util";
4
4
  const DEFAULT_LOADABLE = {
@@ -6,11 +6,11 @@ const DEFAULT_LOADABLE = {
6
6
  timeout: 1e4,
7
7
  loading: null
8
8
  };
9
- function Loadable(WrapComponent) {
9
+ export function Loadable(WrapComponent) {
10
10
  return function(defaultLoadable) {
11
11
  return function Lodable(props) {
12
- var _a;
13
- const { loadable = defaultLoadable != null ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
12
+ var _props_loadable;
13
+ const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
14
14
  let delayTimer = null;
15
15
  let timeoutTimer = null;
16
16
  const [state, setState] = useState(() => {
@@ -26,18 +26,22 @@ function Loadable(WrapComponent) {
26
26
  initState.pastDelay = true;
27
27
  } else {
28
28
  delayTimer = setTimeout(() => {
29
- setStateWithMountCheck({ pastDelay: true });
29
+ setStateWithMountCheck({
30
+ pastDelay: true
31
+ });
30
32
  }, delay);
31
33
  }
32
34
  }
33
35
  if (typeof timeout === "number") {
34
36
  timeoutTimer = setTimeout(() => {
35
- setStateWithMountCheck({ timedOut: true });
37
+ setStateWithMountCheck({
38
+ timedOut: true
39
+ });
36
40
  }, timeout);
37
41
  }
38
42
  return initState;
39
43
  });
40
- const LoadingComponent = (_a = props.loadable) == null ? void 0 : _a.loading;
44
+ const LoadingComponent = (_props_loadable = props.loadable) === null || _props_loadable === void 0 ? void 0 : _props_loadable.loading;
41
45
  useEffect(() => {
42
46
  logger("Loadable render state", {
43
47
  state,
@@ -67,29 +71,31 @@ function Loadable(WrapComponent) {
67
71
  isLoading: true,
68
72
  timedOut: false
69
73
  });
70
- }, [state]);
71
- const setStateWithMountCheck = useCallback(
72
- (newState) => {
73
- setState((state2) => ({ ...state2, ...newState }));
74
- },
75
- [state]
76
- );
74
+ }, [
75
+ state
76
+ ]);
77
+ const setStateWithMountCheck = useCallback((newState) => {
78
+ setState((state2) => ({
79
+ ...state2,
80
+ ...newState
81
+ }));
82
+ }, [
83
+ state
84
+ ]);
77
85
  const showLoading = (state.isLoading || state.error) && LoadingComponent;
78
- return /* @__PURE__ */ jsxs(Fragment, { children: [
79
- showLoading && /* @__PURE__ */ jsx(
80
- LoadingComponent,
81
- {
86
+ return /* @__PURE__ */ _jsxs(_Fragment, {
87
+ children: [
88
+ showLoading && /* @__PURE__ */ _jsx(LoadingComponent, {
82
89
  isLoading: state.isLoading,
83
90
  pastDelay: state.pastDelay,
84
91
  timedOut: state.timedOut,
85
- error: state == null ? void 0 : state.error,
92
+ error: state === null || state === void 0 ? void 0 : state.error,
86
93
  retry
87
- }
88
- ),
89
- /* @__PURE__ */ jsx(
90
- WrapComponent,
91
- {
92
- style: { display: showLoading ? "none" : "block" },
94
+ }),
95
+ /* @__PURE__ */ _jsx(WrapComponent, {
96
+ style: {
97
+ display: showLoading ? "none" : "block"
98
+ },
93
99
  setLoadingState: (props2) => {
94
100
  if (props2.error && !LoadingComponent) {
95
101
  throw props2.error;
@@ -97,12 +103,9 @@ function Loadable(WrapComponent) {
97
103
  setStateWithMountCheck(props2);
98
104
  },
99
105
  ...otherProps
100
- }
101
- )
102
- ] });
106
+ })
107
+ ]
108
+ });
103
109
  };
104
110
  };
105
111
  }
106
- export {
107
- Loadable
108
- };
@@ -1,4 +1,17 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { jsx as _jsx } from "react/jsx-runtime";
2
15
  import GarfishInstance from "garfish";
3
16
  import React from "react";
4
17
  import hoistNonReactStatics from "hoist-non-react-statics";
@@ -8,23 +21,24 @@ import setExternal from "./utils/setExternal";
8
21
  import { generateMApp } from "./utils/MApp";
9
22
  import { generateApps } from "./utils/apps";
10
23
  async function initOptions(manifest = {}, options) {
11
- var _a, _b, _c;
24
+ var _window_modern_manifest, _window_modern_manifest1;
12
25
  let apps = options.apps || [];
13
- if (manifest == null ? void 0 : manifest.modules) {
14
- if ((manifest == null ? void 0 : manifest.modules.length) > 0) {
15
- apps = manifest == null ? void 0 : manifest.modules;
26
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
27
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
28
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
16
29
  }
17
30
  logger("manifest modules", apps);
18
31
  }
19
- if (manifest == null ? void 0 : manifest.getAppList) {
20
- const getAppList = await (manifest == null ? void 0 : manifest.getAppList(manifest));
32
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList) {
33
+ const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
21
34
  if (getAppList.length > 0) {
22
35
  apps = getAppList;
23
36
  }
24
37
  logger("getAppList modules", apps);
25
38
  }
26
- if (((_a = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _a.modules) && ((_b = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _b.modules.length) > 0) {
27
- apps = (_c = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _c.modules;
39
+ if ((window === null || window === void 0 ? void 0 : (_window_modern_manifest = window.modern_manifest) === null || _window_modern_manifest === void 0 ? void 0 : _window_modern_manifest.modules) && (window === null || window === void 0 ? void 0 : (_window_modern_manifest1 = window.modern_manifest) === null || _window_modern_manifest1 === void 0 ? void 0 : _window_modern_manifest1.modules.length) > 0) {
40
+ var _window_modern_manifest2;
41
+ apps = window === null || window === void 0 ? void 0 : (_window_modern_manifest2 = window.modern_manifest) === null || _window_modern_manifest2 === void 0 ? void 0 : _window_modern_manifest2.modules;
28
42
  logger("modern_manifest", apps);
29
43
  }
30
44
  return {
@@ -32,7 +46,7 @@ async function initOptions(manifest = {}, options) {
32
46
  apps
33
47
  };
34
48
  }
35
- var plugin_default = (config) => ({
49
+ export default (config) => ({
36
50
  name: "@modern-js/garfish-plugin",
37
51
  setup: () => {
38
52
  setExternal();
@@ -42,23 +56,29 @@ var plugin_default = (config) => ({
42
56
  return {
43
57
  hoc({ App }, next) {
44
58
  class GetMicroFrontendApp extends React.Component {
59
+ render() {
60
+ logger("GarfishProvider state", this.state);
61
+ return /* @__PURE__ */ _jsx(GarfishProvider, {
62
+ value: this.state,
63
+ children: /* @__PURE__ */ _jsx(App, {
64
+ ...this.props
65
+ })
66
+ });
67
+ }
45
68
  constructor(props) {
46
69
  super(props);
47
- this.state = {
70
+ _define_property(this, "state", {
48
71
  MApp: () => {
49
72
  logger("MApp init Component Render");
50
- return React.createElement("div");
73
+ return /* @__PURE__ */ React.createElement("div");
51
74
  },
52
- apps: new Proxy(
53
- {},
54
- {
55
- get() {
56
- return () => React.createElement("div");
57
- }
75
+ apps: new Proxy({}, {
76
+ get() {
77
+ return () => /* @__PURE__ */ React.createElement("div");
58
78
  }
59
- ),
79
+ }),
60
80
  appInfoList: []
61
- };
81
+ });
62
82
  const load = async () => {
63
83
  GarfishInstance.setOptions({
64
84
  ...options,
@@ -69,14 +89,18 @@ var plugin_default = (config) => ({
69
89
  apps: []
70
90
  });
71
91
  const GarfishConfig = await promise;
72
- const { appInfoList, apps } = generateApps(
73
- GarfishConfig,
74
- manifest
75
- );
92
+ const { appInfoList, apps } = generateApps(GarfishConfig, manifest);
76
93
  GarfishInstance.registerApp(appInfoList);
77
94
  const MApp = generateMApp(GarfishConfig, manifest);
78
- logger("initOptions result", { manifest, GarfishConfig });
79
- logger("generateApps", { MApp, apps, appInfoList });
95
+ logger("initOptions result", {
96
+ manifest,
97
+ GarfishConfig
98
+ });
99
+ logger("generateApps", {
100
+ MApp,
101
+ apps,
102
+ appInfoList
103
+ });
80
104
  this.setState({
81
105
  MApp,
82
106
  apps,
@@ -85,10 +109,6 @@ var plugin_default = (config) => ({
85
109
  };
86
110
  load();
87
111
  }
88
- render() {
89
- logger("GarfishProvider state", this.state);
90
- return /* @__PURE__ */ jsx(GarfishProvider, { value: this.state, children: /* @__PURE__ */ jsx(App, { ...this.props }) });
91
- }
92
112
  }
93
113
  return next({
94
114
  App: hoistNonReactStatics(GetMicroFrontendApp, App)
@@ -97,6 +117,3 @@ var plugin_default = (config) => ({
97
117
  };
98
118
  }
99
119
  });
100
- export {
101
- plugin_default as default
102
- };
@@ -1,36 +1,29 @@
1
1
  import React, { useContext } from "react";
2
2
  import { logger } from "../util";
3
3
  import { GarfishContext } from "./utils/Context";
4
- function useModuleApps() {
4
+ export function useModuleApps() {
5
5
  const { apps, MApp, appInfoList } = useContext(GarfishContext);
6
6
  logger("call useModuleApps", {
7
7
  MApp,
8
8
  apps: appInfoList,
9
9
  ...apps
10
10
  });
11
- const Info = new Proxy(
12
- {
13
- MApp,
14
- apps: appInfoList,
15
- ...apps
16
- },
17
- {
18
- get(target, p, receiver) {
19
- if (typeof p === "string" && p in target) {
20
- return Reflect.get(target, p, receiver);
21
- }
22
- return () => React.createElement("div");
11
+ const Info = new Proxy({
12
+ MApp,
13
+ apps: appInfoList,
14
+ ...apps
15
+ }, {
16
+ get(target, p, receiver) {
17
+ if (typeof p === "string" && p in target) {
18
+ return Reflect.get(target, p, receiver);
23
19
  }
20
+ return () => React.createElement("div");
24
21
  }
25
- );
22
+ });
26
23
  return Info;
27
24
  }
28
- function useModuleApp() {
25
+ export function useModuleApp() {
29
26
  const { MApp } = useContext(GarfishContext);
30
27
  logger("call useModuleApps", MApp);
31
28
  return MApp;
32
29
  }
33
- export {
34
- useModuleApp,
35
- useModuleApps
36
- };
@@ -1,7 +1,4 @@
1
1
  import React from "react";
2
- const GarfishContext = React.createContext(null);
2
+ const GarfishContext = /* @__PURE__ */ React.createContext(null);
3
3
  const GarfishProvider = GarfishContext.Provider;
4
- export {
5
- GarfishContext,
6
- GarfishProvider
7
- };
4
+ export { GarfishContext, GarfishProvider };
@@ -1,38 +1,43 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { jsx as _jsx } from "react/jsx-runtime";
2
15
  import React from "react";
3
16
  import Garfish from "garfish";
4
17
  import { logger, generateSubAppContainerKey } from "../../util";
5
18
  import { Loadable } from "../loadable";
6
- function generateMApp(options, manifest) {
19
+ export function generateMApp(options, manifest) {
7
20
  class MApp extends React.Component {
8
- constructor() {
9
- super(...arguments);
10
- this.state = {
11
- domId: generateSubAppContainerKey()
12
- };
13
- }
14
21
  componentDidMount() {
15
22
  const { domId } = this.state;
16
23
  const { setLoadingState } = this.props;
17
- const {
18
- beforeLoad,
19
- beforeMount,
20
- errorLoadApp,
21
- errorMountApp,
22
- errorUnmountApp
23
- } = options;
24
- Garfish.router.setRouterConfig({ listening: true });
24
+ const { beforeLoad, beforeMount, errorLoadApp, errorMountApp, errorUnmountApp } = options;
25
+ Garfish.router.setRouterConfig({
26
+ listening: true
27
+ });
25
28
  const garfishOptions = {
26
29
  domGetter: `#${domId}`,
27
30
  beforeLoad(appInfo, ...args) {
28
- logger("MApp beforeLoad", [appInfo]);
31
+ logger("MApp beforeLoad", [
32
+ appInfo
33
+ ]);
29
34
  if (appInfo.activeWhen) {
30
35
  setLoadingState({
31
36
  isLoading: true,
32
37
  error: null
33
38
  });
34
39
  }
35
- return beforeLoad == null ? void 0 : beforeLoad(appInfo, ...args);
40
+ return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
36
41
  },
37
42
  beforeMount(appInfo, ...args) {
38
43
  logger("MApp beforeMount", args);
@@ -41,7 +46,7 @@ function generateMApp(options, manifest) {
41
46
  isLoading: false
42
47
  });
43
48
  }
44
- return beforeMount == null ? void 0 : beforeMount(appInfo, ...args);
49
+ return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
45
50
  },
46
51
  errorLoadApp(error, appInfo, ...args) {
47
52
  logger("MApp errorLoadApp", error, args);
@@ -50,7 +55,7 @@ function generateMApp(options, manifest) {
50
55
  error
51
56
  });
52
57
  }
53
- return errorLoadApp == null ? void 0 : errorLoadApp(error, appInfo, ...args);
58
+ return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
54
59
  },
55
60
  errorMountApp(error, appInfo, ...args) {
56
61
  logger("MApp errorMountApp", error, args);
@@ -59,7 +64,7 @@ function generateMApp(options, manifest) {
59
64
  error
60
65
  });
61
66
  }
62
- return errorMountApp == null ? void 0 : errorMountApp(error, appInfo, ...args);
67
+ return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
63
68
  },
64
69
  errorUnmountApp(error, appInfo, ...args) {
65
70
  logger("MApp errorUnmountApp", error, args);
@@ -68,38 +73,43 @@ function generateMApp(options, manifest) {
68
73
  error
69
74
  });
70
75
  }
71
- return errorUnmountApp == null ? void 0 : errorUnmountApp(error, appInfo, ...args);
76
+ return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
72
77
  },
73
78
  customLoader: (provider) => {
74
- const {
75
- render,
76
- destroy,
77
- SubModuleComponent,
78
- jupiter_submodule_app_key
79
- } = provider;
80
- const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
79
+ const { render, destroy, SubModuleComponent, jupiter_submodule_app_key } = provider;
80
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
81
81
  return {
82
82
  mount: (appInfo) => {
83
83
  const transferProps = this.filterTransferProps();
84
- appInfo.props = { ...appInfo.props, ...transferProps };
84
+ appInfo.props = {
85
+ ...appInfo.props,
86
+ ...transferProps
87
+ };
85
88
  if (componetRenderMode) {
86
89
  this.setState({
87
- SubModuleComponent: SubModuleComponent != null ? SubModuleComponent : jupiter_submodule_app_key
90
+ SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
88
91
  });
89
92
  return void 0;
90
93
  } else {
91
94
  logger("MicroApp customer render", appInfo);
92
- return render == null ? void 0 : render.apply(provider, [appInfo]);
95
+ return render === null || render === void 0 ? void 0 : render.apply(provider, [
96
+ appInfo
97
+ ]);
93
98
  }
94
99
  },
95
100
  unmount: (appInfo) => {
96
101
  const transferProps = this.filterTransferProps();
97
- appInfo.props = { ...appInfo.props, ...transferProps };
102
+ appInfo.props = {
103
+ ...appInfo.props,
104
+ ...transferProps
105
+ };
98
106
  if (componetRenderMode) {
99
107
  return void 0;
100
108
  }
101
109
  logger("MicroApp customer destroy", appInfo);
102
- return destroy == null ? void 0 : destroy.apply(provider, [appInfo]);
110
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
111
+ appInfo
112
+ ]);
103
113
  }
104
114
  };
105
115
  }
@@ -113,7 +123,9 @@ function generateMApp(options, manifest) {
113
123
  }
114
124
  }
115
125
  componentWillUnmount() {
116
- Garfish.router.setRouterConfig({ listening: false });
126
+ Garfish.router.setRouterConfig({
127
+ listening: false
128
+ });
117
129
  logger("MApp componentWillUnmount");
118
130
  }
119
131
  filterTransferProps() {
@@ -123,11 +135,20 @@ function generateMApp(options, manifest) {
123
135
  render() {
124
136
  const { style } = this.props;
125
137
  const { SubModuleComponent } = this.state;
126
- return /* @__PURE__ */ jsx("div", { style: { ...style }, id: generateSubAppContainerKey(), children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {}) });
138
+ return /* @__PURE__ */ _jsx("div", {
139
+ style: {
140
+ ...style
141
+ },
142
+ id: generateSubAppContainerKey(),
143
+ children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {})
144
+ });
145
+ }
146
+ constructor(...args) {
147
+ super(...args);
148
+ _define_property(this, "state", {
149
+ domId: generateSubAppContainerKey()
150
+ });
127
151
  }
128
152
  }
129
- return Loadable(MApp)(manifest == null ? void 0 : manifest.loadable);
153
+ return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
130
154
  }
131
- export {
132
- generateMApp
133
- };
@@ -1,10 +1,10 @@
1
- import { Fragment, jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useContext, useState, useEffect, useRef } from "react";
3
3
  import { RuntimeReactContext } from "@modern-js/runtime";
4
4
  import Garfish from "garfish";
5
5
  import { logger, generateSubAppContainerKey } from "../../util";
6
6
  import { Loadable } from "../loadable";
7
- function pathJoin(...args) {
7
+ export function pathJoin(...args) {
8
8
  const res = args.reduce((res2, path) => {
9
9
  let nPath = path;
10
10
  if (!nPath || typeof nPath !== "string") {
@@ -24,28 +24,25 @@ function pathJoin(...args) {
24
24
  function getAppInstance(options, appInfo, manifest) {
25
25
  let locationHref = "";
26
26
  function MicroApp(props) {
27
- var _a, _b, _c, _d, _e, _f;
27
+ var _context_router, _context_router_useRouteMatch, _context_router1, _context_router_useMatches, _context_router2, _context_router_useLocation;
28
28
  const appRef = useRef(null);
29
29
  const domId = generateSubAppContainerKey(appInfo);
30
30
  const [SubModuleComponent, setSubModuleComponent] = useState();
31
31
  const context = useContext(RuntimeReactContext);
32
- const match = (_b = (_a = context == null ? void 0 : context.router) == null ? void 0 : _a.useRouteMatch) == null ? void 0 : _b.call(_a);
33
- const matchs = (_d = (_c = context == null ? void 0 : context.router) == null ? void 0 : _c.useMatches) == null ? void 0 : _d.call(_c);
34
- const location = (_f = (_e = context == null ? void 0 : context.router) == null ? void 0 : _e.useLocation) == null ? void 0 : _f.call(_e);
35
- let basename = (options == null ? 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) || "/";
36
36
  if (matchs && matchs.length > 0) {
37
37
  const matchItem = {
38
38
  ...matchs[matchs.length - 1]
39
39
  };
40
40
  for (const key in matchItem.params) {
41
- matchItem.pathname = matchItem.pathname.replace(
42
- new RegExp(`/${matchItem.params[key]}$`),
43
- ""
44
- );
41
+ matchItem.pathname = matchItem.pathname.replace(new RegExp(`/${matchItem.params[key]}$`), "");
45
42
  }
46
43
  basename = pathJoin(basename, matchItem.pathname || "/");
47
44
  } else if (match) {
48
- basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
45
+ basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
49
46
  }
50
47
  useEffect(() => {
51
48
  if (location && locationHref !== location.pathname && !Garfish.running) {
@@ -55,7 +52,9 @@ function getAppInstance(options, appInfo, manifest) {
55
52
  dispatchEvent(popStateEvent);
56
53
  logger(`MicroApp Garfish.loadApp popstate`);
57
54
  }
58
- }, [location]);
55
+ }, [
56
+ location
57
+ ]);
59
58
  useEffect(() => {
60
59
  const { setLoadingState, ...userProps } = props;
61
60
  const loadAppOptions = {
@@ -72,13 +71,8 @@ function getAppInstance(options, appInfo, manifest) {
72
71
  ...userProps
73
72
  },
74
73
  customLoader: (provider) => {
75
- const {
76
- render,
77
- destroy,
78
- SubModuleComponent: SubModuleComponent2,
79
- jupiter_submodule_app_key
80
- } = provider;
81
- const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
74
+ const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
75
+ const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
82
76
  return {
83
77
  mount: (...props2) => {
84
78
  if (componetRenderMode) {
@@ -86,7 +80,7 @@ function getAppInstance(options, appInfo, manifest) {
86
80
  return void 0;
87
81
  } else {
88
82
  logger("MicroApp customer render", props2);
89
- return render == null ? void 0 : render.apply(provider, props2);
83
+ return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
90
84
  }
91
85
  },
92
86
  unmount(...props2) {
@@ -94,7 +88,7 @@ function getAppInstance(options, appInfo, manifest) {
94
88
  return void 0;
95
89
  }
96
90
  logger("MicroApp customer destroy", props2);
97
- return destroy == null ? void 0 : destroy.apply(provider, props2);
91
+ return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
98
92
  }
99
93
  };
100
94
  }
@@ -108,14 +102,9 @@ function getAppInstance(options, appInfo, manifest) {
108
102
  });
109
103
  async function renderApp() {
110
104
  try {
111
- const appInstance = await Garfish.loadApp(
112
- appInfo.name,
113
- loadAppOptions
114
- );
105
+ const appInstance = await Garfish.loadApp(appInfo.name, loadAppOptions);
115
106
  if (!appInstance) {
116
- throw new Error(
117
- `MicroApp Garfish.loadApp "${appInfo.name}" result is null`
118
- );
107
+ throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
119
108
  }
120
109
  appRef.current = appInstance;
121
110
  setLoadingState({
@@ -126,13 +115,13 @@ function getAppInstance(options, appInfo, manifest) {
126
115
  appInfo: appInstance.appInfo,
127
116
  appInstance
128
117
  });
129
- await (appInstance == null ? void 0 : appInstance.show());
118
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.show());
130
119
  } else {
131
120
  logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
132
121
  appInfo: appInstance.appInfo,
133
122
  appInstance
134
123
  });
135
- await (appInstance == null ? void 0 : appInstance.mount());
124
+ await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
136
125
  }
137
126
  } catch (error) {
138
127
  setLoadingState({
@@ -143,34 +132,39 @@ function getAppInstance(options, appInfo, manifest) {
143
132
  }
144
133
  renderApp();
145
134
  return () => {
146
- var _a2, _b2;
147
135
  if (appRef.current) {
148
136
  const { appInfo: appInfo2 } = appRef.current;
149
137
  if (appInfo2.cache) {
138
+ var _appRef_current;
150
139
  logger(`MicroApp Garfish.loadApp "${appInfo2.name}" hide`);
151
- (_a2 = appRef.current) == null ? void 0 : _a2.hide();
140
+ (_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.hide();
152
141
  } else {
142
+ var _appRef_current1;
153
143
  logger(`MicroApp Garfish.loadApp "${appInfo2.name}" unmount`);
154
- (_b2 = appRef.current) == null ? void 0 : _b2.unmount();
144
+ (_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.unmount();
155
145
  }
156
146
  }
157
147
  };
158
148
  }, []);
159
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { id: domId, children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {}) }) });
149
+ return /* @__PURE__ */ _jsx(_Fragment, {
150
+ children: /* @__PURE__ */ _jsx("div", {
151
+ id: domId,
152
+ children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {})
153
+ })
154
+ });
160
155
  }
161
- return Loadable(MicroApp)(manifest == null ? void 0 : manifest.loadable);
156
+ return Loadable(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
162
157
  }
163
- function generateApps(options, manifest) {
164
- var _a;
158
+ export function generateApps(options, manifest) {
159
+ var _options_apps;
165
160
  const apps = {};
166
- (_a = options.apps) == null ? void 0 : _a.forEach((appInfo) => {
161
+ (_options_apps = options.apps) === null || _options_apps === void 0 ? void 0 : _options_apps.forEach((appInfo) => {
167
162
  const Component = getAppInstance(options, appInfo, manifest);
168
163
  appInfo.Component = Component;
169
164
  apps[appInfo.name] = Component;
170
165
  });
171
- return { apps, appInfoList: options.apps || [] };
166
+ return {
167
+ apps,
168
+ appInfoList: options.apps || []
169
+ };
172
170
  }
173
- export {
174
- generateApps,
175
- pathJoin
176
- };