@ui5/webcomponents-localization 1.22.0-rc.1 → 1.22.0-rc.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/generated/assets/cldr/ar.json +102 -62
  4. package/dist/generated/assets/cldr/ar_EG.json +102 -62
  5. package/dist/generated/assets/cldr/ar_SA.json +102 -62
  6. package/dist/generated/assets/cldr/bg.json +364 -325
  7. package/dist/generated/assets/cldr/ca.json +491 -453
  8. package/dist/generated/assets/cldr/cs.json +431 -324
  9. package/dist/generated/assets/cldr/cy.json +608 -340
  10. package/dist/generated/assets/cldr/da.json +290 -227
  11. package/dist/generated/assets/cldr/de.json +348 -241
  12. package/dist/generated/assets/cldr/de_AT.json +348 -241
  13. package/dist/generated/assets/cldr/de_CH.json +347 -240
  14. package/dist/generated/assets/cldr/el.json +128 -100
  15. package/dist/generated/assets/cldr/el_CY.json +128 -100
  16. package/dist/generated/assets/cldr/en.json +538 -512
  17. package/dist/generated/assets/cldr/en_AU.json +583 -520
  18. package/dist/generated/assets/cldr/en_GB.json +485 -441
  19. package/dist/generated/assets/cldr/en_HK.json +519 -474
  20. package/dist/generated/assets/cldr/en_IE.json +485 -440
  21. package/dist/generated/assets/cldr/en_IN.json +465 -420
  22. package/dist/generated/assets/cldr/en_NZ.json +505 -460
  23. package/dist/generated/assets/cldr/en_PG.json +505 -460
  24. package/dist/generated/assets/cldr/en_SG.json +505 -460
  25. package/dist/generated/assets/cldr/en_ZA.json +485 -440
  26. package/dist/generated/assets/cldr/es.json +709 -456
  27. package/dist/generated/assets/cldr/es_AR.json +687 -434
  28. package/dist/generated/assets/cldr/es_BO.json +721 -468
  29. package/dist/generated/assets/cldr/es_CL.json +567 -422
  30. package/dist/generated/assets/cldr/es_CO.json +485 -339
  31. package/dist/generated/assets/cldr/es_MX.json +734 -481
  32. package/dist/generated/assets/cldr/es_PE.json +409 -372
  33. package/dist/generated/assets/cldr/es_UY.json +433 -396
  34. package/dist/generated/assets/cldr/es_VE.json +453 -416
  35. package/dist/generated/assets/cldr/et.json +340 -307
  36. package/dist/generated/assets/cldr/fa.json +96 -34
  37. package/dist/generated/assets/cldr/fi.json +359 -308
  38. package/dist/generated/assets/cldr/fr.json +347 -321
  39. package/dist/generated/assets/cldr/fr_BE.json +347 -321
  40. package/dist/generated/assets/cldr/fr_CA.json +458 -432
  41. package/dist/generated/assets/cldr/fr_CH.json +290 -264
  42. package/dist/generated/assets/cldr/fr_LU.json +347 -321
  43. package/dist/generated/assets/cldr/he.json +241 -130
  44. package/dist/generated/assets/cldr/hi.json +103 -53
  45. package/dist/generated/assets/cldr/hr.json +467 -410
  46. package/dist/generated/assets/cldr/hu.json +246 -195
  47. package/dist/generated/assets/cldr/id.json +478 -406
  48. package/dist/generated/assets/cldr/it.json +418 -362
  49. package/dist/generated/assets/cldr/it_CH.json +418 -362
  50. package/dist/generated/assets/cldr/ja.json +58 -18
  51. package/dist/generated/assets/cldr/kk.json +562 -398
  52. package/dist/generated/assets/cldr/ko.json +36 -15
  53. package/dist/generated/assets/cldr/lt.json +320 -231
  54. package/dist/generated/assets/cldr/lv.json +184 -120
  55. package/dist/generated/assets/cldr/ms.json +460 -388
  56. package/dist/generated/assets/cldr/nb.json +160 -92
  57. package/dist/generated/assets/cldr/nl.json +621 -373
  58. package/dist/generated/assets/cldr/nl_BE.json +621 -373
  59. package/dist/generated/assets/cldr/pl.json +590 -279
  60. package/dist/generated/assets/cldr/pt.json +696 -334
  61. package/dist/generated/assets/cldr/pt_PT.json +730 -454
  62. package/dist/generated/assets/cldr/ro.json +409 -339
  63. package/dist/generated/assets/cldr/ru.json +317 -279
  64. package/dist/generated/assets/cldr/ru_UA.json +312 -274
  65. package/dist/generated/assets/cldr/sk.json +454 -413
  66. package/dist/generated/assets/cldr/sl.json +118 -80
  67. package/dist/generated/assets/cldr/sr.json +294 -142
  68. package/dist/generated/assets/cldr/sr_Latn.json +972 -824
  69. package/dist/generated/assets/cldr/sv.json +382 -338
  70. package/dist/generated/assets/cldr/th.json +56 -36
  71. package/dist/generated/assets/cldr/tr.json +371 -320
  72. package/dist/generated/assets/cldr/uk.json +340 -290
  73. package/dist/generated/assets/cldr/vi.json +352 -328
  74. package/dist/generated/assets/cldr/zh_CN.json +34 -10
  75. package/dist/generated/assets/cldr/zh_HK.json +33 -9
  76. package/dist/generated/assets/cldr/zh_SG.json +33 -9
  77. package/dist/generated/assets/cldr/zh_TW.json +32 -8
  78. package/dist/sap/base/Event.js +59 -0
  79. package/dist/sap/base/Eventing.js +146 -0
  80. package/dist/sap/base/Log.js +2 -239
  81. package/dist/sap/base/assert.js +28 -1
  82. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  83. package/dist/sap/base/config.js +17 -0
  84. package/dist/sap/base/i18n/Formatting.js +1130 -0
  85. package/dist/sap/base/i18n/LanguageTag.js +168 -30
  86. package/dist/sap/base/i18n/date/CalendarType.js +36 -1
  87. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
  88. package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
  89. package/dist/sap/base/strings/camelize.js +30 -0
  90. package/dist/sap/base/strings/formatMessage.js +88 -15
  91. package/dist/sap/base/util/ObjectPath.js +95 -3
  92. package/dist/sap/base/util/Version.js +157 -0
  93. package/dist/sap/base/util/_merge.js +83 -26
  94. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  95. package/dist/sap/base/util/deepClone.js +102 -0
  96. package/dist/sap/base/util/deepEqual.js +75 -51
  97. package/dist/sap/base/util/extend.js +58 -7
  98. package/dist/sap/base/util/isEmptyObject.js +34 -0
  99. package/dist/sap/base/util/isPlainObject.js +35 -1
  100. package/dist/sap/base/util/now.js +24 -3
  101. package/dist/sap/base/util/resolveReference.js +157 -0
  102. package/dist/sap/base/util/uid.js +27 -0
  103. package/dist/sap/ui/base/DataType.js +657 -0
  104. package/dist/sap/ui/base/Interface.js +47 -1
  105. package/dist/sap/ui/base/Metadata.js +433 -180
  106. package/dist/sap/ui/base/Object.js +284 -48
  107. package/dist/sap/ui/core/CalendarType.js +23 -1
  108. package/dist/sap/ui/core/Locale.js +189 -57
  109. package/dist/sap/ui/core/LocaleData.js +2670 -1380
  110. package/dist/sap/ui/core/Supportability.js +5 -0
  111. package/dist/sap/ui/core/Theming.js +539 -0
  112. package/dist/sap/ui/core/date/Buddhist.js +162 -87
  113. package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
  114. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
  115. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  116. package/dist/sap/ui/core/date/Islamic.js +298 -185
  117. package/dist/sap/ui/core/date/Japanese.js +210 -115
  118. package/dist/sap/ui/core/date/Persian.js +324 -195
  119. package/dist/sap/ui/core/date/UI5Date.js +923 -237
  120. package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
  121. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  122. package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
  123. package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
  124. package/package-scripts.cjs +4 -10
  125. package/package.json +9 -5
  126. package/used-modules.txt +20 -1
  127. package/dist/sap/ui/Device.js +0 -5
@@ -1,59 +1,83 @@
1
- import Log from '../Log.js';
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ /*global Node */
7
+ //@evo-todo check isEqualNode dependency: not yet available...
8
+ //@evo-todo dependency to global name 'Node' contradicts sap/base package
9
+ import Log from "../Log.js";
10
+ /**
11
+ * Compares the two given values for equality, especially by comparing the content.
12
+ *
13
+ * <b>Note:</b> Function does not work with comparing XML objects.
14
+ *
15
+ * @function
16
+ * @since 1.58
17
+ * @param {any} a A value of any type
18
+ * @param {any} b A value of any type
19
+ * @param {int} [maxDepth=10] Maximum recursion depth
20
+ * @param {boolean} [contains] Whether all existing properties in a are equal as in b
21
+ * @alias module:sap/base/util/deepEqual
22
+ * @return {boolean} Whether a and b are equal
23
+ * @public
24
+ */
2
25
  var fnEqual = function (a, b, maxDepth, contains, depth) {
3
- if (typeof maxDepth == 'boolean') {
4
- contains = maxDepth;
5
- maxDepth = undefined;
6
- }
7
- if (!depth) {
8
- depth = 0;
26
+ // Optional parameter normalization
27
+ if (typeof maxDepth == "boolean") {
28
+ contains = maxDepth;
29
+ maxDepth = undefined;
30
+ }
31
+ if (!depth) {
32
+ depth = 0;
33
+ }
34
+ if (!maxDepth) {
35
+ maxDepth = 10;
36
+ }
37
+ if (depth > maxDepth) {
38
+ Log.warning("deepEqual comparison exceeded maximum recursion depth of " + maxDepth + ". Treating values as unequal");
39
+ return false;
40
+ }
41
+ if (a === b || Number.isNaN(a) && Number.isNaN(b)) {
42
+ return true;
43
+ }
44
+ if (Array.isArray(a) && Array.isArray(b)) {
45
+ if (!contains && a.length !== b.length) {
46
+ return false;
9
47
  }
10
- if (!maxDepth) {
11
- maxDepth = 10;
48
+ if (a.length > b.length) {
49
+ return false;
12
50
  }
13
- if (depth > maxDepth) {
14
- Log.warning('deepEqual comparison exceeded maximum recursion depth of ' + maxDepth + '. Treating values as unequal');
51
+ for (var i = 0; i < a.length; i++) {
52
+ if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
15
53
  return false;
54
+ }
16
55
  }
17
- if (a === b || Number.isNaN(a) && Number.isNaN(b)) {
18
- return true;
19
- }
20
- if (Array.isArray(a) && Array.isArray(b)) {
21
- if (!contains && a.length !== b.length) {
22
- return false;
23
- }
24
- if (a.length > b.length) {
25
- return false;
26
- }
27
- for (var i = 0; i < a.length; i++) {
28
- if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
29
- return false;
30
- }
31
- }
32
- return true;
33
- }
34
- if (typeof a == 'object' && typeof b == 'object') {
35
- if (!a || !b) {
36
- return false;
37
- }
38
- if (a.constructor !== b.constructor) {
39
- return false;
40
- }
41
- if (!contains && Object.keys(a).length !== Object.keys(b).length) {
42
- return false;
43
- }
44
- if (a instanceof Node) {
45
- return a.isEqualNode(b);
46
- }
47
- if (a instanceof Date) {
48
- return a.valueOf() === b.valueOf();
49
- }
50
- for (var i in a) {
51
- if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
52
- return false;
53
- }
54
- }
55
- return true;
56
+ return true;
57
+ }
58
+ if (typeof a == "object" && typeof b == "object") {
59
+ if (!a || !b) {
60
+ return false;
56
61
  }
57
- return false;
62
+ if (a.constructor !== b.constructor) {
63
+ return false;
64
+ }
65
+ if (!contains && Object.keys(a).length !== Object.keys(b).length) {
66
+ return false;
67
+ }
68
+ if (a instanceof Node) {
69
+ return a.isEqualNode(b);
70
+ }
71
+ if (a instanceof Date) {
72
+ return a.valueOf() === b.valueOf();
73
+ }
74
+ for (var i in a) {
75
+ if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
81
+ return false;
58
82
  };
59
83
  export default fnEqual;
@@ -1,10 +1,61 @@
1
- import _merge from './_merge.js';
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ import _merge from "./_merge.js";
7
+ /**
8
+ * Performs object extension by merging source objects into a target object. Generates a shallow copy.
9
+ *
10
+ * If during merging a key in the target object exists it is overwritten with the source object's value.
11
+ * Usage is the same as <code>jQuery.extend(...)</code>.
12
+ * Values that are <code>undefined</code> are ignored.
13
+ *
14
+ * As alternative you may also use <code>Object.assign</code>, but note that <code>Object.assign</code>
15
+ * only copies enumerable and own properties and doesn't copy properties on the prototype and non-enumerable
16
+ * properties. Also, values that are <code>undefined</code> are NOT ignored.
17
+ *
18
+ * For deep copies, you may use {@link module:sap/base/util/deepExtend sap/base/util/deepExtend}.
19
+ *
20
+ * @example
21
+ * var oResult = extend({}, {
22
+ * prop1: {
23
+ * prop1a: "1a"
24
+ * }
25
+ * }, {
26
+ * prop2: {
27
+ * prop2a: "2a"
28
+ * }
29
+ * }, {
30
+ * prop1: {
31
+ * prop1b: "1b"
32
+ * }
33
+ * }, {
34
+ * prop2: undefined
35
+ * });
36
+ *
37
+ *
38
+ * console.log(oResult);
39
+ * {
40
+ * "prop1": {
41
+ * "prop1b": "1b"
42
+ * },
43
+ * "prop2": {
44
+ * "prop2a": "2a"
45
+ * }
46
+ * }
47
+ *
48
+ * @function
49
+ * @alias module:sap/base/util/extend
50
+ * @param {object} target The object that will receive new properties
51
+ * @param {...object} [source] One or more objects which get merged into the target object
52
+ * @return {object} the target object which is the result of the merge
53
+ * @public
54
+ * @since 1.71
55
+ */
2
56
  var fnExtend = function () {
3
- var args = [
4
- false,
5
- true
6
- ];
7
- args.push.apply(args, arguments);
8
- return _merge.apply(null, args);
57
+ var args = [false, true];
58
+ args.push.apply(args, arguments);
59
+ return _merge.apply(null, args);
9
60
  };
10
61
  export default fnExtend;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Validates if the given object is empty, that is that it has no enumerable properties.
3
+ *
4
+ * Note that <code>null</code> and <code>undefined</code> comply with this definition of 'empty'.
5
+ * The behavior for non-object values is undefined and might change in future.
6
+ *
7
+ * @example
8
+ * require(["sap/base/util/isEmptyObject"], function(isEmptyObject){
9
+ * isEmptyObject({}); // true
10
+ * isEmptyObject({test: '123'}); // false
11
+ * isEmptyObject(null); // true
12
+ * isEmptyObject(undefined); // true
13
+ * });
14
+ *
15
+ * @function
16
+ * @since 1.65
17
+ * @public
18
+ * @name module:sap/base/util/isEmptyObject
19
+ * @param {Object} obj the object which is checked
20
+ * @returns {boolean} whether or not the given object is empty
21
+ */ /*!
22
+ * OpenUI5
23
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
24
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
25
+ */
26
+
27
+ var fnIsEmptyObject = function isEmptyObject(obj) {
28
+ // eslint-disable-next-line no-unreachable-loop
29
+ for (var sName in obj) {
30
+ return false;
31
+ }
32
+ return true;
33
+ };
34
+ export default fnIsEmptyObject;
@@ -1,18 +1,52 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
1
7
  var class2type = {};
2
8
  var hasOwn = class2type.hasOwnProperty;
3
9
  var toString = class2type.toString;
4
10
  var fnToString = hasOwn.toString;
5
11
  var ObjectFunctionString = fnToString.call(Object);
12
+
13
+ /**
14
+ * Checks whether the object is a plain object (created using "{}" or "new Object").
15
+ *
16
+ * @function
17
+ * @since 1.58
18
+ * @public
19
+ * @alias module:sap/base/util/isPlainObject
20
+ * @param {Object} obj the object which is checked
21
+ * @returns {boolean} whether or not the object is a plain object (created using "{}" or "new Object").
22
+ */
6
23
  var fnIsPlainObject = function (obj) {
24
+ /*
25
+ * The code in this function is taken from jQuery 3.6.0 "jQuery.isPlainObject" and got modified.
26
+ *
27
+ * jQuery JavaScript Library v3.6.0
28
+ * http://jquery.com/
29
+ *
30
+ * Copyright OpenJS Foundation and other contributors
31
+ * Released under the MIT license
32
+ * http://jquery.org/license
33
+ */
7
34
  var proto, Ctor;
35
+
36
+ // Detect obvious negatives
37
+ // Use toString instead of jQuery.type to catch host objects
8
38
  if (!obj || toString.call(obj) !== "[object Object]") {
9
39
  return false;
10
40
  }
11
41
  proto = Object.getPrototypeOf(obj);
42
+
43
+ // Objects with no prototype (e.g., `Object.create( null )`) are plain
12
44
  if (!proto) {
13
45
  return true;
14
46
  }
47
+
48
+ // Objects with a prototype are considered plain only if they were constructed by a global Object function
15
49
  Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
16
50
  return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
17
51
  };
18
- export default fnIsPlainObject;
52
+ export default fnIsPlainObject;
@@ -1,7 +1,28 @@
1
- var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
1
+ // @evo-todo window.performance does not exist on node.js, but there is a module performance-now. Maybe use it
2
+
3
+ /**
4
+ * Returns a high resolution timestamp in microseconds if supported by the environment, otherwise in milliseconds.
5
+ * The timestamp is based on 01/01/1970 00:00:00 (UNIX epoch) as float with microsecond precision or
6
+ * with millisecond precision, if high resolution timestamps are not available.
7
+ * The fractional part of the timestamp represents fractions of a millisecond.
8
+ * Converting to a <code>Date</code> is possible by using <code>require(["sap/base/util/now"], function(now){new Date(now());}</code>
9
+ *
10
+ * @function
11
+ * @since 1.58
12
+ * @public
13
+ * @alias module:sap/base/util/now
14
+ * @returns {float} timestamp in microseconds if supported by the environment otherwise in milliseconds
15
+ */ /*!
16
+ * OpenUI5
17
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
18
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
19
+ */
20
+ /*global performance */
21
+
22
+ var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : function () {
2
23
  var iNavigationStart = performance.timing.navigationStart;
3
24
  return function perfnow() {
4
25
  return iNavigationStart + performance.now();
5
26
  };
6
- })();
7
- export default fnNow;
27
+ }();
28
+ export default fnNow;
@@ -0,0 +1,157 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ import ObjectPath from "./ObjectPath.js";
7
+ // indicator if the reference can't be resolved
8
+ var oNotFound = Object.create(null);
9
+
10
+ /**
11
+ * Resolve the path segments under the given root context
12
+ *
13
+ * @param {array} aParts The path segments
14
+ * @param {object} oRoot The root context
15
+ * @param {object} [mOptions] Options
16
+ * @param {boolean} [mOptions.bindContext] When the resolved value is a
17
+ * function, whether the resolved function is bound to a context
18
+ * @param {boolean} [mOptions.rootContext] When the resolved value is a
19
+ * function and a rootContext is given, the resolved function is bound
20
+ * to this context instead of the object to which it belongs. If
21
+ * <code>mOptions.bindContext=false</code>, this option has no effect
22
+ * @return {any} The resolved value. If the value can't be resolved under the
23
+ * given root context, it returns <code>oNotFound</code>.
24
+ */
25
+ function _resolve(aParts, oRoot, mOptions) {
26
+ var vRef, oContext;
27
+ if (oRoot && aParts[0] in oRoot) {
28
+ // the path consists of at least two segments
29
+ // e.g. key "Module.namespace.function" -> function() {...}
30
+ oContext = aParts.length > 1 ? ObjectPath.get(aParts.slice(0, -1), oRoot) : oRoot;
31
+ vRef = oContext && oContext[aParts[aParts.length - 1]];
32
+ if (typeof vRef === "function" && mOptions.bindContext) {
33
+ vRef = vRef.bind(mOptions.rootContext || oContext);
34
+ }
35
+ return vRef;
36
+ }
37
+ return oNotFound;
38
+ }
39
+
40
+ /**
41
+ * Returns a value located in the provided path using the given
42
+ * <code>mVariables</code> object.
43
+ *
44
+ * If the provided path cannot be resolved completely, <code>undefined</code> is returned.
45
+ *
46
+ * How <code>mVariables</code> are checked for resolving the path depends on
47
+ * the syntax of the path:
48
+ * <ul>
49
+ * <li><i>absolute</i>: paths not starting with a dot ('.') are first checked through
50
+ * <code>mVariables</code>.</li>
51
+ * <li><i>relative</i>: paths starting with a dot ('.') are only checked through the dot variable
52
+ * <code>mVariables["."]</code> and not the other variables in <code>mVariables</code>.</li>
53
+ * <li><i>legacy</i>: when <code>mOptions.preferDotContext=true</code>, paths not starting
54
+ * with a dot ('.') are first checked through the dot Variable
55
+ * <code>mVariables["."]</code> and then - if nothing is found - through the other
56
+ * Variables in <code>mVariables</code>.</li>
57
+ * </ul>
58
+ *
59
+ * For an absolute path, when nothing is found after resolving the value within <code>mVariables</code>,
60
+ * <code>require</code> is called when <code>mOptions.useProbingRequire=true</code> to retrieve the
61
+ * module export of the loaded module with the given <code>sPath</code> after replacing '.' with '/' in
62
+ * the path. If the path can still not be resolved, the last fallback is taken to resolve
63
+ * <code>sPath</code> within the global scope <code>window</code>.
64
+ *
65
+ * When the resolved value is a function, a context may be bound to it with the following
66
+ * conditions:
67
+ * <ul>
68
+ * <li><i>No bound</i>: if the function is resolved from the global scope (not from any
69
+ * given variables in <code>mVariables</code>, it's not bound to any context. If the
70
+ * function exists directly under <code>mVariables</code>, nothing is bound.</li>
71
+ * <li><i>Bound</i>: otherwise, the resolved function is bound to the object to which it
72
+ * belongs</li>
73
+ * <li><i>mOptions.bindContext</i>: when this option is set to <code>false</code>, no
74
+ * context is bound to the resolved function regardless where the function is resolved
75
+ * </li>
76
+ * <li><i>mOptions.bindDotContext</i>: for paths starting with a dot ('.'),
77
+ * <code>mOptions.bindDotContext=false</code> turns off the automatic binding to the
78
+ * dot variable <code>mVariables["."]</code>. <code>mOptions.bindDotContext</code> has
79
+ * no effect when <code>mOptions.bindContext=false</code>.</li>
80
+ * </ul>
81
+ *
82
+ * @function
83
+ * @private
84
+ * @ui5-restricted sap.ui.core
85
+ * @since 1.69
86
+ *
87
+ * @param {string} sPath Path
88
+ * @param {object} [mVariables] An object containing the mapping of variable name to object or function
89
+ * @param {object} [mOptions] Options
90
+ * @param {boolean} [mOptions.preferDotContext=false] Whether the path not starting with a dot ('.') is
91
+ * resolved under the dot variable when it can not be resolved through the given variables object.
92
+ * @param {boolean} [mOptions.bindContext=true] When the resolved value is a function, whether the
93
+ * resolved function is bound to a context. When this property is set to false, the
94
+ * mOptions.bindDotContext has no effect anymore.
95
+ * @param {boolean} [mOptions.bindDotContext=true] When the resolved value is a function, whether the
96
+ * resolved function from a path which starts with a dot ('.') should be bound to the dot context
97
+ * @param {boolean} [mOptions.useProbingRequire=false] When the value cannot be resolved by using the
98
+ * given <code>mVariables</code>, <code>mOptions.useProbingRequire=true</code> leads to a call of
99
+ * <code>require</code> to get the module export of the loaded module under the given
100
+ * <code>sPath</code> after replacing the '.' with '/'.
101
+ * @returns {any} Returns the value located in the provided path, or <code>undefined</code> if the path
102
+ * does not exist completely.
103
+ * @alias module:sap/base/util/resolveReference
104
+ */
105
+ var resolveReference = function (sPath, mVariables, mOptions) {
106
+ // fill the default values
107
+ mVariables = mVariables || {};
108
+ mOptions = mOptions || {};
109
+ mOptions.bindContext = mOptions.bindContext !== false;
110
+ mOptions.bindDotContext = mOptions.bindDotContext !== false;
111
+ var aParts = sPath.split("."),
112
+ // if sPath starts with ".", split returns an empty string
113
+ // at the first position and the dot is used as variable
114
+ sVariable = aParts.shift() || ".",
115
+ bDotCase = sVariable === ".",
116
+ vRef = oNotFound;
117
+
118
+ // push the first part back to the array
119
+ aParts.unshift(sVariable);
120
+
121
+ // if preferDotContext, resolve the sPath under the dot context first for sPath which doesn't begin with "."
122
+ if (mOptions.preferDotContext && !bDotCase) {
123
+ vRef = _resolve(aParts, mVariables["."], {
124
+ bindContext: mOptions.bindContext && mOptions.bindDotContext,
125
+ // resolve function in dot variable should always bind the dot variable
126
+ rootContext: mVariables["."]
127
+ });
128
+ }
129
+
130
+ // If sPath isn't resolved yet, resolve the path under mVariables
131
+ if (vRef === oNotFound) {
132
+ vRef = _resolve(aParts, mVariables, {
133
+ bindContext: mOptions.bindContext
134
+ // dot case: mOptions.bindDotContext determines whether context should be bound
135
+ // non dot case: bind context if sPath contains more than one segment
136
+ && (bDotCase ? mOptions.bindDotContext : aParts.length > 1),
137
+ rootContext: bDotCase ? mVariables["."] : undefined
138
+ });
139
+ }
140
+ if (!bDotCase) {
141
+ if (vRef === oNotFound && mOptions.useProbingRequire) {
142
+ vRef = require(sPath.replace(/\./g, "/"));
143
+ if (vRef === undefined) {
144
+ vRef = oNotFound;
145
+ }
146
+ }
147
+
148
+ // resolve the path under global scope, only when it can't be resolved under mVariables
149
+ if (vRef === oNotFound) {
150
+ // fallback if no value could be found under the given sPath's first segment
151
+ // otherwise resolve under global namespace
152
+ vRef = ObjectPath.get(sPath);
153
+ }
154
+ }
155
+ return vRef === oNotFound ? undefined : vRef;
156
+ };
157
+ export default resolveReference;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Some private variable used for creation of (pseudo-)unique IDs.
3
+ * @type int
4
+ * @private
5
+ */ /*!
6
+ * OpenUI5
7
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
8
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
9
+ */
10
+
11
+ var iIdCounter = 0;
12
+
13
+ /**
14
+ * Creates and returns a pseudo-unique ID.
15
+ *
16
+ * No means for detection of overlap with already present or future UIDs.
17
+ *
18
+ * @function
19
+ * @since 1.58
20
+ * @alias module:sap/base/util/uid
21
+ * @return {string} A pseudo-unique id.
22
+ * @public
23
+ */
24
+ var fnUid = function uid() {
25
+ return "id-" + new Date().valueOf() + "-" + iIdCounter++;
26
+ };
27
+ export default fnUid;