@slopmachine/core 0.1.4 → 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/package.json +4 -1
- package/src/index.ts +0 -61
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -8
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,61 +0,0 @@
|
|
|
1
|
-
export interface SlopImageOptions {
|
|
2
|
-
bucketId: string;
|
|
3
|
-
version?: number;
|
|
4
|
-
resultId?: string;
|
|
5
|
-
aspectRatio?: string;
|
|
6
|
-
model?: "gemini" | "gemini-flash" | "gemini-pro" | "imagen";
|
|
7
|
-
variables?: Record<string, string | number | undefined | null>;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function interpolatePrompt(
|
|
12
|
-
prompt?: string,
|
|
13
|
-
variables?: Record<string, string | number | undefined | null>,
|
|
14
|
-
): string {
|
|
15
|
-
if (!prompt) return "";
|
|
16
|
-
let text = prompt;
|
|
17
|
-
if (!variables) return text;
|
|
18
|
-
|
|
19
|
-
Object.keys(variables).forEach((key) => {
|
|
20
|
-
const value = variables[key];
|
|
21
|
-
if (value !== undefined && value !== null) {
|
|
22
|
-
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return text;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function buildImageUrl(options: SlopImageOptions): string {
|
|
29
|
-
const {
|
|
30
|
-
bucketId,
|
|
31
|
-
version,
|
|
32
|
-
resultId,
|
|
33
|
-
aspectRatio = "1:1",
|
|
34
|
-
model,
|
|
35
|
-
variables = {},
|
|
36
|
-
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage",
|
|
37
|
-
} = options;
|
|
38
|
-
|
|
39
|
-
const params = new URLSearchParams();
|
|
40
|
-
params.set("bucketId", bucketId);
|
|
41
|
-
|
|
42
|
-
if (aspectRatio) {
|
|
43
|
-
params.set("aspectRatio", aspectRatio);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (model) {
|
|
47
|
-
params.set("model", model);
|
|
48
|
-
}
|
|
49
|
-
if (version) {
|
|
50
|
-
params.set("version", String(version));
|
|
51
|
-
}
|
|
52
|
-
if (resultId) {
|
|
53
|
-
params.set("resultId", resultId);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (Object.keys(variables).length > 0) {
|
|
57
|
-
params.set("variables", JSON.stringify(variables));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return `${baseUrl}?${params.toString()}`;
|
|
61
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts"],"version":"5.9.3"}
|