@sap-ux/preview-middleware 0.13.22 → 0.13.24
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/dist/client/flp/init.js +33 -9
- package/dist/client/flp/init.ts +34 -10
- package/package.json +4 -4
package/dist/client/flp/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBundle"
|
|
3
|
+
sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBundle"], function (Log, IconPool, ResourceBundle) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -31,7 +31,7 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
31
31
|
* @param appUrls urls pointing to included applications
|
|
32
32
|
* @returns Promise of a comma separated list of all required libraries.
|
|
33
33
|
*/
|
|
34
|
-
function getManifestLibs(appUrls) {
|
|
34
|
+
async function getManifestLibs(appUrls) {
|
|
35
35
|
const result = {};
|
|
36
36
|
const promises = [];
|
|
37
37
|
for (const url of appUrls) {
|
|
@@ -79,17 +79,32 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Fetch the app state from the given application urls, then reset the app state.
|
|
84
|
+
*
|
|
85
|
+
* @param container the UShell container
|
|
86
|
+
*/
|
|
87
|
+
async function resetAppState(container) {
|
|
88
|
+
const appStateService = await container.getServiceAsync('AppState');
|
|
89
|
+
const urlParams = new URLSearchParams(window.location.hash);
|
|
90
|
+
const appStateValue = urlParams.get('sap-iapp-state') ?? urlParams.get('/?sap-iapp-state');
|
|
91
|
+
if (appStateValue) {
|
|
92
|
+
appStateService.deleteAppState(appStateValue);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
/**
|
|
83
97
|
* Fetch the manifest from the given application urls, then parse them for custom libs, and finally request their urls.
|
|
84
98
|
*
|
|
85
99
|
* @param appUrls application urls
|
|
100
|
+
* @param urlParams URLSearchParams object
|
|
86
101
|
* @returns returns a promise when the registration is completed.
|
|
87
102
|
*/
|
|
88
|
-
async function registerComponentDependencyPaths(appUrls) {
|
|
103
|
+
async function registerComponentDependencyPaths(appUrls, urlParams) {
|
|
89
104
|
const libs = await getManifestLibs(appUrls);
|
|
90
105
|
if (libs && libs.length > 0) {
|
|
91
106
|
let url = '/sap/bc/ui2/app_index/ui5_app_info?id=' + libs;
|
|
92
|
-
const sapClient =
|
|
107
|
+
const sapClient = urlParams.get('sap-client');
|
|
93
108
|
if (sapClient && sapClient.length === 3) {
|
|
94
109
|
url = url + '&sap-client=' + sapClient;
|
|
95
110
|
}
|
|
@@ -129,7 +144,8 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
129
144
|
*/
|
|
130
145
|
function setI18nTitle() {
|
|
131
146
|
let i18nKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'appTitle';
|
|
132
|
-
const
|
|
147
|
+
const localization = sap.ui.require('sap/base/i18n/Localization') ?? sap.ui.getCore().getConfiguration();
|
|
148
|
+
const locale = localization.getLanguage();
|
|
133
149
|
const resourceBundle = ResourceBundle.create({
|
|
134
150
|
url: 'i18n/i18n.properties',
|
|
135
151
|
locale
|
|
@@ -154,10 +170,12 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
154
170
|
flex,
|
|
155
171
|
customInit
|
|
156
172
|
} = _ref;
|
|
173
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
174
|
+
const container = sap?.ushell?.Container ?? sap.ui.require('sap/ushell/Container');
|
|
157
175
|
// Register RTA if configured
|
|
158
176
|
if (flex) {
|
|
159
|
-
|
|
160
|
-
const lifecycleService = await
|
|
177
|
+
container.attachRendererCreatedEvent(async function () {
|
|
178
|
+
const lifecycleService = await container.getServiceAsync('AppLifeCycle');
|
|
161
179
|
lifecycleService.attachAppLoaded(event => {
|
|
162
180
|
const version = sap.ui.version;
|
|
163
181
|
const minor = parseInt(version.split('.')[1], 10);
|
|
@@ -186,9 +204,14 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
186
204
|
});
|
|
187
205
|
}
|
|
188
206
|
|
|
207
|
+
// reset app state if requested
|
|
208
|
+
if (urlParams.get('fiori-tools-iapp-state')?.toLocaleLowerCase() !== 'true') {
|
|
209
|
+
await resetAppState(container);
|
|
210
|
+
}
|
|
211
|
+
|
|
189
212
|
// Load custom library paths if configured
|
|
190
213
|
if (appUrls) {
|
|
191
|
-
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
214
|
+
await registerComponentDependencyPaths(JSON.parse(appUrls), urlParams);
|
|
192
215
|
}
|
|
193
216
|
|
|
194
217
|
// Load custom initialization module
|
|
@@ -199,7 +222,7 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
199
222
|
// init
|
|
200
223
|
setI18nTitle();
|
|
201
224
|
registerSAPFonts();
|
|
202
|
-
const renderer = await
|
|
225
|
+
const renderer = await container.createRenderer(undefined, true);
|
|
203
226
|
renderer.placeAt('content');
|
|
204
227
|
}
|
|
205
228
|
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
@@ -213,6 +236,7 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
213
236
|
var __exports = {
|
|
214
237
|
__esModule: true
|
|
215
238
|
};
|
|
239
|
+
__exports.resetAppState = resetAppState;
|
|
216
240
|
__exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
|
|
217
241
|
__exports.registerSAPFonts = registerSAPFonts;
|
|
218
242
|
__exports.setI18nTitle = setI18nTitle;
|
package/dist/client/flp/init.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type { InitRtaScript, RTAPlugin, StartAdaptation } from 'sap/ui/rta/api/s
|
|
|
4
4
|
import type { RTAOptions } from 'sap/ui/rta/RuntimeAuthoring';
|
|
5
5
|
import IconPool from 'sap/ui/core/IconPool';
|
|
6
6
|
import ResourceBundle from 'sap/base/i18n/ResourceBundle';
|
|
7
|
-
import
|
|
8
|
-
|
|
7
|
+
import AppState from 'sap/ushell/services/AppState';
|
|
8
|
+
import type Localization from 'sap/base/i18n/Localization';
|
|
9
9
|
/**
|
|
10
10
|
* SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
11
11
|
*/
|
|
@@ -59,7 +59,7 @@ function addKeys(dependency: Record<string, unknown>, customLibs: Record<string,
|
|
|
59
59
|
* @param appUrls urls pointing to included applications
|
|
60
60
|
* @returns Promise of a comma separated list of all required libraries.
|
|
61
61
|
*/
|
|
62
|
-
function getManifestLibs(appUrls: string[]): Promise<string> {
|
|
62
|
+
async function getManifestLibs(appUrls: string[]): Promise<string> {
|
|
63
63
|
const result = {} as Record<string, true>;
|
|
64
64
|
const promises = [];
|
|
65
65
|
for (const url of appUrls) {
|
|
@@ -120,17 +120,32 @@ function registerModules(
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Fetch the app state from the given application urls, then reset the app state.
|
|
125
|
+
*
|
|
126
|
+
* @param container the UShell container
|
|
127
|
+
*/
|
|
128
|
+
export async function resetAppState(container: typeof sap.ushell.Container): Promise<void> {
|
|
129
|
+
const appStateService = await container.getServiceAsync<AppState>('AppState');
|
|
130
|
+
const urlParams = new URLSearchParams(window.location.hash);
|
|
131
|
+
const appStateValue = urlParams.get('sap-iapp-state') ?? urlParams.get('/?sap-iapp-state');
|
|
132
|
+
if (appStateValue) {
|
|
133
|
+
appStateService.deleteAppState(appStateValue);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
123
137
|
/**
|
|
124
138
|
* Fetch the manifest from the given application urls, then parse them for custom libs, and finally request their urls.
|
|
125
139
|
*
|
|
126
140
|
* @param appUrls application urls
|
|
141
|
+
* @param urlParams URLSearchParams object
|
|
127
142
|
* @returns returns a promise when the registration is completed.
|
|
128
143
|
*/
|
|
129
|
-
export async function registerComponentDependencyPaths(appUrls: string[]): Promise<void> {
|
|
144
|
+
export async function registerComponentDependencyPaths(appUrls: string[], urlParams: URLSearchParams): Promise<void> {
|
|
130
145
|
const libs = await getManifestLibs(appUrls);
|
|
131
146
|
if (libs && libs.length > 0) {
|
|
132
147
|
let url = '/sap/bc/ui2/app_index/ui5_app_info?id=' + libs;
|
|
133
|
-
const sapClient =
|
|
148
|
+
const sapClient = urlParams.get('sap-client');
|
|
134
149
|
if (sapClient && sapClient.length === 3) {
|
|
135
150
|
url = url + '&sap-client=' + sapClient;
|
|
136
151
|
}
|
|
@@ -169,7 +184,9 @@ export function registerSAPFonts() {
|
|
|
169
184
|
* @param i18nKey optional parameter to define the i18n key to be used for the title.
|
|
170
185
|
*/
|
|
171
186
|
export function setI18nTitle(i18nKey = 'appTitle') {
|
|
172
|
-
const
|
|
187
|
+
const localization =
|
|
188
|
+
(sap.ui.require('sap/base/i18n/Localization') as Localization) ?? sap.ui.getCore().getConfiguration();
|
|
189
|
+
const locale = localization.getLanguage();
|
|
173
190
|
const resourceBundle = ResourceBundle.create({
|
|
174
191
|
url: 'i18n/i18n.properties',
|
|
175
192
|
locale
|
|
@@ -197,10 +214,12 @@ export async function init({
|
|
|
197
214
|
flex?: string | null;
|
|
198
215
|
customInit?: string | null;
|
|
199
216
|
}): Promise<void> {
|
|
217
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
218
|
+
const container = sap?.ushell?.Container ?? (sap.ui.require('sap/ushell/Container') as typeof sap.ushell.Container);
|
|
200
219
|
// Register RTA if configured
|
|
201
220
|
if (flex) {
|
|
202
|
-
|
|
203
|
-
const lifecycleService = await
|
|
221
|
+
container.attachRendererCreatedEvent(async function () {
|
|
222
|
+
const lifecycleService = await container.getServiceAsync<AppLifeCycle>('AppLifeCycle');
|
|
204
223
|
lifecycleService.attachAppLoaded((event) => {
|
|
205
224
|
const version = sap.ui.version;
|
|
206
225
|
const minor = parseInt(version.split('.')[1], 10);
|
|
@@ -236,9 +255,14 @@ export async function init({
|
|
|
236
255
|
});
|
|
237
256
|
}
|
|
238
257
|
|
|
258
|
+
// reset app state if requested
|
|
259
|
+
if (urlParams.get('fiori-tools-iapp-state')?.toLocaleLowerCase() !== 'true') {
|
|
260
|
+
await resetAppState(container);
|
|
261
|
+
}
|
|
262
|
+
|
|
239
263
|
// Load custom library paths if configured
|
|
240
264
|
if (appUrls) {
|
|
241
|
-
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
265
|
+
await registerComponentDependencyPaths(JSON.parse(appUrls), urlParams);
|
|
242
266
|
}
|
|
243
267
|
|
|
244
268
|
// Load custom initialization module
|
|
@@ -249,7 +273,7 @@ export async function init({
|
|
|
249
273
|
// init
|
|
250
274
|
setI18nTitle();
|
|
251
275
|
registerSAPFonts();
|
|
252
|
-
const renderer = await
|
|
276
|
+
const renderer = await container.createRenderer(undefined, true);
|
|
253
277
|
renderer.placeAt('content');
|
|
254
278
|
}
|
|
255
279
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.13.
|
|
12
|
+
"version": "0.13.24",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"mem-fs": "2.1.0",
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"@sap-ux/logger": "0.5.1",
|
|
29
|
-
"@sap-ux/adp-tooling": "0.9.
|
|
29
|
+
"@sap-ux/adp-tooling": "0.9.23",
|
|
30
30
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.17",
|
|
31
|
-
"@sap-ux/project-access": "1.19.
|
|
31
|
+
"@sap-ux/project-access": "1.19.14"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/ejs": "3.1.2",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"supertest": "6.3.3",
|
|
45
45
|
"@sap-ux-private/playwright": "0.0.3",
|
|
46
46
|
"dotenv": "16.3.1",
|
|
47
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.8",
|
|
47
48
|
"@sap-ux/axios-extension": "1.11.7",
|
|
48
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.7",
|
|
49
49
|
"@sap-ux/store": "0.5.0",
|
|
50
50
|
"@sap-ux/i18n": "0.0.6"
|
|
51
51
|
},
|