@sap-ux/ui5-application-writer 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*eslint-disable semi, no-console*/
|
|
2
1
|
(function (sap) {
|
|
3
|
-
var
|
|
2
|
+
var fioriToolsGetManifestLibs = function (manifestPath) {
|
|
3
|
+
var url = manifestPath;
|
|
4
|
+
var result = "";
|
|
4
5
|
// SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
5
6
|
var ui5Libs = [
|
|
6
7
|
"sap.apf",
|
|
@@ -26,72 +27,73 @@
|
|
|
26
27
|
"sap.webanalytics",
|
|
27
28
|
"sap.zen"
|
|
28
29
|
];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
libOrCompKeysString = libOrCompKey;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return libOrCompKeysString;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var updateManifest = function (manifest) {
|
|
47
|
-
var result = "";
|
|
48
|
-
if (manifest) {
|
|
49
|
-
if (manifest["sap.ui5"] && manifest["sap.ui5"].dependencies) {
|
|
50
|
-
if (manifest["sap.ui5"].dependencies.libs) {
|
|
51
|
-
result = getKeys(manifest["sap.ui5"].dependencies.libs, result);
|
|
52
|
-
}
|
|
53
|
-
if (manifest["sap.ui5"].dependencies.components) {
|
|
54
|
-
result = getKeys(manifest["sap.ui5"].dependencies.components, result);
|
|
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
|
+
}
|
|
55
40
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
result = getKeys(manifest["sap.ui5"].componentUsages, result);
|
|
59
|
-
}
|
|
41
|
+
});
|
|
42
|
+
return libOrCompKeysStringTmp;
|
|
60
43
|
}
|
|
61
|
-
return result;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
var fioriToolsGetManifestLibs = function (manifestPath) {
|
|
65
|
-
var url = manifestPath;
|
|
66
44
|
return new Promise(function (resolve, reject) {
|
|
67
45
|
$.ajax(url)
|
|
68
46
|
.done(function (manifest) {
|
|
69
|
-
|
|
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);
|
|
70
67
|
})
|
|
71
|
-
.fail(function () {
|
|
68
|
+
.fail(function (error) {
|
|
72
69
|
reject(new Error("Could not fetch manifest at '" + manifestPath));
|
|
73
70
|
});
|
|
74
71
|
});
|
|
75
72
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
}
|
|
95
97
|
/**
|
|
96
98
|
* Registers the module paths for dependencies of the given component.
|
|
97
99
|
* @param {string} manifestPath The the path to the app manifest path
|
|
@@ -100,22 +102,36 @@
|
|
|
100
102
|
* the app-index was successful and the module paths were registered.
|
|
101
103
|
*/
|
|
102
104
|
sap.registerComponentDependencyPaths = function (manifestPath) {
|
|
103
|
-
|
|
105
|
+
|
|
104
106
|
return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
|
|
105
107
|
if (libs && libs.length > 0) {
|
|
106
108
|
var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
|
|
107
|
-
var sapClient =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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;
|
|
112
129
|
}
|
|
113
130
|
});
|
|
114
131
|
};
|
|
115
132
|
})(sap);
|
|
116
133
|
|
|
117
134
|
/*eslint-disable sap-browser-api-warning, sap-no-dom-access*/
|
|
118
|
-
var scripts = document.getElementsByTagName("script");
|
|
119
135
|
var currentScript = document.getElementById("locate-reuse-libs");
|
|
120
136
|
if (!currentScript) {
|
|
121
137
|
currentScript = document.currentScript;
|
|
@@ -123,22 +139,26 @@ if (!currentScript) {
|
|
|
123
139
|
var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
|
|
124
140
|
var componentName = currentScript.getAttribute("data-sap-ui-componentName");
|
|
125
141
|
var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
|
|
126
|
-
|
|
127
|
-
jQuery.sap.require("jquery.sap.resources");
|
|
128
|
-
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
129
|
-
var oBundle = jQuery.sap.resources({
|
|
130
|
-
url: "i18n/i18n.properties",
|
|
131
|
-
locale: sLocale
|
|
132
|
-
});
|
|
133
|
-
document.title = oBundle.getText("appTitle");
|
|
134
|
-
};
|
|
142
|
+
|
|
135
143
|
sap.registerComponentDependencyPaths(manifestUri)
|
|
136
144
|
.catch(function (error) {
|
|
137
|
-
|
|
145
|
+
sap.ui.require(["sap/base/Log"], function (Log) {
|
|
146
|
+
Log.error(error);
|
|
147
|
+
});
|
|
138
148
|
})
|
|
139
149
|
.finally(function () {
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
|
|
151
|
+
// setting the app title with internationalization
|
|
152
|
+
sap.ui.getCore().attachInit(function () {
|
|
153
|
+
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
154
|
+
sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
|
|
155
|
+
var oResourceBundle = ResourceBundle.create({
|
|
156
|
+
url: "i18n/i18n.properties",
|
|
157
|
+
locale: sLocale
|
|
158
|
+
});
|
|
159
|
+
document.title = oResourceBundle.getText("appTitle");
|
|
160
|
+
});
|
|
161
|
+
});
|
|
142
162
|
|
|
143
163
|
if (componentName && componentName.length > 0) {
|
|
144
164
|
if (useMockserver && useMockserver === "true") {
|
|
@@ -154,8 +174,17 @@ sap.registerComponentDependencyPaths(manifestUri)
|
|
|
154
174
|
// Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
|
|
155
175
|
sap.ui.require(["sap/ui/core/ComponentSupport"]);
|
|
156
176
|
|
|
157
|
-
// setting the app title with the i18n text
|
|
158
|
-
sap.ui.getCore().attachInit(
|
|
177
|
+
// setting the app title with the i18n text
|
|
178
|
+
sap.ui.getCore().attachInit(function () {
|
|
179
|
+
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
180
|
+
sap.ui.require(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
|
|
181
|
+
var oResourceBundle = ResourceBundle.create({
|
|
182
|
+
url: "i18n/i18n.properties",
|
|
183
|
+
locale: sLocale
|
|
184
|
+
});
|
|
185
|
+
document.title = oResourceBundle.getText("appTitle");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
159
188
|
}
|
|
160
189
|
} else {
|
|
161
190
|
sap.ui.getCore().attachInit(function () {
|
|
@@ -163,6 +192,4 @@ sap.registerComponentDependencyPaths(manifestUri)
|
|
|
163
192
|
sap.ushell.Container.createRenderer().placeAt("content");
|
|
164
193
|
});
|
|
165
194
|
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
sap.registerComponentDependencyPaths(manifestUri);
|
|
195
|
+
});
|