@sap-ux/ui5-application-writer 0.11.0 → 0.11.1

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/dist/types.d.ts CHANGED
@@ -34,6 +34,7 @@ export interface AppOptions {
34
34
  codeAssist: boolean;
35
35
  eslint: boolean;
36
36
  sapux: boolean;
37
+ loadReuseLibs: boolean;
37
38
  }
38
39
  export interface Ui5App {
39
40
  app: App;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,GAAG,CAAC,EAAE;QACF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;CACL;AAED,MAAM,WAAW,GAAG;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,oBAAY,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,GAAG;IAChB,SAAS,EAAE,YAAY,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,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MAAM,CAAC;CAC3B;AAED,oBAAY,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,GAAG;IAChB,SAAS,EAAE,YAAY,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,MAAM;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACjC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-application-writer",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -16,12 +16,16 @@
16
16
  data-sap-ui-theme="<%- ui5.ui5Theme %>"
17
17
  data-sap-ui-resourceroots='{
18
18
  "<%- app.id %>": "./"
19
- }'
20
- data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
19
+ }'<% if(!appOptions.loadReuseLibs) { %>
20
+ data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"<% } %>
21
21
  data-sap-ui-compatVersion="edge"
22
22
  data-sap-ui-async="true"
23
23
  data-sap-ui-frameOptions="trusted"
24
- ></script>
24
+ ></script><% if(appOptions.loadReuseLibs) { %>
25
+ <script id="locate-reuse-libs" src="./utils/locate-reuse-libs.js"
26
+ data-sap-ui-manifest-uri="./manifest.json"
27
+ data-sap-ui-componentName="<%- app.id %>">
28
+ </script> <% } %>
25
29
  </head>
26
30
  <body class="sapUiBody sapUiSizeCompact" id="content">
27
31
  <div
@@ -0,0 +1,173 @@
1
+ /*eslint-disable semi, no-console*/
2
+ (function (sap) {
3
+ var fioriToolsGetManifestLibs = function (manifestPath) {
4
+ var url = manifestPath;
5
+ var result = "";
6
+ // SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
7
+ var ui5Libs = [
8
+ "sap.apf",
9
+ "sap.base",
10
+ "sap.chart",
11
+ "sap.collaboration",
12
+ "sap.f",
13
+ "sap.fe",
14
+ "sap.fileviewer",
15
+ "sap.gantt",
16
+ "sap.landvisz",
17
+ "sap.m",
18
+ "sap.ndc",
19
+ "sap.ovp",
20
+ "sap.rules",
21
+ "sap.suite",
22
+ "sap.tnt",
23
+ "sap.ui",
24
+ "sap.uiext",
25
+ "sap.ushell",
26
+ "sap.uxap",
27
+ "sap.viz",
28
+ "sap.webanalytics",
29
+ "sap.zen"
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
+ }
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 (error) {
69
+ reject(new Error("Could not fetch manifest at '" + manifestPath));
70
+ });
71
+ });
72
+ };
73
+ /**
74
+ * Registers the module paths for dependencies of the given component.
75
+ * @param {string} manifestPath The the path to the app manifest path
76
+ * for which the dependencies should be registered.
77
+ * @returns {Promise} A promise which is resolved when the ajax request for
78
+ * the app-index was successful and the module paths were registered.
79
+ */
80
+ sap.registerComponentDependencyPaths = function (manifestPath) {
81
+ /*eslint-disable semi, consistent-return*/
82
+ return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
83
+ if (libs && libs.length > 0) {
84
+ var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
85
+ var sapClient = jQuery.sap.getUriParameters().get("sap-client");
86
+ if (sapClient && sapClient.length === 3) {
87
+ url = url + "&sap-client=" + sapClient;
88
+ }
89
+ return $.ajax(url).done(function (data) {
90
+ if (data) {
91
+ Object.keys(data).forEach(function (moduleDefinitionKey) {
92
+ var moduleDefinition = data[moduleDefinitionKey];
93
+ if (moduleDefinition && moduleDefinition.dependencies) {
94
+ moduleDefinition.dependencies.forEach(function (dependency) {
95
+ if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
96
+ jQuery.sap.log.info(
97
+ "Registering Library " +
98
+ dependency.componentId +
99
+ " from server " +
100
+ dependency.url
101
+ );
102
+ jQuery.sap.registerModulePath(dependency.componentId, dependency.url);
103
+ }
104
+ });
105
+ }
106
+ });
107
+ }
108
+ });
109
+ }
110
+ });
111
+ };
112
+ })(sap);
113
+
114
+ /*eslint-disable sap-browser-api-warning, sap-no-dom-access*/
115
+ var scripts = document.getElementsByTagName("script");
116
+ var currentScript = document.getElementById('locate-reuse-libs');
117
+ if(!currentScript){
118
+ currentScript = document.currentScript;
119
+ };
120
+ var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
121
+ var componentName = currentScript.getAttribute("data-sap-ui-componentName");
122
+ var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
123
+ sap.registerComponentDependencyPaths(manifestUri)
124
+ .catch(function (error) {
125
+ jQuery.sap.log.error(error);
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({
134
+ url: "i18n/i18n.properties",
135
+ locale: sLocale
136
+ });
137
+ document.title = oBundle.getText("appTitle");
138
+ });
139
+
140
+ if (componentName && componentName.length > 0) {
141
+ if (useMockserver && useMockserver === "true") {
142
+ sap.ui.getCore().attachInit(function () {
143
+ sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
144
+ // set up test service for local testing
145
+ server.init();
146
+ // initialize the ushell sandbox component
147
+ sap.ushell.Container.createRenderer().placeAt("content");
148
+ });
149
+ });
150
+ } else {
151
+ // Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
152
+ sap.ui.require(["sap/ui/core/ComponentSupport"]);
153
+
154
+ // setting the app title with the i18n text
155
+ sap.ui.getCore().attachInit(function () {
156
+ jQuery.sap.require("jquery.sap.resources");
157
+ var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
158
+ var oBundle = jQuery.sap.resources({
159
+ url: "i18n/i18n.properties",
160
+ locale: sLocale
161
+ });
162
+ document.title = oBundle.getText("appTitle");
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
+ });
172
+
173
+ sap.registerComponentDependencyPaths(manifestUri);