@slopmachine/react 0.5.0 → 0.7.0
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/CHANGELOG.md +33 -0
- package/dist/index.d.mts +34 -6
- package/dist/index.d.ts +34 -6
- package/dist/index.js +196 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -14
- package/src/components/ErrorOverlay.tsx +91 -0
- package/src/components/SlopImage.tsx +57 -31
- package/src/components/SlopText.tsx +10 -4
- package/src/components/SlopVideo.tsx +52 -29
- package/src/index.ts +9 -1
package/dist/index.js
CHANGED
|
@@ -31,19 +31,97 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
SlopImage: () => SlopImage,
|
|
34
|
+
SlopMachineError: () => import_core4.SlopMachineError,
|
|
34
35
|
SlopText: () => SlopText,
|
|
35
36
|
SlopVideo: () => SlopVideo,
|
|
36
37
|
preloadImage: () => import_core4.preloadImage,
|
|
38
|
+
preloadText: () => import_core4.preloadText,
|
|
39
|
+
preloadVideo: () => import_core4.preloadVideo,
|
|
37
40
|
rateResult: () => import_core4.rateResult
|
|
38
41
|
});
|
|
39
42
|
module.exports = __toCommonJS(index_exports);
|
|
40
43
|
|
|
41
44
|
// src/components/SlopImage.tsx
|
|
42
|
-
var import_react =
|
|
45
|
+
var import_react = require("react");
|
|
43
46
|
var import_clsx = require("clsx");
|
|
44
47
|
var import_tailwind_merge = require("tailwind-merge");
|
|
45
48
|
var import_core = require("@slopmachine/core");
|
|
49
|
+
|
|
50
|
+
// src/components/ErrorOverlay.tsx
|
|
46
51
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var overlayStyle = {
|
|
53
|
+
position: "absolute",
|
|
54
|
+
top: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
right: 0,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
zIndex: 10,
|
|
59
|
+
display: "flex",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center"
|
|
62
|
+
};
|
|
63
|
+
var ErrorOverlay = ({
|
|
64
|
+
error,
|
|
65
|
+
errorFallback,
|
|
66
|
+
label
|
|
67
|
+
}) => {
|
|
68
|
+
if (errorFallback !== void 0) {
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: "absolute inset-0 z-10 flex items-center justify-center",
|
|
73
|
+
style: overlayStyle,
|
|
74
|
+
children: typeof errorFallback === "function" ? errorFallback(error) : errorFallback
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: "absolute inset-0 z-10 flex items-center justify-center bg-muted",
|
|
82
|
+
style: { ...overlayStyle, backgroundColor: "var(--muted, #f3f4f6)" },
|
|
83
|
+
title: error.message,
|
|
84
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: "flex flex-col items-center gap-2 text-muted-foreground",
|
|
88
|
+
style: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
flexDirection: "column",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
gap: "0.5rem",
|
|
93
|
+
color: "var(--muted-foreground, #6b7280)"
|
|
94
|
+
},
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
97
|
+
"svg",
|
|
98
|
+
{
|
|
99
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
100
|
+
viewBox: "0 0 24 24",
|
|
101
|
+
fill: "none",
|
|
102
|
+
stroke: "currentColor",
|
|
103
|
+
strokeWidth: "2",
|
|
104
|
+
strokeLinecap: "round",
|
|
105
|
+
strokeLinejoin: "round",
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
style: { width: "24px", height: "24px" },
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs", style: { fontSize: "0.75rem" }, children: label })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/components/SlopImage.tsx
|
|
124
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
47
125
|
function cn(...inputs) {
|
|
48
126
|
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
49
127
|
}
|
|
@@ -55,6 +133,7 @@ var SlopImage = ({
|
|
|
55
133
|
metadata,
|
|
56
134
|
className,
|
|
57
135
|
aspectRatio = "1:1",
|
|
136
|
+
model,
|
|
58
137
|
version,
|
|
59
138
|
resultId,
|
|
60
139
|
variables = {},
|
|
@@ -62,6 +141,8 @@ var SlopImage = ({
|
|
|
62
141
|
original,
|
|
63
142
|
attachments,
|
|
64
143
|
loader,
|
|
144
|
+
errorFallback,
|
|
145
|
+
onGenerationError,
|
|
65
146
|
objectFit = "cover",
|
|
66
147
|
imageClassName,
|
|
67
148
|
style,
|
|
@@ -77,6 +158,7 @@ var SlopImage = ({
|
|
|
77
158
|
prompt,
|
|
78
159
|
metadata,
|
|
79
160
|
aspectRatio,
|
|
161
|
+
model,
|
|
80
162
|
version,
|
|
81
163
|
resultId,
|
|
82
164
|
variables,
|
|
@@ -91,6 +173,7 @@ var SlopImage = ({
|
|
|
91
173
|
prompt,
|
|
92
174
|
metadata,
|
|
93
175
|
aspectRatio,
|
|
176
|
+
model,
|
|
94
177
|
version,
|
|
95
178
|
resultId,
|
|
96
179
|
variables,
|
|
@@ -100,7 +183,7 @@ var SlopImage = ({
|
|
|
100
183
|
]
|
|
101
184
|
);
|
|
102
185
|
const [src, setSrc] = (0, import_react.useState)(rawSrc);
|
|
103
|
-
import_react.
|
|
186
|
+
(0, import_react.useEffect)(() => {
|
|
104
187
|
const timer = setTimeout(() => {
|
|
105
188
|
setSrc(rawSrc);
|
|
106
189
|
}, 100);
|
|
@@ -108,35 +191,33 @@ var SlopImage = ({
|
|
|
108
191
|
}, [rawSrc]);
|
|
109
192
|
const alt = "Image produced by Slop Machine (slopmachine.dev)";
|
|
110
193
|
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
194
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
111
195
|
const [currentSrc, setCurrentSrc] = (0, import_react.useState)(src);
|
|
112
196
|
if (src !== currentSrc) {
|
|
113
197
|
setCurrentSrc(src);
|
|
114
198
|
setIsLoading(true);
|
|
199
|
+
setError(null);
|
|
115
200
|
}
|
|
116
|
-
import_react.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const errorText = await errRes.text();
|
|
124
|
-
const errorData = JSON.parse(errorText);
|
|
125
|
-
if (errorData.error) {
|
|
126
|
-
errorMessage = errorData.error;
|
|
127
|
-
}
|
|
128
|
-
} catch (e) {
|
|
129
|
-
}
|
|
130
|
-
console.error("SlopImage error:", res.status, errorMessage);
|
|
131
|
-
setIsLoading(false);
|
|
132
|
-
}
|
|
133
|
-
}).catch((err) => {
|
|
134
|
-
console.error(`Error fetching image from ${src}:`, err);
|
|
201
|
+
const onGenerationErrorRef = (0, import_react.useRef)(onGenerationError);
|
|
202
|
+
(0, import_react.useEffect)(() => {
|
|
203
|
+
onGenerationErrorRef.current = onGenerationError;
|
|
204
|
+
});
|
|
205
|
+
const monitor = (0, import_react.useMemo)(
|
|
206
|
+
() => (0, import_core.createRenderUrlMonitor)((err) => {
|
|
207
|
+
console.error("SlopImage error:", err.status ?? "", err.message);
|
|
135
208
|
setIsLoading(false);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
209
|
+
setError(err);
|
|
210
|
+
onGenerationErrorRef.current?.(err);
|
|
211
|
+
}),
|
|
212
|
+
[]
|
|
213
|
+
);
|
|
214
|
+
(0, import_react.useEffect)(() => {
|
|
215
|
+
if (!src) return;
|
|
216
|
+
monitor.watch(src);
|
|
217
|
+
return () => monitor.stop();
|
|
218
|
+
}, [src, monitor]);
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
220
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: `
|
|
140
221
|
@keyframes slop-shimmer {
|
|
141
222
|
0% {
|
|
142
223
|
background-position: 200% 0;
|
|
@@ -154,7 +235,7 @@ var SlopImage = ({
|
|
|
154
235
|
}
|
|
155
236
|
}
|
|
156
237
|
` }),
|
|
157
|
-
/* @__PURE__ */ (0,
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
158
239
|
"div",
|
|
159
240
|
{
|
|
160
241
|
className: "slop-wrapper relative overflow-hidden w-full h-full",
|
|
@@ -166,7 +247,7 @@ var SlopImage = ({
|
|
|
166
247
|
height: "100%"
|
|
167
248
|
},
|
|
168
249
|
children: [
|
|
169
|
-
loader ? /* @__PURE__ */ (0,
|
|
250
|
+
loader ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
170
251
|
"div",
|
|
171
252
|
{
|
|
172
253
|
className: cn(
|
|
@@ -189,8 +270,8 @@ var SlopImage = ({
|
|
|
189
270
|
},
|
|
190
271
|
children: loader
|
|
191
272
|
}
|
|
192
|
-
) : /* @__PURE__ */ (0,
|
|
193
|
-
/* @__PURE__ */ (0,
|
|
273
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
194
275
|
"div",
|
|
195
276
|
{
|
|
196
277
|
className: cn(
|
|
@@ -212,7 +293,7 @@ var SlopImage = ({
|
|
|
212
293
|
pointerEvents: isLoading ? "auto" : "none",
|
|
213
294
|
transition: "opacity 300ms ease-in-out"
|
|
214
295
|
},
|
|
215
|
-
children: /* @__PURE__ */ (0,
|
|
296
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
216
297
|
"div",
|
|
217
298
|
{
|
|
218
299
|
className: "flex flex-col items-center gap-2",
|
|
@@ -223,7 +304,7 @@ var SlopImage = ({
|
|
|
223
304
|
gap: "0.5rem"
|
|
224
305
|
},
|
|
225
306
|
children: [
|
|
226
|
-
/* @__PURE__ */ (0,
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
227
308
|
"svg",
|
|
228
309
|
{
|
|
229
310
|
className: "spinner size-6 text-muted-foreground",
|
|
@@ -237,7 +318,7 @@ var SlopImage = ({
|
|
|
237
318
|
animation: "slop-spin 1s linear infinite"
|
|
238
319
|
},
|
|
239
320
|
children: [
|
|
240
|
-
/* @__PURE__ */ (0,
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
241
322
|
"circle",
|
|
242
323
|
{
|
|
243
324
|
className: "opacity-25",
|
|
@@ -249,7 +330,7 @@ var SlopImage = ({
|
|
|
249
330
|
style: { opacity: 0.25 }
|
|
250
331
|
}
|
|
251
332
|
),
|
|
252
|
-
/* @__PURE__ */ (0,
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
253
334
|
"path",
|
|
254
335
|
{
|
|
255
336
|
className: "opacity-75",
|
|
@@ -261,7 +342,7 @@ var SlopImage = ({
|
|
|
261
342
|
]
|
|
262
343
|
}
|
|
263
344
|
),
|
|
264
|
-
/* @__PURE__ */ (0,
|
|
345
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
265
346
|
"span",
|
|
266
347
|
{
|
|
267
348
|
className: "text-xs text-muted-foreground",
|
|
@@ -277,7 +358,7 @@ var SlopImage = ({
|
|
|
277
358
|
)
|
|
278
359
|
}
|
|
279
360
|
),
|
|
280
|
-
/* @__PURE__ */ (0,
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
281
362
|
"div",
|
|
282
363
|
{
|
|
283
364
|
className: cn(
|
|
@@ -299,7 +380,15 @@ var SlopImage = ({
|
|
|
299
380
|
}
|
|
300
381
|
)
|
|
301
382
|
] }),
|
|
302
|
-
/* @__PURE__ */ (0,
|
|
383
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
384
|
+
ErrorOverlay,
|
|
385
|
+
{
|
|
386
|
+
error,
|
|
387
|
+
errorFallback,
|
|
388
|
+
label: "Failed to load image"
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
303
392
|
"img",
|
|
304
393
|
{
|
|
305
394
|
src,
|
|
@@ -310,12 +399,13 @@ var SlopImage = ({
|
|
|
310
399
|
onLoad?.(e);
|
|
311
400
|
},
|
|
312
401
|
onError: (e) => {
|
|
313
|
-
|
|
402
|
+
monitor.mediaFailed(src, "Failed to load image");
|
|
314
403
|
onError?.(e);
|
|
315
404
|
},
|
|
405
|
+
"aria-hidden": error ? true : props["aria-hidden"],
|
|
316
406
|
className: cn(
|
|
317
407
|
"h-full w-full transition-opacity duration-500",
|
|
318
|
-
isLoading ? "opacity-0" : "opacity-100",
|
|
408
|
+
isLoading || error ? "opacity-0" : "opacity-100",
|
|
319
409
|
imageClassName
|
|
320
410
|
),
|
|
321
411
|
style: {
|
|
@@ -323,7 +413,7 @@ var SlopImage = ({
|
|
|
323
413
|
width: "100%",
|
|
324
414
|
objectFit,
|
|
325
415
|
transition: "opacity 500ms",
|
|
326
|
-
opacity: isLoading ? 0 : 1
|
|
416
|
+
opacity: isLoading || error ? 0 : 1
|
|
327
417
|
}
|
|
328
418
|
},
|
|
329
419
|
src
|
|
@@ -339,7 +429,7 @@ var import_react2 = require("react");
|
|
|
339
429
|
var import_clsx2 = require("clsx");
|
|
340
430
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
341
431
|
var import_core2 = require("@slopmachine/core");
|
|
342
|
-
var
|
|
432
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
343
433
|
function cn2(...inputs) {
|
|
344
434
|
return (0, import_tailwind_merge2.twMerge)((0, import_clsx2.clsx)(inputs));
|
|
345
435
|
}
|
|
@@ -359,6 +449,8 @@ var SlopVideo = ({
|
|
|
359
449
|
original,
|
|
360
450
|
attachments,
|
|
361
451
|
loader,
|
|
452
|
+
errorFallback,
|
|
453
|
+
onGenerationError,
|
|
362
454
|
autoPlay = true,
|
|
363
455
|
loop = true,
|
|
364
456
|
muted = true,
|
|
@@ -407,36 +499,34 @@ var SlopVideo = ({
|
|
|
407
499
|
return () => clearTimeout(timer);
|
|
408
500
|
}, [rawSrc]);
|
|
409
501
|
const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
|
|
502
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
410
503
|
const [currentSrc, setCurrentSrc] = (0, import_react2.useState)(src);
|
|
411
504
|
const videoRef = (0, import_react2.useRef)(null);
|
|
412
505
|
if (src !== currentSrc) {
|
|
413
506
|
setCurrentSrc(src);
|
|
414
507
|
setIsLoading(true);
|
|
508
|
+
setError(null);
|
|
415
509
|
}
|
|
510
|
+
const onGenerationErrorRef = (0, import_react2.useRef)(onGenerationError);
|
|
416
511
|
(0, import_react2.useEffect)(() => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const errRes = await fetch(src);
|
|
423
|
-
const errorText = await errRes.text();
|
|
424
|
-
const errorData = JSON.parse(errorText);
|
|
425
|
-
if (errorData.error) {
|
|
426
|
-
errorMessage = errorData.error;
|
|
427
|
-
}
|
|
428
|
-
} catch (e) {
|
|
429
|
-
}
|
|
430
|
-
console.error("SlopVideo error:", res.status, errorMessage);
|
|
431
|
-
setIsLoading(false);
|
|
432
|
-
}
|
|
433
|
-
}).catch((err) => {
|
|
434
|
-
console.error(`Error fetching video from ${src}:`, err);
|
|
512
|
+
onGenerationErrorRef.current = onGenerationError;
|
|
513
|
+
});
|
|
514
|
+
const monitor = (0, import_react2.useMemo)(
|
|
515
|
+
() => (0, import_core2.createRenderUrlMonitor)((err) => {
|
|
516
|
+
console.error("SlopVideo error:", err.status ?? "", err.message);
|
|
435
517
|
setIsLoading(false);
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
518
|
+
setError(err);
|
|
519
|
+
onGenerationErrorRef.current?.(err);
|
|
520
|
+
}),
|
|
521
|
+
[]
|
|
522
|
+
);
|
|
523
|
+
(0, import_react2.useEffect)(() => {
|
|
524
|
+
if (!src) return;
|
|
525
|
+
monitor.watch(src);
|
|
526
|
+
return () => monitor.stop();
|
|
527
|
+
}, [src, monitor]);
|
|
528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
440
530
|
@keyframes slop-shimmer {
|
|
441
531
|
0% {
|
|
442
532
|
background-position: 200% 0;
|
|
@@ -454,7 +544,7 @@ var SlopVideo = ({
|
|
|
454
544
|
}
|
|
455
545
|
}
|
|
456
546
|
` }),
|
|
457
|
-
/* @__PURE__ */ (0,
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, style: props.style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
458
548
|
"div",
|
|
459
549
|
{
|
|
460
550
|
className: "slop-wrapper relative overflow-hidden w-full h-full",
|
|
@@ -466,7 +556,7 @@ var SlopVideo = ({
|
|
|
466
556
|
height: "100%"
|
|
467
557
|
},
|
|
468
558
|
children: [
|
|
469
|
-
loader ? /* @__PURE__ */ (0,
|
|
559
|
+
loader ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
470
560
|
"div",
|
|
471
561
|
{
|
|
472
562
|
className: cn2(
|
|
@@ -489,8 +579,8 @@ var SlopVideo = ({
|
|
|
489
579
|
},
|
|
490
580
|
children: loader
|
|
491
581
|
}
|
|
492
|
-
) : /* @__PURE__ */ (0,
|
|
493
|
-
/* @__PURE__ */ (0,
|
|
582
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
583
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
494
584
|
"div",
|
|
495
585
|
{
|
|
496
586
|
className: cn2(
|
|
@@ -512,7 +602,7 @@ var SlopVideo = ({
|
|
|
512
602
|
pointerEvents: isLoading ? "auto" : "none",
|
|
513
603
|
transition: "opacity 300ms ease-in-out"
|
|
514
604
|
},
|
|
515
|
-
children: /* @__PURE__ */ (0,
|
|
605
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
516
606
|
"div",
|
|
517
607
|
{
|
|
518
608
|
className: "flex flex-col items-center gap-2",
|
|
@@ -523,7 +613,7 @@ var SlopVideo = ({
|
|
|
523
613
|
gap: "0.5rem"
|
|
524
614
|
},
|
|
525
615
|
children: [
|
|
526
|
-
/* @__PURE__ */ (0,
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
527
617
|
"svg",
|
|
528
618
|
{
|
|
529
619
|
className: "spinner size-6 text-muted-foreground",
|
|
@@ -537,7 +627,7 @@ var SlopVideo = ({
|
|
|
537
627
|
animation: "slop-spin 1s linear infinite"
|
|
538
628
|
},
|
|
539
629
|
children: [
|
|
540
|
-
/* @__PURE__ */ (0,
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
541
631
|
"circle",
|
|
542
632
|
{
|
|
543
633
|
className: "opacity-25",
|
|
@@ -549,7 +639,7 @@ var SlopVideo = ({
|
|
|
549
639
|
style: { opacity: 0.25 }
|
|
550
640
|
}
|
|
551
641
|
),
|
|
552
|
-
/* @__PURE__ */ (0,
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
553
643
|
"path",
|
|
554
644
|
{
|
|
555
645
|
className: "opacity-75",
|
|
@@ -561,7 +651,7 @@ var SlopVideo = ({
|
|
|
561
651
|
]
|
|
562
652
|
}
|
|
563
653
|
),
|
|
564
|
-
/* @__PURE__ */ (0,
|
|
654
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
565
655
|
"span",
|
|
566
656
|
{
|
|
567
657
|
className: "text-xs text-muted-foreground",
|
|
@@ -577,7 +667,7 @@ var SlopVideo = ({
|
|
|
577
667
|
)
|
|
578
668
|
}
|
|
579
669
|
),
|
|
580
|
-
/* @__PURE__ */ (0,
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
581
671
|
"div",
|
|
582
672
|
{
|
|
583
673
|
className: cn2(
|
|
@@ -599,7 +689,15 @@ var SlopVideo = ({
|
|
|
599
689
|
}
|
|
600
690
|
)
|
|
601
691
|
] }),
|
|
602
|
-
/* @__PURE__ */ (0,
|
|
692
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
693
|
+
ErrorOverlay,
|
|
694
|
+
{
|
|
695
|
+
error,
|
|
696
|
+
errorFallback,
|
|
697
|
+
label: "Failed to load video"
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
603
701
|
"video",
|
|
604
702
|
{
|
|
605
703
|
ref: videoRef,
|
|
@@ -614,19 +712,20 @@ var SlopVideo = ({
|
|
|
614
712
|
onLoadedData?.(e);
|
|
615
713
|
},
|
|
616
714
|
onError: (e) => {
|
|
617
|
-
|
|
715
|
+
monitor.mediaFailed(src, "Failed to load video");
|
|
618
716
|
onError?.(e);
|
|
619
717
|
},
|
|
718
|
+
"aria-hidden": error ? true : props["aria-hidden"],
|
|
620
719
|
className: cn2(
|
|
621
720
|
"h-full w-full object-cover transition-opacity duration-500",
|
|
622
|
-
isLoading ? "opacity-0" : "opacity-100"
|
|
721
|
+
isLoading || error ? "opacity-0" : "opacity-100"
|
|
623
722
|
),
|
|
624
723
|
style: {
|
|
625
724
|
height: "100%",
|
|
626
725
|
width: "100%",
|
|
627
726
|
objectFit: "cover",
|
|
628
727
|
transition: "opacity 500ms",
|
|
629
|
-
opacity: isLoading ? 0 : 1
|
|
728
|
+
opacity: isLoading || error ? 0 : 1
|
|
630
729
|
}
|
|
631
730
|
},
|
|
632
731
|
src
|
|
@@ -640,8 +739,7 @@ var SlopVideo = ({
|
|
|
640
739
|
// src/components/SlopText.tsx
|
|
641
740
|
var import_react3 = __toESM(require("react"));
|
|
642
741
|
var import_core3 = require("@slopmachine/core");
|
|
643
|
-
var
|
|
644
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
742
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
645
743
|
var SlopText = import_react3.default.forwardRef(
|
|
646
744
|
({
|
|
647
745
|
bucketId,
|
|
@@ -651,6 +749,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
651
749
|
metadata,
|
|
652
750
|
version,
|
|
653
751
|
resultId,
|
|
752
|
+
model,
|
|
654
753
|
variables,
|
|
655
754
|
baseUrl,
|
|
656
755
|
attachments,
|
|
@@ -670,6 +769,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
670
769
|
metadata,
|
|
671
770
|
version,
|
|
672
771
|
resultId,
|
|
772
|
+
model,
|
|
673
773
|
variables,
|
|
674
774
|
baseUrl,
|
|
675
775
|
attachments
|
|
@@ -682,6 +782,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
682
782
|
JSON.stringify(metadata),
|
|
683
783
|
version,
|
|
684
784
|
resultId,
|
|
785
|
+
model,
|
|
685
786
|
JSON.stringify(variables),
|
|
686
787
|
baseUrl,
|
|
687
788
|
JSON.stringify(attachments)
|
|
@@ -728,14 +829,14 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
728
829
|
};
|
|
729
830
|
}, [rawUrl]);
|
|
730
831
|
if (error && errorFallback) {
|
|
731
|
-
return /* @__PURE__ */ (0,
|
|
832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errorFallback });
|
|
732
833
|
}
|
|
733
834
|
if (loading) {
|
|
734
835
|
if (fallback) {
|
|
735
|
-
return /* @__PURE__ */ (0,
|
|
836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: fallback });
|
|
736
837
|
}
|
|
737
|
-
return /* @__PURE__ */ (0,
|
|
738
|
-
/* @__PURE__ */ (0,
|
|
838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: props.className, style: props.style, children: [
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
|
|
739
840
|
@keyframes slop-shimmer {
|
|
740
841
|
0% { background-position: 200% 0; }
|
|
741
842
|
100% { background-position: -200% 0; }
|
|
@@ -745,7 +846,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
745
846
|
to { transform: rotate(360deg); }
|
|
746
847
|
}
|
|
747
848
|
` }),
|
|
748
|
-
/* @__PURE__ */ (0,
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
749
850
|
"div",
|
|
750
851
|
{
|
|
751
852
|
className: "slop-wrapper relative overflow-hidden w-full",
|
|
@@ -756,7 +857,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
756
857
|
minHeight: "100px"
|
|
757
858
|
},
|
|
758
859
|
children: [
|
|
759
|
-
/* @__PURE__ */ (0,
|
|
860
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
760
861
|
"div",
|
|
761
862
|
{
|
|
762
863
|
className: "absolute inset-0 z-10 flex items-center justify-center bg-muted transition-opacity duration-300",
|
|
@@ -772,7 +873,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
772
873
|
justifyContent: "center",
|
|
773
874
|
backgroundColor: "var(--muted, #f3f4f6)"
|
|
774
875
|
},
|
|
775
|
-
children: /* @__PURE__ */ (0,
|
|
876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
776
877
|
"div",
|
|
777
878
|
{
|
|
778
879
|
className: "flex flex-col items-center gap-2",
|
|
@@ -783,7 +884,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
783
884
|
gap: "0.5rem"
|
|
784
885
|
},
|
|
785
886
|
children: [
|
|
786
|
-
/* @__PURE__ */ (0,
|
|
887
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
787
888
|
"svg",
|
|
788
889
|
{
|
|
789
890
|
className: "spinner size-6 text-muted-foreground",
|
|
@@ -797,7 +898,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
797
898
|
animation: "slop-spin 1s linear infinite"
|
|
798
899
|
},
|
|
799
900
|
children: [
|
|
800
|
-
/* @__PURE__ */ (0,
|
|
901
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
801
902
|
"circle",
|
|
802
903
|
{
|
|
803
904
|
className: "opacity-25",
|
|
@@ -809,7 +910,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
809
910
|
style: { opacity: 0.25 }
|
|
810
911
|
}
|
|
811
912
|
),
|
|
812
|
-
/* @__PURE__ */ (0,
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
813
914
|
"path",
|
|
814
915
|
{
|
|
815
916
|
className: "opacity-75",
|
|
@@ -821,7 +922,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
821
922
|
]
|
|
822
923
|
}
|
|
823
924
|
),
|
|
824
|
-
/* @__PURE__ */ (0,
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
825
926
|
"span",
|
|
826
927
|
{
|
|
827
928
|
className: "text-xs text-muted-foreground",
|
|
@@ -837,7 +938,7 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
837
938
|
)
|
|
838
939
|
}
|
|
839
940
|
),
|
|
840
|
-
/* @__PURE__ */ (0,
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
841
942
|
"div",
|
|
842
943
|
{
|
|
843
944
|
className: "shimmer-effect absolute inset-0 bg-gradient-to-r from-muted via-muted/50 to-muted",
|
|
@@ -858,13 +959,13 @@ var SlopText = import_react3.default.forwardRef(
|
|
|
858
959
|
)
|
|
859
960
|
] });
|
|
860
961
|
}
|
|
861
|
-
return /* @__PURE__ */ (0,
|
|
962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
862
963
|
"div",
|
|
863
964
|
{
|
|
864
965
|
ref,
|
|
865
966
|
...props,
|
|
866
967
|
dangerouslySetInnerHTML: {
|
|
867
|
-
__html: text ?
|
|
968
|
+
__html: text ? (0, import_core3.renderMarkdown)(text) : ""
|
|
868
969
|
}
|
|
869
970
|
}
|
|
870
971
|
);
|
|
@@ -877,9 +978,12 @@ var import_core4 = require("@slopmachine/core");
|
|
|
877
978
|
// Annotate the CommonJS export names for ESM import in node:
|
|
878
979
|
0 && (module.exports = {
|
|
879
980
|
SlopImage,
|
|
981
|
+
SlopMachineError,
|
|
880
982
|
SlopText,
|
|
881
983
|
SlopVideo,
|
|
882
984
|
preloadImage,
|
|
985
|
+
preloadText,
|
|
986
|
+
preloadVideo,
|
|
883
987
|
rateResult
|
|
884
988
|
});
|
|
885
989
|
//# sourceMappingURL=index.js.map
|