@formatjs/intl-locale 5.3.7 → 5.3.9

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.
@@ -41,7 +41,7 @@ function hasIncompleteLocaleInfo() {
41
41
  }
42
42
  }
43
43
  function shouldPolyfill() {
44
- return !("Locale" in Intl) || hasIntlGetCanonicalLocalesBug() || hasIncompleteLocaleInfo() || !hasVariantsProperty();
44
+ return typeof Intl === "undefined" || !("Locale" in Intl) || hasIntlGetCanonicalLocalesBug() || hasIncompleteLocaleInfo() || !hasVariantsProperty();
45
45
  }
46
46
  //#endregion
47
47
  export { shouldPolyfill };
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.js","names":[],"sources":["../should-polyfill.ts"],"sourcesContent":["/**\n * https://bugs.chromium.org/p/v8/issues/detail?id=10682\n */\nfunction hasIntlGetCanonicalLocalesBug(): boolean {\n try {\n return new (Intl as any).Locale('und-x-private').toString() === 'x-private'\n } catch {\n return true\n }\n}\n\n/**\n * Check if Intl.Locale is missing the variants property.\n * This property was added to ECMA-402 via PR #960.\n * https://github.com/tc39/ecma402/pull/960\n * https://github.com/tc39/ecma402/issues/900\n */\nfunction hasVariantsProperty(): boolean {\n try {\n const locale = new (Intl as any).Locale('en-US-posix')\n // Check if variants property exists\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(locale),\n 'variants'\n )\n return descriptor !== undefined && typeof descriptor.get === 'function'\n } catch {\n return false\n }\n}\n\n/**\n * Check if Intl.Locale is missing critical methods from the Intl Locale Info proposal.\n * Firefox has an incomplete implementation that lacks getWeekInfo() and other methods.\n * https://github.com/formatjs/formatjs/issues/5112\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1693576\n */\nfunction hasIncompleteLocaleInfo(): boolean {\n try {\n const locale = new (Intl as any).Locale('en-US')\n // Check for getWeekInfo - critical for week calculations (e.g., Luxon's localWeekNumber)\n // This is the most important check as it affects date/time libraries\n if (typeof locale.getWeekInfo !== 'function') {\n return true\n }\n // Also check for other Intl Locale Info methods\n // These are part of the same proposal and often missing together\n if (\n typeof locale.getCalendars !== 'function' ||\n typeof locale.getCollations !== 'function' ||\n typeof locale.getHourCycles !== 'function' ||\n typeof locale.getNumberingSystems !== 'function' ||\n typeof locale.getTimeZones !== 'function' ||\n typeof locale.getTextInfo !== 'function'\n ) {\n return true\n }\n return false\n } catch {\n return true\n }\n}\n\nexport function shouldPolyfill(): boolean {\n return (\n !('Locale' in Intl) ||\n hasIntlGetCanonicalLocalesBug() ||\n hasIncompleteLocaleInfo() ||\n !hasVariantsProperty()\n )\n}\n"],"mappings":";;;;AAGA,SAAS,gCAAyC;AAChD,KAAI;AACF,SAAO,IAAK,KAAa,OAAO,gBAAgB,CAAC,UAAU,KAAK;SAC1D;AACN,SAAO;;;;;;;;;AAUX,SAAS,sBAA+B;AACtC,KAAI;EACF,MAAM,SAAS,IAAK,KAAa,OAAO,cAAc;EAEtD,MAAM,aAAa,OAAO,yBACxB,OAAO,eAAe,OAAO,EAC7B,WACD;AACD,SAAO,eAAe,KAAA,KAAa,OAAO,WAAW,QAAQ;SACvD;AACN,SAAO;;;;;;;;;AAUX,SAAS,0BAAmC;AAC1C,KAAI;EACF,MAAM,SAAS,IAAK,KAAa,OAAO,QAAQ;AAGhD,MAAI,OAAO,OAAO,gBAAgB,WAChC,QAAO;AAIT,MACE,OAAO,OAAO,iBAAiB,cAC/B,OAAO,OAAO,kBAAkB,cAChC,OAAO,OAAO,kBAAkB,cAChC,OAAO,OAAO,wBAAwB,cACtC,OAAO,OAAO,iBAAiB,cAC/B,OAAO,OAAO,gBAAgB,WAE9B,QAAO;AAET,SAAO;SACD;AACN,SAAO;;;AAIX,SAAgB,iBAA0B;AACxC,QACE,EAAE,YAAY,SACd,+BAA+B,IAC/B,yBAAyB,IACzB,CAAC,qBAAqB"}
1
+ {"version":3,"file":"should-polyfill.js","names":[],"sources":["../should-polyfill.ts"],"sourcesContent":["/**\n * https://bugs.chromium.org/p/v8/issues/detail?id=10682\n */\nfunction hasIntlGetCanonicalLocalesBug(): boolean {\n try {\n return new (Intl as any).Locale('und-x-private').toString() === 'x-private'\n } catch {\n return true\n }\n}\n\n/**\n * Check if Intl.Locale is missing the variants property.\n * This property was added to ECMA-402 via PR #960.\n * https://github.com/tc39/ecma402/pull/960\n * https://github.com/tc39/ecma402/issues/900\n */\nfunction hasVariantsProperty(): boolean {\n try {\n const locale = new (Intl as any).Locale('en-US-posix')\n // Check if variants property exists\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(locale),\n 'variants'\n )\n return descriptor !== undefined && typeof descriptor.get === 'function'\n } catch {\n return false\n }\n}\n\n/**\n * Check if Intl.Locale is missing critical methods from the Intl Locale Info proposal.\n * Firefox has an incomplete implementation that lacks getWeekInfo() and other methods.\n * https://github.com/formatjs/formatjs/issues/5112\n * https://bugzilla.mozilla.org/show_bug.cgi?id=1693576\n */\nfunction hasIncompleteLocaleInfo(): boolean {\n try {\n const locale = new (Intl as any).Locale('en-US')\n // Check for getWeekInfo - critical for week calculations (e.g., Luxon's localWeekNumber)\n // This is the most important check as it affects date/time libraries\n if (typeof locale.getWeekInfo !== 'function') {\n return true\n }\n // Also check for other Intl Locale Info methods\n // These are part of the same proposal and often missing together\n if (\n typeof locale.getCalendars !== 'function' ||\n typeof locale.getCollations !== 'function' ||\n typeof locale.getHourCycles !== 'function' ||\n typeof locale.getNumberingSystems !== 'function' ||\n typeof locale.getTimeZones !== 'function' ||\n typeof locale.getTextInfo !== 'function'\n ) {\n return true\n }\n return false\n } catch {\n return true\n }\n}\n\nexport function shouldPolyfill(): boolean {\n return (\n typeof Intl === 'undefined' ||\n !('Locale' in Intl) ||\n hasIntlGetCanonicalLocalesBug() ||\n hasIncompleteLocaleInfo() ||\n !hasVariantsProperty()\n )\n}\n"],"mappings":";;;;AAGA,SAAS,gCAAyC;CAChD,IAAI;EACF,OAAO,IAAK,KAAa,OAAO,eAAe,EAAE,SAAS,MAAM;CAClE,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,sBAA+B;CACtC,IAAI;EACF,MAAM,SAAS,IAAK,KAAa,OAAO,aAAa;EAErD,MAAM,aAAa,OAAO,yBACxB,OAAO,eAAe,MAAM,GAC5B,UACF;EACA,OAAO,eAAe,KAAA,KAAa,OAAO,WAAW,QAAQ;CAC/D,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,0BAAmC;CAC1C,IAAI;EACF,MAAM,SAAS,IAAK,KAAa,OAAO,OAAO;EAG/C,IAAI,OAAO,OAAO,gBAAgB,YAChC,OAAO;EAIT,IACE,OAAO,OAAO,iBAAiB,cAC/B,OAAO,OAAO,kBAAkB,cAChC,OAAO,OAAO,kBAAkB,cAChC,OAAO,OAAO,wBAAwB,cACtC,OAAO,OAAO,iBAAiB,cAC/B,OAAO,OAAO,gBAAgB,YAE9B,OAAO;EAET,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,iBAA0B;CACxC,OACE,OAAO,SAAS,eAChB,EAAE,YAAY,SACd,8BAA8B,KAC9B,wBAAwB,KACxB,CAAC,oBAAoB;AAEzB"}