@common.js/intl-messageformat 11.2.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.
package/LICENSE.md ADDED
@@ -0,0 +1,33 @@
1
+ Copyright (c) 2023, Oath Inc.
2
+
3
+ Licensed under the terms of the New BSD license. See below for terms.
4
+
5
+ Redistribution and use of this software in source and binary forms,
6
+ with or without modification, are permitted provided that the following
7
+ conditions are met:
8
+
9
+ - Redistributions of source code must retain the above
10
+ copyright notice, this list of conditions and the
11
+ following disclaimer.
12
+
13
+ - Redistributions in binary form must reproduce the above
14
+ copyright notice, this list of conditions and the
15
+ following disclaimer in the documentation and/or other
16
+ materials provided with the distribution.
17
+
18
+ - Neither the name of Oath Inc. nor the names of its
19
+ contributors may be used to endorse or promote products
20
+ derived from this software without specific prior
21
+ written permission of Oath Inc.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @common.js/intl-messageformat
2
+
3
+ The [intl-messageformat](https://www.npmjs.com/package/intl-messageformat) package exported as CommonJS modules.
4
+
5
+ Exported from [intl-messageformat@11.2.9](https://www.npmjs.com/package/intl-messageformat/v/11.2.9) using https://github.com/etienne-martin/common.js.
package/index.d.ts ADDED
@@ -0,0 +1,144 @@
1
+ import { MessageFormatElement, ParserOptions, parse } from "@formatjs/icu-messageformat-parser";
2
+
3
+ //#region packages/ecma402-abstract/types/number.d.ts
4
+ type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
5
+ type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
6
+ type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
7
+ type UseGroupingType = "min2" | "auto" | "always" | boolean;
8
+ interface NumberFormatDigitOptions {
9
+ minimumIntegerDigits?: number;
10
+ minimumSignificantDigits?: number;
11
+ maximumSignificantDigits?: number;
12
+ minimumFractionDigits?: number;
13
+ maximumFractionDigits?: number;
14
+ roundingPriority?: RoundingPriorityType;
15
+ roundingIncrement?: number;
16
+ roundingMode?: RoundingModeType;
17
+ trailingZeroDisplay?: TrailingZeroDisplay;
18
+ }
19
+ type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit";
20
+ type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit";
21
+ type NumberFormatOptionsCompactDisplay = "short" | "long";
22
+ type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol";
23
+ type NumberFormatOptionsCurrencySign = "standard" | "accounting";
24
+ type NumberFormatOptionsNotation = NumberFormatNotation;
25
+ type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative";
26
+ type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow";
27
+ type TrailingZeroDisplay = "auto" | "stripIfInteger";
28
+ type NumberFormatOptions = Omit<Intl.NumberFormatOptions, "signDisplay" | "useGrouping"> & NumberFormatDigitOptions & {
29
+ localeMatcher?: NumberFormatOptionsLocaleMatcher;
30
+ style?: NumberFormatOptionsStyle;
31
+ compactDisplay?: NumberFormatOptionsCompactDisplay;
32
+ currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
33
+ currencySign?: NumberFormatOptionsCurrencySign;
34
+ notation?: NumberFormatOptionsNotation;
35
+ signDisplay?: NumberFormatOptionsSignDisplay;
36
+ unit?: string;
37
+ unitDisplay?: NumberFormatOptionsUnitDisplay;
38
+ numberingSystem?: string;
39
+ trailingZeroDisplay?: TrailingZeroDisplay;
40
+ roundingPriority?: RoundingPriorityType;
41
+ roundingIncrement?: number;
42
+ roundingMode?: RoundingModeType;
43
+ useGrouping?: UseGroupingType;
44
+ };
45
+ //#endregion
46
+ //#region packages/intl-messageformat/formatters.d.ts
47
+ declare global {
48
+ namespace FormatjsIntl {
49
+ interface Message {}
50
+ interface IntlConfig {}
51
+ interface Formats {}
52
+ }
53
+ }
54
+ type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
55
+ interface Formats {
56
+ number: Record<Format<"number">, NumberFormatOptions>;
57
+ date: Record<Format<"date">, Intl.DateTimeFormatOptions>;
58
+ time: Record<Format<"time">, Intl.DateTimeFormatOptions>;
59
+ }
60
+ interface FormatterCache {
61
+ number: Record<string, NumberFormatOptions>;
62
+ dateTime: Record<string, Intl.DateTimeFormat>;
63
+ pluralRules: Record<string, Intl.PluralRules>;
64
+ }
65
+ interface Formatters {
66
+ getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
67
+ getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
68
+ getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
69
+ }
70
+ declare enum PART_TYPE {
71
+ literal = 0,
72
+ object = 1
73
+ }
74
+ interface LiteralPart {
75
+ type: PART_TYPE.literal;
76
+ value: string;
77
+ }
78
+ interface ObjectPart<T = any> {
79
+ type: PART_TYPE.object;
80
+ value: T;
81
+ }
82
+ type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
83
+ type PrimitiveType = string | number | bigint | boolean | null | undefined | Date;
84
+ declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
85
+ declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
86
+ type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
87
+ //#endregion
88
+ //#region packages/intl-messageformat/core.d.ts
89
+ interface Options extends Omit<ParserOptions, "locale"> {
90
+ formatters?: Formatters;
91
+ }
92
+ declare class IntlMessageFormat {
93
+ private readonly ast;
94
+ private readonly locales;
95
+ private readonly resolvedLocale?;
96
+ private readonly formatters;
97
+ private readonly formats;
98
+ private readonly message;
99
+ private readonly formatterCache;
100
+ constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
101
+ format: <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => string | T | (string | T)[];
102
+ formatToParts: <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => MessageFormatPart<T>[];
103
+ resolvedOptions: () => {
104
+ locale: string;
105
+ };
106
+ getAst: () => MessageFormatElement[];
107
+ private static memoizedDefaultLocale;
108
+ static get defaultLocale(): string;
109
+ static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined;
110
+ static __parse: typeof parse | undefined;
111
+ static formats: Formats;
112
+ }
113
+ //#endregion
114
+ //#region packages/intl-messageformat/error.d.ts
115
+ declare enum ErrorCode {
116
+ MISSING_VALUE = "MISSING_VALUE",
117
+ INVALID_VALUE = "INVALID_VALUE",
118
+ MISSING_INTL_API = "MISSING_INTL_API"
119
+ }
120
+ declare class FormatError extends Error {
121
+ readonly code: ErrorCode;
122
+ /**
123
+ * Original message we're trying to format
124
+ * `undefined` if we're only dealing w/ AST
125
+ *
126
+ * @type {(string | undefined)}
127
+ * @memberof FormatError
128
+ */
129
+ readonly originalMessage: string | undefined;
130
+ constructor(msg: string, code: ErrorCode, originalMessage?: string);
131
+ toString(): string;
132
+ }
133
+ declare class InvalidValueError extends FormatError {
134
+ constructor(variableId: string, value: any, options: string[], originalMessage?: string);
135
+ }
136
+ declare class InvalidValueTypeError extends FormatError {
137
+ constructor(value: any, type: string, originalMessage?: string);
138
+ }
139
+ declare class MissingValueError extends FormatError {
140
+ constructor(variableId: string, originalMessage?: string);
141
+ }
142
+ //#endregion
143
+ export { ErrorCode, FormatError, FormatXMLElementFn, Formats, FormatterCache, Formatters, IntlMessageFormat, IntlMessageFormat as default, InvalidValueError, InvalidValueTypeError, LiteralPart, MessageFormatPart, MissingValueError, ObjectPart, Options, PART_TYPE, PrimitiveType, formatToParts, isFormatXMLElementFn };
144
+ //# sourceMappingURL=index.d.ts.map