@slopmachine/core 0.0.1 → 0.1.1

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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @slopmachine/core
2
+
3
+ The core logic and shared utilities for the Slop Machine SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @slopmachine/core
9
+ # or
10
+ yarn add @slopmachine/core
11
+ # or
12
+ pnpm add @slopmachine/core
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ This package provides the core functions and type definitions used by the Slop Machine framework integrations (like `@slopmachine/react` and `@slopmachine/svelte`).
18
+
19
+ ## License
20
+
21
+ MIT
package/dist/index.d.mts CHANGED
@@ -1,11 +1,12 @@
1
- interface SlopMachineOptions {
2
- prompt: string;
1
+ interface SlopImageOptions {
2
+ bucketId: string;
3
+ prompt?: string;
3
4
  aspectRatio?: string;
4
- model?: string;
5
+ model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
5
6
  variables?: Record<string, string | number | undefined | null>;
6
7
  baseUrl?: string;
7
8
  }
8
- declare function interpolatePrompt(prompt: string, variables?: Record<string, string | number | undefined | null>): string;
9
- declare function buildImageUrl(options: SlopMachineOptions): string;
9
+ declare function interpolatePrompt(prompt?: string, variables?: Record<string, string | number | undefined | null>): string;
10
+ declare function buildImageUrl(options: SlopImageOptions): string;
10
11
 
11
- export { type SlopMachineOptions, buildImageUrl, interpolatePrompt };
12
+ export { type SlopImageOptions, buildImageUrl, interpolatePrompt };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- interface SlopMachineOptions {
2
- prompt: string;
1
+ interface SlopImageOptions {
2
+ bucketId: string;
3
+ prompt?: string;
3
4
  aspectRatio?: string;
4
- model?: string;
5
+ model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
5
6
  variables?: Record<string, string | number | undefined | null>;
6
7
  baseUrl?: string;
7
8
  }
8
- declare function interpolatePrompt(prompt: string, variables?: Record<string, string | number | undefined | null>): string;
9
- declare function buildImageUrl(options: SlopMachineOptions): string;
9
+ declare function interpolatePrompt(prompt?: string, variables?: Record<string, string | number | undefined | null>): string;
10
+ declare function buildImageUrl(options: SlopImageOptions): string;
10
11
 
11
- export { type SlopMachineOptions, buildImageUrl, interpolatePrompt };
12
+ export { type SlopImageOptions, buildImageUrl, interpolatePrompt };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
  function interpolatePrompt(prompt, variables) {
28
+ if (!prompt) return "";
28
29
  let text = prompt;
29
30
  if (!variables) return text;
30
31
  Object.keys(variables).forEach((key) => {
@@ -37,6 +38,7 @@ function interpolatePrompt(prompt, variables) {
37
38
  }
38
39
  function buildImageUrl(options) {
39
40
  const {
41
+ bucketId,
40
42
  prompt,
41
43
  aspectRatio = "1:1",
42
44
  model,
@@ -45,10 +47,19 @@ function buildImageUrl(options) {
45
47
  } = options;
46
48
  const finalPrompt = interpolatePrompt(prompt, variables);
47
49
  const params = new URLSearchParams({
48
- prompt: finalPrompt,
50
+ bucketId,
49
51
  aspectRatio: String(aspectRatio),
50
52
  ...model && { model }
51
53
  });
54
+ if (finalPrompt) {
55
+ params.set("prompt", finalPrompt);
56
+ }
57
+ Object.keys(variables).forEach((key) => {
58
+ const value = variables[key];
59
+ if (value !== void 0 && value !== null) {
60
+ params.set(key, String(value));
61
+ }
62
+ });
52
63
  return `${baseUrl}?${params.toString()}`;
53
64
  }
54
65
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/index.ts
2
2
  function interpolatePrompt(prompt, variables) {
3
+ if (!prompt) return "";
3
4
  let text = prompt;
4
5
  if (!variables) return text;
5
6
  Object.keys(variables).forEach((key) => {
@@ -12,6 +13,7 @@ function interpolatePrompt(prompt, variables) {
12
13
  }
13
14
  function buildImageUrl(options) {
14
15
  const {
16
+ bucketId,
15
17
  prompt,
16
18
  aspectRatio = "1:1",
17
19
  model,
@@ -20,10 +22,19 @@ function buildImageUrl(options) {
20
22
  } = options;
21
23
  const finalPrompt = interpolatePrompt(prompt, variables);
22
24
  const params = new URLSearchParams({
23
- prompt: finalPrompt,
25
+ bucketId,
24
26
  aspectRatio: String(aspectRatio),
25
27
  ...model && { model }
26
28
  });
29
+ if (finalPrompt) {
30
+ params.set("prompt", finalPrompt);
31
+ }
32
+ Object.keys(variables).forEach((key) => {
33
+ const value = variables[key];
34
+ if (value !== void 0 && value !== null) {
35
+ params.set(key, String(value));
36
+ }
37
+ });
27
38
  return `${baseUrl}?${params.toString()}`;
28
39
  }
29
40
  export {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@slopmachine/core",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.mjs",
10
- "require": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
11
+ "require": "./dist/index.js"
12
12
  }
13
13
  },
14
14
  "scripts": {
package/src/index.ts CHANGED
@@ -1,15 +1,17 @@
1
- export interface SlopMachineOptions {
2
- prompt: string;
1
+ export interface SlopImageOptions {
2
+ bucketId: string;
3
+ prompt?: string;
3
4
  aspectRatio?: string;
4
- model?: string;
5
+ model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
5
6
  variables?: Record<string, string | number | undefined | null>;
6
7
  baseUrl?: string;
7
8
  }
8
9
 
9
10
  export function interpolatePrompt(
10
- prompt: string,
11
+ prompt?: string,
11
12
  variables?: Record<string, string | number | undefined | null>,
12
13
  ): string {
14
+ if (!prompt) return "";
13
15
  let text = prompt;
14
16
  if (!variables) return text;
15
17
 
@@ -22,8 +24,9 @@ export function interpolatePrompt(
22
24
  return text;
23
25
  }
24
26
 
25
- export function buildImageUrl(options: SlopMachineOptions): string {
27
+ export function buildImageUrl(options: SlopImageOptions): string {
26
28
  const {
29
+ bucketId,
27
30
  prompt,
28
31
  aspectRatio = "1:1",
29
32
  model,
@@ -34,10 +37,21 @@ export function buildImageUrl(options: SlopMachineOptions): string {
34
37
  const finalPrompt = interpolatePrompt(prompt, variables);
35
38
 
36
39
  const params = new URLSearchParams({
37
- prompt: finalPrompt,
40
+ bucketId,
38
41
  aspectRatio: String(aspectRatio),
39
42
  ...(model && { model }),
40
43
  });
41
44
 
45
+ if (finalPrompt) {
46
+ params.set("prompt", finalPrompt);
47
+ }
48
+
49
+ Object.keys(variables).forEach((key) => {
50
+ const value = variables[key];
51
+ if (value !== undefined && value !== null) {
52
+ params.set(key, String(value));
53
+ }
54
+ });
55
+
42
56
  return `${baseUrl}?${params.toString()}`;
43
57
  }