@modern-js/plugin-garfish 1.4.2 → 1.4.4-beta.2
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/CHANGELOG.md +9 -0
- package/dist/js/modern/cli/index.js +202 -211
- package/dist/js/modern/cli/utils.js +8 -6
- package/dist/js/modern/runtime/index.js +1 -1
- package/dist/js/modern/runtime/plugin.js +1 -2
- package/dist/js/modern/runtime/useModuleApps.js +28 -21
- package/dist/js/node/cli/index.js +201 -218
- package/dist/js/node/cli/utils.js +8 -6
- package/dist/js/node/runtime/index.js +0 -6
- package/dist/js/node/runtime/plugin.js +1 -2
- package/dist/js/node/runtime/useModuleApps.js +32 -23
- package/dist/js/treeshaking/cli/index.js +217 -221
- package/dist/js/treeshaking/cli/utils.js +2 -2
- package/dist/js/treeshaking/runtime/index.js +1 -1
- package/dist/js/treeshaking/runtime/plugin.js +1 -2
- package/dist/js/treeshaking/runtime/useModuleApps.js +29 -21
- package/dist/types/cli/index.d.ts +9 -31
- package/dist/types/cli/utils.d.ts +1 -1
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/plugin.d.ts +2 -2
- package/dist/types/runtime/useModuleApps.d.ts +7 -7
- package/dist/types/runtime/utils/Context.d.ts +1 -1
- package/dist/types/runtime/utils/apps.d.ts +2 -2
- package/package.json +6 -6
- package/tests/__snapshots__/cli.test.tsx.snap +82 -0
- package/tests/cli.test.tsx +80 -96
- package/tests/hooks.test.tsx +1 -7
- package/tests/index.test.tsx +7 -7
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.externals = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
-
var _core = require("@modern-js/core");
|
|
13
|
-
|
|
14
12
|
var _util = require("../util");
|
|
15
13
|
|
|
16
14
|
var _utils2 = require("./utils");
|
|
@@ -29,259 +27,244 @@ const externals = {
|
|
|
29
27
|
};
|
|
30
28
|
exports.externals = externals;
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
30
|
+
var _default = ({
|
|
31
|
+
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
|
|
32
|
+
mfPackagePath: _mfPackagePath = _path.default.resolve(__dirname, '../../../../')
|
|
33
|
+
} = {}) => ({
|
|
34
|
+
name: '@modern-js/plugin-garfish',
|
|
35
|
+
setup: ({
|
|
36
|
+
useAppContext,
|
|
37
|
+
useResolvedConfigContext
|
|
38
|
+
}) => {
|
|
39
|
+
let pluginsExportsUtils;
|
|
40
|
+
let runtimeExportsUtils;
|
|
41
|
+
return {
|
|
42
|
+
validateSchema() {
|
|
43
|
+
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
resolvedConfig: async config => {
|
|
47
|
+
const {
|
|
48
|
+
resolved
|
|
49
|
+
} = config;
|
|
50
|
+
const {
|
|
51
|
+
masterApp,
|
|
52
|
+
router
|
|
53
|
+
} = (0, _utils2.getRuntimeConfig)(resolved);
|
|
54
|
+
const nConfig = {
|
|
55
|
+
resolved: _objectSpread({}, resolved)
|
|
56
|
+
};
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
if (masterApp) {
|
|
59
|
+
var _router$historyOption;
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
|
|
69
|
-
defaultEnableHtmlEntry: _defaultEnableHtmlEntry = true,
|
|
70
|
-
defaultExternalBasicLibrary: _defaultExternalBasicLibrary = false
|
|
71
|
-
}) => () => {
|
|
72
|
-
let pluginsExportsUtils;
|
|
73
|
-
let runtimeExportsUtils;
|
|
74
|
-
return {
|
|
75
|
-
validateSchema,
|
|
76
|
-
resolvedConfig,
|
|
77
|
-
|
|
78
|
-
config() {
|
|
79
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
80
|
-
const config = (0, _core.useAppContext)();
|
|
81
|
-
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'plugins');
|
|
82
|
-
runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'index');
|
|
83
|
-
return {
|
|
84
|
-
source: {
|
|
85
|
-
alias: {
|
|
86
|
-
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
tools: {
|
|
90
|
-
webpack: (webpackConfig, {
|
|
91
|
-
chain,
|
|
92
|
-
webpack,
|
|
93
|
-
env: _env = process.env.NODE_ENV || 'development'
|
|
94
|
-
}) => {
|
|
95
|
-
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
61
|
+
// basename does not exist use router's basename
|
|
62
|
+
(0, _utils2.setRuntimeConfig)(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
|
|
63
|
+
basename: (router === null || router === void 0 ? void 0 : (_router$historyOption = router.historyOptions) === null || _router$historyOption === void 0 ? void 0 : _router$historyOption.basename) || (router === null || router === void 0 ? void 0 : router.basename) || '/'
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
96
66
|
|
|
97
|
-
|
|
98
|
-
|
|
67
|
+
(0, _util.logger)(`resolvedConfig`, {
|
|
68
|
+
runtime: nConfig.resolved.runtime,
|
|
69
|
+
deploy: nConfig.resolved.deploy,
|
|
70
|
+
server: nConfig.resolved.server
|
|
71
|
+
});
|
|
72
|
+
return nConfig;
|
|
73
|
+
},
|
|
99
74
|
|
|
100
|
-
|
|
101
|
-
|
|
75
|
+
config() {
|
|
76
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
77
|
+
const config = useAppContext(); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
102
78
|
|
|
103
|
-
|
|
79
|
+
const resolveOptions = useResolvedConfigContext();
|
|
80
|
+
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'plugins');
|
|
81
|
+
runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'index');
|
|
82
|
+
return {
|
|
83
|
+
source: {
|
|
84
|
+
alias: {
|
|
85
|
+
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
tools: {
|
|
89
|
+
webpack: (webpackConfig, {
|
|
90
|
+
chain,
|
|
91
|
+
webpack,
|
|
92
|
+
env: _env = process.env.NODE_ENV || 'development'
|
|
93
|
+
}) => {
|
|
94
|
+
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
95
|
+
|
|
96
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
97
|
+
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
98
|
+
|
|
99
|
+
chain.output.libraryTarget('umd');
|
|
100
|
+
chain.devServer.headers({
|
|
101
|
+
'Access-Control-Allow-Origin': '*'
|
|
102
|
+
});
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
105
|
+
chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
|
|
106
|
+
} // add comments avoid sourcemap abnormal
|
|
108
107
|
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
if (webpack.BannerPlugin) {
|
|
110
|
+
chain.plugin('banner').use(webpack.BannerPlugin, [{
|
|
111
|
+
banner: 'Micro front-end'
|
|
112
|
+
}]);
|
|
113
|
+
}
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
const {
|
|
116
|
+
enableHtmlEntry = true,
|
|
117
|
+
externalBasicLibrary = false
|
|
118
|
+
} = typeof (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend) === 'object' ? resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions$deplo3 = resolveOptions.deploy) === null || _resolveOptions$deplo3 === void 0 ? void 0 : _resolveOptions$deplo3.microFrontend : {}; // external
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
if (externalBasicLibrary) {
|
|
121
|
+
chain.externals(externals);
|
|
122
|
+
} // use html mode
|
|
124
123
|
|
|
125
124
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
if (!enableHtmlEntry) {
|
|
126
|
+
chain.output.filename('index.js');
|
|
127
|
+
chain.plugins.delete('html-main');
|
|
128
|
+
chain.optimization.runtimeChunk(false);
|
|
129
|
+
chain.optimization.splitChunks({
|
|
130
|
+
chunks: 'async'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
133
|
}
|
|
134
|
-
}
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
const resolveWebpackConfig = chain.toConfig();
|
|
136
|
+
(0, _util.logger)('webpackConfig', {
|
|
137
|
+
output: resolveWebpackConfig.output,
|
|
138
|
+
externals: resolveWebpackConfig.externals,
|
|
139
|
+
env: _env,
|
|
140
|
+
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
143
|
}
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
addRuntimeExports() {
|
|
148
|
+
const addExportStatement = `export { default as garfish, default as masterApp } from '${_mfPackagePath}'`;
|
|
149
|
+
(0, _util.logger)('exportStatement', addExportStatement);
|
|
150
|
+
pluginsExportsUtils.addExport(addExportStatement);
|
|
151
|
+
runtimeExportsUtils.addExport(`export * from '${_mfPackagePath}'`);
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
modifyEntryImports({
|
|
155
|
+
entrypoint,
|
|
156
|
+
imports
|
|
157
|
+
}) {
|
|
158
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
159
|
+
const config = useResolvedConfigContext();
|
|
160
|
+
const {
|
|
161
|
+
masterApp
|
|
162
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
163
|
+
|
|
164
|
+
if (masterApp) {
|
|
165
|
+
imports.push({
|
|
166
|
+
value: _runtimePluginName,
|
|
167
|
+
specifiers: [{
|
|
168
|
+
imported: 'garfish'
|
|
169
|
+
}]
|
|
170
|
+
});
|
|
171
|
+
imports.push({
|
|
172
|
+
value: _runtimePluginName,
|
|
173
|
+
specifiers: [{
|
|
174
|
+
imported: 'masterApp'
|
|
175
|
+
}]
|
|
176
|
+
});
|
|
144
177
|
}
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
addRuntimeExports() {
|
|
149
|
-
const mfPackage = _path.default.resolve(__dirname, '../../../../');
|
|
150
|
-
|
|
151
|
-
const addExportStatement = `export { default as garfish, default as masterApp } from '${mfPackage}'`;
|
|
152
|
-
(0, _util.logger)('exportStatement', addExportStatement);
|
|
153
|
-
pluginsExportsUtils.addExport(addExportStatement);
|
|
154
|
-
runtimeExportsUtils.addExport(`export * from '${mfPackage}'`);
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
modifyEntryImports({
|
|
158
|
-
entrypoint,
|
|
159
|
-
imports
|
|
160
|
-
}) {
|
|
161
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
162
|
-
const config = (0, _core.useResolvedConfigContext)();
|
|
163
|
-
const {
|
|
164
|
-
masterApp
|
|
165
|
-
} = (0, _utils2.getRuntimeConfig)(config);
|
|
166
|
-
|
|
167
|
-
if (masterApp) {
|
|
168
|
-
imports.push({
|
|
169
|
-
value: _runtimePluginName,
|
|
170
|
-
specifiers: [{
|
|
171
|
-
imported: 'garfish'
|
|
172
|
-
}]
|
|
173
|
-
});
|
|
178
|
+
|
|
174
179
|
imports.push({
|
|
175
|
-
value:
|
|
180
|
+
value: 'react-dom',
|
|
176
181
|
specifiers: [{
|
|
177
|
-
imported: '
|
|
182
|
+
imported: 'unmountComponentAtNode'
|
|
183
|
+
}, {
|
|
184
|
+
imported: 'createPortal'
|
|
178
185
|
}]
|
|
179
186
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
imported: 'unmountComponentAtNode'
|
|
186
|
-
}, {
|
|
187
|
-
imported: 'createPortal'
|
|
188
|
-
}]
|
|
189
|
-
});
|
|
190
|
-
return {
|
|
191
|
-
imports,
|
|
192
|
-
entrypoint
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
modifyEntryRuntimePlugins({
|
|
197
|
-
entrypoint,
|
|
198
|
-
plugins
|
|
199
|
-
}) {
|
|
200
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
201
|
-
const config = (0, _core.useResolvedConfigContext)();
|
|
202
|
-
const {
|
|
203
|
-
masterApp
|
|
204
|
-
} = (0, _utils2.getRuntimeConfig)(config);
|
|
205
|
-
|
|
206
|
-
if (masterApp) {
|
|
207
|
-
(0, _util.logger)('garfishPlugin options', masterApp);
|
|
208
|
-
plugins.push({
|
|
209
|
-
name: 'garfish',
|
|
210
|
-
args: 'masterApp',
|
|
211
|
-
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
212
|
-
});
|
|
213
|
-
}
|
|
187
|
+
return {
|
|
188
|
+
imports,
|
|
189
|
+
entrypoint
|
|
190
|
+
};
|
|
191
|
+
},
|
|
214
192
|
|
|
215
|
-
|
|
193
|
+
modifyEntryRuntimePlugins({
|
|
216
194
|
entrypoint,
|
|
217
195
|
plugins
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
196
|
+
}) {
|
|
197
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
198
|
+
const config = useResolvedConfigContext();
|
|
199
|
+
const {
|
|
200
|
+
masterApp
|
|
201
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
202
|
+
|
|
203
|
+
if (masterApp) {
|
|
204
|
+
(0, _util.logger)('garfishPlugin options', masterApp);
|
|
205
|
+
plugins.push({
|
|
206
|
+
name: 'garfish',
|
|
207
|
+
args: 'masterApp',
|
|
208
|
+
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
229
211
|
|
|
230
|
-
if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
|
|
231
212
|
return {
|
|
232
213
|
entrypoint,
|
|
233
|
-
|
|
214
|
+
plugins
|
|
234
215
|
};
|
|
235
|
-
}
|
|
216
|
+
},
|
|
236
217
|
|
|
237
|
-
|
|
238
|
-
(0, _util.logger)('makeRenderFunction', nCode);
|
|
239
|
-
return {
|
|
218
|
+
modifyEntryRenderFunction({
|
|
240
219
|
entrypoint,
|
|
241
|
-
code
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
(0, _util.logger)('
|
|
220
|
+
code
|
|
221
|
+
}) {
|
|
222
|
+
var _config$deploy;
|
|
223
|
+
|
|
224
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
225
|
+
const config = useResolvedConfigContext();
|
|
226
|
+
|
|
227
|
+
if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
|
|
228
|
+
return {
|
|
229
|
+
entrypoint,
|
|
230
|
+
code
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const nCode = (0, _utils2.makeRenderFunction)(code);
|
|
235
|
+
(0, _util.logger)('makeRenderFunction', nCode);
|
|
257
236
|
return {
|
|
258
237
|
entrypoint,
|
|
259
|
-
|
|
238
|
+
code: nCode
|
|
260
239
|
};
|
|
261
|
-
}
|
|
240
|
+
},
|
|
262
241
|
|
|
263
|
-
|
|
242
|
+
modifyEntryExport({
|
|
264
243
|
entrypoint,
|
|
265
244
|
exportStatement
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
245
|
+
}) {
|
|
246
|
+
var _config$deploy2;
|
|
247
|
+
|
|
248
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
249
|
+
const config = useResolvedConfigContext();
|
|
250
|
+
|
|
251
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
|
|
252
|
+
const exportStatementCode = (0, _utils2.makeProvider)();
|
|
253
|
+
(0, _util.logger)('exportStatement', exportStatementCode);
|
|
254
|
+
return {
|
|
255
|
+
entrypoint,
|
|
256
|
+
exportStatement: exportStatementCode
|
|
257
|
+
};
|
|
258
|
+
}
|
|
273
259
|
|
|
274
|
-
|
|
275
|
-
|
|
260
|
+
return {
|
|
261
|
+
entrypoint,
|
|
262
|
+
exportStatement
|
|
263
|
+
};
|
|
264
|
+
}
|
|
276
265
|
|
|
277
|
-
|
|
278
|
-
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
266
|
+
};
|
|
279
267
|
}
|
|
280
|
-
|
|
281
|
-
}, {
|
|
282
|
-
runtimePluginName: '@modern-js/runtime/plugins'
|
|
283
|
-
}), {
|
|
284
|
-
name: '@modern-js/plugin-garfish'
|
|
285
268
|
});
|
|
286
269
|
|
|
287
270
|
exports.default = _default;
|
|
@@ -8,13 +8,15 @@ exports.makeRenderFunction = exports.makeProvider = void 0;
|
|
|
8
8
|
exports.setRuntimeConfig = setRuntimeConfig;
|
|
9
9
|
|
|
10
10
|
const makeProvider = () => `
|
|
11
|
-
export const provider = function ({basename, dom
|
|
11
|
+
export const provider = function ({basename, dom}) {
|
|
12
12
|
return {
|
|
13
|
-
render({basename, dom}) {
|
|
14
|
-
|
|
15
|
-
const SubApp = render({props, basename});
|
|
13
|
+
render({basename, dom, props}) {
|
|
14
|
+
const SubApp = render({ props, basename });
|
|
16
15
|
const node = dom.querySelector('#' + MOUNT_ID) || dom;
|
|
17
|
-
|
|
16
|
+
const App = function () {
|
|
17
|
+
return React.createElement(SubApp, props)
|
|
18
|
+
};
|
|
19
|
+
bootstrap(App, node);
|
|
18
20
|
},
|
|
19
21
|
destroy({ dom }) {
|
|
20
22
|
const node = dom.querySelector('#' + MOUNT_ID) || dom;
|
|
@@ -85,7 +87,7 @@ function getRuntimeConfig(config) {
|
|
|
85
87
|
return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
return config === null || config === void 0 ? void 0 : config.runtime;
|
|
90
|
+
return (config === null || config === void 0 ? void 0 : config.runtime) || {};
|
|
89
91
|
} // support legacy config
|
|
90
92
|
|
|
91
93
|
|
|
@@ -15,12 +15,6 @@ Object.defineProperty(exports, "default", {
|
|
|
15
15
|
return _plugin.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "useMicroApps", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _useModuleApps.useMicroApps;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
18
|
Object.defineProperty(exports, "useModuleApp", {
|
|
25
19
|
enumerable: true,
|
|
26
20
|
get: function () {
|
|
@@ -99,8 +99,7 @@ const GarfishPlugin = config => {
|
|
|
99
99
|
return /*#__PURE__*/_react.default.createElement('div');
|
|
100
100
|
},
|
|
101
101
|
apps: new Proxy({}, {
|
|
102
|
-
get(
|
|
103
|
-
(0, _util.logger)('apps init Component Render', _p);
|
|
102
|
+
get() {
|
|
104
103
|
return () => /*#__PURE__*/_react.default.createElement('div');
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -3,22 +3,49 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useMicroApps = useMicroApps;
|
|
7
6
|
exports.useModuleApp = useModuleApp;
|
|
8
7
|
exports.useModuleApps = useModuleApps;
|
|
9
8
|
|
|
10
|
-
var _react = require("react");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
10
|
|
|
12
11
|
var _util = require("../util");
|
|
13
12
|
|
|
14
13
|
var _Context = require("./utils/Context");
|
|
15
14
|
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
|
|
23
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
|
|
16
25
|
function useModuleApps() {
|
|
17
26
|
const {
|
|
18
|
-
apps
|
|
27
|
+
apps,
|
|
28
|
+
MApp,
|
|
29
|
+
appInfoList
|
|
19
30
|
} = (0, _react.useContext)(_Context.GarfishContext);
|
|
20
|
-
(0, _util.logger)('call useModuleApps',
|
|
21
|
-
|
|
31
|
+
(0, _util.logger)('call useModuleApps', _objectSpread({
|
|
32
|
+
MApp,
|
|
33
|
+
apps: appInfoList
|
|
34
|
+
}, apps));
|
|
35
|
+
const Info = new Proxy(_objectSpread({
|
|
36
|
+
MApp,
|
|
37
|
+
apps: appInfoList
|
|
38
|
+
}, apps), {
|
|
39
|
+
get(target, p, receiver) {
|
|
40
|
+
if (typeof p === 'string' && p in target) {
|
|
41
|
+
return Reflect.get(target, p, receiver);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return () => /*#__PURE__*/_react.default.createElement('div');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
return Info;
|
|
22
49
|
}
|
|
23
50
|
|
|
24
51
|
function useModuleApp() {
|
|
@@ -27,22 +54,4 @@ function useModuleApp() {
|
|
|
27
54
|
} = (0, _react.useContext)(_Context.GarfishContext);
|
|
28
55
|
(0, _util.logger)('call useModuleApps', MApp);
|
|
29
56
|
return MApp;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function useMicroApps() {
|
|
33
|
-
const {
|
|
34
|
-
MApp,
|
|
35
|
-
appInfoList,
|
|
36
|
-
apps
|
|
37
|
-
} = (0, _react.useContext)(_Context.GarfishContext);
|
|
38
|
-
(0, _util.logger)('call useMicroApps', {
|
|
39
|
-
MApp,
|
|
40
|
-
apps: appInfoList,
|
|
41
|
-
Components: apps
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
MApp,
|
|
45
|
-
apps: appInfoList,
|
|
46
|
-
Components: apps
|
|
47
|
-
};
|
|
48
57
|
}
|