@sap-ux/preview-middleware 0.4.1 → 0.4.3

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/README.md CHANGED
@@ -11,7 +11,7 @@ The `@sap-ux/preview-middleware` is a [Custom UI5 Server Middleware](https://sap
11
11
  | `flp.intent.object` | `string` | `app` | Optional intent object |
12
12
  | `flp.intent.action` | `string` | `preview` | Optional intent action |
13
13
  | `flp.apps` | `array` | `[]` | Optional additional local apps that are available in local Fiori launchpad |
14
- | `flp.libs` | `boolean` | `false` | Optional flag to add a generic script fetching the paths of used libraries not available in UI5 |
14
+ | `flp.libs` | `boolean` | `undefined` | Optional flag to add a generic script fetching the paths of used libraries not available in UI5. To disable set it to `false`, if not set, then the project is checked for a `load-reuse-libs` script and if available the libraries are fetched as well. |
15
15
  | `adp.target` | | | Required configuration for adaptation projects defining the connected backend |
16
16
  | `adp.ignoreCertErrors` | `boolean` | `false` | Optional setting to ignore certification validation errors when working with e.g. development systems with self signed certificates |
17
17
  | `debug` | `boolean` | `false` | Enables debug output |
@@ -36,7 +36,7 @@ export interface TemplateConfig {
36
36
  layer: UI5FlexLayer;
37
37
  developerMode: boolean;
38
38
  };
39
- locateReuseLibsScript?: string;
39
+ locateReuseLibsScript?: boolean;
40
40
  }
41
41
  /**
42
42
  * Class handling preview of a sandbox FLP.
@@ -74,7 +74,7 @@ export declare class FlpSandbox {
74
74
  *
75
75
  * @returns the location of the locate-reuse-libs script or undefined.
76
76
  */
77
- private findLocateReuseLibsScript;
77
+ private hasLocateReuseLibsScript;
78
78
  /**
79
79
  * Add additional routes for apps also to be shown in the local FLP.
80
80
  */
package/dist/base/flp.js CHANGED
@@ -23,10 +23,6 @@ const DEFAULT_THEME = 'sap_horizon';
23
23
  * Default path for mounting the local FLP.
24
24
  */
25
25
  const DEFAULT_PATH = '/test/flp.html';
26
- /**
27
- * Default name of the locate reuse libs script.
28
- */
29
- const DEFAULT_LOCATE_LIBS_FILENAME = 'locate-reuse-libs.js';
30
26
  /**
31
27
  * Default intent
32
28
  */
@@ -72,7 +68,7 @@ class FlpSandbox {
72
68
  * @param resources optional additional resource mappings
73
69
  */
74
70
  init(manifest, componentId, resources = {}) {
75
- var _a, _b, _c, _d, _e, _f, _g;
71
+ var _a, _b, _c, _d, _e, _f, _g, _h;
76
72
  return __awaiter(this, void 0, void 0, function* () {
77
73
  const flex = this.createFlexHandler();
78
74
  const supportedThemes = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.supportedThemes) !== null && _b !== void 0 ? _b : [DEFAULT_THEME];
@@ -83,15 +79,13 @@ class FlpSandbox {
83
79
  libs: Object.keys((_f = (_e = (_d = manifest['sap.ui5']) === null || _d === void 0 ? void 0 : _d.dependencies) === null || _e === void 0 ? void 0 : _e.libs) !== null && _f !== void 0 ? _f : {}).join(','),
84
80
  theme: supportedThemes.includes(DEFAULT_THEME) ? DEFAULT_THEME : supportedThemes[0],
85
81
  flex,
86
- resources: Object.assign({}, resources)
82
+ resources: Object.assign(Object.assign({}, resources), { 'open.ux.preview': '.' })
87
83
  },
88
- locateReuseLibsScript: this.config.libs
89
- ? `./${DEFAULT_LOCATE_LIBS_FILENAME}`
90
- : yield this.findLocateReuseLibsScript()
84
+ locateReuseLibsScript: (_g = this.config.libs) !== null && _g !== void 0 ? _g : (yield this.hasLocateReuseLibsScript())
91
85
  };
92
86
  this.addApp(manifest, {
93
87
  componentId,
94
- target: (_g = resources[componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id]) !== null && _g !== void 0 ? _g : this.templateConfig.basePath,
88
+ target: (_h = resources[componentId !== null && componentId !== void 0 ? componentId : manifest['sap.app'].id]) !== null && _h !== void 0 ? _h : this.templateConfig.basePath,
95
89
  local: '.',
96
90
  intent: this.config.intent
97
91
  });
@@ -105,6 +99,14 @@ class FlpSandbox {
105
99
  * Add routes for html and scripts required for a local FLP.
106
100
  */
107
101
  addStandardRoutes() {
102
+ // add route for the oninit script
103
+ const previewPath = (0, path_1.dirname)(this.config.path);
104
+ this.router.get(`${previewPath === '/' ? '' : previewPath}/sandboxInit.js`, (_req, res) => {
105
+ const initjs = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandboxInit.js'), 'utf-8');
106
+ res.writeHead(200, { 'Content-Type': 'text/javascript' });
107
+ res.write(initjs);
108
+ res.end();
109
+ });
108
110
  // add route for the sandbox.html
109
111
  this.router.get(this.config.path, ((req, res) => __awaiter(this, void 0, void 0, function* () {
110
112
  var _a, _b;
@@ -137,31 +139,16 @@ class FlpSandbox {
137
139
  res.status(200).contentType('html').send(html);
138
140
  }
139
141
  })));
140
- // add route for locate-reuse-libs if requested
141
- if (this.config.libs && this.templateConfig.locateReuseLibsScript) {
142
- const pathParts = this.config.path.split('/');
143
- pathParts.pop();
144
- pathParts.push(DEFAULT_LOCATE_LIBS_FILENAME);
145
- this.router.get(pathParts.join('/'), (_req, res) => {
146
- const script = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/locate-reuse-libs.js'), 'utf-8');
147
- res.status(200).contentType('text/javascript').send(script);
148
- });
149
- }
150
142
  }
151
143
  /**
152
144
  * Try finding a locate-reuse-libs script in the project.
153
145
  *
154
146
  * @returns the location of the locate-reuse-libs script or undefined.
155
147
  */
156
- findLocateReuseLibsScript() {
148
+ hasLocateReuseLibsScript() {
157
149
  return __awaiter(this, void 0, void 0, function* () {
158
150
  const files = yield this.project.byGlob('**/locate-reuse-libs.js');
159
- if (files.length > 0) {
160
- return files[0].getPath();
161
- }
162
- else {
163
- return undefined;
164
- }
151
+ return files.length > 0;
165
152
  });
166
153
  }
167
154
  /**
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.4.1",
12
+ "version": "0.4.3",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "ejs": "3.1.7",
26
26
  "@sap-ux/logger": "0.3.7",
27
- "@sap-ux/adp-tooling": "0.1.6"
27
+ "@sap-ux/adp-tooling": "0.1.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/ejs": "3.1.0",
@@ -33,9 +33,9 @@
33
33
  "@types/supertest": "2.0.12",
34
34
  "express": "4.18.2",
35
35
  "nock": "13.2.1",
36
- "supertest": "6.3.2",
37
- "@sap-ux/project-access": "1.13.1",
38
- "@sap-ux/store": "0.3.12"
36
+ "supertest": "6.3.3",
37
+ "@sap-ux/store": "0.3.12",
38
+ "@sap-ux/project-access": "1.13.2"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "express": "4"
@@ -53,33 +53,10 @@
53
53
  data-sap-ui-flexibilityServices='<%- JSON.stringify(ui5.flex) %>'
54
54
  data-sap-ui-resourceroots='<%- JSON.stringify(ui5.resources) %>'
55
55
  data-sap-ui-frameOptions="allow"
56
- data-sap-ui-xx-componentPreload="off">
57
- </script><% if (locals.locateReuseLibsScript) { %>
58
- <script id="locate-reuse-libs" src="<%- locateReuseLibsScript %>" data-sap-ui-manifest-uri="/manifest.json">
59
- </script><% } %>
60
- <script>
61
- sap.ui.getCore().attachInit(function () {<% if (locals.flex) { %>
62
- sap.ushell.Container.attachRendererCreatedEvent(function () {
63
- sap.ushell.Container.getServiceAsync('AppLifeCycle').then((serviceInstance) => {
64
- serviceInstance.attachAppLoaded((event) => {
65
- var oView = event.getParameter('componentInstance');
66
- sap.ui.require(["sap/ui/rta/api/startAdaptation"], async function (startAdaptation) {
67
- var options = {
68
- rootControl: oView,
69
- validateAppVersion: false,
70
- flexSettings: {
71
- layer: '<%- flex.layer %>',
72
- developerMode: <%- flex.developerMode %>
73
- }
74
- };
75
- await startAdaptation(options);
76
- });
77
- })
78
- });
79
- });<% } %>
80
- <% if (!locals.locateReuseLibsScript) { %>
81
- sap.ushell.Container.createRenderer().placeAt("content");<% } %>
82
- });
56
+ data-sap-ui-xx-componentPreload="off"
57
+ data-sap-ui-oninit="module:open/ux/preview/sandboxInit"<% if (locals.flex) { %>
58
+ data-open-ux-preview-flex-settings='<%- JSON.stringify(flex) %>'<% } if (locals.locateReuseLibsScript) { %>
59
+ data-open-ux-preview-libs-manifests='<%- JSON.stringify(Object.values(apps).map(app => app.url)) %>'<% } %>>
83
60
  </script>
84
61
  </head>
85
62
 
@@ -0,0 +1,210 @@
1
+ /* global sap document */
2
+
3
+ /**
4
+ * Fetch the manifest for all the given application urls and generate a string containing all required custom library ids.
5
+ *
6
+ * @param {string[]} appUrls
7
+ * @returns {Promise<string>} Promise of a comma separated list of all required libraries.
8
+ */
9
+ function fioriToolsGetManifestLibs(appUrls) {
10
+ var result = {};
11
+ // SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
12
+ var ui5Libs = [
13
+ "sap.apf",
14
+ "sap.base",
15
+ "sap.chart",
16
+ "sap.collaboration",
17
+ "sap.f",
18
+ "sap.fe",
19
+ "sap.fileviewer",
20
+ "sap.gantt",
21
+ "sap.landvisz",
22
+ "sap.m",
23
+ "sap.ndc",
24
+ "sap.ovp",
25
+ "sap.rules",
26
+ "sap.suite",
27
+ "sap.tnt",
28
+ "sap.ui",
29
+ "sap.uiext",
30
+ "sap.ushell",
31
+ "sap.uxap",
32
+ "sap.viz",
33
+ "sap.webanalytics",
34
+ "sap.zen"
35
+ ];
36
+ function addKeys(libOrComp, reuseLibsObj) {
37
+ Object.keys(libOrComp).forEach(function (libOrCompKey) {
38
+ // ignore libs or Components that start with SAPUI5 delivered namespaces
39
+ if (!ui5Libs.some(function (substring) { return libOrCompKey === substring || libOrCompKey.startsWith(substring + "."); })) {
40
+ reuseLibsObj[libOrCompKey] = true;
41
+ }
42
+ });
43
+ }
44
+
45
+ var promises = [];
46
+ for (const url of appUrls) {
47
+ promises.push(new Promise(function (resolve, _reject) {
48
+ $.ajax(`${url}/manifest.json`)
49
+ .done(function (manifest) {
50
+ if (manifest) {
51
+ if (
52
+ manifest["sap.ui5"] &&
53
+ manifest["sap.ui5"].dependencies
54
+ ) {
55
+ if (manifest["sap.ui5"].dependencies.libs) {
56
+ addKeys(manifest["sap.ui5"].dependencies.libs, result);
57
+ }
58
+ if (manifest["sap.ui5"].dependencies.components) {
59
+ addKeys(manifest["sap.ui5"].dependencies.components, result);
60
+ }
61
+ }
62
+ if (
63
+ manifest["sap.ui5"] &&
64
+ manifest["sap.ui5"].componentUsages
65
+ ) {
66
+ addKeys(manifest["sap.ui5"].componentUsages, result);
67
+ }
68
+ }
69
+ resolve();
70
+ })
71
+ })
72
+ );
73
+ }
74
+ return Promise.all(promises).then(() => Object.keys(result).join(','));
75
+ };
76
+
77
+ /**
78
+ * Register the custom libraries and their url with the UI5 loader.
79
+ * @param {*} dataFromAppIndex
80
+ */
81
+ function registerModules(dataFromAppIndex) {
82
+ Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
83
+ var moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
84
+ if (moduleDefinition && moduleDefinition.dependencies) {
85
+ moduleDefinition.dependencies.forEach(function (dependency) {
86
+ if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
87
+ sap.ui.require(["sap/base/Log"], function (Log) {
88
+ Log.info("Registering Library " +
89
+ dependency.componentId +
90
+ " from server " +
91
+ dependency.url);
92
+ });
93
+ var compId = dependency.componentId.replace(/\./g, "/");
94
+ var config = {
95
+ paths: {
96
+ }
97
+ };
98
+ config.paths[compId] = dependency.url;
99
+ sap.ui.loader.config(config);
100
+ }
101
+ });
102
+ }
103
+ });
104
+ }
105
+
106
+ /**
107
+ * Fetch the manifest from the given application urls, then parse them for custom libs, and finally request their urls.
108
+ *
109
+ * @param {string[]} appUrls application urls
110
+ * @returns {Promise<void>} returns a promise when the registration is completed.
111
+ */
112
+ function registerComponentDependencyPaths(appUrls) {
113
+ return fioriToolsGetManifestLibs(appUrls).then(function (libs) {
114
+ if (libs && libs.length > 0) {
115
+ var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
116
+ var sapClient = "";
117
+
118
+ return new Promise(
119
+ function (resolve) {
120
+ sap.ui.require(["sap/base/util/UriParameters"], function (UriParameters) {
121
+ sapClient = UriParameters.fromQuery(window.location.search).get("sap-client");
122
+ if (sapClient && sapClient.length === 3) {
123
+ url = url + "&sap-client=" + sapClient;
124
+ }
125
+ resolve(url);
126
+ });
127
+ }).then(function (url2) {
128
+ return $.ajax(url2).done(function (data) {
129
+ if (data) {
130
+ registerModules(data);
131
+ }
132
+ });
133
+ });
134
+ } else {
135
+ return undefined;
136
+ }
137
+ });
138
+ };
139
+
140
+ /**
141
+ * Reigster SAP fonts that are also registered in a productive Fiori launchpad
142
+ */
143
+ function registerSAPFonts() {
144
+ sap.ui.require(["sap/ui/core/IconPool"], function (IconPool) {
145
+ //Fiori Theme font family and URI
146
+ var fioriTheme = {
147
+ fontFamily: "SAP-icons-TNT",
148
+ fontURI: sap.ui.require.toUrl("sap/tnt/themes/base/fonts/")
149
+ };
150
+ //Registering to the icon pool
151
+ IconPool.registerFont(fioriTheme);
152
+ //SAP Business Suite Theme font family and URI
153
+ var bSuiteTheme = {
154
+ fontFamily: "BusinessSuiteInAppSymbols",
155
+ fontURI: sap.ui.require.toUrl("sap/ushell/themes/base/fonts/")
156
+ };
157
+ //Registering to the icon pool
158
+ IconPool.registerFont(bSuiteTheme);
159
+ });
160
+ }
161
+
162
+ /**
163
+ * Read the application title from the resource bundle and set it as document title.
164
+ */
165
+ function setI18nTitle() {
166
+ var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
167
+ sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
168
+ var oResourceBundle = ResourceBundle.create({
169
+ url: "i18n/i18n.properties",
170
+ locale: sLocale
171
+ });
172
+ document.title = oResourceBundle.getText("appTitle");
173
+ });
174
+ }
175
+
176
+ // Register RTA if configured
177
+ var bootstrapConfig = document.getElementById("sap-ui-bootstrap");
178
+ var flex = bootstrapConfig.getAttribute("data-open-ux-preview-flex-settings");
179
+ if (flex) {
180
+ sap.ushell.Container.attachRendererCreatedEvent(function () {
181
+ sap.ushell.Container.getServiceAsync('AppLifeCycle').then((serviceInstance) => {
182
+ serviceInstance.attachAppLoaded((event) => {
183
+ var oView = event.getParameter('componentInstance');
184
+ sap.ui.require(["sap/ui/rta/api/startAdaptation"], function (startAdaptation) {
185
+ var options = {
186
+ rootControl: oView,
187
+ validateAppVersion: false,
188
+ flexSettings: JSON.parse(flex)
189
+ };
190
+ startAdaptation(options);
191
+ });
192
+ })
193
+ });
194
+ });
195
+ }
196
+
197
+ // Load custom library paths if configured
198
+ var appUrls = bootstrapConfig.getAttribute("data-open-ux-preview-libs-manifests");
199
+ var initPromise = appUrls ? registerComponentDependencyPaths(JSON.parse(appUrls)) : Promise.resolve();
200
+ initPromise.catch(function (error) {
201
+ sap.ui.require(["sap/base/Log"], function (Log) {
202
+ Log.error(error);
203
+ });
204
+ })
205
+ .finally(function() {
206
+ // always set title, register fonts and place the renderer
207
+ setI18nTitle();
208
+ registerSAPFonts();
209
+ sap.ushell.Container.createRenderer().placeAt("content");
210
+ });
@@ -1,217 +0,0 @@
1
- (function (sap) {
2
- var fioriToolsGetManifestLibs = function (manifestPath) {
3
- var url = manifestPath;
4
- var result = "";
5
- // SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
6
- var ui5Libs = [
7
- "sap.apf",
8
- "sap.base",
9
- "sap.chart",
10
- "sap.collaboration",
11
- "sap.f",
12
- "sap.fe",
13
- "sap.fileviewer",
14
- "sap.gantt",
15
- "sap.landvisz",
16
- "sap.m",
17
- "sap.ndc",
18
- "sap.ovp",
19
- "sap.rules",
20
- "sap.suite",
21
- "sap.tnt",
22
- "sap.ui",
23
- "sap.uiext",
24
- "sap.ushell",
25
- "sap.uxap",
26
- "sap.viz",
27
- "sap.webanalytics",
28
- "sap.zen"
29
- ];
30
- function getKeys(libOrComp, libOrCompKeysString) {
31
- var libOrCompKeysStringTmp = libOrCompKeysString;
32
- Object.keys(libOrComp).forEach(function (libOrCompKey) {
33
- // ignore libs or Components that start with SAPUI5 delivered namespaces
34
- if (!ui5Libs.some(function (substring) { return libOrCompKey === substring || libOrCompKey.startsWith(substring + "."); })) {
35
- if (libOrCompKeysStringTmp.length > 0) {
36
- libOrCompKeysStringTmp = libOrCompKeysStringTmp + "," + libOrCompKey;
37
- } else {
38
- libOrCompKeysStringTmp = libOrCompKey;
39
- }
40
- }
41
- });
42
- return libOrCompKeysStringTmp;
43
- }
44
- return new Promise(function (resolve, reject) {
45
- $.ajax(url)
46
- .done(function (manifest) {
47
- if (manifest) {
48
- if (
49
- manifest["sap.ui5"] &&
50
- manifest["sap.ui5"].dependencies
51
- ) {
52
- if (manifest["sap.ui5"].dependencies.libs) {
53
- result = getKeys(manifest["sap.ui5"].dependencies.libs, result);
54
- }
55
- if (manifest["sap.ui5"].dependencies.components) {
56
- result = getKeys(manifest["sap.ui5"].dependencies.components, result);
57
- }
58
- }
59
- if (
60
- manifest["sap.ui5"] &&
61
- manifest["sap.ui5"].componentUsages
62
- ) {
63
- result = getKeys(manifest["sap.ui5"].componentUsages, result);
64
- }
65
- }
66
- resolve(result);
67
- })
68
- .fail(function () {
69
- reject(new Error("Could not fetch manifest at '" + manifestPath));
70
- });
71
- });
72
- };
73
- function registerModules(dataFromAppIndex) {
74
- Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
75
- var moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
76
- if (moduleDefinition && moduleDefinition.dependencies) {
77
- moduleDefinition.dependencies.forEach(function (dependency) {
78
- if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
79
- sap.ui.require(["sap/base/Log"], function (Log) {
80
- Log.info("Registering Library " +
81
- dependency.componentId +
82
- " from server " +
83
- dependency.url);
84
- });
85
- var compId = dependency.componentId.replace(/\./g, "/");
86
- var config = {
87
- paths: {
88
- }
89
- };
90
- config.paths[compId] = dependency.url;
91
- sap.ui.loader.config(config);
92
- }
93
- });
94
- }
95
- });
96
- }
97
- /**
98
- * Registers the module paths for dependencies of the given component.
99
- * @param {string} manifestPath The the path to the app manifest path
100
- * for which the dependencies should be registered.
101
- * @returns {Promise} A promise which is resolved when the ajax request for
102
- * the app-index was successful and the module paths were registered.
103
- */
104
- sap.registerComponentDependencyPaths = function (manifestPath) {
105
-
106
- return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
107
- if (libs && libs.length > 0) {
108
- var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
109
- var sapClient = "";
110
-
111
- return new Promise(
112
- function (resolve) {
113
- sap.ui.require(["sap/base/util/UriParameters"], function (UriParameters) {
114
- sapClient = UriParameters.fromQuery(window.location.search).get("sap-client");
115
- if (sapClient && sapClient.length === 3) {
116
- url = url + "&sap-client=" + sapClient;
117
- }
118
- resolve(url);
119
- });
120
- }).then(function (url2) {
121
- return $.ajax(url2).done(function (data) {
122
- if (data) {
123
- registerModules(data);
124
- }
125
- });
126
- });
127
- } else {
128
- return undefined;
129
- }
130
- });
131
- };
132
- })(sap);
133
-
134
- function registerSAPFonts() {
135
- sap.ui.require(["sap/ui/core/IconPool"], function (IconPool) {
136
- //Fiori Theme font family and URI
137
- var fioriTheme = {
138
- fontFamily: "SAP-icons-TNT",
139
- fontURI: sap.ui.require.toUrl("sap/tnt/themes/base/fonts/")
140
- };
141
- //Registering to the icon pool
142
- IconPool.registerFont(fioriTheme);
143
- //SAP Business Suite Theme font family and URI
144
- var bSuiteTheme = {
145
- fontFamily: "BusinessSuiteInAppSymbols",
146
- fontURI: sap.ui.require.toUrl("sap/ushell/themes/base/fonts/")
147
- };
148
- //Registering to the icon pool
149
- IconPool.registerFont(bSuiteTheme);
150
- });
151
- }
152
-
153
- /*eslint-disable fiori-custom/sap-browser-api-warning, fiori-custom/sap-no-dom-access*/
154
- var currentScript = document.getElementById("locate-reuse-libs");
155
- if (!currentScript) {
156
- currentScript = document.currentScript;
157
- }
158
- var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
159
- var componentName = currentScript.getAttribute("data-sap-ui-componentName");
160
- var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
161
-
162
- sap.registerComponentDependencyPaths(manifestUri)
163
- .catch(function (error) {
164
- sap.ui.require(["sap/base/Log"], function (Log) {
165
- Log.error(error);
166
- });
167
- })
168
- .finally(function () {
169
-
170
- // setting the app title with internationalization
171
- sap.ui.getCore().attachInit(function () {
172
- var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
173
- sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
174
- var oResourceBundle = ResourceBundle.create({
175
- url: "i18n/i18n.properties",
176
- locale: sLocale
177
- });
178
- document.title = oResourceBundle.getText("appTitle");
179
- });
180
- });
181
-
182
- if (componentName && componentName.length > 0) {
183
- if (useMockserver && useMockserver === "true") {
184
- sap.ui.getCore().attachInit(function () {
185
- registerSAPFonts();
186
- sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
187
- // set up test service for local testing
188
- server.init();
189
- // initialize the ushell sandbox component
190
- sap.ushell.Container.createRenderer().placeAt("content");
191
- });
192
- });
193
- } else {
194
- // Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
195
- sap.ui.require(["sap/ui/core/ComponentSupport"]);
196
-
197
- // setting the app title with the i18n text
198
- sap.ui.getCore().attachInit(function () {
199
- registerSAPFonts();
200
- var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
201
- sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
202
- var oResourceBundle = ResourceBundle.create({
203
- url: "i18n/i18n.properties",
204
- locale: sLocale
205
- });
206
- document.title = oResourceBundle.getText("appTitle");
207
- });
208
- });
209
- }
210
- } else {
211
- sap.ui.getCore().attachInit(function () {
212
- registerSAPFonts();
213
- // initialize the ushell sandbox component
214
- sap.ushell.Container.createRenderer().placeAt("content");
215
- });
216
- }
217
- });