use-intl 2.9.2 → 2.10.0-alpha.4

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 (128) hide show
  1. package/CHANGELOG.md +471 -0
  2. package/dist/core/use-intl.esm.js +38 -41
  3. package/dist/core/use-intl.esm.js.map +1 -1
  4. package/dist/core/use-intl.esm2.js +41 -38
  5. package/dist/core/use-intl.esm2.js.map +1 -1
  6. package/dist/core/use-intl.esm3.js +2 -2
  7. package/dist/core/use-intl.esm4.js +12 -56
  8. package/dist/core/use-intl.esm4.js.map +1 -1
  9. package/dist/core/use-intl.esm5.js +56 -12
  10. package/dist/core/use-intl.esm5.js.map +1 -1
  11. package/dist/core/use-intl.esm6.js +1 -1
  12. package/dist/core/use-intl.esm7.js +2 -2
  13. package/dist/react/use-intl.esm.js +2 -2
  14. package/dist/react/use-intl.esm2.js +41 -17
  15. package/dist/react/use-intl.esm2.js.map +1 -1
  16. package/dist/react/use-intl.esm3.js +21 -20
  17. package/dist/react/use-intl.esm3.js.map +1 -1
  18. package/dist/react/use-intl.esm4.js +21 -4
  19. package/dist/react/use-intl.esm4.js.map +1 -1
  20. package/dist/react/use-intl.esm5.js +4 -46
  21. package/dist/react/use-intl.esm5.js.map +1 -1
  22. package/dist/react/use-intl.esm6.js +4 -4
  23. package/dist/react/use-intl.esm6.js.map +1 -1
  24. package/dist/react/use-intl.esm7.js +12 -3
  25. package/dist/react/use-intl.esm7.js.map +1 -1
  26. package/dist/react/use-intl.esm8.js +38 -9
  27. package/dist/react/use-intl.esm8.js.map +1 -1
  28. package/dist/react/use-intl.esm9.js +3 -41
  29. package/dist/react/use-intl.esm9.js.map +1 -1
  30. package/dist/src/core/AbstractIntlMessages.d.ts +9 -0
  31. package/dist/src/core/AbstractIntlMessages.js +2 -0
  32. package/dist/src/core/AbstractIntlMessages.js.map +1 -0
  33. package/dist/src/core/DateTimeFormatOptions.d.ts +72 -0
  34. package/dist/src/core/DateTimeFormatOptions.js +3 -0
  35. package/dist/src/core/DateTimeFormatOptions.js.map +1 -0
  36. package/dist/src/core/Formats.d.ts +7 -0
  37. package/dist/src/core/Formats.js +2 -0
  38. package/dist/src/core/Formats.js.map +1 -0
  39. package/dist/src/core/IntlConfiguration.d.ts +46 -0
  40. package/dist/src/core/IntlConfiguration.js +2 -0
  41. package/dist/src/core/IntlConfiguration.js.map +1 -0
  42. package/dist/src/core/IntlError.d.ts +13 -0
  43. package/dist/src/core/IntlError.js +23 -0
  44. package/dist/src/core/IntlError.js.map +1 -0
  45. package/dist/src/core/IntlMessages.d.ts +2 -0
  46. package/dist/src/core/IntlMessages.js +4 -0
  47. package/dist/src/core/IntlMessages.js.map +1 -0
  48. package/dist/src/core/NumberFormatOptions.d.ts +2 -0
  49. package/dist/src/core/NumberFormatOptions.js +2 -0
  50. package/dist/src/core/NumberFormatOptions.js.map +1 -0
  51. package/dist/src/core/TranslationValues.d.ts +5 -0
  52. package/dist/src/core/TranslationValues.js +2 -0
  53. package/dist/src/core/TranslationValues.js.map +1 -0
  54. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +10 -0
  55. package/dist/src/core/convertFormatsToIntlMessageFormat.js +31 -0
  56. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -0
  57. package/dist/src/core/createBaseTranslator.d.ts +26 -0
  58. package/dist/src/core/createBaseTranslator.js +181 -0
  59. package/dist/src/core/createBaseTranslator.js.map +1 -0
  60. package/dist/src/core/createIntl.d.ts +17 -0
  61. package/dist/src/core/createIntl.js +126 -0
  62. package/dist/src/core/createIntl.js.map +1 -0
  63. package/dist/src/core/createTranslator.d.ts +48 -0
  64. package/dist/src/core/createTranslator.js +24 -0
  65. package/dist/src/core/createTranslator.js.map +1 -0
  66. package/dist/src/core/createTranslatorImpl.d.ts +14 -0
  67. package/dist/src/core/createTranslatorImpl.js +43 -0
  68. package/dist/src/core/createTranslatorImpl.js.map +1 -0
  69. package/dist/src/core/defaults.d.ts +11 -0
  70. package/dist/src/core/defaults.js +11 -0
  71. package/dist/src/core/defaults.js.map +1 -0
  72. package/dist/src/core/index.d.ts +8 -0
  73. package/dist/src/core/index.js +4 -0
  74. package/dist/src/core/index.js.map +1 -0
  75. package/dist/src/core/resolveNamespace.d.ts +5 -0
  76. package/dist/src/core/resolveNamespace.js +10 -0
  77. package/dist/src/core/resolveNamespace.js.map +1 -0
  78. package/dist/src/core/utils/MessageKeys.d.ts +5 -0
  79. package/dist/src/core/utils/MessageKeys.js +2 -0
  80. package/dist/src/core/utils/MessageKeys.js.map +1 -0
  81. package/dist/src/core/utils/NamespaceKeys.d.ts +5 -0
  82. package/dist/src/core/utils/NamespaceKeys.js +2 -0
  83. package/dist/src/core/utils/NamespaceKeys.js.map +1 -0
  84. package/dist/src/core/utils/NestedKeyOf.d.ts +4 -0
  85. package/dist/src/core/utils/NestedKeyOf.js +2 -0
  86. package/dist/src/core/utils/NestedKeyOf.js.map +1 -0
  87. package/dist/src/core/utils/NestedValueOf.d.ts +2 -0
  88. package/dist/src/core/utils/NestedValueOf.js +2 -0
  89. package/dist/src/core/utils/NestedValueOf.js.map +1 -0
  90. package/dist/src/core/validateMessages.d.ts +3 -0
  91. package/dist/src/core/validateMessages.js +22 -0
  92. package/dist/src/core/validateMessages.js.map +1 -0
  93. package/dist/src/index.d.ts +2 -0
  94. package/dist/src/index.js +3 -0
  95. package/dist/src/index.js.map +1 -0
  96. package/dist/src/react/IntlContext.d.ts +21 -0
  97. package/dist/src/react/IntlContext.js +4 -0
  98. package/dist/src/react/IntlContext.js.map +1 -0
  99. package/dist/src/react/IntlProvider.d.ts +16 -0
  100. package/dist/src/react/IntlProvider.js +16 -0
  101. package/dist/src/react/IntlProvider.js.map +1 -0
  102. package/dist/src/react/index.d.ts +6 -0
  103. package/dist/src/react/index.js +7 -0
  104. package/dist/src/react/index.js.map +1 -0
  105. package/dist/src/react/useIntl.d.ts +5 -0
  106. package/dist/src/react/useIntl.js +14 -0
  107. package/dist/src/react/useIntl.js.map +1 -0
  108. package/dist/src/react/useIntlContext.d.ts +1 -0
  109. package/dist/src/react/useIntlContext.js +12 -0
  110. package/dist/src/react/useIntlContext.js.map +1 -0
  111. package/dist/src/react/useLocale.d.ts +1 -0
  112. package/dist/src/react/useLocale.js +5 -0
  113. package/dist/src/react/useLocale.js.map +1 -0
  114. package/dist/src/react/useNow.d.ts +23 -0
  115. package/dist/src/react/useNow.js +40 -0
  116. package/dist/src/react/useNow.js.map +1 -0
  117. package/dist/src/react/useTimeZone.d.ts +1 -0
  118. package/dist/src/react/useTimeZone.js +5 -0
  119. package/dist/src/react/useTimeZone.js.map +1 -0
  120. package/dist/src/react/useTranslations.d.ts +44 -0
  121. package/dist/src/react/useTranslations.js +21 -0
  122. package/dist/src/react/useTranslations.js.map +1 -0
  123. package/dist/src/react/useTranslationsImpl.d.ts +8 -0
  124. package/dist/src/react/useTranslationsImpl.js +35 -0
  125. package/dist/src/react/useTranslationsImpl.js.map +1 -0
  126. package/dist/use-intl.esm.js +7 -7
  127. package/package.json +7 -6
  128. package/LICENSE +0 -21
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm2.js","sources":["../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfiguration from './IntlConfiguration';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n ...rest\n}: IntlConfiguration & {\n messages: IntlMessages;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"names":["createTranslator","onError","defaultOnError","getMessageFallback","defaultGetMessageFallback","messages","namespace","rest","createTranslatorImpl"],"mappings":";;;;;AAYA;;;;;;;AAOG;;AACqB,SAAAA,gBAAA,CAcvB,IAAA,EAAA;AAAA,EAAA,IAAA,YAAA,GAAA,IAAA,CARCC,OAQD;AAAA,MARCA,OAQD,6BARWC,cAQX,GAAA,YAAA;AAAA,MAAA,qBAAA,GAAA,IAAA,CAPCC,kBAOD;AAAA,MAPCA,kBAOD,sCAPsBC,yBAOtB,GAAA,qBAAA;AAAA,MANCC,QAMD,QANCA,QAMD;AAAA,MALCC,SAKD,QALCA,SAKD;AAAA,MAJIC,IAIJ,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AA4DC;AACA;AACA;AACA,EAAOC,OAAAA,oBAAoB,cAKpBD,IALoB,EAAA;AAMvBN,IAAAA,OAAO,EAAPA,OANuB;AAOvBE,IAAAA,kBAAkB,EAAlBA,kBAPuB;AAQvBE,IAAAA,QAAQ,EAAE;AAAC,MAAKA,GAAAA,EAAAA,QAAAA;AAAN,KARa;AASvB;AACAC,IAAAA,SAAS,EAAEA,SAAS,GAAA,IAAA,GAAQA,SAAR,GAAsB,GAAA;AAVnB,GAAA,CAAA,EAYzB,GAZyB,CAA3B,CAAA;AAcD;;;;"}
1
+ {"version":3,"file":"use-intl.esm2.js","sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"names":["IntlErrorCode","IntlError","code","originalMessage","message","Error"],"mappings":";;IAAYA,cAAZ;;AAAA,CAAA,UAAYA,aAAZ,EAAyB;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,mBAAA,CAAA,GAAA,mBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;AACAA,EAAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,kBAAA,CAAA;AACD,CAPD,EAAYA,aAAa,KAAbA,aAAa,GAOxB,EAPwB,CAAzB,CAAA,CAAA;;IASqBC;;;AAInB,EAAYC,SAAAA,SAAAA,CAAAA,IAAZ,EAAiCC,eAAjC,EAAyD;AAAA,IAAA,IAAA,KAAA,CAAA;;AACvD,IAAIC,IAAAA,OAAO,GAAWF,IAAtB,CAAA;;AACA,IAAA,IAAIC,eAAJ,EAAqB;AACnBC,MAAAA,OAAO,IAAI,IAAA,GAAOD,eAAlB,CAAA;AACD,KAAA;;AACD,IAAA,KAAA,GAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAMC,OAAN,CAAA,IAAA,IAAA,CAAA;AALuD,IAAA,KAAA,CAHzCF,IAGyC,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,KAAA,CAFzCC,eAEyC,GAAA,KAAA,CAAA,CAAA;AAOvD,IAAKD,KAAAA,CAAAA,IAAL,GAAYA,IAAZ,CAAA;;AACA,IAAA,IAAIC,eAAJ,EAAqB;AACnB,MAAKA,KAAAA,CAAAA,eAAL,GAAuBA,eAAvB,CAAA;AACD,KAAA;;AAVsD,IAAA,OAAA,KAAA,CAAA;AAWxD,GAAA;;;iCAfoCE;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { extends as _extends } from '../_virtual/use-intl.esm.js';
2
- import IntlError, { IntlErrorCode } from './use-intl.esm.js';
3
- import { defaultOnError } from './use-intl.esm5.js';
2
+ import IntlError, { IntlErrorCode } from './use-intl.esm2.js';
3
+ import { defaultOnError } from './use-intl.esm4.js';
4
4
 
5
5
  var MINUTE = 60;
6
6
  var HOUR = MINUTE * 60;
@@ -1,59 +1,15 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
- import IntlError, { IntlErrorCode } from './use-intl.esm.js';
3
- import createBaseTranslator, { getMessagesOrError } from './use-intl.esm7.js';
4
- import resolveNamespace from './use-intl.esm8.js';
5
-
6
- var _excluded = ["getMessageFallback", "messages", "namespace", "onError"];
7
- function createTranslatorImpl(_ref, namespacePrefix) {
8
- var getMessageFallback = _ref.getMessageFallback,
9
- messages = _ref.messages,
10
- namespace = _ref.namespace,
11
- onError = _ref.onError,
12
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
13
-
14
- // The `namespacePrefix` is part of the type system.
15
- // See the comment in the function invocation.
16
- messages = messages[namespacePrefix];
17
- namespace = resolveNamespace(namespace, namespacePrefix);
18
- var translator = createBaseTranslator(_extends({}, rest, {
19
- onError: onError,
20
- getMessageFallback: getMessageFallback,
21
- messagesOrError: getMessagesOrError({
22
- messages: messages,
23
- namespace: namespace,
24
- onError: onError
25
- })
26
- }));
27
- var originalRich = translator.rich;
28
-
29
- function base() {
30
- return translator.apply(void 0, arguments);
31
- } // Augment `t.rich` to return plain strings
32
-
33
-
34
- base.rich = function (key,
35
- /** Key value pairs for values to interpolate into the message. */
36
- values, formats) {
37
- // `chunks` is returned as a string when no React element
38
- // is used, therefore it's safe to cast this type.
39
- var result = originalRich(key, values, formats); // When only string chunks are provided to the parser, only strings should be returned here.
40
-
41
- if (typeof result !== 'string') {
42
- var error = new IntlError(IntlErrorCode.FORMATTING_ERROR, process.env.NODE_ENV !== "production" ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})" : undefined);
43
- onError(error);
44
- return getMessageFallback({
45
- error: error,
46
- key: key,
47
- namespace: namespace
48
- });
49
- }
50
-
51
- return result;
52
- };
53
-
54
- base.raw = translator.raw;
55
- return base;
1
+ /**
2
+ * Contains defaults that are used for all entry points into the core.
3
+ * See also `InitializedIntlConfiguration`.
4
+ */
5
+ function defaultGetMessageFallback(props) {
6
+ return [props.namespace, props.key].filter(function (part) {
7
+ return part != null;
8
+ }).join('.');
9
+ }
10
+ function defaultOnError(error) {
11
+ console.error(error);
56
12
  }
57
13
 
58
- export { createTranslatorImpl as default };
14
+ export { defaultGetMessageFallback, defaultOnError };
59
15
  //# sourceMappingURL=use-intl.esm4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm4.js","sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfiguration} from './IntlConfiguration';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> =\n InitializedIntlConfiguration & {\n namespace: string;\n messages: Messages;\n };\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n __DEV__\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"names":["createTranslatorImpl","namespacePrefix","getMessageFallback","messages","namespace","onError","rest","resolveNamespace","translator","createBaseTranslator","messagesOrError","getMessagesOrError","originalRich","rich","base","key","values","formats","result","error","IntlError","IntlErrorCode","FORMATTING_ERROR","undefined","raw"],"mappings":";;;;;;AAmBc,SAAUA,oBAAV,CAWZC,IAAAA,EAAAA,eAXY,EAWW;AAAA,EANrBC,IAAAA,kBAMqB,QANrBA,kBAMqB;AAAA,MALrBC,QAKqB,QALrBA,QAKqB;AAAA,MAJrBC,SAIqB,QAJrBA,SAIqB;AAAA,MAHrBC,OAGqB,QAHrBA,OAGqB;AAAA,MAFlBC,IAEkB,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEvB;AACA;AACAH,EAAAA,QAAQ,GAAGA,QAAQ,CAACF,eAAD,CAAnB,CAAA;AACAG,EAAAA,SAAS,GAAGG,gBAAgB,CAACH,SAAD,EAAYH,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMO,UAAU,GAAGC,oBAAoB,CAAA,QAAA,CAAA,EAAA,EAClCH,IADkC,EAAA;AAErCD,IAAAA,OAAO,EAAPA,OAFqC;AAGrCH,IAAAA,kBAAkB,EAAlBA,kBAHqC;AAIrCQ,IAAAA,eAAe,EAAEC,kBAAkB,CAAC;AAClCR,MAAAA,QAAQ,EAARA,QADkC;AAElCC,MAAAA,SAAS,EAATA,SAFkC;AAGlCC,MAAAA,OAAO,EAAPA,OAAAA;AAHkC,KAAD,CAAA;AAJE,GAAvC,CAAA,CAAA,CAAA;AAWA,EAAA,IAAMO,YAAY,GAAGJ,UAAU,CAACK,IAAhC,CAAA;;AAEA,EAAA,SAASC,IAAT,GAAoD;AAClD,IAAON,OAAAA,UAAU,MAAV,CAAP,KAAA,CAAA,EAAA,SAAA,CAAA,CAAA;AACD,GAtBsB;;;AAyBvBM,EAAAA,IAAI,CAACD,IAAL,GAAY,UACVE,GADU;AAEV;AACAC,EAAAA,MAHU,EAIVC,OAJU,EAKA;AACV;AACA;AACA,IAAMC,IAAAA,MAAM,GAAGN,YAAY,CAACG,GAAD,EAAMC,MAAN,EAAuCC,OAAvC,CAA3B,CAHU;;AAMV,IAAA,IAAI,OAAOC,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,MAAA,IAAMC,KAAK,GAAG,IAAIC,SAAJ,CACZC,aAAa,CAACC,gBADF,EAEZ,OAAA,CAAA,GAAA,CAAA,QAAA,KAAA,YAAA,GACI,iKADJ,GAEIC,SAJQ,CAAd,CAAA;AAOAlB,MAAAA,OAAO,CAACc,KAAD,CAAP,CAAA;AACA,MAAA,OAAOjB,kBAAkB,CAAC;AAACiB,QAAAA,KAAK,EAALA,KAAD;AAAQJ,QAAAA,GAAG,EAAHA,GAAR;AAAaX,QAAAA,SAAS,EAATA,SAAAA;AAAb,OAAD,CAAzB,CAAA;AACD,KAAA;;AAED,IAAA,OAAOc,MAAP,CAAA;AACD,GAxBD,CAAA;;AA0BAJ,EAAAA,IAAI,CAACU,GAAL,GAAWhB,UAAU,CAACgB,GAAtB,CAAA;AAEA,EAAA,OAAOV,IAAP,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"use-intl.esm4.js","sources":["../../src/core/defaults.tsx"],"sourcesContent":["import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n"],"names":["defaultGetMessageFallback","props","namespace","key","filter","part","join","defaultOnError","error","console"],"mappings":"AAEA;;;AAGG;AAEG,SAAUA,yBAAV,CAAoCC,KAApC,EAIL;AACC,EAAA,OAAO,CAACA,KAAK,CAACC,SAAP,EAAkBD,KAAK,CAACE,GAAxB,CAA6BC,CAAAA,MAA7B,CAAoC,UAACC,IAAD,EAAA;AAAA,IAAUA,OAAAA,IAAI,IAAI,IAAlB,CAAA;AAAA,GAApC,CAA4DC,CAAAA,IAA5D,CAAiE,GAAjE,CAAP,CAAA;AACD,CAAA;AAEK,SAAUC,cAAV,CAAyBC,KAAzB,EAAyC;AAC7CC,EAAAA,OAAO,CAACD,KAAR,CAAcA,KAAd,CAAA,CAAA;AACD;;;;"}
@@ -1,15 +1,59 @@
1
- /**
2
- * Contains defaults that are used for all entry points into the core.
3
- * See also `InitializedIntlConfiguration`.
4
- */
5
- function defaultGetMessageFallback(props) {
6
- return [props.namespace, props.key].filter(function (part) {
7
- return part != null;
8
- }).join('.');
9
- }
10
- function defaultOnError(error) {
11
- console.error(error);
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
+ import IntlError, { IntlErrorCode } from './use-intl.esm2.js';
3
+ import createBaseTranslator, { getMessagesOrError } from './use-intl.esm7.js';
4
+ import resolveNamespace from './use-intl.esm8.js';
5
+
6
+ var _excluded = ["getMessageFallback", "messages", "namespace", "onError"];
7
+ function createTranslatorImpl(_ref, namespacePrefix) {
8
+ var getMessageFallback = _ref.getMessageFallback,
9
+ messages = _ref.messages,
10
+ namespace = _ref.namespace,
11
+ onError = _ref.onError,
12
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
13
+
14
+ // The `namespacePrefix` is part of the type system.
15
+ // See the comment in the function invocation.
16
+ messages = messages[namespacePrefix];
17
+ namespace = resolveNamespace(namespace, namespacePrefix);
18
+ var translator = createBaseTranslator(_extends({}, rest, {
19
+ onError: onError,
20
+ getMessageFallback: getMessageFallback,
21
+ messagesOrError: getMessagesOrError({
22
+ messages: messages,
23
+ namespace: namespace,
24
+ onError: onError
25
+ })
26
+ }));
27
+ var originalRich = translator.rich;
28
+
29
+ function base() {
30
+ return translator.apply(void 0, arguments);
31
+ } // Augment `t.rich` to return plain strings
32
+
33
+
34
+ base.rich = function (key,
35
+ /** Key value pairs for values to interpolate into the message. */
36
+ values, formats) {
37
+ // `chunks` is returned as a string when no React element
38
+ // is used, therefore it's safe to cast this type.
39
+ var result = originalRich(key, values, formats); // When only string chunks are provided to the parser, only strings should be returned here.
40
+
41
+ if (typeof result !== 'string') {
42
+ var error = new IntlError(IntlErrorCode.FORMATTING_ERROR, process.env.NODE_ENV !== "production" ? "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})" : undefined);
43
+ onError(error);
44
+ return getMessageFallback({
45
+ error: error,
46
+ key: key,
47
+ namespace: namespace
48
+ });
49
+ }
50
+
51
+ return result;
52
+ };
53
+
54
+ base.raw = translator.raw;
55
+ return base;
12
56
  }
13
57
 
14
- export { defaultGetMessageFallback, defaultOnError };
58
+ export { createTranslatorImpl as default };
15
59
  //# sourceMappingURL=use-intl.esm5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm5.js","sources":["../../src/core/defaults.tsx"],"sourcesContent":["import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n"],"names":["defaultGetMessageFallback","props","namespace","key","filter","part","join","defaultOnError","error","console"],"mappings":"AAEA;;;AAGG;AAEG,SAAUA,yBAAV,CAAoCC,KAApC,EAIL;AACC,EAAA,OAAO,CAACA,KAAK,CAACC,SAAP,EAAkBD,KAAK,CAACE,GAAxB,CAA6BC,CAAAA,MAA7B,CAAoC,UAACC,IAAD,EAAA;AAAA,IAAUA,OAAAA,IAAI,IAAI,IAAlB,CAAA;AAAA,GAApC,CAA4DC,CAAAA,IAA5D,CAAiE,GAAjE,CAAP,CAAA;AACD,CAAA;AAEK,SAAUC,cAAV,CAAyBC,KAAzB,EAAyC;AAC7CC,EAAAA,OAAO,CAACD,KAAR,CAAcA,KAAd,CAAA,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"use-intl.esm5.js","sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfiguration} from './IntlConfiguration';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> =\n InitializedIntlConfiguration & {\n namespace: string;\n messages: Messages;\n };\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n __DEV__\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"names":["createTranslatorImpl","namespacePrefix","getMessageFallback","messages","namespace","onError","rest","resolveNamespace","translator","createBaseTranslator","messagesOrError","getMessagesOrError","originalRich","rich","base","key","values","formats","result","error","IntlError","IntlErrorCode","FORMATTING_ERROR","undefined","raw"],"mappings":";;;;;;AAmBc,SAAUA,oBAAV,CAWZC,IAAAA,EAAAA,eAXY,EAWW;AAAA,EANrBC,IAAAA,kBAMqB,QANrBA,kBAMqB;AAAA,MALrBC,QAKqB,QALrBA,QAKqB;AAAA,MAJrBC,SAIqB,QAJrBA,SAIqB;AAAA,MAHrBC,OAGqB,QAHrBA,OAGqB;AAAA,MAFlBC,IAEkB,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEvB;AACA;AACAH,EAAAA,QAAQ,GAAGA,QAAQ,CAACF,eAAD,CAAnB,CAAA;AACAG,EAAAA,SAAS,GAAGG,gBAAgB,CAACH,SAAD,EAAYH,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMO,UAAU,GAAGC,oBAAoB,CAAA,QAAA,CAAA,EAAA,EAClCH,IADkC,EAAA;AAErCD,IAAAA,OAAO,EAAPA,OAFqC;AAGrCH,IAAAA,kBAAkB,EAAlBA,kBAHqC;AAIrCQ,IAAAA,eAAe,EAAEC,kBAAkB,CAAC;AAClCR,MAAAA,QAAQ,EAARA,QADkC;AAElCC,MAAAA,SAAS,EAATA,SAFkC;AAGlCC,MAAAA,OAAO,EAAPA,OAAAA;AAHkC,KAAD,CAAA;AAJE,GAAvC,CAAA,CAAA,CAAA;AAWA,EAAA,IAAMO,YAAY,GAAGJ,UAAU,CAACK,IAAhC,CAAA;;AAEA,EAAA,SAASC,IAAT,GAAoD;AAClD,IAAON,OAAAA,UAAU,MAAV,CAAP,KAAA,CAAA,EAAA,SAAA,CAAA,CAAA;AACD,GAtBsB;;;AAyBvBM,EAAAA,IAAI,CAACD,IAAL,GAAY,UACVE,GADU;AAEV;AACAC,EAAAA,MAHU,EAIVC,OAJU,EAKA;AACV;AACA;AACA,IAAMC,IAAAA,MAAM,GAAGN,YAAY,CAACG,GAAD,EAAMC,MAAN,EAAuCC,OAAvC,CAA3B,CAHU;;AAMV,IAAA,IAAI,OAAOC,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,MAAA,IAAMC,KAAK,GAAG,IAAIC,SAAJ,CACZC,aAAa,CAACC,gBADF,EAEZ,OAAA,CAAA,GAAA,CAAA,QAAA,KAAA,YAAA,GACI,iKADJ,GAEIC,SAJQ,CAAd,CAAA;AAOAlB,MAAAA,OAAO,CAACc,KAAD,CAAP,CAAA;AACA,MAAA,OAAOjB,kBAAkB,CAAC;AAACiB,QAAAA,KAAK,EAALA,KAAD;AAAQJ,QAAAA,GAAG,EAAHA,GAAR;AAAaX,QAAAA,SAAS,EAATA,SAAAA;AAAb,OAAD,CAAzB,CAAA;AACD,KAAA;;AAED,IAAA,OAAOc,MAAP,CAAA;AACD,GAxBD,CAAA;;AA0BAJ,EAAAA,IAAI,CAACU,GAAL,GAAWhB,UAAU,CAACgB,GAAtB,CAAA;AAEA,EAAA,OAAOV,IAAP,CAAA;AACD;;;;"}
@@ -1,4 +1,4 @@
1
- import IntlError, { IntlErrorCode } from './use-intl.esm.js';
1
+ import IntlError, { IntlErrorCode } from './use-intl.esm2.js';
2
2
 
3
3
  function validateMessagesSegment(messages, invalidKeyLabels, parentPath) {
4
4
  Object.entries(messages).forEach(function (_ref) {
@@ -1,9 +1,9 @@
1
1
  import { extends as _extends } from '../_virtual/use-intl.esm.js';
2
2
  import IntlMessageFormat from 'intl-messageformat';
3
3
  import { isValidElement, cloneElement } from 'react';
4
- import IntlError, { IntlErrorCode } from './use-intl.esm.js';
4
+ import IntlError, { IntlErrorCode } from './use-intl.esm2.js';
5
5
  import convertFormatsToIntlMessageFormat from './use-intl.esm9.js';
6
- import { defaultOnError, defaultGetMessageFallback } from './use-intl.esm5.js';
6
+ import { defaultOnError, defaultGetMessageFallback } from './use-intl.esm4.js';
7
7
 
8
8
  function resolvePath(messages, key, namespace) {
9
9
  if (!messages) {
@@ -1,8 +1,8 @@
1
1
  import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
2
  import React, { useEffect } from 'react';
3
- import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
3
+ import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm4.js';
4
4
  import validateMessages from '../core/use-intl.esm6.js';
5
- import IntlContext from './use-intl.esm7.js';
5
+ import IntlContext from './use-intl.esm9.js';
6
6
 
7
7
  var _excluded = ["children", "onError", "getMessageFallback", "messages"];
8
8
  function IntlProvider(_ref) {
@@ -1,26 +1,50 @@
1
- import useIntlContext from './use-intl.esm8.js';
2
- import useTranslationsImpl from './use-intl.esm9.js';
1
+ import { useState, useEffect } from 'react';
2
+ import useIntlContext from './use-intl.esm7.js';
3
3
 
4
+ function getNow() {
5
+ return new Date();
6
+ }
4
7
  /**
5
- * Translates messages from the given namespace by using the ICU syntax.
6
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
8
+ * Reading the current date via `new Date()` in components should be avoided, as
9
+ * it causes components to be impure and can lead to flaky tests. Instead, this
10
+ * hook can be used.
11
+ *
12
+ * By default, it returns the time when the component mounts. If `updateInterval`
13
+ * is specified, the value will be updated based on the interval.
14
+ *
15
+ * You can however also return a static value from this hook, if you
16
+ * configure the `now` parameter on the context provider. Note however,
17
+ * that if `updateInterval` is configured in this case, the component
18
+ * will initialize with the global value, but will afterwards update
19
+ * continuously based on the interval.
7
20
  *
8
- * If no namespace is provided, all available messages are returned.
9
- * The namespace can also indicate nesting by using a dot
10
- * (e.g. `namespace.Component`).
21
+ * For unit tests, this can be mocked to a constant value. For end-to-end
22
+ * testing, an environment parameter can be passed to the `now` parameter
23
+ * of the provider to mock this to a static value.
11
24
  */
12
25
 
13
- function useTranslations(namespace) {
14
- var context = useIntlContext();
15
- var messages = context.messages; // We have to wrap the actual hook so the type inference for the optional
16
- // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
17
- // The prefix ("!") is arbitrary.
18
26
 
19
- return useTranslationsImpl({
20
- '!': messages
21
- }, // @ts-ignore
22
- namespace ? "!." + namespace : '!', '!');
27
+ function useNow(options) {
28
+ var updateInterval = options == null ? void 0 : options.updateInterval;
29
+
30
+ var _useIntlContext = useIntlContext(),
31
+ globalNow = _useIntlContext.now;
32
+
33
+ var _useState = useState(globalNow || getNow()),
34
+ now = _useState[0],
35
+ setNow = _useState[1];
36
+
37
+ useEffect(function () {
38
+ if (!updateInterval) return;
39
+ var intervalId = setInterval(function () {
40
+ setNow(getNow());
41
+ }, updateInterval);
42
+ return function () {
43
+ clearInterval(intervalId);
44
+ };
45
+ }, [globalNow, updateInterval]);
46
+ return now;
23
47
  }
24
48
 
25
- export { useTranslations as default };
49
+ export { useNow as default };
26
50
  //# sourceMappingURL=use-intl.esm2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm2.js","sources":["../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"names":["useTranslations","namespace","context","useIntlContext","messages","useTranslationsImpl"],"mappings":";;;AAYA;;;;;;;AAOG;;AACqB,SAAAA,eAAA,CAMtBC,SANsB,EAMD;AA6DrB,EAAMC,IAAAA,OAAO,GAAGC,cAAc,EAA9B,CAAA;AACA,EAAA,IAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAzB,CA9DqB;AAiErB;AACA;;AACA,EAAA,OAAOC,mBAAmB,CAIxB;AAAC,IAAKD,GAAAA,EAAAA,QAAAA;AAAN,GAJwB;AAMxBH,EAAAA,SAAS,GAAQA,IAAAA,GAAAA,SAAR,GAAsB,GANP,EAOxB,GAPwB,CAA1B,CAAA;AASD;;;;"}
1
+ {"version":3,"file":"use-intl.esm2.js","sources":["../../src/react/useNow.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n"],"names":["getNow","Date","useNow","options","updateInterval","useIntlContext","globalNow","now","useState","setNow","useEffect","intervalId","setInterval","clearInterval"],"mappings":";;;AAOA,SAASA,MAAT,GAAe;AACb,EAAO,OAAA,IAAIC,IAAJ,EAAP,CAAA;AACD,CAAA;AAED;;;;;;;;;;;;;;;;;AAiBG;;;AACqB,SAAAC,MAAA,CAAOC,OAAP,EAAwB;AAC9C,EAAA,IAAMC,cAAc,GAAGD,OAAH,IAAGA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,cAAhC,CAAA;;AAEA,EAAA,IAAA,eAAA,GAAyBC,cAAc,EAAvC;AAAA,MAAYC,SAAZ,mBAAOC,GAAP,CAAA;;AACA,EAAA,IAAA,SAAA,GAAsBC,QAAQ,CAACF,SAAS,IAAIN,MAAM,EAApB,CAA9B;AAAA,MAAOO,GAAP,GAAA,SAAA,CAAA,CAAA,CAAA;AAAA,MAAYE,MAAZ,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;AAEAC,EAAAA,SAAS,CAAC,YAAK;AACb,IAAI,IAAA,CAACN,cAAL,EAAqB,OAAA;AAErB,IAAA,IAAMO,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACT,MAAM,EAAP,CAAN,CAAA;AACD,KAF6B,EAE3BI,cAF2B,CAA9B,CAAA;AAIA,IAAA,OAAO,YAAK;AACVS,MAAAA,aAAa,CAACF,UAAD,CAAb,CAAA;AACD,KAFD,CAAA;AAGD,GAVQ,EAUN,CAACL,SAAD,EAAYF,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOG,GAAP,CAAA;AACD;;;;"}
@@ -1,25 +1,26 @@
1
- import { useMemo } from 'react';
2
- import createIntl from '../core/use-intl.esm3.js';
3
- import useIntlContext from './use-intl.esm8.js';
1
+ import useIntlContext from './use-intl.esm7.js';
2
+ import useTranslationsImpl from './use-intl.esm8.js';
4
3
 
5
- function useIntl() {
6
- var _useIntlContext = useIntlContext(),
7
- formats = _useIntlContext.formats,
8
- locale = _useIntlContext.locale,
9
- globalNow = _useIntlContext.now,
10
- onError = _useIntlContext.onError,
11
- timeZone = _useIntlContext.timeZone;
4
+ /**
5
+ * Translates messages from the given namespace by using the ICU syntax.
6
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
7
+ *
8
+ * If no namespace is provided, all available messages are returned.
9
+ * The namespace can also indicate nesting by using a dot
10
+ * (e.g. `namespace.Component`).
11
+ */
12
12
 
13
- return useMemo(function () {
14
- return createIntl({
15
- formats: formats,
16
- locale: locale,
17
- now: globalNow,
18
- onError: onError,
19
- timeZone: timeZone
20
- });
21
- }, [formats, globalNow, locale, onError, timeZone]);
13
+ function useTranslations(namespace) {
14
+ var context = useIntlContext();
15
+ var messages = context.messages; // We have to wrap the actual hook so the type inference for the optional
16
+ // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
17
+ // The prefix ("!") is arbitrary.
18
+
19
+ return useTranslationsImpl({
20
+ '!': messages
21
+ }, // @ts-ignore
22
+ namespace ? "!." + namespace : '!', '!');
22
23
  }
23
24
 
24
- export { useIntl as default };
25
+ export { useTranslations as default };
25
26
  //# sourceMappingURL=use-intl.esm3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useIntl","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createIntl"],"mappings":";;;;AAIc,SAAUA,OAAV,GAAiB;AAC7B,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTP,MAAAA,OAAO,EAAPA,OADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTE,MAAAA,GAAG,EAAED,SAHI;AAITE,MAAAA,OAAO,EAAPA,OAJS;AAKTC,MAAAA,QAAQ,EAARA,QAAAA;AALS,KAAD,CADZ,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
1
+ {"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"names":["useTranslations","namespace","context","useIntlContext","messages","useTranslationsImpl"],"mappings":";;;AAYA;;;;;;;AAOG;;AACqB,SAAAA,eAAA,CAMtBC,SANsB,EAMD;AA6DrB,EAAMC,IAAAA,OAAO,GAAGC,cAAc,EAA9B,CAAA;AACA,EAAA,IAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAzB,CA9DqB;AAiErB;AACA;;AACA,EAAA,OAAOC,mBAAmB,CAIxB;AAAC,IAAKD,GAAAA,EAAAA,QAAAA;AAAN,GAJwB;AAMxBH,EAAAA,SAAS,GAAQA,IAAAA,GAAAA,SAAR,GAAsB,GANP,EAOxB,GAPwB,CAA1B,CAAA;AASD;;;;"}
@@ -1,8 +1,25 @@
1
- import useIntlContext from './use-intl.esm8.js';
1
+ import { useMemo } from 'react';
2
+ import createIntl from '../core/use-intl.esm3.js';
3
+ import useIntlContext from './use-intl.esm7.js';
2
4
 
3
- function useLocale() {
4
- return useIntlContext().locale;
5
+ function useIntl() {
6
+ var _useIntlContext = useIntlContext(),
7
+ formats = _useIntlContext.formats,
8
+ locale = _useIntlContext.locale,
9
+ globalNow = _useIntlContext.now,
10
+ onError = _useIntlContext.onError,
11
+ timeZone = _useIntlContext.timeZone;
12
+
13
+ return useMemo(function () {
14
+ return createIntl({
15
+ formats: formats,
16
+ locale: locale,
17
+ now: globalNow,
18
+ onError: onError,
19
+ timeZone: timeZone
20
+ });
21
+ }, [formats, globalNow, locale, onError, timeZone]);
5
22
  }
6
23
 
7
- export { useLocale as default };
24
+ export { useIntl as default };
8
25
  //# sourceMappingURL=use-intl.esm4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAAV,GAAmB;AAC/B,EAAOC,OAAAA,cAAc,GAAGC,MAAxB,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useIntl","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createIntl"],"mappings":";;;;AAIc,SAAUA,OAAV,GAAiB;AAC7B,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTP,MAAAA,OAAO,EAAPA,OADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTE,MAAAA,GAAG,EAAED,SAHI;AAITE,MAAAA,OAAO,EAAPA,OAJS;AAKTC,MAAAA,QAAQ,EAARA,QAAAA;AALS,KAAD,CADZ,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
@@ -1,50 +1,8 @@
1
- import { useState, useEffect } from 'react';
2
- import useIntlContext from './use-intl.esm8.js';
1
+ import useIntlContext from './use-intl.esm7.js';
3
2
 
4
- function getNow() {
5
- return new Date();
3
+ function useTimeZone() {
4
+ return useIntlContext().timeZone;
6
5
  }
7
- /**
8
- * Reading the current date via `new Date()` in components should be avoided, as
9
- * it causes components to be impure and can lead to flaky tests. Instead, this
10
- * hook can be used.
11
- *
12
- * By default, it returns the time when the component mounts. If `updateInterval`
13
- * is specified, the value will be updated based on the interval.
14
- *
15
- * You can however also return a static value from this hook, if you
16
- * configure the `now` parameter on the context provider. Note however,
17
- * that if `updateInterval` is configured in this case, the component
18
- * will initialize with the global value, but will afterwards update
19
- * continuously based on the interval.
20
- *
21
- * For unit tests, this can be mocked to a constant value. For end-to-end
22
- * testing, an environment parameter can be passed to the `now` parameter
23
- * of the provider to mock this to a static value.
24
- */
25
6
 
26
-
27
- function useNow(options) {
28
- var updateInterval = options == null ? void 0 : options.updateInterval;
29
-
30
- var _useIntlContext = useIntlContext(),
31
- globalNow = _useIntlContext.now;
32
-
33
- var _useState = useState(globalNow || getNow()),
34
- now = _useState[0],
35
- setNow = _useState[1];
36
-
37
- useEffect(function () {
38
- if (!updateInterval) return;
39
- var intervalId = setInterval(function () {
40
- setNow(getNow());
41
- }, updateInterval);
42
- return function () {
43
- clearInterval(intervalId);
44
- };
45
- }, [globalNow, updateInterval]);
46
- return now;
47
- }
48
-
49
- export { useNow as default };
7
+ export { useTimeZone as default };
50
8
  //# sourceMappingURL=use-intl.esm5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/useNow.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n"],"names":["getNow","Date","useNow","options","updateInterval","useIntlContext","globalNow","now","useState","setNow","useEffect","intervalId","setInterval","clearInterval"],"mappings":";;;AAOA,SAASA,MAAT,GAAe;AACb,EAAO,OAAA,IAAIC,IAAJ,EAAP,CAAA;AACD,CAAA;AAED;;;;;;;;;;;;;;;;;AAiBG;;;AACqB,SAAAC,MAAA,CAAOC,OAAP,EAAwB;AAC9C,EAAA,IAAMC,cAAc,GAAGD,OAAH,IAAGA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,cAAhC,CAAA;;AAEA,EAAA,IAAA,eAAA,GAAyBC,cAAc,EAAvC;AAAA,MAAYC,SAAZ,mBAAOC,GAAP,CAAA;;AACA,EAAA,IAAA,SAAA,GAAsBC,QAAQ,CAACF,SAAS,IAAIN,MAAM,EAApB,CAA9B;AAAA,MAAOO,GAAP,GAAA,SAAA,CAAA,CAAA,CAAA;AAAA,MAAYE,MAAZ,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;AAEAC,EAAAA,SAAS,CAAC,YAAK;AACb,IAAI,IAAA,CAACN,cAAL,EAAqB,OAAA;AAErB,IAAA,IAAMO,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACT,MAAM,EAAP,CAAN,CAAA;AACD,KAF6B,EAE3BI,cAF2B,CAA9B,CAAA;AAIA,IAAA,OAAO,YAAK;AACVS,MAAAA,aAAa,CAACF,UAAD,CAAb,CAAA;AACD,KAFD,CAAA;AAGD,GAVQ,EAUN,CAACL,SAAD,EAAYF,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOG,GAAP,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["useTimeZone","useIntlContext","timeZone"],"mappings":";;AAEc,SAAUA,WAAV,GAAqB;AACjC,EAAOC,OAAAA,cAAc,GAAGC,QAAxB,CAAA;AACD;;;;"}
@@ -1,8 +1,8 @@
1
- import useIntlContext from './use-intl.esm8.js';
1
+ import useIntlContext from './use-intl.esm7.js';
2
2
 
3
- function useTimeZone() {
4
- return useIntlContext().timeZone;
3
+ function useLocale() {
4
+ return useIntlContext().locale;
5
5
  }
6
6
 
7
- export { useTimeZone as default };
7
+ export { useLocale as default };
8
8
  //# sourceMappingURL=use-intl.esm6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["useTimeZone","useIntlContext","timeZone"],"mappings":";;AAEc,SAAUA,WAAV,GAAqB;AACjC,EAAOC,OAAAA,cAAc,GAAGC,QAAxB,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAAV,GAAmB;AAC/B,EAAOC,OAAAA,cAAc,GAAGC,MAAxB,CAAA;AACD;;;;"}
@@ -1,6 +1,15 @@
1
- import { createContext } from 'react';
1
+ import { useContext } from 'react';
2
+ import IntlContext from './use-intl.esm9.js';
2
3
 
3
- var IntlContext = /*#__PURE__*/createContext(undefined);
4
+ function useIntlContext() {
5
+ var context = useContext(IntlContext);
4
6
 
5
- export { IntlContext as default };
7
+ if (!context) {
8
+ throw new Error(process.env.NODE_ENV !== "production" ? 'No intl context found. Have you configured the provider?' : undefined);
9
+ }
10
+
11
+ return context;
12
+ }
13
+
14
+ export { useIntlContext as default };
6
15
  //# sourceMappingURL=use-intl.esm7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport Formats from '../core/Formats';\nimport IntlError from '../core/IntlError';\nimport {RichTranslationValues} from '../core/TranslationValues';\n\nexport type IntlContextShape = {\n messages?: AbstractIntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAqBA,IAAMA,WAAW,gBAAGC,aAAa,CAA+BC,SAA/B;;;;"}
1
+ {"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/useIntlContext.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n"],"names":["useIntlContext","context","useContext","IntlContext","Error","undefined"],"mappings":";;;AAGc,SAAUA,cAAV,GAAwB;AACpC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,WAAD,CAA1B,CAAA;;AAEA,EAAI,IAAA,CAACF,OAAL,EAAc;AACZ,IAAA,MAAM,IAAIG,KAAJ,CACJ,wCACI,0DADJ,GAEIC,SAHA,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OAAOJ,OAAP,CAAA;AACD;;;;"}