@automattic/jetpack-ai-client 0.18.0 → 0.19.0
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 +12 -0
- package/build/hooks/use-image-generator/index.js +0 -1
- package/build/logo-generator/components/prompt.js +1 -1
- package/build/logo-generator/hooks/use-checkout.js +17 -8
- package/package.json +13 -13
- package/src/hooks/use-image-generator/index.ts +0 -1
- package/src/logo-generator/components/prompt.tsx +1 -1
- package/src/logo-generator/hooks/use-checkout.ts +23 -11
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.19.0] - 2024-09-23
|
|
9
|
+
### Changed
|
|
10
|
+
- AI Client: Don't send a default style to jetpack-ai-image endpoint, default is handled in backend and we need to not send it until we're ready for it to be a user option. [#39494]
|
|
11
|
+
- Jetpack AI: Point upgrade links and buttons to checkout instead of product interstitial. [#39469]
|
|
12
|
+
- Logo generator: Get selection from the prompt's document rather than the global `window`. [#39364]
|
|
13
|
+
|
|
14
|
+
## [0.18.1] - 2024-09-10
|
|
15
|
+
### Changed
|
|
16
|
+
- Updated package dependencies. [#39302]
|
|
17
|
+
|
|
8
18
|
## [0.18.0] - 2024-09-09
|
|
9
19
|
### Added
|
|
10
20
|
- AI Client: add placeholders for Logo Generator modal commponents [#39244]
|
|
@@ -405,6 +415,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
405
415
|
- Updated package dependencies. [#31659]
|
|
406
416
|
- Updated package dependencies. [#31785]
|
|
407
417
|
|
|
418
|
+
[0.19.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.18.1...v0.19.0
|
|
419
|
+
[0.18.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.18.0...v0.18.1
|
|
408
420
|
[0.18.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.17.0...v0.18.0
|
|
409
421
|
[0.17.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.16.4...v0.17.0
|
|
410
422
|
[0.16.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.16.3...v0.16.4
|
|
@@ -74,7 +74,7 @@ export const Prompt = ({ initialPrompt = '' }) => {
|
|
|
74
74
|
};
|
|
75
75
|
const onPromptPaste = (event) => {
|
|
76
76
|
event.preventDefault();
|
|
77
|
-
const selection =
|
|
77
|
+
const selection = event.currentTarget.ownerDocument.getSelection();
|
|
78
78
|
if (!selection || !selection.rangeCount) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
@@ -17,18 +17,27 @@ export const useCheckout = () => {
|
|
|
17
17
|
tierPlansEnabled: selectors.getAiAssistantFeature().tierPlansEnabled,
|
|
18
18
|
};
|
|
19
19
|
}, []);
|
|
20
|
+
const isJetpackSite = !isAtomicSite() && !isSimpleSite();
|
|
21
|
+
const redirectSource = isJetpackSite
|
|
22
|
+
? 'jetpack-ai-upgrade-url-for-jetpack-sites'
|
|
23
|
+
: 'jetpack-ai-yearly-tier-upgrade-nudge';
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
25
|
+
* Determine the post-checkout URL for non-Jetpack sites
|
|
22
26
|
*/
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
wpcomCheckoutUrl.searchParams.set('site', getSiteFragment());
|
|
26
|
-
wpcomCheckoutUrl.searchParams.set('path', tierPlansEnabled ? `jetpack_ai_yearly:-q-${nextTier?.limit}` : 'jetpack_ai_yearly');
|
|
27
|
+
const siteFragment = getSiteFragment();
|
|
28
|
+
const wpcomRedirectToURL = `https://wordpress.com/home/${siteFragment}`;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* Use the Jetpack redirect URL to open the checkout page
|
|
29
31
|
*/
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
+
const checkoutUrl = new URL(`https://jetpack.com/redirect/`);
|
|
33
|
+
checkoutUrl.searchParams.set('source', redirectSource);
|
|
34
|
+
checkoutUrl.searchParams.set('site', siteFragment);
|
|
35
|
+
checkoutUrl.searchParams.set('path', tierPlansEnabled ? `jetpack_ai_yearly:-q-${nextTier?.limit}` : 'jetpack_ai_yearly');
|
|
36
|
+
// For Jetpack sites, the redirect_to parameter is handled by the Jetpack redirect source
|
|
37
|
+
if (!isJetpackSite) {
|
|
38
|
+
checkoutUrl.searchParams.set('query', `redirect_to=${encodeURIComponent(wpcomRedirectToURL)}`);
|
|
39
|
+
}
|
|
40
|
+
const nextTierCheckoutURL = checkoutUrl.toString();
|
|
32
41
|
debug('Next tier checkout URL: ', nextTierCheckoutURL);
|
|
33
42
|
return {
|
|
34
43
|
nextTierCheckoutURL,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
"main": "./build/index.js",
|
|
44
44
|
"types": "./build/index.d.ts",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
47
|
-
"@automattic/jetpack-connection": "^0.35.
|
|
48
|
-
"@automattic/jetpack-shared-extension-utils": "^0.15.
|
|
46
|
+
"@automattic/jetpack-base-styles": "^0.6.32",
|
|
47
|
+
"@automattic/jetpack-connection": "^0.35.8",
|
|
48
|
+
"@automattic/jetpack-shared-extension-utils": "^0.15.10",
|
|
49
49
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
50
50
|
"@types/react": "18.3.3",
|
|
51
51
|
"@types/wordpress__block-editor": "11.5.15",
|
|
52
|
-
"@wordpress/api-fetch": "7.
|
|
53
|
-
"@wordpress/blob": "4.
|
|
54
|
-
"@wordpress/block-editor": "14.
|
|
55
|
-
"@wordpress/components": "28.
|
|
56
|
-
"@wordpress/compose": "7.
|
|
57
|
-
"@wordpress/data": "10.
|
|
58
|
-
"@wordpress/element": "6.
|
|
59
|
-
"@wordpress/i18n": "5.
|
|
60
|
-
"@wordpress/icons": "10.
|
|
52
|
+
"@wordpress/api-fetch": "7.7.0",
|
|
53
|
+
"@wordpress/blob": "4.7.0",
|
|
54
|
+
"@wordpress/block-editor": "14.2.0",
|
|
55
|
+
"@wordpress/components": "28.7.0",
|
|
56
|
+
"@wordpress/compose": "7.7.0",
|
|
57
|
+
"@wordpress/data": "10.7.0",
|
|
58
|
+
"@wordpress/element": "6.7.0",
|
|
59
|
+
"@wordpress/i18n": "5.7.0",
|
|
60
|
+
"@wordpress/icons": "10.7.0",
|
|
61
61
|
"clsx": "2.1.1",
|
|
62
62
|
"debug": "4.3.4",
|
|
63
63
|
"markdown-it": "14.0.0",
|
|
@@ -102,7 +102,7 @@ export const Prompt: React.FC< { initialPrompt?: string } > = ( { initialPrompt
|
|
|
102
102
|
const onPromptPaste = ( event: React.ClipboardEvent< HTMLInputElement > ) => {
|
|
103
103
|
event.preventDefault();
|
|
104
104
|
|
|
105
|
-
const selection =
|
|
105
|
+
const selection = event.currentTarget.ownerDocument.getSelection();
|
|
106
106
|
if ( ! selection || ! selection.rangeCount ) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
@@ -28,25 +28,37 @@ export const useCheckout = () => {
|
|
|
28
28
|
};
|
|
29
29
|
}, [] );
|
|
30
30
|
|
|
31
|
+
const isJetpackSite = ! isAtomicSite() && ! isSimpleSite();
|
|
32
|
+
const redirectSource = isJetpackSite
|
|
33
|
+
? 'jetpack-ai-upgrade-url-for-jetpack-sites'
|
|
34
|
+
: 'jetpack-ai-yearly-tier-upgrade-nudge';
|
|
35
|
+
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
37
|
+
* Determine the post-checkout URL for non-Jetpack sites
|
|
33
38
|
*/
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
wpcomCheckoutUrl.searchParams.set( 'site', getSiteFragment() as string );
|
|
39
|
+
const siteFragment = getSiteFragment() as string;
|
|
40
|
+
const wpcomRedirectToURL = `https://wordpress.com/home/${ siteFragment }`;
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Use the Jetpack redirect URL to open the checkout page
|
|
44
|
+
*/
|
|
45
|
+
const checkoutUrl = new URL( `https://jetpack.com/redirect/` );
|
|
46
|
+
checkoutUrl.searchParams.set( 'source', redirectSource );
|
|
47
|
+
checkoutUrl.searchParams.set( 'site', siteFragment );
|
|
48
|
+
checkoutUrl.searchParams.set(
|
|
39
49
|
'path',
|
|
40
50
|
tierPlansEnabled ? `jetpack_ai_yearly:-q-${ nextTier?.limit }` : 'jetpack_ai_yearly'
|
|
41
51
|
);
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
// For Jetpack sites, the redirect_to parameter is handled by the Jetpack redirect source
|
|
54
|
+
if ( ! isJetpackSite ) {
|
|
55
|
+
checkoutUrl.searchParams.set(
|
|
56
|
+
'query',
|
|
57
|
+
`redirect_to=${ encodeURIComponent( wpcomRedirectToURL ) }`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
47
60
|
|
|
48
|
-
const nextTierCheckoutURL =
|
|
49
|
-
isAtomicSite() || isSimpleSite() ? wpcomCheckoutUrl.toString() : jetpackCheckoutUrl;
|
|
61
|
+
const nextTierCheckoutURL = checkoutUrl.toString();
|
|
50
62
|
|
|
51
63
|
debug( 'Next tier checkout URL: ', nextTierCheckoutURL );
|
|
52
64
|
|