@automattic/jetpack-ai-client 0.27.2 → 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,6 +5,10 @@ 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
|
+
|
|
8
12
|
## [0.27.2] - 2025-03-12
|
|
9
13
|
### Changed
|
|
10
14
|
- Update dependencies. [#42328]
|
|
@@ -553,6 +557,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
553
557
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
554
558
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
555
559
|
|
|
560
|
+
[0.27.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.2...v0.27.3
|
|
556
561
|
[0.27.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.1...v0.27.2
|
|
557
562
|
[0.27.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.0...v0.27.1
|
|
558
563
|
[0.27.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.26.3...v0.27.0
|
|
@@ -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": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@automattic/jetpack-base-styles": "^0.6.44",
|
|
48
48
|
"@automattic/jetpack-components": "^0.68.2",
|
|
49
49
|
"@automattic/jetpack-connection": "^0.39.1",
|
|
50
|
-
"@automattic/jetpack-shared-extension-utils": "^0.18.
|
|
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';
|