wc-img-ai 0.0.1 → 0.0.2
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getGeneratedImage = async (endpoint, prompt, width, height) => {
|
|
2
2
|
let response;
|
|
3
|
-
console.log("getOpenAi", endpoint, prompt, width, height);
|
|
4
3
|
try {
|
|
5
4
|
const r = await fetch(endpoint, {
|
|
6
5
|
method: "POST",
|
|
@@ -33,7 +32,7 @@ class AIImage extends HTMLImageElement {
|
|
|
33
32
|
this._endpoint = null;
|
|
34
33
|
this.ph_w = 256;
|
|
35
34
|
this.ph_h = 256;
|
|
36
|
-
this.
|
|
35
|
+
this.getGeneratedImage = getGeneratedImage;
|
|
37
36
|
this.ph_w = Number(super.getAttribute("width")) || 256;
|
|
38
37
|
this.ph_h = Number(super.getAttribute("height")) || 256;
|
|
39
38
|
this.svgPlaceholder = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${this.ph_w} ${this.ph_h}"><rect width="${this.ph_w}" height="${this.ph_h}" fill="#ddd"/></svg>`;
|
|
@@ -48,7 +47,7 @@ class AIImage extends HTMLImageElement {
|
|
|
48
47
|
if (!this._prompt) {
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
|
-
const openAiResponse = await this.
|
|
50
|
+
const openAiResponse = await this.getGeneratedImage(
|
|
52
51
|
this._endpoint,
|
|
53
52
|
this._prompt,
|
|
54
53
|
this.ph_w,
|
package/package.json
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wc-img-ai",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"description": "Use AI to generate images for your img tags.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "John Romani",
|
|
8
|
+
"email": "john@anthood.com"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"web components",
|
|
12
|
+
"ai",
|
|
13
|
+
"image",
|
|
14
|
+
"image ai"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://john.ro",
|
|
5
17
|
"type": "module",
|
|
6
|
-
"
|
|
18
|
+
"repository": "https://github.com/johnroma/wc-image-ai",
|
|
7
19
|
"license": "MIT",
|
|
8
|
-
"types": "./dist/wc-image-ai.d.ts",
|
|
9
20
|
"files": [
|
|
10
21
|
"dist",
|
|
11
22
|
"types"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGeneratedImage: (endpoint: string, prompt: string, width: number, height: number) => Promise<string | undefined>;
|
package/types/get-open-ai.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getOpenAi: (endpoint: string, prompt: string, width: number, height: number) => Promise<string | undefined>;
|