@slopmachine/react 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -45,29 +45,35 @@ function cn(...inputs) {
45
45
  }
46
46
  var SlopImage = ({
47
47
  bucketId,
48
- prompt,
49
48
  className,
50
49
  aspectRatio = "1:1",
50
+ version,
51
+ resultId,
51
52
  model,
52
53
  variables = {},
53
54
  baseUrl,
54
55
  ...props
55
56
  }) => {
56
- const src = (0, import_react.useMemo)(
57
+ const rawSrc = (0, import_react.useMemo)(
57
58
  () => (0, import_core.buildImageUrl)({
58
59
  bucketId,
59
- prompt,
60
60
  aspectRatio,
61
+ version,
62
+ resultId,
61
63
  variables,
62
64
  baseUrl,
63
65
  model
64
66
  }),
65
- [bucketId, prompt, aspectRatio, variables, baseUrl, model]
66
- );
67
- const alt = (0, import_react.useMemo)(
68
- () => (0, import_core.interpolatePrompt)(prompt, variables) ?? "Generated image",
69
- [prompt, variables]
67
+ [bucketId, aspectRatio, version, resultId, variables, baseUrl, model]
70
68
  );
69
+ const [src, setSrc] = (0, import_react.useState)(rawSrc);
70
+ import_react.default.useEffect(() => {
71
+ const timer = setTimeout(() => {
72
+ setSrc(rawSrc);
73
+ }, 100);
74
+ return () => clearTimeout(timer);
75
+ }, [rawSrc]);
76
+ const alt = "Generated image";
71
77
  const [isLoading, setIsLoading] = (0, import_react.useState)(true);
72
78
  const [currentSrc, setCurrentSrc] = (0, import_react.useState)(src);
73
79
  if (src !== currentSrc) {
package/dist/index.mjs CHANGED
@@ -2,39 +2,42 @@
2
2
  import React, { useMemo, useState } from "react";
3
3
  import { clsx } from "clsx";
4
4
  import { twMerge } from "tailwind-merge";
5
- import {
6
- buildImageUrl,
7
- interpolatePrompt
8
- } from "@slopmachine/core";
5
+ import { buildImageUrl } from "@slopmachine/core";
9
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
7
  function cn(...inputs) {
11
8
  return twMerge(clsx(inputs));
12
9
  }
13
10
  var SlopImage = ({
14
11
  bucketId,
15
- prompt,
16
12
  className,
17
13
  aspectRatio = "1:1",
14
+ version,
15
+ resultId,
18
16
  model,
19
17
  variables = {},
20
18
  baseUrl,
21
19
  ...props
22
20
  }) => {
23
- const src = useMemo(
21
+ const rawSrc = useMemo(
24
22
  () => buildImageUrl({
25
23
  bucketId,
26
- prompt,
27
24
  aspectRatio,
25
+ version,
26
+ resultId,
28
27
  variables,
29
28
  baseUrl,
30
29
  model
31
30
  }),
32
- [bucketId, prompt, aspectRatio, variables, baseUrl, model]
33
- );
34
- const alt = useMemo(
35
- () => interpolatePrompt(prompt, variables) ?? "Generated image",
36
- [prompt, variables]
31
+ [bucketId, aspectRatio, version, resultId, variables, baseUrl, model]
37
32
  );
33
+ const [src, setSrc] = useState(rawSrc);
34
+ React.useEffect(() => {
35
+ const timer = setTimeout(() => {
36
+ setSrc(rawSrc);
37
+ }, 100);
38
+ return () => clearTimeout(timer);
39
+ }, [rawSrc]);
40
+ const alt = "Generated image";
38
41
  const [isLoading, setIsLoading] = useState(true);
39
42
  const [currentSrc, setCurrentSrc] = useState(src);
40
43
  if (src !== currentSrc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slopmachine/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "The official React SDK for Slop Machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -2,11 +2,7 @@ import React, { useMemo, useState } from "react";
2
2
  import { clsx, type ClassValue } from "clsx";
3
3
  import { twMerge } from "tailwind-merge";
4
4
 
5
- import {
6
- buildImageUrl,
7
- interpolatePrompt,
8
- type SlopImageOptions,
9
- } from "@slopmachine/core";
5
+ import { buildImageUrl, type SlopImageOptions } from "@slopmachine/core";
10
6
 
11
7
  // Utility for Tailwind classes
12
8
  function cn(...inputs: ClassValue[]) {
@@ -20,32 +16,40 @@ interface SlopImageProps
20
16
 
21
17
  export const SlopImage: React.FC<SlopImageProps> = ({
22
18
  bucketId,
23
- prompt,
24
19
  className,
25
20
  aspectRatio = "1:1",
21
+ version,
22
+ resultId,
26
23
  model,
27
24
  variables = {},
28
25
  baseUrl,
29
26
  ...props
30
27
  }) => {
31
28
  // Construct API URL
32
- const src = useMemo(
29
+ const rawSrc = useMemo(
33
30
  () =>
34
31
  buildImageUrl({
35
32
  bucketId,
36
- prompt,
37
33
  aspectRatio,
34
+ version,
35
+ resultId,
38
36
  variables,
39
37
  baseUrl,
40
38
  model,
41
39
  }),
42
- [bucketId, prompt, aspectRatio, variables, baseUrl, model],
40
+ [bucketId, aspectRatio, version, resultId, variables, baseUrl, model],
43
41
  );
44
42
 
45
- const alt = useMemo(
46
- () => interpolatePrompt(prompt, variables) ?? "Generated image",
47
- [prompt, variables],
48
- );
43
+ const [src, setSrc] = useState(rawSrc);
44
+
45
+ React.useEffect(() => {
46
+ const timer = setTimeout(() => {
47
+ setSrc(rawSrc);
48
+ }, 100);
49
+ return () => clearTimeout(timer);
50
+ }, [rawSrc]);
51
+
52
+ const alt = "Generated image";
49
53
 
50
54
  const [isLoading, setIsLoading] = useState(true);
51
55
  const [currentSrc, setCurrentSrc] = useState(src);