Add files

This commit is contained in:
DoomRye 2022-07-26 10:06:20 -07:00
commit bb80829159
18195 changed files with 2122994 additions and 0 deletions

View file

@ -0,0 +1,214 @@
/* jslint esnext: true */
// Match these datetime components in a CLDR pattern, except those in single quotes
"use strict";
exports.createDateTimeFormat = createDateTimeFormat, exports.createDateTimeFormats = createDateTimeFormats;
var expDTComponents = /(?:[Eec]{1,6}|G{1,5}|(?:[yYu]+|U{1,5})|[ML]{1,5}|d{1,2}|a|[hkHK]{1,2}|m{1,2}|s{1,2}|z{1,4})(?=([^']*'[^']*')*[^']*$)/g;
// Skip over patterns with these datetime components
var unwantedDTCs = /[QxXVOvZASjgFDwWIQqH]/;
// Maps the number of characters in a CLDR pattern to the specification
var dtcLengthMap = {
month: [ 'numeric', '2-digit', 'short', 'long', 'narrow' ],
weekday: [ 'short', 'short', 'short', 'long', 'narrow' ],
era: [ 'short', 'short', 'short', 'long', 'narrow' ]
};
var dtKeys = ["weekday", "era", "year", "month", "day"];
var tmKeys = ["hour", "minute", "second", "timeZoneName"];
function isDateFormatOnly(obj) {
for (var i = 0; i < tmKeys.length; i += 1) {
if (obj.hasOwnProperty(tmKeys[i])) {
return false;
}
}
return true;
}
function isTimeFormatOnly(obj) {
for (var i = 0; i < dtKeys.length; i += 1) {
if (obj.hasOwnProperty(dtKeys[i])) {
return false;
}
}
return true;
}
function createDateTimeFormat(format) {
if (unwantedDTCs.test(format))
return undefined;
var formatObj = {};
// Replace the pattern string with the one required by the specification, whilst
// at the same time evaluating it for the subsets and formats
formatObj.pattern = format.replace(expDTComponents, function ($0) {
// See which symbol we're dealing with
switch ($0.charAt(0)) {
case 'E':
case 'e':
case 'c':
formatObj.weekday = dtcLengthMap.weekday[$0.length-1];
return '{weekday}';
// Not supported yet
case 'G':
formatObj.era = dtcLengthMap.era[$0.length-1];
return '{era}';
case 'y':
case 'Y':
case 'u':
case 'U':
formatObj.year = $0.length === 2 ? '2-digit' : 'numeric';
return '{year}';
case 'M':
case 'L':
formatObj.month = dtcLengthMap.month[$0.length-1];
return '{month}';
case 'd':
formatObj.day = $0.length === 2 ? '2-digit' : 'numeric';
return '{day}';
case 'a':
return '{ampm}';
case 'h':
case 'H':
case 'k':
case 'K':
formatObj.hour = $0.length === 2 ? '2-digit' : 'numeric';
return '{hour}';
case 'm':
formatObj.minute = $0.length === 2 ? '2-digit' : 'numeric';
return '{minute}';
case 's':
formatObj.second = $0.length === 2 ? '2-digit' : 'numeric';
return '{second}';
case 'z':
formatObj.timeZoneName = $0.length < 4 ? 'short' : 'long';
return '{timeZoneName}';
}
});
// From http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns:
// 'In patterns, two single quotes represents a literal single quote, either
// inside or outside single quotes. Text within single quotes is not
// interpreted in any way (except for two adjacent single quotes).'
formatObj.pattern = formatObj.pattern.replace(/'([^']*)'/g, function ($0, literal) {
return literal ? literal : "'";
});
if (formatObj.pattern.indexOf('{ampm}') > -1) {
formatObj.hour12 = true;
formatObj.pattern12 = formatObj.pattern;
formatObj.pattern = formatObj.pattern.replace('{ampm}', '').replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
return formatObj;
}
function createDateTimeFormats(formats) {
var availableFormats = formats.availableFormats;
var timeFormats = formats.timeFormats;
var dateFormats = formats.dateFormats;
var order = formats.medium;
var result = [];
var key, format, computed, i, j;
var timeRelatedFormats = [];
var dateRelatedFormats = [];
function expandFormat(key, pattern) {
// Expand component lengths if necessary, as allowed in the LDML spec
// Get the lengths of 'M' and 'E' substrings in the date pattern
// as arrays that can be joined to create a new substring
var M = new Array((key.match(/M/g)||[]).length + 1);
var E = new Array((key.match(/E/g)||[]).length + 1);
// note from caridy: I'm not sure we really need this, seems to be
// useless since it relies on the keys from CLDR
// instead of the actual format pattern, but I'm not sure.
if (M.length > 2)
pattern = pattern.replace(/(M|L)+/, M.join('$1'));
if (E.length > 2)
pattern = pattern.replace(/([Eec])+/, E.join('$1'));
return pattern;
}
// Map available (custom) formats into a pattern for createDateTimeFormats
for (key in availableFormats) {
if (availableFormats.hasOwnProperty(key)) {
format = expandFormat(key, availableFormats[key]);
computed = createDateTimeFormat(format);
if (computed) {
result.push(computed);
// in some cases, the format is only displaying date specific props
// or time specific props, in which case we need to also produce the
// combined formats.
if (isDateFormatOnly(computed)) {
dateRelatedFormats.push(format);
} else if (isTimeFormatOnly(computed)) {
timeRelatedFormats.push(format);
}
}
}
}
// combine custom time and custom date formats when they are orthogonals to complete the
// formats supported by browsers by relying on the value of "formats.medium" which defines
// how to join custom formats into a single pattern.
for (i = 0; i < timeRelatedFormats.length; i += 1) {
for (j = 0; j < dateRelatedFormats.length; j += 1) {
format = order
.replace('{0}', timeRelatedFormats[i])
.replace('{1}', dateRelatedFormats[j])
.replace(/^[,\s]+|[,\s]+$/gi, '');
computed = createDateTimeFormat(format);
if (computed) {
result.push(computed);
}
}
}
// Map time formats into a pattern for createDateTimeFormats
for (key in timeFormats) {
if (timeFormats.hasOwnProperty(key)) {
format = expandFormat(key, timeFormats[key]);
computed = createDateTimeFormat(format);
if (computed) {
result.push(computed);
}
}
}
// Map date formats into a pattern for createDateTimeFormats
for (key in dateFormats) {
if (dateFormats.hasOwnProperty(key)) {
format = expandFormat(key, dateFormats[key]);
computed = createDateTimeFormat(format);
if (computed) {
result.push(computed);
}
}
}
return result;
}
//# sourceMappingURL=cldr.js.map
//////////////////
// WEBPACK FOOTER
// ./~/intl/lib/cldr.js
// module id = 2556
// module chunks = 4

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,110 @@
/* jshint esnext: true, laxbreak:true */
/**
* Defines regular expressions for various operations related to the BCP 47 syntax,
* as defined at http://tools.ietf.org/html/bcp47#section-2.1
*/
"use strict";
var
// extlang = 3ALPHA ; selected ISO 639 codes
// *2("-" 3ALPHA) ; permanently reserved
extlang = '[a-z]{3}(?:-[a-z]{3}){0,2}',
// language = 2*3ALPHA ; shortest ISO 639 code
// ["-" extlang] ; sometimes followed by
// ; extended language subtags
// / 4ALPHA ; or reserved for future use
// / 5*8ALPHA ; or registered language subtag
language = '(?:[a-z]{2,3}(?:-' + extlang + ')?|[a-z]{4}|[a-z]{5,8})',
// script = 4ALPHA ; ISO 15924 code
script = '[a-z]{4}',
// region = 2ALPHA ; ISO 3166-1 code
// / 3DIGIT ; UN M.49 code
region = '(?:[a-z]{2}|\\d{3})',
// variant = 5*8alphanum ; registered variants
// / (DIGIT 3alphanum)
variant = '(?:[a-z0-9]{5,8}|\\d[a-z0-9]{3})',
// ; Single alphanumerics
// ; "x" reserved for private use
// singleton = DIGIT ; 0 - 9
// / %x41-57 ; A - W
// / %x59-5A ; Y - Z
// / %x61-77 ; a - w
// / %x79-7A ; y - z
singleton = '[0-9a-wy-z]',
// extension = singleton 1*("-" (2*8alphanum))
extension = singleton + '(?:-[a-z0-9]{2,8})+',
// privateuse = "x" 1*("-" (1*8alphanum))
privateuse = 'x(?:-[a-z0-9]{1,8})+',
// irregular = "en-GB-oed" ; irregular tags do not match
// / "i-ami" ; the 'langtag' production and
// / "i-bnn" ; would not otherwise be
// / "i-default" ; considered 'well-formed'
// / "i-enochian" ; These tags are all valid,
// / "i-hak" ; but most are deprecated
// / "i-klingon" ; in favor of more modern
// / "i-lux" ; subtags or subtag
// / "i-mingo" ; combination
// / "i-navajo"
// / "i-pwn"
// / "i-tao"
// / "i-tay"
// / "i-tsu"
// / "sgn-BE-FR"
// / "sgn-BE-NL"
// / "sgn-CH-DE"
irregular = '(?:en-GB-oed'
+ '|i-(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)'
+ '|sgn-(?:BE-FR|BE-NL|CH-DE))',
// regular = "art-lojban" ; these tags match the 'langtag'
// / "cel-gaulish" ; production, but their subtags
// / "no-bok" ; are not extended language
// / "no-nyn" ; or variant subtags: their meaning
// / "zh-guoyu" ; is defined by their registration
// / "zh-hakka" ; and all of these are deprecated
// / "zh-min" ; in favor of a more modern
// / "zh-min-nan" ; subtag or sequence of subtags
// / "zh-xiang"
regular = '(?:art-lojban|cel-gaulish|no-bok|no-nyn'
+ '|zh-(?:guoyu|hakka|min|min-nan|xiang))',
// grandfathered = irregular ; non-redundant tags registered
// / regular ; during the RFC 3066 era
grandfathered = '(?:' + irregular + '|' + regular + ')',
// langtag = language
// ["-" script]
// ["-" region]
// *("-" variant)
// *("-" extension)
// ["-" privateuse]
langtag = language + '(?:-' + script + ')?(?:-' + region + ')?(?:-'
+ variant + ')*(?:-' + extension + ')*(?:-' + privateuse + ')?';
var expBCP47Syntax = RegExp('^(?:'+langtag+'|'+privateuse+'|'+grandfathered+')$', 'i');
var expVariantDupes = RegExp('^(?!x).*?-('+variant+')-(?:\\w{4,8}-(?!x-))*\\1\\b', 'i');
var expSingletonDupes = RegExp('^(?!x).*?-('+singleton+')-(?:\\w+-(?!x-))*\\1\\b', 'i');
var expExtSequences = RegExp('-'+extension, 'ig');
exports.expBCP47Syntax = expBCP47Syntax, exports.expVariantDupes = expVariantDupes, exports.expSingletonDupes = expSingletonDupes, exports.expExtSequences = expExtSequences;
//# sourceMappingURL=exp.js.map
//////////////////
// WEBPACK FOOTER
// ./~/intl/lib/exp.js
// module id = 2558
// module chunks = 4