@etsoo/appscript 1.2.94 → 1.2.96
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/__tests__/app/CoreApp.ts +7 -1
- package/lib/cjs/app/CoreApp.d.ts +11 -4
- package/lib/cjs/app/CoreApp.js +37 -4
- package/lib/cjs/app/IApp.d.ts +17 -3
- package/lib/mjs/app/CoreApp.d.ts +11 -4
- package/lib/mjs/app/CoreApp.js +37 -4
- package/lib/mjs/app/IApp.d.ts +17 -3
- package/package.json +1 -1
- package/src/app/CoreApp.ts +39 -4
- package/src/app/IApp.ts +22 -3
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -71,7 +71,7 @@ class CoreAppTest extends CoreApp<
|
|
|
71
71
|
/**
|
|
72
72
|
* App root url
|
|
73
73
|
*/
|
|
74
|
-
homepage: '',
|
|
74
|
+
homepage: '/cms',
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Web url of the cloud
|
|
@@ -125,6 +125,12 @@ class CoreAppTest extends CoreApp<
|
|
|
125
125
|
|
|
126
126
|
const app = new CoreAppTest();
|
|
127
127
|
|
|
128
|
+
test('Tests for addRootUrl', () => {
|
|
129
|
+
expect(app.addRootUrl('/home')).toBe('/cms/home');
|
|
130
|
+
expect(app.addRootUrl('./home')).toBe('/cms/./home');
|
|
131
|
+
expect(app.addRootUrl('home')).toBe('/cms/home');
|
|
132
|
+
});
|
|
133
|
+
|
|
128
134
|
test('Tests for encrypt / decrypt', () => {
|
|
129
135
|
// Arrange
|
|
130
136
|
const input = 'Hello, world!';
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IActionResult } from '../result/IActionResult';
|
|
|
8
8
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
9
9
|
import { IUser } from '../state/User';
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
|
-
import { IApp, IAppFields, IDetectIPCallback, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
|
+
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
14
14
|
* Core application interface
|
|
@@ -141,6 +141,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
141
141
|
* @returns Result
|
|
142
142
|
*/
|
|
143
143
|
protected addIdentifier(field: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Add root (homepage) to the URL
|
|
146
|
+
* @param url URL to add
|
|
147
|
+
* @returns Result
|
|
148
|
+
*/
|
|
149
|
+
addRootUrl(url: string): string;
|
|
144
150
|
/**
|
|
145
151
|
* Restore settings from persisted source
|
|
146
152
|
*/
|
|
@@ -407,10 +413,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
407
413
|
*/
|
|
408
414
|
hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
|
|
409
415
|
/**
|
|
410
|
-
* Navigate
|
|
411
|
-
* @param url Url
|
|
416
|
+
* Navigate to Url or delta
|
|
417
|
+
* @param url Url or delta
|
|
418
|
+
* @param options Options
|
|
412
419
|
*/
|
|
413
|
-
navigate(
|
|
420
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
414
421
|
/**
|
|
415
422
|
* Callback where exit a page
|
|
416
423
|
*/
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -149,6 +149,21 @@ class CoreApp {
|
|
|
149
149
|
addIdentifier(field) {
|
|
150
150
|
return field + '-' + this.name;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Add root (homepage) to the URL
|
|
154
|
+
* @param url URL to add
|
|
155
|
+
* @returns Result
|
|
156
|
+
*/
|
|
157
|
+
addRootUrl(url) {
|
|
158
|
+
const page = this.settings.homepage;
|
|
159
|
+
const endSlash = page.endsWith('/');
|
|
160
|
+
return (page +
|
|
161
|
+
(endSlash
|
|
162
|
+
? shared_1.Utils.trimStart(url, '/')
|
|
163
|
+
: url.startsWith('/')
|
|
164
|
+
? url
|
|
165
|
+
: '/' + url));
|
|
166
|
+
}
|
|
152
167
|
/**
|
|
153
168
|
* Restore settings from persisted source
|
|
154
169
|
*/
|
|
@@ -979,11 +994,29 @@ class CoreApp {
|
|
|
979
994
|
return false;
|
|
980
995
|
}
|
|
981
996
|
/**
|
|
982
|
-
* Navigate
|
|
983
|
-
* @param url Url
|
|
997
|
+
* Navigate to Url or delta
|
|
998
|
+
* @param url Url or delta
|
|
999
|
+
* @param options Options
|
|
984
1000
|
*/
|
|
985
|
-
navigate(
|
|
986
|
-
|
|
1001
|
+
navigate(to, options) {
|
|
1002
|
+
if (typeof to === 'number') {
|
|
1003
|
+
globalThis.history.go(to);
|
|
1004
|
+
}
|
|
1005
|
+
else {
|
|
1006
|
+
const { state, replace = false } = options !== null && options !== void 0 ? options : {};
|
|
1007
|
+
if (replace) {
|
|
1008
|
+
if (state)
|
|
1009
|
+
globalThis.history.replaceState(state, '', to);
|
|
1010
|
+
else
|
|
1011
|
+
globalThis.location.replace(to);
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
if (state)
|
|
1015
|
+
globalThis.history.pushState(state, '', to);
|
|
1016
|
+
else
|
|
1017
|
+
globalThis.location.assign(to);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
987
1020
|
}
|
|
988
1021
|
/**
|
|
989
1022
|
* Callback where exit a page
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { UserRole } from './UserRole';
|
|
|
13
13
|
export interface IDetectIPCallback {
|
|
14
14
|
(): void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Navigate options
|
|
18
|
+
*/
|
|
19
|
+
export interface NavigateOptions {
|
|
20
|
+
replace?: boolean;
|
|
21
|
+
state?: any;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Refresh token result type
|
|
18
25
|
* true means success, false means failed but no any message
|
|
@@ -122,6 +129,12 @@ export interface IApp {
|
|
|
122
129
|
* Is screen size up 'md'
|
|
123
130
|
*/
|
|
124
131
|
mdUp?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Add root (homepage) to the URL
|
|
134
|
+
* @param url URL to add
|
|
135
|
+
* @returns Result
|
|
136
|
+
*/
|
|
137
|
+
addRootUrl(url: string): string;
|
|
125
138
|
/**
|
|
126
139
|
* Alert action result
|
|
127
140
|
* @param result Action result
|
|
@@ -336,10 +349,11 @@ export interface IApp {
|
|
|
336
349
|
*/
|
|
337
350
|
isValidPassword(password: string): boolean;
|
|
338
351
|
/**
|
|
339
|
-
* Navigate
|
|
340
|
-
* @param url Url
|
|
352
|
+
* Navigate to Url or delta
|
|
353
|
+
* @param url Url or delta
|
|
354
|
+
* @param options Options
|
|
341
355
|
*/
|
|
342
|
-
navigate(
|
|
356
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
343
357
|
/**
|
|
344
358
|
* Callback where exit a page
|
|
345
359
|
*/
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IActionResult } from '../result/IActionResult';
|
|
|
8
8
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
9
9
|
import { IUser } from '../state/User';
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
|
-
import { IApp, IAppFields, IDetectIPCallback, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
|
+
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
14
14
|
* Core application interface
|
|
@@ -141,6 +141,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
141
141
|
* @returns Result
|
|
142
142
|
*/
|
|
143
143
|
protected addIdentifier(field: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Add root (homepage) to the URL
|
|
146
|
+
* @param url URL to add
|
|
147
|
+
* @returns Result
|
|
148
|
+
*/
|
|
149
|
+
addRootUrl(url: string): string;
|
|
144
150
|
/**
|
|
145
151
|
* Restore settings from persisted source
|
|
146
152
|
*/
|
|
@@ -407,10 +413,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
407
413
|
*/
|
|
408
414
|
hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
|
|
409
415
|
/**
|
|
410
|
-
* Navigate
|
|
411
|
-
* @param url Url
|
|
416
|
+
* Navigate to Url or delta
|
|
417
|
+
* @param url Url or delta
|
|
418
|
+
* @param options Options
|
|
412
419
|
*/
|
|
413
|
-
navigate(
|
|
420
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
414
421
|
/**
|
|
415
422
|
* Callback where exit a page
|
|
416
423
|
*/
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -146,6 +146,21 @@ export class CoreApp {
|
|
|
146
146
|
addIdentifier(field) {
|
|
147
147
|
return field + '-' + this.name;
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Add root (homepage) to the URL
|
|
151
|
+
* @param url URL to add
|
|
152
|
+
* @returns Result
|
|
153
|
+
*/
|
|
154
|
+
addRootUrl(url) {
|
|
155
|
+
const page = this.settings.homepage;
|
|
156
|
+
const endSlash = page.endsWith('/');
|
|
157
|
+
return (page +
|
|
158
|
+
(endSlash
|
|
159
|
+
? Utils.trimStart(url, '/')
|
|
160
|
+
: url.startsWith('/')
|
|
161
|
+
? url
|
|
162
|
+
: '/' + url));
|
|
163
|
+
}
|
|
149
164
|
/**
|
|
150
165
|
* Restore settings from persisted source
|
|
151
166
|
*/
|
|
@@ -976,11 +991,29 @@ export class CoreApp {
|
|
|
976
991
|
return false;
|
|
977
992
|
}
|
|
978
993
|
/**
|
|
979
|
-
* Navigate
|
|
980
|
-
* @param url Url
|
|
994
|
+
* Navigate to Url or delta
|
|
995
|
+
* @param url Url or delta
|
|
996
|
+
* @param options Options
|
|
981
997
|
*/
|
|
982
|
-
navigate(
|
|
983
|
-
|
|
998
|
+
navigate(to, options) {
|
|
999
|
+
if (typeof to === 'number') {
|
|
1000
|
+
globalThis.history.go(to);
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
const { state, replace = false } = options !== null && options !== void 0 ? options : {};
|
|
1004
|
+
if (replace) {
|
|
1005
|
+
if (state)
|
|
1006
|
+
globalThis.history.replaceState(state, '', to);
|
|
1007
|
+
else
|
|
1008
|
+
globalThis.location.replace(to);
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
if (state)
|
|
1012
|
+
globalThis.history.pushState(state, '', to);
|
|
1013
|
+
else
|
|
1014
|
+
globalThis.location.assign(to);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
984
1017
|
}
|
|
985
1018
|
/**
|
|
986
1019
|
* Callback where exit a page
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { UserRole } from './UserRole';
|
|
|
13
13
|
export interface IDetectIPCallback {
|
|
14
14
|
(): void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Navigate options
|
|
18
|
+
*/
|
|
19
|
+
export interface NavigateOptions {
|
|
20
|
+
replace?: boolean;
|
|
21
|
+
state?: any;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Refresh token result type
|
|
18
25
|
* true means success, false means failed but no any message
|
|
@@ -122,6 +129,12 @@ export interface IApp {
|
|
|
122
129
|
* Is screen size up 'md'
|
|
123
130
|
*/
|
|
124
131
|
mdUp?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Add root (homepage) to the URL
|
|
134
|
+
* @param url URL to add
|
|
135
|
+
* @returns Result
|
|
136
|
+
*/
|
|
137
|
+
addRootUrl(url: string): string;
|
|
125
138
|
/**
|
|
126
139
|
* Alert action result
|
|
127
140
|
* @param result Action result
|
|
@@ -336,10 +349,11 @@ export interface IApp {
|
|
|
336
349
|
*/
|
|
337
350
|
isValidPassword(password: string): boolean;
|
|
338
351
|
/**
|
|
339
|
-
* Navigate
|
|
340
|
-
* @param url Url
|
|
352
|
+
* Navigate to Url or delta
|
|
353
|
+
* @param url Url or delta
|
|
354
|
+
* @param options Options
|
|
341
355
|
*/
|
|
342
|
-
navigate(
|
|
356
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
343
357
|
/**
|
|
344
358
|
* Callback where exit a page
|
|
345
359
|
*/
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
IApp,
|
|
47
47
|
IAppFields,
|
|
48
48
|
IDetectIPCallback,
|
|
49
|
+
NavigateOptions,
|
|
49
50
|
RefreshTokenProps,
|
|
50
51
|
RefreshTokenResult
|
|
51
52
|
} from './IApp';
|
|
@@ -302,6 +303,24 @@ export abstract class CoreApp<
|
|
|
302
303
|
return field + '-' + this.name;
|
|
303
304
|
}
|
|
304
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Add root (homepage) to the URL
|
|
308
|
+
* @param url URL to add
|
|
309
|
+
* @returns Result
|
|
310
|
+
*/
|
|
311
|
+
addRootUrl(url: string) {
|
|
312
|
+
const page = this.settings.homepage;
|
|
313
|
+
const endSlash = page.endsWith('/');
|
|
314
|
+
return (
|
|
315
|
+
page +
|
|
316
|
+
(endSlash
|
|
317
|
+
? Utils.trimStart(url, '/')
|
|
318
|
+
: url.startsWith('/')
|
|
319
|
+
? url
|
|
320
|
+
: '/' + url)
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
305
324
|
/**
|
|
306
325
|
* Restore settings from persisted source
|
|
307
326
|
*/
|
|
@@ -1304,11 +1323,27 @@ export abstract class CoreApp<
|
|
|
1304
1323
|
}
|
|
1305
1324
|
|
|
1306
1325
|
/**
|
|
1307
|
-
* Navigate
|
|
1308
|
-
* @param url Url
|
|
1326
|
+
* Navigate to Url or delta
|
|
1327
|
+
* @param url Url or delta
|
|
1328
|
+
* @param options Options
|
|
1309
1329
|
*/
|
|
1310
|
-
navigate
|
|
1311
|
-
|
|
1330
|
+
navigate<T extends number | string | URL>(
|
|
1331
|
+
to: T,
|
|
1332
|
+
options?: T extends number ? never : NavigateOptions
|
|
1333
|
+
) {
|
|
1334
|
+
if (typeof to === 'number') {
|
|
1335
|
+
globalThis.history.go(to);
|
|
1336
|
+
} else {
|
|
1337
|
+
const { state, replace = false } = options ?? {};
|
|
1338
|
+
|
|
1339
|
+
if (replace) {
|
|
1340
|
+
if (state) globalThis.history.replaceState(state, '', to);
|
|
1341
|
+
else globalThis.location.replace(to);
|
|
1342
|
+
} else {
|
|
1343
|
+
if (state) globalThis.history.pushState(state, '', to);
|
|
1344
|
+
else globalThis.location.assign(to);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1312
1347
|
}
|
|
1313
1348
|
|
|
1314
1349
|
/**
|
package/src/app/IApp.ts
CHANGED
|
@@ -21,6 +21,14 @@ export interface IDetectIPCallback {
|
|
|
21
21
|
(): void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Navigate options
|
|
26
|
+
*/
|
|
27
|
+
export interface NavigateOptions {
|
|
28
|
+
replace?: boolean;
|
|
29
|
+
state?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
/**
|
|
25
33
|
* Refresh token result type
|
|
26
34
|
* true means success, false means failed but no any message
|
|
@@ -162,6 +170,13 @@ export interface IApp {
|
|
|
162
170
|
*/
|
|
163
171
|
mdUp?: boolean;
|
|
164
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Add root (homepage) to the URL
|
|
175
|
+
* @param url URL to add
|
|
176
|
+
* @returns Result
|
|
177
|
+
*/
|
|
178
|
+
addRootUrl(url: string): string;
|
|
179
|
+
|
|
165
180
|
/**
|
|
166
181
|
* Alert action result
|
|
167
182
|
* @param result Action result
|
|
@@ -438,10 +453,14 @@ export interface IApp {
|
|
|
438
453
|
isValidPassword(password: string): boolean;
|
|
439
454
|
|
|
440
455
|
/**
|
|
441
|
-
* Navigate
|
|
442
|
-
* @param url Url
|
|
456
|
+
* Navigate to Url or delta
|
|
457
|
+
* @param url Url or delta
|
|
458
|
+
* @param options Options
|
|
443
459
|
*/
|
|
444
|
-
navigate
|
|
460
|
+
navigate<T extends number | string | URL>(
|
|
461
|
+
to: T,
|
|
462
|
+
options?: T extends number ? never : NavigateOptions
|
|
463
|
+
): void;
|
|
445
464
|
|
|
446
465
|
/**
|
|
447
466
|
* Callback where exit a page
|