@sapui5/sap.ushell_abap 1.139.0 → 1.141.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.
Files changed (55) hide show
  1. package/package.json +2 -2
  2. package/src/main/js/sap/ushell_abap/.library +1 -1
  3. package/src/main/js/sap/ushell_abap/adapters/abap/AdapterContainer.js +19 -13
  4. package/src/main/js/sap/ushell_abap/adapters/abap/AppStateAdapter.js +11 -11
  5. package/src/main/js/sap/ushell_abap/adapters/abap/ClientSideTargetResolutionAdapter.js +81 -81
  6. package/src/main/js/sap/ushell_abap/adapters/abap/CommonDataModelAdapter.js +1 -1
  7. package/src/main/js/sap/ushell_abap/adapters/abap/ConfigurationDefaultsAdapter.js +1 -2
  8. package/src/main/js/sap/ushell_abap/adapters/abap/ContainerAdapter.js +15 -17
  9. package/src/main/js/sap/ushell_abap/adapters/abap/FlpLaunchPageAdapter.js +230 -167
  10. package/src/main/js/sap/ushell_abap/adapters/abap/LaunchPageAdapter.js +1 -1
  11. package/src/main/js/sap/ushell_abap/adapters/abap/MenuAdapter.js +1 -1
  12. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionAdapter.js +1 -1
  13. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionInternalAdapter.js +1 -1
  14. package/src/main/js/sap/ushell_abap/adapters/abap/PageBuildingAdapter.js +10 -12
  15. package/src/main/js/sap/ushell_abap/adapters/abap/PagePersistenceAdapter.js +20 -17
  16. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationAdapter.js +5 -5
  17. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationV2Adapter.js +1 -1
  18. package/src/main/js/sap/ushell_abap/adapters/abap/SearchAdapter.js +1 -1
  19. package/src/main/js/sap/ushell_abap/adapters/abap/SupportTicketAdapter.js +2 -2
  20. package/src/main/js/sap/ushell_abap/adapters/abap/Ui5ComponentLoaderAdapter.js +1 -1
  21. package/src/main/js/sap/ushell_abap/adapters/abap/UserInfoAdapter.js +34 -28
  22. package/src/main/js/sap/ushell_abap/adapters/hana/ContainerAdapter.js +1 -1
  23. package/src/main/js/sap/ushell_abap/bootstrap/evo/SAPCompanionConditionSetter.js +5 -5
  24. package/src/main/js/sap/ushell_abap/bootstrap/evo/XhrLogonEventHandler.js +5 -2
  25. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.bootstrap.utils.js +2 -2
  26. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.ushell.js +1 -1
  27. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.pageset.js +54 -31
  28. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.startup.js +17 -13
  29. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.theme.handler.js +2 -1
  30. package/src/main/js/sap/ushell_abap/bootstrap/evo/boottask.js +85 -74
  31. package/src/main/js/sap/ushell_abap/components/TCodeNavigation/MessageCode.js +47 -0
  32. package/src/main/js/sap/ushell_abap/components/TCodeNavigation/TCodeNavigationError.js +59 -0
  33. package/src/main/js/sap/ushell_abap/components/TCodeNavigation.js +163 -0
  34. package/src/main/js/sap/ushell_abap/integration/fileshares/AppRuntimeFileShareSupport.js +4 -4
  35. package/src/main/js/sap/ushell_abap/library.js +8 -1
  36. package/src/main/js/sap/ushell_abap/pbServices/ui2/AllCatalogs.js +2 -2
  37. package/src/main/js/sap/ushell_abap/pbServices/ui2/Bag.js +15 -19
  38. package/src/main/js/sap/ushell_abap/pbServices/ui2/Catalog.js +19 -17
  39. package/src/main/js/sap/ushell_abap/pbServices/ui2/Chip.js +14 -23
  40. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipDefinition.js +4 -5
  41. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipInstance.js +8 -13
  42. package/src/main/js/sap/ushell_abap/pbServices/ui2/Error.js +2 -2
  43. package/src/main/js/sap/ushell_abap/pbServices/ui2/Factory.js +12 -20
  44. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataService.js +9 -12
  45. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataWrapper.js +45 -33
  46. package/src/main/js/sap/ushell_abap/pbServices/ui2/Page.js +3 -5
  47. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageBuildingService.js +19 -22
  48. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageSet.js +9 -10
  49. package/src/main/js/sap/ushell_abap/pbServices/ui2/RemoteCatalogService.js +2 -2
  50. package/src/main/js/sap/ushell_abap/pbServices/ui2/Utils.js +19 -69
  51. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/actions.js +3 -4
  52. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configuration.js +1 -1
  53. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/visible.js +2 -2
  54. package/src/main/js/sap/ushell_abap/ui5appruntime/AppInfoAdapter.js +2 -2
  55. package/ui5.yaml +33 -1
@@ -49,7 +49,24 @@ sap.ui.define([
49
49
  }
50
50
  }
51
51
 
52
- let ODataWrapper;
52
+ /**
53
+ * Clones an Object to avoid unwanted changes
54
+ * @param {object} oInputObject
55
+ * The object that needs to be cloned
56
+ * @returns {object}
57
+ * The cloned object
58
+ * @private
59
+ */
60
+ function cloneObject (oInputObject) {
61
+ if (oInputObject === undefined) {
62
+ return undefined;
63
+ }
64
+ try {
65
+ return JSON.parse(JSON.stringify(oInputObject));
66
+ } catch {
67
+ return undefined;
68
+ }
69
+ }
53
70
 
54
71
  // "public class" ************************************************************
55
72
 
@@ -100,13 +117,15 @@ sap.ui.define([
100
117
  * @since 1.19.0
101
118
  */
102
119
  // OLD API: function (sBaseUrl, oODataService, bSupportsChangeSets)
103
- ODataWrapper = function (oSettings, oODataService) {
120
+ function ODataWrapper (oSettings, oODataService) {
104
121
  const S_STICKY_SESSION_HEADER = "saplb"; // header to check during sticky session
105
122
  let aBatchQueue; // corresponds to data.__batchRequests
106
123
  let bChangeSetOpen; // whether a change set is currently open at the end of our batch queue
107
124
  let aDeferredQueue; // jQuery.Deferred() objects corresponding to each request
108
125
  const that = this;
126
+ // eslint-disable-next-line prefer-const
109
127
  let sBaseUrl;
128
+ // eslint-disable-next-line prefer-const
110
129
  let bSupportsChangeSets;
111
130
 
112
131
  // BEWARE: constructor code below!
@@ -137,7 +156,7 @@ sap.ui.define([
137
156
  /**
138
157
  * Getter mainly used for testing.
139
158
  *
140
- * @returns {object}
159
+ * @returns {object} the batch queue
141
160
  */
142
161
  this.getBatchQueue = function () {
143
162
  return aBatchQueue;
@@ -244,7 +263,6 @@ sap.ui.define([
244
263
  * the response headers
245
264
  */
246
265
  this.detectStickySession = function (oResponseHeaders) {
247
- let sHeaderValue;
248
266
  const oStickySessionConfiguration =
249
267
  ODataWrapper.oStickySessionConfiguration[sBaseUrl];
250
268
 
@@ -253,7 +271,7 @@ sap.ui.define([
253
271
  }
254
272
 
255
273
  // add sticky session header value if found
256
- sHeaderValue = ODataWrapper.headerValue(S_STICKY_SESSION_HEADER, oResponseHeaders);
274
+ const sHeaderValue = ODataWrapper.headerValue(S_STICKY_SESSION_HEADER, oResponseHeaders);
257
275
  if (typeof sHeaderValue === "undefined") {
258
276
  return;
259
277
  }
@@ -315,16 +333,25 @@ sap.ui.define([
315
333
  */
316
334
  this.doRequest = function (sRequestUrl, sMethod, oPayload, fnSuccess, fnFailure, oHandler, bIsRepeatedRequest) {
317
335
  Log.debug("[000] do request, sMethod", sMethod, "ODataWrapper");
318
- let oHeaders;
319
336
  fnSuccess = fnSuccess || nop;
320
337
  fnFailure = fnFailure || oODataService.getDefaultErrorHandler();
321
338
  that.check(fnSuccess, fnFailure);
322
- oHeaders = {
339
+ const oHeaders = {
323
340
  Accept: "application/json",
324
341
  "Accept-Language": Localization.getLanguage() || "",
325
342
  "X-CSRF-Token": oODataService.getCsrfToken()
326
343
  };
327
344
 
345
+ // Ensure fetching a csrf token for POST methods always. As of today, ABAP only requires a valid token for POST requests.
346
+ // Conceptual apart from HEAD request, a back-end can require a valid token for GET as well.
347
+ if (oODataService.getCsrfToken() === "" && sMethod !== "GET") {
348
+ oODataService.refreshCsrfToken(
349
+ this.doRequest.bind(that, sRequestUrl, sMethod, oPayload, fnSuccess, fnFailure, oHandler, /* bIsRepeatedRequest */ true),
350
+ fnFailure
351
+ );
352
+ return;
353
+ }
354
+
328
355
  addGlobalSapHeaders(oHeaders);
329
356
  addStickySessionHeader(oHeaders);
330
357
 
@@ -430,7 +457,9 @@ sap.ui.define([
430
457
  const sRequestUrl = this.toRequestUrl(sRelativeUrl);
431
458
  const oHeaders = addStickySessionHeader(addGlobalSapHeaders()); // may return an empty object
432
459
 
433
- if (aBatchQueue) {
460
+ // if sRelativeUrl is empty, we ask for the service document, which is only used for fetching an XSRF token,
461
+ // so we are not taking already queued requests into account.
462
+ if (aBatchQueue && sRelativeUrl !== "") {
434
463
  Log.debug(`Queued OData request for GET "${sRelativeUrl}"`, null,
435
464
  "ODataWrapper");
436
465
  aBatchQueue.push({
@@ -777,15 +806,15 @@ sap.ui.define([
777
806
  oParsedErrorInformation.httpStatus = oError.response.statusCode;
778
807
  }
779
808
  }
780
- } catch (ex) {
809
+ } catch (oParseError) {
781
810
  // do not rely on subtleties of error response, treat error details as optional
782
811
  }
783
812
  }
784
813
 
785
- Log.error(sMessage, JSON.stringify(oError.response),
786
- "ODataWrapper");
814
+ Log.error(sMessage, JSON.stringify(oError.response), "ODataWrapper");
787
815
 
788
816
  if (oDeferred) {
817
+ // reject with string as this is used to call the fnFailure
789
818
  oDeferred.reject(sMessage, oParsedErrorInformation);
790
819
  }
791
820
  fnFailure(sMessage, oParsedErrorInformation);
@@ -859,6 +888,8 @@ sap.ui.define([
859
888
 
860
889
  /**
861
890
  * Success handler for <code>OData.read</code>.
891
+ * @param {object} oData oData returned by the OData service
892
+ * @param {object} oResponse response object
862
893
  */
863
894
  function success (oData, oResponse) {
864
895
  this.detectStickySession(oResponse.headers);
@@ -968,7 +999,7 @@ sap.ui.define([
968
999
  /**
969
1000
  * Success handler for $batch request.
970
1001
  *
971
- * @param {object} oData
1002
+ * @param {object} oData is the oData response object
972
1003
  */
973
1004
  function onBatchSuccess (oData) {
974
1005
  const iActual = oData.__batchResponses.length;
@@ -1135,7 +1166,7 @@ sap.ui.define([
1135
1166
  value: undefined // the value detected if enabled = true
1136
1167
  };
1137
1168
  }
1138
- };
1169
+ }
1139
1170
 
1140
1171
  /**
1141
1172
  * Detects and, if needed, converts old api calls of the createODataWrapper function to the current one.
@@ -1162,25 +1193,6 @@ sap.ui.define([
1162
1193
  return oTransformedApi;
1163
1194
  }
1164
1195
 
1165
- /**
1166
- * Clones an Object to avoid unwanted changes
1167
- * @param {object} oInputObject
1168
- * The object that needs to be cloned
1169
- * @returns {object}
1170
- * The cloned object
1171
- * @private
1172
- */
1173
- function cloneObject (oInputObject) {
1174
- if (oInputObject === undefined) {
1175
- return undefined;
1176
- }
1177
- try {
1178
- return JSON.parse(JSON.stringify(oInputObject));
1179
- } catch (e) {
1180
- return undefined;
1181
- }
1182
- }
1183
-
1184
1196
  /*
1185
1197
  * Configuration for sticky session is done here as it is a static property
1186
1198
  * that should not rely on the instance initialization. Also, it may happen
@@ -1206,7 +1218,7 @@ sap.ui.define([
1206
1218
  try {
1207
1219
  // read the value from UI5 as it may be set via [CTRL-SHIFT-ALT-P]
1208
1220
  ODataWrapper["sap-statistics"] = Supportability.isStatisticsEnabled();
1209
- } catch (e) {
1221
+ } catch {
1210
1222
  // Read sap-statistics directly form query parameter in scenarios without UI5
1211
1223
  ODataWrapper["sap-statistics"] =
1212
1224
  /sap-statistics=(true|x|X)/.test(sWindowLocationSearch);
@@ -46,7 +46,7 @@ sap.ui.define([
46
46
  * @since 1.2.0
47
47
  * @see sap.ushell_abap.pbServices.ui2.PageBuildingService
48
48
  */
49
- const Page = function (oFactory, vPageData) {
49
+ function Page (oFactory, vPageData) {
50
50
  let sId; // the page ID
51
51
  let oAllCatalogs;
52
52
  let oAlterEgo; // page's representation with all relations removed
@@ -322,8 +322,6 @@ sap.ui.define([
322
322
  * @since 1.3.0
323
323
  */
324
324
  this.getBag = function (sBagId) {
325
- let oBag;
326
-
327
325
  if (bIsLoadingBagsOnDemand) {
328
326
  throw new SrvcError(`${that}: page is just a stub, load bags on demand`,
329
327
  "Page");
@@ -337,7 +335,7 @@ sap.ui.define([
337
335
  return mBags.get(sBagId);
338
336
  }
339
337
 
340
- oBag = new Bag(oFactory, { pageId: this.getId(), id: sBagId, $tmp: true });
338
+ const oBag = new Bag(oFactory, { pageId: this.getId(), id: sBagId, $tmp: true });
341
339
  mBags.put(sBagId, oBag);
342
340
  return oBag;
343
341
  };
@@ -909,7 +907,7 @@ sap.ui.define([
909
907
  }
910
908
  mBags = new Utils.Map();
911
909
  Log.debug(`Created: ${this}`, null, "Page");
912
- };
910
+ }
913
911
 
914
912
  return Page;
915
913
  });
@@ -58,7 +58,7 @@ sap.ui.define([
58
58
  * @augments ODataService
59
59
  * @since 1.2.0
60
60
  */
61
- const PageBuildingService = function (vODataBase, fnDefaultFailure, bIsPersonalization, sCacheId) {
61
+ function PageBuildingService (vODataBase, fnDefaultFailure, bIsPersonalization, sCacheId) {
62
62
  let oWrapper;
63
63
  const that = this;
64
64
 
@@ -117,10 +117,10 @@ sap.ui.define([
117
117
  /**
118
118
  * Evaluates status code from OData batch response entry and returns the corresponding OData
119
119
  * entity or the status message.
120
- * @param oEntry The batch response entry which is an element of
120
+ * @param {object} oEntry The batch response entry which is an element of
121
121
  * (For change) oData.__batchResponses[0]._changeResponses array
122
122
  * (For read) oData.__batchResponses array (without the element for change responses)
123
- * @returns OData entity (object or undefined) or status message as string
123
+ * @returns {object} OData entity (object or undefined) or status message as string
124
124
  *
125
125
  * @private
126
126
  */
@@ -264,7 +264,7 @@ sap.ui.define([
264
264
  // Note: drop excess parameters; try/catch
265
265
  Utils.callHandler(fnSuccess.bind(null, oData), fnFailure);
266
266
  }, oWrapper.onError.bind(oWrapper, "GET", sRequestUrl, fnFailure, /* oDeferred */undefined),
267
- OData.metadataHandler);
267
+ OData.metadataHandler);
268
268
  };
269
269
 
270
270
  /**
@@ -601,9 +601,9 @@ sap.ui.define([
601
601
  oWrapper.create(`CloneCatalog?sourceId='${encodeURIComponent(sCatalogId)
602
602
  }'&targetId='${encodeURIComponent(sNewDomainId)
603
603
  }${sNewTitle !== undefined ? `'&title='${encodeURIComponent(sNewTitle)}'` : "'"}`,
604
- {}, // payload
605
- fnSuccess,
606
- fnFailure);
604
+ {}, // payload
605
+ fnSuccess,
606
+ fnFailure);
607
607
  };
608
608
 
609
609
  /**
@@ -646,17 +646,17 @@ sap.ui.define([
646
646
  oWrapper.create(`ClonePageChipInstance?sourcePageId='${encodeURIComponent(sSourcePageId)
647
647
  }'&sourceChipInstanceId='${encodeURIComponent(sSourceChipInstanceId)
648
648
  }'&targetPageId='${encodeURIComponent(sTargetPageId)}'`,
649
- {}, // payload
650
- (oRawChipInstance) => {
651
- // ClonePageChipInstance cannot expand the result
652
- // Note: the CHIP instance cannot be remote and the CHIP has already been loaded
653
- oWrapper.read(`PageChipInstances(pageId='${encodeURIComponent(oRawChipInstance.pageId)
649
+ {}, // payload
650
+ (oRawChipInstance) => {
651
+ // ClonePageChipInstance cannot expand the result
652
+ // Note: the CHIP instance cannot be remote and the CHIP has already been loaded
653
+ oWrapper.read(`PageChipInstances(pageId='${encodeURIComponent(oRawChipInstance.pageId)
654
654
  }',instanceId='${encodeURIComponent(oRawChipInstance.instanceId)}')`
655
655
  + "?$expand=ChipInstanceBags/ChipInstanceProperties",
656
- fnSuccess,
657
- fnFailure);
658
- },
656
+ fnSuccess,
659
657
  fnFailure);
658
+ },
659
+ fnFailure);
660
660
  };
661
661
 
662
662
  /**
@@ -736,7 +736,6 @@ sap.ui.define([
736
736
  * @since 1.16.4
737
737
  */
738
738
  this.readCatalogChips = function (sCatalogId, aChipIds, fnSuccess, fnFailure) {
739
- let sUrl;
740
739
  let sFilter = "";
741
740
  let sPrefix = "?$filter=";
742
741
 
@@ -745,7 +744,7 @@ sap.ui.define([
745
744
  }
746
745
 
747
746
  // TODO: read also CHIP bags
748
- sUrl = `Catalogs('${encodeURIComponent(sCatalogId)}')/Chips`;
747
+ const sUrl = `Catalogs('${encodeURIComponent(sCatalogId)}')/Chips`;
749
748
  if (aChipIds) {
750
749
  if (!aChipIds.length) {
751
750
  throw new SrvcError("No CHIP IDs given", "PageBuildingService");
@@ -1133,7 +1132,7 @@ sap.ui.define([
1133
1132
 
1134
1133
  oWrapper.del(`PageChipInstances(pageId='${encodeURIComponent(sPageId)
1135
1134
  }',instanceId='${encodeURIComponent(sInstanceId)}')`,
1136
- fnSuccess, fnFailure);
1135
+ fnSuccess, fnFailure);
1137
1136
  };
1138
1137
 
1139
1138
  /**
@@ -1334,8 +1333,6 @@ sap.ui.define([
1334
1333
  */
1335
1334
  this.createProperty = function (vParent, sBagId, sPropertyName, sValue, sTranslatable,
1336
1335
  fnSuccess, fnFailure) {
1337
- let oProperty;
1338
-
1339
1336
  if (!vParent) {
1340
1337
  throw new SrvcError("Missing parent ID or object",
1341
1338
  "PageBuildingService");
@@ -1353,7 +1350,7 @@ sap.ui.define([
1353
1350
  return;
1354
1351
  }
1355
1352
 
1356
- oProperty = {
1353
+ const oProperty = {
1357
1354
  bagId: sBagId,
1358
1355
  name: sPropertyName,
1359
1356
  pageId: vParent,
@@ -1466,7 +1463,7 @@ sap.ui.define([
1466
1463
  }
1467
1464
 
1468
1465
  ODataService.call(this, oWrapper, fnDefaultFailure);
1469
- };
1466
+ }
1470
1467
 
1471
1468
  PageBuildingService._createODataWrapper = function (vODataBase, base) {
1472
1469
  return new ODataWrapper(vODataBase, base, /* bSupportsChangeSets=*/true);
@@ -41,8 +41,7 @@ sap.ui.define([
41
41
  * @since 1.11.0
42
42
  * @private
43
43
  */
44
- const PageSet = function (oFactory, sPageSetId) {
45
- let sId; // the page set ID
44
+ function PageSet (oFactory, sPageSetId) {
46
45
  let oAlterEgo; // page set's representation with all relations removed
47
46
  let oDefaultPage;
48
47
  let aPages = [];
@@ -50,6 +49,13 @@ sap.ui.define([
50
49
  let bIsStub = true;
51
50
  const that = this;
52
51
 
52
+ // constructor code -------------------------------------------------------
53
+ const sId = sPageSetId;
54
+ if (!sId) {
55
+ throw new SrvcError("Missing page set ID", "PageSet");
56
+ }
57
+ Log.debug(`Created: ${this}`, null, "PageSet");
58
+
53
59
  /**
54
60
  * Makes sure the given page set is not just a stub.
55
61
  *
@@ -453,14 +459,7 @@ sap.ui.define([
453
459
  aResult.push("})");
454
460
  return aResult.join("");
455
461
  };
456
-
457
- // constructor code -------------------------------------------------------
458
- sId = sPageSetId;
459
- if (!sId) {
460
- throw new SrvcError("Missing page set ID", "PageSet");
461
- }
462
- Log.debug(`Created: ${this}`, null, "PageSet");
463
- };
462
+ }
464
463
 
465
464
  return PageSet;
466
465
  });
@@ -18,7 +18,7 @@ sap.ui.define([
18
18
  * @class
19
19
  * @since 1.19.1
20
20
  */
21
- const RemoteCatalogService = function () {
21
+ function RemoteCatalogService () {
22
22
  // "public" methods --------------------------------------------------------
23
23
 
24
24
  /**
@@ -44,7 +44,7 @@ sap.ui.define([
44
44
  PageBuildingService.createPageBuildingService(sBaseUrl)
45
45
  .readCatalogChips(sCatalogId, aChipIds, fnSuccess, fnFailure);
46
46
  };
47
- };
47
+ }
48
48
 
49
49
  return RemoteCatalogService;
50
50
  });
@@ -19,48 +19,7 @@ sap.ui.define([
19
19
  ) => {
20
20
  "use strict";
21
21
 
22
- const Utils = function () { };
23
-
24
- // ensure that Function.prototype.bind is available, even with iOS 5
25
- // utils.js is used with startup service, shell API and page building services
26
- if (!Function.prototype.bind) {
27
- /**
28
- * Replacement for ECMAScript 5 feature which might still be missing.
29
- *
30
- * @param {object} oThis
31
- * The value to be passed as the <code>this</code> parameter to the target
32
- * function when the bound function is called. The value is ignored if the
33
- * bound function is constructed using the <code>new</code> operator.
34
- * @param {...object} aVarArgs
35
- * Arguments to prepend to arguments provided to the bound function when
36
- * invoking the target function.
37
- * @returns {function}
38
- * A function with the bound arguments aVarArgs
39
- *
40
- * @see <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind">bind in ECMAScript 5</a>
41
- */
42
- Function.prototype.bind = function (oThis) {
43
- /* eslint-enable no-extend-native */
44
- if (typeof this !== "function") {
45
- // closest thing possible to the ECMAScript 5 internal IsCallable function
46
- throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
47
- }
48
-
49
- const aArgs = Array.prototype.slice.call(arguments, 1);
50
- const that = this;
51
- const NOP = function () { /* no-op c'tor */ };
52
- const fBound = function () {
53
- return that.apply(
54
- // passing "window" as "this" has been removed (cf. "use strict";)
55
- this instanceof NOP ? this : oThis,
56
- aArgs.concat(Array.prototype.slice.call(arguments))
57
- );
58
- };
59
- NOP.prototype = this.prototype;
60
- fBound.prototype = new NOP();
61
- return fBound;
62
- };
63
- }
22
+ function Utils () { }
64
23
 
65
24
  // cache for GET requests
66
25
  let oCache;
@@ -85,7 +44,7 @@ sap.ui.define([
85
44
  /* jslint regexp: true */
86
45
 
87
46
  // default base is the page location
88
- sBase = sBase || location.href;
47
+ sBase = sBase || window.location.href;
89
48
  // base must be absolute
90
49
  if (sBase.indexOf("://") < 0 && sBase.charAt(0) !== "/") {
91
50
  throw new SrvcError(`Illegal base URL: ${sBase}`);
@@ -117,8 +76,6 @@ sap.ui.define([
117
76
  */
118
77
  Utils.callHandler = function (fnSuccess, fnFailure, bAsync) {
119
78
  // see also redundant declaration in sap.ushell.utils.call which has to be in sync
120
- let sMessage;
121
-
122
79
  if (bAsync) {
123
80
  setTimeout(() => {
124
81
  Utils.callHandler(fnSuccess, fnFailure, false);
@@ -128,10 +85,9 @@ sap.ui.define([
128
85
 
129
86
  try {
130
87
  fnSuccess();
131
- } catch (e) {
132
- sMessage = e.message || e.toString();
133
- Log.error(`Call to success handler failed: ${sMessage}`,
134
- e.stack);
88
+ } catch (oError) {
89
+ const sMessage = oError.message || oError.toString();
90
+ Log.error(`Call to success handler failed: ${sMessage}`, oError);
135
91
  if (fnFailure) {
136
92
  fnFailure(sMessage);
137
93
  }
@@ -230,10 +186,10 @@ sap.ui.define([
230
186
  }
231
187
  oXHR.send();
232
188
  Log.debug(`Sent request to URL ${sUrl}`, null);
233
- } catch (e) {
234
- Log.error(`Error '${e.message || e}' in request to URL ${sUrl}`,
189
+ } catch (oError) {
190
+ Log.error(`Error '${oError.message || oError}' in request to URL ${sUrl}`,
235
191
  null);
236
- throw e;
192
+ throw oError;
237
193
  }
238
194
  }
239
195
  };
@@ -285,15 +241,10 @@ sap.ui.define([
285
241
  * @private
286
242
  */
287
243
  Utils.removeCBAndNormalizeUrl = function (sUrl) {
288
- let aMatches;
289
244
  let sUrlPrefix;
290
245
  let sCacheBusterSegment;
291
246
  let sUrlPostfix;
292
247
 
293
- if (typeof sUrl !== "string" || sUrl === "" || isUriWithRelativeOrEmptyPath(sUrl)) {
294
- return sUrl;
295
- }
296
-
297
248
  function isUriWithRelativeOrEmptyPath (sUrl0) {
298
249
  const oUri = new URI(sUrl0);
299
250
  const sPath = oUri.path();
@@ -309,9 +260,13 @@ sap.ui.define([
309
260
  return true;
310
261
  }
311
262
 
263
+ if (typeof sUrl !== "string" || sUrl === "" || isUriWithRelativeOrEmptyPath(sUrl)) {
264
+ return sUrl;
265
+ }
266
+
312
267
  // split up the URL into 3 parts: prefix, cache-buster segment, postfix
313
268
  // leading slashes are always part of the segment, the postfix might have a trailing slash
314
- aMatches = sUrl.match(/(.*)(\/~[\w-]+~[A-Z0-9]?)(.*)/);
269
+ const aMatches = sUrl.match(/(.*)(\/~[\w-]+~[A-Z0-9]?)(.*)/);
315
270
  if (aMatches) {
316
271
  sUrlPrefix = aMatches[1];
317
272
  sCacheBusterSegment = aMatches[2];
@@ -384,11 +339,10 @@ sap.ui.define([
384
339
  const oPatterns = oCacheBusting && oCacheBusting.patterns;
385
340
  let sCacheBusterUrl = sUrl;
386
341
  let aParameterMap = [];
387
- let sSapUshellNoCb;
388
342
  const aRules = [];
389
343
 
390
344
  aParameterMap = Utils.getParameterMap();
391
- sSapUshellNoCb = aParameterMap["sap-ushell-nocb"] && aParameterMap["sap-ushell-nocb"][0];
345
+ const sSapUshellNoCb = aParameterMap["sap-ushell-nocb"] && aParameterMap["sap-ushell-nocb"][0];
392
346
 
393
347
  // When URL disables Cache Busting return URL without cache busting token
394
348
  // It can happen that we get a URL which already has a cache-buster token included (from the ABAP server), so we also remove
@@ -517,10 +471,8 @@ sap.ui.define([
517
471
  let sKey;
518
472
  let sValue;
519
473
  let iIndexOfEquals;
520
- let aKeyValuePairs;
521
- let aKeyValuePairsLength;
522
474
  // Note: location.search starts with "?" if not empty
523
- const sSearch = arguments.length > 0 ? sSearchString : location.search;
475
+ const sSearch = arguments.length > 0 ? sSearchString : window.location.search;
524
476
 
525
477
  if (sSearch && sSearch.charAt(0) !== "?") {
526
478
  throw new SrvcError(`Illegal search string ${sSearch}`);
@@ -532,8 +484,8 @@ sap.ui.define([
532
484
  // Note: W3C recommends that servers support ";" as well as "&"
533
485
  // (http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2)
534
486
  // http://unixpapa.com/js/querystring.html advocates this on the client-side also!
535
- aKeyValuePairs = sSearch.substring(1).replace(/\+/g, " ").split(/[&;]/);
536
- aKeyValuePairsLength = aKeyValuePairs.length < 500 ? aKeyValuePairs.length : 500;
487
+ const aKeyValuePairs = sSearch.substring(1).replace(/\+/g, " ").split(/[&;]/);
488
+ const aKeyValuePairsLength = aKeyValuePairs.length < 500 ? aKeyValuePairs.length : 500;
537
489
 
538
490
  for (i = 0, n = aKeyValuePairsLength; i < n; i += 1) {
539
491
  // decode key/value pair at first "=" character
@@ -574,7 +526,6 @@ sap.ui.define([
574
526
  */
575
527
  Utils.getParameterValue = function (sUrl, sName) {
576
528
  let oParameterMap;
577
- let iQueryIndex;
578
529
 
579
530
  if (typeof sName !== "string") {
580
531
  // avoid surprises when sName would later be converted into a string
@@ -582,7 +533,7 @@ sap.ui.define([
582
533
  }
583
534
 
584
535
  sUrl = sUrl.split("#")[0];
585
- iQueryIndex = sUrl.indexOf("?");
536
+ const iQueryIndex = sUrl.indexOf("?");
586
537
  if (iQueryIndex >= 0) {
587
538
  oParameterMap = Utils.getParameterMap(sUrl.slice(iQueryIndex));
588
539
  if (oParameterMap[sName]) {
@@ -630,11 +581,10 @@ sap.ui.define([
630
581
  * @since 1.2.0
631
582
  */
632
583
  Utils.parseXml = function (sXml) {
633
- let oXml;
634
584
  if (!sXml || typeof sXml !== "string") {
635
585
  return null;
636
586
  }
637
- oXml = new DOMParser().parseFromString(sXml, "text/xml");
587
+ const oXml = new DOMParser().parseFromString(sXml, "text/xml");
638
588
  if (oXml.getElementsByTagName("parsererror").length) { // Chrome, Firefox
639
589
  throw new SrvcError(`Invalid XML: ${sXml}`);
640
590
  }
@@ -211,12 +211,11 @@ sap.ui.define([
211
211
  * @see chip.types.getAvailableTypes
212
212
  */
213
213
  setType: function (sType) {
214
- let sTypeLowerCase;
215
214
  if (typeof sType !== "string" || sType === "") {
216
215
  throw new SrvcError("The given type is not a string",
217
216
  "contract.types");
218
217
  }
219
- sTypeLowerCase = sType.toLowerCase();
218
+ const sTypeLowerCase = sType.toLowerCase();
220
219
  if (this.getAvailableTypes().indexOf(sTypeLowerCase) < 0) {
221
220
  throw new SrvcError(`The CHIP does not support type '${sTypeLowerCase}'`,
222
221
  "contract.types");
@@ -230,9 +229,9 @@ sap.ui.define([
230
229
  }
231
230
  try {
232
231
  fnSetTypeHandler(sTypeLowerCase);
233
- } catch (e) {
232
+ } catch (oError) {
234
233
  Log.error(`Could not set CHIP type '${sTypeLowerCase}': ${
235
- e.message || e.toString()}`, null, "chip.types");
234
+ oError.message || oError.toString()}`, null, "chip.types");
236
235
  }
237
236
  }
238
237
  };
@@ -141,7 +141,7 @@ sap.ui.define([
141
141
  * @name chip.writeConfiguration.setParameterValues
142
142
  * @function
143
143
  * @since 1.7.0
144
- * @param {object<string,string>} mConfigurationUpdates
144
+ * @param {object<string, string>} mConfigurationUpdates
145
145
  * The configuration updates. The values must be strings. You can however set a value to
146
146
  * <code>undefined</code>. This removes it from the list of updated properties and effectively
147
147
  * resets it to the default value.
@@ -33,9 +33,9 @@ sap.ui.require([
33
33
  function callOnVisible () {
34
34
  try {
35
35
  fnOnVisible(bVisible);
36
- } catch (e) {
36
+ } catch (oError) {
37
37
  Log.error(`${oChipInstance}: call to visible handler failed: ${
38
- e.message || e.toString()}`, null, "chip.visible");
38
+ oError.message || oError.toString()}`, null, "chip.visible");
39
39
  }
40
40
  }
41
41
 
@@ -24,7 +24,7 @@ sap.ui.define([
24
24
  * @param {string} sAppId the ID of the app which is loaded
25
25
  * @returns {Promise<object>} a Promise resolving with the app data
26
26
  */
27
- AppInfoAdapter.prototype.getAppInfo = function (sAppId) {
27
+ AppInfoAdapter.prototype.getAppInfo = async function (sAppId) {
28
28
  const oUrlParams = new URLSearchParams(window.location.search);
29
29
 
30
30
  // TODO: app ID should always be passed by caller
@@ -35,7 +35,7 @@ sap.ui.define([
35
35
  if (sAppId) {
36
36
  return this._loadAppIndexData("/sap/bc/ui2/app_index/ui5_app_info_json", sAppId);
37
37
  }
38
- return Promise.reject(new Error("Cannot load app info - no app-id provided and URL parameter 'sap-ui-app-id' not set"));
38
+ return new Error("Cannot load app info - no app-id provided and URL parameter 'sap-ui-app-id' not set");
39
39
  };
40
40
 
41
41
  AppInfoAdapter.prototype._loadAppIndexData = function (sServiceUrl, sAppId) {