@oanda/labs-widget-common 1.0.220 → 1.0.222
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/CHANGELOG.md +1748 -0
- package/dist/main/types/liveRatesTypes.js.map +1 -1
- package/dist/main/utils/getLocale.js +8 -2
- package/dist/main/utils/getLocale.js.map +1 -1
- package/dist/module/types/liveRatesTypes.js.map +1 -1
- package/dist/module/utils/getLocale.js +8 -2
- package/dist/module/utils/getLocale.js.map +1 -1
- package/dist/types/types/liveRatesTypes.d.ts +3 -2
- package/package.json +2 -2
- package/src/types/liveRatesTypes.ts +4 -2
- package/src/utils/getLocale.ts +18 -1
- package/test/utils/getLocale.test.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveRatesTypes.js","names":[],"sources":["../../../src/types/liveRatesTypes.ts"],"sourcesContent":["export interface LiveRatesProviderQuery {\n instruments: string[];\n division?: string;\n dataSource?:
|
|
1
|
+
{"version":3,"file":"liveRatesTypes.js","names":[],"sources":["../../../src/types/liveRatesTypes.ts"],"sourcesContent":["export type LiveRatesDataSource = 'V20' | 'MT5';\n\nexport interface LiveRatesProviderQuery {\n instruments: string[];\n division?: string;\n dataSource?: LiveRatesDataSource;\n}\n\nexport interface LiveRatesProviderOptions {\n divisionCode?: string;\n dataSource?: LiveRatesDataSource;\n}\n\nexport interface LiveRatesConfig {\n url: string;\n query?: LiveRatesProviderQuery;\n options?: LiveRatesProviderOptions;\n eventSource?: EventSource;\n eventTarget?: EventTarget;\n eventName?: string;\n}\n\nexport interface LiveRatesHookMessage\n extends Omit<\n LiveRatesUpdateMessage,\n 'closingAsk' | 'closingBid' | 'openingAsk' | 'openingBid' | 'extraPrecision'\n > {\n spread: number;\n priceMovement: number;\n askPriceMovement: number;\n bidPriceMovement: number;\n dailyPriceMovement: number;\n dailyPipsChange: number;\n dailyPercentChange: number;\n dailyPercentChangeFromOpen: string;\n dailyPipsChangeFromOpen: number;\n displayPrecision: number;\n high: number;\n low: number;\n}\n\nexport interface LiveRatesHookReturnObject {\n update: LiveRatesHookMessage | null;\n error: LiveRatesErrorMessage | null;\n connectionError: boolean;\n setQuery: (query: LiveRatesProviderQuery) => void;\n}\n\nexport interface LiveRatesConnectionErrorMessage {\n messageType?: string;\n symbol: string;\n}\n\nexport interface LiveRatesTargetHookReturnObject {\n closeQuery: () => void;\n setQuery: (query: LiveRatesProviderQuery) => void;\n target: EventTarget | null;\n}\n\nexport interface LiveRatesMessageReturnObject {\n update: LiveRatesHookMessage | null;\n error: LiveRatesErrorMessage | null;\n connectionError: boolean;\n}\n\ninterface LiveRatesBaseMessage {\n messageType?: string;\n symbol: string;\n timestamp: string;\n}\nexport interface LiveRatesUpdateMessage extends LiveRatesBaseMessage {\n ask: number;\n bid: number;\n closingAsk: number;\n closingBid: number;\n openingAsk: number;\n openingBid: number;\n pipLocation: number;\n extraPrecision: number;\n low: number;\n high: number;\n}\n\nexport interface LiveRatesErrorMessage extends LiveRatesBaseMessage {\n error: string;\n}\n\nexport interface PriceChange {\n pipsChange: number;\n percentChange: number;\n priceMovement: number;\n askPriceMovement: number;\n bidPriceMovement: number;\n}\n\nexport interface PriceChangeFromOpen {\n percentChangeFromOpen: string;\n}\n\nexport interface PipsChangeFromOpen {\n pipsChangeFromOpen: number;\n}\n\nexport type Base64Decoder = (data: string) => string;\n\nexport type JsonParser = (data: string) => LiveRatesUpdateMessage;\n\nexport interface CalculatePriceChangeInput {\n pipLocation: number;\n extraPrecision: number;\n currentAsk: number;\n currentBid: number;\n prevAsk?: number;\n prevBid?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.validateLocale = exports.getLocale = void 0;
|
|
7
7
|
var _monoI18n = require("@oanda/mono-i18n");
|
|
8
8
|
const validateLocale = locale => {
|
|
9
|
-
const locales = ['en', 'zh', 'es', 'th'];
|
|
9
|
+
const locales = ['en', 'zh', 'es', 'th', 'fr', 'de', 'pt', 'it', 'zhCN', 'vi'];
|
|
10
10
|
return locales.includes(locale?.substring(0, 2));
|
|
11
11
|
};
|
|
12
12
|
exports.validateLocale = validateLocale;
|
|
@@ -15,7 +15,13 @@ const getLocale = locale => {
|
|
|
15
15
|
en: _monoI18n.Locale.en,
|
|
16
16
|
zh: _monoI18n.Locale.zhTW,
|
|
17
17
|
es: _monoI18n.Locale.es,
|
|
18
|
-
th: _monoI18n.Locale.th
|
|
18
|
+
th: _monoI18n.Locale.th,
|
|
19
|
+
fr: _monoI18n.Locale.fr,
|
|
20
|
+
de: _monoI18n.Locale.de,
|
|
21
|
+
pt: _monoI18n.Locale.pt,
|
|
22
|
+
it: _monoI18n.Locale.it,
|
|
23
|
+
['zh-CN']: _monoI18n.Locale.zhCN,
|
|
24
|
+
vi: _monoI18n.Locale.vi
|
|
19
25
|
};
|
|
20
26
|
return languageCodeDictionary[locale] || languageCodeDictionary.en;
|
|
21
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.js","names":["_monoI18n","require","validateLocale","locale","locales","includes","substring","exports","getLocale","languageCodeDictionary","en","Locale","zh","zhTW","es","th"],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\n\nconst validateLocale = (locale?: string) => {\n const locales = ['en'
|
|
1
|
+
{"version":3,"file":"getLocale.js","names":["_monoI18n","require","validateLocale","locale","locales","includes","substring","exports","getLocale","languageCodeDictionary","en","Locale","zh","zhTW","es","th","fr","de","pt","it","zhCN","vi"],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\n\nconst validateLocale = (locale?: string) => {\n const locales = [\n 'en',\n 'zh',\n 'es',\n 'th',\n 'fr',\n 'de',\n 'pt',\n 'it',\n 'zhCN',\n 'vi',\n ];\n\n return locales.includes(locale?.substring(0, 2)!);\n};\n\nconst getLocale = (locale?: string) => {\n const languageCodeDictionary: Record<string, Locale> = {\n en: Locale.en,\n zh: Locale.zhTW,\n es: Locale.es,\n th: Locale.th,\n fr: Locale.fr,\n de: Locale.de,\n pt: Locale.pt,\n it: Locale.it,\n ['zh-CN']: Locale.zhCN,\n vi: Locale.vi,\n };\n\n return languageCodeDictionary[locale!] || languageCodeDictionary.en;\n};\n\nexport { getLocale, validateLocale };\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAIC,MAAe,IAAK;EAC1C,MAAMC,OAAO,GAAG,CACd,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,CACL;EAED,OAAOA,OAAO,CAACC,QAAQ,CAACF,MAAM,EAAEG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAE,CAAC;AACnD,CAAC;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAEF,MAAMM,SAAS,GAAIL,MAAe,IAAK;EACrC,MAAMM,sBAA8C,GAAG;IACrDC,EAAE,EAAEC,gBAAM,CAACD,EAAE;IACbE,EAAE,EAAED,gBAAM,CAACE,IAAI;IACfC,EAAE,EAAEH,gBAAM,CAACG,EAAE;IACbC,EAAE,EAAEJ,gBAAM,CAACI,EAAE;IACbC,EAAE,EAAEL,gBAAM,CAACK,EAAE;IACbC,EAAE,EAAEN,gBAAM,CAACM,EAAE;IACbC,EAAE,EAAEP,gBAAM,CAACO,EAAE;IACbC,EAAE,EAAER,gBAAM,CAACQ,EAAE;IACb,CAAC,OAAO,GAAGR,gBAAM,CAACS,IAAI;IACtBC,EAAE,EAAEV,gBAAM,CAACU;EACb,CAAC;EAED,OAAOZ,sBAAsB,CAACN,MAAM,CAAE,IAAIM,sBAAsB,CAACC,EAAE;AACrE,CAAC;AAACH,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveRatesTypes.js","names":[],"sources":["../../../src/types/liveRatesTypes.ts"],"sourcesContent":["export interface LiveRatesProviderQuery {\n instruments: string[];\n division?: string;\n dataSource?:
|
|
1
|
+
{"version":3,"file":"liveRatesTypes.js","names":[],"sources":["../../../src/types/liveRatesTypes.ts"],"sourcesContent":["export type LiveRatesDataSource = 'V20' | 'MT5';\n\nexport interface LiveRatesProviderQuery {\n instruments: string[];\n division?: string;\n dataSource?: LiveRatesDataSource;\n}\n\nexport interface LiveRatesProviderOptions {\n divisionCode?: string;\n dataSource?: LiveRatesDataSource;\n}\n\nexport interface LiveRatesConfig {\n url: string;\n query?: LiveRatesProviderQuery;\n options?: LiveRatesProviderOptions;\n eventSource?: EventSource;\n eventTarget?: EventTarget;\n eventName?: string;\n}\n\nexport interface LiveRatesHookMessage\n extends Omit<\n LiveRatesUpdateMessage,\n 'closingAsk' | 'closingBid' | 'openingAsk' | 'openingBid' | 'extraPrecision'\n > {\n spread: number;\n priceMovement: number;\n askPriceMovement: number;\n bidPriceMovement: number;\n dailyPriceMovement: number;\n dailyPipsChange: number;\n dailyPercentChange: number;\n dailyPercentChangeFromOpen: string;\n dailyPipsChangeFromOpen: number;\n displayPrecision: number;\n high: number;\n low: number;\n}\n\nexport interface LiveRatesHookReturnObject {\n update: LiveRatesHookMessage | null;\n error: LiveRatesErrorMessage | null;\n connectionError: boolean;\n setQuery: (query: LiveRatesProviderQuery) => void;\n}\n\nexport interface LiveRatesConnectionErrorMessage {\n messageType?: string;\n symbol: string;\n}\n\nexport interface LiveRatesTargetHookReturnObject {\n closeQuery: () => void;\n setQuery: (query: LiveRatesProviderQuery) => void;\n target: EventTarget | null;\n}\n\nexport interface LiveRatesMessageReturnObject {\n update: LiveRatesHookMessage | null;\n error: LiveRatesErrorMessage | null;\n connectionError: boolean;\n}\n\ninterface LiveRatesBaseMessage {\n messageType?: string;\n symbol: string;\n timestamp: string;\n}\nexport interface LiveRatesUpdateMessage extends LiveRatesBaseMessage {\n ask: number;\n bid: number;\n closingAsk: number;\n closingBid: number;\n openingAsk: number;\n openingBid: number;\n pipLocation: number;\n extraPrecision: number;\n low: number;\n high: number;\n}\n\nexport interface LiveRatesErrorMessage extends LiveRatesBaseMessage {\n error: string;\n}\n\nexport interface PriceChange {\n pipsChange: number;\n percentChange: number;\n priceMovement: number;\n askPriceMovement: number;\n bidPriceMovement: number;\n}\n\nexport interface PriceChangeFromOpen {\n percentChangeFromOpen: string;\n}\n\nexport interface PipsChangeFromOpen {\n pipsChangeFromOpen: number;\n}\n\nexport type Base64Decoder = (data: string) => string;\n\nexport type JsonParser = (data: string) => LiveRatesUpdateMessage;\n\nexport interface CalculatePriceChangeInput {\n pipLocation: number;\n extraPrecision: number;\n currentAsk: number;\n currentBid: number;\n prevAsk?: number;\n prevBid?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Locale } from '@oanda/mono-i18n';
|
|
2
2
|
const validateLocale = locale => {
|
|
3
|
-
const locales = ['en', 'zh', 'es', 'th'];
|
|
3
|
+
const locales = ['en', 'zh', 'es', 'th', 'fr', 'de', 'pt', 'it', 'zhCN', 'vi'];
|
|
4
4
|
return locales.includes(locale?.substring(0, 2));
|
|
5
5
|
};
|
|
6
6
|
const getLocale = locale => {
|
|
@@ -8,7 +8,13 @@ const getLocale = locale => {
|
|
|
8
8
|
en: Locale.en,
|
|
9
9
|
zh: Locale.zhTW,
|
|
10
10
|
es: Locale.es,
|
|
11
|
-
th: Locale.th
|
|
11
|
+
th: Locale.th,
|
|
12
|
+
fr: Locale.fr,
|
|
13
|
+
de: Locale.de,
|
|
14
|
+
pt: Locale.pt,
|
|
15
|
+
it: Locale.it,
|
|
16
|
+
['zh-CN']: Locale.zhCN,
|
|
17
|
+
vi: Locale.vi
|
|
12
18
|
};
|
|
13
19
|
return languageCodeDictionary[locale] || languageCodeDictionary.en;
|
|
14
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.js","names":["Locale","validateLocale","locale","locales","includes","substring","getLocale","languageCodeDictionary","en","zh","zhTW","es","th"],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\n\nconst validateLocale = (locale?: string) => {\n const locales = ['en'
|
|
1
|
+
{"version":3,"file":"getLocale.js","names":["Locale","validateLocale","locale","locales","includes","substring","getLocale","languageCodeDictionary","en","zh","zhTW","es","th","fr","de","pt","it","zhCN","vi"],"sources":["../../../src/utils/getLocale.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\n\nconst validateLocale = (locale?: string) => {\n const locales = [\n 'en',\n 'zh',\n 'es',\n 'th',\n 'fr',\n 'de',\n 'pt',\n 'it',\n 'zhCN',\n 'vi',\n ];\n\n return locales.includes(locale?.substring(0, 2)!);\n};\n\nconst getLocale = (locale?: string) => {\n const languageCodeDictionary: Record<string, Locale> = {\n en: Locale.en,\n zh: Locale.zhTW,\n es: Locale.es,\n th: Locale.th,\n fr: Locale.fr,\n de: Locale.de,\n pt: Locale.pt,\n it: Locale.it,\n ['zh-CN']: Locale.zhCN,\n vi: Locale.vi,\n };\n\n return languageCodeDictionary[locale!] || languageCodeDictionary.en;\n};\n\nexport { getLocale, validateLocale };\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,kBAAkB;AAEzC,MAAMC,cAAc,GAAIC,MAAe,IAAK;EAC1C,MAAMC,OAAO,GAAG,CACd,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,CACL;EAED,OAAOA,OAAO,CAACC,QAAQ,CAACF,MAAM,EAAEG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAE,CAAC;AACnD,CAAC;AAED,MAAMC,SAAS,GAAIJ,MAAe,IAAK;EACrC,MAAMK,sBAA8C,GAAG;IACrDC,EAAE,EAAER,MAAM,CAACQ,EAAE;IACbC,EAAE,EAAET,MAAM,CAACU,IAAI;IACfC,EAAE,EAAEX,MAAM,CAACW,EAAE;IACbC,EAAE,EAAEZ,MAAM,CAACY,EAAE;IACbC,EAAE,EAAEb,MAAM,CAACa,EAAE;IACbC,EAAE,EAAEd,MAAM,CAACc,EAAE;IACbC,EAAE,EAAEf,MAAM,CAACe,EAAE;IACbC,EAAE,EAAEhB,MAAM,CAACgB,EAAE;IACb,CAAC,OAAO,GAAGhB,MAAM,CAACiB,IAAI;IACtBC,EAAE,EAAElB,MAAM,CAACkB;EACb,CAAC;EAED,OAAOX,sBAAsB,CAACL,MAAM,CAAE,IAAIK,sBAAsB,CAACC,EAAE;AACrE,CAAC;AAED,SAASF,SAAS,EAAEL,cAAc","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
export type LiveRatesDataSource = 'V20' | 'MT5';
|
|
1
2
|
export interface LiveRatesProviderQuery {
|
|
2
3
|
instruments: string[];
|
|
3
4
|
division?: string;
|
|
4
|
-
dataSource?:
|
|
5
|
+
dataSource?: LiveRatesDataSource;
|
|
5
6
|
}
|
|
6
7
|
export interface LiveRatesProviderOptions {
|
|
7
8
|
divisionCode?: string;
|
|
8
|
-
dataSource?:
|
|
9
|
+
dataSource?: LiveRatesDataSource;
|
|
9
10
|
}
|
|
10
11
|
export interface LiveRatesConfig {
|
|
11
12
|
url: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-widget-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.222",
|
|
4
4
|
"description": "Labs Widget Common",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"tailwind-merge": "2.2.2",
|
|
22
22
|
"usehooks-ts": "3.0.2"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "f3f3b89244e07294747fcce5c3828da9a36ba6c0"
|
|
25
25
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
export type LiveRatesDataSource = 'V20' | 'MT5';
|
|
2
|
+
|
|
1
3
|
export interface LiveRatesProviderQuery {
|
|
2
4
|
instruments: string[];
|
|
3
5
|
division?: string;
|
|
4
|
-
dataSource?:
|
|
6
|
+
dataSource?: LiveRatesDataSource;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export interface LiveRatesProviderOptions {
|
|
8
10
|
divisionCode?: string;
|
|
9
|
-
dataSource?:
|
|
11
|
+
dataSource?: LiveRatesDataSource;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export interface LiveRatesConfig {
|
package/src/utils/getLocale.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { Locale } from '@oanda/mono-i18n';
|
|
2
2
|
|
|
3
3
|
const validateLocale = (locale?: string) => {
|
|
4
|
-
const locales = [
|
|
4
|
+
const locales = [
|
|
5
|
+
'en',
|
|
6
|
+
'zh',
|
|
7
|
+
'es',
|
|
8
|
+
'th',
|
|
9
|
+
'fr',
|
|
10
|
+
'de',
|
|
11
|
+
'pt',
|
|
12
|
+
'it',
|
|
13
|
+
'zhCN',
|
|
14
|
+
'vi',
|
|
15
|
+
];
|
|
5
16
|
|
|
6
17
|
return locales.includes(locale?.substring(0, 2)!);
|
|
7
18
|
};
|
|
@@ -12,6 +23,12 @@ const getLocale = (locale?: string) => {
|
|
|
12
23
|
zh: Locale.zhTW,
|
|
13
24
|
es: Locale.es,
|
|
14
25
|
th: Locale.th,
|
|
26
|
+
fr: Locale.fr,
|
|
27
|
+
de: Locale.de,
|
|
28
|
+
pt: Locale.pt,
|
|
29
|
+
it: Locale.it,
|
|
30
|
+
['zh-CN']: Locale.zhCN,
|
|
31
|
+
vi: Locale.vi,
|
|
15
32
|
};
|
|
16
33
|
|
|
17
34
|
return languageCodeDictionary[locale!] || languageCodeDictionary.en;
|
|
@@ -17,8 +17,8 @@ describe('validateLocale', () => {
|
|
|
17
17
|
expect(validateLocale('zh-tw')).toEqual(true);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it('should return false for
|
|
21
|
-
expect(validateLocale('
|
|
20
|
+
it('should return false for pl', () => {
|
|
21
|
+
expect(validateLocale('pl')).toEqual(false);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -44,7 +44,7 @@ describe('getLocale', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('should return en when locale not included in dictionary', () => {
|
|
47
|
-
expect(getLocale('
|
|
47
|
+
expect(getLocale('pl')).toEqual('en');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('should return en when locale is undefined', () => {
|