diff --git a/projects/js-packages/shared-extension-utils/index.js b/projects/js-packages/shared-extension-utils/index.js index 2dd8f77b42027..1e1cb994ebf14 100644 --- a/projects/js-packages/shared-extension-utils/index.js +++ b/projects/js-packages/shared-extension-utils/index.js @@ -1,3 +1,4 @@ +export * from './src/block-icons'; export { default as getJetpackData, JETPACK_DATA_PATH } from './src/get-jetpack-data'; export { default as getSiteFragment } from './src/get-site-fragment'; export * from './src/site-type-utils'; @@ -14,10 +15,17 @@ export { getUsableBlockProps, } from './src/plan-utils'; export { default as isCurrentUserConnected } from './src/is-current-user-connected'; +export { default as useAiFeature } from './src/hooks/use-api-feature'; export { default as useAnalytics } from './src/hooks/use-analytics'; export { default as useModuleStatus } from './src/hooks/use-module-status'; +export { default as usePlanType } from './src/hooks/use-plan-type'; +export { default as usePostContent } from './src/hooks/use-post-content'; +export { default as useSaveToMediaLibrary } from './src/hooks/use-save-to-media-library'; export { default as JetpackEditorPanelLogo } from './src/components/jetpack-editor-panel-logo'; export { getBlockIconComponent, getBlockIconProp } from './src/get-block-icon-from-metadata'; export { default as getJetpackBlocksVariation } from './src/get-jetpack-blocks-variation'; +export * from './src/icons'; export * from './src/modules-state'; export { default as isMyJetpackAvailable } from './src/is-my-jetpack-available'; +export { default as useRafInterval } from './src/use-ref-interval'; +export * from './src/wait-for'; diff --git a/projects/plugins/jetpack/extensions/shared/block-icons.js b/projects/js-packages/shared-extension-utils/src/block-icons.js similarity index 85% rename from projects/plugins/jetpack/extensions/shared/block-icons.js rename to projects/js-packages/shared-extension-utils/src/block-icons.js index c2f176002e749..c072ceac038b3 100644 --- a/projects/plugins/jetpack/extensions/shared/block-icons.js +++ b/projects/js-packages/shared-extension-utils/src/block-icons.js @@ -1,5 +1,5 @@ import colorStudio from '@automattic/color-studio'; -import { isAtomicSite, isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; +import { isAtomicSite, isSimpleSite } from './site-type-utils'; /** * Constants diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/ai-image-modal.scss b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/ai-image-modal.scss similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/ai-image-modal.scss rename to projects/js-packages/shared-extension-utils/src/components/ai-image/components/ai-image-modal.scss diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/ai-image-modal.tsx b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/ai-image-modal.tsx similarity index 85% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/ai-image-modal.tsx rename to projects/js-packages/shared-extension-utils/src/components/ai-image/components/ai-image-modal.tsx index ea6256a9a7bc7..af5b7756bd64d 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/ai-image-modal.tsx +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/ai-image-modal.tsx @@ -9,11 +9,11 @@ import { ImageStyle, AiModalFooter, } from '@automattic/jetpack-ai-client'; -import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; import { SelectControl } from '@wordpress/components'; import { useCallback, useRef, useState, useEffect } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import debugFactory from 'debug'; +import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; /** * Internal dependencies */ @@ -27,6 +27,42 @@ const FEATURED_IMAGE_UPGRADE_PROMPT_PLACEMENT = 'ai-image-generator'; const debug = debugFactory( 'jetpack-ai:ai-image-modal' ); +/** + * + * @param root0 + * @param root0.title + * @param root0.cost + * @param root0.open + * @param root0.placement + * @param root0.images + * @param root0.currentIndex + * @param root0.onClose + * @param root0.onTryAgain + * @param root0.onGenerate + * @param root0.generating + * @param root0.notEnoughRequests + * @param root0.requireUpgrade + * @param root0.currentLimit + * @param root0.currentUsage + * @param root0.isUnlimited + * @param root0.upgradeDescription + * @param root0.hasError + * @param root0.postContent + * @param root0.handlePreviousImage + * @param root0.handleNextImage + * @param root0.acceptButton + * @param root0.autoStart + * @param root0.autoStartAction + * @param root0.generateButtonLabel + * @param root0.instructionsPlaceholder + * @param root0.imageStyles + * @param root0.onGuessStyle + * @param root0.prompt + * @param root0.setPrompt + * @param root0.initialStyle + * @param root0.inputDisabled + * @param root0.actionDisabled + */ export default function AiImageModal( { title, cost, @@ -133,8 +169,8 @@ export default function AiImageModal( { const upgradePromptVisible = ( requireUpgrade || notEnoughRequests ) && ! generating; const counterVisible = Boolean( ! isUnlimited && cost && currentLimit ); - const generateLabel = __( 'Generate', 'jetpack' ); - const tryAgainLabel = __( 'Try again', 'jetpack' ); + const generateLabel = __( 'Generate', 'jetpack-shared-extension-utils' ); + const tryAgainLabel = __( 'Try again', 'jetpack-shared-extension-utils' ); /** * Trigger image generation automatically. @@ -174,7 +210,7 @@ export default function AiImageModal( { { showStyleSelector && (
- { __( 'Generate image', 'jetpack' ) } + { __( 'Generate image', 'jetpack-shared-extension-utils' ) }
{ generating ? ( - { __( 'Creating image…', 'jetpack' ) } + { __( 'Creating image…', 'jetpack-shared-extension-utils' ) } { __( 'An error occurred while generating the image. Please, try again!', - 'jetpack' + 'jetpack-shared-extension-utils' ) } { error?.message && ( diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/usage-counter.scss b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/usage-counter.scss similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/usage-counter.scss rename to projects/js-packages/shared-extension-utils/src/components/ai-image/components/usage-counter.scss diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/usage-counter.tsx b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/usage-counter.tsx similarity index 75% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/usage-counter.tsx rename to projects/js-packages/shared-extension-utils/src/components/ai-image/components/usage-counter.tsx index 107eebe5c0149..3cbc9c6529700 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/components/usage-counter.tsx +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/components/usage-counter.tsx @@ -14,19 +14,32 @@ type UsageCounterProps = { cost: number; }; +/** + * + * @param root0 + * @param root0.currentLimit + * @param root0.currentUsage + * @param root0.cost + */ export default function UsageCounter( { currentLimit, currentUsage, cost }: UsageCounterProps ) { const requestsBalance = currentLimit - currentUsage; const requestsNeeded = createInterpolateElement( // Translators: %d is the cost of one image. - sprintf( __( 'Requests needed: %d', 'jetpack' ), cost ), + sprintf( + __( 'Requests needed: %d', 'jetpack-shared-extension-utils' ), + cost + ), { counter: , } ); const requestsAvailable = createInterpolateElement( // Translators: %d is the current requests balance. - sprintf( __( 'Requests available: %d', 'jetpack' ), requestsBalance ), + sprintf( + __( 'Requests available: %d', 'jetpack-shared-extension-utils' ), + requestsBalance + ), { counter: requestsBalance < cost ? ( diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx b/projects/js-packages/shared-extension-utils/src/components/ai-image/featured-image.tsx similarity index 93% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx rename to projects/js-packages/shared-extension-utils/src/components/ai-image/featured-image.tsx index fed823639ba92..8506e66275bfb 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/featured-image.tsx @@ -2,25 +2,25 @@ * External dependencies */ import { ImageStyle } from '@automattic/jetpack-ai-client'; -import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; import { Button } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; import { store as editorStore } from '@wordpress/editor'; import { useCallback, useState } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import debugFactory from 'debug'; +import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; /** * Internal dependencies */ import './style.scss'; -import useAiFeature from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; -import { PLAN_TYPE_UNLIMITED, usePlanType } from '../../../../shared/use-plan-type'; -import usePostContent from '../../hooks/use-post-content'; -import useSaveToMediaLibrary from '../../hooks/use-save-to-media-library'; import { PLACEMENT_JETPACK_SIDEBAR, PLACEMENT_DOCUMENT_SETTINGS, -} from '../ai-assistant-plugin-sidebar/constants'; +} from '../../../../../plugins/jetpack/extensions/shared/constants'; +import useAiFeature from '../../hooks/use-ai-feature'; +import { PLAN_TYPE_UNLIMITED, usePlanType } from '../../hooks/use-plan-type'; +import usePostContent from '../../hooks/use-post-content'; +import useSaveToMediaLibrary from '../../hooks/use-save-to-media-library'; import AiImageModal from './components/ai-image-modal'; import useAiImage from './hooks/use-ai-image'; import useSiteType from './hooks/use-site-type'; @@ -35,6 +35,14 @@ import type { EditorSelectors } from './types'; const debug = debugFactory( 'jetpack-ai:featured-image' ); +/** + * + * @param root0 + * @param root0.busy + * @param root0.disabled + * @param root0.placement + * @param root0.onClose + */ export default function FeaturedImage( { busy, disabled, @@ -336,8 +344,8 @@ export default function FeaturedImage( { saveToMediaLibrary, ] ); - const generateAgainText = __( 'Generate another image', 'jetpack' ); - const generateText = __( 'Generate', 'jetpack' ); + const generateAgainText = __( 'Generate another image', 'jetpack-shared-extension-utils' ); + const generateText = __( 'Generate', 'jetpack-shared-extension-utils' ); const hasContent = postContent.trim?.() || postTitle.trim?.() ? true : false; const hasPrompt = hasContent ? prompt.length >= 0 : prompt.length >= 3; @@ -349,7 +357,7 @@ export default function FeaturedImage( { // Translators: %d is the cost of generating a featured image. __( "Featured image generation costs %d requests per image. You don't have enough requests to generate another image.", - 'jetpack' + 'jetpack-shared-extension-utils' ), featuredImageCost ) @@ -365,7 +373,7 @@ export default function FeaturedImage( { currentImage?.libraryId === postFeaturedMediaId } > - { __( 'Set as featured image', 'jetpack' ) } + { __( 'Set as featured image', 'jetpack-shared-extension-utils' ) } ); @@ -374,14 +382,19 @@ export default function FeaturedImage( { { ( placement === PLACEMENT_JETPACK_SIDEBAR || placement === PLACEMENT_DOCUMENT_SETTINGS ) && ( <> -

{ __( 'Create and use an AI generated featured image for your post.', 'jetpack' ) }

+

+ { __( + 'Create and use an AI generated featured image for your post.', + 'jetpack-shared-extension-utils' + ) } +

) } @@ -391,7 +404,7 @@ export default function FeaturedImage( { autoStartAction={ handleFirstGenerate } images={ images } currentIndex={ current } - title={ __( 'Generate a featured image with AI', 'jetpack' ) } + title={ __( 'Generate a featured image with AI', 'jetpack-shared-extension-utils' ) } cost={ featuredImageCost } open={ isFeaturedImageModalVisible } placement={ placement } @@ -414,7 +427,7 @@ export default function FeaturedImage( { generateButtonLabel={ pointer?.current > 0 ? generateAgainText : generateText } instructionsPlaceholder={ __( "Describe the featured image you'd like to create and select a style.", - 'jetpack' + 'jetpack-shared-extension-utils' ) } imageStyles={ imageStyles } onGuessStyle={ handleGuessStyle } diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/general-purpose-image.tsx b/projects/js-packages/shared-extension-utils/src/components/ai-image/general-purpose-image.tsx similarity index 93% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/general-purpose-image.tsx rename to projects/js-packages/shared-extension-utils/src/components/ai-image/general-purpose-image.tsx index 9d87cb99064e4..b82c67577a872 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/general-purpose-image.tsx +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/general-purpose-image.tsx @@ -1,17 +1,17 @@ /** * External dependencies */ -import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; import { Button } from '@wordpress/components'; import { useCallback, useState } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import debugFactory from 'debug'; +import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; /** * Internal dependencies */ import './style.scss'; -import useAiFeature from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; -import { PLAN_TYPE_UNLIMITED, usePlanType } from '../../../../shared/use-plan-type'; +import useAiFeature from '../../hooks/use-ai-feature'; +import { PLAN_TYPE_UNLIMITED, usePlanType } from '../../hooks/use-plan-type'; import usePostContent from '../../hooks/use-post-content'; import useSaveToMediaLibrary from '../../hooks/use-save-to-media-library'; import AiImageModal from './components/ai-image-modal'; @@ -33,6 +33,13 @@ type SetImageCallbackProps = { const debug = debugFactory( 'jetpack-ai:general-purpose-image' ); +/** + * + * @param root0 + * @param root0.placement + * @param root0.onClose + * @param root0.onSetImage + */ export default function GeneralPurposeImage( { placement, onClose = () => {}, @@ -230,15 +237,15 @@ export default function GeneralPurposeImage( { saveToMediaLibrary, ] ); - const generateAgainText = __( 'Generate another image', 'jetpack' ); - const generateText = __( 'Generate', 'jetpack' ); + const generateAgainText = __( 'Generate another image', 'jetpack-shared-extension-utils' ); + const generateText = __( 'Generate', 'jetpack-shared-extension-utils' ); const upgradeDescription = notEnoughRequests ? sprintf( // Translators: %d is the cost of generating a featured image. __( "Image generation costs %d requests per image. You don't have enough requests to generate another image.", - 'jetpack' + 'jetpack-shared-extension-utils' ), generalImageCost ) @@ -250,7 +257,7 @@ export default function GeneralPurposeImage( { variant="primary" disabled={ ! currentImage?.image || currentImage?.generating } > - { __( 'Insert image', 'jetpack' ) } + { __( 'Insert image', 'jetpack-shared-extension-utils' ) } ); @@ -259,7 +266,7 @@ export default function GeneralPurposeImage( { postContent={ true } images={ images } currentIndex={ current } - title={ __( 'Generate an image with AI', 'jetpack' ) } + title={ __( 'Generate an image with AI', 'jetpack-shared-extension-utils' ) } cost={ generalImageCost } open={ isFeaturedImageModalVisible } placement={ placement } @@ -280,7 +287,7 @@ export default function GeneralPurposeImage( { generateButtonLabel={ pointer?.current > 0 ? generateAgainText : generateText } instructionsPlaceholder={ __( "Describe the image you'd like to create and select a style.", - 'jetpack' + 'jetpack-shared-extension-utils' ) } imageStyles={ imageStyles } onGuessStyle={ guessStyle } diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-ai-image.ts b/projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-ai-image.ts similarity index 94% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-ai-image.ts rename to projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-ai-image.ts index 0edcb0176663b..194a9008f7777 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-ai-image.ts +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-ai-image.ts @@ -14,7 +14,7 @@ import { cleanForSlug } from '@wordpress/url'; /** * Internal dependencies */ -import useAiFeature from '../../../../../blocks/ai-assistant/hooks/use-ai-feature'; +import useAiFeature from '../../../hooks/use-ai-feature'; import useSaveToMediaLibrary from '../../../hooks/use-save-to-media-library'; /** * Types @@ -37,6 +37,15 @@ export type ImageResponse = { revisedPrompt?: string; }; +/** + * + * @param root0 + * @param root0.feature + * @param root0.type + * @param root0.cost + * @param root0.autoStart + * @param root0.previousMediaId + */ export default function useAiImage( { feature, type, @@ -158,7 +167,10 @@ export default function useAiImage( { { generating: false, error: new Error( - __( "You don't have enough requests to generate another image.", 'jetpack' ) + __( + "You don't have enough requests to generate another image.", + 'jetpack-shared-extension-utils' + ) ), }, pointer.current @@ -200,7 +212,9 @@ export default function useAiImage( { updateRequestsCount(); saveToMediaLibrary( image, name ) .then( savedImage => { - showSnackbarNotice( __( 'Image saved to media library.', 'jetpack' ) ); + showSnackbarNotice( + __( 'Image saved to media library.', 'jetpack-shared-extension-utils' ) + ); updateImages( { libraryId: savedImage?.id, libraryUrl: savedImage?.url, generating: false }, pointer.current diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-site-type.ts b/projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-site-type.ts similarity index 97% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-site-type.ts rename to projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-site-type.ts index cc99cfa282f22..4e94f023459d2 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/hooks/use-site-type.ts +++ b/projects/js-packages/shared-extension-utils/src/components/ai-image/hooks/use-site-type.ts @@ -1,9 +1,12 @@ /** * External dependencies */ -import { isAtomicSite, isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; import { useState } from '@wordpress/element'; +import { isAtomicSite, isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; +/** + * + */ export default function useSiteType() { const getSiteType = () => { if ( isAtomicSite() ) { diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/index.ts b/projects/js-packages/shared-extension-utils/src/components/ai-image/index.ts similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/index.ts rename to projects/js-packages/shared-extension-utils/src/components/ai-image/index.ts diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/style.scss b/projects/js-packages/shared-extension-utils/src/components/ai-image/style.scss similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/style.scss rename to projects/js-packages/shared-extension-utils/src/components/ai-image/style.scss diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts b/projects/js-packages/shared-extension-utils/src/components/ai-image/types.ts similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts rename to projects/js-packages/shared-extension-utils/src/components/ai-image/types.ts diff --git a/projects/plugins/jetpack/extensions/shared/components/number-control/index.jsx b/projects/js-packages/shared-extension-utils/src/components/number-control/index.jsx similarity index 100% rename from projects/plugins/jetpack/extensions/shared/components/number-control/index.jsx rename to projects/js-packages/shared-extension-utils/src/components/number-control/index.jsx diff --git a/projects/plugins/jetpack/extensions/shared/external-media/constants.js b/projects/js-packages/shared-extension-utils/src/external-media/constants.js similarity index 64% rename from projects/plugins/jetpack/extensions/shared/external-media/constants.js rename to projects/js-packages/shared-extension-utils/src/external-media/constants.js index 83e1731df976e..34e1377a13d8c 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/constants.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/constants.js @@ -18,11 +18,11 @@ export const PATH_ROOT = '/'; export const PATH_OPTIONS = [ { value: PATH_RECENT, - label: __( 'Photos', 'jetpack' ), + label: __( 'Photos', 'jetpack-shared-extension-utils' ), }, { value: PATH_ROOT, - label: __( 'Albums', 'jetpack' ), + label: __( 'Albums', 'jetpack-shared-extension-utils' ), }, ]; export const GOOGLE_PHOTOS_PICKER_SESSION = 'google_photos_picker_session'; @@ -30,107 +30,107 @@ export const GOOGLE_PHOTOS_CATEGORIES = [ { value: '', /* translators: category of images */ - label: __( 'All categories', 'jetpack' ), + label: __( 'All categories', 'jetpack-shared-extension-utils' ), }, { value: 'animals', /* translators: category of images */ - label: __( 'Animals', 'jetpack' ), + label: __( 'Animals', 'jetpack-shared-extension-utils' ), }, { value: 'arts', /* translators: category of images */ - label: __( 'Arts', 'jetpack' ), + label: __( 'Arts', 'jetpack-shared-extension-utils' ), }, { value: 'birthdays', /* translators: category of images */ - label: __( 'Birthdays', 'jetpack' ), + label: __( 'Birthdays', 'jetpack-shared-extension-utils' ), }, { value: 'cityscapes', /* translators: category of images */ - label: __( 'Cityscapes', 'jetpack' ), + label: __( 'Cityscapes', 'jetpack-shared-extension-utils' ), }, { value: 'crafts', /* translators: category of images */ - label: __( 'Crafts', 'jetpack' ), + label: __( 'Crafts', 'jetpack-shared-extension-utils' ), }, { value: 'fashion', /* translators: category of images */ - label: __( 'Fashion', 'jetpack' ), + label: __( 'Fashion', 'jetpack-shared-extension-utils' ), }, { value: 'food', /* translators: category of images */ - label: __( 'Food', 'jetpack' ), + label: __( 'Food', 'jetpack-shared-extension-utils' ), }, { value: 'flowers', /* translators: category of images */ - label: __( 'Flowers', 'jetpack' ), + label: __( 'Flowers', 'jetpack-shared-extension-utils' ), }, { value: 'gardens', /* translators: category of images */ - label: __( 'Gardens', 'jetpack' ), + label: __( 'Gardens', 'jetpack-shared-extension-utils' ), }, { value: 'holidays', /* translators: category of images */ - label: __( 'Holidays', 'jetpack' ), + label: __( 'Holidays', 'jetpack-shared-extension-utils' ), }, { value: 'houses', /* translators: category of images */ - label: __( 'Houses', 'jetpack' ), + label: __( 'Houses', 'jetpack-shared-extension-utils' ), }, { value: 'landmarks', /* translators: category of images */ - label: __( 'Landmarks', 'jetpack' ), + label: __( 'Landmarks', 'jetpack-shared-extension-utils' ), }, { value: 'landscapes', /* translators: category of images */ - label: __( 'Landscapes', 'jetpack' ), + label: __( 'Landscapes', 'jetpack-shared-extension-utils' ), }, { value: 'night', /* translators: category of images */ - label: __( 'Night', 'jetpack' ), + label: __( 'Night', 'jetpack-shared-extension-utils' ), }, { value: 'people', /* translators: category of images */ - label: __( 'People', 'jetpack' ), + label: __( 'People', 'jetpack-shared-extension-utils' ), }, { value: 'pets', /* translators: category of images */ - label: __( 'Pets', 'jetpack' ), + label: __( 'Pets', 'jetpack-shared-extension-utils' ), }, { value: 'selfies', /* translators: category of images */ - label: __( 'Selfies', 'jetpack' ), + label: __( 'Selfies', 'jetpack-shared-extension-utils' ), }, { value: 'sport', /* translators: category of images */ - label: __( 'Sport', 'jetpack' ), + label: __( 'Sport', 'jetpack-shared-extension-utils' ), }, { value: 'travel', /* translators: category of images */ - label: __( 'Travel', 'jetpack' ), + label: __( 'Travel', 'jetpack-shared-extension-utils' ), }, { value: 'weddings', /* translators: category of images */ - label: __( 'Weddings', 'jetpack' ), + label: __( 'Weddings', 'jetpack-shared-extension-utils' ), }, ]; export const PEXELS_EXAMPLE_QUERIES = [ @@ -151,34 +151,34 @@ export const DATE_RANGE_CUSTOM = 'CUSTOM'; export const GOOGLE_PHOTOS_DATE_PRESETS = [ { value: DATE_RANGE_ANY, - label: __( 'Any time', 'jetpack' ), + label: __( 'Any time', 'jetpack-shared-extension-utils' ), }, { value: DATE_RANGE_LAST_7_DAYS, - label: __( 'Last 7 days', 'jetpack' ), + label: __( 'Last 7 days', 'jetpack-shared-extension-utils' ), }, { value: DATE_RANGE_LAST_30_DAYS, - label: __( 'Last 30 days', 'jetpack' ), + label: __( 'Last 30 days', 'jetpack-shared-extension-utils' ), }, { value: DATE_RANGE_LAST_6_MONTHS, - label: __( 'Last 6 months', 'jetpack' ), + label: __( 'Last 6 months', 'jetpack-shared-extension-utils' ), }, { value: DATE_RANGE_LAST_12_MONTHS, - label: __( 'Last 12 months', 'jetpack' ), + label: __( 'Last 12 months', 'jetpack-shared-extension-utils' ), }, { value: DATE_RANGE_CUSTOM, - label: __( 'Specific Month/Year', 'jetpack' ), + label: __( 'Specific Month/Year', 'jetpack-shared-extension-utils' ), }, ]; export const CURRENT_YEAR = new Date().getFullYear(); export const MONTH_SELECT_OPTIONS = [ - { label: __( 'Any Month', 'jetpack' ), value: -1 }, + { label: __( 'Any Month', 'jetpack-shared-extension-utils' ), value: -1 }, ...map( range( 0, 12 ), value => ( { // Following call generates a new date object for the particular month and gets its name. label: dateI18n( 'F', new Date( 0, value ) ), diff --git a/projects/plugins/jetpack/extensions/shared/external-media/editor.scss b/projects/js-packages/shared-extension-utils/src/external-media/editor.scss similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/editor.scss rename to projects/js-packages/shared-extension-utils/src/external-media/editor.scss diff --git a/projects/plugins/jetpack/extensions/shared/external-media/index.js b/projects/js-packages/shared-extension-utils/src/external-media/index.js similarity index 98% rename from projects/plugins/jetpack/extensions/shared/external-media/index.js rename to projects/js-packages/shared-extension-utils/src/external-media/index.js index ecf704908fa6f..d15baf7156a70 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/index.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/index.js @@ -1,11 +1,16 @@ -import { isCurrentUserConnected } from '@automattic/jetpack-shared-extension-utils'; import { useBlockEditContext } from '@wordpress/block-editor'; import { addFilter } from '@wordpress/hooks'; +import { isCurrentUserConnected } from '@automattic/jetpack-shared-extension-utils'; import MediaButton from './media-button'; import { addPexelsToMediaInserter, addGooglePhotosToMediaInserter } from './media-service'; import { mediaSources } from './sources'; import './editor.scss'; +/** + * + * @param settings + * @param name + */ function insertExternalMediaBlocks( settings, name ) { if ( name !== 'core/image' ) { return settings; diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/index.js b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/index.js similarity index 93% rename from projects/plugins/jetpack/extensions/shared/external-media/media-browser/index.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-browser/index.js index afddfb0cdec73..28a805b5b5ece 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/index.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/index.js @@ -11,10 +11,16 @@ const MAX_SELECTED = 10; const EmptyResults = memo( () => (
-

{ __( 'Sorry, but nothing matched your search criteria.', 'jetpack' ) }

+

+ { __( 'Sorry, but nothing matched your search criteria.', 'jetpack-shared-extension-utils' ) } +

) ); +/** + * + * @param props + */ function MediaBrowser( props ) { const { media, @@ -168,9 +174,13 @@ function MediaBrowser( props ) { const disabled = selected.length === 0 || isCopying; const defaultLabel = selectProps?.labelText ? selectProps?.labelText( selected.length ) - : __( 'Select', 'jetpack', /* dummy arg to avoid bad minification */ 0 ); + : __( + 'Select', + 'jetpack-shared-extension-utils', + /* dummy arg to avoid bad minification */ 0 + ); - const label = isCopying ? __( 'Inserting…', 'jetpack' ) : defaultLabel; + const label = isCopying ? __( 'Inserting…', 'jetpack-shared-extension-utils' ) : defaultLabel; return (
@@ -214,7 +224,7 @@ function MediaBrowser( props ) { disabled={ isLoading || isCopying } onClick={ onLoadMoreClick } > - { __( 'Load More', 'jetpack' ) } + { __( 'Load More', 'jetpack-shared-extension-utils' ) } ) } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/media-item.js b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/media-item.js similarity index 97% rename from projects/plugins/jetpack/extensions/shared/external-media/media-browser/media-item.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-browser/media-item.js index ad94853dd0618..3c6d36110779c 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/media-item.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/media-item.js @@ -4,6 +4,10 @@ import { useRef, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import clsx from 'clsx'; +/** + * + * @param props + */ function MediaItem( props ) { const onClick = event => { const { item, index, imageOnly } = props; @@ -101,7 +105,7 @@ function MediaItem( props ) {
- { __( 'Inserting Image…', 'jetpack' ) } + { __( 'Inserting Image…', 'jetpack-shared-extension-utils' ) }
) } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/placeholder.js b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/placeholder.js similarity index 97% rename from projects/plugins/jetpack/extensions/shared/external-media/media-browser/placeholder.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-browser/placeholder.js index b3e9d20f54c7f..620bb500e813d 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-browser/placeholder.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-browser/placeholder.js @@ -1,5 +1,8 @@ import { memo } from '@wordpress/element'; +/** + * + */ function MediaPlaceholder() { const className = 'jetpack-external-media-browser__media__item jetpack-external-media-browser__media__placeholder'; diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-button/index.js b/projects/js-packages/shared-extension-utils/src/external-media/media-button/index.js similarity index 98% rename from projects/plugins/jetpack/extensions/shared/external-media/media-button/index.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-button/index.js index f796c3b4bbe84..8075d99f074f8 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-button/index.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-button/index.js @@ -24,6 +24,10 @@ const isGeneralPurposeImageGeneratorBetaEnabled = // to-do: remove when Jetpack requires WordPress 6.7. const hasLargeButtons = window?.Jetpack_Editor_Initial_State?.next40pxDefaultSize; +/** + * + * @param props + */ function MediaButton( props ) { const { name } = useBlockEditContext(); const { mediaProps } = props; diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-button/media-ai-button.js b/projects/js-packages/shared-extension-utils/src/external-media/media-button/media-ai-button.js similarity index 87% rename from projects/plugins/jetpack/extensions/shared/external-media/media-button/media-ai-button.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-button/media-ai-button.js index 529b8c2a91275..ab752da3c3be4 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-button/media-ai-button.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-button/media-ai-button.js @@ -2,6 +2,10 @@ import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { SOURCE_JETPACK_AI_GENERAL_PURPOSE_IMAGE_FOR_BLOCK } from '../constants'; +/** + * + * @param props + */ function MediaAiButton( props ) { const { setSelectedSource, hasLargeButtons } = props; @@ -16,7 +20,7 @@ function MediaAiButton( props ) { } } >
- { __( 'Generate with AI', 'jetpack' ) } + { __( 'Generate with AI', 'jetpack-shared-extension-utils' ) }
); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-button/media-menu.js b/projects/js-packages/shared-extension-utils/src/external-media/media-button/media-menu.js similarity index 85% rename from projects/plugins/jetpack/extensions/shared/external-media/media-button/media-menu.js rename to projects/js-packages/shared-extension-utils/src/external-media/media-button/media-menu.js index d70335c85dd8b..ca2f86718ca8d 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-button/media-menu.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-button/media-menu.js @@ -3,6 +3,10 @@ import { __ } from '@wordpress/i18n'; import { Icon, media } from '@wordpress/icons'; import MediaSources from './media-sources'; +/** + * + * @param props + */ function MediaButtonMenu( props ) { const { mediaProps, open, setSelectedSource, isFeatured, isReplace, hasImage, hasLargeButtons } = props; @@ -18,18 +22,18 @@ function MediaButtonMenu( props ) { ); } - let label = __( 'Select Image', 'jetpack' ); + let label = __( 'Select Image', 'jetpack-shared-extension-utils' ); if ( mediaProps.multiple ) { - label = __( 'Select Images', 'jetpack' ); + label = __( 'Select Images', 'jetpack-shared-extension-utils' ); } if ( mediaProps.allowedTypes.length > 1 ) { - label = __( 'Select Media', 'jetpack' ); + label = __( 'Select Media', 'jetpack-shared-extension-utils' ); } if ( isFeatured ) { - label = __( 'Replace Image', 'jetpack' ); + label = __( 'Replace Image', 'jetpack-shared-extension-utils' ); } return ( @@ -71,7 +75,7 @@ function MediaButtonMenu( props ) { open(); } } > - { __( 'Media Library', 'jetpack' ) } + { __( 'Media Library', 'jetpack-shared-extension-utils' ) } {}, diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-service/index.ts b/projects/js-packages/shared-extension-utils/src/external-media/media-service/index.ts similarity index 95% rename from projects/plugins/jetpack/extensions/shared/external-media/media-service/index.ts rename to projects/js-packages/shared-extension-utils/src/external-media/media-service/index.ts index 8f7bbc9261397..26fc0edfc4d39 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/media-service/index.ts +++ b/projects/js-packages/shared-extension-utils/src/external-media/media-service/index.ts @@ -11,8 +11,11 @@ import { MediaSource } from './types'; // Pexels constants const PEXELS_ID = 'pexels'; -const PEXELS_NAME = __( 'Pexels Free Photos', 'jetpack' ); -const PEXELS_SEARCH_PLACEHOLDER = __( 'Search Pexels Free Photos', 'jetpack' ); +const PEXELS_NAME = __( 'Pexels Free Photos', 'jetpack-shared-extension-utils' ); +const PEXELS_SEARCH_PLACEHOLDER = __( + 'Search Pexels Free Photos', + 'jetpack-shared-extension-utils' +); const DEFAULT_PEXELS_SEARCH: MediaSearch = { per_page: 10, search: 'mountain', @@ -20,8 +23,11 @@ const DEFAULT_PEXELS_SEARCH: MediaSearch = { // Google Photos constants const GOOGLE_PHOTOS_ID = 'google_photos'; -const GOOGLE_PHOTOS_NAME = __( 'Google Photos', 'jetpack' ); -const GOOGLE_PHOTOS_SEARCH_PLACEHOLDER = __( 'Search Google Photos', 'jetpack' ); +const GOOGLE_PHOTOS_NAME = __( 'Google Photos', 'jetpack-shared-extension-utils' ); +const GOOGLE_PHOTOS_SEARCH_PLACEHOLDER = __( + 'Search Google Photos', + 'jetpack-shared-extension-utils' +); const DEFAULT_GOOGLE_PHOTOS_SEARCH: MediaSearch = { per_page: 25, search: '', diff --git a/projects/plugins/jetpack/extensions/shared/external-media/media-service/types.ts b/projects/js-packages/shared-extension-utils/src/external-media/media-service/types.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/media-service/types.ts rename to projects/js-packages/shared-extension-utils/src/external-media/media-service/types.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/api.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/api.js similarity index 89% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/api.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/api.js index abce2e08d38f5..949a292a94568 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/api.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/api.js @@ -1,5 +1,5 @@ -import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; import { addQueryArgs } from '@wordpress/url'; +import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; const ENDPOINTS = { list: '/wpcom/v2/external-media/list/', @@ -9,6 +9,12 @@ const ENDPOINTS = { connection: '/wpcom/v2/external-media/connection/', }; +/** + * + * @param command + * @param source + * @param args + */ export function getApiUrl( command, source, args = {} ) { if ( ENDPOINTS[ command ] ) { return addQueryArgs( ENDPOINTS[ command ] + source, args ); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-instructions.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-instructions.js similarity index 56% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-instructions.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-instructions.js index 307c22a96efab..103dd07eb2717 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-instructions.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-instructions.js @@ -2,16 +2,29 @@ import { Fragment, memo } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { GooglePhotosLogo } from '../../../icons'; +/** + * + */ function AuthInstructions() { return ( -

{ __( 'To get started, connect your site to your Google Photos library.', 'jetpack' ) }

-

{ __( 'You can remove the connection in either of these places:', 'jetpack' ) }

+

+ { __( + 'To get started, connect your site to your Google Photos library.', + 'jetpack-shared-extension-utils' + ) } +

+

+ { __( + 'You can remove the connection in either of these places:', + 'jetpack-shared-extension-utils' + ) } +

diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-progress.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-progress.js similarity index 60% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-progress.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-progress.js index 33d74de0a9507..e8c672cec1d8e 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/auth-progress.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/auth-progress.js @@ -1,8 +1,11 @@ import { memo } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +/** + * + */ function AuthProgress() { - return

{ __( 'Awaiting authorization', 'jetpack' ) }

; + return

{ __( 'Awaiting authorization', 'jetpack-shared-extension-utils' ) }

; } export default memo( AuthProgress ); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/breadcrumbs.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/breadcrumbs.js similarity index 76% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/breadcrumbs.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/breadcrumbs.js index 71649500f1a41..a6f9c4e927917 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/breadcrumbs.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/breadcrumbs.js @@ -3,11 +3,17 @@ import { Fragment, memo } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { PATH_ROOT } from '../../constants'; +/** + * + * @param root0 + * @param root0.path + * @param root0.setPath + */ function Breadcrumbs( { path, setPath } ) { return ( →   { path.name } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-option.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-option.js similarity index 72% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-option.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-option.js index fe7d499c94d34..831fd9983e06b 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-option.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-option.js @@ -12,10 +12,16 @@ import { CURRENT_YEAR, } from '../../constants'; +/** + * + * @param root0 + * @param root0.value + * @param root0.updateFilter + */ function CategoryOption( { value, updateFilter } ) { return ( updateFilter( { range } ) } @@ -42,7 +54,7 @@ function DateOption( { value, updateFilter } ) { { selectedRange === DATE_RANGE_CUSTOM && ( - { __( 'Apply', 'jetpack' ) } + { __( 'Apply', 'jetpack-shared-extension-utils' ) } ) } @@ -70,20 +82,29 @@ function DateOption( { value, updateFilter } ) { ); } +/** + * + */ function FavoriteOption() { - return { __( 'Favorites', 'jetpack' ) }; + return { __( 'Favorites', 'jetpack-shared-extension-utils' ) }; } +/** + * + * @param root0 + * @param root0.value + * @param root0.updateFilter + */ function MediaTypeOption( { value, updateFilter } ) { const options = [ - { label: __( 'All', 'jetpack' ), value: '' }, - { label: __( 'Images', 'jetpack' ), value: 'photo' }, - { label: __( 'Videos', 'jetpack' ), value: 'video' }, + { label: __( 'All', 'jetpack-shared-extension-utils' ), value: '' }, + { label: __( 'Images', 'jetpack-shared-extension-utils' ), value: 'photo' }, + { label: __( 'Videos', 'jetpack-shared-extension-utils' ), value: 'video' }, ]; return ( ; @@ -111,6 +138,13 @@ function getFilterOption( optionName, optionValue, updateFilter ) { return null; } +/** + * + * @param root0 + * @param root0.children + * @param root0.removeFilter + * @param root0.isRemovable + */ function FilterOption( { children, removeFilter, isRemovable = false } ) { return (
@@ -118,13 +152,19 @@ function FilterOption( { children, removeFilter, isRemovable = false } ) { { !! isRemovable && ( ) }
); } +/** + * + * @param existing + * @param key + * @param value + */ function getUpdatedFilters( existing, key, value ) { const copy = { ...existing, @@ -141,6 +181,13 @@ function getUpdatedFilters( existing, key, value ) { return copy; } +/** + * + * @param root0 + * @param root0.filters + * @param root0.setFilters + * @param root0.canChangeMedia + */ function GoogleFilterOption( { filters, setFilters, canChangeMedia } ) { const options = Object.keys( filters ) .filter( item => canChangeMedia || item !== 'mediaType' ) diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-request.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-request.js similarity index 98% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-request.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-request.js index f2daae9d3f0f4..89228412ee447 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-request.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-request.js @@ -9,6 +9,10 @@ import { const TODAY = moment(); +/** + * + * @param filters + */ export default function getFilterRequest( filters ) { const { mediaType, category, favorite, date } = filters; const query = []; diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-view.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-view.js similarity index 71% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-view.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-view.js index d69d2bc2103c8..c8f958834870c 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/filter-view.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/filter-view.js @@ -3,16 +3,25 @@ import { Fragment, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; const FILTERS = [ - { label: __( 'Category', 'jetpack' ), value: 'category' }, - { label: __( 'Date', 'jetpack' ), value: 'date' }, - { label: __( 'Favorites', 'jetpack' ), value: 'favorite' }, - { label: __( 'Media Type', 'jetpack' ), value: 'mediaType' }, + { label: __( 'Category', 'jetpack-shared-extension-utils' ), value: 'category' }, + { label: __( 'Date', 'jetpack-shared-extension-utils' ), value: 'date' }, + { label: __( 'Favorites', 'jetpack-shared-extension-utils' ), value: 'favorite' }, + { label: __( 'Media Type', 'jetpack-shared-extension-utils' ), value: 'mediaType' }, ]; +/** + * + * @param filters + */ function getFilterOptions( filters ) { return FILTERS.filter( item => filters[ item.value ] === undefined ); } +/** + * + * @param filters + * @param canUseMedia + */ function removeMediaType( filters, canUseMedia ) { if ( canUseMedia ) { return filters; @@ -21,6 +30,10 @@ function removeMediaType( filters, canUseMedia ) { return filters.filter( item => item.value !== 'mediaType' ); } +/** + * + * @param filters + */ function getFirstFilter( filters ) { const filtered = getFilterOptions( filters ); @@ -31,6 +44,11 @@ function getFirstFilter( filters ) { return ''; } +/** + * + * @param existing + * @param newFilter + */ function addFilter( existing, newFilter ) { return { ...existing, @@ -38,6 +56,10 @@ function addFilter( existing, newFilter ) { }; } +/** + * + * @param props + */ function GoogleFilterView( props ) { const [ currentFilter, setCurrentFilter ] = useState( getFirstFilter( [] ) ); const { isLoading, isCopying, filters, canChangeMedia } = props; @@ -56,7 +78,7 @@ function GoogleFilterView( props ) { return ( ); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-account.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-account.js similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-account.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-account.js diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth-upgrade.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth-upgrade.js similarity index 89% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth-upgrade.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth-upgrade.js index 109321f9f7962..1d0d3184df8eb 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth-upgrade.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth-upgrade.js @@ -2,6 +2,10 @@ import { __ } from '@wordpress/i18n'; import { GooglePhotosLogo } from '../../../icons'; import GooglePhotosDisconnect from './google-photos-disconnect'; +/** + * + * @param props + */ export default function GooglePhotosAuthUpgrade( props ) { const { setAuthenticated } = props; @@ -12,7 +16,7 @@ export default function GooglePhotosAuthUpgrade( props ) {

{ __( "We've updated our Google Photos service. You will need to disconnect and reconnect to continue accessing your photos.", - 'jetpack' + 'jetpack-shared-extension-utils' ) }

diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth.js similarity index 93% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth.js index a6cc6b8e49647..a001c12a8fe45 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-auth.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-auth.js @@ -8,6 +8,10 @@ import { getApiUrl } from '../api'; import AuthInstructions from './auth-instructions'; import AuthProgress from './auth-progress'; +/** + * + * @param props + */ function GooglePhotosAuth( props ) { const { setAuthenticated } = props; const [ isAuthing, setIsAuthing ] = useState( false ); @@ -41,7 +45,7 @@ function GooglePhotosAuth( props ) { { isAuthing ? : }
); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-disconnect.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-disconnect.js similarity index 92% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-disconnect.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-disconnect.js index 6b42c5accf29f..a3b3fd5db9f80 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-disconnect.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-disconnect.js @@ -27,7 +27,7 @@ const GooglePhotosDisconnect = ( { setAuthenticated, buttonVariant = 'secondary' disabled={ isDisconnecting } isBusy={ isDisconnecting } > - { __( 'Disconnect from Google Photos', 'jetpack' ) } + { __( 'Disconnect from Google Photos', 'jetpack-shared-extension-utils' ) } ); }; diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-media.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-media.js similarity index 96% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-media.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-media.js index 1748986eeccce..900e6a90c164f 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-media.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-media.js @@ -18,6 +18,10 @@ import GooglePhotosAccount from './google-photos-account'; const isImageOnly = allowed => allowed && allowed.length === 1 && allowed[ 0 ] === 'image'; +/** + * + * @param props + */ function GooglePhotosMedia( props ) { const { account, @@ -117,7 +121,7 @@ function GooglePhotosMedia( props ) { { - { __( 'Change selection', 'jetpack' ) } + { __( 'Change selection', 'jetpack-shared-extension-utils' ) }
) } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-picker-button.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-picker-button.js similarity index 75% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-picker-button.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-picker-button.js index 7d17ba066606a..5c3a335594f41 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/google-photos-picker-button.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/google-photos-picker-button.js @@ -5,6 +5,10 @@ import { useEffect } from 'react'; import mediaImage from '../../../../../images/media.svg'; import GooglePhotosAccount from './google-photos-account'; +/** + * + * @param props + */ export default function GooglePhotosPickerButton( props ) { const { pickerSession, fetchPickerSession, setAuthenticated, account } = props; const isButtonBusy = ! pickerSession; @@ -22,10 +26,19 @@ export default function GooglePhotosPickerButton( props ) { return (
- { + { -

{ __( 'Google Photos', 'jetpack' ) }

-

{ __( 'Select photos directly from your Google Photos library.', 'jetpack' ) }

+

{ __( 'Google Photos', 'jetpack-shared-extension-utils' ) }

+

+ { __( + 'Select photos directly from your Google Photos library.', + 'jetpack-shared-extension-utils' + ) } +

diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/index.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/index.js similarity index 99% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/index.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/index.js index 9438f568b24ff..156fc857fca8e 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/google-photos/index.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/google-photos/index.js @@ -9,6 +9,10 @@ import GooglePhotosAuthUpgrade from './google-photos-auth-upgrade'; import GooglePhotosMedia from './google-photos-media'; import GooglePhotosPickerButton from './google-photos-picker-button'; +/** + * + * @param props + */ function GooglePhotos( props ) { const { isAuthenticated, diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/index.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/index.js similarity index 88% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/index.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/index.js index f150a47ed609c..c5c9a4fa87bda 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/index.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/index.js @@ -22,7 +22,7 @@ import PexelsMedia from './pexels'; export const internalMediaSources = [ { id: SOURCE_JETPACK_APP_MEDIA, - label: __( 'Your Phone', 'jetpack' ), + label: __( 'Your Phone', 'jetpack-shared-extension-utils' ), icon: , keyword: 'jetpack mobile app', }, @@ -34,7 +34,7 @@ export const internalMediaSources = [ export const featuredImageExclusiveMediaSources = [ { id: SOURCE_JETPACK_AI_FEATURED_IMAGE, - label: __( 'Generate with AI', 'jetpack' ), + label: __( 'Generate with AI', 'jetpack-shared-extension-utils' ), icon: aiAssistantIcon, keyword: 'jetpack ai', }, @@ -46,7 +46,7 @@ export const featuredImageExclusiveMediaSources = [ export const generalPurposeImageExclusiveMediaSources = [ { id: SOURCE_JETPACK_AI_GENERAL_PURPOSE_IMAGE_FOR_MEDIA_SOURCE, - label: __( 'Generate with AI', 'jetpack' ), + label: __( 'Generate with AI', 'jetpack-shared-extension-utils' ), icon: aiAssistantIcon, keyword: 'jetpack ai', }, @@ -55,19 +55,19 @@ export const generalPurposeImageExclusiveMediaSources = [ export const externalMediaSources = [ { id: SOURCE_GOOGLE_PHOTOS, - label: __( 'Google Photos', 'jetpack' ), + label: __( 'Google Photos', 'jetpack-shared-extension-utils' ), icon: , keyword: 'google photos', }, { id: SOURCE_PEXELS, - label: __( 'Pexels Free Photos', 'jetpack' ), + label: __( 'Pexels Free Photos', 'jetpack-shared-extension-utils' ), icon: , keyword: 'pexels', }, { id: SOURCE_OPENVERSE, - label: __( 'Openverse', 'jetpack' ), + label: __( 'Openverse', 'jetpack-shared-extension-utils' ), icon: , keyword: 'openverse', }, @@ -75,6 +75,10 @@ export const externalMediaSources = [ export const mediaSources = externalMediaSources.concat( internalMediaSources ); +/** + * + * @param props + */ export function canDisplayPlaceholder( props ) { const { disableMediaButtons, dropZoneUIOnly } = props; @@ -100,6 +104,10 @@ export function canDisplayPlaceholder( props ) { return true; } +/** + * + * @param type + */ export function getExternalLibrary( type ) { if ( type === SOURCE_PEXELS ) { return PexelsMedia; @@ -119,6 +127,10 @@ export function getExternalLibrary( type ) { return null; } +/** + * + * @param type + */ export function getExternalSource( type ) { return mediaSources.find( item => item.id === type ); } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-featured-image.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-featured-image.js similarity index 57% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-featured-image.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-featured-image.js index cebcc49e1d33d..046362d0dc186 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-featured-image.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-featured-image.js @@ -1,8 +1,10 @@ -import { - FeaturedImage, - PLACEMENT_MEDIA_SOURCE_DROPDOWN, -} from '../../../plugins/ai-assistant-plugin/components/ai-image'; +import { FeaturedImage, PLACEMENT_MEDIA_SOURCE_DROPDOWN } from '../../components/ai-image'; +/** + * + * @param root0 + * @param root0.onClose + */ function JetpackAIFeaturedImage( { onClose = () => {} } ) { return ; } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-block.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-block.js similarity index 63% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-block.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-block.js index 1dcdfc1b76743..6071311352078 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-block.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-block.js @@ -1,8 +1,12 @@ -import { - GeneralPurposeImage, - PLACEMENT_BLOCK_PLACEHOLDER_BUTTON, -} from '../../../plugins/ai-assistant-plugin/components/ai-image'; +import { GeneralPurposeImage, PLACEMENT_BLOCK_PLACEHOLDER_BUTTON } from '../../components/ai-image'; +/** + * + * @param root0 + * @param root0.onClose + * @param root0.onSelect + * @param root0.multiple + */ function JetpackAIGeneralPurposeImageForBlock( { onClose = () => {}, onSelect, diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js similarity index 64% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js index 9cff6275e8518..ee79b29ec3863 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-ai-general-purpose-image-for-media-source.js @@ -1,8 +1,12 @@ -import { - GeneralPurposeImage, - PLACEMENT_MEDIA_SOURCE_DROPDOWN, -} from '../../../plugins/ai-assistant-plugin/components/ai-image'; +import { GeneralPurposeImage, PLACEMENT_MEDIA_SOURCE_DROPDOWN } from '../../components/ai-image'; +/** + * + * @param root0 + * @param root0.onClose + * @param root0.onSelect + * @param root0.multiple + */ function JetpackAIGeneralPurposeImageForMediaSource( { onClose = () => {}, onSelect, diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-app-media.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-app-media.js similarity index 92% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-app-media.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-app-media.js index 82030b4127e91..51dc24ce47a1a 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/jetpack-app-media.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/jetpack-app-media.js @@ -8,6 +8,10 @@ import MediaBrowser from '../media-browser'; import { MediaSource } from '../media-service/types'; import withMedia from './with-media'; +/** + * + * @param props + */ function JetpackAppMedia( props ) { const { media, insertMedia, isCopying, multiple, getMedia } = props; @@ -53,28 +57,33 @@ function JetpackAppMedia( props ) { return selectedImages ? sprintf( /* translators: %1$d is the number of images that were selected. */ - _n( 'Add %1$d image', 'Add %1$d images', selectedImages, 'jetpack' ), + _n( + 'Add %1$d image', + 'Add %1$d images', + selectedImages, + 'jetpack-shared-extension-utils' + ), selectedImages ) - : __( 'Add images', 'jetpack' ); + : __( 'Add images', 'jetpack-shared-extension-utils' ); }; return (

- { hasImageUploaded && __( 'Select images to be added', 'jetpack' ) } - { ! hasImageUploaded && __( 'Upload from your phone', 'jetpack' ) } + { hasImageUploaded && __( 'Select images to be added', 'jetpack-shared-extension-utils' ) } + { ! hasImageUploaded && __( 'Upload from your phone', 'jetpack-shared-extension-utils' ) }

{ hasImageUploaded && __( 'Select the images below to add, or continue adding more from your device.', - 'jetpack' + 'jetpack-shared-extension-utils' ) } { ! hasImageUploaded && __( 'Scan the QR code with your iPhone or Android camera to upload from your photos.', - 'jetpack' + 'jetpack-shared-extension-utils' ) }

{ ! hasImageUploaded && ( diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/openverse.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/openverse.js similarity index 95% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/openverse.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/openverse.js index abf2a66aa0a38..9d3179f9d079e 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/openverse.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/openverse.js @@ -8,6 +8,10 @@ import { MediaSource } from '../media-service/types'; import { getApiUrl } from './api'; import withMedia from './with-media'; +/** + * + * @param props + */ function OpenverseMedia( props ) { const { media, isCopying, isLoading, pageHandle, multiple, copyMedia, getMedia } = props; @@ -76,7 +80,7 @@ function OpenverseMedia( props ) { onSubmit={ onSearch } > - { __( 'Search', 'jetpack' ) } + { __( 'Search', 'jetpack-shared-extension-utils' ) } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/pexels.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/pexels.js similarity index 95% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/pexels.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/pexels.js index cdd97bc355e8d..4131d885ac3d1 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/pexels.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/pexels.js @@ -8,6 +8,10 @@ import { MediaSource } from '../media-service/types'; import { getApiUrl } from './api'; import withMedia from './with-media'; +/** + * + * @param props + */ function PexelsMedia( props ) { const { media, isCopying, isLoading, pageHandle, multiple, copyMedia, getMedia } = props; @@ -78,7 +82,7 @@ function PexelsMedia( props ) { onSubmit={ onSearch } > - { __( 'Search', 'jetpack' ) } + { __( 'Search', 'jetpack-shared-extension-utils' ) } diff --git a/projects/plugins/jetpack/extensions/shared/external-media/sources/with-media.js b/projects/js-packages/shared-extension-utils/src/external-media/sources/with-media.js similarity index 97% rename from projects/plugins/jetpack/extensions/shared/external-media/sources/with-media.js rename to projects/js-packages/shared-extension-utils/src/external-media/sources/with-media.js index 0d460713f5c7c..08fcdae749000 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/sources/with-media.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/sources/with-media.js @@ -15,6 +15,10 @@ import { } from '../media-service'; import { MediaSource } from '../media-service/types'; +/** + * + * @param mediaSource + */ export default function withMedia( mediaSource = MediaSource.Unknown ) { return createHigherOrderComponent( OriginalComponent => { // Legacy class as it was ported from an older codebase. @@ -338,18 +342,22 @@ export default function withMedia( mediaSource = MediaSource.Unknown ) { const { allowedTypes, multiple = false, noticeUI, onClose } = this.props; const defaultTitle = - mediaSource !== 'jetpack_app_media' ? __( 'Select media', 'jetpack' ) : ''; + mediaSource !== 'jetpack_app_media' + ? __( 'Select media', 'jetpack-shared-extension-utils' ) + : ''; - const title = isCopying ? __( 'Inserting media', 'jetpack' ) : defaultTitle; + const title = isCopying + ? __( 'Inserting media', 'jetpack-shared-extension-utils' ) + : defaultTitle; const description = isCopying ? __( 'When the media is finished copying and inserting, you will be returned to the editor.', - 'jetpack' + 'jetpack-shared-extension-utils' ) : __( 'Select the media you would like to insert into the editor.', - 'jetpack', + 'jetpack-shared-extension-utils', /* dummy arg to avoid bad minification */ 0 ); diff --git a/projects/plugins/jetpack/extensions/shared/external-media/store/actions.ts b/projects/js-packages/shared-extension-utils/src/external-media/store/actions.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/store/actions.ts rename to projects/js-packages/shared-extension-utils/src/external-media/store/actions.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/store/index.ts b/projects/js-packages/shared-extension-utils/src/external-media/store/index.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/store/index.ts rename to projects/js-packages/shared-extension-utils/src/external-media/store/index.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/store/reducer.ts b/projects/js-packages/shared-extension-utils/src/external-media/store/reducer.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/store/reducer.ts rename to projects/js-packages/shared-extension-utils/src/external-media/store/reducer.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/store/selectors.ts b/projects/js-packages/shared-extension-utils/src/external-media/store/selectors.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/store/selectors.ts rename to projects/js-packages/shared-extension-utils/src/external-media/store/selectors.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/store/types.ts b/projects/js-packages/shared-extension-utils/src/external-media/store/types.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/external-media/store/types.ts rename to projects/js-packages/shared-extension-utils/src/external-media/store/types.ts diff --git a/projects/plugins/jetpack/extensions/shared/external-media/test/external-media-service-test.js b/projects/js-packages/shared-extension-utils/src/external-media/test/external-media-service-test.js similarity index 98% rename from projects/plugins/jetpack/extensions/shared/external-media/test/external-media-service-test.js rename to projects/js-packages/shared-extension-utils/src/external-media/test/external-media-service-test.js index 3d0a2c6e5c0eb..cc07c703c2d3f 100644 --- a/projects/plugins/jetpack/extensions/shared/external-media/test/external-media-service-test.js +++ b/projects/js-packages/shared-extension-utils/src/external-media/test/external-media-service-test.js @@ -8,7 +8,7 @@ import apiFetch from '@wordpress/api-fetch'; import { select, dispatch } from '@wordpress/data'; import { waitFor } from '../../wait-for'; -import { addPexelsToMediaInserter, addGooglePhotosToMediaInserter } from '../media-service/index'; +import { addPexelsToMediaInserter, addGooglePhotosToMediaInserter } from '../media-service'; jest.mock( '../../wait-for' ); jest.mock( '@wordpress/api-fetch' ); diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md b/projects/js-packages/shared-extension-utils/src/hooks/use-ai-feature/Readme.md similarity index 100% rename from projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/Readme.md rename to projects/js-packages/shared-extension-utils/src/hooks/use-ai-feature/Readme.md diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts b/projects/js-packages/shared-extension-utils/src/hooks/use-ai-feature/index.ts similarity index 98% rename from projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts rename to projects/js-packages/shared-extension-utils/src/hooks/use-ai-feature/index.ts index db84bbd4577c7..bc9014822aa7e 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-ai-feature/index.ts +++ b/projects/js-packages/shared-extension-utils/src/hooks/use-ai-feature/index.ts @@ -2,9 +2,12 @@ * External dependencies */ import { useDispatch, useSelect } from '@wordpress/data'; -import { PLAN_TYPE_FREE, usePlanType as getPlanType } from '../../../../shared/use-plan-type'; +import { PLAN_TYPE_FREE, usePlanType as getPlanType } from '../../use-plan-type'; import type { WordPressPlansSelectors } from 'extensions/store/wordpress-com'; +/** + * + */ export default function useAiFeature() { const { data, loading, requestsLimit, requestsCount } = useSelect( select => { const { getAiAssistantFeature, getIsRequestingAiAssistantFeature } = select( diff --git a/projects/plugins/jetpack/extensions/shared/use-plan-type/index.ts b/projects/js-packages/shared-extension-utils/src/hooks/use-plan-type/index.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/use-plan-type/index.ts rename to projects/js-packages/shared-extension-utils/src/hooks/use-plan-type/index.ts diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/hooks/use-post-content.ts b/projects/js-packages/shared-extension-utils/src/hooks/use-post-content.ts similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/hooks/use-post-content.ts rename to projects/js-packages/shared-extension-utils/src/hooks/use-post-content.ts diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/hooks/use-save-to-media-library.ts b/projects/js-packages/shared-extension-utils/src/hooks/use-save-to-media-library.ts similarity index 96% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/hooks/use-save-to-media-library.ts rename to projects/js-packages/shared-extension-utils/src/hooks/use-save-to-media-library.ts index 89bfc570c369b..6c29fcab900b5 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/hooks/use-save-to-media-library.ts +++ b/projects/js-packages/shared-extension-utils/src/hooks/use-save-to-media-library.ts @@ -8,10 +8,13 @@ import debugFactory from 'debug'; /** * Types */ -import type { BlockEditorStore } from '../../../blocks/ai-assistant/types'; +import type { BlockEditorStore } from '../../blocks/ai-assistant/types'; const debug = debugFactory( 'jetpack-ai-assistant-plugin:save-to-media-library' ); +/** + * + */ export default function useSaveToMediaLibrary() { const [ isLoading, setIsLoading ] = useState( false ); const { getSettings } = useSelect( diff --git a/projects/plugins/jetpack/extensions/shared/icons.js b/projects/js-packages/shared-extension-utils/src/icons.js similarity index 100% rename from projects/plugins/jetpack/extensions/shared/icons.js rename to projects/js-packages/shared-extension-utils/src/icons.js diff --git a/projects/plugins/jetpack/extensions/shared/use-ref-interval.ts b/projects/js-packages/shared-extension-utils/src/use-ref-interval.ts similarity index 100% rename from projects/plugins/jetpack/extensions/shared/use-ref-interval.ts rename to projects/js-packages/shared-extension-utils/src/use-ref-interval.ts diff --git a/projects/plugins/jetpack/extensions/shared/wait-for.js b/projects/js-packages/shared-extension-utils/src/wait-for.js similarity index 100% rename from projects/plugins/jetpack/extensions/shared/wait-for.js rename to projects/js-packages/shared-extension-utils/src/wait-for.js diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx index 66878a350339b..a682b929d2593 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/index.tsx @@ -18,20 +18,20 @@ import useAiFeature from '../../../../blocks/ai-assistant/hooks/use-ai-feature'; import useAiProductPage from '../../../../blocks/ai-assistant/hooks/use-ai-product-page'; import { getFeatureAvailability } from '../../../../blocks/ai-assistant/lib/utils/get-feature-availability'; import { isBetaExtension } from '../../../../editor'; +import { FeaturedImage } from '../../../../shared/components/ai-image'; +import { + PLACEMENT_DOCUMENT_SETTINGS, + PLACEMENT_JETPACK_SIDEBAR, + PLACEMENT_PRE_PUBLISH, +} from '../../../../shared/constants'; import JetpackPluginSidebar from '../../../../shared/jetpack-plugin-sidebar'; import { PLAN_TYPE_FREE, PLAN_TYPE_UNLIMITED, usePlanType } from '../../../../shared/use-plan-type'; -import { FeaturedImage } from '../ai-image'; import { Breve, registerBreveHighlights, Highlight } from '../breve'; import { getBreveAvailability, canWriteBriefBeEnabled } from '../breve/utils/get-availability'; import Feedback from '../feedback'; import SeoAssistant from '../seo-assistant'; import TitleOptimization from '../title-optimization'; import UsagePanel from '../usage-panel'; -import { - PLACEMENT_DOCUMENT_SETTINGS, - PLACEMENT_JETPACK_SIDEBAR, - PLACEMENT_PRE_PUBLISH, -} from './constants'; import Upgrade from './upgrade'; import './style.scss'; /** diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/types.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/types.ts index 3647c19c48977..b158f6aff68e7 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/types.ts +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/types.ts @@ -1,4 +1,7 @@ -import { PLACEMENT_DOCUMENT_SETTINGS, PLACEMENT_JETPACK_SIDEBAR } from './constants'; +import { + PLACEMENT_DOCUMENT_SETTINGS, + PLACEMENT_JETPACK_SIDEBAR, +} from '../../../../shared/constants'; export type JetpackSettingsContentProps = { placement: typeof PLACEMENT_JETPACK_SIDEBAR | typeof PLACEMENT_DOCUMENT_SETTINGS; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/feedback/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/feedback/index.tsx index a904ae4fa4297..657bbb4326521 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/feedback/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/feedback/index.tsx @@ -12,7 +12,7 @@ import React from 'react'; /** * Internal dependencies */ -import usePostContent from '../../hooks/use-post-content'; +import usePostContent from '../../../../shared/hooks/use-post-content'; import AiAssistantModal from '../modal'; import './style.scss'; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/title-optimization/index.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/title-optimization/index.tsx index 39f4174238bd2..9dd76c73b9673 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/title-optimization/index.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/title-optimization/index.tsx @@ -19,8 +19,8 @@ import { __ } from '@wordpress/i18n'; */ import QuotaExceededMessage from '../../../../blocks/ai-assistant/components/quota-exceeded-message'; import { getFeatureAvailability } from '../../../../blocks/ai-assistant/lib/utils/get-feature-availability'; +import usePostContent from '../../../../shared/hooks/use-post-content'; import useAutoSaveAndRedirect from '../../../../shared/use-autosave-and-redirect'; -import usePostContent from '../../hooks/use-post-content'; import AiAssistantModal from '../modal'; import TitleOptimizationKeywords from './title-optimization-keywords'; import TitleOptimizationOptions from './title-optimization-options'; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/types.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/types.ts index 82195674a8c2c..ee238ed070946 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/types.ts +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/usage-panel/types.ts @@ -1,8 +1,8 @@ -import { PlanType } from '../../../../shared/use-plan-type'; import { PLACEMENT_DOCUMENT_SETTINGS, PLACEMENT_JETPACK_SIDEBAR, -} from '../ai-assistant-plugin-sidebar/constants'; +} from '../../../../shared/constants'; +import { PlanType } from '../../../../shared/use-plan-type'; export const USAGE_PANEL_PLACEMENT_BLOCK_SETTINGS_SIDEBAR = 'block_settings_sidebar' as const; diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/constants.ts b/projects/plugins/jetpack/extensions/shared/constants.ts similarity index 100% rename from projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-assistant-plugin-sidebar/constants.ts rename to projects/plugins/jetpack/extensions/shared/constants.ts