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.
- package/README.md +1 -0
- package/dist/components/ControlsBar.d.ts +32 -0
- package/dist/components/ControlsBar.js +80 -0
- package/dist/components/ControlsBar.js.map +1 -0
- package/dist/components/ImgGen.css +523 -0
- package/dist/components/ImgGen.d.ts +36 -0
- package/dist/components/ImgGen.js +206 -0
- package/dist/components/ImgGen.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenDisplay.d.ts +3 -0
- package/dist/components/ImgGenUtils/ImgGenDisplay.js +251 -0
- package/dist/components/ImgGenUtils/ImgGenDisplay.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +3 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +115 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +44 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js +127 -0
- package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenError.d.ts +3 -0
- package/dist/components/ImgGenUtils/ImgGenError.js +9 -0
- package/dist/components/ImgGenUtils/ImgGenError.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenModal.d.ts +31 -0
- package/dist/components/ImgGenUtils/ImgGenModal.js +31 -0
- package/dist/components/ImgGenUtils/ImgGenModal.js.map +1 -0
- package/dist/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +7 -0
- package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js +8 -0
- package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
- package/dist/components/ImgGenUtils/index.d.ts +5 -0
- package/dist/components/ImgGenUtils/index.js +8 -0
- package/dist/components/ImgGenUtils/index.js.map +1 -0
- package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +10 -0
- package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +32 -0
- package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +1 -0
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.d.ts +29 -0
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.js +11 -0
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.js.map +1 -0
- package/dist/components/ImgGenUtils/types.d.ts +37 -0
- package/dist/components/ImgGenUtils/types.js +2 -0
- package/dist/components/ImgGenUtils/types.js.map +1 -0
- package/dist/components/ImgGenUtils.d.ts +6 -0
- package/dist/components/ImgGenUtils.js +7 -0
- package/dist/components/ImgGenUtils.js.map +1 -0
- package/dist/components/PromptBar.d.ts +15 -0
- package/dist/components/PromptBar.js +23 -0
- package/dist/components/PromptBar.js.map +1 -0
- package/dist/hooks/image-gen/image-generator.d.ts +14 -0
- package/dist/hooks/image-gen/image-generator.js +78 -0
- package/dist/hooks/image-gen/image-generator.js.map +1 -0
- package/dist/hooks/image-gen/index.d.ts +6 -0
- package/dist/hooks/image-gen/index.js +6 -0
- package/dist/hooks/image-gen/index.js.map +1 -0
- package/dist/hooks/image-gen/types.d.ts +75 -0
- package/dist/hooks/image-gen/types.js +2 -0
- package/dist/hooks/image-gen/types.js.map +1 -0
- package/dist/hooks/image-gen/use-image-gen.d.ts +12 -0
- package/dist/hooks/image-gen/use-image-gen.js +573 -0
- package/dist/hooks/image-gen/use-image-gen.js.map +1 -0
- package/dist/hooks/image-gen/utils.d.ts +61 -0
- package/dist/hooks/image-gen/utils.js +241 -0
- package/dist/hooks/image-gen/utils.js.map +1 -0
- package/dist/hooks/use-image-gen.d.ts +5 -0
- package/dist/hooks/use-image-gen.js +7 -0
- package/dist/hooks/use-image-gen.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/style-loader.d.ts +16 -0
- package/dist/style-loader.js +43 -0
- package/dist/style-loader.js.map +1 -0
- package/dist/utils/style-utils.d.ts +51 -0
- package/dist/utils/style-utils.js +42 -0
- package/dist/utils/style-utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ImageGenOptions } from 'call-ai';
|
|
2
|
+
import { ModuleState, ImageDocument, VersionInfo, PromptEntry } from './types';
|
|
3
|
+
export declare const MODULE_STATE: ModuleState;
|
|
4
|
+
export declare const cleanupRequestKey: (key: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Synchronous hash function to create a key from the prompt string and options
|
|
7
|
+
* @param prompt The prompt string to hash
|
|
8
|
+
* @param options Optional image generation options
|
|
9
|
+
* @returns A hash string for the input
|
|
10
|
+
*/
|
|
11
|
+
export declare function hashInput(prompt: string, options?: ImageGenOptions): string;
|
|
12
|
+
export declare function base64ToFile(base64Data: string, filename: string): File;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a version ID for the file namespace
|
|
15
|
+
* @param versionNumber - The numeric version (1-based)
|
|
16
|
+
* @returns A formatted version string like "v1", "v2", etc.
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateVersionId(versionNumber: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get all version information from a document, or create a default if none exists
|
|
21
|
+
* @param document - The image document
|
|
22
|
+
* @returns Array of version info objects
|
|
23
|
+
*/
|
|
24
|
+
export declare function getVersionsFromDocument(document: Partial<ImageDocument>): {
|
|
25
|
+
versions: Array<VersionInfo>;
|
|
26
|
+
currentVersion: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Generate a prompt key for the prompts namespace
|
|
30
|
+
* @param promptNumber - The numeric prompt (1-based)
|
|
31
|
+
* @returns A formatted prompt string like "p1", "p2", etc.
|
|
32
|
+
*/
|
|
33
|
+
export declare function generatePromptKey(promptNumber: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get all prompt information from a document, or create a default if none exists
|
|
36
|
+
* @param document - The image document
|
|
37
|
+
* @returns Object with prompts record and currentPromptKey
|
|
38
|
+
*/
|
|
39
|
+
export declare function getPromptsFromDocument(document: Partial<ImageDocument>): {
|
|
40
|
+
prompts: Record<string, PromptEntry>;
|
|
41
|
+
currentPromptKey: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Add a new version to an image document
|
|
45
|
+
* @param document - The existing image document
|
|
46
|
+
* @param newImageFile - The new image file to add as a version
|
|
47
|
+
* @param newPrompt - Optional new prompt to use for this version
|
|
48
|
+
* @returns Updated document with the new version added
|
|
49
|
+
*/
|
|
50
|
+
export declare function addNewVersion(document: Partial<ImageDocument>, newImageFile: File, newPrompt?: string): ImageDocument;
|
|
51
|
+
/**
|
|
52
|
+
* Extract only the options properties that matter for image generation
|
|
53
|
+
* to avoid unnecessary re-renders or regenerations
|
|
54
|
+
*/
|
|
55
|
+
export declare function getRelevantOptions(options?: ImageGenOptions): Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Generate a safe filename based on prompt text and timestamp
|
|
58
|
+
* @param promptText - The prompt text to include in the filename
|
|
59
|
+
* @returns A formatted filename like "prompt-text-20250518-2117.png"
|
|
60
|
+
*/
|
|
61
|
+
export declare function generateSafeFilename(promptText: string): string;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Module-level state for tracking and preventing duplicate calls
|
|
2
|
+
export const MODULE_STATE = {
|
|
3
|
+
pendingImageGenCalls: new Map(),
|
|
4
|
+
pendingPrompts: new Set(),
|
|
5
|
+
processingRequests: new Set(),
|
|
6
|
+
requestTimestamps: new Map(),
|
|
7
|
+
requestCounter: 0,
|
|
8
|
+
createdDocuments: new Map(), // Track document IDs created for each generation request
|
|
9
|
+
pendingDocumentCreations: new Map(), // Track document creation promises
|
|
10
|
+
};
|
|
11
|
+
// Helper to safely remove a key from all tracking collections
|
|
12
|
+
export const cleanupRequestKey = (key) => {
|
|
13
|
+
MODULE_STATE.pendingImageGenCalls.delete(key);
|
|
14
|
+
MODULE_STATE.processingRequests.delete(key);
|
|
15
|
+
MODULE_STATE.pendingPrompts.delete(key);
|
|
16
|
+
// We also clean up the document creation promise to prevent memory leaks
|
|
17
|
+
MODULE_STATE.pendingDocumentCreations.delete(key);
|
|
18
|
+
// Keep the createdDocuments entry as it's the actual deduplication map
|
|
19
|
+
// But do clean up the timestamp to prevent memory leaks
|
|
20
|
+
MODULE_STATE.requestTimestamps.delete(key);
|
|
21
|
+
};
|
|
22
|
+
// Periodically clean up stale requests (every minute)
|
|
23
|
+
setInterval(() => {
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
for (const [key, timestamp] of MODULE_STATE.requestTimestamps.entries()) {
|
|
26
|
+
if (now - timestamp > 5 * 60 * 1000) {
|
|
27
|
+
// For stale requests that are over 5 minutes old,
|
|
28
|
+
// also remove them from createdDocuments tracking
|
|
29
|
+
MODULE_STATE.createdDocuments.delete(key);
|
|
30
|
+
// Clean up all other state
|
|
31
|
+
cleanupRequestKey(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, 60000); // Check every minute
|
|
35
|
+
/**
|
|
36
|
+
* Synchronous hash function to create a key from the prompt string and options
|
|
37
|
+
* @param prompt The prompt string to hash
|
|
38
|
+
* @param options Optional image generation options
|
|
39
|
+
* @returns A hash string for the input
|
|
40
|
+
*/
|
|
41
|
+
export function hashInput(prompt, options) {
|
|
42
|
+
// Create a string that includes both prompt and relevant options
|
|
43
|
+
const inputString = JSON.stringify({
|
|
44
|
+
prompt,
|
|
45
|
+
// Only include relevant options properties to avoid unnecessary regeneration
|
|
46
|
+
options: options
|
|
47
|
+
? {
|
|
48
|
+
size: options.size,
|
|
49
|
+
quality: options.quality,
|
|
50
|
+
model: options.model,
|
|
51
|
+
style: options.style,
|
|
52
|
+
}
|
|
53
|
+
: undefined,
|
|
54
|
+
});
|
|
55
|
+
// Use a fast non-crypto hash for immediate results (FNV-1a algorithm)
|
|
56
|
+
let hash = 2166136261; // FNV offset basis
|
|
57
|
+
for (let i = 0; i < inputString.length; i++) {
|
|
58
|
+
hash ^= inputString.charCodeAt(i);
|
|
59
|
+
// Multiply by the FNV prime (32-bit)
|
|
60
|
+
hash = Math.imul(hash, 16777619);
|
|
61
|
+
}
|
|
62
|
+
// Convert to hex string and take first 12 chars
|
|
63
|
+
const hashHex = (hash >>> 0).toString(16).padStart(8, '0');
|
|
64
|
+
const requestId = hashHex.slice(0, 12);
|
|
65
|
+
// Add a timestamp to make the ID unique even for identical requests
|
|
66
|
+
return `${requestId}-${Date.now().toString(36)}`;
|
|
67
|
+
}
|
|
68
|
+
// Convert base64 to File object
|
|
69
|
+
export function base64ToFile(base64Data, filename) {
|
|
70
|
+
const byteString = atob(base64Data);
|
|
71
|
+
const ab = new ArrayBuffer(byteString.length);
|
|
72
|
+
const ia = new Uint8Array(ab);
|
|
73
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
74
|
+
ia[i] = byteString.charCodeAt(i);
|
|
75
|
+
}
|
|
76
|
+
const blob = new Blob([ab], { type: 'image/png' });
|
|
77
|
+
return new File([blob], filename, { type: 'image/png' });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generate a version ID for the file namespace
|
|
81
|
+
* @param versionNumber - The numeric version (1-based)
|
|
82
|
+
* @returns A formatted version string like "v1", "v2", etc.
|
|
83
|
+
*/
|
|
84
|
+
export function generateVersionId(versionNumber) {
|
|
85
|
+
return `v${versionNumber}`;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all version information from a document, or create a default if none exists
|
|
89
|
+
* @param document - The image document
|
|
90
|
+
* @returns Array of version info objects
|
|
91
|
+
*/
|
|
92
|
+
export function getVersionsFromDocument(document) {
|
|
93
|
+
// Check if document has proper version structure
|
|
94
|
+
if (document?.versions && document.versions.length > 0) {
|
|
95
|
+
return {
|
|
96
|
+
versions: document.versions,
|
|
97
|
+
currentVersion: document.currentVersion ?? document.versions.length,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Legacy document with just an 'image' file - convert to version format
|
|
101
|
+
if (document?._files?.image) {
|
|
102
|
+
return {
|
|
103
|
+
versions: [{ id: 'v1', created: document.created || Date.now() }],
|
|
104
|
+
currentVersion: 1,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// No versions found
|
|
108
|
+
return { versions: [], currentVersion: 0 };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Generate a prompt key for the prompts namespace
|
|
112
|
+
* @param promptNumber - The numeric prompt (1-based)
|
|
113
|
+
* @returns A formatted prompt string like "p1", "p2", etc.
|
|
114
|
+
*/
|
|
115
|
+
export function generatePromptKey(promptNumber) {
|
|
116
|
+
return `p${promptNumber}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get all prompt information from a document, or create a default if none exists
|
|
120
|
+
* @param document - The image document
|
|
121
|
+
* @returns Object with prompts record and currentPromptKey
|
|
122
|
+
*/
|
|
123
|
+
export function getPromptsFromDocument(document) {
|
|
124
|
+
// Check if document has proper prompts structure
|
|
125
|
+
if (document?.prompts && document?.currentPromptKey) {
|
|
126
|
+
return {
|
|
127
|
+
prompts: document.prompts,
|
|
128
|
+
currentPromptKey: document.currentPromptKey,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Legacy document with just a 'prompt' string - convert to prompts format
|
|
132
|
+
if (document?.prompt) {
|
|
133
|
+
return {
|
|
134
|
+
prompts: {
|
|
135
|
+
p1: { text: document.prompt, created: document.created || Date.now() },
|
|
136
|
+
},
|
|
137
|
+
currentPromptKey: 'p1',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// No prompts found
|
|
141
|
+
return { prompts: {}, currentPromptKey: '' };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add a new version to an image document
|
|
145
|
+
* @param document - The existing image document
|
|
146
|
+
* @param newImageFile - The new image file to add as a version
|
|
147
|
+
* @param newPrompt - Optional new prompt to use for this version
|
|
148
|
+
* @returns Updated document with the new version added
|
|
149
|
+
*/
|
|
150
|
+
export function addNewVersion(document, newImageFile, newPrompt) {
|
|
151
|
+
// Get existing versions or initialize
|
|
152
|
+
const { versions } = getVersionsFromDocument(document);
|
|
153
|
+
const versionCount = versions.length + 1;
|
|
154
|
+
const newVersionId = generateVersionId(versionCount);
|
|
155
|
+
// Get existing prompts or initialize
|
|
156
|
+
const { prompts, currentPromptKey } = getPromptsFromDocument(document);
|
|
157
|
+
// Handle prompt versioning
|
|
158
|
+
const updatedPrompts = { ...prompts };
|
|
159
|
+
let updatedCurrentPromptKey = currentPromptKey;
|
|
160
|
+
// If a new prompt is provided and it's different from the current one, create a new prompt version
|
|
161
|
+
if (newPrompt && (!currentPromptKey || newPrompt !== prompts[currentPromptKey]?.text)) {
|
|
162
|
+
const promptCount = Object.keys(updatedPrompts).length + 1;
|
|
163
|
+
updatedCurrentPromptKey = generatePromptKey(promptCount);
|
|
164
|
+
updatedPrompts[updatedCurrentPromptKey] = {
|
|
165
|
+
text: newPrompt,
|
|
166
|
+
created: Date.now(),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
else if (!updatedCurrentPromptKey && document.prompt) {
|
|
170
|
+
// Legacy migration - create p1 from document.prompt
|
|
171
|
+
updatedCurrentPromptKey = 'p1';
|
|
172
|
+
updatedPrompts['p1'] = {
|
|
173
|
+
text: document.prompt,
|
|
174
|
+
created: document.created || Date.now(),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
// Copy existing files and add the new version
|
|
178
|
+
const updatedFiles = { ...(document._files || {}) };
|
|
179
|
+
updatedFiles[newVersionId] = newImageFile;
|
|
180
|
+
// Handle legacy documents by migrating 'image' to 'v1' if needed
|
|
181
|
+
if (versionCount === 1 && document._files?.image) {
|
|
182
|
+
updatedFiles['v1'] = document._files.image;
|
|
183
|
+
delete updatedFiles.image;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
...document,
|
|
187
|
+
currentVersion: versionCount - 1, // Make it 0-based
|
|
188
|
+
versions: [
|
|
189
|
+
...versions,
|
|
190
|
+
{
|
|
191
|
+
id: newVersionId,
|
|
192
|
+
created: Date.now(),
|
|
193
|
+
promptKey: updatedCurrentPromptKey,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
prompts: updatedPrompts,
|
|
197
|
+
currentPromptKey: updatedCurrentPromptKey,
|
|
198
|
+
_files: updatedFiles,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Extract only the options properties that matter for image generation
|
|
203
|
+
* to avoid unnecessary re-renders or regenerations
|
|
204
|
+
*/
|
|
205
|
+
export function getRelevantOptions(options) {
|
|
206
|
+
if (!options)
|
|
207
|
+
return {};
|
|
208
|
+
const relevantOptions = {};
|
|
209
|
+
if (options.size)
|
|
210
|
+
relevantOptions.size = options.size;
|
|
211
|
+
if (options.quality)
|
|
212
|
+
relevantOptions.quality = options.quality;
|
|
213
|
+
if (options.model)
|
|
214
|
+
relevantOptions.model = options.model;
|
|
215
|
+
if (options.style)
|
|
216
|
+
relevantOptions.style = options.style;
|
|
217
|
+
return relevantOptions;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Generate a safe filename based on prompt text and timestamp
|
|
221
|
+
* @param promptText - The prompt text to include in the filename
|
|
222
|
+
* @returns A formatted filename like "prompt-text-20250518-2117.png"
|
|
223
|
+
*/
|
|
224
|
+
export function generateSafeFilename(promptText) {
|
|
225
|
+
// Limit prompt length to avoid extremely long filenames
|
|
226
|
+
const maxPromptChars = 40;
|
|
227
|
+
// Clean the prompt by removing special characters and converting to lowercase
|
|
228
|
+
const cleanedPrompt = promptText
|
|
229
|
+
.toLowerCase()
|
|
230
|
+
.replace(/[^a-z0-9\s-]/g, '') // Keep only alphanumeric, spaces, and hyphens
|
|
231
|
+
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
232
|
+
.substring(0, maxPromptChars) // Limit length
|
|
233
|
+
.replace(/-+$/g, ''); // Remove trailing hyphens
|
|
234
|
+
// Generate date part in format YYYYMMDD-HHMM
|
|
235
|
+
const now = new Date();
|
|
236
|
+
const datePart = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`;
|
|
237
|
+
const timePart = `${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}`;
|
|
238
|
+
// Construct filename
|
|
239
|
+
return `${cleanedPrompt}-${datePart}-${timePart}.png`;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/hooks/image-gen/utils.ts"],"names":[],"mappings":"AAGA,iEAAiE;AACjE,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,oBAAoB,EAAE,IAAI,GAAG,EAAE;IAC/B,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,kBAAkB,EAAE,IAAI,GAAG,EAAE;IAC7B,iBAAiB,EAAE,IAAI,GAAG,EAAE;IAC5B,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,yDAAyD;IACtF,wBAAwB,EAAE,IAAI,GAAG,EAAE,EAAE,mCAAmC;CACzE,CAAC;AAEF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC/C,YAAY,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9C,YAAY,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxC,yEAAyE;IACzE,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClD,uEAAuE;IACvE,wDAAwD;IACxD,YAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;A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;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACrD,wDAAwD;IACxD,MAAM,cAAc,GAAG,EAAE,CAAC;IAE1B,8EAA8E;IAC9E,MAAM,aAAa,GAAG,UAAU;SAC7B,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,8CAA8C;SAC3E,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,8BAA8B;SACnD,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,eAAe;SAC5C,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,0BAA0B;IAElD,6CAA6C;IAC7C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAC/H,MAAM,QAAQ,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAE1G,qBAAqB;IACrB,OAAO,GAAG,aAAa,IAAI,QAAQ,IAAI,QAAQ,MAAM,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is a barrel file that re-exports from the modular structure.
|
|
3
|
+
* The implementation has been split into smaller files for better maintainability.
|
|
4
|
+
*/
|
|
5
|
+
// Re-export everything from the new modular structure
|
|
6
|
+
export * from './image-gen';
|
|
7
|
+
//# sourceMappingURL=use-image-gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-image-gen.js","sourceRoot":"","sources":["../../src/hooks/use-image-gen.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sDAAsD;AACtD,cAAc,aAAa,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { imageGen, type ImageGenOptions, type ImageResponse } from 'call-ai';
|
|
2
|
+
export { imageGen, type ImageGenOptions, type ImageResponse };
|
|
3
|
+
export { default as ImgGen } from './components/ImgGen';
|
|
4
|
+
export type { ImgGenProps } from './components/ImgGen';
|
|
5
|
+
export type { ImgGenClasses } from './utils/style-utils';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAA4C,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAA4C,CAAC;AAE9D,0BAA0B;AAC1B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional utility to automatically load the use-vibes CSS styles
|
|
3
|
+
* This is an alternative to manually adding a <link> tag
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```js
|
|
7
|
+
* import { bootstrapUseVibesStyles } from 'use-vibes/style-loader';
|
|
8
|
+
* // CSS styles are now automatically loaded
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Automatically injects the use-vibes CSS into the document head
|
|
13
|
+
* Only runs in browser environments and only injects the styles once
|
|
14
|
+
* @returns true if styles were injected, false if already present or not in browser
|
|
15
|
+
*/
|
|
16
|
+
export declare function bootstrapUseVibesStyles(): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional utility to automatically load the use-vibes CSS styles
|
|
3
|
+
* This is an alternative to manually adding a <link> tag
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```js
|
|
7
|
+
* import { bootstrapUseVibesStyles } from 'use-vibes/style-loader';
|
|
8
|
+
* // CSS styles are now automatically loaded
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Automatically injects the use-vibes CSS into the document head
|
|
13
|
+
* Only runs in browser environments and only injects the styles once
|
|
14
|
+
* @returns true if styles were injected, false if already present or not in browser
|
|
15
|
+
*/
|
|
16
|
+
export function bootstrapUseVibesStyles() {
|
|
17
|
+
// Skip in non-browser environments
|
|
18
|
+
if (typeof document === 'undefined') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const cssPath = './components/ImgGen.css';
|
|
22
|
+
// Check if already loaded
|
|
23
|
+
if (document.querySelector(`link[data-use-vibes-css]`)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
// Create link element
|
|
28
|
+
const link = document.createElement('link');
|
|
29
|
+
link.rel = 'stylesheet';
|
|
30
|
+
link.href = new URL(cssPath, import.meta.url).toString();
|
|
31
|
+
link.setAttribute('data-use-vibes-css', 'true');
|
|
32
|
+
// Append to head
|
|
33
|
+
document.head.appendChild(link);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.warn('Failed to auto-load use-vibes styles:', e);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Auto-execute when this module is imported
|
|
42
|
+
bootstrapUseVibesStyles();
|
|
43
|
+
//# sourceMappingURL=style-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-loader.js","sourceRoot":"","sources":["../src/style-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,mCAAmC;IACnC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,yBAAyB,CAAC;IAE1C,0BAA0B;IAC1B,IAAI,QAAQ,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,sBAAsB;QACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAEhD,iBAAiB;QACjB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,uCAAuC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,4CAA4C;AAC5C,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for managing component styling
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Combines multiple class names into a single string, filtering out falsy values
|
|
6
|
+
* Also adds backward compatibility class names for testing and legacy support
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Returns "foo bar baz"
|
|
10
|
+
* combineClasses('foo', 'bar', 'baz')
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Returns "btn btn-primary"
|
|
14
|
+
* combineClasses('btn', condition && 'btn-primary', false && 'btn-large')
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Returns "imggen-root img-gen-container" (with legacy class name)
|
|
18
|
+
* combineClasses('imggen-root', classes.root)
|
|
19
|
+
*/
|
|
20
|
+
export declare function combineClasses(...classes: (string | boolean | null | undefined)[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Type definitions for component classes props pattern
|
|
23
|
+
*/
|
|
24
|
+
export interface ImgGenClasses {
|
|
25
|
+
/** Root container class */
|
|
26
|
+
root?: string;
|
|
27
|
+
/** Image container class */
|
|
28
|
+
container?: string;
|
|
29
|
+
/** Image element class */
|
|
30
|
+
image?: string;
|
|
31
|
+
/** Overlay panel class */
|
|
32
|
+
overlay?: string;
|
|
33
|
+
/** Progress indicator class */
|
|
34
|
+
progress?: string;
|
|
35
|
+
/** Placeholder element class */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** Error container class */
|
|
38
|
+
error?: string;
|
|
39
|
+
/** Control buttons container class */
|
|
40
|
+
controls?: string;
|
|
41
|
+
/** Button class */
|
|
42
|
+
button?: string;
|
|
43
|
+
/** Prompt container class */
|
|
44
|
+
prompt?: string;
|
|
45
|
+
/** Delete confirmation overlay class */
|
|
46
|
+
deleteOverlay?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Default empty classes object
|
|
50
|
+
*/
|
|
51
|
+
export declare const defaultClasses: ImgGenClasses;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for managing component styling
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Combines multiple class names into a single string, filtering out falsy values
|
|
6
|
+
* Also adds backward compatibility class names for testing and legacy support
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Returns "foo bar baz"
|
|
10
|
+
* combineClasses('foo', 'bar', 'baz')
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Returns "btn btn-primary"
|
|
14
|
+
* combineClasses('btn', condition && 'btn-primary', false && 'btn-large')
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Returns "imggen-root img-gen-container" (with legacy class name)
|
|
18
|
+
* combineClasses('imggen-root', classes.root)
|
|
19
|
+
*/
|
|
20
|
+
export function combineClasses(...classes) {
|
|
21
|
+
// Filter out falsy values
|
|
22
|
+
const validClasses = classes.filter(Boolean);
|
|
23
|
+
// Add backward compatibility classes (img-gen-* format)
|
|
24
|
+
const allClasses = [...validClasses];
|
|
25
|
+
// For each imggen-* class, add a corresponding img-gen-* class for backward compatibility
|
|
26
|
+
validClasses.forEach((cls) => {
|
|
27
|
+
if (cls.startsWith('imggen-')) {
|
|
28
|
+
// Convert imggen-root to img-gen-root, etc.
|
|
29
|
+
const legacyClass = cls.replace('imggen-', 'img-gen-');
|
|
30
|
+
// Only add if not already present
|
|
31
|
+
if (!allClasses.includes(legacyClass)) {
|
|
32
|
+
allClasses.push(legacyClass);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return allClasses.join(' ');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default empty classes object
|
|
40
|
+
*/
|
|
41
|
+
export const defaultClasses = {};
|
|
42
|
+
//# sourceMappingURL=style-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-utils.js","sourceRoot":"","sources":["../../src/utils/style-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,GAAG,OAAgD;IAChF,0BAA0B;IAC1B,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC;IAEzD,wDAAwD;IACxD,MAAM,UAAU,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;IAErC,0FAA0F;IAC1F,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3B,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,4CAA4C;YAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACvD,kCAAkC;YAClC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AA8BD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,EAAE,CAAC"}
|