@slopmachine/core 0.1.3 → 0.1.5

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.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  interface SlopImageOptions {
2
2
  bucketId: string;
3
- prompt?: string;
3
+ version?: number;
4
+ resultId?: string;
4
5
  aspectRatio?: string;
5
6
  model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
6
7
  variables?: Record<string, string | number | undefined | null>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  interface SlopImageOptions {
2
2
  bucketId: string;
3
- prompt?: string;
3
+ version?: number;
4
+ resultId?: string;
4
5
  aspectRatio?: string;
5
6
  model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
6
7
  variables?: Record<string, string | number | undefined | null>;
package/dist/index.js CHANGED
@@ -39,20 +39,26 @@ function interpolatePrompt(prompt, variables) {
39
39
  function buildImageUrl(options) {
40
40
  const {
41
41
  bucketId,
42
- prompt,
42
+ version,
43
+ resultId,
43
44
  aspectRatio = "1:1",
44
45
  model,
45
46
  variables = {},
46
47
  baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
47
48
  } = options;
48
- const finalPrompt = interpolatePrompt(prompt, variables);
49
- const params = new URLSearchParams({
50
- bucketId,
51
- aspectRatio: String(aspectRatio),
52
- ...model && { model }
53
- });
54
- if (finalPrompt) {
55
- params.set("prompt", finalPrompt);
49
+ const params = new URLSearchParams();
50
+ params.set("bucketId", bucketId);
51
+ if (aspectRatio) {
52
+ params.set("aspectRatio", aspectRatio);
53
+ }
54
+ if (model) {
55
+ params.set("model", model);
56
+ }
57
+ if (version) {
58
+ params.set("version", String(version));
59
+ }
60
+ if (resultId) {
61
+ params.set("resultId", resultId);
56
62
  }
57
63
  if (Object.keys(variables).length > 0) {
58
64
  params.set("variables", JSON.stringify(variables));
package/dist/index.mjs CHANGED
@@ -14,20 +14,26 @@ function interpolatePrompt(prompt, variables) {
14
14
  function buildImageUrl(options) {
15
15
  const {
16
16
  bucketId,
17
- prompt,
17
+ version,
18
+ resultId,
18
19
  aspectRatio = "1:1",
19
20
  model,
20
21
  variables = {},
21
22
  baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
22
23
  } = options;
23
- const finalPrompt = interpolatePrompt(prompt, variables);
24
- const params = new URLSearchParams({
25
- bucketId,
26
- aspectRatio: String(aspectRatio),
27
- ...model && { model }
28
- });
29
- if (finalPrompt) {
30
- params.set("prompt", finalPrompt);
24
+ const params = new URLSearchParams();
25
+ params.set("bucketId", bucketId);
26
+ if (aspectRatio) {
27
+ params.set("aspectRatio", aspectRatio);
28
+ }
29
+ if (model) {
30
+ params.set("model", model);
31
+ }
32
+ if (version) {
33
+ params.set("version", String(version));
34
+ }
35
+ if (resultId) {
36
+ params.set("resultId", resultId);
31
37
  }
32
38
  if (Object.keys(variables).length > 0) {
33
39
  params.set("variables", JSON.stringify(variables));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slopmachine/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -11,6 +11,9 @@
11
11
  "require": "./dist/index.js"
12
12
  }
13
13
  },
14
+ "files": [
15
+ "dist"
16
+ ],
14
17
  "scripts": {
15
18
  "build": "tsup",
16
19
  "dev": "tsup --watch"
package/src/index.ts DELETED
@@ -1,54 +0,0 @@
1
- export interface SlopImageOptions {
2
- bucketId: string;
3
- prompt?: string;
4
- aspectRatio?: string;
5
- model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
6
- variables?: Record<string, string | number | undefined | null>;
7
- baseUrl?: string;
8
- }
9
-
10
- export function interpolatePrompt(
11
- prompt?: string,
12
- variables?: Record<string, string | number | undefined | null>,
13
- ): string {
14
- if (!prompt) return "";
15
- let text = prompt;
16
- if (!variables) return text;
17
-
18
- Object.keys(variables).forEach((key) => {
19
- const value = variables[key];
20
- if (value !== undefined && value !== null) {
21
- text = text.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
22
- }
23
- });
24
- return text;
25
- }
26
-
27
- export function buildImageUrl(options: SlopImageOptions): string {
28
- const {
29
- bucketId,
30
- prompt,
31
- aspectRatio = "1:1",
32
- model,
33
- variables = {},
34
- baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage",
35
- } = options;
36
-
37
- const finalPrompt = interpolatePrompt(prompt, variables);
38
-
39
- const params = new URLSearchParams({
40
- bucketId,
41
- aspectRatio: String(aspectRatio),
42
- ...(model && { model }),
43
- });
44
-
45
- if (finalPrompt) {
46
- params.set("prompt", finalPrompt);
47
- }
48
-
49
- if (Object.keys(variables).length > 0) {
50
- params.set("variables", JSON.stringify(variables));
51
- }
52
-
53
- return `${baseUrl}?${params.toString()}`;
54
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "declaration": true,
8
- "skipLibCheck": true
9
- },
10
- "include": ["src"]
11
- }
@@ -1 +0,0 @@
1
- {"root":["./src/index.ts"],"version":"5.9.3"}
package/tsup.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- format: ["cjs", "esm"],
6
- dts: true,
7
- clean: true,
8
- });