@automattic/jetpack-ai-client 0.33.4 → 0.33.7

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,21 @@ 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.7] - 2025-08-14
9
+ ### Changed
10
+ - Update package dependencies. [#44701]
11
+
12
+ ## [0.33.6] - 2025-08-11
13
+ ### Changed
14
+ - Update package dependencies. [#44677]
15
+
16
+ ### Fixed
17
+ - I18n: Improve context hints in comments for translators. [#44686]
18
+
19
+ ## [0.33.5] - 2025-08-04
20
+ ### Changed
21
+ - Update dependencies. [#44551]
22
+
8
23
  ## [0.33.4] - 2025-07-28
9
24
  ### Fixed
10
25
  - Block Editor: Fix Jetpack AI upgrade links. [#44405]
@@ -671,6 +686,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
671
686
  - AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
672
687
  - Updated package dependencies. [#31468] [#31659] [#31785]
673
688
 
689
+ [0.33.7]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.6...v0.33.7
690
+ [0.33.6]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.5...v0.33.6
691
+ [0.33.5]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.4...v0.33.5
674
692
  [0.33.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.3...v0.33.4
675
693
  [0.33.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.2...v0.33.3
676
694
  [0.33.2]: https://github.com/Automattic/jetpack-ai-client/compare/v0.33.1...v0.33.2
@@ -50,7 +50,7 @@ export default function useAiImage({ feature, type, cost, autoStart = true, prev
50
50
  });
51
51
  }, []);
52
52
  // the selec/useEffect combo...
53
- const loadedMedia = useSelect((select) => select('core')?.getMedia?.(previousMediaId), [previousMediaId]);
53
+ const loadedMedia = useSelect((select) => select('core')?.getEntityRecord?.('postType', 'attachment', previousMediaId), [previousMediaId]);
54
54
  useEffect(() => {
55
55
  if (loadedMedia) {
56
56
  updateImages({
@@ -9,7 +9,7 @@ export interface EditorSelectors {
9
9
  isEditorPanelOpened: (panel: string) => boolean;
10
10
  }
11
11
  export interface CoreSelectors {
12
- getMedia: (mediaId: number) => {
12
+ getEntityRecord: (kind: string, name: string, key: number) => {
13
13
  id: number;
14
14
  source_url: string;
15
15
  } | null;
@@ -91,12 +91,12 @@ const DefaultUpgradePrompt = ({ placement = null, description = null, useLightNu
91
91
  return (_jsx(Nudge, { buttonText: __('Contact Us', 'jetpack-ai-client'), description: description || contactUsDescription, className: 'jetpack-ai-upgrade-banner', checkoutUrl: contactHref, visible: true, align: null, title: null, context: null, goToCheckoutPage: handleContactUsClick, target: "_blank" }));
92
92
  }
93
93
  const upgradeDescription = createInterpolateElement(sprintf(
94
- /* Translators: number of requests */
94
+ /* Translators: %d: the number of requests allowed */
95
95
  __('You have reached the requests limit for your current plan. <strong>Upgrade now to increase your requests limit to %d.</strong>', 'jetpack-ai-client'), nextTier.limit), {
96
96
  strong: _jsx("strong", {}),
97
97
  });
98
98
  return (_jsx(Nudge, { buttonText: sprintf(
99
- /* Translators: number of requests */
99
+ /* Translators: %d: the number of requests */
100
100
  __('Upgrade to %d requests', 'jetpack-ai-client'), nextTier.limit), checkoutUrl: checkoutUrl, className: 'jetpack-ai-upgrade-banner', description: description || upgradeDescription, goToCheckoutPage: handleUpgradeClick, visible: true, align: 'center', title: null, context: null, target: "_blank" }));
101
101
  }
102
102
  return (_jsx(Nudge, { buttonText: __('Upgrade', 'jetpack-ai-client'), checkoutUrl: checkoutUrl, className: 'jetpack-ai-upgrade-banner', description: createInterpolateElement(__('Congratulations on exploring Jetpack AI and reaching the free requests limit! <strong>Upgrade now to keep using it.</strong>', 'jetpack-ai-client'), {
@@ -1,80 +1,80 @@
1
1
  export declare const LANGUAGE_MAP: {
2
2
  en: {
3
- label: string;
3
+ label: import("@wordpress/i18n").TranslatableText<"English">;
4
4
  };
5
5
  es: {
6
- label: string;
6
+ label: import("@wordpress/i18n").TranslatableText<"Spanish">;
7
7
  };
8
8
  fr: {
9
- label: string;
9
+ label: import("@wordpress/i18n").TranslatableText<"French">;
10
10
  };
11
11
  de: {
12
- label: string;
12
+ label: import("@wordpress/i18n").TranslatableText<"German">;
13
13
  };
14
14
  it: {
15
- label: string;
15
+ label: import("@wordpress/i18n").TranslatableText<"Italian">;
16
16
  };
17
17
  pt: {
18
- label: string;
18
+ label: import("@wordpress/i18n").TranslatableText<"Portuguese">;
19
19
  };
20
20
  ru: {
21
- label: string;
21
+ label: import("@wordpress/i18n").TranslatableText<"Russian">;
22
22
  };
23
23
  zh: {
24
- label: string;
24
+ label: import("@wordpress/i18n").TranslatableText<"Chinese">;
25
25
  };
26
26
  ja: {
27
- label: string;
27
+ label: import("@wordpress/i18n").TranslatableText<"Japanese">;
28
28
  };
29
29
  ar: {
30
- label: string;
30
+ label: import("@wordpress/i18n").TranslatableText<"Arabic">;
31
31
  };
32
32
  hi: {
33
- label: string;
33
+ label: import("@wordpress/i18n").TranslatableText<"Hindi">;
34
34
  };
35
35
  ko: {
36
- label: string;
36
+ label: import("@wordpress/i18n").TranslatableText<"Korean">;
37
37
  };
38
38
  };
39
39
  export declare const PROMPT_TONES_MAP: {
40
40
  formal: {
41
- label: string;
41
+ label: import("@wordpress/i18n").TranslatableText<"Formal">;
42
42
  emoji: string;
43
43
  };
44
44
  informal: {
45
- label: string;
45
+ label: import("@wordpress/i18n").TranslatableText<"Informal">;
46
46
  emoji: string;
47
47
  };
48
48
  optimistic: {
49
- label: string;
49
+ label: import("@wordpress/i18n").TranslatableText<"Optimistic">;
50
50
  emoji: string;
51
51
  };
52
52
  humorous: {
53
- label: string;
53
+ label: import("@wordpress/i18n").TranslatableText<"Humorous">;
54
54
  emoji: string;
55
55
  };
56
56
  serious: {
57
- label: string;
57
+ label: import("@wordpress/i18n").TranslatableText<"Serious">;
58
58
  emoji: string;
59
59
  };
60
60
  skeptical: {
61
- label: string;
61
+ label: import("@wordpress/i18n").TranslatableText<"Skeptical">;
62
62
  emoji: string;
63
63
  };
64
64
  empathetic: {
65
- label: string;
65
+ label: import("@wordpress/i18n").TranslatableText<"Empathetic">;
66
66
  emoji: string;
67
67
  };
68
68
  confident: {
69
- label: string;
69
+ label: import("@wordpress/i18n").TranslatableText<"Confident">;
70
70
  emoji: string;
71
71
  };
72
72
  passionate: {
73
- label: string;
73
+ label: import("@wordpress/i18n").TranslatableText<"Passionate">;
74
74
  emoji: string;
75
75
  };
76
76
  provocative: {
77
- label: string;
77
+ label: import("@wordpress/i18n").TranslatableText<"Provocative">;
78
78
  emoji: string;
79
79
  };
80
80
  };
@@ -92,18 +92,18 @@ export declare const PROMPT_TYPE_USER_PROMPT: "userPrompt";
92
92
  export declare const PROMPT_TYPE_JETPACK_FORM_CUSTOM_PROMPT: "jetpackFormCustomPrompt";
93
93
  export declare const PROMPT_TYPE_TRANSFORM_LIST_TO_TABLE: "transformListToTable";
94
94
  export declare const PROMPT_TYPE_WRITE_POST_FROM_LIST: "writePostFromList";
95
- export declare const TRANSLATE_LABEL: string;
96
- export declare const TONE_LABEL: string;
97
- export declare const CORRECT_SPELLING_LABEL: string;
98
- export declare const SIMPLIFY_LABEL: string;
99
- export declare const SUMMARIZE_LABEL: string;
100
- export declare const MAKE_SHORTER_LABEL: string;
101
- export declare const MAKE_LONGER_LABEL: string;
102
- export declare const TURN_LIST_INTO_TABLE_LABEL: string;
103
- export declare const WRITE_POST_FROM_LIST_LABEL: string;
104
- export declare const GENERATE_TITLE_LABEL: string;
105
- export declare const SUMMARY_BASED_ON_TITLE_LABEL: string;
106
- export declare const CONTINUE_LABEL: string;
95
+ export declare const TRANSLATE_LABEL: import("@wordpress/i18n").TranslatableText<"Translate">;
96
+ export declare const TONE_LABEL: import("@wordpress/i18n").TranslatableText<"Change tone">;
97
+ export declare const CORRECT_SPELLING_LABEL: import("@wordpress/i18n").TranslatableText<"Correct spelling and grammar">;
98
+ export declare const SIMPLIFY_LABEL: import("@wordpress/i18n").TranslatableText<"Simplify">;
99
+ export declare const SUMMARIZE_LABEL: import("@wordpress/i18n").TranslatableText<"Summarize">;
100
+ export declare const MAKE_SHORTER_LABEL: import("@wordpress/i18n").TranslatableText<"Make shorter">;
101
+ export declare const MAKE_LONGER_LABEL: import("@wordpress/i18n").TranslatableText<"Expand">;
102
+ export declare const TURN_LIST_INTO_TABLE_LABEL: import("@wordpress/i18n").TranslatableText<"Turn list into a table">;
103
+ export declare const WRITE_POST_FROM_LIST_LABEL: import("@wordpress/i18n").TranslatableText<"Write a post from this list">;
104
+ export declare const GENERATE_TITLE_LABEL: import("@wordpress/i18n").TranslatableText<"Generate a post title">;
105
+ export declare const SUMMARY_BASED_ON_TITLE_LABEL: import("@wordpress/i18n").TranslatableText<"Summary based on title">;
106
+ export declare const CONTINUE_LABEL: import("@wordpress/i18n").TranslatableText<"Continue writing">;
107
107
  export declare const PLACEMENT_JETPACK_SIDEBAR: "jetpack-sidebar";
108
108
  export declare const PLACEMENT_DOCUMENT_SETTINGS: "document-settings";
109
109
  export declare const PLACEMENT_PRE_PUBLISH: "pre-publish";
@@ -155,6 +155,6 @@ export const Prompt = ({ initialPrompt = '' }) => {
155
155
  recordTracksEvent(EVENT_SWITCH_STYLE, { context, style: imageStyle });
156
156
  }, [context, setStyle, recordTracksEvent]);
157
157
  return (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt", children: [_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-header", children: [_jsx("div", { className: "jetpack-ai-logo-generator__prompt-label", children: __('Describe your site:', 'jetpack-ai-client') }), _jsx("div", { className: "jetpack-ai-logo-generator__prompt-actions", children: _jsxs(Button, { variant: "link", disabled: isBusy || requireUpgrade || !hasPrompt, onClick: onEnhance, children: [_jsx(AiIcon, {}), enhanceButtonLabel] }) }), showStyleSelector && (_jsx(SelectControl, { __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, value: style, options: styles, onChange: updateStyle, disabled: isBusy || requireUpgrade }))] }), _jsx(AiModalPromptInput, { prompt: prompt, setPrompt: setPrompt, generateHandler: onGenerate, disabled: isBusy || requireUpgrade, actionDisabled: isBusy || requireUpgrade || !hasPrompt, placeholder: __('Describe your site or simply ask for a logo specifying some details about it', 'jetpack-ai-client') }), _jsxs("div", { className: "jetpack-ai-logo-generator__prompt-footer", children: [!isUnlimited && !requireUpgrade && (_jsxs("div", { className: "jetpack-ai-logo-generator__prompt-requests", children: [_jsx("div", { children: sprintf(
158
- // translators: %u is the number of requests
159
- __('%u requests remaining.', 'jetpack-ai-client'), requestsRemaining) }), hasNextTier && (_jsxs(_Fragment, { children: ["\u00A0", _jsx(Button, { variant: "link", href: checkoutUrl, target: "_blank", onClick: onUpgradeClick, children: _jsx("span", { children: __('Upgrade', 'jetpack-ai-client') }) })] })), "\u00A0", _jsx(Tooltip, { text: __('Logo generation costs 10 requests; prompt enhancement costs 1 request each', 'jetpack-ai-client'), placement: "bottom", children: _jsx(Icon, { className: "prompt-footer__icon", icon: info }) })] })), requireUpgrade && tierPlansEnabled && _jsx(UpgradeNudge, {}), requireUpgrade && !tierPlansEnabled && _jsx(FairUsageNotice, {}), enhancePromptFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error enhancing prompt. Please try again.', 'jetpack-ai-client') })), logoFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error generating logo. Please try again.', 'jetpack-ai-client') }))] })] }));
158
+ // translators: %d is the number of requests
159
+ __('%d requests remaining.', 'jetpack-ai-client'), requestsRemaining) }), hasNextTier && (_jsxs(_Fragment, { children: ["\u00A0", _jsx(Button, { variant: "link", href: checkoutUrl, target: "_blank", onClick: onUpgradeClick, children: _jsx("span", { children: __('Upgrade', 'jetpack-ai-client') }) })] })), "\u00A0", _jsx(Tooltip, { text: __('Logo generation costs 10 requests; prompt enhancement costs 1 request each', 'jetpack-ai-client'), placement: "bottom", children: _jsx(Icon, { className: "prompt-footer__icon", icon: info }) })] })), requireUpgrade && tierPlansEnabled && _jsx(UpgradeNudge, {}), requireUpgrade && !tierPlansEnabled && _jsx(FairUsageNotice, {}), enhancePromptFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error enhancing prompt. Please try again.', 'jetpack-ai-client') })), logoFetchError && (_jsx("div", { className: "jetpack-ai-logo-generator__prompt-error", children: __('Error generating logo. Please try again.', 'jetpack-ai-client') }))] })] }));
160
160
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "private": false,
3
2
  "name": "@automattic/jetpack-ai-client",
4
- "version": "0.33.4",
3
+ "version": "0.33.7",
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",
7
7
  "bugs": {
@@ -14,27 +14,7 @@
14
14
  },
15
15
  "license": "GPL-2.0-or-later",
16
16
  "author": "Automattic",
17
- "scripts": {
18
- "build": "pnpm run clean && pnpm run compile-ts",
19
- "clean": "rm -rf build/",
20
- "compile-ts": "tsc --pretty",
21
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
22
- "test-coverage": "pnpm run test --coverage",
23
- "typecheck": "tsc --noEmit",
24
- "watch": "tsc --watch --pretty"
25
- },
26
17
  "type": "module",
27
- "devDependencies": {
28
- "@storybook/addon-docs": "9.0.15",
29
- "@storybook/react": "9.0.15",
30
- "@testing-library/dom": "10.4.0",
31
- "@types/markdown-it": "14.1.2",
32
- "@types/turndown": "5.0.5",
33
- "jest": "30.0.4",
34
- "jest-environment-jsdom": "30.0.4",
35
- "storybook": "9.0.15",
36
- "typescript": "5.8.3"
37
- },
38
18
  "exports": {
39
19
  ".": {
40
20
  "types": "./build/index.d.ts",
@@ -43,36 +23,56 @@
43
23
  },
44
24
  "main": "./build/index.js",
45
25
  "types": "./build/index.d.ts",
26
+ "scripts": {
27
+ "build": "pnpm run clean && pnpm run compile-ts",
28
+ "clean": "rm -rf build/",
29
+ "compile-ts": "tsc --pretty",
30
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
31
+ "test-coverage": "pnpm run test --coverage",
32
+ "typecheck": "tsc --noEmit",
33
+ "watch": "tsc --watch --pretty"
34
+ },
46
35
  "dependencies": {
47
- "@automattic/jetpack-base-styles": "^1.0.6",
48
- "@automattic/jetpack-components": "^1.1.15",
49
- "@automattic/jetpack-connection": "^1.3.1",
36
+ "@automattic/jetpack-base-styles": "^1.0.8",
37
+ "@automattic/jetpack-components": "^1.2.0",
38
+ "@automattic/jetpack-connection": "^1.4.3",
50
39
  "@automattic/jetpack-explat": "workspace:*",
51
- "@automattic/jetpack-script-data": "^0.5.0",
52
- "@automattic/jetpack-shared-extension-utils": "^1.3.7",
40
+ "@automattic/jetpack-script-data": "^0.5.1",
41
+ "@automattic/jetpack-shared-extension-utils": "^1.3.11",
53
42
  "@microsoft/fetch-event-source": "2.0.1",
54
43
  "@types/jest": "30.0.0",
55
44
  "@types/react": "18.3.23",
56
45
  "@types/wordpress__block-editor": "11.5.16",
57
- "@wordpress/api-fetch": "7.26.0",
58
- "@wordpress/base-styles": "6.2.0",
59
- "@wordpress/blob": "4.26.0",
60
- "@wordpress/block-editor": "14.21.0",
61
- "@wordpress/blocks": "14.15.0",
62
- "@wordpress/components": "29.12.0",
63
- "@wordpress/compose": "7.26.0",
64
- "@wordpress/data": "10.26.0",
65
- "@wordpress/editor": "14.26.0",
66
- "@wordpress/element": "6.26.0",
67
- "@wordpress/i18n": "5.26.0",
68
- "@wordpress/icons": "10.26.0",
69
- "@wordpress/primitives": "4.26.0",
70
- "@wordpress/url": "4.26.0",
46
+ "@wordpress/api-fetch": "7.28.0",
47
+ "@wordpress/base-styles": "6.4.0",
48
+ "@wordpress/blob": "4.28.0",
49
+ "@wordpress/block-editor": "15.1.0",
50
+ "@wordpress/blocks": "15.1.0",
51
+ "@wordpress/components": "30.1.0",
52
+ "@wordpress/compose": "7.28.0",
53
+ "@wordpress/data": "10.28.0",
54
+ "@wordpress/editor": "14.28.0",
55
+ "@wordpress/element": "6.28.0",
56
+ "@wordpress/i18n": "6.1.0",
57
+ "@wordpress/icons": "10.28.0",
58
+ "@wordpress/primitives": "4.28.0",
59
+ "@wordpress/url": "4.28.0",
71
60
  "clsx": "2.1.1",
72
61
  "debug": "4.4.1",
73
62
  "markdown-it": "14.1.0",
74
63
  "react": "18.3.1",
75
64
  "react-dom": "18.3.1",
76
65
  "turndown": "7.1.2"
66
+ },
67
+ "devDependencies": {
68
+ "@storybook/addon-docs": "9.0.15",
69
+ "@storybook/react": "9.0.15",
70
+ "@testing-library/dom": "10.4.0",
71
+ "@types/markdown-it": "14.1.2",
72
+ "@types/turndown": "5.0.5",
73
+ "jest": "30.0.4",
74
+ "jest-environment-jsdom": "30.0.4",
75
+ "storybook": "9.0.15",
76
+ "typescript": "5.8.3"
77
77
  }
78
78
  }
@@ -119,7 +119,8 @@ export default function useAiImage( {
119
119
 
120
120
  // the selec/useEffect combo...
121
121
  const loadedMedia = useSelect(
122
- ( select: ( store ) => CoreSelectors ) => select( 'core' )?.getMedia?.( previousMediaId ),
122
+ ( select: ( store ) => CoreSelectors ) =>
123
+ select( 'core' )?.getEntityRecord?.( 'postType', 'attachment', previousMediaId ),
123
124
  [ previousMediaId ]
124
125
  );
125
126
  useEffect( () => {
@@ -12,7 +12,11 @@ export interface EditorSelectors {
12
12
  }
13
13
 
14
14
  export interface CoreSelectors {
15
- getMedia: ( mediaId: number ) => {
15
+ getEntityRecord: (
16
+ kind: string,
17
+ name: string,
18
+ key: number
19
+ ) => {
16
20
  id: number;
17
21
  source_url: string;
18
22
  } | null;
@@ -167,7 +167,7 @@ const DefaultUpgradePrompt = ( {
167
167
 
168
168
  const upgradeDescription = createInterpolateElement(
169
169
  sprintf(
170
- /* Translators: number of requests */
170
+ /* Translators: %d: the number of requests allowed */
171
171
  __(
172
172
  'You have reached the requests limit for your current plan. <strong>Upgrade now to increase your requests limit to %d.</strong>',
173
173
  'jetpack-ai-client'
@@ -182,7 +182,7 @@ const DefaultUpgradePrompt = ( {
182
182
  return (
183
183
  <Nudge
184
184
  buttonText={ sprintf(
185
- /* Translators: number of requests */
185
+ /* Translators: %d: the number of requests */
186
186
  __( 'Upgrade to %d requests', 'jetpack-ai-client' ),
187
187
  nextTier.limit
188
188
  ) }
@@ -293,8 +293,8 @@ export const Prompt = ( { initialPrompt = '' }: PromptProps ) => {
293
293
  <div className="jetpack-ai-logo-generator__prompt-requests">
294
294
  <div>
295
295
  { sprintf(
296
- // translators: %u is the number of requests
297
- __( '%u requests remaining.', 'jetpack-ai-client' ),
296
+ // translators: %d is the number of requests
297
+ __( '%d requests remaining.', 'jetpack-ai-client' ),
298
298
  requestsRemaining
299
299
  ) }
300
300
  </div>