@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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -9
- package/dist/index.mjs +15 -9
- package/package.json +4 -1
- package/src/index.ts +0 -54
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -8
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
aspectRatio
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
aspectRatio
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
"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
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts"],"version":"5.9.3"}
|