@modern-js/plugin-garfish 1.3.0 → 1.4.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.
Files changed (41) hide show
  1. package/.eslintrc.js +1 -1
  2. package/CHANGELOG.md +35 -0
  3. package/dist/js/modern/cli/index.js +204 -225
  4. package/dist/js/modern/cli/utils.js +85 -31
  5. package/dist/js/modern/index.js +2 -1
  6. package/dist/js/modern/runtime/index.js +2 -1
  7. package/dist/js/modern/runtime/loadable.js +36 -19
  8. package/dist/js/modern/runtime/plugin.js +24 -19
  9. package/dist/js/modern/runtime/utils/MApp.js +7 -10
  10. package/dist/js/modern/runtime/utils/apps.js +3 -9
  11. package/dist/js/node/cli/index.js +207 -222
  12. package/dist/js/node/cli/utils.js +89 -31
  13. package/dist/js/node/index.js +18 -3
  14. package/dist/js/node/runtime/index.js +25 -12
  15. package/dist/js/node/runtime/loadable.js +36 -19
  16. package/dist/js/node/runtime/plugin.js +21 -18
  17. package/dist/js/node/runtime/utils/MApp.js +7 -10
  18. package/dist/js/node/runtime/utils/apps.js +3 -9
  19. package/dist/js/treeshaking/cli/index.js +124 -121
  20. package/dist/js/treeshaking/cli/utils.js +33 -4
  21. package/dist/js/treeshaking/index.js +2 -1
  22. package/dist/js/treeshaking/runtime/index.js +2 -1
  23. package/dist/js/treeshaking/runtime/loadable.js +39 -25
  24. package/dist/js/treeshaking/runtime/plugin.js +29 -24
  25. package/dist/js/treeshaking/runtime/utils/MApp.js +23 -31
  26. package/dist/js/treeshaking/runtime/utils/apps.js +22 -24
  27. package/dist/types/cli/index.d.ts +18 -10
  28. package/dist/types/cli/utils.d.ts +5 -2
  29. package/dist/types/index.d.ts +2 -1
  30. package/dist/types/runtime/index.d.ts +3 -1
  31. package/dist/types/runtime/loadable.d.ts +2 -8
  32. package/dist/types/runtime/plugin.d.ts +29 -3
  33. package/dist/types/runtime/useModuleApps.d.ts +7 -9
  34. package/dist/types/runtime/utils/MApp.d.ts +1 -15
  35. package/dist/types/runtime/utils/apps.d.ts +1 -1
  36. package/package.json +21 -9
  37. package/tests/cli.test.tsx +203 -33
  38. package/tests/hooks.test.tsx +1 -0
  39. package/tests/index.test.tsx +6 -3
  40. package/tsconfig.json +3 -2
  41. package/tests/__snapshots__/cli.test.tsx.snap +0 -71
@@ -1,6 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
 
3
- var _excluded = ["manifest", "LoadingComponent"];
3
+ var _excluded = ["manifest"];
4
4
 
5
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
@@ -38,6 +38,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
38
38
 
39
39
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
40
40
 
41
+ // eslint-disable-next-line filenames/match-exported
41
42
  import { createPlugin } from '@modern-js/runtime-core';
42
43
  import React from 'react';
43
44
  import hoistNonReactStatics from 'hoist-non-react-statics';
@@ -54,13 +55,14 @@ function initOptions() {
54
55
 
55
56
  function _initOptions() {
56
57
  _initOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
57
- var _window, _window$modern_manife;
58
+ var _window, _window$modern_manife, _window2, _window2$modern_manif;
58
59
 
59
60
  var manifest,
60
61
  options,
61
62
  apps,
62
- _window2,
63
- _window2$modern_manif,
63
+ getAppList,
64
+ _window3,
65
+ _window3$modern_manif,
64
66
  _args2 = arguments;
65
67
 
66
68
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -69,16 +71,19 @@ function _initOptions() {
69
71
  case 0:
70
72
  manifest = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
71
73
  options = _args2.length > 1 ? _args2[1] : undefined;
72
- apps = []; // use manifest modules
74
+ apps = options.apps || []; // use manifest modules
73
75
 
74
76
  if (manifest !== null && manifest !== void 0 && manifest.modules) {
75
- apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
77
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
78
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
79
+ }
80
+
76
81
  logger('manifest modules', apps);
77
82
  } // get module list
78
83
 
79
84
 
80
85
  if (!(manifest !== null && manifest !== void 0 && manifest.getAppList)) {
81
- _context2.next = 9;
86
+ _context2.next = 10;
82
87
  break;
83
88
  }
84
89
 
@@ -86,21 +91,26 @@ function _initOptions() {
86
91
  return manifest === null || manifest === void 0 ? void 0 : manifest.getAppList();
87
92
 
88
93
  case 7:
89
- apps = _context2.sent;
94
+ getAppList = _context2.sent;
95
+
96
+ if (getAppList.length > 0) {
97
+ apps = getAppList;
98
+ }
99
+
90
100
  logger('getAppList modules', apps);
91
101
 
92
- case 9:
102
+ case 10:
93
103
  // get inject modules list
94
- if ((_window = window) !== null && _window !== void 0 && (_window$modern_manife = _window.modern_manifest) !== null && _window$modern_manife !== void 0 && _window$modern_manife.modules) {
95
- apps = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$modern_manif = _window2.modern_manifest) === null || _window2$modern_manif === void 0 ? void 0 : _window2$modern_manif.modules;
104
+ if ((_window = window) !== null && _window !== void 0 && (_window$modern_manife = _window.modern_manifest) !== null && _window$modern_manife !== void 0 && _window$modern_manife.modules && ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$modern_manif = _window2.modern_manifest) === null || _window2$modern_manif === void 0 ? void 0 : _window2$modern_manif.modules.length) > 0) {
105
+ apps = (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$modern_manif = _window3.modern_manifest) === null || _window3$modern_manif === void 0 ? void 0 : _window3$modern_manif.modules;
96
106
  logger('modern_manifest', apps);
97
107
  }
98
108
 
99
- return _context2.abrupt("return", _objectSpread({
109
+ return _context2.abrupt("return", _objectSpread(_objectSpread({}, options), {}, {
100
110
  apps: apps
101
- }, options));
111
+ }));
102
112
 
103
- case 11:
113
+ case 12:
104
114
  case "end":
105
115
  return _context2.stop();
106
116
  }
@@ -110,22 +120,15 @@ function _initOptions() {
110
120
  return _initOptions.apply(this, arguments);
111
121
  }
112
122
 
113
- export default (function (config) {
123
+ var GarfishPlugin = function GarfishPlugin(config) {
114
124
  setExternal();
115
125
 
116
- var _config$manifest = config.manifest,
117
- manifest = _config$manifest === void 0 ? {} : _config$manifest,
118
- LoadingComponent = config.LoadingComponent,
126
+ var manifest = config.manifest,
119
127
  options = _objectWithoutProperties(config, _excluded);
120
128
 
121
129
  logger('createPlugin', {
122
130
  config: config
123
131
  });
124
-
125
- if (!manifest.LoadingComponent && LoadingComponent) {
126
- manifest.LoadingComponent = LoadingComponent;
127
- }
128
-
129
132
  var promise = initOptions(manifest, options);
130
133
  return createPlugin(function () {
131
134
  return {
@@ -227,4 +230,6 @@ export default (function (config) {
227
230
  }
228
231
  };
229
232
  });
230
- });
233
+ };
234
+
235
+ export default GarfishPlugin;
@@ -38,9 +38,7 @@ import Garfish from 'garfish';
38
38
  import { logger, generateSubAppContainerKey } from "../../util";
39
39
  import { Loadable } from "../loadable";
40
40
  import { jsx as _jsx } from "react/jsx-runtime";
41
- export function generateMApp(options, _ref) {
42
- var LoadingComponent = _ref.LoadingComponent;
43
-
41
+ export function generateMApp(options, manifest) {
44
42
  var MApp = /*#__PURE__*/function (_React$Component) {
45
43
  _inherits(MApp, _React$Component);
46
44
 
@@ -83,64 +81,59 @@ export function generateMApp(options, _ref) {
83
81
  var garfishOptions = _objectSpread({
84
82
  domGetter: "#".concat(domId),
85
83
  beforeLoad: function beforeLoad() {
86
- // logger('MApp beforeLoad', args);
87
- setLoadingState({
88
- isLoading: true,
89
- error: null
90
- });
91
-
92
84
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
93
85
  args[_key2] = arguments[_key2];
94
86
  }
95
87
 
88
+ logger('MApp beforeLoad', args);
89
+ setLoadingState({
90
+ isLoading: true,
91
+ error: null
92
+ });
96
93
  return _beforeLoad === null || _beforeLoad === void 0 ? void 0 : _beforeLoad.apply(void 0, args);
97
94
  },
98
95
  beforeMount: function beforeMount() {
99
- // logger('MApp beforeMount', args);
100
- setLoadingState({
101
- isLoading: false
102
- });
103
-
104
96
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
105
97
  args[_key3] = arguments[_key3];
106
98
  }
107
99
 
100
+ logger('MApp beforeMount', args);
101
+ setLoadingState({
102
+ isLoading: false
103
+ });
108
104
  return _beforeMount === null || _beforeMount === void 0 ? void 0 : _beforeMount.apply(void 0, args);
109
105
  },
110
106
  errorLoadApp: function errorLoadApp(error) {
111
- // logger('MApp errorLoadApp', args);
112
- setLoadingState({
113
- error: error
114
- });
115
-
116
107
  for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
117
108
  args[_key4 - 1] = arguments[_key4];
118
109
  }
119
110
 
120
- return _errorLoadApp === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp.apply(void 0, [error].concat(args));
121
- },
122
- errorMountApp: function errorMountApp(error) {
123
- // logger('MApp errorMountApp', args);
111
+ logger('MApp errorLoadApp', error, args);
124
112
  setLoadingState({
125
113
  error: error
126
114
  });
127
-
115
+ return _errorLoadApp === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp.apply(void 0, [error].concat(args));
116
+ },
117
+ errorMountApp: function errorMountApp(error) {
128
118
  for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
129
119
  args[_key5 - 1] = arguments[_key5];
130
120
  }
131
121
 
132
- return _errorMountApp === null || _errorMountApp === void 0 ? void 0 : _errorMountApp.apply(void 0, [error].concat(args));
133
- },
134
- errorUnmountApp: function errorUnmountApp(error) {
135
- // logger('MApp errorUnmountApp', args);
122
+ logger('MApp errorMountApp', error, args);
136
123
  setLoadingState({
137
124
  error: error
138
125
  });
139
-
126
+ return _errorMountApp === null || _errorMountApp === void 0 ? void 0 : _errorMountApp.apply(void 0, [error].concat(args));
127
+ },
128
+ errorUnmountApp: function errorUnmountApp(error) {
140
129
  for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
141
130
  args[_key6 - 1] = arguments[_key6];
142
131
  }
143
132
 
133
+ logger('MApp errorUnmountApp', error, args);
134
+ setLoadingState({
135
+ error: error
136
+ });
144
137
  return _errorUnmountApp === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [error].concat(args));
145
138
  }
146
139
  }, otherOptions);
@@ -166,7 +159,6 @@ export function generateMApp(options, _ref) {
166
159
  }, {
167
160
  key: "render",
168
161
  value: function render() {
169
- logger('MApp render status', this.state);
170
162
  return /*#__PURE__*/_jsx("div", {
171
163
  id: generateSubAppContainerKey()
172
164
  });
@@ -176,5 +168,5 @@ export function generateMApp(options, _ref) {
176
168
  return MApp;
177
169
  }(React.Component);
178
170
 
179
- return Loadable(MApp)(LoadingComponent);
171
+ return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
180
172
  }
@@ -54,8 +54,7 @@ import { Loadable } from "../loadable"; // type Provider = {
54
54
  import { jsx as _jsx } from "react/jsx-runtime";
55
55
  import { Fragment as _Fragment } from "react/jsx-runtime";
56
56
 
57
- function getAppInstance(appInfo, manifest) {
58
- var LoadingComponent = manifest.LoadingComponent;
57
+ function getAppInstance(options, appInfo, manifest) {
59
58
  var locationHref = '';
60
59
 
61
60
  var MicroApp = /*#__PURE__*/function (_React$Component) {
@@ -85,7 +84,7 @@ function getAppInstance(appInfo, manifest) {
85
84
  value: // eslint-disable-next-line @typescript-eslint/naming-convention
86
85
  function () {
87
86
  var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
88
- var _this$props, match, history, setLoadingState, userProps, domId, options, loadAppOptions, appInstance;
87
+ var _this$props, match, history, setLoadingState, userProps, domId, loadAppOptions, appInstance;
89
88
 
90
89
  return _regeneratorRuntime.wrap(function _callee$(_context) {
91
90
  while (1) {
@@ -93,7 +92,6 @@ function getAppInstance(appInfo, manifest) {
93
92
  case 0:
94
93
  _this$props = this.props, match = _this$props.match, history = _this$props.history, setLoadingState = _this$props.setLoadingState, userProps = _objectWithoutProperties(_this$props, _excluded);
95
94
  domId = this.state.domId;
96
- options = Garfish.options;
97
95
  loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
98
96
  domGetter: "#".concat(domId),
99
97
  basename: path.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
@@ -129,21 +127,21 @@ function getAppInstance(appInfo, manifest) {
129
127
  logger("MicroApp Garfish.loadApp \"".concat(appInfo.name, "\""), {
130
128
  loadAppOptions: loadAppOptions
131
129
  });
132
- _context.prev = 6;
133
- _context.next = 9;
130
+ _context.prev = 5;
131
+ _context.next = 8;
134
132
  return Garfish.loadApp(appInfo.name, loadAppOptions);
135
133
 
136
- case 9:
134
+ case 8:
137
135
  appInstance = _context.sent;
138
136
 
139
137
  if (appInstance) {
140
- _context.next = 12;
138
+ _context.next = 11;
141
139
  break;
142
140
  }
143
141
 
144
142
  throw new Error("MicroApp Garfish.loadApp \"".concat(appInfo.name, "\" result is null"));
145
143
 
146
- case 12:
144
+ case 11:
147
145
  this.setState({
148
146
  appInstance: appInstance
149
147
  });
@@ -152,7 +150,7 @@ function getAppInstance(appInfo, manifest) {
152
150
  });
153
151
 
154
152
  if (!(appInstance.mounted && appInstance.appInfo.cache)) {
155
- _context.next = 20;
153
+ _context.next = 19;
156
154
  break;
157
155
  }
158
156
 
@@ -160,22 +158,22 @@ function getAppInstance(appInfo, manifest) {
160
158
  appInfo: appInstance.appInfo,
161
159
  appInstance: appInstance
162
160
  });
163
- _context.next = 18;
161
+ _context.next = 17;
164
162
  return appInstance === null || appInstance === void 0 ? void 0 : appInstance.show();
165
163
 
166
- case 18:
167
- _context.next = 23;
164
+ case 17:
165
+ _context.next = 22;
168
166
  break;
169
167
 
170
- case 20:
168
+ case 19:
171
169
  logger("MicroApp Garfish.loadApp \"".concat(appInfo.name, "\" mount"), {
172
170
  appInfo: appInstance.appInfo,
173
171
  appInstance: appInstance
174
172
  });
175
- _context.next = 23;
173
+ _context.next = 22;
176
174
  return appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount();
177
175
 
178
- case 23:
176
+ case 22:
179
177
  history === null || history === void 0 ? void 0 : history.listen(function () {
180
178
  if (locationHref !== history.location.pathname) {
181
179
  locationHref = history.location.pathname;
@@ -184,23 +182,23 @@ function getAppInstance(appInfo, manifest) {
184
182
  logger("MicroApp Garfish.loadApp popstate");
185
183
  }
186
184
  });
187
- _context.next = 29;
185
+ _context.next = 28;
188
186
  break;
189
187
 
190
- case 26:
191
- _context.prev = 26;
192
- _context.t0 = _context["catch"](6);
188
+ case 25:
189
+ _context.prev = 25;
190
+ _context.t0 = _context["catch"](5);
193
191
  setLoadingState({
194
192
  isLoading: true,
195
193
  error: _context.t0
196
194
  });
197
195
 
198
- case 29:
196
+ case 28:
199
197
  case "end":
200
198
  return _context.stop();
201
199
  }
202
200
  }
203
- }, _callee, this, [[6, 26]]);
201
+ }, _callee, this, [[5, 25]]);
204
202
  }));
205
203
 
206
204
  function UNSAFE_componentWillMount() {
@@ -263,7 +261,7 @@ function getAppInstance(appInfo, manifest) {
263
261
  return MicroApp;
264
262
  }(React.Component);
265
263
 
266
- return Loadable(withRouter(MicroApp))(LoadingComponent);
264
+ return Loadable(withRouter(MicroApp))(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
267
265
  }
268
266
 
269
267
  export function generateApps(options, manifest) {
@@ -271,7 +269,7 @@ export function generateApps(options, manifest) {
271
269
 
272
270
  var apps = {};
273
271
  (_options$apps = options.apps) === null || _options$apps === void 0 ? void 0 : _options$apps.forEach(function (appInfo) {
274
- var Component = getAppInstance(appInfo, manifest);
272
+ var Component = getAppInstance(options, appInfo, manifest);
275
273
  appInfo.Component = Component;
276
274
  apps[appInfo.name] = Component;
277
275
  });
@@ -1,17 +1,25 @@
1
- import { createPlugin, NormalizedConfig } from '@modern-js/core';
2
- declare type GetFirstArgumentOfFunction<T> = T extends (first: infer FirstArgument, ...args: any[]) => any ? FirstArgument : never;
3
- interface InitializerOptions {
4
- validateSchema: () => Array<any>;
5
- externals: any;
6
- componentKey: string;
7
- }
8
- declare type InitializerFn = GetFirstArgumentOfFunction<typeof createPlugin>;
9
- export declare const initializer: (options: InitializerOptions) => InitializerFn;
1
+ import { createPlugin } from '@modern-js/core';
2
+ export declare const externals: {
3
+ 'react-dom': string;
4
+ react: string;
5
+ };
6
+ declare type Initializer = Parameters<typeof createPlugin>[0];
7
+ declare type NonVoidPromiseAble<T> = T extends void | Promise<any> ? never : T;
8
+ export declare type LifeCycle = NonVoidPromiseAble<ReturnType<Initializer>>;
9
+ export declare const resolvedConfig: NonNullable<LifeCycle['resolvedConfig']>;
10
+ export declare const initializer: (hooks: {
11
+ resolvedConfig: LifeCycle['resolvedConfig'];
12
+ validateSchema: LifeCycle['validateSchema'];
13
+ }, initializerConfig: {
14
+ runtimePluginName?: string;
15
+ defaultEnableHtmlEntry?: boolean;
16
+ defaultExternalBasicLibrary?: boolean;
17
+ }) => Initializer;
10
18
 
11
19
  declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
12
20
  config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
13
21
  resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
14
- resolved: NormalizedConfig;
22
+ resolved: import("@modern-js/core").NormalizedConfig;
15
23
  }>;
16
24
  validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
17
25
  prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
@@ -1,2 +1,5 @@
1
- export declare const makeProvider: (componentKey: string) => string;
2
- export declare const makeRenderFunction: (code: string) => string;
1
+ import { NormalizedConfig } from '@modern-js/core';
2
+ export declare const makeProvider: () => string;
3
+ export declare const makeRenderFunction: (code: string) => string;
4
+ export declare function getRuntimeConfig(config: Partial<NormalizedConfig>): any;
5
+ export declare function setRuntimeConfig(config: Partial<NormalizedConfig>, key: string, value: any): undefined;
@@ -1 +1,2 @@
1
- export { default } from './cli';
1
+ export { default } from './runtime';
2
+ export * from './runtime';
@@ -1,2 +1,4 @@
1
1
  export { default } from './plugin';
2
- export * from './useModuleApps';
2
+ export { useModuleApps, useMicroApps, useModuleApp } from './useModuleApps';
3
+ export type { Manifest, ModuleInfo } from './useModuleApps';
4
+ export { default as Garfish } from 'garfish';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { LoadingComponent, MicroComponentProps } from './useModuleApps';
2
+ import { LoadableConfig, MicroComponentProps } from './useModuleApps';
3
3
  export interface MicroProps {
4
4
  setLoadingState: (state: {
5
5
  isLoading?: boolean;
@@ -7,16 +7,13 @@ export interface MicroProps {
7
7
  }) => void;
8
8
  [key: string]: any;
9
9
  }
10
- export declare function Loadable(WrapComponent: any): (defaultLoadingComponent?: LoadingComponent | undefined) => {
10
+ export declare function Loadable(WrapComponent: any): (defaultLoadable?: LoadableConfig | undefined) => {
11
11
  new (props: MicroComponentProps | Readonly<MicroComponentProps>): {
12
12
  state: {
13
13
  error: any;
14
14
  pastDelay: boolean;
15
15
  timedOut: boolean;
16
16
  isLoading: boolean;
17
- delay: number;
18
- timeout: number;
19
- LoadingComponent?: LoadingComponent;
20
17
  };
21
18
  mounted: boolean;
22
19
  delay: NodeJS.Timeout | undefined;
@@ -53,9 +50,6 @@ export declare function Loadable(WrapComponent: any): (defaultLoadingComponent?:
53
50
  pastDelay: boolean;
54
51
  timedOut: boolean;
55
52
  isLoading: boolean;
56
- delay: number;
57
- timeout: number;
58
- LoadingComponent?: LoadingComponent;
59
53
  };
60
54
  mounted: boolean;
61
55
  delay: NodeJS.Timeout | undefined;
@@ -1,3 +1,29 @@
1
- declare const _default: any;
2
-
3
- export default _default;
1
+ import React from 'react';
2
+ import { Config } from './useModuleApps';
3
+ declare const GarfishPlugin: (config: Config) => import("@modern-js/core").Plugin<Partial<import("@modern-js/runtime-core").Progresses2Threads<{
4
+ hoc: import("@modern-js/runtime-core").Pipeline<{
5
+ App: React.ComponentType<any>;
6
+ }, React.ComponentType<any>>;
7
+ provide: import("@modern-js/runtime-core").Pipeline<{
8
+ element: JSX.Element;
9
+ readonly props: import("@modern-js/runtime-core/src/plugin").AppProps;
10
+ readonly context: import("@modern-js/runtime-core").RuntimeContext;
11
+ }, JSX.Element>;
12
+ client: import("@modern-js/runtime-core").AsyncPipeline<{
13
+ App: React.ComponentType<any>;
14
+ readonly context?: import("@modern-js/runtime-core").RuntimeContext | undefined;
15
+ rootElement: HTMLElement;
16
+ }, void>;
17
+ server: import("@modern-js/runtime-core").AsyncPipeline<{
18
+ App: React.ComponentType<any>;
19
+ readonly context?: import("@modern-js/runtime-core").RuntimeContext | undefined;
20
+ }, string>;
21
+ init: import("@modern-js/runtime-core").AsyncPipeline<{
22
+ context: import("@modern-js/runtime-core").RuntimeContext;
23
+ }, unknown>;
24
+ pickContext: import("@modern-js/runtime-core").Pipeline<{
25
+ context: import("@modern-js/runtime-core").RuntimeContext;
26
+ pickedContext: import("@modern-js/runtime-core").TRuntimeContext;
27
+ }, import("@modern-js/runtime-core").TRuntimeContext>;
28
+ } & import("@modern-js/runtime-core").ClearDraftProgress<{}>>>>;
29
+ export default GarfishPlugin;
@@ -7,13 +7,8 @@ export declare type ModuleInfo = GarfishInterfaces.AppInfo & {
7
7
  export declare type ModulesInfo = Array<ModuleInfo>;
8
8
  export declare type Manifest = {
9
9
  modules?: ModulesInfo;
10
+ loadable?: LoadableConfig;
10
11
  getAppList?: () => Promise<Array<GarfishInterfaces.AppInfo>>;
11
- LoadingComponent?: LoadingComponent;
12
- componentKey?: string;
13
- };
14
- export declare type ModernGarfishConfig = {
15
- LoadingComponent?: LoadingComponent;
16
- manifest?: Manifest;
17
12
  };
18
13
  export declare type LoadingComponent = React.ComponentType<{
19
14
  isLoading: boolean;
@@ -22,13 +17,16 @@ export declare type LoadingComponent = React.ComponentType<{
22
17
  error: any;
23
18
  retry: () => void;
24
19
  }>;
25
- export interface LoadingConfig {
20
+ export interface LoadableConfig {
26
21
  timeout?: number;
27
22
  delay?: number;
28
- LoadingComponent?: LoadingComponent;
23
+ loading?: LoadingComponent;
29
24
  }
25
+ export declare type ModernGarfishConfig = {
26
+ manifest?: Manifest;
27
+ };
30
28
  export declare type MicroComponentProps = {
31
- loadingConfig: LoadingConfig;
29
+ loadable?: LoadableConfig;
32
30
  };
33
31
  export declare type Config = Partial<Options> & ModernGarfishConfig;
34
32
  export declare function useModuleApps(): Record<string, import("react").ComponentType<any>>;
@@ -9,18 +9,13 @@ declare global {
9
9
  };
10
10
  }
11
11
  }
12
- export declare function generateMApp(options: typeof Garfish.options, {
13
- LoadingComponent
14
- }: Manifest): {
12
+ export declare function generateMApp(options: typeof Garfish.options, manifest?: Manifest): {
15
13
  new (props: import("../useModuleApps").MicroComponentProps | Readonly<import("../useModuleApps").MicroComponentProps>): {
16
14
  state: {
17
15
  error: any;
18
16
  pastDelay: boolean;
19
17
  timedOut: boolean;
20
18
  isLoading: boolean;
21
- delay: number;
22
- timeout: number;
23
- LoadingComponent?: import("../useModuleApps").LoadingComponent | undefined;
24
19
  };
25
20
  mounted: boolean;
26
21
  delay: NodeJS.Timeout | undefined;
@@ -32,9 +27,6 @@ export declare function generateMApp(options: typeof Garfish.options, {
32
27
  pastDelay: boolean;
33
28
  timedOut: boolean;
34
29
  isLoading: boolean;
35
- delay: number;
36
- timeout: number;
37
- LoadingComponent?: import("../useModuleApps").LoadingComponent | undefined;
38
30
  }>): void;
39
31
  readonly retry: () => void;
40
32
  clearTimeouts(): void;
@@ -65,9 +57,6 @@ export declare function generateMApp(options: typeof Garfish.options, {
65
57
  pastDelay: boolean;
66
58
  timedOut: boolean;
67
59
  isLoading: boolean;
68
- delay: number;
69
- timeout: number;
70
- LoadingComponent?: import("../useModuleApps").LoadingComponent | undefined;
71
60
  };
72
61
  mounted: boolean;
73
62
  delay: NodeJS.Timeout | undefined;
@@ -79,9 +68,6 @@ export declare function generateMApp(options: typeof Garfish.options, {
79
68
  pastDelay: boolean;
80
69
  timedOut: boolean;
81
70
  isLoading: boolean;
82
- delay: number;
83
- timeout: number;
84
- LoadingComponent?: import("../useModuleApps").LoadingComponent | undefined;
85
71
  }>): void;
86
72
  readonly retry: () => void;
87
73
  clearTimeouts(): void;
@@ -4,7 +4,7 @@ import { Manifest, MicroComponentProps, ModulesInfo } from '../useModuleApps';
4
4
  export interface AppMap {
5
5
  [key: string]: React.ComponentType<MicroComponentProps>;
6
6
  }
7
- export declare function generateApps(options: typeof Garfish.options, manifest: Manifest): {
7
+ export declare function generateApps(options: typeof Garfish.options, manifest?: Manifest): {
8
8
  apps: AppMap;
9
9
  appInfoList: ModulesInfo;
10
10
  };
package/package.json CHANGED
@@ -11,9 +11,22 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.0",
14
+ "version": "1.4.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/runtime/index.d.ts",
17
+ "typesVersions": {
18
+ "*": {
19
+ ".": [
20
+ "./dist/types/runtime/index.d.ts"
21
+ ],
22
+ "cli": [
23
+ "./dist/types/cli/index.d.ts"
24
+ ],
25
+ "runtime": [
26
+ "./dist/types/runtime/index.d.ts"
27
+ ]
28
+ }
29
+ },
17
30
  "main": "./dist/js/node/index.js",
18
31
  "module": "./dist/js/treeshaking/runtime/index.js",
19
32
  "jsnext:modern": "./dist/js/modern/index.js",
@@ -33,7 +46,7 @@
33
46
  },
34
47
  "dependencies": {
35
48
  "@babel/runtime": "^7",
36
- "@modern-js/utils": "^1.3.0",
49
+ "@modern-js/utils": "^1.3.3",
37
50
  "@types/debug": "^4.1.7",
38
51
  "@types/react-loadable": "^5.5.6",
39
52
  "debug": "^4.3.2",
@@ -42,10 +55,10 @@
42
55
  "react-loadable": "^5.5.0"
43
56
  },
44
57
  "devDependencies": {
45
- "@modern-js/core": "^1.4.0",
58
+ "@modern-js/core": "^1.4.4",
46
59
  "@modern-js/plugin-router": "^1.2.2",
47
- "@modern-js/runtime-core": "^1.2.2",
48
- "@modern-js/types": "^1.3.0",
60
+ "@modern-js/runtime-core": "^1.2.4",
61
+ "@modern-js/types": "^1.3.4",
49
62
  "@scripts/build": "0.0.0",
50
63
  "@scripts/jest-config": "0.0.0",
51
64
  "@testing-library/jest-dom": "^5.16.1",
@@ -53,11 +66,10 @@
53
66
  "@testing-library/react-hooks": "^7.0.1",
54
67
  "@testing-library/user-event": "^13.5.0",
55
68
  "@types/hoist-non-react-statics": "^3.3.1",
56
- "@types/jest": "^26",
69
+ "@types/jest": "^26.0.24",
57
70
  "@types/node": "^14",
58
71
  "@types/react": "^17",
59
72
  "@types/react-dom": "^17",
60
- "html-webpack-externals-plugin": "^3.8.0",
61
73
  "jest": "^27",
62
74
  "jest-fetch-mock": "^3.0.3",
63
75
  "react": "^17.0.2",
@@ -67,9 +79,9 @@
67
79
  "webpack-chain": "^6.5.1"
68
80
  },
69
81
  "peerDependencies": {
70
- "@modern-js/core": "^1.4.0",
82
+ "@modern-js/core": "^1.4.4",
71
83
  "@modern-js/plugin-router": "^1.2.2",
72
- "@modern-js/runtime-core": "^1.2.2"
84
+ "@modern-js/runtime-core": "^1.2.4"
73
85
  },
74
86
  "sideEffects": false,
75
87
  "modernConfig": {},