@automattic/jetpack-ai-client 0.27.1 → 0.27.3
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
CHANGED
|
@@ -5,21 +5,29 @@ 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.27.3] - 2025-03-17
|
|
9
|
+
### Changed
|
|
10
|
+
- Internal updates.
|
|
11
|
+
|
|
12
|
+
## [0.27.2] - 2025-03-12
|
|
13
|
+
### Changed
|
|
14
|
+
- Update dependencies. [#42328]
|
|
15
|
+
|
|
8
16
|
## [0.27.1] - 2025-03-10
|
|
9
17
|
### Added
|
|
10
|
-
-
|
|
18
|
+
- Add optional preprocess function to getPostContent. [#42269]
|
|
11
19
|
|
|
12
20
|
### Changed
|
|
13
21
|
- Update dependencies. [#42222]
|
|
14
22
|
|
|
15
23
|
## [0.27.0] - 2025-03-03
|
|
16
24
|
### Added
|
|
17
|
-
-
|
|
25
|
+
- Move openBlockSidebar utility function. [#42016]
|
|
18
26
|
|
|
19
27
|
### Changed
|
|
20
28
|
- AI Assistant: Add experimental functionality to test Chrome's built-in AI API with the AI excerpt. [#41922]
|
|
21
|
-
-
|
|
22
|
-
-
|
|
29
|
+
- Move showAiAssistantSection function to AI Client. [#42158]
|
|
30
|
+
- Refactor usePostContent hook to expose isEditedPostEmpty. [#42149]
|
|
23
31
|
- Update package dependencies. [#42163]
|
|
24
32
|
|
|
25
33
|
## [0.26.3] - 2025-02-24
|
|
@@ -549,6 +557,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
549
557
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
550
558
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
551
559
|
|
|
560
|
+
[0.27.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.2...v0.27.3
|
|
561
|
+
[0.27.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.1...v0.27.2
|
|
552
562
|
[0.27.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.0...v0.27.1
|
|
553
563
|
[0.27.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.3...v0.27.0
|
|
554
564
|
[0.26.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.2...v0.26.3
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the base64 representation of an image.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url - The URL of the image.
|
|
5
|
+
* @return {Promise<string>} The base64 representation of the image.
|
|
6
|
+
*/
|
|
7
|
+
export const getBase64Image = async (url) => {
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch(url);
|
|
10
|
+
const buffer = await response.arrayBuffer();
|
|
11
|
+
const base64String = btoa(new Uint8Array(buffer).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
12
|
+
return `data:image/png;base64,${base64String}`;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// If we can't fetch the image, return the original URL.
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
18
|
+
};
|
package/build/libs/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, fixes, } from './markdown/index.js';
|
|
2
|
-
export type { RenderHTMLRules } from './markdown/index.js';
|
|
3
2
|
export { mapActionToHumanText } from './map-action-to-human-text.js';
|
|
4
3
|
export { openBlockSidebar } from './open-block-sidebar.js';
|
|
5
4
|
export { showAiAssistantSection } from './show-ai-assistant-section.js';
|
|
6
5
|
export { getAllBlocks } from './get-all-blocks.js';
|
|
6
|
+
export { getBase64Image } from './get-base64-image.js';
|
|
7
|
+
export type { RenderHTMLRules } from './markdown/index.js';
|
package/build/libs/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { mapActionToHumanText } from './map-action-to-human-text.js';
|
|
|
3
3
|
export { openBlockSidebar } from './open-block-sidebar.js';
|
|
4
4
|
export { showAiAssistantSection } from './show-ai-assistant-section.js';
|
|
5
5
|
export { getAllBlocks } from './get-all-blocks.js';
|
|
6
|
+
export { getBase64Image } from './get-base64-image.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.3",
|
|
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": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"types": "./build/index.d.ts",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@automattic/jetpack-base-styles": "^0.6.44",
|
|
48
|
-
"@automattic/jetpack-components": "^0.68.
|
|
49
|
-
"@automattic/jetpack-connection": "^0.39.
|
|
50
|
-
"@automattic/jetpack-shared-extension-utils": "^0.
|
|
48
|
+
"@automattic/jetpack-components": "^0.68.2",
|
|
49
|
+
"@automattic/jetpack-connection": "^0.39.1",
|
|
50
|
+
"@automattic/jetpack-shared-extension-utils": "^0.18.1",
|
|
51
51
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
52
52
|
"@types/jest": "29.5.14",
|
|
53
53
|
"@types/react": "18.3.18",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the base64 representation of an image.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url - The URL of the image.
|
|
5
|
+
* @return {Promise<string>} The base64 representation of the image.
|
|
6
|
+
*/
|
|
7
|
+
export const getBase64Image = async ( url: string ) => {
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch( url );
|
|
10
|
+
const buffer = await response.arrayBuffer();
|
|
11
|
+
const base64String = btoa(
|
|
12
|
+
new Uint8Array( buffer ).reduce( ( data, byte ) => data + String.fromCharCode( byte ), '' )
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
return `data:image/png;base64,${ base64String }`;
|
|
16
|
+
} catch {
|
|
17
|
+
// If we can't fetch the image, return the original URL.
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
};
|
package/src/libs/index.ts
CHANGED
|
@@ -6,12 +6,10 @@ export {
|
|
|
6
6
|
fixes,
|
|
7
7
|
} from './markdown/index.js';
|
|
8
8
|
|
|
9
|
-
export type { RenderHTMLRules } from './markdown/index.js';
|
|
10
|
-
|
|
11
9
|
export { mapActionToHumanText } from './map-action-to-human-text.js';
|
|
12
|
-
|
|
13
10
|
export { openBlockSidebar } from './open-block-sidebar.js';
|
|
14
|
-
|
|
15
11
|
export { showAiAssistantSection } from './show-ai-assistant-section.js';
|
|
16
|
-
|
|
17
12
|
export { getAllBlocks } from './get-all-blocks.js';
|
|
13
|
+
export { getBase64Image } from './get-base64-image.js';
|
|
14
|
+
|
|
15
|
+
export type { RenderHTMLRules } from './markdown/index.js';
|