@modern-js/plugin-garfish 1.4.2 → 1.4.3
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 +7 -5
- 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 +202 -218
- package/dist/js/node/cli/utils.js +7 -5
- 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 +216 -221
- package/dist/js/treeshaking/cli/utils.js +1 -1
- 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 +7 -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 +4 -5
- 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,245 @@ 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
|
-
|
|
30
|
+
var _default = ({
|
|
31
|
+
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins'
|
|
32
|
+
} = {}) => ({
|
|
33
|
+
name: '@modern-js/plugin-garfish',
|
|
34
|
+
setup: ({
|
|
35
|
+
useAppContext,
|
|
36
|
+
useResolvedConfigContext
|
|
37
|
+
}) => {
|
|
38
|
+
let pluginsExportsUtils;
|
|
39
|
+
let runtimeExportsUtils;
|
|
40
|
+
return {
|
|
41
|
+
validateSchema() {
|
|
42
|
+
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
resolvedConfig: async config => {
|
|
46
|
+
const {
|
|
47
|
+
resolved
|
|
48
|
+
} = config;
|
|
49
|
+
const {
|
|
50
|
+
masterApp,
|
|
51
|
+
router
|
|
52
|
+
} = (0, _utils2.getRuntimeConfig)(resolved);
|
|
53
|
+
const nConfig = {
|
|
54
|
+
resolved: _objectSpread({}, resolved)
|
|
55
|
+
};
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
deploy: nConfig.resolved.deploy,
|
|
56
|
-
server: nConfig.resolved.server
|
|
57
|
-
});
|
|
58
|
-
return nConfig;
|
|
59
|
-
};
|
|
57
|
+
if (masterApp) {
|
|
58
|
+
var _router$historyOption;
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
validateSchema
|
|
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;
|
|
60
|
+
// basename does not exist use router's basename
|
|
61
|
+
(0, _utils2.setRuntimeConfig)(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
|
|
62
|
+
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) || '/'
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
96
65
|
|
|
97
|
-
|
|
98
|
-
|
|
66
|
+
(0, _util.logger)(`resolvedConfig`, {
|
|
67
|
+
runtime: nConfig.resolved.runtime,
|
|
68
|
+
deploy: nConfig.resolved.deploy,
|
|
69
|
+
server: nConfig.resolved.server
|
|
70
|
+
});
|
|
71
|
+
return nConfig;
|
|
72
|
+
},
|
|
99
73
|
|
|
100
|
-
|
|
101
|
-
|
|
74
|
+
config() {
|
|
75
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
76
|
+
const config = useAppContext(); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
102
77
|
|
|
103
|
-
|
|
78
|
+
const resolveOptions = useResolvedConfigContext();
|
|
79
|
+
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'plugins');
|
|
80
|
+
runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'index');
|
|
81
|
+
return {
|
|
82
|
+
source: {
|
|
83
|
+
alias: {
|
|
84
|
+
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
tools: {
|
|
88
|
+
webpack: (webpackConfig, {
|
|
89
|
+
chain,
|
|
90
|
+
webpack,
|
|
91
|
+
env: _env = process.env.NODE_ENV || 'development'
|
|
92
|
+
}) => {
|
|
93
|
+
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
94
|
+
|
|
95
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
96
|
+
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
97
|
+
|
|
98
|
+
chain.output.libraryTarget('umd');
|
|
99
|
+
chain.devServer.headers({
|
|
100
|
+
'Access-Control-Allow-Origin': '*'
|
|
101
|
+
});
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
104
|
+
chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
|
|
105
|
+
} // add comments avoid sourcemap abnormal
|
|
108
106
|
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
if (webpack.BannerPlugin) {
|
|
109
|
+
chain.plugin('banner').use(webpack.BannerPlugin, [{
|
|
110
|
+
banner: 'Micro front-end'
|
|
111
|
+
}]);
|
|
112
|
+
}
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const {
|
|
115
|
+
enableHtmlEntry = true,
|
|
116
|
+
externalBasicLibrary = false
|
|
117
|
+
} = 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
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
if (externalBasicLibrary) {
|
|
120
|
+
chain.externals(externals);
|
|
121
|
+
} // use html mode
|
|
124
122
|
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
if (!enableHtmlEntry) {
|
|
125
|
+
chain.output.filename('index.js');
|
|
126
|
+
chain.plugins.delete('html-main');
|
|
127
|
+
chain.optimization.runtimeChunk(false);
|
|
128
|
+
chain.optimization.splitChunks({
|
|
129
|
+
chunks: 'async'
|
|
130
|
+
});
|
|
131
|
+
}
|
|
133
132
|
}
|
|
134
|
-
}
|
|
135
133
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
const resolveWebpackConfig = chain.toConfig();
|
|
135
|
+
(0, _util.logger)('webpackConfig', {
|
|
136
|
+
output: resolveWebpackConfig.output,
|
|
137
|
+
externals: resolveWebpackConfig.externals,
|
|
138
|
+
env: _env,
|
|
139
|
+
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
140
|
+
});
|
|
141
|
+
}
|
|
143
142
|
}
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
addRuntimeExports() {
|
|
147
|
+
const mfPackage = _path.default.resolve(__dirname, '../../../../');
|
|
148
|
+
|
|
149
|
+
const addExportStatement = `export { default as garfish, default as masterApp } from '${mfPackage}'`;
|
|
150
|
+
(0, _util.logger)('exportStatement', addExportStatement);
|
|
151
|
+
pluginsExportsUtils.addExport(addExportStatement);
|
|
152
|
+
runtimeExportsUtils.addExport(`export * from '${mfPackage}'`);
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
modifyEntryImports({
|
|
156
|
+
entrypoint,
|
|
157
|
+
imports
|
|
158
|
+
}) {
|
|
159
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
160
|
+
const config = useResolvedConfigContext();
|
|
161
|
+
const {
|
|
162
|
+
masterApp
|
|
163
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
164
|
+
|
|
165
|
+
if (masterApp) {
|
|
166
|
+
imports.push({
|
|
167
|
+
value: _runtimePluginName,
|
|
168
|
+
specifiers: [{
|
|
169
|
+
imported: 'garfish'
|
|
170
|
+
}]
|
|
171
|
+
});
|
|
172
|
+
imports.push({
|
|
173
|
+
value: _runtimePluginName,
|
|
174
|
+
specifiers: [{
|
|
175
|
+
imported: 'masterApp'
|
|
176
|
+
}]
|
|
177
|
+
});
|
|
144
178
|
}
|
|
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
|
-
});
|
|
179
|
+
|
|
174
180
|
imports.push({
|
|
175
|
-
value:
|
|
181
|
+
value: 'react-dom',
|
|
176
182
|
specifiers: [{
|
|
177
|
-
imported: '
|
|
183
|
+
imported: 'unmountComponentAtNode'
|
|
184
|
+
}, {
|
|
185
|
+
imported: 'createPortal'
|
|
178
186
|
}]
|
|
179
187
|
});
|
|
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
|
-
}
|
|
188
|
+
return {
|
|
189
|
+
imports,
|
|
190
|
+
entrypoint
|
|
191
|
+
};
|
|
192
|
+
},
|
|
214
193
|
|
|
215
|
-
|
|
194
|
+
modifyEntryRuntimePlugins({
|
|
216
195
|
entrypoint,
|
|
217
196
|
plugins
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
197
|
+
}) {
|
|
198
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
199
|
+
const config = useResolvedConfigContext();
|
|
200
|
+
const {
|
|
201
|
+
masterApp
|
|
202
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
203
|
+
|
|
204
|
+
if (masterApp) {
|
|
205
|
+
(0, _util.logger)('garfishPlugin options', masterApp);
|
|
206
|
+
plugins.push({
|
|
207
|
+
name: 'garfish',
|
|
208
|
+
args: 'masterApp',
|
|
209
|
+
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
210
|
+
});
|
|
211
|
+
}
|
|
229
212
|
|
|
230
|
-
if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
|
|
231
213
|
return {
|
|
232
214
|
entrypoint,
|
|
233
|
-
|
|
215
|
+
plugins
|
|
234
216
|
};
|
|
235
|
-
}
|
|
217
|
+
},
|
|
236
218
|
|
|
237
|
-
|
|
238
|
-
(0, _util.logger)('makeRenderFunction', nCode);
|
|
239
|
-
return {
|
|
219
|
+
modifyEntryRenderFunction({
|
|
240
220
|
entrypoint,
|
|
241
|
-
code
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
(0, _util.logger)('
|
|
221
|
+
code
|
|
222
|
+
}) {
|
|
223
|
+
var _config$deploy;
|
|
224
|
+
|
|
225
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
226
|
+
const config = useResolvedConfigContext();
|
|
227
|
+
|
|
228
|
+
if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
|
|
229
|
+
return {
|
|
230
|
+
entrypoint,
|
|
231
|
+
code
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const nCode = (0, _utils2.makeRenderFunction)(code);
|
|
236
|
+
(0, _util.logger)('makeRenderFunction', nCode);
|
|
257
237
|
return {
|
|
258
238
|
entrypoint,
|
|
259
|
-
|
|
239
|
+
code: nCode
|
|
260
240
|
};
|
|
261
|
-
}
|
|
241
|
+
},
|
|
262
242
|
|
|
263
|
-
|
|
243
|
+
modifyEntryExport({
|
|
264
244
|
entrypoint,
|
|
265
245
|
exportStatement
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
246
|
+
}) {
|
|
247
|
+
var _config$deploy2;
|
|
248
|
+
|
|
249
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
250
|
+
const config = useResolvedConfigContext();
|
|
251
|
+
|
|
252
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
|
|
253
|
+
const exportStatementCode = (0, _utils2.makeProvider)();
|
|
254
|
+
(0, _util.logger)('exportStatement', exportStatementCode);
|
|
255
|
+
return {
|
|
256
|
+
entrypoint,
|
|
257
|
+
exportStatement: exportStatementCode
|
|
258
|
+
};
|
|
259
|
+
}
|
|
273
260
|
|
|
274
|
-
|
|
275
|
-
|
|
261
|
+
return {
|
|
262
|
+
entrypoint,
|
|
263
|
+
exportStatement
|
|
264
|
+
};
|
|
265
|
+
}
|
|
276
266
|
|
|
277
|
-
|
|
278
|
-
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
267
|
+
};
|
|
279
268
|
}
|
|
280
|
-
|
|
281
|
-
}, {
|
|
282
|
-
runtimePluginName: '@modern-js/runtime/plugins'
|
|
283
|
-
}), {
|
|
284
|
-
name: '@modern-js/plugin-garfish'
|
|
285
269
|
});
|
|
286
270
|
|
|
287
271
|
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;
|
|
@@ -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
|
}
|