@alfalab/bridge-to-native 1.3.2-beta.0828f8f → 1.3.2-beta.14525ab
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint max-lines: ["error", {"max":
|
|
2
|
+
/* eslint max-lines: ["error", {"max": 400, "skipComments": true}] */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.NativeNavigationAndTitleService = void 0;
|
|
5
5
|
const query_and_headers_keys_1 = require("../../query-and-headers-keys");
|
|
@@ -148,20 +148,26 @@ class NativeNavigationAndTitleService {
|
|
|
148
148
|
initializeNativeHistoryStack() {
|
|
149
149
|
const { nextPageId, title } = this.nativeParamsService;
|
|
150
150
|
const hasSS = this.hasSavedHistoryStack();
|
|
151
|
+
console.log('-------');
|
|
152
|
+
console.log('Инициализируюсь');
|
|
151
153
|
if (nextPageId && !hasSS) {
|
|
152
154
|
// есть nextPageId + нет SS → на этом origin ранее не были.
|
|
155
|
+
console.log('есть nextPageId + нет SS → на этом origin ранее не были.');
|
|
153
156
|
this.nativeHistoryStack = this.initializeForNewOrigin(nextPageId, title);
|
|
154
157
|
}
|
|
155
158
|
else if (nextPageId && hasSS) {
|
|
156
159
|
// есть nextPageId + есть SS → forward навигация.
|
|
160
|
+
console.log('есть nextPageId + есть SS → forward навигация.');
|
|
157
161
|
this.nativeHistoryStack = this.initializeForForward(nextPageId, title);
|
|
158
162
|
}
|
|
159
163
|
else if (!nextPageId && hasSS) {
|
|
160
164
|
// нет nextPageId + есть SS → back-навигация или reload.
|
|
165
|
+
console.log('нет nextPageId + есть SS → back-навигация или reload.');
|
|
161
166
|
this.nativeHistoryStack = this.initializeFromBackwardOrReload(title);
|
|
162
167
|
}
|
|
163
168
|
else {
|
|
164
169
|
// нет nextPageId + нет SS → старт нового WV, назад идти некуда.
|
|
170
|
+
console.log('нет nextPageId + нет SS → старт нового WV, назад идти некуда.');
|
|
165
171
|
this.nativeHistoryStack = [title];
|
|
166
172
|
}
|
|
167
173
|
this.saveNativeHistoryStack();
|
|
@@ -171,6 +177,8 @@ class NativeNavigationAndTitleService {
|
|
|
171
177
|
initializeForNewOrigin(nextPageId, title) {
|
|
172
178
|
const stack = new Array(nextPageId).fill(0 /* NativeHistoryStackSpecialValues.ServerSideNavigationStub */);
|
|
173
179
|
stack[stack.length - 1] = title;
|
|
180
|
+
console.log('nextPageId', nextPageId);
|
|
181
|
+
console.log('newStack', stack);
|
|
174
182
|
return stack;
|
|
175
183
|
}
|
|
176
184
|
initializeForForward(nextPageId, title) {
|
|
@@ -184,10 +192,14 @@ class NativeNavigationAndTitleService {
|
|
|
184
192
|
stack[i] = savedStack[i];
|
|
185
193
|
}
|
|
186
194
|
stack[stack.length - 1] = title;
|
|
195
|
+
console.log('nextPageId', nextPageId);
|
|
196
|
+
console.log('newStack', stack);
|
|
187
197
|
return stack;
|
|
188
198
|
}
|
|
189
199
|
if (savedStack.length === nextPageId) {
|
|
190
200
|
savedStack[savedStack.length - 1] = title;
|
|
201
|
+
console.log('nextPageId', nextPageId);
|
|
202
|
+
console.log('newStack', savedStack);
|
|
191
203
|
return savedStack;
|
|
192
204
|
}
|
|
193
205
|
return this.initializeForNewOrigin(nextPageId, title);
|
|
@@ -199,21 +211,16 @@ class NativeNavigationAndTitleService {
|
|
|
199
211
|
initializeFromBackwardOrReload(title) {
|
|
200
212
|
try {
|
|
201
213
|
const savedStack = this.readSavedHistoryStack();
|
|
202
|
-
const lastEntry = savedStack[savedStack.length - 1];
|
|
203
|
-
if (lastEntry === 1 /* NativeHistoryStackSpecialValues.TemporaryReloadStub */) {
|
|
204
|
-
savedStack.pop();
|
|
205
|
-
if (savedStack.length === 0) {
|
|
206
|
-
return [title];
|
|
207
|
-
}
|
|
208
|
-
return savedStack;
|
|
209
|
-
}
|
|
210
|
-
if (this.stackContainsCrossOriginMarker(savedStack)) {
|
|
211
|
-
return this.truncateToLastCrossOriginMarker(savedStack);
|
|
212
|
-
}
|
|
213
214
|
savedStack.pop();
|
|
214
215
|
if (savedStack.length === 0) {
|
|
216
|
+
console.log('newStack', [title]);
|
|
215
217
|
return [title];
|
|
216
218
|
}
|
|
219
|
+
if (typeof savedStack[savedStack.length - 1] !== 'string') {
|
|
220
|
+
console.log('newStack', this.truncateToLastCrossOriginMarker(savedStack));
|
|
221
|
+
return this.truncateToLastCrossOriginMarker(savedStack);
|
|
222
|
+
}
|
|
223
|
+
console.log('newStack', savedStack);
|
|
217
224
|
return savedStack;
|
|
218
225
|
}
|
|
219
226
|
catch (_a) {
|
|
@@ -243,6 +250,7 @@ class NativeNavigationAndTitleService {
|
|
|
243
250
|
if (!serialized) {
|
|
244
251
|
throw new Error(`${query_and_headers_keys_1.SS_KEY_BRIDGE_TO_NATIVE_HISTORY_STACK} sessionStorage expected not to be null`);
|
|
245
252
|
}
|
|
253
|
+
console.log('serializedStack', serialized);
|
|
246
254
|
return JSON.parse(serialized);
|
|
247
255
|
}
|
|
248
256
|
catch (e) {
|
|
@@ -282,6 +290,10 @@ class NativeNavigationAndTitleService {
|
|
|
282
290
|
*/
|
|
283
291
|
saveNativeHistoryStack() {
|
|
284
292
|
const serializedNativeHistoryStack = JSON.stringify(this.nativeHistoryStack);
|
|
293
|
+
console.log('-------');
|
|
294
|
+
console.log('сохраняю стек');
|
|
295
|
+
console.log('стек', this.nativeHistoryStack);
|
|
296
|
+
console.log('сериализованный стек', serializedNativeHistoryStack);
|
|
285
297
|
sessionStorage.setItem(query_and_headers_keys_1.SS_KEY_BRIDGE_TO_NATIVE_HISTORY_STACK, serializedNativeHistoryStack);
|
|
286
298
|
}
|
|
287
299
|
/**
|
package/package.json
CHANGED