@automattic/jetpack-ai-client 0.34.5 → 0.34.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 +10 -0
- package/build/{ask-question → src/ask-question}/index.d.ts +1 -1
- package/build/{ask-question → src/ask-question}/index.js +1 -1
- package/build/{ask-question → src/ask-question}/sync.js +1 -1
- package/build/{audio-transcription → src/audio-transcription}/index.js +1 -1
- package/build/{components → src/components}/ai-control/ai-control.d.ts +1 -1
- package/build/{components → src/components}/ai-control/ai-control.js +4 -2
- package/build/{components → src/components}/ai-control/block-ai-control.d.ts +1 -1
- package/build/{components → src/components}/ai-control/block-ai-control.js +7 -4
- package/build/{components → src/components}/ai-control/extension-ai-control.d.ts +1 -1
- package/build/{components → src/components}/ai-control/extension-ai-control.js +6 -4
- package/build/src/components/ai-control/index.js +3 -0
- package/build/{components → src/components}/ai-feedback/index.d.ts +1 -1
- package/build/{components → src/components}/ai-feedback/index.js +4 -2
- package/build/src/components/ai-icon/index.js +17 -0
- package/build/{components → src/components}/ai-image/components/ai-image-modal.d.ts +1 -1
- package/build/{components → src/components}/ai-image/components/ai-image-modal.js +14 -9
- package/build/{components → src/components}/ai-image/components/carrousel.d.ts +1 -1
- package/build/{components → src/components}/ai-image/components/carrousel.js +15 -7
- package/build/{components → src/components}/ai-image/components/usage-counter.js +3 -1
- package/build/{components → src/components}/ai-image/featured-image.d.ts +1 -1
- package/build/{components → src/components}/ai-image/featured-image.js +13 -10
- package/build/{components → src/components}/ai-image/general-purpose-image.d.ts +1 -1
- package/build/{components → src/components}/ai-image/general-purpose-image.js +7 -7
- package/build/{components → src/components}/ai-image/hooks/use-ai-image.d.ts +2 -2
- package/build/{components → src/components}/ai-image/hooks/use-ai-image.js +5 -5
- package/build/{components → src/components}/ai-image/index.js +3 -3
- package/build/{components → src/components}/ai-modal-footer/index.d.ts +1 -1
- package/build/src/components/ai-modal-footer/index.js +31 -0
- package/build/{components → src/components}/audio-duration-display/index.d.ts +1 -1
- package/build/{components → src/components}/audio-duration-display/index.js +1 -1
- package/build/src/components/index.js +10 -0
- package/build/{components → src/components}/message/index.d.ts +4 -4
- package/build/{components → src/components}/message/index.js +12 -7
- package/build/{components → src/components}/modal/index.d.ts +1 -1
- package/build/{components → src/components}/modal/index.js +8 -3
- package/build/{components → src/components}/quota-exceeded-message/index.js +3 -3
- package/build/{data-flow → src/data-flow}/context.d.ts +1 -1
- package/build/src/data-flow/index.js +3 -0
- package/build/{data-flow → src/data-flow}/use-ai-context.d.ts +1 -1
- package/build/{data-flow → src/data-flow}/use-ai-context.js +2 -2
- package/build/{data-flow → src/data-flow}/with-ai-assistant-data.js +2 -2
- package/build/{hooks → src/hooks}/use-ai-checkout/index.js +1 -1
- package/build/{hooks → src/hooks}/use-ai-feature/index.d.ts +8 -8
- package/build/{hooks → src/hooks}/use-ai-suggestions/index.d.ts +1 -1
- package/build/{hooks → src/hooks}/use-ai-suggestions/index.js +2 -2
- package/build/{hooks → src/hooks}/use-audio-transcription/index.d.ts +1 -1
- package/build/{hooks → src/hooks}/use-audio-transcription/index.js +1 -1
- package/build/{hooks → src/hooks}/use-image-generator/index.d.ts +1 -1
- package/build/{hooks → src/hooks}/use-image-generator/index.js +3 -3
- package/build/{hooks → src/hooks}/use-media-recording/index.d.ts +1 -1
- package/build/{hooks → src/hooks}/use-post-content.js +1 -1
- package/build/{hooks → src/hooks}/use-transcription-post-processing/index.d.ts +1 -1
- package/build/{hooks → src/hooks}/use-transcription-post-processing/index.js +1 -1
- package/build/src/icons/ai-assistant.js +9 -0
- package/build/src/icons/error-exclamation.js +9 -0
- package/build/src/icons/index.js +7 -0
- package/build/src/icons/mic.js +9 -0
- package/build/src/icons/origami-plane.js +9 -0
- package/build/src/icons/player-pause.js +9 -0
- package/build/src/icons/player-play.js +9 -0
- package/build/src/icons/player-stop.js +9 -0
- package/build/src/icons/speak-tone.js +9 -0
- package/build/src/index.js +49 -0
- package/build/{jwt → src/jwt}/index.d.ts +1 -1
- package/build/{jwt → src/jwt}/index.js +1 -1
- package/build/{libs → src/libs}/get-all-blocks.d.ts +1 -1
- package/build/src/libs/index.js +6 -0
- package/build/{libs → src/libs}/map-action-to-human-text.js +1 -1
- package/build/{libs → src/libs}/markdown/html-to-markdown.d.ts +1 -1
- package/build/{libs → src/libs}/markdown/index.js +2 -2
- package/build/{libs → src/libs}/markdown/markdown-to-html.d.ts +1 -1
- package/build/src/logo-generator/assets/icons/ai.js +10 -0
- package/build/src/logo-generator/assets/icons/media.js +10 -0
- package/build/{logo-generator → src/logo-generator}/components/fair-usage-notice.js +1 -1
- package/build/src/logo-generator/components/feature-fetch-failure-screen.js +14 -0
- package/build/{logo-generator → src/logo-generator}/components/first-load-screen.js +4 -2
- package/build/{logo-generator → src/logo-generator}/components/generator-modal.js +20 -16
- package/build/{logo-generator → src/logo-generator}/components/history-carousel.js +2 -2
- package/build/{logo-generator → src/logo-generator}/components/logo-presenter.js +42 -19
- package/build/{logo-generator → src/logo-generator}/components/prompt.js +24 -13
- package/build/{logo-generator → src/logo-generator}/components/upgrade-nudge.js +8 -4
- package/build/{logo-generator → src/logo-generator}/components/upgrade-screen.js +11 -3
- package/build/src/logo-generator/components/visit-site-banner.js +22 -0
- package/build/{logo-generator → src/logo-generator}/hooks/use-checkout.js +1 -1
- package/build/{logo-generator → src/logo-generator}/hooks/use-fair-usage-notice-message.js +1 -1
- package/build/{logo-generator → src/logo-generator}/hooks/use-logo-generator.d.ts +5 -5
- package/build/{logo-generator → src/logo-generator}/hooks/use-logo-generator.js +9 -9
- package/build/{logo-generator → src/logo-generator}/hooks/use-request-errors.js +1 -1
- package/build/src/logo-generator/index.js +2 -0
- package/build/{logo-generator → src/logo-generator}/lib/logo-storage.d.ts +1 -1
- package/build/{logo-generator → src/logo-generator}/lib/logo-storage.js +1 -1
- package/build/{logo-generator → src/logo-generator}/lib/media-exists.js +1 -1
- package/build/{logo-generator → src/logo-generator}/lib/set-site-logo.js +1 -1
- package/build/{logo-generator → src/logo-generator}/lib/wpcom-limited-request.js +1 -1
- package/build/{logo-generator → src/logo-generator}/store/actions.js +3 -3
- package/build/{logo-generator → src/logo-generator}/store/index.js +3 -3
- package/build/{logo-generator → src/logo-generator}/store/initial-state.js +1 -1
- package/build/{logo-generator → src/logo-generator}/store/reducer.d.ts +94 -94
- package/build/{logo-generator → src/logo-generator}/store/reducer.js +3 -3
- package/build/{logo-generator → src/logo-generator}/store/selectors.d.ts +3 -3
- package/build/{logo-generator → src/logo-generator}/store/selectors.js +1 -1
- package/build/{suggestions-event-source → src/suggestions-event-source}/index.d.ts +1 -1
- package/build/{suggestions-event-source → src/suggestions-event-source}/index.js +4 -4
- package/build/{types.js → src/types.js} +1 -1
- package/package.json +25 -25
- package/build/components/ai-control/index.js +0 -3
- package/build/components/ai-icon/index.js +0 -13
- package/build/components/ai-modal-footer/index.js +0 -27
- package/build/components/index.js +0 -10
- package/build/data-flow/index.js +0 -3
- package/build/icons/ai-assistant.js +0 -7
- package/build/icons/error-exclamation.js +0 -7
- package/build/icons/index.js +0 -7
- package/build/icons/mic.js +0 -7
- package/build/icons/origami-plane.js +0 -7
- package/build/icons/player-pause.js +0 -7
- package/build/icons/player-play.js +0 -7
- package/build/icons/player-stop.js +0 -7
- package/build/icons/speak-tone.js +0 -7
- package/build/index.js +0 -49
- package/build/libs/index.js +0 -6
- package/build/logo-generator/assets/icons/ai.js +0 -8
- package/build/logo-generator/assets/icons/media.js +0 -8
- package/build/logo-generator/components/feature-fetch-failure-screen.js +0 -11
- package/build/logo-generator/components/visit-site-banner.js +0 -16
- package/build/logo-generator/index.js +0 -2
- package/build/{api-fetch → src/api-fetch}/index.d.ts +0 -0
- package/build/{api-fetch → src/api-fetch}/index.js +0 -0
- package/build/{ask-question → src/ask-question}/sync.d.ts +0 -0
- package/build/{audio-transcription → src/audio-transcription}/index.d.ts +0 -0
- package/build/{components → src/components}/ai-control/index.d.ts +0 -0
- package/build/{components → src/components}/ai-icon/index.d.ts +0 -0
- package/build/{components → src/components}/ai-image/components/usage-counter.d.ts +0 -0
- package/build/{components → src/components}/ai-image/hooks/use-site-type.d.ts +0 -0
- package/build/{components → src/components}/ai-image/hooks/use-site-type.js +0 -0
- package/build/{components → src/components}/ai-image/index.d.ts +0 -0
- package/build/{components → src/components}/ai-image/types.d.ts +0 -0
- package/build/{components → src/components}/ai-image/types.js +0 -0
- package/build/{components → src/components}/ai-status-indicator/index.d.ts +0 -0
- package/build/{components → src/components}/ai-status-indicator/index.js +0 -0
- package/build/{components → src/components}/audio-duration-display/lib/media.d.ts +0 -0
- package/build/{components → src/components}/audio-duration-display/lib/media.js +0 -0
- package/build/{components → src/components}/index.d.ts +0 -0
- package/build/{components → src/components}/quota-exceeded-message/index.d.ts +0 -0
- package/build/{components → src/components}/quota-exceeded-message/light-nudge.d.ts +2 -2
- /package/build/{components → src/components}/quota-exceeded-message/light-nudge.js +0 -0
- /package/build/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/build/{constants.js → src/constants.js} +0 -0
- /package/build/{data-flow → src/data-flow}/context.js +0 -0
- /package/build/{data-flow → src/data-flow}/index.d.ts +0 -0
- /package/build/{data-flow → src/data-flow}/with-ai-assistant-data.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-ai-checkout/index.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-ai-feature/index.js +0 -0
- /package/build/{hooks → src/hooks}/use-audio-validation/index.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-audio-validation/index.js +0 -0
- /package/build/{hooks → src/hooks}/use-image-generator/constants.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-image-generator/constants.js +0 -0
- /package/build/{hooks → src/hooks}/use-media-recording/index.js +0 -0
- /package/build/{hooks → src/hooks}/use-post-content.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-save-to-media-library/index.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-save-to-media-library/index.js +0 -0
- /package/build/{hooks → src/hooks}/use-save-to-media-library.d.ts +0 -0
- /package/build/{hooks → src/hooks}/use-save-to-media-library.js +0 -0
- /package/build/{icons → src/icons}/ai-assistant.d.ts +0 -0
- /package/build/{icons → src/icons}/error-exclamation.d.ts +0 -0
- /package/build/{icons → src/icons}/index.d.ts +0 -0
- /package/build/{icons → src/icons}/mic.d.ts +0 -0
- /package/build/{icons → src/icons}/origami-plane.d.ts +0 -0
- /package/build/{icons → src/icons}/player-pause.d.ts +0 -0
- /package/build/{icons → src/icons}/player-play.d.ts +0 -0
- /package/build/{icons → src/icons}/player-stop.d.ts +0 -0
- /package/build/{icons → src/icons}/speak-tone.d.ts +0 -0
- /package/build/{index.d.ts → src/index.d.ts} +0 -0
- /package/build/{libs → src/libs}/get-all-blocks.js +0 -0
- /package/build/{libs → src/libs}/get-base64-image.d.ts +0 -0
- /package/build/{libs → src/libs}/get-base64-image.js +0 -0
- /package/build/{libs → src/libs}/index.d.ts +0 -0
- /package/build/{libs → src/libs}/map-action-to-human-text.d.ts +0 -0
- /package/build/{libs → src/libs}/markdown/html-to-markdown.js +0 -0
- /package/build/{libs → src/libs}/markdown/index.d.ts +0 -0
- /package/build/{libs → src/libs}/markdown/markdown-to-html.js +0 -0
- /package/build/{libs → src/libs}/open-block-sidebar.d.ts +0 -0
- /package/build/{libs → src/libs}/open-block-sidebar.js +0 -0
- /package/build/{libs → src/libs}/show-ai-assistant-section.d.ts +0 -0
- /package/build/{libs → src/libs}/show-ai-assistant-section.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/ai.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/check.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/check.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/logo.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/logo.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/assets/icons/media.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/fair-usage-notice.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/feature-fetch-failure-screen.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/first-load-screen.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/generator-modal.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/history-carousel.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/image-loader.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/image-loader.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/logo-presenter.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/prompt.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/upgrade-nudge.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/upgrade-screen.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/components/visit-site-banner.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/constants.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/constants.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/hooks/use-checkout.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/hooks/use-fair-usage-notice-message.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/hooks/use-request-errors.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/index.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/lib/media-exists.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/lib/set-site-logo.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/lib/wpcom-limited-request.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/actions.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/constants.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/constants.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/index.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/initial-state.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/types.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/store/types.js +0 -0
- /package/build/{logo-generator → src/logo-generator}/types.d.ts +0 -0
- /package/build/{logo-generator → src/logo-generator}/types.js +0 -0
- /package/build/{types.d.ts → src/types.d.ts} +0 -0
|
@@ -6,11 +6,13 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { ImageLoader } from
|
|
9
|
+
import { ImageLoader } from './image-loader.js';
|
|
10
10
|
import './first-load-screen.scss';
|
|
11
11
|
export const FirstLoadScreen = ({ state = 'loadingFeature' }) => {
|
|
12
12
|
const loadingLabel = __('Loading…', 'jetpack-ai-client');
|
|
13
13
|
const analyzingLabel = __('Analyzing your site to create the perfect logo…', 'jetpack-ai-client');
|
|
14
14
|
const generatingLabel = __('Generating logo…', 'jetpack-ai-client');
|
|
15
|
-
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__loading-wrapper", children: [
|
|
15
|
+
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__loading-wrapper", children: [
|
|
16
|
+
_jsx(ImageLoader, {}), _jsxs("span", { className: "jetpack-ai-logo-generator-modal__loading-message", children: [state === 'loadingFeature' && loadingLabel, state === 'analyzing' && analyzingLabel, state === 'generating' && generatingLabel] })
|
|
17
|
+
] }));
|
|
16
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
@@ -12,20 +12,20 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import AiModalFooter from
|
|
16
|
-
import { DEFAULT_LOGO_COST, EVENT_MODAL_OPEN, EVENT_FEEDBACK, EVENT_MODAL_CLOSE, EVENT_GENERATE, } from
|
|
17
|
-
import { useCheckout } from
|
|
18
|
-
import useLogoGenerator from
|
|
19
|
-
import useRequestErrors from
|
|
20
|
-
import { isLogoHistoryEmpty, clearDeletedMedia } from
|
|
21
|
-
import { STORE_NAME } from
|
|
22
|
-
import { FeatureFetchFailureScreen } from
|
|
23
|
-
import { FirstLoadScreen } from
|
|
24
|
-
import { HistoryCarousel } from
|
|
25
|
-
import { LogoPresenter } from
|
|
26
|
-
import { Prompt } from
|
|
27
|
-
import { UpgradeScreen } from
|
|
28
|
-
import { VisitSiteBanner } from
|
|
15
|
+
import AiModalFooter from '../../components/ai-modal-footer/index.js';
|
|
16
|
+
import { DEFAULT_LOGO_COST, EVENT_MODAL_OPEN, EVENT_FEEDBACK, EVENT_MODAL_CLOSE, EVENT_GENERATE, } from '../constants.js';
|
|
17
|
+
import { useCheckout } from '../hooks/use-checkout.js';
|
|
18
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
19
|
+
import useRequestErrors from '../hooks/use-request-errors.js';
|
|
20
|
+
import { isLogoHistoryEmpty, clearDeletedMedia } from '../lib/logo-storage.js';
|
|
21
|
+
import { STORE_NAME } from '../store/index.js';
|
|
22
|
+
import { FeatureFetchFailureScreen } from './feature-fetch-failure-screen.js';
|
|
23
|
+
import { FirstLoadScreen } from './first-load-screen.js';
|
|
24
|
+
import { HistoryCarousel } from './history-carousel.js';
|
|
25
|
+
import { LogoPresenter } from './logo-presenter.js';
|
|
26
|
+
import { Prompt } from './prompt.js';
|
|
27
|
+
import { UpgradeScreen } from './upgrade-screen.js';
|
|
28
|
+
import { VisitSiteBanner } from './visit-site-banner.js';
|
|
29
29
|
import './generator-modal.scss';
|
|
30
30
|
const debug = debugFactory('jetpack-ai-calypso:generator-modal');
|
|
31
31
|
export const GeneratorModal = ({ isOpen, onClose, onApplyLogo, onReload = null, siteDetails, context, placement, }) => {
|
|
@@ -212,7 +212,11 @@ export const GeneratorModal = ({ isOpen, onClose, onApplyLogo, onReload = null,
|
|
|
212
212
|
body = (_jsx(UpgradeScreen, { onCancel: closeModal, upgradeURL: upgradeURL, reason: needsFeature ? 'feature' : 'requests' }));
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
|
-
body = (_jsxs(_Fragment, { children: [!logoAccepted && _jsx(Prompt, { initialPrompt: initialPrompt }), _jsx(LogoPresenter, { logo: selectedLogo, onApplyLogo: handleApplyLogo, logoAccepted: logoAccepted, siteId: String(siteId) }), logoAccepted ? (_jsxs("div", { className: "jetpack-ai-logo-generator__accept", children: [
|
|
215
|
+
body = (_jsxs(_Fragment, { children: [!logoAccepted && _jsx(Prompt, { initialPrompt: initialPrompt }), _jsx(LogoPresenter, { logo: selectedLogo, onApplyLogo: handleApplyLogo, logoAccepted: logoAccepted, siteId: String(siteId) }), logoAccepted ? (_jsxs("div", { className: "jetpack-ai-logo-generator__accept", children: [
|
|
216
|
+
_jsx(VisitSiteBanner, {}), _jsx("div", { className: "jetpack-ai-logo-generator__accept-actions", children: _jsx(Button, { variant: "primary", onClick: closeModal, children: __('Close', 'jetpack-ai-client') }) })
|
|
217
|
+
] })) : (_jsxs(_Fragment, { children: [
|
|
218
|
+
_jsx(HistoryCarousel, {}), _jsx("div", { className: "jetpack-ai-logo-generator__footer", children: _jsx(AiModalFooter, { onFeedbackClick: handleFeedbackClick }) })
|
|
219
|
+
] }))] }));
|
|
216
220
|
}
|
|
217
221
|
return (_jsx(_Fragment, { children: isOpen && (_jsx(Modal, { className: "jetpack-ai-logo-generator-modal", onRequestClose: closeModal, shouldCloseOnClickOutside: false, shouldCloseOnEsc: false, title: __('Jetpack AI Logo Generator', 'jetpack-ai-client'), children: _jsx("div", { className: clsx('jetpack-ai-logo-generator-modal__body', {
|
|
218
222
|
'notice-modal': needsFeature || needsMoreRequests || featureFetchError || firstLogoPromptFetchError,
|
|
@@ -9,8 +9,8 @@ import clsx from 'clsx';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import loader from '../assets/images/loader.gif';
|
|
12
|
-
import { EVENT_NAVIGATE } from
|
|
13
|
-
import useLogoGenerator from
|
|
12
|
+
import { EVENT_NAVIGATE } from '../constants.js';
|
|
13
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
14
14
|
import './history-carousel.scss';
|
|
15
15
|
export const HistoryCarousel = () => {
|
|
16
16
|
const { tracks } = useAnalytics();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
@@ -10,16 +10,16 @@ import debugFactory from 'debug';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import AiFeedbackThumbs from
|
|
14
|
-
import CheckIcon from
|
|
15
|
-
import LogoIcon from
|
|
16
|
-
import MediaIcon from
|
|
17
|
-
import { EVENT_SAVE, EVENT_USE } from
|
|
18
|
-
import useLogoGenerator from
|
|
19
|
-
import useRequestErrors from
|
|
20
|
-
import { updateLogo } from
|
|
21
|
-
import { STORE_NAME } from
|
|
22
|
-
import { ImageLoader } from
|
|
13
|
+
import AiFeedbackThumbs from '../../components/ai-feedback/index.js';
|
|
14
|
+
import CheckIcon from '../assets/icons/check.js';
|
|
15
|
+
import LogoIcon from '../assets/icons/logo.js';
|
|
16
|
+
import MediaIcon from '../assets/icons/media.js';
|
|
17
|
+
import { EVENT_SAVE, EVENT_USE } from '../constants.js';
|
|
18
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
19
|
+
import useRequestErrors from '../hooks/use-request-errors.js';
|
|
20
|
+
import { updateLogo } from '../lib/logo-storage.js';
|
|
21
|
+
import { STORE_NAME } from '../store/index.js';
|
|
22
|
+
import { ImageLoader } from './image-loader.js';
|
|
23
23
|
import './logo-presenter.scss';
|
|
24
24
|
const debug = debugFactory('jetpack-ai-calypso:logo-presenter');
|
|
25
25
|
const SaveInLibraryButton = ({ siteId }) => {
|
|
@@ -54,7 +54,10 @@ const SaveInLibraryButton = ({ siteId }) => {
|
|
|
54
54
|
};
|
|
55
55
|
const savingLabel = _x('Saving…', 'Logo save button', 'jetpack-ai-client');
|
|
56
56
|
const savedLabel = __('Saved', 'jetpack-ai-client');
|
|
57
|
-
return !saving && !saved ? (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", onClick: handleClick, children: [
|
|
57
|
+
return !saving && !saved ? (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", onClick: handleClick, children: [
|
|
58
|
+
_jsx(Icon, { icon: _jsx(MediaIcon, {}) }), _jsx("span", { className: "action-text", children: __('Save in Library', 'jetpack-ai-client') })
|
|
59
|
+
] })) : (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", children: [_jsx(Icon, { icon: saving ? _jsx(MediaIcon, {}) : _jsx(CheckIcon, {}) }), _jsx("span", { className: "action-text", children: saving ? savingLabel : savedLabel })
|
|
60
|
+
] }));
|
|
58
61
|
};
|
|
59
62
|
const UseOnSiteButton = ({ onApplyLogo }) => {
|
|
60
63
|
const { tracks } = useAnalytics();
|
|
@@ -70,16 +73,24 @@ const UseOnSiteButton = ({ onApplyLogo }) => {
|
|
|
70
73
|
onApplyLogo?.(selectedLogo?.mediaId);
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
|
-
return (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", onClick: handleClick, disabled: isSavingLogoToLibrary || !selectedLogo?.mediaId, variant: "secondary", children: [
|
|
76
|
+
return (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", onClick: handleClick, disabled: isSavingLogoToLibrary || !selectedLogo?.mediaId, variant: "secondary", children: [
|
|
77
|
+
_jsx(Icon, { icon: _jsx(LogoIcon, {}) }), _jsx("span", { className: "action-text", children: __('Use on block', 'jetpack-ai-client') })
|
|
78
|
+
] }));
|
|
74
79
|
};
|
|
75
80
|
const LogoLoading = () => {
|
|
76
|
-
return (_jsxs(_Fragment, { children: [
|
|
81
|
+
return (_jsxs(_Fragment, { children: [
|
|
82
|
+
_jsx(ImageLoader, { className: "jetpack-ai-logo-generator-modal-presenter__logo" }), _jsx("span", { className: "jetpack-ai-logo-generator-modal-presenter__loading-text", children: __('Generating new logo…', 'jetpack-ai-client') })
|
|
83
|
+
] }));
|
|
77
84
|
};
|
|
78
85
|
const LogoFetching = () => {
|
|
79
|
-
return (_jsxs(_Fragment, { children: [
|
|
86
|
+
return (_jsxs(_Fragment, { children: [
|
|
87
|
+
_jsx(ImageLoader, { className: "jetpack-ai-logo-generator-modal-presenter__logo" }), _jsx("span", { className: "jetpack-ai-logo-generator-modal-presenter__loading-text", children: __('Fetching previous logos…', 'jetpack-ai-client') })
|
|
88
|
+
] }));
|
|
80
89
|
};
|
|
81
90
|
const LogoEmpty = () => {
|
|
82
|
-
return (_jsxs(_Fragment, { children: [
|
|
91
|
+
return (_jsxs(_Fragment, { children: [
|
|
92
|
+
_jsx("div", { style: { width: 0, height: '229px' } }), _jsx("span", { className: "jetpack-ai-logo-generator-modal-presenter__loading-text", children: __('Once you generate a logo, it will show up here', 'jetpack-ai-client') })
|
|
93
|
+
] }));
|
|
83
94
|
};
|
|
84
95
|
const RateLogo = ({ disabled, ratedItem, onRate }) => {
|
|
85
96
|
const { logos, selectedLogo } = useLogoGenerator();
|
|
@@ -105,10 +116,20 @@ const LogoReady = ({ siteId, logo, onApplyLogo }) => {
|
|
|
105
116
|
rating,
|
|
106
117
|
});
|
|
107
118
|
};
|
|
108
|
-
return (_jsxs(_Fragment, { children: [
|
|
119
|
+
return (_jsxs(_Fragment, { children: [
|
|
120
|
+
_jsx("img", { src: logo.url, alt: logo.description, className: "jetpack-ai-logo-generator-modal-presenter__logo" }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter__action-wrapper", children: [
|
|
121
|
+
_jsx("span", { className: "jetpack-ai-logo-generator-modal-presenter__description", children: logo.description }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter__actions", children: [
|
|
122
|
+
_jsx(SaveInLibraryButton, { siteId: siteId }), _jsx(UseOnSiteButton, { onApplyLogo: onApplyLogo }), _jsx(RateLogo, { ratedItem: logo.url, disabled: false, onRate: handleRateLogo })
|
|
123
|
+
] })
|
|
124
|
+
] })
|
|
125
|
+
] }));
|
|
109
126
|
};
|
|
110
127
|
const LogoUpdated = ({ logo }) => {
|
|
111
|
-
return (_jsxs(_Fragment, { children: [
|
|
128
|
+
return (_jsxs(_Fragment, { children: [
|
|
129
|
+
_jsx("img", { src: logo.url, alt: logo.description, className: "jetpack-ai-logo-generator-modal-presenter__logo" }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter__success-wrapper", children: [
|
|
130
|
+
_jsx(Icon, { icon: _jsx(CheckIcon, {}) }), _jsx("span", { children: __('Your new logo was set to the block!', 'jetpack-ai-client') })
|
|
131
|
+
] })
|
|
132
|
+
] }));
|
|
112
133
|
};
|
|
113
134
|
export const LogoPresenter = ({ logo = null, loading = false, onApplyLogo, logoAccepted = false, siteId, }) => {
|
|
114
135
|
const { isRequestingImage } = useLogoGenerator();
|
|
@@ -130,5 +151,7 @@ export const LogoPresenter = ({ logo = null, loading = false, onApplyLogo, logoA
|
|
|
130
151
|
else {
|
|
131
152
|
logoContent = (_jsx(LogoReady, { siteId: String(siteId), logo: logo, onApplyLogo: onApplyLogo }));
|
|
132
153
|
}
|
|
133
|
-
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter__wrapper", children: [
|
|
154
|
+
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter__wrapper", children: [
|
|
155
|
+
_jsxs("div", { className: "jetpack-ai-logo-generator-modal-presenter", children: [
|
|
156
|
+
_jsx("div", { className: "jetpack-ai-logo-generator-modal-presenter__content", children: logoContent }), !logoAccepted && (_jsx("div", { className: "jetpack-ai-logo-generator-modal-presenter__rectangle" }))] }), saveToLibraryError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error saving the logo to your library. Please try again.', 'jetpack-ai-client') })), logoUpdateError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error applying the logo to your site. Please try again.', 'jetpack-ai-client') }))] }));
|
|
134
157
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
@@ -11,14 +11,14 @@ import { useCallback, useEffect, useState, useRef } from 'react';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import { IMAGE_STYLE_NONE, IMAGE_STYLE_AUTO } from
|
|
15
|
-
import AiIcon from
|
|
16
|
-
import { EVENT_GENERATE, MINIMUM_PROMPT_LENGTH, EVENT_UPGRADE, EVENT_PLACEMENT_INPUT_FOOTER, EVENT_SWITCH_STYLE, EVENT_GUESS_STYLE, } from
|
|
17
|
-
import { useCheckout } from
|
|
18
|
-
import useLogoGenerator from
|
|
19
|
-
import useRequestErrors from
|
|
20
|
-
import { FairUsageNotice } from
|
|
21
|
-
import { UpgradeNudge } from
|
|
14
|
+
import { IMAGE_STYLE_NONE, IMAGE_STYLE_AUTO } from '../../hooks/use-image-generator/constants.js';
|
|
15
|
+
import AiIcon from '../assets/icons/ai.js';
|
|
16
|
+
import { EVENT_GENERATE, MINIMUM_PROMPT_LENGTH, EVENT_UPGRADE, EVENT_PLACEMENT_INPUT_FOOTER, EVENT_SWITCH_STYLE, EVENT_GUESS_STYLE, } from '../constants.js';
|
|
17
|
+
import { useCheckout } from '../hooks/use-checkout.js';
|
|
18
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
19
|
+
import useRequestErrors from '../hooks/use-request-errors.js';
|
|
20
|
+
import { FairUsageNotice } from './fair-usage-notice.js';
|
|
21
|
+
import { UpgradeNudge } from './upgrade-nudge.js';
|
|
22
22
|
import './prompt.scss';
|
|
23
23
|
const debug = debugFactory('jetpack-ai-calypso:prompt-box');
|
|
24
24
|
export const AiModalPromptInput = ({ prompt = '', setPrompt = () => { }, disabled = false, actionDisabled = false, generateHandler = () => { }, placeholder = '', buttonLabel = '', }) => {
|
|
@@ -60,9 +60,11 @@ export const AiModalPromptInput = ({ prompt = '', setPrompt = () => { }, disable
|
|
|
60
60
|
inputRef.current.innerHTML = '';
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
return (_jsxs("div", { className: "jetpack-ai-image-generator__prompt-query", children: [
|
|
63
|
+
return (_jsxs("div", { className: "jetpack-ai-image-generator__prompt-query", children: [
|
|
64
|
+
_jsx("div", { role: "textbox", tabIndex: 0, ref: inputRef, contentEditable: !disabled,
|
|
64
65
|
// The content editable div is expected to be updated by the enhance prompt, so warnings are suppressed
|
|
65
|
-
suppressContentEditableWarning: true, className: "prompt-query__input", onInput: onPromptInput, onPaste: onPromptPaste, onKeyDown: onKeyDown, onKeyUp: onKeyUp, "data-placeholder": placeholder }), _jsx(Button, { variant: "primary", className: "jetpack-ai-image-generator__prompt-submit", onClick: generateHandler, disabled: actionDisabled, children: buttonLabel || __('Generate', 'jetpack-ai-client') })
|
|
66
|
+
suppressContentEditableWarning: true, className: "prompt-query__input", onInput: onPromptInput, onPaste: onPromptPaste, onKeyDown: onKeyDown, onKeyUp: onKeyUp, "data-placeholder": placeholder }), _jsx(Button, { variant: "primary", className: "jetpack-ai-image-generator__prompt-submit", onClick: generateHandler, disabled: actionDisabled, children: buttonLabel || __('Generate', 'jetpack-ai-client') })
|
|
67
|
+
] }));
|
|
66
68
|
};
|
|
67
69
|
export const Prompt = ({ initialPrompt = '' }) => {
|
|
68
70
|
const { tracks } = useAnalytics();
|
|
@@ -154,7 +156,16 @@ export const Prompt = ({ initialPrompt = '' }) => {
|
|
|
154
156
|
setStyle(imageStyle);
|
|
155
157
|
recordTracksEvent(EVENT_SWITCH_STYLE, { context, style: imageStyle });
|
|
156
158
|
}, [context, setStyle, recordTracksEvent]);
|
|
157
|
-
return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt", children: [
|
|
159
|
+
return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt", children: [
|
|
160
|
+
_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-header", children: [
|
|
161
|
+
_jsx("div", { className: "jetpack-ai-logo-generator__prompt-label", children: __('Describe your site:', 'jetpack-ai-client') }), _jsx("div", { className: "jetpack-ai-logo-generator__prompt-actions", children: _jsxs(Button, { variant: "link", disabled: isBusy || requireUpgrade || !hasPrompt, onClick: onEnhance, children: [
|
|
162
|
+
_jsx(AiIcon, {}), enhanceButtonLabel] }) }), showStyleSelector && (_jsx(SelectControl, { __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, value: style, options: styles, onChange: updateStyle, disabled: isBusy || requireUpgrade }))] }), _jsx(AiModalPromptInput, { prompt: prompt, setPrompt: setPrompt, generateHandler: onGenerate, disabled: isBusy || requireUpgrade, actionDisabled: isBusy || requireUpgrade || !hasPrompt, placeholder: __('Describe your site or simply ask for a logo specifying some details about it', 'jetpack-ai-client') }), _jsxs("div", { className: "jetpack-ai-logo-generator__prompt-footer", children: [!isUnlimited && !requireUpgrade && (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-requests", children: [
|
|
163
|
+
_jsx("div", { children: sprintf(
|
|
158
164
|
// translators: %d is the number of requests
|
|
159
|
-
__('%d requests remaining.', 'jetpack-ai-client'), requestsRemaining) }), hasNextTier && (_jsxs(_Fragment, { children: ["\u00A0",
|
|
165
|
+
__('%d requests remaining.', 'jetpack-ai-client'), requestsRemaining) }), hasNextTier && (_jsxs(_Fragment, { children: ["\u00A0",
|
|
166
|
+
_jsx(Button, { variant: "link", href: checkoutUrl, target: "_blank", onClick: onUpgradeClick, children: _jsx("span", { children: __('Upgrade', 'jetpack-ai-client') }) })
|
|
167
|
+
] })), "\u00A0",
|
|
168
|
+
_jsx(Tooltip, { text: __('Logo generation costs 10 requests; prompt enhancement costs 1 request each', 'jetpack-ai-client'), placement: "bottom", children: _jsx(Icon, { className: "prompt-footer__icon", icon: info }) })
|
|
169
|
+
] })), requireUpgrade && tierPlansEnabled && _jsx(UpgradeNudge, {}), requireUpgrade && !tierPlansEnabled && _jsx(FairUsageNotice, {}), enhancePromptFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error enhancing prompt. Please try again.', 'jetpack-ai-client') })), logoFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error generating logo. Please try again.', 'jetpack-ai-client') }))] })
|
|
170
|
+
] }));
|
|
160
171
|
};
|
|
@@ -10,9 +10,9 @@ import { Icon, cautionFilled as warning } from '@wordpress/icons';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import { EVENT_PLACEMENT_UPGRADE_PROMPT, EVENT_UPGRADE } from
|
|
14
|
-
import { useCheckout } from
|
|
15
|
-
import useLogoGenerator from
|
|
13
|
+
import { EVENT_PLACEMENT_UPGRADE_PROMPT, EVENT_UPGRADE } from '../constants.js';
|
|
14
|
+
import { useCheckout } from '../hooks/use-checkout.js';
|
|
15
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
16
16
|
import './upgrade-nudge.scss';
|
|
17
17
|
export const UpgradeNudge = () => {
|
|
18
18
|
const { tracks } = useAnalytics();
|
|
@@ -26,5 +26,9 @@ export const UpgradeNudge = () => {
|
|
|
26
26
|
const handleUpgradeClick = () => {
|
|
27
27
|
recordTracksEvent(EVENT_UPGRADE, { context, placement: EVENT_PLACEMENT_UPGRADE_PROMPT });
|
|
28
28
|
};
|
|
29
|
-
return (_jsx("div", { className: "jetpack-upgrade-plan-banner", children: _jsxs("div", { className: "jetpack-upgrade-plan-banner__wrapper", children: [
|
|
29
|
+
return (_jsx("div", { className: "jetpack-upgrade-plan-banner", children: _jsxs("div", { className: "jetpack-upgrade-plan-banner__wrapper", children: [
|
|
30
|
+
_jsxs("div", { children: [
|
|
31
|
+
_jsx(Icon, { className: "jetpack-upgrade-plan-banner__icon", icon: warning }), _jsx("span", { className: "jetpack-upgrade-plan-banner__banner-description", children: upgradeMessage })
|
|
32
|
+
] }), _jsx(Button, { href: checkoutUrl, target: "_blank", className: "is-primary", onClick: handleUpgradeClick, children: _jsx("span", { children: buttonText }) })
|
|
33
|
+
] }) }));
|
|
30
34
|
};
|
|
@@ -9,8 +9,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import { EVENT_PLACEMENT_FREE_USER_SCREEN, EVENT_UPGRADE } from
|
|
13
|
-
import useLogoGenerator from
|
|
12
|
+
import { EVENT_PLACEMENT_FREE_USER_SCREEN, EVENT_UPGRADE } from '../constants.js';
|
|
13
|
+
import useLogoGenerator from '../hooks/use-logo-generator.js';
|
|
14
14
|
export const UpgradeScreen = ({ onCancel, upgradeURL, reason }) => {
|
|
15
15
|
const { tracks } = useAnalytics();
|
|
16
16
|
const { recordEvent: recordTracksEvent } = tracks;
|
|
@@ -24,5 +24,13 @@ export const UpgradeScreen = ({ onCancel, upgradeURL, reason }) => {
|
|
|
24
24
|
recordTracksEvent(EVENT_UPGRADE, { context, placement: EVENT_PLACEMENT_FREE_USER_SCREEN });
|
|
25
25
|
onCancel();
|
|
26
26
|
};
|
|
27
|
-
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-message-wrapper", children: [
|
|
27
|
+
return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-message-wrapper", children: [
|
|
28
|
+
_jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-message", children: [
|
|
29
|
+
_jsx("span", { className: "jetpack-ai-logo-generator-modal__loading-message", children: reason === 'feature' ? upgradeMessageFeature : upgradeMessageRequests }),
|
|
30
|
+
"\u00A0",
|
|
31
|
+
_jsx(Button, { variant: "link", href: upgradeInfoUrl, target: "_blank", children: _jsx("span", { children: __('Learn more about Jetpack AI.', 'jetpack-ai-client') }) })
|
|
32
|
+
] }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-actions", children: [
|
|
33
|
+
_jsx(Button, { variant: "tertiary", onClick: onCancel, children: _jsx("span", { children: __('Cancel', 'jetpack-ai-client') }) }), _jsx(Button, { variant: "primary", href: upgradeURL, target: "_blank", onClick: handleUpgradeClick, children: _jsx("span", { children: __('Upgrade', 'jetpack-ai-client') }) })
|
|
34
|
+
] })
|
|
35
|
+
] }));
|
|
28
36
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { Button, Icon } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { external } from '@wordpress/icons';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import jetpackLogo from '../assets/images/jetpack-logo.svg';
|
|
13
|
+
import './visit-site-banner.scss';
|
|
14
|
+
export const VisitSiteBanner = ({ className = null, onVisitBlankTarget }) => {
|
|
15
|
+
return (_jsxs("div", { className: clsx('jetpack-ai-logo-generator-modal-visit-site-banner', className), children: [
|
|
16
|
+
_jsx("div", { className: "jetpack-ai-logo-generator-modal-visit-site-banner__jetpack-logo", children: _jsx("img", { src: jetpackLogo, alt: "Jetpack" }) }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal-visit-site-banner__content", children: [
|
|
17
|
+
_jsx("strong", { children: __('Do you want to know all the amazing things you can do with Jetpack AI?', 'jetpack-ai-client') }), _jsx("span", { children: __('Generate and tweak content, create forms, get feedback and much more.', 'jetpack-ai-client') }), _jsx("div", { children: _jsxs(Button, { variant: "link", href: "https://jetpack.com/redirect/?source=logo_generator_learn_more_about_jetpack_ai", target: "_blank", onClick: onVisitBlankTarget ? onVisitBlankTarget : null, children: [
|
|
18
|
+
_jsx("span", { children: __('Learn more about Jetpack AI', 'jetpack-ai-client') }), _jsx(Icon, { icon: external, size: 20 })
|
|
19
|
+
] }) })
|
|
20
|
+
] })
|
|
21
|
+
] }));
|
|
22
|
+
};
|
|
@@ -7,7 +7,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { STORE_NAME } from
|
|
10
|
+
import { STORE_NAME } from '../store/index.js';
|
|
11
11
|
export const useCheckout = () => {
|
|
12
12
|
const { nextTier, tierPlansEnabled } = useSelect(select => {
|
|
13
13
|
const selectors = select(STORE_NAME);
|
|
@@ -6,7 +6,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { STORE_NAME } from
|
|
9
|
+
import { STORE_NAME } from '../store/index.js';
|
|
10
10
|
const useFairUsageNoticeMessage = () => {
|
|
11
11
|
const { usagePeriod } = useSelect(select => {
|
|
12
12
|
const selectors = select(STORE_NAME);
|
|
@@ -18,11 +18,11 @@ declare const useLogoGenerator: () => {
|
|
|
18
18
|
applyLogo: () => Promise<void>;
|
|
19
19
|
generateImage: ({ prompt, style, }: {
|
|
20
20
|
prompt: string;
|
|
21
|
-
style?: ImageStyle
|
|
21
|
+
style?: ImageStyle;
|
|
22
22
|
}) => Promise<{
|
|
23
|
-
data:
|
|
23
|
+
data: {
|
|
24
24
|
url: string;
|
|
25
|
-
}
|
|
25
|
+
}[];
|
|
26
26
|
}>;
|
|
27
27
|
enhancePrompt: ({ prompt }: {
|
|
28
28
|
prompt: string;
|
|
@@ -30,7 +30,7 @@ declare const useLogoGenerator: () => {
|
|
|
30
30
|
storeLogo: (logo: Logo) => void;
|
|
31
31
|
generateLogo: ({ prompt, style, }: {
|
|
32
32
|
prompt: string;
|
|
33
|
-
style?: ImageStyle
|
|
33
|
+
style?: ImageStyle;
|
|
34
34
|
}) => Promise<void>;
|
|
35
35
|
setIsEnhancingPrompt: any;
|
|
36
36
|
setIsRequestingImage: any;
|
|
@@ -49,6 +49,6 @@ declare const useLogoGenerator: () => {
|
|
|
49
49
|
isLoadingHistory: boolean;
|
|
50
50
|
setIsLoadingHistory: any;
|
|
51
51
|
imageStyles: ImageStyleObject[];
|
|
52
|
-
guessStyle: (prompt: string) => Promise<ImageStyle
|
|
52
|
+
guessStyle: (prompt: string) => Promise<ImageStyle>;
|
|
53
53
|
};
|
|
54
54
|
export default useLogoGenerator;
|
|
@@ -7,14 +7,14 @@ import { useCallback } from 'react';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import askQuestionSync from
|
|
11
|
-
import useImageGenerator from
|
|
12
|
-
import useSaveToMediaLibrary from
|
|
13
|
-
import requestJwt from
|
|
14
|
-
import { stashLogo } from
|
|
15
|
-
import { setSiteLogo } from
|
|
16
|
-
import { STORE_NAME } from
|
|
17
|
-
import useRequestErrors from
|
|
10
|
+
import askQuestionSync from '../../ask-question/sync.js';
|
|
11
|
+
import useImageGenerator from '../../hooks/use-image-generator/index.js';
|
|
12
|
+
import useSaveToMediaLibrary from '../../hooks/use-save-to-media-library/index.js';
|
|
13
|
+
import requestJwt from '../../jwt/index.js';
|
|
14
|
+
import { stashLogo } from '../lib/logo-storage.js';
|
|
15
|
+
import { setSiteLogo } from '../lib/set-site-logo.js';
|
|
16
|
+
import { STORE_NAME } from '../store/index.js';
|
|
17
|
+
import useRequestErrors from './use-request-errors.js';
|
|
18
18
|
const debug = debugFactory('jetpack-ai-calypso:use-logo-generator');
|
|
19
19
|
const useLogoGenerator = () => {
|
|
20
20
|
const { setSelectedLogoIndex, setIsSavingLogoToLibrary, setIsApplyingLogo, setIsRequestingImage, setIsEnhancingPrompt, increaseAiAssistantRequestsCount, addLogoToHistory, setContext, setIsLoadingHistory, } = useDispatch(STORE_NAME);
|
|
@@ -211,7 +211,7 @@ User request:${prompt}`;
|
|
|
211
211
|
throw error;
|
|
212
212
|
}
|
|
213
213
|
}, [name, description]);
|
|
214
|
-
const saveLogo = useCallback(async
|
|
214
|
+
const saveLogo = useCallback(async logo => {
|
|
215
215
|
setSaveToLibraryError(null);
|
|
216
216
|
try {
|
|
217
217
|
debug('Saving logo for site');
|
|
@@ -5,7 +5,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import { STORE_NAME } from
|
|
8
|
+
import { STORE_NAME } from '../store/index.js';
|
|
9
9
|
const useRequestErrors = () => {
|
|
10
10
|
const { setFeatureFetchError, setFirstLogoPromptFetchError, setEnhancePromptFetchError, setLogoFetchError, setSaveToLibraryError, setLogoUpdateError, } = useDispatch(STORE_NAME);
|
|
11
11
|
const { featureFetchError, firstLogoPromptFetchError, enhancePromptFetchError, logoFetchError, saveToLibraryError, logoUpdateError, } = useSelect(select => {
|
|
@@ -14,7 +14,7 @@ import { RemoveFromStorageProps, SaveToStorageProps, UpdateInStorageProps } from
|
|
|
14
14
|
* @param {SaveToStorageProps.revisedPrompt} saveToStorageProps.revisedPrompt - The revised prompt of the logo
|
|
15
15
|
* @return {Logo} The logo that was saved
|
|
16
16
|
*/
|
|
17
|
-
export declare function stashLogo({ siteId, url, description, mediaId, revisedPrompt
|
|
17
|
+
export declare function stashLogo({ siteId, url, description, mediaId, revisedPrompt }: SaveToStorageProps): Logo;
|
|
18
18
|
/**
|
|
19
19
|
* Update an entry in the site's logo history.
|
|
20
20
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getSiteLogoHistory } from
|
|
5
|
-
import wpcomLimitedRequest from
|
|
4
|
+
import { getSiteLogoHistory } from '../lib/logo-storage.js';
|
|
5
|
+
import wpcomLimitedRequest from '../lib/wpcom-limited-request.js';
|
|
6
6
|
/**
|
|
7
7
|
* Types & Constants
|
|
8
8
|
*/
|
|
9
|
-
import { ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, ACTION_REQUEST_AI_ASSISTANT_FEATURE, ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE, ACTION_SET_SITE_DETAILS, ACTION_STORE_AI_ASSISTANT_FEATURE, ACTION_SET_TIER_PLANS_ENABLED, ACTION_SET_SELECTED_LOGO_INDEX, ACTION_ADD_LOGO_TO_HISTORY, ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY, ACTION_SAVE_SELECTED_LOGO, ACTION_SET_IS_REQUESTING_IMAGE, ACTION_SET_IS_APPLYING_LOGO, ACTION_SET_IS_ENHANCING_PROMPT, ACTION_SET_SITE_HISTORY, ACTION_SET_FEATURE_FETCH_ERROR, ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR, ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR, ACTION_SET_LOGO_FETCH_ERROR, ACTION_SET_LOGO_UPDATE_ERROR, ACTION_SET_SAVE_TO_LIBRARY_ERROR, ACTION_SET_CONTEXT, ACTION_SET_IS_LOADING_HISTORY, } from
|
|
9
|
+
import { ACTION_INCREASE_AI_ASSISTANT_REQUESTS_COUNT, ACTION_REQUEST_AI_ASSISTANT_FEATURE, ACTION_SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE, ACTION_SET_SITE_DETAILS, ACTION_STORE_AI_ASSISTANT_FEATURE, ACTION_SET_TIER_PLANS_ENABLED, ACTION_SET_SELECTED_LOGO_INDEX, ACTION_ADD_LOGO_TO_HISTORY, ACTION_SET_IS_SAVING_LOGO_TO_LIBRARY, ACTION_SAVE_SELECTED_LOGO, ACTION_SET_IS_REQUESTING_IMAGE, ACTION_SET_IS_APPLYING_LOGO, ACTION_SET_IS_ENHANCING_PROMPT, ACTION_SET_SITE_HISTORY, ACTION_SET_FEATURE_FETCH_ERROR, ACTION_SET_FIRST_LOGO_PROMPT_FETCH_ERROR, ACTION_SET_ENHANCE_PROMPT_FETCH_ERROR, ACTION_SET_LOGO_FETCH_ERROR, ACTION_SET_LOGO_UPDATE_ERROR, ACTION_SET_SAVE_TO_LIBRARY_ERROR, ACTION_SET_CONTEXT, ACTION_SET_IS_LOADING_HISTORY, } from './constants.js';
|
|
10
10
|
/**
|
|
11
11
|
* Map the response from the `sites/$site/ai-assistant-feature`
|
|
12
12
|
* endpoint to the AI Assistant feature props.
|
|
@@ -5,9 +5,9 @@ import { createReduxStore, register } from '@wordpress/data';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import actions from
|
|
9
|
-
import reducer from
|
|
10
|
-
import selectors from
|
|
8
|
+
import actions from './actions.js';
|
|
9
|
+
import reducer from './reducer.js';
|
|
10
|
+
import selectors from './selectors.js';
|
|
11
11
|
export const STORE_NAME = 'jetpack-ai/logo-generator';
|
|
12
12
|
const jetpackAiLogoGeneratorStore = createReduxStore(STORE_NAME, {
|
|
13
13
|
// @ts-expect-error -- TSCONVERSION
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types & Constants
|
|
3
3
|
*/
|
|
4
|
-
import { ASYNC_REQUEST_COUNTDOWN_INIT_VALUE, FREE_PLAN_REQUESTS_LIMIT } from
|
|
4
|
+
import { ASYNC_REQUEST_COUNTDOWN_INIT_VALUE, FREE_PLAN_REQUESTS_LIMIT } from './constants.js';
|
|
5
5
|
const INITIAL_STATE = {
|
|
6
6
|
siteDetails: {},
|
|
7
7
|
features: {
|