@automattic/jetpack-ai-client 0.1.5 → 0.1.7
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/CHANGELOG.md +25 -0
- package/index.ts +1 -0
- package/package.json +12 -12
- package/src/components/audio-duration-display/index.tsx +37 -0
- package/src/components/audio-duration-display/lib/media.ts +73 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/use-ai-suggestions/Readme.md +1 -0
- package/src/hooks/use-ai-suggestions/index.ts +18 -1
- package/src/hooks/use-media-recording/Readme.md +50 -0
- package/src/hooks/use-media-recording/index.ts +210 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/mic.tsx +15 -5
- package/src/icons/player-pause.tsx +18 -0
- package/src/icons/player-play.tsx +20 -0
- package/src/icons/player-stop.tsx +17 -0
- package/.gitattributes +0 -7
- package/jest.config.cjs +0 -5
- package/src/components/ai-control/stories/index.stories.tsx +0 -68
- package/src/components/ai-status-indicator/stories/index.mdx +0 -25
- package/src/components/ai-status-indicator/stories/index.stories.tsx +0 -84
- package/src/icons/stories/index.stories.tsx +0 -46
- package/src/icons/stories/style.module.scss +0 -21
- package/tests/index.test.js +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.7] - 2023-09-11
|
|
9
|
+
### Added
|
|
10
|
+
- AI Client: add and expose reset() from useAiSuggestions() hook [#32886]
|
|
11
|
+
- AI Client: introduce audio duration display component [#32825]
|
|
12
|
+
|
|
13
|
+
## [0.1.6] - 2023-09-04
|
|
14
|
+
### Added
|
|
15
|
+
- AI Client: add play and pause icons [#32788]
|
|
16
|
+
- AI Client: add player stop button icon [#32728]
|
|
17
|
+
- AI Client: create blob audio data. Introduce onDone() callback [#32791]
|
|
18
|
+
- AI Client: improve useMediaRecorder() timeslice recording option [#32805]
|
|
19
|
+
- AI Client: introduce useMediaRecording() hook [#32767]
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- AI Client: minor change in useMediaRecording() hook example [#32769]
|
|
23
|
+
- Updated package dependencies. [#32803]
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
- Remove unnecessary files from mirror repo and published package. [#32674]
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- AI Client: fix mic icon visual issue in Safari [#32787]
|
|
30
|
+
|
|
8
31
|
## [0.1.5] - 2023-08-28
|
|
9
32
|
### Added
|
|
10
33
|
- AI Client: add mic icon [#32665]
|
|
@@ -92,6 +115,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
92
115
|
- Updated package dependencies. [#31659]
|
|
93
116
|
- Updated package dependencies. [#31785]
|
|
94
117
|
|
|
118
|
+
[0.1.7]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.6...v0.1.7
|
|
119
|
+
[0.1.6]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.5...v0.1.6
|
|
95
120
|
[0.1.5]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.4...v0.1.5
|
|
96
121
|
[0.1.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.3...v0.1.4
|
|
97
122
|
[0.1.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.2...v0.1.3
|
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as askQuestion } from './src/ask-question';
|
|
|
9
9
|
* Hooks
|
|
10
10
|
*/
|
|
11
11
|
export { default as useAiSuggestions } from './src/hooks/use-ai-suggestions';
|
|
12
|
+
export { default as useMediaRecording } from './src/hooks/use-media-recording';
|
|
12
13
|
|
|
13
14
|
/*
|
|
14
15
|
* Components: Icons
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
".": "./index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
36
|
-
"@automattic/jetpack-connection": "^0.29.
|
|
37
|
-
"@automattic/jetpack-shared-extension-utils": "^0.11.
|
|
35
|
+
"@automattic/jetpack-base-styles": "^0.6.9",
|
|
36
|
+
"@automattic/jetpack-connection": "^0.29.9",
|
|
37
|
+
"@automattic/jetpack-shared-extension-utils": "^0.11.4",
|
|
38
38
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
39
|
-
"@wordpress/api-fetch": "6.
|
|
40
|
-
"@wordpress/block-editor": "12.
|
|
41
|
-
"@wordpress/components": "25.
|
|
42
|
-
"@wordpress/compose": "6.
|
|
43
|
-
"@wordpress/data": "9.
|
|
44
|
-
"@wordpress/element": "5.
|
|
45
|
-
"@wordpress/i18n": "4.
|
|
46
|
-
"@wordpress/icons": "9.
|
|
39
|
+
"@wordpress/api-fetch": "6.38.0",
|
|
40
|
+
"@wordpress/block-editor": "12.9.0",
|
|
41
|
+
"@wordpress/components": "25.7.0",
|
|
42
|
+
"@wordpress/compose": "6.18.0",
|
|
43
|
+
"@wordpress/data": "9.11.0",
|
|
44
|
+
"@wordpress/element": "5.18.0",
|
|
45
|
+
"@wordpress/i18n": "4.41.0",
|
|
46
|
+
"@wordpress/icons": "9.32.0",
|
|
47
47
|
"classnames": "2.3.2",
|
|
48
48
|
"debug": "4.3.4",
|
|
49
49
|
"react": "18.2.0",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
5
|
+
/*
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { formatTime, getDuration } from './lib/media';
|
|
9
|
+
/*
|
|
10
|
+
* Types
|
|
11
|
+
*/
|
|
12
|
+
import type React from 'react';
|
|
13
|
+
|
|
14
|
+
type AudioDurationDisplayProps = {
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* AudioDurationDisplay component.
|
|
20
|
+
*
|
|
21
|
+
* @param {AudioDurationDisplayProps} props - Component props.
|
|
22
|
+
* @returns {React.ReactElement} Rendered component.
|
|
23
|
+
*/
|
|
24
|
+
export default function AudioDurationDisplay( {
|
|
25
|
+
url,
|
|
26
|
+
}: AudioDurationDisplayProps ): React.ReactElement {
|
|
27
|
+
const [ duration, setDuration ] = useState( 0 );
|
|
28
|
+
useEffect( () => {
|
|
29
|
+
if ( ! url ) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getDuration( url ).then( setDuration );
|
|
34
|
+
}, [ url ] );
|
|
35
|
+
|
|
36
|
+
return <span>{ formatTime( duration, { addDecimalPart: false } ) }</span>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to get duration of audio file
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url - The url of the audio file
|
|
5
|
+
* @returns {Promise<number>} The duration of the audio file
|
|
6
|
+
* @see https://stackoverflow.com/questions/21522036/html-audio-tag-duration-always-infinity
|
|
7
|
+
*/
|
|
8
|
+
export function getDuration( url: string ): Promise< number > {
|
|
9
|
+
return new Promise( next => {
|
|
10
|
+
const tmpAudioInstance = new Audio( url );
|
|
11
|
+
tmpAudioInstance.addEventListener(
|
|
12
|
+
'durationchange',
|
|
13
|
+
function () {
|
|
14
|
+
if ( this.duration === Infinity ) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const duration = this.duration;
|
|
19
|
+
tmpAudioInstance.remove(); // remove instance from memory
|
|
20
|
+
next( duration );
|
|
21
|
+
},
|
|
22
|
+
false
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
tmpAudioInstance.load();
|
|
26
|
+
tmpAudioInstance.currentTime = 24 * 60 * 60; // Fake big time
|
|
27
|
+
tmpAudioInstance.volume = 0;
|
|
28
|
+
tmpAudioInstance.play(); // This will call `durationchange` event
|
|
29
|
+
} );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type FormatTimeOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* Whether to add the decimal part to the formatted time.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
addDecimalPart?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Formats the given time in milliseconds into a string with the format HH:MM:SS.DD,
|
|
42
|
+
* adding hours and minutes only when needed.
|
|
43
|
+
*
|
|
44
|
+
* @param {number} time - The time in seconds to format.
|
|
45
|
+
* @param {FormatTimeOptions} options - The arguments.
|
|
46
|
+
* @returns {string} The formatted time string.
|
|
47
|
+
* @example
|
|
48
|
+
* const formattedTime1 = formatTime( 1234567 ); // Returns "20:34.56"
|
|
49
|
+
* const formattedTime2 = formatTime( 45123 ); // Returns "45.12"
|
|
50
|
+
* const formattedTime3 = formatTime( 64, { addDecimalPart: false } ); // Returns "01:04"
|
|
51
|
+
*/
|
|
52
|
+
export function formatTime(
|
|
53
|
+
time: number,
|
|
54
|
+
{ addDecimalPart = true }: FormatTimeOptions = {}
|
|
55
|
+
): string {
|
|
56
|
+
time = time * 1000;
|
|
57
|
+
const hours = Math.floor( time / 3600000 );
|
|
58
|
+
const minutes = Math.floor( time / 60000 ) % 60;
|
|
59
|
+
const seconds = Math.floor( time / 1000 ) % 60;
|
|
60
|
+
const deciseconds = Math.floor( time / 10 ) % 100;
|
|
61
|
+
|
|
62
|
+
const parts = [
|
|
63
|
+
hours > 0 ? hours.toString().padStart( 2, '0' ) + ':' : '',
|
|
64
|
+
hours > 0 || minutes > 0 ? minutes.toString().padStart( 2, '0' ) + ':' : '',
|
|
65
|
+
seconds.toString().padStart( 2, '0' ),
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
if ( addDecimalPart ) {
|
|
69
|
+
parts.push( '.' + deciseconds.toString().padStart( 2, '0' ) );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return parts.join( '' );
|
|
73
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ An object with the following properties:
|
|
|
36
36
|
- `requestingState: RequestingStateProp`: The state of the request.
|
|
37
37
|
- `eventSource: SuggestionsEventSource | undefined`: The event source of the request.
|
|
38
38
|
- `request: ( prompt: Array< PromptItemProps >, options: AskQuestionOptionsArgProps ) => Promise< void >`: The request handler.
|
|
39
|
+
- `reset`: `() => void`: Reset the request state.
|
|
39
40
|
|
|
40
41
|
### `PromptItemProps`
|
|
41
42
|
|
|
@@ -98,6 +98,11 @@ type useAiSuggestionsProps = {
|
|
|
98
98
|
*/
|
|
99
99
|
request: ( prompt: PromptProp, options?: AskQuestionOptionsArgProps ) => Promise< void >;
|
|
100
100
|
|
|
101
|
+
/*
|
|
102
|
+
* Reset the request state.
|
|
103
|
+
*/
|
|
104
|
+
reset: () => void;
|
|
105
|
+
|
|
101
106
|
/*
|
|
102
107
|
* The handler to stop a suggestion.
|
|
103
108
|
*/
|
|
@@ -294,6 +299,17 @@ export default function useAiSuggestions( {
|
|
|
294
299
|
]
|
|
295
300
|
);
|
|
296
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Reset the request state.
|
|
304
|
+
*
|
|
305
|
+
* @returns {void}
|
|
306
|
+
*/
|
|
307
|
+
const reset = useCallback( () => {
|
|
308
|
+
setRequestingState( 'init' );
|
|
309
|
+
setSuggestion( '' );
|
|
310
|
+
setError( undefined );
|
|
311
|
+
}, [] );
|
|
312
|
+
|
|
297
313
|
/**
|
|
298
314
|
* Stop suggestion handler.
|
|
299
315
|
*
|
|
@@ -358,9 +374,10 @@ export default function useAiSuggestions( {
|
|
|
358
374
|
error,
|
|
359
375
|
requestingState,
|
|
360
376
|
|
|
361
|
-
//
|
|
377
|
+
// Requests handlers
|
|
362
378
|
request,
|
|
363
379
|
stopSuggestion,
|
|
380
|
+
reset,
|
|
364
381
|
|
|
365
382
|
// SuggestionsEventSource
|
|
366
383
|
eventSource: eventSourceRef.current,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# `useMediaRecording` Custom React Hook
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`useMediaRecording` is a custom React hook for handling media recording functionalities in a React application. It provides an easy way to start, pause, resume, and stop media recording, as well as to track the current recording state.
|
|
6
|
+
|
|
7
|
+
Based on [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder) API
|
|
8
|
+
|
|
9
|
+
## API
|
|
10
|
+
|
|
11
|
+
The hook returns an object with the following properties and methods:
|
|
12
|
+
|
|
13
|
+
- `state: 'inactive' | 'recording' | 'paused'` - Current recording state
|
|
14
|
+
- `blob`: `blob` - The recorded blob
|
|
15
|
+
- `url`: `string` - The recorded blob url
|
|
16
|
+
- `start: ( timeslice ) => void` - Start the media recording
|
|
17
|
+
- `pause: () => void` - Pause the current media recording
|
|
18
|
+
- `resume: () => void` - Resume a paused recording
|
|
19
|
+
- `stop: () => void` - Stop the current recording
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
Here's an example React component that utilizes the `useMediaRecording` hook.
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import useMediaRecording from './useMediaRecording';
|
|
27
|
+
|
|
28
|
+
const MediaRecorderComponent = () => {
|
|
29
|
+
const { start, pause, resume, stop, state } = useMediaRecording();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<h1>Media Recorder</h1>
|
|
34
|
+
<p>Current State: { state }</p>
|
|
35
|
+
<button onClick={ start } disabled={ state !== 'inactive' }>
|
|
36
|
+
Start
|
|
37
|
+
</button>
|
|
38
|
+
<button onClick={ pause } disabled={ state !== 'recording' }>
|
|
39
|
+
Pause
|
|
40
|
+
</button>
|
|
41
|
+
<button onClick={ resume } disabled={ state !== 'paused' }>
|
|
42
|
+
Resume
|
|
43
|
+
</button>
|
|
44
|
+
<button onClick={ stop } disabled={ state === 'inactive' }>
|
|
45
|
+
Stop
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
```
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef, useState, useEffect, useCallback } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Types
|
|
8
|
+
*/
|
|
9
|
+
type RecordingStateProp = 'inactive' | 'recording' | 'paused';
|
|
10
|
+
type UseMediaRecordingProps = {
|
|
11
|
+
onDone?: ( blob: Blob ) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type UseMediaRecordingReturn = {
|
|
15
|
+
/**
|
|
16
|
+
* The current recording state
|
|
17
|
+
*/
|
|
18
|
+
state: RecordingStateProp;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The recorded blob
|
|
22
|
+
*/
|
|
23
|
+
blob: Blob | null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The recorded blob url
|
|
27
|
+
*/
|
|
28
|
+
url: string | null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `start` recording handler
|
|
32
|
+
*/
|
|
33
|
+
start: ( timeslice?: number ) => void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `pause` recording handler
|
|
37
|
+
*/
|
|
38
|
+
pause: () => void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `resume` recording handler
|
|
42
|
+
*/
|
|
43
|
+
resume: () => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `stop` recording handler
|
|
47
|
+
*/
|
|
48
|
+
stop: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type MediaRecorderEvent = {
|
|
52
|
+
data: Blob;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* react custom hook to handle media recording.
|
|
57
|
+
*
|
|
58
|
+
* @param {UseMediaRecordingProps} props - The props
|
|
59
|
+
* @returns {UseMediaRecordingReturn} The media recorder instance
|
|
60
|
+
*/
|
|
61
|
+
export default function useMediaRecording( {
|
|
62
|
+
onDone,
|
|
63
|
+
}: UseMediaRecordingProps = {} ): UseMediaRecordingReturn {
|
|
64
|
+
// Reference to the media recorder instance
|
|
65
|
+
const mediaRecordRef = useRef( null );
|
|
66
|
+
|
|
67
|
+
// Recording state: `inactive`, `recording`, `paused`
|
|
68
|
+
const [ state, setState ] = useState< RecordingStateProp >( 'inactive' );
|
|
69
|
+
|
|
70
|
+
// The recorded blob
|
|
71
|
+
const [ blob, setBlob ] = useState< Blob | null >( null );
|
|
72
|
+
|
|
73
|
+
// Store the recorded chunks
|
|
74
|
+
const recordedChunks = useRef< Array< Blob > >( [] ).current;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get the recorded blob.
|
|
78
|
+
*
|
|
79
|
+
* @returns {Blob} The recorded blob
|
|
80
|
+
*/
|
|
81
|
+
function getBlob() {
|
|
82
|
+
return new Blob( recordedChunks, {
|
|
83
|
+
type: 'audio/webm',
|
|
84
|
+
} );
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// `start` recording handler
|
|
88
|
+
const start = useCallback( ( timeslice: number ) => {
|
|
89
|
+
if ( ! timeslice ) {
|
|
90
|
+
return mediaRecordRef?.current?.start();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ( timeslice < 100 ) {
|
|
94
|
+
timeslice = 100; // set minimum timeslice to 100ms
|
|
95
|
+
}
|
|
96
|
+
mediaRecordRef?.current?.start( timeslice );
|
|
97
|
+
}, [] );
|
|
98
|
+
|
|
99
|
+
// `pause` recording handler
|
|
100
|
+
const pause = useCallback( () => {
|
|
101
|
+
mediaRecordRef?.current?.pause();
|
|
102
|
+
}, [] );
|
|
103
|
+
|
|
104
|
+
// `resume` recording handler
|
|
105
|
+
const resume = useCallback( () => {
|
|
106
|
+
mediaRecordRef?.current?.resume();
|
|
107
|
+
}, [] );
|
|
108
|
+
|
|
109
|
+
// `stop` recording handler
|
|
110
|
+
const stop = useCallback( () => {
|
|
111
|
+
mediaRecordRef?.current?.stop();
|
|
112
|
+
}, [] );
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* `start` event listener for the media recorder instance.
|
|
116
|
+
*/
|
|
117
|
+
function onStartListener() {
|
|
118
|
+
setState( 'recording' );
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* `stop` event listener for the media recorder instance.
|
|
123
|
+
*
|
|
124
|
+
* @returns {void}
|
|
125
|
+
*/
|
|
126
|
+
function onStopListener(): void {
|
|
127
|
+
setState( 'inactive' );
|
|
128
|
+
onDone?.( getBlob() );
|
|
129
|
+
|
|
130
|
+
// Clear the recorded chunks
|
|
131
|
+
recordedChunks.length = 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `pause` event listener for the media recorder instance.
|
|
136
|
+
*/
|
|
137
|
+
function onPauseListener() {
|
|
138
|
+
setState( 'paused' );
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `resume` event listener for the media recorder instance.
|
|
143
|
+
*/
|
|
144
|
+
function onResumeListener() {
|
|
145
|
+
setState( 'recording' );
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* `dataavailable` event listener for the media recorder instance.
|
|
150
|
+
*
|
|
151
|
+
* @param {MediaRecorderEvent} event - The event object
|
|
152
|
+
* @returns {void}
|
|
153
|
+
*/
|
|
154
|
+
function onDataAvailableListener( event: MediaRecorderEvent ): void {
|
|
155
|
+
const { data } = event;
|
|
156
|
+
if ( ! data?.size ) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Store the recorded chunks
|
|
161
|
+
recordedChunks.push( data );
|
|
162
|
+
|
|
163
|
+
// Create and store the Blob for the recorded chunks
|
|
164
|
+
setBlob( getBlob() );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Create media recorder instance
|
|
168
|
+
useEffect( () => {
|
|
169
|
+
// Check if the getUserMedia API is supported
|
|
170
|
+
if ( ! navigator.mediaDevices?.getUserMedia ) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const constraints = { audio: true };
|
|
175
|
+
|
|
176
|
+
navigator.mediaDevices
|
|
177
|
+
.getUserMedia( constraints )
|
|
178
|
+
.then( stream => {
|
|
179
|
+
mediaRecordRef.current = new MediaRecorder( stream );
|
|
180
|
+
|
|
181
|
+
mediaRecordRef.current.addEventListener( 'start', onStartListener );
|
|
182
|
+
mediaRecordRef.current.addEventListener( 'stop', onStopListener );
|
|
183
|
+
mediaRecordRef.current.addEventListener( 'pause', onPauseListener );
|
|
184
|
+
mediaRecordRef.current.addEventListener( 'resume', onResumeListener );
|
|
185
|
+
mediaRecordRef.current.addEventListener( 'dataavailable', onDataAvailableListener );
|
|
186
|
+
} )
|
|
187
|
+
.catch( err => {
|
|
188
|
+
// @todo: handle error
|
|
189
|
+
throw err;
|
|
190
|
+
} );
|
|
191
|
+
return () => {
|
|
192
|
+
mediaRecordRef.current.removeEventListener( 'start', onStartListener );
|
|
193
|
+
mediaRecordRef.current.removeEventListener( 'stop', onStopListener );
|
|
194
|
+
mediaRecordRef.current.removeEventListener( 'pause', onPauseListener );
|
|
195
|
+
mediaRecordRef.current.removeEventListener( 'resume', onResumeListener );
|
|
196
|
+
mediaRecordRef.current.removeEventListener( 'dataavailable', onDataAvailableListener );
|
|
197
|
+
};
|
|
198
|
+
}, [] );
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
state,
|
|
202
|
+
blob,
|
|
203
|
+
url: blob ? URL.createObjectURL( blob ) : null,
|
|
204
|
+
|
|
205
|
+
start,
|
|
206
|
+
pause,
|
|
207
|
+
resume,
|
|
208
|
+
stop,
|
|
209
|
+
};
|
|
210
|
+
}
|
package/src/icons/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as aiAssistantIcon } from './ai-assistant';
|
|
2
2
|
export { default as micIcon } from './mic';
|
|
3
3
|
export { default as origamiPlaneIcon } from './origami-plane';
|
|
4
|
+
export { default as playerPlayIcon } from './player-play';
|
|
5
|
+
export { default as playerStopIcon } from './player-stop';
|
|
6
|
+
export { default as playerPauseIcon } from './player-pause';
|
|
4
7
|
export { default as speakToneIcon } from './speak-tone';
|
package/src/icons/mic.tsx
CHANGED
|
@@ -5,13 +5,23 @@ import { SVG, Rect, Line, Path } from '@wordpress/components';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
const mic = (
|
|
8
|
-
<SVG width="24" height="24" viewBox="0 0 24 24"
|
|
9
|
-
<Rect
|
|
10
|
-
|
|
8
|
+
<SVG width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/SVG">
|
|
9
|
+
<Rect
|
|
10
|
+
x="8.75"
|
|
11
|
+
y="2.75"
|
|
12
|
+
width="6.5"
|
|
13
|
+
height="11.5"
|
|
14
|
+
rx="3.25"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
strokeWidth="1.5"
|
|
17
|
+
fill="none"
|
|
18
|
+
/>
|
|
19
|
+
<Line x1="12" y1="17" x2="12" y2="21" stroke="currentColor" strokeWidth="1.5" fill="none" />
|
|
11
20
|
<Path
|
|
12
21
|
d="M18 11C18 11.7879 17.8448 12.5681 17.5433 13.2961C17.2417 14.0241 16.7998 14.6855 16.2426 15.2426C15.6855 15.7998 15.0241 16.2418 14.2961 16.5433C13.5681 16.8448 12.7879 17 12 17C11.2121 17 10.4319 16.8448 9.7039 16.5433C8.97595 16.2417 8.31451 15.7998 7.75736 15.2426C7.20021 14.6855 6.75825 14.0241 6.45672 13.2961C6.15519 12.5681 6 11.7879 6 11"
|
|
13
|
-
stroke="
|
|
14
|
-
|
|
22
|
+
stroke="currentColor"
|
|
23
|
+
strokeWidth="1.5"
|
|
24
|
+
fill="none"
|
|
15
25
|
/>
|
|
16
26
|
</SVG>
|
|
17
27
|
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Path, Rect } from '@wordpress/components';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const playerPause = (
|
|
8
|
+
<SVG width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
9
|
+
<Path
|
|
10
|
+
d="M16 6.33325C14.7306 6.33325 13.4736 6.58329 12.3007 7.06908C11.1279 7.55488 10.0623 8.26692 9.16464 9.16455C8.26701 10.0622 7.55497 11.1278 7.06917 12.3006C6.58338 13.4735 6.33334 14.7305 6.33334 15.9999C6.33334 17.2694 6.58338 18.5264 7.06917 19.6992C7.55497 20.872 8.26701 21.9377 9.16464 22.8353C10.0623 23.7329 11.1279 24.445 12.3007 24.9308C13.4736 25.4165 14.7306 25.6666 16 25.6666C18.5638 25.6666 21.0225 24.6481 22.8354 22.8353C24.6482 21.0224 25.6667 18.5637 25.6667 15.9999C25.6667 13.4362 24.6482 10.9774 22.8354 9.16455C21.0225 7.3517 18.5638 6.33325 16 6.33325ZM4.33334 15.9999C4.33334 12.9057 5.56251 9.93826 7.75043 7.75034C9.93836 5.56242 12.9058 4.33325 16 4.33325C19.0942 4.33325 22.0617 5.56242 24.2496 7.75034C26.4375 9.93826 27.6667 12.9057 27.6667 15.9999C27.6667 19.0941 26.4375 22.0616 24.2496 24.2495C22.0617 26.4374 19.0942 27.6666 16 27.6666C12.9058 27.6666 9.93836 26.4374 7.75043 24.2495C5.56251 22.0616 4.33334 19.0941 4.33334 15.9999Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
/>
|
|
13
|
+
<Rect x="17" y="12" width="3" height="8" fill="currentColor" />
|
|
14
|
+
<Rect x="12" y="12" width="3" height="8" fill="currentColor" />
|
|
15
|
+
</SVG>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default playerPause;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Path } from '@wordpress/components';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const playerPlay = (
|
|
8
|
+
<SVG width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
9
|
+
<Path
|
|
10
|
+
d="M16 6.33325C14.7306 6.33325 13.4736 6.58329 12.3007 7.06908C11.1279 7.55488 10.0623 8.26692 9.16464 9.16455C8.26701 10.0622 7.55497 11.1278 7.06917 12.3006C6.58338 13.4735 6.33334 14.7305 6.33334 15.9999C6.33334 17.2694 6.58338 18.5264 7.06917 19.6992C7.55497 20.872 8.26701 21.9377 9.16464 22.8353C10.0623 23.7329 11.1279 24.445 12.3007 24.9308C13.4736 25.4165 14.7306 25.6666 16 25.6666C18.5638 25.6666 21.0225 24.6481 22.8354 22.8353C24.6482 21.0224 25.6667 18.5637 25.6667 15.9999C25.6667 13.4362 24.6482 10.9774 22.8354 9.16455C21.0225 7.3517 18.5638 6.33325 16 6.33325ZM4.33334 15.9999C4.33334 12.9057 5.56251 9.93826 7.75043 7.75034C9.93836 5.56242 12.9058 4.33325 16 4.33325C19.0942 4.33325 22.0617 5.56242 24.2496 7.75034C26.4375 9.93826 27.6667 12.9057 27.6667 15.9999C27.6667 19.0941 26.4375 22.0616 24.2496 24.2495C22.0617 26.4374 19.0942 27.6666 16 27.6666C12.9058 27.6666 9.93836 26.4374 7.75043 24.2495C5.56251 22.0616 4.33334 19.0941 4.33334 15.9999Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
/>
|
|
13
|
+
<Path
|
|
14
|
+
d="M20.1838 15.098C20.8674 15.5051 20.8675 16.4949 20.1839 16.902L14.8877 20.0553C14.188 20.4719 13.301 19.9677 13.301 19.1533L13.301 12.8467C13.301 12.0323 14.188 11.5281 14.8877 11.9447L20.1838 15.098Z"
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
/>
|
|
17
|
+
</SVG>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default playerPlay;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Rect, Path } from '@wordpress/components';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const playerStop = (
|
|
8
|
+
<SVG width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/SVG">
|
|
9
|
+
<Path
|
|
10
|
+
d="M16.0002 6.33301C14.7307 6.33301 13.4737 6.58304 12.3009 7.06884C11.1281 7.55463 10.0624 8.26668 9.1648 9.16431C8.26716 10.0619 7.55512 11.1276 7.06933 12.3004C6.58353 13.4732 6.3335 14.7302 6.3335 15.9997C6.3335 17.2691 6.58353 18.5261 7.06933 19.6989C7.55512 20.8718 8.26716 21.9374 9.1648 22.835C10.0624 23.7327 11.1281 24.4447 12.3009 24.9305C13.4737 25.4163 14.7307 25.6663 16.0002 25.6663C18.5639 25.6663 21.0227 24.6479 22.8355 22.835C24.6484 21.0222 25.6668 18.5634 25.6668 15.9997C25.6668 13.4359 24.6484 10.9772 22.8355 9.16431C21.0227 7.35146 18.5639 6.33301 16.0002 6.33301ZM4.3335 15.9997C4.3335 12.9055 5.56266 9.93802 7.75058 7.7501C9.93851 5.56217 12.906 4.33301 16.0002 4.33301C19.0944 4.33301 22.0618 5.56217 24.2497 7.7501C26.4377 9.93802 27.6668 12.9055 27.6668 15.9997C27.6668 19.0939 26.4377 22.0613 24.2497 24.2493C22.0618 26.4372 19.0944 27.6663 16.0002 27.6663C12.906 27.6663 9.93851 26.4372 7.75058 24.2493C5.56266 22.0613 4.3335 19.0939 4.3335 15.9997Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
/>
|
|
13
|
+
<Rect x="12" y="12" width="8" height="8" fill="currentColor" />
|
|
14
|
+
</SVG>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default playerStop;
|
package/.gitattributes
DELETED
package/jest.config.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { action } from '@storybook/addon-actions';
|
|
5
|
-
import { useState } from '@wordpress/element';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { REQUESTING_STATES } from '../../../types';
|
|
11
|
-
import AIControl from '../index';
|
|
12
|
-
/**
|
|
13
|
-
* Types
|
|
14
|
-
*/
|
|
15
|
-
import type { Meta } from '@storybook/react';
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
title: 'JS Packages/AI Client/AI Control',
|
|
19
|
-
component: AIControl,
|
|
20
|
-
decorators: [
|
|
21
|
-
Story => (
|
|
22
|
-
<div style={ { backgroundColor: 'white' } }>
|
|
23
|
-
<Story />
|
|
24
|
-
</div>
|
|
25
|
-
),
|
|
26
|
-
],
|
|
27
|
-
argTypes: {
|
|
28
|
-
requestingState: {
|
|
29
|
-
control: {
|
|
30
|
-
type: 'select',
|
|
31
|
-
},
|
|
32
|
-
options: REQUESTING_STATES,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
parameters: {
|
|
36
|
-
controls: {
|
|
37
|
-
exclude: /on[A-Z].*/,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
} as Meta< typeof AIControl >;
|
|
41
|
-
|
|
42
|
-
const Template = args => {
|
|
43
|
-
const [ value, setValue ] = useState( '' );
|
|
44
|
-
|
|
45
|
-
const handleChange = ( newValue: string ) => {
|
|
46
|
-
setValue( newValue );
|
|
47
|
-
args?.onChange?.( newValue );
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return <AIControl { ...args } onChange={ handleChange } value={ args?.value ?? value } />;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const DefaultArgs = {
|
|
54
|
-
loading: false,
|
|
55
|
-
isTransparent: false,
|
|
56
|
-
placeholder: '',
|
|
57
|
-
requestingState: 'init',
|
|
58
|
-
showButtonLabels: true,
|
|
59
|
-
showAccept: false,
|
|
60
|
-
acceptLabel: 'Accept',
|
|
61
|
-
onChange: action( 'onChange' ),
|
|
62
|
-
onSend: action( 'onSend' ),
|
|
63
|
-
onStop: action( 'onStop' ),
|
|
64
|
-
onAccept: action( 'onAccept' ),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const Default = Template.bind( {} );
|
|
68
|
-
Default.args = DefaultArgs;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, Canvas } from '@storybook/blocks';
|
|
2
|
-
import AiStatusIndicator from '../index';
|
|
3
|
-
import * as AiStatusIndicatorStory from './index.stories';
|
|
4
|
-
|
|
5
|
-
<Meta of={AiStatusIndicatorStory} />
|
|
6
|
-
|
|
7
|
-
# AiStatusIndicator
|
|
8
|
-
|
|
9
|
-
## Requesting states
|
|
10
|
-
|
|
11
|
-
### Init
|
|
12
|
-
<Story id="js-packages-ai-client-aistatusindicator--init" />
|
|
13
|
-
|
|
14
|
-
### Requesting
|
|
15
|
-
<Story id="js-packages-ai-client-aistatusindicator--requesting" />
|
|
16
|
-
|
|
17
|
-
### Suggesting
|
|
18
|
-
<Story id="js-packages-ai-client-aistatusindicator--suggesting" />
|
|
19
|
-
|
|
20
|
-
### Done
|
|
21
|
-
<Story id="js-packages-ai-client-aistatusindicator--done" />
|
|
22
|
-
|
|
23
|
-
### Error
|
|
24
|
-
<Story id="js-packages-ai-client-aistatusindicator--error" />
|
|
25
|
-
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* External Dependencies
|
|
3
|
-
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
/*
|
|
6
|
-
* Internal Dependencies
|
|
7
|
-
*/
|
|
8
|
-
import AiStatusIndicator, { AiStatusIndicatorProps } from '..';
|
|
9
|
-
import { REQUESTING_STATES } from '../../../types';
|
|
10
|
-
|
|
11
|
-
type AiStatusIndicatoryStoryProps = AiStatusIndicatorProps & {
|
|
12
|
-
icon: string;
|
|
13
|
-
children?: React.ReactNode;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: 'JS Packages/AI Client/AiStatusIndicator',
|
|
18
|
-
component: AiStatusIndicator,
|
|
19
|
-
argTypes: {
|
|
20
|
-
state: {
|
|
21
|
-
control: {
|
|
22
|
-
type: 'select',
|
|
23
|
-
},
|
|
24
|
-
options: REQUESTING_STATES,
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
control: {
|
|
28
|
-
type: 'select',
|
|
29
|
-
},
|
|
30
|
-
options: [ 24, 32, 48, 64 ],
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
action: {
|
|
34
|
-
table: {
|
|
35
|
-
disable: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const DefaultTemplate = ( args: AiStatusIndicatoryStoryProps ) => {
|
|
42
|
-
const props: AiStatusIndicatorProps = {
|
|
43
|
-
state: args.state,
|
|
44
|
-
size: args.size,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return <AiStatusIndicator { ...props } />;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const _default = DefaultTemplate.bind( {} );
|
|
51
|
-
_default.args = {
|
|
52
|
-
state: 'init',
|
|
53
|
-
size: 24,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Init = DefaultTemplate.bind( {} );
|
|
57
|
-
Init.args = {
|
|
58
|
-
state: 'init',
|
|
59
|
-
size: 48,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const Requesting = DefaultTemplate.bind( {} );
|
|
63
|
-
Requesting.args = {
|
|
64
|
-
state: 'requesting',
|
|
65
|
-
size: 48,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const Suggesting = DefaultTemplate.bind( {} );
|
|
69
|
-
Suggesting.args = {
|
|
70
|
-
state: 'suggesting',
|
|
71
|
-
size: 48,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const Error = DefaultTemplate.bind( {} );
|
|
75
|
-
Error.args = {
|
|
76
|
-
state: 'error',
|
|
77
|
-
size: 48,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const Done = DefaultTemplate.bind( {} );
|
|
81
|
-
Done.args = {
|
|
82
|
-
state: 'done',
|
|
83
|
-
size: 48,
|
|
84
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Icon } from '@wordpress/components';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import * as allIcons from '../index';
|
|
10
|
-
import styles from './style.module.scss';
|
|
11
|
-
/**
|
|
12
|
-
* Types
|
|
13
|
-
*/
|
|
14
|
-
import type { Meta } from '@storybook/react';
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
title: 'JS Packages/AI Client/Icons',
|
|
18
|
-
component: allIcons,
|
|
19
|
-
parameters: {},
|
|
20
|
-
} as Meta< typeof allIcons >;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Icons story components.
|
|
24
|
-
*
|
|
25
|
-
* @returns {object} - story component
|
|
26
|
-
*/
|
|
27
|
-
function IconsStory() {
|
|
28
|
-
return (
|
|
29
|
-
<div className={ styles[ 'icons-container' ] }>
|
|
30
|
-
{ Object.entries( allIcons ).map( ( [ name, icon ] ) => {
|
|
31
|
-
return (
|
|
32
|
-
<div key={ name } className={ styles[ 'icon-container' ] }>
|
|
33
|
-
<Icon icon={ icon } size={ 32 } />
|
|
34
|
-
<div className={ styles[ 'icon-name' ] }>{ name }</div>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
} ) }
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const Template = args => <IconsStory { ...args } />;
|
|
43
|
-
|
|
44
|
-
const DefaultArgs = {};
|
|
45
|
-
export const Default = Template.bind( {} );
|
|
46
|
-
Default.args = DefaultArgs;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
.icons-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
margin-bottom: 20px;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.icon-container {
|
|
9
|
-
padding: 10px;
|
|
10
|
-
box-shadow: 0 0 1px inset rgba(0, 0, 0 , 0.5 );
|
|
11
|
-
background-color: white;
|
|
12
|
-
border-radius: 5px;
|
|
13
|
-
margin: 2px;
|
|
14
|
-
display: flex;
|
|
15
|
-
gap: 8px;
|
|
16
|
-
align-items: center;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.icon-name {
|
|
20
|
-
font-size: 14px;
|
|
21
|
-
}
|
package/tests/index.test.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// We recommend using `jest` for testing. If you're testing React code, we recommend `@testing-library/react` and related packages.
|
|
2
|
-
// Please match the versions used elsewhere in the monorepo.
|
|
3
|
-
//
|
|
4
|
-
// Please don't add new uses of `mocha`, `chai`, `sinon`, `enzyme`, and so on. We're trying to standardize on one testing framework.
|
|
5
|
-
//
|
|
6
|
-
// The default setup is to have files named like "name.test.js" (or .jsx, .ts, or .tsx) in this `tests/` directory.
|
|
7
|
-
// But you could instead put them in `src/`, or put files like "name.js" (or .jsx, .ts, or .tsx) in `test` or `__tests__` directories somewhere.
|
|
8
|
-
|
|
9
|
-
describe( 'ai-client', () => {
|
|
10
|
-
it( 'should export something', () => {
|
|
11
|
-
expect( true ).toBe( true );
|
|
12
|
-
} );
|
|
13
|
-
} );
|