@sap-ux/preview-middleware 0.6.1 → 0.6.2
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 +23 -24
- package/dist/client/flp/init.ts +23 -26
- package/package.json +2 -2
package/dist/client/flp/init.js
CHANGED
|
@@ -110,35 +110,40 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
110
110
|
//Registering to the icon pool
|
|
111
111
|
IconPool.registerFont(fioriTheme);
|
|
112
112
|
//SAP Business Suite Theme font family and URI
|
|
113
|
-
const
|
|
113
|
+
const suiteTheme = {
|
|
114
114
|
fontFamily: 'BusinessSuiteInAppSymbols',
|
|
115
115
|
fontURI: sap.ui.require.toUrl('sap/ushell/themes/base/fonts/')
|
|
116
116
|
};
|
|
117
117
|
//Registering to the icon pool
|
|
118
|
-
IconPool.registerFont(
|
|
118
|
+
IconPool.registerFont(suiteTheme);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Read the application title from the resource bundle and set it as document title.
|
|
123
|
+
*
|
|
124
|
+
* @param i18nKey optional parameter to define the i18n key to be used for the title.
|
|
123
125
|
*/
|
|
124
126
|
function setI18nTitle() {
|
|
127
|
+
let i18nKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'appTitle';
|
|
125
128
|
const locale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
126
129
|
const resourceBundle = ResourceBundle.create({
|
|
127
130
|
url: 'i18n/i18n.properties',
|
|
128
131
|
locale
|
|
129
132
|
});
|
|
130
|
-
|
|
133
|
+
if (resourceBundle.hasText(i18nKey)) {
|
|
134
|
+
document.title = resourceBundle.getText(i18nKey) ?? document.title;
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
/**
|
|
134
|
-
* Apply additional configuration.
|
|
139
|
+
* Apply additional configuration and initialize sandbox.
|
|
135
140
|
*
|
|
136
141
|
* @param params init parameters read from the script tag
|
|
137
142
|
* @param params.appUrls JSON containing a string array of application urls
|
|
138
143
|
* @param params.flex JSON containing the flex configuration
|
|
139
144
|
* @returns promise
|
|
140
145
|
*/
|
|
141
|
-
function
|
|
146
|
+
async function init(_ref) {
|
|
142
147
|
let {
|
|
143
148
|
appUrls,
|
|
144
149
|
flex
|
|
@@ -146,18 +151,18 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
146
151
|
// Register RTA if configured
|
|
147
152
|
if (flex) {
|
|
148
153
|
sap.ushell.Container.attachRendererCreatedEvent(async function () {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
const
|
|
154
|
+
const lifecycleService = await sap.ushell.Container.getServiceAsync('AppLifeCycle');
|
|
155
|
+
lifecycleService.attachAppLoaded(event => {
|
|
156
|
+
const view = event.getParameter('componentInstance');
|
|
157
|
+
const libs = ['sap/ui/rta/api/startAdaptation'];
|
|
153
158
|
const flexSettings = JSON.parse(flex);
|
|
154
159
|
if (flexSettings.pluginScript) {
|
|
155
|
-
|
|
160
|
+
libs.push(flexSettings.pluginScript);
|
|
156
161
|
delete flexSettings.pluginScript;
|
|
157
162
|
}
|
|
158
|
-
sap.ui.require(
|
|
163
|
+
sap.ui.require(libs, function (startAdaptation, pluginScript) {
|
|
159
164
|
const options = {
|
|
160
|
-
rootControl:
|
|
165
|
+
rootControl: view,
|
|
161
166
|
validateAppVersion: false,
|
|
162
167
|
flexSettings
|
|
163
168
|
};
|
|
@@ -169,26 +174,21 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
169
174
|
|
|
170
175
|
// Load custom library paths if configured
|
|
171
176
|
if (appUrls) {
|
|
172
|
-
|
|
173
|
-
} else {
|
|
174
|
-
return Promise.resolve();
|
|
177
|
+
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
175
178
|
}
|
|
176
|
-
}
|
|
177
179
|
|
|
178
|
-
|
|
179
|
-
* Initialize the FLP sandbox.
|
|
180
|
-
*/
|
|
181
|
-
function init() {
|
|
180
|
+
// init
|
|
182
181
|
setI18nTitle();
|
|
183
182
|
registerSAPFonts();
|
|
184
|
-
sap.ushell.Container.createRenderer()
|
|
183
|
+
const renderer = await sap.ushell.Container.createRenderer(true);
|
|
184
|
+
renderer.placeAt('content');
|
|
185
185
|
}
|
|
186
186
|
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
187
187
|
if (bootstrapConfig) {
|
|
188
|
-
|
|
188
|
+
init({
|
|
189
189
|
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
190
190
|
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
|
|
191
|
-
}).
|
|
191
|
+
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
192
192
|
}
|
|
193
193
|
var __exports = {
|
|
194
194
|
__esModule: true
|
|
@@ -196,7 +196,6 @@ sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBu
|
|
|
196
196
|
__exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
|
|
197
197
|
__exports.registerSAPFonts = registerSAPFonts;
|
|
198
198
|
__exports.setI18nTitle = setI18nTitle;
|
|
199
|
-
__exports.configure = configure;
|
|
200
199
|
__exports.init = init;
|
|
201
200
|
return __exports;
|
|
202
201
|
});
|
package/dist/client/flp/init.ts
CHANGED
|
@@ -150,50 +150,54 @@ export function registerSAPFonts() {
|
|
|
150
150
|
//Registering to the icon pool
|
|
151
151
|
IconPool.registerFont(fioriTheme);
|
|
152
152
|
//SAP Business Suite Theme font family and URI
|
|
153
|
-
const
|
|
153
|
+
const suiteTheme = {
|
|
154
154
|
fontFamily: 'BusinessSuiteInAppSymbols',
|
|
155
155
|
fontURI: sap.ui.require.toUrl('sap/ushell/themes/base/fonts/')
|
|
156
156
|
};
|
|
157
157
|
//Registering to the icon pool
|
|
158
|
-
IconPool.registerFont(
|
|
158
|
+
IconPool.registerFont(suiteTheme);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Read the application title from the resource bundle and set it as document title.
|
|
163
|
+
*
|
|
164
|
+
* @param i18nKey optional parameter to define the i18n key to be used for the title.
|
|
163
165
|
*/
|
|
164
|
-
export function setI18nTitle() {
|
|
166
|
+
export function setI18nTitle(i18nKey = 'appTitle') {
|
|
165
167
|
const locale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
166
168
|
const resourceBundle = ResourceBundle.create({
|
|
167
169
|
url: 'i18n/i18n.properties',
|
|
168
170
|
locale
|
|
169
171
|
}) as ResourceBundle;
|
|
170
|
-
|
|
172
|
+
if (resourceBundle.hasText(i18nKey)) {
|
|
173
|
+
document.title = resourceBundle.getText(i18nKey) ?? document.title;
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
|
|
173
177
|
/**
|
|
174
|
-
* Apply additional configuration.
|
|
178
|
+
* Apply additional configuration and initialize sandbox.
|
|
175
179
|
*
|
|
176
180
|
* @param params init parameters read from the script tag
|
|
177
181
|
* @param params.appUrls JSON containing a string array of application urls
|
|
178
182
|
* @param params.flex JSON containing the flex configuration
|
|
179
183
|
* @returns promise
|
|
180
184
|
*/
|
|
181
|
-
export function
|
|
185
|
+
export async function init({ appUrls, flex }: { appUrls?: string | null; flex?: string | null }): Promise<void> {
|
|
182
186
|
// Register RTA if configured
|
|
183
187
|
if (flex) {
|
|
184
188
|
sap.ushell.Container.attachRendererCreatedEvent(async function () {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
+
const lifecycleService = await sap.ushell.Container.getServiceAsync<AppLifeCycle>('AppLifeCycle');
|
|
190
|
+
lifecycleService.attachAppLoaded(event => {
|
|
191
|
+
const view = event.getParameter('componentInstance');
|
|
192
|
+
const libs = ['sap/ui/rta/api/startAdaptation'];
|
|
189
193
|
const flexSettings = JSON.parse(flex);
|
|
190
194
|
if (flexSettings.pluginScript) {
|
|
191
|
-
|
|
195
|
+
libs.push(flexSettings.pluginScript);
|
|
192
196
|
delete flexSettings.pluginScript;
|
|
193
197
|
}
|
|
194
|
-
sap.ui.require(
|
|
198
|
+
sap.ui.require(libs, function (startAdaptation: StartAdaptation, pluginScript?: RTAPlugin) {
|
|
195
199
|
const options = {
|
|
196
|
-
rootControl:
|
|
200
|
+
rootControl:view,
|
|
197
201
|
validateAppVersion: false,
|
|
198
202
|
flexSettings
|
|
199
203
|
};
|
|
@@ -205,27 +209,20 @@ export function configure({ appUrls, flex }: { appUrls?: string | null; flex?: s
|
|
|
205
209
|
|
|
206
210
|
// Load custom library paths if configured
|
|
207
211
|
if (appUrls) {
|
|
208
|
-
|
|
209
|
-
} else {
|
|
210
|
-
return Promise.resolve();
|
|
212
|
+
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
211
213
|
}
|
|
212
|
-
}
|
|
213
214
|
|
|
214
|
-
|
|
215
|
-
* Initialize the FLP sandbox.
|
|
216
|
-
*/
|
|
217
|
-
export function init() {
|
|
215
|
+
// init
|
|
218
216
|
setI18nTitle();
|
|
219
217
|
registerSAPFonts();
|
|
220
|
-
sap.ushell.Container.createRenderer()
|
|
218
|
+
const renderer = await sap.ushell.Container.createRenderer(true);
|
|
219
|
+
renderer.placeAt('content');
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
224
223
|
if (bootstrapConfig) {
|
|
225
|
-
|
|
224
|
+
init({
|
|
226
225
|
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
227
226
|
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
|
|
228
|
-
})
|
|
229
|
-
.then(init)
|
|
230
|
-
.catch(() => Log.error('Sandbox initialization failed.'));
|
|
227
|
+
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
231
228
|
}
|
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.6.
|
|
12
|
+
"version": "0.6.2",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"express": "4.18.2",
|
|
37
37
|
"nock": "13.2.1",
|
|
38
38
|
"supertest": "6.3.3",
|
|
39
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.2.
|
|
39
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.2.1",
|
|
40
40
|
"@sap-ux/project-access": "1.13.6",
|
|
41
41
|
"@sap-ux/store": "0.3.14"
|
|
42
42
|
},
|