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.
Files changed (155) hide show
  1. package/README.md +0 -7
  2. package/components/ControlsBar.d.ts +20 -0
  3. package/components/ControlsBar.js +80 -0
  4. package/components/ControlsBar.js.map +1 -0
  5. package/{dist/components → components}/ImgGen.css +21 -13
  6. package/components/ImgGen.d.ts +25 -0
  7. package/{dist/components → components}/ImgGen.js +25 -119
  8. package/components/ImgGen.js.map +1 -0
  9. package/{dist/components → components}/ImgGenUtils/ImgGenDisplay.d.ts +2 -2
  10. package/components/ImgGenUtils/ImgGenDisplay.js +192 -0
  11. package/components/ImgGenUtils/ImgGenDisplay.js.map +1 -0
  12. package/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +3 -0
  13. package/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +107 -0
  14. package/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +1 -0
  15. package/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +27 -0
  16. package/{dist/components → components}/ImgGenUtils/ImgGenDisplayUtils.js +4 -36
  17. package/components/ImgGenUtils/ImgGenDisplayUtils.js.map +1 -0
  18. package/components/ImgGenUtils/ImgGenError.d.ts +3 -0
  19. package/components/ImgGenUtils/ImgGenError.js +6 -0
  20. package/components/ImgGenUtils/ImgGenError.js.map +1 -0
  21. package/components/ImgGenUtils/ImgGenFileDrop.d.ts +12 -0
  22. package/{dist/components → components}/ImgGenUtils/ImgGenFileDrop.js +2 -9
  23. package/components/ImgGenUtils/ImgGenFileDrop.js.map +1 -0
  24. package/components/ImgGenUtils/ImgGenModal.d.ts +24 -0
  25. package/components/ImgGenUtils/ImgGenModal.js +28 -0
  26. package/components/ImgGenUtils/ImgGenModal.js.map +1 -0
  27. package/components/ImgGenUtils/ImgGenModeUtils.d.ts +9 -0
  28. package/{dist/components → components}/ImgGenUtils/ImgGenModeUtils.js +0 -15
  29. package/components/ImgGenUtils/ImgGenModeUtils.js.map +1 -0
  30. package/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +12 -0
  31. package/{dist/components → components}/ImgGenUtils/ImgGenPromptWaiting.js +3 -15
  32. package/components/ImgGenUtils/ImgGenPromptWaiting.js.map +1 -0
  33. package/components/ImgGenUtils/ImgGenUploadWaiting.d.ts +17 -0
  34. package/{dist/components → components}/ImgGenUtils/ImgGenUploadWaiting.js +3 -52
  35. package/components/ImgGenUtils/ImgGenUploadWaiting.js.map +1 -0
  36. package/components/ImgGenUtils/index.d.ts +6 -0
  37. package/components/ImgGenUtils/index.js +7 -0
  38. package/components/ImgGenUtils/index.js.map +1 -0
  39. package/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +9 -0
  40. package/{dist/components → components}/ImgGenUtils/overlays/DeleteConfirmationOverlay.js +8 -10
  41. package/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +1 -0
  42. package/components/ImgGenUtils/overlays/ImageOverlay.d.ts +22 -0
  43. package/components/ImgGenUtils/overlays/ImageOverlay.js +8 -0
  44. package/components/ImgGenUtils/overlays/ImageOverlay.js.map +1 -0
  45. package/components/ImgGenUtils/types.d.ts +29 -0
  46. package/components/ImgGenUtils/types.js.map +1 -0
  47. package/components/ImgGenUtils.d.ts +2 -0
  48. package/components/ImgGenUtils.js +3 -0
  49. package/components/ImgGenUtils.js.map +1 -0
  50. package/components/PromptBar.d.ts +11 -0
  51. package/components/PromptBar.js +16 -0
  52. package/components/PromptBar.js.map +1 -0
  53. package/hooks/image-gen/image-generator.d.ts +11 -0
  54. package/{dist/hooks → hooks}/image-gen/image-generator.js +2 -42
  55. package/hooks/image-gen/image-generator.js.map +1 -0
  56. package/hooks/image-gen/index.d.ts +7 -0
  57. package/hooks/image-gen/index.js +6 -0
  58. package/hooks/image-gen/index.js.map +1 -0
  59. package/hooks/image-gen/types.d.ts +66 -0
  60. package/{dist/hooks → hooks}/image-gen/types.js.map +1 -1
  61. package/hooks/image-gen/use-image-gen.d.ts +4 -0
  62. package/hooks/image-gen/use-image-gen.js +544 -0
  63. package/hooks/image-gen/use-image-gen.js.map +1 -0
  64. package/hooks/image-gen/utils.d.ts +20 -0
  65. package/{dist/hooks → hooks}/image-gen/utils.js +11 -93
  66. package/hooks/image-gen/utils.js.map +1 -0
  67. package/hooks/use-image-gen.d.ts +1 -0
  68. package/hooks/use-image-gen.js +2 -0
  69. package/hooks/use-image-gen.js.map +1 -0
  70. package/index.d.ts +20 -0
  71. package/index.js +21 -0
  72. package/index.js.map +1 -0
  73. package/package.json +23 -24
  74. package/style-loader.d.ts +1 -0
  75. package/style-loader.js +23 -0
  76. package/style-loader.js.map +1 -0
  77. package/tsconfig.json +18 -0
  78. package/{dist/utils → utils}/base64.js +0 -4
  79. package/utils/base64.js.map +1 -0
  80. package/{dist/utils → utils}/debug.js +0 -1
  81. package/utils/debug.js.map +1 -0
  82. package/utils/style-utils.d.ts +17 -0
  83. package/utils/style-utils.js +15 -0
  84. package/utils/style-utils.js.map +1 -0
  85. package/dist/components/ControlsBar.d.ts +0 -32
  86. package/dist/components/ControlsBar.js +0 -109
  87. package/dist/components/ControlsBar.js.map +0 -1
  88. package/dist/components/ImgGen.d.ts +0 -42
  89. package/dist/components/ImgGen.js.map +0 -1
  90. package/dist/components/ImgGenUtils/ImgGenDisplay.js +0 -264
  91. package/dist/components/ImgGenUtils/ImgGenDisplay.js.map +0 -1
  92. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.d.ts +0 -3
  93. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js +0 -125
  94. package/dist/components/ImgGenUtils/ImgGenDisplayPlaceholder.js.map +0 -1
  95. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.d.ts +0 -44
  96. package/dist/components/ImgGenUtils/ImgGenDisplayUtils.js.map +0 -1
  97. package/dist/components/ImgGenUtils/ImgGenError.d.ts +0 -3
  98. package/dist/components/ImgGenUtils/ImgGenError.js +0 -9
  99. package/dist/components/ImgGenUtils/ImgGenError.js.map +0 -1
  100. package/dist/components/ImgGenUtils/ImgGenFileDrop.d.ts +0 -21
  101. package/dist/components/ImgGenUtils/ImgGenFileDrop.js.map +0 -1
  102. package/dist/components/ImgGenUtils/ImgGenModal.d.ts +0 -31
  103. package/dist/components/ImgGenUtils/ImgGenModal.js +0 -34
  104. package/dist/components/ImgGenUtils/ImgGenModal.js.map +0 -1
  105. package/dist/components/ImgGenUtils/ImgGenModeUtils.d.ts +0 -16
  106. package/dist/components/ImgGenUtils/ImgGenModeUtils.js.map +0 -1
  107. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.d.ts +0 -17
  108. package/dist/components/ImgGenUtils/ImgGenPromptWaiting.js.map +0 -1
  109. package/dist/components/ImgGenUtils/ImgGenUploadWaiting.d.ts +0 -30
  110. package/dist/components/ImgGenUtils/ImgGenUploadWaiting.js.map +0 -1
  111. package/dist/components/ImgGenUtils/index.d.ts +0 -6
  112. package/dist/components/ImgGenUtils/index.js +0 -9
  113. package/dist/components/ImgGenUtils/index.js.map +0 -1
  114. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.d.ts +0 -10
  115. package/dist/components/ImgGenUtils/overlays/DeleteConfirmationOverlay.js.map +0 -1
  116. package/dist/components/ImgGenUtils/overlays/ImageOverlay.d.ts +0 -29
  117. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js +0 -11
  118. package/dist/components/ImgGenUtils/overlays/ImageOverlay.js.map +0 -1
  119. package/dist/components/ImgGenUtils/types.d.ts +0 -43
  120. package/dist/components/ImgGenUtils/types.js.map +0 -1
  121. package/dist/components/ImgGenUtils.d.ts +0 -6
  122. package/dist/components/ImgGenUtils.js +0 -7
  123. package/dist/components/ImgGenUtils.js.map +0 -1
  124. package/dist/components/PromptBar.d.ts +0 -15
  125. package/dist/components/PromptBar.js +0 -23
  126. package/dist/components/PromptBar.js.map +0 -1
  127. package/dist/hooks/image-gen/image-generator.d.ts +0 -18
  128. package/dist/hooks/image-gen/image-generator.js.map +0 -1
  129. package/dist/hooks/image-gen/index.d.ts +0 -6
  130. package/dist/hooks/image-gen/index.js +0 -6
  131. package/dist/hooks/image-gen/index.js.map +0 -1
  132. package/dist/hooks/image-gen/types.d.ts +0 -75
  133. package/dist/hooks/image-gen/use-image-gen.d.ts +0 -12
  134. package/dist/hooks/image-gen/use-image-gen.js +0 -675
  135. package/dist/hooks/image-gen/use-image-gen.js.map +0 -1
  136. package/dist/hooks/image-gen/utils.d.ts +0 -61
  137. package/dist/hooks/image-gen/utils.js.map +0 -1
  138. package/dist/hooks/use-image-gen.d.ts +0 -5
  139. package/dist/hooks/use-image-gen.js +0 -7
  140. package/dist/hooks/use-image-gen.js.map +0 -1
  141. package/dist/index.d.ts +0 -6
  142. package/dist/index.js +0 -8
  143. package/dist/index.js.map +0 -1
  144. package/dist/style-loader.d.ts +0 -16
  145. package/dist/style-loader.js +0 -43
  146. package/dist/style-loader.js.map +0 -1
  147. package/dist/utils/base64.js.map +0 -1
  148. package/dist/utils/debug.js.map +0 -1
  149. package/dist/utils/style-utils.d.ts +0 -55
  150. package/dist/utils/style-utils.js +0 -42
  151. package/dist/utils/style-utils.js.map +0 -1
  152. /package/{dist/components → components}/ImgGenUtils/types.js +0 -0
  153. /package/{dist/hooks → hooks}/image-gen/types.js +0 -0
  154. /package/{dist/utils → utils}/base64.d.ts +0 -0
  155. /package/{dist/utils → utils}/debug.d.ts +0 -0
@@ -0,0 +1,9 @@
1
+ import type { PartialImageDocument } from '../../hooks/image-gen/types.js';
2
+ export type ImgGenMode = 'placeholder' | 'uploadWaiting' | 'generating' | 'display' | 'error';
3
+ export declare function getImgGenMode({ document, prompt, loading, error, debug }: {
4
+ document?: PartialImageDocument | null;
5
+ prompt?: string;
6
+ loading: boolean;
7
+ error?: Error;
8
+ debug?: boolean;
9
+ }): ImgGenMode;
@@ -1,26 +1,16 @@
1
- /**
2
- * Pure function to determine the current mode of the ImgGen component
3
- * based on available document data and component state
4
- */
5
1
  export function getImgGenMode({ document, prompt, loading, error, debug, }) {
6
2
  if (error) {
7
3
  if (debug)
8
4
  console.log('[ImgGenModeUtils] Error present - error mode');
9
5
  return 'error';
10
6
  }
11
- // Special case: When we have a prompt and loading, always show generating
12
- // This helps during initial generation before document is created
13
7
  if (loading && prompt) {
14
8
  if (debug)
15
9
  console.log('[ImgGenModeUtils] Prompt + loading → generating');
16
10
  return 'generating';
17
11
  }
18
- // Check if we have versions (generated images)
19
12
  const hasVersions = !!document?.versions?.length;
20
- // Check if document has input files (uploaded images waiting for prompt)
21
13
  const hasInputFiles = document?._files && Object.keys(document._files).some((key) => key.startsWith('in'));
22
- // Check if document exists but has no input files or versions
23
- // This usually means it's a brand new document or an error case
24
14
  const hasEmptyDoc = !!document && (!document._files || Object.keys(document._files).length === 0) && !hasVersions;
25
15
  if (debug) {
26
16
  console.log('[ImgGenModeUtils] Determining mode:', {
@@ -31,31 +21,26 @@ export function getImgGenMode({ document, prompt, loading, error, debug, }) {
31
21
  loading,
32
22
  });
33
23
  }
34
- // Case 1: Total blank slate - no prompt, no document
35
24
  if (!document) {
36
25
  if (debug)
37
26
  console.log('[ImgGenModeUtils] No document - placeholder mode');
38
27
  return 'placeholder';
39
28
  }
40
- // Case 2: Has input files but no prompt yet - stay in upload waiting mode
41
29
  if (hasInputFiles && !prompt && !hasVersions) {
42
30
  if (debug)
43
31
  console.log('[ImgGenModeUtils] Has input files but no prompt - uploadWaiting mode');
44
32
  return 'uploadWaiting';
45
33
  }
46
- // Case 3: Has prompt but no versions yet (or is currently loading) - generating mode
47
34
  if ((prompt || loading) && !hasVersions) {
48
35
  if (debug)
49
36
  console.log('[ImgGenModeUtils] Has prompt but no versions - generating mode');
50
37
  return 'generating';
51
38
  }
52
- // Case 4: Has versions - display mode
53
39
  if (hasVersions) {
54
40
  if (debug)
55
41
  console.log('[ImgGenModeUtils] Has versions - display mode');
56
42
  return 'display';
57
43
  }
58
- // Fallback - if we have an empty document or other invalid state, go back to placeholder
59
44
  if (debug)
60
45
  console.log('[ImgGenModeUtils] Fallback - placeholder mode');
61
46
  return 'placeholder';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenModeUtils.js","sourceRoot":"","sources":["../../../jsr/components/ImgGenUtils/ImgGenModeUtils.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,EACL,KAAK,GAON,EAAc;IACb,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QACvE,OAAO,OAAO,CAAC;IACjB,CAAC;IAID,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACtB,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,mDAAiD,CAAC,CAAC;QAC1E,OAAO,YAAY,CAAC;IACtB,CAAC;IAGD,MAAM,WAAW,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;IAGjD,MAAM,aAAa,GACjB,QAAQ,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAIvF,MAAM,WAAW,GACf,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAEhG,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE;YACjD,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,WAAW;YACX,aAAa;YACb,WAAW;YACX,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAGD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAC3E,OAAO,aAAa,CAAC;IACvB,CAAC;IAGD,IAAI,aAAa,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7C,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,sEAAsE,CAAC,CAAC;QAC/F,OAAO,eAAe,CAAC;IACzB,CAAC;IAGD,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACxC,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;QACzF,OAAO,YAAY,CAAC;IACtB,CAAC;IAGD,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC;IACnB,CAAC;IAGD,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IACxE,OAAO,aAAa,CAAC;AAAA,CACtB"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import '../ImgGen.css';
3
+ import { ImgGenClasses } from '../../utils/style-utils.js';
4
+ interface ImgGenPromptWaitingProps {
5
+ readonly className?: string;
6
+ readonly classes?: Partial<ImgGenClasses>;
7
+ readonly database?: string;
8
+ readonly debug?: boolean;
9
+ readonly onFilesUploaded?: (docId: string) => void;
10
+ }
11
+ export declare function ImgGenPromptWaiting({ className, classes, database, debug, onFilesUploaded }: ImgGenPromptWaitingProps): React.JSX.Element;
12
+ export {};
@@ -1,12 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import '../ImgGen.css';
3
- import { combineClasses, defaultClasses } from '../../utils/style-utils';
4
- import { ImgGenFileDrop } from './ImgGenFileDrop';
3
+ import { combineClasses, defaultClasses } from '../../utils/style-utils.js';
4
+ import { ImgGenFileDrop } from './ImgGenFileDrop.js';
5
5
  import { useFireproof } from 'use-fireproof';
6
- // Component for when neither prompt nor _id is provided
7
6
  export function ImgGenPromptWaiting({ className, classes = defaultClasses, database, debug, onFilesUploaded, }) {
8
7
  const { database: db } = useFireproof(database || 'ImgGen');
9
- // Handle files being uploaded
10
8
  const handleFilesDropped = React.useCallback(async (files) => {
11
9
  if (!files.length)
12
10
  return;
@@ -14,24 +12,18 @@ export function ImgGenPromptWaiting({ className, classes = defaultClasses, datab
14
12
  console.log(`[ImgGenPromptWaiting] Handling ${files.length} dropped files`);
15
13
  }
16
14
  try {
17
- // Create new document to hold the uploaded files
18
15
  const newDoc = {
19
16
  type: 'image',
20
17
  createdAt: new Date().toISOString(),
21
18
  _files: {},
22
19
  };
23
- // Add files to the document with input file keys
24
20
  files.forEach((file, index) => {
25
- // Input files are prefixed with 'in' followed by a number
26
- // These are files uploaded by the user, not generated by AI
27
21
  newDoc._files[`in${index + 1}`] = file;
28
22
  });
29
- // Save the document to get an ID
30
23
  const result = await db.put(newDoc);
31
24
  if (debug) {
32
25
  console.log('[ImgGenPromptWaiting] Created document for uploads:', result.id);
33
26
  }
34
- // Notify parent component that files were uploaded
35
27
  if (onFilesUploaded && result.id) {
36
28
  onFilesUploaded(result.id);
37
29
  }
@@ -40,10 +32,6 @@ export function ImgGenPromptWaiting({ className, classes = defaultClasses, datab
40
32
  console.error('[ImgGenPromptWaiting] Error handling file upload:', error);
41
33
  }
42
34
  }, [db, debug, onFilesUploaded]);
43
- return (React.createElement("div", { className: combineClasses('imggen-upload-waiting', className || '', classes?.uploadWaiting || '') },
44
- React.createElement("div", { className: "imggen-placeholder-content", style: { marginBottom: '1rem', textAlign: 'center' } },
45
- React.createElement("h3", { style: { margin: '0 0 0.5rem 0', color: '#333' } }, "Generate an Image"),
46
- React.createElement("p", { style: { margin: '0', color: '#666' } }, "Enter a prompt or upload an image to edit")),
47
- React.createElement(ImgGenFileDrop, { className: classes?.dropZone || '', onFilesDropped: handleFilesDropped, isActive: true, maxFiles: 10, debug: debug, addFilesMessage: "Drop images here to upload (or click to browse)" })));
35
+ return (React.createElement("div", { className: combineClasses('imggen-upload-waiting', className || '', classes?.uploadWaiting || '') }, React.createElement("div", { className: "imggen-placeholder-content", style: { marginBottom: '1rem', textAlign: 'center' } }, React.createElement("h3", { style: { margin: '0 0 0.5rem 0', color: '#333' } }, "Generate an Image"), React.createElement("p", { style: { margin: '0', color: '#666' } }, "Enter a prompt or upload an image to edit")), React.createElement(ImgGenFileDrop, { className: classes?.dropZone || '', onFilesDropped: handleFilesDropped, isActive: true, maxFiles: 10, debug: debug, addFilesMessage: "Drop images here to upload (or click to browse)" })));
48
36
  }
49
37
  //# sourceMappingURL=ImgGenPromptWaiting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenPromptWaiting.js","sourceRoot":"","sources":["../../../jsr/components/ImgGenUtils/ImgGenPromptWaiting.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiB7C,MAAM,UAAU,mBAAmB,CAAC,EAClC,SAAS,EACT,OAAO,GAAG,cAAc,EACxB,QAAQ,EACR,KAAK,EACL,eAAe,GACU,EAAE;IAC3B,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,YAAY,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;IAG5D,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAC1C,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO;QAE1B,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,kCAAkC,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,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,gDAA+C,CACnF,EAEN,oBAAC,cAAc,IACb,SAAS,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAClC,cAAc,EAAE,kBAAkB,EAClC,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,EAAE,EACZ,KAAK,EAAE,KAAK,EACZ,eAAe,EAAC,iDAAiD,GACjE,CACE,CACP,CAAC;AAAA,CACH"}
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import type { PartialImageDocument } from '../../hooks/image-gen/types.js';
3
+ import { Database } from 'use-fireproof';
4
+ import { ImgGenClasses } from '../../utils/style-utils.js';
5
+ import '../ImgGen.css';
6
+ interface ImgGenUploadWaitingProps {
7
+ readonly document?: PartialImageDocument;
8
+ readonly className?: string;
9
+ readonly classes?: Partial<ImgGenClasses>;
10
+ readonly debug?: boolean;
11
+ readonly database?: string | Database;
12
+ readonly onFilesAdded?: () => void;
13
+ readonly onDocumentCreated?: (docId: string) => void;
14
+ readonly onPromptSubmit: (prompt: string, documentId?: string) => void;
15
+ }
16
+ export declare function ImgGenUploadWaiting({ document, className, classes, debug, database, onFilesAdded, onDocumentCreated, onPromptSubmit }: ImgGenUploadWaitingProps): React.ReactElement;
17
+ export {};
@@ -1,18 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { useFireproof, ImgFile } from 'use-fireproof';
3
- import { ImgGenFileDrop } from '../ImgGenUtils/ImgGenFileDrop';
4
- import { combineClasses } from '../../utils/style-utils';
3
+ import { ImgGenFileDrop } from '../ImgGenUtils/ImgGenFileDrop.js';
4
+ import { combineClasses } from '../../utils/style-utils.js';
5
5
  import '../ImgGen.css';
6
- /**
7
- * Component for displaying uploaded images and allowing users to:
8
- * 1. Upload more images to the same document
9
- * 2. Enter a prompt to start generation
10
- */
11
6
  export function ImgGenUploadWaiting({ document, className, classes, debug, database, onFilesAdded, onDocumentCreated, onPromptSubmit, }) {
12
7
  const { database: db } = useFireproof(database || 'ImgGen');
13
8
  const [prompt, setPrompt] = React.useState('');
14
9
  const [inputFiles, setInputFiles] = React.useState([]);
15
- // Get all input files from the document
16
10
  React.useEffect(() => {
17
11
  if (document?._files) {
18
12
  const inFiles = Object.keys(document._files)
@@ -24,19 +18,15 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
24
18
  }
25
19
  }
26
20
  }, [document, debug]);
27
- // Clean up any created object URLs when unmounting
28
21
  React.useEffect(() => {
29
22
  const objectUrls = [];
30
23
  return () => {
31
- // Clean up any created object URLs
32
24
  objectUrls.forEach((url) => URL.revokeObjectURL(url));
33
25
  };
34
26
  }, []);
35
- // Handle files being uploaded - two paths: add to existing doc or create new doc
36
27
  const handleFilesUploaded = async (files) => {
37
28
  if (!files.length)
38
29
  return;
39
- // If we already have a document, add files to it
40
30
  if (document && document._id) {
41
31
  await addFilesToExistingDocument(files);
42
32
  }
@@ -45,27 +35,20 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
45
35
  await createNewDocumentWithFiles(files);
46
36
  }
47
37
  };
48
- // Create a new document with the uploaded files
49
38
  const createNewDocumentWithFiles = async (files) => {
50
39
  try {
51
- // Create new document to hold the uploaded files
52
40
  const newDoc = {
53
41
  type: 'image',
54
42
  createdAt: new Date().toISOString(),
55
43
  _files: {},
56
44
  };
57
- // Add files to the document with input file keys
58
45
  files.forEach((file, index) => {
59
- // Input files are prefixed with 'in' followed by a number
60
- // These are files uploaded by the user, not generated by AI
61
46
  newDoc._files[`in${index + 1}`] = file;
62
47
  });
63
- // Save the document to get an ID
64
48
  const result = await db.put(newDoc);
65
49
  if (debug) {
66
50
  console.log('[ImgGenUploadWaiting] Created document for uploads:', result.id);
67
51
  }
68
- // Notify parent component that files were uploaded and document created
69
52
  if (onDocumentCreated && result.id) {
70
53
  onDocumentCreated(result.id);
71
54
  }
@@ -74,18 +57,15 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
74
57
  console.error('[ImgGenUploadWaiting] Error creating document for uploads:', error);
75
58
  }
76
59
  };
77
- // Add files to an existing document
78
60
  const addFilesToExistingDocument = async (files) => {
79
61
  if (!document || !document._id)
80
62
  return;
81
63
  try {
82
- // Load existing document
83
64
  const doc = await db.get(document._id);
84
65
  if (!doc) {
85
66
  console.error('[ImgGenUploadWaiting] Document not found:', document._id);
86
67
  return;
87
68
  }
88
- // Find highest current input file number
89
69
  let maxInputNum = 0;
90
70
  if (doc._files) {
91
71
  Object.keys(doc._files).forEach((key) => {
@@ -97,28 +77,23 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
97
77
  }
98
78
  });
99
79
  }
100
- // Add new files with incremented keys
101
80
  const updatedDoc = { ...doc };
102
81
  if (!updatedDoc._files)
103
82
  updatedDoc._files = {};
104
83
  for (let i = 0; i < files.length; i++) {
105
84
  const file = files[i];
106
85
  const fileKey = `in${maxInputNum + i + 1}`;
107
- // Add file to document
108
86
  updatedDoc._files[fileKey] = file;
109
87
  if (debug) {
110
88
  console.log(`[ImgGenUploadWaiting] Adding file to document: ${fileKey}`, file.name);
111
89
  }
112
90
  }
113
- // Save updated document
114
91
  const result = await db.put(updatedDoc);
115
92
  if (debug) {
116
93
  console.log('[ImgGenUploadWaiting] Document updated with new files:', result.id);
117
94
  }
118
- // Refresh the document to get the latest version with new files
119
95
  const refreshedDoc = await db.get(result.id);
120
96
  if (refreshedDoc) {
121
- // Update input files state with the new files
122
97
  const inFiles = Object.keys(refreshedDoc._files || {})
123
98
  .filter((key) => key.startsWith('in'))
124
99
  .sort();
@@ -127,7 +102,6 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
127
102
  console.log('[ImgGenUploadWaiting] Refreshed input files:', inFiles);
128
103
  }
129
104
  }
130
- // Notify parent about files added
131
105
  if (onFilesAdded) {
132
106
  onFilesAdded();
133
107
  }
@@ -136,11 +110,9 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
136
110
  console.error('[ImgGenUploadWaiting] Error updating document with new files:', error);
137
111
  }
138
112
  };
139
- // Handle prompt submission
140
113
  const handleSubmit = (e) => {
141
114
  e.preventDefault();
142
115
  if (prompt.trim()) {
143
- // Pass both the prompt and document ID to the parent component if we have a document
144
116
  if (document && document._id) {
145
117
  if (debug) {
146
118
  console.log('[ImgGenUploadWaiting] Submitting prompt with document ID:', document._id);
@@ -148,7 +120,6 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
148
120
  onPromptSubmit(prompt.trim(), document._id);
149
121
  }
150
122
  else {
151
- // Submit just the prompt if no document is available
152
123
  if (debug) {
153
124
  console.log('[ImgGenUploadWaiting] Submitting prompt with no document');
154
125
  }
@@ -156,26 +127,6 @@ export function ImgGenUploadWaiting({ document, className, classes, debug, datab
156
127
  }
157
128
  }
158
129
  };
159
- // We no longer need this function since we're using ImgFile component
160
- // which handles all the file display logic for us
161
- return (React.createElement("div", { className: combineClasses('imggen-upload-waiting', className || '', classes?.uploadWaiting || '') },
162
- React.createElement("div", { className: "imggen-placeholder-content", style: { textAlign: 'center' } },
163
- React.createElement("h3", { style: { margin: '0 0 0.5rem 0', color: '#333' } }, "Image Generator")),
164
- React.createElement("form", { onSubmit: handleSubmit, className: "imggen-prompt-form" },
165
- React.createElement("input", { type: "text", value: prompt, onChange: (e) => setPrompt(e.target.value), placeholder: "Enter a prompt...", className: "imggen-prompt-input" }),
166
- React.createElement("button", { type: "submit", disabled: !prompt.trim(), className: "imggen-prompt-submit" }, "Generate")),
167
- inputFiles.length > 0 && (React.createElement("div", { className: "imggen-uploaded-previews" },
168
- React.createElement("div", { className: "imggen-upload-count" },
169
- inputFiles.length,
170
- " ",
171
- inputFiles.length === 1 ? 'image' : 'images',
172
- " uploaded"),
173
- React.createElement("div", { className: "imggen-thumbnails" },
174
- inputFiles.slice(0, 4).map((fileKey) => (React.createElement("div", { key: fileKey, className: "imggen-thumbnail" }, document?._files && document._files[fileKey] && (React.createElement(ImgFile, { file: document._files[fileKey], alt: `Upload ${fileKey}`, className: "imggen-thumbnail-img" }))))),
175
- inputFiles.length > 4 && (React.createElement("div", { className: "imggen-more-count" },
176
- "+",
177
- inputFiles.length - 4,
178
- " more"))))),
179
- React.createElement(ImgGenFileDrop, { className: classes?.dropZone || '', onFilesDropped: handleFilesUploaded, isActive: true, maxFiles: 10, debug: debug, addFilesMessage: "Drop images or click to upload (optional)" })));
130
+ return (React.createElement("div", { className: combineClasses('imggen-upload-waiting', className || '', classes?.uploadWaiting || '') }, React.createElement("div", { className: "imggen-placeholder-content", style: { textAlign: 'center' } }, React.createElement("h3", { style: { margin: '0 0 0.5rem 0', color: '#333' } }, "Image Generator")), React.createElement("form", { onSubmit: handleSubmit, className: "imggen-prompt-form" }, React.createElement("input", { type: "text", value: prompt, onChange: (e) => setPrompt(e.target.value), placeholder: "Enter a prompt...", className: "imggen-prompt-input" }), React.createElement("button", { type: "submit", disabled: !prompt.trim(), className: "imggen-prompt-submit" }, "Generat")), inputFiles.length > 0 && (React.createElement("div", { className: "imggen-uploaded-previews" }, React.createElement("div", { className: "imggen-upload-count" }, inputFiles.length, " ", inputFiles.length === 1 ? 'image' : 'images', " uploade"), React.createElement("div", { className: "imggen-thumbnails" }, inputFiles.slice(0, 4).map((fileKey) => (React.createElement("div", { key: fileKey, className: "imggen-thumbnail" }, document?._files && document._files[fileKey] && (React.createElement(ImgFile, { file: document._files[fileKey], alt: `Upload ${fileKey}`, className: "imggen-thumbnail-img" }))))), inputFiles.length > 4 && (React.createElement("div", { className: "imggen-more-count" }, "+", inputFiles.length - 4, " more"))))), React.createElement(ImgGenFileDrop, { className: classes?.dropZone || '', onFilesDropped: handleFilesUploaded, isActive: true, maxFiles: 10, debug: debug, addFilesMessage: "Drop images or click to upload (optional)" })));
180
131
  }
181
132
  //# sourceMappingURL=ImgGenUploadWaiting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGenUploadWaiting.js","sourceRoot":"","sources":["../../../jsr/components/ImgGenUtils/ImgGenUploadWaiting.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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,IAAI,EAAE,EAAE,SAAS,EAAC,sBAAsB,cAEvE,CACJ,EAGN,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CACxB,6BAAK,SAAS,EAAC,0BAA0B,IACvC,6BAAK,SAAS,EAAC,qBAAqB,IACjC,UAAU,CAAC,MAAM,OAAG,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,aAC7D,EACN,6BAAK,SAAS,EAAC,mBAAmB,IAC/B,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvC,6BAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,kBAAkB,IAC5C,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAC/C,oBAAC,OAAO,IACN,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAC9B,GAAG,EAAE,UAAU,OAAO,EAAE,EACxB,SAAS,EAAC,sBAAsB,GAChC,CACH,CACG,CACP,CAAC,EACD,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CACxB,6BAAK,SAAS,EAAC,mBAAmB,SAAG,UAAU,CAAC,MAAM,GAAG,CAAC,UAAY,CACvE,CACG,CACF,CACP,EAGD,oBAAC,cAAc,IACb,SAAS,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAClC,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,EAAE,EACZ,KAAK,EAAE,KAAK,EACZ,eAAe,EAAC,2CAA2C,GAC3D,CACE,CACP,CAAC;AAAA,CACH"}
@@ -0,0 +1,6 @@
1
+ export { ImgGenPromptWaiting } from './ImgGenPromptWaiting.js';
2
+ export { ImgGenError } from './ImgGenError.js';
3
+ export { ImgGenDisplayPlaceholder } from './ImgGenDisplayPlaceholder.js';
4
+ export { ImgGenDisplay } from './ImgGenDisplay.js';
5
+ export { ImgGenUploadWaiting } from './ImgGenUploadWaiting.js';
6
+ export * from './types.js';
@@ -0,0 +1,7 @@
1
+ export { ImgGenPromptWaiting } from './ImgGenPromptWaiting.js';
2
+ export { ImgGenError } from './ImgGenError.js';
3
+ export { ImgGenDisplayPlaceholder } from './ImgGenDisplayPlaceholder.js';
4
+ export { ImgGenDisplay } from './ImgGenDisplay.js';
5
+ export { ImgGenUploadWaiting } from './ImgGenUploadWaiting.js';
6
+ export * from './types.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../jsr/components/ImgGenUtils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,cAAc,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { ImgGenClasses } from '../../../utils/style-utils.js';
3
+ interface DeleteConfirmationOverlayProps {
4
+ readonly handleDeleteConfirm: () => void;
5
+ readonly handleCancelDelete: () => void;
6
+ readonly classes?: Partial<ImgGenClasses>;
7
+ }
8
+ export declare function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDelete, classes }: DeleteConfirmationOverlayProps): React.JSX.Element;
9
+ export {};
@@ -1,11 +1,10 @@
1
1
  import * as React from 'react';
2
- import { combineClasses, defaultClasses } from '../../../utils/style-utils';
2
+ import { combineClasses, defaultClasses } from '../../../utils/style-utils.js';
3
3
  export function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDelete, classes = defaultClasses, }) {
4
- // Using React's useEffect to automatically dismiss the confirmation after 3 seconds
5
4
  React.useEffect(() => {
6
5
  const timeoutId = setTimeout(() => {
7
6
  handleCancelDelete();
8
- }, 3000); // Auto-dismiss after 3 seconds
7
+ }, 3000);
9
8
  return () => clearTimeout(timeoutId);
10
9
  }, [handleCancelDelete]);
11
10
  return (React.createElement("div", { className: combineClasses('imggen-delete-message', classes.overlay), style: {
@@ -21,12 +20,11 @@ export function DeleteConfirmationOverlay({ handleDeleteConfirm, handleCancelDel
21
20
  boxSizing: 'border-box',
22
21
  border: '1px solid var(--imggen-error-border)',
23
22
  cursor: 'pointer',
24
- }, onClick: handleDeleteConfirm, "aria-label": "Confirm delete" },
25
- React.createElement("p", { style: {
26
- color: '#ff3333',
27
- fontSize: '14px',
28
- margin: 0,
29
- fontWeight: 'bold',
30
- } }, "Confirm delete? This action cannot be undone.")));
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")));
31
29
  }
32
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,2 @@
1
+ export { ImgGenPromptWaiting, ImgGenError, ImgGenDisplayPlaceholder, ImgGenDisplay, } from './ImgGenUtils/index.js';
2
+ export * from './ImgGenUtils/types.js';
@@ -0,0 +1,3 @@
1
+ export { ImgGenPromptWaiting, ImgGenError, ImgGenDisplayPlaceholder, ImgGenDisplay, } from './ImgGenUtils/index.js';
2
+ export * from './ImgGenUtils/types.js';
3
+ //# sourceMappingURL=ImgGenUtils.js.map
@@ -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,16 @@
1
+ import * as React from 'react';
2
+ import { combineClasses, defaultClasses } from '../utils/style-utils.js';
3
+ export function PromptBar({ promptText, editedPrompt, setEditedPrompt, handlePromptEdit, classes = defaultClasses, }) {
4
+ return (React.createElement("div", { className: "imggen-top-line" }, React.createElement("div", { className: combineClasses('imggen-prompt', classes.prompt) }, editedPrompt !== null ? (React.createElement("input", { type: "text", value: editedPrompt, onChange: (e) => setEditedPrompt(e.target.value), onKeyDown: (e) => {
5
+ if (e.key === 'Enter') {
6
+ e.preventDefault();
7
+ handlePromptEdit(editedPrompt);
8
+ }
9
+ else if (e.key === 'Escape') {
10
+ setEditedPrompt(null);
11
+ }
12
+ }, autoFocus: true, className: "imggen-prompt-input imggen-edit-mode", "aria-label": "Edit prompt" })) : (React.createElement("div", { onClick: () => {
13
+ setEditedPrompt(promptText);
14
+ }, className: "imggen-prompt-text imggen-truncate", title: "Click to edit prompt" }, promptText)))));
15
+ }
16
+ //# 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;AAgBxF,MAAM,UAAU,SAAS,CAAC,EACxB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,OAAO,GAAG,cAAc,GACT,EAAE;IACjB,OAAO,CACL,6BAAK,SAAS,EAAC,iBAAiB,IAC9B,6BAAK,SAAS,EAAE,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,IAC5D,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,SAAS,EAAC,sCAAsC,gBACrC,aAAa,GACxB,CACH,CAAC,CAAC,CAAC,CACF,6BACE,OAAO,EAAE,GAAG,EAAE,CAAC;YAEb,eAAe,CAAC,UAAU,CAAC,CAAC;QAAA,CAC7B,EACD,SAAS,EAAC,oCAAoC,EAC9C,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 {};