hevy-shared 1.0.945 → 1.0.947
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/built/adminPermissions.d.ts +1 -1
- package/built/adminPermissions.js +1 -1
- package/built/filterExercises.d.ts +2 -1
- package/built/index.d.ts +2 -2
- package/built/index.js +1 -1
- package/built/translations/index.d.ts +2 -0
- package/built/translations/index.js +18 -0
- package/built/translations/translationUtils.d.ts +2 -0
- package/built/translations/translationUtils.js +61 -0
- package/built/translations/types.d.ts +8 -0
- package/built/translations/types.js +20 -0
- package/package.json +6 -2
- package/built/translationUtils.d.ts +0 -5
- package/built/translationUtils.js +0 -30
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Lookup } from './typeUtils';
|
|
2
|
-
export declare const AdminPermissions: readonly ["become_user", "
|
|
2
|
+
export declare const AdminPermissions: readonly ["become_user", "blacklists", "featured_users", "feature_flags", "hevy_trainer", "user_account_management", "import_strong_csv", "community_management", "user_app_logs", "backend_maintenance"];
|
|
3
3
|
export type AdminPermission = Lookup<typeof AdminPermissions>;
|
|
4
4
|
export declare const isAdminPermission: (permission?: any) => permission is AdminPermission;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EquipmentFilter,
|
|
1
|
+
import { EquipmentFilter, LibraryExercise, MuscleGroupFilter, CustomExercise } from './index';
|
|
2
|
+
import { Language } from './translations';
|
|
2
3
|
export interface SearchableLibraryExercise extends LibraryExercise {
|
|
3
4
|
localized_muscle_group_name: string;
|
|
4
5
|
}
|
package/built/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkoutDurationMinutes } from './hevyTrainer';
|
|
2
|
-
import { Language } from './
|
|
2
|
+
import { Language } from './translations';
|
|
3
3
|
import { Lookup } from './typeUtils';
|
|
4
4
|
export * from './constants';
|
|
5
5
|
export * from './utils';
|
|
@@ -21,7 +21,7 @@ export * from './async';
|
|
|
21
21
|
export * from './adminPermissions';
|
|
22
22
|
export * from './adjustEventTokens';
|
|
23
23
|
export * from './hevyTrainer';
|
|
24
|
-
export * from './
|
|
24
|
+
export * from './translations';
|
|
25
25
|
export type WeightUnit = 'kg' | 'lbs';
|
|
26
26
|
export declare const isWeightUnit: (x: string) => x is WeightUnit;
|
|
27
27
|
export type DistanceUnit = 'kilometers' | 'miles';
|
package/built/index.js
CHANGED
|
@@ -37,7 +37,7 @@ __exportStar(require("./async"), exports);
|
|
|
37
37
|
__exportStar(require("./adminPermissions"), exports);
|
|
38
38
|
__exportStar(require("./adjustEventTokens"), exports);
|
|
39
39
|
__exportStar(require("./hevyTrainer"), exports);
|
|
40
|
-
__exportStar(require("./
|
|
40
|
+
__exportStar(require("./translations"), exports);
|
|
41
41
|
const isWeightUnit = (x) => {
|
|
42
42
|
return x === 'kg' || x === 'lbs';
|
|
43
43
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./translationUtils"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { PositionalTextParams, NamedTextParams, PositionalReactParams, NamedReactParams } from './types';
|
|
2
|
+
export declare function interpolate<T extends string>(str: string, params: PositionalTextParams | NamedTextParams<T> | PositionalReactParams | NamedReactParams<T>): string | (string | number)[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interpolate = interpolate;
|
|
4
|
+
const hasReact = (params) => Object.values(params).some((v) => v !== null &&
|
|
5
|
+
v !== undefined &&
|
|
6
|
+
typeof v !== 'string' &&
|
|
7
|
+
typeof v !== 'number' &&
|
|
8
|
+
typeof v !== 'boolean');
|
|
9
|
+
function interpolate(str, params) {
|
|
10
|
+
if (Array.isArray(params)) {
|
|
11
|
+
const positionalParams = params;
|
|
12
|
+
const hasReactParams = hasReact(positionalParams);
|
|
13
|
+
const re = () => /(%s)/g;
|
|
14
|
+
let i = 0;
|
|
15
|
+
if (hasReactParams) {
|
|
16
|
+
return str
|
|
17
|
+
.split(/(%s)/g)
|
|
18
|
+
.filter((w) => !!w)
|
|
19
|
+
.map((w) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const [, key] = (_a = re().exec(w)) !== null && _a !== void 0 ? _a : [];
|
|
22
|
+
if (!key) {
|
|
23
|
+
return w;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return ((_b = positionalParams[i++]) !== null && _b !== void 0 ? _b : (console.error(`Missing param ${i} in the string "${str}"`), w));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return str.replace(re(), (_) => { var _a; return String((_a = positionalParams[i++]) !== null && _a !== void 0 ? _a : _); });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const namedParams = params;
|
|
36
|
+
const hasReactParams = hasReact(namedParams);
|
|
37
|
+
const re = () => /%{([^}]*)}/g;
|
|
38
|
+
if (hasReactParams) {
|
|
39
|
+
return str
|
|
40
|
+
.split(/(%{[^}]*})/g)
|
|
41
|
+
.filter((w) => !!w)
|
|
42
|
+
.map((w) => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const [, key] = (_a = re().exec(w)) !== null && _a !== void 0 ? _a : [];
|
|
45
|
+
if (!key) {
|
|
46
|
+
if (key === '') {
|
|
47
|
+
console.error(`Empty param in the string "${str}"`);
|
|
48
|
+
}
|
|
49
|
+
return w;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return ((_b = namedParams[key]) !== null && _b !== void 0 ? _b : (console.error(`Missing param "${key}" in the string "${str}"`),
|
|
53
|
+
w));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return str.replace(re(), (_, key) => { var _a; return String((_a = namedParams[key]) !== null && _a !== void 0 ? _a : _); });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Lookup } from '../typeUtils';
|
|
2
|
+
export declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "pt", "tr", "zh_CN", "zh_TW", "ru", "ja", "ko"];
|
|
3
|
+
export type Language = Lookup<typeof supportedLanguages>;
|
|
4
|
+
export declare const isLanguage: (x: string) => x is Language;
|
|
5
|
+
export type PositionalTextParams = (string | number)[];
|
|
6
|
+
export type NamedTextParams<T extends string> = Record<T, string | number>;
|
|
7
|
+
export type PositionalReactParams = (string | number | object)[];
|
|
8
|
+
export type NamedReactParams<T extends string> = Record<T, string | number | object>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLanguage = exports.supportedLanguages = void 0;
|
|
4
|
+
const typeUtils_1 = require("../typeUtils");
|
|
5
|
+
exports.supportedLanguages = [
|
|
6
|
+
'en',
|
|
7
|
+
'es',
|
|
8
|
+
'de',
|
|
9
|
+
'fr',
|
|
10
|
+
'it',
|
|
11
|
+
'pt',
|
|
12
|
+
'tr',
|
|
13
|
+
'zh_CN',
|
|
14
|
+
'zh_TW',
|
|
15
|
+
'ru',
|
|
16
|
+
'ja',
|
|
17
|
+
'ko',
|
|
18
|
+
];
|
|
19
|
+
const isLanguage = (x) => (0, typeUtils_1.isInArray)(x, exports.supportedLanguages);
|
|
20
|
+
exports.isLanguage = isLanguage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hevy-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.947",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"types": "built/index.d.ts",
|
|
@@ -17,12 +17,16 @@
|
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./built/index.js",
|
|
20
|
-
"./API": "./built/API/index.js"
|
|
20
|
+
"./API": "./built/API/index.js",
|
|
21
|
+
"./translations": "./built/translations/index.js"
|
|
21
22
|
},
|
|
22
23
|
"typesVersions": {
|
|
23
24
|
"*": {
|
|
24
25
|
"API": [
|
|
25
26
|
"built/API/index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"translations": [
|
|
29
|
+
"built/translations/index.d.ts"
|
|
26
30
|
]
|
|
27
31
|
}
|
|
28
32
|
},
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Lookup } from './typeUtils';
|
|
2
|
-
export declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "pt", "tr", "zh_CN", "zh_TW", "ru", "ja", "ko"];
|
|
3
|
-
export type Language = Lookup<typeof supportedLanguages>;
|
|
4
|
-
export declare const isLanguage: (x: string) => x is Language;
|
|
5
|
-
export declare const interpolate: (str: string, params: any[]) => string;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.interpolate = exports.isLanguage = exports.supportedLanguages = void 0;
|
|
4
|
-
const typeUtils_1 = require("./typeUtils");
|
|
5
|
-
exports.supportedLanguages = [
|
|
6
|
-
'en',
|
|
7
|
-
'es',
|
|
8
|
-
'de',
|
|
9
|
-
'fr',
|
|
10
|
-
'it',
|
|
11
|
-
'pt',
|
|
12
|
-
'tr',
|
|
13
|
-
'zh_CN',
|
|
14
|
-
'zh_TW',
|
|
15
|
-
'ru',
|
|
16
|
-
'ja',
|
|
17
|
-
'ko',
|
|
18
|
-
];
|
|
19
|
-
const isLanguage = (x) => (0, typeUtils_1.isInArray)(x, exports.supportedLanguages);
|
|
20
|
-
exports.isLanguage = isLanguage;
|
|
21
|
-
const interpolate = (str, params) => {
|
|
22
|
-
let i = 0;
|
|
23
|
-
return str
|
|
24
|
-
.replace(/%s/g, () => {
|
|
25
|
-
i += 1;
|
|
26
|
-
return params[i - 1];
|
|
27
|
-
})
|
|
28
|
-
.replace(/%{([\w-]*)}/g, (__, key) => params[0][key]);
|
|
29
|
-
};
|
|
30
|
-
exports.interpolate = interpolate;
|