Skip to content

Commit f4a9dfa

Browse files
v0.5.1 hotfix: types for JS SDK v2.20.0
1 parent c5a07af commit f4a9dfa

File tree

159 files changed

+11627
-80240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+11627
-80240
lines changed

.storybook/main.ts

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,96 @@ import type { StorybookConfig } from '@storybook/react-webpack5';
33
const config: StorybookConfig = {
44
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
55
addons: [
6-
'@storybook/addon-links',
7-
'@storybook/addon-essentials',
8-
'@storybook/preset-create-react-app',
6+
'@storybook/addon-webpack5-compiler-swc',
97
'@storybook/addon-onboarding',
8+
'@storybook/addon-essentials',
9+
'@chromatic-com/storybook',
1010
'@storybook/addon-interactions',
11-
'@storybook/addon-viewport'
1211
],
1312
framework: {
1413
name: '@storybook/react-webpack5',
15-
options: {
16-
builder: {
17-
useSWC: true,
18-
},
19-
},
14+
options: {},
2015
},
21-
docs: {
22-
autodocs: 'tag',
16+
webpackFinal: async (config) => {
17+
// ✅ Гарантируем, что module и module.rules существуют
18+
if (!config.module) {
19+
config.module = { rules: [] };
20+
}
21+
if (!config.module.rules) {
22+
config.module.rules = [];
23+
}
24+
25+
// ✅ Удаляем встроенные Storybook'ом правила для SVG и других медиафайлов
26+
config.module.rules = config.module.rules.filter(
27+
(rule) =>
28+
rule &&
29+
typeof rule === 'object' &&
30+
'test' in rule &&
31+
rule.test instanceof RegExp &&
32+
!rule.test.toString().includes(
33+
'(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)'
34+
)
35+
);
36+
37+
// ✅ Поддержка SVG как React-компонентов (если импортируется с `?react`)
38+
config.module.rules.unshift({
39+
test: /\.svg$/i,
40+
oneOf: [
41+
{
42+
resourceQuery: /react/, // 🔥 `?react` → импорт как React-компонент
43+
use: [
44+
{
45+
loader: '@svgr/webpack',
46+
options: {
47+
icon: true,
48+
esModule: true,
49+
},
50+
},
51+
],
52+
},
53+
{
54+
// 🔥 Обычные импорты SVG без `?react` → обрабатываются как файлы
55+
type: 'asset/resource',
56+
},
57+
],
58+
});
59+
60+
// ✅ Восстанавливаем обработку PNG, JPG, шрифтов и других медиафайлов
61+
config.module.rules.push({
62+
test: /\.(png|jpg|jpeg|gif|woff|woff2|eot|ttf)$/i,
63+
type: 'asset/resource',
64+
});
65+
66+
// ✅ Поддержка SCSS/SASS
67+
config.module.rules.push({
68+
test: /\.scss$/,
69+
use: ['style-loader', 'css-loader', 'sass-loader'],
70+
});
71+
72+
// ✅ Поддержка Babel для JS/TS файлов
73+
config.module.rules.push({
74+
test: /\.(ts|tsx|js|jsx)$/,
75+
exclude: /node_modules/,
76+
use: {
77+
loader: 'babel-loader',
78+
},
79+
});
80+
81+
// ✅ Поддержка alias
82+
if (!config.resolve) {
83+
config.resolve = {};
84+
}
85+
config.resolve = {
86+
...config.resolve,
87+
extensions: ['.tsx', '.ts', '.js', '.jsx', '.scss', '.css', '.svg'],
88+
alias: {
89+
...config.resolve?.alias,
90+
path: require.resolve('path-browserify'),
91+
},
92+
};
93+
94+
return config;
2395
},
24-
staticDirs: ['../public'],
2596
};
97+
2698
export default config;

.storybook/preview.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import type { Preview } from '@storybook/react';
2+
import { fn } from '@storybook/test';
23
import '../src/index.scss';
34

45
const preview: Preview = {
56
parameters: {
6-
actions: { argTypesRegex: '^on[A-Z].*' },
7+
actions: {
8+
onClick: fn(),
9+
onChange: fn(),
10+
},
711
controls: {
812
matchers: {
913
color: /(background|color)$/i,
1014
date: /Date$/i,
1115
},
1216
},
17+
viewMode: 'docs',
1318
},
1419
};
1520

babel.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
presets: [
3+
'@babel/preset-env', // Поддержка современных возможностей JavaScript
4+
'@babel/preset-react', // Добавляем поддержку JSX
5+
'@babel/preset-typescript' // Поддержка TypeScript
6+
],
7+
};

global.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
type Dictionary<T> = Record<string, T>;
22

3+
declare module "*.svg" {
4+
import React from "react";
5+
const content: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
6+
export default content;
7+
}
8+
9+
declare module "*.svg?react" {
10+
import React from "react";
11+
const content: (props: React.SVGProps<SVGSVGElement>) => JSX.Element;
12+
export default content;
13+
}
14+
315
interface Window {
416
webkitAudioContext: typeof AudioContext;
517
}

media-recorder-js.d.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
11
declare module 'media-recorder-js' {
22
interface QBMediaRecorderConstructorProps {
33
/** Preferred MIME type */
4-
mimeType?: string;
5-
workerPath?: string;
4+
mimeType?: string
5+
workerPath?: string
66
/**
77
* The minimum number of milliseconds of data to return
88
* in a single Blob, fire 'ondataavaible' callback
99
* (isn't need to use with 'audio/wav' of 'audio/mp3')
1010
*
1111
* @default 1000
1212
*/
13-
timeslice?: number;
13+
timeslice?: number
1414
/**
1515
* What to do with a muted input MediaStreamTrack,
1616
* e.g. insert black frames/zero audio volume in the recording
1717
* or ignore altogether
1818
*
1919
* @default true
2020
*/
21-
ignoreMutedMedia?: boolean;
21+
ignoreMutedMedia?: boolean
2222
/** Recording start event handler */
23-
onstart?: VoidFunction;
23+
onstart?: VoidFunction
2424
/** Recording stop event handler */
25-
onstop?: (file: Blob) => void;
25+
onstop?: (file: Blob) => void
2626
/** Recording pause event handler */
27-
onpause?: VoidFunction;
27+
onpause?: VoidFunction
2828
/** Recording resume event handler */
29-
onresume?: VoidFunction;
29+
onresume?: VoidFunction
3030
/** Error event handler */
31-
onerror?: (error: unknown) => void;
31+
onerror?: (error: unknown) => void
3232
/**
3333
* `dataavailable` event handler.
3434
* The Blob of recorded data is contained in this event (callback
3535
* isn't supported if use 'audio/wav' of 'audio/mp3' for recording)
3636
*/
37-
ondataavailable?: (event: { data: Blob }) => void;
37+
ondataavailable?: (event: { data: Blob }) => void
3838
}
3939

4040
class QBMediaRecorder {
41-
constructor(config: QBMediaRecorderConstructorProps);
41+
constructor(config: QBMediaRecorderConstructorProps)
4242

4343
/**
4444
* Switch recording Blob objects to the specified
4545
* MIME type if `MediaRecorder` support it.
4646
*/
47-
toggleMimeType(mimeType: string): void;
47+
toggleMimeType(mimeType: string): void
4848

4949
/**
5050
* Returns current `MediaRecorder` state
5151
*/
52-
getState(): 'inactive' | 'recording' | 'paused';
52+
getState(): 'inactive' | 'recording' | 'paused'
5353

5454
/**
5555
* Starts recording a stream.
5656
* Fires `onstart` callback.
5757
*/
58-
start(stream: MediaStream): void;
58+
start(stream: MediaStream): void
5959

6060
/**
6161
* Stops recording a stream
6262
*
6363
* @fires `onstop` callback and passing there Blob recorded
6464
*/
65-
stop(): void;
65+
stop(): void
6666

6767
/** Pausing stream recording */
68-
pause(): void;
68+
pause(): void
6969

7070
/** Resumes stream recording */
71-
resume(): void;
71+
resume(): void
7272

7373
/**
7474
* Change record source
7575
*/
76-
change(stream: MediaStream): void;
76+
change(stream: MediaStream): void
7777

7878
/**
7979
* Create a file from blob and download as file.
@@ -82,9 +82,9 @@ declare module 'media-recorder-js' {
8282
* @param {string} filename Name of video file to be downloaded
8383
* (default to `Date.now()`)
8484
*/
85-
download(filename?: string): void;
85+
download(filename?: string): void
8686

87-
_getBlobRecorded(): Blob;
87+
_getBlobRecorded(): Blob
8888

8989
callbacks: Pick<
9090
QBMediaRecorderConstructorProps,
@@ -94,19 +94,19 @@ declare module 'media-recorder-js' {
9494
| 'onresume'
9595
| 'ondataavailable'
9696
| 'onerror'
97-
>;
97+
>
9898

9999
/**
100100
* Checks capability of recording in the environment.
101101
* Checks `MediaRecorder`, `MediaRecorder.isTypeSupported` and `Blob`.
102102
*/
103-
static isAvailable(): boolean;
103+
static isAvailable(): boolean
104104

105105
/**
106106
* Checks if AudioContext API is available.
107107
* Checks `window.AudioContext` or `window.webkitAudioContext`.
108108
*/
109-
static isAudioContext(): boolean;
109+
static isAudioContext(): boolean
110110
/**
111111
* The `QBMediaRecorder.isTypeSupported()` static method returns
112112
* a Boolean which is true if the MIME type specified is one
@@ -120,14 +120,14 @@ declare module 'media-recorder-js' {
120120
* agent is incapable of recording the specified format.
121121
*/
122122

123-
static isTypeSupported(mimeType: string): boolean;
123+
static isTypeSupported(mimeType: string): boolean
124124

125125
/**
126126
* Return supported mime types
127127
* @param type video or audio (dafault to 'video')
128128
*/
129-
static getSupportedMimeTypes(type: 'audio' | 'video' = 'video'): string[];
129+
static getSupportedMimeTypes(type: 'audio' | 'video' = 'video'): string[]
130130
}
131131

132-
export default QBMediaRecorder;
132+
export default QBMediaRecorder
133133
}

0 commit comments

Comments
 (0)