@edx/frontend-platform 8.0.4 → 8.1.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/analytics/MockAnalyticsService.js +5 -5
- package/analytics/SegmentAnalyticsService.js +5 -6
- package/analytics/SegmentAnalyticsService.js.map +1 -1
- package/auth/AxiosCsrfTokenService.js +9 -10
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js +9 -10
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js +8 -9
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js +3 -3
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js +6 -7
- package/auth/MockAuthService.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js +3 -3
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js +4 -4
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +3 -3
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js +3 -3
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js +3 -3
- package/auth/interface.js.map +1 -1
- package/auth/utils.js +6 -6
- package/i18n/countries.js +31 -18
- package/i18n/countries.js.map +1 -1
- package/i18n/injectIntlWithShim.js +12 -13
- package/i18n/injectIntlWithShim.js.map +1 -1
- package/i18n/languages.js +34 -18
- package/i18n/languages.js.map +1 -1
- package/i18n/lib.js +8 -8
- package/i18n/lib.js.map +1 -1
- package/i18n/scripts/transifex-utils.js +5 -5
- package/i18n/scripts/transifex-utils.js.map +1 -1
- package/initialize.js +6 -6
- package/initialize.js.map +1 -1
- package/logging/MockLoggingService.js +5 -5
- package/logging/NewRelicLoggingService.js +6 -7
- package/logging/NewRelicLoggingService.js.map +1 -1
- package/package.json +9 -8
- package/react/AppProvider.js +4 -4
- package/react/ErrorBoundary.js +11 -12
- package/react/ErrorBoundary.js.map +1 -1
- package/react/ErrorPage.js +4 -4
- package/scripts/GoogleAnalyticsLoader.js +5 -6
- package/scripts/GoogleAnalyticsLoader.js.map +1 -1
- package/testing/initializeMockApp.js +2 -2
- package/utils.js +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectIntlWithShim.js","names":["React","injectIntl","getLoggingService","intlShape","injectIntlWithShim","WrappedComponent","ShimmedIntlComponent","_React$Component","
|
|
1
|
+
{"version":3,"file":"injectIntlWithShim.js","names":["React","injectIntl","getLoggingService","intlShape","injectIntlWithShim","WrappedComponent","ShimmedIntlComponent","_React$Component","props","_this","_classCallCheck","_callSuper","shimmedIntl","Object","create","intl","formatMessage","value","definition","_this$props$intl","undefined","id","error","Error","process","env","NODE_ENV","console","logError","_len","arguments","length","args","Array","_key","apply","concat","_inherits","_createClass","key","render","createElement","_extends","Component","propTypes","isRequired"],"sources":["../../src/i18n/injectIntlWithShim.jsx"],"sourcesContent":["import React from 'react';\nimport { injectIntl } from 'react-intl';\nimport { getLoggingService, intlShape } from './lib';\n\n/**\n * This function wraps react-intl's injectIntl function in order to add error logging to the intl\n * property's formatMessage function.\n *\n * @memberof I18n\n */\nconst injectIntlWithShim = (WrappedComponent) => {\n class ShimmedIntlComponent extends React.Component {\n constructor(props) {\n super(props);\n this.shimmedIntl = Object.create(this.props.intl, {\n formatMessage: {\n value: (definition, ...args) => {\n if (definition === undefined || definition.id === undefined) {\n const error = new Error('i18n error: An undefined message was supplied to intl.formatMessage.');\n if (process.env.NODE_ENV !== 'production') {\n console.error(error); // eslint-disable-line no-console\n return '!!! Missing message supplied to intl.formatMessage !!!';\n }\n getLoggingService().logError(error);\n return ''; // Fail silently in production\n }\n return this.props.intl.formatMessage(definition, ...args);\n },\n },\n });\n }\n\n render() {\n return <WrappedComponent {...this.props} intl={this.shimmedIntl} />;\n }\n }\n\n ShimmedIntlComponent.propTypes = {\n intl: intlShape.isRequired,\n };\n\n return injectIntl(ShimmedIntlComponent);\n};\n\nexport default injectIntlWithShim;\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,YAAY;AACvC,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,OAAO;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,gBAAgB,EAAK;EAAA,IACzCC,oBAAoB,0BAAAC,gBAAA;IACxB,SAAAD,qBAAYE,KAAK,EAAE;MAAA,IAAAC,KAAA;MAAAC,eAAA,OAAAJ,oBAAA;MACjBG,KAAA,GAAAE,UAAA,OAAAL,oBAAA,GAAME,KAAK;MACXC,KAAA,CAAKG,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACL,KAAA,CAAKD,KAAK,CAACO,IAAI,EAAE;QAChDC,aAAa,EAAE;UACbC,KAAK,EAAE,SAAAA,MAACC,UAAU,EAAc;YAAA,IAAAC,gBAAA;YAC9B,IAAID,UAAU,KAAKE,SAAS,IAAIF,UAAU,CAACG,EAAE,KAAKD,SAAS,EAAE;cAC3D,IAAME,KAAK,GAAG,IAAIC,KAAK,CAAC,sEAAsE,CAAC;cAC/F,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;gBACzCC,OAAO,CAACL,KAAK,CAACA,KAAK,CAAC,CAAC,CAAC;gBACtB,OAAO,wDAAwD;cACjE;cACApB,iBAAiB,CAAC,CAAC,CAAC0B,QAAQ,CAACN,KAAK,CAAC;cACnC,OAAO,EAAE,CAAC,CAAC;YACb;YAAC,SAAAO,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAToBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;cAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;YAAA;YAUzB,OAAO,CAAAf,gBAAA,GAAAV,KAAA,CAAKD,KAAK,CAACO,IAAI,EAACC,aAAa,CAAAmB,KAAA,CAAAhB,gBAAA,GAACD,UAAU,EAAAkB,MAAA,CAAKJ,IAAI,EAAC;UAC3D;QACF;MACF,CAAC,CAAC;MAAC,OAAAvB,KAAA;IACL;IAAC4B,SAAA,CAAA/B,oBAAA,EAAAC,gBAAA;IAAA,OAAA+B,YAAA,CAAAhC,oBAAA;MAAAiC,GAAA;MAAAtB,KAAA,EAED,SAAAuB,OAAA,EAAS;QACP,oBAAOxC,KAAA,CAAAyC,aAAA,CAACpC,gBAAgB,EAAAqC,QAAA,KAAK,IAAI,CAAClC,KAAK;UAAEO,IAAI,EAAE,IAAI,CAACH;QAAY,EAAE,CAAC;MACrE;IAAC;EAAA,EAvBgCZ,KAAK,CAAC2C,SAAS;EA0BlDrC,oBAAoB,CAACsC,SAAS,GAAG;IAC/B7B,IAAI,EAAEZ,SAAS,CAAC0C;EAClB,CAAC;EAED,OAAO5C,UAAU,CAACK,oBAAoB,CAAC;AACzC,CAAC;AAED,eAAeF,kBAAkB","ignoreList":[]}
|
package/i18n/languages.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
function _slicedToArray(
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(
|
|
4
|
-
function _arrayLikeToArray(
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
7
|
/* eslint-disable import/extensions */
|
|
8
8
|
import LANGUAGES, { langs as languageLangs } from '@cospired/i18n-iso-languages';
|
|
9
|
+
|
|
10
|
+
// import arLocale from '@cospired/i18n-iso-languages/langs/ar.json';
|
|
11
|
+
import enLocale from '@cospired/i18n-iso-languages/langs/en.json';
|
|
12
|
+
import esLocale from '@cospired/i18n-iso-languages/langs/es.json';
|
|
13
|
+
import frLocale from '@cospired/i18n-iso-languages/langs/fr.json';
|
|
14
|
+
// import zhLocale from '@cospired/i18n-iso-languages/langs/zh.json';
|
|
15
|
+
// import caLocale from '@cospired/i18n-iso-languages/langs/ca.json';
|
|
16
|
+
// import heLocale from '@cospired/i18n-iso-languages/langs/he.json';
|
|
17
|
+
// import idLocale from '@cospired/i18n-iso-languages/langs/id.json';
|
|
18
|
+
// import koLocale from '@cospired/i18n-iso-languages/langs/ko.json';
|
|
19
|
+
import plLocale from '@cospired/i18n-iso-languages/langs/pl.json';
|
|
20
|
+
import ptLocale from '@cospired/i18n-iso-languages/langs/pt.json';
|
|
21
|
+
// import ruLocale from '@cospired/i18n-iso-languages/langs/ru.json';
|
|
22
|
+
// import thLocale from '@cospired/i18n-iso-languages/langs/th.json';
|
|
23
|
+
// import ukLocale from '@cospired/i18n-iso-languages/langs/uk.json';
|
|
24
|
+
|
|
9
25
|
import { getPrimaryLanguageSubtag } from './lib';
|
|
10
26
|
|
|
11
27
|
/*
|
|
@@ -19,20 +35,20 @@ import { getPrimaryLanguageSubtag } from './lib';
|
|
|
19
35
|
* been a while, go check and see if that's changed!
|
|
20
36
|
*/
|
|
21
37
|
|
|
22
|
-
// LANGUAGES.registerLocale(
|
|
23
|
-
LANGUAGES.registerLocale(
|
|
24
|
-
LANGUAGES.registerLocale(
|
|
25
|
-
LANGUAGES.registerLocale(
|
|
26
|
-
// LANGUAGES.registerLocale(
|
|
27
|
-
// LANGUAGES.registerLocale(
|
|
28
|
-
// LANGUAGES.registerLocale(
|
|
29
|
-
// LANGUAGES.registerLocale(
|
|
30
|
-
// LANGUAGES.registerLocale(
|
|
31
|
-
LANGUAGES.registerLocale(
|
|
32
|
-
LANGUAGES.registerLocale(
|
|
33
|
-
// LANGUAGES.registerLocale(
|
|
34
|
-
// LANGUAGES.registerLocale(
|
|
35
|
-
// LANGUAGES.registerLocale(
|
|
38
|
+
// LANGUAGES.registerLocale(arLocale);
|
|
39
|
+
LANGUAGES.registerLocale(enLocale);
|
|
40
|
+
LANGUAGES.registerLocale(esLocale);
|
|
41
|
+
LANGUAGES.registerLocale(frLocale);
|
|
42
|
+
// LANGUAGES.registerLocale(zhLocale);
|
|
43
|
+
// LANGUAGES.registerLocale(caLocale);
|
|
44
|
+
// LANGUAGES.registerLocale(heLocale);
|
|
45
|
+
// LANGUAGES.registerLocale(idLocale);
|
|
46
|
+
// LANGUAGES.registerLocale(koLocale);
|
|
47
|
+
LANGUAGES.registerLocale(plLocale);
|
|
48
|
+
LANGUAGES.registerLocale(ptLocale);
|
|
49
|
+
// LANGUAGES.registerLocale(ruLocale);
|
|
50
|
+
// LANGUAGES.registerLocale(thLocale);
|
|
51
|
+
// LANGUAGES.registerLocale(ukLocale);
|
|
36
52
|
|
|
37
53
|
/**
|
|
38
54
|
* Provides a lookup table of language IDs to language names for the current locale.
|
package/i18n/languages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languages.js","names":["LANGUAGES","langs","languageLangs","
|
|
1
|
+
{"version":3,"file":"languages.js","names":["LANGUAGES","langs","languageLangs","enLocale","esLocale","frLocale","plLocale","ptLocale","getPrimaryLanguageSubtag","registerLocale","getLanguageMessages","locale","primaryLanguageSubtag","languageCode","includes","getNames","getLanguageList","languageMessages","Object","entries","map","_ref","_ref2","_slicedToArray","code","name"],"sources":["../../src/i18n/languages.js"],"sourcesContent":["/* eslint-disable import/extensions */\nimport LANGUAGES, { langs as languageLangs } from '@cospired/i18n-iso-languages';\n\n// import arLocale from '@cospired/i18n-iso-languages/langs/ar.json';\nimport enLocale from '@cospired/i18n-iso-languages/langs/en.json';\nimport esLocale from '@cospired/i18n-iso-languages/langs/es.json';\nimport frLocale from '@cospired/i18n-iso-languages/langs/fr.json';\n// import zhLocale from '@cospired/i18n-iso-languages/langs/zh.json';\n// import caLocale from '@cospired/i18n-iso-languages/langs/ca.json';\n// import heLocale from '@cospired/i18n-iso-languages/langs/he.json';\n// import idLocale from '@cospired/i18n-iso-languages/langs/id.json';\n// import koLocale from '@cospired/i18n-iso-languages/langs/ko.json';\nimport plLocale from '@cospired/i18n-iso-languages/langs/pl.json';\nimport ptLocale from '@cospired/i18n-iso-languages/langs/pt.json';\n// import ruLocale from '@cospired/i18n-iso-languages/langs/ru.json';\n// import thLocale from '@cospired/i18n-iso-languages/langs/th.json';\n// import ukLocale from '@cospired/i18n-iso-languages/langs/uk.json';\n\nimport { getPrimaryLanguageSubtag } from './lib';\n\n/*\n * LANGUAGE LISTS\n *\n * Lists of language names localized in supported languages.\n *\n * TODO: When we start dynamically loading translations only for the current locale, change this.\n * TODO: Also note that a bunch of languages are missing here. They're present but commented out\n * for reference. That's because they're not implemented in this library. If you read this and it's\n * been a while, go check and see if that's changed!\n */\n\n// LANGUAGES.registerLocale(arLocale);\nLANGUAGES.registerLocale(enLocale);\nLANGUAGES.registerLocale(esLocale);\nLANGUAGES.registerLocale(frLocale);\n// LANGUAGES.registerLocale(zhLocale);\n// LANGUAGES.registerLocale(caLocale);\n// LANGUAGES.registerLocale(heLocale);\n// LANGUAGES.registerLocale(idLocale);\n// LANGUAGES.registerLocale(koLocale);\nLANGUAGES.registerLocale(plLocale);\nLANGUAGES.registerLocale(ptLocale);\n// LANGUAGES.registerLocale(ruLocale);\n// LANGUAGES.registerLocale(thLocale);\n// LANGUAGES.registerLocale(ukLocale);\n\n/**\n * Provides a lookup table of language IDs to language names for the current locale.\n *\n * @memberof I18n\n */\nexport const getLanguageMessages = (locale) => {\n const primaryLanguageSubtag = getPrimaryLanguageSubtag(locale);\n const languageCode = languageLangs().includes(primaryLanguageSubtag) ? primaryLanguageSubtag : 'en';\n\n return LANGUAGES.getNames(languageCode);\n};\n\n/**\n * Provides a list of languages represented as objects of the following shape:\n *\n * {\n * key, // The ID of the language\n * name // The localized name of the language\n * }\n *\n * TODO: ARCH-878: The list should be sorted alphabetically in the current locale.\n * This is useful for populating dropdowns.\n *\n * @memberof I18n\n */\nexport const getLanguageList = (locale) => {\n const languageMessages = getLanguageMessages(locale);\n return Object.entries(languageMessages).map(([code, name]) => ({ code, name }));\n};\n"],"mappings":";;;;;;AAAA;AACA,OAAOA,SAAS,IAAIC,KAAK,IAAIC,aAAa,QAAQ,8BAA8B;;AAEhF;AACA,OAAOC,QAAQ,MAAM,4CAA4C;AACjE,OAAOC,QAAQ,MAAM,4CAA4C;AACjE,OAAOC,QAAQ,MAAM,4CAA4C;AACjE;AACA;AACA;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,4CAA4C;AACjE,OAAOC,QAAQ,MAAM,4CAA4C;AACjE;A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ConsumableArray(
|
|
1
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
2
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(
|
|
4
|
-
function _iterableToArray(
|
|
5
|
-
function _arrayWithoutHoles(
|
|
6
|
-
function _arrayLikeToArray(
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import Cookies from 'universal-cookie';
|
|
9
9
|
import merge from 'lodash.merge';
|
|
@@ -184,7 +184,7 @@ export function getLocale(locale) {
|
|
|
184
184
|
// Note that some browers prefer upper case for the region part of the locale, while others don't.
|
|
185
185
|
// Thus the toLowerCase, for consistency.
|
|
186
186
|
// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language
|
|
187
|
-
return findSupportedLocale(
|
|
187
|
+
return findSupportedLocale(globalThis.navigator.language.toLowerCase());
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
@@ -217,9 +217,9 @@ export function isRtl(locale) {
|
|
|
217
217
|
*/
|
|
218
218
|
export function handleRtl() {
|
|
219
219
|
if (isRtl(getLocale())) {
|
|
220
|
-
|
|
220
|
+
globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');
|
|
221
221
|
} else {
|
|
222
|
-
|
|
222
|
+
globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
var messagesShape = {
|
package/i18n/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","names":["PropTypes","Cookies","merge","cookies","supportedLocales","rtlLocales","config","loggingService","messages","intlShape","object","getLoggingService","LOCALE_TOPIC","LOCALE_CHANGED","concat","getCookies","getPrimaryLanguageSubtag","code","split","findSupportedLocale","locale","undefined","getLocale","Error","cookieLangPref","get","LANGUAGE_PREFERENCE_COOKIE_NAME","toLowerCase","global","navigator","language","getMessages","arguments","length","isRtl","includes","handleRtl","document","getElementsByTagName","setAttribute","messagesShape","ar","objectOf","string","en","fr","ca","he","id","pl","ru","th","uk","optionsShape","isRequired","shape","logError","func","oneOfType","arrayOf","mergeMessages","newMessages","msgs","Array","isArray","apply","_toConsumableArray","configure","options","checkPropTypes","ENVIRONMENT","Object","keys","forEach","key","indexOf","console","warn"],"sources":["../../src/i18n/lib.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport Cookies from 'universal-cookie';\nimport merge from 'lodash.merge';\n\nimport '@formatjs/intl-pluralrules/polyfill';\nimport '@formatjs/intl-pluralrules/locale-data/ar';\nimport '@formatjs/intl-pluralrules/locale-data/en';\nimport '@formatjs/intl-pluralrules/locale-data/es';\nimport '@formatjs/intl-pluralrules/locale-data/fr';\nimport '@formatjs/intl-pluralrules/locale-data/zh';\nimport '@formatjs/intl-pluralrules/locale-data/ca';\nimport '@formatjs/intl-pluralrules/locale-data/he';\nimport '@formatjs/intl-pluralrules/locale-data/id';\nimport '@formatjs/intl-pluralrules/locale-data/ko';\nimport '@formatjs/intl-pluralrules/locale-data/pl';\nimport '@formatjs/intl-pluralrules/locale-data/pt';\nimport '@formatjs/intl-pluralrules/locale-data/ru';\nimport '@formatjs/intl-pluralrules/locale-data/th';\nimport '@formatjs/intl-pluralrules/locale-data/uk';\n\nimport '@formatjs/intl-relativetimeformat/polyfill';\nimport '@formatjs/intl-relativetimeformat/locale-data/ar';\nimport '@formatjs/intl-relativetimeformat/locale-data/en';\nimport '@formatjs/intl-relativetimeformat/locale-data/es';\nimport '@formatjs/intl-relativetimeformat/locale-data/fr';\nimport '@formatjs/intl-relativetimeformat/locale-data/zh';\nimport '@formatjs/intl-relativetimeformat/locale-data/ca';\nimport '@formatjs/intl-relativetimeformat/locale-data/he';\nimport '@formatjs/intl-relativetimeformat/locale-data/id';\nimport '@formatjs/intl-relativetimeformat/locale-data/ko';\nimport '@formatjs/intl-relativetimeformat/locale-data/pl';\nimport '@formatjs/intl-relativetimeformat/locale-data/pt';\nimport '@formatjs/intl-relativetimeformat/locale-data/ru';\nimport '@formatjs/intl-relativetimeformat/locale-data/th';\nimport '@formatjs/intl-relativetimeformat/locale-data/uk';\n\nconst cookies = new Cookies();\nconst supportedLocales = [\n 'ar', // Arabic\n // NOTE: 'en' is not included in this list intentionally, since it's the fallback.\n 'es-419', // Spanish, Latin American\n 'fa', // Farsi\n 'fa-ir', // Farsi, Iran\n 'fr', // French\n 'zh-cn', // Chinese, Simplified\n 'ca', // Catalan\n 'he', // Hebrew\n 'id', // Indonesian\n 'ko-kr', // Korean (Korea)\n 'pl', // Polish\n 'pt-br', // Portuguese (Brazil)\n 'ru', // Russian\n 'th', // Thai\n 'uk', // Ukrainian\n];\nconst rtlLocales = [\n 'ar', // Arabic\n 'he', // Hebrew\n 'fa', // Farsi (not currently supported)\n 'fa-ir', // Farsi Iran\n 'ur', // Urdu (not currently supported)\n];\n\nlet config = null;\nlet loggingService = null;\nlet messages = null;\n\n/**\n * @memberof module:Internationalization\n *\n * Prior versions of react-intl (our primary implementation of the i18n service) included a\n * PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy\n * compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this\n * export is deprecated.\n *\n * @deprecated\n */\nexport const intlShape = PropTypes.object;\n\n/**\n *\n * @ignore\n * @returns {LoggingService}\n */\nexport const getLoggingService = () => loggingService;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configure with messages first.');\n }\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n const cookieLangPref = cookies\n .get(config.LANGUAGE_PREFERENCE_COOKIE_NAME);\n if (cookieLangPref) {\n return findSupportedLocale(cookieLangPref.toLowerCase());\n }\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(global.navigator.language.toLowerCase());\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\nconst messagesShape = {\n ar: PropTypes.objectOf(PropTypes.string), // Arabic\n en: PropTypes.objectOf(PropTypes.string),\n 'es-419': PropTypes.objectOf(PropTypes.string), // Spanish, Latin American\n fr: PropTypes.objectOf(PropTypes.string), // French\n 'zh-cn': PropTypes.objectOf(PropTypes.string), // Chinese, Simplified\n ca: PropTypes.objectOf(PropTypes.string), // Catalan\n he: PropTypes.objectOf(PropTypes.string), // Hebrew\n id: PropTypes.objectOf(PropTypes.string), // Indonesian\n 'ko-kr': PropTypes.objectOf(PropTypes.string), // Korean (Korea)\n pl: PropTypes.objectOf(PropTypes.string), // Polish\n 'pt-br': PropTypes.objectOf(PropTypes.string), // Portuguese (Brazil)\n ru: PropTypes.objectOf(PropTypes.string), // Russian\n th: PropTypes.objectOf(PropTypes.string), // Thai\n uk: PropTypes.objectOf(PropTypes.string), // Ukrainian\n};\n\nconst optionsShape = {\n config: PropTypes.object.isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n }).isRequired,\n messages: PropTypes.oneOfType([\n PropTypes.shape(messagesShape),\n PropTypes.arrayOf(PropTypes.shape(messagesShape)),\n ]).isRequired,\n};\n\n/**\n *\n *\n * @param {Object} newMessages\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(newMessages) {\n const msgs = Array.isArray(newMessages) ? merge({}, ...newMessages) : newMessages;\n messages = merge(messages, msgs);\n\n return messages;\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {LoggingService} options.loggingService\n * @param {Object} options.config\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configure(options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'i18n');\n // eslint-disable-next-line prefer-destructuring\n loggingService = options.loggingService;\n // eslint-disable-next-line prefer-destructuring\n config = options.config;\n messages = Array.isArray(options.messages) ? merge({}, ...options.messages) : options.messages;\n\n if (config.ENVIRONMENT !== 'production') {\n Object.keys(messages).forEach((key) => {\n if (supportedLocales.indexOf(key) < 0) {\n console.warn(`Unexpected locale: ${key}`); // eslint-disable-line no-console\n }\n });\n\n supportedLocales.forEach((key) => {\n if (messages[key] === undefined) {\n console.warn(`Missing locale: ${key}`); // eslint-disable-line no-console\n }\n });\n }\n\n handleRtl();\n}\n"],"mappings":";;;;;;AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,kBAAkB;AACtC,OAAOC,KAAK,MAAM,cAAc;AAEhC,OAAO,qCAAqC;AAC5C,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CA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GAAG,CAAC,KAAKrD,SAAS,EAAE;QAC/BuD,OAAO,CAACC,IAAI,oBAAA/D,MAAA,CAAoB4D,GAAG,CAAE,CAAC,CAAC,CAAC;MAC1C;IACF,CAAC,CAAC;EACJ;EAEAtC,SAAS,CAAC,CAAC;AACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"lib.js","names":["PropTypes","Cookies","merge","cookies","supportedLocales","rtlLocales","config","loggingService","messages","intlShape","object","getLoggingService","LOCALE_TOPIC","LOCALE_CHANGED","concat","getCookies","getPrimaryLanguageSubtag","code","split","findSupportedLocale","locale","undefined","getLocale","Error","cookieLangPref","get","LANGUAGE_PREFERENCE_COOKIE_NAME","toLowerCase","globalThis","navigator","language","getMessages","arguments","length","isRtl","includes","handleRtl","document","getElementsByTagName","setAttribute","messagesShape","ar","objectOf","string","en","fr","ca","he","id","pl","ru","th","uk","optionsShape","isRequired","shape","logError","func","oneOfType","arrayOf","mergeMessages","newMessages","msgs","Array","isArray","apply","_toConsumableArray","configure","options","checkPropTypes","ENVIRONMENT","Object","keys","forEach","key","indexOf","console","warn"],"sources":["../../src/i18n/lib.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport Cookies from 'universal-cookie';\nimport merge from 'lodash.merge';\n\nimport '@formatjs/intl-pluralrules/polyfill';\nimport '@formatjs/intl-pluralrules/locale-data/ar';\nimport '@formatjs/intl-pluralrules/locale-data/en';\nimport '@formatjs/intl-pluralrules/locale-data/es';\nimport '@formatjs/intl-pluralrules/locale-data/fr';\nimport '@formatjs/intl-pluralrules/locale-data/zh';\nimport '@formatjs/intl-pluralrules/locale-data/ca';\nimport '@formatjs/intl-pluralrules/locale-data/he';\nimport '@formatjs/intl-pluralrules/locale-data/id';\nimport '@formatjs/intl-pluralrules/locale-data/ko';\nimport '@formatjs/intl-pluralrules/locale-data/pl';\nimport '@formatjs/intl-pluralrules/locale-data/pt';\nimport '@formatjs/intl-pluralrules/locale-data/ru';\nimport '@formatjs/intl-pluralrules/locale-data/th';\nimport '@formatjs/intl-pluralrules/locale-data/uk';\n\nimport '@formatjs/intl-relativetimeformat/polyfill';\nimport '@formatjs/intl-relativetimeformat/locale-data/ar';\nimport '@formatjs/intl-relativetimeformat/locale-data/en';\nimport '@formatjs/intl-relativetimeformat/locale-data/es';\nimport '@formatjs/intl-relativetimeformat/locale-data/fr';\nimport '@formatjs/intl-relativetimeformat/locale-data/zh';\nimport '@formatjs/intl-relativetimeformat/locale-data/ca';\nimport '@formatjs/intl-relativetimeformat/locale-data/he';\nimport '@formatjs/intl-relativetimeformat/locale-data/id';\nimport '@formatjs/intl-relativetimeformat/locale-data/ko';\nimport '@formatjs/intl-relativetimeformat/locale-data/pl';\nimport '@formatjs/intl-relativetimeformat/locale-data/pt';\nimport '@formatjs/intl-relativetimeformat/locale-data/ru';\nimport '@formatjs/intl-relativetimeformat/locale-data/th';\nimport '@formatjs/intl-relativetimeformat/locale-data/uk';\n\nconst cookies = new Cookies();\nconst supportedLocales = [\n 'ar', // Arabic\n // NOTE: 'en' is not included in this list intentionally, since it's the fallback.\n 'es-419', // Spanish, Latin American\n 'fa', // Farsi\n 'fa-ir', // Farsi, Iran\n 'fr', // French\n 'zh-cn', // Chinese, Simplified\n 'ca', // Catalan\n 'he', // Hebrew\n 'id', // Indonesian\n 'ko-kr', // Korean (Korea)\n 'pl', // Polish\n 'pt-br', // Portuguese (Brazil)\n 'ru', // Russian\n 'th', // Thai\n 'uk', // Ukrainian\n];\nconst rtlLocales = [\n 'ar', // Arabic\n 'he', // Hebrew\n 'fa', // Farsi (not currently supported)\n 'fa-ir', // Farsi Iran\n 'ur', // Urdu (not currently supported)\n];\n\nlet config = null;\nlet loggingService = null;\nlet messages = null;\n\n/**\n * @memberof module:Internationalization\n *\n * Prior versions of react-intl (our primary implementation of the i18n service) included a\n * PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy\n * compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this\n * export is deprecated.\n *\n * @deprecated\n */\nexport const intlShape = PropTypes.object;\n\n/**\n *\n * @ignore\n * @returns {LoggingService}\n */\nexport const getLoggingService = () => loggingService;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configure with messages first.');\n }\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n const cookieLangPref = cookies\n .get(config.LANGUAGE_PREFERENCE_COOKIE_NAME);\n if (cookieLangPref) {\n return findSupportedLocale(cookieLangPref.toLowerCase());\n }\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(globalThis.navigator.language.toLowerCase());\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\nconst messagesShape = {\n ar: PropTypes.objectOf(PropTypes.string), // Arabic\n en: PropTypes.objectOf(PropTypes.string),\n 'es-419': PropTypes.objectOf(PropTypes.string), // Spanish, Latin American\n fr: PropTypes.objectOf(PropTypes.string), // French\n 'zh-cn': PropTypes.objectOf(PropTypes.string), // Chinese, Simplified\n ca: PropTypes.objectOf(PropTypes.string), // Catalan\n he: PropTypes.objectOf(PropTypes.string), // Hebrew\n id: PropTypes.objectOf(PropTypes.string), // Indonesian\n 'ko-kr': PropTypes.objectOf(PropTypes.string), // Korean (Korea)\n pl: PropTypes.objectOf(PropTypes.string), // Polish\n 'pt-br': PropTypes.objectOf(PropTypes.string), // Portuguese (Brazil)\n ru: PropTypes.objectOf(PropTypes.string), // Russian\n th: PropTypes.objectOf(PropTypes.string), // Thai\n uk: PropTypes.objectOf(PropTypes.string), // Ukrainian\n};\n\nconst optionsShape = {\n config: PropTypes.object.isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n }).isRequired,\n messages: PropTypes.oneOfType([\n PropTypes.shape(messagesShape),\n PropTypes.arrayOf(PropTypes.shape(messagesShape)),\n ]).isRequired,\n};\n\n/**\n *\n *\n * @param {Object} newMessages\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(newMessages) {\n const msgs = Array.isArray(newMessages) ? merge({}, ...newMessages) : newMessages;\n messages = merge(messages, msgs);\n\n return messages;\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {LoggingService} options.loggingService\n * @param {Object} options.config\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configure(options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'i18n');\n // eslint-disable-next-line prefer-destructuring\n loggingService = options.loggingService;\n // eslint-disable-next-line prefer-destructuring\n config = options.config;\n messages = Array.isArray(options.messages) ? merge({}, ...options.messages) : options.messages;\n\n if (config.ENVIRONMENT !== 'production') {\n Object.keys(messages).forEach((key) => {\n if (supportedLocales.indexOf(key) < 0) {\n console.warn(`Unexpected locale: ${key}`); // eslint-disable-line no-console\n }\n });\n\n supportedLocales.forEach((key) => {\n if (messages[key] === undefined) {\n console.warn(`Missing locale: ${key}`); // eslint-disable-line no-console\n }\n });\n }\n\n handleRtl();\n}\n"],"mappings":";;;;;;AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,kBAAkB;AACtC,OAAOC,KAAK,MAAM,cAAc;AAEhC,OAAO,qCAAqC;AAC5C,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2CAA2C;AAClD,OAAO,2C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ACF,CAAC,CAAC;EACJ;EAEAtC,SAAS,CAAC,CAAC;AACb","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function _toConsumableArray(
|
|
2
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(
|
|
5
|
-
function _iterableToArray(
|
|
6
|
-
function _arrayWithoutHoles(
|
|
7
|
-
function _arrayLikeToArray(
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
8
|
var fs = require('fs');
|
|
9
9
|
var glob = require('glob');
|
|
10
10
|
var path = require('path');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transifex-utils.js","names":["_toConsumableArray","
|
|
1
|
+
{"version":3,"file":"transifex-utils.js","names":["_toConsumableArray","r","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","TypeError","a","_arrayLikeToArray","t","toString","call","slice","constructor","name","Array","from","test","Symbol","iterator","isArray","length","e","n","fs","require","glob","path","gatherJson","dir","ret","files","sync","concat","forEach","filename","messages","JSON","parse","readFileSync","push","apply","escapeDots","messageId","replace","jsonDir","process","argv","messageObjects","exitCode","Error","loggingPrefix","basename","__filename","bashScriptsPath","hashFile","stdout","write","messageInfo","outputFile","writeFileSync","message","transifexFormatId","id","info","find","mi","key","appendFileSync","string_hash","description","output","defaultMessage","stringify"],"sources":["../../../src/i18n/scripts/transifex-utils.js"],"sourcesContent":["#!/usr/bin/env node\n\nconst fs = require('fs');\nconst glob = require('glob');\nconst path = require('path');\n\n/*\n * See the Makefile for how the required hash file is downloaded from Transifex.\n */\n\n/*\n * Expected input: a directory, possibly containing subdirectories, with .json files. Each .json\n * file is an array of translation triplets (id, description, defaultMessage).\n *\n *\n */\nfunction gatherJson(dir) {\n const ret = [];\n const files = glob.sync(`${dir}/**/*.json`);\n\n files.forEach((filename) => {\n const messages = JSON.parse(fs.readFileSync(filename));\n ret.push(...messages);\n });\n return ret;\n}\n\n// the hash file returns ids whose periods are \"escaped\" (sort of), like this:\n// \"key\": \"profile\\\\.sociallinks\\\\.social\\\\.links\"\n// so our regular messageIds won't match them out of the box\nfunction escapeDots(messageId) {\n return messageId.replace(/\\./g, '\\\\.');\n}\n\nconst jsonDir = process.argv[2];\nconst messageObjects = gatherJson(jsonDir);\n\nif (messageObjects.length === 0) {\n process.exitCode = 1;\n throw new Error('Found no messages');\n}\n\nif (process.argv[3] === '--comments') { // prepare to handle the translator notes\n const loggingPrefix = path.basename(`${__filename}`); // the name of this JS file\n const bashScriptsPath = (\n process.argv[4] && process.argv[4] === '--v3-scripts-path'\n ? './node_modules/@edx/reactifex/bash_scripts'\n : './node_modules/reactifex/bash_scripts');\n\n const hashFile = `${bashScriptsPath}/hashmap.json`;\n process.stdout.write(`${loggingPrefix}: reading hash file ${hashFile}\\n`);\n const messageInfo = JSON.parse(fs.readFileSync(hashFile));\n\n const outputFile = `${bashScriptsPath}/hashed_data.txt`;\n process.stdout.write(`${loggingPrefix}: writing to output file ${outputFile}\\n`);\n fs.writeFileSync(outputFile, '');\n\n messageObjects.forEach((message) => {\n const transifexFormatId = escapeDots(message.id);\n\n const info = messageInfo.find(mi => mi.key === transifexFormatId);\n if (info) {\n fs.appendFileSync(outputFile, `${info.string_hash}|${message.description}\\n`);\n } else {\n process.stdout.write(`${loggingPrefix}: string ${message.id} does not yet exist on transifex!\\n`);\n }\n });\n} else {\n const output = {};\n\n messageObjects.forEach((message) => {\n output[message.id] = message.defaultMessage;\n });\n fs.writeFileSync(process.argv[3], JSON.stringify(output, null, 2));\n}\n"],"mappings":"AAAA;AAAmB,SAAAA,mBAAAC,CAAA,WAAAC,kBAAA,CAAAD,CAAA,KAAAE,gBAAA,CAAAF,CAAA,KAAAG,2BAAA,CAAAH,CAAA,KAAAI,kBAAA;AAAA,SAAAA,mBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAH,CAAA,EAAAM,CAAA,QAAAN,CAAA,2BAAAA,CAAA,SAAAO,iBAAA,CAAAP,CAAA,EAAAM,CAAA,OAAAE,CAAA,MAAAC,QAAA,CAAAC,IAAA,CAAAV,CAAA,EAAAW,KAAA,6BAAAH,CAAA,IAAAR,CAAA,CAAAY,WAAA,KAAAJ,CAAA,GAAAR,CAAA,CAAAY,WAAA,CAAAC,IAAA,aAAAL,CAAA,cAAAA,CAAA,GAAAM,KAAA,CAAAC,IAAA,CAAAf,CAAA,oBAAAQ,CAAA,+CAAAQ,IAAA,CAAAR,CAAA,IAAAD,iBAAA,CAAAP,CAAA,EAAAM,CAAA;AAAA,SAAAJ,iBAAAF,CAAA,8BAAAiB,MAAA,YAAAjB,CAAA,CAAAiB,MAAA,CAAAC,QAAA,aAAAlB,CAAA,uBAAAc,KAAA,CAAAC,IAAA,CAAAf,CAAA;AAAA,SAAAC,mBAAAD,CAAA,QAAAc,KAAA,CAAAK,OAAA,CAAAnB,CAAA,UAAAO,iBAAA,CAAAP,CAAA;AAAA,SAA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,OAAApC,MAAA,CAAI4B,OAAO,CAACS,WAAW,OAAI,CAAC;IAC/E,CAAC,MAAM;MACLxB,OAAO,CAACU,MAAM,CAACC,KAAK,IAAAxB,MAAA,CAAIkB,aAAa,eAAAlB,MAAA,CAAY4B,OAAO,CAACE,EAAE,wCAAqC,CAAC;IACnG;EACF,CAAC,CAAC;AACJ,CAAC,MAAM;EACL,IAAMQ,MAAM,GAAG,CAAC,CAAC;EAEjBvB,cAAc,CAACd,OAAO,CAAC,UAAC2B,OAAO,EAAK;IAClCU,MAAM,CAACV,OAAO,CAACE,EAAE,CAAC,GAAGF,OAAO,CAACW,cAAc;EAC7C,CAAC,CAAC;EACFhD,EAAE,CAACoC,aAAa,CAACd,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,EAAEV,IAAI,CAACoC,SAAS,CAACF,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACpE","ignoreList":[]}
|
package/initialize.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw
|
|
8
|
-
function asyncGeneratorStep(
|
|
9
|
-
function _asyncToGenerator(
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
9
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
10
10
|
/**
|
|
11
11
|
* #### Import members from **@edx/frontend-platform**
|
|
12
12
|
*
|
|
@@ -158,7 +158,7 @@ function _auth() {
|
|
|
158
158
|
break;
|
|
159
159
|
}
|
|
160
160
|
_context3.next = 3;
|
|
161
|
-
return ensureAuthenticatedUser(
|
|
161
|
+
return ensureAuthenticatedUser(globalThis.location.href);
|
|
162
162
|
case 3:
|
|
163
163
|
_context3.next = 7;
|
|
164
164
|
break;
|