hevy-shared 1.0.960 → 1.0.962

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.
Files changed (88) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +21 -0
  3. package/.github/workflows/ci.yml +15 -0
  4. package/.github/workflows/npm-publish.yml +59 -0
  5. package/.github/workflows/pr-auto-assign.yml +15 -0
  6. package/.prettierrc.js +5 -0
  7. package/README.md +2 -17
  8. package/built/chat.d.ts +23 -25
  9. package/built/coachPlans.d.ts +1 -2
  10. package/built/coachPlans.js +2 -2
  11. package/built/filterExercises.d.ts +3 -19
  12. package/built/filterExercises.js +60 -72
  13. package/built/index.d.ts +304 -1140
  14. package/built/index.js +75 -269
  15. package/built/setIndicatorUtils.d.ts +3 -4
  16. package/built/setIndicatorUtils.js +1 -15
  17. package/built/tests/utils.test.js +0 -748
  18. package/built/tests/workoutVolume.test.js +49 -165
  19. package/built/units.d.ts +7 -14
  20. package/built/units.js +14 -24
  21. package/built/utils.d.ts +5 -192
  22. package/built/utils.js +85 -598
  23. package/built/websocket.d.ts +2 -14
  24. package/built/workoutVolume.d.ts +5 -24
  25. package/built/workoutVolume.js +34 -25
  26. package/jest.config.js +4 -0
  27. package/package.json +10 -32
  28. package/src/chat.ts +130 -0
  29. package/src/coachPlans.ts +57 -0
  30. package/src/constants.ts +14 -0
  31. package/src/filterExercises.ts +222 -0
  32. package/src/index.ts +1576 -0
  33. package/src/setIndicatorUtils.ts +137 -0
  34. package/src/tests/utils.test.ts +156 -0
  35. package/src/tests/workoutVolume.test.ts +93 -0
  36. package/src/units.ts +41 -0
  37. package/src/utils.ts +516 -0
  38. package/src/websocket.ts +36 -0
  39. package/src/workoutVolume.ts +175 -0
  40. package/tsconfig.json +70 -0
  41. package/built/API/APIClient.d.ts +0 -157
  42. package/built/API/APIClient.js +0 -381
  43. package/built/API/index.d.ts +0 -2
  44. package/built/API/index.js +0 -18
  45. package/built/API/types.d.ts +0 -38
  46. package/built/API/types.js +0 -18
  47. package/built/adjustEventTokens.d.ts +0 -16
  48. package/built/adjustEventTokens.js +0 -18
  49. package/built/adminPermissions.d.ts +0 -4
  50. package/built/adminPermissions.js +0 -22
  51. package/built/async.d.ts +0 -50
  52. package/built/async.js +0 -170
  53. package/built/cue.d.ts +0 -12
  54. package/built/cue.js +0 -22
  55. package/built/exerciseLocaleUtils.d.ts +0 -17
  56. package/built/exerciseLocaleUtils.js +0 -62
  57. package/built/hevyTrainer.d.ts +0 -250
  58. package/built/hevyTrainer.js +0 -676
  59. package/built/muscleHeatmaps.d.ts +0 -31
  60. package/built/muscleHeatmaps.js +0 -68
  61. package/built/muscleSplits.d.ts +0 -36
  62. package/built/muscleSplits.js +0 -100
  63. package/built/normalizedWorkoutUtils.d.ts +0 -88
  64. package/built/normalizedWorkoutUtils.js +0 -112
  65. package/built/notifications.d.ts +0 -215
  66. package/built/notifications.js +0 -9
  67. package/built/routineUtils.d.ts +0 -14
  68. package/built/routineUtils.js +0 -186
  69. package/built/schemas.d.ts +0 -6
  70. package/built/schemas.js +0 -12
  71. package/built/tests/async.test.d.ts +0 -1
  72. package/built/tests/async.test.js +0 -49
  73. package/built/tests/hevyTrainer.test.d.ts +0 -1
  74. package/built/tests/hevyTrainer.test.js +0 -1199
  75. package/built/tests/muscleSplit.test.d.ts +0 -1
  76. package/built/tests/muscleSplit.test.js +0 -153
  77. package/built/tests/routineUtils.test.d.ts +0 -1
  78. package/built/tests/routineUtils.test.js +0 -745
  79. package/built/tests/testUtils.d.ts +0 -85
  80. package/built/tests/testUtils.js +0 -319
  81. package/built/translations/index.d.ts +0 -2
  82. package/built/translations/index.js +0 -18
  83. package/built/translations/translationUtils.d.ts +0 -2
  84. package/built/translations/translationUtils.js +0 -61
  85. package/built/translations/types.d.ts +0 -8
  86. package/built/translations/types.js +0 -20
  87. package/built/typeUtils.d.ts +0 -70
  88. package/built/typeUtils.js +0 -55
@@ -1,85 +0,0 @@
1
- import { ExerciseType, RPE, RepRange, Routine, RoutineExercise, RoutineUpdate, RoutineUpdateExercise, SetType } from '..';
2
- import { NormalizedExercise, NormalizedWorkout } from '../normalizedWorkoutUtils';
3
- interface RoutineBuilderScope {
4
- nextExerciseId: () => string;
5
- }
6
- export declare class RoutineBuilder {
7
- private _exerciseId;
8
- private _exercises;
9
- constructor();
10
- private _scope;
11
- addExercise: (builderScope: (builder: RoutineExerciseBuilder) => RoutineExerciseBuilder) => this;
12
- build: () => Routine;
13
- }
14
- interface RoutineExerciseBuilderProps {
15
- exerciseTemplateId: string;
16
- exerciseType: ExerciseType;
17
- supersetId?: number | null;
18
- restSeconds?: number | null;
19
- inputModifier?: 'rep-range';
20
- }
21
- declare class RoutineExerciseBuilder {
22
- private _routineBuilderScope;
23
- private _exercise;
24
- constructor(routineBuilderScope: RoutineBuilderScope);
25
- setProps: (props: RoutineExerciseBuilderProps) => RoutineExerciseBuilder;
26
- private _addSet;
27
- addWeightRepsSet: (indicator: SetType, weight_kg?: number | null, reps?: number | null, rpe?: RPE | null) => this;
28
- addWeightRepRangeSet: (indicator: SetType, weight_kg?: number | null, rep_range?: RepRange, rpe?: RPE | null) => this;
29
- addRepsSet: (indicator: SetType, reps?: number | null, rpe?: RPE | null) => this;
30
- addRepRangeSet: (indicator: SetType, rep_range?: RepRange, rpe?: RPE | null) => this;
31
- addDistanceDurationSet: (indicator: SetType, distance_meters?: number | null, duration_seconds?: number | null) => this;
32
- addDurationSet: (indicator: SetType, duration_seconds?: number | null) => this;
33
- addShortDistanceWeightSet: (indicator: SetType, distance_meters?: number | null, weight_kg?: number | null) => this;
34
- build: () => RoutineExercise;
35
- }
36
- export declare class WorkoutBuilder {
37
- private _exercises;
38
- constructor();
39
- addExercise: (builderScope: (builder: WorkoutExerciseBuilder) => WorkoutExerciseBuilder) => this;
40
- build: () => NormalizedWorkout;
41
- }
42
- interface WorkoutExerciseBuilderProps {
43
- id: string;
44
- supersetId?: number;
45
- autoRestTimerSeconds?: number;
46
- }
47
- declare class WorkoutExerciseBuilder {
48
- private _exercise;
49
- constructor();
50
- setProps: (props: WorkoutExerciseBuilderProps) => WorkoutExerciseBuilder;
51
- private _addSet;
52
- addWeightRepsSet: (indicator: SetType, weight?: number, reps?: number, rpe?: RPE, completed?: boolean) => this;
53
- addRepsSet: (indicator: SetType, reps?: number, rpe?: RPE, completed?: boolean) => this;
54
- addDistanceDurationSet: (indicator: SetType, distance?: number, duration?: number) => this;
55
- addDurationSet: (indicator: SetType, duration?: number) => this;
56
- addShortDistanceWeightSet: (indicator: SetType, distance?: number, weight?: number) => this;
57
- build: () => NormalizedExercise;
58
- }
59
- export declare class RoutineUpdateBuilder {
60
- private _exercises;
61
- constructor();
62
- addExercise: (builderScope: (builder: RoutineUpdateExerciseBuilder) => RoutineUpdateExerciseBuilder) => this;
63
- build: () => RoutineUpdate;
64
- }
65
- interface RoutineUpdateExerciseBuilderProps {
66
- exerciseTemplateId: string;
67
- supersetId?: number;
68
- restSeconds?: number;
69
- inputModifier?: 'rep-range';
70
- }
71
- declare class RoutineUpdateExerciseBuilder {
72
- private _exercise;
73
- constructor();
74
- setProps: (props: RoutineUpdateExerciseBuilderProps) => RoutineUpdateExerciseBuilder;
75
- private _addSet;
76
- addWeightRepsSet: (indicator: SetType, weight_kg?: number | null, reps?: number | null, rpe?: RPE | null) => this;
77
- addWeightRepRangeSet: (indicator: SetType, weight_kg?: number | null, rep_range?: RepRange, rpe?: RPE | null) => this;
78
- addRepsSet: (indicator: SetType, reps?: number | null, rpe?: RPE | null) => this;
79
- addRepRangeSet: (indicator: SetType, rep_range?: RepRange, rpe?: RPE | null) => this;
80
- addDistanceDurationSet: (indicator: SetType, distance_meters?: number | null, duration_seconds?: number | null) => this;
81
- addDurationSet: (indicator: SetType, duration_seconds?: number | null) => this;
82
- addShortDistanceWeightSet: (indicator: SetType, distance_meters?: number | null, weight_kg?: number | null) => this;
83
- build: () => RoutineUpdateExercise;
84
- }
85
- export {};
@@ -1,319 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoutineUpdateBuilder = exports.WorkoutBuilder = exports.RoutineBuilder = void 0;
4
- const u8ToUuid = (id) => {
5
- const hex = (Number(id) || 0).toString(16);
6
- return '00000000-0000-4000-8000-000000000000'.slice(0, -hex.length) + hex;
7
- };
8
- class RoutineBuilder {
9
- constructor() {
10
- this._exerciseId = 1;
11
- this._scope = {
12
- nextExerciseId: () => u8ToUuid(this._exerciseId++),
13
- };
14
- this.addExercise = (builderScope) => {
15
- const exercise = builderScope(new RoutineExerciseBuilder(this._scope)).build();
16
- this._exercises.push(exercise);
17
- return this;
18
- };
19
- this.build = () => ({
20
- username: '',
21
- id: '',
22
- short_id: '',
23
- parent_routine_id: null,
24
- title: '',
25
- profile_pic: undefined,
26
- exercises: this._exercises,
27
- updated_at: '',
28
- index: null,
29
- folder_id: null,
30
- program_id: null,
31
- coach_id: null,
32
- notes: null,
33
- coach_force_rpe_enabled: false,
34
- hevy_trainer_program_id: null,
35
- created_at: '',
36
- });
37
- this._exercises = [];
38
- }
39
- }
40
- exports.RoutineBuilder = RoutineBuilder;
41
- class RoutineExerciseBuilder {
42
- constructor(routineBuilderScope) {
43
- this.setProps = (props) => {
44
- var _a, _b, _c;
45
- const exercise = Object.assign(Object.assign({}, this._exercise), { exercise_template_id: props.exerciseTemplateId, exercise_type: props.exerciseType, superset_id: (_a = props.supersetId) !== null && _a !== void 0 ? _a : null, rest_seconds: (_b = props.restSeconds) !== null && _b !== void 0 ? _b : null, input_modifier: (_c = props.inputModifier) !== null && _c !== void 0 ? _c : undefined });
46
- this._exercise = exercise;
47
- return this;
48
- };
49
- this._addSet = (props) => {
50
- const set = Object.assign({ index: this._exercise.sets.length }, props);
51
- this._exercise.sets.push(set);
52
- return this;
53
- };
54
- this.addWeightRepsSet = (indicator, weight_kg, reps, rpe) => this._addSet({
55
- indicator,
56
- weight_kg,
57
- reps,
58
- distance_meters: undefined,
59
- duration_seconds: undefined,
60
- rep_range: undefined,
61
- rpe,
62
- });
63
- this.addWeightRepRangeSet = (indicator, weight_kg, rep_range, rpe) => this._addSet({
64
- indicator,
65
- weight_kg,
66
- reps: undefined,
67
- distance_meters: undefined,
68
- duration_seconds: undefined,
69
- rep_range,
70
- rpe,
71
- });
72
- this.addRepsSet = (indicator, reps, rpe) => this._addSet({
73
- indicator,
74
- weight_kg: undefined,
75
- reps,
76
- distance_meters: undefined,
77
- duration_seconds: undefined,
78
- rep_range: undefined,
79
- rpe,
80
- });
81
- this.addRepRangeSet = (indicator, rep_range, rpe) => this._addSet({
82
- indicator,
83
- weight_kg: undefined,
84
- reps: undefined,
85
- distance_meters: undefined,
86
- duration_seconds: undefined,
87
- rep_range,
88
- rpe,
89
- });
90
- this.addDistanceDurationSet = (indicator, distance_meters, duration_seconds) => this._addSet({
91
- indicator,
92
- weight_kg: undefined,
93
- reps: undefined,
94
- distance_meters,
95
- duration_seconds,
96
- rep_range: undefined,
97
- rpe: undefined,
98
- });
99
- this.addDurationSet = (indicator, duration_seconds) => this._addSet({
100
- indicator,
101
- weight_kg: undefined,
102
- reps: undefined,
103
- distance_meters: undefined,
104
- duration_seconds,
105
- rep_range: undefined,
106
- rpe: undefined,
107
- });
108
- this.addShortDistanceWeightSet = (indicator, distance_meters, weight_kg) => this._addSet({
109
- indicator,
110
- weight_kg,
111
- reps: undefined,
112
- distance_meters,
113
- duration_seconds: undefined,
114
- rep_range: undefined,
115
- rpe: undefined,
116
- });
117
- this.build = () => this._exercise;
118
- this._routineBuilderScope = routineBuilderScope;
119
- const exercise = {
120
- exercise_template_id: '',
121
- id: this._routineBuilderScope.nextExerciseId(),
122
- username: 'tester',
123
- warmup_set_count: 0,
124
- normal_set_count: 0,
125
- title: '',
126
- muscle_group: 'chest',
127
- other_muscles: [],
128
- exercise_type: 'weight_reps',
129
- equipment_category: 'barbell',
130
- notes: '',
131
- sets: [],
132
- superset_id: null,
133
- rest_seconds: null,
134
- };
135
- this._exercise = exercise;
136
- }
137
- }
138
- class WorkoutBuilder {
139
- constructor() {
140
- this.addExercise = (builderScope) => {
141
- const exercise = builderScope(new WorkoutExerciseBuilder()).build();
142
- this._exercises.push(exercise);
143
- return this;
144
- };
145
- this.build = () => ({
146
- name: '',
147
- description: '',
148
- media: [],
149
- startTime: 0,
150
- timeEvents: [],
151
- exercises: this._exercises,
152
- trackWorkoutAsRoutine: false,
153
- appleWatch: false,
154
- wearosWatch: false,
155
- workoutVisibility: 'public',
156
- isWorkoutBiometricsPublic: true,
157
- trainerProgramId: undefined,
158
- shareTo: {
159
- strava: false,
160
- appleHealth: false,
161
- healthConnect: false,
162
- },
163
- clientId: '',
164
- });
165
- this._exercises = [];
166
- }
167
- }
168
- exports.WorkoutBuilder = WorkoutBuilder;
169
- class WorkoutExerciseBuilder {
170
- constructor() {
171
- this.setProps = (props) => {
172
- const exercise = Object.assign(Object.assign({}, this._exercise), { exerciseTemplateId: props.id, supersetId: props.supersetId, autoRestTimerSeconds: props.autoRestTimerSeconds });
173
- this._exercise = exercise;
174
- return this;
175
- };
176
- this._addSet = (props) => {
177
- var _a;
178
- const set = Object.assign(Object.assign({ index: this._exercise.sets.length }, props), { completed: (_a = props.completed) !== null && _a !== void 0 ? _a : true });
179
- this._exercise.sets.push(set);
180
- return this;
181
- };
182
- this.addWeightRepsSet = (indicator, weight, reps, rpe, completed) => this._addSet({ indicator, weight, reps, rpe, completed });
183
- this.addRepsSet = (indicator, reps, rpe, completed) => this._addSet({ indicator, reps, rpe, completed });
184
- this.addDistanceDurationSet = (indicator, distance, duration) => this._addSet({
185
- indicator,
186
- distance,
187
- duration,
188
- });
189
- this.addDurationSet = (indicator, duration) => this._addSet({
190
- indicator,
191
- duration,
192
- });
193
- this.addShortDistanceWeightSet = (indicator, distance, weight) => this._addSet({
194
- indicator,
195
- weight,
196
- distance,
197
- });
198
- this.build = () => this._exercise;
199
- const exercise = {
200
- exerciseTemplateId: '',
201
- supersetId: undefined,
202
- autoRestTimerSeconds: undefined,
203
- title: '',
204
- notes: '',
205
- routineNotes: '',
206
- volumeDoublingEnabled: false,
207
- sets: [],
208
- };
209
- this._exercise = exercise;
210
- }
211
- }
212
- class RoutineUpdateBuilder {
213
- constructor() {
214
- this.addExercise = (builderScope) => {
215
- const exercise = builderScope(new RoutineUpdateExerciseBuilder()).build();
216
- this._exercises.push(exercise);
217
- return this;
218
- };
219
- this.build = () => ({
220
- title: '',
221
- exercises: this._exercises,
222
- parent_routine_id: undefined,
223
- folder_id: null,
224
- index: 0,
225
- program_id: null,
226
- notes: null,
227
- coach_force_rpe_enabled: false,
228
- });
229
- this._exercises = [];
230
- }
231
- }
232
- exports.RoutineUpdateBuilder = RoutineUpdateBuilder;
233
- class RoutineUpdateExerciseBuilder {
234
- constructor() {
235
- this.setProps = (props) => {
236
- const exercise = Object.assign(Object.assign({}, this._exercise), { exercise_template_id: props.exerciseTemplateId, superset_id: props.supersetId, rest_seconds: props.restSeconds, input_modifier: props.inputModifier });
237
- this._exercise = exercise;
238
- return this;
239
- };
240
- this._addSet = (props) => {
241
- const set = Object.assign({ index: this._exercise.sets.length }, props);
242
- this._exercise.sets.push(set);
243
- return this;
244
- };
245
- this.addWeightRepsSet = (indicator, weight_kg, reps, rpe) => this._addSet({
246
- indicator,
247
- weight_kg,
248
- reps,
249
- distance_meters: undefined,
250
- duration_seconds: undefined,
251
- rpe,
252
- rep_range: undefined,
253
- });
254
- this.addWeightRepRangeSet = (indicator, weight_kg, rep_range, rpe) => this._addSet({
255
- indicator,
256
- weight_kg,
257
- reps: undefined,
258
- distance_meters: undefined,
259
- duration_seconds: undefined,
260
- rep_range,
261
- rpe,
262
- });
263
- this.addRepsSet = (indicator, reps, rpe) => this._addSet({
264
- indicator,
265
- weight_kg: undefined,
266
- reps,
267
- distance_meters: undefined,
268
- duration_seconds: undefined,
269
- rep_range: undefined,
270
- rpe,
271
- });
272
- this.addRepRangeSet = (indicator, rep_range, rpe) => this._addSet({
273
- indicator,
274
- weight_kg: undefined,
275
- reps: undefined,
276
- distance_meters: undefined,
277
- duration_seconds: undefined,
278
- rep_range,
279
- rpe,
280
- });
281
- this.addDistanceDurationSet = (indicator, distance_meters, duration_seconds) => this._addSet({
282
- indicator,
283
- weight_kg: undefined,
284
- reps: undefined,
285
- distance_meters,
286
- duration_seconds,
287
- rpe: undefined,
288
- rep_range: undefined,
289
- });
290
- this.addDurationSet = (indicator, duration_seconds) => this._addSet({
291
- indicator,
292
- weight_kg: undefined,
293
- reps: undefined,
294
- distance_meters: undefined,
295
- duration_seconds,
296
- rpe: undefined,
297
- rep_range: undefined,
298
- });
299
- this.addShortDistanceWeightSet = (indicator, distance_meters, weight_kg) => this._addSet({
300
- indicator,
301
- weight_kg,
302
- reps: undefined,
303
- distance_meters,
304
- duration_seconds: undefined,
305
- rpe: undefined,
306
- rep_range: undefined,
307
- });
308
- this.build = () => this._exercise;
309
- const exercise = {
310
- exercise_template_id: '',
311
- superset_id: undefined,
312
- rest_seconds: undefined,
313
- notes: '',
314
- input_modifier: undefined,
315
- sets: [],
316
- };
317
- this._exercise = exercise;
318
- }
319
- }
@@ -1,2 +0,0 @@
1
- export * from './translationUtils';
2
- export * from './types';
@@ -1,18 +0,0 @@
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);
@@ -1,2 +0,0 @@
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)[];
@@ -1,61 +0,0 @@
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
- }
@@ -1,8 +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 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>;
@@ -1,20 +0,0 @@
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;
@@ -1,70 +0,0 @@
1
- export type Lookup<T extends readonly unknown[]> = T[number];
2
- export declare const isInArray: <T, ReadonlyArrayOfT extends readonly T[]>(value: T, array: ReadonlyArrayOfT) => value is Lookup<ReadonlyArrayOfT>;
3
- export type DeepReadonly<T> = {
4
- readonly [P in keyof T]: T[P] extends (...args: any[]) => any ? T[P] : DeepReadonly<T[P]>;
5
- };
6
- export declare const exhaustiveTypeCheck: (_: never) => undefined;
7
- export declare const exhaustiveTypeException: (type: never) => Error;
8
- export type Some<T> = {
9
- hasValue: true;
10
- value: T;
11
- } | {
12
- hasValue: false;
13
- };
14
- /**
15
- * Please use this instead of using the 'as' keyword directly, so it's easier
16
- * to screen for these ticking time bombs in the code from time to time. Or
17
- * better yet, just implement validation for your types straight away.
18
- *
19
- * If you would think twice before using this, then by pure logic you should
20
- * likewise also think twice - no, make it at least thrice - before making the
21
- * decision to opt into undefined behaviour by letting the compile-time TS type
22
- * diverge from the runtime JS value.
23
- *
24
- * This is your last chance to turn back.
25
- *
26
- * You have been warned.
27
- *
28
- * @example
29
- * ```ts
30
- * const someData = await AsyncStorage.getItem(SOME_KEY);
31
- * const parsedData = JSON.parse(someData);
32
- * const data = dangerousUncheckedTypeCast<SomeDataType>(parsedData);
33
- * ```
34
- */
35
- export declare const dangerousUncheckedTypeCast: <T = void, U extends T = T>(value: unknown) => U;
36
- /**
37
- * Wrapper for TypeScript's non-nullish assertion operator (`!`). Use this
38
- * instead of the operator directly so it's easier to spot. And, again, only
39
- * use this if you 100% know what you're doing. If you're not sure, then don't!
40
- */
41
- export declare const assertNonNullish: <T>(value: T) => T & {};
42
- /**
43
- * What it's not: "I don't know what type this value may be."
44
- * What it is: "I don't **CARE** about the type of this value."
45
- * What it is: "Disable the type system for this variable."
46
- *
47
- * Alias for `any` that makes it more clear what's going on. Avoid using this,
48
- * and absolutely avoid using `any` directly even harder! Instead, you may want
49
- * to use one of the following:
50
- *
51
- * - `unknown` // any value, can be nullish or not - need to use type guards
52
- * - `unknown[]` // same as above, but we know it's an array of these unknowns,
53
- * // so we allow array functions to be used on it
54
- * - `object` // any value where `typeof value === 'object'` - except `null`
55
- * - `{}` // any non-nullish value, object or not; ignore the lint error
56
- * - `never` // no value; not `undefined` or `null`, but _unreachable code_
57
- */
58
- export type UNSAFE_Untyped = any;
59
- /**
60
- * Safer alternative to `JSON.parse`. Returns `unknown` instead of `any`.
61
- *
62
- * @see JSON.parse
63
- */
64
- export declare const parseJSON: (...args: Parameters<typeof JSON.parse>) => unknown;
65
- /**
66
- * Same as `array[index]`, but adds `undefined` to the return type. Maybe some
67
- * fine day we will enable `noUncheckedIndexedAccess` in all our projects. 🤞
68
- */
69
- export declare const typeSafeIndex: <T>(array: T[], index: number) => T | undefined;
70
- export declare const TODO: (message?: string) => never;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TODO = exports.typeSafeIndex = exports.parseJSON = exports.assertNonNullish = exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
4
- const isInArray = (value, array) => array.includes(value);
5
- exports.isInArray = isInArray;
6
- const exhaustiveTypeCheck = (_) => void _;
7
- exports.exhaustiveTypeCheck = exhaustiveTypeCheck;
8
- const exhaustiveTypeException = (type) => new Error(`Assertion failed: "unreachable" code reached with unknown type: ${typeof type === 'object' ? JSON.stringify(type) : String(type)}`);
9
- exports.exhaustiveTypeException = exhaustiveTypeException;
10
- /**
11
- * Please use this instead of using the 'as' keyword directly, so it's easier
12
- * to screen for these ticking time bombs in the code from time to time. Or
13
- * better yet, just implement validation for your types straight away.
14
- *
15
- * If you would think twice before using this, then by pure logic you should
16
- * likewise also think twice - no, make it at least thrice - before making the
17
- * decision to opt into undefined behaviour by letting the compile-time TS type
18
- * diverge from the runtime JS value.
19
- *
20
- * This is your last chance to turn back.
21
- *
22
- * You have been warned.
23
- *
24
- * @example
25
- * ```ts
26
- * const someData = await AsyncStorage.getItem(SOME_KEY);
27
- * const parsedData = JSON.parse(someData);
28
- * const data = dangerousUncheckedTypeCast<SomeDataType>(parsedData);
29
- * ```
30
- */
31
- const dangerousUncheckedTypeCast = (value) => value;
32
- exports.dangerousUncheckedTypeCast = dangerousUncheckedTypeCast;
33
- /**
34
- * Wrapper for TypeScript's non-nullish assertion operator (`!`). Use this
35
- * instead of the operator directly so it's easier to spot. And, again, only
36
- * use this if you 100% know what you're doing. If you're not sure, then don't!
37
- */
38
- const assertNonNullish = (value) => value;
39
- exports.assertNonNullish = assertNonNullish;
40
- /**
41
- * Safer alternative to `JSON.parse`. Returns `unknown` instead of `any`.
42
- *
43
- * @see JSON.parse
44
- */
45
- exports.parseJSON = JSON.parse;
46
- /**
47
- * Same as `array[index]`, but adds `undefined` to the return type. Maybe some
48
- * fine day we will enable `noUncheckedIndexedAccess` in all our projects. 🤞
49
- */
50
- const typeSafeIndex = (array, index) => array[index];
51
- exports.typeSafeIndex = typeSafeIndex;
52
- const TODO = (message) => {
53
- throw new Error(message !== null && message !== void 0 ? message : 'Not implemented');
54
- };
55
- exports.TODO = TODO;