@sap-ux/ui5-application-writer 0.15.1 → 0.16.0
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,173 +1,168 @@
|
|
|
1
1
|
/*eslint-disable semi, no-console*/
|
|
2
2
|
(function (sap) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function getKeys(libOrComp,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 (libOrCompKeysString.length > 0) {
|
|
36
|
-
libOrCompKeysString = libOrCompKeysString + "," + libOrCompKey;
|
|
37
|
-
} else {
|
|
38
|
-
libOrCompKeysString = libOrCompKey;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return libOrCompKeysString;
|
|
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
|
-
}
|
|
3
|
+
var getKeys = function (libOrComp, libOrCompKeysString) {
|
|
4
|
+
// SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
5
|
+
var ui5Libs = [
|
|
6
|
+
"sap.apf",
|
|
7
|
+
"sap.base",
|
|
8
|
+
"sap.chart",
|
|
9
|
+
"sap.collaboration",
|
|
10
|
+
"sap.f",
|
|
11
|
+
"sap.fe",
|
|
12
|
+
"sap.fileviewer",
|
|
13
|
+
"sap.gantt",
|
|
14
|
+
"sap.landvisz",
|
|
15
|
+
"sap.m",
|
|
16
|
+
"sap.ndc",
|
|
17
|
+
"sap.ovp",
|
|
18
|
+
"sap.rules",
|
|
19
|
+
"sap.suite",
|
|
20
|
+
"sap.tnt",
|
|
21
|
+
"sap.ui",
|
|
22
|
+
"sap.uiext",
|
|
23
|
+
"sap.ushell",
|
|
24
|
+
"sap.uxap",
|
|
25
|
+
"sap.viz",
|
|
26
|
+
"sap.webanalytics",
|
|
27
|
+
"sap.zen"
|
|
28
|
+
];
|
|
29
|
+
Object.keys(libOrComp).forEach(function (libOrCompKey) {
|
|
30
|
+
// ignore libs or Components that start with SAPUI5 delivered namespaces
|
|
59
31
|
if (
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
!ui5Libs.some(function (substring) {
|
|
33
|
+
return libOrCompKey === substring || libOrCompKey.startsWith(substring + ".");
|
|
34
|
+
})
|
|
62
35
|
) {
|
|
63
|
-
|
|
36
|
+
if (libOrCompKeysString.length > 0) {
|
|
37
|
+
libOrCompKeysString = libOrCompKeysString + "," + libOrCompKey;
|
|
38
|
+
} else {
|
|
39
|
+
libOrCompKeysString = libOrCompKey;
|
|
40
|
+
}
|
|
64
41
|
}
|
|
65
|
-
}
|
|
66
|
-
resolve(result);
|
|
67
|
-
})
|
|
68
|
-
.fail(function (error) {
|
|
69
|
-
reject(new Error("Could not fetch manifest at '" + manifestPath));
|
|
70
42
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (manifest["sap.ui5"] && manifest["sap.ui5"].componentUsages) {
|
|
58
|
+
result = getKeys(manifest["sap.ui5"].componentUsages, result);
|
|
59
|
+
}
|
|
88
60
|
}
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
102
|
-
jQuery.sap.registerModulePath(dependency.componentId, dependency.url);
|
|
103
|
-
}
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var fioriToolsGetManifestLibs = function (manifestPath) {
|
|
65
|
+
var url = manifestPath;
|
|
66
|
+
return new Promise(function (resolve, reject) {
|
|
67
|
+
$.ajax(url)
|
|
68
|
+
.done(function (manifest) {
|
|
69
|
+
resolve(updateManifest(manifest));
|
|
70
|
+
})
|
|
71
|
+
.fail(function () {
|
|
72
|
+
reject(new Error("Could not fetch manifest at '" + manifestPath));
|
|
104
73
|
});
|
|
105
|
-
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var updateModuleDefinition = function (data) {
|
|
78
|
+
if (data) {
|
|
79
|
+
Object.keys(data).forEach(function (moduleDefinitionKey) {
|
|
80
|
+
var moduleDefinition = data[moduleDefinitionKey];
|
|
81
|
+
if (moduleDefinition && moduleDefinition.dependencies) {
|
|
82
|
+
moduleDefinition.dependencies.forEach(function (dependency) {
|
|
83
|
+
if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
|
|
84
|
+
jQuery.sap.log.info(
|
|
85
|
+
"Registering Library " + dependency.componentId + " from server " + dependency.url
|
|
86
|
+
);
|
|
87
|
+
jQuery.sap.registerModulePath(dependency.componentId, dependency.url);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
106
91
|
});
|
|
107
|
-
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Registers the module paths for dependencies of the given component.
|
|
97
|
+
* @param {string} manifestPath The the path to the app manifest path
|
|
98
|
+
* for which the dependencies should be registered.
|
|
99
|
+
* @returns {Promise} A promise which is resolved when the ajax request for
|
|
100
|
+
* the app-index was successful and the module paths were registered.
|
|
101
|
+
*/
|
|
102
|
+
sap.registerComponentDependencyPaths = function (manifestPath) {
|
|
103
|
+
/*eslint-disable semi, consistent-return*/
|
|
104
|
+
return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
|
|
105
|
+
if (libs && libs.length > 0) {
|
|
106
|
+
var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
|
|
107
|
+
var sapClient = jQuery.sap.getUriParameters().get("sap-client");
|
|
108
|
+
if (sapClient && sapClient.length === 3) {
|
|
109
|
+
url = url + "&sap-client=" + sapClient;
|
|
110
|
+
}
|
|
111
|
+
return $.ajax(url).done(updateModuleDefinition);
|
|
112
|
+
}
|
|
108
113
|
});
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
};
|
|
114
|
+
};
|
|
112
115
|
})(sap);
|
|
113
116
|
|
|
114
117
|
/*eslint-disable sap-browser-api-warning, sap-no-dom-access*/
|
|
115
118
|
var scripts = document.getElementsByTagName("script");
|
|
116
|
-
var currentScript = document.getElementById(
|
|
117
|
-
if(!currentScript){
|
|
119
|
+
var currentScript = document.getElementById("locate-reuse-libs");
|
|
120
|
+
if (!currentScript) {
|
|
118
121
|
currentScript = document.currentScript;
|
|
119
|
-
}
|
|
122
|
+
}
|
|
120
123
|
var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
|
|
121
124
|
var componentName = currentScript.getAttribute("data-sap-ui-componentName");
|
|
122
125
|
var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.finally(function () {
|
|
128
|
-
|
|
129
|
-
// setting the app title with internationalization
|
|
130
|
-
sap.ui.getCore().attachInit(function () {
|
|
131
|
-
jQuery.sap.require("jquery.sap.resources");
|
|
132
|
-
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
133
|
-
var oBundle = jQuery.sap.resources({
|
|
126
|
+
var bundleResources = function () {
|
|
127
|
+
jQuery.sap.require("jquery.sap.resources");
|
|
128
|
+
var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
|
|
129
|
+
var oBundle = jQuery.sap.resources({
|
|
134
130
|
url: "i18n/i18n.properties",
|
|
135
131
|
locale: sLocale
|
|
136
|
-
});
|
|
137
|
-
document.title = oBundle.getText("appTitle");
|
|
138
132
|
});
|
|
133
|
+
document.title = oBundle.getText("appTitle");
|
|
134
|
+
};
|
|
135
|
+
sap.registerComponentDependencyPaths(manifestUri)
|
|
136
|
+
.catch(function (error) {
|
|
137
|
+
jQuery.sap.log.error(error);
|
|
138
|
+
})
|
|
139
|
+
.finally(function () {
|
|
140
|
+
// setting the app title with internationalization
|
|
141
|
+
sap.ui.getCore().attachInit(bundleResources);
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
if (componentName && componentName.length > 0) {
|
|
144
|
+
if (useMockserver && useMockserver === "true") {
|
|
145
|
+
sap.ui.getCore().attachInit(function () {
|
|
146
|
+
sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
|
|
147
|
+
// set up test service for local testing
|
|
148
|
+
server.init();
|
|
149
|
+
// initialize the ushell sandbox component
|
|
150
|
+
sap.ushell.Container.createRenderer().placeAt("content");
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
// Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
|
|
155
|
+
sap.ui.require(["sap/ui/core/ComponentSupport"]);
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
sap.ui.getCore().attachInit(function () {
|
|
167
|
-
// initialize the ushell sandbox component
|
|
168
|
-
sap.ushell.Container.createRenderer().placeAt("content");
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
});
|
|
157
|
+
// setting the app title with the i18n text
|
|
158
|
+
sap.ui.getCore().attachInit(bundleResources);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
sap.ui.getCore().attachInit(function () {
|
|
162
|
+
// initialize the ushell sandbox component
|
|
163
|
+
sap.ushell.Container.createRenderer().placeAt("content");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
172
167
|
|
|
173
168
|
sap.registerComponentDependencyPaths(manifestUri);
|