@slopmachine/react 0.1.1 → 0.1.2

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/dist/index.js CHANGED
@@ -53,7 +53,7 @@ var SlopImage = ({
53
53
  baseUrl,
54
54
  ...props
55
55
  }) => {
56
- const src = (0, import_react.useMemo)(
56
+ const rawSrc = (0, import_react.useMemo)(
57
57
  () => (0, import_core.buildImageUrl)({
58
58
  bucketId,
59
59
  prompt,
@@ -64,6 +64,13 @@ var SlopImage = ({
64
64
  }),
65
65
  [bucketId, prompt, aspectRatio, variables, baseUrl, model]
66
66
  );
67
+ const [src, setSrc] = (0, import_react.useState)(rawSrc);
68
+ import_react.default.useEffect(() => {
69
+ const timer = setTimeout(() => {
70
+ setSrc(rawSrc);
71
+ }, 100);
72
+ return () => clearTimeout(timer);
73
+ }, [rawSrc]);
67
74
  const alt = (0, import_react.useMemo)(
68
75
  () => (0, import_core.interpolatePrompt)(prompt, variables) ?? "Generated image",
69
76
  [prompt, variables]
package/dist/index.mjs CHANGED
@@ -20,7 +20,7 @@ var SlopImage = ({
20
20
  baseUrl,
21
21
  ...props
22
22
  }) => {
23
- const src = useMemo(
23
+ const rawSrc = useMemo(
24
24
  () => buildImageUrl({
25
25
  bucketId,
26
26
  prompt,
@@ -31,6 +31,13 @@ var SlopImage = ({
31
31
  }),
32
32
  [bucketId, prompt, aspectRatio, variables, baseUrl, model]
33
33
  );
34
+ const [src, setSrc] = useState(rawSrc);
35
+ React.useEffect(() => {
36
+ const timer = setTimeout(() => {
37
+ setSrc(rawSrc);
38
+ }, 100);
39
+ return () => clearTimeout(timer);
40
+ }, [rawSrc]);
34
41
  const alt = useMemo(
35
42
  () => interpolatePrompt(prompt, variables) ?? "Generated image",
36
43
  [prompt, variables]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slopmachine/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "The official React SDK for Slop Machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@ export const SlopImage: React.FC<SlopImageProps> = ({
29
29
  ...props
30
30
  }) => {
31
31
  // Construct API URL
32
- const src = useMemo(
32
+ const rawSrc = useMemo(
33
33
  () =>
34
34
  buildImageUrl({
35
35
  bucketId,
@@ -42,6 +42,15 @@ export const SlopImage: React.FC<SlopImageProps> = ({
42
42
  [bucketId, prompt, aspectRatio, variables, baseUrl, model],
43
43
  );
44
44
 
45
+ const [src, setSrc] = useState(rawSrc);
46
+
47
+ React.useEffect(() => {
48
+ const timer = setTimeout(() => {
49
+ setSrc(rawSrc);
50
+ }, 100);
51
+ return () => clearTimeout(timer);
52
+ }, [rawSrc]);
53
+
45
54
  const alt = useMemo(
46
55
  () => interpolatePrompt(prompt, variables) ?? "Generated image",
47
56
  [prompt, variables],