@ui5/task-adaptation 1.0.21 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/dist/annotationManager.d.ts +3 -4
  3. package/dist/annotationManager.js +20 -56
  4. package/dist/annotations/oDataModel.d.ts +20 -0
  5. package/dist/annotations/oDataModel.js +46 -0
  6. package/dist/annotations/oDataV2Model.d.ts +4 -0
  7. package/dist/annotations/oDataV2Model.js +13 -0
  8. package/dist/annotations/serviceRequestor.d.ts +17 -0
  9. package/dist/annotations/serviceRequestor.js +36 -0
  10. package/dist/appVariantManager.d.ts +0 -7
  11. package/dist/appVariantManager.js +2 -20
  12. package/dist/baseAppManager.d.ts +1 -0
  13. package/dist/baseAppManager.js +22 -5
  14. package/dist/i18nManager.d.ts +11 -10
  15. package/dist/i18nManager.js +19 -19
  16. package/dist/index.js +2 -0
  17. package/dist/model/language.d.ts +13 -0
  18. package/dist/model/language.js +37 -0
  19. package/dist/model/types.d.ts +1 -1
  20. package/dist/processors/abapProcessor.js +2 -2
  21. package/dist/repositories/abapRepoManager.js +2 -1
  22. package/dist/util/cfUtil.js +1 -1
  23. package/dist/util/commonUtil.d.ts +1 -0
  24. package/dist/util/commonUtil.js +13 -1
  25. package/dist/util/jsonDiffUtil.d.ts +14 -3
  26. package/dist/util/jsonDiffUtil.js +29 -9
  27. package/package.json +4 -3
  28. package/scripts/metadataDownloadHelper.ts +85 -0
  29. package/scripts/rollup.ts +0 -9
  30. package/dist/bundle-resourceBundle.js +0 -692
  31. package/scripts/rollup/bundleDefinition-resourceBundle.js +0 -5
  32. package/scripts/rollup/overrides/sap/base/i18n/Localization.js +0 -1
  33. package/scripts/rollup/overrides/sap/base/string/formatMessage.js +0 -1
  34. package/scripts/rollup/overrides/sap/base/util/Properties.js +0 -1
  35. package/scripts/rollup/overrides/sap/base/util/merge.js +0 -1
@@ -1,692 +0,0 @@
1
- //undefined
2
- var window = {};
3
- 'use strict';
4
-
5
- Object.defineProperty(exports, '__esModule', { value: true });
6
-
7
- var fnAssert = function (bResult, vMessage) {
8
- if (!bResult) {
9
- var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
10
- console.assert(bResult, sMessage);
11
- }
12
- };
13
-
14
- var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
15
- var iNavigationStart = performance.timing.navigationStart;
16
- return function perfnow() {
17
- return iNavigationStart + performance.now();
18
- };
19
- })();
20
-
21
- var Log = {};
22
- Log.Level = {
23
- NONE: -1,
24
- FATAL: 0,
25
- ERROR: 1,
26
- WARNING: 2,
27
- INFO: 3,
28
- DEBUG: 4,
29
- TRACE: 5,
30
- ALL: 5 + 1
31
- };
32
- var aLog = [], mMaxLevel = {
33
- "": Log.Level.ERROR
34
- }, iLogEntriesLimit = 3000, oListener = null, bLogSupportInfo = false;
35
- function pad0(i, w) {
36
- return ("000" + String(i)).slice(-w);
37
- }
38
- function level(sComponent) {
39
- return !sComponent || isNaN(mMaxLevel[sComponent]) ? mMaxLevel[""] : mMaxLevel[sComponent];
40
- }
41
- function discardLogEntries() {
42
- var iLogLength = aLog.length;
43
- if (iLogLength) {
44
- var iEntriesToKeep = Math.min(iLogLength, Math.floor(iLogEntriesLimit * 0.7));
45
- if (oListener) {
46
- oListener.onDiscardLogEntries(aLog.slice(0, iLogLength - iEntriesToKeep));
47
- }
48
- if (iEntriesToKeep) {
49
- aLog = aLog.slice(-iEntriesToKeep, iLogLength);
50
- } else {
51
- aLog = [];
52
- }
53
- }
54
- }
55
- function getLogEntryListenerInstance() {
56
- if (!oListener) {
57
- oListener = {
58
- listeners: [],
59
- onLogEntry: function (oLogEntry) {
60
- for (var i = 0; i < oListener.listeners.length; i++) {
61
- if (oListener.listeners[i].onLogEntry) {
62
- oListener.listeners[i].onLogEntry(oLogEntry);
63
- }
64
- }
65
- },
66
- onDiscardLogEntries: function (aDiscardedLogEntries) {
67
- for (var i = 0; i < oListener.listeners.length; i++) {
68
- if (oListener.listeners[i].onDiscardLogEntries) {
69
- oListener.listeners[i].onDiscardLogEntries(aDiscardedLogEntries);
70
- }
71
- }
72
- },
73
- attach: function (oLog, oLstnr) {
74
- if (oLstnr) {
75
- oListener.listeners.push(oLstnr);
76
- if (oLstnr.onAttachToLog) {
77
- oLstnr.onAttachToLog(oLog);
78
- }
79
- }
80
- },
81
- detach: function (oLog, oLstnr) {
82
- for (var i = 0; i < oListener.listeners.length; i++) {
83
- if (oListener.listeners[i] === oLstnr) {
84
- if (oLstnr.onDetachFromLog) {
85
- oLstnr.onDetachFromLog(oLog);
86
- }
87
- oListener.listeners.splice(i, 1);
88
- return;
89
- }
90
- }
91
- }
92
- };
93
- }
94
- return oListener;
95
- }
96
- Log.fatal = function (sMessage, vDetails, sComponent, fnSupportInfo) {
97
- log(Log.Level.FATAL, sMessage, vDetails, sComponent, fnSupportInfo);
98
- };
99
- Log.error = function (sMessage, vDetails, sComponent, fnSupportInfo) {
100
- log(Log.Level.ERROR, sMessage, vDetails, sComponent, fnSupportInfo);
101
- };
102
- Log.warning = function (sMessage, vDetails, sComponent, fnSupportInfo) {
103
- log(Log.Level.WARNING, sMessage, vDetails, sComponent, fnSupportInfo);
104
- };
105
- Log.info = function (sMessage, vDetails, sComponent, fnSupportInfo) {
106
- log(Log.Level.INFO, sMessage, vDetails, sComponent, fnSupportInfo);
107
- };
108
- Log.debug = function (sMessage, vDetails, sComponent, fnSupportInfo) {
109
- log(Log.Level.DEBUG, sMessage, vDetails, sComponent, fnSupportInfo);
110
- };
111
- Log.trace = function (sMessage, vDetails, sComponent, fnSupportInfo) {
112
- log(Log.Level.TRACE, sMessage, vDetails, sComponent, fnSupportInfo);
113
- };
114
- Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
115
- sComponent = sComponent || "";
116
- if (!_bDefault || mMaxLevel[sComponent] == null) {
117
- mMaxLevel[sComponent] = iLogLevel;
118
- var sLogLevel;
119
- Object.keys(Log.Level).forEach(function (sLevel) {
120
- if (Log.Level[sLevel] === iLogLevel) {
121
- sLogLevel = sLevel;
122
- }
123
- });
124
- log(Log.Level.INFO, "Changing log level " + (sComponent ? "for '" + sComponent + "' " : "") + "to " + sLogLevel, "", "sap.base.log");
125
- }
126
- };
127
- Log.getLevel = function (sComponent) {
128
- return level(sComponent);
129
- };
130
- Log.isLoggable = function (iLevel, sComponent) {
131
- return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent);
132
- };
133
- Log.logSupportInfo = function (bEnabled) {
134
- bLogSupportInfo = bEnabled;
135
- };
136
- function log(iLevel, sMessage, vDetails, sComponent, fnSupportInfo) {
137
- if (!fnSupportInfo && !sComponent && typeof vDetails === "function") {
138
- fnSupportInfo = vDetails;
139
- vDetails = "";
140
- }
141
- if (!fnSupportInfo && typeof sComponent === "function") {
142
- fnSupportInfo = sComponent;
143
- sComponent = "";
144
- }
145
- if (iLevel <= level(sComponent)) {
146
- var fNow = fnNow(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = {
147
- time: pad0(oNow.getHours(), 2) + ":" + pad0(oNow.getMinutes(), 2) + ":" + pad0(oNow.getSeconds(), 2) + "." + pad0(oNow.getMilliseconds(), 3) + pad0(iMicroSeconds, 3),
148
- date: pad0(oNow.getFullYear(), 4) + "-" + pad0(oNow.getMonth() + 1, 2) + "-" + pad0(oNow.getDate(), 2),
149
- timestamp: fNow,
150
- level: iLevel,
151
- message: String(sMessage || ""),
152
- details: String(vDetails || ""),
153
- component: String(sComponent || "")
154
- };
155
- if (bLogSupportInfo && typeof fnSupportInfo === "function") {
156
- oLogEntry.supportInfo = fnSupportInfo();
157
- }
158
- if (iLogEntriesLimit) {
159
- if (aLog.length >= iLogEntriesLimit) {
160
- discardLogEntries();
161
- }
162
- aLog.push(oLogEntry);
163
- }
164
- if (oListener) {
165
- oListener.onLogEntry(oLogEntry);
166
- }
167
- if (console) {
168
- var isDetailsError = vDetails instanceof Error, logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
169
- switch (iLevel) {
170
- case Log.Level.FATAL:
171
- case Log.Level.ERROR:
172
- isDetailsError ? console.error(logText, "\n", vDetails) : console.error(logText);
173
- break;
174
- case Log.Level.WARNING:
175
- isDetailsError ? console.warn(logText, "\n", vDetails) : console.warn(logText);
176
- break;
177
- case Log.Level.INFO:
178
- if (console.info) {
179
- isDetailsError ? console.info(logText, "\n", vDetails) : console.info(logText);
180
- } else {
181
- isDetailsError ? console.log(logText, "\n", vDetails) : console.log(logText);
182
- }
183
- break;
184
- case Log.Level.DEBUG:
185
- isDetailsError ? console.debug(logText, "\n", vDetails) : console.debug(logText);
186
- break;
187
- case Log.Level.TRACE:
188
- isDetailsError ? console.trace(logText, "\n", vDetails) : console.trace(logText);
189
- break;
190
- }
191
- if (console.info && oLogEntry.supportInfo) {
192
- console.info(oLogEntry.supportInfo);
193
- }
194
- }
195
- return oLogEntry;
196
- }
197
- }
198
- Log.getLogEntries = function () {
199
- return aLog.slice();
200
- };
201
- Log.getLogEntriesLimit = function () {
202
- return iLogEntriesLimit;
203
- };
204
- Log.setLogEntriesLimit = function (iLimit) {
205
- if (iLimit < 0) {
206
- throw new Error("The log entries limit needs to be greater than or equal to 0!");
207
- }
208
- iLogEntriesLimit = iLimit;
209
- if (aLog.length >= iLogEntriesLimit) {
210
- discardLogEntries();
211
- }
212
- };
213
- Log.addLogListener = function (oListener) {
214
- getLogEntryListenerInstance().attach(this, oListener);
215
- };
216
- Log.removeLogListener = function (oListener) {
217
- getLogEntryListenerInstance().detach(this, oListener);
218
- };
219
- function Logger(sComponent) {
220
- this.fatal = function (msg, detail, comp, support) {
221
- Log.fatal(msg, detail, comp || sComponent, support);
222
- return this;
223
- };
224
- this.error = function (msg, detail, comp, support) {
225
- Log.error(msg, detail, comp || sComponent, support);
226
- return this;
227
- };
228
- this.warning = function (msg, detail, comp, support) {
229
- Log.warning(msg, detail, comp || sComponent, support);
230
- return this;
231
- };
232
- this.info = function (msg, detail, comp, support) {
233
- Log.info(msg, detail, comp || sComponent, support);
234
- return this;
235
- };
236
- this.debug = function (msg, detail, comp, support) {
237
- Log.debug(msg, detail, comp || sComponent, support);
238
- return this;
239
- };
240
- this.trace = function (msg, detail, comp, support) {
241
- Log.trace(msg, detail, comp || sComponent, support);
242
- return this;
243
- };
244
- this.setLevel = function (level, comp) {
245
- Log.setLevel(level, comp || sComponent);
246
- return this;
247
- };
248
- this.getLevel = function (comp) {
249
- return Log.getLevel(comp || sComponent);
250
- };
251
- this.isLoggable = function (level, comp) {
252
- return Log.isLoggable(level, comp || sComponent);
253
- };
254
- }
255
- Log.getLogger = function (sComponent, iDefaultLogLevel) {
256
- if (!isNaN(iDefaultLogLevel) && mMaxLevel[sComponent] == null) {
257
- mMaxLevel[sComponent] = iDefaultLogLevel;
258
- }
259
- return new Logger(sComponent);
260
- };
261
-
262
- var rMessageFormat = /('')|'([^']+(?:''[^']*)*)(?:'|$)|\{([0-9]+(?:\s*,[^{}]*)?)\}|[{}]/g;
263
- var fnFormatMessage = function (sPattern, aValues) {
264
- fnAssert(typeof sPattern === "string" || sPattern instanceof String, "pattern must be string");
265
- if (arguments.length > 2 || aValues != null && !Array.isArray(aValues)) {
266
- aValues = Array.prototype.slice.call(arguments, 1);
267
- }
268
- aValues = aValues || [];
269
- return sPattern.replace(rMessageFormat, function ($0, $1, $2, $3, offset) {
270
- if ($1) {
271
- return "'";
272
- } else if ($2) {
273
- return $2.replace(/''/g, "'");
274
- } else if ($3) {
275
- return String(aValues[parseInt($3)]);
276
- }
277
- throw new Error("formatMessage: pattern syntax error at pos. " + offset);
278
- });
279
- };
280
-
281
- class Properties {}
282
-
283
- class merge {}
284
-
285
- var rLocale = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;
286
- var M_ISO639_NEW_TO_OLD = {
287
- "he": "iw",
288
- "yi": "ji",
289
- "nb": "no",
290
- "sr": "sh"
291
- };
292
- var M_ISO639_OLD_TO_NEW = {
293
- "iw": "he",
294
- "ji": "yi",
295
- "no": "nb"
296
- };
297
- var M_SUPPORTABILITY_TO_XS = {
298
- "en_US_saptrc": "1Q",
299
- "en_US_sappsd": "2Q",
300
- "en_US_saprigi": "3Q"
301
- };
302
- var sDefaultFallbackLocale = "en";
303
- var rSAPSupportabilityLocales = /(?:^|-)(saptrc|sappsd|saprigi)(?:-|$)/i;
304
- function normalize(sLocale, bPreserveLanguage) {
305
- var m;
306
- if (typeof sLocale === "string" && (m = rLocale.exec(sLocale.replace(/_/g, "-")))) {
307
- var sLanguage = m[1].toLowerCase();
308
- if (!bPreserveLanguage) {
309
- sLanguage = M_ISO639_NEW_TO_OLD[sLanguage] || sLanguage;
310
- }
311
- var sScript = m[2] ? m[2].toLowerCase() : undefined;
312
- var sRegion = m[3] ? m[3].toUpperCase() : undefined;
313
- var sVariants = m[4] ? m[4].slice(1) : undefined;
314
- var sPrivate = m[6];
315
- if (sPrivate && (m = rSAPSupportabilityLocales.exec(sPrivate)) || sVariants && (m = rSAPSupportabilityLocales.exec(sVariants))) {
316
- return "en_US_" + m[1].toLowerCase();
317
- }
318
- if (sLanguage === "zh" && !sRegion) {
319
- if (sScript === "hans") {
320
- sRegion = "CN";
321
- } else if (sScript === "hant") {
322
- sRegion = "TW";
323
- }
324
- }
325
- if (sLanguage === "sr" && sScript === "latn") {
326
- if (bPreserveLanguage) {
327
- sLanguage = "sr_Latn";
328
- } else {
329
- sLanguage = "sh";
330
- }
331
- }
332
- return sLanguage + (sRegion ? "_" + sRegion + (sVariants ? "_" + sVariants.replace("-", "_") : "") : "");
333
- }
334
- }
335
- function normalizePreserveEmpty(sLocale, bPreserveLanguage) {
336
- if (sLocale === "") {
337
- return sLocale;
338
- }
339
- var sNormalizedLocale = normalize(sLocale, bPreserveLanguage);
340
- if (sNormalizedLocale === undefined) {
341
- throw new TypeError("Locale '" + sLocale + "' is not a valid BCP47 language tag");
342
- }
343
- return sNormalizedLocale;
344
- }
345
- function defaultLocale(sFallbackLocale) {
346
- var sLocale;
347
- if (window.sap && window.sap.ui && sap.ui.getCore) {
348
- sLocale = sap.ui.getCore().getConfiguration().getLanguage();
349
- sLocale = normalize(sLocale);
350
- }
351
- return sLocale || sFallbackLocale;
352
- }
353
- function defaultSupportedLocales() {
354
- if (window.sap && window.sap.ui && sap.ui.getCore) {
355
- return sap.ui.getCore().getConfiguration().getSupportedLanguages();
356
- }
357
- return [];
358
- }
359
- function convertLocaleToBCP47(sLocale, bConvertToModern) {
360
- var m;
361
- if (typeof sLocale === "string" && (m = rLocale.exec(sLocale.replace(/_/g, "-")))) {
362
- var sLanguage = m[1].toLowerCase();
363
- var sScript = m[2] ? m[2].toLowerCase() : undefined;
364
- if (bConvertToModern && sLanguage === "sh" && !sScript) {
365
- sLanguage = "sr_Latn";
366
- } else if (!bConvertToModern && sLanguage === "sr" && sScript === "latn") {
367
- sLanguage = "sh";
368
- }
369
- sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
370
- return sLanguage + (m[3] ? "-" + m[3].toUpperCase() + (m[4] ? "-" + m[4].slice(1).replace("_", "-") : "") : "");
371
- }
372
- }
373
- var rUrl = /^((?:[^?#]*\/)?[^\/?#]*)(\.[^.\/?#]+)((?:\?([^#]*))?(?:#(.*))?)$/;
374
- var A_VALID_FILE_TYPES = [".properties", ".hdbtextbundle"];
375
- function splitUrl(sUrl) {
376
- var m = rUrl.exec(sUrl);
377
- if (!m || A_VALID_FILE_TYPES.indexOf(m[2]) < 0) {
378
- throw new Error("resource URL '" + sUrl + "' has unknown type (should be one of " + A_VALID_FILE_TYPES.join(",") + ")");
379
- }
380
- return {
381
- url: sUrl,
382
- prefix: m[1],
383
- ext: m[2],
384
- query: m[4],
385
- hash: m[5] || "",
386
- suffix: m[2] + (m[3] || "")
387
- };
388
- }
389
- function ResourceBundle(sUrl, sLocale, bIncludeInfo, bAsync, aSupportedLocales, sFallbackLocale, bSkipFallbackLocaleAndRaw) {
390
- this.sLocale = normalize(sLocale) || defaultLocale(sFallbackLocale === undefined ? sDefaultFallbackLocale : sFallbackLocale);
391
- this.oUrlInfo = splitUrl(sUrl);
392
- this.bIncludeInfo = bIncludeInfo;
393
- this.bAsync = bAsync;
394
- this.aCustomBundles = [];
395
- this.aPropertyFiles = [];
396
- this.aPropertyOrigins = [];
397
- this.aLocales = [];
398
- this._aFallbackLocales = calculateFallbackChain(this.sLocale, aSupportedLocales || defaultSupportedLocales(), sFallbackLocale, " of the bundle '" + this.oUrlInfo.url + "'", bSkipFallbackLocaleAndRaw);
399
- if (bAsync) {
400
- var resolveWithThis = (function () {
401
- return this;
402
- }).bind(this);
403
- return loadNextPropertiesAsync(this).then(resolveWithThis, resolveWithThis);
404
- }
405
- loadNextPropertiesSync(this);
406
- }
407
- ResourceBundle.prototype._enhance = function (oCustomBundle) {
408
- if (oCustomBundle instanceof ResourceBundle) {
409
- this.aCustomBundles.push(oCustomBundle);
410
- } else {
411
- Log.error("Custom resource bundle is either undefined or not an instanceof sap/base/i18n/ResourceBundle. Therefore this custom resource bundle will be ignored!");
412
- }
413
- };
414
- ResourceBundle.prototype.getText = function (sKey, aArgs, bIgnoreKeyFallback) {
415
- var sValue = this._getTextFromProperties(sKey, aArgs);
416
- if (sValue != null) {
417
- return sValue;
418
- }
419
- sValue = this._getTextFromFallback(sKey, aArgs);
420
- if (sValue != null) {
421
- return sValue;
422
- }
423
- if (bIgnoreKeyFallback) {
424
- return undefined;
425
- } else {
426
- fnAssert(false, "could not find any translatable text for key '" + sKey + "' in bundle file(s): '" + this.aPropertyOrigins.join("', '") + "'");
427
- return this._formatValue(sKey, sKey, aArgs);
428
- }
429
- };
430
- ResourceBundle.prototype._formatValue = function (sValue, sKey, aArgs) {
431
- if (typeof sValue === "string") {
432
- if (aArgs) {
433
- sValue = fnFormatMessage(sValue, aArgs);
434
- }
435
- if (this.bIncludeInfo) {
436
- sValue = new String(sValue);
437
- sValue.originInfo = {
438
- source: "Resource Bundle",
439
- url: this.oUrlInfo.url,
440
- locale: this.sLocale,
441
- key: sKey
442
- };
443
- }
444
- }
445
- return sValue;
446
- };
447
- ResourceBundle.prototype._getTextFromFallback = function (sKey, aArgs) {
448
- var sValue, i;
449
- for (i = this.aCustomBundles.length - 1; i >= 0; i--) {
450
- sValue = this.aCustomBundles[i]._getTextFromFallback(sKey, aArgs);
451
- if (sValue != null) {
452
- return sValue;
453
- }
454
- }
455
- while (typeof sValue !== "string" && this._aFallbackLocales.length) {
456
- var oProperties = loadNextPropertiesSync(this);
457
- if (oProperties) {
458
- sValue = oProperties.getProperty(sKey);
459
- if (typeof sValue === "string") {
460
- return this._formatValue(sValue, sKey, aArgs);
461
- }
462
- }
463
- }
464
- return null;
465
- };
466
- ResourceBundle.prototype._getTextFromProperties = function (sKey, aArgs) {
467
- var sValue = null, i;
468
- for (i = this.aCustomBundles.length - 1; i >= 0; i--) {
469
- sValue = this.aCustomBundles[i]._getTextFromProperties(sKey, aArgs);
470
- if (sValue != null) {
471
- return sValue;
472
- }
473
- }
474
- for (i = 0; i < this.aPropertyFiles.length; i++) {
475
- sValue = this.aPropertyFiles[i].getProperty(sKey);
476
- if (typeof sValue === "string") {
477
- return this._formatValue(sValue, sKey, aArgs);
478
- }
479
- }
480
- return null;
481
- };
482
- ResourceBundle.prototype.hasText = function (sKey) {
483
- return this.aPropertyFiles.length > 0 && typeof this.aPropertyFiles[0].getProperty(sKey) === "string";
484
- };
485
- ResourceBundle.prototype._recreate = function () {
486
- if (!this._mCreateFactoryParams) {
487
- var error = new Error("ResourceBundle instance can't be recreated as it has not been created by the ResourceBundle.create factory.");
488
- if (this.bAsync) {
489
- return Promise.reject(error);
490
- } else {
491
- throw error;
492
- }
493
- } else {
494
- return ResourceBundle.create(this._mCreateFactoryParams);
495
- }
496
- };
497
- function loadNextPropertiesAsync(oBundle) {
498
- if (oBundle._aFallbackLocales.length) {
499
- return tryToLoadNextProperties(oBundle, true).then(function (oProps) {
500
- return oProps || loadNextPropertiesAsync(oBundle);
501
- });
502
- }
503
- return Promise.resolve(null);
504
- }
505
- function loadNextPropertiesSync(oBundle) {
506
- while (oBundle._aFallbackLocales.length) {
507
- var oProps = tryToLoadNextProperties(oBundle, false);
508
- if (oProps) {
509
- return oProps;
510
- }
511
- }
512
- return null;
513
- }
514
- function tryToLoadNextProperties(oBundle, bAsync) {
515
- var sLocale = oBundle._aFallbackLocales.shift();
516
- if (sLocale != null) {
517
- var oUrl = oBundle.oUrlInfo, sUrl, mHeaders;
518
- if (oUrl.ext === ".hdbtextbundle") {
519
- if (M_SUPPORTABILITY_TO_XS[sLocale]) {
520
- sUrl = oUrl.prefix + oUrl.suffix + "?" + (oUrl.query ? oUrl.query + "&" : "") + "sap-language=" + M_SUPPORTABILITY_TO_XS[sLocale] + (oUrl.hash ? "#" + oUrl.hash : "");
521
- } else {
522
- sUrl = oUrl.url;
523
- }
524
- mHeaders = {
525
- "Accept-Language": convertLocaleToBCP47(sLocale) || ""
526
- };
527
- } else {
528
- sUrl = oUrl.prefix + (sLocale ? "_" + sLocale : "") + oUrl.suffix;
529
- }
530
- var vProperties = Properties.create({
531
- url: sUrl,
532
- headers: mHeaders,
533
- async: !!bAsync,
534
- returnNullIfMissing: true
535
- });
536
- var addProperties = function (oProps) {
537
- if (oProps) {
538
- oBundle.aPropertyFiles.push(oProps);
539
- oBundle.aPropertyOrigins.push(sUrl);
540
- oBundle.aLocales.push(sLocale);
541
- }
542
- return oProps;
543
- };
544
- return bAsync ? vProperties.then(addProperties) : addProperties(vProperties);
545
- }
546
- return bAsync ? Promise.resolve(null) : null;
547
- }
548
- ResourceBundle._getUrl = function (bundleUrl, bundleName) {
549
- var sUrl = bundleUrl;
550
- if (bundleName) {
551
- bundleName = bundleName.replace(/\./g, "/");
552
- sUrl = sap.ui.require.toUrl(bundleName) + ".properties";
553
- }
554
- return sUrl;
555
- };
556
- function getEnhanceWithResourceBundles(aActiveTerminologies, aEnhanceWith, sLocale, bIncludeInfo, bAsync, sFallbackLocale, aSupportedLocales) {
557
- if (!aEnhanceWith) {
558
- return [];
559
- }
560
- var aCustomBundles = [];
561
- aEnhanceWith.forEach(function (oEnhanceWith) {
562
- if (oEnhanceWith.fallbackLocale === undefined) {
563
- oEnhanceWith.fallbackLocale = sFallbackLocale;
564
- }
565
- if (oEnhanceWith.supportedLocales === undefined) {
566
- oEnhanceWith.supportedLocales = aSupportedLocales;
567
- }
568
- var sUrl = ResourceBundle._getUrl(oEnhanceWith.bundleUrl, oEnhanceWith.bundleName);
569
- var vResourceBundle = new ResourceBundle(sUrl, sLocale, bIncludeInfo, bAsync, oEnhanceWith.supportedLocales, oEnhanceWith.fallbackLocale);
570
- aCustomBundles.push(vResourceBundle);
571
- if (oEnhanceWith.terminologies) {
572
- aCustomBundles = aCustomBundles.concat(getTerminologyResourceBundles(aActiveTerminologies, oEnhanceWith.terminologies, sLocale, bIncludeInfo, bAsync));
573
- }
574
- });
575
- return aCustomBundles;
576
- }
577
- function getTerminologyResourceBundles(aActiveTerminologies, oTerminologies, sLocale, bIncludeInfo, bAsync) {
578
- if (!aActiveTerminologies) {
579
- return [];
580
- }
581
- aActiveTerminologies = aActiveTerminologies.filter(function (sActiveTechnology) {
582
- return oTerminologies.hasOwnProperty(sActiveTechnology);
583
- });
584
- aActiveTerminologies.reverse();
585
- return aActiveTerminologies.map(function (sActiveTechnology) {
586
- var mParamsTerminology = oTerminologies[sActiveTechnology];
587
- var sUrl = ResourceBundle._getUrl(mParamsTerminology.bundleUrl, mParamsTerminology.bundleName);
588
- var aSupportedLocales = mParamsTerminology.supportedLocales;
589
- return new ResourceBundle(sUrl, sLocale, bIncludeInfo, bAsync, aSupportedLocales, null, true);
590
- });
591
- }
592
- ResourceBundle.create = function (mParams) {
593
- var mOriginalCreateParams = merge({}, mParams);
594
- mParams = merge({
595
- url: "",
596
- includeInfo: false
597
- }, mParams);
598
- if (mParams.bundleUrl || mParams.bundleName) {
599
- mParams.url = mParams.url || ResourceBundle._getUrl(mParams.bundleUrl, mParams.bundleName);
600
- }
601
- mParams = ResourceBundle._enrichBundleConfig(mParams);
602
- var vResourceBundle = new ResourceBundle(mParams.url, mParams.locale, mParams.includeInfo, !!mParams.async, mParams.supportedLocales, mParams.fallbackLocale);
603
- if (vResourceBundle instanceof Promise) {
604
- vResourceBundle = vResourceBundle.then(function (oResourceBundle) {
605
- oResourceBundle._mCreateFactoryParams = mOriginalCreateParams;
606
- return oResourceBundle;
607
- });
608
- } else {
609
- vResourceBundle._mCreateFactoryParams = mOriginalCreateParams;
610
- }
611
- var aCustomBundles = [];
612
- if (mParams.terminologies) {
613
- aCustomBundles = aCustomBundles.concat(getTerminologyResourceBundles(mParams.activeTerminologies, mParams.terminologies, mParams.locale, mParams.includeInfo, !!mParams.async));
614
- }
615
- if (mParams.enhanceWith) {
616
- aCustomBundles = aCustomBundles.concat(getEnhanceWithResourceBundles(mParams.activeTerminologies, mParams.enhanceWith, mParams.locale, mParams.includeInfo, !!mParams.async, mParams.fallbackLocale, mParams.supportedLocales));
617
- }
618
- if (aCustomBundles.length) {
619
- if (vResourceBundle instanceof Promise) {
620
- vResourceBundle = vResourceBundle.then(function (oResourceBundle) {
621
- return Promise.all(aCustomBundles).then(function (aCustomBundles) {
622
- aCustomBundles.forEach(oResourceBundle._enhance, oResourceBundle);
623
- }).then(function () {
624
- return oResourceBundle;
625
- });
626
- });
627
- } else {
628
- aCustomBundles.forEach(vResourceBundle._enhance, vResourceBundle);
629
- }
630
- }
631
- return vResourceBundle;
632
- };
633
- ResourceBundle._enrichBundleConfig = function (mParams) {
634
- return mParams;
635
- };
636
- function findSupportedLocale(sLocale, aSupportedLocales) {
637
- if (!aSupportedLocales || aSupportedLocales.length === 0 || aSupportedLocales.indexOf(sLocale) >= 0) {
638
- return sLocale;
639
- }
640
- sLocale = convertLocaleToBCP47(sLocale, true);
641
- if (sLocale) {
642
- sLocale = normalize(sLocale, true);
643
- }
644
- if (aSupportedLocales.indexOf(sLocale) >= 0) {
645
- return sLocale;
646
- }
647
- return undefined;
648
- }
649
- function calculateFallbackChain(sLocale, aSupportedLocales, sFallbackLocale, sContextInfo, bSkipFallbackLocaleAndRaw) {
650
- aSupportedLocales = aSupportedLocales && aSupportedLocales.map(function (sSupportedLocale) {
651
- return normalizePreserveEmpty(sSupportedLocale, true);
652
- });
653
- if (!bSkipFallbackLocaleAndRaw) {
654
- var bFallbackLocaleDefined = sFallbackLocale !== undefined;
655
- sFallbackLocale = bFallbackLocaleDefined ? sFallbackLocale : sDefaultFallbackLocale;
656
- sFallbackLocale = normalizePreserveEmpty(sFallbackLocale);
657
- if (sFallbackLocale !== "" && !findSupportedLocale(sFallbackLocale, aSupportedLocales)) {
658
- var sMessage = "The fallback locale '" + sFallbackLocale + "' is not contained in the list of supported locales ['" + aSupportedLocales.join("', '") + "']" + sContextInfo + " and will be ignored.";
659
- if (bFallbackLocaleDefined) {
660
- throw new Error(sMessage);
661
- }
662
- Log.error(sMessage);
663
- }
664
- }
665
- var aLocales = [], sSupportedLocale;
666
- while (sLocale != null) {
667
- sSupportedLocale = findSupportedLocale(sLocale, aSupportedLocales);
668
- if (sSupportedLocale !== undefined && aLocales.indexOf(sSupportedLocale) === -1) {
669
- aLocales.push(sSupportedLocale);
670
- }
671
- if (!sLocale) {
672
- sLocale = null;
673
- } else if (sLocale === "zh_HK") {
674
- sLocale = "zh_TW";
675
- } else if (sLocale.lastIndexOf("_") >= 0) {
676
- sLocale = sLocale.slice(0, sLocale.lastIndexOf("_"));
677
- } else if (bSkipFallbackLocaleAndRaw) {
678
- sLocale = null;
679
- } else if (sFallbackLocale) {
680
- sLocale = sFallbackLocale;
681
- sFallbackLocale = null;
682
- } else {
683
- sLocale = "";
684
- }
685
- }
686
- return aLocales;
687
- }
688
- ResourceBundle._getFallbackLocales = function (sLocale, aSupportedLocales, sFallbackLocale) {
689
- return calculateFallbackChain(normalize(sLocale), aSupportedLocales, sFallbackLocale, "");
690
- };
691
-
692
- exports.ResourceBundle = ResourceBundle;
@@ -1,5 +0,0 @@
1
- import ResourceBundle from "sap/base/i18n/ResourceBundle";
2
-
3
- export {
4
- ResourceBundle
5
- };
@@ -1 +0,0 @@
1
- export default class Localization {}
@@ -1 +0,0 @@
1
- export default class formatMessage {}
@@ -1 +0,0 @@
1
- export default class Properties {}