@nu-art/thunderstorm-frontend 0.400.10 → 0.400.12
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/modules/ModuleFE_BrowserHistory.d.ts +199 -5
- package/modules/ModuleFE_BrowserHistory.js +242 -4
- package/modules/ModuleFE_Thunderstorm.js +1 -1
- package/modules/component-loader/entry-component-loading-module.js +2 -2
- package/modules/routing/ModuleFE_Routing.d.ts +154 -0
- package/modules/routing/ModuleFE_Routing.js +157 -3
- package/modules/routing/ModuleFE_RoutingV2.d.ts +91 -1
- package/modules/routing/ModuleFE_RoutingV2.js +193 -1
- package/modules/routing/index.d.ts +0 -1
- package/modules/routing/index.js +0 -1
- package/package.json +6 -6
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by tacb0ss on 27/07/2018.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated This module is deprecated. Use ModuleFE_RoutingV2 instead.
|
|
5
|
+
*
|
|
6
|
+
* Migration Guide:
|
|
7
|
+
*
|
|
8
|
+
* Query Parameters:
|
|
9
|
+
* - ModuleFE_BrowserHistory.getQueryParams() → ModuleFE_RoutingV2.getQueryParams()
|
|
10
|
+
* - ModuleFE_BrowserHistory.getQueryParameter(key) → ModuleFE_RoutingV2.getQueryParameter(key)
|
|
11
|
+
* - ModuleFE_BrowserHistory.setQuery(params) → ModuleFE_RoutingV2.setQuery(params)
|
|
12
|
+
* - ModuleFE_BrowserHistory.addQueryParam(key, value) → ModuleFE_RoutingV2.addQueryParam(key, value)
|
|
13
|
+
* - ModuleFE_BrowserHistory.removeQueryParam(key) → ModuleFE_RoutingV2.removeQueryParam(key)
|
|
14
|
+
*
|
|
15
|
+
* URL Utilities:
|
|
16
|
+
* - ModuleFE_BrowserHistory.getCurrent() → ModuleFE_RoutingV2.getCurrent()
|
|
17
|
+
* - ModuleFE_BrowserHistory.getCurrentUrl() → ModuleFE_RoutingV2.getCurrentUrl()
|
|
18
|
+
* - ModuleFE_BrowserHistory.getOrigin() → ModuleFE_RoutingV2.getOrigin()
|
|
19
|
+
*
|
|
20
|
+
* Navigation:
|
|
21
|
+
* - ModuleFE_BrowserHistory.push(location) → ModuleFE_RoutingV2.push(location)
|
|
22
|
+
* - ModuleFE_BrowserHistory.replace(location) → ModuleFE_RoutingV2.replace(location)
|
|
23
|
+
* - ModuleFE_BrowserHistory.setUrl(url, params) → Use ModuleFE_RoutingV2.push({pathname: url, search: ...})
|
|
24
|
+
*
|
|
25
|
+
* Utility Functions:
|
|
26
|
+
* - composeURL(url, params) → ModuleFE_RoutingV2.composeURL(url, params) (or import from routing module)
|
|
27
|
+
* - encodeUrlParams(params) → ModuleFE_RoutingV2.encodeUrlParams(params) (or import from routing module)
|
|
28
|
+
* - composeQuery(params) → ModuleFE_RoutingV2.composeQuery(params) (or import from routing module)
|
|
29
|
+
*
|
|
30
|
+
* This module will be removed in a future version. Please migrate to ModuleFE_RoutingV2.
|
|
3
31
|
*/
|
|
4
32
|
import { Module } from '@nu-art/ts-common';
|
|
5
33
|
import { History, LocationDescriptorObject } from 'history';
|
|
@@ -9,38 +37,204 @@ export type OnUrlParamsChangedListener = {
|
|
|
9
37
|
__onUrlParamsChanged: VoidFunction;
|
|
10
38
|
};
|
|
11
39
|
export declare const dispatcher_urlParamsChanged: ThunderDispatcher<OnUrlParamsChangedListener, "__onUrlParamsChanged", [], void>;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This class will be removed in a future version.
|
|
42
|
+
*
|
|
43
|
+
* All functionality has been migrated to ModuleFE_RoutingV2. See file-level deprecation notice for migration guide.
|
|
44
|
+
*/
|
|
12
45
|
export declare class ModuleFE_BrowserHistory_Class extends Module {
|
|
13
46
|
private readonly history;
|
|
14
47
|
constructor();
|
|
15
48
|
/**
|
|
16
49
|
* Update and navigate according to query params
|
|
50
|
+
*
|
|
51
|
+
* @deprecated Use ModuleFE_RoutingV2.push() instead
|
|
52
|
+
*
|
|
53
|
+
* Migration:
|
|
54
|
+
* // Old:
|
|
55
|
+
* ModuleFE_BrowserHistory.push({pathname: '/path', search: '?key=value'});
|
|
56
|
+
*
|
|
57
|
+
* // New:
|
|
58
|
+
* ModuleFE_RoutingV2.push({pathname: '/path', search: '?key=value'});
|
|
17
59
|
*/
|
|
18
60
|
push(push: LocationDescriptorObject): void;
|
|
19
61
|
/**
|
|
20
62
|
* Update query params
|
|
63
|
+
*
|
|
64
|
+
* @deprecated Use ModuleFE_RoutingV2.replace() instead
|
|
65
|
+
*
|
|
66
|
+
* Migration:
|
|
67
|
+
* // Old:
|
|
68
|
+
* ModuleFE_BrowserHistory.replace({pathname: '/path', search: '?key=value'});
|
|
69
|
+
*
|
|
70
|
+
* // New:
|
|
71
|
+
* ModuleFE_RoutingV2.replace({pathname: '/path', search: '?key=value'});
|
|
21
72
|
*/
|
|
22
73
|
replace(push: LocationDescriptorObject): void;
|
|
23
74
|
private composeQuery;
|
|
24
75
|
private getEncodedQueryParams;
|
|
76
|
+
/**
|
|
77
|
+
* Get all query parameters from the current URL (decoded)
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
80
|
+
*
|
|
81
|
+
* Migration:
|
|
82
|
+
* // Old:
|
|
83
|
+
* const params = ModuleFE_BrowserHistory.getQueryParams();
|
|
84
|
+
*
|
|
85
|
+
* // New:
|
|
86
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
87
|
+
*/
|
|
25
88
|
getQueryParams(): UrlQueryParams;
|
|
89
|
+
/**
|
|
90
|
+
* Replace all query parameters on the current route
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Use ModuleFE_RoutingV2.setQuery() instead
|
|
93
|
+
*
|
|
94
|
+
* Migration:
|
|
95
|
+
* // Old:
|
|
96
|
+
* ModuleFE_BrowserHistory.setQuery({key: 'value'});
|
|
97
|
+
*
|
|
98
|
+
* // New:
|
|
99
|
+
* ModuleFE_RoutingV2.setQuery({key: 'value'});
|
|
100
|
+
*/
|
|
26
101
|
setQuery(queryParams: UrlQueryParams): void;
|
|
102
|
+
/**
|
|
103
|
+
* Add or update a single query parameter on the current route
|
|
104
|
+
*
|
|
105
|
+
* @deprecated Use ModuleFE_RoutingV2.addQueryParam() instead
|
|
106
|
+
*
|
|
107
|
+
* Migration:
|
|
108
|
+
* // Old:
|
|
109
|
+
* ModuleFE_BrowserHistory.addQueryParam('key', 'value');
|
|
110
|
+
*
|
|
111
|
+
* // New:
|
|
112
|
+
* ModuleFE_RoutingV2.addQueryParam('key', 'value');
|
|
113
|
+
*/
|
|
27
114
|
addQueryParam(key: string, value: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Remove a single query parameter from the current route
|
|
117
|
+
*
|
|
118
|
+
* @deprecated Use ModuleFE_RoutingV2.removeQueryParam() instead
|
|
119
|
+
*
|
|
120
|
+
* Migration:
|
|
121
|
+
* // Old:
|
|
122
|
+
* ModuleFE_BrowserHistory.removeQueryParam('key');
|
|
123
|
+
*
|
|
124
|
+
* // New:
|
|
125
|
+
* ModuleFE_RoutingV2.removeQueryParam('key');
|
|
126
|
+
*/
|
|
28
127
|
removeQueryParam(key: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* Set URL with optional query parameters
|
|
130
|
+
*
|
|
131
|
+
* @deprecated Use ModuleFE_RoutingV2.push() instead
|
|
132
|
+
*
|
|
133
|
+
* Migration:
|
|
134
|
+
* // Old:
|
|
135
|
+
* ModuleFE_BrowserHistory.setUrl('/path', {key: 'value'});
|
|
136
|
+
*
|
|
137
|
+
* // New:
|
|
138
|
+
* const search = ModuleFE_RoutingV2.composeQuery({key: 'value'});
|
|
139
|
+
* ModuleFE_RoutingV2.push({pathname: '/path', search: search ? `?${search}` : ''});
|
|
140
|
+
*/
|
|
29
141
|
setUrl(url: string, queryParams?: UrlQueryParams): void;
|
|
30
142
|
private createHistoryDataFromQueryParams;
|
|
31
143
|
private updateQueryParams;
|
|
144
|
+
/**
|
|
145
|
+
* Get the window origin
|
|
146
|
+
*
|
|
147
|
+
* @deprecated Use ModuleFE_RoutingV2.getOrigin() instead
|
|
148
|
+
*
|
|
149
|
+
* Migration:
|
|
150
|
+
* // Old:
|
|
151
|
+
* const origin = ModuleFE_BrowserHistory.getOrigin();
|
|
152
|
+
*
|
|
153
|
+
* // New:
|
|
154
|
+
* const origin = ModuleFE_RoutingV2.getOrigin();
|
|
155
|
+
*/
|
|
32
156
|
getOrigin(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Get the current location object
|
|
159
|
+
*
|
|
160
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrent() instead
|
|
161
|
+
*
|
|
162
|
+
* Migration:
|
|
163
|
+
* // Old:
|
|
164
|
+
* const location = ModuleFE_BrowserHistory.getCurrent();
|
|
165
|
+
*
|
|
166
|
+
* // New:
|
|
167
|
+
* const location = ModuleFE_RoutingV2.getCurrent();
|
|
168
|
+
*/
|
|
33
169
|
getCurrent(): import("history").Location<any>;
|
|
170
|
+
/**
|
|
171
|
+
* Get the history object (internal use)
|
|
172
|
+
*
|
|
173
|
+
* @deprecated This method is deprecated. The history object is no longer exposed.
|
|
174
|
+
* If you need navigation functionality, use ModuleFE_RoutingV2 methods instead.
|
|
175
|
+
*/
|
|
34
176
|
getHistory(): History<any>;
|
|
177
|
+
/**
|
|
178
|
+
* Get a single query parameter from the current URL
|
|
179
|
+
*
|
|
180
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParameter() instead
|
|
181
|
+
*
|
|
182
|
+
* Migration:
|
|
183
|
+
* // Old:
|
|
184
|
+
* const value = ModuleFE_BrowserHistory.getQueryParameter('key');
|
|
185
|
+
*
|
|
186
|
+
* // New:
|
|
187
|
+
* const value = ModuleFE_RoutingV2.getQueryParameter('key');
|
|
188
|
+
*/
|
|
35
189
|
getQueryParameter(key: string): string | null | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* Get the current URL pathname
|
|
192
|
+
*
|
|
193
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
194
|
+
*
|
|
195
|
+
* Migration:
|
|
196
|
+
* // Old:
|
|
197
|
+
* const url = ModuleFE_BrowserHistory.getCurrentUrl();
|
|
198
|
+
*
|
|
199
|
+
* // New:
|
|
200
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
201
|
+
*/
|
|
36
202
|
getCurrentUrl(): string;
|
|
37
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
206
|
+
*
|
|
207
|
+
* Migration:
|
|
208
|
+
* // Old:
|
|
209
|
+
* const url = getCurrentUrl();
|
|
210
|
+
*
|
|
211
|
+
* // New:
|
|
212
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
213
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
214
|
+
*/
|
|
38
215
|
export declare function getCurrentUrl(): string;
|
|
216
|
+
/**
|
|
217
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParameter() instead
|
|
218
|
+
*
|
|
219
|
+
* Migration:
|
|
220
|
+
* // Old:
|
|
221
|
+
* const value = getQueryParameter('key');
|
|
222
|
+
*
|
|
223
|
+
* // New:
|
|
224
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
225
|
+
* const value = ModuleFE_RoutingV2.getQueryParameter('key');
|
|
226
|
+
*/
|
|
39
227
|
export declare function getQueryParameter(name: string): string | null | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
230
|
+
*
|
|
231
|
+
* Migration:
|
|
232
|
+
* // Old:
|
|
233
|
+
* const params = getUrlQuery();
|
|
234
|
+
*
|
|
235
|
+
* // New:
|
|
236
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
237
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
238
|
+
*/
|
|
40
239
|
export declare function getUrlQuery(): UrlQueryParams;
|
|
41
|
-
export declare function encodeUrlParams(queryParams?: UrlQueryParams): {
|
|
42
|
-
[key: string]: string | undefined;
|
|
43
|
-
};
|
|
44
|
-
export declare function composeQuery(queryParams?: UrlQueryParams): string;
|
|
45
|
-
export declare function composeURL(url: string, queryParams?: UrlQueryParams): string;
|
|
46
240
|
export declare const ModuleFE_BrowserHistory: ModuleFE_BrowserHistory_Class;
|
|
@@ -20,12 +20,44 @@
|
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* Created by tacb0ss on 27/07/2018.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated This module is deprecated. Use ModuleFE_RoutingV2 instead.
|
|
25
|
+
*
|
|
26
|
+
* Migration Guide:
|
|
27
|
+
*
|
|
28
|
+
* Query Parameters:
|
|
29
|
+
* - ModuleFE_BrowserHistory.getQueryParams() → ModuleFE_RoutingV2.getQueryParams()
|
|
30
|
+
* - ModuleFE_BrowserHistory.getQueryParameter(key) → ModuleFE_RoutingV2.getQueryParameter(key)
|
|
31
|
+
* - ModuleFE_BrowserHistory.setQuery(params) → ModuleFE_RoutingV2.setQuery(params)
|
|
32
|
+
* - ModuleFE_BrowserHistory.addQueryParam(key, value) → ModuleFE_RoutingV2.addQueryParam(key, value)
|
|
33
|
+
* - ModuleFE_BrowserHistory.removeQueryParam(key) → ModuleFE_RoutingV2.removeQueryParam(key)
|
|
34
|
+
*
|
|
35
|
+
* URL Utilities:
|
|
36
|
+
* - ModuleFE_BrowserHistory.getCurrent() → ModuleFE_RoutingV2.getCurrent()
|
|
37
|
+
* - ModuleFE_BrowserHistory.getCurrentUrl() → ModuleFE_RoutingV2.getCurrentUrl()
|
|
38
|
+
* - ModuleFE_BrowserHistory.getOrigin() → ModuleFE_RoutingV2.getOrigin()
|
|
39
|
+
*
|
|
40
|
+
* Navigation:
|
|
41
|
+
* - ModuleFE_BrowserHistory.push(location) → ModuleFE_RoutingV2.push(location)
|
|
42
|
+
* - ModuleFE_BrowserHistory.replace(location) → ModuleFE_RoutingV2.replace(location)
|
|
43
|
+
* - ModuleFE_BrowserHistory.setUrl(url, params) → Use ModuleFE_RoutingV2.push({pathname: url, search: ...})
|
|
44
|
+
*
|
|
45
|
+
* Utility Functions:
|
|
46
|
+
* - composeURL(url, params) → ModuleFE_RoutingV2.composeURL(url, params) (or import from routing module)
|
|
47
|
+
* - encodeUrlParams(params) → ModuleFE_RoutingV2.encodeUrlParams(params) (or import from routing module)
|
|
48
|
+
* - composeQuery(params) → ModuleFE_RoutingV2.composeQuery(params) (or import from routing module)
|
|
49
|
+
*
|
|
50
|
+
* This module will be removed in a future version. Please migrate to ModuleFE_RoutingV2.
|
|
23
51
|
*/
|
|
24
52
|
import { _keys, composeQueryParams, exists, Module, } from '@nu-art/ts-common';
|
|
25
53
|
import { createBrowserHistory } from 'history';
|
|
26
54
|
import { ThunderDispatcher } from '../core/thunder-dispatcher.js';
|
|
27
55
|
export const dispatcher_urlParamsChanged = new ThunderDispatcher('__onUrlParamsChanged');
|
|
28
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use ModuleFE_RoutingV2 instead. This class will be removed in a future version.
|
|
58
|
+
*
|
|
59
|
+
* All functionality has been migrated to ModuleFE_RoutingV2. See file-level deprecation notice for migration guide.
|
|
60
|
+
*/
|
|
29
61
|
export class ModuleFE_BrowserHistory_Class extends Module {
|
|
30
62
|
history;
|
|
31
63
|
constructor() {
|
|
@@ -34,12 +66,30 @@ export class ModuleFE_BrowserHistory_Class extends Module {
|
|
|
34
66
|
}
|
|
35
67
|
/**
|
|
36
68
|
* Update and navigate according to query params
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Use ModuleFE_RoutingV2.push() instead
|
|
71
|
+
*
|
|
72
|
+
* Migration:
|
|
73
|
+
* // Old:
|
|
74
|
+
* ModuleFE_BrowserHistory.push({pathname: '/path', search: '?key=value'});
|
|
75
|
+
*
|
|
76
|
+
* // New:
|
|
77
|
+
* ModuleFE_RoutingV2.push({pathname: '/path', search: '?key=value'});
|
|
37
78
|
*/
|
|
38
79
|
push(push) {
|
|
39
80
|
this.history.push(push);
|
|
40
81
|
}
|
|
41
82
|
/**
|
|
42
83
|
* Update query params
|
|
84
|
+
*
|
|
85
|
+
* @deprecated Use ModuleFE_RoutingV2.replace() instead
|
|
86
|
+
*
|
|
87
|
+
* Migration:
|
|
88
|
+
* // Old:
|
|
89
|
+
* ModuleFE_BrowserHistory.replace({pathname: '/path', search: '?key=value'});
|
|
90
|
+
*
|
|
91
|
+
* // New:
|
|
92
|
+
* ModuleFE_RoutingV2.replace({pathname: '/path', search: '?key=value'});
|
|
43
93
|
*/
|
|
44
94
|
replace(push) {
|
|
45
95
|
this.history.replace(push);
|
|
@@ -72,6 +122,18 @@ export class ModuleFE_BrowserHistory_Class extends Module {
|
|
|
72
122
|
return toRet;
|
|
73
123
|
}, queryParams);
|
|
74
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* Get all query parameters from the current URL (decoded)
|
|
127
|
+
*
|
|
128
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
129
|
+
*
|
|
130
|
+
* Migration:
|
|
131
|
+
* // Old:
|
|
132
|
+
* const params = ModuleFE_BrowserHistory.getQueryParams();
|
|
133
|
+
*
|
|
134
|
+
* // New:
|
|
135
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
136
|
+
*/
|
|
75
137
|
getQueryParams() {
|
|
76
138
|
const params = this.getEncodedQueryParams();
|
|
77
139
|
_keys(params).forEach(key => {
|
|
@@ -83,21 +145,70 @@ export class ModuleFE_BrowserHistory_Class extends Module {
|
|
|
83
145
|
});
|
|
84
146
|
return params;
|
|
85
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Replace all query parameters on the current route
|
|
150
|
+
*
|
|
151
|
+
* @deprecated Use ModuleFE_RoutingV2.setQuery() instead
|
|
152
|
+
*
|
|
153
|
+
* Migration:
|
|
154
|
+
* // Old:
|
|
155
|
+
* ModuleFE_BrowserHistory.setQuery({key: 'value'});
|
|
156
|
+
*
|
|
157
|
+
* // New:
|
|
158
|
+
* ModuleFE_RoutingV2.setQuery({key: 'value'});
|
|
159
|
+
*/
|
|
86
160
|
setQuery(queryParams) {
|
|
87
161
|
const encodedQueryParams = encodeUrlParams(queryParams);
|
|
88
162
|
this.updateQueryParams(encodedQueryParams);
|
|
89
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Add or update a single query parameter on the current route
|
|
166
|
+
*
|
|
167
|
+
* @deprecated Use ModuleFE_RoutingV2.addQueryParam() instead
|
|
168
|
+
*
|
|
169
|
+
* Migration:
|
|
170
|
+
* // Old:
|
|
171
|
+
* ModuleFE_BrowserHistory.addQueryParam('key', 'value');
|
|
172
|
+
*
|
|
173
|
+
* // New:
|
|
174
|
+
* ModuleFE_RoutingV2.addQueryParam('key', 'value');
|
|
175
|
+
*/
|
|
90
176
|
addQueryParam(key, value) {
|
|
91
177
|
const decodedQueryParams = this.getQueryParams();
|
|
92
178
|
decodedQueryParams[key] = value;
|
|
93
179
|
this.updateQueryParams(decodedQueryParams);
|
|
94
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Remove a single query parameter from the current route
|
|
183
|
+
*
|
|
184
|
+
* @deprecated Use ModuleFE_RoutingV2.removeQueryParam() instead
|
|
185
|
+
*
|
|
186
|
+
* Migration:
|
|
187
|
+
* // Old:
|
|
188
|
+
* ModuleFE_BrowserHistory.removeQueryParam('key');
|
|
189
|
+
*
|
|
190
|
+
* // New:
|
|
191
|
+
* ModuleFE_RoutingV2.removeQueryParam('key');
|
|
192
|
+
*/
|
|
95
193
|
removeQueryParam(key) {
|
|
96
194
|
const encodedQueryParams = this.getEncodedQueryParams();
|
|
97
195
|
delete encodedQueryParams[key];
|
|
98
196
|
const data = this.createHistoryDataFromQueryParams(encodedQueryParams);
|
|
99
197
|
this.replace(data);
|
|
100
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Set URL with optional query parameters
|
|
201
|
+
*
|
|
202
|
+
* @deprecated Use ModuleFE_RoutingV2.push() instead
|
|
203
|
+
*
|
|
204
|
+
* Migration:
|
|
205
|
+
* // Old:
|
|
206
|
+
* ModuleFE_BrowserHistory.setUrl('/path', {key: 'value'});
|
|
207
|
+
*
|
|
208
|
+
* // New:
|
|
209
|
+
* const search = ModuleFE_RoutingV2.composeQuery({key: 'value'});
|
|
210
|
+
* ModuleFE_RoutingV2.push({pathname: '/path', search: search ? `?${search}` : ''});
|
|
211
|
+
*/
|
|
101
212
|
setUrl(url, queryParams) {
|
|
102
213
|
this.push(this.createHistoryDataFromQueryParams(queryParams, url));
|
|
103
214
|
}
|
|
@@ -111,15 +222,57 @@ export class ModuleFE_BrowserHistory_Class extends Module {
|
|
|
111
222
|
const data = this.createHistoryDataFromQueryParams(encodedQueryParams);
|
|
112
223
|
this.replace(data);
|
|
113
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Get the window origin
|
|
227
|
+
*
|
|
228
|
+
* @deprecated Use ModuleFE_RoutingV2.getOrigin() instead
|
|
229
|
+
*
|
|
230
|
+
* Migration:
|
|
231
|
+
* // Old:
|
|
232
|
+
* const origin = ModuleFE_BrowserHistory.getOrigin();
|
|
233
|
+
*
|
|
234
|
+
* // New:
|
|
235
|
+
* const origin = ModuleFE_RoutingV2.getOrigin();
|
|
236
|
+
*/
|
|
114
237
|
getOrigin() {
|
|
115
238
|
return window.location.origin;
|
|
116
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Get the current location object
|
|
242
|
+
*
|
|
243
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrent() instead
|
|
244
|
+
*
|
|
245
|
+
* Migration:
|
|
246
|
+
* // Old:
|
|
247
|
+
* const location = ModuleFE_BrowserHistory.getCurrent();
|
|
248
|
+
*
|
|
249
|
+
* // New:
|
|
250
|
+
* const location = ModuleFE_RoutingV2.getCurrent();
|
|
251
|
+
*/
|
|
117
252
|
getCurrent() {
|
|
118
253
|
return this.history.location;
|
|
119
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the history object (internal use)
|
|
257
|
+
*
|
|
258
|
+
* @deprecated This method is deprecated. The history object is no longer exposed.
|
|
259
|
+
* If you need navigation functionality, use ModuleFE_RoutingV2 methods instead.
|
|
260
|
+
*/
|
|
120
261
|
getHistory() {
|
|
121
262
|
return this.history;
|
|
122
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Get a single query parameter from the current URL
|
|
266
|
+
*
|
|
267
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParameter() instead
|
|
268
|
+
*
|
|
269
|
+
* Migration:
|
|
270
|
+
* // Old:
|
|
271
|
+
* const value = ModuleFE_BrowserHistory.getQueryParameter('key');
|
|
272
|
+
*
|
|
273
|
+
* // New:
|
|
274
|
+
* const value = ModuleFE_RoutingV2.getQueryParameter('key');
|
|
275
|
+
*/
|
|
123
276
|
getQueryParameter(key) {
|
|
124
277
|
const queryParams = ModuleFE_BrowserHistory.getQueryParams();
|
|
125
278
|
const value = queryParams[key];
|
|
@@ -127,20 +280,78 @@ export class ModuleFE_BrowserHistory_Class extends Module {
|
|
|
127
280
|
return null;
|
|
128
281
|
return value;
|
|
129
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Get the current URL pathname
|
|
285
|
+
*
|
|
286
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
287
|
+
*
|
|
288
|
+
* Migration:
|
|
289
|
+
* // Old:
|
|
290
|
+
* const url = ModuleFE_BrowserHistory.getCurrentUrl();
|
|
291
|
+
*
|
|
292
|
+
* // New:
|
|
293
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
294
|
+
*/
|
|
130
295
|
getCurrentUrl() {
|
|
131
296
|
return ModuleFE_BrowserHistory.getCurrent().pathname;
|
|
132
297
|
}
|
|
133
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* @deprecated Use ModuleFE_RoutingV2.getCurrentUrl() instead
|
|
301
|
+
*
|
|
302
|
+
* Migration:
|
|
303
|
+
* // Old:
|
|
304
|
+
* const url = getCurrentUrl();
|
|
305
|
+
*
|
|
306
|
+
* // New:
|
|
307
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
308
|
+
* const url = ModuleFE_RoutingV2.getCurrentUrl();
|
|
309
|
+
*/
|
|
134
310
|
export function getCurrentUrl() {
|
|
135
311
|
return ModuleFE_BrowserHistory.getCurrentUrl();
|
|
136
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParameter() instead
|
|
315
|
+
*
|
|
316
|
+
* Migration:
|
|
317
|
+
* // Old:
|
|
318
|
+
* const value = getQueryParameter('key');
|
|
319
|
+
*
|
|
320
|
+
* // New:
|
|
321
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
322
|
+
* const value = ModuleFE_RoutingV2.getQueryParameter('key');
|
|
323
|
+
*/
|
|
137
324
|
export function getQueryParameter(name) {
|
|
138
325
|
return ModuleFE_BrowserHistory.getQueryParameter(name);
|
|
139
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* @deprecated Use ModuleFE_RoutingV2.getQueryParams() instead
|
|
329
|
+
*
|
|
330
|
+
* Migration:
|
|
331
|
+
* // Old:
|
|
332
|
+
* const params = getUrlQuery();
|
|
333
|
+
*
|
|
334
|
+
* // New:
|
|
335
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
336
|
+
* const params = ModuleFE_RoutingV2.getQueryParams();
|
|
337
|
+
*/
|
|
140
338
|
export function getUrlQuery() {
|
|
141
339
|
return ModuleFE_BrowserHistory.getQueryParams();
|
|
142
340
|
}
|
|
143
|
-
|
|
341
|
+
/**
|
|
342
|
+
* @deprecated Use ModuleFE_RoutingV2.encodeUrlParams() or import from routing module instead
|
|
343
|
+
*
|
|
344
|
+
* Migration:
|
|
345
|
+
* // Old:
|
|
346
|
+
* const encoded = encodeUrlParams(params);
|
|
347
|
+
*
|
|
348
|
+
* // New:
|
|
349
|
+
* import {encodeUrlParams} from '@nu-art/thunderstorm-frontend/modules/routing/ModuleFE_RoutingV2';
|
|
350
|
+
* // OR
|
|
351
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
352
|
+
* const encoded = ModuleFE_RoutingV2.encodeUrlParams(params);
|
|
353
|
+
*/
|
|
354
|
+
function encodeUrlParams(queryParams) {
|
|
144
355
|
const encodedQueryParams = { ...queryParams };
|
|
145
356
|
_keys(encodedQueryParams).forEach(key => {
|
|
146
357
|
const value = encodedQueryParams[key];
|
|
@@ -152,13 +363,40 @@ export function encodeUrlParams(queryParams) {
|
|
|
152
363
|
});
|
|
153
364
|
return encodedQueryParams;
|
|
154
365
|
}
|
|
155
|
-
|
|
366
|
+
/**
|
|
367
|
+
* @deprecated Use ModuleFE_RoutingV2.composeQuery() or import from routing module instead
|
|
368
|
+
*
|
|
369
|
+
* Migration:
|
|
370
|
+
* // Old:
|
|
371
|
+
* const query = composeQuery(params);
|
|
372
|
+
*
|
|
373
|
+
* // New:
|
|
374
|
+
* import {composeQuery} from '@nu-art/thunderstorm-frontend/modules/routing/ModuleFE_RoutingV2';
|
|
375
|
+
* // OR
|
|
376
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
377
|
+
* const query = ModuleFE_RoutingV2.composeQuery(params);
|
|
378
|
+
*/
|
|
379
|
+
function composeQuery(queryParams) {
|
|
156
380
|
const queryAsString = composeQueryParams(queryParams);
|
|
157
381
|
if (queryAsString.length === 0)
|
|
158
382
|
return '';
|
|
159
383
|
return queryAsString;
|
|
160
384
|
}
|
|
161
|
-
|
|
385
|
+
/**
|
|
386
|
+
* @deprecated Use ModuleFE_RoutingV2.composeURL() or import from routing module instead
|
|
387
|
+
*
|
|
388
|
+
* Migration:
|
|
389
|
+
* // Old:
|
|
390
|
+
* const url = composeURL('/path', params);
|
|
391
|
+
*
|
|
392
|
+
* // New:
|
|
393
|
+
* import {composeURL} from '@nu-art/thunderstorm-frontend/modules/routing/ModuleFE_RoutingV2';
|
|
394
|
+
* // OR
|
|
395
|
+
* import {ModuleFE_RoutingV2} from '@nu-art/thunderstorm-frontend';
|
|
396
|
+
* const url = ModuleFE_RoutingV2.composeURL('/path', params);
|
|
397
|
+
*/
|
|
398
|
+
// @ts-ignore
|
|
399
|
+
function composeURL(url, queryParams) {
|
|
162
400
|
const queryAsString = composeQuery(queryParams);
|
|
163
401
|
return `${url}${queryAsString.length > 0 ? `?${queryAsString}` : ''}`;
|
|
164
402
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { _keys, BadImplementationException, Module } from '@nu-art/ts-common';
|
|
22
22
|
import { ModuleFE_Toaster } from '../component-modules/ModuleFE_Toaster.js';
|
|
23
|
-
import { composeURL } from './
|
|
23
|
+
import { composeURL } from './routing/ModuleFE_RoutingV2.js';
|
|
24
24
|
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
25
25
|
import { base64ToBlob } from '../utils/tools.js';
|
|
26
26
|
import { ModuleFE_XHR } from './http/ModuleFE_XHR.js';
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
import { Module } from '@nu-art/ts-common';
|
|
22
22
|
// noinspection TypeScriptPreferShortImport
|
|
23
23
|
import { ModuleFE_XHR } from '../http/ModuleFE_XHR.js';
|
|
24
|
-
import {
|
|
24
|
+
import { ModuleFE_RoutingV2 } from '../routing/ModuleFE_RoutingV2.js';
|
|
25
25
|
import { HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
26
26
|
export class PageLoadingModule_Class extends Module {
|
|
27
27
|
injected = {};
|
|
28
28
|
loadScript(src, progressListener) {
|
|
29
29
|
const apiDef = {
|
|
30
30
|
method: HttpMethod.GET,
|
|
31
|
-
baseUrl:
|
|
31
|
+
baseUrl: ModuleFE_RoutingV2.getOrigin(),
|
|
32
32
|
path: src
|
|
33
33
|
};
|
|
34
34
|
ModuleFE_XHR
|