@vibes.diy/use-vibes-base 0.12.0-dev-preview
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/LICENSE.md +232 -0
- package/README.md +549 -0
- package/components/ControlsBar.d.ts +20 -0
- package/components/ControlsBar.js +84 -0
- package/components/ControlsBar.js.map +1 -0
- package/components/ImgGen.css +675 -0
- package/components/ImgGen.d.ts +24 -0
- package/components/ImgGen.js +256 -0
- package/components/ImgGen.js.map +1 -0
- package/components/ImgGenUtils/ImgGenDisplay.d.ts +3 -0
- 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 +90 -0
- package/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
- package/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +27 -0
- package/components/ImgGenUtils/ImgGenDisplayUtils.js +95 -0
- package/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
- package/components/ImgGenUtils/ImgGenError.d.ts +3 -0
- package/components/ImgGenUtils/ImgGenError.js +7 -0
- package/components/ImgGenUtils/ImgGenError.js.map +1 -0
- package/components/ImgGenUtils/ImgGenFileDrop.d.ts +11 -0
- package/components/ImgGenUtils/ImgGenFileDrop.js +49 -0
- package/components/ImgGenUtils/ImgGenFileDrop.js.map +1 -0
- package/components/ImgGenUtils/ImgGenModal.d.ts +24 -0
- package/components/ImgGenUtils/ImgGenModal.js +63 -0
- package/components/ImgGenUtils/ImgGenModal.js.map +1 -0
- package/components/ImgGenUtils/ImgGenModeUtils.d.ts +9 -0
- package/components/ImgGenUtils/ImgGenModeUtils.js +48 -0
- package/components/ImgGenUtils/ImgGenModeUtils.js.map +1 -0
- package/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +11 -0
- package/components/ImgGenUtils/ImgGenPromptWaiting.js +36 -0
- package/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
- package/components/ImgGenUtils/ImgGenUploadWaiting.d.ts +16 -0
- package/components/ImgGenUtils/ImgGenUploadWaiting.js +131 -0
- 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/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +30 -0
- 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 +2 -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 +23 -0
- package/components/PromptBar.js.map +1 -0
- package/hooks/image-gen/image-generator.d.ts +11 -0
- package/hooks/image-gen/image-generator.js +136 -0
- 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/hooks/image-gen/types.js +2 -0
- package/hooks/image-gen/types.js.map +1 -0
- 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/hooks/image-gen/utils.js +159 -0
- 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 +22 -0
- package/index.js +21 -0
- package/index.js.map +1 -0
- package/package.json +30 -0
- package/tsconfig.json +22 -0
- package/utils/base64.d.ts +1 -0
- package/utils/base64.js +13 -0
- package/utils/base64.js.map +1 -0
- package/utils/debug.d.ts +2 -0
- package/utils/debug.js +8 -0
- 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/utils/styles.d.ts +227 -0
- package/utils/styles.js +230 -0
- package/utils/styles.js.map +1 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { combineClasses, defaultClasses } from '../../../utils/style-utils.js';
|
|
3
|
+
export function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDelete, classes = defaultClasses, }) {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const timeoutId = setTimeout(() => {
|
|
6
|
+
handleCancelDelete();
|
|
7
|
+
}, 3000);
|
|
8
|
+
return () => clearTimeout(timeoutId);
|
|
9
|
+
}, [handleCancelDelete]);
|
|
10
|
+
return (React.createElement("div", { className: combineClasses('imggen-delete-message', classes.overlay), style: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
backgroundColor: 'rgba(255, 0, 0, 0.1)',
|
|
15
|
+
borderRadius: 'var(--imggen-border-radius)',
|
|
16
|
+
padding: '10px 15px',
|
|
17
|
+
marginBottom: '8px',
|
|
18
|
+
textAlign: 'center',
|
|
19
|
+
width: 'auto',
|
|
20
|
+
boxSizing: 'border-box',
|
|
21
|
+
border: '1px solid var(--imggen-error-border)',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
}, onClick: handleDeleteConfirm, "aria-label": "Confirm delete" }, React.createElement("p", { style: {
|
|
24
|
+
color: '#ff3333',
|
|
25
|
+
fontSize: '14px',
|
|
26
|
+
margin: 0,
|
|
27
|
+
fontWeight: 'bold',
|
|
28
|
+
} }, "Confirm delete? This action cannot be undone")));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=DeleteConfirmationOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteConfirmationOverlay.js","sourceRoot":"","sources":["../../../../jsr/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,+BAA+B,CAAC;AAS9F,MAAM,UAAU,yBAAyB,CAAC,EACxC,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,GAAG,cAAc,GACO,EAAE;IAEjC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;YACjC,kBAAkB,EAAE,CAAC;QAAA,CACtB,EAAE,IAAI,CAAC,CAAC;QAET,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAAA,CACtC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,6BACE,SAAS,EAAE,cAAc,CAAC,uBAAuB,EAAE,OAAO,CAAC,OAAO,CAAC,EACnE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,eAAe,EAAE,sBAAsB;YACvC,YAAY,EAAE,6BAA6B;YAC3C,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,KAAK;YACnB,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,YAAY;YACvB,MAAM,EAAE,sCAAsC;YAC9C,MAAM,EAAE,SAAS;SAClB,EACD,OAAO,EAAE,mBAAmB,gBACjB,gBAAgB,IAE3B,2BACE,KAAK,EAAE;YACL,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,CAAC;YACT,UAAU,EAAE,MAAM;SACnB,mDAGC,CACA,CACP,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ImgGenClasses } from '../../../utils/style-utils.js';
|
|
3
|
+
interface ImageOverlayProps {
|
|
4
|
+
readonly promptText: string;
|
|
5
|
+
readonly editedPrompt: string | null;
|
|
6
|
+
readonly setEditedPrompt: (prompt: string | null) => void;
|
|
7
|
+
readonly handlePromptEdit: (prompt: string) => void;
|
|
8
|
+
readonly handleDeleteConfirm: () => void;
|
|
9
|
+
readonly handlePrevVersion: () => void;
|
|
10
|
+
readonly handleNextVersion: () => void;
|
|
11
|
+
readonly handleRegen: () => void;
|
|
12
|
+
readonly versionIndex: number;
|
|
13
|
+
readonly totalVersions: number;
|
|
14
|
+
readonly classes?: Partial<ImgGenClasses>;
|
|
15
|
+
readonly showControls?: boolean;
|
|
16
|
+
readonly progress?: number;
|
|
17
|
+
readonly showDelete?: boolean;
|
|
18
|
+
readonly versionFlash?: boolean;
|
|
19
|
+
readonly isRegenerating?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function ImageOverlay({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, classes, showControls, progress, showDelete, versionFlash, isRegenerating }: ImageOverlayProps): React.JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { combineClasses, defaultClasses } from '../../../utils/style-utils.js';
|
|
3
|
+
import { PromptBar } from '../../../components/PromptBar.js';
|
|
4
|
+
import { ControlsBar } from '../../../components/ControlsBar.js';
|
|
5
|
+
export function ImageOverlay({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, handleDeleteConfirm, handlePrevVersion, handleNextVersion, handleRegen, versionIndex, totalVersions, classes = defaultClasses, showControls = true, progress = 100, showDelete = true, versionFlash = false, isRegenerating = false, }) {
|
|
6
|
+
return (React.createElement("div", { className: combineClasses('imggen-overlay', classes.overlay), style: { position: 'relative' } }, React.createElement(React.Fragment, null, React.createElement(PromptBar, { promptText: promptText, editedPrompt: editedPrompt, setEditedPrompt: setEditedPrompt, handlePromptEdit: handlePromptEdit, classes: classes }), React.createElement(ControlsBar, { handleDeleteConfirm: handleDeleteConfirm, handlePrevVersion: handlePrevVersion, handleNextVersion: handleNextVersion, handleRegen: handleRegen, versionIndex: versionIndex, totalVersions: totalVersions, classes: classes, showControls: showControls, showDelete: showDelete, editedPrompt: editedPrompt, promptText: promptText, progress: progress, versionFlash: versionFlash, isRegenerating: isRegenerating }))));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ImageOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageOverlay.js","sourceRoot":"","sources":["../../../../jsr/components/ImgGenUtils/overlays/ImageOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA8BjE,MAAM,UAAU,YAAY,CAAC,EAC3B,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,OAAO,GAAG,cAAc,EACxB,YAAY,GAAG,IAAI,EACnB,QAAQ,GAAG,GAAG,EACd,UAAU,GAAG,IAAI,EACjB,YAAY,GAAG,KAAK,EACpB,cAAc,GAAG,KAAK,GACJ,EAAE;IAEpB,OAAO,CACL,6BACE,SAAS,EAAE,cAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,EAC5D,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,IAG7B,0CAEE,oBAAC,SAAS,IACR,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB,EAGF,oBAAC,WAAW,IACV,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACD,CAED,CACP,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PartialImageDocument } from '../../hooks/image-gen/types.js';
|
|
2
|
+
import { ImgGenClasses } from '../../utils/style-utils.js';
|
|
3
|
+
export interface ImgGenPlaceholderProps {
|
|
4
|
+
readonly className?: string;
|
|
5
|
+
readonly alt?: string;
|
|
6
|
+
readonly prompt?: string;
|
|
7
|
+
progress: number;
|
|
8
|
+
readonly loading?: boolean;
|
|
9
|
+
readonly error?: Error | null;
|
|
10
|
+
readonly classes?: Partial<ImgGenClasses>;
|
|
11
|
+
}
|
|
12
|
+
export interface ImgGenDisplayProps {
|
|
13
|
+
readonly document: PartialImageDocument;
|
|
14
|
+
readonly className: string;
|
|
15
|
+
readonly alt: string;
|
|
16
|
+
readonly onDelete: (id: string) => void;
|
|
17
|
+
readonly onRegen: (id: string) => void;
|
|
18
|
+
readonly onPromptEdit: (id: string, newPrompt: string) => void;
|
|
19
|
+
readonly classes: Partial<ImgGenClasses>;
|
|
20
|
+
readonly loading: boolean;
|
|
21
|
+
readonly progress: number;
|
|
22
|
+
readonly error: Error | null;
|
|
23
|
+
readonly debug: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ImgGenErrorProps {
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly className: string;
|
|
28
|
+
readonly classes: Partial<ImgGenClasses>;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../jsr/components/ImgGenUtils/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImgGenUtils.js","sourceRoot":"","sources":["../../jsr/components/ImgGenUtils.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EACxB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ImgGenClasses } from '../utils/style-utils.js';
|
|
3
|
+
interface PromptBarProps {
|
|
4
|
+
readonly promptText: string;
|
|
5
|
+
readonly editedPrompt: string | null;
|
|
6
|
+
readonly setEditedPrompt: (prompt: string | null) => void;
|
|
7
|
+
readonly handlePromptEdit: (prompt: string) => void;
|
|
8
|
+
readonly classes?: Partial<ImgGenClasses>;
|
|
9
|
+
}
|
|
10
|
+
export declare function PromptBar({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, classes }: PromptBarProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { combineClasses, defaultClasses } from '../utils/style-utils.js';
|
|
3
|
+
import { imgGenStyles } from '../utils/styles.js';
|
|
4
|
+
export function PromptBar({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, classes = defaultClasses, }) {
|
|
5
|
+
return (React.createElement("div", { style: imgGenStyles.topLine }, React.createElement("div", { className: combineClasses(classes.prompt), style: imgGenStyles.prompt }, editedPrompt !== null ? (React.createElement("input", { type: "text", value: editedPrompt, onChange: (e) => setEditedPrompt(e.target.value), onKeyDown: (e) => {
|
|
6
|
+
if (e.key === 'Enter') {
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
handlePromptEdit(editedPrompt);
|
|
9
|
+
}
|
|
10
|
+
else if (e.key === 'Escape') {
|
|
11
|
+
setEditedPrompt(null);
|
|
12
|
+
}
|
|
13
|
+
}, autoFocus: true, style: {
|
|
14
|
+
...imgGenStyles.promptInput,
|
|
15
|
+
...imgGenStyles.promptInputEditMode,
|
|
16
|
+
}, "aria-label": "Edit prompt" })) : (React.createElement("div", { className: "imggen-prompt-text", onClick: () => {
|
|
17
|
+
setEditedPrompt(promptText);
|
|
18
|
+
}, style: {
|
|
19
|
+
...imgGenStyles.promptText,
|
|
20
|
+
...imgGenStyles.truncate,
|
|
21
|
+
}, title: "Click to edit prompt" }, promptText)))));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=PromptBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptBar.js","sourceRoot":"","sources":["../../jsr/components/PromptBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgBlD,MAAM,UAAU,SAAS,CAAC,EACxB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,OAAO,GAAG,cAAc,GACT,EAAE;IACjB,OAAO,CACL,6BAAK,KAAK,EAAE,YAAY,CAAC,OAAO,IAC9B,6BAAK,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,IACvE,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,CACvB,+BACE,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAChD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;gBACtB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,gBAAgB,CAAC,YAAY,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC9B,eAAe,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QAAA,CACF,EAED,SAAS,QACT,KAAK,EAAE;YACL,GAAG,YAAY,CAAC,WAAW;YAC3B,GAAG,YAAY,CAAC,mBAAmB;SACpC,gBACU,aAAa,GACxB,CACH,CAAC,CAAC,CAAC,CACF,6BACE,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC;YAEb,eAAe,CAAC,UAAU,CAAC,CAAC;QAAA,CAC7B,EACD,KAAK,EAAE;YACL,GAAG,YAAY,CAAC,UAAU;YAC1B,GAAG,YAAY,CAAC,QAAQ;SACzB,EACD,KAAK,EAAC,sBAAsB,IAE3B,UAAU,CACP,CACP,CACG,CACF,CACP,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ImageGenOptions as BaseImageGenOptions, ImageResponse } from 'call-ai';
|
|
2
|
+
import { ImageDocument } from './types.js';
|
|
3
|
+
interface ImageGenOptions extends BaseImageGenOptions {
|
|
4
|
+
readonly _regenerationId: number;
|
|
5
|
+
readonly images: File[];
|
|
6
|
+
readonly document: Partial<ImageDocument>;
|
|
7
|
+
readonly debug: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function imageGen(prompt: string, options?: Partial<ImageGenOptions>): Promise<ImageResponse>;
|
|
10
|
+
export declare function createImageGenerator(requestHash: string): (promptText: string, genOptions?: Partial<ImageGenOptions> | undefined) => Promise<ImageResponse>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { imageGen as originalImageGen, } from 'call-ai';
|
|
2
|
+
import { MODULE_STATE, getRelevantOptions } from './utils.js';
|
|
3
|
+
export async function imageGen(prompt, options) {
|
|
4
|
+
const relevantOptions = getRelevantOptions(options);
|
|
5
|
+
const stableKey = options?._regenerationId
|
|
6
|
+
? `${prompt}-${JSON.stringify(relevantOptions)}-regen-${options._regenerationId}`
|
|
7
|
+
: `${prompt}-${JSON.stringify(relevantOptions)}`;
|
|
8
|
+
const requestId = ++MODULE_STATE.requestCounter;
|
|
9
|
+
if (MODULE_STATE.pendingPrompts.has(stableKey)) {
|
|
10
|
+
if (MODULE_STATE.pendingImageGenCalls.has(stableKey)) {
|
|
11
|
+
return MODULE_STATE.pendingImageGenCalls.get(stableKey);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
MODULE_STATE.pendingPrompts.add(stableKey);
|
|
15
|
+
MODULE_STATE.processingRequests.add(stableKey);
|
|
16
|
+
MODULE_STATE.requestTimestamps.set(stableKey, Date.now());
|
|
17
|
+
if (options?.debug) {
|
|
18
|
+
console.log(`[ImgGen Debug] Generating image with prompt: "${prompt}"`, {
|
|
19
|
+
requestId,
|
|
20
|
+
options,
|
|
21
|
+
hasImages: options.images ? options.images.length + ' files' : 'No',
|
|
22
|
+
stableKey,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
let promise;
|
|
26
|
+
try {
|
|
27
|
+
const enhancedOptions = { ...options };
|
|
28
|
+
if (!enhancedOptions.images && enhancedOptions.document && enhancedOptions.document._files) {
|
|
29
|
+
const imageFiles = [];
|
|
30
|
+
for (const key of Object.keys(enhancedOptions.document._files)) {
|
|
31
|
+
if (key.startsWith('in') || key === 'original') {
|
|
32
|
+
const file = enhancedOptions.document._files[key];
|
|
33
|
+
if (file) {
|
|
34
|
+
if (file instanceof File) {
|
|
35
|
+
imageFiles.push(file);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof file.file === 'function') {
|
|
38
|
+
try {
|
|
39
|
+
const fileObj = await file.file();
|
|
40
|
+
imageFiles.push(fileObj);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.error(`Error getting file from DocFileMeta for key ${key}:`, e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (imageFiles.length > 0) {
|
|
50
|
+
enhancedOptions.images = imageFiles;
|
|
51
|
+
if (enhancedOptions.debug) {
|
|
52
|
+
console.log('[ImgGen Debug] Extracted images from document:', {
|
|
53
|
+
count: imageFiles.length,
|
|
54
|
+
keys: Object.keys(enhancedOptions.document._files).filter((k) => k.startsWith('in') || k === 'original'),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
promise = originalImageGen(prompt, enhancedOptions);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
console.error(`[ImgGen Debug] Error with imageGen for request #${requestId}:`, e);
|
|
63
|
+
promise = Promise.reject(e);
|
|
64
|
+
}
|
|
65
|
+
MODULE_STATE.pendingImageGenCalls.set(stableKey, promise);
|
|
66
|
+
promise
|
|
67
|
+
.then((response) => {
|
|
68
|
+
MODULE_STATE.processingRequests.delete(stableKey);
|
|
69
|
+
return response;
|
|
70
|
+
})
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
console.error(`[ImgGen Debug] Request #${requestId} failed [key:${stableKey.slice(0, 12)}...]: ${error}`);
|
|
73
|
+
MODULE_STATE.processingRequests.delete(stableKey);
|
|
74
|
+
return Promise.reject(error);
|
|
75
|
+
});
|
|
76
|
+
return promise;
|
|
77
|
+
}
|
|
78
|
+
export function createImageGenerator(requestHash) {
|
|
79
|
+
return async (promptText, genOptions) => {
|
|
80
|
+
JSON.stringify(getRelevantOptions(genOptions));
|
|
81
|
+
const debug = genOptions?.debug;
|
|
82
|
+
if (genOptions && 'document' in genOptions && genOptions.document) {
|
|
83
|
+
const document = genOptions.document;
|
|
84
|
+
const imageFiles = [];
|
|
85
|
+
if (document._files) {
|
|
86
|
+
for (const key of Object.keys(document._files)) {
|
|
87
|
+
if (key.startsWith('in')) {
|
|
88
|
+
const file = document._files[key];
|
|
89
|
+
if (file) {
|
|
90
|
+
if (file instanceof File) {
|
|
91
|
+
imageFiles.push(file);
|
|
92
|
+
}
|
|
93
|
+
else if (typeof file.file === 'function') {
|
|
94
|
+
try {
|
|
95
|
+
const fileObj = await file.file();
|
|
96
|
+
imageFiles.push(fileObj);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
console.error(`Error getting file from DocFileMeta for key ${key}:`, e);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (imageFiles.length > 0) {
|
|
107
|
+
if (debug) {
|
|
108
|
+
console.log('[imageGenerator] Found images to include:', {
|
|
109
|
+
count: imageFiles.length,
|
|
110
|
+
fileTypes: imageFiles.map((f) => f.type),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
genOptions = {
|
|
114
|
+
...genOptions,
|
|
115
|
+
images: imageFiles,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
if (debug) {
|
|
121
|
+
console.log(`[imageGenerator] Generating image with prompt: "${promptText.slice(0, 30)}...", options:`, {
|
|
122
|
+
...genOptions,
|
|
123
|
+
hasImages: genOptions?.images ? 'Yes' : 'No',
|
|
124
|
+
imageCount: genOptions?.images ? genOptions.images.length : 0,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const response = await imageGen(promptText, genOptions);
|
|
128
|
+
return response;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error(`[ImgGen Debug] Failed request [ID:${requestHash}]: ${error}`);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=image-generator.js.map
|
|
@@ -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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AE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,WAAW,MAAM,KAAK,EAAE,CAAC,CAAC;YAC7E,MAAM,KAAK,CAAC;QACd,CAAC;IAAA,CACF,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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;
|