@modern-js/plugin-garfish 1.3.0 → 1.3.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.
- package/.eslintrc.js +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/js/modern/cli/index.js +190 -209
- package/dist/js/modern/cli/utils.js +1 -6
- package/dist/js/modern/index.js +2 -1
- package/dist/js/modern/runtime/index.js +2 -1
- package/dist/js/modern/runtime/loadable.js +36 -19
- package/dist/js/modern/runtime/plugin.js +14 -17
- package/dist/js/modern/runtime/utils/MApp.js +7 -10
- package/dist/js/modern/runtime/utils/apps.js +1 -4
- package/dist/js/node/cli/index.js +192 -213
- package/dist/js/node/cli/utils.js +1 -6
- package/dist/js/node/index.js +18 -3
- package/dist/js/node/runtime/index.js +25 -12
- package/dist/js/node/runtime/loadable.js +36 -19
- package/dist/js/node/runtime/plugin.js +11 -16
- package/dist/js/node/runtime/utils/MApp.js +7 -10
- package/dist/js/node/runtime/utils/apps.js +1 -4
- package/dist/js/treeshaking/cli/index.js +183 -199
- package/dist/js/treeshaking/cli/utils.js +2 -2
- package/dist/js/treeshaking/index.js +2 -1
- package/dist/js/treeshaking/runtime/index.js +2 -1
- package/dist/js/treeshaking/runtime/loadable.js +39 -25
- package/dist/js/treeshaking/runtime/plugin.js +15 -19
- package/dist/js/treeshaking/runtime/utils/MApp.js +23 -31
- package/dist/js/treeshaking/runtime/utils/apps.js +1 -2
- package/dist/types/cli/index.d.ts +1 -9
- package/dist/types/cli/utils.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/runtime/index.d.ts +3 -1
- package/dist/types/runtime/loadable.d.ts +2 -8
- package/dist/types/runtime/plugin.d.ts +29 -3
- package/dist/types/runtime/useModuleApps.d.ts +7 -9
- package/dist/types/runtime/utils/MApp.d.ts +1 -15
- package/dist/types/runtime/utils/apps.d.ts +1 -1
- package/package.json +20 -8
- package/tests/cli.test.tsx +21 -43
- package/tests/hooks.test.tsx +1 -0
- package/tests/index.test.tsx +6 -3
- package/tsconfig.json +3 -2
- 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"
|
|
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,13 @@ 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
|
-
|
|
63
|
-
|
|
63
|
+
_window3,
|
|
64
|
+
_window3$modern_manif,
|
|
64
65
|
_args2 = arguments;
|
|
65
66
|
|
|
66
67
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -69,7 +70,7 @@ function _initOptions() {
|
|
|
69
70
|
case 0:
|
|
70
71
|
manifest = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
71
72
|
options = _args2.length > 1 ? _args2[1] : undefined;
|
|
72
|
-
apps = []; // use manifest modules
|
|
73
|
+
apps = options.apps || []; // use manifest modules
|
|
73
74
|
|
|
74
75
|
if (manifest !== null && manifest !== void 0 && manifest.modules) {
|
|
75
76
|
apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
|
|
@@ -91,14 +92,14 @@ function _initOptions() {
|
|
|
91
92
|
|
|
92
93
|
case 9:
|
|
93
94
|
// 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 = (
|
|
95
|
+
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) {
|
|
96
|
+
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
97
|
logger('modern_manifest', apps);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
return _context2.abrupt("return", _objectSpread({
|
|
100
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, options), {}, {
|
|
100
101
|
apps: apps
|
|
101
|
-
}
|
|
102
|
+
}));
|
|
102
103
|
|
|
103
104
|
case 11:
|
|
104
105
|
case "end":
|
|
@@ -110,22 +111,15 @@ function _initOptions() {
|
|
|
110
111
|
return _initOptions.apply(this, arguments);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
var GarfishPlugin = function GarfishPlugin(config) {
|
|
114
115
|
setExternal();
|
|
115
116
|
|
|
116
|
-
var
|
|
117
|
-
manifest = _config$manifest === void 0 ? {} : _config$manifest,
|
|
118
|
-
LoadingComponent = config.LoadingComponent,
|
|
117
|
+
var manifest = config.manifest,
|
|
119
118
|
options = _objectWithoutProperties(config, _excluded);
|
|
120
119
|
|
|
121
120
|
logger('createPlugin', {
|
|
122
121
|
config: config
|
|
123
122
|
});
|
|
124
|
-
|
|
125
|
-
if (!manifest.LoadingComponent && LoadingComponent) {
|
|
126
|
-
manifest.LoadingComponent = LoadingComponent;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
123
|
var promise = initOptions(manifest, options);
|
|
130
124
|
return createPlugin(function () {
|
|
131
125
|
return {
|
|
@@ -227,4 +221,6 @@ export default (function (config) {
|
|
|
227
221
|
}
|
|
228
222
|
};
|
|
229
223
|
});
|
|
230
|
-
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
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,
|
|
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
|
-
|
|
121
|
-
},
|
|
122
|
-
errorMountApp: function errorMountApp(error) {
|
|
123
|
-
// logger('MApp errorMountApp', args);
|
|
111
|
+
logger('MApp errorLoadApp', 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
|
-
|
|
133
|
-
},
|
|
134
|
-
errorUnmountApp: function errorUnmountApp(error) {
|
|
135
|
-
// logger('MApp errorUnmountApp', args);
|
|
122
|
+
logger('MApp errorMountApp', 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', 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)(
|
|
171
|
+
return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
180
172
|
}
|
|
@@ -55,7 +55,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
55
55
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
56
56
|
|
|
57
57
|
function getAppInstance(appInfo, manifest) {
|
|
58
|
-
var LoadingComponent = manifest.LoadingComponent;
|
|
59
58
|
var locationHref = '';
|
|
60
59
|
|
|
61
60
|
var MicroApp = /*#__PURE__*/function (_React$Component) {
|
|
@@ -263,7 +262,7 @@ function getAppInstance(appInfo, manifest) {
|
|
|
263
262
|
return MicroApp;
|
|
264
263
|
}(React.Component);
|
|
265
264
|
|
|
266
|
-
return Loadable(withRouter(MicroApp))(
|
|
265
|
+
return Loadable(withRouter(MicroApp))(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
export function generateApps(options, manifest) {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 { NormalizedConfig } from '@modern-js/core';
|
|
10
2
|
|
|
11
3
|
declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
|
|
12
4
|
config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const makeProvider: (
|
|
1
|
+
export declare const makeProvider: () => string;
|
|
2
2
|
export declare const makeRenderFunction: (code: string) => string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './runtime';
|
|
2
|
+
export * from './runtime';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
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): (
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
20
|
+
export interface LoadableConfig {
|
|
26
21
|
timeout?: number;
|
|
27
22
|
delay?: number;
|
|
28
|
-
|
|
23
|
+
loading?: LoadingComponent;
|
|
29
24
|
}
|
|
25
|
+
export declare type ModernGarfishConfig = {
|
|
26
|
+
manifest?: Manifest;
|
|
27
|
+
};
|
|
30
28
|
export declare type MicroComponentProps = {
|
|
31
|
-
|
|
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
|
|
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.
|
|
14
|
+
"version": "1.3.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.
|
|
49
|
+
"@modern-js/utils": "^1.3.1",
|
|
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.
|
|
58
|
+
"@modern-js/core": "^1.4.1",
|
|
46
59
|
"@modern-js/plugin-router": "^1.2.2",
|
|
47
60
|
"@modern-js/runtime-core": "^1.2.2",
|
|
48
|
-
"@modern-js/types": "^1.3.
|
|
61
|
+
"@modern-js/types": "^1.3.1",
|
|
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,7 +66,7 @@
|
|
|
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",
|
|
@@ -67,7 +80,7 @@
|
|
|
67
80
|
"webpack-chain": "^6.5.1"
|
|
68
81
|
},
|
|
69
82
|
"peerDependencies": {
|
|
70
|
-
"@modern-js/core": "^1.4.
|
|
83
|
+
"@modern-js/core": "^1.4.1",
|
|
71
84
|
"@modern-js/plugin-router": "^1.2.2",
|
|
72
85
|
"@modern-js/runtime-core": "^1.2.2"
|
|
73
86
|
},
|
|
@@ -75,8 +88,7 @@
|
|
|
75
88
|
"modernConfig": {},
|
|
76
89
|
"publishConfig": {
|
|
77
90
|
"registry": "https://registry.npmjs.org/",
|
|
78
|
-
"access": "public"
|
|
79
|
-
"types": "./dist/types/runtime/index.d.ts"
|
|
91
|
+
"access": "public"
|
|
80
92
|
},
|
|
81
93
|
"scripts": {
|
|
82
94
|
"new": "modern new",
|
package/tests/cli.test.tsx
CHANGED
|
@@ -1,50 +1,28 @@
|
|
|
1
1
|
import '@testing-library/jest-dom';
|
|
2
|
-
import
|
|
3
|
-
import { makeProvider } from '../src/cli/utils';
|
|
4
|
-
import GarfishPlugin, { initializer } from '../src/cli';
|
|
2
|
+
import GarfishPlugin from '../src/cli';
|
|
5
3
|
|
|
6
|
-
jest.mock('@modern-js/core', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
4
|
+
// jest.mock('@modern-js/core', () => {
|
|
5
|
+
// const originalModule = jest.requireActual('@modern-js/core');
|
|
6
|
+
// return {
|
|
7
|
+
// __esModule: true,
|
|
8
|
+
// ...originalModule,
|
|
9
|
+
// default: jest.fn(() => 'mocked baz'),
|
|
10
|
+
// useResolvedConfigContext: () => ({
|
|
11
|
+
// runtime: {
|
|
12
|
+
// masterApp: {
|
|
13
|
+
// manifest: {
|
|
14
|
+
// componentKey: 'test-dynamic-key',
|
|
15
|
+
// },
|
|
16
|
+
// },
|
|
17
|
+
// },
|
|
18
|
+
// deploy: {
|
|
19
|
+
// microFrontend: 'dynamicComponentKey',
|
|
20
|
+
// },
|
|
21
|
+
// }),
|
|
22
|
+
// };
|
|
23
|
+
// });
|
|
26
24
|
|
|
27
25
|
describe('plugin-garfish cli', () => {
|
|
28
|
-
test('makeProvider', async () => {
|
|
29
|
-
const garfishExport = makeProvider('modernJSExportComponent');
|
|
30
|
-
expect(garfishExport).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('test modifyEntryExport', () => {
|
|
34
|
-
const lifeCycle: any = initializer({
|
|
35
|
-
validateSchema() {
|
|
36
|
-
return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
37
|
-
},
|
|
38
|
-
externals: { 'react-dom': 'react-dom', react: 'react' },
|
|
39
|
-
componentKey: 'test-dynamic-key',
|
|
40
|
-
})();
|
|
41
|
-
const { exportStatement } = lifeCycle.modifyEntryExport({
|
|
42
|
-
entrypoint: 'hello',
|
|
43
|
-
exportStatement: '',
|
|
44
|
-
});
|
|
45
|
-
expect(exportStatement).toMatchSnapshot();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
26
|
test('cli garfish plugin', () => {
|
|
49
27
|
expect(GarfishPlugin.name).toBe('@modern-js/plugin-garfish');
|
|
50
28
|
});
|
package/tests/hooks.test.tsx
CHANGED
package/tests/index.test.tsx
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
useLocation,
|
|
13
13
|
MemoryRouter,
|
|
14
14
|
} from '@modern-js/plugin-router';
|
|
15
|
-
import ModernGarfishPlugin
|
|
15
|
+
import ModernGarfishPlugin from '../src/runtime';
|
|
16
|
+
import { useMicroApps } from '../src';
|
|
16
17
|
import {
|
|
17
18
|
TABLE_LIST_ESCAPE_NODE,
|
|
18
19
|
TABLE_LIST_HTML,
|
|
@@ -99,8 +100,10 @@ describe('plugin-garfish', () => {
|
|
|
99
100
|
const microFrontendConfig = {
|
|
100
101
|
apps: [tableListModuleInfo, dashBoardModuleInfo, userInfo],
|
|
101
102
|
manifest: {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
loadable: {
|
|
104
|
+
loading: ()=> {
|
|
105
|
+
return <div data-testid="loading-id">loading</div>;
|
|
106
|
+
}
|
|
104
107
|
},
|
|
105
108
|
},
|
|
106
109
|
};
|
package/tsconfig.json
CHANGED