@slopmachine/core 0.0.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/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +58 -0
- package/dist/index.mjs +32 -0
- package/package.json +22 -0
- package/src/index.ts +43 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +8 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface SlopMachineOptions {
|
|
2
|
+
prompt: string;
|
|
3
|
+
aspectRatio?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function interpolatePrompt(prompt: string, variables?: Record<string, string | number | undefined | null>): string;
|
|
9
|
+
declare function buildImageUrl(options: SlopMachineOptions): string;
|
|
10
|
+
|
|
11
|
+
export { type SlopMachineOptions, buildImageUrl, interpolatePrompt };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface SlopMachineOptions {
|
|
2
|
+
prompt: string;
|
|
3
|
+
aspectRatio?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function interpolatePrompt(prompt: string, variables?: Record<string, string | number | undefined | null>): string;
|
|
9
|
+
declare function buildImageUrl(options: SlopMachineOptions): string;
|
|
10
|
+
|
|
11
|
+
export { type SlopMachineOptions, buildImageUrl, interpolatePrompt };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
buildImageUrl: () => buildImageUrl,
|
|
24
|
+
interpolatePrompt: () => interpolatePrompt
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
function interpolatePrompt(prompt, variables) {
|
|
28
|
+
let text = prompt;
|
|
29
|
+
if (!variables) return text;
|
|
30
|
+
Object.keys(variables).forEach((key) => {
|
|
31
|
+
const value = variables[key];
|
|
32
|
+
if (value !== void 0 && value !== null) {
|
|
33
|
+
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return text;
|
|
37
|
+
}
|
|
38
|
+
function buildImageUrl(options) {
|
|
39
|
+
const {
|
|
40
|
+
prompt,
|
|
41
|
+
aspectRatio = "1:1",
|
|
42
|
+
model,
|
|
43
|
+
variables = {},
|
|
44
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
|
|
45
|
+
} = options;
|
|
46
|
+
const finalPrompt = interpolatePrompt(prompt, variables);
|
|
47
|
+
const params = new URLSearchParams({
|
|
48
|
+
prompt: finalPrompt,
|
|
49
|
+
aspectRatio: String(aspectRatio),
|
|
50
|
+
...model && { model }
|
|
51
|
+
});
|
|
52
|
+
return `${baseUrl}?${params.toString()}`;
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
buildImageUrl,
|
|
57
|
+
interpolatePrompt
|
|
58
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function interpolatePrompt(prompt, variables) {
|
|
3
|
+
let text = prompt;
|
|
4
|
+
if (!variables) return text;
|
|
5
|
+
Object.keys(variables).forEach((key) => {
|
|
6
|
+
const value = variables[key];
|
|
7
|
+
if (value !== void 0 && value !== null) {
|
|
8
|
+
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return text;
|
|
12
|
+
}
|
|
13
|
+
function buildImageUrl(options) {
|
|
14
|
+
const {
|
|
15
|
+
prompt,
|
|
16
|
+
aspectRatio = "1:1",
|
|
17
|
+
model,
|
|
18
|
+
variables = {},
|
|
19
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage"
|
|
20
|
+
} = options;
|
|
21
|
+
const finalPrompt = interpolatePrompt(prompt, variables);
|
|
22
|
+
const params = new URLSearchParams({
|
|
23
|
+
prompt: finalPrompt,
|
|
24
|
+
aspectRatio: String(aspectRatio),
|
|
25
|
+
...model && { model }
|
|
26
|
+
});
|
|
27
|
+
return `${baseUrl}?${params.toString()}`;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
buildImageUrl,
|
|
31
|
+
interpolatePrompt
|
|
32
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slopmachine/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsup --watch"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"tsup": "^8.0.0",
|
|
20
|
+
"typescript": "^5.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface SlopMachineOptions {
|
|
2
|
+
prompt: string;
|
|
3
|
+
aspectRatio?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
variables?: Record<string, string | number | undefined | null>;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function interpolatePrompt(
|
|
10
|
+
prompt: string,
|
|
11
|
+
variables?: Record<string, string | number | undefined | null>,
|
|
12
|
+
): string {
|
|
13
|
+
let text = prompt;
|
|
14
|
+
if (!variables) return text;
|
|
15
|
+
|
|
16
|
+
Object.keys(variables).forEach((key) => {
|
|
17
|
+
const value = variables[key];
|
|
18
|
+
if (value !== undefined && value !== null) {
|
|
19
|
+
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function buildImageUrl(options: SlopMachineOptions): string {
|
|
26
|
+
const {
|
|
27
|
+
prompt,
|
|
28
|
+
aspectRatio = "1:1",
|
|
29
|
+
model,
|
|
30
|
+
variables = {},
|
|
31
|
+
baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage",
|
|
32
|
+
} = options;
|
|
33
|
+
|
|
34
|
+
const finalPrompt = interpolatePrompt(prompt, variables);
|
|
35
|
+
|
|
36
|
+
const params = new URLSearchParams({
|
|
37
|
+
prompt: finalPrompt,
|
|
38
|
+
aspectRatio: String(aspectRatio),
|
|
39
|
+
...(model && { model }),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return `${baseUrl}?${params.toString()}`;
|
|
43
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/index.ts"],"version":"5.9.3"}
|