@automattic/jetpack-ai-client 0.33.0 → 0.33.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/CHANGELOG.md +11 -0
- package/build/chrome-ai/get-availability.js +1 -1
- package/build/components/ai-control/ai-control.d.ts +2 -3
- package/build/components/ai-control/block-ai-control.d.ts +5 -6
- package/build/components/ai-control/block-ai-control.js +2 -2
- package/build/components/ai-control/extension-ai-control.d.ts +5 -6
- package/build/components/ai-control/extension-ai-control.js +1 -1
- package/build/components/ai-feedback/index.d.ts +3 -3
- package/build/components/ai-feedback/index.js +1 -1
- package/build/components/ai-icon/index.d.ts +1 -1
- package/build/components/ai-icon/index.js +1 -4
- package/build/components/ai-image/components/ai-image-modal.d.ts +3 -5
- package/build/components/ai-image/components/ai-image-modal.js +1 -7
- package/build/components/ai-image/components/carrousel.d.ts +3 -2
- package/build/components/ai-image/components/carrousel.js +2 -8
- package/build/components/ai-image/components/usage-counter.d.ts +1 -4
- package/build/components/ai-image/components/usage-counter.js +1 -7
- package/build/components/ai-image/featured-image.d.ts +1 -4
- package/build/components/ai-image/featured-image.js +1 -7
- package/build/components/ai-image/general-purpose-image.d.ts +1 -4
- package/build/components/ai-image/general-purpose-image.js +1 -7
- package/build/components/ai-image/hooks/use-ai-image.d.ts +2 -3
- package/build/components/ai-modal-footer/index.d.ts +3 -3
- package/build/components/ai-modal-footer/index.js +1 -1
- package/build/components/ai-status-indicator/index.d.ts +3 -3
- package/build/components/ai-status-indicator/index.js +1 -1
- package/build/components/audio-duration-display/index.d.ts +3 -3
- package/build/components/audio-duration-display/index.js +1 -1
- package/build/components/message/index.d.ts +14 -14
- package/build/components/message/index.js +6 -6
- package/build/components/modal/index.d.ts +3 -2
- package/build/components/modal/index.js +1 -7
- package/build/data-flow/context.d.ts +5 -8
- package/build/data-flow/context.js +1 -1
- package/build/data-flow/with-ai-assistant-data.d.ts +4 -4
- package/build/data-flow/with-ai-assistant-data.js +2 -2
- package/build/logo-generator/components/feature-fetch-failure-screen.d.ts +2 -2
- package/build/logo-generator/components/first-load-screen.d.ts +2 -2
- package/build/logo-generator/components/generator-modal.d.ts +2 -2
- package/build/logo-generator/components/history-carousel.d.ts +2 -2
- package/build/logo-generator/components/image-loader.d.ts +2 -2
- package/build/logo-generator/components/logo-presenter.d.ts +2 -2
- package/build/logo-generator/components/logo-presenter.js +1 -1
- package/build/logo-generator/components/upgrade-screen.d.ts +2 -2
- package/build/logo-generator/components/visit-site-banner.d.ts +2 -2
- package/package.json +26 -27
- package/src/chrome-ai/get-availability.ts +1 -1
- package/src/components/ai-control/ai-control.tsx +2 -3
- package/src/components/ai-control/block-ai-control.tsx +5 -5
- package/src/components/ai-control/extension-ai-control.tsx +5 -5
- package/src/components/ai-feedback/index.tsx +3 -3
- package/src/components/ai-icon/index.tsx +2 -4
- package/src/components/ai-image/components/ai-image-modal.tsx +3 -8
- package/src/components/ai-image/components/carrousel.tsx +5 -10
- package/src/components/ai-image/components/usage-counter.tsx +2 -7
- package/src/components/ai-image/featured-image.tsx +2 -7
- package/src/components/ai-image/general-purpose-image.tsx +2 -7
- package/src/components/ai-image/hooks/use-ai-image.ts +2 -2
- package/src/components/ai-modal-footer/index.tsx +3 -3
- package/src/components/ai-status-indicator/index.tsx +3 -3
- package/src/components/audio-duration-display/index.tsx +3 -3
- package/src/components/message/index.tsx +16 -16
- package/src/components/modal/index.tsx +3 -8
- package/src/data-flow/Readme.md +2 -2
- package/src/data-flow/context.tsx +5 -4
- package/src/data-flow/with-ai-assistant-data.tsx +38 -41
- package/src/icons/ai-assistant.tsx +0 -1
- package/src/icons/mic.tsx +0 -1
- package/src/icons/origami-plane.tsx +0 -1
- package/src/icons/player-pause.tsx +0 -1
- package/src/icons/player-play.tsx +0 -1
- package/src/icons/player-stop.tsx +0 -1
- package/src/icons/speak-tone.tsx +0 -1
- package/src/logo-generator/components/feature-fetch-failure-screen.tsx +2 -2
- package/src/logo-generator/components/first-load-screen.tsx +2 -2
- package/src/logo-generator/components/generator-modal.tsx +3 -3
- package/src/logo-generator/components/history-carousel.tsx +2 -2
- package/src/logo-generator/components/image-loader.tsx +2 -2
- package/src/logo-generator/components/logo-presenter.tsx +11 -13
- package/src/logo-generator/components/prompt.tsx +4 -3
- package/src/logo-generator/components/upgrade-screen.tsx +2 -2
- package/src/logo-generator/components/visit-site-banner.tsx +2 -2
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import {
|
|
5
2
|
useAnalytics,
|
|
6
3
|
PLAN_TYPE_UNLIMITED,
|
|
@@ -12,9 +9,6 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
12
9
|
import { useCallback, useState } from '@wordpress/element';
|
|
13
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
14
11
|
import debugFactory from 'debug';
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
12
|
import './style.scss';
|
|
19
13
|
import { PLACEMENT_JETPACK_SIDEBAR, PLACEMENT_DOCUMENT_SETTINGS } from '../../constants.ts';
|
|
20
14
|
import useAiFeature from '../../hooks/use-ai-feature/index.ts';
|
|
@@ -32,6 +26,7 @@ import {
|
|
|
32
26
|
} from './types.ts';
|
|
33
27
|
import type { ImageResponse } from './hooks/use-ai-image.ts';
|
|
34
28
|
import type { EditorSelectors } from './types.ts';
|
|
29
|
+
import type { ReactElement } from 'react';
|
|
35
30
|
|
|
36
31
|
const debug = debugFactory( 'jetpack-ai-client:featured-image' );
|
|
37
32
|
|
|
@@ -45,7 +40,7 @@ type FeaturedImageProps = {
|
|
|
45
40
|
/**
|
|
46
41
|
* FeaturedImage component
|
|
47
42
|
* @param {FeaturedImageProps} props - The component properties.
|
|
48
|
-
* @return {
|
|
43
|
+
* @return {ReactElement} - rendered component.
|
|
49
44
|
*/
|
|
50
45
|
export default function FeaturedImage( {
|
|
51
46
|
busy,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import {
|
|
5
2
|
useAnalytics,
|
|
6
3
|
PLAN_TYPE_UNLIMITED,
|
|
@@ -10,9 +7,6 @@ import { Button } from '@wordpress/components';
|
|
|
10
7
|
import { useCallback, useState } from '@wordpress/element';
|
|
11
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
9
|
import debugFactory from 'debug';
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
10
|
import './style.scss';
|
|
17
11
|
import useAiFeature from '../../hooks/use-ai-feature/index.ts';
|
|
18
12
|
import usePostContent from '../../hooks/use-post-content.ts';
|
|
@@ -25,6 +19,7 @@ import {
|
|
|
25
19
|
IMAGE_GENERATION_MODEL_DALL_E_3,
|
|
26
20
|
GENERAL_IMAGE_FEATURE_NAME,
|
|
27
21
|
} from './types.ts';
|
|
22
|
+
import type { ReactElement } from 'react';
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* The type for the callback function that is called when the user selects an image.
|
|
@@ -45,7 +40,7 @@ const debug = debugFactory( 'jetpack-ai:general-purpose-image' );
|
|
|
45
40
|
/**
|
|
46
41
|
* GeneralPurposeImage component
|
|
47
42
|
* @param {GeneralPurposeImageProps} props - The component properties.
|
|
48
|
-
* @return {
|
|
43
|
+
* @return {ReactElement} - rendered component.
|
|
49
44
|
*/
|
|
50
45
|
export default function GeneralPurposeImage( {
|
|
51
46
|
placement,
|
|
@@ -5,7 +5,6 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { cleanForSlug } from '@wordpress/url';
|
|
8
|
-
import React from 'react';
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
import type { RoleType } from '../../../types.ts';
|
|
26
25
|
import type { CarrouselImageData, CarrouselImages } from '../components/carrousel.tsx';
|
|
27
26
|
import type { FeatureControl } from '@automattic/jetpack-shared-extension-utils/store/wordpress-com/types';
|
|
27
|
+
import type { RefObject } from 'react';
|
|
28
28
|
|
|
29
29
|
type ImageFeatureControl = FeatureControl & {
|
|
30
30
|
styles: Array< ImageStyleObject > | [];
|
|
@@ -69,7 +69,7 @@ type UseAiImageReturn = {
|
|
|
69
69
|
currentImage: CarrouselImageData;
|
|
70
70
|
currentPointer: CarrouselImageData;
|
|
71
71
|
images: CarrouselImages;
|
|
72
|
-
pointer:
|
|
72
|
+
pointer: RefObject< number >;
|
|
73
73
|
imageStyles: Array< ImageStyleObject >;
|
|
74
74
|
guessStyle: GuessStyleFunction;
|
|
75
75
|
};
|
|
@@ -12,7 +12,7 @@ import './style.scss';
|
|
|
12
12
|
/**
|
|
13
13
|
* Types
|
|
14
14
|
*/
|
|
15
|
-
import type
|
|
15
|
+
import type { ReactElement } from 'react';
|
|
16
16
|
|
|
17
17
|
type AiModalFooterProps = {
|
|
18
18
|
onGuidelinesClick?: () => void;
|
|
@@ -23,12 +23,12 @@ type AiModalFooterProps = {
|
|
|
23
23
|
* AiModalFooter component.
|
|
24
24
|
*
|
|
25
25
|
* @param {AiModalFooterProps} props - component props.
|
|
26
|
-
* @return {
|
|
26
|
+
* @return {ReactElement} - rendered component.
|
|
27
27
|
*/
|
|
28
28
|
export default function AiModalFooter( {
|
|
29
29
|
onGuidelinesClick,
|
|
30
30
|
onFeedbackClick,
|
|
31
|
-
}: AiModalFooterProps ):
|
|
31
|
+
}: AiModalFooterProps ): ReactElement {
|
|
32
32
|
const handleGuidelinesClick = useCallback( () => {
|
|
33
33
|
onGuidelinesClick?.();
|
|
34
34
|
}, [ onGuidelinesClick ] );
|
|
@@ -8,7 +8,7 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { RequestingStateProp } from '../../types.ts';
|
|
10
10
|
export type AiStatusIndicatorIconSize = 24 | 32 | 48 | 64;
|
|
11
|
-
import type
|
|
11
|
+
import type { ReactElement } from 'react';
|
|
12
12
|
|
|
13
13
|
import './style.scss';
|
|
14
14
|
|
|
@@ -21,9 +21,9 @@ export type AiStatusIndicatorProps = {
|
|
|
21
21
|
* AiStatusIndicator component.
|
|
22
22
|
*
|
|
23
23
|
* @param {AiStatusIndicatorProps} props - component props.
|
|
24
|
-
* @return {
|
|
24
|
+
* @return {ReactElement} - rendered component.
|
|
25
25
|
*/
|
|
26
|
-
export default function AiStatusIndicator( { state }: AiStatusIndicatorProps ):
|
|
26
|
+
export default function AiStatusIndicator( { state }: AiStatusIndicatorProps ): ReactElement {
|
|
27
27
|
return (
|
|
28
28
|
<div
|
|
29
29
|
className={ clsx( 'jetpack-ai-status-indicator__icon-wrapper', {
|
|
@@ -5,7 +5,7 @@ import { formatTime } from './lib/media.ts';
|
|
|
5
5
|
/*
|
|
6
6
|
* Types
|
|
7
7
|
*/
|
|
8
|
-
import type
|
|
8
|
+
import type { ReactElement } from 'react';
|
|
9
9
|
|
|
10
10
|
type AudioDurationDisplayProps = {
|
|
11
11
|
duration: number;
|
|
@@ -16,11 +16,11 @@ type AudioDurationDisplayProps = {
|
|
|
16
16
|
* AudioDurationDisplay component.
|
|
17
17
|
*
|
|
18
18
|
* @param {AudioDurationDisplayProps} props - Component props.
|
|
19
|
-
* @return {
|
|
19
|
+
* @return {ReactElement} Rendered component.
|
|
20
20
|
*/
|
|
21
21
|
export default function AudioDurationDisplay( {
|
|
22
22
|
duration,
|
|
23
23
|
className,
|
|
24
|
-
}: AudioDurationDisplayProps ):
|
|
24
|
+
}: AudioDurationDisplayProps ): ReactElement {
|
|
25
25
|
return <span className={ className }>{ formatTime( duration, { addDecimalPart: false } ) }</span>;
|
|
26
26
|
}
|
|
@@ -17,7 +17,7 @@ import AiFeedbackThumbs from '../ai-feedback/index.tsx';
|
|
|
17
17
|
* Types
|
|
18
18
|
*/
|
|
19
19
|
import type { SuggestionErrorCode } from '../../types.ts';
|
|
20
|
-
import type
|
|
20
|
+
import type { MouseEvent, ReactElement, ReactNode } from 'react';
|
|
21
21
|
|
|
22
22
|
export const MESSAGE_SEVERITY_WARNING = 'warning';
|
|
23
23
|
export const MESSAGE_SEVERITY_ERROR = 'error';
|
|
@@ -40,17 +40,17 @@ type AiFeedbackThumbsOptions = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export type MessageProps = {
|
|
43
|
-
icon?:
|
|
43
|
+
icon?: ReactNode;
|
|
44
44
|
severity?: MessageSeverityProp;
|
|
45
45
|
aiFeedbackThumbsOptions?: AiFeedbackThumbsOptions;
|
|
46
|
-
children:
|
|
46
|
+
children: ReactNode;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export type GuidelineMessageProps = {
|
|
50
50
|
aiFeedbackThumbsOptions?: AiFeedbackThumbsOptions;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export type OnUpgradeClick = ( event?:
|
|
53
|
+
export type OnUpgradeClick = ( event?: MouseEvent< HTMLButtonElement > ) => void;
|
|
54
54
|
|
|
55
55
|
export type UpgradeMessageProps = {
|
|
56
56
|
requestsRemaining: number;
|
|
@@ -78,7 +78,7 @@ const messageIconsMap = {
|
|
|
78
78
|
* React component to render a block message.
|
|
79
79
|
*
|
|
80
80
|
* @param {MessageProps} props - Component props.
|
|
81
|
-
* @return {
|
|
81
|
+
* @return {ReactElement} Banner component.
|
|
82
82
|
*/
|
|
83
83
|
export default function Message( {
|
|
84
84
|
severity = MESSAGE_SEVERITY_INFO,
|
|
@@ -91,7 +91,7 @@ export default function Message( {
|
|
|
91
91
|
onRate: () => {},
|
|
92
92
|
},
|
|
93
93
|
children,
|
|
94
|
-
}: MessageProps ):
|
|
94
|
+
}: MessageProps ): ReactElement {
|
|
95
95
|
return (
|
|
96
96
|
<div
|
|
97
97
|
className={ clsx(
|
|
@@ -122,9 +122,9 @@ export default function Message( {
|
|
|
122
122
|
/**
|
|
123
123
|
* React component to render a learn more link.
|
|
124
124
|
*
|
|
125
|
-
* @return {
|
|
125
|
+
* @return {ReactElement} - Learn more link component.
|
|
126
126
|
*/
|
|
127
|
-
function LearnMoreLink():
|
|
127
|
+
function LearnMoreLink(): ReactElement {
|
|
128
128
|
return (
|
|
129
129
|
<ExternalLink href="https://jetpack.com/redirect/?source=ai-guidelines">
|
|
130
130
|
{ __( 'Learn more', 'jetpack-ai-client' ) }
|
|
@@ -136,7 +136,7 @@ function LearnMoreLink(): React.ReactElement {
|
|
|
136
136
|
* React component to render a guideline message.
|
|
137
137
|
*
|
|
138
138
|
* @param {GuidelineMessageProps} props - Component props.
|
|
139
|
-
* @return {
|
|
139
|
+
* @return {ReactElement} - Message component.
|
|
140
140
|
*/
|
|
141
141
|
export function GuidelineMessage( {
|
|
142
142
|
aiFeedbackThumbsOptions = {
|
|
@@ -146,7 +146,7 @@ export function GuidelineMessage( {
|
|
|
146
146
|
block: null,
|
|
147
147
|
onRate: () => {},
|
|
148
148
|
},
|
|
149
|
-
}: GuidelineMessageProps ):
|
|
149
|
+
}: GuidelineMessageProps ): ReactElement {
|
|
150
150
|
return (
|
|
151
151
|
<Message aiFeedbackThumbsOptions={ aiFeedbackThumbsOptions }>
|
|
152
152
|
<span>
|
|
@@ -160,9 +160,9 @@ export function GuidelineMessage( {
|
|
|
160
160
|
/**
|
|
161
161
|
* React component to render a fair usage limit message.
|
|
162
162
|
*
|
|
163
|
-
* @return {
|
|
163
|
+
* @return {ReactElement} - Message component.
|
|
164
164
|
*/
|
|
165
|
-
export function FairUsageLimitMessage():
|
|
165
|
+
export function FairUsageLimitMessage(): ReactElement {
|
|
166
166
|
const message = __(
|
|
167
167
|
"You've reached this month's request limit, per our <link>fair usage policy</link>",
|
|
168
168
|
'jetpack-ai-client'
|
|
@@ -180,14 +180,14 @@ export function FairUsageLimitMessage(): React.ReactElement {
|
|
|
180
180
|
* React component to render an upgrade message for free tier users
|
|
181
181
|
*
|
|
182
182
|
* @param {number} requestsRemaining - Number of requests remaining.
|
|
183
|
-
* @return {
|
|
183
|
+
* @return {ReactElement} - Message component.
|
|
184
184
|
*/
|
|
185
185
|
export function UpgradeMessage( {
|
|
186
186
|
requestsRemaining,
|
|
187
187
|
severity,
|
|
188
188
|
onUpgradeClick,
|
|
189
189
|
upgradeUrl,
|
|
190
|
-
}: UpgradeMessageProps ):
|
|
190
|
+
}: UpgradeMessageProps ): ReactElement {
|
|
191
191
|
let messageSeverity = severity;
|
|
192
192
|
|
|
193
193
|
if ( messageSeverity == null ) {
|
|
@@ -219,7 +219,7 @@ export function UpgradeMessage( {
|
|
|
219
219
|
* React component to render an error message
|
|
220
220
|
*
|
|
221
221
|
* @param {number} requestsRemaining - Number of requests remaining.
|
|
222
|
-
* @return {
|
|
222
|
+
* @return {ReactElement} - Message component.
|
|
223
223
|
*/
|
|
224
224
|
export function ErrorMessage( {
|
|
225
225
|
error,
|
|
@@ -227,7 +227,7 @@ export function ErrorMessage( {
|
|
|
227
227
|
onTryAgainClick,
|
|
228
228
|
onUpgradeClick,
|
|
229
229
|
upgradeUrl,
|
|
230
|
-
}: ErrorMessageProps ):
|
|
230
|
+
}: ErrorMessageProps ): ReactElement {
|
|
231
231
|
const errorMessage = error || __( 'Something went wrong', 'jetpack-ai-client' );
|
|
232
232
|
|
|
233
233
|
return (
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Modal, Button } from '@wordpress/components';
|
|
5
2
|
import { __ } from '@wordpress/i18n';
|
|
6
3
|
import { close } from '@wordpress/icons';
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
4
|
import AiStatusIndicator from '../ai-status-indicator/index.tsx';
|
|
11
5
|
import type { RequestingStateProp } from '../../types.ts';
|
|
12
6
|
import './style.scss';
|
|
7
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
13
8
|
|
|
14
9
|
const ModalHeader = ( {
|
|
15
10
|
requestingState,
|
|
@@ -32,7 +27,7 @@ const ModalHeader = ( {
|
|
|
32
27
|
};
|
|
33
28
|
|
|
34
29
|
type AiAssistantModalProps = {
|
|
35
|
-
children:
|
|
30
|
+
children: ReactNode;
|
|
36
31
|
handleClose: () => void;
|
|
37
32
|
hideHeader?: boolean;
|
|
38
33
|
requestingState?: RequestingStateProp;
|
|
@@ -43,7 +38,7 @@ type AiAssistantModalProps = {
|
|
|
43
38
|
/**
|
|
44
39
|
* AiAssistantModal component
|
|
45
40
|
* @param {AiAssistantModalProps} props - The component properties.
|
|
46
|
-
* @return {
|
|
41
|
+
* @return {ReactElement} - rendered component.
|
|
47
42
|
*/
|
|
48
43
|
export default function AiAssistantModal( {
|
|
49
44
|
children,
|
package/src/data-flow/Readme.md
CHANGED
|
@@ -59,7 +59,7 @@ Use the Provider in your component's render method to wrap the children componen
|
|
|
59
59
|
You can access the context values in your child components using the `useContext` hook:
|
|
60
60
|
|
|
61
61
|
```javascript
|
|
62
|
-
const aiContext =
|
|
62
|
+
const aiContext = useContext( AiDataContext );
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
### Context Values
|
|
@@ -129,4 +129,4 @@ An array of block names (e.g., `[ 'core/paragraph', 'core/image' ]`) to which th
|
|
|
129
129
|
|
|
130
130
|
When a block type matches one of the specified names in `options.blocks`, the returned component will be wrapped with the AI Assistant Data context, providing all the available data and functionalities. The original component will be returned without any modifications for other block types.
|
|
131
131
|
|
|
132
|
-
_Before using this function, ensure the AI Assistant Data is available in the higher component hierarchy. The [Ai Data Context](#ai-assistant-content) should typically wrap the top-level component or application._
|
|
132
|
+
_Before using this function, ensure the AI Assistant Data is available in the higher component hierarchy. The [Ai Data Context](#ai-assistant-content) should typically wrap the top-level component or application._
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { createContext } from 'react';
|
|
5
5
|
/**
|
|
6
6
|
* Types & Constants
|
|
7
7
|
*/
|
|
@@ -9,6 +9,7 @@ import SuggestionsEventSource from '../suggestions-event-source/index.ts';
|
|
|
9
9
|
import type { AskQuestionOptionsArgProps } from '../ask-question/index.ts';
|
|
10
10
|
import type { RequestingErrorProps } from '../hooks/use-ai-suggestions/index.ts';
|
|
11
11
|
import type { PromptProp, RequestingStateProp } from '../types.ts';
|
|
12
|
+
import type { ReactElement } from 'react';
|
|
12
13
|
|
|
13
14
|
export type AiDataContextProps = {
|
|
14
15
|
/*
|
|
@@ -51,7 +52,7 @@ type AiDataContextProviderProps = {
|
|
|
51
52
|
/*
|
|
52
53
|
* Children
|
|
53
54
|
*/
|
|
54
|
-
children:
|
|
55
|
+
children: ReactElement;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -65,7 +66,7 @@ export const AiDataContext = createContext< AiDataContextProps | object >( {} );
|
|
|
65
66
|
* AI Data Context Provider
|
|
66
67
|
*
|
|
67
68
|
* @param {AiDataContextProviderProps} props - Component props.
|
|
68
|
-
* @return {
|
|
69
|
+
* @return {ReactElement} Context provider.
|
|
69
70
|
* @example
|
|
70
71
|
* <AiDataContextProvider value={ value }>
|
|
71
72
|
* { children }
|
|
@@ -74,6 +75,6 @@ export const AiDataContext = createContext< AiDataContextProps | object >( {} );
|
|
|
74
75
|
export const AiDataContextProvider = ( {
|
|
75
76
|
value,
|
|
76
77
|
children,
|
|
77
|
-
}: AiDataContextProviderProps ):
|
|
78
|
+
}: AiDataContextProviderProps ): ReactElement => (
|
|
78
79
|
<AiDataContext.Provider value={ value } children={ children } />
|
|
79
80
|
);
|
|
@@ -3,62 +3,59 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
5
5
|
import { useMemo } from '@wordpress/element';
|
|
6
|
-
import React from 'react';
|
|
7
6
|
/**
|
|
8
7
|
* Internal Dependencies
|
|
9
8
|
*/
|
|
10
9
|
import useAiSuggestions from '../hooks/use-ai-suggestions/index.ts';
|
|
11
10
|
import { AiDataContextProvider } from './index.ts';
|
|
11
|
+
import type { ReactElement, ComponentType } from 'react';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* High Order Component that provides the
|
|
15
15
|
* AI Assistant Data context to the wrapped component.
|
|
16
16
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @return {
|
|
17
|
+
* @param {ReactElement} WrappedComponent - component to wrap.
|
|
18
|
+
* @return {ReactElement} Wrapped component, with the AI Assistant Data context.
|
|
19
19
|
*/
|
|
20
|
-
const withAiDataProvider = createHigherOrderComponent(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const withAiDataProvider = createHigherOrderComponent( ( WrappedComponent: ComponentType ) => {
|
|
21
|
+
return props => {
|
|
22
|
+
// Connect with the AI Assistant communication layer.
|
|
23
|
+
const {
|
|
24
|
+
suggestion,
|
|
25
|
+
error: requestingError,
|
|
26
|
+
requestingState,
|
|
27
|
+
request: requestSuggestion,
|
|
28
|
+
stopSuggestion,
|
|
29
|
+
eventSource,
|
|
30
|
+
} = useAiSuggestions();
|
|
31
|
+
|
|
32
|
+
// Build the context value to pass to the ai assistant data provider.
|
|
33
|
+
const dataContextValue = useMemo(
|
|
34
|
+
() => ( {
|
|
25
35
|
suggestion,
|
|
26
|
-
|
|
36
|
+
requestingError,
|
|
27
37
|
requestingState,
|
|
28
|
-
request: requestSuggestion,
|
|
29
|
-
stopSuggestion,
|
|
30
38
|
eventSource,
|
|
31
|
-
} = useAiSuggestions();
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
suggestion,
|
|
46
|
-
requestingError,
|
|
47
|
-
requestingState,
|
|
48
|
-
eventSource,
|
|
49
|
-
requestSuggestion,
|
|
50
|
-
stopSuggestion,
|
|
51
|
-
]
|
|
52
|
-
);
|
|
40
|
+
requestSuggestion,
|
|
41
|
+
stopSuggestion,
|
|
42
|
+
} ),
|
|
43
|
+
[
|
|
44
|
+
suggestion,
|
|
45
|
+
requestingError,
|
|
46
|
+
requestingState,
|
|
47
|
+
eventSource,
|
|
48
|
+
requestSuggestion,
|
|
49
|
+
stopSuggestion,
|
|
50
|
+
]
|
|
51
|
+
);
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'withAiDataProvider'
|
|
62
|
-
);
|
|
53
|
+
return (
|
|
54
|
+
<AiDataContextProvider value={ dataContextValue }>
|
|
55
|
+
<WrappedComponent { ...props } />
|
|
56
|
+
</AiDataContextProvider>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
}, 'withAiDataProvider' );
|
|
63
60
|
|
|
64
61
|
export default withAiDataProvider;
|
package/src/icons/mic.tsx
CHANGED
package/src/icons/speak-tone.tsx
CHANGED
|
@@ -6,9 +6,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Types
|
|
8
8
|
*/
|
|
9
|
-
import type
|
|
9
|
+
import type { FC } from 'react';
|
|
10
10
|
|
|
11
|
-
export const FeatureFetchFailureScreen:
|
|
11
|
+
export const FeatureFetchFailureScreen: FC< {
|
|
12
12
|
onCancel: () => void;
|
|
13
13
|
onRetry?: () => void;
|
|
14
14
|
} > = ( { onCancel, onRetry } ) => {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import React from 'react';
|
|
6
5
|
/**
|
|
7
6
|
* Internal dependencies
|
|
8
7
|
*/
|
|
9
8
|
import { ImageLoader } from './image-loader.tsx';
|
|
10
9
|
import './first-load-screen.scss';
|
|
10
|
+
import type { FC } from 'react';
|
|
11
11
|
|
|
12
|
-
export const FirstLoadScreen:
|
|
12
|
+
export const FirstLoadScreen: FC< {
|
|
13
13
|
state?: 'loadingFeature' | 'analyzing' | 'generating';
|
|
14
14
|
} > = ( { state = 'loadingFeature' } ) => {
|
|
15
15
|
const loadingLabel = __( 'Loading…', 'jetpack-ai-client' );
|
|
@@ -36,11 +36,11 @@ import './generator-modal.scss';
|
|
|
36
36
|
* Types
|
|
37
37
|
*/
|
|
38
38
|
import type { GeneratorModalProps } from '../types.ts';
|
|
39
|
-
import type
|
|
39
|
+
import type { FC, ReactNode } from 'react';
|
|
40
40
|
|
|
41
41
|
const debug = debugFactory( 'jetpack-ai-calypso:generator-modal' );
|
|
42
42
|
|
|
43
|
-
export const GeneratorModal:
|
|
43
|
+
export const GeneratorModal: FC< GeneratorModalProps > = ( {
|
|
44
44
|
isOpen,
|
|
45
45
|
onClose,
|
|
46
46
|
onApplyLogo,
|
|
@@ -259,7 +259,7 @@ export const GeneratorModal: React.FC< GeneratorModalProps > = ( {
|
|
|
259
259
|
}
|
|
260
260
|
}, [ isOpen, handleModalOpen ] );
|
|
261
261
|
|
|
262
|
-
let body:
|
|
262
|
+
let body: ReactNode;
|
|
263
263
|
|
|
264
264
|
if ( loadingState ) {
|
|
265
265
|
body = <FirstLoadScreen state={ loadingState } />;
|
|
@@ -14,9 +14,9 @@ import './history-carousel.scss';
|
|
|
14
14
|
/**
|
|
15
15
|
* Types
|
|
16
16
|
*/
|
|
17
|
-
import type
|
|
17
|
+
import type { FC } from 'react';
|
|
18
18
|
|
|
19
|
-
export const HistoryCarousel:
|
|
19
|
+
export const HistoryCarousel: FC = () => {
|
|
20
20
|
const { tracks } = useAnalytics();
|
|
21
21
|
const { recordEvent: recordTracksEvent } = tracks;
|
|
22
22
|
const { logos, selectedLogo, setSelectedLogoIndex, context, isLoadingHistory } =
|
|
@@ -9,9 +9,9 @@ import loader from '../assets/images/loader.gif';
|
|
|
9
9
|
/**
|
|
10
10
|
* Types
|
|
11
11
|
*/
|
|
12
|
-
import type
|
|
12
|
+
import type { FC } from 'react';
|
|
13
13
|
|
|
14
|
-
export const ImageLoader:
|
|
14
|
+
export const ImageLoader: FC< { className?: string } > = ( { className = null } ) => {
|
|
15
15
|
return (
|
|
16
16
|
<img
|
|
17
17
|
src={ loader }
|