@slopmachine/svelte 0.1.25 → 0.2.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 ADDED
@@ -0,0 +1,12 @@
1
+ # @slopmachine/svelte
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 15b923d: Switch pipeline execution parameters to use pipelineId (with optional siloId) instead of pipelineKey.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [15b923d]
12
+ - @slopmachine/core@0.2.0
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # @slopmachine/svelte
2
2
 
3
- The official Svelte wrapper for Slop Machine. Easily integrate Slop Machine image generation into your Svelte 5 applications.
3
+ The official Svelte SDK for Slop Machine. Easily integrate Slop Machine image, video, and text generation into your Svelte 5 applications.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @slopmachine/svelte
8
+ npm install @slopmachine/svelte @slopmachine/core
9
9
  # or
10
- yarn add @slopmachine/svelte
10
+ yarn add @slopmachine/svelte @slopmachine/core
11
11
  # or
12
- pnpm add @slopmachine/svelte
12
+ pnpm add @slopmachine/svelte @slopmachine/core
13
13
  ```
14
14
 
15
15
  ## Demo
@@ -18,33 +18,66 @@ https://docs.slopmachine.dev/demo-svelte/
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### 1. Using Pre-Templated Buckets
22
+
21
23
  ```svelte
22
24
  <script lang="ts">
23
- import { SlopImage } from "@slopmachine/svelte";
25
+ import { SlopImage, SlopVideo, SlopText } from "@slopmachine/svelte";
24
26
  </script>
25
27
 
26
- <div style="width: 400px; height: 400px;">
28
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
27
29
  <SlopImage
28
- prompt={"A cute dog wearing a hat in a {style} style"}
30
+ bucketId="my-bucket-id"
29
31
  aspectRatio="1:1"
30
- variables={{ style: "realistic" }}
32
+ variables={{ style: "realistic", character: "owl" }}
33
+ class="rounded-lg shadow"
34
+ />
35
+
36
+ <SlopVideo
37
+ bucketId="my-video-bucket"
38
+ aspectRatio="16:9"
39
+ duration={4}
40
+ autoplay
41
+ loop
42
+ muted
43
+ />
44
+
45
+ <SlopText
46
+ bucketId="my-text-bucket"
47
+ variables={{ item: "magical sword" }}
31
48
  />
32
49
  </div>
33
50
  ```
34
51
 
35
- ## API / Props
52
+ ### 2. Using Dynamic Multi-Step Pipelines
53
+
54
+ Pipelines give developers runtime prompt flexibility and multi-step AI chaining:
55
+
56
+ ```svelte
57
+ <script lang="ts">
58
+ import { SlopImage, SlopVideo, SlopText } from "@slopmachine/svelte";
59
+ </script>
36
60
 
37
- ### `SlopImage`
61
+ <div>
62
+ <SlopImage
63
+ pipelineId="pipe_live_abc123"
64
+ prompt="A futuristic neon marketplace in Tokyo at dusk"
65
+ aspectRatio="16:9"
66
+ metadata={{ source: "user-generated-content" }}
67
+ />
38
68
 
39
- The `SlopImage` component inherits standard HTML `<img>` attributes and accepts the following additional props:
69
+ <SlopVideo
70
+ pipelineId="pipe_live_def456"
71
+ prompt="Hyperlapse sunset over Martian red sand dunes"
72
+ aspectRatio="9:16"
73
+ />
40
74
 
41
- | Prop | Type | Default | Description |
42
- | :------------ | :----------------------- | :----------- | :------------------------------------------------------ |
43
- | `prompt` | `string` | **Required** | The prompt to use for image generation. |
44
- | `aspectRatio` | `string` | `"1:1"` | The aspect ratio of the image (e.g. `"16:9"`, `"1:1"`). |
45
- | `variables` | `Record<string, string>` | `{}` | Variables to interpolate into the prompt. |
46
- | `model` | `string` | `undefined` | The AI model to use for generation. |
47
- | `baseUrl` | `string` | `undefined` | Custom base URL for the Slop Machine API. |
75
+ <SlopText
76
+ pipelineId="pipe_live_ghi789"
77
+ prompt="Write an intro paragraph for a sci-fi novel about sentient houseplants"
78
+ />
79
+ </div>
80
+ ```
48
81
 
49
82
  ## License
50
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slopmachine/svelte",
3
- "version": "0.1.25",
3
+ "version": "0.2.0",
4
4
  "llms": "https://docs.slopmachine.dev/llms.txt",
5
5
  "llmsFull": "https://docs.slopmachine.dev/llms-full.txt",
6
6
  "description": "The official Svelte SDK for Slop Machine",
@@ -19,7 +19,7 @@
19
19
  "url": "git+https://github.com/slopmachine-dev/slopmachine-sdk.git"
20
20
  },
21
21
  "dependencies": {
22
- "@slopmachine/core": "^0.1.25",
22
+ "@slopmachine/core": "^0.2.0",
23
23
  "@types/marked": "^5.0.2",
24
24
  "marked": "^17.0.4"
25
25
  },
@@ -15,7 +15,7 @@
15
15
  />
16
16
  ```
17
17
 
18
- @version 0.1.25
18
+ @version 0.2.0
19
19
  -->
20
20
  <script lang="ts">
21
21
  import {
@@ -50,13 +50,18 @@
50
50
  * Additional CSS classes to apply directly to the `<img />` element.
51
51
  */
52
52
  imageClass?: string;
53
+ [key: string]: any;
53
54
  }
54
55
 
55
56
  let {
56
- bucketId,
57
+ bucketId = undefined,
58
+ pipelineId = undefined,
59
+ siloId = undefined,
60
+ prompt = undefined,
61
+ metadata = undefined,
57
62
  aspectRatio = "1:1",
58
- version,
59
- resultId,
63
+ version = undefined,
64
+ resultId = undefined,
60
65
  quality = "fast",
61
66
  variables = {},
62
67
  baseUrl = undefined,
@@ -66,6 +71,8 @@
66
71
  objectFit = "cover",
67
72
  imageClass = "",
68
73
  loader,
74
+ onload,
75
+ onerror,
69
76
  ...restProps
70
77
  }: SlopImageProps = $props();
71
78
 
@@ -74,6 +81,10 @@
74
81
  let computedSrc = $derived(
75
82
  buildImageUrl({
76
83
  bucketId,
84
+ pipelineId,
85
+ siloId,
86
+ prompt,
87
+ metadata,
77
88
  aspectRatio,
78
89
  version,
79
90
  resultId,
@@ -142,12 +153,14 @@
142
153
  }
143
154
  });
144
155
 
145
- function handleLoad() {
156
+ function handleLoad(e: Event) {
146
157
  isLoading = false;
158
+ onload?.(e);
147
159
  }
148
160
 
149
- function handleError() {
161
+ function handleError(e: Event) {
150
162
  isLoading = false;
163
+ onerror?.(e);
151
164
  }
152
165
  </script>
153
166
 
@@ -193,10 +206,10 @@
193
206
  {src}
194
207
  {alt}
195
208
  style="object-fit: {objectFit};"
196
- onload={handleLoad}
197
- onerror={handleError}
198
209
  class="slop-image {imageClass} {isLoading ? '' : 'loaded'}"
199
210
  {...restProps}
211
+ onload={handleLoad}
212
+ onerror={handleError}
200
213
  />
201
214
  </div>
202
215
  </div>
@@ -23,11 +23,15 @@
23
23
  * </SlopText>
24
24
  * ```
25
25
  *
26
- * @version 0.1.25
26
+ * @version 0.2.0
27
27
  */
28
28
  interface Props {
29
29
  // SlopTextOptions
30
- bucketId: string;
30
+ bucketId?: string | undefined;
31
+ pipelineId?: string | undefined;
32
+ siloId?: string | undefined;
33
+ prompt?: string | undefined;
34
+ metadata?: Record<string, any> | undefined;
31
35
  version?: number | undefined;
32
36
  resultId?: string | undefined;
33
37
  model?: string | undefined;
@@ -42,7 +46,11 @@
42
46
  }
43
47
 
44
48
  let {
45
- bucketId,
49
+ bucketId = undefined,
50
+ pipelineId = undefined,
51
+ siloId = undefined,
52
+ prompt = undefined,
53
+ metadata = undefined,
46
54
  version = undefined,
47
55
  resultId = undefined,
48
56
  model = undefined,
@@ -70,6 +78,10 @@
70
78
 
71
79
  const url = buildTextUrl({
72
80
  bucketId,
81
+ pipelineId,
82
+ siloId,
83
+ prompt,
84
+ metadata,
73
85
  version,
74
86
  resultId,
75
87
  variables,
@@ -18,7 +18,7 @@
18
18
  />
19
19
  ```
20
20
 
21
- @version 0.1.25
21
+ @version 0.2.0
22
22
  -->
23
23
  <script lang="ts">
24
24
  import {
@@ -53,10 +53,14 @@
53
53
  }
54
54
 
55
55
  let {
56
- bucketId,
56
+ bucketId = undefined,
57
+ pipelineId = undefined,
58
+ siloId = undefined,
59
+ prompt = undefined,
60
+ metadata = undefined,
57
61
  aspectRatio = "16:9",
58
- version,
59
- resultId,
62
+ version = undefined,
63
+ resultId = undefined,
60
64
  model,
61
65
  quality = "fast",
62
66
  variables = {},
@@ -70,6 +74,8 @@
70
74
  loop = true,
71
75
  muted = true,
72
76
  playsinline = true,
77
+ onloadeddata,
78
+ onerror,
73
79
  ...restProps
74
80
  }: SlopVideoProps = $props();
75
81
 
@@ -78,6 +84,10 @@
78
84
  let computedSrc = $derived(
79
85
  buildVideoUrl({
80
86
  bucketId,
87
+ pipelineId,
88
+ siloId,
89
+ prompt,
90
+ metadata,
81
91
  aspectRatio,
82
92
  version,
83
93
  resultId,
@@ -146,12 +156,14 @@
146
156
  }
147
157
  });
148
158
 
149
- function handleLoadedData() {
159
+ function handleLoadedData(e: Event) {
150
160
  isLoading = false;
161
+ onloadeddata?.(e);
151
162
  }
152
163
 
153
- function handleError() {
164
+ function handleError(e: Event) {
154
165
  isLoading = false;
166
+ onerror?.(e);
155
167
  }
156
168
  </script>
157
169
 
@@ -200,10 +212,10 @@
200
212
  {loop}
201
213
  {muted}
202
214
  {playsinline}
203
- onloadeddata={handleLoadedData}
204
- onerror={handleError}
205
215
  class:loaded={!isLoading}
206
216
  {...restProps}
217
+ onloadeddata={handleLoadedData}
218
+ onerror={handleError}
207
219
  ></video>
208
220
  </div>
209
221
  </div>
File without changes