@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.
@@ -14,261 +14,257 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
14
14
 
15
15
  import path from 'path';
16
16
  import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
17
- import { createPlugin, useAppContext, useResolvedConfigContext } from '@modern-js/core';
18
17
  import { logger } from "../util";
19
18
  import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig } from "./utils";
20
19
  export var externals = {
21
20
  'react-dom': 'react-dom',
22
21
  react: 'react'
23
22
  };
24
- export var resolvedConfig = /*#__PURE__*/function () {
25
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(config) {
26
- var resolved, _getRuntimeConfig, masterApp, router, nConfig, _router$historyOption;
27
-
28
- return _regeneratorRuntime.wrap(function _callee$(_context) {
29
- while (1) {
30
- switch (_context.prev = _context.next) {
31
- case 0:
32
- resolved = config.resolved;
33
- _getRuntimeConfig = getRuntimeConfig(resolved), masterApp = _getRuntimeConfig.masterApp, router = _getRuntimeConfig.router;
34
- nConfig = {
35
- resolved: _objectSpread({}, resolved)
36
- };
37
-
38
- if (masterApp) {
39
- // basename does not exist use router's basename
40
- setRuntimeConfig(nConfig.resolved, 'masterApp', Object.assign(_typeof(masterApp) === 'object' ? _objectSpread({}, masterApp) : {}, {
41
- basename: (router === null || router === void 0 ? void 0 : (_router$historyOption = router.historyOptions) === null || _router$historyOption === void 0 ? void 0 : _router$historyOption.basename) || '/'
42
- }));
43
- }
44
-
45
- logger("resolvedConfig", {
46
- runtime: nConfig.resolved.runtime,
47
- deploy: nConfig.resolved.deploy,
48
- server: nConfig.resolved.server
49
- });
50
- return _context.abrupt("return", nConfig);
51
-
52
- case 6:
53
- case "end":
54
- return _context.stop();
55
- }
56
- }
57
- }, _callee);
58
- }));
59
-
60
- return function resolvedConfig(_x) {
61
- return _ref.apply(this, arguments);
62
- };
63
- }();
64
- export var initializer = function initializer( // eslint-disable-next-line @typescript-eslint/no-shadow
65
- _ref2, _ref3) {
66
- var resolvedConfig = _ref2.resolvedConfig,
67
- validateSchema = _ref2.validateSchema;
68
- var _ref3$runtimePluginNa = _ref3.runtimePluginName,
69
- runtimePluginName = _ref3$runtimePluginNa === void 0 ? '@modern-js/runtime/plugins' : _ref3$runtimePluginNa,
70
- _ref3$defaultEnableHt = _ref3.defaultEnableHtmlEntry,
71
- defaultEnableHtmlEntry = _ref3$defaultEnableHt === void 0 ? true : _ref3$defaultEnableHt,
72
- _ref3$defaultExternal = _ref3.defaultExternalBasicLibrary,
73
- defaultExternalBasicLibrary = _ref3$defaultExternal === void 0 ? false : _ref3$defaultExternal;
74
- return function () {
75
- var pluginsExportsUtils;
76
- var runtimeExportsUtils;
77
- return {
78
- validateSchema: validateSchema,
79
- resolvedConfig: resolvedConfig,
80
- config: function config() {
81
- // eslint-disable-next-line react-hooks/rules-of-hooks
82
- var config = useAppContext();
83
- pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
84
- runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
85
- return {
86
- source: {
87
- alias: {
88
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
89
- }
90
- },
91
- tools: {
92
- webpack: function webpack(webpackConfig, _ref4) {
93
- var _resolveOptions$deplo, _resolveWebpackConfig;
23
+ export default (function () {
24
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25
+ _ref$runtimePluginNam = _ref.runtimePluginName,
26
+ runtimePluginName = _ref$runtimePluginNam === void 0 ? '@modern-js/runtime/plugins' : _ref$runtimePluginNam,
27
+ _ref$mfPackagePath = _ref.mfPackagePath,
28
+ mfPackagePath = _ref$mfPackagePath === void 0 ? path.resolve(__dirname, '../../../../') : _ref$mfPackagePath;
29
+
30
+ return {
31
+ name: '@modern-js/plugin-garfish',
32
+ setup: function setup(_ref2) {
33
+ var useAppContext = _ref2.useAppContext,
34
+ useResolvedConfigContext = _ref2.useResolvedConfigContext;
35
+ var pluginsExportsUtils;
36
+ var runtimeExportsUtils;
37
+ return {
38
+ validateSchema: function validateSchema() {
39
+ return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
40
+ },
41
+ resolvedConfig: function () {
42
+ var _resolvedConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(config) {
43
+ var resolved, _getRuntimeConfig, masterApp, router, nConfig, _router$historyOption;
44
+
45
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
46
+ while (1) {
47
+ switch (_context.prev = _context.next) {
48
+ case 0:
49
+ resolved = config.resolved;
50
+ _getRuntimeConfig = getRuntimeConfig(resolved), masterApp = _getRuntimeConfig.masterApp, router = _getRuntimeConfig.router;
51
+ nConfig = {
52
+ resolved: _objectSpread({}, resolved)
53
+ };
54
+
55
+ if (masterApp) {
56
+ // basename does not exist use router's basename
57
+ setRuntimeConfig(nConfig.resolved, 'masterApp', Object.assign(_typeof(masterApp) === 'object' ? _objectSpread({}, masterApp) : {}, {
58
+ 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) || '/'
59
+ }));
60
+ }
61
+
62
+ logger("resolvedConfig", {
63
+ runtime: nConfig.resolved.runtime,
64
+ deploy: nConfig.resolved.deploy,
65
+ server: nConfig.resolved.server
66
+ });
67
+ return _context.abrupt("return", nConfig);
68
+
69
+ case 6:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }
74
+ }, _callee);
75
+ }));
94
76
 
95
- var chain = _ref4.chain,
96
- _webpack = _ref4.webpack,
97
- _ref4$env = _ref4.env,
98
- env = _ref4$env === void 0 ? process.env.NODE_ENV || 'development' : _ref4$env;
99
- // eslint-disable-next-line react-hooks/rules-of-hooks
100
- var resolveOptions = useResolvedConfigContext();
77
+ function resolvedConfig(_x) {
78
+ return _resolvedConfig.apply(this, arguments);
79
+ }
101
80
 
102
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
103
- var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
81
+ return resolvedConfig;
82
+ }(),
83
+ config: function config() {
84
+ // eslint-disable-next-line react-hooks/rules-of-hooks
85
+ var config = useAppContext(); // eslint-disable-next-line react-hooks/rules-of-hooks
104
86
 
105
- chain.output.libraryTarget('umd');
87
+ var resolveOptions = useResolvedConfigContext();
88
+ pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
89
+ runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
90
+ return {
91
+ source: {
92
+ alias: {
93
+ '@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
94
+ }
95
+ },
96
+ tools: {
97
+ webpack: function webpack(webpackConfig, _ref3) {
98
+ var _resolveOptions$deplo, _resolveWebpackConfig;
99
+
100
+ var chain = _ref3.chain,
101
+ _webpack = _ref3.webpack,
102
+ _ref3$env = _ref3.env,
103
+ env = _ref3$env === void 0 ? process.env.NODE_ENV || 'development' : _ref3$env;
104
+
105
+ if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
106
+ var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
107
+
108
+ chain.output.libraryTarget('umd');
109
+ chain.devServer.headers({
110
+ 'Access-Control-Allow-Origin': '*'
111
+ });
106
112
 
107
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
108
- chain.output.publicPath(env === 'development' ? "//localhost:".concat(resolveOptions.server.port, "/") : webpackConfig.output.publicPath);
109
- } // add comments avoid sourcemap abnormal
113
+ if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
114
+ chain.output.publicPath(env === 'development' ? "//localhost:".concat(resolveOptions.server.port, "/") : webpackConfig.output.publicPath);
115
+ } // add comments avoid sourcemap abnormal
110
116
 
111
117
 
112
- if (_webpack.BannerPlugin) {
113
- chain.plugin('banner').use(_webpack.BannerPlugin, [{
114
- banner: 'Micro front-end'
115
- }]);
116
- }
118
+ if (_webpack.BannerPlugin) {
119
+ chain.plugin('banner').use(_webpack.BannerPlugin, [{
120
+ banner: 'Micro front-end'
121
+ }]);
122
+ }
117
123
 
118
- var _ref5 = _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 : {},
119
- _ref5$enableHtmlEntry = _ref5.enableHtmlEntry,
120
- enableHtmlEntry = _ref5$enableHtmlEntry === void 0 ? defaultEnableHtmlEntry : _ref5$enableHtmlEntry,
121
- _ref5$externalBasicLi = _ref5.externalBasicLibrary,
122
- externalBasicLibrary = _ref5$externalBasicLi === void 0 ? defaultExternalBasicLibrary : _ref5$externalBasicLi; // external
124
+ var _ref4 = _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 : {},
125
+ _ref4$enableHtmlEntry = _ref4.enableHtmlEntry,
126
+ enableHtmlEntry = _ref4$enableHtmlEntry === void 0 ? true : _ref4$enableHtmlEntry,
127
+ _ref4$externalBasicLi = _ref4.externalBasicLibrary,
128
+ externalBasicLibrary = _ref4$externalBasicLi === void 0 ? false : _ref4$externalBasicLi; // external
123
129
 
124
130
 
125
- if (externalBasicLibrary) {
126
- chain.externals(externals);
127
- } // use html mode
131
+ if (externalBasicLibrary) {
132
+ chain.externals(externals);
133
+ } // use html mode
128
134
 
129
135
 
130
- if (!enableHtmlEntry) {
131
- chain.output.filename('index.js');
132
- chain.plugins["delete"]('html-main');
133
- chain.optimization.runtimeChunk(false);
134
- chain.optimization.splitChunks({
135
- chunks: 'async'
136
- });
136
+ if (!enableHtmlEntry) {
137
+ chain.output.filename('index.js');
138
+ chain.plugins["delete"]('html-main');
139
+ chain.optimization.runtimeChunk(false);
140
+ chain.optimization.splitChunks({
141
+ chunks: 'async'
142
+ });
143
+ }
137
144
  }
138
- }
139
145
 
140
- var resolveWebpackConfig = chain.toConfig();
141
- logger('webpackConfig', {
142
- output: resolveWebpackConfig.output,
143
- externals: resolveWebpackConfig.externals,
144
- env: env,
145
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
146
- });
146
+ var resolveWebpackConfig = chain.toConfig();
147
+ logger('webpackConfig', {
148
+ output: resolveWebpackConfig.output,
149
+ externals: resolveWebpackConfig.externals,
150
+ env: env,
151
+ alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
152
+ });
153
+ }
147
154
  }
155
+ };
156
+ },
157
+ addRuntimeExports: function addRuntimeExports() {
158
+ var addExportStatement = "export { default as garfish, default as masterApp } from '".concat(mfPackagePath, "'");
159
+ logger('exportStatement', addExportStatement);
160
+ pluginsExportsUtils.addExport(addExportStatement);
161
+ runtimeExportsUtils.addExport("export * from '".concat(mfPackagePath, "'"));
162
+ },
163
+ modifyEntryImports: function modifyEntryImports(_ref5) {
164
+ var entrypoint = _ref5.entrypoint,
165
+ imports = _ref5.imports;
166
+ // eslint-disable-next-line react-hooks/rules-of-hooks
167
+ var config = useResolvedConfigContext();
168
+
169
+ var _getRuntimeConfig2 = getRuntimeConfig(config),
170
+ masterApp = _getRuntimeConfig2.masterApp;
171
+
172
+ if (masterApp) {
173
+ imports.push({
174
+ value: runtimePluginName,
175
+ specifiers: [{
176
+ imported: 'garfish'
177
+ }]
178
+ });
179
+ imports.push({
180
+ value: runtimePluginName,
181
+ specifiers: [{
182
+ imported: 'masterApp'
183
+ }]
184
+ });
148
185
  }
149
- };
150
- },
151
- addRuntimeExports: function addRuntimeExports() {
152
- var mfPackage = path.resolve(__dirname, '../../../../');
153
- var addExportStatement = "export { default as garfish, default as masterApp } from '".concat(mfPackage, "'");
154
- logger('exportStatement', addExportStatement);
155
- pluginsExportsUtils.addExport(addExportStatement);
156
- runtimeExportsUtils.addExport("export * from '".concat(mfPackage, "'"));
157
- },
158
- modifyEntryImports: function modifyEntryImports(_ref6) {
159
- var entrypoint = _ref6.entrypoint,
160
- imports = _ref6.imports;
161
- // eslint-disable-next-line react-hooks/rules-of-hooks
162
- var config = useResolvedConfigContext();
163
-
164
- var _getRuntimeConfig2 = getRuntimeConfig(config),
165
- masterApp = _getRuntimeConfig2.masterApp;
166
-
167
- if (masterApp) {
168
- imports.push({
169
- value: runtimePluginName,
170
- specifiers: [{
171
- imported: 'garfish'
172
- }]
173
- });
186
+
174
187
  imports.push({
175
- value: runtimePluginName,
188
+ value: 'react-dom',
176
189
  specifiers: [{
177
- imported: 'masterApp'
190
+ imported: 'unmountComponentAtNode'
191
+ }, {
192
+ imported: 'createPortal'
178
193
  }]
179
194
  });
180
- }
181
-
182
- imports.push({
183
- value: 'react-dom',
184
- specifiers: [{
185
- imported: 'unmountComponentAtNode'
186
- }, {
187
- imported: 'createPortal'
188
- }]
189
- });
190
- return {
191
- imports: imports,
192
- entrypoint: entrypoint
193
- };
194
- },
195
- modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref7) {
196
- var entrypoint = _ref7.entrypoint,
197
- plugins = _ref7.plugins;
198
- // eslint-disable-next-line react-hooks/rules-of-hooks
199
- var config = useResolvedConfigContext();
200
-
201
- var _getRuntimeConfig3 = getRuntimeConfig(config),
202
- masterApp = _getRuntimeConfig3.masterApp;
203
-
204
- if (masterApp) {
205
- logger('garfishPlugin options', masterApp);
206
- plugins.push({
207
- name: 'garfish',
208
- args: 'masterApp',
209
- options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
210
- });
211
- }
212
-
213
- return {
214
- entrypoint: entrypoint,
215
- plugins: plugins
216
- };
217
- },
218
- modifyEntryRenderFunction: function modifyEntryRenderFunction(_ref8) {
219
- var _config$deploy;
195
+ return {
196
+ imports: imports,
197
+ entrypoint: entrypoint
198
+ };
199
+ },
200
+ modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref6) {
201
+ var entrypoint = _ref6.entrypoint,
202
+ plugins = _ref6.plugins;
203
+ // eslint-disable-next-line react-hooks/rules-of-hooks
204
+ var config = useResolvedConfigContext();
205
+
206
+ var _getRuntimeConfig3 = getRuntimeConfig(config),
207
+ masterApp = _getRuntimeConfig3.masterApp;
208
+
209
+ if (masterApp) {
210
+ logger('garfishPlugin options', masterApp);
211
+ plugins.push({
212
+ name: 'garfish',
213
+ args: 'masterApp',
214
+ options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
215
+ });
216
+ }
220
217
 
221
- var entrypoint = _ref8.entrypoint,
222
- code = _ref8.code;
223
- // eslint-disable-next-line react-hooks/rules-of-hooks
224
- var config = useResolvedConfigContext();
218
+ return {
219
+ entrypoint: entrypoint,
220
+ plugins: plugins
221
+ };
222
+ },
223
+ modifyEntryRenderFunction: function modifyEntryRenderFunction(_ref7) {
224
+ var _config$deploy;
225
+
226
+ var entrypoint = _ref7.entrypoint,
227
+ code = _ref7.code;
228
+ // eslint-disable-next-line react-hooks/rules-of-hooks
229
+ var config = useResolvedConfigContext();
230
+
231
+ if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
232
+ return {
233
+ entrypoint: entrypoint,
234
+ code: code
235
+ };
236
+ }
225
237
 
226
- if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
238
+ var nCode = makeRenderFunction(code);
239
+ logger('makeRenderFunction', nCode);
227
240
  return {
228
241
  entrypoint: entrypoint,
229
- code: code
242
+ code: nCode
230
243
  };
231
- }
244
+ },
245
+ modifyEntryExport: function modifyEntryExport(_ref8) {
246
+ var _config$deploy2;
247
+
248
+ var entrypoint = _ref8.entrypoint,
249
+ exportStatement = _ref8.exportStatement;
250
+ // eslint-disable-next-line react-hooks/rules-of-hooks
251
+ var config = useResolvedConfigContext();
252
+
253
+ if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
254
+ var exportStatementCode = makeProvider();
255
+ logger('exportStatement', exportStatementCode);
256
+ return {
257
+ entrypoint: entrypoint,
258
+ exportStatement: exportStatementCode
259
+ };
260
+ }
232
261
 
233
- var nCode = makeRenderFunction(code);
234
- logger('makeRenderFunction', nCode);
235
- return {
236
- entrypoint: entrypoint,
237
- code: nCode
238
- };
239
- },
240
- modifyEntryExport: function modifyEntryExport(_ref9) {
241
- var _config$deploy2;
242
-
243
- var entrypoint = _ref9.entrypoint,
244
- exportStatement = _ref9.exportStatement;
245
- // eslint-disable-next-line react-hooks/rules-of-hooks
246
- var config = useResolvedConfigContext();
247
-
248
- if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
249
- var exportStatementCode = makeProvider();
250
- logger('exportStatement', exportStatementCode);
251
262
  return {
252
263
  entrypoint: entrypoint,
253
- exportStatement: exportStatementCode
264
+ exportStatement: exportStatement
254
265
  };
255
266
  }
256
-
257
- return {
258
- entrypoint: entrypoint,
259
- exportStatement: exportStatement
260
- };
261
- }
262
- };
267
+ };
268
+ }
263
269
  };
264
- };
265
- export default createPlugin(initializer({
266
- resolvedConfig: resolvedConfig,
267
- validateSchema: function validateSchema() {
268
- return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
269
- }
270
- }, {
271
- runtimePluginName: '@modern-js/runtime/plugins'
272
- }), {
273
- name: '@modern-js/plugin-garfish'
274
270
  });
@@ -1,5 +1,5 @@
1
1
  export var makeProvider = function makeProvider() {
2
- return "\nexport const provider = function ({basename, dom, ...props}) {\n return {\n render({basename, dom}) {\n console.log('App.config', App.config);\n const SubApp = render({props, basename});\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n bootstrap(SubApp, node);\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n unmountComponentAtNode(node);\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n";
2
+ return "\nexport const provider = function ({basename, dom}) {\n return {\n render({basename, dom, props}) {\n const SubApp = render({ props, basename });\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n const App = function () {\n return React.createElement(SubApp, props)\n };\n bootstrap(App, node);\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n unmountComponentAtNode(node);\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n";
3
3
  };
4
4
  export var makeRenderFunction = function makeRenderFunction(code) {
5
5
  var inGarfishToRender = "\n const { basename, props } = arguments[0] || {};\n let renderByGarfish = false;\n const renderByProvider = !!basename;\n\n if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) renderByGarfish = true;\n if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) renderByGarfish = true;\n if (typeof __GARFISH_EXPORTS__ !== 'undefined') renderByGarfish = true;\n if (renderByGarfish && !renderByProvider) return null;\n\n function RouterPlugin (routerConfig) {\n if (basename) {\n routerConfig.basename = basename;\n if (routerConfig.supportHtml5History !== false) {\n if (!routerConfig.historyOptions) {\n routerConfig.historyOptions = {\n basename: basename\n };\n } else {\n routerConfig.historyOptions.basename = basename;\n }\n }\n }\n return router(routerConfig);\n }\n ";
@@ -15,7 +15,7 @@ export function getRuntimeConfig(config) {
15
15
  return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
16
16
  }
17
17
 
18
- return config === null || config === void 0 ? void 0 : config.runtime;
18
+ return (config === null || config === void 0 ? void 0 : config.runtime) || {};
19
19
  } // support legacy config
20
20
 
21
21
  export function setRuntimeConfig(config, key, value) {
@@ -1,3 +1,3 @@
1
1
  export { default } from "./plugin";
2
- export { useModuleApps, useMicroApps, useModuleApp } from "./useModuleApps";
2
+ export { useModuleApps, useModuleApp } from "./useModuleApps";
3
3
  export { default as Garfish } from 'garfish';
@@ -152,8 +152,7 @@ var GarfishPlugin = function GarfishPlugin(config) {
152
152
  return /*#__PURE__*/React.createElement('div');
153
153
  },
154
154
  apps: new Proxy({}, {
155
- get: function get(_target, _p) {
156
- logger('apps init Component Render', _p);
155
+ get: function get() {
157
156
  return function () {
158
157
  return /*#__PURE__*/React.createElement('div');
159
158
  };
@@ -1,12 +1,37 @@
1
- import { useContext } from 'react';
1
+ 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; }
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ import React, { useContext } from 'react';
2
8
  import { logger } from "../util";
3
9
  import { GarfishContext } from "./utils/Context";
4
10
  export function useModuleApps() {
5
11
  var _useContext = useContext(GarfishContext),
6
- apps = _useContext.apps;
12
+ apps = _useContext.apps,
13
+ MApp = _useContext.MApp,
14
+ appInfoList = _useContext.appInfoList;
15
+
16
+ logger('call useModuleApps', _objectSpread({
17
+ MApp: MApp,
18
+ apps: appInfoList
19
+ }, apps));
20
+ var Info = new Proxy(_objectSpread({
21
+ MApp: MApp,
22
+ apps: appInfoList
23
+ }, apps), {
24
+ get: function get(target, p, receiver) {
25
+ if (typeof p === 'string' && p in target) {
26
+ return Reflect.get(target, p, receiver);
27
+ }
7
28
 
8
- logger('call useModuleApps', apps);
9
- return apps;
29
+ return function () {
30
+ return /*#__PURE__*/React.createElement('div');
31
+ };
32
+ }
33
+ });
34
+ return Info;
10
35
  }
11
36
  export function useModuleApp() {
12
37
  var _useContext2 = useContext(GarfishContext),
@@ -14,21 +39,4 @@ export function useModuleApp() {
14
39
 
15
40
  logger('call useModuleApps', MApp);
16
41
  return MApp;
17
- }
18
- export function useMicroApps() {
19
- var _useContext3 = useContext(GarfishContext),
20
- MApp = _useContext3.MApp,
21
- appInfoList = _useContext3.appInfoList,
22
- apps = _useContext3.apps;
23
-
24
- logger('call useMicroApps', {
25
- MApp: MApp,
26
- apps: appInfoList,
27
- Components: apps
28
- });
29
- return {
30
- MApp: MApp,
31
- apps: appInfoList,
32
- Components: apps
33
- };
34
42
  }
@@ -1,38 +1,16 @@
1
- import { createPlugin } from '@modern-js/core';
1
+ import type { CliHookCallbacks, CliPlugin } from '@modern-js/core';
2
2
  export declare const externals: {
3
3
  'react-dom': string;
4
4
  react: string;
5
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;
6
+ export declare type LifeCycle = CliHookCallbacks;
18
7
 
19
- declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
20
- config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
21
- resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
22
- resolved: import("@modern-js/core").NormalizedConfig;
23
- }>;
24
- validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
25
- prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
26
- commands: import("@modern-js/core").AsyncWorkflow<{
27
- program: import("commander").Command;
28
- }, void>;
29
- watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
30
- fileChange: import("@modern-js/core").AsyncWorkflow<{
31
- filename: string;
32
- eventType: "add" | "unlink" | "change";
33
- }, void>;
34
- beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
35
- beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
36
- } & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
8
+ declare const _default: ({
9
+ runtimePluginName,
10
+ mfPackagePath
11
+ }?: {
12
+ runtimePluginName?: string | undefined;
13
+ mfPackagePath?: string | undefined;
14
+ }) => CliPlugin;
37
15
 
38
16
  export default _default;
@@ -1,4 +1,4 @@
1
- import { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig } from '@modern-js/core';
2
2
  export declare const makeProvider: () => string;
3
3
  export declare const makeRenderFunction: (code: string) => string;
4
4
  export declare function getRuntimeConfig(config: Partial<NormalizedConfig>): any;
@@ -1,4 +1,4 @@
1
1
  export { default } from './plugin';
2
- export { useModuleApps, useMicroApps, useModuleApp } from './useModuleApps';
2
+ export { useModuleApps, useModuleApp } from './useModuleApps';
3
3
  export type { Manifest, ModuleInfo } from './useModuleApps';
4
4
  export { default as Garfish } from 'garfish';