@common.js/use-intl 4.13.1
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 +21 -0
- package/README.md +5 -0
- package/core.d.ts +2 -0
- package/dist/esm/development/core.js +174 -0
- package/dist/esm/development/format-message/format-only.js +314 -0
- package/dist/esm/development/format-message/index.js +238 -0
- package/dist/esm/development/formatters-r4aAmsMP.js +266 -0
- package/dist/esm/development/index.js +64 -0
- package/dist/esm/development/initializeConfig-CUsOI8u2.js +651 -0
- package/dist/esm/development/react.js +390 -0
- package/dist/esm/production/core.js +149 -0
- package/dist/esm/production/format-message/format-only.js +299 -0
- package/dist/esm/production/format-message/index.js +188 -0
- package/dist/esm/production/formatters-CJcico0N.js +244 -0
- package/dist/esm/production/index.js +64 -0
- package/dist/esm/production/initializeConfig-CHgjheii.js +399 -0
- package/dist/esm/production/react.js +270 -0
- package/dist/types/core/AbstractIntlMessages.d.ts +10 -0
- package/dist/types/core/AppConfig.d.ts +29 -0
- package/dist/types/core/DateTimeFormatOptions.d.ts +73 -0
- package/dist/types/core/Formats.d.ts +9 -0
- package/dist/types/core/ICUArgs.d.ts +3 -0
- package/dist/types/core/ICUTags.d.ts +2 -0
- package/dist/types/core/IntlConfig.d.ts +54 -0
- package/dist/types/core/IntlError.d.ts +6 -0
- package/dist/types/core/IntlErrorCode.d.ts +10 -0
- package/dist/types/core/MessageKeys.d.ts +10 -0
- package/dist/types/core/NumberFormatOptions.d.ts +3 -0
- package/dist/types/core/RelativeTimeFormatOptions.d.ts +7 -0
- package/dist/types/core/TimeZone.d.ts +2 -0
- package/dist/types/core/TranslationValues.d.ts +6 -0
- package/dist/types/core/convertFormatsToIntlMessageFormat.d.ts +11 -0
- package/dist/types/core/createBaseTranslator.d.ts +21 -0
- package/dist/types/core/createFormatter.d.ts +47 -0
- package/dist/types/core/createTranslator.d.ts +59 -0
- package/dist/types/core/createTranslatorImpl.d.ts +17 -0
- package/dist/types/core/defaults.d.ts +11 -0
- package/dist/types/core/format-message/compile-format.d.ts +12 -0
- package/dist/types/core/format-message/format-only.d.ts +13 -0
- package/dist/types/core/format-message/index.d.ts +5 -0
- package/dist/types/core/format-message/types.d.ts +15 -0
- package/dist/types/core/formatters.d.ts +25 -0
- package/dist/types/core/hasLocale.d.ts +7 -0
- package/dist/types/core/index.d.ts +22 -0
- package/dist/types/core/initializeConfig.d.ts +14 -0
- package/dist/types/core/joinPath.d.ts +1 -0
- package/dist/types/core/resolveNamespace.d.ts +5 -0
- package/dist/types/core/types.d.ts +6 -0
- package/dist/types/core/validateMessages.d.ts +3 -0
- package/dist/types/core.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/react/IntlContext.d.ts +8 -0
- package/dist/types/react/IntlProvider.d.ts +7 -0
- package/dist/types/react/index.d.ts +9 -0
- package/dist/types/react/useExtracted.d.ts +42 -0
- package/dist/types/react/useFormatter.d.ts +2 -0
- package/dist/types/react/useIntlContext.d.ts +2 -0
- package/dist/types/react/useLocale.d.ts +2 -0
- package/dist/types/react/useMessages.d.ts +2 -0
- package/dist/types/react/useNow.d.ts +8 -0
- package/dist/types/react/useTimeZone.d.ts +1 -0
- package/dist/types/react/useTranslations.d.ts +12 -0
- package/dist/types/react/useTranslationsImpl.d.ts +9 -0
- package/dist/types/react.d.ts +1 -0
- package/format-message/format-only.d.ts +2 -0
- package/format-message.d.ts +2 -0
- package/package.json +45 -0
- package/react.d.ts +2 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return formatMessage;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _intlMessageformat = require("intl-messageformat");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _formattersR4AAmsMPJs = require("../formatters-r4aAmsMP.js");
|
|
14
|
+
function _arrayLikeToArray(arr, len) {
|
|
15
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
16
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
17
|
+
return arr2;
|
|
18
|
+
}
|
|
19
|
+
function _arrayWithHoles(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return arr;
|
|
21
|
+
}
|
|
22
|
+
function _defineProperty(obj, key, value) {
|
|
23
|
+
if (key in obj) {
|
|
24
|
+
Object.defineProperty(obj, key, {
|
|
25
|
+
value: value,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
obj[key] = value;
|
|
32
|
+
}
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
function _iterableToArrayLimit(arr, i) {
|
|
36
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
37
|
+
if (_i == null) return;
|
|
38
|
+
var _arr = [];
|
|
39
|
+
var _n = true;
|
|
40
|
+
var _d = false;
|
|
41
|
+
var _s, _e;
|
|
42
|
+
try {
|
|
43
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
44
|
+
_arr.push(_s.value);
|
|
45
|
+
if (i && _arr.length === i) break;
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
_d = true;
|
|
49
|
+
_e = err;
|
|
50
|
+
} finally{
|
|
51
|
+
try {
|
|
52
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
53
|
+
} finally{
|
|
54
|
+
if (_d) throw _e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return _arr;
|
|
58
|
+
}
|
|
59
|
+
function _nonIterableRest() {
|
|
60
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
61
|
+
}
|
|
62
|
+
function _objectSpread(target) {
|
|
63
|
+
for(var i = 1; i < arguments.length; i++){
|
|
64
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
65
|
+
var ownKeys = Object.keys(source);
|
|
66
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
67
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
68
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
ownKeys.forEach(function(key) {
|
|
72
|
+
_defineProperty(target, key, source[key]);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return target;
|
|
76
|
+
}
|
|
77
|
+
function ownKeys(object, enumerableOnly) {
|
|
78
|
+
var keys = Object.keys(object);
|
|
79
|
+
if (Object.getOwnPropertySymbols) {
|
|
80
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
81
|
+
if (enumerableOnly) {
|
|
82
|
+
symbols = symbols.filter(function(sym) {
|
|
83
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
keys.push.apply(keys, symbols);
|
|
87
|
+
}
|
|
88
|
+
return keys;
|
|
89
|
+
}
|
|
90
|
+
function _objectSpreadProps(target, source) {
|
|
91
|
+
source = source != null ? source : {};
|
|
92
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
93
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
94
|
+
} else {
|
|
95
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
96
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return target;
|
|
100
|
+
}
|
|
101
|
+
function _slicedToArray(arr, i) {
|
|
102
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
103
|
+
}
|
|
104
|
+
var _typeof = function(obj) {
|
|
105
|
+
"@swc/helpers - typeof";
|
|
106
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
107
|
+
};
|
|
108
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
109
|
+
if (!o) return;
|
|
110
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
111
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
112
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
113
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
114
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `intl-messageformat` uses separate keys for `date` and `time`, but there's
|
|
118
|
+
* only one native API: `Intl.DateTimeFormat`. Additionally you might want to
|
|
119
|
+
* include both a time and a date in a value, therefore the separation doesn't
|
|
120
|
+
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
121
|
+
* to convert the format before `intl-messageformat` can be used.
|
|
122
|
+
*/ function convertFormatsToIntlMessageFormat(globalFormats, inlineFormats, timeZone) {
|
|
123
|
+
var mfDateDefaults = _intlMessageformat.IntlMessageFormat.formats.date;
|
|
124
|
+
var mfTimeDefaults = _intlMessageformat.IntlMessageFormat.formats.time;
|
|
125
|
+
var dateTimeFormats = _objectSpread({}, globalFormats === null || globalFormats === void 0 ? void 0 : globalFormats.dateTime, inlineFormats === null || inlineFormats === void 0 ? void 0 : inlineFormats.dateTime);
|
|
126
|
+
var allFormats = {
|
|
127
|
+
date: _objectSpread({}, mfDateDefaults, dateTimeFormats),
|
|
128
|
+
time: _objectSpread({}, mfTimeDefaults, dateTimeFormats),
|
|
129
|
+
number: _objectSpread({}, globalFormats === null || globalFormats === void 0 ? void 0 : globalFormats.number, inlineFormats === null || inlineFormats === void 0 ? void 0 : inlineFormats.number)
|
|
130
|
+
};
|
|
131
|
+
if (timeZone) {
|
|
132
|
+
// The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
133
|
+
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
134
|
+
[
|
|
135
|
+
"date",
|
|
136
|
+
"time"
|
|
137
|
+
].forEach(function(property) {
|
|
138
|
+
var formats = allFormats[property];
|
|
139
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
140
|
+
try {
|
|
141
|
+
for(var _iterator = Object.entries(formats)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
142
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
143
|
+
formats[key] = _objectSpread({
|
|
144
|
+
timeZone: timeZone
|
|
145
|
+
}, value);
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
_didIteratorError = true;
|
|
149
|
+
_iteratorError = err;
|
|
150
|
+
} finally{
|
|
151
|
+
try {
|
|
152
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
153
|
+
_iterator.return();
|
|
154
|
+
}
|
|
155
|
+
} finally{
|
|
156
|
+
if (_didIteratorError) {
|
|
157
|
+
throw _iteratorError;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return allFormats;
|
|
164
|
+
}
|
|
165
|
+
// Placed here for improved tree shaking. Somehow when this is placed in
|
|
166
|
+
// `formatters.tsx`, then it can't be shaken off from `next-intl`.
|
|
167
|
+
function createMessageFormatter(cache, intlFormatters) {
|
|
168
|
+
var getMessageFormat = (0, _formattersR4AAmsMPJs.m)(function() {
|
|
169
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
170
|
+
args[_key] = arguments[_key];
|
|
171
|
+
}
|
|
172
|
+
return new _intlMessageformat.IntlMessageFormat(args[0], args[1], args[2], _objectSpread({
|
|
173
|
+
formatters: intlFormatters
|
|
174
|
+
}, args[3]));
|
|
175
|
+
}, cache.message);
|
|
176
|
+
return getMessageFormat;
|
|
177
|
+
}
|
|
178
|
+
function getPlainMessage(candidate, values) {
|
|
179
|
+
// To improve runtime performance, only compile message if:
|
|
180
|
+
return(// 1. Values are provided
|
|
181
|
+
values || // 2. There are ICU escape sequences (e.g. "'{name'}")
|
|
182
|
+
/'[{}<#|']/.test(candidate) || // 3. There are missing arguments or tags (dev-only error handling)
|
|
183
|
+
/<|{/.test(candidate) ? undefined // Compile
|
|
184
|
+
: candidate // Don't compile
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Compiles and formats an ICU message at runtime using intl-messageformat.
|
|
189
|
+
* This is the default implementation used when messages are not precompiled.
|
|
190
|
+
*/ function formatMessage() {
|
|
191
|
+
/** The raw ICU message string (or precompiled message, though this implementation ignores precompilation) */ for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++){
|
|
192
|
+
_tmp[_key] = arguments[_key];
|
|
193
|
+
}
|
|
194
|
+
var __tmp = _slicedToArray(_tmp, 4), key = __tmp[0], message = __tmp[1], values = __tmp[2], options = __tmp[3];
|
|
195
|
+
if (Array.isArray(message)) {
|
|
196
|
+
throw new _formattersR4AAmsMPJs.I(_formattersR4AAmsMPJs.a.INVALID_MESSAGE, "Message at `".concat(key, "` resolved to an array, but only strings are supported. See https://next-intl.dev/docs/usage/translations#arrays-of-messages"));
|
|
197
|
+
}
|
|
198
|
+
if (typeof message === "object") {
|
|
199
|
+
throw new _formattersR4AAmsMPJs.I(_formattersR4AAmsMPJs.a.INSUFFICIENT_PATH, "Message at `".concat(key, "` resolved to `").concat(typeof message === "undefined" ? "undefined" : _typeof(message), "`, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl.dev/docs/usage/translations#structuring-messages"));
|
|
200
|
+
}
|
|
201
|
+
// Hot path that avoids creating an `IntlMessageFormat` instance
|
|
202
|
+
if (typeof message === "string") {
|
|
203
|
+
var plainMessage = getPlainMessage(message, values);
|
|
204
|
+
if (plainMessage) return plainMessage;
|
|
205
|
+
}
|
|
206
|
+
var cache = options.cache, formats = options.formats, formatters = options.formatters, globalFormats = options.globalFormats, locale = options.locale, timeZone = options.timeZone;
|
|
207
|
+
// Lazy init the message formatter for better tree
|
|
208
|
+
// shaking in case message formatting is not used.
|
|
209
|
+
if (!formatters.getMessageFormat) {
|
|
210
|
+
formatters.getMessageFormat = createMessageFormatter(cache, formatters);
|
|
211
|
+
}
|
|
212
|
+
var messageFormat;
|
|
213
|
+
try {
|
|
214
|
+
messageFormat = formatters.getMessageFormat(message, locale, convertFormatsToIntlMessageFormat(globalFormats, formats, timeZone), {
|
|
215
|
+
formatters: _objectSpreadProps(_objectSpread({}, formatters), {
|
|
216
|
+
getDateTimeFormat: function getDateTimeFormat(locales, dateTimeOptions) {
|
|
217
|
+
var ref;
|
|
218
|
+
// Workaround for https://github.com/formatjs/formatjs/issues/4279
|
|
219
|
+
return formatters.getDateTimeFormat(locales, _objectSpreadProps(_objectSpread({}, dateTimeOptions), {
|
|
220
|
+
timeZone: (ref = dateTimeOptions === null || dateTimeOptions === void 0 ? void 0 : dateTimeOptions.timeZone) !== null && ref !== void 0 ? ref : timeZone
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
} catch (error) {
|
|
226
|
+
throw new _formattersR4AAmsMPJs.I(_formattersR4AAmsMPJs.a.INVALID_MESSAGE, "".concat(error.message, " (").concat(error.originalMessage, ")"));
|
|
227
|
+
}
|
|
228
|
+
var formattedMessage = messageFormat.format(// @ts-expect-error `intl-messageformat` expects a different format
|
|
229
|
+
// for rich text elements since a recent minor update. This
|
|
230
|
+
// needs to be evaluated in detail, possibly also in regard
|
|
231
|
+
// to be able to format to parts.
|
|
232
|
+
values);
|
|
233
|
+
// Limit the function signature to return strings or React elements
|
|
234
|
+
return /*#__PURE__*/ (0, _react.isValidElement)(formattedMessage) || // Arrays of React elements
|
|
235
|
+
Array.isArray(formattedMessage) || typeof formattedMessage === "string" ? formattedMessage : String(formattedMessage);
|
|
236
|
+
}
|
|
237
|
+
// `t.raw` is supported
|
|
238
|
+
formatMessage.raw = true;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
I: function() {
|
|
13
|
+
return IntlError;
|
|
14
|
+
},
|
|
15
|
+
a: function() {
|
|
16
|
+
return IntlErrorCode;
|
|
17
|
+
},
|
|
18
|
+
b: function() {
|
|
19
|
+
return createCache;
|
|
20
|
+
},
|
|
21
|
+
c: function() {
|
|
22
|
+
return createIntlFormatters;
|
|
23
|
+
},
|
|
24
|
+
m: function() {
|
|
25
|
+
return memoFn;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var _fastMemoize = require("@formatjs/fast-memoize");
|
|
29
|
+
function _arrayLikeToArray(arr, len) {
|
|
30
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
31
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
32
|
+
return arr2;
|
|
33
|
+
}
|
|
34
|
+
function _arrayWithoutHoles(arr) {
|
|
35
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
36
|
+
}
|
|
37
|
+
function _assertThisInitialized(self) {
|
|
38
|
+
if (self === void 0) {
|
|
39
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
40
|
+
}
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
function _classCallCheck(instance, Constructor) {
|
|
44
|
+
if (!(instance instanceof Constructor)) {
|
|
45
|
+
throw new TypeError("Cannot call a class as a function");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function isNativeReflectConstruct() {
|
|
49
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
50
|
+
if (Reflect.construct.sham) return false;
|
|
51
|
+
if (typeof Proxy === "function") return true;
|
|
52
|
+
try {
|
|
53
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
|
|
54
|
+
return true;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function _construct(Parent, args, Class) {
|
|
60
|
+
if (isNativeReflectConstruct()) {
|
|
61
|
+
_construct = Reflect.construct;
|
|
62
|
+
} else {
|
|
63
|
+
_construct = function _construct(Parent, args, Class) {
|
|
64
|
+
var a = [
|
|
65
|
+
null
|
|
66
|
+
];
|
|
67
|
+
a.push.apply(a, args);
|
|
68
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
69
|
+
var instance = new Constructor();
|
|
70
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
71
|
+
return instance;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return _construct.apply(null, arguments);
|
|
75
|
+
}
|
|
76
|
+
function _getPrototypeOf(o) {
|
|
77
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
78
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
79
|
+
};
|
|
80
|
+
return _getPrototypeOf(o);
|
|
81
|
+
}
|
|
82
|
+
function _inherits(subClass, superClass) {
|
|
83
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
84
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
85
|
+
}
|
|
86
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
87
|
+
constructor: {
|
|
88
|
+
value: subClass,
|
|
89
|
+
writable: true,
|
|
90
|
+
configurable: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
94
|
+
}
|
|
95
|
+
function _isNativeFunction(fn) {
|
|
96
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
97
|
+
}
|
|
98
|
+
function _iterableToArray(iter) {
|
|
99
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
100
|
+
}
|
|
101
|
+
function _nonIterableSpread() {
|
|
102
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
103
|
+
}
|
|
104
|
+
function _possibleConstructorReturn(self, call) {
|
|
105
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
106
|
+
return call;
|
|
107
|
+
}
|
|
108
|
+
return _assertThisInitialized(self);
|
|
109
|
+
}
|
|
110
|
+
function _setPrototypeOf(o, p) {
|
|
111
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
112
|
+
o.__proto__ = p;
|
|
113
|
+
return o;
|
|
114
|
+
};
|
|
115
|
+
return _setPrototypeOf(o, p);
|
|
116
|
+
}
|
|
117
|
+
function _toConsumableArray(arr) {
|
|
118
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
119
|
+
}
|
|
120
|
+
var _typeof = function(obj) {
|
|
121
|
+
"@swc/helpers - typeof";
|
|
122
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
123
|
+
};
|
|
124
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
125
|
+
if (!o) return;
|
|
126
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
127
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
128
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
129
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
130
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
131
|
+
}
|
|
132
|
+
function _wrapNativeSuper(Class) {
|
|
133
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
134
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
135
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
136
|
+
if (typeof Class !== "function") {
|
|
137
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
138
|
+
}
|
|
139
|
+
if (typeof _cache !== "undefined") {
|
|
140
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
141
|
+
_cache.set(Class, Wrapper);
|
|
142
|
+
}
|
|
143
|
+
function Wrapper() {
|
|
144
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
145
|
+
}
|
|
146
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
147
|
+
constructor: {
|
|
148
|
+
value: Wrapper,
|
|
149
|
+
enumerable: false,
|
|
150
|
+
writable: true,
|
|
151
|
+
configurable: true
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
155
|
+
};
|
|
156
|
+
return _wrapNativeSuper(Class);
|
|
157
|
+
}
|
|
158
|
+
function _isNativeReflectConstruct() {
|
|
159
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
160
|
+
if (Reflect.construct.sham) return false;
|
|
161
|
+
if (typeof Proxy === "function") return true;
|
|
162
|
+
try {
|
|
163
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
164
|
+
return true;
|
|
165
|
+
} catch (e) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function _createSuper(Derived) {
|
|
170
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
171
|
+
return function _createSuperInternal() {
|
|
172
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
173
|
+
if (hasNativeReflectConstruct) {
|
|
174
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
175
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
176
|
+
} else {
|
|
177
|
+
result = Super.apply(this, arguments);
|
|
178
|
+
}
|
|
179
|
+
return _possibleConstructorReturn(this, result);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
var IntlError = /*#__PURE__*/ function(Error1) {
|
|
183
|
+
"use strict";
|
|
184
|
+
_inherits(IntlError, Error1);
|
|
185
|
+
var _super = _createSuper(IntlError);
|
|
186
|
+
function IntlError(code, originalMessage) {
|
|
187
|
+
_classCallCheck(this, IntlError);
|
|
188
|
+
var _this;
|
|
189
|
+
var message = code;
|
|
190
|
+
if (originalMessage) {
|
|
191
|
+
message += ": " + originalMessage;
|
|
192
|
+
}
|
|
193
|
+
_this = _super.call(this, message);
|
|
194
|
+
_this.code = code;
|
|
195
|
+
if (originalMessage) {
|
|
196
|
+
_this.originalMessage = originalMessage;
|
|
197
|
+
}
|
|
198
|
+
return _this;
|
|
199
|
+
}
|
|
200
|
+
return IntlError;
|
|
201
|
+
}(_wrapNativeSuper(Error));
|
|
202
|
+
var IntlErrorCode = /*#__PURE__*/ function(IntlErrorCode) {
|
|
203
|
+
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
|
|
204
|
+
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
|
|
205
|
+
IntlErrorCode["ENVIRONMENT_FALLBACK"] = "ENVIRONMENT_FALLBACK";
|
|
206
|
+
IntlErrorCode["INSUFFICIENT_PATH"] = "INSUFFICIENT_PATH";
|
|
207
|
+
IntlErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
|
|
208
|
+
IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
|
|
209
|
+
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
|
|
210
|
+
return IntlErrorCode;
|
|
211
|
+
}(IntlErrorCode || {});
|
|
212
|
+
function createCache() {
|
|
213
|
+
return {
|
|
214
|
+
dateTime: {},
|
|
215
|
+
number: {},
|
|
216
|
+
message: {},
|
|
217
|
+
relativeTime: {},
|
|
218
|
+
pluralRules: {},
|
|
219
|
+
list: {},
|
|
220
|
+
displayNames: {}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function createMemoCache(store) {
|
|
224
|
+
return {
|
|
225
|
+
create: function create() {
|
|
226
|
+
return {
|
|
227
|
+
get: function get(key) {
|
|
228
|
+
return store[key];
|
|
229
|
+
},
|
|
230
|
+
set: function set(key, value) {
|
|
231
|
+
store[key] = value;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function memoFn(fn, cache) {
|
|
238
|
+
return (0, _fastMemoize.memoize)(fn, {
|
|
239
|
+
cache: createMemoCache(cache),
|
|
240
|
+
strategy: _fastMemoize.strategies.variadic
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function memoConstructor(ConstructorFn, cache) {
|
|
244
|
+
return memoFn(function() {
|
|
245
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
246
|
+
args[_key] = arguments[_key];
|
|
247
|
+
}
|
|
248
|
+
return _construct(ConstructorFn, _toConsumableArray(args));
|
|
249
|
+
}, cache);
|
|
250
|
+
}
|
|
251
|
+
function createIntlFormatters(cache) {
|
|
252
|
+
var getDateTimeFormat = memoConstructor(Intl.DateTimeFormat, cache.dateTime);
|
|
253
|
+
var getNumberFormat = memoConstructor(Intl.NumberFormat, cache.number);
|
|
254
|
+
var getPluralRules = memoConstructor(Intl.PluralRules, cache.pluralRules);
|
|
255
|
+
var getRelativeTimeFormat = memoConstructor(Intl.RelativeTimeFormat, cache.relativeTime);
|
|
256
|
+
var getListFormat = memoConstructor(Intl.ListFormat, cache.list);
|
|
257
|
+
var getDisplayNames = memoConstructor(Intl.DisplayNames, cache.displayNames);
|
|
258
|
+
return {
|
|
259
|
+
getDateTimeFormat: getDateTimeFormat,
|
|
260
|
+
getNumberFormat: getNumberFormat,
|
|
261
|
+
getPluralRules: getPluralRules,
|
|
262
|
+
getRelativeTimeFormat: getRelativeTimeFormat,
|
|
263
|
+
getListFormat: getListFormat,
|
|
264
|
+
getDisplayNames: getDisplayNames
|
|
265
|
+
};
|
|
266
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
IntlError: function() {
|
|
13
|
+
return _formattersR4AAmsMPJs.I;
|
|
14
|
+
},
|
|
15
|
+
IntlErrorCode: function() {
|
|
16
|
+
return _formattersR4AAmsMPJs.a;
|
|
17
|
+
},
|
|
18
|
+
"_createCache": function() {
|
|
19
|
+
return _formattersR4AAmsMPJs.b;
|
|
20
|
+
},
|
|
21
|
+
"_createIntlFormatters": function() {
|
|
22
|
+
return _formattersR4AAmsMPJs.c;
|
|
23
|
+
},
|
|
24
|
+
createTranslator: function() {
|
|
25
|
+
return _coreJs.createTranslator;
|
|
26
|
+
},
|
|
27
|
+
hasLocale: function() {
|
|
28
|
+
return _coreJs.hasLocale;
|
|
29
|
+
},
|
|
30
|
+
createFormatter: function() {
|
|
31
|
+
return _initializeConfigCUsOI8U2Js.c;
|
|
32
|
+
},
|
|
33
|
+
initializeConfig: function() {
|
|
34
|
+
return _initializeConfigCUsOI8U2Js.i;
|
|
35
|
+
},
|
|
36
|
+
IntlProvider: function() {
|
|
37
|
+
return _reactJs.IntlProvider;
|
|
38
|
+
},
|
|
39
|
+
"_useExtracted": function() {
|
|
40
|
+
return _reactJs["_useExtracted"];
|
|
41
|
+
},
|
|
42
|
+
useFormatter: function() {
|
|
43
|
+
return _reactJs.useFormatter;
|
|
44
|
+
},
|
|
45
|
+
useLocale: function() {
|
|
46
|
+
return _reactJs.useLocale;
|
|
47
|
+
},
|
|
48
|
+
useMessages: function() {
|
|
49
|
+
return _reactJs.useMessages;
|
|
50
|
+
},
|
|
51
|
+
useNow: function() {
|
|
52
|
+
return _reactJs.useNow;
|
|
53
|
+
},
|
|
54
|
+
useTimeZone: function() {
|
|
55
|
+
return _reactJs.useTimeZone;
|
|
56
|
+
},
|
|
57
|
+
useTranslations: function() {
|
|
58
|
+
return _reactJs.useTranslations;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var _formattersR4AAmsMPJs = require("./formatters-r4aAmsMP.js");
|
|
62
|
+
var _coreJs = require("./core.js");
|
|
63
|
+
var _initializeConfigCUsOI8U2Js = require("./initializeConfig-CUsOI8u2.js");
|
|
64
|
+
var _reactJs = require("./react.js");
|