@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/js/modern/cli/index.js +164 -157
  3. package/dist/js/modern/cli/utils.js +31 -23
  4. package/dist/js/modern/global.d.js +0 -0
  5. package/dist/js/modern/index.js +5 -2
  6. package/dist/js/modern/modern-app.env.d.js +0 -0
  7. package/dist/js/modern/runtime/global.d.js +0 -0
  8. package/dist/js/modern/runtime/index.js +12 -4
  9. package/dist/js/modern/runtime/loadable.js +74 -56
  10. package/dist/js/modern/runtime/plugin.js +114 -79
  11. package/dist/js/modern/runtime/useModuleApps.js +40 -26
  12. package/dist/js/modern/runtime/utils/Context.js +6 -3
  13. package/dist/js/modern/runtime/utils/MApp.js +76 -72
  14. package/dist/js/modern/runtime/utils/apps.js +177 -142
  15. package/dist/js/modern/runtime/utils/setExternal.js +11 -11
  16. package/dist/js/modern/type.d.js +0 -0
  17. package/dist/js/modern/util.js +11 -9
  18. package/dist/js/node/cli/index.js +184 -168
  19. package/dist/js/node/cli/utils.js +45 -30
  20. package/dist/js/node/global.d.js +0 -0
  21. package/dist/js/node/index.js +29 -24
  22. package/dist/js/node/modern-app.env.d.js +0 -0
  23. package/dist/js/node/runtime/global.d.js +0 -0
  24. package/dist/js/node/runtime/index.js +35 -44
  25. package/dist/js/node/runtime/loadable.js +95 -61
  26. package/dist/js/node/runtime/plugin.js +147 -95
  27. package/dist/js/node/runtime/useModuleApps.js +64 -34
  28. package/dist/js/node/runtime/utils/Context.js +30 -10
  29. package/dist/js/node/runtime/utils/MApp.js +107 -84
  30. package/dist/js/node/runtime/utils/apps.js +204 -146
  31. package/dist/js/node/runtime/utils/setExternal.js +35 -18
  32. package/dist/js/node/type.d.js +0 -0
  33. package/dist/js/node/util.js +34 -19
  34. package/dist/js/treeshaking/cli/index.js +402 -284
  35. package/dist/js/treeshaking/cli/utils.js +28 -31
  36. package/dist/js/treeshaking/global.d.js +1 -0
  37. package/dist/js/treeshaking/index.js +3 -2
  38. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  39. package/dist/js/treeshaking/runtime/global.d.js +1 -0
  40. package/dist/js/treeshaking/runtime/index.js +5 -4
  41. package/dist/js/treeshaking/runtime/loadable.js +230 -109
  42. package/dist/js/treeshaking/runtime/plugin.js +469 -168
  43. package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
  44. package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
  45. package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
  46. package/dist/js/treeshaking/runtime/utils/apps.js +536 -230
  47. package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
  48. package/dist/js/treeshaking/type.d.js +1 -0
  49. package/dist/js/treeshaking/util.js +7 -9
  50. package/dist/types/cli/index.d.ts +2 -0
  51. package/dist/types/runtime/plugin.d.ts +2 -0
  52. package/dist/types/runtime/utils/setExternal.d.ts +1 -0
  53. package/package.json +10 -10
@@ -1,178 +1,479 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/esm/createClass";
6
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
7
- import _inherits from "@babel/runtime/helpers/esm/inherits";
8
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
11
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
12
- var _excluded = ["manifest"];
13
- import GarfishInstance from 'garfish';
14
- import React from 'react';
15
- import hoistNonReactStatics from 'hoist-non-react-statics';
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _assertThisInitialized(self) {
10
+ if (self === void 0) {
11
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12
+ }
13
+ return self;
14
+ }
15
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
+ try {
17
+ var info = gen[key](arg);
18
+ var value = info.value;
19
+ } catch (error) {
20
+ reject(error);
21
+ return;
22
+ }
23
+ if (info.done) {
24
+ resolve(value);
25
+ } else {
26
+ Promise.resolve(value).then(_next, _throw);
27
+ }
28
+ }
29
+ function _asyncToGenerator(fn) {
30
+ return function() {
31
+ var self = this, args = arguments;
32
+ return new Promise(function(resolve, reject) {
33
+ var gen = fn.apply(self, args);
34
+ function _next(value) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
36
+ }
37
+ function _throw(err) {
38
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
39
+ }
40
+ _next(undefined);
41
+ });
42
+ };
43
+ }
44
+ function _classCallCheck(instance, Constructor) {
45
+ if (!(instance instanceof Constructor)) {
46
+ throw new TypeError("Cannot call a class as a function");
47
+ }
48
+ }
49
+ function _defineProperties(target, props) {
50
+ for(var i = 0; i < props.length; i++){
51
+ var descriptor = props[i];
52
+ descriptor.enumerable = descriptor.enumerable || false;
53
+ descriptor.configurable = true;
54
+ if ("value" in descriptor) descriptor.writable = true;
55
+ Object.defineProperty(target, descriptor.key, descriptor);
56
+ }
57
+ }
58
+ function _createClass(Constructor, protoProps, staticProps) {
59
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
60
+ if (staticProps) _defineProperties(Constructor, staticProps);
61
+ return Constructor;
62
+ }
63
+ function _defineProperty(obj, key, value) {
64
+ if (key in obj) {
65
+ Object.defineProperty(obj, key, {
66
+ value: value,
67
+ enumerable: true,
68
+ configurable: true,
69
+ writable: true
70
+ });
71
+ } else {
72
+ obj[key] = value;
73
+ }
74
+ return obj;
75
+ }
76
+ function _getPrototypeOf(o) {
77
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
78
+ return o.__proto__ || Object.getPrototypeOf(o);
79
+ };
80
+ return _getPrototypeOf(o);
81
+ }
82
+ function _inherits(subClass, superClass) {
83
+ if (typeof superClass !== "function" && superClass !== null) {
84
+ throw new TypeError("Super expression must either be null or a function");
85
+ }
86
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
87
+ constructor: {
88
+ value: subClass,
89
+ writable: true,
90
+ configurable: true
91
+ }
92
+ });
93
+ if (superClass) _setPrototypeOf(subClass, superClass);
94
+ }
95
+ function _iterableToArray(iter) {
96
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
97
+ }
98
+ function _nonIterableSpread() {
99
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
100
+ }
101
+ function _objectSpread(target) {
102
+ for(var i = 1; i < arguments.length; i++){
103
+ var source = arguments[i] != null ? arguments[i] : {};
104
+ var ownKeys = Object.keys(source);
105
+ if (typeof Object.getOwnPropertySymbols === "function") {
106
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
107
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
108
+ }));
109
+ }
110
+ ownKeys.forEach(function(key) {
111
+ _defineProperty(target, key, source[key]);
112
+ });
113
+ }
114
+ return target;
115
+ }
116
+ function ownKeys(object, enumerableOnly) {
117
+ var keys = Object.keys(object);
118
+ if (Object.getOwnPropertySymbols) {
119
+ var symbols = Object.getOwnPropertySymbols(object);
120
+ if (enumerableOnly) {
121
+ symbols = symbols.filter(function(sym) {
122
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
123
+ });
124
+ }
125
+ keys.push.apply(keys, symbols);
126
+ }
127
+ return keys;
128
+ }
129
+ function _objectSpreadProps(target, source) {
130
+ source = source != null ? source : {};
131
+ if (Object.getOwnPropertyDescriptors) {
132
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
133
+ } else {
134
+ ownKeys(Object(source)).forEach(function(key) {
135
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
136
+ });
137
+ }
138
+ return target;
139
+ }
140
+ function _objectWithoutProperties(source, excluded) {
141
+ if (source == null) return {};
142
+ var target = _objectWithoutPropertiesLoose(source, excluded);
143
+ var key, i;
144
+ if (Object.getOwnPropertySymbols) {
145
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
146
+ for(i = 0; i < sourceSymbolKeys.length; i++){
147
+ key = sourceSymbolKeys[i];
148
+ if (excluded.indexOf(key) >= 0) continue;
149
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
150
+ target[key] = source[key];
151
+ }
152
+ }
153
+ return target;
154
+ }
155
+ function _objectWithoutPropertiesLoose(source, excluded) {
156
+ if (source == null) return {};
157
+ var target = {};
158
+ var sourceKeys = Object.keys(source);
159
+ var key, i;
160
+ for(i = 0; i < sourceKeys.length; i++){
161
+ key = sourceKeys[i];
162
+ if (excluded.indexOf(key) >= 0) continue;
163
+ target[key] = source[key];
164
+ }
165
+ return target;
166
+ }
167
+ function _possibleConstructorReturn(self, call) {
168
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
169
+ return call;
170
+ }
171
+ return _assertThisInitialized(self);
172
+ }
173
+ function _setPrototypeOf(o, p) {
174
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
175
+ o.__proto__ = p;
176
+ return o;
177
+ };
178
+ return _setPrototypeOf(o, p);
179
+ }
180
+ function _toConsumableArray(arr) {
181
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
182
+ }
183
+ var _typeof = function(obj) {
184
+ "@swc/helpers - typeof";
185
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
186
+ };
187
+ function _unsupportedIterableToArray(o, minLen) {
188
+ if (!o) return;
189
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
190
+ var n = Object.prototype.toString.call(o).slice(8, -1);
191
+ if (n === "Object" && o.constructor) n = o.constructor.name;
192
+ if (n === "Map" || n === "Set") return Array.from(n);
193
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
194
+ }
195
+ function _isNativeReflectConstruct() {
196
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
197
+ if (Reflect.construct.sham) return false;
198
+ if (typeof Proxy === "function") return true;
199
+ try {
200
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
201
+ return true;
202
+ } catch (e) {
203
+ return false;
204
+ }
205
+ }
206
+ function _createSuper(Derived) {
207
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
208
+ return function _createSuperInternal() {
209
+ var Super = _getPrototypeOf(Derived), result;
210
+ if (hasNativeReflectConstruct) {
211
+ var NewTarget = _getPrototypeOf(this).constructor;
212
+ result = Reflect.construct(Super, arguments, NewTarget);
213
+ } else {
214
+ result = Super.apply(this, arguments);
215
+ }
216
+ return _possibleConstructorReturn(this, result);
217
+ };
218
+ }
219
+ var __generator = this && this.__generator || function(thisArg, body) {
220
+ var f, y, t, g, _ = {
221
+ label: 0,
222
+ sent: function() {
223
+ if (t[0] & 1) throw t[1];
224
+ return t[1];
225
+ },
226
+ trys: [],
227
+ ops: []
228
+ };
229
+ return(g = {
230
+ next: verb(0),
231
+ "throw": verb(1),
232
+ "return": verb(2)
233
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
234
+ return this;
235
+ }), g);
236
+ function verb(n) {
237
+ return function(v) {
238
+ return step([
239
+ n,
240
+ v
241
+ ]);
242
+ };
243
+ }
244
+ function step(op) {
245
+ if (f) throw new TypeError("Generator is already executing.");
246
+ while(_)try {
247
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
248
+ if (y = 0, t) op = [
249
+ op[0] & 2,
250
+ t.value
251
+ ];
252
+ switch(op[0]){
253
+ case 0:
254
+ case 1:
255
+ t = op;
256
+ break;
257
+ case 4:
258
+ _.label++;
259
+ return {
260
+ value: op[1],
261
+ done: false
262
+ };
263
+ case 5:
264
+ _.label++;
265
+ y = op[1];
266
+ op = [
267
+ 0
268
+ ];
269
+ continue;
270
+ case 7:
271
+ op = _.ops.pop();
272
+ _.trys.pop();
273
+ continue;
274
+ default:
275
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
276
+ _ = 0;
277
+ continue;
278
+ }
279
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
280
+ _.label = op[1];
281
+ break;
282
+ }
283
+ if (op[0] === 6 && _.label < t[1]) {
284
+ _.label = t[1];
285
+ t = op;
286
+ break;
287
+ }
288
+ if (t && _.label < t[2]) {
289
+ _.label = t[2];
290
+ _.ops.push(op);
291
+ break;
292
+ }
293
+ if (t[2]) _.ops.pop();
294
+ _.trys.pop();
295
+ continue;
296
+ }
297
+ op = body.call(thisArg, _);
298
+ } catch (e) {
299
+ op = [
300
+ 6,
301
+ e
302
+ ];
303
+ y = 0;
304
+ } finally{
305
+ f = t = 0;
306
+ }
307
+ if (op[0] & 5) throw op[1];
308
+ return {
309
+ value: op[0] ? op[1] : void 0,
310
+ done: true
311
+ };
312
+ }
313
+ };
314
+ import { jsx } from "react/jsx-runtime";
315
+ import GarfishInstance from "garfish";
316
+ import React from "react";
317
+ import hoistNonReactStatics from "hoist-non-react-statics";
16
318
  import { logger } from "../util";
17
319
  import { GarfishProvider } from "./utils/Context";
18
320
  import setExternal from "./utils/setExternal";
19
321
  import { generateMApp } from "./utils/MApp";
20
322
  import { generateApps } from "./utils/apps";
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
323
  function initOptions() {
23
- return _initOptions.apply(this, arguments);
24
- } // export default GarfishPlugin;
324
+ return _initOptions.apply(this, arguments);
325
+ }
25
326
  function _initOptions() {
26
- _initOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
27
- var _window, _window$modern_manife, _window2, _window2$modern_manif;
28
- var manifest,
29
- options,
30
- apps,
31
- getAppList,
32
- _window3,
33
- _window3$modern_manif,
34
- _args2 = arguments;
35
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
36
- while (1) {
37
- switch (_context2.prev = _context2.next) {
38
- case 0:
39
- manifest = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
40
- options = _args2.length > 1 ? _args2[1] : undefined;
41
- apps = options.apps || []; // use manifest modules
42
- if (manifest !== null && manifest !== void 0 && manifest.modules) {
43
- if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
44
- apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
45
- }
46
- logger('manifest modules', apps);
47
- }
48
-
49
- // get module list
50
- if (!(manifest !== null && manifest !== void 0 && manifest.getAppList)) {
51
- _context2.next = 10;
52
- break;
53
- }
54
- _context2.next = 7;
55
- return manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest);
56
- case 7:
57
- getAppList = _context2.sent;
58
- if (getAppList.length > 0) {
59
- apps = getAppList;
60
- }
61
- logger('getAppList modules', apps);
62
- case 10:
63
- // get inject modules list
64
- 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) {
65
- 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;
66
- logger('modern_manifest', apps);
67
- }
68
- return _context2.abrupt("return", _objectSpread(_objectSpread({}, options), {}, {
69
- apps: apps
70
- }));
71
- case 12:
72
- case "end":
73
- return _context2.stop();
74
- }
75
- }
76
- }, _callee2);
77
- }));
78
- return _initOptions.apply(this, arguments);
79
- }
80
- export default (function (config) {
81
- return {
82
- name: '@modern-js/garfish-plugin',
83
- setup: function setup() {
84
- setExternal();
85
- var manifest = config.manifest,
86
- options = _objectWithoutProperties(config, _excluded);
87
- logger('createPlugin', config);
88
- var promise = initOptions(manifest, options);
89
- return {
90
- hoc: function hoc(_ref, next) {
91
- var App = _ref.App;
92
- var GetMicroFrontendApp = /*#__PURE__*/function (_React$Component) {
93
- _inherits(GetMicroFrontendApp, _React$Component);
94
- var _super = _createSuper(GetMicroFrontendApp);
95
- function GetMicroFrontendApp(props) {
96
- var _this;
97
- _classCallCheck(this, GetMicroFrontendApp);
98
- _this = _super.call(this, props);
99
- _defineProperty(_assertThisInitialized(_this), "state", {
100
- MApp: function MApp() {
101
- logger('MApp init Component Render');
102
- return /*#__PURE__*/React.createElement('div');
103
- },
104
- apps: new Proxy({}, {
105
- get: function get() {
106
- return function () {
107
- return /*#__PURE__*/React.createElement('div');
108
- };
109
- }
110
- }),
111
- appInfoList: []
112
- });
113
- var load = /*#__PURE__*/function () {
114
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
115
- var GarfishConfig, _generateApps, appInfoList, apps, MApp;
116
- return _regeneratorRuntime().wrap(function _callee$(_context) {
117
- while (1) {
118
- switch (_context.prev = _context.next) {
119
- case 0:
120
- GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
121
- insulationVariable: [].concat(_toConsumableArray(options.insulationVariable || []), ['_SERVER_DATA']),
122
- apps: []
123
- }));
124
- _context.next = 3;
125
- return promise;
126
- case 3:
127
- GarfishConfig = _context.sent;
128
- _generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
129
- GarfishInstance.registerApp(appInfoList);
130
- MApp = generateMApp(GarfishConfig, manifest);
131
- logger('initOptions result', {
132
- manifest: manifest,
133
- GarfishConfig: GarfishConfig
134
- });
135
- logger('generateApps', {
136
- MApp: MApp,
137
- apps: apps,
138
- appInfoList: appInfoList
139
- });
140
- _this.setState({
141
- MApp: MApp,
142
- apps: apps,
143
- appInfoList: appInfoList
144
- });
145
- case 10:
146
- case "end":
147
- return _context.stop();
148
- }
327
+ _initOptions = _asyncToGenerator(function() {
328
+ var manifest, options, ref, ref1, apps, getAppList, ref2;
329
+ var _arguments = arguments;
330
+ return __generator(this, function(_state) {
331
+ switch(_state.label){
332
+ case 0:
333
+ manifest = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, options = _arguments.length > 1 ? _arguments[1] : void 0;
334
+ apps = options.apps || [];
335
+ if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
336
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
337
+ apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
338
+ }
339
+ logger("manifest modules", apps);
149
340
  }
150
- }, _callee);
151
- }));
152
- return function load() {
153
- return _ref2.apply(this, arguments);
154
- };
155
- }();
156
- load();
157
- return _this;
341
+ if (!(manifest === null || manifest === void 0 ? void 0 : manifest.getAppList)) return [
342
+ 3,
343
+ 2
344
+ ];
345
+ return [
346
+ 4,
347
+ manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest)
348
+ ];
349
+ case 1:
350
+ getAppList = _state.sent();
351
+ if (getAppList.length > 0) {
352
+ apps = getAppList;
353
+ }
354
+ logger("getAppList modules", apps);
355
+ _state.label = 2;
356
+ case 2:
357
+ if ((window === null || window === void 0 ? void 0 : (ref = window.modern_manifest) === null || ref === void 0 ? void 0 : ref.modules) && (window === null || window === void 0 ? void 0 : (ref1 = window.modern_manifest) === null || ref1 === void 0 ? void 0 : ref1.modules.length) > 0) {
358
+ ;
359
+ apps = window === null || window === void 0 ? void 0 : (ref2 = window.modern_manifest) === null || ref2 === void 0 ? void 0 : ref2.modules;
360
+ logger("modern_manifest", apps);
361
+ }
362
+ return [
363
+ 2,
364
+ _objectSpreadProps(_objectSpread({}, options), {
365
+ apps: apps
366
+ })
367
+ ];
158
368
  }
159
- _createClass(GetMicroFrontendApp, [{
160
- key: "render",
161
- value: function render() {
162
- logger('GarfishProvider state', this.state);
163
- return /*#__PURE__*/_jsx(GarfishProvider, {
164
- value: this.state,
165
- children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
166
- });
167
- }
168
- }]);
169
- return GetMicroFrontendApp;
170
- }(React.Component);
171
- return next({
172
- App: hoistNonReactStatics(GetMicroFrontendApp, App)
173
- });
369
+ });
370
+ });
371
+ return _initOptions.apply(this, arguments);
372
+ }
373
+ var plugin_default = function(config) {
374
+ return {
375
+ name: "@modern-js/garfish-plugin",
376
+ setup: function() {
377
+ setExternal();
378
+ var manifest = config.manifest, options = _objectWithoutProperties(config, [
379
+ "manifest"
380
+ ]);
381
+ logger("createPlugin", config);
382
+ var promise = initOptions(manifest, options);
383
+ return {
384
+ hoc: function hoc(param, next) {
385
+ var App = param.App;
386
+ var GetMicroFrontendApp = /*#__PURE__*/ function(_Component) {
387
+ "use strict";
388
+ _inherits(GetMicroFrontendApp, _Component);
389
+ var _super = _createSuper(GetMicroFrontendApp);
390
+ function GetMicroFrontendApp(props) {
391
+ _classCallCheck(this, GetMicroFrontendApp);
392
+ var _this;
393
+ _this = _super.call(this, props);
394
+ _defineProperty(_assertThisInitialized(_this), "state", {
395
+ MApp: function() {
396
+ logger("MApp init Component Render");
397
+ return React.createElement("div");
398
+ },
399
+ apps: new Proxy({}, {
400
+ get: function get() {
401
+ return function() {
402
+ return React.createElement("div");
403
+ };
404
+ }
405
+ }),
406
+ appInfoList: []
407
+ });
408
+ var _this1 = _assertThisInitialized(_this);
409
+ var load = function() {
410
+ var _ref = _asyncToGenerator(function() {
411
+ var GarfishConfig, ref, appInfoList, apps, MApp;
412
+ return __generator(this, function(_state) {
413
+ switch(_state.label){
414
+ case 0:
415
+ GarfishInstance.setOptions(_objectSpreadProps(_objectSpread({}, options), {
416
+ insulationVariable: _toConsumableArray(options.insulationVariable || []).concat([
417
+ "_SERVER_DATA"
418
+ ]),
419
+ apps: []
420
+ }));
421
+ return [
422
+ 4,
423
+ promise
424
+ ];
425
+ case 1:
426
+ GarfishConfig = _state.sent();
427
+ ref = generateApps(GarfishConfig, manifest), appInfoList = ref.appInfoList, apps = ref.apps;
428
+ GarfishInstance.registerApp(appInfoList);
429
+ MApp = generateMApp(GarfishConfig, manifest);
430
+ logger("initOptions result", {
431
+ manifest: manifest,
432
+ GarfishConfig: GarfishConfig
433
+ });
434
+ logger("generateApps", {
435
+ MApp: MApp,
436
+ apps: apps,
437
+ appInfoList: appInfoList
438
+ });
439
+ _this1.setState({
440
+ MApp: MApp,
441
+ apps: apps,
442
+ appInfoList: appInfoList
443
+ });
444
+ return [
445
+ 2
446
+ ];
447
+ }
448
+ });
449
+ });
450
+ return function load() {
451
+ return _ref.apply(this, arguments);
452
+ };
453
+ }();
454
+ load();
455
+ return _this;
456
+ }
457
+ _createClass(GetMicroFrontendApp, [
458
+ {
459
+ key: "render",
460
+ value: function render() {
461
+ logger("GarfishProvider state", this.state);
462
+ return /* @__PURE__ */ jsx(GarfishProvider, {
463
+ value: this.state,
464
+ children: /* @__PURE__ */ jsx(App, _objectSpread({}, this.props, this.state))
465
+ });
466
+ }
467
+ }
468
+ ]);
469
+ return GetMicroFrontendApp;
470
+ }(React.Component);
471
+ return next({
472
+ App: hoistNonReactStatics(GetMicroFrontendApp, App)
473
+ });
474
+ }
475
+ };
174
476
  }
175
- };
176
- }
177
- };
178
- });
477
+ };
478
+ };
479
+ export { plugin_default as default };