@react-motion-router/stack 2.0.0-beta.sha-1c021e3 → 2.0.0-beta.sha-c1cce91
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/build/Navigation.d.ts +11 -10
- package/build/Router.d.ts +18 -8
- package/build/Screen.d.ts +48 -42
- package/build/common/constants.d.ts +1 -1
- package/build/common/events.d.ts +6 -6
- package/build/common/hooks.d.ts +2 -1
- package/build/common/promise-wrapper.d.ts +9 -0
- package/build/common/types.d.ts +11 -2
- package/build/common/utils.d.ts +2 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +328 -196
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -895,6 +895,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
895
895
|
"zF": () => (/* reexport */ FadeInKeyframes),
|
|
896
896
|
"JA": () => (/* reexport */ FadeOutKeyframes),
|
|
897
897
|
"rN": () => (/* reexport */ GestureRegion),
|
|
898
|
+
"c4": () => (/* reexport */ HistoryEntry),
|
|
898
899
|
"W_": () => (/* reexport */ Navigation),
|
|
899
900
|
"F0": () => (/* reexport */ Router),
|
|
900
901
|
"lL": () => (/* reexport */ Screen),
|
|
@@ -946,7 +947,7 @@ var web_gesture_events = __webpack_require__(190);
|
|
|
946
947
|
;// CONCATENATED MODULE: external "@react-motion-router/core"
|
|
947
948
|
var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
948
949
|
var y = x => () => x
|
|
949
|
-
const core_namespaceObject = x({ ["NavigationBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.NavigationBase, ["RouterBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.RouterBase, ["ScreenBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.ScreenBase, ["includesRoute"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.includesRoute, ["isValidScreenChild"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.isValidScreenChild, ["matchRoute"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.matchRoute, ["resolveBaseURLFromPattern"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.resolveBaseURLFromPattern, ["useNavigationBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useNavigationBase, ["useRouteBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useRouteBase, ["useRouterBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useRouterBase });
|
|
950
|
+
const core_namespaceObject = x({ ["NavigationBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.NavigationBase, ["RouterBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.RouterBase, ["ScreenBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.ScreenBase, ["cloneAndInject"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.cloneAndInject, ["includesRoute"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.includesRoute, ["isValidScreenChild"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.isValidScreenChild, ["matchRoute"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.matchRoute, ["resolveBaseURLFromPattern"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.resolveBaseURLFromPattern, ["useNavigationBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useNavigationBase, ["useRouteBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useRouteBase, ["useRouterBase"]: () => __WEBPACK_EXTERNAL_MODULE__react_motion_router_core_d1cff82c__.useRouterBase });
|
|
950
951
|
;// CONCATENATED MODULE: ./src/common/events.ts
|
|
951
952
|
class NavigateEvent extends Event {
|
|
952
953
|
routerId;
|
|
@@ -954,42 +955,42 @@ class NavigateEvent extends Event {
|
|
|
954
955
|
props;
|
|
955
956
|
navigationType;
|
|
956
957
|
signal;
|
|
957
|
-
|
|
958
|
+
committed;
|
|
958
959
|
transition;
|
|
959
|
-
constructor(routerId, route, props, type, signal,
|
|
960
|
+
constructor(routerId, route, props, type, signal, committed, transition) {
|
|
960
961
|
super('navigate');
|
|
961
962
|
this.routerId = routerId;
|
|
962
963
|
this.route = route;
|
|
963
964
|
this.props = props;
|
|
964
965
|
this.navigationType = type ?? "push";
|
|
965
966
|
this.signal = signal;
|
|
966
|
-
this.
|
|
967
|
+
this.committed = committed;
|
|
967
968
|
this.transition = transition;
|
|
968
969
|
}
|
|
969
970
|
}
|
|
970
971
|
class BackEvent extends Event {
|
|
971
972
|
routerId;
|
|
972
973
|
signal;
|
|
973
|
-
|
|
974
|
+
committed;
|
|
974
975
|
transition;
|
|
975
|
-
constructor(routerId, signal,
|
|
976
|
+
constructor(routerId, signal, committed, transition) {
|
|
976
977
|
super('back');
|
|
977
978
|
this.routerId = routerId;
|
|
978
979
|
this.signal = signal;
|
|
979
|
-
this.
|
|
980
|
+
this.committed = committed;
|
|
980
981
|
this.transition = transition;
|
|
981
982
|
}
|
|
982
983
|
}
|
|
983
984
|
class ForwardEvent extends Event {
|
|
984
985
|
routerId;
|
|
985
986
|
signal;
|
|
986
|
-
|
|
987
|
+
committed;
|
|
987
988
|
transition;
|
|
988
|
-
constructor(routerId, signal,
|
|
989
|
+
constructor(routerId, signal, committed, transition) {
|
|
989
990
|
super('forward');
|
|
990
991
|
this.routerId = routerId;
|
|
991
992
|
this.signal = signal;
|
|
992
|
-
this.
|
|
993
|
+
this.committed = committed;
|
|
993
994
|
this.transition = transition;
|
|
994
995
|
}
|
|
995
996
|
}
|
|
@@ -1068,12 +1069,9 @@ class HistoryEntry {
|
|
|
1068
1069
|
class Navigation extends core_namespaceObject.NavigationBase {
|
|
1069
1070
|
router;
|
|
1070
1071
|
constructor(router) {
|
|
1071
|
-
super(
|
|
1072
|
+
super();
|
|
1072
1073
|
this.router = router;
|
|
1073
1074
|
}
|
|
1074
|
-
traverseTo(key) {
|
|
1075
|
-
return window.navigation.traverseTo(key);
|
|
1076
|
-
}
|
|
1077
1075
|
replace(route, props = {}, options = {}) {
|
|
1078
1076
|
return this.navigate(route, props, { ...options, type: "replace" });
|
|
1079
1077
|
}
|
|
@@ -1083,6 +1081,24 @@ class Navigation extends core_namespaceObject.NavigationBase {
|
|
|
1083
1081
|
reload(props = {}) {
|
|
1084
1082
|
return window.navigation.reload({ state: props });
|
|
1085
1083
|
}
|
|
1084
|
+
traverseTo(key, options = {}) {
|
|
1085
|
+
const result = window.navigation.traverseTo(key);
|
|
1086
|
+
const transition = window.navigation.transition;
|
|
1087
|
+
const fromIndex = transition.from.index;
|
|
1088
|
+
const destinationIndex = window.navigation.entries().findIndex(entry => entry.key === key);
|
|
1089
|
+
const controller = new AbortController();
|
|
1090
|
+
controller.signal.addEventListener('abort', () => this.traverseTo(transition.from.key), { once: true });
|
|
1091
|
+
options.signal?.addEventListener('abort', controller.abort, { once: true });
|
|
1092
|
+
let event;
|
|
1093
|
+
if (fromIndex > destinationIndex) {
|
|
1094
|
+
event = this.createBackEvent(controller.signal, result.committed, transition);
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
event = this.createForwardEvent(controller.signal, result.committed, transition);
|
|
1098
|
+
}
|
|
1099
|
+
this.dispatchEvent?.(event);
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1086
1102
|
navigate(route, props = {}, options = {}) {
|
|
1087
1103
|
const { type: history = "push" } = options;
|
|
1088
1104
|
const url = new URL(route, this.baseURL);
|
|
@@ -1091,50 +1107,51 @@ class Navigation extends core_namespaceObject.NavigationBase {
|
|
|
1091
1107
|
const controller = new AbortController();
|
|
1092
1108
|
controller.signal.addEventListener('abort', () => this.goBack(), { once: true });
|
|
1093
1109
|
options.signal?.addEventListener('abort', controller.abort, { once: true });
|
|
1094
|
-
const event = this.createNavigateEvent(route, props, history, controller.signal, result, transition);
|
|
1110
|
+
const event = this.createNavigateEvent(route, props, history, controller.signal, result.committed, transition);
|
|
1095
1111
|
this.dispatchEvent?.(event);
|
|
1096
1112
|
return result;
|
|
1097
1113
|
}
|
|
1098
1114
|
goBack(options = {}) {
|
|
1099
|
-
if (!this.canGoBack)
|
|
1115
|
+
if (!this.canGoBack())
|
|
1100
1116
|
return;
|
|
1101
|
-
const
|
|
1102
|
-
const result = window.navigation.traverseTo(previous.key);
|
|
1117
|
+
const result = window.navigation.traverseTo(this.previous.key);
|
|
1103
1118
|
const transition = window.navigation.transition;
|
|
1104
1119
|
const controller = new AbortController();
|
|
1105
1120
|
controller.signal.addEventListener('abort', () => this.goForward(), { once: true });
|
|
1106
1121
|
options.signal?.addEventListener('abort', controller.abort, { once: true });
|
|
1107
|
-
const event = this.createBackEvent(controller.signal, result, transition);
|
|
1122
|
+
const event = this.createBackEvent(controller.signal, result.committed, transition);
|
|
1108
1123
|
this.dispatchEvent?.(event);
|
|
1109
1124
|
return result;
|
|
1110
1125
|
}
|
|
1111
1126
|
goForward(options = {}) {
|
|
1112
|
-
if (!this.canGoForward)
|
|
1127
|
+
if (!this.canGoForward())
|
|
1113
1128
|
return;
|
|
1114
|
-
const
|
|
1115
|
-
const result = window.navigation.traverseTo(next.key);
|
|
1129
|
+
const result = window.navigation.traverseTo(this.next.key);
|
|
1116
1130
|
const transition = window.navigation.transition;
|
|
1117
1131
|
const controller = new AbortController();
|
|
1118
1132
|
controller.signal.addEventListener('abort', () => this.goBack(), { once: true });
|
|
1119
1133
|
options.signal?.addEventListener('abort', controller.abort, { once: true });
|
|
1120
|
-
const event = this.createForwardEvent(controller.signal, result, transition);
|
|
1134
|
+
const event = this.createForwardEvent(controller.signal, result.committed, transition);
|
|
1121
1135
|
this.dispatchEvent?.(event);
|
|
1122
1136
|
return result;
|
|
1123
1137
|
}
|
|
1124
|
-
createBackEvent(signal,
|
|
1138
|
+
createBackEvent(signal, committed, transition) {
|
|
1125
1139
|
if (!this.routerId)
|
|
1126
1140
|
throw new Error("Router ID is not set");
|
|
1127
|
-
return new BackEvent(this.routerId, signal,
|
|
1141
|
+
return new BackEvent(this.routerId, signal, committed, transition);
|
|
1128
1142
|
}
|
|
1129
|
-
createForwardEvent(signal,
|
|
1143
|
+
createForwardEvent(signal, committed, transition) {
|
|
1130
1144
|
if (!this.routerId)
|
|
1131
1145
|
throw new Error("Router ID is not set");
|
|
1132
|
-
return new ForwardEvent(this.routerId, signal,
|
|
1146
|
+
return new ForwardEvent(this.routerId, signal, committed, transition);
|
|
1133
1147
|
}
|
|
1134
|
-
createNavigateEvent(route, props, type, signal,
|
|
1148
|
+
createNavigateEvent(route, props, type, signal, committed, transition) {
|
|
1135
1149
|
if (!this.routerId)
|
|
1136
1150
|
throw new Error("Router ID is not set");
|
|
1137
|
-
return new NavigateEvent(this.routerId, route, props, type, signal,
|
|
1151
|
+
return new NavigateEvent(this.routerId, route, props, type, signal, committed, transition);
|
|
1152
|
+
}
|
|
1153
|
+
get committed() {
|
|
1154
|
+
return this.router.committed;
|
|
1138
1155
|
}
|
|
1139
1156
|
get transition() {
|
|
1140
1157
|
return this.router.state.transition;
|
|
@@ -1190,49 +1207,87 @@ class Navigation extends core_namespaceObject.NavigationBase {
|
|
|
1190
1207
|
get current() {
|
|
1191
1208
|
return this.entries[this.index];
|
|
1192
1209
|
}
|
|
1193
|
-
|
|
1210
|
+
canGoBack() {
|
|
1194
1211
|
return Boolean(this.previous?.sameDocument);
|
|
1195
1212
|
}
|
|
1196
|
-
|
|
1213
|
+
canGoForward() {
|
|
1197
1214
|
return Boolean(this.next?.sameDocument);
|
|
1198
1215
|
}
|
|
1199
1216
|
}
|
|
1200
1217
|
|
|
1218
|
+
;// CONCATENATED MODULE: ./src/common/utils.ts
|
|
1219
|
+
function searchParamsToObject(searchParams) {
|
|
1220
|
+
const entries = searchParams.entries();
|
|
1221
|
+
const result = {};
|
|
1222
|
+
for (const [key, value] of entries) { // each 'entry' is a [key, value] tuple
|
|
1223
|
+
let parsedValue = '';
|
|
1224
|
+
try {
|
|
1225
|
+
parsedValue = JSON.parse(value);
|
|
1226
|
+
}
|
|
1227
|
+
catch (e) {
|
|
1228
|
+
console.warn("Non JSON serialisable value was passed as URL route param.");
|
|
1229
|
+
parsedValue = value;
|
|
1230
|
+
}
|
|
1231
|
+
result[key] = parsedValue;
|
|
1232
|
+
}
|
|
1233
|
+
return Object.keys(result).length ? result : undefined;
|
|
1234
|
+
}
|
|
1235
|
+
function searchParamsFromObject(params) {
|
|
1236
|
+
try {
|
|
1237
|
+
for (const [key, value] of Object.entries(params)) {
|
|
1238
|
+
params[key] = JSON.stringify(value);
|
|
1239
|
+
}
|
|
1240
|
+
return new URLSearchParams(params).toString();
|
|
1241
|
+
}
|
|
1242
|
+
catch (e) {
|
|
1243
|
+
console.error(e);
|
|
1244
|
+
console.warn("Non JSON serialisable value was passed as query param.");
|
|
1245
|
+
}
|
|
1246
|
+
return '';
|
|
1247
|
+
}
|
|
1248
|
+
function isGesture(info) {
|
|
1249
|
+
if (info && typeof info === 'object' && 'gesture' in info)
|
|
1250
|
+
return Boolean(info.gesture);
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
function isRollback(info) {
|
|
1254
|
+
if (info && typeof info === 'object' && 'rollback' in info)
|
|
1255
|
+
return Boolean(info.rollback);
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
function deepEquals(obj1, obj2) {
|
|
1259
|
+
if (obj1 === obj2) {
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1265
|
+
const keys1 = Object.keys(obj1);
|
|
1266
|
+
const keys2 = Object.keys(obj2);
|
|
1267
|
+
if (keys1.length !== keys2.length) {
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
for (let key of keys1) {
|
|
1271
|
+
if (!keys2.includes(key) || !deepEquals(obj1[key], obj2[key])) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return true;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1201
1278
|
;// CONCATENATED MODULE: ./src/Screen.tsx
|
|
1202
1279
|
|
|
1280
|
+
|
|
1203
1281
|
class Screen extends core_namespaceObject.ScreenBase {
|
|
1204
|
-
|
|
1282
|
+
#historyEntry;
|
|
1205
1283
|
constructor(props, context) {
|
|
1206
1284
|
super(props, context);
|
|
1207
|
-
const
|
|
1208
|
-
const
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
setConfig,
|
|
1214
|
-
get path() {
|
|
1215
|
-
return getProps().path;
|
|
1216
|
-
},
|
|
1217
|
-
get resolvedPathname() {
|
|
1218
|
-
return getProps().resolvedPathname;
|
|
1219
|
-
},
|
|
1220
|
-
get focused() {
|
|
1221
|
-
return getState().focused;
|
|
1222
|
-
},
|
|
1223
|
-
get config() {
|
|
1224
|
-
return {
|
|
1225
|
-
...getProps().config,
|
|
1226
|
-
...context.screenState.get(this.path)?.config
|
|
1227
|
-
};
|
|
1228
|
-
},
|
|
1229
|
-
get params() {
|
|
1230
|
-
return {
|
|
1231
|
-
...getProps().defaultParams,
|
|
1232
|
-
...context.screenState.get(this.path)?.params
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1285
|
+
const router = context;
|
|
1286
|
+
const id = this.internalProps.id;
|
|
1287
|
+
const historyEntry = router.navigation.entries.find(entry => entry.key === id);
|
|
1288
|
+
if (!historyEntry)
|
|
1289
|
+
throw new Error(`No history entry found for: ${id}`);
|
|
1290
|
+
this.#historyEntry = historyEntry;
|
|
1236
1291
|
}
|
|
1237
1292
|
static getDerivedStateFromProps(props) {
|
|
1238
1293
|
if (props.config?.presentation === "dialog"
|
|
@@ -1241,31 +1296,78 @@ class Screen extends core_namespaceObject.ScreenBase {
|
|
|
1241
1296
|
else
|
|
1242
1297
|
return { elementType: "div" };
|
|
1243
1298
|
}
|
|
1244
|
-
get config() {
|
|
1245
|
-
return {
|
|
1246
|
-
...this.props.config,
|
|
1247
|
-
...this.context.screenState.get(this.props.path)?.config
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
get params() {
|
|
1251
|
-
return {
|
|
1252
|
-
...this.props.defaultParams,
|
|
1253
|
-
...this.context.screenState.get(this.props.path)?.params
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
1299
|
setParams(params) {
|
|
1257
1300
|
super.setParams(params);
|
|
1258
|
-
|
|
1259
|
-
window.navigation.updateCurrentEntry({ state: { params } });
|
|
1301
|
+
this.setHistoryState({ params });
|
|
1260
1302
|
}
|
|
1261
1303
|
setConfig(config) {
|
|
1262
1304
|
super.setConfig(config);
|
|
1263
|
-
|
|
1264
|
-
window.navigation.updateCurrentEntry({ state: { config } });
|
|
1305
|
+
this.setHistoryState({ config });
|
|
1265
1306
|
}
|
|
1266
1307
|
get router() {
|
|
1267
1308
|
return this.context;
|
|
1268
1309
|
}
|
|
1310
|
+
get internalProps() {
|
|
1311
|
+
return this.props;
|
|
1312
|
+
}
|
|
1313
|
+
get resolvedPathname() {
|
|
1314
|
+
return this.internalProps.resolvedPathname;
|
|
1315
|
+
}
|
|
1316
|
+
get historyEntryState() {
|
|
1317
|
+
const entry = this.#historyEntry;
|
|
1318
|
+
if (entry?.url) {
|
|
1319
|
+
const state = entry.getState() ?? {};
|
|
1320
|
+
const queryParams = searchParamsToObject(entry.url.searchParams);
|
|
1321
|
+
state.params = {
|
|
1322
|
+
...state.params,
|
|
1323
|
+
...queryParams
|
|
1324
|
+
};
|
|
1325
|
+
return state;
|
|
1326
|
+
}
|
|
1327
|
+
return {};
|
|
1328
|
+
}
|
|
1329
|
+
get id() {
|
|
1330
|
+
return this.internalProps.id.toString();
|
|
1331
|
+
}
|
|
1332
|
+
get params() {
|
|
1333
|
+
return {
|
|
1334
|
+
...this.props.defaultParams,
|
|
1335
|
+
...this.historyEntryState.params,
|
|
1336
|
+
...this.state.params
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
get config() {
|
|
1340
|
+
return {
|
|
1341
|
+
...this.props.config,
|
|
1342
|
+
...this.historyEntryState.config,
|
|
1343
|
+
...this.state.config
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
get routeProp() {
|
|
1347
|
+
const setParams = this.setParams.bind(this);
|
|
1348
|
+
const setConfig = this.setConfig.bind(this);
|
|
1349
|
+
const { path } = this.props;
|
|
1350
|
+
const { focused } = this.state;
|
|
1351
|
+
const { params, config, resolvedPathname } = this;
|
|
1352
|
+
return {
|
|
1353
|
+
setParams,
|
|
1354
|
+
setConfig,
|
|
1355
|
+
path,
|
|
1356
|
+
resolvedPathname,
|
|
1357
|
+
focused,
|
|
1358
|
+
params,
|
|
1359
|
+
config
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
setHistoryState(newState) {
|
|
1363
|
+
if (!this.state.focused)
|
|
1364
|
+
return;
|
|
1365
|
+
const state = {
|
|
1366
|
+
...window.navigation.currentEntry?.getState() ?? {},
|
|
1367
|
+
...newState
|
|
1368
|
+
};
|
|
1369
|
+
window.navigation.updateCurrentEntry({ state });
|
|
1370
|
+
}
|
|
1269
1371
|
onClickOutside(e) {
|
|
1270
1372
|
if (!this.transitionProvider.current?.ref.current)
|
|
1271
1373
|
return;
|
|
@@ -1326,8 +1428,26 @@ function isRefObject(value) {
|
|
|
1326
1428
|
return true;
|
|
1327
1429
|
return false;
|
|
1328
1430
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1431
|
+
const directions = {
|
|
1432
|
+
"horizontal": ["left", "right"],
|
|
1433
|
+
"vertical": ["up", "down"],
|
|
1434
|
+
"up": ["up"],
|
|
1435
|
+
"down": ["down"],
|
|
1436
|
+
"left": ["left"],
|
|
1437
|
+
"right": ["right"]
|
|
1438
|
+
};
|
|
1439
|
+
function isSupportedDirection(direction, supported) {
|
|
1440
|
+
return directions[supported].includes(direction);
|
|
1441
|
+
}
|
|
1442
|
+
function isOutOfBounds(direction, { x, y }, clientRect, gestureAreaWidth) {
|
|
1443
|
+
if (direction === "right" && Math.abs(x - clientRect.left) >= gestureAreaWidth)
|
|
1444
|
+
return false;
|
|
1445
|
+
if (direction === "left" && Math.abs(x - clientRect.right) >= gestureAreaWidth)
|
|
1446
|
+
return false;
|
|
1447
|
+
if (direction === "down" && Math.abs(y - clientRect.top) >= gestureAreaWidth)
|
|
1448
|
+
return false;
|
|
1449
|
+
if (direction === "up" && Math.abs(y - clientRect.bottom) >= gestureAreaWidth)
|
|
1450
|
+
return false;
|
|
1331
1451
|
}
|
|
1332
1452
|
function isHorizontalDirection(direction) {
|
|
1333
1453
|
return direction === 'left' || direction === 'right' || direction === 'horizontal';
|
|
@@ -1339,67 +1459,41 @@ var external_react_ = __webpack_require__(810);
|
|
|
1339
1459
|
var external_web_animations_extension_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
1340
1460
|
var external_web_animations_extension_y = x => () => x
|
|
1341
1461
|
const external_web_animations_extension_namespaceObject = external_web_animations_extension_x({ ["GestureTimeline"]: () => __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__.GestureTimeline, ["easingToLinear"]: () => __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__.easingToLinear, ["springToLinear"]: () => __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__.springToLinear });
|
|
1342
|
-
;// CONCATENATED MODULE: ./src/common/utils.ts
|
|
1343
|
-
function searchParamsToObject(searchPart) {
|
|
1344
|
-
const entries = new URLSearchParams(decodeURI(searchPart)).entries();
|
|
1345
|
-
const result = {};
|
|
1346
|
-
for (const [key, value] of entries) { // each 'entry' is a [key, value] tuple
|
|
1347
|
-
let parsedValue = '';
|
|
1348
|
-
try {
|
|
1349
|
-
parsedValue = JSON.parse(value);
|
|
1350
|
-
}
|
|
1351
|
-
catch (e) {
|
|
1352
|
-
console.warn("Non JSON serialisable value was passed as URL route param.");
|
|
1353
|
-
parsedValue = value;
|
|
1354
|
-
}
|
|
1355
|
-
result[key] = parsedValue;
|
|
1356
|
-
}
|
|
1357
|
-
return Object.keys(result).length ? result : undefined;
|
|
1358
|
-
}
|
|
1359
|
-
function searchParamsFromObject(params) {
|
|
1360
|
-
try {
|
|
1361
|
-
return new URLSearchParams(params).toString();
|
|
1362
|
-
}
|
|
1363
|
-
catch (e) {
|
|
1364
|
-
console.error(e);
|
|
1365
|
-
console.warn("Non JSON serialisable value was passed as query param.");
|
|
1366
|
-
}
|
|
1367
|
-
return '';
|
|
1368
|
-
}
|
|
1369
|
-
function isRollback(info) {
|
|
1370
|
-
if (info && typeof info === 'object' && 'rollback' in info)
|
|
1371
|
-
return Boolean(info.rollback);
|
|
1372
|
-
return false;
|
|
1373
|
-
}
|
|
1374
|
-
function deepEquals(obj1, obj2) {
|
|
1375
|
-
if (obj1 === obj2) {
|
|
1376
|
-
return true;
|
|
1377
|
-
}
|
|
1378
|
-
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
1379
|
-
return false;
|
|
1380
|
-
}
|
|
1381
|
-
const keys1 = Object.keys(obj1);
|
|
1382
|
-
const keys2 = Object.keys(obj2);
|
|
1383
|
-
if (keys1.length !== keys2.length) {
|
|
1384
|
-
return false;
|
|
1385
|
-
}
|
|
1386
|
-
for (let key of keys1) {
|
|
1387
|
-
if (!keys2.includes(key) || !deepEquals(obj1[key], obj2[key])) {
|
|
1388
|
-
return false;
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
return true;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
1462
|
;// CONCATENATED MODULE: ./src/common/constants.ts
|
|
1395
1463
|
const DEFAULT_GESTURE_CONFIG = {
|
|
1396
1464
|
gestureHysteresis: 0.5,
|
|
1397
1465
|
gestureMinFlingVelocity: 400,
|
|
1398
1466
|
gestureAreaWidth: 100,
|
|
1399
1467
|
gestureDirection: 'right',
|
|
1400
|
-
|
|
1468
|
+
gestureDisabled: false
|
|
1401
1469
|
};
|
|
1402
1470
|
|
|
1471
|
+
;// CONCATENATED MODULE: ./src/common/promise-wrapper.ts
|
|
1472
|
+
class PromiseWrapper {
|
|
1473
|
+
promise;
|
|
1474
|
+
state;
|
|
1475
|
+
nativeResolve;
|
|
1476
|
+
nativeReject;
|
|
1477
|
+
constructor() {
|
|
1478
|
+
this.state = 'pending';
|
|
1479
|
+
this.nativeResolve = this.nativeReject = null;
|
|
1480
|
+
this.promise = new Promise((resolve, reject) => {
|
|
1481
|
+
this.nativeResolve = resolve;
|
|
1482
|
+
this.nativeReject = reject;
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
resolve(value) {
|
|
1486
|
+
this.state = 'resolved';
|
|
1487
|
+
this.nativeResolve?.(value);
|
|
1488
|
+
}
|
|
1489
|
+
reject(reason) {
|
|
1490
|
+
this.state = 'rejected';
|
|
1491
|
+
// Do not report unhandled promise rejections.
|
|
1492
|
+
this.promise.catch(() => { });
|
|
1493
|
+
this.nativeReject?.(reason);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1403
1497
|
;// CONCATENATED MODULE: ./src/Router.tsx
|
|
1404
1498
|
|
|
1405
1499
|
|
|
@@ -1409,8 +1503,10 @@ const DEFAULT_GESTURE_CONFIG = {
|
|
|
1409
1503
|
|
|
1410
1504
|
|
|
1411
1505
|
|
|
1506
|
+
|
|
1412
1507
|
class Router extends core_namespaceObject.RouterBase {
|
|
1413
1508
|
navigation = new Navigation(this);
|
|
1509
|
+
#committed = null;
|
|
1414
1510
|
constructor(props, context) {
|
|
1415
1511
|
super(props, context);
|
|
1416
1512
|
this.state = {
|
|
@@ -1418,13 +1514,13 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1418
1514
|
gestureDirection: "horizontal",
|
|
1419
1515
|
gestureAreaWidth: 50,
|
|
1420
1516
|
gestureHysteresis: 0.5,
|
|
1421
|
-
|
|
1517
|
+
gestureDisabled: true,
|
|
1422
1518
|
gestureMinFlingVelocity: 500,
|
|
1423
1519
|
transition: null,
|
|
1424
|
-
backNavigating: false,
|
|
1425
1520
|
documentTitle: document.title,
|
|
1426
1521
|
fromKey: null,
|
|
1427
|
-
destinationKey: null
|
|
1522
|
+
destinationKey: null,
|
|
1523
|
+
controller: null
|
|
1428
1524
|
};
|
|
1429
1525
|
}
|
|
1430
1526
|
static defaultProps = {
|
|
@@ -1442,7 +1538,7 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1442
1538
|
gestureAreaWidth: config?.gestureAreaWidth ?? DEFAULT_GESTURE_CONFIG.gestureAreaWidth,
|
|
1443
1539
|
gestureMinFlingVelocity: config?.gestureMinFlingVelocity ?? DEFAULT_GESTURE_CONFIG.gestureMinFlingVelocity,
|
|
1444
1540
|
gestureHysteresis: config?.gestureHysteresis ?? DEFAULT_GESTURE_CONFIG.gestureHysteresis,
|
|
1445
|
-
|
|
1541
|
+
gestureDisabled: config?.gestureDisabled ?? DEFAULT_GESTURE_CONFIG.gestureDisabled,
|
|
1446
1542
|
documentTitle: config?.title
|
|
1447
1543
|
};
|
|
1448
1544
|
}
|
|
@@ -1450,6 +1546,10 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1450
1546
|
super.componentDidMount();
|
|
1451
1547
|
this.ref.current?.addEventListener('swipestart', this.onSwipeStart);
|
|
1452
1548
|
this.ref.current?.addEventListener('swipeend', this.onSwipeEnd);
|
|
1549
|
+
window.navigation.addEventListener("currententrychange", this.onCurrentEntryChange);
|
|
1550
|
+
window.navigation.addEventListener("navigate", this.onNavigate);
|
|
1551
|
+
window.navigation.addEventListener("navigatesuccess", this.onNavigateSuccess);
|
|
1552
|
+
window.navigation.addEventListener("navigateerror", this.onNavigateError);
|
|
1453
1553
|
}
|
|
1454
1554
|
shouldComponentUpdate(nextProps, nextState) {
|
|
1455
1555
|
return (!deepEquals(this.props.config, nextProps.config)
|
|
@@ -1459,29 +1559,44 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1459
1559
|
componentWillUnmount() {
|
|
1460
1560
|
this.ref.current?.removeEventListener('swipestart', this.onSwipeStart);
|
|
1461
1561
|
this.ref.current?.removeEventListener('swipeend', this.onSwipeEnd);
|
|
1562
|
+
window.navigation.removeEventListener("currententrychange", this.onCurrentEntryChange);
|
|
1563
|
+
window.navigation.removeEventListener("navigate", this.onNavigate);
|
|
1564
|
+
window.navigation.removeEventListener("navigatesuccess", this.onNavigateSuccess);
|
|
1565
|
+
window.navigation.removeEventListener("navigateerror", this.onNavigateError);
|
|
1462
1566
|
}
|
|
1567
|
+
onNavigate = () => {
|
|
1568
|
+
this.#committed = new PromiseWrapper();
|
|
1569
|
+
};
|
|
1570
|
+
onCurrentEntryChange = () => {
|
|
1571
|
+
this.#committed?.nativeResolve?.(window.navigation.currentEntry);
|
|
1572
|
+
};
|
|
1573
|
+
onNavigateSuccess = () => {
|
|
1574
|
+
this.#committed = null;
|
|
1575
|
+
};
|
|
1576
|
+
onNavigateError = ({ error }) => {
|
|
1577
|
+
if (this.#committed?.state === "pending")
|
|
1578
|
+
this.#committed.nativeReject?.(error); // TODO: find out what the spec does for cancelled navigations
|
|
1579
|
+
this.#committed = null;
|
|
1580
|
+
};
|
|
1581
|
+
onGestureCancel = () => {
|
|
1582
|
+
if (!this.state.transition)
|
|
1583
|
+
throw new Error("Rollback failed, transition is null");
|
|
1584
|
+
window.navigation.traverseTo(this.state.transition.from.key, { info: { rollback: true } });
|
|
1585
|
+
};
|
|
1463
1586
|
canGestureNavigate(e) {
|
|
1464
1587
|
if (!this.ref.current)
|
|
1465
1588
|
return false;
|
|
1466
|
-
if (this.state.
|
|
1589
|
+
if (this.state.gestureDisabled)
|
|
1467
1590
|
return false;
|
|
1468
1591
|
const clientRect = this.ref.current.getBoundingClientRect();
|
|
1469
1592
|
const { direction } = e;
|
|
1470
|
-
if ((direction === "down" || direction === "right") && !this.navigation.canGoBack)
|
|
1471
|
-
return false;
|
|
1472
|
-
if ((direction === "up" || direction === "left") && !this.navigation.canGoForward)
|
|
1473
|
-
return false;
|
|
1474
|
-
if (isHorizontalDirection(direction) !== isHorizontalDirection(this.state.gestureDirection))
|
|
1475
|
-
return false;
|
|
1476
|
-
if (direction === "right" && Math.abs(e.x - clientRect.left) >= this.state.gestureAreaWidth)
|
|
1477
|
-
return false;
|
|
1478
|
-
if (direction === "left" && Math.abs(e.x - clientRect.right) >= this.state.gestureAreaWidth)
|
|
1593
|
+
if ((direction === "down" || direction === "right") && !this.navigation.canGoBack())
|
|
1479
1594
|
return false;
|
|
1480
|
-
if (direction === "
|
|
1595
|
+
if ((direction === "up" || direction === "left") && !this.navigation.canGoForward())
|
|
1481
1596
|
return false;
|
|
1482
|
-
if (direction
|
|
1597
|
+
if (isOutOfBounds(direction, e, clientRect, this.state.gestureAreaWidth))
|
|
1483
1598
|
return false;
|
|
1484
|
-
return
|
|
1599
|
+
return isSupportedDirection(direction, this.state.gestureDirection);
|
|
1485
1600
|
}
|
|
1486
1601
|
onSwipeStart = (e) => {
|
|
1487
1602
|
if (!this.canGestureNavigate(e))
|
|
@@ -1517,10 +1632,11 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1517
1632
|
rangeStart,
|
|
1518
1633
|
rangeEnd
|
|
1519
1634
|
});
|
|
1635
|
+
const gesture = true;
|
|
1520
1636
|
if (direction === "down" || direction === "right")
|
|
1521
|
-
this.navigation.
|
|
1637
|
+
window.navigation.traverseTo(this.navigation.previous.key, { info: { gesture } });
|
|
1522
1638
|
else
|
|
1523
|
-
this.navigation.
|
|
1639
|
+
window.navigation.traverseTo(this.navigation.next.key, { info: { gesture } });
|
|
1524
1640
|
this.dispatchEvent(new GestureStartEvent(e));
|
|
1525
1641
|
};
|
|
1526
1642
|
onSwipeEnd = (e) => {
|
|
@@ -1530,22 +1646,29 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1530
1646
|
const playbackRate = this.screenTransitionLayer.current.animation.playbackRate;
|
|
1531
1647
|
this.screenTransitionLayer.current.animation.timeline = document.timeline;
|
|
1532
1648
|
const hysteresisReached = playbackRate > 0 ? progress > this.state.gestureHysteresis : progress < this.state.gestureHysteresis;
|
|
1533
|
-
let
|
|
1649
|
+
let gestureCancelled = false;
|
|
1534
1650
|
if (e.velocity < this.state.gestureMinFlingVelocity && !hysteresisReached) {
|
|
1651
|
+
gestureCancelled = true;
|
|
1535
1652
|
this.screenTransitionLayer.current.animation.reverse();
|
|
1536
|
-
rollback = true;
|
|
1537
1653
|
this.dispatchEvent(new GestureCancelEvent());
|
|
1538
1654
|
}
|
|
1539
1655
|
else {
|
|
1540
1656
|
this.dispatchEvent(new GestureEndEvent(e));
|
|
1541
1657
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
window.navigation.traverseTo(fromKey.toString(), { info: { rollback } });
|
|
1658
|
+
if (gestureCancelled) {
|
|
1659
|
+
this.screenTransitionLayer.current.animation.finished.then(() => {
|
|
1660
|
+
this.state.controller?.abort("gesture-cancel");
|
|
1546
1661
|
});
|
|
1547
1662
|
}
|
|
1548
1663
|
};
|
|
1664
|
+
get committed() {
|
|
1665
|
+
return this.#committed?.promise ?? null;
|
|
1666
|
+
}
|
|
1667
|
+
get backNavigating() {
|
|
1668
|
+
const fromIndex = this.state.screenStack.findIndex(screen => screen.key === this.state.fromKey);
|
|
1669
|
+
const destinationIndex = this.state.screenStack.findIndex(screen => screen.key === this.state.destinationKey);
|
|
1670
|
+
return destinationIndex >= 0 && destinationIndex < fromIndex;
|
|
1671
|
+
}
|
|
1549
1672
|
get screens() {
|
|
1550
1673
|
const screenStack = this.state.screenStack;
|
|
1551
1674
|
return screenStack
|
|
@@ -1560,26 +1683,23 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1560
1683
|
|| screen.key === this.state.destinationKey;
|
|
1561
1684
|
});
|
|
1562
1685
|
}
|
|
1563
|
-
screenChildFromPathname(pathname, key
|
|
1686
|
+
screenChildFromPathname(pathname, key) {
|
|
1564
1687
|
const screenChild = external_react_.Children.toArray(this.props.children)
|
|
1565
|
-
.find(child => {
|
|
1688
|
+
.find((child) => {
|
|
1566
1689
|
if (!(0,core_namespaceObject.isValidScreenChild)(child))
|
|
1567
|
-
return;
|
|
1568
|
-
return (0,core_namespaceObject.matchRoute)(child.props.path, pathname, this.baseURLPattern.pathname, child.props.caseSensitive);
|
|
1690
|
+
return false;
|
|
1691
|
+
return (0,core_namespaceObject.matchRoute)(child.props.path, pathname, this.baseURLPattern.pathname, child.props.caseSensitive) !== null;
|
|
1569
1692
|
});
|
|
1570
|
-
if (!
|
|
1693
|
+
if (!screenChild)
|
|
1571
1694
|
return null;
|
|
1572
|
-
|
|
1695
|
+
key ??= crypto.randomUUID();
|
|
1696
|
+
return (0,core_namespaceObject.cloneAndInject)(screenChild, {
|
|
1573
1697
|
config: {
|
|
1574
1698
|
title: document.title,
|
|
1575
1699
|
...this.props.config?.screenConfig,
|
|
1576
|
-
...screenChild.props.config
|
|
1577
|
-
...config
|
|
1578
|
-
},
|
|
1579
|
-
defaultParams: {
|
|
1580
|
-
...screenChild.props.defaultParams,
|
|
1581
|
-
...params
|
|
1700
|
+
...screenChild.props.config
|
|
1582
1701
|
},
|
|
1702
|
+
id: key,
|
|
1583
1703
|
resolvedPathname: pathname,
|
|
1584
1704
|
key,
|
|
1585
1705
|
ref: (0,external_react_.createRef)()
|
|
@@ -1641,9 +1761,7 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1641
1761
|
entries.forEach((entry) => {
|
|
1642
1762
|
if (!entry.url)
|
|
1643
1763
|
return null;
|
|
1644
|
-
const
|
|
1645
|
-
const queryParams = searchParamsToObject(entry.url.search);
|
|
1646
|
-
const screen = this.screenChildFromPathname(entry.url.pathname, entry.key, config, { ...queryParams, ...params });
|
|
1764
|
+
const screen = this.screenChildFromPathname(entry.url.pathname, entry.key);
|
|
1647
1765
|
if (!screen)
|
|
1648
1766
|
return null;
|
|
1649
1767
|
screenStack.push(screen);
|
|
@@ -1680,10 +1798,8 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1680
1798
|
const screenStack = this.state.screenStack;
|
|
1681
1799
|
const destination = e.destination;
|
|
1682
1800
|
const destinationPathname = new URL(destination.url).pathname;
|
|
1683
|
-
const { params, config } = destination.getState() ?? {};
|
|
1684
|
-
const queryParams = searchParamsToObject(new URL(destination.url).search);
|
|
1685
1801
|
const destinationKey = window.navigation.currentEntry?.key ?? destination.key;
|
|
1686
|
-
const destinationScreen = this.screenChildFromPathname(destinationPathname, destinationKey
|
|
1802
|
+
const destinationScreen = this.screenChildFromPathname(destinationPathname, destinationKey);
|
|
1687
1803
|
if (!destinationScreen)
|
|
1688
1804
|
return e.preventDefault();
|
|
1689
1805
|
const handler = () => {
|
|
@@ -1691,7 +1807,6 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1691
1807
|
const transition = this.state.transition ?? window.navigation.transition;
|
|
1692
1808
|
const fromKey = transition?.from?.key ?? null;
|
|
1693
1809
|
const currentIndex = screenStack.findIndex(screen => screen.key === this.navigation.current?.key);
|
|
1694
|
-
const backNavigating = this.state.backNavigating;
|
|
1695
1810
|
screenStack.splice(currentIndex, 1, destinationScreen);
|
|
1696
1811
|
return new Promise((resolve, reject) => (0,external_react_.startTransition)(() => {
|
|
1697
1812
|
this.setState({ destinationKey, fromKey, transition, screenStack }, async () => {
|
|
@@ -1703,7 +1818,7 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1703
1818
|
const currentTime = this.screenTransitionLayer.current?.animation.currentTime ?? 0;
|
|
1704
1819
|
this.screenTransitionLayer.current?.animation.cancel();
|
|
1705
1820
|
await new Promise(requestAnimationFrame);
|
|
1706
|
-
const animation = this.screenTransition(incomingScreen, outgoingScreen
|
|
1821
|
+
const animation = this.screenTransition(incomingScreen, outgoingScreen);
|
|
1707
1822
|
if (animation) {
|
|
1708
1823
|
animation.currentTime = currentTime;
|
|
1709
1824
|
}
|
|
@@ -1724,6 +1839,8 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1724
1839
|
if (!(0,core_namespaceObject.isValidScreenChild)(this.getScreenChildByPathname(destinationPathname)))
|
|
1725
1840
|
return e.preventDefault();
|
|
1726
1841
|
const handler = () => {
|
|
1842
|
+
if (isRollback(e.info))
|
|
1843
|
+
return Promise.resolve();
|
|
1727
1844
|
const transition = window.navigation.transition;
|
|
1728
1845
|
let fromIndex = screenStack.findIndex(screen => screen.key === transition?.from.key);
|
|
1729
1846
|
if (fromIndex === -1 && e.navigationType === "traverse") {
|
|
@@ -1738,51 +1855,62 @@ class Router extends core_namespaceObject.RouterBase {
|
|
|
1738
1855
|
const fromKey = (screenStack[fromIndex]?.key || transition?.from.key) ?? null;
|
|
1739
1856
|
const destinationIndex = screenStack.findIndex(screen => screen.key === e.destination.key);
|
|
1740
1857
|
const destinationKey = (screenStack[destinationIndex]?.key || window.navigation.currentEntry?.key) ?? null;
|
|
1741
|
-
const backNavigating = destinationIndex >= 0 && destinationIndex < fromIndex;
|
|
1742
1858
|
if (e.navigationType === "push") {
|
|
1743
|
-
const { params, config } = destination.getState() ?? {};
|
|
1744
1859
|
const destinationPathname = new URL(destination.url).pathname;
|
|
1745
|
-
const
|
|
1746
|
-
const destinationScreen = this.screenChildFromPathname(destinationPathname, destinationKey, config, { ...queryParams, ...params });
|
|
1860
|
+
const destinationScreen = this.screenChildFromPathname(destinationPathname, destinationKey);
|
|
1747
1861
|
if (!destinationScreen)
|
|
1748
1862
|
return Promise.resolve();
|
|
1749
1863
|
screenStack.splice(fromIndex + 1, Infinity, // Remove all screens after current
|
|
1750
1864
|
destinationScreen);
|
|
1751
1865
|
}
|
|
1866
|
+
const controller = new AbortController();
|
|
1752
1867
|
return new Promise((resolve, reject) => (0,external_react_.startTransition)(() => {
|
|
1753
|
-
this.setState({ destinationKey, fromKey, transition, screenStack
|
|
1868
|
+
this.setState({ controller, destinationKey, fromKey, transition, screenStack }, async () => {
|
|
1869
|
+
controller.signal.onabort = reject;
|
|
1754
1870
|
const signal = e.signal;
|
|
1755
1871
|
const outgoingScreen = this.getScreenRefByKey(String(fromKey));
|
|
1756
1872
|
const incomingScreen = this.getScreenRefByKey(String(destinationKey));
|
|
1757
1873
|
const pendingLifecycleHandlers = this.dispatchLifecycleHandlers(incomingScreen, outgoingScreen, signal).catch(reject);
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
animation?.finished.catch(reject);
|
|
1762
|
-
}
|
|
1874
|
+
const animation = this.screenTransition(incomingScreen, outgoingScreen);
|
|
1875
|
+
animation?.updatePlaybackRate(1);
|
|
1876
|
+
animation?.finished.catch(reject);
|
|
1763
1877
|
await pendingLifecycleHandlers;
|
|
1764
|
-
this.setState({ destinationKey: null, fromKey: null, transition: null }, resolve);
|
|
1878
|
+
this.setState({ destinationKey: null, fromKey: null, transition: null, controller: null }, resolve);
|
|
1765
1879
|
});
|
|
1766
1880
|
}));
|
|
1767
1881
|
};
|
|
1768
|
-
|
|
1882
|
+
let commit;
|
|
1883
|
+
if (isGesture(e.info)) {
|
|
1884
|
+
commit = "after-transition";
|
|
1885
|
+
this.addEventListener("gesture-end", () => e.commit?.(), { once: true });
|
|
1886
|
+
this.addEventListener("gesture-cancel", this.onGestureCancel, { once: true });
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
commit = "immediate";
|
|
1890
|
+
}
|
|
1891
|
+
const options = { handler, commit };
|
|
1892
|
+
e.intercept(options);
|
|
1769
1893
|
}
|
|
1770
1894
|
async dispatchLifecycleHandlers(incomingScreen, outgoingScreen, signal) {
|
|
1771
1895
|
let animationStarted = false;
|
|
1772
1896
|
this.addEventListener('transition-start', () => animationStarted = true, { once: true });
|
|
1773
1897
|
await Promise.all([
|
|
1774
|
-
outgoingScreen?.current?.onExit(signal)
|
|
1775
|
-
incomingScreen?.current?.onEnter(signal)
|
|
1898
|
+
outgoingScreen?.current?.onExit(signal),
|
|
1899
|
+
incomingScreen?.current?.onEnter(signal),
|
|
1776
1900
|
incomingScreen?.current?.load(signal)
|
|
1777
1901
|
]);
|
|
1778
1902
|
if (animationStarted)
|
|
1779
1903
|
await new Promise((resolve) => this.addEventListener('transition-end', resolve, { once: true }));
|
|
1904
|
+
// if gesture navigation cancelled then exit here
|
|
1905
|
+
if (this.state.controller?.signal.aborted)
|
|
1906
|
+
return;
|
|
1780
1907
|
await Promise.all([
|
|
1781
|
-
outgoingScreen?.current?.onExited(signal),
|
|
1782
|
-
incomingScreen?.current?.onEntered(signal)
|
|
1908
|
+
outgoingScreen?.current?.onExited(signal).then(() => outgoingScreen.current?.blur()),
|
|
1909
|
+
incomingScreen?.current?.onEntered(signal).then(() => incomingScreen.current?.focus())
|
|
1783
1910
|
]);
|
|
1784
1911
|
}
|
|
1785
|
-
screenTransition(incomingScreen, outgoingScreen
|
|
1912
|
+
screenTransition(incomingScreen, outgoingScreen) {
|
|
1913
|
+
const { backNavigating } = this;
|
|
1786
1914
|
if (this.screenTransitionLayer.current && incomingScreen && outgoingScreen) {
|
|
1787
1915
|
this.screenTransitionLayer.current.direction = backNavigating ? 'reverse' : 'normal';
|
|
1788
1916
|
if (incomingScreen.current?.transitionProvider.current) {
|
|
@@ -2286,6 +2414,8 @@ function androidScaleFromCentre({ ref, direction, index, playbackRate }) {
|
|
|
2286
2414
|
function GestureRegion({ disabled, children, ...props }) {
|
|
2287
2415
|
const ref = (0,external_react_.useRef)(null);
|
|
2288
2416
|
(0,external_react_.useEffect)(() => {
|
|
2417
|
+
if (disabled)
|
|
2418
|
+
return;
|
|
2289
2419
|
const onSwipeStart = (e) => {
|
|
2290
2420
|
e.stopPropagation();
|
|
2291
2421
|
e.preventDefault();
|
|
@@ -2294,7 +2424,7 @@ function GestureRegion({ disabled, children, ...props }) {
|
|
|
2294
2424
|
return () => {
|
|
2295
2425
|
ref.current?.removeEventListener('swipestart', onSwipeStart);
|
|
2296
2426
|
};
|
|
2297
|
-
}, [ref]);
|
|
2427
|
+
}, [ref, disabled]);
|
|
2298
2428
|
return ((0,jsx_runtime.jsx)("div", { ref: ref, className: "gesture-region", "data-disabled": disabled, style: { display: 'contents' }, ...props, children: children }));
|
|
2299
2429
|
}
|
|
2300
2430
|
|
|
@@ -2311,12 +2441,14 @@ function GestureRegion({ disabled, children, ...props }) {
|
|
|
2311
2441
|
|
|
2312
2442
|
|
|
2313
2443
|
|
|
2444
|
+
|
|
2314
2445
|
})();
|
|
2315
2446
|
|
|
2316
2447
|
var __webpack_exports__Anchor = __webpack_exports__.ee;
|
|
2317
2448
|
var __webpack_exports__FadeInKeyframes = __webpack_exports__.zF;
|
|
2318
2449
|
var __webpack_exports__FadeOutKeyframes = __webpack_exports__.JA;
|
|
2319
2450
|
var __webpack_exports__GestureRegion = __webpack_exports__.rN;
|
|
2451
|
+
var __webpack_exports__HistoryEntry = __webpack_exports__.c4;
|
|
2320
2452
|
var __webpack_exports__Navigation = __webpack_exports__.W_;
|
|
2321
2453
|
var __webpack_exports__Router = __webpack_exports__.F0;
|
|
2322
2454
|
var __webpack_exports__Screen = __webpack_exports__.lL;
|
|
@@ -2361,6 +2493,6 @@ var __webpack_exports__iOSSlideOutToRightKeyframes = __webpack_exports__.Cj;
|
|
|
2361
2493
|
var __webpack_exports__useNavigation = __webpack_exports__.HJ;
|
|
2362
2494
|
var __webpack_exports__useRoute = __webpack_exports__.yj;
|
|
2363
2495
|
var __webpack_exports__useRouter = __webpack_exports__.tv;
|
|
2364
|
-
export { __webpack_exports__Anchor as Anchor, __webpack_exports__FadeInKeyframes as FadeInKeyframes, __webpack_exports__FadeOutKeyframes as FadeOutKeyframes, __webpack_exports__GestureRegion as GestureRegion, __webpack_exports__Navigation as Navigation, __webpack_exports__Router as Router, __webpack_exports__Screen as Screen, __webpack_exports__SlideInFromBottomKeyframes as SlideInFromBottomKeyframes, __webpack_exports__SlideInFromLeftKeyframes as SlideInFromLeftKeyframes, __webpack_exports__SlideInFromRightKeyframes as SlideInFromRightKeyframes, __webpack_exports__SlideInFromTopKeyframes as SlideInFromTopKeyframes, __webpack_exports__SlideOutToBottomKeyframes as SlideOutToBottomKeyframes, __webpack_exports__SlideOutToLeftKeyframes as SlideOutToLeftKeyframes, __webpack_exports__SlideOutToRightKeyframes as SlideOutToRightKeyframes, __webpack_exports__SlideOutToTopKeyframes as SlideOutToTopKeyframes, __webpack_exports__ZoomInKeyframes as ZoomInKeyframes, __webpack_exports__ZoomOutKeyframes as ZoomOutKeyframes, __webpack_exports__androidBottomSheetSlideInOptions as androidBottomSheetSlideInOptions, __webpack_exports__androidBottomSheetSlideOutOptions as androidBottomSheetSlideOutOptions, __webpack_exports__androidConcealToBottomKeyframes as androidConcealToBottomKeyframes, __webpack_exports__androidFadeInFromBottom as androidFadeInFromBottom, __webpack_exports__androidFadeInFromBottomKeyframes as androidFadeInFromBottomKeyframes, __webpack_exports__androidFadeInFromBottomOptions as androidFadeInFromBottomOptions, __webpack_exports__androidFadeInFromBottomSheet as androidFadeInFromBottomSheet, __webpack_exports__androidFadeInFromBottomSheetKeyframes as androidFadeInFromBottomSheetKeyframes, __webpack_exports__androidFadeInFromRight as androidFadeInFromRight, __webpack_exports__androidFadeInFromRightKeyframes as androidFadeInFromRightKeyframes, __webpack_exports__androidFadeOutToBottomOptions as androidFadeOutToBottomOptions, __webpack_exports__androidFadeOutToLeftKeyframes as androidFadeOutToLeftKeyframes, __webpack_exports__androidRevealFromBottom as androidRevealFromBottom, __webpack_exports__androidRevealFromBottomKeyframes as androidRevealFromBottomKeyframes, __webpack_exports__androidRevealFromBottomOptions as androidRevealFromBottomOptions, __webpack_exports__androidScaleFromCentre as androidScaleFromCentre, __webpack_exports__androidScaleFromCentreKeyframes as androidScaleFromCentreKeyframes, __webpack_exports__androidScaleFromCentreOptions as androidScaleFromCentreOptions, __webpack_exports__androidScaleToCentreKeyframes as androidScaleToCentreKeyframes, __webpack_exports__iOSKeyframeOptions as iOSKeyframeOptions, __webpack_exports__iOSSlideInFromBottom as iOSSlideInFromBottom, __webpack_exports__iOSSlideInFromBottomKeyframes as iOSSlideInFromBottomKeyframes, __webpack_exports__iOSSlideInFromLeft as iOSSlideInFromLeft, __webpack_exports__iOSSlideInFromLeftKeyframes as iOSSlideInFromLeftKeyframes, __webpack_exports__iOSSlideInFromRight as iOSSlideInFromRight, __webpack_exports__iOSSlideInFromRightKeyframes as iOSSlideInFromRightKeyframes, __webpack_exports__iOSSlideOutToLeftKeyframes as iOSSlideOutToLeftKeyframes, __webpack_exports__iOSSlideOutToRightKeyframes as iOSSlideOutToRightKeyframes, __webpack_exports__useNavigation as useNavigation, __webpack_exports__useRoute as useRoute, __webpack_exports__useRouter as useRouter };
|
|
2496
|
+
export { __webpack_exports__Anchor as Anchor, __webpack_exports__FadeInKeyframes as FadeInKeyframes, __webpack_exports__FadeOutKeyframes as FadeOutKeyframes, __webpack_exports__GestureRegion as GestureRegion, __webpack_exports__HistoryEntry as HistoryEntry, __webpack_exports__Navigation as Navigation, __webpack_exports__Router as Router, __webpack_exports__Screen as Screen, __webpack_exports__SlideInFromBottomKeyframes as SlideInFromBottomKeyframes, __webpack_exports__SlideInFromLeftKeyframes as SlideInFromLeftKeyframes, __webpack_exports__SlideInFromRightKeyframes as SlideInFromRightKeyframes, __webpack_exports__SlideInFromTopKeyframes as SlideInFromTopKeyframes, __webpack_exports__SlideOutToBottomKeyframes as SlideOutToBottomKeyframes, __webpack_exports__SlideOutToLeftKeyframes as SlideOutToLeftKeyframes, __webpack_exports__SlideOutToRightKeyframes as SlideOutToRightKeyframes, __webpack_exports__SlideOutToTopKeyframes as SlideOutToTopKeyframes, __webpack_exports__ZoomInKeyframes as ZoomInKeyframes, __webpack_exports__ZoomOutKeyframes as ZoomOutKeyframes, __webpack_exports__androidBottomSheetSlideInOptions as androidBottomSheetSlideInOptions, __webpack_exports__androidBottomSheetSlideOutOptions as androidBottomSheetSlideOutOptions, __webpack_exports__androidConcealToBottomKeyframes as androidConcealToBottomKeyframes, __webpack_exports__androidFadeInFromBottom as androidFadeInFromBottom, __webpack_exports__androidFadeInFromBottomKeyframes as androidFadeInFromBottomKeyframes, __webpack_exports__androidFadeInFromBottomOptions as androidFadeInFromBottomOptions, __webpack_exports__androidFadeInFromBottomSheet as androidFadeInFromBottomSheet, __webpack_exports__androidFadeInFromBottomSheetKeyframes as androidFadeInFromBottomSheetKeyframes, __webpack_exports__androidFadeInFromRight as androidFadeInFromRight, __webpack_exports__androidFadeInFromRightKeyframes as androidFadeInFromRightKeyframes, __webpack_exports__androidFadeOutToBottomOptions as androidFadeOutToBottomOptions, __webpack_exports__androidFadeOutToLeftKeyframes as androidFadeOutToLeftKeyframes, __webpack_exports__androidRevealFromBottom as androidRevealFromBottom, __webpack_exports__androidRevealFromBottomKeyframes as androidRevealFromBottomKeyframes, __webpack_exports__androidRevealFromBottomOptions as androidRevealFromBottomOptions, __webpack_exports__androidScaleFromCentre as androidScaleFromCentre, __webpack_exports__androidScaleFromCentreKeyframes as androidScaleFromCentreKeyframes, __webpack_exports__androidScaleFromCentreOptions as androidScaleFromCentreOptions, __webpack_exports__androidScaleToCentreKeyframes as androidScaleToCentreKeyframes, __webpack_exports__iOSKeyframeOptions as iOSKeyframeOptions, __webpack_exports__iOSSlideInFromBottom as iOSSlideInFromBottom, __webpack_exports__iOSSlideInFromBottomKeyframes as iOSSlideInFromBottomKeyframes, __webpack_exports__iOSSlideInFromLeft as iOSSlideInFromLeft, __webpack_exports__iOSSlideInFromLeftKeyframes as iOSSlideInFromLeftKeyframes, __webpack_exports__iOSSlideInFromRight as iOSSlideInFromRight, __webpack_exports__iOSSlideInFromRightKeyframes as iOSSlideInFromRightKeyframes, __webpack_exports__iOSSlideOutToLeftKeyframes as iOSSlideOutToLeftKeyframes, __webpack_exports__iOSSlideOutToRightKeyframes as iOSSlideOutToRightKeyframes, __webpack_exports__useNavigation as useNavigation, __webpack_exports__useRoute as useRoute, __webpack_exports__useRouter as useRouter };
|
|
2365
2497
|
|
|
2366
2498
|
//# sourceMappingURL=index.js.map
|