@etsoo/appscript 1.5.21 → 1.5.22

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.
@@ -123,6 +123,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
123
123
  */
124
124
  get isReady(): boolean;
125
125
  private set isReady(value);
126
+ /**
127
+ * Current cached URL
128
+ */
129
+ get cachedUrl(): string | undefined | null;
130
+ set cachedUrl(value: string | undefined | null);
126
131
  private _isTryingLogin;
127
132
  /**
128
133
  * Last called with token refresh
@@ -83,6 +83,15 @@ class CoreApp {
83
83
  set isReady(value) {
84
84
  this._isReady = value;
85
85
  }
86
+ /**
87
+ * Current cached URL
88
+ */
89
+ get cachedUrl() {
90
+ return this.storage.getData(this.fields.cachedUrl);
91
+ }
92
+ set cachedUrl(value) {
93
+ this.storage.setData(this.fields.cachedUrl, value);
94
+ }
86
95
  /**
87
96
  * Get persisted fields
88
97
  */
@@ -1525,8 +1534,9 @@ class CoreApp {
1525
1534
  * @param removeUrl Remove current URL for reuse
1526
1535
  */
1527
1536
  toLoginPage(tryLogin, removeUrl) {
1528
- const url = `/?tryLogin=${tryLogin ?? false}` +
1529
- (removeUrl ? '' : '&url=' + encodeURIComponent(location.href));
1537
+ // Save the current URL
1538
+ this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
1539
+ const url = `/?tryLogin=${tryLogin ?? false}`;
1530
1540
  this.navigate(url);
1531
1541
  }
1532
1542
  /**
@@ -55,7 +55,7 @@ export interface RefreshTokenProps {
55
55
  /**
56
56
  * App fields
57
57
  */
58
- export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase"];
58
+ export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase", "cachedUrl"];
59
59
  /**
60
60
  * Basic type template
61
61
  */
@@ -130,6 +130,10 @@ export interface IApp {
130
130
  * Is debug mode
131
131
  */
132
132
  readonly debug: boolean;
133
+ /**
134
+ * Cached URL
135
+ */
136
+ cachedUrl: string | undefined | null;
133
137
  /**
134
138
  * IP data
135
139
  */
@@ -9,5 +9,6 @@ exports.appFields = [
9
9
  'serversideDeviceId',
10
10
  'deviceId',
11
11
  'devices',
12
- 'devicePassphrase'
12
+ 'devicePassphrase',
13
+ 'cachedUrl'
13
14
  ];
@@ -123,6 +123,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
123
123
  */
124
124
  get isReady(): boolean;
125
125
  private set isReady(value);
126
+ /**
127
+ * Current cached URL
128
+ */
129
+ get cachedUrl(): string | undefined | null;
130
+ set cachedUrl(value: string | undefined | null);
126
131
  private _isTryingLogin;
127
132
  /**
128
133
  * Last called with token refresh
@@ -80,6 +80,15 @@ export class CoreApp {
80
80
  set isReady(value) {
81
81
  this._isReady = value;
82
82
  }
83
+ /**
84
+ * Current cached URL
85
+ */
86
+ get cachedUrl() {
87
+ return this.storage.getData(this.fields.cachedUrl);
88
+ }
89
+ set cachedUrl(value) {
90
+ this.storage.setData(this.fields.cachedUrl, value);
91
+ }
83
92
  /**
84
93
  * Get persisted fields
85
94
  */
@@ -1522,8 +1531,9 @@ export class CoreApp {
1522
1531
  * @param removeUrl Remove current URL for reuse
1523
1532
  */
1524
1533
  toLoginPage(tryLogin, removeUrl) {
1525
- const url = `/?tryLogin=${tryLogin ?? false}` +
1526
- (removeUrl ? '' : '&url=' + encodeURIComponent(location.href));
1534
+ // Save the current URL
1535
+ this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
1536
+ const url = `/?tryLogin=${tryLogin ?? false}`;
1527
1537
  this.navigate(url);
1528
1538
  }
1529
1539
  /**
@@ -55,7 +55,7 @@ export interface RefreshTokenProps {
55
55
  /**
56
56
  * App fields
57
57
  */
58
- export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase"];
58
+ export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase", "cachedUrl"];
59
59
  /**
60
60
  * Basic type template
61
61
  */
@@ -130,6 +130,10 @@ export interface IApp {
130
130
  * Is debug mode
131
131
  */
132
132
  readonly debug: boolean;
133
+ /**
134
+ * Cached URL
135
+ */
136
+ cachedUrl: string | undefined | null;
133
137
  /**
134
138
  * IP data
135
139
  */
@@ -6,5 +6,6 @@ export const appFields = [
6
6
  'serversideDeviceId',
7
7
  'deviceId',
8
8
  'devices',
9
- 'devicePassphrase'
9
+ 'devicePassphrase',
10
+ 'cachedUrl'
10
11
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.21",
3
+ "version": "1.5.22",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -234,6 +234,16 @@ export abstract class CoreApp<
234
234
  this._isReady = value;
235
235
  }
236
236
 
237
+ /**
238
+ * Current cached URL
239
+ */
240
+ get cachedUrl() {
241
+ return this.storage.getData(this.fields.cachedUrl);
242
+ }
243
+ set cachedUrl(value: string | undefined | null) {
244
+ this.storage.setData(this.fields.cachedUrl, value);
245
+ }
246
+
237
247
  private _isTryingLogin = false;
238
248
 
239
249
  /**
@@ -2102,9 +2112,10 @@ export abstract class CoreApp<
2102
2112
  * @param removeUrl Remove current URL for reuse
2103
2113
  */
2104
2114
  toLoginPage(tryLogin?: boolean, removeUrl?: boolean) {
2105
- const url =
2106
- `/?tryLogin=${tryLogin ?? false}` +
2107
- (removeUrl ? '' : '&url=' + encodeURIComponent(location.href));
2115
+ // Save the current URL
2116
+ this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
2117
+
2118
+ const url = `/?tryLogin=${tryLogin ?? false}`;
2108
2119
 
2109
2120
  this.navigate(url);
2110
2121
  }
package/src/app/IApp.ts CHANGED
@@ -89,7 +89,8 @@ export const appFields = [
89
89
  'serversideDeviceId',
90
90
  'deviceId',
91
91
  'devices',
92
- 'devicePassphrase'
92
+ 'devicePassphrase',
93
+ 'cachedUrl'
93
94
  ] as const;
94
95
 
95
96
  /**
@@ -181,6 +182,11 @@ export interface IApp {
181
182
  */
182
183
  readonly debug: boolean;
183
184
 
185
+ /**
186
+ * Cached URL
187
+ */
188
+ cachedUrl: string | undefined | null;
189
+
184
190
  /**
185
191
  * IP data
186
192
  */