@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/chrome-ai/get-availability.js +1 -1
  3. package/build/components/ai-control/ai-control.d.ts +2 -3
  4. package/build/components/ai-control/block-ai-control.d.ts +5 -6
  5. package/build/components/ai-control/block-ai-control.js +2 -2
  6. package/build/components/ai-control/extension-ai-control.d.ts +5 -6
  7. package/build/components/ai-control/extension-ai-control.js +1 -1
  8. package/build/components/ai-feedback/index.d.ts +3 -3
  9. package/build/components/ai-feedback/index.js +1 -1
  10. package/build/components/ai-icon/index.d.ts +1 -1
  11. package/build/components/ai-icon/index.js +1 -4
  12. package/build/components/ai-image/components/ai-image-modal.d.ts +3 -5
  13. package/build/components/ai-image/components/ai-image-modal.js +1 -7
  14. package/build/components/ai-image/components/carrousel.d.ts +3 -2
  15. package/build/components/ai-image/components/carrousel.js +2 -8
  16. package/build/components/ai-image/components/usage-counter.d.ts +1 -4
  17. package/build/components/ai-image/components/usage-counter.js +1 -7
  18. package/build/components/ai-image/featured-image.d.ts +1 -4
  19. package/build/components/ai-image/featured-image.js +1 -7
  20. package/build/components/ai-image/general-purpose-image.d.ts +1 -4
  21. package/build/components/ai-image/general-purpose-image.js +1 -7
  22. package/build/components/ai-image/hooks/use-ai-image.d.ts +2 -3
  23. package/build/components/ai-modal-footer/index.d.ts +3 -3
  24. package/build/components/ai-modal-footer/index.js +1 -1
  25. package/build/components/ai-status-indicator/index.d.ts +3 -3
  26. package/build/components/ai-status-indicator/index.js +1 -1
  27. package/build/components/audio-duration-display/index.d.ts +3 -3
  28. package/build/components/audio-duration-display/index.js +1 -1
  29. package/build/components/message/index.d.ts +14 -14
  30. package/build/components/message/index.js +6 -6
  31. package/build/components/modal/index.d.ts +3 -2
  32. package/build/components/modal/index.js +1 -7
  33. package/build/data-flow/context.d.ts +5 -8
  34. package/build/data-flow/context.js +1 -1
  35. package/build/data-flow/with-ai-assistant-data.d.ts +4 -4
  36. package/build/data-flow/with-ai-assistant-data.js +2 -2
  37. package/build/logo-generator/components/feature-fetch-failure-screen.d.ts +2 -2
  38. package/build/logo-generator/components/first-load-screen.d.ts +2 -2
  39. package/build/logo-generator/components/generator-modal.d.ts +2 -2
  40. package/build/logo-generator/components/history-carousel.d.ts +2 -2
  41. package/build/logo-generator/components/image-loader.d.ts +2 -2
  42. package/build/logo-generator/components/logo-presenter.d.ts +2 -2
  43. package/build/logo-generator/components/logo-presenter.js +1 -1
  44. package/build/logo-generator/components/upgrade-screen.d.ts +2 -2
  45. package/build/logo-generator/components/visit-site-banner.d.ts +2 -2
  46. package/package.json +26 -27
  47. package/src/chrome-ai/get-availability.ts +1 -1
  48. package/src/components/ai-control/ai-control.tsx +2 -3
  49. package/src/components/ai-control/block-ai-control.tsx +5 -5
  50. package/src/components/ai-control/extension-ai-control.tsx +5 -5
  51. package/src/components/ai-feedback/index.tsx +3 -3
  52. package/src/components/ai-icon/index.tsx +2 -4
  53. package/src/components/ai-image/components/ai-image-modal.tsx +3 -8
  54. package/src/components/ai-image/components/carrousel.tsx +5 -10
  55. package/src/components/ai-image/components/usage-counter.tsx +2 -7
  56. package/src/components/ai-image/featured-image.tsx +2 -7
  57. package/src/components/ai-image/general-purpose-image.tsx +2 -7
  58. package/src/components/ai-image/hooks/use-ai-image.ts +2 -2
  59. package/src/components/ai-modal-footer/index.tsx +3 -3
  60. package/src/components/ai-status-indicator/index.tsx +3 -3
  61. package/src/components/audio-duration-display/index.tsx +3 -3
  62. package/src/components/message/index.tsx +16 -16
  63. package/src/components/modal/index.tsx +3 -8
  64. package/src/data-flow/Readme.md +2 -2
  65. package/src/data-flow/context.tsx +5 -4
  66. package/src/data-flow/with-ai-assistant-data.tsx +38 -41
  67. package/src/icons/ai-assistant.tsx +0 -1
  68. package/src/icons/mic.tsx +0 -1
  69. package/src/icons/origami-plane.tsx +0 -1
  70. package/src/icons/player-pause.tsx +0 -1
  71. package/src/icons/player-play.tsx +0 -1
  72. package/src/icons/player-stop.tsx +0 -1
  73. package/src/icons/speak-tone.tsx +0 -1
  74. package/src/logo-generator/components/feature-fetch-failure-screen.tsx +2 -2
  75. package/src/logo-generator/components/first-load-screen.tsx +2 -2
  76. package/src/logo-generator/components/generator-modal.tsx +3 -3
  77. package/src/logo-generator/components/history-carousel.tsx +2 -2
  78. package/src/logo-generator/components/image-loader.tsx +2 -2
  79. package/src/logo-generator/components/logo-presenter.tsx +11 -13
  80. package/src/logo-generator/components/prompt.tsx +4 -3
  81. package/src/logo-generator/components/upgrade-screen.tsx +2 -2
  82. 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 {React.ReactElement} - rendered component.
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 {React.ReactElement} - rendered component.
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: React.RefObject< number >;
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 React from 'react';
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 {React.ReactElement} - rendered component.
26
+ * @return {ReactElement} - rendered component.
27
27
  */
28
28
  export default function AiModalFooter( {
29
29
  onGuidelinesClick,
30
30
  onFeedbackClick,
31
- }: AiModalFooterProps ): React.ReactElement {
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 React from 'react';
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 {React.ReactElement} - rendered component.
24
+ * @return {ReactElement} - rendered component.
25
25
  */
26
- export default function AiStatusIndicator( { state }: AiStatusIndicatorProps ): React.ReactElement {
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 React from 'react';
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 {React.ReactElement} Rendered component.
19
+ * @return {ReactElement} Rendered component.
20
20
  */
21
21
  export default function AudioDurationDisplay( {
22
22
  duration,
23
23
  className,
24
- }: AudioDurationDisplayProps ): React.ReactElement {
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 React from 'react';
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?: React.ReactNode;
43
+ icon?: ReactNode;
44
44
  severity?: MessageSeverityProp;
45
45
  aiFeedbackThumbsOptions?: AiFeedbackThumbsOptions;
46
- children: React.ReactNode;
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?: React.MouseEvent< HTMLButtonElement > ) => void;
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 {React.ReactElement} Banner component.
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 ): React.ReactElement {
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 {React.ReactElement} - Learn more link component.
125
+ * @return {ReactElement} - Learn more link component.
126
126
  */
127
- function LearnMoreLink(): React.ReactElement {
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 {React.ReactElement} - Message component.
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 ): React.ReactElement {
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 {React.ReactElement} - Message component.
163
+ * @return {ReactElement} - Message component.
164
164
  */
165
- export function FairUsageLimitMessage(): React.ReactElement {
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 {React.ReactElement} - Message component.
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 ): React.ReactElement {
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 {React.ReactElement} - Message component.
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 ): React.ReactElement {
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: React.ReactNode;
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 {React.ReactElement} - rendered component.
41
+ * @return {ReactElement} - rendered component.
47
42
  */
48
43
  export default function AiAssistantModal( {
49
44
  children,
@@ -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 = React.useContext( AiDataContext );
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 React, { createContext } from 'react';
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: React.ReactElement;
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 {React.ReactElement} Context provider.
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 ): React.ReactElement => (
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 {React.ReactElement} WrappedComponent - component to wrap.
18
- * @return {React.ReactElement} Wrapped component, with the AI Assistant Data context.
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
- ( WrappedComponent: React.ComponentType ) => {
22
- return props => {
23
- // Connect with the AI Assistant communication layer.
24
- const {
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
- error: requestingError,
36
+ requestingError,
27
37
  requestingState,
28
- request: requestSuggestion,
29
- stopSuggestion,
30
38
  eventSource,
31
- } = useAiSuggestions();
32
39
 
33
- // Build the context value to pass to the ai assistant data provider.
34
- const dataContextValue = useMemo(
35
- () => ( {
36
- suggestion,
37
- requestingError,
38
- requestingState,
39
- eventSource,
40
-
41
- requestSuggestion,
42
- stopSuggestion,
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
- return (
55
- <AiDataContextProvider value={ dataContextValue }>
56
- <WrappedComponent { ...props } />
57
- </AiDataContextProvider>
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;
@@ -2,7 +2,6 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { SVG, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const aiAssistant = (
8
7
  <SVG
package/src/icons/mic.tsx CHANGED
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { SVG, Rect, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const mic = (
8
7
  <SVG width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/SVG">
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { SVG, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const origamiPlane = (
8
7
  <SVG
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { SVG, Path, Rect } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const playerPause = (
8
7
  <SVG width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/SVG">
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { SVG, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const playerPlay = (
8
7
  <SVG width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { SVG, Rect, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const playerStop = (
8
7
  <SVG width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/SVG">
@@ -2,7 +2,6 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { SVG, Path } from '@wordpress/components';
5
- import React from 'react';
6
5
 
7
6
  const speakTone = (
8
7
  <SVG width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -6,9 +6,9 @@ import { __ } from '@wordpress/i18n';
6
6
  /**
7
7
  * Types
8
8
  */
9
- import type React from 'react';
9
+ import type { FC } from 'react';
10
10
 
11
- export const FeatureFetchFailureScreen: React.FC< {
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: React.FC< {
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 React from 'react';
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: React.FC< GeneratorModalProps > = ( {
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: React.ReactNode;
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 React from 'react';
17
+ import type { FC } from 'react';
18
18
 
19
- export const HistoryCarousel: React.FC = () => {
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 React from 'react';
12
+ import type { FC } from 'react';
13
13
 
14
- export const ImageLoader: React.FC< { className?: string } > = ( { className = null } ) => {
14
+ export const ImageLoader: FC< { className?: string } > = ( { className = null } ) => {
15
15
  return (
16
16
  <img
17
17
  src={ loader }