@modern-js/plugin-garfish 1.21.1 → 1.21.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 1.21.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 92501d9: fix(garfish): fix reRender issue when use apps and Garfish.run with activeWhen parameter
8
+ 修复在同时调用 apps 和 Garfish.run 方法并提供 activeWhen 参数时重复渲染的问题
9
+ - @modern-js/runtime@1.21.2
10
+ - @modern-js/utils@1.21.2
11
+
3
12
  ## 1.21.1
4
13
 
5
14
  ### Patch Changes
@@ -93,18 +93,21 @@ export default (config => ({
93
93
  });
94
94
 
95
95
  const load = async () => {
96
+ GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
97
+ insulationVariable: [...(options.insulationVariable || []), '_SERVER_DATA'],
98
+ apps: []
99
+ }));
96
100
  const GarfishConfig = await promise;
97
- logger('initOptions result', {
98
- manifest,
99
- GarfishConfig
100
- });
101
- const MApp = generateMApp(GarfishConfig, manifest);
102
101
  const {
103
102
  appInfoList,
104
103
  apps
105
104
  } = generateApps(GarfishConfig, manifest);
106
- GarfishInstance.setOptions(GarfishConfig);
107
105
  GarfishInstance.registerApp(appInfoList);
106
+ const MApp = generateMApp(GarfishConfig, manifest);
107
+ logger('initOptions result', {
108
+ manifest,
109
+ GarfishConfig
110
+ });
108
111
  logger('generateApps', {
109
112
  MApp,
110
113
  apps,
@@ -1,14 +1,13 @@
1
- const _excluded = ["beforeLoad", "beforeMount", "errorLoadApp", "errorMountApp", "errorUnmountApp"],
2
- _excluded2 = ["style", "setLoadingState"];
3
-
4
- 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; }
5
-
6
- 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; }
1
+ const _excluded = ["style", "setLoadingState"];
7
2
 
8
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
4
 
10
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
6
 
7
+ 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; }
8
+
9
+ 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; }
10
+
12
11
  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; }
13
12
 
14
13
  import React from 'react'; // eslint-disable-next-line import/no-named-as-default
@@ -34,22 +33,18 @@ export function generateMApp(options, manifest) {
34
33
  const {
35
34
  setLoadingState
36
35
  } = this.props;
37
-
38
36
  const {
39
37
  beforeLoad,
40
38
  beforeMount,
41
39
  errorLoadApp,
42
40
  errorMountApp,
43
41
  errorUnmountApp
44
- } = options,
45
- otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
46
-
42
+ } = options; // start auto render able
47
43
 
48
44
  Garfish.router.setRouterConfig({
49
45
  listening: true
50
46
  });
51
-
52
- const garfishOptions = _objectSpread(_objectSpread({
47
+ const garfishOptions = {
53
48
  domGetter: `#${domId}`,
54
49
 
55
50
  beforeLoad(appInfo, ...args) {
@@ -111,10 +106,8 @@ export function generateMApp(options, manifest) {
111
106
  }
112
107
 
113
108
  return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
114
- }
109
+ },
115
110
 
116
- }, otherOptions), {}, {
117
- insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
118
111
  customLoader: provider => {
119
112
  const {
120
113
  render,
@@ -151,8 +144,7 @@ export function generateMApp(options, manifest) {
151
144
  }
152
145
  };
153
146
  }
154
- });
155
-
147
+ };
156
148
  logger('MApp componentDidMount', {
157
149
  garfishRunning: Garfish.running,
158
150
  garfishOptions
@@ -177,7 +169,7 @@ export function generateMApp(options, manifest) {
177
169
  style,
178
170
  setLoadingState
179
171
  } = _this$props,
180
- others = _objectWithoutProperties(_this$props, _excluded2);
172
+ others = _objectWithoutProperties(_this$props, _excluded);
181
173
 
182
174
  return others;
183
175
  }
@@ -110,21 +110,24 @@ var _default = config => ({
110
110
  });
111
111
 
112
112
  const load = async () => {
113
+ _garfish.default.setOptions(_objectSpread(_objectSpread({}, options), {}, {
114
+ insulationVariable: [...(options.insulationVariable || []), '_SERVER_DATA'],
115
+ apps: []
116
+ }));
117
+
113
118
  const GarfishConfig = await promise;
114
- (0, _util.logger)('initOptions result', {
115
- manifest,
116
- GarfishConfig
117
- });
118
- const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
119
119
  const {
120
120
  appInfoList,
121
121
  apps
122
122
  } = (0, _apps.generateApps)(GarfishConfig, manifest);
123
123
 
124
- _garfish.default.setOptions(GarfishConfig);
125
-
126
124
  _garfish.default.registerApp(appInfoList);
127
125
 
126
+ const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
127
+ (0, _util.logger)('initOptions result', {
128
+ manifest,
129
+ GarfishConfig
130
+ });
128
131
  (0, _util.logger)('generateApps', {
129
132
  MApp,
130
133
  apps,
@@ -15,19 +15,18 @@ var _loadable = require("../loadable");
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
- const _excluded = ["beforeLoad", "beforeMount", "errorLoadApp", "errorMountApp", "errorUnmountApp"],
19
- _excluded2 = ["style", "setLoadingState"];
18
+ const _excluded = ["style", "setLoadingState"];
20
19
 
21
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
21
 
23
- 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; }
24
-
25
- 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; }
26
-
27
22
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
28
23
 
29
24
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
30
25
 
26
+ 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; }
27
+
28
+ 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; }
29
+
31
30
  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; }
32
31
 
33
32
  function generateMApp(options, manifest) {
@@ -47,22 +46,19 @@ function generateMApp(options, manifest) {
47
46
  const {
48
47
  setLoadingState
49
48
  } = this.props;
50
-
51
49
  const {
52
50
  beforeLoad,
53
51
  beforeMount,
54
52
  errorLoadApp,
55
53
  errorMountApp,
56
54
  errorUnmountApp
57
- } = options,
58
- otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
59
-
55
+ } = options; // start auto render able
60
56
 
61
57
  _garfish.default.router.setRouterConfig({
62
58
  listening: true
63
59
  });
64
60
 
65
- const garfishOptions = _objectSpread(_objectSpread({
61
+ const garfishOptions = {
66
62
  domGetter: `#${domId}`,
67
63
 
68
64
  beforeLoad(appInfo, ...args) {
@@ -124,10 +120,8 @@ function generateMApp(options, manifest) {
124
120
  }
125
121
 
126
122
  return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
127
- }
123
+ },
128
124
 
129
- }, otherOptions), {}, {
130
- insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
131
125
  customLoader: provider => {
132
126
  const {
133
127
  render,
@@ -164,8 +158,7 @@ function generateMApp(options, manifest) {
164
158
  }
165
159
  };
166
160
  }
167
- });
168
-
161
+ };
169
162
  (0, _util.logger)('MApp componentDidMount', {
170
163
  garfishRunning: _garfish.default.running,
171
164
  garfishOptions
@@ -191,7 +184,7 @@ function generateMApp(options, manifest) {
191
184
  style,
192
185
  setLoadingState
193
186
  } = _this$props,
194
- others = _objectWithoutProperties(_this$props, _excluded2);
187
+ others = _objectWithoutProperties(_this$props, _excluded);
195
188
 
196
189
  return others;
197
190
  }
@@ -1,5 +1,6 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
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";
3
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
5
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
6
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -135,25 +136,28 @@ export default (function (config) {
135
136
 
136
137
  var load = /*#__PURE__*/function () {
137
138
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
138
- var GarfishConfig, MApp, _generateApps, appInfoList, apps;
139
+ var GarfishConfig, _generateApps, appInfoList, apps, MApp;
139
140
 
140
141
  return _regeneratorRuntime().wrap(function _callee$(_context) {
141
142
  while (1) {
142
143
  switch (_context.prev = _context.next) {
143
144
  case 0:
144
- _context.next = 2;
145
+ GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
146
+ insulationVariable: [].concat(_toConsumableArray(options.insulationVariable || []), ['_SERVER_DATA']),
147
+ apps: []
148
+ }));
149
+ _context.next = 3;
145
150
  return promise;
146
151
 
147
- case 2:
152
+ case 3:
148
153
  GarfishConfig = _context.sent;
154
+ _generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
155
+ GarfishInstance.registerApp(appInfoList);
156
+ MApp = generateMApp(GarfishConfig, manifest);
149
157
  logger('initOptions result', {
150
158
  manifest: manifest,
151
159
  GarfishConfig: GarfishConfig
152
160
  });
153
- MApp = generateMApp(GarfishConfig, manifest);
154
- _generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
155
- GarfishInstance.setOptions(GarfishConfig);
156
- GarfishInstance.registerApp(appInfoList);
157
161
  logger('generateApps', {
158
162
  MApp: MApp,
159
163
  apps: apps,
@@ -1,14 +1,12 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
6
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
7
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
8
7
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- var _excluded = ["beforeLoad", "beforeMount", "errorLoadApp", "errorMountApp", "errorUnmountApp"],
11
- _excluded2 = ["style", "setLoadingState"];
9
+ var _excluded = ["style", "setLoadingState"];
12
10
  import React from 'react'; // eslint-disable-next-line import/no-named-as-default
13
11
 
14
12
  import Garfish from 'garfish';
@@ -46,20 +44,16 @@ export function generateMApp(options, manifest) {
46
44
 
47
45
  var domId = this.state.domId;
48
46
  var setLoadingState = this.props.setLoadingState;
49
-
50
47
  var _beforeLoad = options.beforeLoad,
51
48
  _beforeMount = options.beforeMount,
52
49
  _errorLoadApp = options.errorLoadApp,
53
50
  _errorMountApp = options.errorMountApp,
54
- _errorUnmountApp = options.errorUnmountApp,
55
- otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
56
-
51
+ _errorUnmountApp = options.errorUnmountApp; // start auto render able
57
52
 
58
53
  Garfish.router.setRouterConfig({
59
54
  listening: true
60
55
  });
61
-
62
- var garfishOptions = _objectSpread(_objectSpread({
56
+ var garfishOptions = {
63
57
  domGetter: "#".concat(domId),
64
58
  beforeLoad: function beforeLoad(appInfo) {
65
59
  logger('MApp beforeLoad', [appInfo]);
@@ -136,9 +130,7 @@ export function generateMApp(options, manifest) {
136
130
  }
137
131
 
138
132
  return _errorUnmountApp === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [error, appInfo].concat(args));
139
- }
140
- }, otherOptions), {}, {
141
- insulationVariable: [].concat(_toConsumableArray(otherOptions.insulationVariable || []), ['_SERVER_DATA']),
133
+ },
142
134
  customLoader: function customLoader(provider) {
143
135
  var render = provider.render,
144
136
  destroy = provider.destroy,
@@ -176,8 +168,7 @@ export function generateMApp(options, manifest) {
176
168
  }
177
169
  };
178
170
  }
179
- });
180
-
171
+ };
181
172
  logger('MApp componentDidMount', {
182
173
  garfishRunning: Garfish.running,
183
174
  garfishOptions: garfishOptions
@@ -202,7 +193,7 @@ export function generateMApp(options, manifest) {
202
193
  var _this$props = this.props,
203
194
  style = _this$props.style,
204
195
  setLoadingState = _this$props.setLoadingState,
205
- others = _objectWithoutProperties(_this$props, _excluded2);
196
+ others = _objectWithoutProperties(_this$props, _excluded);
206
197
 
207
198
  return others;
208
199
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.1",
14
+ "version": "1.21.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/runtime/index.d.ts",
17
17
  "typesVersions": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@babel/runtime": "^7.18.0",
53
- "@modern-js/utils": "1.21.1",
53
+ "@modern-js/utils": "1.21.2",
54
54
  "@types/debug": "^4.1.7",
55
55
  "@types/react-loadable": "^5.5.6",
56
56
  "debug": "^4.3.2",
@@ -59,7 +59,7 @@
59
59
  "react-loadable": "^5.5.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@modern-js/runtime": "^1.21.1"
62
+ "@modern-js/runtime": "^1.21.2"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "@modern-js/runtime": {
@@ -67,11 +67,11 @@
67
67
  }
68
68
  },
69
69
  "devDependencies": {
70
- "@modern-js/core": "1.21.1",
71
- "@modern-js/runtime": "1.21.1",
72
- "@modern-js/types": "1.21.1",
73
- "@scripts/build": "1.21.1",
74
- "@scripts/jest-config": "1.21.1",
70
+ "@modern-js/core": "1.21.2",
71
+ "@modern-js/runtime": "1.21.2",
72
+ "@modern-js/types": "1.21.2",
73
+ "@scripts/build": "1.21.2",
74
+ "@scripts/jest-config": "1.21.2",
75
75
  "@testing-library/jest-dom": "^5.16.1",
76
76
  "@testing-library/react": "^12.0.0",
77
77
  "@testing-library/react-hooks": "^7.0.1",