@automattic/jetpack-ai-client 0.33.23 → 0.33.25
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 +13 -0
- package/build/components/ai-image/general-purpose-image.d.ts +1 -0
- package/build/components/ai-image/general-purpose-image.js +9 -3
- package/build/hooks/use-save-to-media-library.d.ts +7 -4
- package/build/hooks/use-save-to-media-library.js +5 -1
- package/build/logo-generator/components/logo-presenter.js +2 -2
- package/package.json +5 -5
- package/src/components/ai-image/general-purpose-image.tsx +10 -3
- package/src/hooks/use-save-to-media-library.ts +13 -6
- package/src/logo-generator/components/logo-presenter.tsx +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.33.25] - 2025-12-15
|
|
9
|
+
### Changed
|
|
10
|
+
- Update package dependencies. [#46244]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fix minification issue with production build. [#46147]
|
|
14
|
+
|
|
15
|
+
## [0.33.24] - 2025-12-08
|
|
16
|
+
### Changed
|
|
17
|
+
- Update dependencies. [#45553]
|
|
18
|
+
|
|
8
19
|
## [0.33.23] - 2025-12-01
|
|
9
20
|
### Changed
|
|
10
21
|
- Update package dependencies. [#46143]
|
|
@@ -751,6 +762,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
751
762
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
752
763
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
753
764
|
|
|
765
|
+
[0.33.25]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.24...v0.33.25
|
|
766
|
+
[0.33.24]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.23...v0.33.24
|
|
754
767
|
[0.33.23]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.22...v0.33.23
|
|
755
768
|
[0.33.22]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.21...v0.33.22
|
|
756
769
|
[0.33.21]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.20...v0.33.21
|
|
@@ -152,8 +152,8 @@ export default function GeneralPurposeImage({ placement, onClose = () => { }, on
|
|
|
152
152
|
model: generalImageActiveModel,
|
|
153
153
|
site_type: siteType,
|
|
154
154
|
});
|
|
155
|
-
const setImage =
|
|
156
|
-
onSetImage?.({ id
|
|
155
|
+
const setImage = ({ id, url, mime }) => {
|
|
156
|
+
onSetImage?.({ id, url, mime });
|
|
157
157
|
handleModalClose();
|
|
158
158
|
};
|
|
159
159
|
// If the image is already in the media library, use it directly, if it failed for some reason
|
|
@@ -162,11 +162,17 @@ export default function GeneralPurposeImage({ placement, onClose = () => { }, on
|
|
|
162
162
|
setImage({
|
|
163
163
|
id: currentImage?.libraryId,
|
|
164
164
|
url: currentImage?.libraryUrl,
|
|
165
|
+
// Default to image/png for cached images (AI generates PNG)
|
|
166
|
+
mime: 'image/png',
|
|
165
167
|
});
|
|
166
168
|
}
|
|
167
169
|
else {
|
|
168
170
|
saveToMediaLibrary(currentImage?.image).then(image => {
|
|
169
|
-
setImage(
|
|
171
|
+
setImage({
|
|
172
|
+
id: image.id,
|
|
173
|
+
url: image.url,
|
|
174
|
+
mime: image.mime,
|
|
175
|
+
});
|
|
170
176
|
});
|
|
171
177
|
}
|
|
172
178
|
}, [
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
type SavedMediaItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
url: string;
|
|
4
|
+
mime?: string;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* Hook to save data to media library
|
|
3
8
|
*
|
|
@@ -5,8 +10,6 @@
|
|
|
5
10
|
*/
|
|
6
11
|
export default function useSaveToMediaLibrary(): {
|
|
7
12
|
isLoading: boolean;
|
|
8
|
-
saveToMediaLibrary: (url: string, name?: string) => Promise<
|
|
9
|
-
id: string;
|
|
10
|
-
url: string;
|
|
11
|
-
}>;
|
|
13
|
+
saveToMediaLibrary: (url: string, name?: string) => Promise<SavedMediaItem>;
|
|
12
14
|
};
|
|
15
|
+
export {};
|
|
@@ -43,7 +43,11 @@ export default function useSaveToMediaLibrary() {
|
|
|
43
43
|
}
|
|
44
44
|
if (image) {
|
|
45
45
|
debug('Image uploaded to media library', image);
|
|
46
|
-
resolve(
|
|
46
|
+
resolve({
|
|
47
|
+
id: image.id,
|
|
48
|
+
url: image.url,
|
|
49
|
+
mime: image.mime,
|
|
50
|
+
});
|
|
47
51
|
}
|
|
48
52
|
setIsLoading(false);
|
|
49
53
|
},
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
|
|
6
6
|
import { Button, Icon } from '@wordpress/components';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { __, _x } from '@wordpress/i18n';
|
|
9
9
|
import debugFactory from 'debug';
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
@@ -52,7 +52,7 @@ const SaveInLibraryButton = ({ siteId }) => {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
const savingLabel =
|
|
55
|
+
const savingLabel = _x('Saving…', 'Logo save button', 'jetpack-ai-client');
|
|
56
56
|
const savedLabel = __('Saved', 'jetpack-ai-client');
|
|
57
57
|
return !saving && !saved ? (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", onClick: handleClick, children: [_jsx(Icon, { icon: _jsx(MediaIcon, {}) }), _jsx("span", { className: "action-text", children: __('Save in Library', 'jetpack-ai-client') })] })) : (_jsxs(Button, { className: "jetpack-ai-logo-generator-modal-presenter__action", children: [_jsx(Icon, { icon: saving ? _jsx(MediaIcon, {}) : _jsx(CheckIcon, {}) }), _jsx("span", { className: "action-text", children: saving ? savingLabel : savedLabel })] }));
|
|
58
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-ai-client",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.25",
|
|
4
4
|
"private": false,
|
|
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",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@automattic/jetpack-base-styles": "^1.0.12",
|
|
37
|
-
"@automattic/jetpack-components": "^1.
|
|
38
|
-
"@automattic/jetpack-connection": "^1.4.
|
|
37
|
+
"@automattic/jetpack-components": "^1.4.2",
|
|
38
|
+
"@automattic/jetpack-connection": "^1.4.23",
|
|
39
39
|
"@automattic/jetpack-explat": "workspace:*",
|
|
40
40
|
"@automattic/jetpack-script-data": "^0.5.4",
|
|
41
|
-
"@automattic/jetpack-shared-extension-utils": "^1.
|
|
41
|
+
"@automattic/jetpack-shared-extension-utils": "^1.4.2",
|
|
42
42
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
43
43
|
"@types/jest": "30.0.0",
|
|
44
44
|
"@types/react": "18.3.26",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@wordpress/primitives": "4.36.0",
|
|
59
59
|
"@wordpress/url": "4.36.0",
|
|
60
60
|
"clsx": "2.1.1",
|
|
61
|
-
"debug": "4.4.
|
|
61
|
+
"debug": "4.4.3",
|
|
62
62
|
"markdown-it": "14.1.0",
|
|
63
63
|
"react": "18.3.1",
|
|
64
64
|
"react-dom": "18.3.1",
|
|
@@ -27,6 +27,7 @@ import type { ReactElement } from 'react';
|
|
|
27
27
|
type SetImageCallbackProps = {
|
|
28
28
|
id: number;
|
|
29
29
|
url: string;
|
|
30
|
+
mime?: string;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
type GeneralPurposeImageProps = {
|
|
@@ -214,8 +215,8 @@ export default function GeneralPurposeImage( {
|
|
|
214
215
|
site_type: siteType,
|
|
215
216
|
} );
|
|
216
217
|
|
|
217
|
-
const setImage =
|
|
218
|
-
onSetImage?.( { id
|
|
218
|
+
const setImage = ( { id, url, mime } ) => {
|
|
219
|
+
onSetImage?.( { id, url, mime } );
|
|
219
220
|
handleModalClose();
|
|
220
221
|
};
|
|
221
222
|
|
|
@@ -225,10 +226,16 @@ export default function GeneralPurposeImage( {
|
|
|
225
226
|
setImage( {
|
|
226
227
|
id: currentImage?.libraryId,
|
|
227
228
|
url: currentImage?.libraryUrl,
|
|
229
|
+
// Default to image/png for cached images (AI generates PNG)
|
|
230
|
+
mime: 'image/png',
|
|
228
231
|
} );
|
|
229
232
|
} else {
|
|
230
233
|
saveToMediaLibrary( currentImage?.image ).then( image => {
|
|
231
|
-
setImage(
|
|
234
|
+
setImage( {
|
|
235
|
+
id: image.id,
|
|
236
|
+
url: image.url,
|
|
237
|
+
mime: image.mime,
|
|
238
|
+
} );
|
|
232
239
|
} );
|
|
233
240
|
}
|
|
234
241
|
}, [
|
|
@@ -12,9 +12,15 @@ import type { BlockEditorStore } from '../types.ts';
|
|
|
12
12
|
|
|
13
13
|
const debug = debugFactory( 'jetpack-ai-client:save-to-media-library' );
|
|
14
14
|
|
|
15
|
+
type SavedMediaItem = {
|
|
16
|
+
id: string;
|
|
17
|
+
url: string;
|
|
18
|
+
mime?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
15
21
|
type UseSaveToMediaLibraryReturn = {
|
|
16
22
|
isLoading: boolean;
|
|
17
|
-
saveToMediaLibrary: ( url: string, name
|
|
23
|
+
saveToMediaLibrary: ( url: string, name?: string ) => Promise< SavedMediaItem >;
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
/**
|
|
@@ -29,10 +35,7 @@ export default function useSaveToMediaLibrary() {
|
|
|
29
35
|
[]
|
|
30
36
|
) as BlockEditorStore[ 'selectors' ];
|
|
31
37
|
|
|
32
|
-
const saveToMediaLibrary = (
|
|
33
|
-
url: string,
|
|
34
|
-
name: string = null
|
|
35
|
-
): Promise< { id: string; url: string } > => {
|
|
38
|
+
const saveToMediaLibrary = ( url: string, name: string = null ): Promise< SavedMediaItem > => {
|
|
36
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
40
|
const settings = getSettings() as any;
|
|
38
41
|
|
|
@@ -67,7 +70,11 @@ export default function useSaveToMediaLibrary() {
|
|
|
67
70
|
|
|
68
71
|
if ( image ) {
|
|
69
72
|
debug( 'Image uploaded to media library', image );
|
|
70
|
-
resolve(
|
|
73
|
+
resolve( {
|
|
74
|
+
id: image.id,
|
|
75
|
+
url: image.url,
|
|
76
|
+
mime: image.mime,
|
|
77
|
+
} );
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
setIsLoading( false );
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
|
|
5
5
|
import { Button, Icon } from '@wordpress/components';
|
|
6
6
|
import { useDispatch } from '@wordpress/data';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { __, _x } from '@wordpress/i18n';
|
|
8
8
|
import debugFactory from 'debug';
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
@@ -71,7 +71,7 @@ const SaveInLibraryButton: FC< { siteId: string } > = ( { siteId } ) => {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const savingLabel =
|
|
74
|
+
const savingLabel = _x( 'Saving…', 'Logo save button', 'jetpack-ai-client' );
|
|
75
75
|
const savedLabel = __( 'Saved', 'jetpack-ai-client' );
|
|
76
76
|
|
|
77
77
|
return ! saving && ! saved ? (
|