@alicloud/alfa-react 1.5.3 → 1.5.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.
- package/LICENSE +21 -0
- package/es/createApplication.js +19 -7
- package/es/index.js +1 -0
- package/es/version.js +1 -1
- package/lib/createApplication.js +19 -5
- package/lib/index.js +23 -0
- package/lib/version.js +1 -1
- package/package.json +19 -18
- package/types/index.d.ts +1 -0
- package/types/version.d.ts +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Alibaba Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/es/createApplication.js
CHANGED
|
@@ -48,6 +48,21 @@ var stripBasename = function stripBasename(path, basename) {
|
|
|
48
48
|
return _path.replace(new RegExp("^".concat(_basename.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1')), 'ig'), '');
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* fix Error (we do not know why):
|
|
53
|
+
* Failed to read the 'state' property from 'History':
|
|
54
|
+
* May not use a History object associated with a Document that is not fully active
|
|
55
|
+
* @returns any
|
|
56
|
+
*/
|
|
57
|
+
var getHistoryState = function getHistoryState() {
|
|
58
|
+
try {
|
|
59
|
+
var _window;
|
|
60
|
+
return (_window = window) === null || _window === void 0 ? void 0 : _window.history.state;
|
|
61
|
+
} catch (e) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
51
66
|
/**
|
|
52
67
|
* container for microApp mount
|
|
53
68
|
* @param loader alfa-core loader
|
|
@@ -55,7 +70,6 @@ var stripBasename = function stripBasename(path, basename) {
|
|
|
55
70
|
*/
|
|
56
71
|
export default function createApplication(loader) {
|
|
57
72
|
return function Application(props) {
|
|
58
|
-
var _window$history;
|
|
59
73
|
var name = props.name,
|
|
60
74
|
version = props.version,
|
|
61
75
|
manifest = props.manifest,
|
|
@@ -99,13 +113,11 @@ export default function createApplication(loader) {
|
|
|
99
113
|
setReleaseVersion = _useState6[1];
|
|
100
114
|
$syncHistory.current = syncHistory;
|
|
101
115
|
$basename.current = basename;
|
|
102
|
-
|
|
103
|
-
console.info(noCache, '===');
|
|
104
116
|
|
|
105
117
|
// if (customProps.__innerStamp) console.warn('Please do not use __innerStamp which used in internal.');
|
|
106
118
|
// 更新标记,保证每次更新都会更新
|
|
107
119
|
customProps.__innerStamp = (+new Date()).toString(36);
|
|
108
|
-
customProps.__historyState = (
|
|
120
|
+
customProps.__historyState = getHistoryState();
|
|
109
121
|
if (customProps.path) customProps.path = addLeftSlash(customProps.path);
|
|
110
122
|
|
|
111
123
|
// 受控模式锁定一些参数
|
|
@@ -177,7 +189,7 @@ export default function createApplication(loader) {
|
|
|
177
189
|
var dispatchFramePopstate = function dispatchFramePopstate() {
|
|
178
190
|
var _App, _App$context$baseFram, _App$context$baseFram2;
|
|
179
191
|
var popstateEvent = new Event('popstate');
|
|
180
|
-
popstateEvent.state =
|
|
192
|
+
popstateEvent.state = getHistoryState() || {};
|
|
181
193
|
(_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);
|
|
182
194
|
};
|
|
183
195
|
|
|
@@ -196,7 +208,7 @@ export default function createApplication(loader) {
|
|
|
196
208
|
// 如果主子应用路径不同,主动通知子应用 popstate 事件
|
|
197
209
|
if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
|
|
198
210
|
if (originalReplaceState) {
|
|
199
|
-
originalReplaceState(
|
|
211
|
+
originalReplaceState(getHistoryState(), '', stripBasename(peelPath(window.location), $basename.current));
|
|
200
212
|
dispatchFramePopstate();
|
|
201
213
|
}
|
|
202
214
|
}
|
|
@@ -259,7 +271,7 @@ export default function createApplication(loader) {
|
|
|
259
271
|
originalReplaceState = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.replaceState;
|
|
260
272
|
originalGo = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.go;
|
|
261
273
|
// update context history according to path
|
|
262
|
-
if (path) originalReplaceState(
|
|
274
|
+
if (path) originalReplaceState(getHistoryState(), '', path.replace(/\/+/g, '/'));
|
|
263
275
|
if (frameWindow) {
|
|
264
276
|
frameWindow.history.pushState = function (data, unused, _url) {
|
|
265
277
|
if ($syncHistory.current) {
|
package/es/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export { default as createAlfaApp, useAlfaApp } from './createAlfaApp';
|
|
|
3
3
|
export { default as createAlfaWidget, useAlfaWidget } from './createAlfaWidget';
|
|
4
4
|
export { eventEmitter as widgetEventEmitter } from './widget/index';
|
|
5
5
|
export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
|
|
6
|
+
export * from './utils';
|
|
6
7
|
// todo
|
|
7
8
|
export { createEventBus, prefetch } from '@alicloud/alfa-core';
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.5.
|
|
1
|
+
export var version = '1.5.5';
|
package/lib/createApplication.js
CHANGED
|
@@ -58,6 +58,21 @@ var stripBasename = function stripBasename(path, basename) {
|
|
|
58
58
|
return _path.replace(new RegExp("^".concat(_basename.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1')), 'ig'), '');
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* fix Error (we do not know why):
|
|
63
|
+
* Failed to read the 'state' property from 'History':
|
|
64
|
+
* May not use a History object associated with a Document that is not fully active
|
|
65
|
+
* @returns any
|
|
66
|
+
*/
|
|
67
|
+
var getHistoryState = function getHistoryState() {
|
|
68
|
+
try {
|
|
69
|
+
var _window;
|
|
70
|
+
return (_window = window) === null || _window === void 0 ? void 0 : _window.history.state;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
61
76
|
/**
|
|
62
77
|
* container for microApp mount
|
|
63
78
|
* @param loader alfa-core loader
|
|
@@ -65,7 +80,6 @@ var stripBasename = function stripBasename(path, basename) {
|
|
|
65
80
|
*/
|
|
66
81
|
function createApplication(loader) {
|
|
67
82
|
return function Application(props) {
|
|
68
|
-
var _window$history;
|
|
69
83
|
var name = props.name,
|
|
70
84
|
version = props.version,
|
|
71
85
|
manifest = props.manifest,
|
|
@@ -113,7 +127,7 @@ function createApplication(loader) {
|
|
|
113
127
|
// if (customProps.__innerStamp) console.warn('Please do not use __innerStamp which used in internal.');
|
|
114
128
|
// 更新标记,保证每次更新都会更新
|
|
115
129
|
customProps.__innerStamp = (+new Date()).toString(36);
|
|
116
|
-
customProps.__historyState = (
|
|
130
|
+
customProps.__historyState = getHistoryState();
|
|
117
131
|
if (customProps.path) customProps.path = addLeftSlash(customProps.path);
|
|
118
132
|
|
|
119
133
|
// 受控模式锁定一些参数
|
|
@@ -185,7 +199,7 @@ function createApplication(loader) {
|
|
|
185
199
|
var dispatchFramePopstate = function dispatchFramePopstate() {
|
|
186
200
|
var _App, _App$context$baseFram, _App$context$baseFram2;
|
|
187
201
|
var popstateEvent = new Event('popstate');
|
|
188
|
-
popstateEvent.state =
|
|
202
|
+
popstateEvent.state = getHistoryState() || {};
|
|
189
203
|
(_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);
|
|
190
204
|
};
|
|
191
205
|
|
|
@@ -204,7 +218,7 @@ function createApplication(loader) {
|
|
|
204
218
|
// 如果主子应用路径不同,主动通知子应用 popstate 事件
|
|
205
219
|
if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
|
|
206
220
|
if (originalReplaceState) {
|
|
207
|
-
originalReplaceState(
|
|
221
|
+
originalReplaceState(getHistoryState(), '', stripBasename(peelPath(window.location), $basename.current));
|
|
208
222
|
dispatchFramePopstate();
|
|
209
223
|
}
|
|
210
224
|
}
|
|
@@ -267,7 +281,7 @@ function createApplication(loader) {
|
|
|
267
281
|
originalReplaceState = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.replaceState;
|
|
268
282
|
originalGo = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.go;
|
|
269
283
|
// update context history according to path
|
|
270
|
-
if (path) originalReplaceState(
|
|
284
|
+
if (path) originalReplaceState(getHistoryState(), '', path.replace(/\/+/g, '/'));
|
|
271
285
|
if (frameWindow) {
|
|
272
286
|
frameWindow.history.pushState = function (data, unused, _url) {
|
|
273
287
|
if ($syncHistory.current) {
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,17 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
Skeleton: true,
|
|
10
|
+
createAlfaApp: true,
|
|
11
|
+
useAlfaApp: true,
|
|
12
|
+
createAlfaWidget: true,
|
|
13
|
+
useAlfaWidget: true,
|
|
14
|
+
widgetEventEmitter: true,
|
|
15
|
+
addGlobalRequestInterceptor: true,
|
|
16
|
+
createEventBus: true,
|
|
17
|
+
prefetch: true
|
|
18
|
+
};
|
|
8
19
|
Object.defineProperty(exports, "Skeleton", {
|
|
9
20
|
enumerable: true,
|
|
10
21
|
get: function get() {
|
|
@@ -64,6 +75,18 @@ var _createAlfaApp = _interopRequireWildcard(require("./createAlfaApp"));
|
|
|
64
75
|
var _createAlfaWidget = _interopRequireWildcard(require("./createAlfaWidget"));
|
|
65
76
|
var _index = require("./widget/index");
|
|
66
77
|
var _addGlobalRequestInterceptor = _interopRequireDefault(require("./addGlobalRequestInterceptor"));
|
|
78
|
+
var _utils = require("./utils");
|
|
79
|
+
Object.keys(_utils).forEach(function (key) {
|
|
80
|
+
if (key === "default" || key === "__esModule") return;
|
|
81
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
82
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
83
|
+
Object.defineProperty(exports, key, {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function get() {
|
|
86
|
+
return _utils[key];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
67
90
|
var _alfaCore = require("@alicloud/alfa-core");
|
|
68
91
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
69
92
|
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; }
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
8
|
"author": "pushiming",
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prepublish": "npm run version && npm run build && npm run babel && npm run babel:esm && npm run types",
|
|
12
|
-
"build": "breezr build --engine webpack",
|
|
13
|
-
"babel": "breezr build --engine babel",
|
|
14
|
-
"babel:esm": "breezr build --engine babel --es-module",
|
|
15
|
-
"types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
|
|
16
|
-
"storybook": "breezr start-storybook",
|
|
17
|
-
"clean": "rm -rf lib es dist types yarn.lock",
|
|
18
|
-
"start": "breezr start-storybook",
|
|
19
|
-
"precommit": "npm run version",
|
|
20
|
-
"version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts"
|
|
21
|
-
},
|
|
22
10
|
"publishConfig": {
|
|
23
11
|
"access": "public"
|
|
24
12
|
},
|
|
@@ -43,16 +31,29 @@
|
|
|
43
31
|
"typescript": "^4.0.0"
|
|
44
32
|
},
|
|
45
33
|
"dependencies": {
|
|
46
|
-
"@alicloud/alfa-core": "workspace:*",
|
|
47
|
-
"@alicloud/console-os-loader": "workspace:*",
|
|
48
34
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
49
35
|
"axios": "^1.4.0",
|
|
50
36
|
"classnames": "^2.2.6",
|
|
51
37
|
"crypto-js": "^4.1.1",
|
|
52
|
-
"prop-types": "^15.8.1"
|
|
38
|
+
"prop-types": "^15.8.1",
|
|
39
|
+
"@alicloud/console-os-loader": "1.4.30-alpha.0",
|
|
40
|
+
"@alicloud/alfa-core": "1.4.32"
|
|
53
41
|
},
|
|
54
42
|
"peerDependencies": {
|
|
55
43
|
"react": ">=16.0.0"
|
|
56
44
|
},
|
|
57
|
-
"gitHead": "ff9294b1d5e08b14691c8aa2bef098da2857f3df"
|
|
58
|
-
|
|
45
|
+
"gitHead": "ff9294b1d5e08b14691c8aa2bef098da2857f3df",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepublish": "npm run version && npm run build && npm run babel && npm run babel:esm && npm run types",
|
|
48
|
+
"pub": "pnpm publish",
|
|
49
|
+
"build": "breezr build --engine webpack",
|
|
50
|
+
"babel": "breezr build --engine babel",
|
|
51
|
+
"babel:esm": "breezr build --engine babel --es-module",
|
|
52
|
+
"types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
|
|
53
|
+
"storybook": "breezr start-storybook",
|
|
54
|
+
"clean": "rm -rf lib es dist types yarn.lock",
|
|
55
|
+
"start": "breezr start-storybook",
|
|
56
|
+
"precommit": "npm run version",
|
|
57
|
+
"version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { default as createAlfaApp, useAlfaApp } from './createAlfaApp';
|
|
|
3
3
|
export { default as createAlfaWidget, useAlfaWidget } from './createAlfaWidget';
|
|
4
4
|
export { eventEmitter as widgetEventEmitter } from './widget/index';
|
|
5
5
|
export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
|
|
6
|
+
export * from './utils';
|
|
6
7
|
export { createEventBus, prefetch } from '@alicloud/alfa-core';
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.5.
|
|
1
|
+
export declare const version = "1.5.5";
|