@ui5/webcomponents-localization 0.0.0-3236d56be → 0.0.0-33e059bcd

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 (235) hide show
  1. package/.eslintignore +2 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +662 -0
  4. package/README.md +6 -6
  5. package/dist/.tsbuildinfo +1 -0
  6. package/{src/Assets-static.js → dist/Assets-static.d.ts} +0 -1
  7. package/dist/Assets-static.js +1 -0
  8. package/dist/Assets-static.js.map +1 -0
  9. package/dist/Assets.d.ts +1 -0
  10. package/dist/Assets.js +1 -0
  11. package/dist/Assets.js.map +1 -0
  12. package/dist/DateFormat.d.ts +6 -0
  13. package/dist/DateFormat.js +6 -2
  14. package/dist/DateFormat.js.map +1 -0
  15. package/dist/LocaleData.d.ts +6 -0
  16. package/dist/LocaleData.js +6 -2
  17. package/dist/LocaleData.js.map +1 -0
  18. package/dist/dates/CalendarDate.d.ts +43 -0
  19. package/dist/dates/CalendarDate.js +171 -207
  20. package/dist/dates/CalendarDate.js.map +1 -0
  21. package/dist/dates/ExtremeDates.d.ts +5 -0
  22. package/dist/dates/ExtremeDates.js +25 -35
  23. package/dist/dates/ExtremeDates.js.map +1 -0
  24. package/dist/dates/UI5Date.d.ts +6 -0
  25. package/dist/dates/UI5Date.js +7 -0
  26. package/dist/dates/UI5Date.js.map +1 -0
  27. package/dist/dates/UniversalDate.d.ts +47 -0
  28. package/dist/dates/UniversalDate.js +5 -0
  29. package/dist/dates/UniversalDate.js.map +1 -0
  30. package/dist/dates/calculateWeekNumber.d.ts +5 -0
  31. package/dist/dates/calculateWeekNumber.js +42 -48
  32. package/dist/dates/calculateWeekNumber.js.map +1 -0
  33. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  34. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  35. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  36. package/dist/dates/getDaysInMonth.d.ts +3 -0
  37. package/dist/dates/getDaysInMonth.js +10 -0
  38. package/dist/dates/getDaysInMonth.js.map +1 -0
  39. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  40. package/dist/dates/getRoundedTimestamp.js +10 -9
  41. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  42. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  43. package/dist/dates/getTodayUTCTimestamp.js +3 -3
  44. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  45. package/dist/dates/modifyDateBy.d.ts +14 -0
  46. package/dist/dates/modifyDateBy.js +42 -29
  47. package/dist/dates/modifyDateBy.js.map +1 -0
  48. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  49. package/dist/dates/transformDateToSecondaryType.js +18 -0
  50. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  51. package/dist/features/calendar/Buddhist.js +1 -0
  52. package/dist/features/calendar/Buddhist.js.map +1 -0
  53. package/dist/features/calendar/Gregorian.js +1 -0
  54. package/dist/features/calendar/Gregorian.js.map +1 -0
  55. package/dist/features/calendar/Islamic.js +1 -0
  56. package/dist/features/calendar/Islamic.js.map +1 -0
  57. package/dist/features/calendar/Japanese.js +1 -0
  58. package/dist/features/calendar/Japanese.js.map +1 -0
  59. package/dist/features/calendar/Persian.js +1 -0
  60. package/dist/features/calendar/Persian.js.map +1 -0
  61. package/dist/generated/assets/cldr/ar.json +5571 -5906
  62. package/dist/generated/assets/cldr/ar_EG.json +5571 -5906
  63. package/dist/generated/assets/cldr/ar_SA.json +5570 -5906
  64. package/dist/generated/assets/cldr/bg.json +4491 -4979
  65. package/dist/generated/assets/cldr/ca.json +4478 -4996
  66. package/dist/generated/assets/cldr/cs.json +5067 -5498
  67. package/dist/generated/assets/cldr/cy.json +5479 -5884
  68. package/dist/generated/assets/cldr/da.json +4371 -4888
  69. package/dist/generated/assets/cldr/de.json +4420 -4916
  70. package/dist/generated/assets/cldr/de_AT.json +4421 -4917
  71. package/dist/generated/assets/cldr/de_CH.json +4419 -4915
  72. package/dist/generated/assets/cldr/el.json +4309 -4883
  73. package/dist/generated/assets/cldr/el_CY.json +4309 -4883
  74. package/dist/generated/assets/cldr/en.json +4342 -4971
  75. package/dist/generated/assets/cldr/en_AU.json +4382 -4962
  76. package/dist/generated/assets/cldr/en_GB.json +4373 -4971
  77. package/dist/generated/assets/cldr/en_HK.json +4382 -4977
  78. package/dist/generated/assets/cldr/en_IE.json +4373 -4971
  79. package/dist/generated/assets/cldr/en_IN.json +4378 -4972
  80. package/dist/generated/assets/cldr/en_NZ.json +4373 -4971
  81. package/dist/generated/assets/cldr/en_PG.json +4374 -4972
  82. package/dist/generated/assets/cldr/en_SG.json +4378 -4973
  83. package/dist/generated/assets/cldr/en_ZA.json +4374 -4972
  84. package/dist/generated/assets/cldr/es.json +4584 -4912
  85. package/dist/generated/assets/cldr/es_AR.json +4587 -4914
  86. package/dist/generated/assets/cldr/es_BO.json +4586 -4913
  87. package/dist/generated/assets/cldr/es_CL.json +4479 -4914
  88. package/dist/generated/assets/cldr/es_CO.json +4479 -4913
  89. package/dist/generated/assets/cldr/es_MX.json +4588 -4915
  90. package/dist/generated/assets/cldr/es_PE.json +4370 -4913
  91. package/dist/generated/assets/cldr/es_UY.json +4372 -4915
  92. package/dist/generated/assets/cldr/es_VE.json +4371 -4914
  93. package/dist/generated/assets/cldr/et.json +4373 -4967
  94. package/dist/generated/assets/cldr/fa.json +4429 -4883
  95. package/dist/generated/assets/cldr/fi.json +4514 -5008
  96. package/dist/generated/assets/cldr/fr.json +4383 -4979
  97. package/dist/generated/assets/cldr/fr_BE.json +4383 -4979
  98. package/dist/generated/assets/cldr/fr_CA.json +4377 -4973
  99. package/dist/generated/assets/cldr/fr_CH.json +4401 -4997
  100. package/dist/generated/assets/cldr/fr_LU.json +4383 -4979
  101. package/dist/generated/assets/cldr/he.json +4980 -5378
  102. package/dist/generated/assets/cldr/hi.json +4345 -4829
  103. package/dist/generated/assets/cldr/hr.json +4640 -4919
  104. package/dist/generated/assets/cldr/hu.json +4415 -4856
  105. package/dist/generated/assets/cldr/id.json +4132 -4658
  106. package/dist/generated/assets/cldr/it.json +4355 -4950
  107. package/dist/generated/assets/cldr/it_CH.json +4355 -4950
  108. package/dist/generated/assets/cldr/ja.json +4251 -4830
  109. package/dist/generated/assets/cldr/kk.json +4503 -4725
  110. package/dist/generated/assets/cldr/ko.json +4210 -4738
  111. package/dist/generated/assets/cldr/lt.json +4939 -5481
  112. package/dist/generated/assets/cldr/lv.json +4651 -5112
  113. package/dist/generated/assets/cldr/ms.json +4093 -4515
  114. package/dist/generated/assets/cldr/nb.json +4403 -4977
  115. package/dist/generated/assets/cldr/nl.json +4542 -4884
  116. package/dist/generated/assets/cldr/nl_BE.json +4542 -4884
  117. package/dist/generated/assets/cldr/pl.json +4978 -5176
  118. package/dist/generated/assets/cldr/pt.json +4597 -4805
  119. package/dist/generated/assets/cldr/pt_PT.json +4648 -4940
  120. package/dist/generated/assets/cldr/ro.json +4633 -5090
  121. package/dist/generated/assets/cldr/ru.json +4947 -5407
  122. package/dist/generated/assets/cldr/ru_UA.json +4947 -5407
  123. package/dist/generated/assets/cldr/sk.json +4980 -5370
  124. package/dist/generated/assets/cldr/sl.json +4948 -5340
  125. package/dist/generated/assets/cldr/sr.json +4737 -5126
  126. package/dist/generated/assets/cldr/sr_Latn.json +4722 -5127
  127. package/dist/generated/assets/cldr/sv.json +4406 -5011
  128. package/dist/generated/assets/cldr/th.json +4234 -4797
  129. package/dist/generated/assets/cldr/tr.json +4451 -4979
  130. package/dist/generated/assets/cldr/uk.json +4908 -5353
  131. package/dist/generated/assets/cldr/vi.json +4094 -4673
  132. package/dist/generated/assets/cldr/zh_CN.json +4124 -4632
  133. package/dist/generated/assets/cldr/zh_HK.json +4132 -4640
  134. package/dist/generated/assets/cldr/zh_SG.json +4132 -4640
  135. package/dist/generated/assets/cldr/zh_TW.json +4155 -4728
  136. package/dist/generated/json-imports/LocaleData-static.d.ts +1 -0
  137. package/dist/generated/json-imports/LocaleData-static.js +9 -11
  138. package/dist/generated/json-imports/LocaleData-static.js.map +1 -0
  139. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  140. package/dist/generated/json-imports/LocaleData.js +86 -88
  141. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  142. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  143. package/dist/getCachedLocaleDataInstance.js +6 -9
  144. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  145. package/dist/locale/getLocaleData.d.ts +11 -0
  146. package/dist/locale/getLocaleData.js +13 -17
  147. package/dist/locale/getLocaleData.js.map +1 -0
  148. package/dist/sap/base/Event.js +59 -0
  149. package/dist/sap/base/Eventing.js +146 -0
  150. package/dist/sap/base/Log.js +2 -240
  151. package/dist/sap/base/assert.js +31 -5
  152. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  153. package/dist/sap/base/config.js +17 -0
  154. package/dist/sap/base/i18n/Formatting.js +1130 -0
  155. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  156. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  157. package/dist/sap/base/i18n/Localization.js +12 -0
  158. package/dist/sap/base/i18n/Localization.js.map +1 -0
  159. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  160. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  161. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  162. package/dist/sap/base/strings/camelize.js +30 -0
  163. package/dist/sap/base/strings/formatMessage.js +88 -15
  164. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  165. package/dist/sap/base/util/LoaderExtensions.js +9 -12
  166. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  167. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  168. package/dist/sap/base/util/ObjectPath.js +4 -33
  169. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  170. package/dist/sap/base/util/Version.js +157 -0
  171. package/dist/sap/base/util/_merge.js +83 -26
  172. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  173. package/dist/sap/base/util/deepClone.js +102 -0
  174. package/dist/sap/base/util/deepEqual.js +75 -51
  175. package/dist/sap/base/util/extend.js +58 -7
  176. package/dist/sap/base/util/isEmptyObject.js +34 -0
  177. package/dist/sap/base/util/isPlainObject.js +35 -1
  178. package/dist/sap/base/util/now.js +24 -3
  179. package/dist/sap/base/util/resolveReference.js +157 -0
  180. package/dist/sap/base/util/uid.js +27 -0
  181. package/dist/sap/ui/base/DataType.js +657 -0
  182. package/dist/sap/ui/base/Interface.js +47 -1
  183. package/dist/sap/ui/base/Metadata.js +435 -171
  184. package/dist/sap/ui/base/Object.js +284 -48
  185. package/dist/sap/ui/core/CalendarType.js +24 -8
  186. package/dist/sap/ui/core/Configuration.d.ts +18 -0
  187. package/dist/sap/ui/core/Configuration.js +23 -0
  188. package/dist/sap/ui/core/Configuration.js.map +1 -0
  189. package/dist/sap/ui/core/Core.d.ts +27 -0
  190. package/dist/sap/ui/core/Core.js +7 -34
  191. package/dist/sap/ui/core/Core.js.map +1 -0
  192. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  193. package/dist/sap/ui/core/FormatSettings.js +14 -0
  194. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  195. package/dist/sap/ui/core/Locale.js +190 -152
  196. package/dist/sap/ui/core/LocaleData.js +2665 -1228
  197. package/dist/sap/ui/core/Supportability.js +5 -0
  198. package/dist/sap/ui/core/Theming.js +539 -0
  199. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  200. package/dist/sap/ui/core/date/CalendarUtils.js +65 -0
  201. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  202. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  203. package/dist/sap/ui/core/date/Islamic.js +298 -185
  204. package/dist/sap/ui/core/date/Japanese.js +212 -117
  205. package/dist/sap/ui/core/date/Persian.js +324 -195
  206. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  207. package/dist/sap/ui/core/date/UniversalDate.js +1251 -217
  208. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  209. package/dist/sap/ui/core/format/DateFormat.js +3139 -1965
  210. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -83
  211. package/package-scripts.cjs +26 -0
  212. package/package.json +13 -6
  213. package/tsconfig.json +24 -0
  214. package/used-modules.txt +28 -2
  215. package/dist/sap/ui/Device.js +0 -5
  216. package/package-scripts.js +0 -35
  217. package/src/Assets.js +0 -2
  218. package/src/DateFormat.js +0 -3
  219. package/src/LocaleData.js +0 -3
  220. package/src/dates/CalendarDate.js +0 -229
  221. package/src/dates/ExtremeDates.js +0 -39
  222. package/src/dates/calculateWeekNumber.js +0 -51
  223. package/src/dates/getRoundedTimestamp.js +0 -14
  224. package/src/dates/getTodayUTCTimestamp.js +0 -9
  225. package/src/dates/modifyDateBy.js +0 -42
  226. package/src/getCachedLocaleDataInstance.js +0 -13
  227. package/src/locale/getLocaleData.js +0 -27
  228. package/src/sap/base/util/LoaderExtensions.js +0 -17
  229. package/src/sap/ui/core/Core.js +0 -40
  230. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  231. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  232. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  233. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  234. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  235. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1,146 @@
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
+ // Provides mixin sap/base/Eventing
7
+ import assert from "./assert.js";
8
+ import Event from "./Event.js";
9
+ /**
10
+ * Eventing
11
+ *
12
+ * @author SAP SE
13
+ * @version 1.120.3
14
+ *
15
+ * @since 1.120.0
16
+ * @private
17
+ * @ui5-restricted sap.ui.core sap/base/i18n
18
+ */
19
+ class Eventing {
20
+ #mEventRegistry = {};
21
+ /**
22
+ * Attaches an event handler to the event with the given identifier.
23
+ *
24
+ * @param {string}
25
+ * sType The type of the event to listen for
26
+ * @param {function}
27
+ * fnFunction The handler function to call when the event occurs. The event
28
+ * object ({@link module:sap/base/Event}) is provided as first argument of the handler. Handlers must not change
29
+ * the content of the event.
30
+ * @param {object}
31
+ * [oData] An object that will be passed to the handler along with the event object when the event is fired
32
+ * @since 1.120.0
33
+ * @private
34
+ * @ui5-restricted sap.ui.core sap/base/i18n
35
+ */
36
+ attachEvent(sType, fnFunction, oData) {
37
+ assert(typeof sType === "string" && sType, "Eventing.attachEvent: sType must be a non-empty string");
38
+ assert(typeof fnFunction === "function", "Eventing.attachEvent: fnFunction must be a function");
39
+ let aEventListeners = this.#mEventRegistry[sType];
40
+ if (!Array.isArray(aEventListeners)) {
41
+ aEventListeners = this.#mEventRegistry[sType] = [];
42
+ }
43
+ aEventListeners.push({
44
+ fnFunction: fnFunction,
45
+ oData: oData
46
+ });
47
+ }
48
+
49
+ /**
50
+ * Attaches an event handler, called one time only, to the event with the given identifier.
51
+ *
52
+ * When the event occurs, the handler function is called and the handler registration is automatically removed afterwards.
53
+ *
54
+ * @param {string}
55
+ * sType The type of the event to listen for
56
+ * @param {function}
57
+ * fnFunction The handler function to call when the event occurs. The event
58
+ * object ({@link module:sap/base/Event}) is provided as first argument of the handler. Handlers must not change
59
+ * the content of the event.
60
+ * @param {object}
61
+ * [oData] An object that will be passed to the handler along with the event object when the event is fired
62
+ * @since 1.120.0
63
+ * @private
64
+ * @ui5-restricted sap.ui.core sap/base/i18n
65
+ */
66
+ attachEventOnce(sType, fnFunction, oData) {
67
+ const fnOnce = oEvent => {
68
+ this.detachEvent(sType, fnOnce);
69
+ fnFunction.call(null, oEvent); // needs to do the same resolution as in fireEvent
70
+ };
71
+ fnOnce.oOriginal = {
72
+ fnFunction: fnFunction
73
+ };
74
+ this.attachEvent(sType, fnOnce, oData);
75
+ }
76
+
77
+ /**
78
+ * Removes a previously attached event handler from the event with the given identifier.
79
+ *
80
+ * The passed parameters must match those used for registration with {@link #attachEvent} beforehand.
81
+ *
82
+ * @param {string}
83
+ * sType The type of the event to detach from
84
+ * @param {function}
85
+ * fnFunction The handler function to detach from the event
86
+ * @since 1.120.0
87
+ * @private
88
+ * @ui5-restricted sap.ui.core sap/base/i18n
89
+ */
90
+ detachEvent(sType, fnFunction) {
91
+ assert(typeof sType === "string" && sType, "Eventing.detachEvent: sType must be a non-empty string");
92
+ assert(typeof fnFunction === "function", "Eventing.detachEvent: fnFunction must be a function");
93
+ const aEventListeners = this.#mEventRegistry[sType];
94
+ if (!Array.isArray(aEventListeners)) {
95
+ return;
96
+ }
97
+ let oFound;
98
+ for (let i = 0, iL = aEventListeners.length; i < iL; i++) {
99
+ if (aEventListeners[i].fnFunction === fnFunction) {
100
+ oFound = aEventListeners[i];
101
+ aEventListeners.splice(i, 1);
102
+ break;
103
+ }
104
+ }
105
+ // If no listener was found, look for original listeners of attachEventOnce
106
+ if (!oFound) {
107
+ for (let i = 0, iL = aEventListeners.length; i < iL; i++) {
108
+ const oOriginal = aEventListeners[i].fnFunction.oOriginal;
109
+ if (oOriginal && oOriginal.fnFunction === fnFunction) {
110
+ aEventListeners.splice(i, 1);
111
+ break;
112
+ }
113
+ }
114
+ }
115
+ // If we just deleted the last registered EventHandler, remove the whole entry from our map.
116
+ if (aEventListeners.length == 0) {
117
+ delete this.#mEventRegistry[sType];
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Fires an {@link module:sap/base/Event event} with the given settings and notifies all attached event handlers.
123
+ *
124
+ * @param {string}
125
+ * sType The type of the event to fire
126
+ * @param {object}
127
+ * [oParameters] Parameters which should be carried by the event
128
+ * @since 1.120.0
129
+ * @private
130
+ * @ui5-restricted sap.ui.core sap/base/i18n
131
+ */
132
+ fireEvent(sType, oParameters) {
133
+ let aEventListeners, oEvent, i, iL, oInfo;
134
+ aEventListeners = this.#mEventRegistry[sType];
135
+ if (Array.isArray(aEventListeners)) {
136
+ // avoid issues with 'concurrent modification' (e.g. if an event listener unregisters itself).
137
+ aEventListeners = aEventListeners.slice();
138
+ oEvent = new Event(sType, oParameters);
139
+ for (i = 0, iL = aEventListeners.length; i < iL; i++) {
140
+ oInfo = aEventListeners[i];
141
+ oInfo.fnFunction.call(null, oEvent);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ export default Eventing;
@@ -1,241 +1,3 @@
1
- import now from './util/now.js';
2
- var Log = {};
3
- Log.Level = {
4
- NONE: -1,
5
- FATAL: 0,
6
- ERROR: 1,
7
- WARNING: 2,
8
- INFO: 3,
9
- DEBUG: 4,
10
- TRACE: 5,
11
- ALL: 5 + 1
12
- };
13
- var sDefaultComponent, aLog = [], mMaxLevel = { '': Log.Level.ERROR }, iLogEntriesLimit = 3000, oListener = null, bLogSupportInfo = false;
14
- function pad0(i, w) {
15
- return ('000' + String(i)).slice(-w);
16
- }
17
- function level(sComponent) {
18
- return !sComponent || isNaN(mMaxLevel[sComponent]) ? mMaxLevel[''] : mMaxLevel[sComponent];
19
- }
20
- function discardLogEntries() {
21
- var iLogLength = aLog.length;
22
- if (iLogLength) {
23
- var iEntriesToKeep = Math.min(iLogLength, Math.floor(iLogEntriesLimit * 0.7));
24
- if (oListener) {
25
- oListener.onDiscardLogEntries(aLog.slice(0, iLogLength - iEntriesToKeep));
26
- }
27
- if (iEntriesToKeep) {
28
- aLog = aLog.slice(-iEntriesToKeep, iLogLength);
29
- } else {
30
- aLog = [];
31
- }
32
- }
33
- }
34
- function getLogEntryListenerInstance() {
35
- if (!oListener) {
36
- oListener = {
37
- listeners: [],
38
- onLogEntry: function (oLogEntry) {
39
- for (var i = 0; i < oListener.listeners.length; i++) {
40
- if (oListener.listeners[i].onLogEntry) {
41
- oListener.listeners[i].onLogEntry(oLogEntry);
42
- }
43
- }
44
- },
45
- onDiscardLogEntries: function (aDiscardedLogEntries) {
46
- for (var i = 0; i < oListener.listeners.length; i++) {
47
- if (oListener.listeners[i].onDiscardLogEntries) {
48
- oListener.listeners[i].onDiscardLogEntries(aDiscardedLogEntries);
49
- }
50
- }
51
- },
52
- attach: function (oLog, oLstnr) {
53
- if (oLstnr) {
54
- oListener.listeners.push(oLstnr);
55
- if (oLstnr.onAttachToLog) {
56
- oLstnr.onAttachToLog(oLog);
57
- }
58
- }
59
- },
60
- detach: function (oLog, oLstnr) {
61
- for (var i = 0; i < oListener.listeners.length; i++) {
62
- if (oListener.listeners[i] === oLstnr) {
63
- if (oLstnr.onDetachFromLog) {
64
- oLstnr.onDetachFromLog(oLog);
65
- }
66
- oListener.listeners.splice(i, 1);
67
- return;
68
- }
69
- }
70
- }
71
- };
72
- }
73
- return oListener;
74
- }
75
- Log.fatal = function (sMessage, sDetails, sComponent, fnSupportInfo) {
76
- log(Log.Level.FATAL, sMessage, sDetails, sComponent, fnSupportInfo);
77
- };
78
- Log.error = function (sMessage, sDetails, sComponent, fnSupportInfo) {
79
- log(Log.Level.ERROR, sMessage, sDetails, sComponent, fnSupportInfo);
80
- };
81
- Log.warning = function (sMessage, sDetails, sComponent, fnSupportInfo) {
82
- log(Log.Level.WARNING, sMessage, sDetails, sComponent, fnSupportInfo);
83
- };
84
- Log.info = function (sMessage, sDetails, sComponent, fnSupportInfo) {
85
- log(Log.Level.INFO, sMessage, sDetails, sComponent, fnSupportInfo);
86
- };
87
- Log.debug = function (sMessage, sDetails, sComponent, fnSupportInfo) {
88
- log(Log.Level.DEBUG, sMessage, sDetails, sComponent, fnSupportInfo);
89
- };
90
- Log.trace = function (sMessage, sDetails, sComponent, fnSupportInfo) {
91
- log(Log.Level.TRACE, sMessage, sDetails, sComponent, fnSupportInfo);
92
- };
93
- Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
94
- sComponent = sComponent || sDefaultComponent || '';
95
- if (!_bDefault || mMaxLevel[sComponent] == null) {
96
- mMaxLevel[sComponent] = iLogLevel;
97
- var sLogLevel;
98
- Object.keys(Log.Level).forEach(function (sLevel) {
99
- if (Log.Level[sLevel] === iLogLevel) {
100
- sLogLevel = sLevel;
101
- }
102
- });
103
- log(Log.Level.INFO, 'Changing log level ' + (sComponent ? 'for \'' + sComponent + '\' ' : '') + 'to ' + sLogLevel, '', 'sap.base.log');
104
- }
105
- };
106
- Log.getLevel = function (sComponent) {
107
- return level(sComponent || sDefaultComponent);
108
- };
109
- Log.isLoggable = function (iLevel, sComponent) {
110
- return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent || sDefaultComponent);
111
- };
112
- Log.logSupportInfo = function (bEnabled) {
113
- bLogSupportInfo = bEnabled;
114
- };
115
- function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
116
- if (!fnSupportInfo && !sComponent && typeof sDetails === 'function') {
117
- fnSupportInfo = sDetails;
118
- sDetails = '';
119
- }
120
- if (!fnSupportInfo && typeof sComponent === 'function') {
121
- fnSupportInfo = sComponent;
122
- sComponent = '';
123
- }
124
- sComponent = sComponent || sDefaultComponent;
125
- if (iLevel <= level(sComponent)) {
126
- var fNow = now(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = {
127
- time: pad0(oNow.getHours(), 2) + ':' + pad0(oNow.getMinutes(), 2) + ':' + pad0(oNow.getSeconds(), 2) + '.' + pad0(oNow.getMilliseconds(), 3) + pad0(iMicroSeconds, 3),
128
- date: pad0(oNow.getFullYear(), 4) + '-' + pad0(oNow.getMonth() + 1, 2) + '-' + pad0(oNow.getDate(), 2),
129
- timestamp: fNow,
130
- level: iLevel,
131
- message: String(sMessage || ''),
132
- details: String(sDetails || ''),
133
- component: String(sComponent || '')
134
- };
135
- if (bLogSupportInfo && typeof fnSupportInfo === 'function') {
136
- oLogEntry.supportInfo = fnSupportInfo();
137
- }
138
- if (iLogEntriesLimit) {
139
- if (aLog.length >= iLogEntriesLimit) {
140
- discardLogEntries();
141
- }
142
- aLog.push(oLogEntry);
143
- }
144
- if (oListener) {
145
- oListener.onLogEntry(oLogEntry);
146
- }
147
- if (console) {
148
- var isDetailsError = sDetails instanceof Error, logText = oLogEntry.date + ' ' + oLogEntry.time + ' ' + oLogEntry.message + ' - ' + oLogEntry.details + ' ' + oLogEntry.component;
149
- switch (iLevel) {
150
- case Log.Level.FATAL:
151
- case Log.Level.ERROR:
152
- isDetailsError ? console.error(logText, '\n', sDetails) : console.error(logText);
153
- break;
154
- case Log.Level.WARNING:
155
- isDetailsError ? console.warn(logText, '\n', sDetails) : console.warn(logText);
156
- break;
157
- case Log.Level.INFO:
158
- if (console.info) {
159
- isDetailsError ? console.info(logText, '\n', sDetails) : console.info(logText);
160
- } else {
161
- isDetailsError ? console.log(logText, '\n', sDetails) : console.log(logText);
162
- }
163
- break;
164
- case Log.Level.DEBUG:
165
- isDetailsError ? console.debug(logText, '\n', sDetails) : console.debug(logText);
166
- break;
167
- case Log.Level.TRACE:
168
- isDetailsError ? console.trace(logText, '\n', sDetails) : console.trace(logText);
169
- break;
170
- }
171
- if (console.info && oLogEntry.supportInfo) {
172
- console.info(oLogEntry.supportInfo);
173
- }
174
- }
175
- return oLogEntry;
176
- }
177
- }
178
- Log.getLogEntries = function () {
179
- return aLog.slice();
180
- };
181
- Log.getLogEntriesLimit = function () {
182
- return iLogEntriesLimit;
183
- };
184
- Log.setLogEntriesLimit = function (iLimit) {
185
- if (iLimit < 0) {
186
- throw new Error('The log entries limit needs to be greater than or equal to 0!');
187
- }
188
- iLogEntriesLimit = iLimit;
189
- if (aLog.length >= iLogEntriesLimit) {
190
- discardLogEntries();
191
- }
192
- };
193
- Log.addLogListener = function (oListener) {
194
- getLogEntryListenerInstance().attach(this, oListener);
195
- };
196
- Log.removeLogListener = function (oListener) {
197
- getLogEntryListenerInstance().detach(this, oListener);
198
- };
199
- function Logger(sComponent) {
200
- this.fatal = function (msg, detail, comp, support) {
201
- Log.fatal(msg, detail, comp || sComponent, support);
202
- return this;
203
- };
204
- this.error = function (msg, detail, comp, support) {
205
- Log.error(msg, detail, comp || sComponent, support);
206
- return this;
207
- };
208
- this.warning = function (msg, detail, comp, support) {
209
- Log.warning(msg, detail, comp || sComponent, support);
210
- return this;
211
- };
212
- this.info = function (msg, detail, comp, support) {
213
- Log.info(msg, detail, comp || sComponent, support);
214
- return this;
215
- };
216
- this.debug = function (msg, detail, comp, support) {
217
- Log.debug(msg, detail, comp || sComponent, support);
218
- return this;
219
- };
220
- this.trace = function (msg, detail, comp, support) {
221
- Log.trace(msg, detail, comp || sComponent, support);
222
- return this;
223
- };
224
- this.setLevel = function (level, comp) {
225
- Log.setLevel(level, comp || sComponent);
226
- return this;
227
- };
228
- this.getLevel = function (comp) {
229
- return Log.getLevel(comp || sComponent);
230
- };
231
- this.isLoggable = function (level, comp) {
232
- return Log.isLoggable(level, comp || sComponent);
233
- };
234
- }
235
- Log.getLogger = function (sComponent, iDefaultLogLevel) {
236
- if (!isNaN(iDefaultLogLevel) && mMaxLevel[sComponent] == null) {
237
- mMaxLevel[sComponent] = iDefaultLogLevel;
238
- }
239
- return new Logger(sComponent);
240
- };
1
+ const Log = console;
2
+ Log.warning = console.warn;
241
3
  export default Log;
@@ -1,8 +1,34 @@
1
- import Log from './Log.js';
1
+ // TODO-evo:assert on node throws an error if the assertion is violated
2
+
3
+ /**
4
+ * A simple assertion mechanism that logs a message when a given condition is not met.
5
+ *
6
+ * <b>Note:</b> Calls to this method might be removed when the JavaScript code
7
+ * is optimized during build. Therefore, callers should not rely on any side effects
8
+ * of this method.
9
+ *
10
+ * @function
11
+ * @since 1.58
12
+ * @alias module:sap/base/assert
13
+ * @param {boolean} bResult Result of the checked assertion
14
+ * @param {string|function():any} vMessage Message that will be logged when the result is <code>false</code>.
15
+ * In case this is a function, the return value of the function will be displayed. This can be used to execute
16
+ * complex code only if the assertion fails.
17
+ * @public
18
+ * @SecSink {1|SECRET} Could expose secret data in logs
19
+ *
20
+ */ /*!
21
+ * OpenUI5
22
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
23
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
24
+ */
25
+
2
26
  var fnAssert = function (bResult, vMessage) {
3
- if (!bResult) {
4
- var sMessage = typeof vMessage === 'function' ? vMessage() : vMessage;
5
- console.assert(bResult, sMessage);
6
- }
27
+ if (!bResult) {
28
+ var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
29
+ /*eslint-disable no-console */
30
+ console.assert(bResult, sMessage);
31
+ /*eslint-enable no-console */
32
+ }
7
33
  };
8
34
  export default fnAssert;
@@ -0,0 +1,20 @@
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 uid from "../util/uid.js";
7
+ var MemoryConfigurationProvider = function () {
8
+ this.oConfig = Object.create(null);
9
+ this.id = uid();
10
+ };
11
+ MemoryConfigurationProvider.prototype.getId = function () {
12
+ return this.id;
13
+ };
14
+ MemoryConfigurationProvider.prototype.get = function (sName) {
15
+ return this.oConfig[sName];
16
+ };
17
+ MemoryConfigurationProvider.prototype.set = function (sName, vValue) {
18
+ this.oConfig[sName] = vValue;
19
+ };
20
+ export default MemoryConfigurationProvider;
@@ -0,0 +1,17 @@
1
+ // called from sapui5, but not supported by us
2
+ const legacyFormats = ["sapUiLegacyTimeFormat", "sapUiABAPTimeFormat", "sapUiLegacyDateFormat", "sapUiABAPDateFormat", "sapUiLegacyNumberFormat", "sapUiABAPNumberFormat"];
3
+ export default {
4
+ getWritableInstance() {
5
+ return {
6
+ get({
7
+ name
8
+ }) {
9
+ if (legacyFormats.includes(name)) {
10
+ return undefined;
11
+ }
12
+ throw new Error("Localization :: missing configuration requested.");
13
+ }
14
+ };
15
+ },
16
+ Type: {}
17
+ };