@tma.js/sdk 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tma.js/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "TypeScript Source Development Kit for Telegram Mini Apps client application.",
5
5
  "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
6
6
  "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
@@ -24,8 +24,6 @@ interface Methods {
24
24
  saveStorageValue: { key: string; value: string };
25
25
  }
26
26
 
27
- const stringArray = array().of(string());
28
-
29
27
  function objectFromKeys<K extends string, V>(keys: K[], value: V): Record<K, V> {
30
28
  return keys.reduce<Record<K, V>>((acc, key) => {
31
29
  acc[key] = value;
@@ -93,7 +91,7 @@ export class CloudStorage {
93
91
  async getKeys(options?: WiredRequestOptions): Promise<string[]> {
94
92
  const result = await this.invokeCustomMethod('getStorageKeys', {}, options);
95
93
 
96
- return stringArray.parse(result);
94
+ return array().of(string()).parse(result);
97
95
  }
98
96
 
99
97
  /**
@@ -1,13 +1,11 @@
1
1
  import { number } from './number.js';
2
2
  import { createValueParserGenerator } from '../createValueParserGenerator.js';
3
3
 
4
- const num = number();
5
-
6
4
  /**
7
5
  * Returns parser to parse value as Date.
8
6
  */
9
7
  export const date = createValueParserGenerator<Date>((value) => (
10
8
  value instanceof Date
11
9
  ? value
12
- : new Date(num.parse(value) * 1000)
10
+ : new Date(number().parse(value) * 1000)
13
11
  ), 'Date');
@@ -4,9 +4,7 @@ import type { RGB } from '~/colors/index.js';
4
4
  import { string } from './string.js';
5
5
  import { createValueParserGenerator } from '../createValueParserGenerator.js';
6
6
 
7
- const str = string();
8
-
9
7
  /**
10
8
  * Returns parser to parse value as RGB color.
11
9
  */
12
- export const rgb = createValueParserGenerator<RGB>((value) => toRGB(str.parse(value)), 'rgb');
10
+ export const rgb = createValueParserGenerator<RGB>((value) => toRGB(string().parse(value)), 'rgb');
@@ -7,14 +7,16 @@ import {
7
7
  import { keyToLocal } from './keys.js';
8
8
  import type { ThemeParamsParsed } from './types.js';
9
9
 
10
- const rgbOptional = rgb().optional();
11
-
12
10
  export const themeParamsParser = createValueParserGenerator<ThemeParamsParsed>(
13
- (value) => Object
14
- .entries(toRecord(value))
15
- .reduce<ThemeParamsParsed>((acc, [k, v]) => {
16
- acc[keyToLocal(k)] = rgbOptional.parse(v);
17
- return acc;
18
- }, {}),
11
+ (value) => {
12
+ const rgbOptional = rgb().optional();
13
+
14
+ return Object
15
+ .entries(toRecord(value))
16
+ .reduce<ThemeParamsParsed>((acc, [k, v]) => {
17
+ acc[keyToLocal(k)] = rgbOptional.parse(v);
18
+ return acc;
19
+ }, {});
20
+ },
19
21
  'ThemeParams',
20
22
  );