@automattic/jetpack-ai-client 0.1.12 → 0.1.14

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,15 @@ 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.1.14] - 2023-11-03
9
+
10
+ ## [0.1.13] - 2023-10-23
11
+ ### Changed
12
+ - Updated package dependencies. [#33687]
13
+
14
+ ### Removed
15
+ - AI Client: Remove obsolete blockListBlockWithAiDataProvider() HOC component. [#33726]
16
+
8
17
  ## [0.1.12] - 2023-10-16
9
18
  ### Changed
10
19
  - Updated package dependencies. [#33584]
@@ -144,6 +153,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
144
153
  - Updated package dependencies. [#31659]
145
154
  - Updated package dependencies. [#31785]
146
155
 
156
+ [0.1.14]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.13...v0.1.14
157
+ [0.1.13]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.12...v0.1.13
147
158
  [0.1.12]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.11...v0.1.12
148
159
  [0.1.11]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.10...v0.1.11
149
160
  [0.1.10]: https://github.com/Automattic/jetpack-ai-client/compare/v0.1.9...v0.1.10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@automattic/jetpack-ai-client",
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
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": {
@@ -32,18 +32,18 @@
32
32
  ".": "./index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@automattic/jetpack-base-styles": "^0.6.10",
36
- "@automattic/jetpack-connection": "^0.30.2",
37
- "@automattic/jetpack-shared-extension-utils": "^0.12.2",
35
+ "@automattic/jetpack-base-styles": "^0.6.11",
36
+ "@automattic/jetpack-connection": "^0.30.5",
37
+ "@automattic/jetpack-shared-extension-utils": "^0.12.5",
38
38
  "@microsoft/fetch-event-source": "2.0.1",
39
- "@wordpress/api-fetch": "6.40.0",
40
- "@wordpress/block-editor": "12.11.0",
41
- "@wordpress/components": "25.9.0",
42
- "@wordpress/compose": "6.20.0",
43
- "@wordpress/data": "9.13.0",
44
- "@wordpress/element": "5.20.0",
45
- "@wordpress/i18n": "4.43.0",
46
- "@wordpress/icons": "9.34.0",
39
+ "@wordpress/api-fetch": "6.41.0",
40
+ "@wordpress/block-editor": "12.12.0",
41
+ "@wordpress/components": "25.10.0",
42
+ "@wordpress/compose": "6.21.0",
43
+ "@wordpress/data": "9.14.0",
44
+ "@wordpress/element": "5.21.0",
45
+ "@wordpress/i18n": "4.44.0",
46
+ "@wordpress/icons": "9.35.0",
47
47
  "classnames": "2.3.2",
48
48
  "debug": "4.3.4",
49
49
  "react": "18.2.0",
@@ -33,7 +33,6 @@ export default withAiAssistantData( MyComponent );
33
33
 
34
34
  * [AI Data Context](#ai-assistant-content)
35
35
  * [withAiDataProvider HOC](#with-ai-data-provider)
36
- * [blockListBlockWithAiDataProvider](#block-list-block-with-ai-data-provider)
37
36
  * [useAiContext Hook](#use-ai-context)
38
37
 
39
38
  <h2 id="ai-assistant-content">Ai Data Context</h2>
@@ -116,25 +115,6 @@ These callbacks will be invoked with the detail of the corresponding event emitt
116
115
  When called, the hook returns the Ai Data Context.
117
116
 
118
117
 
119
- <h2 id="block-list-block-with-ai-data-provider">blockListBlockWithAiDataProvider Function</h2>
120
-
121
- The `blockListBlockWithAiDataProvider` function returns a Higher Order Component (HOC) that wraps and provides the AI Assistant Data context to a specified set of blocks. Primarily designed for use with the `editor.BlockListBlock` filter in the WordPress Block Editor, it conditionally applies the data provider only to block types specified in the function options.
122
-
123
- ### Usage
124
-
125
- To use the `blockListBlockWithAiDataProvider`, you'll need to specify which blocks should have access to the AI Assistant Data context:
126
-
127
- ```jsx
128
- import { blockListBlockWithAiDataProvider } from '@automattic/jetpack-ai-client';
129
-
130
- // Example usage with WordPress filters
131
- const enhancedBlockListBlock = blockListBlockWithAiDataProvider( {
132
- blocks: [ 'core/paragraph', 'core/heading' ]
133
- } );
134
-
135
- wp.hooks.addFilter( 'editor.BlockListBlock', 'my-plugin/with-ai-data', enhancedBlockListBlock );
136
- ```
137
-
138
118
  ### Parameters
139
119
 
140
120
  The function accepts an optional options object:
@@ -1,6 +1,3 @@
1
1
  export { AiDataContext, AiDataContextProvider } from './context';
2
- export {
3
- default as withAiDataProvider,
4
- blockListBlockWithAiDataProvider,
5
- } from './with-ai-assistant-data';
2
+ export { default as withAiDataProvider } from './with-ai-assistant-data';
6
3
  export { default as useAiContext } from './use-ai-context';
@@ -59,82 +59,3 @@ const withAiDataProvider = createHigherOrderComponent( ( WrappedComponent: React
59
59
  }, 'withAiDataProvider' );
60
60
 
61
61
  export default withAiDataProvider;
62
-
63
- type OptionsProps = {
64
- /**
65
- * Array of block names to apply the data provider to.
66
- */
67
- blocks: string[] | string;
68
- };
69
-
70
- /**
71
- * Function that returns a High Order Component that provides the
72
- * AI Assistant Data context to the wrapped component.
73
- *
74
- * Ideally though to use with the `editor.BlockListBlock` filter.
75
- *
76
- * @see https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#editor-blocklistblock
77
- * @param {OptionsProps} options - Options
78
- * @param {string[]} options.blocks - Array of block names to apply the data provider to.
79
- * @returns {ReactNode} Wrapped component, populated with the AI Assistant Data context.
80
- */
81
- export const blockListBlockWithAiDataProvider = ( options: OptionsProps = { blocks: [ '' ] } ) => {
82
- return createHigherOrderComponent( ( WrappedComponent: ReactNode ) => {
83
- return props => {
84
- const blockName = props?.block?.name;
85
- if ( ! blockName ) {
86
- return <WrappedComponent { ...props } />;
87
- }
88
-
89
- /*
90
- * Extend only blocks that are specified in the blocks option.
91
- * `blocks` option accepts a string or an array of strings.
92
- */
93
- const blockTypesToExtend = Array.isArray( options.blocks )
94
- ? options.blocks
95
- : [ options.blocks ];
96
-
97
- if ( ! blockTypesToExtend.includes( blockName ) ) {
98
- return <WrappedComponent { ...props } />;
99
- }
100
-
101
- // Connect with the AI Assistant communication layer.
102
- // @todo: this is a copy of the code above, we should refactor this.
103
- const {
104
- suggestion,
105
- error: requestingError,
106
- requestingState,
107
- request: requestSuggestion,
108
- stopSuggestion,
109
- eventSource,
110
- } = useAiSuggestions();
111
-
112
- // Build the context value to pass to the ai assistant data provider.
113
- const dataContextValue = useMemo(
114
- () => ( {
115
- suggestion,
116
- requestingError,
117
- requestingState,
118
- eventSource,
119
-
120
- requestSuggestion,
121
- stopSuggestion,
122
- } ),
123
- [
124
- suggestion,
125
- requestingError,
126
- requestingState,
127
- eventSource,
128
- requestSuggestion,
129
- stopSuggestion,
130
- ]
131
- );
132
-
133
- return (
134
- <AiDataContextProvider value={ dataContextValue }>
135
- <WrappedComponent { ...props } />
136
- </AiDataContextProvider>
137
- );
138
- };
139
- }, 'blockListBlockWithAiDataProvider' );
140
- };