@alicloud/alfa-react 1.4.30-alpha.4 → 1.4.30-alpha.5

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.
@@ -98,7 +98,9 @@ export default function createApplication(loader) {
98
98
  // 禁止子应用和 consoleBase 通信
99
99
  customProps.consoleBase = null; // 覆写 path 参数,用于通知子应用更新路由
100
100
 
101
- customProps.path = stripBasename(peelPath(window.location), $basename.current);
101
+ customProps.path = stripBasename(peelPath(window.location), $basename.current); // 禁止注入 history
102
+
103
+ customProps.__injectHistory = null;
102
104
  }
103
105
 
104
106
  var sandbox = useMemo(function () {
@@ -156,20 +158,27 @@ export default function createApplication(loader) {
156
158
  var App;
157
159
  var originalPushState;
158
160
  var originalReplaceState;
159
- var originalGo; // 受控模式下,返回不会触发子应用内的路由更新
161
+ var originalGo;
162
+
163
+ var dispatchFramePopstate = function dispatchFramePopstate() {
164
+ var _App, _App$context$baseFram, _App$context$baseFram2;
165
+
166
+ var popstateEvent = new Event('popstate');
167
+ popstateEvent.state = 'mock';
168
+ (_App = App) === null || _App === void 0 ? void 0 : (_App$context$baseFram = _App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
169
+ }; // 受控模式下,返回不会触发子应用内的路由更新
170
+
160
171
 
161
172
  var updateAppHistory = function updateAppHistory() {
162
173
  if (App) {
163
- // 如果子应用路径不同,则主动通知
174
+ // 如果子应用路径不同,主动通知子应用 popstate 事件
164
175
  var nextPath = peelPath(App.context.location);
165
176
 
166
177
  if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
167
- var _App$context$baseFram, _App$context$baseFram2;
168
-
169
178
  var popstateEvent = new Event('popstate');
170
179
  popstateEvent.state = 'mock';
171
180
  if (originalReplaceState) originalReplaceState(null, '', stripBasename(peelPath(window.location), $basename.current));
172
- (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
181
+ dispatchFramePopstate();
173
182
  }
174
183
  }
175
184
  };
@@ -276,10 +285,15 @@ export default function createApplication(loader) {
276
285
  });
277
286
 
278
287
  case 18:
279
- // just run once
288
+ if (frameWindow) {
289
+ // 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
290
+ dispatchFramePopstate();
291
+ } // just run once
292
+
293
+
280
294
  setAppInstance(app);
281
295
 
282
- case 19:
296
+ case 20:
283
297
  case "end":
284
298
  return _context.stop();
285
299
  }
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.4.30-alpha.4';
1
+ export var version = '1.4.30-alpha.5';
@@ -120,7 +120,9 @@ function createApplication(loader) {
120
120
  // 禁止子应用和 consoleBase 通信
121
121
  customProps.consoleBase = null; // 覆写 path 参数,用于通知子应用更新路由
122
122
 
123
- customProps.path = stripBasename(peelPath(window.location), $basename.current);
123
+ customProps.path = stripBasename(peelPath(window.location), $basename.current); // 禁止注入 history
124
+
125
+ customProps.__injectHistory = null;
124
126
  }
125
127
 
126
128
  var sandbox = (0, _react.useMemo)(function () {
@@ -178,20 +180,27 @@ function createApplication(loader) {
178
180
  var App;
179
181
  var originalPushState;
180
182
  var originalReplaceState;
181
- var originalGo; // 受控模式下,返回不会触发子应用内的路由更新
183
+ var originalGo;
184
+
185
+ var dispatchFramePopstate = function dispatchFramePopstate() {
186
+ var _App, _App$context$baseFram, _App$context$baseFram2;
187
+
188
+ var popstateEvent = new Event('popstate');
189
+ popstateEvent.state = 'mock';
190
+ (_App = App) === null || _App === void 0 ? void 0 : (_App$context$baseFram = _App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
191
+ }; // 受控模式下,返回不会触发子应用内的路由更新
192
+
182
193
 
183
194
  var updateAppHistory = function updateAppHistory() {
184
195
  if (App) {
185
- // 如果子应用路径不同,则主动通知
196
+ // 如果子应用路径不同,主动通知子应用 popstate 事件
186
197
  var nextPath = peelPath(App.context.location);
187
198
 
188
199
  if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
189
- var _App$context$baseFram, _App$context$baseFram2;
190
-
191
200
  var popstateEvent = new Event('popstate');
192
201
  popstateEvent.state = 'mock';
193
202
  if (originalReplaceState) originalReplaceState(null, '', stripBasename(peelPath(window.location), $basename.current));
194
- (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
203
+ dispatchFramePopstate();
195
204
  }
196
205
  }
197
206
  };
@@ -297,10 +306,15 @@ function createApplication(loader) {
297
306
  });
298
307
 
299
308
  case 18:
300
- // just run once
309
+ if (frameWindow) {
310
+ // 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
311
+ dispatchFramePopstate();
312
+ } // just run once
313
+
314
+
301
315
  setAppInstance(app);
302
316
 
303
- case 19:
317
+ case 20:
304
318
  case "end":
305
319
  return _context.stop();
306
320
  }
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '1.4.30-alpha.4';
7
+ var version = '1.4.30-alpha.5';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.4.30-alpha.4",
3
+ "version": "1.4.30-alpha.5",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1 +1 @@
1
- export declare const version = "1.4.30-alpha.4";
1
+ export declare const version = "1.4.30-alpha.5";