navigation-stack 0.3.1 → 0.4.0
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/README.md +603 -163
- package/data-storage/package.json +6 -0
- package/karma.conf.cjs +21 -4
- package/lib/cjs/NavigationStack.js +73 -0
- package/lib/cjs/data-storage/DataStorage.js +71 -0
- package/lib/cjs/data-storage/LocationDataStorage.js +29 -0
- package/lib/cjs/data-storage/index.js +9 -0
- package/lib/cjs/environment/InMemoryEnvironment.js +15 -0
- package/lib/cjs/environment/WebBrowserEnvironment.js +15 -0
- package/lib/cjs/environment/data-storage/InMemoryDataStorage.js +27 -0
- package/lib/cjs/environment/data-storage/WebBrowserDataStorage.js +21 -0
- package/lib/cjs/environment/scroll-position/InMemoryScrollPosition.js +44 -0
- package/lib/cjs/environment/scroll-position/WebBrowserScrollPosition.js +60 -0
- package/lib/cjs/getLocationFromInternalLocation.js +14 -0
- package/lib/cjs/index.js +20 -16
- package/lib/cjs/navigationBlockers.js +25 -23
- package/lib/cjs/{normalizeInputLocation.js → parseInputLocation.js} +25 -9
- package/lib/cjs/{ActionTypes.js → redux/ActionTypes.js} +1 -1
- package/lib/cjs/redux/ActionTypesInternal.js +8 -0
- package/lib/cjs/{Actions.js → redux/Actions.js} +5 -4
- package/lib/cjs/redux/createMiddlewares.js +60 -0
- package/lib/cjs/redux/index.js +13 -0
- package/lib/cjs/redux/internalLocationReducer.js +14 -0
- package/lib/cjs/redux/middleware/createAddInputLocationBasePathMiddleware.js +32 -0
- package/lib/cjs/redux/middleware/createNonProgrammaticNavigationBlockerMiddleware.js +113 -0
- package/lib/cjs/redux/middleware/createProgrammaticNavigationBlockerMiddleware.js +94 -0
- package/lib/cjs/redux/middleware/createRemoveOutputLocationBasePathMiddleware.js +30 -0
- package/lib/cjs/redux/middleware/createUpdateInternalLocationMiddleware.js +73 -0
- package/lib/cjs/{middleware/navigationActionMiddleware.js → redux/middleware/navigationOperationMiddleware.js} +11 -8
- package/lib/cjs/{middleware/normalizeInputLocationMiddleware.js → redux/middleware/parseInputLocationMiddleware.js} +6 -4
- package/lib/cjs/redux/middleware/updateLocationMiddleware.js +34 -0
- package/lib/cjs/scroll-position/PageScrollPositionSetter.js +97 -0
- package/lib/cjs/scroll-position/ScrollPositionAutoSaver.js +130 -0
- package/lib/cjs/scroll-position/ScrollPositionRestoration.js +383 -0
- package/lib/cjs/scroll-position/ScrollPositionSaver.js +81 -0
- package/lib/cjs/scroll-position/ScrollPositionSetter.js +16 -0
- package/lib/cjs/scroll-position/constants.js +5 -0
- package/lib/cjs/scroll-position/index.js +7 -0
- package/lib/cjs/scroll-position/scheduleNextTick.js +11 -0
- package/lib/cjs/session/InMemorySession.js +22 -0
- package/lib/cjs/session/ServerSideRenderSession.js +17 -0
- package/lib/cjs/session/Session.js +196 -0
- package/lib/cjs/session/WebBrowserSession.js +20 -0
- package/lib/cjs/session/key/createSessionKey.js +23 -0
- package/lib/cjs/session/lifecycle/InMemorySessionLifecycle.js +19 -0
- package/lib/cjs/session/lifecycle/WebBrowserSessionLifecycle.js +128 -0
- package/lib/cjs/session/lifecycle/page-lifecycle/PageLifecycle.js +269 -0
- package/lib/cjs/session/lifecycle/page-lifecycle/PageLifecycleInstance.js +8 -0
- package/lib/cjs/session/lifecycle/page-lifecycle/supportsConstructableEventTarget.js +33 -0
- package/lib/cjs/session/navigation/InMemoryNavigation.js +104 -0
- package/lib/cjs/session/navigation/ServerSideNavigation.js +61 -0
- package/lib/cjs/session/navigation/WebBrowserNavigation.js +221 -0
- package/lib/cjs/session/navigation/error/NavigationOutOfBoundsError.js +12 -0
- package/lib/cjs/session/navigation/error/ServerSideNavigationError.js +21 -0
- package/lib/cjs/session/navigation/operation/operations.js +11 -0
- package/lib/cjs/session/subscription/Subscription.js +81 -0
- package/lib/data-storage/index.d.ts +35 -0
- package/lib/esm/NavigationStack.js +66 -0
- package/lib/esm/data-storage/DataStorage.js +65 -0
- package/lib/esm/data-storage/LocationDataStorage.js +22 -0
- package/lib/esm/data-storage/index.js +2 -0
- package/lib/esm/environment/InMemoryEnvironment.js +8 -0
- package/lib/esm/environment/WebBrowserEnvironment.js +8 -0
- package/lib/esm/environment/data-storage/InMemoryDataStorage.js +21 -0
- package/lib/esm/environment/data-storage/WebBrowserDataStorage.js +15 -0
- package/lib/esm/environment/scroll-position/InMemoryScrollPosition.js +38 -0
- package/lib/esm/environment/scroll-position/WebBrowserScrollPosition.js +54 -0
- package/lib/esm/getLocationFromInternalLocation.js +9 -0
- package/lib/esm/index.js +10 -8
- package/lib/esm/navigationBlockers.js +25 -23
- package/lib/esm/{normalizeInputLocation.js → parseInputLocation.js} +24 -8
- package/lib/esm/{ActionTypes.js → redux/ActionTypes.js} +1 -1
- package/lib/esm/redux/ActionTypesInternal.js +3 -0
- package/lib/esm/{Actions.js → redux/Actions.js} +5 -4
- package/lib/esm/redux/createMiddlewares.js +54 -0
- package/lib/esm/redux/index.js +4 -0
- package/lib/esm/redux/internalLocationReducer.js +8 -0
- package/lib/esm/redux/middleware/createAddInputLocationBasePathMiddleware.js +27 -0
- package/lib/esm/redux/middleware/createNonProgrammaticNavigationBlockerMiddleware.js +108 -0
- package/lib/esm/redux/middleware/createProgrammaticNavigationBlockerMiddleware.js +88 -0
- package/lib/esm/redux/middleware/createRemoveOutputLocationBasePathMiddleware.js +25 -0
- package/lib/esm/redux/middleware/createUpdateInternalLocationMiddleware.js +68 -0
- package/lib/esm/{middleware/navigationActionMiddleware.js → redux/middleware/navigationOperationMiddleware.js} +10 -7
- package/lib/esm/{middleware/normalizeInputLocationMiddleware.js → redux/middleware/parseInputLocationMiddleware.js} +5 -3
- package/lib/esm/redux/middleware/updateLocationMiddleware.js +28 -0
- package/lib/esm/scroll-position/PageScrollPositionSetter.js +91 -0
- package/lib/esm/scroll-position/ScrollPositionAutoSaver.js +123 -0
- package/lib/esm/scroll-position/ScrollPositionRestoration.js +376 -0
- package/lib/esm/scroll-position/ScrollPositionSaver.js +74 -0
- package/lib/esm/scroll-position/ScrollPositionSetter.js +10 -0
- package/lib/esm/scroll-position/constants.js +1 -0
- package/lib/esm/scroll-position/index.js +1 -0
- package/lib/esm/scroll-position/scheduleNextTick.js +6 -0
- package/lib/esm/session/InMemorySession.js +15 -0
- package/lib/esm/session/ServerSideRenderSession.js +11 -0
- package/lib/esm/session/Session.js +189 -0
- package/lib/esm/session/WebBrowserSession.js +13 -0
- package/lib/esm/session/key/createSessionKey.js +18 -0
- package/lib/esm/session/lifecycle/InMemorySessionLifecycle.js +13 -0
- package/lib/esm/session/lifecycle/WebBrowserSessionLifecycle.js +120 -0
- package/lib/esm/session/lifecycle/page-lifecycle/PageLifecycle.js +263 -0
- package/lib/esm/session/lifecycle/page-lifecycle/PageLifecycleInstance.js +2 -0
- package/lib/esm/session/lifecycle/page-lifecycle/supportsConstructableEventTarget.js +30 -0
- package/lib/esm/session/navigation/InMemoryNavigation.js +97 -0
- package/lib/esm/session/navigation/ServerSideNavigation.js +54 -0
- package/lib/esm/session/navigation/WebBrowserNavigation.js +213 -0
- package/lib/esm/session/navigation/error/NavigationOutOfBoundsError.js +6 -0
- package/lib/esm/session/navigation/error/ServerSideNavigationError.js +14 -0
- package/lib/esm/session/navigation/operation/operations.js +6 -0
- package/lib/esm/session/subscription/Subscription.js +75 -0
- package/lib/index.d.ts +178 -157
- package/lib/redux/index.d.ts +90 -0
- package/lib/scroll-position/index.d.ts +107 -0
- package/package.json +9 -5
- package/redux/package.json +6 -0
- package/scroll-position/package.json +6 -0
- package/src/NavigationStack.js +84 -0
- package/src/data-storage/DataStorage.js +69 -0
- package/src/data-storage/LocationDataStorage.js +23 -0
- package/src/data-storage/index.js +2 -0
- package/src/environment/InMemoryEnvironment.js +9 -0
- package/src/environment/WebBrowserEnvironment.js +9 -0
- package/src/environment/data-storage/InMemoryDataStorage.js +23 -0
- package/src/environment/data-storage/WebBrowserDataStorage.js +17 -0
- package/src/environment/scroll-position/InMemoryScrollPosition.js +45 -0
- package/src/environment/scroll-position/WebBrowserScrollPosition.js +72 -0
- package/src/getLocationFromInternalLocation.js +7 -0
- package/src/index.js +10 -8
- package/src/navigationBlockers.js +28 -27
- package/src/{normalizeInputLocation.js → parseInputLocation.js} +23 -8
- package/src/{ActionTypes.js → redux/ActionTypes.js} +1 -1
- package/src/redux/ActionTypesInternal.js +3 -0
- package/src/{Actions.js → redux/Actions.js} +4 -3
- package/src/redux/createMiddlewares.js +65 -0
- package/src/redux/index.js +4 -0
- package/src/redux/internalLocationReducer.js +9 -0
- package/src/redux/middleware/createAddInputLocationBasePathMiddleware.js +27 -0
- package/src/redux/middleware/createNonProgrammaticNavigationBlockerMiddleware.js +119 -0
- package/src/redux/middleware/createProgrammaticNavigationBlockerMiddleware.js +94 -0
- package/src/redux/middleware/createRemoveOutputLocationBasePathMiddleware.js +26 -0
- package/src/redux/middleware/createUpdateInternalLocationMiddleware.js +72 -0
- package/src/{middleware/navigationActionMiddleware.js → redux/middleware/navigationOperationMiddleware.js} +10 -3
- package/src/{middleware/normalizeInputLocationMiddleware.js → redux/middleware/parseInputLocationMiddleware.js} +5 -3
- package/src/redux/middleware/updateLocationMiddleware.js +28 -0
- package/src/scroll-position/PageScrollPositionSetter.js +110 -0
- package/src/scroll-position/ScrollPositionAutoSaver.js +151 -0
- package/src/scroll-position/ScrollPositionRestoration.js +506 -0
- package/src/scroll-position/ScrollPositionSaver.js +100 -0
- package/src/scroll-position/ScrollPositionSetter.js +16 -0
- package/src/scroll-position/constants.js +1 -0
- package/src/scroll-position/index.js +1 -0
- package/src/scroll-position/scheduleNextTick.js +6 -0
- package/src/session/InMemorySession.js +13 -0
- package/src/session/ServerSideRenderSession.js +9 -0
- package/src/session/Session.js +216 -0
- package/src/session/WebBrowserSession.js +13 -0
- package/src/session/key/createSessionKey.js +18 -0
- package/src/session/lifecycle/InMemorySessionLifecycle.js +13 -0
- package/src/session/lifecycle/WebBrowserSessionLifecycle.js +126 -0
- package/src/session/lifecycle/page-lifecycle/PageLifecycle.js +291 -0
- package/src/session/lifecycle/page-lifecycle/PageLifecycleInstance.js +3 -0
- package/src/session/lifecycle/page-lifecycle/supportsConstructableEventTarget.js +32 -0
- package/src/session/navigation/InMemoryNavigation.js +78 -0
- package/src/session/navigation/ServerSideNavigation.js +43 -0
- package/src/session/navigation/WebBrowserNavigation.js +224 -0
- package/src/session/navigation/error/NavigationOutOfBoundsError.js +7 -0
- package/src/session/navigation/error/ServerSideNavigationError.js +18 -0
- package/src/session/navigation/operation/operations.js +6 -0
- package/src/session/subscription/Subscription.js +76 -0
- package/test/NavigationStack.test.js +296 -0
- package/test/{LocationDataStorage.test.js → data-storage/LocationDataStorage.test.js} +3 -3
- package/test/data-storage/index.test.js +8 -0
- package/test/index.js +12 -0
- package/test/index.test.js +8 -7
- package/test/{helpers.js → middlewareTestUtil.js} +9 -12
- package/test/{normalizeInputLocation.test.js → parseInputLocationMiddleware.test.js} +9 -9
- package/test/{Action.test.js → redux/Action.test.js} +7 -6
- package/test/{ActionTypes.test.js → redux/ActionTypes.test.js} +2 -2
- package/test/redux/createMiddlewares.test.js +96 -0
- package/test/redux/index.test.js +10 -0
- package/test/{locationReducer.test.js → redux/locationReducer.test.js} +4 -7
- package/test/redux/middleware/createAddInputLocationBasePathMiddleware.test.js +40 -0
- package/test/redux/middleware/createNonProgrammaticNavigationBlockerMiddleware.test.js +264 -0
- package/test/redux/middleware/createProgrammaticNavigationBlockerMiddleware.test.js +312 -0
- package/test/redux/middleware/createRemoveOutputLocationBasePathMiddleware.test.js +51 -0
- package/test/{middleware/navigationActionMiddleware.test.js → redux/middleware/navigationOperationMiddleware.test.js} +16 -12
- package/test/{middleware/normalizeInputLocationMiddleware.test.js → redux/middleware/parseInputLocationMiddleware.test.js} +4 -4
- package/test/scroll-position/ScrollPositionRestoration.test.js +418 -0
- package/test/scroll-position/addScrollableContainer.js +36 -0
- package/test/scroll-position/addScrollableContainerWithHyperlink.js +50 -0
- package/test/scroll-position/createApp.js +112 -0
- package/test/scroll-position/delay.js +9 -0
- package/test/scroll-position/mockPageLifecycle.js +17 -0
- package/test/scroll-position/runApp.js +24 -0
- package/test/scroll-position/withScrollableContainerAtIndexPage.js +62 -0
- package/test/session/InMemorySession.test.js +348 -0
- package/test/session/ServerSession.test.js +17 -9
- package/test/session/WebBrowserSession.test.js +265 -0
- package/test/testUtil.js +3 -0
- package/types/data-storage/index.d.ts +35 -0
- package/types/index.d.ts +178 -157
- package/types/redux/index.d.ts +90 -0
- package/types/scroll-position/index.d.ts +107 -0
- package/types/tsconfig.json +1 -1
- package/lib/cjs/LocationDataStorage.js +0 -61
- package/lib/cjs/addBeforeLocationChangeListener.js +0 -7
- package/lib/cjs/beforeLocationChangeListeners.js +0 -51
- package/lib/cjs/createMiddlewares.js +0 -47
- package/lib/cjs/middleware/createBasePathMiddleware.js +0 -24
- package/lib/cjs/middleware/createBeforeLocationChangeListenerMiddleware.js +0 -39
- package/lib/cjs/middleware/createLocationMiddleware.js +0 -56
- package/lib/cjs/middleware/createNavigationBlockerMiddleware.js +0 -161
- package/lib/cjs/middleware/createTransformLocationMiddleware.js +0 -38
- package/lib/cjs/onlyAllowedOnClientSide.js +0 -10
- package/lib/cjs/session/BrowserSession.js +0 -235
- package/lib/cjs/session/MemorySession.js +0 -223
- package/lib/cjs/session/ServerSession.js +0 -65
- package/lib/esm/LocationDataStorage.js +0 -54
- package/lib/esm/addBeforeLocationChangeListener.js +0 -2
- package/lib/esm/beforeLocationChangeListeners.js +0 -44
- package/lib/esm/createMiddlewares.js +0 -41
- package/lib/esm/middleware/createBasePathMiddleware.js +0 -19
- package/lib/esm/middleware/createBeforeLocationChangeListenerMiddleware.js +0 -34
- package/lib/esm/middleware/createLocationMiddleware.js +0 -50
- package/lib/esm/middleware/createNavigationBlockerMiddleware.js +0 -156
- package/lib/esm/middleware/createTransformLocationMiddleware.js +0 -33
- package/lib/esm/onlyAllowedOnClientSide.js +0 -5
- package/lib/esm/session/BrowserSession.js +0 -229
- package/lib/esm/session/MemorySession.js +0 -217
- package/lib/esm/session/ServerSession.js +0 -58
- package/src/LocationDataStorage.js +0 -60
- package/src/addBeforeLocationChangeListener.js +0 -2
- package/src/beforeLocationChangeListeners.js +0 -54
- package/src/createMiddlewares.js +0 -45
- package/src/middleware/createBasePathMiddleware.js +0 -20
- package/src/middleware/createBeforeLocationChangeListenerMiddleware.js +0 -40
- package/src/middleware/createLocationMiddleware.js +0 -55
- package/src/middleware/createNavigationBlockerMiddleware.js +0 -168
- package/src/middleware/createTransformLocationMiddleware.js +0 -29
- package/src/onlyAllowedOnClientSide.js +0 -5
- package/src/session/BrowserSession.js +0 -235
- package/src/session/MemorySession.js +0 -219
- package/src/session/ServerSession.js +0 -67
- package/test/createMiddlewares.test.js +0 -62
- package/test/middleware/createBasePathMiddleware.test.js +0 -67
- package/test/middleware/createBeforeLocationChangeListenerMiddleware.test.js +0 -141
- package/test/middleware/createNavigationBlockerMiddleware.test.js +0 -471
- package/test/middleware/createTransformLocationMiddleware.test.js +0 -44
- package/test/session/BrowserSession.test.js +0 -182
- package/test/session/MemorySession.test.js +0 -244
- /package/lib/cjs/{locationReducer.js → redux/locationReducer.js} +0 -0
- /package/lib/esm/{locationReducer.js → redux/locationReducer.js} +0 -0
- /package/src/{locationReducer.js → redux/locationReducer.js} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _ScrollPositionAutoSaver = _interopRequireDefault(require("./ScrollPositionAutoSaver"));
|
|
6
|
+
var _constants = require("./constants");
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
/* eslint-disable no-underscore-dangle */
|
|
9
|
+
|
|
10
|
+
class ScrollPositionSaver {
|
|
11
|
+
constructor({
|
|
12
|
+
scrollPosition,
|
|
13
|
+
getLocation,
|
|
14
|
+
saveScrollPositionForLocation,
|
|
15
|
+
getScrollableContainers,
|
|
16
|
+
shouldSaveScrollPosition
|
|
17
|
+
}) {
|
|
18
|
+
this._scrollPosition = scrollPosition;
|
|
19
|
+
this._getLocation = getLocation;
|
|
20
|
+
this._saveScrollPositionForLocation = saveScrollPositionForLocation;
|
|
21
|
+
this._getScrollableContainers = getScrollableContainers;
|
|
22
|
+
this._shouldSaveScrollPosition = shouldSaveScrollPosition;
|
|
23
|
+
this._scrollPositionAutoSaver = new _ScrollPositionAutoSaver.default({
|
|
24
|
+
scrollPosition: this._scrollPosition,
|
|
25
|
+
scrollPositionSaver: this,
|
|
26
|
+
getScrollableContainers,
|
|
27
|
+
shouldSaveScrollPosition
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
start() {
|
|
31
|
+
this._scrollPositionAutoSaver.start();
|
|
32
|
+
}
|
|
33
|
+
stop() {
|
|
34
|
+
this._scrollPositionAutoSaver.stop();
|
|
35
|
+
}
|
|
36
|
+
cancelPreviouslyScheduledAutoSave() {
|
|
37
|
+
this._scrollPositionAutoSaver.cancelScheduledAutoSave();
|
|
38
|
+
}
|
|
39
|
+
saveScrollPosition() {
|
|
40
|
+
// This flag is not used in real life and is only used in tests (for some reason).
|
|
41
|
+
if (!this._shouldSaveScrollPosition()) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Get scrollable containers.
|
|
46
|
+
const scrollableContainers = this._getScrollableContainers();
|
|
47
|
+
|
|
48
|
+
// Save scroll position of each scrollable container.
|
|
49
|
+
for (const scrollableContainerKey of Object.keys(scrollableContainers)) {
|
|
50
|
+
if (scrollableContainerKey === _constants.PAGE_SCROLLABLE_CONTAINER_KEY) {
|
|
51
|
+
this.savePageScrollPosition();
|
|
52
|
+
} else {
|
|
53
|
+
this.saveScrollableContainerScrollPosition(scrollableContainerKey, scrollableContainers[scrollableContainerKey].scrollableContainer);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
savePageScrollPosition() {
|
|
58
|
+
// * If this is not a scheduled "auto-save" of scroll position
|
|
59
|
+
// and there already exists any scheduled "auto-save" of scroll position,
|
|
60
|
+
// cancel it and save scroll position right now instead.
|
|
61
|
+
// * If this is a scheduled "auto-save" of scroll position,
|
|
62
|
+
// clear the "cancel" function because it's no longer of use.
|
|
63
|
+
this._scrollPositionAutoSaver.cancelSavePageScrollPosition();
|
|
64
|
+
|
|
65
|
+
// Save scroll position.
|
|
66
|
+
this._saveScrollPositionForLocation(this._getLocation(), undefined, this._scrollPosition.getPageScrollPosition());
|
|
67
|
+
}
|
|
68
|
+
saveScrollableContainerScrollPosition(scrollableContainerKey, scrollableContainer) {
|
|
69
|
+
// * If this is not a scheduled "auto-save" of scroll position
|
|
70
|
+
// and there already exists any scheduled "auto-save" of scroll position,
|
|
71
|
+
// cancel it and save scroll position right now instead.
|
|
72
|
+
// * If this is a scheduled "auto-save" of scroll position,
|
|
73
|
+
// clear the "cancel" function because it's no longer of use.
|
|
74
|
+
this._scrollPositionAutoSaver.cancelSaveScrollableContainerScrollPosition(scrollableContainerKey);
|
|
75
|
+
|
|
76
|
+
// Save scroll position.
|
|
77
|
+
this._saveScrollPositionForLocation(this._getLocation(), scrollableContainerKey, this._scrollPosition.getScrollableContainerScrollPosition(scrollableContainer));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = ScrollPositionSaver;
|
|
81
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
class ScrollPositionSetter {
|
|
6
|
+
set(scrollableContainer, scrollPositionOrAnchor, environmentScrollPosition) {
|
|
7
|
+
if (typeof scrollPositionOrAnchor === 'string') {
|
|
8
|
+
throw new Error('`ScrollPositionSetter` only allows setting numeric scroll position, not an anchor string');
|
|
9
|
+
}
|
|
10
|
+
environmentScrollPosition.setScrollableContainerScrollPosition(scrollableContainer, scrollPositionOrAnchor);
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
cancel() {}
|
|
14
|
+
}
|
|
15
|
+
exports.default = ScrollPositionSetter;
|
|
16
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.ScrollPositionRestoration = void 0;
|
|
5
|
+
var _ScrollPositionRestoration = _interopRequireDefault(require("./ScrollPositionRestoration"));
|
|
6
|
+
exports.ScrollPositionRestoration = _ScrollPositionRestoration.default;
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = scheduleNextTick;
|
|
5
|
+
function scheduleNextTick(func) {
|
|
6
|
+
const timerId = window.requestAnimationFrame(func);
|
|
7
|
+
return () => {
|
|
8
|
+
cancelAnimationFrame(timerId);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _Session = _interopRequireDefault(require("./Session"));
|
|
6
|
+
var _InMemoryEnvironment = _interopRequireDefault(require("../environment/InMemoryEnvironment"));
|
|
7
|
+
var _InMemorySessionLifecycle = _interopRequireDefault(require("./lifecycle/InMemorySessionLifecycle"));
|
|
8
|
+
var _InMemoryNavigation = _interopRequireDefault(require("./navigation/InMemoryNavigation"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
class InMemorySession extends _Session.default {
|
|
11
|
+
constructor({
|
|
12
|
+
navigation = new _InMemoryNavigation.default()
|
|
13
|
+
} = {}) {
|
|
14
|
+
super({
|
|
15
|
+
navigation
|
|
16
|
+
});
|
|
17
|
+
this.environment = new _InMemoryEnvironment.default();
|
|
18
|
+
this.lifecycle = new _InMemorySessionLifecycle.default();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = InMemorySession;
|
|
22
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _InMemorySession = _interopRequireDefault(require("./InMemorySession"));
|
|
6
|
+
var _ServerSideNavigation = _interopRequireDefault(require("./navigation/ServerSideNavigation"));
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
// `ServerSideRenderSession` is just a `InMemorySession` that specifically prohibits any navigation.
|
|
9
|
+
class ServerSideRenderSession extends _InMemorySession.default {
|
|
10
|
+
constructor() {
|
|
11
|
+
super({
|
|
12
|
+
navigation: new _ServerSideNavigation.default()
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = ServerSideRenderSession;
|
|
17
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _parseInputLocation = _interopRequireDefault(require("../parseInputLocation"));
|
|
6
|
+
var _createSessionKey = _interopRequireDefault(require("./key/createSessionKey"));
|
|
7
|
+
var _NavigationOutOfBoundsError = _interopRequireDefault(require("./navigation/error/NavigationOutOfBoundsError"));
|
|
8
|
+
var _operations = _interopRequireDefault(require("./navigation/operation/operations"));
|
|
9
|
+
var _Subscription = _interopRequireDefault(require("./subscription/Subscription"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const INITIAL_KEY_INDEX = -1;
|
|
12
|
+
const INITIAL_INDEX = -1;
|
|
13
|
+
const INIT_LOCATION_DELTA = 0;
|
|
14
|
+
class Session {
|
|
15
|
+
constructor({
|
|
16
|
+
navigation
|
|
17
|
+
}) {
|
|
18
|
+
// This function is used by navigation.
|
|
19
|
+
this._getCurrentLocationIndex = () => {
|
|
20
|
+
return this._currentLocationIndex;
|
|
21
|
+
};
|
|
22
|
+
// `key` is used in `WebBrowserSession` to uniquely identify a session
|
|
23
|
+
// when storing data in a `WebBrowserDataStorage` which uses `window.sessionStorage`
|
|
24
|
+
// under the hood, and `window.sessionStorage` is shared between different sessions.
|
|
25
|
+
this.key = (0, _createSessionKey.default)();
|
|
26
|
+
|
|
27
|
+
// `this._locationKeyIndex` is incremented every time the current location changes.
|
|
28
|
+
this._locationKeyIndex = INITIAL_KEY_INDEX;
|
|
29
|
+
|
|
30
|
+
// `this._currentLocationIndex` is the index of the top element in the navigation stack.
|
|
31
|
+
// I.e. it's the index of the "current" location in the navigation stack.
|
|
32
|
+
this._currentLocationIndex = INITIAL_INDEX;
|
|
33
|
+
|
|
34
|
+
// The `index` of the terminal (rightmost) location in the navigation history.
|
|
35
|
+
// In other words, this is the last location index that it can `.shift()` to.
|
|
36
|
+
this._terminalLocationIndex = this._currentLocationIndex;
|
|
37
|
+
|
|
38
|
+
// Create `navigation`.
|
|
39
|
+
this._navigation = navigation;
|
|
40
|
+
|
|
41
|
+
// Manages subscriptions.
|
|
42
|
+
this._subscription = new _Subscription.default({
|
|
43
|
+
activateSubscription: listener => {
|
|
44
|
+
return this._navigation.subscribe(listener);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Update current location index when a location change was not initiated
|
|
49
|
+
// by this session but rather by the user clicking "Back" or "Forward" button.
|
|
50
|
+
this._unsubscribe = this.subscribe(location => {
|
|
51
|
+
// Update `this._currentLocationIndex` when the location change was not initiated
|
|
52
|
+
// by this session but rather by the user clicking "Back" or "Forward" button.
|
|
53
|
+
this._currentLocationIndex = location.index;
|
|
54
|
+
// Since `currentLocationIndex` has been updated, update `terminalLocationIndex`.
|
|
55
|
+
// It's not really currently possible to see a "PUSH" or a "REPLACE" operation here,
|
|
56
|
+
// but if it was possible, this call would be required. It would also be required
|
|
57
|
+
// by `navigation` to call `session.getNextKey()` function to increment `locationKeyIndex`.
|
|
58
|
+
this._updateTerminalLocationIndex(location);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Subscribes to changes in location.
|
|
63
|
+
subscribe(listener) {
|
|
64
|
+
return this._subscription.subscribe(location => {
|
|
65
|
+
if (!this._isStarted() && location.operation !== _operations.default.INIT) {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.error('Unexpected location change', location);
|
|
68
|
+
throw new Error('Not started');
|
|
69
|
+
} else {
|
|
70
|
+
// Call the listener.
|
|
71
|
+
listener(location);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
start(initialLocation) {
|
|
76
|
+
if (this._stopped) {
|
|
77
|
+
throw new Error('Can not be restarted');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Simplify "developer experience" by automatically calling
|
|
81
|
+
// `.init(initialLocation)` in case of using a `WebBrowserSession`.
|
|
82
|
+
//
|
|
83
|
+
// That's because `WebBrowserSession` environment already knows
|
|
84
|
+
// the initial location by the time javascript code starts execution.
|
|
85
|
+
//
|
|
86
|
+
if (!initialLocation) {
|
|
87
|
+
initialLocation = this._navigation.getInitialLocation();
|
|
88
|
+
if (initialLocation) {
|
|
89
|
+
initialLocation = (0, _parseInputLocation.default)(initialLocation);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!initialLocation) {
|
|
93
|
+
throw new Error('`initialLocation` is required');
|
|
94
|
+
}
|
|
95
|
+
if (this._currentLocationIndex !== INITIAL_INDEX) {
|
|
96
|
+
throw new Error('Already started');
|
|
97
|
+
}
|
|
98
|
+
this._started = true;
|
|
99
|
+
const key = this._getNextLocationKey();
|
|
100
|
+
const index = INITIAL_INDEX + 1;
|
|
101
|
+
const delta = INIT_LOCATION_DELTA;
|
|
102
|
+
const locationResult = this._navigation.init(initialLocation, {
|
|
103
|
+
operation: _operations.default.INIT,
|
|
104
|
+
key,
|
|
105
|
+
index,
|
|
106
|
+
delta
|
|
107
|
+
});
|
|
108
|
+
if (locationResult) {
|
|
109
|
+
this._subscription.notifySubscribers(locationResult);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
stop() {
|
|
113
|
+
if (this._stopped) {
|
|
114
|
+
throw Error('Already stopped');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Once stopped, it won't be able to be restarted.
|
|
118
|
+
this._stopped = true;
|
|
119
|
+
|
|
120
|
+
// Remove location change subscription.
|
|
121
|
+
this._unsubscribe();
|
|
122
|
+
|
|
123
|
+
// Even if it calls `unsubscribe()` function above, any other subscriptions
|
|
124
|
+
// would still stay. For example, subscriptions created by the application code.
|
|
125
|
+
// To work around that, `.stop()` function removes all subscriptions.
|
|
126
|
+
this._subscription.stop();
|
|
127
|
+
}
|
|
128
|
+
navigate(operation, location) {
|
|
129
|
+
if (!this._isStarted()) {
|
|
130
|
+
throw Error('Not started');
|
|
131
|
+
}
|
|
132
|
+
if (operation !== _operations.default.PUSH && operation !== _operations.default.REPLACE) {
|
|
133
|
+
throw Error(`Unknown navigation operation: ${operation}`);
|
|
134
|
+
}
|
|
135
|
+
const delta = operation === _operations.default.PUSH ? 1 : 0;
|
|
136
|
+
this._updateTerminalLocationIndex({
|
|
137
|
+
operation
|
|
138
|
+
});
|
|
139
|
+
const key = this._getNextLocationKey();
|
|
140
|
+
const index = this._currentLocationIndex + delta;
|
|
141
|
+
|
|
142
|
+
// Navigate to the location.
|
|
143
|
+
const locationResult = this._navigation.navigate(location, {
|
|
144
|
+
operation,
|
|
145
|
+
key,
|
|
146
|
+
index,
|
|
147
|
+
delta
|
|
148
|
+
});
|
|
149
|
+
if (locationResult) {
|
|
150
|
+
this._subscription.notifySubscribers(locationResult);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
shift(delta) {
|
|
154
|
+
if (!this._isStarted()) {
|
|
155
|
+
throw Error('Not started');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// If there'll be no navigation, return.
|
|
159
|
+
if (delta === 0) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const index = this._currentLocationIndex + delta;
|
|
163
|
+
|
|
164
|
+
// Validate that the new `index` is not out of bounds.
|
|
165
|
+
if (index < 0 || index > this._terminalLocationIndex) {
|
|
166
|
+
throw new _NavigationOutOfBoundsError.default(index);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Navigate to the location.
|
|
170
|
+
const locationResult = this._navigation.shift({
|
|
171
|
+
operation: _operations.default.SHIFT,
|
|
172
|
+
index,
|
|
173
|
+
delta
|
|
174
|
+
});
|
|
175
|
+
if (locationResult) {
|
|
176
|
+
this._subscription.notifySubscribers(locationResult);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_updateTerminalLocationIndex({
|
|
180
|
+
operation
|
|
181
|
+
}) {
|
|
182
|
+
// A `PUSH` navigation sets a new terminal (rightmost) location.
|
|
183
|
+
if (operation === _operations.default.PUSH || operation === _operations.default.INIT) {
|
|
184
|
+
this._terminalLocationIndex = this._currentLocationIndex;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
_getNextLocationKey() {
|
|
188
|
+
this._locationKeyIndex++;
|
|
189
|
+
return this._locationKeyIndex.toString(36);
|
|
190
|
+
}
|
|
191
|
+
_isStarted() {
|
|
192
|
+
return !this._stopped && this._currentLocationIndex !== INITIAL_INDEX;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.default = Session;
|
|
196
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _Session = _interopRequireDefault(require("./Session"));
|
|
6
|
+
var _WebBrowserEnvironment = _interopRequireDefault(require("../environment/WebBrowserEnvironment"));
|
|
7
|
+
var _WebBrowserSessionLifecycle = _interopRequireDefault(require("./lifecycle/WebBrowserSessionLifecycle"));
|
|
8
|
+
var _WebBrowserNavigation = _interopRequireDefault(require("./navigation/WebBrowserNavigation"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
class WebBrowserSession extends _Session.default {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
navigation: new _WebBrowserNavigation.default()
|
|
14
|
+
});
|
|
15
|
+
this.environment = new _WebBrowserEnvironment.default();
|
|
16
|
+
this.lifecycle = new _WebBrowserSessionLifecycle.default();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = WebBrowserSession;
|
|
20
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = createSessionKey;
|
|
5
|
+
// `session.key` exists to avoid `location.key` collision after a page refresh.
|
|
6
|
+
// After a page refresh, a different `session.key` is created
|
|
7
|
+
// while the previous navigation history still exists because
|
|
8
|
+
// web browser navigation history survives a page reload.
|
|
9
|
+
// So web browser navigation history after a refresh contains records from different sessions.
|
|
10
|
+
// This means that some of those history records end up having same `location.key`s
|
|
11
|
+
// because `location.key` always starts from `0` for each different session.
|
|
12
|
+
// So `location.key` alone can't be used to identify navigation history entries
|
|
13
|
+
// because it's not unique among them. In order to get a unique key for a navigation history entry,
|
|
14
|
+
// one should combine a unique `session.key` with a `location.key`.
|
|
15
|
+
// That's what `session.key` exists for.
|
|
16
|
+
// Supplementary features such as scroll position restoration
|
|
17
|
+
// use `window.sessionStorage` to store supplementary data for a given navigation history entry.
|
|
18
|
+
// Because `window.sessionStorage` is shared between all navigation history entries from different websites,
|
|
19
|
+
// the keys used for storing that supplementary data have to be unique.
|
|
20
|
+
function createSessionKey() {
|
|
21
|
+
return Date.now().toString(36);
|
|
22
|
+
}
|
|
23
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
class InMemorySessionLifecycle {
|
|
6
|
+
// Termination blockers of an "in-memory session" are currently ignored.
|
|
7
|
+
// eslint-disable-next-line no-unused-vars
|
|
8
|
+
addTerminationBlocker(blocker) {
|
|
9
|
+
return () => {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// An "in-memory session" execution status is always `running: true`.
|
|
13
|
+
// eslint-disable-next-line no-unused-vars
|
|
14
|
+
addExecutionStatusListener(listener) {
|
|
15
|
+
return () => {};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = InMemorySessionLifecycle;
|
|
19
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _PageLifecycleInstance = _interopRequireDefault(require("./page-lifecycle/PageLifecycleInstance"));
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
// https://developers.google.com/web/updates/2018/07/page-lifecycle-api
|
|
8
|
+
// https://github.com/GoogleChromeLabs/page-lifecycle
|
|
9
|
+
|
|
10
|
+
class WebBrowserSessionLifecycle {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._running = true;
|
|
13
|
+
}
|
|
14
|
+
addTerminationBlocker(terminationBlocker) {
|
|
15
|
+
const onBeforeUnload = event => {
|
|
16
|
+
if (terminationBlocker()) {
|
|
17
|
+
// Calling `event.preventDefault()` will cause a web browser
|
|
18
|
+
// to show a generic "Ok"/"Cancel" modal with some generic text:
|
|
19
|
+
// "Are you sure to leave the current page?".
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener('beforeunload', onBeforeUnload);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
addExecutionStatusListener(listener) {
|
|
29
|
+
const pageLifecycleListener = stateChange => {
|
|
30
|
+
// (stateChange: PageLifecycleStateChange)
|
|
31
|
+
const {
|
|
32
|
+
newState
|
|
33
|
+
} = stateChange;
|
|
34
|
+
const running = !['terminated', 'frozen', 'discarded'].includes(newState);
|
|
35
|
+
if (this._running !== running) {
|
|
36
|
+
this._running = running;
|
|
37
|
+
listener({
|
|
38
|
+
running
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
_PageLifecycleInstance.default.addEventListener('statechange', pageLifecycleListener);
|
|
43
|
+
return () => {
|
|
44
|
+
_PageLifecycleInstance.default.removeEventListener('statechange', pageLifecycleListener);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// interface PageLifecycleStateChange {
|
|
50
|
+
// newState: PageLifecycleState;
|
|
51
|
+
// oldState: PageLifecycleState;
|
|
52
|
+
// originalEvent: Event;
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
// // Page Lifecycle API event types.
|
|
56
|
+
// // https://developer.chrome.com/docs/web-platform/page-lifecycle-api#states
|
|
57
|
+
// // https://wicg.github.io/page-lifecycle/spec.html
|
|
58
|
+
// //
|
|
59
|
+
// type PageLifecycleState =
|
|
60
|
+
// // The page is visible and is focused.
|
|
61
|
+
// | 'active'
|
|
62
|
+
// // The page is visible but is not focused.
|
|
63
|
+
// | 'passive'
|
|
64
|
+
// // The page is not visible (and has not been frozen, discarded, or terminated).
|
|
65
|
+
// | 'hidden'
|
|
66
|
+
// // If a page is hidden, a browser may choose to freeze it to reduce energy consumption.
|
|
67
|
+
// | 'frozen'
|
|
68
|
+
// // The process of terminating (destroying, closing) the page has started.
|
|
69
|
+
// | 'terminated'
|
|
70
|
+
// // The page is discarded by the web browser due to insufficient resources.
|
|
71
|
+
// // The page snapshot could still be visible to the user even though it's no longer running.
|
|
72
|
+
// | 'discarded';
|
|
73
|
+
|
|
74
|
+
// // Page Lifecycle API event types.
|
|
75
|
+
// // https://developer.chrome.com/docs/web-platform/page-lifecycle-api
|
|
76
|
+
// // https://wicg.github.io/page-lifecycle/spec.html
|
|
77
|
+
// //
|
|
78
|
+
// type PageLifecycleEvent =
|
|
79
|
+
// // When the web browser window with an opened page gets focus, a `focus` event is emitted.
|
|
80
|
+
// | 'focus'
|
|
81
|
+
//
|
|
82
|
+
// // When the web browser window with an opened page is no longer focused, a `blur` event is emitted.
|
|
83
|
+
// | 'blur'
|
|
84
|
+
//
|
|
85
|
+
// // `visibilitychange` event fires with `document.visibilityState` being "hidden"
|
|
86
|
+
// // when a user navigates to a new page, switches tabs, closes the tab, minimizes or closes the browser,
|
|
87
|
+
// // or, on mobile, switches from the browser to a different app.
|
|
88
|
+
// //
|
|
89
|
+
// // Transitioning to "hidden" is the last event that's reliably observable by the page,
|
|
90
|
+
// // so developers should treat it as the likely end of the user's session
|
|
91
|
+
// // (for example, for sending analytics data).
|
|
92
|
+
// //
|
|
93
|
+
// // The transition to "hidden" is also a good point at which pages can stop making UI updates
|
|
94
|
+
// // and stop any tasks that the user doesn't want to have running in the background.
|
|
95
|
+
// //
|
|
96
|
+
// | 'visibilitychange'
|
|
97
|
+
//
|
|
98
|
+
// // Sometimes browsers "freeze" hidden pages in order to reduce energy consumption on mobile devices.
|
|
99
|
+
// // In case of freezing an already-hidden page, a `freeze` event will be emitted, if supported by the browser.
|
|
100
|
+
// | 'freeze'
|
|
101
|
+
//
|
|
102
|
+
// // Sometimes browsers "freeze" hidden pages in order to reduce energy consumption on mobile devices.
|
|
103
|
+
// // In case of unfreezing an already-frozen page, a `resume` event will be emitted, if supported by the browser.
|
|
104
|
+
// | 'resume'
|
|
105
|
+
//
|
|
106
|
+
// // `pageshow` event is emitted when a new page gets shown.
|
|
107
|
+
// //
|
|
108
|
+
// // For example, `pageshow` event is emitted when visiting a web page
|
|
109
|
+
// // or after being navigated to a new page by clicking a hyperlink.
|
|
110
|
+
// //
|
|
111
|
+
// // `pageshow` event is also emitted when the user performs "Back" or "Forward" transition.
|
|
112
|
+
// //
|
|
113
|
+
// | 'pageshow'
|
|
114
|
+
//
|
|
115
|
+
// // `pagehide` event is emitted when the current page gets "destroyed".
|
|
116
|
+
// //
|
|
117
|
+
// // For example, `pagehide` event is emitted when the user performs "Back" or "Forward" transition.
|
|
118
|
+
// // In that case, `pagehide` event will be emitted for the current page before the transition.
|
|
119
|
+
// //
|
|
120
|
+
// // In any other cases of "destroying" The current page, `pagehide` event is not guaranteed to be emitted.
|
|
121
|
+
// // For example, it won't be emitted when closing the web browser app via a task manager.
|
|
122
|
+
// //
|
|
123
|
+
// // Hence, `pagehide` event is unreliable and it's adivised to use `visibilitychange` event instead.
|
|
124
|
+
// // Only if `visibilitychange` even is not supported by a web browser should one consider resorting to using `pagehide` event.
|
|
125
|
+
// //
|
|
126
|
+
// | 'pagehide';
|
|
127
|
+
exports.default = WebBrowserSessionLifecycle;
|
|
128
|
+
module.exports = exports.default;
|