import { ExtendifyCodeConnector } from '@auto-launch/components/ExtendifyCodeConnector'; import { Launch } from '@auto-launch/components/Launch'; import { LaunchUpdate } from '@auto-launch/components/LaunchUpdate'; import { Logo } from '@auto-launch/components/Logo'; import { MigrateChoice } from '@auto-launch/components/MigrateChoice'; import { MovingGradient } from '@auto-launch/components/MovingGradients'; import { NeedsTheme } from '@auto-launch/components/NeedsTheme'; import { RestartLaunchModal } from '@auto-launch/components/RestartLaunchModal'; import { ViewportPulse } from '@auto-launch/components/ViewportPulse'; import { getAbTest } from '@auto-launch/functions/getAbTest'; import { preLaunchFunctions } from '@auto-launch/functions/setup'; import { updateOption } from '@auto-launch/functions/wp'; import { useLaunchDataStore } from '@auto-launch/state/launch-data'; import { digest } from '@shared/api/digest'; import { registerCoreBlocks } from '@wordpress/block-library'; import { getBlockTypes } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { useEffect, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { chevronLeft, Icon } from '@wordpress/icons'; import classNames from 'classnames'; import { AnimatePresence, motion } from 'framer-motion'; import { checkIn, reportRestApiStatus } from './functions/insights'; export const LaunchPage = () => { const theme = useSelect((select) => select('core').getCurrentTheme()); // Checking `theme` here makes sure the data is populated const needsTheme = theme && theme?.textdomain !== 'extendable'; const oldPages = window.extLaunchData.resetSiteInformation.pagesIds ?? []; const needsToReset = oldPages.length > 0; const pluginUpdateNeeded = Boolean(window.extLaunchData?.pluginUpdateNeeded); const themeUpdateNeeded = Boolean(window.extLaunchData?.themeUpdateNeeded); const pluginUpdateViaRest = Boolean( window.extLaunchData?.pluginUpdateViaRest, ); const launchUpdateNeeded = pluginUpdateNeeded || themeUpdateNeeded; const launchUpdateAttempt = window.extLaunchData?.launchUpdateAttempt ?? 0; const launchUpdateStale = window.extLaunchData?.launchUpdateStale ?? {}; const launchUpdateGaveUp = Object.keys(launchUpdateStale).length > 0; const { title, descriptionRaw, go, urlParams, designBuild, setData, showExtendifyCodeScreen, } = useLaunchDataStore(); const skipDescription = Boolean(urlParams?.['build-id']) || designBuild || ((title || descriptionRaw) && go); const showConnector = !skipDescription && showExtendifyCodeScreen; const showExitLink = !skipDescription && !window.extLaunchData?.hideAutoLaunchExitLink; const inMigrateVariant = getAbTest('AutoLaunch.MigrateScreen').variant === 'B'; const [choosingMigration, setChoosingMigration] = useState(inMigrateVariant); const showMigrateChoice = !skipDescription && choosingMigration; const containerRef = useRef(null); useEffect(() => { if (launchUpdateNeeded) return; if (launchUpdateGaveUp) { digest({ error: new Error('Launch went ahead without the pending update'), details: { source: 'auto-launch', caller: 'launch-update', stale: launchUpdateStale, }, }); } // translators: Launch is a noun. document.title = __('Launch - AI-Powered Web Creation', 'extendify-local'); updateOption('extendify_launch_loaded', new Date().toISOString()); // We load core blocks so we can parse them if (getBlockTypes().length === 0) registerCoreBlocks(); preLaunchFunctions(); checkIn({ stage: 'launch_page' }); reportRestApiStatus(); }, [launchUpdateNeeded, launchUpdateGaveUp]); if (launchUpdateNeeded) { return (
); } if (needsTheme) { return (
); } if (needsToReset) { return (
); } return ( setData('showExtendifyCodeScreen', false)} /> ) : showExitLink ? ( ) : null } >
{showConnector && ( setData('go', true)} /> )} {!showConnector && showMigrateChoice && ( setChoosingMigration(false)} /> )} {!showConnector && !showMigrateChoice && ( )}
); }; const Wrapper = ({ children, footer }) => { const { pulse } = useLaunchDataStore(); return (
{children}
{footer &&
{footer}
}
{pulse ? : null}
); }; const ExitLink = () => { return ( checkIn({ stage: 'exit_to_wp_admin' })} > {__('WP Admin Dashboard', 'extendify-local')} ); }; const BackLink = ({ onClick }) => { return ( ); }; const TheTitle = ({ hide, migrate }) => { const useOldHeader = getAbTest('AutoLaunch.HeaderParagraphOld').variant === 'B'; if (hide) return null; const headingClass = 'text-xl md:text-2xl text-pretty text-banner-text font-semibold p-0 m-0 text-center'; const transition = { animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.4 }, }; if (migrate) { return ( {__('How would you like to start your website?', 'extendify-local')} ); } if (useOldHeader) { return (

{__('Tell Us About Your Website', 'extendify-local')}

{__( "Share your vision, and we'll craft a website that's perfectly tailored to your needs, ready to launch in no time.", 'extendify-local', )}

); } return ( {__('Describe the website you want to build', 'extendify-local')} ); };