@sap-ux/ui5-application-writer 1.2.0 → 1.2.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.
@@ -26,11 +26,4 @@ export declare const defaultUI5Libs: string[];
26
26
  * @returns {UI5} the updated copy of UI5 instance (does not change `ui5`)
27
27
  */
28
28
  export declare function mergeUi5(ui5: Partial<UI5>, options?: Partial<AppOptions>): UI5;
29
- /**
30
- * Retrieve the tag version of the @sap/ux-specification based on the given version.
31
- *
32
- * @param ui5Version UI5 version used in the project
33
- * @returns version tag
34
- */
35
- export declare function getSpecTagVersion(ui5Version: string | undefined): string;
36
29
  //# sourceMappingURL=defaults.d.ts.map
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSpecTagVersion = exports.mergeUi5 = exports.defaultUI5Libs = exports.mergeApp = exports.packageDefaults = void 0;
6
+ exports.defaultUI5Libs = void 0;
7
+ exports.packageDefaults = packageDefaults;
8
+ exports.mergeApp = mergeApp;
9
+ exports.mergeUi5 = mergeUi5;
7
10
  const ui5_config_1 = require("@sap-ux/ui5-config");
8
11
  const mapping_json_1 = __importDefault(require("@ui5/manifest/mapping.json")); // from https://github.com/SAP/ui5-manifest/blob/master/mapping.json
9
12
  const ui5Libs_1 = require("./ui5Libs");
@@ -43,7 +46,6 @@ function packageDefaults(version, description, isEdmxProjectType) {
43
46
  scripts: {}
44
47
  };
45
48
  }
46
- exports.packageDefaults = packageDefaults;
47
49
  /**
48
50
  * Returns an app instance merged with default properties.
49
51
  *
@@ -63,7 +65,6 @@ function mergeApp(app) {
63
65
  }
64
66
  }, app);
65
67
  }
66
- exports.mergeApp = mergeApp;
67
68
  // Required default libs
68
69
  exports.defaultUI5Libs = ['sap.m', 'sap.ui.core'];
69
70
  /**
@@ -96,7 +97,6 @@ function mergeUi5(ui5, options) {
96
97
  merged.ui5Libs = (0, ui5Libs_1.getUI5Libs)(ui5.ui5Libs);
97
98
  return Object.assign({}, ui5, merged);
98
99
  }
99
- exports.mergeUi5 = mergeUi5;
100
100
  /**
101
101
  * Gets the miminum UI5 version based on the specified version.
102
102
  *
@@ -190,23 +190,4 @@ function getLocalVersion({ framework, version, localVersion }) {
190
190
  return minVersion;
191
191
  }
192
192
  }
193
- /**
194
- * Retrieve the tag version of the @sap/ux-specification based on the given version.
195
- *
196
- * @param ui5Version UI5 version used in the project
197
- * @returns version tag
198
- */
199
- function getSpecTagVersion(ui5Version) {
200
- if (ui5Version) {
201
- if (semver_1.default.valid(ui5Version)) {
202
- return `UI5-${semver_1.default.major(ui5Version)}.${semver_1.default.minor(ui5Version)}`;
203
- }
204
- else if (ui5Version.includes('snapshot') && ui5Version.includes('.')) {
205
- const snaphotVersion = ui5Version.split('snapshot-')[1];
206
- return `UI5-${snaphotVersion}`;
207
- }
208
- }
209
- return 'latest';
210
- }
211
- exports.getSpecTagVersion = getSpecTagVersion;
212
193
  //# sourceMappingURL=defaults.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeWithDefaults = void 0;
3
+ exports.mergeWithDefaults = mergeWithDefaults;
4
4
  const ui5_config_1 = require("@sap-ux/ui5-config");
5
5
  const defaults_1 = require("./defaults");
6
6
  const validators_1 = require("./validators");
@@ -27,12 +27,6 @@ function mergeWithDefaults(ui5App) {
27
27
  // sapuxLayer is not defined for cap projects
28
28
  ui5App.package.sapuxLayer = undefined;
29
29
  }
30
- if (ui5App.appOptions.sapux && isEdmxProjectType) {
31
- // Add @sap/ux-specification to devDependencies only for non-CAP projects
32
- ui5App.package.devDependencies = ui5App.package.devDependencies || {};
33
- ui5App.package.devDependencies['@sap/ux-specification'] = (0, defaults_1.getSpecTagVersion)(ui5App.ui5.version);
34
- }
35
30
  return ui5App;
36
31
  }
37
- exports.mergeWithDefaults = mergeWithDefaults;
38
32
  //# sourceMappingURL=index.js.map
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validate = exports.validateUI5Version = exports.validateAppId = void 0;
6
+ exports.validateAppId = validateAppId;
7
+ exports.validateUI5Version = validateUI5Version;
8
+ exports.validate = validate;
7
9
  const semver_1 = __importDefault(require("semver"));
8
10
  const i18n_1 = require("../i18n");
9
11
  /**
@@ -23,7 +25,6 @@ function validateAppId(appId) {
23
25
  }
24
26
  return true;
25
27
  }
26
- exports.validateAppId = validateAppId;
27
28
  /**
28
29
  * Validates by throwing if the specified version does not have a coercible semantic version.
29
30
  * Currently we have special handling for empty string and undefined otherwise see: https://github.com/npm/node-semver#coercion.
@@ -38,7 +39,6 @@ function validateUI5Version(version) {
38
39
  }
39
40
  return true;
40
41
  }
41
- exports.validateUI5Version = validateUI5Version;
42
42
  /**
43
43
  * Validates the specified ui5App.
44
44
  *
@@ -52,5 +52,4 @@ function validate(ui5App) {
52
52
  validateUI5Version(ui5App.ui5?.localVersion) &&
53
53
  validateUI5Version(ui5App.ui5?.minUI5Version));
54
54
  }
55
- exports.validate = validate;
56
55
  //# sourceMappingURL=validators.js.map
package/dist/i18n.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.t = exports.initI18n = void 0;
6
+ exports.initI18n = initI18n;
7
+ exports.t = t;
7
8
  const i18next_1 = __importDefault(require("i18next"));
8
9
  const ui5_application_writer_i18n_json_1 = __importDefault(require("./translations/ui5-application-writer.i18n.json"));
9
10
  const NS = 'ui5-application-writer';
@@ -23,7 +24,6 @@ async function initI18n() {
23
24
  ns: [NS]
24
25
  });
25
26
  }
26
- exports.initI18n = initI18n;
27
27
  /**
28
28
  * Helper function facading the call to i18next.
29
29
  *
@@ -34,7 +34,6 @@ exports.initI18n = initI18n;
34
34
  function t(key, options) {
35
35
  return i18next_1.default.t(key, options);
36
36
  }
37
- exports.t = t;
38
37
  initI18n().catch(() => {
39
38
  // Ignore any errors since the write will still work
40
39
  });
package/dist/index.d.ts CHANGED
@@ -29,4 +29,5 @@ declare function isTypescriptEnabled(basePath: string, fs?: Editor): Promise<boo
29
29
  declare function enableTypescript(basePath: string, fs?: Editor): Promise<Editor>;
30
30
  export { Ui5App, generate, enableTypescript, isTypescriptEnabled };
31
31
  export { App, Package, UI5, AppOptions };
32
+ export { compareUI5VersionGte, ui5LtsVersion_1_120, ui5LtsVersion_1_71, processDestinationPath, getTemplateVersionPath } from './utils';
32
33
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTypescriptEnabled = exports.enableTypescript = exports.generate = void 0;
3
+ exports.getTemplateVersionPath = exports.processDestinationPath = exports.ui5LtsVersion_1_71 = exports.ui5LtsVersion_1_120 = exports.compareUI5VersionGte = void 0;
4
+ exports.generate = generate;
5
+ exports.enableTypescript = enableTypescript;
6
+ exports.isTypescriptEnabled = isTypescriptEnabled;
4
7
  const path_1 = require("path");
5
8
  const mem_fs_1 = require("mem-fs");
6
9
  const mem_fs_editor_1 = require("mem-fs-editor");
@@ -76,7 +79,6 @@ async function generate(basePath, ui5AppConfig, fs) {
76
79
  fs.write(ui5ConfigPath, ui5Config.toString());
77
80
  return fs;
78
81
  }
79
- exports.generate = generate;
80
82
  /**
81
83
  * Check if Typescript is enabled for the given path.
82
84
  *
@@ -98,7 +100,6 @@ async function isTypescriptEnabled(basePath, fs) {
98
100
  }
99
101
  return true;
100
102
  }
101
- exports.isTypescriptEnabled = isTypescriptEnabled;
102
103
  /**
103
104
  * Enable typescript in an existing valid UI5 project.
104
105
  *
@@ -135,5 +136,10 @@ async function enableTypescript(basePath, fs) {
135
136
  fs.write(ui5ConfigPath, ui5Config.toString());
136
137
  return fs;
137
138
  }
138
- exports.enableTypescript = enableTypescript;
139
+ var utils_1 = require("./utils");
140
+ Object.defineProperty(exports, "compareUI5VersionGte", { enumerable: true, get: function () { return utils_1.compareUI5VersionGte; } });
141
+ Object.defineProperty(exports, "ui5LtsVersion_1_120", { enumerable: true, get: function () { return utils_1.ui5LtsVersion_1_120; } });
142
+ Object.defineProperty(exports, "ui5LtsVersion_1_71", { enumerable: true, get: function () { return utils_1.ui5LtsVersion_1_71; } });
143
+ Object.defineProperty(exports, "processDestinationPath", { enumerable: true, get: function () { return utils_1.processDestinationPath; } });
144
+ Object.defineProperty(exports, "getTemplateVersionPath", { enumerable: true, get: function () { return utils_1.getTemplateVersionPath; } });
139
145
  //# sourceMappingURL=index.js.map
package/dist/options.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { Ui5App } from './types';
2
+ import type { UI5, Ui5App } from './types';
3
3
  import type { UI5Config } from '@sap-ux/ui5-config';
4
4
  import type { ProjectType } from '@sap-ux/project-access';
5
5
  /**
@@ -12,6 +12,7 @@ export interface FeatureInput {
12
12
  baseComponent?: string;
13
13
  projectType?: ProjectType;
14
14
  };
15
+ ui5?: Partial<UI5>;
15
16
  };
16
17
  fs: Editor;
17
18
  basePath: string;
package/dist/options.js CHANGED
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTemplateOptions = exports.applyOptionalFeatures = exports.enableNpmPackageConsumption = exports.enableTypescript = void 0;
3
+ exports.enableTypescript = enableTypescript;
4
+ exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
5
+ exports.applyOptionalFeatures = applyOptionalFeatures;
6
+ exports.getTemplateOptions = getTemplateOptions;
4
7
  const path_1 = require("path");
5
8
  const ejs_1 = require("ejs");
6
9
  const project_access_1 = require("@sap-ux/project-access");
7
10
  const ui5Libs_1 = require("./data/ui5Libs");
8
11
  const ui5_config_1 = require("@sap-ux/ui5-config");
12
+ const utils_1 = require("./utils");
9
13
  /**
10
14
  * Copy all template files into the target project.
11
15
  *
@@ -17,7 +21,11 @@ const ui5_config_1 = require("@sap-ux/ui5-config");
17
21
  * @param input.tmplPath template basepath
18
22
  */
19
23
  async function copyTemplates(name, { ui5App, fs, basePath, tmplPath }) {
20
- const optTmplDirPath = (0, path_1.join)(tmplPath, 'optional', `${name}`);
24
+ let optTmplDirPath = (0, path_1.join)(tmplPath, 'optional', `${name}`);
25
+ const optionPath = (0, utils_1.getTemplateVersionPath)(ui5App.ui5);
26
+ if (name === 'loadReuseLibs') {
27
+ optTmplDirPath = (0, path_1.join)(optTmplDirPath, optionPath);
28
+ }
21
29
  const optTmplFilePaths = await (0, project_access_1.getFilePaths)(optTmplDirPath);
22
30
  optTmplFilePaths.forEach((optTmplFilePath) => {
23
31
  const relPath = optTmplFilePath.replace(optTmplDirPath, '');
@@ -25,7 +33,8 @@ async function copyTemplates(name, { ui5App, fs, basePath, tmplPath }) {
25
33
  // Extend or add
26
34
  if (!fs.exists(outPath)) {
27
35
  fs.copyTpl(optTmplFilePath, outPath, ui5App, undefined, {
28
- globOptions: { dot: true }
36
+ globOptions: { dot: true },
37
+ processDestinationPath: utils_1.processDestinationPath
29
38
  });
30
39
  }
31
40
  else {
@@ -72,7 +81,6 @@ async function enableTypescript(input, keepOldComponent = false) {
72
81
  input.fs.delete(compPath);
73
82
  }
74
83
  }
75
- exports.enableTypescript = enableTypescript;
76
84
  /**
77
85
  * Enable npm module import for the given input.
78
86
  *
@@ -85,7 +93,6 @@ async function enableNpmPackageConsumption(input) {
85
93
  ui5Config.addCustomTasks([ui5Libs_1.ui5NPMSupport.task]);
86
94
  });
87
95
  }
88
- exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
89
96
  /**
90
97
  * Check if the ui5 app config requires optional features to be enabled and if yes, enable them.
91
98
  *
@@ -104,7 +111,6 @@ async function applyOptionalFeatures(ui5App, fs, basePath, tmplPath, ui5Configs)
104
111
  }
105
112
  }
106
113
  }
107
- exports.applyOptionalFeatures = applyOptionalFeatures;
108
114
  /**
109
115
  * Generates the resource URL based on the project type and ui5 framework details.
110
116
  *
@@ -129,5 +135,4 @@ function getTemplateOptions(isEdmxProjectType, frameworkUrl, version) {
129
135
  return url;
130
136
  }
131
137
  }
132
- exports.getTemplateOptions = getTemplateOptions;
133
138
  //# sourceMappingURL=options.js.map
@@ -0,0 +1,26 @@
1
+ import { type UI5 } from './types';
2
+ export declare const ui5LtsVersion_1_71 = "1.71.0";
3
+ export declare const ui5LtsVersion_1_120 = "1.120.0";
4
+ /**
5
+ * Compares two UI5 versions to determine if the first is greater than or equal to the second.
6
+ *
7
+ * @param {string} ui5VersionA - The first UI5 version to compare.
8
+ * @param {string} ui5VersionB - The second UI5 version to compare.
9
+ * @returns {boolean} - True if the first version is greater than or equal to the second, false otherwise.
10
+ */
11
+ export declare function compareUI5VersionGte(ui5VersionA: string, ui5VersionB: string): boolean;
12
+ /**
13
+ * Gets the template version path based on the UI5 version and template type.
14
+ *
15
+ * @param {UI5} ui5 - The UI5 configuration.
16
+ * @returns {string} - The template version path.
17
+ */
18
+ export declare function getTemplateVersionPath(ui5: UI5): string;
19
+ /**
20
+ * Processes the destination path by removing specific version segments.
21
+ *
22
+ * @param {string} filePath - The file path to process.
23
+ * @returns {string} - The processed file path.
24
+ */
25
+ export declare function processDestinationPath(filePath: string): string;
26
+ //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ui5LtsVersion_1_120 = exports.ui5LtsVersion_1_71 = void 0;
4
+ exports.compareUI5VersionGte = compareUI5VersionGte;
5
+ exports.getTemplateVersionPath = getTemplateVersionPath;
6
+ exports.processDestinationPath = processDestinationPath;
7
+ const semver_1 = require("semver");
8
+ exports.ui5LtsVersion_1_71 = '1.71.0';
9
+ exports.ui5LtsVersion_1_120 = '1.120.0';
10
+ /**
11
+ * Compares two UI5 versions to determine if the first is greater than or equal to the second.
12
+ *
13
+ * @param {string} ui5VersionA - The first UI5 version to compare.
14
+ * @param {string} ui5VersionB - The second UI5 version to compare.
15
+ * @returns {boolean} - True if the first version is greater than or equal to the second, false otherwise.
16
+ */
17
+ function compareUI5VersionGte(ui5VersionA, ui5VersionB) {
18
+ if (ui5VersionA === '') {
19
+ // latest version
20
+ return true;
21
+ }
22
+ else {
23
+ return (0, semver_1.gte)(ui5VersionA, ui5VersionB, { loose: true });
24
+ }
25
+ }
26
+ /**
27
+ * Gets the template version path based on the UI5 version and template type.
28
+ *
29
+ * @param {UI5} ui5 - The UI5 configuration.
30
+ * @returns {string} - The template version path.
31
+ */
32
+ function getTemplateVersionPath(ui5) {
33
+ let templateVersionPath = '';
34
+ const ui5Version = ui5?.minUI5Version ?? ui5?.version ?? '';
35
+ if (ui5Version && compareUI5VersionGte(ui5Version, exports.ui5LtsVersion_1_120)) {
36
+ templateVersionPath = exports.ui5LtsVersion_1_120;
37
+ }
38
+ else {
39
+ templateVersionPath = exports.ui5LtsVersion_1_71;
40
+ }
41
+ return templateVersionPath;
42
+ }
43
+ /**
44
+ * Processes the destination path by removing specific version segments.
45
+ *
46
+ * @param {string} filePath - The file path to process.
47
+ * @returns {string} - The processed file path.
48
+ */
49
+ function processDestinationPath(filePath) {
50
+ return filePath.replace('/1.120.0', '').replace('/1.71.0', '');
51
+ }
52
+ //# sourceMappingURL=utils.js.map
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%3Aui5-application-writer"
11
11
  },
12
- "version": "1.2.0",
12
+ "version": "1.2.2",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -38,7 +38,7 @@
38
38
  "@types/semver": "7.5.2",
39
39
  "fs-extra": "10.0.0",
40
40
  "@sap-ux/eslint-plugin-fiori-tools": "0.5.0",
41
- "@sap-ux/project-access": "1.27.4"
41
+ "@sap-ux/project-access": "1.28.4"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=18.x"
@@ -0,0 +1,267 @@
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
+ var getKeys = function (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
+ var getComponentUsageNames = function (compUsages, libOrCompKeysString) {
45
+ var libOrCompKeysStringTmp = libOrCompKeysString;
46
+ var compNames = Object.keys(compUsages).map(function (compUsageKey) {
47
+ return compUsages[compUsageKey].name;
48
+ });
49
+ compNames.forEach(function (compName) {
50
+ // ignore libs or Components that start with SAPUI5 delivered namespaces
51
+ if (!ui5Libs.some(function (substring) { return compName === substring || compName.startsWith(substring + "."); })) {
52
+ if (libOrCompKeysStringTmp.length > 0) {
53
+ libOrCompKeysStringTmp = libOrCompKeysStringTmp + "," + compName;
54
+ } else {
55
+ libOrCompKeysStringTmp = compName;
56
+ }
57
+ }
58
+ });
59
+ return libOrCompKeysStringTmp;
60
+ }
61
+ return new Promise(function (resolve, reject) {
62
+
63
+ sap.ui.require(["sap/ui/thirdparty/jquery"], function (localJQuery) {
64
+ localJQuery.ajax(url)
65
+ .done(function (manifest) {
66
+ if (manifest) {
67
+ if (
68
+ manifest["sap.ui5"] &&
69
+ manifest["sap.ui5"].dependencies
70
+ ) {
71
+ if (manifest["sap.ui5"].dependencies.libs) {
72
+ result = getKeys(manifest["sap.ui5"].dependencies.libs, result);
73
+ }
74
+ if (manifest["sap.ui5"].dependencies.components) {
75
+ result = getKeys(manifest["sap.ui5"].dependencies.components, result);
76
+ }
77
+ }
78
+ if (
79
+ manifest["sap.ui5"] &&
80
+ manifest["sap.ui5"].componentUsages
81
+ ) {
82
+ result = getComponentUsageNames(manifest["sap.ui5"].componentUsages, result);
83
+ }
84
+ }
85
+ resolve(result);
86
+ })
87
+ .fail(function () {
88
+ reject(new Error("Could not fetch manifest at '" + manifestPath));
89
+ });
90
+ });
91
+ });
92
+ };
93
+ var registerModules = function (dataFromAppIndex) {
94
+ Object.keys(dataFromAppIndex).forEach(function (moduleDefinitionKey) {
95
+ var moduleDefinition = dataFromAppIndex[moduleDefinitionKey];
96
+ if (moduleDefinition && moduleDefinition.dependencies) {
97
+ moduleDefinition.dependencies.forEach(function (dependency) {
98
+ if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
99
+ sap.ui.require(["sap/base/Log"], function (Log) {
100
+ Log.info("Registering Library " +
101
+ dependency.componentId +
102
+ " from server " +
103
+ dependency.url);
104
+ });
105
+ var compId = dependency.componentId.replace(/\./g, "/");
106
+ var config = {
107
+ paths: {
108
+ }
109
+ };
110
+ config.paths[compId] = dependency.url;
111
+ sap.ui.loader.config(config);
112
+ }
113
+ });
114
+ }
115
+ });
116
+ }
117
+ /**
118
+ * Registers the module paths for dependencies of the given component.
119
+ * @param {string} manifestPath The the path to the app manifest path
120
+ * for which the dependencies should be registered.
121
+ * @returns {Promise} A promise which is resolved when the ajax request for
122
+ * the app-index was successful and the module paths were registered.
123
+ */
124
+ var registerComponentDependencyPaths = function (manifestPath) {
125
+
126
+ return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
127
+ if (libs && libs.length > 0) {
128
+ var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
129
+ var sapClient = "";
130
+
131
+ return new Promise(
132
+ function (resolve) {
133
+ sapClient = new URLSearchParams(window.location.search).get("sap-client");
134
+ if (sapClient && sapClient.length === 3) {
135
+ url = url + "&sap-client=" + sapClient;
136
+ }
137
+ resolve(url);
138
+ }).then(function (url2) {
139
+ sap.ui.require(["sap/ui/thirdparty/jquery"], function (localJQuery) {
140
+ return localJQuery.ajax(url2)
141
+ .done(function (data) {
142
+ if (data) {
143
+ registerModules(data);
144
+ }
145
+ });
146
+ });
147
+ });
148
+ } else {
149
+ return undefined;
150
+ }
151
+ });
152
+ };
153
+
154
+ var registerSAPFonts = function () {
155
+ sap.ui.require(["sap/ui/core/IconPool"], function (IconPool) {
156
+ //Fiori Theme font family and URI
157
+ var fioriTheme = {
158
+ fontFamily: "SAP-icons-TNT",
159
+ fontURI: sap.ui.require.toUrl("sap/tnt/themes/base/fonts/")
160
+ };
161
+ //Registering to the icon pool
162
+ IconPool.registerFont(fioriTheme);
163
+ //SAP Business Suite Theme font family and URI
164
+ var bSuiteTheme = {
165
+ fontFamily: "BusinessSuiteInAppSymbols",
166
+ fontURI: sap.ui.require.toUrl("sap/ushell/themes/base/fonts/")
167
+ };
168
+ //Registering to the icon pool
169
+ IconPool.registerFont(bSuiteTheme);
170
+ });
171
+ }
172
+
173
+ /*eslint-disable fiori-custom/sap-browser-api-warning, fiori-custom/sap-no-dom-access*/
174
+ var currentScript = document.getElementById("locate-reuse-libs");
175
+ if (!currentScript) {
176
+ currentScript = document.currentScript;
177
+ }
178
+ var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
179
+ var componentName = currentScript.getAttribute("data-sap-ui-componentName");
180
+ var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
181
+
182
+ // Patch (KW): resourceRoot is needed to load the correct ResourceBundles
183
+ var resourceRoot = manifestUri.substring(0, manifestUri.lastIndexOf('/')+1);
184
+
185
+
186
+ return registerComponentDependencyPaths(manifestUri)
187
+ .catch(function (error) {
188
+ sap.ui.require(["sap/base/Log"], function (Log) {
189
+ Log.error(error);
190
+ });
191
+ })
192
+ .finally(function () {
193
+
194
+ // setting the app title with internationalization
195
+ sap.ui.require(["sap/ui/core/Core"], async function(Core) {
196
+ Core.ready(() => {
197
+ sap.ui.require(["sap/base/i18n/Localization"], function (Localization) {
198
+ sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
199
+ var oResourceBundle = ResourceBundle.create({
200
+ // Patch (KW): resourceRoot is needed to load the correct ResourceBundles
201
+ url: resourceRoot + "i18n/i18n.properties",
202
+ locale: Localization.getLanguage()
203
+ });
204
+ document.title = oResourceBundle.getText("appTitle");
205
+ });
206
+ });
207
+ });
208
+ });
209
+
210
+ if (componentName && componentName.length > 0) {
211
+ if (useMockserver && useMockserver === "true") {
212
+ sap.ui.require(["sap/ui/core/Core"], async function(Core) {
213
+ Core.ready(() => {
214
+ registerSAPFonts();
215
+ sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
216
+ // set up test service for local testing
217
+ server.init();
218
+ // initialize the ushell sandbox component
219
+ sap.ui.require(["sap/ushell/Container"], async function (Container) {
220
+ Container.createRenderer(true).then(function (component) {
221
+ component.placeAt("content");
222
+ });
223
+ });
224
+ });
225
+ });
226
+ });
227
+ } else {
228
+ // Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
229
+ sap.ui.require(["sap/ui/core/ComponentSupport"]);
230
+
231
+ // setting the app title with the i18n text
232
+ sap.ui.require(["sap/ui/core/Core"], async function(Core) {
233
+ Core.ready(() => {
234
+ registerSAPFonts();
235
+ sap.ui.require(["sap/base/i18n/Localization"], function (Localization) {
236
+ sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
237
+ var oResourceBundle = ResourceBundle.create({
238
+ // Patch (KW): resourceRoot is needed to load the correct ResourceBundles
239
+ url: resourceRoot + "i18n/i18n.properties",
240
+ locale: Localization.getLanguage()
241
+ });
242
+ document.title = oResourceBundle.getText("appTitle");
243
+ });
244
+ });
245
+ });
246
+ });
247
+ }
248
+ } else {
249
+ sap.ui.require(["sap/ui/core/Core"], async function(Core) {
250
+ Core.ready(() => {
251
+ registerSAPFonts();
252
+ // initialize the ushell sandbox component
253
+ sap.ui.require(["sap/ushell/Container"], async function (Container) {
254
+ try {
255
+ Container.createRenderer(true).then(function (component) {
256
+ component.placeAt("content");
257
+ });
258
+ } catch (error) {
259
+ // support older versions of ui5
260
+ Container.createRenderer().placeAt("content");
261
+ }
262
+ });
263
+ });
264
+ });
265
+ }
266
+ });
267
+ })(sap);