@ui5/webcomponents-localization 0.0.0-4821618b2 → 0.0.0-49bade48d

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 (284) hide show
  1. package/.eslintignore +2 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +2355 -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 -201
  33. package/dist/dates/CalendarDate.js.map +1 -0
  34. package/dist/dates/ExtremeDates.d.ts +5 -0
  35. package/dist/dates/ExtremeDates.js +25 -35
  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 +10 -9
  51. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  52. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  53. package/dist/dates/getTodayUTCTimestamp.js +3 -3
  54. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  55. package/dist/dates/modifyDateBy.d.ts +14 -0
  56. package/dist/dates/modifyDateBy.js +42 -29
  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 +2176 -727
  73. package/dist/generated/assets/cldr/ar_EG.json +2176 -727
  74. package/dist/generated/assets/cldr/ar_SA.json +2272 -824
  75. package/dist/generated/assets/cldr/bg.json +1921 -797
  76. package/dist/generated/assets/cldr/ca.json +2024 -815
  77. package/dist/generated/assets/cldr/cnr.json +6476 -0
  78. package/dist/generated/assets/cldr/cs.json +1862 -841
  79. package/dist/generated/assets/cldr/cy.json +2050 -1370
  80. package/dist/generated/assets/cldr/da.json +1841 -681
  81. package/dist/generated/assets/cldr/de.json +1803 -545
  82. package/dist/generated/assets/cldr/de_AT.json +1794 -536
  83. package/dist/generated/assets/cldr/de_CH.json +1876 -610
  84. package/dist/generated/assets/cldr/el.json +1494 -382
  85. package/dist/generated/assets/cldr/el_CY.json +1494 -382
  86. package/dist/generated/assets/cldr/en.json +1987 -562
  87. package/dist/generated/assets/cldr/en_AU.json +2336 -762
  88. package/dist/generated/assets/cldr/en_GB.json +2167 -620
  89. package/dist/generated/assets/cldr/en_HK.json +2073 -627
  90. package/dist/generated/assets/cldr/en_IE.json +2035 -592
  91. package/dist/generated/assets/cldr/en_IN.json +2333 -703
  92. package/dist/generated/assets/cldr/en_NZ.json +2053 -610
  93. package/dist/generated/assets/cldr/en_PG.json +2046 -603
  94. package/dist/generated/assets/cldr/en_SG.json +2038 -592
  95. package/dist/generated/assets/cldr/en_ZA.json +2043 -598
  96. package/dist/generated/assets/cldr/es.json +2194 -880
  97. package/dist/generated/assets/cldr/es_AR.json +2164 -818
  98. package/dist/generated/assets/cldr/es_BO.json +2207 -862
  99. package/dist/generated/assets/cldr/es_CL.json +2084 -847
  100. package/dist/generated/assets/cldr/es_CO.json +1944 -706
  101. package/dist/generated/assets/cldr/es_MX.json +2443 -1090
  102. package/dist/generated/assets/cldr/es_PE.json +1909 -772
  103. package/dist/generated/assets/cldr/es_UY.json +1923 -794
  104. package/dist/generated/assets/cldr/es_VE.json +1917 -788
  105. package/dist/generated/assets/cldr/et.json +1758 -543
  106. package/dist/generated/assets/cldr/fa.json +1869 -565
  107. package/dist/generated/assets/cldr/fi.json +1956 -525
  108. package/dist/generated/assets/cldr/fr.json +1708 -459
  109. package/dist/generated/assets/cldr/fr_BE.json +1707 -458
  110. package/dist/generated/assets/cldr/fr_CA.json +2084 -813
  111. package/dist/generated/assets/cldr/fr_CH.json +1666 -417
  112. package/dist/generated/assets/cldr/fr_LU.json +1708 -459
  113. package/dist/generated/assets/cldr/he.json +2015 -1032
  114. package/dist/generated/assets/cldr/hi.json +1616 -347
  115. package/dist/generated/assets/cldr/hr.json +1852 -568
  116. package/dist/generated/assets/cldr/hu.json +1761 -550
  117. package/dist/generated/assets/cldr/id.json +1921 -600
  118. package/dist/generated/assets/cldr/it.json +1818 -665
  119. package/dist/generated/assets/cldr/it_CH.json +1824 -671
  120. package/dist/generated/assets/cldr/ja.json +1423 -108
  121. package/dist/generated/assets/cldr/kk.json +2248 -736
  122. package/dist/generated/assets/cldr/ko.json +1481 -195
  123. package/dist/generated/assets/cldr/lt.json +1711 -733
  124. package/dist/generated/assets/cldr/lv.json +1683 -681
  125. package/dist/generated/assets/cldr/mk.json +6177 -0
  126. package/dist/generated/assets/cldr/ms.json +1900 -594
  127. package/dist/generated/assets/cldr/nb.json +1545 -368
  128. package/dist/generated/assets/cldr/nl.json +1932 -510
  129. package/dist/generated/assets/cldr/nl_BE.json +1952 -530
  130. package/dist/generated/assets/cldr/pl.json +1870 -585
  131. package/dist/generated/assets/cldr/pt.json +2181 -752
  132. package/dist/generated/assets/cldr/pt_PT.json +2146 -777
  133. package/dist/generated/assets/cldr/ro.json +1844 -764
  134. package/dist/generated/assets/cldr/ru.json +2079 -754
  135. package/dist/generated/assets/cldr/ru_UA.json +2073 -748
  136. package/dist/generated/assets/cldr/sk.json +1857 -971
  137. package/dist/generated/assets/cldr/sl.json +1859 -920
  138. package/dist/generated/assets/cldr/sr.json +1826 -766
  139. package/dist/generated/assets/cldr/sr_Latn.json +2179 -1135
  140. package/dist/generated/assets/cldr/sv.json +1786 -586
  141. package/dist/generated/assets/cldr/th.json +1701 -372
  142. package/dist/generated/assets/cldr/tr.json +1852 -586
  143. package/dist/generated/assets/cldr/uk.json +2163 -710
  144. package/dist/generated/assets/cldr/vi.json +2051 -708
  145. package/dist/generated/assets/cldr/zh_CN.json +1733 -396
  146. package/dist/generated/assets/cldr/zh_HK.json +1710 -373
  147. package/dist/generated/assets/cldr/zh_SG.json +1720 -383
  148. package/dist/generated/assets/cldr/zh_TW.json +1675 -370
  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 +89 -88
  157. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  158. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  159. package/dist/getCachedLocaleDataInstance.js +8 -9
  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 +9 -12
  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 +47 -1
  214. package/dist/sap/ui/base/Metadata.js +470 -171
  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 -140
  232. package/dist/sap/ui/core/LocaleData.js +2836 -2703
  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 -219
  245. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  246. package/dist/sap/ui/core/format/DateFormat.js +3160 -1790
  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 +22 -23
  258. package/tsconfig.json +24 -0
  259. package/used-modules.txt +33 -1
  260. package/dist/Assets-static.js +0 -2
  261. package/dist/dates/calculateWeekNumber.js +0 -51
  262. package/dist/generated/json-imports/LocaleData-static.js +0 -89
  263. package/hash.txt +0 -1
  264. package/package-scripts.js +0 -40
  265. package/src/Assets-static.js +0 -2
  266. package/src/Assets.js +0 -2
  267. package/src/DateFormat.js +0 -3
  268. package/src/LocaleData.js +0 -3
  269. package/src/dates/CalendarDate.js +0 -223
  270. package/src/dates/ExtremeDates.js +0 -39
  271. package/src/dates/calculateWeekNumber.js +0 -51
  272. package/src/dates/getRoundedTimestamp.js +0 -14
  273. package/src/dates/getTodayUTCTimestamp.js +0 -9
  274. package/src/dates/modifyDateBy.js +0 -42
  275. package/src/getCachedLocaleDataInstance.js +0 -13
  276. package/src/locale/getLocaleData.js +0 -27
  277. package/src/sap/base/util/LoaderExtensions.js +0 -17
  278. package/src/sap/ui/core/Core.js +0 -38
  279. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  280. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  281. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  282. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  283. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  284. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -1,219 +1,518 @@
1
- import ObjectPath from '../../base/util/ObjectPath.js';
2
- import assert from '../../base/assert.js';
3
- import Log from '../../base/Log.js';
4
- 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
+ */
5
33
  var Metadata = function (sClassName, oClassInfo) {
6
- assert(typeof sClassName === 'string' && sClassName, 'Metadata: sClassName must be a non-empty string');
7
- assert(typeof oClassInfo === 'object', 'Metadata: oClassInfo must be empty or an object');
8
- if (!oClassInfo || typeof oClassInfo.metadata !== 'object') {
9
- oClassInfo = {
10
- metadata: oClassInfo || {},
11
- constructor: ObjectPath.get(sClassName)
12
- };
13
- oClassInfo.metadata.__version = 1;
14
- }
15
- oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
16
- if (typeof oClassInfo.constructor !== 'function') {
17
- throw Error('constructor for class ' + sClassName + ' must have been declared before creating metadata for it');
18
- }
19
- this._sClassName = sClassName;
20
- this._oClass = oClassInfo.constructor;
21
- 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);
22
59
  };
60
+
61
+ /**
62
+ * @private
63
+ * @final
64
+ */
23
65
  Metadata.prototype.extend = function (oClassInfo) {
24
- this.applySettings(oClassInfo);
25
- this.afterApplySettings();
66
+ this.applySettings(oClassInfo);
67
+ this.afterApplySettings();
26
68
  };
69
+
70
+ /**
71
+ * @private
72
+ * @since 1.3.1
73
+ */
27
74
  Metadata.prototype.applySettings = function (oClassInfo) {
28
- var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
29
- if (oStaticInfo.baseType) {
30
- var oParentClass = ObjectPath.get(oStaticInfo.baseType);
31
- if (typeof oParentClass !== 'function') {
32
- Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
33
- }
34
- if (oParentClass.getMetadata) {
35
- this._oParent = oParentClass.getMetadata();
36
- assert(oParentClass === oParentClass.getMetadata().getClass(), 'Metadata: oParentClass must match the class in the parent metadata');
37
- } else {
38
- this._oParent = new Metadata(oStaticInfo.baseType, {});
39
- }
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");
40
103
  } else {
41
- 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, {});
42
106
  }
43
- this._bAbstract = !!oStaticInfo['abstract'];
44
- this._bFinal = !!oStaticInfo['final'];
45
- this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : 'object');
46
- this._bDeprecated = !!oStaticInfo['deprecated'];
47
- this._aInterfaces = oStaticInfo.interfaces || [];
48
- this._aPublicMethods = oStaticInfo.publicMethods || [];
49
- this._bInterfacesUnique = false;
50
- oPrototype = this._oClass.prototype;
51
- for (var n in oClassInfo) {
52
- if (n !== 'metadata' && n !== 'constructor') {
53
- oPrototype[n] = oClassInfo[n];
54
- if (!n.match(/^_|^on|^init$|^exit$/)) {
55
- that._aPublicMethods.push(n);
56
- }
57
- }
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
+ }
58
133
  }
134
+ }
59
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
+ */
60
145
  Metadata.prototype.afterApplySettings = function () {
61
- if (this._oParent) {
62
- this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
63
- this._bInterfacesUnique = false;
64
- } else {
65
- this._aAllPublicMethods = this._aPublicMethods;
66
- }
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
+ }
67
153
  };
154
+
155
+ /**
156
+ * Stereotype of the described class.
157
+ *
158
+ * @private
159
+ * @ui5-restricted
160
+ */
68
161
  Metadata.prototype.getStereotype = function () {
69
- return this._sStereotype;
162
+ return this._sStereotype;
70
163
  };
164
+
165
+ /**
166
+ * Returns the fully qualified name of the described class
167
+ * @return {string} name of the described class
168
+ * @public
169
+ */
71
170
  Metadata.prototype.getName = function () {
72
- return this._sClassName;
171
+ return this._sClassName;
73
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
+ */
74
179
  Metadata.prototype.getClass = function () {
75
- return this._oClass;
180
+ return this._oClass;
76
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
+ */
77
190
  Metadata.prototype.getParent = function () {
78
- return this._oParent;
191
+ return this._oParent;
79
192
  };
193
+
194
+ /**
195
+ * Removes duplicate names in place from the interfaces and public methods members of this metadata object.
196
+ *
197
+ * @private
198
+ */
80
199
  Metadata.prototype._dedupInterfaces = function () {
81
- if (!this._bInterfacesUnique) {
82
- uniqueSort(this._aInterfaces);
83
- uniqueSort(this._aPublicMethods);
84
- uniqueSort(this._aAllPublicMethods);
85
- this._bInterfacesUnique = true;
86
- }
200
+ if (!this._bInterfacesUnique) {
201
+ uniqueSort(this._aInterfaces);
202
+ uniqueSort(this._aPublicMethods);
203
+ uniqueSort(this._aAllPublicMethods);
204
+ this._bInterfacesUnique = true;
205
+ }
87
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
+ */
88
223
  Metadata.prototype.getPublicMethods = function () {
89
- this._dedupInterfaces();
90
- return this._aPublicMethods;
224
+ this._dedupInterfaces();
225
+ return this._aPublicMethods;
91
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
+ */
92
243
  Metadata.prototype.getAllPublicMethods = function () {
93
- this._dedupInterfaces();
94
- return this._aAllPublicMethods;
244
+ this._dedupInterfaces();
245
+ return this._aAllPublicMethods;
95
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
+ */
96
255
  Metadata.prototype.getInterfaces = function () {
97
- this._dedupInterfaces();
98
- return this._aInterfaces;
256
+ this._dedupInterfaces();
257
+ return this._aInterfaces;
99
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
+ */
100
267
  Metadata.prototype.isInstanceOf = function (sInterface) {
101
- if (this._oParent) {
102
- if (this._oParent.isInstanceOf(sInterface)) {
103
- return true;
104
- }
268
+ if (this._oParent) {
269
+ if (this._oParent.isInstanceOf(sInterface)) {
270
+ return true;
105
271
  }
106
- var a = this._aInterfaces;
107
- for (var i = 0, l = a.length; i < l; i++) {
108
- if (a[i] === sInterface) {
109
- return true;
110
- }
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;
111
278
  }
112
- return false;
279
+ }
280
+ return false;
113
281
  };
114
- Object.defineProperty(Metadata.prototype, '_mImplementedTypes', {
115
- get: function () {
116
- if (this === Metadata.prototype) {
117
- throw new Error('sap.ui.base.Metadata: The \'_mImplementedTypes\' property must not be accessed on the prototype');
118
- }
119
- var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
120
- result[this._sClassName] = true;
121
- var aInterfaces = this._aInterfaces, i = aInterfaces.length;
122
- while (i-- > 0) {
123
- if (!result[aInterfaces[i]]) {
124
- result[aInterfaces[i]] = true;
125
- }
126
- }
127
- Object.defineProperty(this, '_mImplementedTypes', {
128
- value: Object.freeze(result),
129
- writable: false,
130
- configurable: false
131
- });
132
- return result;
133
- },
134
- 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
135
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
+ */
136
354
  Metadata.prototype.isA = function (vTypeName) {
137
- var mTypes = this._mImplementedTypes;
138
- if (Array.isArray(vTypeName)) {
139
- for (var i = 0; i < vTypeName.length; i++) {
140
- if (vTypeName[i] in mTypes) {
141
- return true;
142
- }
143
- }
144
- 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
+ }
145
361
  }
146
- 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;
147
366
  };
367
+
368
+ /**
369
+ * Returns whether the described class is abstract
370
+ * @return {boolean} whether the class is abstract
371
+ * @public
372
+ */
148
373
  Metadata.prototype.isAbstract = function () {
149
- return this._bAbstract;
374
+ return this._bAbstract;
150
375
  };
376
+
377
+ /**
378
+ * Returns whether the described class is final
379
+ * @return {boolean} whether the class is final
380
+ * @public
381
+ */
151
382
  Metadata.prototype.isFinal = function () {
152
- return this._bFinal;
383
+ return this._bFinal;
153
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
+ */
154
393
  Metadata.prototype.isDeprecated = function () {
155
- return this._bDeprecated;
394
+ return this._bDeprecated;
156
395
  };
157
- Metadata.prototype.addPublicMethods = function (sMethod) {
158
- var aNames = sMethod instanceof Array ? sMethod : arguments;
159
- Array.prototype.push.apply(this._aPublicMethods, aNames);
160
- Array.prototype.push.apply(this._aAllPublicMethods, aNames);
161
- 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];
162
430
  };
431
+
432
+ /**
433
+ * @since 1.3.1
434
+ * @private
435
+ */
163
436
  Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl) {
164
- if (typeof fnBaseClass === 'string') {
165
- FNMetaImpl = oClassInfo;
166
- oClassInfo = sClassName;
167
- sClassName = fnBaseClass;
168
- fnBaseClass = null;
169
- }
170
- assert(!fnBaseClass || typeof fnBaseClass === 'function');
171
- assert(typeof sClassName === 'string' && !!sClassName);
172
- assert(!oClassInfo || typeof oClassInfo === 'object');
173
- assert(!FNMetaImpl || typeof FNMetaImpl === 'function');
174
- FNMetaImpl = FNMetaImpl || Metadata;
175
- if (typeof FNMetaImpl.preprocessClassInfo === 'function') {
176
- oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
177
- }
178
- oClassInfo = oClassInfo || {};
179
- oClassInfo.metadata = oClassInfo.metadata || {};
180
- if (!oClassInfo.hasOwnProperty('constructor')) {
181
- oClassInfo.constructor = undefined;
182
- }
183
- var fnClass = oClassInfo.constructor;
184
- assert(!fnClass || typeof fnClass === 'function');
185
- if (fnBaseClass) {
186
- if (!fnClass) {
187
- if (oClassInfo.metadata.deprecated) {
188
- fnClass = function () {
189
- Log.warning('Usage of deprecated class: ' + sClassName);
190
- fnBaseClass.apply(this, arguments);
191
- };
192
- } else {
193
- fnClass = function () {
194
- fnBaseClass.apply(this, arguments);
195
- };
196
- }
197
- }
198
- fnClass.prototype = Object.create(fnBaseClass.prototype);
199
- fnClass.prototype.constructor = fnClass;
200
- oClassInfo.metadata.baseType = fnBaseClass.getMetadata().getName();
201
- } else {
202
- 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);
203
477
  };
204
- delete oClassInfo.metadata.baseType;
205
- }
206
- oClassInfo.constructor = fnClass;
207
- ObjectPath.set(sClassName, fnClass);
208
- var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
209
- fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
210
- return oMetadata;
211
- };
212
- if (!fnClass.getMetadata().isFinal()) {
213
- fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
214
- return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
478
+ } else {
479
+ // create default factory
480
+ fnClass = function () {
481
+ fnBaseClass.apply(this, arguments);
215
482
  };
483
+ }
216
484
  }
217
- 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;
218
517
  };
219
518
  export default Metadata;