@ui5/webcomponents-localization 0.0.0-0fcda382e → 0.0.0-10f3c0dc7

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 (275) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +2427 -0
  4. package/LICENSE.txt +201 -0
  5. package/README.md +38 -10
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/Assets-fetch.d.ts +1 -0
  8. package/dist/Assets-fetch.js +3 -0
  9. package/dist/Assets-fetch.js.map +1 -0
  10. package/dist/Assets-node.d.ts +11 -0
  11. package/dist/Assets-node.js +12 -0
  12. package/dist/Assets-node.js.map +1 -0
  13. package/dist/Assets.d.ts +1 -0
  14. package/dist/Assets.js +1 -0
  15. package/dist/Assets.js.map +1 -0
  16. package/dist/CalendarUtils.d.ts +3 -0
  17. package/dist/CalendarUtils.js +6 -0
  18. package/dist/CalendarUtils.js.map +1 -0
  19. package/dist/DateFormat.d.ts +28 -0
  20. package/dist/DateFormat.js +22 -2
  21. package/dist/DateFormat.js.map +1 -0
  22. package/dist/Locale.d.ts +5 -0
  23. package/dist/Locale.js +7 -0
  24. package/dist/Locale.js.map +1 -0
  25. package/dist/LocaleData.d.ts +5 -0
  26. package/dist/LocaleData.js +6 -2
  27. package/dist/LocaleData.js.map +1 -0
  28. package/dist/NumberFormat.d.ts +5 -0
  29. package/dist/NumberFormat.js +7 -0
  30. package/dist/NumberFormat.js.map +1 -0
  31. package/dist/dates/CalendarDate.d.ts +42 -0
  32. package/dist/dates/CalendarDate.js +171 -181
  33. package/dist/dates/CalendarDate.js.map +1 -0
  34. package/dist/dates/ExtremeDates.d.ts +5 -0
  35. package/dist/dates/ExtremeDates.js +29 -0
  36. package/dist/dates/ExtremeDates.js.map +1 -0
  37. package/dist/dates/UI5Date.d.ts +5 -0
  38. package/dist/dates/UI5Date.js +7 -0
  39. package/dist/dates/UI5Date.js.map +1 -0
  40. package/dist/dates/UniversalDate.d.ts +47 -0
  41. package/dist/dates/UniversalDate.js +5 -0
  42. package/dist/dates/UniversalDate.js.map +1 -0
  43. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  44. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  45. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  46. package/dist/dates/getDaysInMonth.d.ts +3 -0
  47. package/dist/dates/getDaysInMonth.js +10 -0
  48. package/dist/dates/getDaysInMonth.js.map +1 -0
  49. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  50. package/dist/dates/getRoundedTimestamp.js +15 -0
  51. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  52. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  53. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  54. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  55. package/dist/dates/modifyDateBy.d.ts +14 -0
  56. package/dist/dates/modifyDateBy.js +55 -0
  57. package/dist/dates/modifyDateBy.js.map +1 -0
  58. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  59. package/dist/dates/transformDateToSecondaryType.js +18 -0
  60. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  61. package/dist/features/calendar/Buddhist.js +1 -0
  62. package/dist/features/calendar/Buddhist.js.map +1 -0
  63. package/dist/features/calendar/Gregorian.js +1 -0
  64. package/dist/features/calendar/Gregorian.js.map +1 -0
  65. package/dist/features/calendar/Islamic.js +1 -0
  66. package/dist/features/calendar/Islamic.js.map +1 -0
  67. package/dist/features/calendar/Japanese.js +1 -0
  68. package/dist/features/calendar/Japanese.js.map +1 -0
  69. package/dist/features/calendar/Persian.js +1 -0
  70. package/dist/features/calendar/Persian.js.map +1 -0
  71. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +39 -0
  72. package/dist/generated/assets/cldr/ar.json +2179 -728
  73. package/dist/generated/assets/cldr/ar_EG.json +2179 -728
  74. package/dist/generated/assets/cldr/ar_SA.json +2275 -825
  75. package/dist/generated/assets/cldr/bg.json +1924 -798
  76. package/dist/generated/assets/cldr/ca.json +2027 -816
  77. package/dist/generated/assets/cldr/cnr.json +6476 -0
  78. package/dist/generated/assets/cldr/cs.json +1865 -842
  79. package/dist/generated/assets/cldr/cy.json +6566 -0
  80. package/dist/generated/assets/cldr/da.json +1844 -682
  81. package/dist/generated/assets/cldr/de.json +1806 -546
  82. package/dist/generated/assets/cldr/de_AT.json +1797 -537
  83. package/dist/generated/assets/cldr/de_CH.json +1879 -611
  84. package/dist/generated/assets/cldr/el.json +1497 -383
  85. package/dist/generated/assets/cldr/el_CY.json +1497 -383
  86. package/dist/generated/assets/cldr/en.json +1990 -563
  87. package/dist/generated/assets/cldr/en_AU.json +2339 -763
  88. package/dist/generated/assets/cldr/en_GB.json +2170 -621
  89. package/dist/generated/assets/cldr/en_HK.json +2076 -628
  90. package/dist/generated/assets/cldr/en_IE.json +2038 -593
  91. package/dist/generated/assets/cldr/en_IN.json +2336 -704
  92. package/dist/generated/assets/cldr/en_NZ.json +2056 -611
  93. package/dist/generated/assets/cldr/en_PG.json +2049 -604
  94. package/dist/generated/assets/cldr/en_SG.json +2041 -593
  95. package/dist/generated/assets/cldr/en_ZA.json +2046 -599
  96. package/dist/generated/assets/cldr/es.json +2197 -881
  97. package/dist/generated/assets/cldr/es_AR.json +2167 -819
  98. package/dist/generated/assets/cldr/es_BO.json +2210 -863
  99. package/dist/generated/assets/cldr/es_CL.json +2087 -848
  100. package/dist/generated/assets/cldr/es_CO.json +1947 -707
  101. package/dist/generated/assets/cldr/es_MX.json +2446 -1091
  102. package/dist/generated/assets/cldr/es_PE.json +1912 -773
  103. package/dist/generated/assets/cldr/es_UY.json +1926 -795
  104. package/dist/generated/assets/cldr/es_VE.json +1920 -789
  105. package/dist/generated/assets/cldr/et.json +1761 -544
  106. package/dist/generated/assets/cldr/fa.json +1872 -566
  107. package/dist/generated/assets/cldr/fi.json +1959 -526
  108. package/dist/generated/assets/cldr/fr.json +1711 -460
  109. package/dist/generated/assets/cldr/fr_BE.json +1710 -459
  110. package/dist/generated/assets/cldr/fr_CA.json +2087 -814
  111. package/dist/generated/assets/cldr/fr_CH.json +1669 -418
  112. package/dist/generated/assets/cldr/fr_LU.json +1711 -460
  113. package/dist/generated/assets/cldr/he.json +2018 -1033
  114. package/dist/generated/assets/cldr/hi.json +1619 -348
  115. package/dist/generated/assets/cldr/hr.json +1855 -569
  116. package/dist/generated/assets/cldr/hu.json +1764 -551
  117. package/dist/generated/assets/cldr/id.json +1924 -601
  118. package/dist/generated/assets/cldr/it.json +1821 -666
  119. package/dist/generated/assets/cldr/it_CH.json +1827 -672
  120. package/dist/generated/assets/cldr/ja.json +1426 -109
  121. package/dist/generated/assets/cldr/kk.json +2251 -737
  122. package/dist/generated/assets/cldr/ko.json +1484 -196
  123. package/dist/generated/assets/cldr/lt.json +1714 -734
  124. package/dist/generated/assets/cldr/lv.json +1686 -682
  125. package/dist/generated/assets/cldr/mk.json +6177 -0
  126. package/dist/generated/assets/cldr/ms.json +1903 -595
  127. package/dist/generated/assets/cldr/nb.json +1548 -369
  128. package/dist/generated/assets/cldr/nl.json +1935 -511
  129. package/dist/generated/assets/cldr/nl_BE.json +1955 -531
  130. package/dist/generated/assets/cldr/pl.json +1873 -586
  131. package/dist/generated/assets/cldr/pt.json +2184 -753
  132. package/dist/generated/assets/cldr/pt_PT.json +2149 -778
  133. package/dist/generated/assets/cldr/ro.json +1847 -765
  134. package/dist/generated/assets/cldr/ru.json +2082 -755
  135. package/dist/generated/assets/cldr/ru_UA.json +2076 -749
  136. package/dist/generated/assets/cldr/sk.json +1860 -972
  137. package/dist/generated/assets/cldr/sl.json +1861 -920
  138. package/dist/generated/assets/cldr/sr.json +1829 -767
  139. package/dist/generated/assets/cldr/sr_Latn.json +6173 -0
  140. package/dist/generated/assets/cldr/sv.json +1789 -587
  141. package/dist/generated/assets/cldr/th.json +1704 -373
  142. package/dist/generated/assets/cldr/tr.json +1855 -587
  143. package/dist/generated/assets/cldr/uk.json +2166 -711
  144. package/dist/generated/assets/cldr/vi.json +2054 -709
  145. package/dist/generated/assets/cldr/zh_CN.json +1736 -397
  146. package/dist/generated/assets/cldr/zh_HK.json +1713 -374
  147. package/dist/generated/assets/cldr/zh_SG.json +1723 -384
  148. package/dist/generated/assets/cldr/zh_TW.json +1678 -371
  149. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  150. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  151. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  152. package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
  153. package/dist/generated/json-imports/LocaleData-node.js +93 -0
  154. package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
  155. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  156. package/dist/generated/json-imports/LocaleData.js +92 -95
  157. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  158. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  159. package/dist/getCachedLocaleDataInstance.js +12 -0
  160. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  161. package/dist/locale/getLocaleData.d.ts +11 -0
  162. package/dist/locale/getLocaleData.js +15 -17
  163. package/dist/locale/getLocaleData.js.map +1 -0
  164. package/dist/sap/base/Event.js +59 -0
  165. package/dist/sap/base/Eventing.js +147 -0
  166. package/dist/sap/base/Log.js +2 -248
  167. package/dist/sap/base/assert.js +31 -9
  168. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  169. package/dist/sap/base/config.js +17 -0
  170. package/dist/sap/base/future.js +12 -0
  171. package/dist/sap/base/i18n/Formatting.d.ts +13 -0
  172. package/dist/sap/base/i18n/Formatting.js +18 -0
  173. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  174. package/dist/sap/base/i18n/LanguageTag.js +179 -0
  175. package/dist/sap/base/i18n/Localization.d.ts +7 -0
  176. package/dist/sap/base/i18n/Localization.js +17 -0
  177. package/dist/sap/base/i18n/Localization.js.map +1 -0
  178. package/dist/sap/base/i18n/ResourceBundle.js +20 -0
  179. package/dist/sap/base/i18n/date/CalendarType.js +44 -0
  180. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +106 -0
  181. package/dist/sap/base/i18n/date/TimezoneUtils.js +471 -0
  182. package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
  183. package/dist/sap/base/strings/camelize.js +30 -0
  184. package/dist/sap/base/strings/formatMessage.js +93 -15
  185. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  186. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  187. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  188. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  189. package/dist/sap/base/util/ObjectPath.js +4 -33
  190. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  191. package/dist/sap/base/util/Properties.js +12 -0
  192. package/dist/sap/base/util/Version.js +163 -0
  193. package/dist/sap/base/util/_merge.js +83 -26
  194. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  195. package/dist/sap/base/util/deepClone.js +102 -0
  196. package/dist/sap/base/util/deepEqual.js +75 -55
  197. package/dist/sap/base/util/deepExtend.js +60 -0
  198. package/dist/sap/base/util/extend.js +58 -7
  199. package/dist/sap/base/util/fetch.js +8 -0
  200. package/dist/sap/base/util/isEmptyObject.js +34 -0
  201. package/dist/sap/base/util/isPlainObject.js +35 -1
  202. package/dist/sap/base/util/merge.js +57 -0
  203. package/dist/sap/base/util/mixedFetch.js +3 -0
  204. package/dist/sap/base/util/now.js +22 -7
  205. package/dist/sap/base/util/resolveReference.js +3 -0
  206. package/dist/sap/base/util/uid.js +27 -0
  207. package/dist/sap/ui/Device.js +25 -3
  208. package/dist/sap/ui/Global.js +1 -0
  209. package/dist/sap/ui/VersionInfo.js +14 -0
  210. package/dist/sap/ui/base/DataType.js +708 -0
  211. package/dist/sap/ui/base/DesignTime.js +11 -0
  212. package/dist/sap/ui/base/EventProvider.js +21 -0
  213. package/dist/sap/ui/base/Interface.js +50 -6
  214. package/dist/sap/ui/base/Metadata.js +470 -173
  215. package/dist/sap/ui/base/Object.js +287 -27
  216. package/dist/sap/ui/base/OwnStatics.js +6 -0
  217. package/dist/sap/ui/base/SyncPromise.js +98 -0
  218. package/dist/sap/ui/core/AnimationMode.js +42 -0
  219. package/dist/sap/ui/core/CalendarType.js +24 -8
  220. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  221. package/dist/sap/ui/core/Configuration.js +23 -0
  222. package/dist/sap/ui/core/Configuration.js.map +1 -0
  223. package/dist/sap/ui/core/ControlBehavior.js +11 -0
  224. package/dist/sap/ui/core/Core.d.ts +25 -0
  225. package/dist/sap/ui/core/Core.js +7 -32
  226. package/dist/sap/ui/core/Core.js.map +1 -0
  227. package/dist/sap/ui/core/FormatSettings.d.ts +9 -0
  228. package/dist/sap/ui/core/FormatSettings.js +12 -0
  229. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  230. package/dist/sap/ui/core/Lib.js +41 -0
  231. package/dist/sap/ui/core/Locale.js +190 -116
  232. package/dist/sap/ui/core/LocaleData.js +2837 -2683
  233. package/dist/sap/ui/core/Supportability.js +5 -0
  234. package/dist/sap/ui/core/Theming.js +39 -0
  235. package/dist/sap/ui/core/_UrlResolver.js +11 -0
  236. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  237. package/dist/sap/ui/core/date/CalendarUtils.js +67 -0
  238. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  239. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  240. package/dist/sap/ui/core/date/Islamic.js +298 -185
  241. package/dist/sap/ui/core/date/Japanese.js +212 -117
  242. package/dist/sap/ui/core/date/Persian.js +324 -195
  243. package/dist/sap/ui/core/date/UI5Date.js +1039 -0
  244. package/dist/sap/ui/core/date/UniversalDate.js +1241 -217
  245. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  246. package/dist/sap/ui/core/format/DateFormat.js +3160 -1781
  247. package/dist/sap/ui/core/format/FormatUtils.js +30 -0
  248. package/dist/sap/ui/core/format/NumberFormat.js +3164 -0
  249. package/dist/sap/ui/core/format/TimezoneUtil.js +93 -0
  250. package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
  251. package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
  252. package/dist/sap/ui/security/Security.js +12 -0
  253. package/dist/sap/ui/util/XMLHelper.js +11 -0
  254. package/dist/sap/ui/util/_URL.js +1 -0
  255. package/dist/ui5loader-autoconfig.js +1 -0
  256. package/package-scripts.cjs +35 -0
  257. package/package.json +27 -21
  258. package/tsconfig.json +24 -0
  259. package/used-modules.txt +33 -1
  260. package/dist/dates/calculateWeekNumber.js +0 -51
  261. package/package-scripts.js +0 -31
  262. package/src/Assets.js +0 -2
  263. package/src/DateFormat.js +0 -3
  264. package/src/LocaleData.js +0 -3
  265. package/src/dates/CalendarDate.js +0 -203
  266. package/src/dates/calculateWeekNumber.js +0 -51
  267. package/src/locale/getLocaleData.js +0 -27
  268. package/src/sap/base/util/LoaderExtensions.js +0 -7
  269. package/src/sap/ui/core/Core.js +0 -38
  270. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  271. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  272. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  273. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  274. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  275. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -1,221 +1,518 @@
1
- import ObjectPath from '../../base/util/ObjectPath.js';
2
- import Device from '../Device.js';
3
- import assert from '../../base/assert.js';
4
- import Log from '../../base/Log.js';
5
- import uniqueSort from '../../base/util/array/uniqueSort.js';
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ // Provides class sap.ui.base.Metadata
7
+ import ObjectPath from "../../base/util/ObjectPath.js";
8
+ import assert from "../../base/assert.js";
9
+ import Log from "../../base/Log.js";
10
+ import uniqueSort from "../../base/util/array/uniqueSort.js";
11
+ function isFunction(obj) {
12
+ return typeof obj === "function";
13
+ }
14
+
15
+ /**
16
+ * Creates a new metadata object from the given static infos.
17
+ *
18
+ * <b>Note:</b> Throughout this class documentation, the described subclass of Object
19
+ * is referenced as <i>the described class</i>.
20
+ *
21
+ * @param {string} sClassName Fully qualified name of the described class
22
+ * @param {object} oClassInfo Info to construct the class and its metadata from
23
+ * @param {sap.ui.base.Object.MetadataOptions} [oClassInfo.metadata]
24
+ * The metadata object describing the class
25
+ *
26
+ * @class Metadata for a class.
27
+ * @author Frank Weigel
28
+ * @version 1.146.0
29
+ * @since 0.8.6
30
+ * @public
31
+ * @alias sap.ui.base.Metadata
32
+ */
6
33
  var Metadata = function (sClassName, oClassInfo) {
7
- assert(typeof sClassName === 'string' && sClassName, 'Metadata: sClassName must be a non-empty string');
8
- assert(typeof oClassInfo === 'object', 'Metadata: oClassInfo must be empty or an object');
9
- if (!oClassInfo || typeof oClassInfo.metadata !== 'object') {
10
- oClassInfo = {
11
- metadata: oClassInfo || {},
12
- constructor: ObjectPath.get(sClassName)
13
- };
14
- oClassInfo.metadata.__version = 1;
15
- }
16
- oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
17
- if (typeof oClassInfo.constructor !== 'function') {
18
- throw Error('constructor for class ' + sClassName + ' must have been declared before creating metadata for it');
19
- }
20
- this._sClassName = sClassName;
21
- this._oClass = oClassInfo.constructor;
22
- this.extend(oClassInfo);
34
+ assert(typeof sClassName === "string" && sClassName, "Metadata: sClassName must be a non-empty string");
35
+ assert(typeof oClassInfo === "object", "Metadata: oClassInfo must be empty or an object");
36
+
37
+ /**
38
+ * Support for old usage of Metadata.
39
+ * @deprecated Since 1.3.1
40
+ */
41
+ if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
42
+ oClassInfo = {
43
+ metadata: oClassInfo || {},
44
+ // retrieve class by its name. Using a lookup costs time but avoids the need for redundant arguments to this function
45
+ constructor: ObjectPath.get(sClassName) // legacy-relevant, code path not used by extend call
46
+ };
47
+ oClassInfo.metadata.__version = 1.0;
48
+ }
49
+ oClassInfo.metadata ??= {};
50
+ oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2.0;
51
+ if (!isFunction(oClassInfo.constructor)) {
52
+ throw Error("constructor for class " + sClassName + " must have been declared before creating metadata for it");
53
+ }
54
+
55
+ // invariant: oClassInfo exists, oClassInfo.metadata exists, oClassInfo.constructor exists
56
+ this._sClassName = sClassName;
57
+ this._oClass = oClassInfo.constructor;
58
+ this.extend(oClassInfo);
23
59
  };
60
+
61
+ /**
62
+ * @private
63
+ * @final
64
+ */
24
65
  Metadata.prototype.extend = function (oClassInfo) {
25
- this.applySettings(oClassInfo);
26
- this.afterApplySettings();
66
+ this.applySettings(oClassInfo);
67
+ this.afterApplySettings();
27
68
  };
69
+
70
+ /**
71
+ * @private
72
+ * @since 1.3.1
73
+ */
28
74
  Metadata.prototype.applySettings = function (oClassInfo) {
29
- var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
30
- if (oStaticInfo.baseType) {
31
- var oParentClass = ObjectPath.get(oStaticInfo.baseType);
32
- if (typeof oParentClass !== 'function') {
33
- Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
34
- }
35
- if (oParentClass.getMetadata) {
36
- this._oParent = oParentClass.getMetadata();
37
- assert(oParentClass === oParentClass.getMetadata().getClass(), 'Metadata: oParentClass must match the class in the parent metadata');
38
- } else {
39
- this._oParent = new Metadata(oStaticInfo.baseType, {});
40
- }
75
+ var that = this,
76
+ oStaticInfo = oClassInfo.metadata,
77
+ oPrototype;
78
+ if (oStaticInfo.baseType) {
79
+ var oParentClass,
80
+ bValidBaseType = isFunction(oStaticInfo.baseType);
81
+ if (bValidBaseType) {
82
+ oParentClass = oStaticInfo.baseType;
83
+ if (!isFunction(oParentClass.getMetadata)) {
84
+ throw new TypeError("baseType must be a UI5 class with a static getMetadata function");
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @deprecated
90
+ */
91
+ if (!bValidBaseType) {
92
+ // lookup base class by its name - same reasoning as above
93
+ oParentClass = ObjectPath.get(oStaticInfo.baseType); // legacy-relevant, code path not used by extend call
94
+ if (!isFunction(oParentClass)) {
95
+ Log.fatal("base class '" + oStaticInfo.baseType + "' does not exist");
96
+ }
97
+ }
98
+
99
+ // link metadata with base metadata
100
+ if (oParentClass.getMetadata) {
101
+ this._oParent = oParentClass.getMetadata();
102
+ assert(oParentClass === oParentClass.getMetadata().getClass(), "Metadata: oParentClass must match the class in the parent metadata");
41
103
  } else {
42
- this._oParent = undefined;
104
+ // fallback, if base class has no metadata - can only happen if baseType is a string
105
+ this._oParent = new Metadata(oStaticInfo.baseType, {});
43
106
  }
44
- this._bAbstract = !!oStaticInfo['abstract'];
45
- this._bFinal = !!oStaticInfo['final'];
46
- this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : 'object');
47
- this._bDeprecated = !!oStaticInfo['deprecated'];
48
- this._aInterfaces = oStaticInfo.interfaces || [];
49
- this._aPublicMethods = oStaticInfo.publicMethods || [];
50
- this._bInterfacesUnique = false;
51
- oPrototype = this._oClass.prototype;
52
- for (var n in oClassInfo) {
53
- if (n !== 'metadata' && n !== 'constructor') {
54
- oPrototype[n] = oClassInfo[n];
55
- if (!n.match(/^_|^on|^init$|^exit$/)) {
56
- that._aPublicMethods.push(n);
57
- }
58
- }
107
+ } else {
108
+ this._oParent = undefined;
109
+ }
110
+ this._bAbstract = !!oStaticInfo["abstract"];
111
+ this._bFinal = !!oStaticInfo["final"];
112
+ this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : "object");
113
+ this._bDeprecated = !!oStaticInfo["deprecated"];
114
+
115
+ // handle interfaces
116
+ this._aInterfaces = oStaticInfo.interfaces || [];
117
+
118
+ // take over metadata from static info
119
+ this._aPublicMethods = oStaticInfo.publicMethods || [];
120
+
121
+ // interfaces info possibly not unique
122
+ this._bInterfacesUnique = false;
123
+
124
+ // enrich prototype
125
+ oPrototype = this._oClass.prototype;
126
+ for (var n in oClassInfo) {
127
+ if (n !== "metadata" && n !== "constructor") {
128
+ oPrototype[n] = oClassInfo[n];
129
+ if (!n.match(/^_|^on|^init$|^exit$/)) {
130
+ // TODO hard coded knowledge about event handlers ("on") and about init/exit hooks is not nice....
131
+ that._aPublicMethods.push(n);
132
+ }
59
133
  }
134
+ }
60
135
  };
136
+
137
+ /**
138
+ * Called after new settings have been applied.
139
+ *
140
+ * Typically, this method is used to do some cleanup (e.g. uniqueness)
141
+ * or to calculate an optimized version of some data.
142
+ * @private
143
+ * @since 1.3.1
144
+ */
61
145
  Metadata.prototype.afterApplySettings = function () {
62
- if (this._oParent) {
63
- this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
64
- this._bInterfacesUnique = false;
65
- } else {
66
- this._aAllPublicMethods = this._aPublicMethods;
67
- }
146
+ // create the flattened "all" view
147
+ if (this._oParent) {
148
+ this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
149
+ this._bInterfacesUnique = false;
150
+ } else {
151
+ this._aAllPublicMethods = this._aPublicMethods;
152
+ }
68
153
  };
154
+
155
+ /**
156
+ * Stereotype of the described class.
157
+ *
158
+ * @private
159
+ * @ui5-restricted
160
+ */
69
161
  Metadata.prototype.getStereotype = function () {
70
- return this._sStereotype;
162
+ return this._sStereotype;
71
163
  };
164
+
165
+ /**
166
+ * Returns the fully qualified name of the described class
167
+ * @return {string} name of the described class
168
+ * @public
169
+ */
72
170
  Metadata.prototype.getName = function () {
73
- return this._sClassName;
171
+ return this._sClassName;
74
172
  };
173
+
174
+ /**
175
+ * Returns the (constructor of the) described class
176
+ * @return {function(new:sap.ui.base.Object)} class described by this metadata
177
+ * @public
178
+ */
75
179
  Metadata.prototype.getClass = function () {
76
- return this._oClass;
180
+ return this._oClass;
77
181
  };
182
+
183
+ /**
184
+ * Returns the metadata object of the base class of the described class
185
+ * or undefined if the class has no (documented) base class.
186
+ *
187
+ * @return {sap.ui.base.Metadata | undefined} metadata of the base class
188
+ * @public
189
+ */
78
190
  Metadata.prototype.getParent = function () {
79
- return this._oParent;
191
+ return this._oParent;
80
192
  };
193
+
194
+ /**
195
+ * Removes duplicate names in place from the interfaces and public methods members of this metadata object.
196
+ *
197
+ * @private
198
+ */
81
199
  Metadata.prototype._dedupInterfaces = function () {
82
- if (!this._bInterfacesUnique) {
83
- uniqueSort(this._aInterfaces);
84
- uniqueSort(this._aPublicMethods);
85
- uniqueSort(this._aAllPublicMethods);
86
- this._bInterfacesUnique = true;
87
- }
200
+ if (!this._bInterfacesUnique) {
201
+ uniqueSort(this._aInterfaces);
202
+ uniqueSort(this._aPublicMethods);
203
+ uniqueSort(this._aAllPublicMethods);
204
+ this._bInterfacesUnique = true;
205
+ }
88
206
  };
207
+
208
+ /**
209
+ * Returns an array with the names of the public methods declared by the described class, methods of
210
+ * ancestors are not listed.
211
+ *
212
+ * @return {string[]} array with names of public methods declared by the described class
213
+ * @deprecated As of 1.58, this method should not be used for productive code. The accuracy of the returned
214
+ * information highly depends on the concrete class and is not actively monitored. There might be
215
+ * more public methods or some of the returned methods might not really be intended for public use.
216
+ * In general, pure visibility information should not be exposed in runtime metadata but be part of the
217
+ * documentation.
218
+ * Subclasses of <code>sap.ui.base.Object</code> might decide to provide runtime metadata describing
219
+ * their public API, but this then should not be backed by this method.
220
+ * See {@link sap.ui.core.mvc.ControllerMetadata#getAllMethods} for an example.
221
+ * @public
222
+ */
89
223
  Metadata.prototype.getPublicMethods = function () {
90
- this._dedupInterfaces();
91
- return this._aPublicMethods;
224
+ this._dedupInterfaces();
225
+ return this._aPublicMethods;
92
226
  };
227
+
228
+ /**
229
+ * Returns an array with the names of all public methods declared by the described class
230
+ * and all its ancestors classes.
231
+ *
232
+ * @return {string[]} array with names of all public methods provided by the described class and its ancestors
233
+ * @deprecated As of 1.58, this method should not be used for productive code. The accuracy of the returned
234
+ * information highly depends on the concrete class and is not actively monitored. There might be
235
+ * more public methods or some of the returned methods might not really be intended for public use.
236
+ * In general, pure visibility information should not be exposed in runtime metadata but be part of the
237
+ * documentation.
238
+ * Subclasses of <code>sap.ui.base.Object</code> might decide to provide runtime metadata describing
239
+ * their public API, but this then should not be backed by this method.
240
+ * See {@link sap.ui.core.mvc.ControllerMetadata#getAllMethods} for an example.
241
+ * @public
242
+ */
93
243
  Metadata.prototype.getAllPublicMethods = function () {
94
- this._dedupInterfaces();
95
- return this._aAllPublicMethods;
244
+ this._dedupInterfaces();
245
+ return this._aAllPublicMethods;
96
246
  };
247
+
248
+ /**
249
+ * Returns the names of interfaces implemented by the described class.
250
+ * As the representation of interfaces is not clear yet, this method is still private.
251
+ *
252
+ * @return {string} array of names of implemented interfaces
253
+ * @private
254
+ */
97
255
  Metadata.prototype.getInterfaces = function () {
98
- this._dedupInterfaces();
99
- return this._aInterfaces;
256
+ this._dedupInterfaces();
257
+ return this._aInterfaces;
100
258
  };
259
+
260
+ /**
261
+ * Checks whether the described class or one of its ancestor classes implements the given interface.
262
+ *
263
+ * @param {string} sInterface name of the interface to test for (in dot notation)
264
+ * @return {boolean} whether this class implements the interface
265
+ * @public
266
+ */
101
267
  Metadata.prototype.isInstanceOf = function (sInterface) {
102
- if (this._oParent) {
103
- if (this._oParent.isInstanceOf(sInterface)) {
104
- return true;
105
- }
268
+ if (this._oParent) {
269
+ if (this._oParent.isInstanceOf(sInterface)) {
270
+ return true;
106
271
  }
107
- var a = this._aInterfaces;
108
- for (var i = 0, l = a.length; i < l; i++) {
109
- if (a[i] === sInterface) {
110
- return true;
111
- }
272
+ }
273
+ var a = this._aInterfaces;
274
+ for (var i = 0, l = a.length; i < l; i++) {
275
+ // FIXME doesn't handle interface inheritance (requires object representation for interfaces)
276
+ if (a[i] === sInterface) {
277
+ return true;
112
278
  }
113
- return false;
279
+ }
280
+ return false;
114
281
  };
115
- var WRITABLE_IFF_PHANTOM = !!Device.browser.phantomJS;
116
- Object.defineProperty(Metadata.prototype, '_mImplementedTypes', {
117
- get: function () {
118
- if (this === Metadata.prototype) {
119
- throw new Error('sap.ui.base.Metadata: The \'_mImplementedTypes\' property must not be accessed on the prototype');
120
- }
121
- var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
122
- result[this._sClassName] = true;
123
- var aInterfaces = this._aInterfaces, i = aInterfaces.length;
124
- while (i-- > 0) {
125
- if (!result[aInterfaces[i]]) {
126
- result[aInterfaces[i]] = true;
127
- }
128
- }
129
- Object.defineProperty(this, '_mImplementedTypes', {
130
- value: Object.freeze(result),
131
- writable: WRITABLE_IFF_PHANTOM,
132
- configurable: false
133
- });
134
- return result;
135
- },
136
- configurable: true
282
+
283
+ /*
284
+ * Lazy calculation of the set of implemented types.
285
+ *
286
+ * A calculation function is configured as getter for the <code>_mImplementedTypes</code>
287
+ * on the prototype object. On first call for a metadata instance, it collects
288
+ * the implemented types (classes, interfaces) from the described class and
289
+ * any base classes and writes it to the property <code>_mImplementedTypes</code> of the
290
+ * current instance of metadata. Future read access to the property will immediately
291
+ * return the instance property and not call the calculation function again.
292
+ */
293
+ Object.defineProperty(Metadata.prototype, "_mImplementedTypes", {
294
+ get: function () {
295
+ if (this === Metadata.prototype) {
296
+ throw new Error("sap.ui.base.Metadata: The '_mImplementedTypes' property must not be accessed on the prototype");
297
+ }
298
+
299
+ // create map of types, including inherited types
300
+ // Note: to save processing time and memory, the inherited types are merged via the prototype chain of 'result'
301
+ var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
302
+ /*
303
+ * Flat alternative:
304
+ * var result = Object.create(null);
305
+ * if ( this._oParent ) {
306
+ * Object.assign(result, this._oParent._mImplementedTypes);
307
+ * }
308
+ */
309
+
310
+ // add own class
311
+ result[this._sClassName] = true;
312
+
313
+ // additionally collect interfaces
314
+ var aInterfaces = this._aInterfaces,
315
+ i = aInterfaces.length;
316
+ while (i-- > 0) {
317
+ if (!result[aInterfaces[i]]) {
318
+ // take care to write property only if it hasn't been set already
319
+ result[aInterfaces[i]] = true;
320
+ }
321
+ }
322
+
323
+ // write instance property, hiding the getter on the prototype
324
+ Object.defineProperty(this, "_mImplementedTypes", {
325
+ value: Object.freeze(result),
326
+ writable: false,
327
+ configurable: false
328
+ });
329
+ return result;
330
+ },
331
+ configurable: true
137
332
  });
333
+
334
+ /**
335
+ * Checks whether the class described by this metadata object is of the named type.
336
+ *
337
+ * This check is solely based on the type names as declared in the class metadata.
338
+ * It compares the given <code>vTypeName</code> with the name of this class, with the
339
+ * names of any base class of this class and with the names of all interfaces
340
+ * implemented by any of the aforementioned classes.
341
+ *
342
+ * Instead of a single type name, an array of type names can be given and the method
343
+ * will check if this class is of any of the listed types (logical or).
344
+ *
345
+ * Should the UI5 class system in future implement additional means of associating classes
346
+ * with type names (e.g. by introducing mixins), then this method might detect matches
347
+ * for those names as well.
348
+ *
349
+ * @param {string|string[]} vTypeName Type or types to check for
350
+ * @returns {boolean} Whether this class is of the given type or of any of the given types
351
+ * @public
352
+ * @since 1.56
353
+ */
138
354
  Metadata.prototype.isA = function (vTypeName) {
139
- var mTypes = this._mImplementedTypes;
140
- if (Array.isArray(vTypeName)) {
141
- for (var i = 0; i < vTypeName.length; i++) {
142
- if (vTypeName[i] in mTypes) {
143
- return true;
144
- }
145
- }
146
- return false;
355
+ var mTypes = this._mImplementedTypes;
356
+ if (Array.isArray(vTypeName)) {
357
+ for (var i = 0; i < vTypeName.length; i++) {
358
+ if (vTypeName[i] in mTypes) {
359
+ return true;
360
+ }
147
361
  }
148
- return vTypeName in mTypes;
362
+ return false;
363
+ }
364
+ // Note: the check with 'in' also finds inherited types via the prototype chain of mTypes
365
+ return vTypeName in mTypes;
149
366
  };
367
+
368
+ /**
369
+ * Returns whether the described class is abstract
370
+ * @return {boolean} whether the class is abstract
371
+ * @public
372
+ */
150
373
  Metadata.prototype.isAbstract = function () {
151
- return this._bAbstract;
374
+ return this._bAbstract;
152
375
  };
376
+
377
+ /**
378
+ * Returns whether the described class is final
379
+ * @return {boolean} whether the class is final
380
+ * @public
381
+ */
153
382
  Metadata.prototype.isFinal = function () {
154
- return this._bFinal;
383
+ return this._bFinal;
155
384
  };
385
+
386
+ /**
387
+ * Whether the described class is deprecated and should not be used any more
388
+ *
389
+ * @return {boolean} whether the class is considered deprecated
390
+ * @public
391
+ * @since 1.26.4
392
+ */
156
393
  Metadata.prototype.isDeprecated = function () {
157
- return this._bDeprecated;
394
+ return this._bDeprecated;
158
395
  };
159
- Metadata.prototype.addPublicMethods = function (sMethod) {
160
- var aNames = sMethod instanceof Array ? sMethod : arguments;
161
- Array.prototype.push.apply(this._aPublicMethods, aNames);
162
- Array.prototype.push.apply(this._aAllPublicMethods, aNames);
163
- this._bInterfacesUnique = false;
396
+
397
+ /**
398
+ * Adds one or more new methods to the list of API methods.
399
+ *
400
+ * Can be used by contributer classes (like the EnabledPropagator) to enrich the declared set of methods.
401
+ * The method can either be called with multiple names (strings) or with one array of strings.
402
+ *
403
+ * <b>Note</b>: the newly added method(s) will only be visible in {@link sap.ui.base.Interface interface}
404
+ * objects that are created <i>after</i> this method has been called.
405
+ *
406
+ * @param {string|string[]} sMethod name(s) of the new method(s)
407
+ */
408
+ Metadata.prototype.addPublicMethods = function (sMethod /* ... */) {
409
+ var aNames = sMethod instanceof Array ? sMethod : arguments;
410
+ Array.prototype.push.apply(this._aPublicMethods, aNames);
411
+ Array.prototype.push.apply(this._aAllPublicMethods, aNames);
412
+ this._bInterfacesUnique = false;
413
+ };
414
+
415
+ /**
416
+ * Traverse up through the parent chain to find the static property on the class.
417
+ *
418
+ * @param {string} sStaticName The name of the static property
419
+ * @returns {any} If found, returns the static property
420
+ * @private
421
+ * @ui5-restricted sap.ui.core
422
+ */
423
+ Metadata.prototype.getStaticProperty = function (sStaticName) {
424
+ let oMetadata = this;
425
+ while (oMetadata && !(sStaticName in oMetadata.getClass())) {
426
+ oMetadata = oMetadata.getParent();
427
+ }
428
+ const oClass = oMetadata?.getClass();
429
+ return oClass?.[sStaticName];
164
430
  };
431
+
432
+ /**
433
+ * @since 1.3.1
434
+ * @private
435
+ */
165
436
  Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl) {
166
- if (typeof fnBaseClass === 'string') {
167
- FNMetaImpl = oClassInfo;
168
- oClassInfo = sClassName;
169
- sClassName = fnBaseClass;
170
- fnBaseClass = null;
171
- }
172
- assert(!fnBaseClass || typeof fnBaseClass === 'function');
173
- assert(typeof sClassName === 'string' && !!sClassName);
174
- assert(!oClassInfo || typeof oClassInfo === 'object');
175
- assert(!FNMetaImpl || typeof FNMetaImpl === 'function');
176
- FNMetaImpl = FNMetaImpl || Metadata;
177
- if (typeof FNMetaImpl.preprocessClassInfo === 'function') {
178
- oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
179
- }
180
- oClassInfo = oClassInfo || {};
181
- oClassInfo.metadata = oClassInfo.metadata || {};
182
- if (!oClassInfo.hasOwnProperty('constructor')) {
183
- oClassInfo.constructor = undefined;
184
- }
185
- var fnClass = oClassInfo.constructor;
186
- assert(!fnClass || typeof fnClass === 'function');
187
- if (fnBaseClass) {
188
- if (!fnClass) {
189
- if (oClassInfo.metadata.deprecated) {
190
- fnClass = function () {
191
- Log.warning('Usage of deprecated class: ' + sClassName);
192
- fnBaseClass.apply(this, arguments);
193
- };
194
- } else {
195
- fnClass = function () {
196
- fnBaseClass.apply(this, arguments);
197
- };
198
- }
199
- }
200
- fnClass.prototype = Object.create(fnBaseClass.prototype);
201
- fnClass.prototype.constructor = fnClass;
202
- oClassInfo.metadata.baseType = fnBaseClass.getMetadata().getName();
203
- } else {
204
- fnClass = fnClass || function () {
437
+ if (typeof fnBaseClass === "string") {
438
+ FNMetaImpl = oClassInfo;
439
+ oClassInfo = sClassName;
440
+ sClassName = fnBaseClass;
441
+ fnBaseClass = null;
442
+ }
443
+ assert(!fnBaseClass || isFunction(fnBaseClass));
444
+ assert(typeof sClassName === "string" && !!sClassName);
445
+ assert(!oClassInfo || typeof oClassInfo === "object");
446
+ assert(!FNMetaImpl || isFunction(FNMetaImpl));
447
+ FNMetaImpl = FNMetaImpl || Metadata;
448
+
449
+ /**
450
+ * allow metadata class to preprocess
451
+ * Component- and UIComponentMetadata uses this to derive if "component.json"
452
+ * must be loaded synchronously.
453
+ * @deprecated
454
+ */
455
+ if (isFunction(FNMetaImpl.preprocessClassInfo)) {
456
+ oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
457
+ }
458
+
459
+ // normalize oClassInfo
460
+ oClassInfo = oClassInfo || {};
461
+ oClassInfo.metadata = oClassInfo.metadata || {};
462
+ if (!oClassInfo.hasOwnProperty('constructor')) {
463
+ oClassInfo.constructor = undefined;
464
+ }
465
+ var fnClass = oClassInfo.constructor;
466
+ assert(!fnClass || isFunction(fnClass));
467
+
468
+ // ensure defaults
469
+ if (fnBaseClass) {
470
+ // default constructor just delegates to base class
471
+ if (!fnClass) {
472
+ if (oClassInfo.metadata.deprecated) {
473
+ // create default factory with deprecation warning
474
+ fnClass = function () {
475
+ Log.warning("Usage of deprecated class: " + sClassName);
476
+ fnBaseClass.apply(this, arguments);
205
477
  };
206
- delete oClassInfo.metadata.baseType;
207
- }
208
- oClassInfo.constructor = fnClass;
209
- ObjectPath.set(sClassName, fnClass);
210
- var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
211
- fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
212
- return oMetadata;
213
- };
214
- if (!fnClass.getMetadata().isFinal()) {
215
- fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
216
- return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
478
+ } else {
479
+ // create default factory
480
+ fnClass = function () {
481
+ fnBaseClass.apply(this, arguments);
217
482
  };
483
+ }
218
484
  }
219
- return fnClass;
485
+ // create prototype chain
486
+ fnClass.prototype = Object.create(fnBaseClass.prototype);
487
+ fnClass.prototype.constructor = fnClass;
488
+ // enforce correct baseType
489
+ oClassInfo.metadata.baseType = fnBaseClass;
490
+ } else {
491
+ // default constructor does nothing
492
+ fnClass = fnClass || function () {};
493
+ // enforce correct baseType
494
+ delete oClassInfo.metadata.baseType;
495
+ }
496
+ oClassInfo.constructor = fnClass;
497
+
498
+ /**
499
+ * make the class visible as JS Object
500
+ * @deprecated
501
+ */
502
+ ObjectPath.set(sClassName, fnClass);
503
+
504
+ // add metadata
505
+ var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
506
+ fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
507
+ return oMetadata;
508
+ };
509
+
510
+ // enrich function
511
+ if (!fnClass.getMetadata().isFinal()) {
512
+ fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
513
+ return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
514
+ };
515
+ }
516
+ return fnClass;
220
517
  };
221
518
  export default Metadata;