@sap-ux/preview-middleware 0.12.4 → 0.12.6

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.
Files changed (30) hide show
  1. package/README.md +9 -0
  2. package/dist/base/flp.js +3 -10
  3. package/dist/client/adp/api-handler.js +141 -141
  4. package/dist/client/adp/command-executor.js +54 -54
  5. package/dist/client/adp/control-utils.js +44 -44
  6. package/dist/client/adp/controllers/AddFragment.controller.js +206 -206
  7. package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
  8. package/dist/client/adp/controllers/ControllerExtension.controller.js +174 -174
  9. package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
  10. package/dist/client/adp/init-dialogs.js +74 -74
  11. package/dist/client/adp/ui5-version-utils.js +63 -63
  12. package/dist/client/adp/utils.js +33 -33
  13. package/dist/client/cpe/changes/flex-change.js +51 -51
  14. package/dist/client/cpe/changes/index.js +10 -10
  15. package/dist/client/cpe/changes/validator.js +35 -35
  16. package/dist/client/cpe/documentation.js +164 -164
  17. package/dist/client/cpe/logger.js +30 -30
  18. package/dist/client/cpe/outline/nodes.js +84 -84
  19. package/dist/client/cpe/outline/utils.js +37 -37
  20. package/dist/client/cpe/types.js +4 -4
  21. package/dist/client/cpe/ui5-utils.js +49 -49
  22. package/dist/client/cpe/utils.js +48 -48
  23. package/dist/client/flp/WorkspaceConnector.js +69 -69
  24. package/dist/client/flp/common.js +28 -28
  25. package/dist/client/flp/enableFakeConnector.js +77 -77
  26. package/dist/client/flp/init.js +212 -212
  27. package/dist/client/flp/initConnectors.js +33 -33
  28. package/dist/client/flp/initRta.js +178 -178
  29. package/package.json +3 -3
  30. package/templates/flp/editor.html +1 -0
@@ -1,214 +1,214 @@
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
- * @returns promise
149
- */
150
- async function init(_ref) {
151
- let {
152
- appUrls,
153
- flex
154
- } = _ref;
155
- // Register RTA if configured
156
- if (flex) {
157
- sap.ushell.Container.attachRendererCreatedEvent(async function () {
158
- const lifecycleService = await sap.ushell.Container.getServiceAsync('AppLifeCycle');
159
- lifecycleService.attachAppLoaded(event => {
160
- const version = sap.ui.version;
161
- const minor = parseInt(version.split('.')[1], 10);
162
- const view = event.getParameter('componentInstance');
163
- const flexSettings = JSON.parse(flex);
164
- const pluginScript = flexSettings.pluginScript ?? '';
165
- let libs = [];
166
- if (minor > 71) {
167
- libs.push('sap/ui/rta/api/startAdaptation');
168
- } else {
169
- libs.push('open/ux/preview/client/flp/initRta');
170
- }
171
- if (flexSettings.pluginScript) {
172
- libs.push(pluginScript);
173
- delete flexSettings.pluginScript;
174
- }
175
- const options = {
176
- rootControl: view,
177
- validateAppVersion: false,
178
- flexSettings
179
- };
180
- sap.ui.require(libs, async function (startAdaptation, pluginScript) {
181
- await startAdaptation(options, pluginScript);
182
- });
183
- });
184
- });
185
- }
186
-
187
- // Load custom library paths if configured
188
- if (appUrls) {
189
- await registerComponentDependencyPaths(JSON.parse(appUrls));
190
- }
191
-
192
- // init
193
- setI18nTitle();
194
- registerSAPFonts();
195
- const renderer = await sap.ushell.Container.createRenderer(undefined, true);
196
- renderer.placeAt('content');
197
- }
198
- const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
199
- if (bootstrapConfig) {
200
- init({
201
- appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
202
- flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
203
- }).catch(() => Log.error('Sandbox initialization failed.'));
204
- }
205
- var __exports = {
206
- __esModule: true
207
- };
208
- __exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
209
- __exports.registerSAPFonts = registerSAPFonts;
210
- __exports.setI18nTitle = setI18nTitle;
211
- __exports.init = init;
212
- 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
+ * @returns promise
149
+ */
150
+ async function init(_ref) {
151
+ let {
152
+ appUrls,
153
+ flex
154
+ } = _ref;
155
+ // Register RTA if configured
156
+ if (flex) {
157
+ sap.ushell.Container.attachRendererCreatedEvent(async function () {
158
+ const lifecycleService = await sap.ushell.Container.getServiceAsync('AppLifeCycle');
159
+ lifecycleService.attachAppLoaded(event => {
160
+ const version = sap.ui.version;
161
+ const minor = parseInt(version.split('.')[1], 10);
162
+ const view = event.getParameter('componentInstance');
163
+ const flexSettings = JSON.parse(flex);
164
+ const pluginScript = flexSettings.pluginScript ?? '';
165
+ let libs = [];
166
+ if (minor > 71) {
167
+ libs.push('sap/ui/rta/api/startAdaptation');
168
+ } else {
169
+ libs.push('open/ux/preview/client/flp/initRta');
170
+ }
171
+ if (flexSettings.pluginScript) {
172
+ libs.push(pluginScript);
173
+ delete flexSettings.pluginScript;
174
+ }
175
+ const options = {
176
+ rootControl: view,
177
+ validateAppVersion: false,
178
+ flexSettings
179
+ };
180
+ sap.ui.require(libs, async function (startAdaptation, pluginScript) {
181
+ await startAdaptation(options, pluginScript);
182
+ });
183
+ });
184
+ });
185
+ }
186
+
187
+ // Load custom library paths if configured
188
+ if (appUrls) {
189
+ await registerComponentDependencyPaths(JSON.parse(appUrls));
190
+ }
191
+
192
+ // init
193
+ setI18nTitle();
194
+ registerSAPFonts();
195
+ const renderer = await sap.ushell.Container.createRenderer(undefined, true);
196
+ renderer.placeAt('content');
197
+ }
198
+ const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
199
+ if (bootstrapConfig) {
200
+ init({
201
+ appUrls: bootstrapConfig.getAttribute('data-open-ux-preview-libs-manifests'),
202
+ flex: bootstrapConfig.getAttribute('data-open-ux-preview-flex-settings')
203
+ }).catch(() => Log.error('Sandbox initialization failed.'));
204
+ }
205
+ var __exports = {
206
+ __esModule: true
207
+ };
208
+ __exports.registerComponentDependencyPaths = registerComponentDependencyPaths;
209
+ __exports.registerSAPFonts = registerSAPFonts;
210
+ __exports.setI18nTitle = setI18nTitle;
211
+ __exports.init = init;
212
+ return __exports;
213
213
  });
214
214
  //# sourceMappingURL=init.js.map
@@ -1,35 +1,35 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Initializes UI5 connectors based on the current UI5 version.
8
- *
9
- * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
10
- * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
11
- * This setup allows for flexibility in using different connectors based on the UI5 version.
12
- *
13
- * @example
14
- * intiConnectors(); // Simply call the function without any arguments.
15
- * @returns {void}
16
- */
17
- function initConnectors() {
18
- const version = sap.ui.version;
19
- const minor = parseInt(version.split('.')[1], 10);
20
- if (minor < 72) {
21
- sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
22
- enableFakeConnector();
23
- });
24
- } else {
25
- sap.ui.define('custom.connectors.WorkspaceConnector', ['open/ux/preview/client/flp/WorkspaceConnector'], connector => connector, true);
26
- }
27
- }
28
- initConnectors();
29
- var __exports = {
30
- __esModule: true
31
- };
32
- __exports.initConnectors = initConnectors;
33
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Initializes UI5 connectors based on the current UI5 version.
8
+ *
9
+ * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
10
+ * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
11
+ * This setup allows for flexibility in using different connectors based on the UI5 version.
12
+ *
13
+ * @example
14
+ * intiConnectors(); // Simply call the function without any arguments.
15
+ * @returns {void}
16
+ */
17
+ function initConnectors() {
18
+ const version = sap.ui.version;
19
+ const minor = parseInt(version.split('.')[1], 10);
20
+ if (minor < 72) {
21
+ sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
22
+ enableFakeConnector();
23
+ });
24
+ } else {
25
+ sap.ui.define('custom.connectors.WorkspaceConnector', ['open/ux/preview/client/flp/WorkspaceConnector'], connector => connector, true);
26
+ }
27
+ }
28
+ initConnectors();
29
+ var __exports = {
30
+ __esModule: true
31
+ };
32
+ __exports.initConnectors = initConnectors;
33
+ return __exports;
34
34
  });
35
35
  //# sourceMappingURL=initConnectors.js.map