@automattic/jetpack-ai-client 0.14.5 → 0.15.0

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/ask-question/sync.d.ts +2 -8
  3. package/build/ask-question/sync.js +20 -19
  4. package/build/hooks/use-ai-suggestions/index.d.ts +7 -0
  5. package/build/hooks/use-ai-suggestions/index.js +17 -3
  6. package/build/hooks/use-image-generator/index.js +1 -1
  7. package/build/hooks/use-save-to-media-library/index.d.ts +12 -0
  8. package/build/hooks/use-save-to-media-library/index.js +74 -0
  9. package/build/index.d.ts +2 -0
  10. package/build/index.js +5 -0
  11. package/build/libs/index.d.ts +1 -1
  12. package/build/libs/index.js +1 -1
  13. package/build/libs/markdown/index.d.ts +2 -2
  14. package/build/libs/markdown/index.js +2 -2
  15. package/build/libs/markdown/markdown-to-html.d.ts +8 -1
  16. package/build/libs/markdown/markdown-to-html.js +10 -1
  17. package/build/logo-generator/assets/icons/ai.d.ts +6 -0
  18. package/build/logo-generator/assets/icons/ai.js +8 -0
  19. package/build/logo-generator/assets/icons/check.d.ts +6 -0
  20. package/build/logo-generator/assets/icons/check.js +8 -0
  21. package/build/logo-generator/assets/icons/logo.d.ts +6 -0
  22. package/build/logo-generator/assets/icons/logo.js +8 -0
  23. package/build/logo-generator/assets/icons/media.d.ts +6 -0
  24. package/build/logo-generator/assets/icons/media.js +8 -0
  25. package/build/logo-generator/components/feature-fetch-failure-screen.d.ts +8 -0
  26. package/build/logo-generator/components/feature-fetch-failure-screen.js +10 -0
  27. package/build/logo-generator/components/first-load-screen.d.ts +5 -0
  28. package/build/logo-generator/components/first-load-screen.js +16 -0
  29. package/build/logo-generator/components/generator-modal.d.ts +7 -0
  30. package/build/logo-generator/components/generator-modal.js +184 -0
  31. package/build/logo-generator/components/history-carousel.d.ts +6 -0
  32. package/build/logo-generator/components/history-carousel.js +36 -0
  33. package/build/logo-generator/components/image-loader.d.ts +7 -0
  34. package/build/logo-generator/components/image-loader.js +12 -0
  35. package/build/logo-generator/components/logo-presenter.d.ts +4 -0
  36. package/build/logo-generator/components/logo-presenter.js +106 -0
  37. package/build/logo-generator/components/prompt.d.ts +5 -0
  38. package/build/logo-generator/components/prompt.js +96 -0
  39. package/build/logo-generator/components/upgrade-nudge.d.ts +2 -0
  40. package/build/logo-generator/components/upgrade-nudge.js +30 -0
  41. package/build/logo-generator/components/upgrade-screen.d.ts +9 -0
  42. package/build/logo-generator/components/upgrade-screen.js +24 -0
  43. package/build/logo-generator/components/visit-site-banner.d.ts +10 -0
  44. package/build/logo-generator/components/visit-site-banner.js +16 -0
  45. package/build/logo-generator/constants.d.ts +16 -0
  46. package/build/logo-generator/constants.js +19 -0
  47. package/build/logo-generator/hooks/use-checkout.d.ts +4 -0
  48. package/build/logo-generator/hooks/use-checkout.js +26 -0
  49. package/build/logo-generator/hooks/use-logo-generator.d.ts +46 -0
  50. package/build/logo-generator/hooks/use-logo-generator.js +286 -0
  51. package/build/logo-generator/hooks/use-request-errors.d.ts +16 -0
  52. package/build/logo-generator/hooks/use-request-errors.js +46 -0
  53. package/build/logo-generator/index.d.ts +1 -0
  54. package/build/logo-generator/index.js +1 -0
  55. package/build/logo-generator/lib/logo-storage.d.ts +58 -0
  56. package/build/logo-generator/lib/logo-storage.js +123 -0
  57. package/build/logo-generator/lib/media-exists.d.ts +12 -0
  58. package/build/logo-generator/lib/media-exists.js +33 -0
  59. package/build/logo-generator/lib/set-site-logo.d.ts +13 -0
  60. package/build/logo-generator/lib/set-site-logo.js +26 -0
  61. package/build/logo-generator/lib/wpcom-limited-request.d.ts +7 -0
  62. package/build/logo-generator/lib/wpcom-limited-request.js +33 -0
  63. package/build/logo-generator/store/actions.d.ts +105 -0
  64. package/build/logo-generator/store/actions.js +193 -0
  65. package/build/logo-generator/store/constants.d.ts +44 -0
  66. package/build/logo-generator/store/constants.js +44 -0
  67. package/build/logo-generator/store/index.d.ts +1 -0
  68. package/build/logo-generator/store/index.js +19 -0
  69. package/build/logo-generator/store/initial-state.d.ts +3 -0
  70. package/build/logo-generator/store/initial-state.js +40 -0
  71. package/build/logo-generator/store/reducer.d.ts +347 -0
  72. package/build/logo-generator/store/reducer.js +293 -0
  73. package/build/logo-generator/store/selectors.d.ts +119 -0
  74. package/build/logo-generator/store/selectors.js +173 -0
  75. package/build/logo-generator/store/types.d.ts +164 -0
  76. package/build/logo-generator/store/types.js +1 -0
  77. package/build/logo-generator/types.d.ts +82 -0
  78. package/build/logo-generator/types.js +1 -0
  79. package/build/types.d.ts +6 -0
  80. package/package.json +5 -3
  81. package/src/ask-question/sync.ts +22 -27
  82. package/src/hooks/use-ai-suggestions/index.ts +22 -3
  83. package/src/hooks/use-image-generator/index.ts +1 -1
  84. package/src/hooks/use-save-to-media-library/index.ts +95 -0
  85. package/src/index.ts +6 -0
  86. package/src/libs/index.ts +1 -0
  87. package/src/libs/markdown/index.ts +2 -2
  88. package/src/libs/markdown/markdown-to-html.ts +20 -3
  89. package/src/logo-generator/assets/icons/ai.tsx +21 -0
  90. package/src/logo-generator/assets/icons/check.tsx +23 -0
  91. package/src/logo-generator/assets/icons/icons.scss +5 -0
  92. package/src/logo-generator/assets/icons/logo.tsx +23 -0
  93. package/src/logo-generator/assets/icons/media.tsx +24 -0
  94. package/src/logo-generator/assets/images/jetpack-logo.svg +4 -0
  95. package/src/logo-generator/assets/images/loader.gif +0 -0
  96. package/src/logo-generator/assets/index.d.ts +3 -0
  97. package/src/logo-generator/components/feature-fetch-failure-screen.tsx +35 -0
  98. package/src/logo-generator/components/first-load-screen.scss +12 -0
  99. package/src/logo-generator/components/first-load-screen.tsx +32 -0
  100. package/src/logo-generator/components/generator-modal.scss +92 -0
  101. package/src/logo-generator/components/generator-modal.tsx +291 -0
  102. package/src/logo-generator/components/history-carousel.scss +36 -0
  103. package/src/logo-generator/components/history-carousel.tsx +57 -0
  104. package/src/logo-generator/components/image-loader.tsx +22 -0
  105. package/src/logo-generator/components/logo-presenter.scss +116 -0
  106. package/src/logo-generator/components/logo-presenter.tsx +234 -0
  107. package/src/logo-generator/components/prompt.scss +102 -0
  108. package/src/logo-generator/components/prompt.tsx +211 -0
  109. package/src/logo-generator/components/upgrade-nudge.scss +43 -0
  110. package/src/logo-generator/components/upgrade-nudge.tsx +58 -0
  111. package/src/logo-generator/components/upgrade-screen.tsx +67 -0
  112. package/src/logo-generator/components/visit-site-banner.scss +29 -0
  113. package/src/logo-generator/components/visit-site-banner.tsx +50 -0
  114. package/src/logo-generator/constants.ts +22 -0
  115. package/src/logo-generator/hooks/use-checkout.ts +37 -0
  116. package/src/logo-generator/hooks/use-logo-generator.ts +389 -0
  117. package/src/logo-generator/hooks/use-request-errors.ts +70 -0
  118. package/src/logo-generator/index.ts +1 -0
  119. package/src/logo-generator/lib/logo-storage.ts +166 -0
  120. package/src/logo-generator/lib/media-exists.ts +42 -0
  121. package/src/logo-generator/lib/set-site-logo.ts +32 -0
  122. package/src/logo-generator/lib/wpcom-limited-request.ts +41 -0
  123. package/src/logo-generator/store/actions.ts +251 -0
  124. package/src/logo-generator/store/constants.ts +49 -0
  125. package/src/logo-generator/store/index.ts +25 -0
  126. package/src/logo-generator/store/initial-state.ts +43 -0
  127. package/src/logo-generator/store/reducer.ts +387 -0
  128. package/src/logo-generator/store/selectors.ts +201 -0
  129. package/src/logo-generator/store/types.ts +207 -0
  130. package/src/logo-generator/types.ts +97 -0
  131. package/src/types.ts +8 -0
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.15.0] - 2024-07-22
9
+ ### Added
10
+ - Jetpack AI: Add logo generator codebase to the ai-client package. [#38391]
11
+
12
+ ### Changed
13
+ - Update and export askQuestionSync. [#38344]
14
+
15
+ ## [0.14.6] - 2024-07-15
16
+ ### Added
17
+ - AI Client: Filter suggestions starting with llama artifacts [#38208]
18
+
8
19
  ## [0.14.5] - 2024-07-08
9
20
  ### Changed
10
21
  - Updated package dependencies. [#38132]
@@ -347,6 +358,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
347
358
  - Updated package dependencies. [#31659]
348
359
  - Updated package dependencies. [#31785]
349
360
 
361
+ [0.15.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.14.6...v0.15.0
362
+ [0.14.6]: https://github.com/Automattic/jetpack-ai-client/compare/v0.14.5...v0.14.6
350
363
  [0.14.5]: https://github.com/Automattic/jetpack-ai-client/compare/v0.14.4...v0.14.5
351
364
  [0.14.4]: https://github.com/Automattic/jetpack-ai-client/compare/v0.14.3...v0.14.4
352
365
  [0.14.3]: https://github.com/Automattic/jetpack-ai-client/compare/v0.14.2...v0.14.3
@@ -3,13 +3,7 @@ import type { PromptProp } from '../types.js';
3
3
  /**
4
4
  * The response data from the AI assistant when doing a sync, not-streamed question.
5
5
  */
6
- export type ResponseData = {
7
- choices: Array<{
8
- message: {
9
- content: string;
10
- };
11
- }>;
12
- };
6
+ export type ResponseData = string;
13
7
  /**
14
8
  * A function that asks a question without streaming.
15
9
  *
@@ -27,4 +21,4 @@ export type ResponseData = {
27
21
  * const content = responseData.choices[ 0 ].message.content;
28
22
  * } );
29
23
  */
30
- export default function askQuestionSync(question: PromptProp, { postId, feature, model }?: AskQuestionOptionsArgProps): Promise<ResponseData>;
24
+ export default function askQuestionSync(question: PromptProp, options?: AskQuestionOptionsArgProps): Promise<ResponseData>;
@@ -24,12 +24,8 @@ const debug = debugFactory('jetpack-ai-client:ask-question-sync');
24
24
  * const content = responseData.choices[ 0 ].message.content;
25
25
  * } );
26
26
  */
27
- export default async function askQuestionSync(question, { postId = null, feature, model } = {}) {
28
- debug('Asking question with no streaming: %o. options: %o', question, {
29
- postId,
30
- feature,
31
- model,
32
- });
27
+ export default async function askQuestionSync(question, options = {}) {
28
+ debug('Asking question with no streaming: %o. options: %o', question, options);
33
29
  /**
34
30
  * The URL to the AI assistant query endpoint.
35
31
  */
@@ -42,25 +38,30 @@ export default async function askQuestionSync(question, { postId = null, feature
42
38
  debug('Error getting token: %o', error);
43
39
  return Promise.reject(error);
44
40
  }
41
+ const messages = Array.isArray(question) ? { messages: question } : { question: question };
45
42
  const body = {
46
- question: question,
43
+ ...messages,
44
+ ...options,
47
45
  stream: false,
48
- postId,
49
- feature,
50
- model,
51
46
  };
52
47
  const headers = {
53
48
  Authorization: `Bearer ${token}`,
54
49
  'Content-Type': 'application/json',
55
50
  };
56
- const data = await fetch(URL, {
57
- method: 'POST',
58
- headers,
59
- body: JSON.stringify(body),
60
- }).then(response => response.json());
61
- if (data?.data?.status && data?.data?.status > 200) {
62
- debug('Error generating prompt: %o', data);
63
- return Promise.reject(data);
51
+ try {
52
+ const data = await fetch(URL, {
53
+ method: 'POST',
54
+ headers,
55
+ body: JSON.stringify(body),
56
+ }).then(response => response.json());
57
+ if (data?.data?.status && data?.data?.status > 200) {
58
+ debug('Error generating prompt: %o', data);
59
+ return Promise.reject(data);
60
+ }
61
+ return data.choices?.[0]?.message?.content;
62
+ }
63
+ catch (error) {
64
+ debug('Error asking question: %o', error);
65
+ return Promise.reject(error);
64
66
  }
65
- return data;
66
67
  }
@@ -41,6 +41,13 @@ type useAiSuggestionsProps = {
41
41
  * @returns {RequestingErrorProps} The error data.
42
42
  */
43
43
  export declare function getErrorData(errorCode: SuggestionErrorCode): RequestingErrorProps;
44
+ /**
45
+ * Remove the llama artifact from a suggestion.
46
+ *
47
+ * @param {string} suggestion - The suggestion.
48
+ * @returns {string} The suggestion without the llama artifact.
49
+ */
50
+ export declare function removeLlamaArtifact(suggestion: string): string;
44
51
  /**
45
52
  * React custom hook to get suggestions from AI,
46
53
  * by hitting the query endpoint.
@@ -55,6 +55,15 @@ export function getErrorData(errorCode) {
55
55
  };
56
56
  }
57
57
  }
58
+ /**
59
+ * Remove the llama artifact from a suggestion.
60
+ *
61
+ * @param {string} suggestion - The suggestion.
62
+ * @returns {string} The suggestion without the llama artifact.
63
+ */
64
+ export function removeLlamaArtifact(suggestion) {
65
+ return suggestion.replace(/^<\|start_header_id\|>assistant<\|end_header_id\|>[\n]+/, '');
66
+ }
58
67
  /**
59
68
  * React custom hook to get suggestions from AI,
60
69
  * by hitting the query endpoint.
@@ -75,8 +84,12 @@ export default function useAiSuggestions({ prompt, autoRequest = false, askQuest
75
84
  * @returns {void}
76
85
  */
77
86
  const handleSuggestion = useCallback((event) => {
78
- setSuggestion(event?.detail);
79
- onSuggestion?.(event?.detail);
87
+ const partialSuggestion = removeLlamaArtifact(event?.detail);
88
+ if (!partialSuggestion) {
89
+ return;
90
+ }
91
+ setSuggestion(partialSuggestion);
92
+ onSuggestion?.(partialSuggestion);
80
93
  }, [onSuggestion]);
81
94
  /**
82
95
  * onDone function handler.
@@ -86,7 +99,8 @@ export default function useAiSuggestions({ prompt, autoRequest = false, askQuest
86
99
  */
87
100
  const handleDone = useCallback((event) => {
88
101
  closeEventSource();
89
- onDone?.(event?.detail);
102
+ const fullSuggestion = removeLlamaArtifact(event?.detail);
103
+ onDone?.(fullSuggestion);
90
104
  setRequestingState('done');
91
105
  }, [onDone]);
92
106
  const handleAnyError = useCallback((event) => {
@@ -126,7 +126,7 @@ const getStableDiffusionImageGenerationPrompt = async (postContent, userPrompt,
126
126
  * Request the prompt on the AI Assistant endpoint
127
127
  */
128
128
  const data = await askQuestionSync(prompt, { feature });
129
- return data.choices?.[0]?.message?.content;
129
+ return data;
130
130
  };
131
131
  const useImageGenerator = () => {
132
132
  const executeImageGeneration = async function (parameters) {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hook to save an image to the media library.
3
+ *
4
+ * @returns {object} Object with the loading state and the function to save the image to the media library.
5
+ */
6
+ export default function useSaveToMediaLibrary(): {
7
+ isLoading: boolean;
8
+ saveToMediaLibrary: (url: string, name?: string) => Promise<{
9
+ id: string;
10
+ url: string;
11
+ }>;
12
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { isBlobURL } from '@wordpress/blob';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useState } from '@wordpress/element';
7
+ import debugFactory from 'debug';
8
+ const debug = debugFactory('ai-client:save-to-media-library');
9
+ /**
10
+ * Hook to save an image to the media library.
11
+ *
12
+ * @returns {object} Object with the loading state and the function to save the image to the media library.
13
+ */
14
+ export default function useSaveToMediaLibrary() {
15
+ const [isLoading, setIsLoading] = useState(false);
16
+ const { getSettings } = useSelect(select => select('core/block-editor'), []);
17
+ const saveToMediaLibrary = (url, name) => {
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ const settings = getSettings();
20
+ return new Promise((resolve, reject) => {
21
+ setIsLoading(true);
22
+ debug('Fetching image from URL');
23
+ fetch(url)
24
+ .then(response => {
25
+ debug('Transforming response to blob');
26
+ response
27
+ .blob()
28
+ .then((blob) => {
29
+ debug('Uploading blob to media library');
30
+ const filesList = Array();
31
+ if (name) {
32
+ filesList.push(new File([blob], name));
33
+ }
34
+ else {
35
+ filesList.push(blob);
36
+ }
37
+ settings.mediaUpload({
38
+ allowedTypes: ['image'],
39
+ filesList,
40
+ onFileChange([image]) {
41
+ if (isBlobURL(image?.url)) {
42
+ return;
43
+ }
44
+ if (image) {
45
+ debug('Image uploaded to media library', image);
46
+ resolve(image);
47
+ }
48
+ setIsLoading(false);
49
+ },
50
+ onError(message) {
51
+ debug('Error uploading image to media library:', message);
52
+ reject(message);
53
+ setIsLoading(false);
54
+ },
55
+ });
56
+ })
57
+ .catch(e => {
58
+ debug('Error transforming response to blob:', e?.message);
59
+ reject(e?.message);
60
+ setIsLoading(false);
61
+ });
62
+ })
63
+ .catch(e => {
64
+ debug('Error fetching image from URL:', e?.message);
65
+ reject(e?.message);
66
+ setIsLoading(false);
67
+ });
68
+ });
69
+ };
70
+ return {
71
+ isLoading,
72
+ saveToMediaLibrary,
73
+ };
74
+ }
package/build/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as requestJwt } from './jwt/index.js';
2
2
  export { default as SuggestionsEventSource } from './suggestions-event-source/index.js';
3
3
  export { default as askQuestion } from './ask-question/index.js';
4
+ export { default as askQuestionSync } from './ask-question/sync.js';
4
5
  export { default as transcribeAudio } from './audio-transcription/index.js';
5
6
  export { default as useAiSuggestions, getErrorData } from './hooks/use-ai-suggestions/index.js';
6
7
  export { default as useMediaRecording } from './hooks/use-media-recording/index.js';
@@ -13,3 +14,4 @@ export * from './components/index.js';
13
14
  export * from './data-flow/index.js';
14
15
  export * from './types.js';
15
16
  export * from './libs/index.js';
17
+ export * from './logo-generator/index.js';
package/build/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  export { default as requestJwt } from './jwt/index.js';
5
5
  export { default as SuggestionsEventSource } from './suggestions-event-source/index.js';
6
6
  export { default as askQuestion } from './ask-question/index.js';
7
+ export { default as askQuestionSync } from './ask-question/sync.js';
7
8
  export { default as transcribeAudio } from './audio-transcription/index.js';
8
9
  /*
9
10
  * Hooks
@@ -34,3 +35,7 @@ export * from './types.js';
34
35
  * Libs
35
36
  */
36
37
  export * from './libs/index.js';
38
+ /*
39
+ * Logo Generator
40
+ */
41
+ export * from './logo-generator/index.js';
@@ -1,2 +1,2 @@
1
- export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, } from './markdown/index.js';
1
+ export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, fixes, } from './markdown/index.js';
2
2
  export type { RenderHTMLRules } from './markdown/index.js';
@@ -1 +1 @@
1
- export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, } from './markdown/index.js';
1
+ export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, fixes, } from './markdown/index.js';
@@ -2,7 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import HTMLToMarkdown from './html-to-markdown.js';
5
- import MarkdownToHTML from './markdown-to-html.js';
5
+ import MarkdownToHTML, { fixes } from './markdown-to-html.js';
6
6
  /**
7
7
  * Types
8
8
  */
@@ -16,4 +16,4 @@ declare const renderHTMLFromMarkdown: ({ content, rules, extension, }: {
16
16
  declare const renderMarkdownFromHTML: ({ content }: {
17
17
  content: string;
18
18
  }) => string;
19
- export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML };
19
+ export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, fixes };
@@ -2,7 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import HTMLToMarkdown from './html-to-markdown.js';
5
- import MarkdownToHTML from './markdown-to-html.js';
5
+ import MarkdownToHTML, { fixes } from './markdown-to-html.js';
6
6
  const defaultMarkdownConverter = new MarkdownToHTML();
7
7
  const defaultHTMLConverter = new HTMLToMarkdown();
8
8
  const renderHTMLFromMarkdown = ({ content, rules, extension, }) => {
@@ -11,4 +11,4 @@ const renderHTMLFromMarkdown = ({ content, rules, extension, }) => {
11
11
  const renderMarkdownFromHTML = ({ content }) => {
12
12
  return defaultHTMLConverter.render({ content });
13
13
  };
14
- export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML };
14
+ export { MarkdownToHTML, HTMLToMarkdown, renderHTMLFromMarkdown, renderMarkdownFromHTML, fixes };
@@ -6,7 +6,13 @@ import MarkdownIt from 'markdown-it';
6
6
  * Types
7
7
  */
8
8
  import type { Options } from 'markdown-it';
9
- export type Fix = 'list' | 'paragraph' | 'listItem';
9
+ export type Fix = 'list' | 'paragraph' | 'listItem' | 'table';
10
+ type Fixes = {
11
+ [key in Fix]: (content: string, extension?: boolean, options?: {
12
+ [key: string]: unknown;
13
+ }) => string;
14
+ };
15
+ export declare const fixes: Fixes;
10
16
  export default class MarkdownToHTML {
11
17
  markdownConverter: MarkdownIt;
12
18
  constructor(options?: Options);
@@ -24,3 +30,4 @@ export default class MarkdownToHTML {
24
30
  extension?: boolean;
25
31
  }): string;
26
32
  }
33
+ export {};
@@ -19,7 +19,7 @@ const addListComments = (content) => {
19
19
  .replaceAll('<ul>', '<!-- wp:list --><ul>')
20
20
  .replaceAll('</ul>', '</ul><!-- /wp:list -->'));
21
21
  };
22
- const fixes = {
22
+ export const fixes = {
23
23
  list: (content, extension = false) => {
24
24
  // Fix list indentation
25
25
  const fixedIndentation = content
@@ -43,6 +43,15 @@ const fixes = {
43
43
  // Fix encoding of <br /> tags
44
44
  return content.replaceAll(/\s*&lt;br \/&gt;\s*/g, '<br />');
45
45
  },
46
+ table: (content, extension = false, { hasFixedLayout = false }) => {
47
+ if (!extension) {
48
+ return content;
49
+ }
50
+ if (content.startsWith('<!-- wp:table')) {
51
+ return content;
52
+ }
53
+ return `<!-- wp:table { "hasFixedLayout":${hasFixedLayout ? 'true' : 'false'} } -->${content}<!-- /wp:table -->`;
54
+ },
46
55
  };
47
56
  const defaultMarkdownItOptions = {
48
57
  breaks: true,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import './icons.scss';
5
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import './icons.scss';
6
+ export default () => {
7
+ return (_jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "jetpack-ai-logo-generator-icon", children: [_jsx("path", { d: "M6.99976 3.99994L7.84828 6.15141L9.99976 6.99994L7.84828 7.84847L6.99976 9.99994L6.15123 7.84847L3.99976 6.99994L6.15123 6.15141L6.99976 3.99994Z" }), _jsx("path", { d: "M16 4L17.1314 6.86863L20 8L17.1314 9.13137L16 12L14.8686 9.13137L12 8L14.8686 6.86863L16 4Z" }), _jsx("path", { d: "M11 10L12.4142 13.5858L16 15L12.4142 16.4142L11 20L9.58579 16.4142L6 15L9.58579 13.5858L11 10Z" })] }));
8
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import './icons.scss';
5
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import './icons.scss';
6
+ export default () => {
7
+ return (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "jetpack-ai-logo-generator-icon", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M17.9291 7.96836L10.7308 17.6492L6.2145 14.2911L7.10952 13.0873L10.4221 15.5504L16.7253 7.07333L17.9291 7.96836Z" }) }));
8
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import './icons.scss';
5
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import './icons.scss';
6
+ export default () => {
7
+ return (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "jetpack-ai-logo-generator-icon", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.2927 13.7485C18.5014 17.0423 15.5366 19.4901 12 19.4901C8.92508 19.4901 6.28236 17.6396 5.12469 14.9915L8.79556 12.8139L12.2508 14.0309C12.482 14.1123 12.7383 14.0756 12.9374 13.9327L15.8243 11.8601L15.9039 11.8992C16.1998 12.0451 16.6072 12.249 17.0533 12.4807C17.8331 12.8857 18.6946 13.3572 19.2927 13.7485ZM19.499 12.1129C18.9341 11.7788 18.3001 11.4379 17.7447 11.1495C17.287 10.9118 16.8698 10.7031 16.5672 10.5539C16.4158 10.4792 16.2928 10.4193 16.2074 10.378L16.1085 10.3303L16.0824 10.3177L16.0729 10.3132C15.8261 10.1954 15.5347 10.2214 15.3126 10.3809L12.3802 12.4861L8.9634 11.2827C8.75395 11.2089 8.52258 11.2318 8.3316 11.3451L4.65716 13.5248C4.55414 13.0294 4.5 12.5161 4.5 11.9901C4.5 7.84798 7.85786 4.49011 12 4.49011C16.1421 4.49011 19.5 7.84798 19.5 11.9901C19.5 12.0311 19.4997 12.072 19.499 12.1129ZM21 11.9901C21 16.9607 16.9706 20.9901 12 20.9901C7.02944 20.9901 3 16.9607 3 11.9901C3 7.01955 7.02944 2.99011 12 2.99011C16.9706 2.99011 21 7.01955 21 11.9901Z" }) }));
8
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import './icons.scss';
5
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import './icons.scss';
6
+ export default () => {
7
+ return (_jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "jetpack-ai-logo-generator-icon", children: [_jsx("path", { d: "M7 6.49011L11 8.99011L7 11.4901V6.49011Z" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5 2.99011C3.89543 2.99011 3 3.88554 3 4.99011V18.9901C3 20.0947 3.89543 20.9901 5 20.9901H19C20.1046 20.9901 21 20.0947 21 18.9901V4.99011C21 3.88554 20.1046 2.99011 19 2.99011H5ZM19 4.49011H5C4.72386 4.49011 4.5 4.71397 4.5 4.99011V15.6973L8.12953 13.0508C8.38061 12.8677 8.71858 12.8584 8.97934 13.0274L11.906 14.9243L15.4772 11.4524C15.7683 11.1694 16.2317 11.1694 16.5228 11.4524L19.5 14.3469V4.99011C19.5 4.71397 19.2761 4.49011 19 4.49011ZM4.5 18.9901V17.5537L8.59643 14.5667L11.5921 16.5084C11.8857 16.6987 12.2719 16.6607 12.5228 16.4167L16 13.0361L19.4772 16.4167L19.5 16.3933V18.9901C19.5 19.2663 19.2761 19.4901 19 19.4901H5C4.72386 19.4901 4.5 19.2663 4.5 18.9901Z" })] }));
8
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types
3
+ */
4
+ import type React from 'react';
5
+ export declare const FeatureFetchFailureScreen: React.FC<{
6
+ onCancel: () => void;
7
+ onRetry: () => void;
8
+ }>;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { Button } from '@wordpress/components';
6
+ import { __ } from '@wordpress/i18n';
7
+ export const FeatureFetchFailureScreen = ({ onCancel, onRetry }) => {
8
+ const errorMessage = __('We are sorry. There was an error loading your Jetpack AI account settings. Please, try again.', 'jetpack-ai-client');
9
+ return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-message-wrapper", children: [_jsx("div", { className: "jetpack-ai-logo-generator-modal__notice-message", children: _jsx("span", { className: "jetpack-ai-logo-generator-modal__loading-message", children: errorMessage }) }), _jsxs("div", { className: "jetpack-ai-logo-generator-modal__notice-actions", children: [_jsx(Button, { variant: "tertiary", onClick: onCancel, children: __('Cancel', 'jetpack-ai-client') }), _jsx(Button, { variant: "primary", onClick: onRetry, children: __('Try again', 'jetpack-ai-client') })] })] }));
10
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './first-load-screen.scss';
3
+ export declare const FirstLoadScreen: React.FC<{
4
+ state?: 'loadingFeature' | 'analyzing' | 'generating';
5
+ }>;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { __ } from '@wordpress/i18n';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { ImageLoader } from './image-loader.js';
10
+ import './first-load-screen.scss';
11
+ export const FirstLoadScreen = ({ state = 'loadingFeature' }) => {
12
+ const loadingLabel = __('Loading…', 'jetpack-ai-client');
13
+ const analyzingLabel = __('Analyzing your site to create the perfect logo…', 'jetpack-ai-client');
14
+ const generatingLabel = __('Generating logo…', 'jetpack-ai-client');
15
+ return (_jsxs("div", { className: "jetpack-ai-logo-generator-modal__loading-wrapper", children: [_jsx(ImageLoader, {}), _jsxs("span", { className: "jetpack-ai-logo-generator-modal__loading-message", children: [state === 'loadingFeature' && loadingLabel, state === 'analyzing' && analyzingLabel, state === 'generating' && generatingLabel] })] }));
16
+ };
@@ -0,0 +1,7 @@
1
+ import './generator-modal.scss';
2
+ /**
3
+ * Types
4
+ */
5
+ import type { GeneratorModalProps } from '../types.js';
6
+ import type React from 'react';
7
+ export declare const GeneratorModal: React.FC<GeneratorModalProps>;