@formatjs/intl-displaynames 7.3.1 → 7.3.2
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.
- package/index.d.ts +99 -24
- package/index.js +291 -92
- package/index.js.map +1 -0
- package/package.json +4 -5
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +396 -2
- package/polyfill-force.js.map +1 -0
- package/polyfill.d.ts +1 -1
- package/polyfill.iife.js +4719 -5514
- package/polyfill.js +1014 -3
- package/polyfill.js.map +1 -0
- package/should-polyfill.d.ts +6 -2
- package/should-polyfill.js +586 -15
- package/should-polyfill.js.map +1 -0
- package/abstract/CanonicalCodeForDisplayNames.d.ts +0 -1
- package/abstract/CanonicalCodeForDisplayNames.js +0 -48
- package/abstract/IsValidDateTimeFieldCode.d.ts +0 -1
- package/abstract/IsValidDateTimeFieldCode.js +0 -17
- package/supported-locales.generated.d.ts +0 -1
- package/supported-locales.generated.js +0 -573
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../ecma262-abstract/ToString.js","../../ecma402-abstract/CanonicalizeLocaleList.js","../../ecma402-abstract/GetOption.js","../../ecma402-abstract/GetOptionsObject.js","../../ecma402-abstract/IsWellFormedCurrencyCode.js","../../ecma262-abstract/ToObject.js","../../ecma402-abstract/SupportedLocales.js","../../../node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js","../../ecma402-abstract/utils.js","../../ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js","../../ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js","../index.ts"],"sourcesContent":["/**\n* https://tc39.es/ecma262/#sec-tostring\n*/\nexport function ToString(o) {\n\tif (typeof o === \"symbol\") {\n\t\tthrow TypeError(\"Cannot convert a Symbol value to a string\");\n\t}\n\treturn String(o);\n}\n","/**\n* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist\n* @param locales\n*/\nexport function CanonicalizeLocaleList(locales) {\n\t// TODO\n\treturn Intl.getCanonicalLocales(locales);\n}\n","import { ToString } from \"#packages/ecma262-abstract/ToString.js\";\n/**\n* https://tc39.es/ecma402/#sec-getoption\n* @param opts\n* @param prop\n* @param type\n* @param values\n* @param fallback\n*/\nexport function GetOption(opts, prop, type, values, fallback) {\n\tif (typeof opts !== \"object\") {\n\t\tthrow new TypeError(\"Options must be an object\");\n\t}\n\tlet value = opts[prop];\n\tif (value !== undefined) {\n\t\tif (type !== \"boolean\" && type !== \"string\") {\n\t\t\tthrow new TypeError(\"invalid type\");\n\t\t}\n\t\tif (type === \"boolean\") {\n\t\t\tvalue = Boolean(value);\n\t\t}\n\t\tif (type === \"string\") {\n\t\t\tvalue = ToString(value);\n\t\t}\n\t\tif (values !== undefined && !values.filter((val) => val == value).length) {\n\t\t\tthrow new RangeError(`${value} is not within ${values.join(\", \")}`);\n\t\t}\n\t\treturn value;\n\t}\n\treturn fallback;\n}\n","/**\n* https://tc39.es/ecma402/#sec-getoptionsobject\n* @param options\n* @returns\n*/\nexport function GetOptionsObject(options) {\n\tif (typeof options === \"undefined\") {\n\t\treturn Object.create(null);\n\t}\n\tif (typeof options === \"object\") {\n\t\treturn options;\n\t}\n\tthrow new TypeError(\"Options must be an object\");\n}\n","/**\n* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping\n* @param str string to convert\n*/\nfunction toUpperCase(str) {\n\treturn str.replace(/([a-z])/g, (_, c) => c.toUpperCase());\n}\nconst NOT_A_Z_REGEX = /[^A-Z]/;\n/**\n* https://tc39.es/ecma402/#sec-iswellformedcurrencycode\n*/\nexport function IsWellFormedCurrencyCode(currency) {\n\tcurrency = toUpperCase(currency);\n\tif (currency.length !== 3) {\n\t\treturn false;\n\t}\n\tif (NOT_A_Z_REGEX.test(currency)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n","/**\n* https://tc39.es/ecma262/#sec-toobject\n*/\nexport function ToObject(arg) {\n\tif (arg == null) {\n\t\tthrow new TypeError(\"undefined/null cannot be converted to object\");\n\t}\n\treturn Object(arg);\n}\n","import { LookupSupportedLocales } from \"@formatjs/intl-localematcher\";\nimport { ToObject } from \"#packages/ecma262-abstract/ToObject.js\";\nimport { GetOption } from \"#packages/ecma402-abstract/GetOption.js\";\n/**\n* https://tc39.es/ecma402/#sec-supportedlocales\n* @param availableLocales\n* @param requestedLocales\n* @param options\n*/\nexport function SupportedLocales(availableLocales, requestedLocales, options) {\n\tlet matcher = \"best fit\";\n\tif (options !== undefined) {\n\t\toptions = ToObject(options);\n\t\tmatcher = GetOption(options, \"localeMatcher\", \"string\", [\"lookup\", \"best fit\"], \"best fit\");\n\t}\n\tif (matcher === \"best fit\") {\n\t\treturn LookupSupportedLocales(Array.from(availableLocales), requestedLocales);\n\t}\n\treturn LookupSupportedLocales(Array.from(availableLocales), requestedLocales);\n}\n","//#region packages/fast-memoize/index.ts\nfunction memoize(fn, options) {\n\tconst cache = options && options.cache ? options.cache : cacheDefault;\n\tconst serializer = options && options.serializer ? options.serializer : serializerDefault;\n\treturn (options && options.strategy ? options.strategy : strategyDefault)(fn, {\n\t\tcache,\n\t\tserializer\n\t});\n}\nfunction isPrimitive(value) {\n\treturn value == null || typeof value === \"number\" || typeof value === \"boolean\";\n}\nfunction monadic(fn, cache, serializer, arg) {\n\tconst cacheKey = isPrimitive(arg) ? arg : serializer(arg);\n\tlet computedValue = cache.get(cacheKey);\n\tif (typeof computedValue === \"undefined\") {\n\t\tcomputedValue = fn.call(this, arg);\n\t\tcache.set(cacheKey, computedValue);\n\t}\n\treturn computedValue;\n}\nfunction variadic(fn, cache, serializer) {\n\tconst args = Array.prototype.slice.call(arguments, 3);\n\tconst cacheKey = serializer(args);\n\tlet computedValue = cache.get(cacheKey);\n\tif (typeof computedValue === \"undefined\") {\n\t\tcomputedValue = fn.apply(this, args);\n\t\tcache.set(cacheKey, computedValue);\n\t}\n\treturn computedValue;\n}\nfunction assemble(fn, context, strategy, cache, serialize) {\n\treturn strategy.bind(context, fn, cache, serialize);\n}\nfunction strategyDefault(fn, options) {\n\tconst strategy = fn.length === 1 ? monadic : variadic;\n\treturn assemble(fn, this, strategy, options.cache.create(), options.serializer);\n}\nfunction strategyVariadic(fn, options) {\n\treturn assemble(fn, this, variadic, options.cache.create(), options.serializer);\n}\nfunction strategyMonadic(fn, options) {\n\treturn assemble(fn, this, monadic, options.cache.create(), options.serializer);\n}\nconst serializerDefault = function() {\n\treturn JSON.stringify(arguments);\n};\nvar ObjectWithoutPrototypeCache = class {\n\tconstructor() {\n\t\tthis.cache = Object.create(null);\n\t}\n\tget(key) {\n\t\treturn this.cache[key];\n\t}\n\tset(key, value) {\n\t\tthis.cache[key] = value;\n\t}\n};\nconst cacheDefault = { create: function create() {\n\treturn new ObjectWithoutPrototypeCache();\n} };\nconst strategies = {\n\tvariadic: strategyVariadic,\n\tmonadic: strategyMonadic\n};\n//#endregion\nexport { memoize, strategies };\n\n//# sourceMappingURL=index.js.map","import { memoize, strategies } from \"@formatjs/fast-memoize\";\nexport function repeat(s, times) {\n\tif (typeof s.repeat === \"function\") {\n\t\treturn s.repeat(times);\n\t}\n\tconst arr = Array.from({ length: times });\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tarr[i] = s;\n\t}\n\treturn arr.join(\"\");\n}\nexport function setInternalSlot(map, pl, field, value) {\n\tif (!map.get(pl)) {\n\t\tmap.set(pl, Object.create(null));\n\t}\n\tconst slots = map.get(pl);\n\tslots[field] = value;\n}\nexport function setMultiInternalSlots(map, pl, props) {\n\tfor (const k of Object.keys(props)) {\n\t\tsetInternalSlot(map, pl, k, props[k]);\n\t}\n}\nexport function getInternalSlot(map, pl, field) {\n\treturn getMultiInternalSlots(map, pl, field)[field];\n}\nexport function getMultiInternalSlots(map, pl, ...fields) {\n\tconst slots = map.get(pl);\n\tif (!slots) {\n\t\tthrow new TypeError(`${pl} InternalSlot has not been initialized`);\n\t}\n\treturn fields.reduce((all, f) => {\n\t\tall[f] = slots[f];\n\t\treturn all;\n\t}, Object.create(null));\n}\nexport function isLiteralPart(patternPart) {\n\treturn patternPart.type === \"literal\";\n}\n/*\n17 ECMAScript Standard Built-in Objects:\nEvery built-in Function object, including constructors, that is not\nidentified as an anonymous function has a name property whose value\nis a String.\n\nUnless otherwise specified, the name property of a built-in Function\nobject, if it exists, has the attributes { [[Writable]]: false,\n[[Enumerable]]: false, [[Configurable]]: true }.\n*/\nexport function defineProperty(target, name, { value }) {\n\tObject.defineProperty(target, name, {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tvalue\n\t});\n}\n/**\n* 7.3.5 CreateDataProperty\n* @param target\n* @param name\n* @param value\n*/\nexport function createDataProperty(target, name, value) {\n\tObject.defineProperty(target, name, {\n\t\tconfigurable: true,\n\t\tenumerable: true,\n\t\twritable: true,\n\t\tvalue\n\t});\n}\nexport const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;\nexport function invariant(condition, message, Err = Error) {\n\tif (!condition) {\n\t\tthrow new Err(message);\n\t}\n}\nexport const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });\nexport const createMemoizedPluralRules = memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });\nexport const createMemoizedLocale = memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });\nexport const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });\n","const CODES_FOR_DATE_TIME_FIELD = [\n\t\"era\",\n\t\"year\",\n\t\"quarter\",\n\t\"month\",\n\t\"weekOfYear\",\n\t\"weekday\",\n\t\"day\",\n\t\"dayPeriod\",\n\t\"hour\",\n\t\"minute\",\n\t\"second\",\n\t\"timeZoneName\"\n];\nexport function IsValidDateTimeFieldCode(field) {\n\treturn CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;\n}\n","import { CanonicalizeLocaleList } from \"#packages/ecma402-abstract/CanonicalizeLocaleList.js\";\nimport { IsWellFormedCurrencyCode } from \"#packages/ecma402-abstract/IsWellFormedCurrencyCode.js\";\nimport { invariant } from \"#packages/ecma402-abstract/utils.js\";\nimport { IsValidDateTimeFieldCode } from \"#packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js\";\nconst UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;\nconst ALPHA_4 = /^[a-z]{4}$/i;\nconst UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;\nfunction isUnicodeRegionSubtag(region) {\n\treturn UNICODE_REGION_SUBTAG_REGEX.test(region);\n}\nfunction isUnicodeScriptSubtag(script) {\n\treturn ALPHA_4.test(script);\n}\nfunction isUnicodeLocaleIdentifierType(code) {\n\treturn UNICODE_TYPE_REGEX.test(code);\n}\nexport function CanonicalCodeForDisplayNames(type, code) {\n\tif (type === \"language\") {\n\t\treturn CanonicalizeLocaleList([code])[0];\n\t}\n\tif (type === \"region\") {\n\t\tif (!isUnicodeRegionSubtag(code)) {\n\t\t\tthrow RangeError(\"invalid region\");\n\t\t}\n\t\treturn code.toUpperCase();\n\t}\n\tif (type === \"script\") {\n\t\tif (!isUnicodeScriptSubtag(code)) {\n\t\t\tthrow RangeError(\"invalid script\");\n\t\t}\n\t\treturn `${code[0].toUpperCase()}${code.slice(1).toLowerCase()}`;\n\t}\n\tif (type === \"calendar\") {\n\t\tif (!isUnicodeLocaleIdentifierType(code)) {\n\t\t\tthrow RangeError(\"invalid calendar\");\n\t\t}\n\t\treturn code.toLowerCase();\n\t}\n\tif (type === \"dateTimeField\") {\n\t\tif (!IsValidDateTimeFieldCode(code)) {\n\t\t\tthrow RangeError(\"invalid dateTimeField\");\n\t\t}\n\t\treturn code;\n\t}\n\tinvariant(type === \"currency\", \"invalid type\");\n\tif (!IsWellFormedCurrencyCode(code)) {\n\t\tthrow RangeError(\"invalid currency\");\n\t}\n\treturn code.toUpperCase();\n}\n","import {ToString} from '#packages/ecma262-abstract/ToString.js'\nimport {CanonicalizeLocaleList} from '#packages/ecma402-abstract/CanonicalizeLocaleList.js'\nimport {GetOption} from '#packages/ecma402-abstract/GetOption.js'\nimport {GetOptionsObject} from '#packages/ecma402-abstract/GetOptionsObject.js'\nimport {IsWellFormedCurrencyCode} from '#packages/ecma402-abstract/IsWellFormedCurrencyCode.js'\nimport {SupportedLocales} from '#packages/ecma402-abstract/SupportedLocales.js'\nimport {\n type DisplayNamesData,\n type DisplayNamesLocaleData,\n} from '#packages/ecma402-abstract/types/displaynames.js'\nimport {\n getInternalSlot,\n getMultiInternalSlots,\n invariant,\n setInternalSlot,\n} from '#packages/ecma402-abstract/utils.js'\nimport {CanonicalCodeForDisplayNames} from '#packages/ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js'\nimport {IsValidDateTimeFieldCode} from '#packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js'\n\nimport {ResolveLocale} from '@formatjs/intl-localematcher'\n\nexport interface DisplayNamesOptions {\n localeMatcher?: 'lookup' | 'best fit'\n style?: 'narrow' | 'short' | 'long'\n type:\n | 'language'\n | 'region'\n | 'script'\n | 'currency'\n | 'calendar'\n | 'dateTimeField'\n fallback?: 'code' | 'none'\n languageDisplay?: 'dialect' | 'standard'\n}\n\nexport interface DisplayNamesResolvedOptions {\n locale: string\n style: NonNullable<DisplayNamesOptions['style']>\n type: NonNullable<DisplayNamesOptions['type']>\n fallback: NonNullable<DisplayNamesOptions['fallback']>\n languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>\n}\n\nexport class DisplayNames {\n constructor(\n locales: string | string[] | undefined,\n options: DisplayNamesOptions\n ) {\n if (new.target === undefined) {\n throw TypeError(`Constructor Intl.DisplayNames requires 'new'`)\n }\n const requestedLocales = CanonicalizeLocaleList(locales)\n options = GetOptionsObject(options)\n\n const opt = Object.create(null)\n const {localeData} = DisplayNames\n const matcher = GetOption(\n options,\n 'localeMatcher',\n 'string',\n ['lookup', 'best fit'],\n 'best fit'\n )\n opt.localeMatcher = matcher\n\n const r = ResolveLocale(\n Array.from(DisplayNames.availableLocales),\n requestedLocales,\n opt,\n [], // there is no relevantExtensionKeys\n DisplayNames.localeData,\n DisplayNames.getDefaultLocale\n )\n\n const style = GetOption(\n options,\n 'style',\n 'string',\n ['narrow', 'short', 'long'],\n 'long'\n )\n setSlot(this, 'style', style)\n\n const type = GetOption(\n options,\n 'type',\n 'string',\n ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'],\n undefined\n )\n if (type === undefined) {\n throw TypeError(`Intl.DisplayNames constructor requires \"type\" option`)\n }\n\n setSlot(this, 'type', type)\n\n const fallback = GetOption(\n options,\n 'fallback',\n 'string',\n ['code', 'none'],\n 'code'\n )\n setSlot(this, 'fallback', fallback)\n setSlot(this, 'locale', r.locale)\n\n const {dataLocale} = r\n const dataLocaleData = localeData[dataLocale]\n invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`)\n setSlot(this, 'localeData', dataLocaleData)\n invariant(\n dataLocaleData !== undefined,\n `locale data for ${r.locale} does not exist.`\n )\n const {types} = dataLocaleData\n invariant(typeof types === 'object' && types != null, 'invalid types data')\n const typeFields = types[type]\n invariant(\n typeof typeFields === 'object' && typeFields != null,\n 'invalid typeFields data'\n )\n const languageDisplay = GetOption(\n options,\n 'languageDisplay',\n 'string',\n ['dialect', 'standard'],\n 'dialect'\n )\n if (type === 'language') {\n setSlot(this, 'languageDisplay', languageDisplay)\n // Using types[type] instead of typeFields because TypeScript cannot infer the correct type\n const typeFields = types[type][languageDisplay]\n invariant(\n typeof typeFields === 'object' && typeFields != null,\n 'invalid language typeFields data'\n )\n }\n\n // Using types[type] instead of typeFields because TypeScript cannot infer the correct type\n const styleFields =\n type === 'language'\n ? types[type][languageDisplay][style]\n : types[type][style]\n invariant(\n typeof styleFields === 'object' && styleFields != null,\n 'invalid styleFields data'\n )\n setSlot(this, 'fields', styleFields)\n }\n\n static supportedLocalesOf(\n locales?: string | string[],\n options?: Pick<DisplayNamesOptions, 'localeMatcher'>\n ): string[] {\n return SupportedLocales(\n DisplayNames.availableLocales,\n CanonicalizeLocaleList(locales),\n options\n )\n }\n\n static __addLocaleData(...data: DisplayNamesLocaleData[]): void {\n for (const {data: d, locale} of data) {\n const minimizedLocale = new (Intl as any).Locale(locale)\n .minimize()\n .toString()\n DisplayNames.localeData[locale] = DisplayNames.localeData[\n minimizedLocale\n ] = d\n DisplayNames.availableLocales.add(minimizedLocale)\n DisplayNames.availableLocales.add(locale)\n if (!DisplayNames.__defaultLocale) {\n DisplayNames.__defaultLocale = minimizedLocale\n }\n }\n }\n\n of(code: string | number | Record<string, unknown>): string | undefined {\n checkReceiver(this, 'of')\n const type = getSlot(this, 'type')\n const codeAsString = ToString(code)\n if (!isValidCodeForDisplayNames(type, codeAsString)) {\n throw RangeError('invalid code for Intl.DisplayNames.prototype.of')\n }\n const {localeData, style, fallback} = getMultiInternalSlots(\n __INTERNAL_SLOT_MAP__,\n this,\n 'localeData',\n 'style',\n 'fallback'\n )\n\n // Canonicalize the case.\n let canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString)\n\n let name: string | undefined\n if (type === 'language') {\n const languageDisplay = getSlot(this, 'languageDisplay')\n name = getNameForTypeLanguage(\n languageDisplay,\n localeData,\n style,\n canonicalCode,\n fallback\n )\n } else {\n // All the other types\n const typesData = localeData.types[type]\n name = typesData[style][canonicalCode] || typesData.long[canonicalCode]\n }\n\n if (name !== undefined) {\n return name\n }\n\n if (fallback === 'code') {\n return codeAsString\n }\n }\n\n resolvedOptions(): DisplayNamesResolvedOptions {\n checkReceiver(this, 'resolvedOptions')\n return {\n ...getMultiInternalSlots(\n __INTERNAL_SLOT_MAP__,\n this,\n 'locale',\n 'style',\n 'type',\n 'fallback',\n 'languageDisplay'\n ),\n }\n }\n\n static localeData: Record<string, DisplayNamesData | undefined> = {}\n private static availableLocales = new Set<string>()\n private static __defaultLocale = ''\n private static getDefaultLocale() {\n return DisplayNames.__defaultLocale\n }\n public static readonly polyfilled = true\n}\n\n// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames\nfunction isValidCodeForDisplayNames(\n type: NonNullable<DisplayNamesOptions['type']>,\n code: string\n): boolean {\n switch (type) {\n case 'language':\n // subset of unicode_language_id\n // languageCode [\"-\" scriptCode] [\"-\" regionCode] *(\"-\" variant)\n // where:\n // - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.\n // - scriptCode is should be an ISO-15924 four letters script code\n // - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.\n return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\\d{3}))?(-([a-z\\d]{5,8}|\\d[a-z\\d]{3}))*$/i.test(\n code\n )\n case 'region':\n // unicode_region_subtag\n return /^([a-z]{2}|\\d{3})$/i.test(code)\n case 'script':\n // unicode_script_subtag\n return /^[a-z]{4}$/i.test(code)\n case 'currency':\n return IsWellFormedCurrencyCode(code)\n case 'calendar':\n // unicode locale identifier type\n return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code)\n case 'dateTimeField':\n return IsValidDateTimeFieldCode(code)\n }\n}\n\ntry {\n // IE11 does not have Symbol\n if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {\n value: 'Intl.DisplayNames',\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n Object.defineProperty(DisplayNames, 'length', {\n value: 2,\n writable: false,\n enumerable: false,\n configurable: true,\n })\n} catch {\n // Make test 262 compliant\n}\n\ninterface DisplayNamesInternalSlots {\n locale: string\n style: NonNullable<DisplayNamesOptions['style']>\n type: NonNullable<DisplayNamesOptions['type']>\n fallback: NonNullable<DisplayNamesOptions['fallback']>\n languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>\n // Note that this differs from `fields` slot in the spec.\n localeData: DisplayNamesData\n fields: Record<string, string>\n}\n\nconst __INTERNAL_SLOT_MAP__ = new WeakMap<\n DisplayNames,\n DisplayNamesInternalSlots\n>()\n\nfunction getSlot<K extends keyof DisplayNamesInternalSlots>(\n instance: DisplayNames,\n key: K\n): DisplayNamesInternalSlots[K] {\n return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key)\n}\n\nfunction setSlot<K extends keyof DisplayNamesInternalSlots>(\n instance: DisplayNames,\n key: K,\n value: DisplayNamesInternalSlots[K]\n): void {\n setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value)\n}\n\nfunction checkReceiver(receiver: unknown, methodName: string) {\n if (!(receiver instanceof DisplayNames)) {\n throw TypeError(\n `Method Intl.DisplayNames.prototype.${methodName} called on incompatible receiver`\n )\n }\n}\n\nfunction getNameForTypeLanguage(\n languageDisplay: DisplayNamesInternalSlots['languageDisplay'],\n localeData: DisplayNamesData,\n style: DisplayNamesInternalSlots['style'],\n canonicalCode: string,\n fallback: DisplayNamesInternalSlots['fallback']\n): string | undefined {\n // First, try to get the name using the canonicalCode\n const typesData = localeData.types.language[languageDisplay]\n const name = typesData[style][canonicalCode] || typesData.long[canonicalCode]\n\n if (name === undefined) {\n // If no name has been found using the canonicalCode,\n // check if the latter contains a region sub tag\n const regionMatch = /-([a-z]{2}|\\d{3})\\b/i.exec(canonicalCode)\n if (regionMatch) {\n // Extract the language and region sub tags\n const languageSubTag =\n canonicalCode.substring(0, regionMatch.index) +\n canonicalCode.substring(regionMatch.index + regionMatch[0].length)\n const regionSubTag = regionMatch[1]\n\n // Let's try again using languageSubTag this time\n const name =\n typesData[style][languageSubTag] || typesData.long[languageSubTag]\n\n // If a name has been found and a region sub tag exists,\n // compose them together or use the code fallback\n if (name !== undefined && regionSubTag) {\n // Retrieve region display names\n const regionsData = localeData.types.region\n const regionDisplayName: string | undefined =\n regionsData[style][regionSubTag] || regionsData.long[regionSubTag]\n\n if (regionDisplayName || fallback === 'code') {\n // Interpolate into locale-specific pattern.\n const pattern = localeData.patterns.locale\n return pattern\n .replace('{0}', name)\n .replace('{1}', regionDisplayName || regionSubTag)\n }\n } else {\n return name\n }\n }\n } else {\n return name\n }\n}\n"],"x_google_ignoreList":[7],"mappings":";;;;;AAGA,SAAgB,SAAS,GAAG;AAC3B,KAAI,OAAO,MAAM,SAChB,OAAM,UAAU,4CAA4C;AAE7D,QAAO,OAAO,EAAE;;;;;;;;ACHjB,SAAgB,uBAAuB,SAAS;AAE/C,QAAO,KAAK,oBAAoB,QAAQ;;;;;;;;;;;;ACGzC,SAAgB,UAAU,MAAM,MAAM,MAAM,QAAQ,UAAU;AAC7D,KAAI,OAAO,SAAS,SACnB,OAAM,IAAI,UAAU,4BAA4B;CAEjD,IAAI,QAAQ,KAAK;AACjB,KAAI,UAAU,KAAA,GAAW;AACxB,MAAI,SAAS,aAAa,SAAS,SAClC,OAAM,IAAI,UAAU,eAAe;AAEpC,MAAI,SAAS,UACZ,SAAQ,QAAQ,MAAM;AAEvB,MAAI,SAAS,SACZ,SAAQ,SAAS,MAAM;AAExB,MAAI,WAAW,KAAA,KAAa,CAAC,OAAO,QAAQ,QAAQ,OAAO,MAAM,CAAC,OACjE,OAAM,IAAI,WAAW,GAAG,MAAM,iBAAiB,OAAO,KAAK,KAAK,GAAG;AAEpE,SAAO;;AAER,QAAO;;;;;;;;;ACxBR,SAAgB,iBAAiB,SAAS;AACzC,KAAI,OAAO,YAAY,YACtB,QAAO,OAAO,OAAO,KAAK;AAE3B,KAAI,OAAO,YAAY,SACtB,QAAO;AAER,OAAM,IAAI,UAAU,4BAA4B;;;;;;;;ACRjD,SAAS,YAAY,KAAK;AACzB,QAAO,IAAI,QAAQ,aAAa,GAAG,MAAM,EAAE,aAAa,CAAC;;AAE1D,MAAM,gBAAgB;;;;AAItB,SAAgB,yBAAyB,UAAU;AAClD,YAAW,YAAY,SAAS;AAChC,KAAI,SAAS,WAAW,EACvB,QAAO;AAER,KAAI,cAAc,KAAK,SAAS,CAC/B,QAAO;AAER,QAAO;;;;;;;AChBR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eR,MAAM,wCAAwB,IAAI,SAG/B;AAEH,SAAS,QACP,UACA,KAC8B;AAC9B,QAAO,gBAAgB,uBAAuB,UAAU,IAAI;;AAG9D,SAAS,QACP,UACA,KACA,OACM;AACN,iBAAgB,uBAAuB,UAAU,KAAK,MAAM;;AAG9D,SAAS,cAAc,UAAmB,YAAoB;AAC5D,KAAI,EAAE,oBAAoB,cACxB,OAAM,UACJ,sCAAsC,WAAW,kCAClD;;AAIL,SAAS,uBACP,iBACA,YACA,OACA,eACA,UACoB;CAEpB,MAAM,YAAY,WAAW,MAAM,SAAS;CAC5C,MAAM,OAAO,UAAU,OAAO,kBAAkB,UAAU,KAAK;AAE/D,KAAI,SAAS,KAAA,GAAW;EAGtB,MAAM,cAAc,uBAAuB,KAAK,cAAc;AAC9D,MAAI,aAAa;GAEf,MAAM,iBACJ,cAAc,UAAU,GAAG,YAAY,MAAM,GAC7C,cAAc,UAAU,YAAY,QAAQ,YAAY,GAAG,OAAO;GACpE,MAAM,eAAe,YAAY;GAGjC,MAAM,OACJ,UAAU,OAAO,mBAAmB,UAAU,KAAK;AAIrD,OAAI,SAAS,KAAA,KAAa,cAAc;IAEtC,MAAM,cAAc,WAAW,MAAM;IACrC,MAAM,oBACJ,YAAY,OAAO,iBAAiB,YAAY,KAAK;AAEvD,QAAI,qBAAqB,aAAa,OAGpC,QADgB,WAAW,SAAS,OAEjC,QAAQ,OAAO,KAAK,CACpB,QAAQ,OAAO,qBAAqB,aAAa;SAGtD,QAAO;;OAIX,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-displaynames",
|
|
3
3
|
"description": "Polyfill for: https://tc39.es/proposal-intl-displaynames",
|
|
4
|
-
"version": "7.3.
|
|
4
|
+
"version": "7.3.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Linjie Ding <pyrocat101@users.noreply.github.com>",
|
|
7
7
|
"type": "module",
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
"./locale-data": "./locale-data"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@formatjs/
|
|
19
|
-
"@formatjs/intl-localematcher": "0.8.2"
|
|
18
|
+
"@formatjs/intl-localematcher": "0.8.3"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
|
-
"@formatjs/intl-
|
|
23
|
-
"@formatjs/intl-
|
|
21
|
+
"@formatjs/intl-getcanonicallocales": "3.2.3",
|
|
22
|
+
"@formatjs/intl-locale": "5.3.2"
|
|
24
23
|
},
|
|
25
24
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
26
25
|
"homepage": "https://github.com/formatjs/formatjs",
|
package/polyfill-force.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/polyfill-force.js
CHANGED
|
@@ -1,13 +1,407 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
|
+
//#region packages/ecma262-abstract/ToString.js
|
|
3
|
+
/**
|
|
4
|
+
* https://tc39.es/ecma262/#sec-tostring
|
|
5
|
+
*/
|
|
6
|
+
function ToString(o) {
|
|
7
|
+
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
|
|
8
|
+
return String(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
12
|
+
/**
|
|
13
|
+
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
14
|
+
* @param locales
|
|
15
|
+
*/
|
|
16
|
+
function CanonicalizeLocaleList(locales) {
|
|
17
|
+
return Intl.getCanonicalLocales(locales);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region packages/ecma402-abstract/GetOption.js
|
|
21
|
+
/**
|
|
22
|
+
* https://tc39.es/ecma402/#sec-getoption
|
|
23
|
+
* @param opts
|
|
24
|
+
* @param prop
|
|
25
|
+
* @param type
|
|
26
|
+
* @param values
|
|
27
|
+
* @param fallback
|
|
28
|
+
*/
|
|
29
|
+
function GetOption(opts, prop, type, values, fallback) {
|
|
30
|
+
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
31
|
+
let value = opts[prop];
|
|
32
|
+
if (value !== void 0) {
|
|
33
|
+
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
34
|
+
if (type === "boolean") value = Boolean(value);
|
|
35
|
+
if (type === "string") value = ToString(value);
|
|
36
|
+
if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return fallback;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region packages/ecma402-abstract/GetOptionsObject.js
|
|
43
|
+
/**
|
|
44
|
+
* https://tc39.es/ecma402/#sec-getoptionsobject
|
|
45
|
+
* @param options
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function GetOptionsObject(options) {
|
|
49
|
+
if (typeof options === "undefined") return Object.create(null);
|
|
50
|
+
if (typeof options === "object") return options;
|
|
51
|
+
throw new TypeError("Options must be an object");
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/ecma402-abstract/IsWellFormedCurrencyCode.js
|
|
55
|
+
/**
|
|
56
|
+
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
57
|
+
* @param str string to convert
|
|
58
|
+
*/
|
|
59
|
+
function toUpperCase(str) {
|
|
60
|
+
return str.replace(/([a-z])/g, (_, c) => c.toUpperCase());
|
|
61
|
+
}
|
|
62
|
+
const NOT_A_Z_REGEX = /[^A-Z]/;
|
|
63
|
+
/**
|
|
64
|
+
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
|
|
65
|
+
*/
|
|
66
|
+
function IsWellFormedCurrencyCode(currency) {
|
|
67
|
+
currency = toUpperCase(currency);
|
|
68
|
+
if (currency.length !== 3) return false;
|
|
69
|
+
if (NOT_A_Z_REGEX.test(currency)) return false;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region packages/ecma262-abstract/ToObject.js
|
|
74
|
+
/**
|
|
75
|
+
* https://tc39.es/ecma262/#sec-toobject
|
|
76
|
+
*/
|
|
77
|
+
function ToObject(arg) {
|
|
78
|
+
if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
|
|
79
|
+
return Object(arg);
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region packages/ecma402-abstract/SupportedLocales.js
|
|
83
|
+
/**
|
|
84
|
+
* https://tc39.es/ecma402/#sec-supportedlocales
|
|
85
|
+
* @param availableLocales
|
|
86
|
+
* @param requestedLocales
|
|
87
|
+
* @param options
|
|
88
|
+
*/
|
|
89
|
+
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
90
|
+
let matcher = "best fit";
|
|
91
|
+
if (options !== void 0) {
|
|
92
|
+
options = ToObject(options);
|
|
93
|
+
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
94
|
+
}
|
|
95
|
+
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
96
|
+
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
100
|
+
function memoize(fn, options) {
|
|
101
|
+
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
102
|
+
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
103
|
+
return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
|
|
104
|
+
cache,
|
|
105
|
+
serializer
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function isPrimitive(value) {
|
|
109
|
+
return value == null || typeof value === "number" || typeof value === "boolean";
|
|
110
|
+
}
|
|
111
|
+
function monadic(fn, cache, serializer, arg) {
|
|
112
|
+
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
113
|
+
let computedValue = cache.get(cacheKey);
|
|
114
|
+
if (typeof computedValue === "undefined") {
|
|
115
|
+
computedValue = fn.call(this, arg);
|
|
116
|
+
cache.set(cacheKey, computedValue);
|
|
117
|
+
}
|
|
118
|
+
return computedValue;
|
|
119
|
+
}
|
|
120
|
+
function variadic(fn, cache, serializer) {
|
|
121
|
+
const args = Array.prototype.slice.call(arguments, 3);
|
|
122
|
+
const cacheKey = serializer(args);
|
|
123
|
+
let computedValue = cache.get(cacheKey);
|
|
124
|
+
if (typeof computedValue === "undefined") {
|
|
125
|
+
computedValue = fn.apply(this, args);
|
|
126
|
+
cache.set(cacheKey, computedValue);
|
|
127
|
+
}
|
|
128
|
+
return computedValue;
|
|
129
|
+
}
|
|
130
|
+
function assemble(fn, context, strategy, cache, serialize) {
|
|
131
|
+
return strategy.bind(context, fn, cache, serialize);
|
|
132
|
+
}
|
|
133
|
+
function strategyDefault(fn, options) {
|
|
134
|
+
const strategy = fn.length === 1 ? monadic : variadic;
|
|
135
|
+
return assemble(fn, this, strategy, options.cache.create(), options.serializer);
|
|
136
|
+
}
|
|
137
|
+
function strategyVariadic(fn, options) {
|
|
138
|
+
return assemble(fn, this, variadic, options.cache.create(), options.serializer);
|
|
139
|
+
}
|
|
140
|
+
function strategyMonadic(fn, options) {
|
|
141
|
+
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
|
142
|
+
}
|
|
143
|
+
const serializerDefault = function() {
|
|
144
|
+
return JSON.stringify(arguments);
|
|
145
|
+
};
|
|
146
|
+
var ObjectWithoutPrototypeCache = class {
|
|
147
|
+
constructor() {
|
|
148
|
+
this.cache = Object.create(null);
|
|
149
|
+
}
|
|
150
|
+
get(key) {
|
|
151
|
+
return this.cache[key];
|
|
152
|
+
}
|
|
153
|
+
set(key, value) {
|
|
154
|
+
this.cache[key] = value;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const cacheDefault = { create: function create() {
|
|
158
|
+
return new ObjectWithoutPrototypeCache();
|
|
159
|
+
} };
|
|
160
|
+
const strategies = {
|
|
161
|
+
variadic: strategyVariadic,
|
|
162
|
+
monadic: strategyMonadic
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region packages/ecma402-abstract/utils.js
|
|
166
|
+
function setInternalSlot(map, pl, field, value) {
|
|
167
|
+
if (!map.get(pl)) map.set(pl, Object.create(null));
|
|
168
|
+
const slots = map.get(pl);
|
|
169
|
+
slots[field] = value;
|
|
170
|
+
}
|
|
171
|
+
function getInternalSlot(map, pl, field) {
|
|
172
|
+
return getMultiInternalSlots(map, pl, field)[field];
|
|
173
|
+
}
|
|
174
|
+
function getMultiInternalSlots(map, pl, ...fields) {
|
|
175
|
+
const slots = map.get(pl);
|
|
176
|
+
if (!slots) throw new TypeError(`${pl} InternalSlot has not been initialized`);
|
|
177
|
+
return fields.reduce((all, f) => {
|
|
178
|
+
all[f] = slots[f];
|
|
179
|
+
return all;
|
|
180
|
+
}, Object.create(null));
|
|
181
|
+
}
|
|
182
|
+
function invariant(condition, message, Err = Error) {
|
|
183
|
+
if (!condition) throw new Err(message);
|
|
184
|
+
}
|
|
185
|
+
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
186
|
+
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
|
|
187
|
+
memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });
|
|
188
|
+
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js
|
|
191
|
+
const CODES_FOR_DATE_TIME_FIELD = [
|
|
192
|
+
"era",
|
|
193
|
+
"year",
|
|
194
|
+
"quarter",
|
|
195
|
+
"month",
|
|
196
|
+
"weekOfYear",
|
|
197
|
+
"weekday",
|
|
198
|
+
"day",
|
|
199
|
+
"dayPeriod",
|
|
200
|
+
"hour",
|
|
201
|
+
"minute",
|
|
202
|
+
"second",
|
|
203
|
+
"timeZoneName"
|
|
204
|
+
];
|
|
205
|
+
function IsValidDateTimeFieldCode(field) {
|
|
206
|
+
return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region packages/ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js
|
|
210
|
+
const UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
|
|
211
|
+
const ALPHA_4 = /^[a-z]{4}$/i;
|
|
212
|
+
const UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
|
|
213
|
+
function isUnicodeRegionSubtag(region) {
|
|
214
|
+
return UNICODE_REGION_SUBTAG_REGEX.test(region);
|
|
215
|
+
}
|
|
216
|
+
function isUnicodeScriptSubtag(script) {
|
|
217
|
+
return ALPHA_4.test(script);
|
|
218
|
+
}
|
|
219
|
+
function isUnicodeLocaleIdentifierType(code) {
|
|
220
|
+
return UNICODE_TYPE_REGEX.test(code);
|
|
221
|
+
}
|
|
222
|
+
function CanonicalCodeForDisplayNames(type, code) {
|
|
223
|
+
if (type === "language") return CanonicalizeLocaleList([code])[0];
|
|
224
|
+
if (type === "region") {
|
|
225
|
+
if (!isUnicodeRegionSubtag(code)) throw RangeError("invalid region");
|
|
226
|
+
return code.toUpperCase();
|
|
227
|
+
}
|
|
228
|
+
if (type === "script") {
|
|
229
|
+
if (!isUnicodeScriptSubtag(code)) throw RangeError("invalid script");
|
|
230
|
+
return `${code[0].toUpperCase()}${code.slice(1).toLowerCase()}`;
|
|
231
|
+
}
|
|
232
|
+
if (type === "calendar") {
|
|
233
|
+
if (!isUnicodeLocaleIdentifierType(code)) throw RangeError("invalid calendar");
|
|
234
|
+
return code.toLowerCase();
|
|
235
|
+
}
|
|
236
|
+
if (type === "dateTimeField") {
|
|
237
|
+
if (!IsValidDateTimeFieldCode(code)) throw RangeError("invalid dateTimeField");
|
|
238
|
+
return code;
|
|
239
|
+
}
|
|
240
|
+
invariant(type === "currency", "invalid type");
|
|
241
|
+
if (!IsWellFormedCurrencyCode(code)) throw RangeError("invalid currency");
|
|
242
|
+
return code.toUpperCase();
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region packages/intl-displaynames/index.ts
|
|
246
|
+
var DisplayNames = class DisplayNames {
|
|
247
|
+
constructor(locales, options) {
|
|
248
|
+
if (new.target === void 0) throw TypeError(`Constructor Intl.DisplayNames requires 'new'`);
|
|
249
|
+
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
250
|
+
options = GetOptionsObject(options);
|
|
251
|
+
const opt = Object.create(null);
|
|
252
|
+
const { localeData } = DisplayNames;
|
|
253
|
+
opt.localeMatcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
254
|
+
const r = ResolveLocale(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], DisplayNames.localeData, DisplayNames.getDefaultLocale);
|
|
255
|
+
const style = GetOption(options, "style", "string", [
|
|
256
|
+
"narrow",
|
|
257
|
+
"short",
|
|
258
|
+
"long"
|
|
259
|
+
], "long");
|
|
260
|
+
setSlot(this, "style", style);
|
|
261
|
+
const type = GetOption(options, "type", "string", [
|
|
262
|
+
"language",
|
|
263
|
+
"region",
|
|
264
|
+
"script",
|
|
265
|
+
"currency",
|
|
266
|
+
"calendar",
|
|
267
|
+
"dateTimeField"
|
|
268
|
+
], void 0);
|
|
269
|
+
if (type === void 0) throw TypeError(`Intl.DisplayNames constructor requires "type" option`);
|
|
270
|
+
setSlot(this, "type", type);
|
|
271
|
+
const fallback = GetOption(options, "fallback", "string", ["code", "none"], "code");
|
|
272
|
+
setSlot(this, "fallback", fallback);
|
|
273
|
+
setSlot(this, "locale", r.locale);
|
|
274
|
+
const { dataLocale } = r;
|
|
275
|
+
const dataLocaleData = localeData[dataLocale];
|
|
276
|
+
invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`);
|
|
277
|
+
setSlot(this, "localeData", dataLocaleData);
|
|
278
|
+
invariant(dataLocaleData !== void 0, `locale data for ${r.locale} does not exist.`);
|
|
279
|
+
const { types } = dataLocaleData;
|
|
280
|
+
invariant(typeof types === "object" && types != null, "invalid types data");
|
|
281
|
+
const typeFields = types[type];
|
|
282
|
+
invariant(typeof typeFields === "object" && typeFields != null, "invalid typeFields data");
|
|
283
|
+
const languageDisplay = GetOption(options, "languageDisplay", "string", ["dialect", "standard"], "dialect");
|
|
284
|
+
if (type === "language") {
|
|
285
|
+
setSlot(this, "languageDisplay", languageDisplay);
|
|
286
|
+
const typeFields = types[type][languageDisplay];
|
|
287
|
+
invariant(typeof typeFields === "object" && typeFields != null, "invalid language typeFields data");
|
|
288
|
+
}
|
|
289
|
+
const styleFields = type === "language" ? types[type][languageDisplay][style] : types[type][style];
|
|
290
|
+
invariant(typeof styleFields === "object" && styleFields != null, "invalid styleFields data");
|
|
291
|
+
setSlot(this, "fields", styleFields);
|
|
292
|
+
}
|
|
293
|
+
static supportedLocalesOf(locales, options) {
|
|
294
|
+
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
295
|
+
}
|
|
296
|
+
static __addLocaleData(...data) {
|
|
297
|
+
for (const { data: d, locale } of data) {
|
|
298
|
+
const minimizedLocale = new Intl.Locale(locale).minimize().toString();
|
|
299
|
+
DisplayNames.localeData[locale] = DisplayNames.localeData[minimizedLocale] = d;
|
|
300
|
+
DisplayNames.availableLocales.add(minimizedLocale);
|
|
301
|
+
DisplayNames.availableLocales.add(locale);
|
|
302
|
+
if (!DisplayNames.__defaultLocale) DisplayNames.__defaultLocale = minimizedLocale;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
of(code) {
|
|
306
|
+
checkReceiver(this, "of");
|
|
307
|
+
const type = getSlot(this, "type");
|
|
308
|
+
const codeAsString = ToString(code);
|
|
309
|
+
if (!isValidCodeForDisplayNames(type, codeAsString)) throw RangeError("invalid code for Intl.DisplayNames.prototype.of");
|
|
310
|
+
const { localeData, style, fallback } = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, "localeData", "style", "fallback");
|
|
311
|
+
let canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
|
|
312
|
+
let name;
|
|
313
|
+
if (type === "language") name = getNameForTypeLanguage(getSlot(this, "languageDisplay"), localeData, style, canonicalCode, fallback);
|
|
314
|
+
else {
|
|
315
|
+
const typesData = localeData.types[type];
|
|
316
|
+
name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
317
|
+
}
|
|
318
|
+
if (name !== void 0) return name;
|
|
319
|
+
if (fallback === "code") return codeAsString;
|
|
320
|
+
}
|
|
321
|
+
resolvedOptions() {
|
|
322
|
+
checkReceiver(this, "resolvedOptions");
|
|
323
|
+
return { ...getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, "locale", "style", "type", "fallback", "languageDisplay") };
|
|
324
|
+
}
|
|
325
|
+
static {
|
|
326
|
+
this.localeData = {};
|
|
327
|
+
}
|
|
328
|
+
static {
|
|
329
|
+
this.availableLocales = /* @__PURE__ */ new Set();
|
|
330
|
+
}
|
|
331
|
+
static {
|
|
332
|
+
this.__defaultLocale = "";
|
|
333
|
+
}
|
|
334
|
+
static getDefaultLocale() {
|
|
335
|
+
return DisplayNames.__defaultLocale;
|
|
336
|
+
}
|
|
337
|
+
static {
|
|
338
|
+
this.polyfilled = true;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
function isValidCodeForDisplayNames(type, code) {
|
|
342
|
+
switch (type) {
|
|
343
|
+
case "language": return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(code);
|
|
344
|
+
case "region": return /^([a-z]{2}|\d{3})$/i.test(code);
|
|
345
|
+
case "script": return /^[a-z]{4}$/i.test(code);
|
|
346
|
+
case "currency": return IsWellFormedCurrencyCode(code);
|
|
347
|
+
case "calendar": return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
|
|
348
|
+
case "dateTimeField": return IsValidDateTimeFieldCode(code);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
if (typeof Symbol !== "undefined" && Symbol.toStringTag) Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
|
|
353
|
+
value: "Intl.DisplayNames",
|
|
354
|
+
configurable: true,
|
|
355
|
+
enumerable: false,
|
|
356
|
+
writable: false
|
|
357
|
+
});
|
|
358
|
+
Object.defineProperty(DisplayNames, "length", {
|
|
359
|
+
value: 2,
|
|
360
|
+
writable: false,
|
|
361
|
+
enumerable: false,
|
|
362
|
+
configurable: true
|
|
363
|
+
});
|
|
364
|
+
} catch {}
|
|
365
|
+
const __INTERNAL_SLOT_MAP__ = /* @__PURE__ */ new WeakMap();
|
|
366
|
+
function getSlot(instance, key) {
|
|
367
|
+
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
|
|
368
|
+
}
|
|
369
|
+
function setSlot(instance, key, value) {
|
|
370
|
+
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
|
|
371
|
+
}
|
|
372
|
+
function checkReceiver(receiver, methodName) {
|
|
373
|
+
if (!(receiver instanceof DisplayNames)) throw TypeError(`Method Intl.DisplayNames.prototype.${methodName} called on incompatible receiver`);
|
|
374
|
+
}
|
|
375
|
+
function getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback) {
|
|
376
|
+
const typesData = localeData.types.language[languageDisplay];
|
|
377
|
+
const name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
378
|
+
if (name === void 0) {
|
|
379
|
+
const regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
|
|
380
|
+
if (regionMatch) {
|
|
381
|
+
const languageSubTag = canonicalCode.substring(0, regionMatch.index) + canonicalCode.substring(regionMatch.index + regionMatch[0].length);
|
|
382
|
+
const regionSubTag = regionMatch[1];
|
|
383
|
+
const name = typesData[style][languageSubTag] || typesData.long[languageSubTag];
|
|
384
|
+
if (name !== void 0 && regionSubTag) {
|
|
385
|
+
const regionsData = localeData.types.region;
|
|
386
|
+
const regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
|
|
387
|
+
if (regionDisplayName || fallback === "code") return localeData.patterns.locale.replace("{0}", name).replace("{1}", regionDisplayName || regionSubTag);
|
|
388
|
+
} else return name;
|
|
389
|
+
}
|
|
390
|
+
} else return name;
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region packages/intl-displaynames/polyfill-force.ts
|
|
2
394
|
Object.defineProperty(Intl, "DisplayNames", {
|
|
3
395
|
value: DisplayNames,
|
|
4
396
|
enumerable: false,
|
|
5
397
|
writable: true,
|
|
6
398
|
configurable: true
|
|
7
399
|
});
|
|
8
|
-
// Drain any locale data that was buffered before polyfill loaded
|
|
9
400
|
const buf = globalThis.__FORMATJS_DISPLAYNAMES_DATA__;
|
|
10
401
|
if (buf) {
|
|
11
402
|
for (const d of buf) DisplayNames.__addLocaleData(d);
|
|
12
403
|
delete globalThis.__FORMATJS_DISPLAYNAMES_DATA__;
|
|
13
404
|
}
|
|
405
|
+
//#endregion
|
|
406
|
+
|
|
407
|
+
//# sourceMappingURL=polyfill-force.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill-force.js","names":[],"sources":["../../ecma262-abstract/ToString.js","../../ecma402-abstract/CanonicalizeLocaleList.js","../../ecma402-abstract/GetOption.js","../../ecma402-abstract/GetOptionsObject.js","../../ecma402-abstract/IsWellFormedCurrencyCode.js","../../ecma262-abstract/ToObject.js","../../ecma402-abstract/SupportedLocales.js","../../../node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js","../../ecma402-abstract/utils.js","../../ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js","../../ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js","../index.ts","../polyfill-force.ts"],"sourcesContent":["/**\n* https://tc39.es/ecma262/#sec-tostring\n*/\nexport function ToString(o) {\n\tif (typeof o === \"symbol\") {\n\t\tthrow TypeError(\"Cannot convert a Symbol value to a string\");\n\t}\n\treturn String(o);\n}\n","/**\n* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist\n* @param locales\n*/\nexport function CanonicalizeLocaleList(locales) {\n\t// TODO\n\treturn Intl.getCanonicalLocales(locales);\n}\n","import { ToString } from \"#packages/ecma262-abstract/ToString.js\";\n/**\n* https://tc39.es/ecma402/#sec-getoption\n* @param opts\n* @param prop\n* @param type\n* @param values\n* @param fallback\n*/\nexport function GetOption(opts, prop, type, values, fallback) {\n\tif (typeof opts !== \"object\") {\n\t\tthrow new TypeError(\"Options must be an object\");\n\t}\n\tlet value = opts[prop];\n\tif (value !== undefined) {\n\t\tif (type !== \"boolean\" && type !== \"string\") {\n\t\t\tthrow new TypeError(\"invalid type\");\n\t\t}\n\t\tif (type === \"boolean\") {\n\t\t\tvalue = Boolean(value);\n\t\t}\n\t\tif (type === \"string\") {\n\t\t\tvalue = ToString(value);\n\t\t}\n\t\tif (values !== undefined && !values.filter((val) => val == value).length) {\n\t\t\tthrow new RangeError(`${value} is not within ${values.join(\", \")}`);\n\t\t}\n\t\treturn value;\n\t}\n\treturn fallback;\n}\n","/**\n* https://tc39.es/ecma402/#sec-getoptionsobject\n* @param options\n* @returns\n*/\nexport function GetOptionsObject(options) {\n\tif (typeof options === \"undefined\") {\n\t\treturn Object.create(null);\n\t}\n\tif (typeof options === \"object\") {\n\t\treturn options;\n\t}\n\tthrow new TypeError(\"Options must be an object\");\n}\n","/**\n* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping\n* @param str string to convert\n*/\nfunction toUpperCase(str) {\n\treturn str.replace(/([a-z])/g, (_, c) => c.toUpperCase());\n}\nconst NOT_A_Z_REGEX = /[^A-Z]/;\n/**\n* https://tc39.es/ecma402/#sec-iswellformedcurrencycode\n*/\nexport function IsWellFormedCurrencyCode(currency) {\n\tcurrency = toUpperCase(currency);\n\tif (currency.length !== 3) {\n\t\treturn false;\n\t}\n\tif (NOT_A_Z_REGEX.test(currency)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n","/**\n* https://tc39.es/ecma262/#sec-toobject\n*/\nexport function ToObject(arg) {\n\tif (arg == null) {\n\t\tthrow new TypeError(\"undefined/null cannot be converted to object\");\n\t}\n\treturn Object(arg);\n}\n","import { LookupSupportedLocales } from \"@formatjs/intl-localematcher\";\nimport { ToObject } from \"#packages/ecma262-abstract/ToObject.js\";\nimport { GetOption } from \"#packages/ecma402-abstract/GetOption.js\";\n/**\n* https://tc39.es/ecma402/#sec-supportedlocales\n* @param availableLocales\n* @param requestedLocales\n* @param options\n*/\nexport function SupportedLocales(availableLocales, requestedLocales, options) {\n\tlet matcher = \"best fit\";\n\tif (options !== undefined) {\n\t\toptions = ToObject(options);\n\t\tmatcher = GetOption(options, \"localeMatcher\", \"string\", [\"lookup\", \"best fit\"], \"best fit\");\n\t}\n\tif (matcher === \"best fit\") {\n\t\treturn LookupSupportedLocales(Array.from(availableLocales), requestedLocales);\n\t}\n\treturn LookupSupportedLocales(Array.from(availableLocales), requestedLocales);\n}\n","//#region packages/fast-memoize/index.ts\nfunction memoize(fn, options) {\n\tconst cache = options && options.cache ? options.cache : cacheDefault;\n\tconst serializer = options && options.serializer ? options.serializer : serializerDefault;\n\treturn (options && options.strategy ? options.strategy : strategyDefault)(fn, {\n\t\tcache,\n\t\tserializer\n\t});\n}\nfunction isPrimitive(value) {\n\treturn value == null || typeof value === \"number\" || typeof value === \"boolean\";\n}\nfunction monadic(fn, cache, serializer, arg) {\n\tconst cacheKey = isPrimitive(arg) ? arg : serializer(arg);\n\tlet computedValue = cache.get(cacheKey);\n\tif (typeof computedValue === \"undefined\") {\n\t\tcomputedValue = fn.call(this, arg);\n\t\tcache.set(cacheKey, computedValue);\n\t}\n\treturn computedValue;\n}\nfunction variadic(fn, cache, serializer) {\n\tconst args = Array.prototype.slice.call(arguments, 3);\n\tconst cacheKey = serializer(args);\n\tlet computedValue = cache.get(cacheKey);\n\tif (typeof computedValue === \"undefined\") {\n\t\tcomputedValue = fn.apply(this, args);\n\t\tcache.set(cacheKey, computedValue);\n\t}\n\treturn computedValue;\n}\nfunction assemble(fn, context, strategy, cache, serialize) {\n\treturn strategy.bind(context, fn, cache, serialize);\n}\nfunction strategyDefault(fn, options) {\n\tconst strategy = fn.length === 1 ? monadic : variadic;\n\treturn assemble(fn, this, strategy, options.cache.create(), options.serializer);\n}\nfunction strategyVariadic(fn, options) {\n\treturn assemble(fn, this, variadic, options.cache.create(), options.serializer);\n}\nfunction strategyMonadic(fn, options) {\n\treturn assemble(fn, this, monadic, options.cache.create(), options.serializer);\n}\nconst serializerDefault = function() {\n\treturn JSON.stringify(arguments);\n};\nvar ObjectWithoutPrototypeCache = class {\n\tconstructor() {\n\t\tthis.cache = Object.create(null);\n\t}\n\tget(key) {\n\t\treturn this.cache[key];\n\t}\n\tset(key, value) {\n\t\tthis.cache[key] = value;\n\t}\n};\nconst cacheDefault = { create: function create() {\n\treturn new ObjectWithoutPrototypeCache();\n} };\nconst strategies = {\n\tvariadic: strategyVariadic,\n\tmonadic: strategyMonadic\n};\n//#endregion\nexport { memoize, strategies };\n\n//# sourceMappingURL=index.js.map","import { memoize, strategies } from \"@formatjs/fast-memoize\";\nexport function repeat(s, times) {\n\tif (typeof s.repeat === \"function\") {\n\t\treturn s.repeat(times);\n\t}\n\tconst arr = Array.from({ length: times });\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tarr[i] = s;\n\t}\n\treturn arr.join(\"\");\n}\nexport function setInternalSlot(map, pl, field, value) {\n\tif (!map.get(pl)) {\n\t\tmap.set(pl, Object.create(null));\n\t}\n\tconst slots = map.get(pl);\n\tslots[field] = value;\n}\nexport function setMultiInternalSlots(map, pl, props) {\n\tfor (const k of Object.keys(props)) {\n\t\tsetInternalSlot(map, pl, k, props[k]);\n\t}\n}\nexport function getInternalSlot(map, pl, field) {\n\treturn getMultiInternalSlots(map, pl, field)[field];\n}\nexport function getMultiInternalSlots(map, pl, ...fields) {\n\tconst slots = map.get(pl);\n\tif (!slots) {\n\t\tthrow new TypeError(`${pl} InternalSlot has not been initialized`);\n\t}\n\treturn fields.reduce((all, f) => {\n\t\tall[f] = slots[f];\n\t\treturn all;\n\t}, Object.create(null));\n}\nexport function isLiteralPart(patternPart) {\n\treturn patternPart.type === \"literal\";\n}\n/*\n17 ECMAScript Standard Built-in Objects:\nEvery built-in Function object, including constructors, that is not\nidentified as an anonymous function has a name property whose value\nis a String.\n\nUnless otherwise specified, the name property of a built-in Function\nobject, if it exists, has the attributes { [[Writable]]: false,\n[[Enumerable]]: false, [[Configurable]]: true }.\n*/\nexport function defineProperty(target, name, { value }) {\n\tObject.defineProperty(target, name, {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tvalue\n\t});\n}\n/**\n* 7.3.5 CreateDataProperty\n* @param target\n* @param name\n* @param value\n*/\nexport function createDataProperty(target, name, value) {\n\tObject.defineProperty(target, name, {\n\t\tconfigurable: true,\n\t\tenumerable: true,\n\t\twritable: true,\n\t\tvalue\n\t});\n}\nexport const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;\nexport function invariant(condition, message, Err = Error) {\n\tif (!condition) {\n\t\tthrow new Err(message);\n\t}\n}\nexport const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });\nexport const createMemoizedPluralRules = memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });\nexport const createMemoizedLocale = memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });\nexport const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });\n","const CODES_FOR_DATE_TIME_FIELD = [\n\t\"era\",\n\t\"year\",\n\t\"quarter\",\n\t\"month\",\n\t\"weekOfYear\",\n\t\"weekday\",\n\t\"day\",\n\t\"dayPeriod\",\n\t\"hour\",\n\t\"minute\",\n\t\"second\",\n\t\"timeZoneName\"\n];\nexport function IsValidDateTimeFieldCode(field) {\n\treturn CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;\n}\n","import { CanonicalizeLocaleList } from \"#packages/ecma402-abstract/CanonicalizeLocaleList.js\";\nimport { IsWellFormedCurrencyCode } from \"#packages/ecma402-abstract/IsWellFormedCurrencyCode.js\";\nimport { invariant } from \"#packages/ecma402-abstract/utils.js\";\nimport { IsValidDateTimeFieldCode } from \"#packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js\";\nconst UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;\nconst ALPHA_4 = /^[a-z]{4}$/i;\nconst UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;\nfunction isUnicodeRegionSubtag(region) {\n\treturn UNICODE_REGION_SUBTAG_REGEX.test(region);\n}\nfunction isUnicodeScriptSubtag(script) {\n\treturn ALPHA_4.test(script);\n}\nfunction isUnicodeLocaleIdentifierType(code) {\n\treturn UNICODE_TYPE_REGEX.test(code);\n}\nexport function CanonicalCodeForDisplayNames(type, code) {\n\tif (type === \"language\") {\n\t\treturn CanonicalizeLocaleList([code])[0];\n\t}\n\tif (type === \"region\") {\n\t\tif (!isUnicodeRegionSubtag(code)) {\n\t\t\tthrow RangeError(\"invalid region\");\n\t\t}\n\t\treturn code.toUpperCase();\n\t}\n\tif (type === \"script\") {\n\t\tif (!isUnicodeScriptSubtag(code)) {\n\t\t\tthrow RangeError(\"invalid script\");\n\t\t}\n\t\treturn `${code[0].toUpperCase()}${code.slice(1).toLowerCase()}`;\n\t}\n\tif (type === \"calendar\") {\n\t\tif (!isUnicodeLocaleIdentifierType(code)) {\n\t\t\tthrow RangeError(\"invalid calendar\");\n\t\t}\n\t\treturn code.toLowerCase();\n\t}\n\tif (type === \"dateTimeField\") {\n\t\tif (!IsValidDateTimeFieldCode(code)) {\n\t\t\tthrow RangeError(\"invalid dateTimeField\");\n\t\t}\n\t\treturn code;\n\t}\n\tinvariant(type === \"currency\", \"invalid type\");\n\tif (!IsWellFormedCurrencyCode(code)) {\n\t\tthrow RangeError(\"invalid currency\");\n\t}\n\treturn code.toUpperCase();\n}\n","import {ToString} from '#packages/ecma262-abstract/ToString.js'\nimport {CanonicalizeLocaleList} from '#packages/ecma402-abstract/CanonicalizeLocaleList.js'\nimport {GetOption} from '#packages/ecma402-abstract/GetOption.js'\nimport {GetOptionsObject} from '#packages/ecma402-abstract/GetOptionsObject.js'\nimport {IsWellFormedCurrencyCode} from '#packages/ecma402-abstract/IsWellFormedCurrencyCode.js'\nimport {SupportedLocales} from '#packages/ecma402-abstract/SupportedLocales.js'\nimport {\n type DisplayNamesData,\n type DisplayNamesLocaleData,\n} from '#packages/ecma402-abstract/types/displaynames.js'\nimport {\n getInternalSlot,\n getMultiInternalSlots,\n invariant,\n setInternalSlot,\n} from '#packages/ecma402-abstract/utils.js'\nimport {CanonicalCodeForDisplayNames} from '#packages/ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js'\nimport {IsValidDateTimeFieldCode} from '#packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js'\n\nimport {ResolveLocale} from '@formatjs/intl-localematcher'\n\nexport interface DisplayNamesOptions {\n localeMatcher?: 'lookup' | 'best fit'\n style?: 'narrow' | 'short' | 'long'\n type:\n | 'language'\n | 'region'\n | 'script'\n | 'currency'\n | 'calendar'\n | 'dateTimeField'\n fallback?: 'code' | 'none'\n languageDisplay?: 'dialect' | 'standard'\n}\n\nexport interface DisplayNamesResolvedOptions {\n locale: string\n style: NonNullable<DisplayNamesOptions['style']>\n type: NonNullable<DisplayNamesOptions['type']>\n fallback: NonNullable<DisplayNamesOptions['fallback']>\n languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>\n}\n\nexport class DisplayNames {\n constructor(\n locales: string | string[] | undefined,\n options: DisplayNamesOptions\n ) {\n if (new.target === undefined) {\n throw TypeError(`Constructor Intl.DisplayNames requires 'new'`)\n }\n const requestedLocales = CanonicalizeLocaleList(locales)\n options = GetOptionsObject(options)\n\n const opt = Object.create(null)\n const {localeData} = DisplayNames\n const matcher = GetOption(\n options,\n 'localeMatcher',\n 'string',\n ['lookup', 'best fit'],\n 'best fit'\n )\n opt.localeMatcher = matcher\n\n const r = ResolveLocale(\n Array.from(DisplayNames.availableLocales),\n requestedLocales,\n opt,\n [], // there is no relevantExtensionKeys\n DisplayNames.localeData,\n DisplayNames.getDefaultLocale\n )\n\n const style = GetOption(\n options,\n 'style',\n 'string',\n ['narrow', 'short', 'long'],\n 'long'\n )\n setSlot(this, 'style', style)\n\n const type = GetOption(\n options,\n 'type',\n 'string',\n ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'],\n undefined\n )\n if (type === undefined) {\n throw TypeError(`Intl.DisplayNames constructor requires \"type\" option`)\n }\n\n setSlot(this, 'type', type)\n\n const fallback = GetOption(\n options,\n 'fallback',\n 'string',\n ['code', 'none'],\n 'code'\n )\n setSlot(this, 'fallback', fallback)\n setSlot(this, 'locale', r.locale)\n\n const {dataLocale} = r\n const dataLocaleData = localeData[dataLocale]\n invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`)\n setSlot(this, 'localeData', dataLocaleData)\n invariant(\n dataLocaleData !== undefined,\n `locale data for ${r.locale} does not exist.`\n )\n const {types} = dataLocaleData\n invariant(typeof types === 'object' && types != null, 'invalid types data')\n const typeFields = types[type]\n invariant(\n typeof typeFields === 'object' && typeFields != null,\n 'invalid typeFields data'\n )\n const languageDisplay = GetOption(\n options,\n 'languageDisplay',\n 'string',\n ['dialect', 'standard'],\n 'dialect'\n )\n if (type === 'language') {\n setSlot(this, 'languageDisplay', languageDisplay)\n // Using types[type] instead of typeFields because TypeScript cannot infer the correct type\n const typeFields = types[type][languageDisplay]\n invariant(\n typeof typeFields === 'object' && typeFields != null,\n 'invalid language typeFields data'\n )\n }\n\n // Using types[type] instead of typeFields because TypeScript cannot infer the correct type\n const styleFields =\n type === 'language'\n ? types[type][languageDisplay][style]\n : types[type][style]\n invariant(\n typeof styleFields === 'object' && styleFields != null,\n 'invalid styleFields data'\n )\n setSlot(this, 'fields', styleFields)\n }\n\n static supportedLocalesOf(\n locales?: string | string[],\n options?: Pick<DisplayNamesOptions, 'localeMatcher'>\n ): string[] {\n return SupportedLocales(\n DisplayNames.availableLocales,\n CanonicalizeLocaleList(locales),\n options\n )\n }\n\n static __addLocaleData(...data: DisplayNamesLocaleData[]): void {\n for (const {data: d, locale} of data) {\n const minimizedLocale = new (Intl as any).Locale(locale)\n .minimize()\n .toString()\n DisplayNames.localeData[locale] = DisplayNames.localeData[\n minimizedLocale\n ] = d\n DisplayNames.availableLocales.add(minimizedLocale)\n DisplayNames.availableLocales.add(locale)\n if (!DisplayNames.__defaultLocale) {\n DisplayNames.__defaultLocale = minimizedLocale\n }\n }\n }\n\n of(code: string | number | Record<string, unknown>): string | undefined {\n checkReceiver(this, 'of')\n const type = getSlot(this, 'type')\n const codeAsString = ToString(code)\n if (!isValidCodeForDisplayNames(type, codeAsString)) {\n throw RangeError('invalid code for Intl.DisplayNames.prototype.of')\n }\n const {localeData, style, fallback} = getMultiInternalSlots(\n __INTERNAL_SLOT_MAP__,\n this,\n 'localeData',\n 'style',\n 'fallback'\n )\n\n // Canonicalize the case.\n let canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString)\n\n let name: string | undefined\n if (type === 'language') {\n const languageDisplay = getSlot(this, 'languageDisplay')\n name = getNameForTypeLanguage(\n languageDisplay,\n localeData,\n style,\n canonicalCode,\n fallback\n )\n } else {\n // All the other types\n const typesData = localeData.types[type]\n name = typesData[style][canonicalCode] || typesData.long[canonicalCode]\n }\n\n if (name !== undefined) {\n return name\n }\n\n if (fallback === 'code') {\n return codeAsString\n }\n }\n\n resolvedOptions(): DisplayNamesResolvedOptions {\n checkReceiver(this, 'resolvedOptions')\n return {\n ...getMultiInternalSlots(\n __INTERNAL_SLOT_MAP__,\n this,\n 'locale',\n 'style',\n 'type',\n 'fallback',\n 'languageDisplay'\n ),\n }\n }\n\n static localeData: Record<string, DisplayNamesData | undefined> = {}\n private static availableLocales = new Set<string>()\n private static __defaultLocale = ''\n private static getDefaultLocale() {\n return DisplayNames.__defaultLocale\n }\n public static readonly polyfilled = true\n}\n\n// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames\nfunction isValidCodeForDisplayNames(\n type: NonNullable<DisplayNamesOptions['type']>,\n code: string\n): boolean {\n switch (type) {\n case 'language':\n // subset of unicode_language_id\n // languageCode [\"-\" scriptCode] [\"-\" regionCode] *(\"-\" variant)\n // where:\n // - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.\n // - scriptCode is should be an ISO-15924 four letters script code\n // - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.\n return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\\d{3}))?(-([a-z\\d]{5,8}|\\d[a-z\\d]{3}))*$/i.test(\n code\n )\n case 'region':\n // unicode_region_subtag\n return /^([a-z]{2}|\\d{3})$/i.test(code)\n case 'script':\n // unicode_script_subtag\n return /^[a-z]{4}$/i.test(code)\n case 'currency':\n return IsWellFormedCurrencyCode(code)\n case 'calendar':\n // unicode locale identifier type\n return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code)\n case 'dateTimeField':\n return IsValidDateTimeFieldCode(code)\n }\n}\n\ntry {\n // IE11 does not have Symbol\n if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {\n value: 'Intl.DisplayNames',\n configurable: true,\n enumerable: false,\n writable: false,\n })\n }\n Object.defineProperty(DisplayNames, 'length', {\n value: 2,\n writable: false,\n enumerable: false,\n configurable: true,\n })\n} catch {\n // Make test 262 compliant\n}\n\ninterface DisplayNamesInternalSlots {\n locale: string\n style: NonNullable<DisplayNamesOptions['style']>\n type: NonNullable<DisplayNamesOptions['type']>\n fallback: NonNullable<DisplayNamesOptions['fallback']>\n languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>\n // Note that this differs from `fields` slot in the spec.\n localeData: DisplayNamesData\n fields: Record<string, string>\n}\n\nconst __INTERNAL_SLOT_MAP__ = new WeakMap<\n DisplayNames,\n DisplayNamesInternalSlots\n>()\n\nfunction getSlot<K extends keyof DisplayNamesInternalSlots>(\n instance: DisplayNames,\n key: K\n): DisplayNamesInternalSlots[K] {\n return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key)\n}\n\nfunction setSlot<K extends keyof DisplayNamesInternalSlots>(\n instance: DisplayNames,\n key: K,\n value: DisplayNamesInternalSlots[K]\n): void {\n setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value)\n}\n\nfunction checkReceiver(receiver: unknown, methodName: string) {\n if (!(receiver instanceof DisplayNames)) {\n throw TypeError(\n `Method Intl.DisplayNames.prototype.${methodName} called on incompatible receiver`\n )\n }\n}\n\nfunction getNameForTypeLanguage(\n languageDisplay: DisplayNamesInternalSlots['languageDisplay'],\n localeData: DisplayNamesData,\n style: DisplayNamesInternalSlots['style'],\n canonicalCode: string,\n fallback: DisplayNamesInternalSlots['fallback']\n): string | undefined {\n // First, try to get the name using the canonicalCode\n const typesData = localeData.types.language[languageDisplay]\n const name = typesData[style][canonicalCode] || typesData.long[canonicalCode]\n\n if (name === undefined) {\n // If no name has been found using the canonicalCode,\n // check if the latter contains a region sub tag\n const regionMatch = /-([a-z]{2}|\\d{3})\\b/i.exec(canonicalCode)\n if (regionMatch) {\n // Extract the language and region sub tags\n const languageSubTag =\n canonicalCode.substring(0, regionMatch.index) +\n canonicalCode.substring(regionMatch.index + regionMatch[0].length)\n const regionSubTag = regionMatch[1]\n\n // Let's try again using languageSubTag this time\n const name =\n typesData[style][languageSubTag] || typesData.long[languageSubTag]\n\n // If a name has been found and a region sub tag exists,\n // compose them together or use the code fallback\n if (name !== undefined && regionSubTag) {\n // Retrieve region display names\n const regionsData = localeData.types.region\n const regionDisplayName: string | undefined =\n regionsData[style][regionSubTag] || regionsData.long[regionSubTag]\n\n if (regionDisplayName || fallback === 'code') {\n // Interpolate into locale-specific pattern.\n const pattern = localeData.patterns.locale\n return pattern\n .replace('{0}', name)\n .replace('{1}', regionDisplayName || regionSubTag)\n }\n } else {\n return name\n }\n }\n } else {\n return name\n }\n}\n","import {DisplayNames} from '#packages/intl-displaynames/index.js'\n\nObject.defineProperty(Intl, 'DisplayNames', {\n value: DisplayNames,\n enumerable: false,\n writable: true,\n configurable: true,\n})\n\n// Drain any locale data that was buffered before polyfill loaded\nconst buf = (globalThis as Record<string, unknown>)\n .__FORMATJS_DISPLAYNAMES_DATA__ as\n | Parameters<(typeof DisplayNames)['__addLocaleData']>[0][]\n | undefined\nif (buf) {\n for (const d of buf) DisplayNames.__addLocaleData(d)\n delete (globalThis as Record<string, unknown>).__FORMATJS_DISPLAYNAMES_DATA__\n}\n"],"x_google_ignoreList":[7],"mappings":";;;;;AAGA,SAAgB,SAAS,GAAG;AAC3B,KAAI,OAAO,MAAM,SAChB,OAAM,UAAU,4CAA4C;AAE7D,QAAO,OAAO,EAAE;;;;;;;;ACHjB,SAAgB,uBAAuB,SAAS;AAE/C,QAAO,KAAK,oBAAoB,QAAQ;;;;;;;;;;;;ACGzC,SAAgB,UAAU,MAAM,MAAM,MAAM,QAAQ,UAAU;AAC7D,KAAI,OAAO,SAAS,SACnB,OAAM,IAAI,UAAU,4BAA4B;CAEjD,IAAI,QAAQ,KAAK;AACjB,KAAI,UAAU,KAAA,GAAW;A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