@slopmachine/core 0.1.14 → 0.1.15

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
@@ -92,5 +92,37 @@ interface SlopVideoOptions {
92
92
  baseUrl?: string;
93
93
  }
94
94
  declare function buildVideoUrl(options: SlopVideoOptions): string;
95
+ interface SlopTextOptions {
96
+ /**
97
+ * The unique identifier of your Slop Machine bucket.
98
+ */
99
+ bucketId: string;
100
+ /**
101
+ * The specific version of the prompt/settings to use.
102
+ * If omitted, the latest version will be used.
103
+ */
104
+ version?: number;
105
+ /**
106
+ * Result ID to retrieve a specific previously generated text
107
+ * instead of generating a new one.
108
+ */
109
+ resultId?: string;
110
+ /**
111
+ * The AI model to use for generation.
112
+ * Overrides the default model specified in the bucket settings.
113
+ */
114
+ model?: string;
115
+ /**
116
+ * Dynamic variables to interpolate into the prompt.
117
+ * E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
118
+ */
119
+ variables?: Record<string, string | number | undefined | null>;
120
+ /**
121
+ * The base URL for the Slop Machine API.
122
+ * Defaults to the production URL. Useful for testing against local deployments.
123
+ */
124
+ baseUrl?: string;
125
+ }
126
+ declare function buildTextUrl(options: SlopTextOptions): string;
95
127
 
96
- export { type ImageAspectRatio, type SlopImageOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildVideoUrl, interpolatePrompt };
128
+ export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt };
package/dist/index.d.ts CHANGED
@@ -92,5 +92,37 @@ interface SlopVideoOptions {
92
92
  baseUrl?: string;
93
93
  }
94
94
  declare function buildVideoUrl(options: SlopVideoOptions): string;
95
+ interface SlopTextOptions {
96
+ /**
97
+ * The unique identifier of your Slop Machine bucket.
98
+ */
99
+ bucketId: string;
100
+ /**
101
+ * The specific version of the prompt/settings to use.
102
+ * If omitted, the latest version will be used.
103
+ */
104
+ version?: number;
105
+ /**
106
+ * Result ID to retrieve a specific previously generated text
107
+ * instead of generating a new one.
108
+ */
109
+ resultId?: string;
110
+ /**
111
+ * The AI model to use for generation.
112
+ * Overrides the default model specified in the bucket settings.
113
+ */
114
+ model?: string;
115
+ /**
116
+ * Dynamic variables to interpolate into the prompt.
117
+ * E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
118
+ */
119
+ variables?: Record<string, string | number | undefined | null>;
120
+ /**
121
+ * The base URL for the Slop Machine API.
122
+ * Defaults to the production URL. Useful for testing against local deployments.
123
+ */
124
+ baseUrl?: string;
125
+ }
126
+ declare function buildTextUrl(options: SlopTextOptions): string;
95
127
 
96
- export { type ImageAspectRatio, type SlopImageOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildVideoUrl, interpolatePrompt };
128
+ export { type ImageAspectRatio, type SlopImageOptions, type SlopTextOptions, type SlopVideoOptions, type VideoAspectRatio, buildImageUrl, buildTextUrl, buildVideoUrl, interpolatePrompt };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  buildImageUrl: () => buildImageUrl,
24
+ buildTextUrl: () => buildTextUrl,
24
25
  buildVideoUrl: () => buildVideoUrl,
25
26
  interpolatePrompt: () => interpolatePrompt
26
27
  });
@@ -98,12 +99,6 @@ function buildVideoUrl(options) {
98
99
  if (resultId) {
99
100
  params.set("resultId", resultId);
100
101
  } else {
101
- const clampedDuration = Math.max(4, Math.min(8, duration));
102
- params.set("duration", String(clampedDuration));
103
- }
104
- if (quality && quality !== "fast") {
105
- params.set("quality", quality);
106
- } else if (quality === "fast") {
107
102
  params.set("quality", "fast");
108
103
  }
109
104
  if (Object.keys(variables).length > 0) {
@@ -111,9 +106,35 @@ function buildVideoUrl(options) {
111
106
  }
112
107
  return `${baseUrl}?${params.toString()}`;
113
108
  }
109
+ function buildTextUrl(options) {
110
+ const {
111
+ bucketId,
112
+ version,
113
+ resultId,
114
+ model,
115
+ variables = {},
116
+ baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText"
117
+ } = options;
118
+ const params = new URLSearchParams();
119
+ params.set("bucketId", bucketId);
120
+ if (model) {
121
+ params.set("model", model);
122
+ }
123
+ if (version) {
124
+ params.set("version", String(version));
125
+ }
126
+ if (resultId) {
127
+ params.set("resultId", resultId);
128
+ }
129
+ if (Object.keys(variables).length > 0) {
130
+ params.set("variables", JSON.stringify(variables));
131
+ }
132
+ return `${baseUrl}?${params.toString()}`;
133
+ }
114
134
  // Annotate the CommonJS export names for ESM import in node:
115
135
  0 && (module.exports = {
116
136
  buildImageUrl,
137
+ buildTextUrl,
117
138
  buildVideoUrl,
118
139
  interpolatePrompt
119
140
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n // Only append duration if resultId is NOT provided\n const clampedDuration = Math.max(4, Math.min(8, duration));\n params.set(\"duration\", String(clampedDuration));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuDO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,M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AAW;AAAA,IACX,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,aAAa;AACf,WAAO,IAAI,eAAe,WAAW;AAAA,EACvC;AAEA,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,WAAO,IAAI,WAAW,OAAO,OAAO,CAAC;AAAA,EACvC;AACA,MAAI,UAAU;AACZ,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC,OAAO;AAEL,UAAM,kBAAkB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,CAAC;AACzD,WAAO,IAAI,YAAY,OAAO,eAAe,CAAC;AAAA,EAChD;AACA,MAAI,WAAW,YAAY,QAAQ;AACjC,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B,WAAW,YAAY,QAAQ;AAC7B,WAAO,IAAI,WAAW,MAAM;AAAA,EAC9B;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n version,\n resultId,\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuDO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IAC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,IAAI,WAAW,MAAM;AAAA,EAC9B;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;AAkCO,SAAS,aAAa,SAAkC;AAC7D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,CAAC;AAAA,IACb,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,WAAO,IAAI,WAAW,OAAO,OAAO,CAAC;AAAA,EACvC;AACA,MAAI,UAAU;AACZ,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
package/dist/index.mjs CHANGED
@@ -72,12 +72,6 @@ function buildVideoUrl(options) {
72
72
  if (resultId) {
73
73
  params.set("resultId", resultId);
74
74
  } else {
75
- const clampedDuration = Math.max(4, Math.min(8, duration));
76
- params.set("duration", String(clampedDuration));
77
- }
78
- if (quality && quality !== "fast") {
79
- params.set("quality", quality);
80
- } else if (quality === "fast") {
81
75
  params.set("quality", "fast");
82
76
  }
83
77
  if (Object.keys(variables).length > 0) {
@@ -85,8 +79,34 @@ function buildVideoUrl(options) {
85
79
  }
86
80
  return `${baseUrl}?${params.toString()}`;
87
81
  }
82
+ function buildTextUrl(options) {
83
+ const {
84
+ bucketId,
85
+ version,
86
+ resultId,
87
+ model,
88
+ variables = {},
89
+ baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText"
90
+ } = options;
91
+ const params = new URLSearchParams();
92
+ params.set("bucketId", bucketId);
93
+ if (model) {
94
+ params.set("model", model);
95
+ }
96
+ if (version) {
97
+ params.set("version", String(version));
98
+ }
99
+ if (resultId) {
100
+ params.set("resultId", resultId);
101
+ }
102
+ if (Object.keys(variables).length > 0) {
103
+ params.set("variables", JSON.stringify(variables));
104
+ }
105
+ return `${baseUrl}?${params.toString()}`;
106
+ }
88
107
  export {
89
108
  buildImageUrl,
109
+ buildTextUrl,
90
110
  buildVideoUrl,
91
111
  interpolatePrompt
92
112
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n // Only append duration if resultId is NOT provided\n const clampedDuration = Math.max(4, Math.min(8, duration));\n params.set(\"duration\", String(clampedDuration));\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":";AAuDO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,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S;AACX,WAAO,IAAI,WAAW,OAAO,OAAO,CAAC;AAAA,EACvC;AACA,MAAI,UAAU;AACZ,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC,OAAO;AAEL,UAAM,kBAAkB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,CAAC;AACzD,WAAO,IAAI,YAAY,OAAO,eAAe,CAAC;AAAA,EAChD;AACA,MAAI,WAAW,YAAY,QAAQ;AACjC,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B,WAAW,YAAY,QAAQ;AAC7B,WAAO,IAAI,WAAW,MAAM;AAAA,EAC9B;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type ImageAspectRatio =\n | \"1:1\"\n | \"2:3\"\n | \"3:2\"\n | \"3:4\"\n | \"4:3\"\n | \"4:5\"\n | \"5:4\"\n | \"9:16\"\n | \"16:9\"\n | \"21:9\";\n\nexport interface SlopImageOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated image\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated image. Defaults to \"1:1\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: ImageAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: \"gemini\" | \"gemini-flash\" | \"gemini-pro\" | \"imagen\";\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A photo of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function interpolatePrompt(\n prompt?: string,\n variables?: Record<string, string | number | undefined | null>,\n): string {\n if (!prompt) return \"\";\n let text = prompt;\n if (!variables) return text;\n\n Object.keys(variables).forEach((key) => {\n const value = variables[key];\n if (value !== undefined && value !== null) {\n text = text.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), String(value));\n }\n });\n return text;\n}\n\nexport function buildImageUrl(options: SlopImageOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"1:1\",\n model,\n quality = \"fast\",\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderImage\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n if (quality && quality !== \"fast\") {\n params.set(\"quality\", quality);\n } else if (quality === \"fast\") {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport type VideoAspectRatio = \"9:16\" | \"16:9\";\n\nexport interface SlopVideoOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated video\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The aspect ratio of the generated video. Defaults to \"16:9\".\n * Common values: \"1:1\", \"16:9\", \"9:16\", \"4:3\", \"3:4\".\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A video of a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The duration of the generated video in seconds.\n * Must be between 4 and 8. Defaults to 4.\n */\n duration?: number;\n /**\n * The target quality (\"fast\" or \"high\"). Only affects new generations and is ignored for caching.\n * Ignored if `model` is provided.\n * Defaults to \"fast\".\n */\n quality?: \"fast\" | \"high\";\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildVideoUrl(options: SlopVideoOptions): string {\n const {\n bucketId,\n version,\n resultId,\n aspectRatio = \"16:9\",\n model,\n quality = \"fast\",\n variables = {},\n duration = 4,\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderVideo\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (aspectRatio) {\n params.set(\"aspectRatio\", aspectRatio);\n }\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n } else {\n params.set(\"quality\", \"fast\");\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n\nexport interface SlopTextOptions {\n /**\n * The unique identifier of your Slop Machine bucket.\n */\n bucketId: string;\n /**\n * The specific version of the prompt/settings to use.\n * If omitted, the latest version will be used.\n */\n version?: number;\n /**\n * Result ID to retrieve a specific previously generated text\n * instead of generating a new one.\n */\n resultId?: string;\n /**\n * The AI model to use for generation.\n * Overrides the default model specified in the bucket settings.\n */\n model?: string;\n /**\n * Dynamic variables to interpolate into the prompt.\n * E.g., if prompt is \"A story about a {color} dog\", pass { color: \"brown\" }.\n */\n variables?: Record<string, string | number | undefined | null>;\n /**\n * The base URL for the Slop Machine API.\n * Defaults to the production URL. Useful for testing against local deployments.\n */\n baseUrl?: string;\n}\n\nexport function buildTextUrl(options: SlopTextOptions): string {\n const {\n bucketId,\n version,\n resultId,\n model,\n variables = {},\n baseUrl = \"https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText\",\n } = options;\n\n const params = new URLSearchParams();\n params.set(\"bucketId\", bucketId);\n\n if (model) {\n params.set(\"model\", model);\n }\n if (version) {\n params.set(\"version\", String(version));\n }\n if (resultId) {\n params.set(\"resultId\", resultId);\n }\n\n if (Object.keys(variables).length > 0) {\n params.set(\"variables\", JSON.stringify(variables));\n }\n\n return `${baseUrl}?${params.toString()}`;\n}\n"],"mappings":";AAuDO,SAAS,kBACd,QACA,WACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,OAAO;AACX,MAAI,CAAC,UAAW,QAAO;AAEvB,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AACtC,UAAM,QAAQ,UAAU,GAAG;AAC3B,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,aAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;AAAA,IACpE;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEO,SAAS,cAAc,SAAmC;AAC/D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,UAAU;AAAA,IACV,YAAY,CAAC;AAAA,IACb,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,aAAa;AACf,WAAO,IAAI,eAAe,WAAW;AAAA,EACvC;AAEA,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,WAAO,IAA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b,UAAU;AAAA,EACZ,IAAI;AAEJ,QAAM,SAAS,IAAI,gBAAgB;AACnC,SAAO,IAAI,YAAY,QAAQ;AAE/B,MAAI,OAAO;AACT,WAAO,IAAI,SAAS,KAAK;AAAA,EAC3B;AACA,MAAI,SAAS;AACX,WAAO,IAAI,WAAW,OAAO,OAAO,CAAC;AAAA,EACvC;AACA,MAAI,UAAU;AACZ,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC;AAEA,MAAI,OAAO,KAAK,SAAS,EAAE,SAAS,GAAG;AACrC,WAAO,IAAI,aAAa,KAAK,UAAU,SAAS,CAAC;AAAA,EACnD;AAEA,SAAO,GAAG,OAAO,IAAI,OAAO,SAAS,CAAC;AACxC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@slopmachine/core",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
+ "description": "The official Core / VanillaJS SDK for Slop Machine",
5
+ "llms": "https://slopmachine-dev.github.io/slopmachine-sdk/llms.txt",
6
+ "llmsFull": "https://slopmachine-dev.github.io/slopmachine-sdk/llms-full.txt",
4
7
  "main": "dist/index.js",
5
8
  "module": "dist/index.mjs",
6
9
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -190,13 +190,6 @@ export function buildVideoUrl(options: SlopVideoOptions): string {
190
190
  if (resultId) {
191
191
  params.set("resultId", resultId);
192
192
  } else {
193
- // Only append duration if resultId is NOT provided
194
- const clampedDuration = Math.max(4, Math.min(8, duration));
195
- params.set("duration", String(clampedDuration));
196
- }
197
- if (quality && quality !== "fast") {
198
- params.set("quality", quality);
199
- } else if (quality === "fast") {
200
193
  params.set("quality", "fast");
201
194
  }
202
195
 
@@ -206,3 +199,65 @@ export function buildVideoUrl(options: SlopVideoOptions): string {
206
199
 
207
200
  return `${baseUrl}?${params.toString()}`;
208
201
  }
202
+
203
+ export interface SlopTextOptions {
204
+ /**
205
+ * The unique identifier of your Slop Machine bucket.
206
+ */
207
+ bucketId: string;
208
+ /**
209
+ * The specific version of the prompt/settings to use.
210
+ * If omitted, the latest version will be used.
211
+ */
212
+ version?: number;
213
+ /**
214
+ * Result ID to retrieve a specific previously generated text
215
+ * instead of generating a new one.
216
+ */
217
+ resultId?: string;
218
+ /**
219
+ * The AI model to use for generation.
220
+ * Overrides the default model specified in the bucket settings.
221
+ */
222
+ model?: string;
223
+ /**
224
+ * Dynamic variables to interpolate into the prompt.
225
+ * E.g., if prompt is "A story about a {color} dog", pass { color: "brown" }.
226
+ */
227
+ variables?: Record<string, string | number | undefined | null>;
228
+ /**
229
+ * The base URL for the Slop Machine API.
230
+ * Defaults to the production URL. Useful for testing against local deployments.
231
+ */
232
+ baseUrl?: string;
233
+ }
234
+
235
+ export function buildTextUrl(options: SlopTextOptions): string {
236
+ const {
237
+ bucketId,
238
+ version,
239
+ resultId,
240
+ model,
241
+ variables = {},
242
+ baseUrl = "https://us-central1-slopmachine-12bfb.cloudfunctions.net/renderText",
243
+ } = options;
244
+
245
+ const params = new URLSearchParams();
246
+ params.set("bucketId", bucketId);
247
+
248
+ if (model) {
249
+ params.set("model", model);
250
+ }
251
+ if (version) {
252
+ params.set("version", String(version));
253
+ }
254
+ if (resultId) {
255
+ params.set("resultId", resultId);
256
+ }
257
+
258
+ if (Object.keys(variables).length > 0) {
259
+ params.set("variables", JSON.stringify(variables));
260
+ }
261
+
262
+ return `${baseUrl}?${params.toString()}`;
263
+ }