use-vibes 0.5.7 → 0.11.0-dev-preview1
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 +0 -7
- package/components/ControlsBar.d.ts +20 -0
- package/components/ControlsBar.js +80 -0
- package/components/ControlsBar.js.map +1 -0
- package/{dist/components → components}/ImgGen.css +21 -13
- package/components/ImgGen.d.ts +25 -0
- package/{dist/components → components}/ImgGen.js +25 -119
- package/components/ImgGen.js.map +1 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenDisplay.d.ts +2 -2
- package/components/ImgGenUtils/ImgGenDisplay.js +192 -0
- package/components/ImgGenUtils/ImgGenDisplay.js.map +1 -0
- package/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +3 -0
- package/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +107 -0
- package/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
- package/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +27 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenDisplayUtils.js +4 -36
- package/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
- package/components/ImgGenUtils/ImgGenError.d.ts +3 -0
- package/components/ImgGenUtils/ImgGenError.js +6 -0
- package/components/ImgGenUtils/ImgGenError.js.map +1 -0
- package/components/ImgGenUtils/ImgGenFileDrop.d.ts +12 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenFileDrop.js +2 -9
- package/components/ImgGenUtils/ImgGenFileDrop.js.map +1 -0
- package/components/ImgGenUtils/ImgGenModal.d.ts +24 -0
- package/components/ImgGenUtils/ImgGenModal.js +28 -0
- package/components/ImgGenUtils/ImgGenModal.js.map +1 -0
- package/components/ImgGenUtils/ImgGenModeUtils.d.ts +9 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenModeUtils.js +0 -15
- package/components/ImgGenUtils/ImgGenModeUtils.js.map +1 -0
- package/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +12 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenPromptWaiting.js +3 -15
- package/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
- package/components/ImgGenUtils/ImgGenUploadWaiting.d.ts +17 -0
- package/{dist/components → components}/ImgGenUtils/ImgGenUploadWaiting.js +3 -52
- package/components/ImgGenUtils/ImgGenUploadWaiting.js.map +1 -0
- package/components/ImgGenUtils/index.d.ts +6 -0
- package/components/ImgGenUtils/index.js +7 -0
- package/components/ImgGenUtils/index.js.map +1 -0
- package/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +9 -0
- package/{dist/components → components}/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +8 -10
- package/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +1 -0
- package/components/ImgGenUtils/overlays/ImageOverlay.d.ts +22 -0
- package/components/ImgGenUtils/overlays/ImageOverlay.js +8 -0
- package/components/ImgGenUtils/overlays/ImageOverlay.js.map +1 -0
- package/components/ImgGenUtils/types.d.ts +29 -0
- package/components/ImgGenUtils/types.js.map +1 -0
- package/components/ImgGenUtils.d.ts +2 -0
- package/components/ImgGenUtils.js +3 -0
- package/components/ImgGenUtils.js.map +1 -0
- package/components/PromptBar.d.ts +11 -0
- package/components/PromptBar.js +16 -0
- package/components/PromptBar.js.map +1 -0
- package/hooks/image-gen/image-generator.d.ts +11 -0
- package/{dist/hooks → hooks}/image-gen/image-generator.js +2 -42
- package/hooks/image-gen/image-generator.js.map +1 -0
- package/hooks/image-gen/index.d.ts +7 -0
- package/hooks/image-gen/index.js +6 -0
- package/hooks/image-gen/index.js.map +1 -0
- package/hooks/image-gen/types.d.ts +66 -0
- package/{dist/hooks → hooks}/image-gen/types.js.map +1 -1
- package/hooks/image-gen/use-image-gen.d.ts +4 -0
- package/hooks/image-gen/use-image-gen.js +544 -0
- package/hooks/image-gen/use-image-gen.js.map +1 -0
- package/hooks/image-gen/utils.d.ts +20 -0
- package/{dist/hooks → hooks}/image-gen/utils.js +11 -93
- package/hooks/image-gen/utils.js.map +1 -0
- package/hooks/use-image-gen.d.ts +1 -0
- package/hooks/use-image-gen.js +2 -0
- package/hooks/use-image-gen.js.map +1 -0
- package/index.d.ts +20 -0
- package/index.js +21 -0
- package/index.js.map +1 -0
- package/package.json +23 -24
- package/style-loader.d.ts +1 -0
- package/style-loader.js +23 -0
- package/style-loader.js.map +1 -0
- package/tsconfig.json +18 -0
- package/{dist/utils → utils}/base64.js +0 -4
- package/utils/base64.js.map +1 -0
- package/{dist/utils → utils}/debug.js +0 -1
- package/utils/debug.js.map +1 -0
- package/utils/style-utils.d.ts +17 -0
- package/utils/style-utils.js +15 -0
- package/utils/style-utils.js.map +1 -0
- package/dist/components/ControlsBar.d.ts +0 -32
- package/dist/components/ControlsBar.js +0 -109
- package/dist/components/ControlsBar.js.map +0 -1
- package/dist/components/ImgGen.d.ts +0 -42
- package/dist/components/ImgGen.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenDisplay.js +0 -264
- package/dist/components/ImgGenUtils/ImgGenDisplay.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +0 -3
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +0 -125
- package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +0 -44
- package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenError.d.ts +0 -3
- package/dist/components/ImgGenUtils/ImgGenError.js +0 -9
- package/dist/components/ImgGenUtils/ImgGenError.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenFileDrop.d.ts +0 -21
- package/dist/components/ImgGenUtils/ImgGenFileDrop.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenModal.d.ts +0 -31
- package/dist/components/ImgGenUtils/ImgGenModal.js +0 -34
- package/dist/components/ImgGenUtils/ImgGenModal.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenModeUtils.d.ts +0 -16
- package/dist/components/ImgGenUtils/ImgGenModeUtils.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +0 -17
- package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js.map +0 -1
- package/dist/components/ImgGenUtils/ImgGenUploadWaiting.d.ts +0 -30
- package/dist/components/ImgGenUtils/ImgGenUploadWaiting.js.map +0 -1
- package/dist/components/ImgGenUtils/index.d.ts +0 -6
- package/dist/components/ImgGenUtils/index.js +0 -9
- package/dist/components/ImgGenUtils/index.js.map +0 -1
- package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +0 -10
- package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +0 -1
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.d.ts +0 -29
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.js +0 -11
- package/dist/components/ImgGenUtils/overlays/ImageOverlay.js.map +0 -1
- package/dist/components/ImgGenUtils/types.d.ts +0 -43
- package/dist/components/ImgGenUtils/types.js.map +0 -1
- package/dist/components/ImgGenUtils.d.ts +0 -6
- package/dist/components/ImgGenUtils.js +0 -7
- package/dist/components/ImgGenUtils.js.map +0 -1
- package/dist/components/PromptBar.d.ts +0 -15
- package/dist/components/PromptBar.js +0 -23
- package/dist/components/PromptBar.js.map +0 -1
- package/dist/hooks/image-gen/image-generator.d.ts +0 -18
- package/dist/hooks/image-gen/image-generator.js.map +0 -1
- package/dist/hooks/image-gen/index.d.ts +0 -6
- package/dist/hooks/image-gen/index.js +0 -6
- package/dist/hooks/image-gen/index.js.map +0 -1
- package/dist/hooks/image-gen/types.d.ts +0 -75
- package/dist/hooks/image-gen/use-image-gen.d.ts +0 -12
- package/dist/hooks/image-gen/use-image-gen.js +0 -675
- package/dist/hooks/image-gen/use-image-gen.js.map +0 -1
- package/dist/hooks/image-gen/utils.d.ts +0 -61
- package/dist/hooks/image-gen/utils.js.map +0 -1
- package/dist/hooks/use-image-gen.d.ts +0 -5
- package/dist/hooks/use-image-gen.js +0 -7
- package/dist/hooks/use-image-gen.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/style-loader.d.ts +0 -16
- package/dist/style-loader.js +0 -43
- package/dist/style-loader.js.map +0 -1
- package/dist/utils/base64.js.map +0 -1
- package/dist/utils/debug.js.map +0 -1
- package/dist/utils/style-utils.d.ts +0 -55
- package/dist/utils/style-utils.js +0 -42
- package/dist/utils/style-utils.js.map +0 -1
- /package/{dist/components → components}/ImgGenUtils/types.js +0 -0
- /package/{dist/hooks → hooks}/image-gen/types.js +0 -0
- /package/{dist/utils → utils}/base64.d.ts +0 -0
- /package/{dist/utils → utils}/debug.d.ts +0 -0
|
@@ -1,33 +1,19 @@
|
|
|
1
1
|
import { imageGen as originalImageGen, } from 'call-ai';
|
|
2
|
-
import { MODULE_STATE, getRelevantOptions } from './utils';
|
|
3
|
-
/**
|
|
4
|
-
* Wrapper for imageGen that prevents duplicate calls
|
|
5
|
-
* This function maintains a module-level cache to prevent duplicate API calls
|
|
6
|
-
*/
|
|
2
|
+
import { MODULE_STATE, getRelevantOptions } from './utils.js';
|
|
7
3
|
export async function imageGen(prompt, options) {
|
|
8
|
-
// Get the relevant options to form a stable key
|
|
9
4
|
const relevantOptions = getRelevantOptions(options);
|
|
10
|
-
// Track regeneration requests when an ID is provided
|
|
11
|
-
// This was previously used for logging, which has been removed
|
|
12
|
-
// Create a stable key for the request cache
|
|
13
|
-
// Include regeneration ID if present to ensure unique keys for regeneration requests
|
|
14
5
|
const stableKey = options?._regenerationId
|
|
15
6
|
? `${prompt}-${JSON.stringify(relevantOptions)}-regen-${options._regenerationId}`
|
|
16
7
|
: `${prompt}-${JSON.stringify(relevantOptions)}`;
|
|
17
|
-
// Create a unique ID for this specific request instance (for logging)
|
|
18
8
|
const requestId = ++MODULE_STATE.requestCounter;
|
|
19
|
-
// Check if this prompt+options combination is already being processed
|
|
20
9
|
if (MODULE_STATE.pendingPrompts.has(stableKey)) {
|
|
21
|
-
// Return the existing promise for this prompt+options combination
|
|
22
10
|
if (MODULE_STATE.pendingImageGenCalls.has(stableKey)) {
|
|
23
11
|
return MODULE_STATE.pendingImageGenCalls.get(stableKey);
|
|
24
12
|
}
|
|
25
13
|
}
|
|
26
|
-
// Mark this prompt+options as being processed
|
|
27
14
|
MODULE_STATE.pendingPrompts.add(stableKey);
|
|
28
15
|
MODULE_STATE.processingRequests.add(stableKey);
|
|
29
16
|
MODULE_STATE.requestTimestamps.set(stableKey, Date.now());
|
|
30
|
-
// Log complete request details if debug is true
|
|
31
17
|
if (options?.debug) {
|
|
32
18
|
console.log(`[ImgGen Debug] Generating image with prompt: "${prompt}"`, {
|
|
33
19
|
requestId,
|
|
@@ -38,23 +24,18 @@ export async function imageGen(prompt, options) {
|
|
|
38
24
|
}
|
|
39
25
|
let promise;
|
|
40
26
|
try {
|
|
41
|
-
// Check if we need to extract images from document
|
|
42
27
|
const enhancedOptions = { ...options };
|
|
43
|
-
// Extract input files from document._files if present
|
|
44
28
|
if (!enhancedOptions.images && enhancedOptions.document && enhancedOptions.document._files) {
|
|
45
29
|
const imageFiles = [];
|
|
46
|
-
// Look for files with keys starting with 'in' (input files) or the 'original' file
|
|
47
30
|
for (const key of Object.keys(enhancedOptions.document._files)) {
|
|
48
31
|
if (key.startsWith('in') || key === 'original') {
|
|
49
32
|
const file = enhancedOptions.document._files[key];
|
|
50
33
|
if (file) {
|
|
51
|
-
// Handle both direct File objects and Fireproof's DocFileMeta
|
|
52
34
|
if (file instanceof File) {
|
|
53
35
|
imageFiles.push(file);
|
|
54
36
|
}
|
|
55
37
|
else if (typeof file.file === 'function') {
|
|
56
38
|
try {
|
|
57
|
-
// For DocFileMeta objects, we need to call the file() method
|
|
58
39
|
const fileObj = await file.file();
|
|
59
40
|
imageFiles.push(fileObj);
|
|
60
41
|
}
|
|
@@ -65,7 +46,6 @@ export async function imageGen(prompt, options) {
|
|
|
65
46
|
}
|
|
66
47
|
}
|
|
67
48
|
}
|
|
68
|
-
// If we found image files, add them to the images option
|
|
69
49
|
if (imageFiles.length > 0) {
|
|
70
50
|
enhancedOptions.images = imageFiles;
|
|
71
51
|
if (enhancedOptions.debug) {
|
|
@@ -76,59 +56,42 @@ export async function imageGen(prompt, options) {
|
|
|
76
56
|
}
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
|
-
// Direct import from call-ai - this works consistently with test mocks
|
|
80
59
|
promise = originalImageGen(prompt, enhancedOptions);
|
|
81
60
|
}
|
|
82
61
|
catch (e) {
|
|
83
62
|
console.error(`[ImgGen Debug] Error with imageGen for request #${requestId}:`, e);
|
|
84
63
|
promise = Promise.reject(e);
|
|
85
64
|
}
|
|
86
|
-
// Store the promise so other requests for the same prompt+options can use it
|
|
87
65
|
MODULE_STATE.pendingImageGenCalls.set(stableKey, promise);
|
|
88
|
-
// Clean up after the promise resolves or rejects
|
|
89
66
|
promise
|
|
90
67
|
.then((response) => {
|
|
91
|
-
// Remove from processing set but KEEP in pendingPrompts to ensure deduplication persists
|
|
92
|
-
// until page reload
|
|
93
68
|
MODULE_STATE.processingRequests.delete(stableKey);
|
|
94
69
|
return response;
|
|
95
70
|
})
|
|
96
71
|
.catch((error) => {
|
|
97
72
|
console.error(`[ImgGen Debug] Request #${requestId} failed [key:${stableKey.slice(0, 12)}...]: ${error}`);
|
|
98
|
-
// Even on failure, we'll keep the key in pendingPrompts to prevent repeated failures
|
|
99
|
-
// but remove it from processing to allow potential retries after page reload
|
|
100
73
|
MODULE_STATE.processingRequests.delete(stableKey);
|
|
101
74
|
return Promise.reject(error);
|
|
102
75
|
});
|
|
103
76
|
return promise;
|
|
104
77
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Create a wrapper function for generating images with logging and tracking
|
|
107
|
-
*/
|
|
108
78
|
export function createImageGenerator(requestHash) {
|
|
109
79
|
return async (promptText, genOptions) => {
|
|
110
|
-
|
|
111
|
-
JSON.stringify(getRelevantOptions(genOptions)); // Still generate to maintain behavior
|
|
112
|
-
// Check if the document has input files that should be included
|
|
80
|
+
JSON.stringify(getRelevantOptions(genOptions));
|
|
113
81
|
const debug = genOptions?.debug;
|
|
114
|
-
// Look for input files in the document
|
|
115
82
|
if (genOptions && 'document' in genOptions && genOptions.document) {
|
|
116
83
|
const document = genOptions.document;
|
|
117
84
|
const imageFiles = [];
|
|
118
|
-
// Extract input files from document._files
|
|
119
85
|
if (document._files) {
|
|
120
|
-
// Find files with keys starting with 'in' (input files)
|
|
121
86
|
for (const key of Object.keys(document._files)) {
|
|
122
87
|
if (key.startsWith('in')) {
|
|
123
88
|
const file = document._files[key];
|
|
124
89
|
if (file) {
|
|
125
|
-
// Handle both direct File objects and Fireproof's DocFileMeta
|
|
126
90
|
if (file instanceof File) {
|
|
127
91
|
imageFiles.push(file);
|
|
128
92
|
}
|
|
129
93
|
else if (typeof file.file === 'function') {
|
|
130
94
|
try {
|
|
131
|
-
// For DocFileMeta objects, we need to call the file() method
|
|
132
95
|
const fileObj = await file.file();
|
|
133
96
|
imageFiles.push(fileObj);
|
|
134
97
|
}
|
|
@@ -140,7 +103,6 @@ export function createImageGenerator(requestHash) {
|
|
|
140
103
|
}
|
|
141
104
|
}
|
|
142
105
|
}
|
|
143
|
-
// If we found image files, add them to options
|
|
144
106
|
if (imageFiles.length > 0) {
|
|
145
107
|
if (debug) {
|
|
146
108
|
console.log('[imageGenerator] Found images to include:', {
|
|
@@ -148,7 +110,6 @@ export function createImageGenerator(requestHash) {
|
|
|
148
110
|
fileTypes: imageFiles.map((f) => f.type),
|
|
149
111
|
});
|
|
150
112
|
}
|
|
151
|
-
// Update options with images array
|
|
152
113
|
genOptions = {
|
|
153
114
|
...genOptions,
|
|
154
115
|
images: imageFiles,
|
|
@@ -156,7 +117,6 @@ export function createImageGenerator(requestHash) {
|
|
|
156
117
|
}
|
|
157
118
|
}
|
|
158
119
|
try {
|
|
159
|
-
// Log a debug message if debug is enabled
|
|
160
120
|
if (debug) {
|
|
161
121
|
console.log(`[imageGenerator] Generating image with prompt: "${promptText.slice(0, 30)}...", options:`, {
|
|
162
122
|
...genOptions,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generator.js","sourceRoot":"","sources":["../../../jsr/hooks/image-gen/image-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,IAAI,gBAAgB,GAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAiB9D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAc,EACd,OAAkC,EACV;IAExB,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAOpD,MAAM,SAAS,GAAG,OAAO,EAAE,eAAe;QACxC,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,UAAU,OAAO,CAAC,eAAe,EAAE;QACjF,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;IAGnD,MAAM,SAAS,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC;IAGhD,IAAI,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAE/C,IAAI,YAAY,CAAC,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,OAAO,YAAY,CAAC,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAA2B,CAAC;QACpF,CAAC;IACH,CAAC;IAGD,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3C,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,YAAY,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;I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useImageGen } from './use-image-gen.js';
|
|
2
|
+
import { imageGen } from './image-generator.js';
|
|
3
|
+
import { base64ToFile, hashInput, MODULE_STATE } from './utils.js';
|
|
4
|
+
import type { ImageDocument, UseImageGenOptions, UseImageGenResult } from './types.js';
|
|
5
|
+
export { MODULE_STATE };
|
|
6
|
+
export { useImageGen, imageGen, base64ToFile, hashInput };
|
|
7
|
+
export type { ImageDocument, UseImageGenOptions, UseImageGenResult };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useImageGen } from './use-image-gen.js';
|
|
2
|
+
import { imageGen } from './image-generator.js';
|
|
3
|
+
import { base64ToFile, hashInput, MODULE_STATE } from './utils.js';
|
|
4
|
+
export { MODULE_STATE };
|
|
5
|
+
export { useImageGen, imageGen, base64ToFile, hashInput };
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../jsr/hooks/image-gen/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Database, DocWithId } from 'use-fireproof';
|
|
2
|
+
import { ImageGenOptions, ImageResponse } from 'call-ai';
|
|
3
|
+
export interface PromptEntry {
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly created: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ImageDocumentPlain {
|
|
8
|
+
readonly _rev?: string;
|
|
9
|
+
readonly type: 'image';
|
|
10
|
+
readonly prompt?: string;
|
|
11
|
+
readonly prompts?: Record<string, PromptEntry>;
|
|
12
|
+
readonly created: number;
|
|
13
|
+
readonly currentVersion: number;
|
|
14
|
+
readonly versions: VersionInfo[];
|
|
15
|
+
readonly currentPromptKey: string;
|
|
16
|
+
}
|
|
17
|
+
export type ImageDocument = DocWithId<ImageDocumentPlain>;
|
|
18
|
+
export type PartialImageDocument = DocWithId<Partial<ImageDocumentPlain>>;
|
|
19
|
+
export interface VersionInfo {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly created: number;
|
|
22
|
+
readonly promptKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export type GenerationPhase = 'idle' | 'generating' | 'complete' | 'error';
|
|
25
|
+
export interface UseImageGenOptions {
|
|
26
|
+
readonly prompt: string;
|
|
27
|
+
readonly _id: string;
|
|
28
|
+
readonly _rev?: string;
|
|
29
|
+
readonly database: string | Database;
|
|
30
|
+
readonly options: Partial<ImageGenOptions>;
|
|
31
|
+
readonly generationId: string;
|
|
32
|
+
readonly skip: boolean;
|
|
33
|
+
readonly type?: string;
|
|
34
|
+
readonly currentVersion?: number;
|
|
35
|
+
readonly versions?: {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly created: number;
|
|
38
|
+
readonly promptKey: string;
|
|
39
|
+
}[];
|
|
40
|
+
readonly _files?: Record<string, File>;
|
|
41
|
+
readonly prompts?: Record<string, PromptEntry>;
|
|
42
|
+
readonly editedPrompt: string;
|
|
43
|
+
}
|
|
44
|
+
export interface UseImageGenResult {
|
|
45
|
+
readonly imageData?: string | null;
|
|
46
|
+
readonly loading: boolean;
|
|
47
|
+
readonly progress: number;
|
|
48
|
+
readonly error?: Error | null;
|
|
49
|
+
readonly size?: {
|
|
50
|
+
readonly width: number;
|
|
51
|
+
readonly height: number;
|
|
52
|
+
};
|
|
53
|
+
readonly document?: PartialImageDocument | null;
|
|
54
|
+
}
|
|
55
|
+
export interface ModuleState {
|
|
56
|
+
readonly pendingImageGenCalls: Map<string, Promise<ImageResponse>>;
|
|
57
|
+
readonly pendingPrompts: Set<string>;
|
|
58
|
+
readonly processingRequests: Set<string>;
|
|
59
|
+
readonly requestTimestamps: Map<string, number>;
|
|
60
|
+
requestCounter: number;
|
|
61
|
+
readonly createdDocuments: Map<string, string>;
|
|
62
|
+
readonly pendingDocumentCreations: Map<string, Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
doc: ImageDocument;
|
|
65
|
+
}>>;
|
|
66
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../jsr/hooks/image-gen/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UseImageGenOptions, UseImageGenResult } from './types.js';
|
|
2
|
+
export declare function useImageGen({ prompt, _id, _rev, options, database, skip, // Skip processing flag
|
|
3
|
+
generationId, // Unique ID that changes for each new generation request
|
|
4
|
+
editedPrompt }: Partial<UseImageGenOptions>): UseImageGenResult;
|