@jsb188/app 1.1.10 → 1.1.11

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 (63) hide show
  1. package/package.json +54 -45
  2. package/src/constants/agent.ts +58 -25
  3. package/src/constants/app.ts +18 -14
  4. package/src/constants/billing.ts +92 -92
  5. package/src/constants/emoji.ts +9144 -8936
  6. package/src/constants/other.ts +1 -5
  7. package/src/constants/user.ts +16 -25
  8. package/src/constants/wsActions.ts +35 -0
  9. package/src/i18n/account.ts +129 -107
  10. package/src/i18n/agent.ts +63 -43
  11. package/src/i18n/agentDoc.ts +110 -0
  12. package/src/i18n/app.ts +101 -91
  13. package/src/i18n/auth.ts +119 -102
  14. package/src/i18n/billing.ts +73 -78
  15. package/src/i18n/campaign.ts +217 -0
  16. package/src/i18n/country.ts +248 -248
  17. package/src/i18n/datetime.ts +26 -26
  18. package/src/i18n/error.ts +428 -182
  19. package/src/i18n/field_docs.ts +28 -0
  20. package/src/i18n/form.ts +464 -344
  21. package/src/i18n/index.ts +25 -18
  22. package/src/i18n/log.ts +53 -213
  23. package/src/i18n/memory.ts +39 -0
  24. package/src/i18n/message.ts +3 -4
  25. package/src/i18n/note.ts +17 -0
  26. package/src/i18n/org.ts +115 -109
  27. package/src/i18n/sheet.ts +376 -4
  28. package/src/i18n/workflow.ts +70 -23
  29. package/src/main.ts +66 -62
  30. package/src/platform.ts +25 -24
  31. package/src/types/ai.d.ts +33 -23
  32. package/src/types/app.d.ts +95 -37
  33. package/src/types/auth.d.ts +66 -40
  34. package/src/types/console.d.ts +3 -0
  35. package/src/types/form.d.ts +65 -61
  36. package/src/types/other.d.ts +6 -6
  37. package/src/types.d.ts +12 -14
  38. package/src/utils/account.ts +64 -58
  39. package/src/utils/api.ts +280 -77
  40. package/src/utils/authSession.ts +24 -0
  41. package/src/utils/billing.ts +110 -103
  42. package/src/utils/color.ts +202 -0
  43. package/src/utils/cron.ts +49 -18
  44. package/src/utils/datetime.ts +255 -103
  45. package/src/utils/emoji.ts +107 -84
  46. package/src/utils/expression.ts +867 -0
  47. package/src/utils/interval.ts +80 -0
  48. package/src/utils/logic.ts +209 -36
  49. package/src/utils/managedSession.ts +34 -0
  50. package/src/utils/managedSessionBff.test.ts +60 -0
  51. package/src/utils/managedSessionBff.ts +117 -0
  52. package/src/utils/number.ts +60 -32
  53. package/src/utils/object.ts +198 -30
  54. package/src/utils/promise.ts +27 -0
  55. package/src/utils/queryReset.ts +179 -0
  56. package/src/utils/recurringTask.ts +60 -0
  57. package/src/utils/schema.ts +293 -0
  58. package/src/utils/string.test.ts +220 -208
  59. package/src/utils/string.ts +471 -438
  60. package/src/utils/timeZone.ts +309 -851
  61. package/src/utils/url_client.ts +73 -69
  62. package/tsconfig.json +10 -10
  63. package/src/i18n/product.ts +0 -76
@@ -1,28 +1,31 @@
1
- import { SUBSCRIPTION_CATALOG, SUBSCRIPTION_CATALOG_TEST } from '../constants/billing.ts';
1
+ import {
2
+ SUBSCRIPTION_CATALOG,
3
+ SUBSCRIPTION_CATALOG_TEST,
4
+ } from '../constants/billing.ts';
2
5
 
3
6
  /**
4
7
  * Types
5
8
  */
6
9
 
7
10
  type SubscriptionCatalogItem = {
8
- group: string;
9
- notReady: boolean;
10
- priceLabel: string | null;
11
- startingPrice: number;
12
- currency: string;
13
- recurringInterval: string;
14
- recurringIntervalCount: number;
11
+ group: string;
12
+ notReady: boolean;
13
+ priceLabel: string | null;
14
+ startingPrice: number;
15
+ currency: string;
16
+ recurringInterval: string;
17
+ recurringIntervalCount: number;
15
18
  };
16
19
 
17
20
  type SubscriptionPricingOption = {
18
- id: string;
19
- group: string;
20
- notReady: boolean;
21
- priceLabel: string;
22
- price: number;
23
- currency: string;
24
- recurringInterval: string;
25
- recurringIntervalCount: number;
21
+ id: string;
22
+ group: string;
23
+ notReady: boolean;
24
+ priceLabel: string;
25
+ price: number;
26
+ currency: string;
27
+ recurringInterval: string;
28
+ recurringIntervalCount: number;
26
29
  };
27
30
 
28
31
  /**
@@ -30,105 +33,109 @@ type SubscriptionPricingOption = {
30
33
  */
31
34
 
32
35
  function getSubscriptionCatalog(isDev = false) {
33
- return isDev ? SUBSCRIPTION_CATALOG_TEST : SUBSCRIPTION_CATALOG;
36
+ return isDev ? SUBSCRIPTION_CATALOG_TEST : SUBSCRIPTION_CATALOG;
34
37
  }
35
38
 
36
39
  /**
37
40
  * Get list of subscription catalogs
38
41
  */
39
42
 
40
- export function getPlatformSubscriptionCatalog(platformProducts?: any[], isDev?: boolean): SubscriptionCatalogItem[] {
41
-
42
- return getSubscriptionCatalog(isDev).map((sub) => {
43
- const [groupName, stripeProductId, stripePriceId] = sub;
44
- const product = platformProducts?.find((pr: any) => pr.id === stripeProductId);
45
- const startingPrice = product?.prices?.find((pc: any) => pc.id === stripePriceId);
46
-
47
- if (!startingPrice) {
48
- // Data is not ready; or the Stripe API Key used by the server is _not_ the live key
49
- return {
50
- group: groupName,
51
- notReady: true,
52
- priceLabel: null,
53
- startingPrice: 0,
54
- currency: 'USD',
55
- recurringInterval: 'month',
56
- recurringIntervalCount: 1
57
- };
58
- }
59
-
60
- // Add locale here later
61
- const locale = undefined;
62
-
63
- const priceLabel = (
64
- startingPrice.unitAmount / 100
65
- ).toLocaleString(locale, {
66
- style: 'currency',
67
- currency: startingPrice.currency,
68
- });
69
-
70
- return {
71
- group: groupName,
72
- notReady: false,
73
- priceLabel,
74
- startingPrice: startingPrice.unitAmount,
75
- currency: startingPrice.currency,
76
- recurringInterval: startingPrice.recurringInterval,
77
- recurringIntervalCount: startingPrice.recurringIntervalCount,
78
- };
79
- });
43
+ export function getPlatformSubscriptionCatalog(
44
+ platformProducts?: any[],
45
+ isDev?: boolean,
46
+ ): SubscriptionCatalogItem[] {
47
+ return getSubscriptionCatalog(isDev).map((sub) => {
48
+ const [groupName, stripeProductId, stripePriceId] = sub;
49
+ const product = platformProducts?.find(
50
+ (pr: any) => pr.id === stripeProductId,
51
+ );
52
+ const startingPrice = product?.prices?.find(
53
+ (pc: any) => pc.id === stripePriceId,
54
+ );
55
+
56
+ if (!startingPrice) {
57
+ // Data is not ready; or the Stripe API Key used by the server is _not_ the live key
58
+ return {
59
+ group: groupName,
60
+ notReady: true,
61
+ priceLabel: null,
62
+ startingPrice: 0,
63
+ currency: 'USD',
64
+ recurringInterval: 'month',
65
+ recurringIntervalCount: 1,
66
+ };
67
+ }
68
+
69
+ // Add locale here later
70
+ const locale = undefined;
71
+
72
+ const priceLabel = (startingPrice.unitAmount / 100).toLocaleString(locale, {
73
+ style: 'currency',
74
+ currency: startingPrice.currency,
75
+ });
76
+
77
+ return {
78
+ group: groupName,
79
+ notReady: false,
80
+ priceLabel,
81
+ startingPrice: startingPrice.unitAmount,
82
+ currency: startingPrice.currency,
83
+ recurringInterval: startingPrice.recurringInterval,
84
+ recurringIntervalCount: startingPrice.recurringIntervalCount,
85
+ };
86
+ });
80
87
  }
81
88
 
82
-
83
89
  /**
84
90
  * Get list of subscription options for each tier
85
91
  */
86
92
 
87
93
  export function getPlatformSubscriptionPricingOptions(
88
- platformProducts?: any[],
89
- subGroup?: 'PERKS' | 'PLUS' | 'PRO' | 'COINS',
90
- isDev?: boolean
94
+ platformProducts?: any[],
95
+ subGroup?: 'PERKS' | 'PLUS' | 'PRO' | 'COINS',
96
+ isDev?: boolean,
91
97
  ): SubscriptionPricingOption[] {
92
-
93
- const catalogItem = getSubscriptionCatalog(isDev).find((item: any) => item[0] === subGroup);
94
- if (!catalogItem) {
95
- console.warn('Unknown subscription group: ' + subGroup);
96
- return [];
97
- }
98
-
99
- const [, stripeProductId] = catalogItem;
100
- const product = platformProducts?.find((pr: any) => pr.id === stripeProductId);
101
- if (!product) {
102
- if (platformProducts) {
103
- console.warn('Platform product not found for: ' + stripeProductId);
104
- }
105
- return [];
106
- }
107
-
108
- const pricingList = product.prices
109
- .filter((pc: any) => pc.productGroup === subGroup)
110
- .sort((pc: any) => pc.recurringInterval === 'year' ? -1 : 1);
111
-
112
- return pricingList.map((pc: any) => {
113
- // Add locale here later
114
- const locale = undefined;
115
-
116
- const priceLabel = (
117
- pc.unitAmount / 100
118
- ).toLocaleString(locale, {
119
- style: 'currency',
120
- currency: pc.currency,
121
- });
122
-
123
- return {
124
- id: pc.id,
125
- group: pc.productGroup,
126
- notReady: false,
127
- priceLabel,
128
- price: pc.unitAmount,
129
- currency: pc.currency,
130
- recurringInterval: pc.recurringInterval,
131
- recurringIntervalCount: pc.recurringIntervalCount,
132
- };
133
- });
98
+ const catalogItem = getSubscriptionCatalog(isDev).find(
99
+ (item: any) => item[0] === subGroup,
100
+ );
101
+ if (!catalogItem) {
102
+ console.warn('Unknown subscription group: ' + subGroup);
103
+ return [];
104
+ }
105
+
106
+ const [, stripeProductId] = catalogItem;
107
+ const product = platformProducts?.find(
108
+ (pr: any) => pr.id === stripeProductId,
109
+ );
110
+ if (!product) {
111
+ if (platformProducts) {
112
+ console.warn('Platform product not found for: ' + stripeProductId);
113
+ }
114
+ return [];
115
+ }
116
+
117
+ const pricingList = product.prices
118
+ .filter((pc: any) => pc.productGroup === subGroup)
119
+ .sort((pc: any) => (pc.recurringInterval === 'year' ? -1 : 1));
120
+
121
+ return pricingList.map((pc: any) => {
122
+ // Add locale here later
123
+ const locale = undefined;
124
+
125
+ const priceLabel = (pc.unitAmount / 100).toLocaleString(locale, {
126
+ style: 'currency',
127
+ currency: pc.currency,
128
+ });
129
+
130
+ return {
131
+ id: pc.id,
132
+ group: pc.productGroup,
133
+ notReady: false,
134
+ priceLabel,
135
+ price: pc.unitAmount,
136
+ currency: pc.currency,
137
+ recurringInterval: pc.recurringInterval,
138
+ recurringIntervalCount: pc.recurringIntervalCount,
139
+ };
140
+ });
134
141
  }
@@ -0,0 +1,202 @@
1
+ import { COLORS } from '../constants/app.ts';
2
+ import type { ColorEnum } from '../types/app.d.ts';
3
+ import { hashStringFNV1a } from './string.ts';
4
+
5
+ type RGBColorObj = {
6
+ blue: number;
7
+ green: number;
8
+ red: number;
9
+ };
10
+
11
+ const APP_COLOR_HEX_VALUES: Record<ColorEnum, string> = {
12
+ amber: '#f59e0b',
13
+ blue: '#3b82f6',
14
+ brown: '#a16207',
15
+ cyan: '#06b6d4',
16
+ emerald: '#10b981',
17
+ fuchsia: '#d946ef',
18
+ green: '#22c55e',
19
+ indigo: '#6366f1',
20
+ lime: '#84cc16',
21
+ orange: '#f97316',
22
+ pink: '#ec4899',
23
+ purple: '#a855f7',
24
+ red: '#ef4444',
25
+ rose: '#f43f5e',
26
+ sky: '#0ea5e9',
27
+ slate: '#64748b',
28
+ stone: '#78716c',
29
+ teal: '#14b8a6',
30
+ violet: '#8b5cf6',
31
+ yellow: '#eab308',
32
+ zinc: '#71717a',
33
+ };
34
+
35
+ /**
36
+ * Return one app palette hex color picked deterministically by index.
37
+ */
38
+ export function getAppColorHexByIndex(index: number): string {
39
+ const hexValues = Object.values(APP_COLOR_HEX_VALUES);
40
+ return hexValues[Math.abs(Math.floor(index)) % hexValues.length];
41
+ }
42
+
43
+ /**
44
+ * Return a valid app color name, falling back to a stable color selected from the fully mixed id string.
45
+ */
46
+ export function getValidColor(
47
+ color: string | null | undefined,
48
+ id: string | number | null | undefined,
49
+ ): ColorEnum {
50
+ const normalizedColor = String(color || '')
51
+ .trim()
52
+ .toLowerCase();
53
+
54
+ if (COLORS.includes(normalizedColor as ColorEnum)) {
55
+ return normalizedColor as ColorEnum;
56
+ }
57
+
58
+ let colorIndexHash = parseInt(hashStringFNV1a(String(id)), 16);
59
+ colorIndexHash ^= colorIndexHash >>> 16;
60
+ colorIndexHash = Math.imul(colorIndexHash, 0x85ebca6b);
61
+ colorIndexHash ^= colorIndexHash >>> 13;
62
+ colorIndexHash = Math.imul(colorIndexHash, 0xc2b2ae35);
63
+ colorIndexHash ^= colorIndexHash >>> 16;
64
+
65
+ return COLORS[(colorIndexHash >>> 0) % COLORS.length] as ColorEnum;
66
+ }
67
+
68
+ const RGB_COLOR_REGEX = /^rgba?\(([^)]+)\)$/i;
69
+ const HEX_COLOR_VALUE_REGEX = /^#[0-9a-f]{6}$/i;
70
+ const HEX_COLOR_DRAFT_VALUE_REGEX = /^#[0-9a-f]{0,6}$/i;
71
+
72
+ /**
73
+ * Return whether one value is a valid hex color value or editable hex draft.
74
+ */
75
+ export function isHexColorValue(
76
+ value: string | null | undefined,
77
+ allowDraft: boolean = false,
78
+ ): boolean {
79
+ const normalized = String(value || '').trim();
80
+
81
+ if (allowDraft && !normalized) {
82
+ return true;
83
+ }
84
+
85
+ return allowDraft
86
+ ? HEX_COLOR_DRAFT_VALUE_REGEX.test(normalized)
87
+ : HEX_COLOR_VALUE_REGEX.test(normalized);
88
+ }
89
+
90
+ /**
91
+ * Convert a CSS hex color into RGB channel values.
92
+ */
93
+ function getRGBColorFromHex(color: string): RGBColorObj | null {
94
+ const normalized = color.trim().replace('#', '');
95
+ const isShortHex = normalized.length === 3;
96
+ const isLongHex = normalized.length === 6;
97
+
98
+ if ((!isShortHex && !isLongHex) || /[^0-9a-f]/i.test(normalized)) {
99
+ return null;
100
+ }
101
+
102
+ const fullHex = isShortHex
103
+ ? normalized
104
+ .split('')
105
+ .map((char) => char + char)
106
+ .join('')
107
+ : normalized;
108
+
109
+ return {
110
+ red: parseInt(fullHex.slice(0, 2), 16),
111
+ green: parseInt(fullHex.slice(2, 4), 16),
112
+ blue: parseInt(fullHex.slice(4, 6), 16),
113
+ };
114
+ }
115
+
116
+ /**
117
+ * Convert a CSS rgb() or rgba() color into RGB channel values.
118
+ */
119
+ function getRGBColorFromRGBFunction(color: string): RGBColorObj | null {
120
+ const match = color.trim().match(RGB_COLOR_REGEX);
121
+ if (!match) {
122
+ return null;
123
+ }
124
+
125
+ const channels = match[1]
126
+ .split(',')
127
+ .slice(0, 3)
128
+ .map((channel) => Number(channel.trim()));
129
+ if (
130
+ channels.length < 3 ||
131
+ channels.some((channel) => Number.isNaN(channel))
132
+ ) {
133
+ return null;
134
+ }
135
+
136
+ return {
137
+ red: channels[0],
138
+ green: channels[1],
139
+ blue: channels[2],
140
+ };
141
+ }
142
+
143
+ /**
144
+ * Convert a supported color value into RGB channel values.
145
+ */
146
+ export function getRGBColor(
147
+ color: string | null | undefined,
148
+ ): RGBColorObj | null {
149
+ if (!color) {
150
+ return null;
151
+ }
152
+
153
+ const normalized = color.trim().toLowerCase();
154
+ const appColorHex = APP_COLOR_HEX_VALUES[normalized as ColorEnum];
155
+
156
+ if (appColorHex) {
157
+ return getRGBColorFromHex(appColorHex);
158
+ } else if (normalized.startsWith('#')) {
159
+ return getRGBColorFromHex(normalized);
160
+ }
161
+
162
+ return getRGBColorFromRGBFunction(normalized);
163
+ }
164
+
165
+ /**
166
+ * Return a darker hex color derived from any supported color value, scaling
167
+ * every RGB channel toward black by the given factor (0-1). Useful for
168
+ * deriving an accent tone from a soft pastel background color.
169
+ */
170
+ export function getDarkerHexColor(
171
+ color: string | null | undefined,
172
+ factor: number = 0.5,
173
+ ): string | null {
174
+ const rgb = getRGBColor(color);
175
+ if (!rgb) {
176
+ return null;
177
+ }
178
+
179
+ const channel = (value: number) =>
180
+ Math.max(0, Math.min(255, Math.round(value * factor)))
181
+ .toString(16)
182
+ .padStart(2, '0');
183
+
184
+ return `#${channel(rgb.red)}${channel(rgb.green)}${channel(rgb.blue)}`;
185
+ }
186
+
187
+ /**
188
+ * Return whether a color should be treated as dark based on perceived brightness.
189
+ */
190
+ export function isDarkColor(
191
+ color: string | null | undefined,
192
+ fallback: boolean = false,
193
+ ): boolean {
194
+ const rgb = getRGBColor(color);
195
+ if (!rgb) {
196
+ return fallback;
197
+ }
198
+
199
+ const brightness = (rgb.red * 299 + rgb.green * 587 + rgb.blue * 114) / 1000;
200
+
201
+ return brightness < 128;
202
+ }
package/src/utils/cron.ts CHANGED
@@ -7,7 +7,8 @@ import { CronExpressionParser } from 'cron-parser';
7
7
  export function getCronDescription(schedule: string, verbose = false): string {
8
8
  try {
9
9
  const parsed = CronExpressionParser.parse(schedule);
10
- const { second, minute, hour, dayOfMonth, month, dayOfWeek } = parsed.fields;
10
+ const { second, minute, hour, dayOfMonth, month, dayOfWeek } =
11
+ parsed.fields;
11
12
  const secondRawValues = second.values as Array<number | string>;
12
13
  const minuteRawValues = minute.values as Array<number | string>;
13
14
  const hourRawValues = hour.values as Array<number | string>;
@@ -33,12 +34,11 @@ export function getCronDescription(schedule: string, verbose = false): string {
33
34
  const monthValues = normalizeValues(monthRawValues);
34
35
  const dayOfWeekValues = normalizeDayOfWeekValues(dayOfWeekRawValues);
35
36
 
36
- const hasSimpleTimeNoSeconds = (
37
+ const hasSimpleTimeNoSeconds =
37
38
  secondValues.length === 1 &&
38
39
  secondValues[0] === 0 &&
39
40
  minuteValues.length === 1 &&
40
- hourValues.length === 1
41
- );
41
+ hourValues.length === 1;
42
42
 
43
43
  if (hasSimpleTimeNoSeconds) {
44
44
  const timeText = formatCronTime(hourValues[0], minuteValues[0]);
@@ -51,11 +51,19 @@ export function getCronDescription(schedule: string, verbose = false): string {
51
51
  return `Every day${timeJoinText}${timeText}`;
52
52
  }
53
53
 
54
- if (isEveryMonth && isEveryDayOfMonth && isExactValues(dayOfWeekValues, [1, 2, 3, 4, 5])) {
54
+ if (
55
+ isEveryMonth &&
56
+ isEveryDayOfMonth &&
57
+ isExactValues(dayOfWeekValues, [1, 2, 3, 4, 5])
58
+ ) {
55
59
  return `Mon-Fri${timeJoinText}${timeText}`;
56
60
  }
57
61
 
58
- if (isEveryMonth && isEveryDayOfMonth && isExactValues(dayOfWeekValues, [1, 3, 5])) {
62
+ if (
63
+ isEveryMonth &&
64
+ isEveryDayOfMonth &&
65
+ isExactValues(dayOfWeekValues, [1, 3, 5])
66
+ ) {
59
67
  return `Every other Mon-Fri${timeJoinText}${timeText}`;
60
68
  }
61
69
 
@@ -86,7 +94,11 @@ function formatCronTime(hour24: number, minute: number): string {
86
94
  return `${hour12}:${minuteText} ${amPm}`;
87
95
  }
88
96
 
89
- function formatCronTimeWithSeconds(hour24: number, minute: number, second: number): string {
97
+ function formatCronTimeWithSeconds(
98
+ hour24: number,
99
+ minute: number,
100
+ second: number,
101
+ ): string {
90
102
  const amPm = hour24 >= 12 ? 'PM' : 'AM';
91
103
  const hour12 = hour24 % 12 || 12;
92
104
  const minuteText = String(minute).padStart(2, '0');
@@ -130,14 +142,22 @@ function normalizeDayOfWeekValues(values: number[]): number[] {
130
142
  return normalizeValues(values.map((v) => (v === 7 ? 0 : v)));
131
143
  }
132
144
 
133
- function describeCalendar(dayOfMonthValues: number[], monthValues: number[], dayOfWeekValues: number[]): string {
145
+ function describeCalendar(
146
+ dayOfMonthValues: number[],
147
+ monthValues: number[],
148
+ dayOfWeekValues: number[],
149
+ ): string {
134
150
  const dom = describeDayOfMonth(dayOfMonthValues);
135
151
  const mon = describeMonth(monthValues);
136
152
  const dow = describeDayOfWeek(dayOfWeekValues);
137
153
  return `${dom}, ${mon}, ${dow}`;
138
154
  }
139
155
 
140
- function describeTime(secondValues: number[], minuteValues: number[], hourValues: number[]): string {
156
+ function describeTime(
157
+ secondValues: number[],
158
+ minuteValues: number[],
159
+ hourValues: number[],
160
+ ): string {
141
161
  const singleHour = hourValues.length === 1;
142
162
  const singleMinute = minuteValues.length === 1;
143
163
  const singleSecond = secondValues.length === 1;
@@ -195,7 +215,11 @@ function describeDayOfWeek(values: number[]): string {
195
215
  return formatRanges(normalized, (v) => DAY_LABELS[v]);
196
216
  }
197
217
 
198
- function describeNumericValues(values: number[], min: number, max: number): string {
218
+ function describeNumericValues(
219
+ values: number[],
220
+ min: number,
221
+ max: number,
222
+ ): string {
199
223
  const normalized = normalizeValues(values);
200
224
  if (isRangeFull(normalized, min, max)) {
201
225
  return 'every value';
@@ -209,7 +233,9 @@ function describeNumericValues(values: number[], min: number, max: number): stri
209
233
  return formatRanges(normalized);
210
234
  }
211
235
 
212
- function detectStep(values: number[]): { value: number; start: number; end: number } | null {
236
+ function detectStep(
237
+ values: number[],
238
+ ): { value: number; start: number; end: number } | null {
213
239
  if (values.length < 3) {
214
240
  return null;
215
241
  }
@@ -218,14 +244,17 @@ function detectStep(values: number[]): { value: number; start: number; end: numb
218
244
  return null;
219
245
  }
220
246
  for (let i = 2; i < values.length; i += 1) {
221
- if ((values[i] - values[i - 1]) !== diff) {
247
+ if (values[i] - values[i - 1] !== diff) {
222
248
  return null;
223
249
  }
224
250
  }
225
251
  return { value: diff, start: values[0], end: values[values.length - 1] };
226
252
  }
227
253
 
228
- function formatRanges(values: number[], labeler?: (v: number) => string): string {
254
+ function formatRanges(
255
+ values: number[],
256
+ labeler?: (v: number) => string,
257
+ ): string {
229
258
  if (values.length === 0) {
230
259
  return '';
231
260
  }
@@ -246,11 +275,13 @@ function formatRanges(values: number[], labeler?: (v: number) => string): string
246
275
  }
247
276
  segments.push({ start, end: prev });
248
277
 
249
- return segments.map(({ start: s, end: e }) => {
250
- const a = labeler ? labeler(s) : String(s);
251
- const b = labeler ? labeler(e) : String(e);
252
- return s === e ? a : `${a}-${b}`;
253
- }).join(', ');
278
+ return segments
279
+ .map(({ start: s, end: e }) => {
280
+ const a = labeler ? labeler(s) : String(s);
281
+ const b = labeler ? labeler(e) : String(e);
282
+ return s === e ? a : `${a}-${b}`;
283
+ })
284
+ .join(', ');
254
285
  }
255
286
 
256
287
  const DAY_LABELS: Record<number, string> = {