@automattic/jetpack-ai-client 0.32.1 → 0.33.1

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 (87) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/api-fetch/index.d.ts +9 -1
  3. package/build/chrome-ai/get-availability.js +35 -3
  4. package/build/components/ai-control/ai-control.d.ts +2 -3
  5. package/build/components/ai-control/block-ai-control.d.ts +5 -6
  6. package/build/components/ai-control/block-ai-control.js +2 -2
  7. package/build/components/ai-control/extension-ai-control.d.ts +5 -6
  8. package/build/components/ai-control/extension-ai-control.js +1 -1
  9. package/build/components/ai-feedback/index.d.ts +3 -3
  10. package/build/components/ai-feedback/index.js +1 -1
  11. package/build/components/ai-icon/index.d.ts +1 -1
  12. package/build/components/ai-icon/index.js +1 -4
  13. package/build/components/ai-image/components/ai-image-modal.d.ts +3 -5
  14. package/build/components/ai-image/components/ai-image-modal.js +1 -7
  15. package/build/components/ai-image/components/carrousel.d.ts +3 -2
  16. package/build/components/ai-image/components/carrousel.js +2 -8
  17. package/build/components/ai-image/components/usage-counter.d.ts +1 -4
  18. package/build/components/ai-image/components/usage-counter.js +1 -7
  19. package/build/components/ai-image/featured-image.d.ts +1 -4
  20. package/build/components/ai-image/featured-image.js +1 -7
  21. package/build/components/ai-image/general-purpose-image.d.ts +1 -4
  22. package/build/components/ai-image/general-purpose-image.js +1 -7
  23. package/build/components/ai-image/hooks/use-ai-image.d.ts +2 -3
  24. package/build/components/ai-modal-footer/index.d.ts +3 -3
  25. package/build/components/ai-modal-footer/index.js +1 -1
  26. package/build/components/ai-status-indicator/index.d.ts +3 -3
  27. package/build/components/ai-status-indicator/index.js +1 -1
  28. package/build/components/audio-duration-display/index.d.ts +3 -3
  29. package/build/components/audio-duration-display/index.js +1 -1
  30. package/build/components/message/index.d.ts +14 -14
  31. package/build/components/message/index.js +6 -6
  32. package/build/components/modal/index.d.ts +3 -2
  33. package/build/components/modal/index.js +1 -7
  34. package/build/data-flow/context.d.ts +5 -8
  35. package/build/data-flow/context.js +1 -1
  36. package/build/data-flow/with-ai-assistant-data.d.ts +4 -4
  37. package/build/data-flow/with-ai-assistant-data.js +2 -2
  38. package/build/jwt/index.js +4 -4
  39. package/build/logo-generator/components/feature-fetch-failure-screen.d.ts +2 -2
  40. package/build/logo-generator/components/first-load-screen.d.ts +2 -2
  41. package/build/logo-generator/components/generator-modal.d.ts +2 -2
  42. package/build/logo-generator/components/history-carousel.d.ts +2 -2
  43. package/build/logo-generator/components/image-loader.d.ts +2 -2
  44. package/build/logo-generator/components/logo-presenter.d.ts +2 -2
  45. package/build/logo-generator/components/logo-presenter.js +1 -1
  46. package/build/logo-generator/components/upgrade-screen.d.ts +2 -2
  47. package/build/logo-generator/components/visit-site-banner.d.ts +2 -2
  48. package/package.json +19 -19
  49. package/src/api-fetch/index.ts +11 -1
  50. package/src/chrome-ai/get-availability.ts +50 -5
  51. package/src/components/ai-control/ai-control.tsx +2 -3
  52. package/src/components/ai-control/block-ai-control.tsx +5 -5
  53. package/src/components/ai-control/extension-ai-control.tsx +5 -5
  54. package/src/components/ai-feedback/index.tsx +3 -3
  55. package/src/components/ai-icon/index.tsx +2 -4
  56. package/src/components/ai-image/components/ai-image-modal.tsx +3 -8
  57. package/src/components/ai-image/components/carrousel.tsx +5 -10
  58. package/src/components/ai-image/components/usage-counter.tsx +2 -7
  59. package/src/components/ai-image/featured-image.tsx +2 -7
  60. package/src/components/ai-image/general-purpose-image.tsx +2 -7
  61. package/src/components/ai-image/hooks/use-ai-image.ts +2 -2
  62. package/src/components/ai-modal-footer/index.tsx +3 -3
  63. package/src/components/ai-status-indicator/index.tsx +3 -3
  64. package/src/components/audio-duration-display/index.tsx +3 -3
  65. package/src/components/message/index.tsx +16 -16
  66. package/src/components/modal/index.tsx +3 -8
  67. package/src/data-flow/Readme.md +2 -2
  68. package/src/data-flow/context.tsx +5 -4
  69. package/src/data-flow/with-ai-assistant-data.tsx +38 -41
  70. package/src/icons/ai-assistant.tsx +0 -1
  71. package/src/icons/mic.tsx +0 -1
  72. package/src/icons/origami-plane.tsx +0 -1
  73. package/src/icons/player-pause.tsx +0 -1
  74. package/src/icons/player-play.tsx +0 -1
  75. package/src/icons/player-stop.tsx +0 -1
  76. package/src/icons/speak-tone.tsx +0 -1
  77. package/src/jwt/index.ts +4 -4
  78. package/src/logo-generator/components/feature-fetch-failure-screen.tsx +2 -2
  79. package/src/logo-generator/components/first-load-screen.tsx +2 -2
  80. package/src/logo-generator/components/generator-modal.tsx +3 -3
  81. package/src/logo-generator/components/history-carousel.tsx +2 -2
  82. package/src/logo-generator/components/image-loader.tsx +2 -2
  83. package/src/logo-generator/components/logo-presenter.tsx +11 -13
  84. package/src/logo-generator/components/prompt.tsx +4 -3
  85. package/src/logo-generator/components/upgrade-screen.tsx +2 -2
  86. package/src/logo-generator/components/visit-site-banner.tsx +2 -2
  87. package/src/logo-generator/lib/wpcom-limited-request.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ 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.33.1] - 2025-07-07
9
+ ### Changed
10
+ - Jetpack AI: Change Chrome AI experiment name to v2. [#44135]
11
+ - Update package dependencies. [#44148]
12
+
13
+ ## [0.33.0] - 2025-06-30
14
+ ### Changed
15
+ - Create custom explat client with public-api fetch for assignments. [#44081]
16
+
8
17
  ## [0.32.1] - 2025-06-24
9
18
  ### Added
10
19
  - Improve error handling on Chrome AI events. [#44048]
@@ -650,6 +659,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
650
659
  - AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
651
660
  - Updated package dependencies. [#31468] [#31659] [#31785]
652
661
 
662
+ [0.33.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.0...v0.33.1
663
+ [0.33.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.32.1...v0.33.0
653
664
  [0.32.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.32.0...v0.32.1
654
665
  [0.32.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.31.2...v0.32.0
655
666
  [0.31.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.31.1...v0.31.2
@@ -2,7 +2,15 @@
2
2
  * External dependencies
3
3
  */
4
4
  import apiFetchMod from '@wordpress/api-fetch';
5
+ /**
6
+ * Types
7
+ */
8
+ import type { APIFetchOptions } from '@wordpress/api-fetch';
5
9
  declare const apiFetch: typeof apiFetchMod.default;
6
10
  type ApiFetchType = typeof apiFetch extends Function ? typeof apiFetch : typeof apiFetchMod;
7
- declare const _default: ApiFetchType;
11
+ type AugmentedAPIFetchOptions = APIFetchOptions & {
12
+ global?: boolean;
13
+ };
14
+ type AugmentedApiFetchType = (options: AugmentedAPIFetchOptions) => ReturnType<ApiFetchType>;
15
+ declare const _default: AugmentedApiFetchType;
8
16
  export default _default;
@@ -1,9 +1,14 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { initializeExPlat, loadExperimentAssignmentWithAuth } from '@automattic/jetpack-explat';
4
+ import { initializeExPlat, createExPlatClient } from '@automattic/jetpack-explat';
5
5
  import { select } from '@wordpress/data';
6
+ import { addQueryArgs } from '@wordpress/url';
6
7
  import debugFactory from 'debug';
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import apiFetch from "../api-fetch/index.js";
7
12
  const debug = debugFactory('ai-client:chrome-ai-availability');
8
13
  /**
9
14
  * Get the AI Assistant feature.
@@ -14,6 +19,28 @@ function getAiAssistantFeature() {
14
19
  const { getAiAssistantFeature: getFeature } = select('wordpress-com/plans');
15
20
  return getFeature();
16
21
  }
22
+ /**
23
+ * Fetch an experiment assignment.
24
+ *
25
+ * @param {boolean} asConnectedUser - Whether the user is connected.
26
+ * @return {Function} A function that fetches an experiment assignment.
27
+ */
28
+ const fetchExperimentAssignmentWithConnectedUser = async ({ experimentName, }) => {
29
+ const params = {
30
+ experiment_name: experimentName,
31
+ anon_id: undefined,
32
+ as_connected_user: true,
33
+ };
34
+ debug('params', params);
35
+ const assignmentsRequestUrl = addQueryArgs('https://public-api.wordpress.com/wpcom/v2/experiments/0.1.0/assignments/jetpack', params);
36
+ debug('assignmentsRequestUrl', assignmentsRequestUrl);
37
+ return apiFetch({
38
+ url: assignmentsRequestUrl,
39
+ credentials: 'include',
40
+ mode: 'cors',
41
+ global: true,
42
+ });
43
+ };
17
44
  /**
18
45
  * Check if Chrome AI can be enabled.
19
46
  *
@@ -27,8 +54,13 @@ export async function isChromeAIAvailable() {
27
54
  return false;
28
55
  }
29
56
  initializeExPlat();
30
- debug('initialized explat');
31
- const { variationName } = await loadExperimentAssignmentWithAuth('calypso_jetpack_ai_gemini_api_202503_v1');
57
+ const { loadExperimentAssignment: loadExperimentAssignmentWithAuth } = createExPlatClient({
58
+ fetchExperimentAssignment: fetchExperimentAssignmentWithConnectedUser,
59
+ getAnonId: async () => null,
60
+ logError: debug,
61
+ isDevelopmentMode: false,
62
+ });
63
+ const { variationName } = await loadExperimentAssignmentWithAuth('calypso_jetpack_ai_gemini_api_202503_v2');
32
64
  debug('variationName', variationName);
33
65
  return variationName === 'treatment';
34
66
  }
@@ -2,13 +2,12 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { PlainText } from '@wordpress/block-editor';
5
- import React from 'react';
6
5
  import './style.scss';
7
6
  /**
8
7
  * Types
9
8
  */
10
9
  import type { RequestingStateProp } from '../../types.ts';
11
- import type { ReactElement } from 'react';
10
+ import type { MutableRefObject, ReactElement } from 'react';
12
11
  type AIControlProps = {
13
12
  className?: string;
14
13
  disabled?: boolean;
@@ -22,7 +21,7 @@ type AIControlProps = {
22
21
  actions?: ReactElement;
23
22
  message?: ReactElement;
24
23
  promptUserInputRef?: PlainText.Props['ref'];
25
- wrapperRef?: React.MutableRefObject<HTMLDivElement | null>;
24
+ wrapperRef?: MutableRefObject<HTMLDivElement | null>;
26
25
  };
27
26
  /**
28
27
  * Base AIControl component. Contains the main structure of the control component and slots for banner, error, actions and message.
@@ -1,10 +1,9 @@
1
- import React from 'react';
2
1
  import './style.scss';
3
2
  /**
4
3
  * Types
5
4
  */
6
5
  import type { RequestingStateProp } from '../../types.ts';
7
- import type { ReactElement } from 'react';
6
+ import type { MutableRefObject, ReactElement } from 'react';
8
7
  type BlockAIControlProps = {
9
8
  disabled?: boolean;
10
9
  value: string;
@@ -29,10 +28,10 @@ type BlockAIControlProps = {
29
28
  /**
30
29
  * BlockAIControl component. Used by the AI Assistant block, adding logic and components to the base AIControl component.
31
30
  *
32
- * @param {BlockAIControlProps} props - Component props
33
- * @param {React.MutableRefObject} ref - Ref to the component
31
+ * @param {BlockAIControlProps} props - Component props
32
+ * @param {MutableRefObject} ref - Ref to the component
34
33
  * @return {ReactElement} Rendered component
35
34
  */
36
- export declare function BlockAIControl({ disabled, value, placeholder, showAccept, acceptLabel, showButtonLabels, isTransparent, state, showGuideLine, customFooter, onChange, onSend, onStop, onAccept, onDiscard, showRemove, banner, error, lastAction, }: BlockAIControlProps, ref: React.MutableRefObject<HTMLInputElement>): ReactElement;
37
- declare const _default: React.ForwardRefExoticComponent<BlockAIControlProps & React.RefAttributes<HTMLInputElement>>;
35
+ export declare function BlockAIControl({ disabled, value, placeholder, showAccept, acceptLabel, showButtonLabels, isTransparent, state, showGuideLine, customFooter, onChange, onSend, onStop, onAccept, onDiscard, showRemove, banner, error, lastAction, }: BlockAIControlProps, ref: MutableRefObject<HTMLInputElement>): ReactElement;
36
+ declare const _default: import("react").ForwardRefExoticComponent<BlockAIControlProps & import("react").RefAttributes<HTMLInputElement>>;
38
37
  export default _default;
@@ -19,8 +19,8 @@ const debug = debugFactory('jetpack-ai-client:block-ai-control');
19
19
  /**
20
20
  * BlockAIControl component. Used by the AI Assistant block, adding logic and components to the base AIControl component.
21
21
  *
22
- * @param {BlockAIControlProps} props - Component props
23
- * @param {React.MutableRefObject} ref - Ref to the component
22
+ * @param {BlockAIControlProps} props - Component props
23
+ * @param {MutableRefObject} ref - Ref to the component
24
24
  * @return {ReactElement} Rendered component
25
25
  */
26
26
  export function BlockAIControl({ disabled = false, value = '', placeholder = '', showAccept = false, acceptLabel = __('Accept', 'jetpack-ai-client'), showButtonLabels = true, isTransparent = false, state = 'init', showGuideLine = false, customFooter = null, onChange, onSend, onStop, onAccept, onDiscard, showRemove = false, banner = null, error = null, lastAction, }, ref) {
@@ -1,10 +1,9 @@
1
- import React from 'react';
2
1
  import './style.scss';
3
2
  /**
4
3
  * Types
5
4
  */
6
5
  import type { RequestingErrorProps, RequestingStateProp } from '../../types.ts';
7
- import type { ReactElement, MouseEvent } from 'react';
6
+ import type { MutableRefObject, ReactElement, MouseEvent } from 'react';
8
7
  type ExtensionAIControlProps = {
9
8
  className?: string;
10
9
  disabled?: boolean;
@@ -19,7 +18,7 @@ type ExtensionAIControlProps = {
19
18
  showUpgradeMessage?: boolean;
20
19
  showFairUsageMessage?: boolean;
21
20
  upgradeUrl?: string;
22
- wrapperRef?: React.MutableRefObject<HTMLDivElement | null>;
21
+ wrapperRef?: MutableRefObject<HTMLDivElement | null>;
23
22
  onChange?: (newValue: string) => void;
24
23
  onSend?: (currentValue: string) => void;
25
24
  onStop?: () => void;
@@ -34,9 +33,9 @@ type ExtensionAIControlProps = {
34
33
  * ExtensionAIControl component. Used by the AI Assistant inline extensions, adding logic and components to the base AIControl component.
35
34
  *
36
35
  * @param {ExtensionAIControlProps} props - Component props
37
- * @param {React.MutableRefObject} ref - Ref to the component
36
+ * @param {MutableRefObject} ref - Ref to the component
38
37
  * @return {ReactElement} Rendered component
39
38
  */
40
- export declare function ExtensionAIControl({ className, disabled, value, placeholder, showButtonLabels, isTransparent, state, showGuideLine, error, requestsRemaining, showUpgradeMessage, showFairUsageMessage, upgradeUrl, wrapperRef, onChange, onSend, onStop, onClose, onUndo, onUpgrade, onTryAgain, lastAction, blockType, }: ExtensionAIControlProps, ref: React.MutableRefObject<HTMLInputElement>): ReactElement;
41
- declare const _default: React.ForwardRefExoticComponent<ExtensionAIControlProps & React.RefAttributes<HTMLInputElement>>;
39
+ export declare function ExtensionAIControl({ className, disabled, value, placeholder, showButtonLabels, isTransparent, state, showGuideLine, error, requestsRemaining, showUpgradeMessage, showFairUsageMessage, upgradeUrl, wrapperRef, onChange, onSend, onStop, onClose, onUndo, onUpgrade, onTryAgain, lastAction, blockType, }: ExtensionAIControlProps, ref: MutableRefObject<HTMLInputElement>): ReactElement;
40
+ declare const _default: import("react").ForwardRefExoticComponent<ExtensionAIControlProps & import("react").RefAttributes<HTMLInputElement>>;
42
41
  export default _default;
@@ -18,7 +18,7 @@ import './style.scss';
18
18
  * ExtensionAIControl component. Used by the AI Assistant inline extensions, adding logic and components to the base AIControl component.
19
19
  *
20
20
  * @param {ExtensionAIControlProps} props - Component props
21
- * @param {React.MutableRefObject} ref - Ref to the component
21
+ * @param {MutableRefObject} ref - Ref to the component
22
22
  * @return {ReactElement} Rendered component
23
23
  */
24
24
  export function ExtensionAIControl({ className, disabled = false, value = '', placeholder = '', showButtonLabels = true, isTransparent = false, state = 'init', showGuideLine = false, error, requestsRemaining, showUpgradeMessage = false, showFairUsageMessage = false, upgradeUrl, wrapperRef, onChange, onSend, onStop, onClose, onUndo, onUpgrade, onTryAgain, lastAction, blockType, }, ref) {
@@ -2,7 +2,7 @@ import './style.scss';
2
2
  /**
3
3
  * Types
4
4
  */
5
- import type React from 'react';
5
+ import type { ReactElement } from 'react';
6
6
  type AiFeedbackThumbsProps = {
7
7
  disabled?: boolean;
8
8
  iconSize?: number;
@@ -21,7 +21,7 @@ type AiFeedbackThumbsProps = {
21
21
  * AiFeedbackThumbs component.
22
22
  *
23
23
  * @param {AiFeedbackThumbsProps} props - component props.
24
- * @return {React.ReactElement} - rendered component.
24
+ * @return {ReactElement} - rendered component.
25
25
  */
26
- export default function AiFeedbackThumbs({ disabled, iconSize, ratedItem, feature, savedRatings, options, onRate, }: AiFeedbackThumbsProps): React.ReactElement;
26
+ export default function AiFeedbackThumbs({ disabled, iconSize, ratedItem, feature, savedRatings, options, onRate, }: AiFeedbackThumbsProps): ReactElement;
27
27
  export {};
@@ -25,7 +25,7 @@ function getFeatureAvailability(feature) {
25
25
  * AiFeedbackThumbs component.
26
26
  *
27
27
  * @param {AiFeedbackThumbsProps} props - component props.
28
- * @return {React.ReactElement} - rendered component.
28
+ * @return {ReactElement} - rendered component.
29
29
  */
30
30
  export default function AiFeedbackThumbs({ disabled = false, iconSize = 24, ratedItem = '', feature = '', savedRatings = {}, options = {}, onRate, }) {
31
31
  if (!getFeatureAvailability('ai-response-feedback')) {
@@ -2,7 +2,7 @@ export declare const AiSVG: import("react/jsx-runtime").JSX.Element;
2
2
  /**
3
3
  * AiIcon component
4
4
  * @param {string} className - The wrapper class name.
5
- * @return {React.ReactElement} The `AiIcon` component.
5
+ * @return {ReactElement} The `AiIcon` component.
6
6
  */
7
7
  export default function AiIcon({ className, size }: {
8
8
  className?: string;
@@ -1,7 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { G, Path, SVG, Rect } from '@wordpress/components';
6
3
  import { Icon } from '@wordpress/icons';
7
4
  import { Defs } from '@wordpress/primitives';
@@ -9,7 +6,7 @@ export const AiSVG = (_jsxs(SVG, { width: "42", height: "42", viewBox: "0 0 42 4
9
6
  /**
10
7
  * AiIcon component
11
8
  * @param {string} className - The wrapper class name.
12
- * @return {React.ReactElement} The `AiIcon` component.
9
+ * @return {ReactElement} The `AiIcon` component.
13
10
  */
14
11
  export default function AiIcon({ className, size = 42 }) {
15
12
  return _jsx(Icon, { icon: AiSVG, width: size, height: size, className: className });
@@ -1,9 +1,7 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import { ImageStyleObject, ImageStyle } from '../../../hooks/use-image-generator/constants.ts';
5
2
  import { CarrouselImages } from './carrousel.tsx';
6
3
  import './ai-image-modal.scss';
4
+ import type { JSX } from 'react';
7
5
  type AiImageModalProps = {
8
6
  title: string;
9
7
  cost: number;
@@ -30,7 +28,7 @@ type AiImageModalProps = {
30
28
  hasError: boolean;
31
29
  handlePreviousImage: () => void;
32
30
  handleNextImage: () => void;
33
- acceptButton: React.JSX.Element;
31
+ acceptButton: JSX.Element;
34
32
  autoStart?: boolean;
35
33
  autoStartAction?: ({ userPrompt, style }: {
36
34
  userPrompt?: string;
@@ -49,7 +47,7 @@ type AiImageModalProps = {
49
47
  /**
50
48
  * AiImageModal component
51
49
  * @param {AiImageModalProps} props - The component properties.
52
- * @return {React.ReactElement} - rendered component.
50
+ * @return {ReactElement} - rendered component.
53
51
  */
54
52
  export default function AiImageModal({ title, cost, open, images, currentIndex, onClose, onTryAgain, onGenerate, generating, notEnoughRequests, requireUpgrade, currentLimit, currentUsage, isUnlimited, upgradeDescription, hasError, handlePreviousImage, handleNextImage, acceptButton, autoStart, autoStartAction, instructionsPlaceholder, imageStyles, onGuessStyle, prompt, setPrompt, initialStyle, inputDisabled, actionDisabled, }: AiImageModalProps): import("react/jsx-runtime").JSX.Element;
55
53
  export {};
@@ -1,15 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
6
3
  import { SelectControl } from '@wordpress/components';
7
4
  import { useCallback, useRef, useState, useEffect } from '@wordpress/element';
8
5
  import { __ } from '@wordpress/i18n';
9
6
  import debugFactory from 'debug';
10
- /**
11
- * Internal dependencies
12
- */
13
7
  import { IMAGE_STYLE_NONE, IMAGE_STYLE_AUTO, } from "../../../hooks/use-image-generator/constants.js";
14
8
  import { AiModalPromptInput } from "../../../logo-generator/index.js";
15
9
  import AiModalFooter from "../../ai-modal-footer/index.js";
@@ -23,7 +17,7 @@ const debug = debugFactory('jetpack-ai-client:ai-image-modal');
23
17
  /**
24
18
  * AiImageModal component
25
19
  * @param {AiImageModalProps} props - The component properties.
26
- * @return {React.ReactElement} - rendered component.
20
+ * @return {ReactElement} - rendered component.
27
21
  */
28
22
  export default function AiImageModal({ title, cost, open, images, currentIndex = 0, onClose = null, onTryAgain = null, onGenerate = null, generating = false, notEnoughRequests = false, requireUpgrade = false, currentLimit = null, currentUsage = null, isUnlimited = false, upgradeDescription = null, hasError = false, handlePreviousImage = () => { }, handleNextImage = () => { }, acceptButton = null, autoStart = false, autoStartAction = null, instructionsPlaceholder = null, imageStyles = [], onGuessStyle = null, prompt = '', setPrompt = () => { }, initialStyle = null, inputDisabled = false, actionDisabled = false, }) {
29
23
  const { tracks } = useAnalytics();
@@ -1,4 +1,5 @@
1
1
  import './carrousel.scss';
2
+ import type { JSX } from 'react';
2
3
  export type CarrouselImageData = {
3
4
  image?: string;
4
5
  libraryId?: number | string;
@@ -16,12 +17,12 @@ type CarrouselProps = {
16
17
  current: number;
17
18
  handlePreviousImage: () => void;
18
19
  handleNextImage: () => void;
19
- actions?: React.JSX.Element;
20
+ actions?: JSX.Element;
20
21
  };
21
22
  /**
22
23
  * Carrousel component
23
24
  * @param {CarrouselProps} props - The component properties.
24
- * @return {React.ReactElement} - rendered component.
25
+ * @return {ReactElement} - rendered component.
25
26
  */
26
27
  export default function Carrousel({ images, current, handlePreviousImage, handleNextImage, actions, }: CarrouselProps): import("react/jsx-runtime").JSX.Element;
27
28
  export {};
@@ -1,22 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { Spinner } from '@wordpress/components';
6
3
  import { useEffect, useState } from '@wordpress/element';
7
4
  import { __ } from '@wordpress/i18n';
8
5
  import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
9
6
  import clsx from 'clsx';
10
- /**
11
- * Internal dependencies
12
- */
13
7
  import AiFeedbackThumbs from "../../ai-feedback/index.js";
14
8
  import AiIcon from "../../ai-icon/index.js";
15
9
  import './carrousel.scss';
16
10
  /**
17
11
  * BlankImage component
18
12
  * @param {BlankImageProps} props - The component properties.
19
- * @return {React.ReactElement} - rendered component.
13
+ * @return {ReactElement} - rendered component.
20
14
  */
21
15
  function BlankImage({ children, isDotted = false, contentClassName = '' }) {
22
16
  const blankImage = (_jsx("img", { className: "ai-assistant-image__carrousel-image", src: "data:image/svg+xml,<svg viewBox='0 0 1 1' width='1024' height='768' xmlns='http://www.w3.org/2000/svg'><path d='M0 0 L1 0 L1 1 L0 1 L0 0 Z' fill='none' /></svg>", alt: "" }));
@@ -27,7 +21,7 @@ function BlankImage({ children, isDotted = false, contentClassName = '' }) {
27
21
  /**
28
22
  * Carrousel component
29
23
  * @param {CarrouselProps} props - The component properties.
30
- * @return {React.ReactElement} - rendered component.
24
+ * @return {ReactElement} - rendered component.
31
25
  */
32
26
  export default function Carrousel({ images, current, handlePreviousImage, handleNextImage, actions = null, }) {
33
27
  const [imageFeedbackDisabled, setImageFeedbackDisabled] = useState(false);
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import './usage-counter.scss';
5
2
  type UsageCounterProps = {
6
3
  currentLimit: number;
@@ -10,7 +7,7 @@ type UsageCounterProps = {
10
7
  /**
11
8
  * UsageCounter component
12
9
  * @param {UsageCounterProps} props - The component properties.
13
- * @return {React.ReactElement} - rendered component.
10
+ * @return {ReactElement} - rendered component.
14
11
  */
15
12
  export default function UsageCounter({ currentLimit, currentUsage, cost }: UsageCounterProps): import("react/jsx-runtime").JSX.Element;
16
13
  export {};
@@ -1,17 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { createInterpolateElement } from '@wordpress/element';
6
3
  import { __, sprintf } from '@wordpress/i18n';
7
- /**
8
- * Internal dependencies
9
- */
10
4
  import './usage-counter.scss';
11
5
  /**
12
6
  * UsageCounter component
13
7
  * @param {UsageCounterProps} props - The component properties.
14
- * @return {React.ReactElement} - rendered component.
8
+ * @return {ReactElement} - rendered component.
15
9
  */
16
10
  export default function UsageCounter({ currentLimit, currentUsage, cost }) {
17
11
  const requestsBalance = currentLimit - currentUsage;
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import './style.scss';
5
2
  type FeaturedImageProps = {
6
3
  busy: boolean;
@@ -11,7 +8,7 @@ type FeaturedImageProps = {
11
8
  /**
12
9
  * FeaturedImage component
13
10
  * @param {FeaturedImageProps} props - The component properties.
14
- * @return {React.ReactElement} - rendered component.
11
+ * @return {ReactElement} - rendered component.
15
12
  */
16
13
  export default function FeaturedImage({ busy, disabled, placement, onClose, }: FeaturedImageProps): import("react/jsx-runtime").JSX.Element;
17
14
  export {};
@@ -1,7 +1,4 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { useAnalytics, PLAN_TYPE_UNLIMITED, usePlanType, } from '@automattic/jetpack-shared-extension-utils';
6
3
  import { Button } from '@wordpress/components';
7
4
  import { useDispatch, useSelect } from '@wordpress/data';
@@ -9,9 +6,6 @@ import { store as editorStore } from '@wordpress/editor';
9
6
  import { useCallback, useState } from '@wordpress/element';
10
7
  import { __, sprintf } from '@wordpress/i18n';
11
8
  import debugFactory from 'debug';
12
- /**
13
- * Internal dependencies
14
- */
15
9
  import './style.scss';
16
10
  import { PLACEMENT_JETPACK_SIDEBAR, PLACEMENT_DOCUMENT_SETTINGS } from "../../constants.js";
17
11
  import useAiFeature from "../../hooks/use-ai-feature/index.js";
@@ -25,7 +19,7 @@ const debug = debugFactory('jetpack-ai-client:featured-image');
25
19
  /**
26
20
  * FeaturedImage component
27
21
  * @param {FeaturedImageProps} props - The component properties.
28
- * @return {React.ReactElement} - rendered component.
22
+ * @return {ReactElement} - rendered component.
29
23
  */
30
24
  export default function FeaturedImage({ busy, disabled, placement, onClose = () => { }, }) {
31
25
  const [isFeaturedImageModalVisible, setIsFeaturedImageModalVisible] = useState(placement === PLACEMENT_MEDIA_SOURCE_DROPDOWN);
@@ -1,6 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  import './style.scss';
5
2
  /**
6
3
  * The type for the callback function that is called when the user selects an image.
@@ -17,7 +14,7 @@ type GeneralPurposeImageProps = {
17
14
  /**
18
15
  * GeneralPurposeImage component
19
16
  * @param {GeneralPurposeImageProps} props - The component properties.
20
- * @return {React.ReactElement} - rendered component.
17
+ * @return {ReactElement} - rendered component.
21
18
  */
22
19
  export default function GeneralPurposeImage({ placement, onClose, onSetImage, }: GeneralPurposeImageProps): import("react/jsx-runtime").JSX.Element;
23
20
  export {};
@@ -1,15 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * External dependencies
4
- */
5
2
  import { useAnalytics, PLAN_TYPE_UNLIMITED, usePlanType, } from '@automattic/jetpack-shared-extension-utils';
6
3
  import { Button } from '@wordpress/components';
7
4
  import { useCallback, useState } from '@wordpress/element';
8
5
  import { __, sprintf } from '@wordpress/i18n';
9
6
  import debugFactory from 'debug';
10
- /**
11
- * Internal dependencies
12
- */
13
7
  import './style.scss';
14
8
  import useAiFeature from "../../hooks/use-ai-feature/index.js";
15
9
  import usePostContent from "../../hooks/use-post-content.js";
@@ -22,7 +16,7 @@ const debug = debugFactory('jetpack-ai:general-purpose-image');
22
16
  /**
23
17
  * GeneralPurposeImage component
24
18
  * @param {GeneralPurposeImageProps} props - The component properties.
25
- * @return {React.ReactElement} - rendered component.
19
+ * @return {ReactElement} - rendered component.
26
20
  */
27
21
  export default function GeneralPurposeImage({ placement, onClose = () => { }, onSetImage = () => { }, }) {
28
22
  const [isFeaturedImageModalVisible, setIsFeaturedImageModalVisible] = useState(true);
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { ImageStyleObject, ImageStyle } from '../../../hooks/use-image-generator/constants.ts';
3
2
  /**
4
3
  * Types
@@ -34,14 +33,14 @@ type UseAiImageProps = {
34
33
  */
35
34
  export default function useAiImage({ feature, type, cost, autoStart, previousMediaId, }: UseAiImageProps): {
36
35
  current: number;
37
- setCurrent: React.Dispatch<React.SetStateAction<number>>;
36
+ setCurrent: import("react").Dispatch<import("react").SetStateAction<number>>;
38
37
  processImageGeneration: ({ userPrompt, postContent, notEnoughRequests, style, }: ProcessImageGenerationProps) => Promise<ImageResponse>;
39
38
  handlePreviousImage: () => void;
40
39
  handleNextImage: () => void;
41
40
  currentImage: CarrouselImageData;
42
41
  currentPointer: CarrouselImageData;
43
42
  images: CarrouselImages;
44
- pointer: React.MutableRefObject<number>;
43
+ pointer: import("react").MutableRefObject<number>;
45
44
  imageStyles: ImageStyleObject[];
46
45
  guessStyle: (prompt: string, requestType?: string, content?: string) => Promise<ImageStyle | null>;
47
46
  };
@@ -5,7 +5,7 @@ import './style.scss';
5
5
  /**
6
6
  * Types
7
7
  */
8
- import type React from 'react';
8
+ import type { ReactElement } from 'react';
9
9
  type AiModalFooterProps = {
10
10
  onGuidelinesClick?: () => void;
11
11
  onFeedbackClick?: () => void;
@@ -14,7 +14,7 @@ type AiModalFooterProps = {
14
14
  * AiModalFooter component.
15
15
  *
16
16
  * @param {AiModalFooterProps} props - component props.
17
- * @return {React.ReactElement} - rendered component.
17
+ * @return {ReactElement} - rendered component.
18
18
  */
19
- export default function AiModalFooter({ onGuidelinesClick, onFeedbackClick, }: AiModalFooterProps): React.ReactElement;
19
+ export default function AiModalFooter({ onGuidelinesClick, onFeedbackClick, }: AiModalFooterProps): ReactElement;
20
20
  export {};
@@ -14,7 +14,7 @@ import './style.scss';
14
14
  * AiModalFooter component.
15
15
  *
16
16
  * @param {AiModalFooterProps} props - component props.
17
- * @return {React.ReactElement} - rendered component.
17
+ * @return {ReactElement} - rendered component.
18
18
  */
19
19
  export default function AiModalFooter({ onGuidelinesClick, onFeedbackClick, }) {
20
20
  const handleGuidelinesClick = useCallback(() => {
@@ -1,6 +1,6 @@
1
1
  import type { RequestingStateProp } from '../../types.ts';
2
2
  export type AiStatusIndicatorIconSize = 24 | 32 | 48 | 64;
3
- import type React from 'react';
3
+ import type { ReactElement } from 'react';
4
4
  import './style.scss';
5
5
  export type AiStatusIndicatorProps = {
6
6
  state?: RequestingStateProp;
@@ -10,6 +10,6 @@ export type AiStatusIndicatorProps = {
10
10
  * AiStatusIndicator component.
11
11
  *
12
12
  * @param {AiStatusIndicatorProps} props - component props.
13
- * @return {React.ReactElement} - rendered component.
13
+ * @return {ReactElement} - rendered component.
14
14
  */
15
- export default function AiStatusIndicator({ state }: AiStatusIndicatorProps): React.ReactElement;
15
+ export default function AiStatusIndicator({ state }: AiStatusIndicatorProps): ReactElement;
@@ -9,7 +9,7 @@ import './style.scss';
9
9
  * AiStatusIndicator component.
10
10
  *
11
11
  * @param {AiStatusIndicatorProps} props - component props.
12
- * @return {React.ReactElement} - rendered component.
12
+ * @return {ReactElement} - rendered component.
13
13
  */
14
14
  export default function AiStatusIndicator({ state }) {
15
15
  return (_jsx("div", { className: clsx('jetpack-ai-status-indicator__icon-wrapper', {
@@ -1,4 +1,4 @@
1
- import type React from 'react';
1
+ import type { ReactElement } from 'react';
2
2
  type AudioDurationDisplayProps = {
3
3
  duration: number;
4
4
  className?: string | null;
@@ -7,7 +7,7 @@ type AudioDurationDisplayProps = {
7
7
  * AudioDurationDisplay component.
8
8
  *
9
9
  * @param {AudioDurationDisplayProps} props - Component props.
10
- * @return {React.ReactElement} Rendered component.
10
+ * @return {ReactElement} Rendered component.
11
11
  */
12
- export default function AudioDurationDisplay({ duration, className, }: AudioDurationDisplayProps): React.ReactElement;
12
+ export default function AudioDurationDisplay({ duration, className, }: AudioDurationDisplayProps): ReactElement;
13
13
  export {};
@@ -7,7 +7,7 @@ import { formatTime } from "./lib/media.js";
7
7
  * AudioDurationDisplay component.
8
8
  *
9
9
  * @param {AudioDurationDisplayProps} props - Component props.
10
- * @return {React.ReactElement} Rendered component.
10
+ * @return {ReactElement} Rendered component.
11
11
  */
12
12
  export default function AudioDurationDisplay({ duration, className, }) {
13
13
  return _jsx("span", { className: className, children: formatTime(duration, { addDecimalPart: false }) });