wc-img-ai 0.0.1 → 0.0.3

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 getOpenAi = async (endpoint, prompt, width, height) => {
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.getOpenAi = getOpenAi;
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.getOpenAi(
50
+ const openAiResponse = await this.getGeneratedImage(
52
51
  this._endpoint,
53
52
  this._prompt,
54
53
  this.ph_w,
@@ -78,3 +77,6 @@ class AIImage extends HTMLImageElement {
78
77
  }
79
78
  }
80
79
  customElements.define("ai-image", AIImage, { extends: "img" });
80
+ export {
81
+ AIImage
82
+ };
package/package.json CHANGED
@@ -1,15 +1,30 @@
1
1
  {
2
2
  "name": "wc-img-ai",
3
3
  "private": false,
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
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
- "exports": "./dist/wc-image-ai.js",
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"
12
23
  ],
24
+ "main": "./dist/wc-img-ai.js",
25
+ "exports": {
26
+ ".": "./dist/wc-img-ai.js"
27
+ },
13
28
  "devDependencies": {
14
29
  "@typescript-eslint/eslint-plugin": "^6.17.0",
15
30
  "@typescript-eslint/parser": "^6.17.0",
@@ -1,3 +1,19 @@
1
+ export declare class AIImage extends HTMLImageElement {
2
+ static get observedAttributes(): string[];
3
+ private _fallbackSrc;
4
+ private _prompt;
5
+ private _originalSrc;
6
+ private svgPlaceholder;
7
+ private _endpoint;
8
+ private ph_w;
9
+ private ph_h;
10
+ constructor();
11
+ get src(): string;
12
+ set src(value: string);
13
+ set fallbackSrc(value: string | null);
14
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
15
+ protected getGeneratedImage: (endpoint: string, prompt: string, width: number, height: number) => Promise<string | undefined>;
16
+ }
1
17
  declare global {
2
18
  interface AIImage extends HTMLImageElement {
3
19
  "data-fallback"?: string;
@@ -6,4 +22,3 @@ declare global {
6
22
  "ai-image": AIImage;
7
23
  }
8
24
  }
9
- export {};
@@ -0,0 +1 @@
1
+ export declare const getGeneratedImage: (endpoint: string, prompt: string, width: number, height: number) => Promise<string | undefined>;
@@ -1 +0,0 @@
1
- export declare const getOpenAi: (endpoint: string, prompt: string, width: number, height: number) => Promise<string | undefined>;