@sap-ux/preview-middleware 0.13.18 → 0.13.19
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/base/flex.d.ts +5 -15
- package/dist/base/flex.js +4 -32
- package/dist/base/flp.d.ts +12 -2
- package/dist/base/flp.js +27 -5
- package/dist/client/adp/api-handler.js +141 -141
- package/dist/client/adp/command-executor.js +54 -54
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +185 -206
- package/dist/client/adp/controllers/AddFragment.controller.ts +5 -24
- package/dist/client/adp/controllers/BaseDialog.controller.js +74 -57
- package/dist/client/adp/controllers/BaseDialog.controller.ts +36 -2
- package/dist/client/adp/controllers/ControllerExtension.controller.js +179 -179
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +90 -100
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +9 -22
- package/dist/client/adp/init-dialogs.js +74 -74
- package/dist/client/adp/ui5-version-utils.js +63 -63
- package/dist/client/adp/utils.js +61 -33
- package/dist/client/adp/utils.ts +34 -0
- package/dist/client/cpe/changes/flex-change.js +51 -51
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +35 -35
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/nodes.js +84 -84
- package/dist/client/cpe/outline/utils.js +37 -37
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +49 -49
- package/dist/client/cpe/utils.js +48 -48
- package/dist/client/flp/WorkspaceConnector.js +84 -84
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +77 -77
- package/dist/client/flp/init.js +220 -220
- package/dist/client/flp/initConnectors.js +33 -33
- package/dist/client/flp/initRta.js +178 -178
- package/package.json +7 -3
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define([], function () {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
const CHANGES_API_PATH = '/preview/api/changes';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
|
|
10
|
-
* Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
|
|
11
|
-
*
|
|
12
|
-
* @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
|
|
13
|
-
*/
|
|
14
|
-
function getFlexSettings() {
|
|
15
|
-
let result;
|
|
16
|
-
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
17
|
-
const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
|
|
18
|
-
if (flexSetting) {
|
|
19
|
-
result = JSON.parse(flexSetting);
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
var __exports = {
|
|
24
|
-
__esModule: true
|
|
25
|
-
};
|
|
26
|
-
__exports.CHANGES_API_PATH = CHANGES_API_PATH;
|
|
27
|
-
__exports.getFlexSettings = getFlexSettings;
|
|
28
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define([], function () {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const CHANGES_API_PATH = '/preview/api/changes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves Flex settings from a 'sap-ui-bootstrap' element's data attribute.
|
|
10
|
+
* Parses the 'data-open-ux-preview-flex-settings' attribute as JSON.
|
|
11
|
+
*
|
|
12
|
+
* @returns {FlexSettings | undefined} The parsed Flex settings if available, otherwise undefined.
|
|
13
|
+
*/
|
|
14
|
+
function getFlexSettings() {
|
|
15
|
+
let result;
|
|
16
|
+
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
17
|
+
const flexSetting = bootstrapConfig?.getAttribute('data-open-ux-preview-flex-settings');
|
|
18
|
+
if (flexSetting) {
|
|
19
|
+
result = JSON.parse(flexSetting);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
var __exports = {
|
|
24
|
+
__esModule: true
|
|
25
|
+
};
|
|
26
|
+
__exports.CHANGES_API_PATH = CHANGES_API_PATH;
|
|
27
|
+
__exports.getFlexSettings = getFlexSettings;
|
|
28
|
+
return __exports;
|
|
29
29
|
});
|
|
30
30
|
//# sourceMappingURL=common.js.map
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./common"], function (LrepConnector, FakeLrepConnector, ___common) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
|
|
7
|
-
const getFlexSettings = ___common["getFlexSettings"];
|
|
8
|
-
/**
|
|
9
|
-
* Processes an array of FlexChange objects.
|
|
10
|
-
* It updates each change object with settings and sends them to a API endpoint.
|
|
11
|
-
*
|
|
12
|
-
* @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
|
|
13
|
-
* @returns {Promise<void>} A promise that resolves when all changes are processed.
|
|
14
|
-
*/
|
|
15
|
-
async function create(changes) {
|
|
16
|
-
const settings = getFlexSettings();
|
|
17
|
-
await Promise.all(changes.map(change => {
|
|
18
|
-
if (settings) {
|
|
19
|
-
change.support ??= {};
|
|
20
|
-
change.support.generator = settings.generator;
|
|
21
|
-
}
|
|
22
|
-
return fetch(CHANGES_API_PATH, {
|
|
23
|
-
method: 'POST',
|
|
24
|
-
body: JSON.stringify(change, null, 2),
|
|
25
|
-
headers: {
|
|
26
|
-
'content-type': 'application/json'
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Loads changes from a given path and processes them using an LrepConnector instance.
|
|
34
|
-
* The changes are then formatted and returned in a specified structure.
|
|
35
|
-
*
|
|
36
|
-
* @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
|
|
37
|
-
*/
|
|
38
|
-
async function loadChanges() {
|
|
39
|
-
const lrep = new LrepConnector();
|
|
40
|
-
const response = await fetch(CHANGES_API_PATH, {
|
|
41
|
-
method: 'GET',
|
|
42
|
-
headers: {
|
|
43
|
-
'content-type': 'application/json'
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const changes = await response.json();
|
|
47
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
-
args[_key] = arguments[_key];
|
|
49
|
-
}
|
|
50
|
-
return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
|
|
51
|
-
const flexChanges = Object.values(changes);
|
|
52
|
-
res.changes.changes = flexChanges;
|
|
53
|
-
return res;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Configures and enables the FakeLrepConnector based on the SAP UI5 version.
|
|
59
|
-
* If the minor version of the SAP UI5 is less than 72, this function extends
|
|
60
|
-
* the FakeLrepConnector's prototype with specific methods and enables the fake connector.
|
|
61
|
-
*
|
|
62
|
-
* Assumes the existence of a global 'sap' object with a 'ui.version' property,
|
|
63
|
-
* and global jQuery object with 'extend' method.
|
|
64
|
-
*
|
|
65
|
-
* @returns {void}
|
|
66
|
-
*/
|
|
67
|
-
var __exports = function () {
|
|
68
|
-
jQuery.extend(FakeLrepConnector.prototype, {
|
|
69
|
-
create,
|
|
70
|
-
loadChanges,
|
|
71
|
-
loadSettings: () => Promise.resolve()
|
|
72
|
-
});
|
|
73
|
-
FakeLrepConnector.enableFakeConnector();
|
|
74
|
-
};
|
|
75
|
-
__exports.create = create;
|
|
76
|
-
__exports.loadChanges = loadChanges;
|
|
77
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/ui/fl/LrepConnector", "sap/ui/fl/FakeLrepConnector", "./common"], function (LrepConnector, FakeLrepConnector, ___common) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
|
|
7
|
+
const getFlexSettings = ___common["getFlexSettings"];
|
|
8
|
+
/**
|
|
9
|
+
* Processes an array of FlexChange objects.
|
|
10
|
+
* It updates each change object with settings and sends them to a API endpoint.
|
|
11
|
+
*
|
|
12
|
+
* @param {FlexChange[]} changes - Array of FlexChange objects to be processed.
|
|
13
|
+
* @returns {Promise<void>} A promise that resolves when all changes are processed.
|
|
14
|
+
*/
|
|
15
|
+
async function create(changes) {
|
|
16
|
+
const settings = getFlexSettings();
|
|
17
|
+
await Promise.all(changes.map(change => {
|
|
18
|
+
if (settings) {
|
|
19
|
+
change.support ??= {};
|
|
20
|
+
change.support.generator = settings.generator;
|
|
21
|
+
}
|
|
22
|
+
return fetch(CHANGES_API_PATH, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
body: JSON.stringify(change, null, 2),
|
|
25
|
+
headers: {
|
|
26
|
+
'content-type': 'application/json'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Loads changes from a given path and processes them using an LrepConnector instance.
|
|
34
|
+
* The changes are then formatted and returned in a specified structure.
|
|
35
|
+
*
|
|
36
|
+
* @returns {Promise<LoadChangesResult>} A promise that resolves to an object of type LoadChangesResult.
|
|
37
|
+
*/
|
|
38
|
+
async function loadChanges() {
|
|
39
|
+
const lrep = new LrepConnector();
|
|
40
|
+
const response = await fetch(CHANGES_API_PATH, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: {
|
|
43
|
+
'content-type': 'application/json'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const changes = await response.json();
|
|
47
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
+
args[_key] = arguments[_key];
|
|
49
|
+
}
|
|
50
|
+
return LrepConnector.prototype.loadChanges.apply(lrep, args).then(res => {
|
|
51
|
+
const flexChanges = Object.values(changes);
|
|
52
|
+
res.changes.changes = flexChanges;
|
|
53
|
+
return res;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Configures and enables the FakeLrepConnector based on the SAP UI5 version.
|
|
59
|
+
* If the minor version of the SAP UI5 is less than 72, this function extends
|
|
60
|
+
* the FakeLrepConnector's prototype with specific methods and enables the fake connector.
|
|
61
|
+
*
|
|
62
|
+
* Assumes the existence of a global 'sap' object with a 'ui.version' property,
|
|
63
|
+
* and global jQuery object with 'extend' method.
|
|
64
|
+
*
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
var __exports = function () {
|
|
68
|
+
jQuery.extend(FakeLrepConnector.prototype, {
|
|
69
|
+
create,
|
|
70
|
+
loadChanges,
|
|
71
|
+
loadSettings: () => Promise.resolve()
|
|
72
|
+
});
|
|
73
|
+
FakeLrepConnector.enableFakeConnector();
|
|
74
|
+
};
|
|
75
|
+
__exports.create = create;
|
|
76
|
+
__exports.loadChanges = loadChanges;
|
|
77
|
+
return __exports;
|
|
78
78
|
});
|
|
79
79
|
//# sourceMappingURL=enableFakeConnector.js.map
|
package/dist/client/flp/init.js
CHANGED
|
@@ -1,222 +1,222 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBundle", "sap/base/util/UriParameters"], function (Log, IconPool, ResourceBundle, UriParameters) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
8
|
-
*/
|
|
9
|
-
const UI5_LIBS = ['sap.apf', 'sap.base', 'sap.chart', 'sap.collaboration', 'sap.f', 'sap.fe', 'sap.fileviewer', 'sap.gantt', 'sap.landvisz', 'sap.m', 'sap.ndc', 'sap.ovp', 'sap.rules', 'sap.suite', 'sap.tnt', 'sap.ui', 'sap.uiext', 'sap.ushell', 'sap.uxap', 'sap.viz', 'sap.webanalytics', 'sap.zen'];
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Check whether a specific dependency is a custom library, and if yes, add it to the map.
|
|
13
|
-
*
|
|
14
|
-
* @param dependency dependency from the manifest
|
|
15
|
-
* @param customLibs map containing the required custom libraries
|
|
16
|
-
*/
|
|
17
|
-
function addKeys(dependency, customLibs) {
|
|
18
|
-
Object.keys(dependency).forEach(function (key) {
|
|
19
|
-
// ignore libs or Components that start with SAPUI5 delivered namespaces
|
|
20
|
-
if (!UI5_LIBS.some(function (substring) {
|
|
21
|
-
return key === substring || key.startsWith(substring + '.');
|
|
22
|
-
})) {
|
|
23
|
-
customLibs[key] = true;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Fetch the manifest for all the given application urls and generate a string containing all required custom library ids.
|
|
30
|
-
*
|
|
31
|
-
* @param appUrls urls pointing to included applications
|
|
32
|
-
* @returns Promise of a comma separated list of all required libraries.
|
|
33
|
-
*/
|
|
34
|
-
function getManifestLibs(appUrls) {
|
|
35
|
-
const result = {};
|
|
36
|
-
const promises = [];
|
|
37
|
-
for (const url of appUrls) {
|
|
38
|
-
promises.push(fetch(`${url}/manifest.json`).then(async resp => {
|
|
39
|
-
const manifest = await resp.json();
|
|
40
|
-
if (manifest) {
|
|
41
|
-
if (manifest['sap.ui5'] && manifest['sap.ui5'].dependencies) {
|
|
42
|
-
if (manifest['sap.ui5'].dependencies.libs) {
|
|
43
|
-
addKeys(manifest['sap.ui5'].dependencies.libs, result);
|
|
44
|
-
}
|
|
45
|
-
if (manifest['sap.ui5'].dependencies.components) {
|
|
46
|
-
addKeys(manifest['sap.ui5'].dependencies.components, result);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (manifest['sap.ui5'] && manifest['sap.ui5'].componentUsages) {
|
|
50
|
-
addKeys(manifest['sap.ui5'].componentUsages, result);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
return Promise.all(promises).then(() => Object.keys(result).join(','));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Register the custom libraries and their url with the UI5 loader.
|
|
60
|
-
*
|
|
61
|
-
* @param dataFromAppIndex data returned from the app index service
|
|
62
|
-
*/
|
|
63
|
-
function registerModules(dataFromAppIndex) {
|
|
64
|
-
Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
|
|
65
|
-
const moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
|
|
66
|
-
if (moduleDefinition && moduleDefinition.dependencies) {
|
|
67
|
-
moduleDefinition.dependencies.forEach(function (dependency) {
|
|
68
|
-
if (dependency.url && dependency.url.length > 0 && dependency.type === 'UI5LIB') {
|
|
69
|
-
Log.info('Registering Library ' + dependency.componentId + ' from server ' + dependency.url);
|
|
70
|
-
const compId = dependency.componentId.replace(/\./g, '/');
|
|
71
|
-
const config = {
|
|
72
|
-
paths: {}
|
|
73
|
-
};
|
|
74
|
-
config.paths[compId] = dependency.url;
|
|
75
|
-
sap.ui.loader.config(config);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Fetch the manifest from the given application urls, then parse them for custom libs, and finally request their urls.
|
|
84
|
-
*
|
|
85
|
-
* @param appUrls application urls
|
|
86
|
-
* @returns returns a promise when the registration is completed.
|
|
87
|
-
*/
|
|
88
|
-
async function registerComponentDependencyPaths(appUrls) {
|
|
89
|
-
const libs = await getManifestLibs(appUrls);
|
|
90
|
-
if (libs && libs.length > 0) {
|
|
91
|
-
let url = '/sap/bc/ui2/app_index/ui5_app_info?id=' + libs;
|
|
92
|
-
const sapClient = UriParameters.fromQuery(window.location.search).get('sap-client');
|
|
93
|
-
if (sapClient && sapClient.length === 3) {
|
|
94
|
-
url = url + '&sap-client=' + sapClient;
|
|
95
|
-
}
|
|
96
|
-
const response = await fetch(url);
|
|
97
|
-
try {
|
|
98
|
-
registerModules(await response.json());
|
|
99
|
-
} catch (error) {
|
|
100
|
-
Log.error(`Registering of reuse libs failed. Error:${error}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Register SAP fonts that are also registered in a productive Fiori launchpad.
|
|
107
|
-
*/
|
|
108
|
-
function registerSAPFonts() {
|
|
109
|
-
//Fiori Theme font family and URI
|
|
110
|
-
const fioriTheme = {
|
|
111
|
-
fontFamily: 'SAP-icons-TNT',
|
|
112
|
-
fontURI: sap.ui.require.toUrl('sap/tnt/themes/base/fonts/')
|
|
113
|
-
};
|
|
114
|
-
//Registering to the icon pool
|
|
115
|
-
IconPool.registerFont(fioriTheme);
|
|
116
|
-
//SAP Business Suite Theme font family and URI
|
|
117
|
-
const suiteTheme = {
|
|
118
|
-
fontFamily: 'BusinessSuiteInAppSymbols',
|
|
119
|
-
fontURI: sap.ui.require.toUrl('sap/ushell/themes/base/fonts/')
|
|
120
|
-
};
|
|
121
|
-
//Registering to the icon pool
|
|
122
|
-
IconPool.registerFont(suiteTheme);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Read the application title from the resource bundle and set it as document title.
|
|
127
|
-
*
|
|
128
|
-
* @param i18nKey optional parameter to define the i18n key to be used for the title.
|
|
129
|
-
*/
|
|
130
|
-
function setI18nTitle() {
|
|
131
|
-
let i18nKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'appTitle';
|
|
132
|
-
const locale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
133
|
-
const resourceBundle = ResourceBundle.create({
|
|
134
|
-
url: 'i18n/i18n.properties',
|
|
135
|
-
locale
|
|
136
|
-
});
|
|
137
|
-
if (resourceBundle.hasText(i18nKey)) {
|
|
138
|
-
document.title = resourceBundle.getText(i18nKey) ?? document.title;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Apply additional configuration and initialize sandbox.
|
|
144
|
-
*
|
|
145
|
-
* @param params init parameters read from the script tag
|
|
146
|
-
* @param params.appUrls JSON containing a string array of application urls
|
|
147
|
-
* @param params.flex JSON containing the flex configuration
|
|
148
|
-
* @param params.customInit path to the custom init module to be called
|
|
149
|
-
* @returns promise
|
|
150
|
-
*/
|
|
151
|
-
async function init(_ref) {
|
|
152
|
-
let {
|
|
153
|
-
appUrls,
|
|
154
|
-
flex,
|
|
155
|
-
customInit
|
|
156
|
-
} = _ref;
|
|
157
|
-
// Register RTA if configured
|
|
158
|
-
if (flex) {
|
|
159
|
-
sap.ushell.Container.attachRendererCreatedEvent(async function () {
|
|
160
|
-
const lifecycleService = await sap.ushell.Container.getServiceAsync('AppLifeCycle');
|
|
161
|
-
lifecycleService.attachAppLoaded(event => {
|
|
162
|
-
const version = sap.ui.version;
|
|
163
|
-
const minor = parseInt(version.split('.')[1], 10);
|
|
164
|
-
const view = event.getParameter('componentInstance');
|
|
165
|
-
const flexSettings = JSON.parse(flex);
|
|
166
|
-
const pluginScript = flexSettings.pluginScript ?? '';
|
|
167
|
-
let libs = [];
|
|
168
|
-
if (minor > 71) {
|
|
169
|
-
libs.push('sap/ui/rta/api/startAdaptation');
|
|
170
|
-
} else {
|
|
171
|
-
libs.push('open/ux/preview/client/flp/initRta');
|
|
172
|
-
}
|
|
173
|
-
if (flexSettings.pluginScript) {
|
|
174
|
-
libs.push(pluginScript);
|
|
175
|
-
delete flexSettings.pluginScript;
|
|
176
|
-
}
|
|
177
|
-
const options = {
|
|
178
|
-
rootControl: view,
|
|
179
|
-
validateAppVersion: false,
|
|
180
|
-
flexSettings
|
|
181
|
-
};
|
|
182
|
-
sap.ui.require(libs, async function (startAdaptation, pluginScript) {
|
|
183
|
-
await startAdaptation(options, pluginScript);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Load custom library paths if configured
|
|
190
|
-
if (appUrls) {
|
|
191
|
-
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Load custom initialization module
|
|
195
|
-
if (customInit) {
|
|
196
|
-
sap.ui.require([customInit]);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// init
|
|
200
|
-
setI18nTitle();
|
|
201
|
-
registerSAPFonts();
|
|
202
|
-
const renderer = await sap.ushell.Container.createRenderer(undefined, true);
|
|
203
|
-
renderer.placeAt('content');
|
|
204
|
-
}
|
|
205
|
-
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
206
|
-
if (bootstrapConfig) {
|
|
207
|
-
init({
|
|
208
|
-
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
209
|
-
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings'),
|
|
210
|
-
customInit: bootstrapConfig.getAttribute('data-open-ux-preview-customInit')
|
|
211
|
-
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
212
|
-
}
|
|
213
|
-
var __exports = {
|
|
214
|
-
__esModule: true
|
|
215
|
-
};
|
|
216
|
-
__exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
|
|
217
|
-
__exports.registerSAPFonts = registerSAPFonts;
|
|
218
|
-
__exports.setI18nTitle = setI18nTitle;
|
|
219
|
-
__exports.init = init;
|
|
220
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/base/Log", "sap/ui/core/IconPool", "sap/base/i18n/ResourceBundle", "sap/base/util/UriParameters"], function (Log, IconPool, ResourceBundle, UriParameters) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
8
|
+
*/
|
|
9
|
+
const UI5_LIBS = ['sap.apf', 'sap.base', 'sap.chart', 'sap.collaboration', 'sap.f', 'sap.fe', 'sap.fileviewer', 'sap.gantt', 'sap.landvisz', 'sap.m', 'sap.ndc', 'sap.ovp', 'sap.rules', 'sap.suite', 'sap.tnt', 'sap.ui', 'sap.uiext', 'sap.ushell', 'sap.uxap', 'sap.viz', 'sap.webanalytics', 'sap.zen'];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check whether a specific dependency is a custom library, and if yes, add it to the map.
|
|
13
|
+
*
|
|
14
|
+
* @param dependency dependency from the manifest
|
|
15
|
+
* @param customLibs map containing the required custom libraries
|
|
16
|
+
*/
|
|
17
|
+
function addKeys(dependency, customLibs) {
|
|
18
|
+
Object.keys(dependency).forEach(function (key) {
|
|
19
|
+
// ignore libs or Components that start with SAPUI5 delivered namespaces
|
|
20
|
+
if (!UI5_LIBS.some(function (substring) {
|
|
21
|
+
return key === substring || key.startsWith(substring + '.');
|
|
22
|
+
})) {
|
|
23
|
+
customLibs[key] = true;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Fetch the manifest for all the given application urls and generate a string containing all required custom library ids.
|
|
30
|
+
*
|
|
31
|
+
* @param appUrls urls pointing to included applications
|
|
32
|
+
* @returns Promise of a comma separated list of all required libraries.
|
|
33
|
+
*/
|
|
34
|
+
function getManifestLibs(appUrls) {
|
|
35
|
+
const result = {};
|
|
36
|
+
const promises = [];
|
|
37
|
+
for (const url of appUrls) {
|
|
38
|
+
promises.push(fetch(`${url}/manifest.json`).then(async resp => {
|
|
39
|
+
const manifest = await resp.json();
|
|
40
|
+
if (manifest) {
|
|
41
|
+
if (manifest['sap.ui5'] && manifest['sap.ui5'].dependencies) {
|
|
42
|
+
if (manifest['sap.ui5'].dependencies.libs) {
|
|
43
|
+
addKeys(manifest['sap.ui5'].dependencies.libs, result);
|
|
44
|
+
}
|
|
45
|
+
if (manifest['sap.ui5'].dependencies.components) {
|
|
46
|
+
addKeys(manifest['sap.ui5'].dependencies.components, result);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (manifest['sap.ui5'] && manifest['sap.ui5'].componentUsages) {
|
|
50
|
+
addKeys(manifest['sap.ui5'].componentUsages, result);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
return Promise.all(promises).then(() => Object.keys(result).join(','));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Register the custom libraries and their url with the UI5 loader.
|
|
60
|
+
*
|
|
61
|
+
* @param dataFromAppIndex data returned from the app index service
|
|
62
|
+
*/
|
|
63
|
+
function registerModules(dataFromAppIndex) {
|
|
64
|
+
Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
|
|
65
|
+
const moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
|
|
66
|
+
if (moduleDefinition && moduleDefinition.dependencies) {
|
|
67
|
+
moduleDefinition.dependencies.forEach(function (dependency) {
|
|
68
|
+
if (dependency.url && dependency.url.length > 0 && dependency.type === 'UI5LIB') {
|
|
69
|
+
Log.info('Registering Library ' + dependency.componentId + ' from server ' + dependency.url);
|
|
70
|
+
const compId = dependency.componentId.replace(/\./g, '/');
|
|
71
|
+
const config = {
|
|
72
|
+
paths: {}
|
|
73
|
+
};
|
|
74
|
+
config.paths[compId] = dependency.url;
|
|
75
|
+
sap.ui.loader.config(config);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Fetch the manifest from the given application urls, then parse them for custom libs, and finally request their urls.
|
|
84
|
+
*
|
|
85
|
+
* @param appUrls application urls
|
|
86
|
+
* @returns returns a promise when the registration is completed.
|
|
87
|
+
*/
|
|
88
|
+
async function registerComponentDependencyPaths(appUrls) {
|
|
89
|
+
const libs = await getManifestLibs(appUrls);
|
|
90
|
+
if (libs && libs.length > 0) {
|
|
91
|
+
let url = '/sap/bc/ui2/app_index/ui5_app_info?id=' + libs;
|
|
92
|
+
const sapClient = UriParameters.fromQuery(window.location.search).get('sap-client');
|
|
93
|
+
if (sapClient && sapClient.length === 3) {
|
|
94
|
+
url = url + '&sap-client=' + sapClient;
|
|
95
|
+
}
|
|
96
|
+
const response = await fetch(url);
|
|
97
|
+
try {
|
|
98
|
+
registerModules(await response.json());
|
|
99
|
+
} catch (error) {
|
|
100
|
+
Log.error(`Registering of reuse libs failed. Error:${error}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Register SAP fonts that are also registered in a productive Fiori launchpad.
|
|
107
|
+
*/
|
|
108
|
+
function registerSAPFonts() {
|
|
109
|
+
//Fiori Theme font family and URI
|
|
110
|
+
const fioriTheme = {
|
|
111
|
+
fontFamily: 'SAP-icons-TNT',
|
|
112
|
+
fontURI: sap.ui.require.toUrl('sap/tnt/themes/base/fonts/')
|
|
113
|
+
};
|
|
114
|
+
//Registering to the icon pool
|
|
115
|
+
IconPool.registerFont(fioriTheme);
|
|
116
|
+
//SAP Business Suite Theme font family and URI
|
|
117
|
+
const suiteTheme = {
|
|
118
|
+
fontFamily: 'BusinessSuiteInAppSymbols',
|
|
119
|
+
fontURI: sap.ui.require.toUrl('sap/ushell/themes/base/fonts/')
|
|
120
|
+
};
|
|
121
|
+
//Registering to the icon pool
|
|
122
|
+
IconPool.registerFont(suiteTheme);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Read the application title from the resource bundle and set it as document title.
|
|
127
|
+
*
|
|
128
|
+
* @param i18nKey optional parameter to define the i18n key to be used for the title.
|
|
129
|
+
*/
|
|
130
|
+
function setI18nTitle() {
|
|
131
|
+
let i18nKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'appTitle';
|
|
132
|
+
const locale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
133
|
+
const resourceBundle = ResourceBundle.create({
|
|
134
|
+
url: 'i18n/i18n.properties',
|
|
135
|
+
locale
|
|
136
|
+
});
|
|
137
|
+
if (resourceBundle.hasText(i18nKey)) {
|
|
138
|
+
document.title = resourceBundle.getText(i18nKey) ?? document.title;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Apply additional configuration and initialize sandbox.
|
|
144
|
+
*
|
|
145
|
+
* @param params init parameters read from the script tag
|
|
146
|
+
* @param params.appUrls JSON containing a string array of application urls
|
|
147
|
+
* @param params.flex JSON containing the flex configuration
|
|
148
|
+
* @param params.customInit path to the custom init module to be called
|
|
149
|
+
* @returns promise
|
|
150
|
+
*/
|
|
151
|
+
async function init(_ref) {
|
|
152
|
+
let {
|
|
153
|
+
appUrls,
|
|
154
|
+
flex,
|
|
155
|
+
customInit
|
|
156
|
+
} = _ref;
|
|
157
|
+
// Register RTA if configured
|
|
158
|
+
if (flex) {
|
|
159
|
+
sap.ushell.Container.attachRendererCreatedEvent(async function () {
|
|
160
|
+
const lifecycleService = await sap.ushell.Container.getServiceAsync('AppLifeCycle');
|
|
161
|
+
lifecycleService.attachAppLoaded(event => {
|
|
162
|
+
const version = sap.ui.version;
|
|
163
|
+
const minor = parseInt(version.split('.')[1], 10);
|
|
164
|
+
const view = event.getParameter('componentInstance');
|
|
165
|
+
const flexSettings = JSON.parse(flex);
|
|
166
|
+
const pluginScript = flexSettings.pluginScript ?? '';
|
|
167
|
+
let libs = [];
|
|
168
|
+
if (minor > 71) {
|
|
169
|
+
libs.push('sap/ui/rta/api/startAdaptation');
|
|
170
|
+
} else {
|
|
171
|
+
libs.push('open/ux/preview/client/flp/initRta');
|
|
172
|
+
}
|
|
173
|
+
if (flexSettings.pluginScript) {
|
|
174
|
+
libs.push(pluginScript);
|
|
175
|
+
delete flexSettings.pluginScript;
|
|
176
|
+
}
|
|
177
|
+
const options = {
|
|
178
|
+
rootControl: view,
|
|
179
|
+
validateAppVersion: false,
|
|
180
|
+
flexSettings
|
|
181
|
+
};
|
|
182
|
+
sap.ui.require(libs, async function (startAdaptation, pluginScript) {
|
|
183
|
+
await startAdaptation(options, pluginScript);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Load custom library paths if configured
|
|
190
|
+
if (appUrls) {
|
|
191
|
+
await registerComponentDependencyPaths(JSON.parse(appUrls));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Load custom initialization module
|
|
195
|
+
if (customInit) {
|
|
196
|
+
sap.ui.require([customInit]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// init
|
|
200
|
+
setI18nTitle();
|
|
201
|
+
registerSAPFonts();
|
|
202
|
+
const renderer = await sap.ushell.Container.createRenderer(undefined, true);
|
|
203
|
+
renderer.placeAt('content');
|
|
204
|
+
}
|
|
205
|
+
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
|
206
|
+
if (bootstrapConfig) {
|
|
207
|
+
init({
|
|
208
|
+
appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
|
|
209
|
+
flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings'),
|
|
210
|
+
customInit: bootstrapConfig.getAttribute('data-open-ux-preview-customInit')
|
|
211
|
+
}).catch(() => Log.error('Sandbox initialization failed.'));
|
|
212
|
+
}
|
|
213
|
+
var __exports = {
|
|
214
|
+
__esModule: true
|
|
215
|
+
};
|
|
216
|
+
__exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
|
|
217
|
+
__exports.registerSAPFonts = registerSAPFonts;
|
|
218
|
+
__exports.setI18nTitle = setI18nTitle;
|
|
219
|
+
__exports.init = init;
|
|
220
|
+
return __exports;
|
|
221
221
|
});
|
|
222
222
|
//# sourceMappingURL=init.js.map
|