use-vibes 0.4.0 → 0.4.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.
Files changed (72) hide show
  1. package/README.md +1 -0
  2. package/dist/components/ControlsBar.d.ts +32 -0
  3. package/dist/components/ControlsBar.js +80 -0
  4. package/dist/components/ControlsBar.js.map +1 -0
  5. package/dist/components/ImgGen.css +523 -0
  6. package/dist/components/ImgGen.d.ts +36 -0
  7. package/dist/components/ImgGen.js +206 -0
  8. package/dist/components/ImgGen.js.map +1 -0
  9. package/dist/components/ImgGenUtils/ImgGenDisplay.d.ts +3 -0
  10. package/dist/components/ImgGenUtils/ImgGenDisplay.js +251 -0
  11. package/dist/components/ImgGenUtils/ImgGenDisplay.js.map +1 -0
  12. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +3 -0
  13. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +115 -0
  14. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
  15. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +44 -0
  16. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js +127 -0
  17. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
  18. package/dist/components/ImgGenUtils/ImgGenError.d.ts +3 -0
  19. package/dist/components/ImgGenUtils/ImgGenError.js +9 -0
  20. package/dist/components/ImgGenUtils/ImgGenError.js.map +1 -0
  21. package/dist/components/ImgGenUtils/ImgGenModal.d.ts +31 -0
  22. package/dist/components/ImgGenUtils/ImgGenModal.js +31 -0
  23. package/dist/components/ImgGenUtils/ImgGenModal.js.map +1 -0
  24. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +7 -0
  25. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js +8 -0
  26. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
  27. package/dist/components/ImgGenUtils/index.d.ts +5 -0
  28. package/dist/components/ImgGenUtils/index.js +8 -0
  29. package/dist/components/ImgGenUtils/index.js.map +1 -0
  30. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +10 -0
  31. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +32 -0
  32. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +1 -0
  33. package/dist/components/ImgGenUtils/overlays/ImageOverlay.d.ts +29 -0
  34. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js +11 -0
  35. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js.map +1 -0
  36. package/dist/components/ImgGenUtils/types.d.ts +37 -0
  37. package/dist/components/ImgGenUtils/types.js +2 -0
  38. package/dist/components/ImgGenUtils/types.js.map +1 -0
  39. package/dist/components/ImgGenUtils.d.ts +6 -0
  40. package/dist/components/ImgGenUtils.js +7 -0
  41. package/dist/components/ImgGenUtils.js.map +1 -0
  42. package/dist/components/PromptBar.d.ts +15 -0
  43. package/dist/components/PromptBar.js +23 -0
  44. package/dist/components/PromptBar.js.map +1 -0
  45. package/dist/hooks/image-gen/image-generator.d.ts +14 -0
  46. package/dist/hooks/image-gen/image-generator.js +78 -0
  47. package/dist/hooks/image-gen/image-generator.js.map +1 -0
  48. package/dist/hooks/image-gen/index.d.ts +6 -0
  49. package/dist/hooks/image-gen/index.js +6 -0
  50. package/dist/hooks/image-gen/index.js.map +1 -0
  51. package/dist/hooks/image-gen/types.d.ts +75 -0
  52. package/dist/hooks/image-gen/types.js +2 -0
  53. package/dist/hooks/image-gen/types.js.map +1 -0
  54. package/dist/hooks/image-gen/use-image-gen.d.ts +12 -0
  55. package/dist/hooks/image-gen/use-image-gen.js +573 -0
  56. package/dist/hooks/image-gen/use-image-gen.js.map +1 -0
  57. package/dist/hooks/image-gen/utils.d.ts +61 -0
  58. package/dist/hooks/image-gen/utils.js +241 -0
  59. package/dist/hooks/image-gen/utils.js.map +1 -0
  60. package/dist/hooks/use-image-gen.d.ts +5 -0
  61. package/dist/hooks/use-image-gen.js +7 -0
  62. package/dist/hooks/use-image-gen.js.map +1 -0
  63. package/dist/index.d.ts +5 -0
  64. package/dist/index.js +6 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/style-loader.d.ts +16 -0
  67. package/dist/style-loader.js +43 -0
  68. package/dist/style-loader.js.map +1 -0
  69. package/dist/utils/style-utils.d.ts +51 -0
  70. package/dist/utils/style-utils.js +42 -0
  71. package/dist/utils/style-utils.js.map +1 -0
  72. package/package.json +1 -1
@@ -0,0 +1,206 @@
1
+ import * as React from 'react';
2
+ import { v4 as uuid } from 'uuid';
3
+ import { useImageGen } from '../hooks/image-gen/use-image-gen';
4
+ import { useFireproof } from 'use-fireproof';
5
+ import { ImgGenPromptWaiting, ImgGenDisplayPlaceholder, ImgGenDisplay, ImgGenError, } from './ImgGenUtils';
6
+ import { defaultClasses, combineClasses } from '../utils/style-utils';
7
+ import './ImgGen.css';
8
+ /**
9
+ * Core implementation of ImgGen component
10
+ * This is the component that gets remounted when the document ID or prompt changes
11
+ */
12
+ function ImgGenCore(props) {
13
+ // Destructure the props for cleaner code
14
+ const { prompt, _id, className, alt, options, database, onLoad, onError, onDelete, onPromptEdit, classes = defaultClasses, } = props;
15
+ // Get access to the Fireproof database directly
16
+ const { database: db } = useFireproof(database || 'ImgGen');
17
+ // Use a unique generationId to trigger regeneration
18
+ // This provides a clearer signal when regeneration is needed
19
+ const [generationId, setGenerationId] = React.useState(undefined);
20
+ // Calculate isPlaceholder as a pure expression instead of using useMemo
21
+ // This is simple enough that React doesn't need to track dependencies or cache the result
22
+ const isPlaceholder = !prompt && !_id;
23
+ // Track the edited prompt to pass to the image generator and show in UI
24
+ const [currentEditedPrompt, setCurrentEditedPrompt] = React.useState(undefined);
25
+ // Use the custom hook for all the image generation logic
26
+ const { imageData, loading, error, progress, document } = useImageGen({
27
+ // Always provide prompt when available, even with _id (helps with fallback generation)
28
+ prompt: prompt || '',
29
+ _id: _id,
30
+ options,
31
+ database,
32
+ // Use the generationId to signal when we want a new image
33
+ generationId,
34
+ // Pass the edited prompt if it exists, allowing it to override the document prompt
35
+ editedPrompt: currentEditedPrompt,
36
+ // Skip processing if neither prompt nor _id is provided
37
+ skip: isPlaceholder,
38
+ });
39
+ // When document is generated, use its ID for subsequent operations
40
+ // This is done through the parent component's remounting logic with uuid()
41
+ // Handle regeneration when the button is clicked
42
+ const handleRegen = React.useCallback(() => {
43
+ if (document?._id || _id || prompt) {
44
+ // Create a new unique ID to trigger regeneration
45
+ const newGenId = crypto.randomUUID();
46
+ setGenerationId(newGenId);
47
+ }
48
+ }, [document, _id, prompt]);
49
+ // Handle prompt editing
50
+ const handlePromptEdit = React.useCallback(async (id, newPrompt) => {
51
+ // Update the tracked edited prompt
52
+ setCurrentEditedPrompt(newPrompt);
53
+ try {
54
+ // First, update the document in the database with the new prompt
55
+ const docToUpdate = (await db.get(id));
56
+ if (docToUpdate) {
57
+ // Create a type-safe update object
58
+ const baseUpdate = {
59
+ ...docToUpdate,
60
+ prompt: newPrompt, // Update the legacy prompt field
61
+ };
62
+ // Check if the document has the prompts structure and update it if it exists
63
+ if ('prompts' in docToUpdate &&
64
+ 'currentPromptKey' in docToUpdate &&
65
+ docToUpdate.prompts &&
66
+ docToUpdate.currentPromptKey) {
67
+ // Instead of updating the existing prompt, create a new prompt entry
68
+ const updatedPrompts = { ...docToUpdate.prompts };
69
+ // Create a new prompt key
70
+ const promptCount = Object.keys(updatedPrompts).length + 1;
71
+ const newPromptKey = `p${promptCount}`;
72
+ // Add new prompt entry
73
+ updatedPrompts[newPromptKey] = {
74
+ text: newPrompt,
75
+ created: Date.now(),
76
+ };
77
+ // Update currentPromptKey to point to the new prompt
78
+ Object.assign(baseUpdate, { currentPromptKey: newPromptKey });
79
+ // Don't modify the existing version's promptKey
80
+ // This ensures that each version keeps its original prompt association
81
+ // The new prompt will be used for the next version that gets generated
82
+ // No need to update versions array here
83
+ // Add the updated prompts to our update object
84
+ Object.assign(baseUpdate, { prompts: updatedPrompts });
85
+ }
86
+ // Save the updated document back to the database
87
+ await db.put(baseUpdate);
88
+ }
89
+ // Call the user-provided onPromptEdit callback if it exists
90
+ if (onPromptEdit) {
91
+ onPromptEdit(id, newPrompt);
92
+ }
93
+ // Now trigger regeneration with the updated prompt
94
+ handleRegen();
95
+ }
96
+ catch (error) {
97
+ console.error('Error updating prompt:', error);
98
+ }
99
+ }, [db, onPromptEdit, handleRegen]);
100
+ // Handle delete request
101
+ const handleDelete = React.useCallback((id) => {
102
+ if (onDelete) {
103
+ // If custom delete handler provided, use it
104
+ onDelete(id);
105
+ }
106
+ else if (db) {
107
+ // Otherwise use the database directly
108
+ db.del(id)
109
+ .then(() => { })
110
+ .catch((err) => {
111
+ console.error(`Failed to delete document: ${id}`, err);
112
+ });
113
+ }
114
+ else {
115
+ // No database available for deletion
116
+ }
117
+ }, [onDelete, db]);
118
+ // Load/error effect - always declare in the same order
119
+ React.useEffect(() => {
120
+ if (!loading) {
121
+ if (error) {
122
+ // Image generation failed
123
+ onError?.(error); // Pass error to callback
124
+ }
125
+ else if (document && document._files) {
126
+ // Image generation succeeded - now supports both legacy and versioned files
127
+ onLoad?.();
128
+ }
129
+ }
130
+ }, [loading, error, document, onLoad, onError]);
131
+ // No longer need to detect regeneration completion
132
+ // The generationId approach doesn't require resetting since each regeneration
133
+ // uses a new unique ID, eliminating the need for this effect
134
+ // Render function that determines what to show
135
+ const renderContent = () => {
136
+ // If we don't have a prompt or ID, show the waiting component
137
+ if (isPlaceholder) {
138
+ return React.createElement(ImgGenPromptWaiting, { className: className, classes: classes });
139
+ }
140
+ // Check if we have a document, even if we're still loading (for regeneration case)
141
+ if (document && document._files) {
142
+ // Get the alt text from either:
143
+ // 1. Explicitly provided alt prop
144
+ // 2. Current prompt from the document's prompt structure
145
+ // 3. Legacy prompt field
146
+ // 4. Empty string as fallback
147
+ const altText = alt ||
148
+ (document.prompts && document.currentPromptKey
149
+ ? document.prompts[document.currentPromptKey]?.text
150
+ : document.prompt || '');
151
+ // Show the document display with regeneration state if applicable
152
+ // Ensure document has a defined _id for display
153
+ if (!document._id) {
154
+ console.error('Document is missing _id', document);
155
+ return React.createElement("div", null, "Error: Invalid document");
156
+ }
157
+ return (React.createElement("div", { className: "imggen-container" },
158
+ React.createElement(ImgGenDisplay, { document: document, className: className, alt: altText, onDelete: handleDelete, onRegen: handleRegen, onPromptEdit: handlePromptEdit, classes: classes, loading: loading, error: error }),
159
+ loading && generationId && (React.createElement("div", { className: "imggen-progress-container" },
160
+ React.createElement("div", { className: combineClasses('imggen-progress', classes.progress), style: { width: `${progress}%` }, "aria-hidden": "true" })))));
161
+ }
162
+ // Otherwise, for initial load or error states, show the placeholder
163
+ if (loading || !imageData || error) {
164
+ // Use the edited prompt during regeneration if available
165
+ const displayPrompt = currentEditedPrompt || prompt;
166
+ return (React.createElement(ImgGenDisplayPlaceholder, { className: className, alt: alt, prompt: displayPrompt, progress: progress, error: null, classes: classes }));
167
+ }
168
+ // Fallback for any other unexpected state
169
+ return React.createElement(ImgGenError, { classes: classes });
170
+ };
171
+ // Always render through the render function - no conditional returns in the main component body
172
+ return renderContent();
173
+ }
174
+ /**
175
+ * Main component for generating images with call-ai's imageGen
176
+ * Provides automatic caching, reactive updates, and placeholder handling
177
+ * Uses a mountKey to ensure clean state when switching documents
178
+ */
179
+ export function ImgGen(props) {
180
+ // Destructure key props for identity-change tracking
181
+ // classes prop is used via the props spread to ImgGenCore
182
+ const { _id, prompt } = props;
183
+ // Generate a unique mountKey for this instance
184
+ const [mountKey, setMountKey] = React.useState(() => uuid());
185
+ // Track previous props to detect identity changes
186
+ const prevIdRef = React.useRef(_id);
187
+ const prevPromptRef = React.useRef(prompt);
188
+ // Update mountKey when document identity changes
189
+ React.useEffect(() => {
190
+ const idChanged = _id !== prevIdRef.current;
191
+ const promptChanged = prompt && prompt !== prevPromptRef.current;
192
+ // Reset mountKey if we switched documents, or if we're showing a new prompt
193
+ // with no document ID (which means a brand new generation)
194
+ if (idChanged || (!_id && promptChanged)) {
195
+ setMountKey(uuid()); // Force a remount of ImgGenCore
196
+ }
197
+ // Update refs for next comparison
198
+ prevIdRef.current = _id;
199
+ prevPromptRef.current = prompt;
200
+ }, [_id, prompt]);
201
+ // Render the core component with a key to force remount when identity changes
202
+ return React.createElement(ImgGenCore, { ...props, key: mountKey });
203
+ }
204
+ // Simple export - no memoization or complex structure
205
+ export default ImgGen;
206
+ //# sourceMappingURL=ImgGen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGen.js","sourceRoot":"","sources":["../../src/components/ImgGen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAY,MAAM,eAAe,CAAC;AAEvD,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,cAAc,CAAC;AAwCtB;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAkB;IACpC,yCAAyC;IACzC,MAAM,EACJ,MAAM,EACN,GAAG,EACH,SAAS,EACT,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,OAAO,GAAG,cAAc,GACzB,GAAG,KAAK,CAAC;IAEV,gDAAgD;IAChD,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,YAAY,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;IAE5D,oDAAoD;IACpD,6DAA6D;IAC7D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAEtF,wEAAwE;I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AAC;QAED,kCAAkC;QAClC,SAAS,CAAC,OAAO,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,OAAO,GAAG,MAAM,CAAC;IACjC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAElB,8EAA8E;IAC9E,OAAO,oBAAC,UAAU,OAAK,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAI,CAAC;AAClD,CAAC;AAED,sDAAsD;AACtD,eAAe,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { ImgGenDisplayProps } from './types';
3
+ export declare function ImgGenDisplay({ document, className, alt, onDelete, onRegen, onPromptEdit, classes, loading, error, }: ImgGenDisplayProps): React.JSX.Element;
@@ -0,0 +1,251 @@
1
+ import * as React from 'react';
2
+ import { ImgFile } from 'use-fireproof';
3
+ import { ImgGenError } from './ImgGenError';
4
+ import { combineClasses, defaultClasses } from '../../utils/style-utils';
5
+ import { getCurrentFileKey, getPromptInfo, getVersionInfo } from './ImgGenDisplayUtils';
6
+ import { ImgGenModal } from './ImgGenModal';
7
+ // Component for displaying the generated image
8
+ export function ImgGenDisplay({ document, className, alt, onDelete, onRegen, onPromptEdit, classes = defaultClasses, loading, error, }) {
9
+ // Delete confirmation is now handled within ControlsBar
10
+ // Use null to indicate not editing, or string for edit mode
11
+ const [editedPrompt, setEditedPrompt] = React.useState(null);
12
+ // Track the prompt that's currently being generated
13
+ const [generatingPrompt, setGeneratingPrompt] = React.useState(null);
14
+ // --- Fullscreen backdrop state ---
15
+ const [isFullscreen, setIsFullscreen] = React.useState(false);
16
+ const openFullscreen = () => setIsFullscreen(true);
17
+ const closeFullscreen = () => setIsFullscreen(false);
18
+ // Get version information directly at render time
19
+ const { versions, currentVersion } = getVersionInfo(document);
20
+ // Calculate the initial version index based on document state
21
+ const initialVersionIndex = React.useMemo(() => {
22
+ return typeof currentVersion === 'number'
23
+ ? currentVersion
24
+ : versions?.length
25
+ ? versions.length - 1
26
+ : 0;
27
+ }, [currentVersion, versions]);
28
+ // Track previous version count to detect when new versions are added
29
+ const prevVersionsCountRef = React.useRef(versions.length);
30
+ // Set flash effect when new version is added
31
+ React.useEffect(() => {
32
+ // If we have more versions than before, it means a new version was added
33
+ if (versions.length > prevVersionsCountRef.current) {
34
+ // Trigger the flash effect
35
+ setVersionFlash(true);
36
+ // Auto-reset flash after animation completes
37
+ const timer = setTimeout(() => {
38
+ setVersionFlash(false);
39
+ }, 2000); // Match the animation duration in CSS
40
+ return () => clearTimeout(timer);
41
+ }
42
+ // Update ref for next comparison
43
+ prevVersionsCountRef.current = versions.length;
44
+ }, [versions.length]);
45
+ // Only track user-selected version index as state
46
+ const [userSelectedIndex, setUserSelectedIndex] = React.useState(null);
47
+ // Track when a new version has been added to enable flash effect
48
+ const [versionFlash, setVersionFlash] = React.useState(false);
49
+ // Explicitly track regeneration state while waiting for progress to update
50
+ const [pendingRegeneration, setPendingRegeneration] = React.useState(false);
51
+ // Keep track of pending regeneration requests
52
+ const pendingRegenerationRef = React.useRef(false);
53
+ // Track simulated progress for regeneration
54
+ const [simulatedProgress, setSimulatedProgress] = React.useState(null);
55
+ const progressTimerRef = React.useRef(null);
56
+ // Derive the final version index - use user selection if available, otherwise use the document's current version
57
+ const versionIndex = userSelectedIndex !== null ? userSelectedIndex : initialVersionIndex;
58
+ // Custom setter function that manages user selections
59
+ const setVersionIndex = React.useCallback((index) => {
60
+ setUserSelectedIndex(index);
61
+ }, []);
62
+ const fileKey = getCurrentFileKey(document, versionIndex, versions);
63
+ const totalVersions = versions ? versions.length : 0;
64
+ // We now use getPromptInfo directly at render time as a pure function
65
+ // Navigation handlers
66
+ function handlePrevVersion() {
67
+ if (versionIndex > 0) {
68
+ setVersionIndex(versionIndex - 1);
69
+ // Exit edit mode when changing versions
70
+ setEditedPrompt(null);
71
+ }
72
+ }
73
+ function handleNextVersion() {
74
+ if (versionIndex < totalVersions - 1) {
75
+ setVersionIndex(versionIndex + 1);
76
+ // Exit edit mode when changing versions
77
+ setEditedPrompt(null);
78
+ }
79
+ }
80
+ // ESC handling moved to ImgGenModal component
81
+ // Determine which file to use - either the versioned file or the legacy 'image' file
82
+ const currentFile = fileKey && document._files
83
+ ? document._files[fileKey]
84
+ : document._files?.image;
85
+ // Get prompt text early (moved before portal)
86
+ const promptInfo = getPromptInfo(document, versionIndex);
87
+ const promptText = promptInfo.currentPrompt || alt || 'Generated image';
88
+ // State for delete confirmation is managed directly
89
+ // Handle delete confirmation
90
+ function handleDeleteConfirm() {
91
+ if (onDelete) {
92
+ onDelete(document._id);
93
+ }
94
+ }
95
+ // Handle generating a new version
96
+ function handleRegen() {
97
+ // Set pending regeneration flag
98
+ setPendingRegeneration(true);
99
+ pendingRegenerationRef.current = true;
100
+ // Reset and start simulated progress
101
+ setSimulatedProgress(0);
102
+ // Clear any existing timer
103
+ if (progressTimerRef.current) {
104
+ clearInterval(progressTimerRef.current);
105
+ progressTimerRef.current = null;
106
+ }
107
+ // Create a new progress timer that simulates progress from 0 to 99
108
+ const timer = setInterval(() => {
109
+ setSimulatedProgress((prev) => {
110
+ const current = prev ?? 0;
111
+ // Asymptotically approach 99%
112
+ const next = current + (99 - current) * 0.05;
113
+ return next > 99 ? 99 : next;
114
+ });
115
+ }, 500); // Update twice per second for smoother animation
116
+ progressTimerRef.current = timer;
117
+ // const { currentPrompt } = getPromptInfo(document, versionIndex);
118
+ if (editedPrompt !== null) {
119
+ // User has edited the prompt - always use the edited version
120
+ // even if it happens to be the same as the current prompt
121
+ const newPrompt = editedPrompt.trim();
122
+ if (newPrompt) {
123
+ // Always submit the edited prompt as a new prompt
124
+ onPromptEdit?.(document._id, newPrompt);
125
+ }
126
+ else {
127
+ // Empty prompt, just regenerate with existing prompt
128
+ onRegen?.(document._id);
129
+ }
130
+ }
131
+ else {
132
+ // Not in edit mode → regenerate current prompt
133
+ onRegen?.(document._id);
134
+ }
135
+ // Reset user selection when generating a new version
136
+ // This will make the display automatically switch to the latest version when it returns
137
+ setUserSelectedIndex(null);
138
+ // Save the prompt we're generating with
139
+ let promptToGenerate = '';
140
+ if (editedPrompt !== null) {
141
+ promptToGenerate = editedPrompt.trim();
142
+ }
143
+ else {
144
+ const { currentPrompt } = getPromptInfo(document, versionIndex);
145
+ promptToGenerate = currentPrompt;
146
+ }
147
+ setGeneratingPrompt(promptToGenerate);
148
+ // Reset edited prompt since we're no longer in edit mode
149
+ setEditedPrompt(null);
150
+ }
151
+ // Handle prompt editing
152
+ function handlePromptEdit(newPrompt) {
153
+ // Get the current prompt for comparison at the exact time of editing
154
+ const { currentPrompt } = getPromptInfo(document, versionIndex);
155
+ const trimmedPrompt = newPrompt.trim();
156
+ if (trimmedPrompt && trimmedPrompt !== currentPrompt) {
157
+ // Set the edited prompt to the new trimmed value
158
+ setEditedPrompt(trimmedPrompt);
159
+ // Now use handleRegen to handle the regeneration process
160
+ // This ensures the regeneration logic is consistent
161
+ handleRegen();
162
+ }
163
+ else {
164
+ // If the prompt hasn't changed, just exit edit mode
165
+ setEditedPrompt(null);
166
+ }
167
+ }
168
+ // We're not using document.progress as it's always 100
169
+ // Just track the document loading state
170
+ const documentLoading = document.loading ?? false;
171
+ // Reset regeneration state when loading state changes
172
+ React.useEffect(() => {
173
+ if (!documentLoading && pendingRegenerationRef.current) {
174
+ pendingRegenerationRef.current = false;
175
+ setPendingRegeneration(false);
176
+ // Clear the simulated progress timer
177
+ if (progressTimerRef.current) {
178
+ clearInterval(progressTimerRef.current);
179
+ progressTimerRef.current = null;
180
+ }
181
+ // Set simulated progress to 100% to complete the progress bar
182
+ setSimulatedProgress(100);
183
+ // Then clear it after a short delay to hide the progress bar
184
+ setTimeout(() => {
185
+ setSimulatedProgress(null);
186
+ // Also clear the generating prompt
187
+ setGeneratingPrompt(null);
188
+ }, 500);
189
+ }
190
+ }, [documentLoading]);
191
+ // Additional check for document updates to detect version changes
192
+ const documentIdRef = React.useRef(document?._id);
193
+ const versionsLengthRef = React.useRef(versions?.length || 0);
194
+ React.useEffect(() => {
195
+ // Check if a new version was added (version count increased)
196
+ if (versions?.length > versionsLengthRef.current) {
197
+ pendingRegenerationRef.current = false;
198
+ setPendingRegeneration(false);
199
+ // Clear the simulated progress timer
200
+ if (progressTimerRef.current) {
201
+ clearInterval(progressTimerRef.current);
202
+ progressTimerRef.current = null;
203
+ }
204
+ // Set simulated progress to 100% to complete the progress bar
205
+ setSimulatedProgress(100);
206
+ // Then clear it after a short delay to hide the progress bar
207
+ setTimeout(() => {
208
+ setSimulatedProgress(null);
209
+ }, 500);
210
+ }
211
+ // Update refs
212
+ versionsLengthRef.current = versions?.length || 0;
213
+ documentIdRef.current = document?._id;
214
+ }, [document?._id, versions?.length]);
215
+ // Clean up timer on unmount
216
+ React.useEffect(() => {
217
+ return () => {
218
+ if (progressTimerRef.current) {
219
+ clearInterval(progressTimerRef.current);
220
+ progressTimerRef.current = null;
221
+ }
222
+ };
223
+ }, []);
224
+ // Calculate the effective progress - use simulated progress during regeneration if available
225
+ const effectiveProgress = simulatedProgress ?? 100;
226
+ // Is regeneration in progress - either from loading state or pending state
227
+ const isRegenerating = pendingRegeneration || documentLoading === true || loading === true;
228
+ if (!document._files || (!fileKey && !document._files.image)) {
229
+ return React.createElement(ImgGenError, { message: "Missing image file" });
230
+ }
231
+ // Determine which prompt to display:
232
+ // 1. If in edit mode, show the edited prompt
233
+ // 2. If generating, show the generating prompt
234
+ // 3. Otherwise, show the document's prompt
235
+ const displayPrompt = editedPrompt !== null
236
+ ? editedPrompt
237
+ : pendingRegeneration && generatingPrompt !== null
238
+ ? generatingPrompt
239
+ : promptText;
240
+ return (React.createElement("div", { className: combineClasses('imggen-root', className, classes.root), title: displayPrompt },
241
+ React.createElement("div", { className: "imggen-image-container", style: { position: 'relative', width: '100%' } },
242
+ React.createElement("button", { className: "imggen-expand-button", onClick: openFullscreen, title: "Expand image", "aria-label": "Expand image" },
243
+ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", stroke: "currentColor", strokeWidth: "2", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" },
244
+ React.createElement("polyline", { points: "15,5 20,5 20,10" }),
245
+ React.createElement("polyline", { points: "9,19 4,19 4,14" }),
246
+ React.createElement("line", { x1: "20", y1: "5", x2: "14", y2: "11" }),
247
+ React.createElement("line", { x1: "4", y1: "19", x2: "10", y2: "13" }))),
248
+ React.createElement(ImgFile, { file: currentFile, className: combineClasses('imggen-image', classes.image), alt: alt || 'Generated image', style: { width: '100%' } })),
249
+ React.createElement(ImgGenModal, { isOpen: isFullscreen, onClose: closeFullscreen, currentFile: currentFile, alt: alt, promptText: displayPrompt, editedPrompt: editedPrompt, setEditedPrompt: setEditedPrompt, handlePromptEdit: handlePromptEdit, handleDeleteConfirm: handleDeleteConfirm, handlePrevVersion: handlePrevVersion, handleNextVersion: handleNextVersion, handleRegen: handleRegen, versionIndex: versionIndex, totalVersions: totalVersions, progress: effectiveProgress, classes: classes, versionFlash: versionFlash, isRegenerating: isRegenerating, error: error })));
250
+ }
251
+ //# sourceMappingURL=ImgGenDisplay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenDisplay.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,GAAG,EACH,QAAQ,EACR,OAAO,EACP,YAAY,EACZ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aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,GACZ,CACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { ImgGenPlaceholderProps } from './types';
3
+ export declare function ImgGenDisplayPlaceholder({ className, alt, prompt, progress, error, classes, }: ImgGenPlaceholderProps): React.JSX.Element;
@@ -0,0 +1,115 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../../utils/style-utils';
3
+ import { ImageOverlay } from './overlays/ImageOverlay';
4
+ // Component for loading/placeholder state
5
+ export function ImgGenDisplayPlaceholder({ className, alt, prompt, progress, error, classes = defaultClasses, }) {
6
+ // State to track the visible progress width for animation
7
+ const [visibleProgress, setVisibleProgress] = React.useState(0);
8
+ // Animate progress bar when component mounts or progress changes
9
+ React.useEffect(() => {
10
+ // Only start at zero on initial mount, not on every progress update
11
+ if (progress === 0) {
12
+ setVisibleProgress(0);
13
+ }
14
+ // Smoothly animate to the actual progress (or minimum 5%)
15
+ const timer = setTimeout(() => {
16
+ setVisibleProgress(Math.max(5, progress));
17
+ }, 20); // Smaller delay for smoother transitions
18
+ return () => clearTimeout(timer);
19
+ }, [progress]);
20
+ // Extract error information from the error object
21
+ const parseErrorInfo = (error) => {
22
+ const errorMsg = error.message;
23
+ let title = 'Image Generation Failed';
24
+ let body = errorMsg;
25
+ let code = '';
26
+ // Try to parse JSON error details if present
27
+ if (errorMsg.includes('{')) {
28
+ try {
29
+ const jsonStart = errorMsg.indexOf('{');
30
+ const jsonStr = errorMsg.substring(jsonStart);
31
+ const jsonObj = JSON.parse(jsonStr);
32
+ // Get error code if it exists
33
+ if (errorMsg.match(/\d{3}/)) {
34
+ code = errorMsg.match(/\d{3}/)?.[0] || '';
35
+ }
36
+ // Special handling for moderation blocked errors
37
+ if (jsonObj.details?.error?.code === 'moderation_blocked' ||
38
+ jsonObj.code === 'moderation_blocked') {
39
+ // Include error code in title but avoid duplication
40
+ title = code ? `${code} - Failed to generate image` : 'Failed to generate image';
41
+ body =
42
+ 'Your request was rejected as a result of our safety system. Your request may contain content that is not allowed by our safety system.';
43
+ return { title, body, code };
44
+ }
45
+ // Set the title from the main error message
46
+ if (jsonObj.error) {
47
+ title = jsonObj.error;
48
+ }
49
+ // Set the body from the detailed error message
50
+ if (jsonObj.details?.error?.message) {
51
+ body = jsonObj.details.error.message;
52
+ }
53
+ else if (jsonObj.error?.details?.error?.message) {
54
+ body = jsonObj.error.details.error.message;
55
+ }
56
+ }
57
+ catch { }
58
+ }
59
+ return { title, body, code };
60
+ };
61
+ // Check if we're displaying an error
62
+ if (error) {
63
+ return (React.createElement("div", { className: combineClasses('imggen-placeholder', 'imggen-error-container', className, classes.placeholder), style: {
64
+ backgroundColor: '#222', // Dark gray background
65
+ width: '100%',
66
+ height: '100%',
67
+ minHeight: '512px', // Standard image height
68
+ aspectRatio: '1 / 1', // Square aspect ratio like images
69
+ }, "aria-label": alt || 'Error display', role: "img" },
70
+ React.createElement("div", { className: combineClasses('imggen-error', classes.error) }, (() => {
71
+ const { title, body } = parseErrorInfo(error);
72
+ return (React.createElement(React.Fragment, null,
73
+ React.createElement("h3", { className: "imggen-error-title", style: { color: '#ff4d4d', margin: '0 0 0.75rem 0' } }, title),
74
+ React.createElement("p", { className: "imggen-error-message", style: { color: '#e0e0e0', margin: '0' } }, body)));
75
+ })())));
76
+ }
77
+ // Regular placeholder when no error
78
+ return (React.createElement("div", { className: combineClasses('imggen-placeholder', className, classes.placeholder), "aria-label": alt || prompt || 'Image placeholder', role: "img", style: {
79
+ display: 'flex',
80
+ flexDirection: 'column',
81
+ justifyContent: 'center',
82
+ alignItems: 'center',
83
+ textAlign: 'center',
84
+ minHeight: '200px',
85
+ position: 'relative',
86
+ backgroundColor: '#222', // Ensure dark background
87
+ color: '#eee', // Light text color
88
+ } },
89
+ prompt && (React.createElement("div", { className: combineClasses('imggen-progress', classes.progress), style: {
90
+ width: `${visibleProgress}%`,
91
+ position: 'absolute',
92
+ top: 0,
93
+ left: 0,
94
+ }, "aria-hidden": "true" })),
95
+ !prompt && (React.createElement("div", { style: {
96
+ color: '#eee',
97
+ fontSize: 'var(--imggen-font-size)',
98
+ padding: '20px',
99
+ } }, "Waiting for prompt")),
100
+ prompt && !error && (
101
+ /* In production environment, show the styled prompt text */
102
+ React.createElement(React.Fragment, null,
103
+ React.createElement("div", { style: {
104
+ color: '#eee',
105
+ fontSize: 'var(--imggen-font-size)',
106
+ padding: '20px',
107
+ maxWidth: '90%',
108
+ wordBreak: 'break-word',
109
+ fontWeight: 'bold',
110
+ textAlign: 'center',
111
+ } }, prompt),
112
+ React.createElement("div", { style: { display: 'none' } },
113
+ React.createElement(ImageOverlay, { promptText: prompt || '', editedPrompt: null, setEditedPrompt: () => { }, handlePromptEdit: () => { }, handleDeleteConfirm: () => { }, handlePrevVersion: () => { }, handleNextVersion: () => { }, handleRegen: () => { }, versionIndex: 0, totalVersions: 1, classes: classes, showControls: false, showDelete: false }))))));
114
+ }
115
+ //# sourceMappingURL=ImgGenDisplayPlaceholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenDisplayPlaceholder.js","sourceRoot":"","sources":["../../../src/components/ImgGenUtils/ImgGenDisplayPlaceholder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,0CAA0C;AAC1C,MAAM,UAAU,wBAAwB,CAAC,EACvC,SAAS,EACT,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,GAAG,cAAc,GACD;IACvB,0DAA0D;IAC1D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CA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