@mts-pjsc/image-optimize 1.1.2 → 1.1.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.
@@ -10,19 +10,31 @@ export interface IImageOptions {
10
10
  export declare class Image<P extends IImageOptions> extends React.Component<P> {
11
11
  static isShowDiagnostic: boolean;
12
12
  static controlPoints: number[];
13
- private static isAvif;
14
- private static isWebP;
15
13
  /**
16
- * Change for local development.
14
+ * Image optimizer will take source url for show image.
15
+ *
16
+ * This is required when working on localhost.
17
+ * Because a remote microservice cannot make requests to your localhost.
18
+ *
19
+ * Example:
20
+ * Image.isUseSourceUrl = process.env.NODE_ENV !== "production";
21
+ */
22
+ static isUseSourceUrl: boolean;
23
+ /**
24
+ * Image optimizer will change origin to other domain.
25
+ *
26
+ * This is necessary when you developing locally, this will take pictures from the DEV server by CORS.
17
27
  *
18
- * The server microservice will not be able to make a request to your localhost.
19
- * Therefore, when developing locally, you must specify a production or development server origin.
28
+ * Also, this parameter must be specified if the component works in the microfront.
29
+ * Then you need to specify the address to the server with pictures.
20
30
  *
21
31
  * Example:
22
- * https://tb.mts.ru
32
+ * Image.imgOrigin = https://tb.mts.ru
23
33
  *
24
34
  */
25
35
  static imgOrigin?: string;
36
+ private static isAvif;
37
+ private static isWebP;
26
38
  resultUrl: string;
27
39
  resizeCheckTimeout: number;
28
40
  thisComponent: HTMLImageElement | null;
@@ -42,6 +42,10 @@ export class Image extends React.Component {
42
42
  }, src: this.resultUrl }));
43
43
  }
44
44
  async checkImage(isResize = false) {
45
+ if (Image.isUseSourceUrl && this.thisComponent) {
46
+ this.thisComponent.src = this.resultUrl;
47
+ return;
48
+ }
45
49
  if (this.checks > 1) {
46
50
  return;
47
51
  }
@@ -169,17 +173,28 @@ export class Image extends React.Component {
169
173
  }
170
174
  Image.isShowDiagnostic = false;
171
175
  Image.controlPoints = [160, 320, 640, 1280, 1920];
172
- Image.isAvif = null;
173
- Image.isWebP = null;
174
176
  /**
175
- * Change for local development.
177
+ * Image optimizer will take source url for show image.
176
178
  *
177
- * The server microservice will not be able to make a request to your localhost.
178
- * Therefore, when developing locally, you must specify a production or development server origin.
179
+ * This is required when working on localhost.
180
+ * Because a remote microservice cannot make requests to your localhost.
179
181
  *
180
182
  * Example:
181
- * https://tb.mts.ru
183
+ * Image.isUseSourceUrl = process.env.NODE_ENV !== "production";
184
+ */
185
+ Image.isUseSourceUrl = false;
186
+ /**
187
+ * Image optimizer will change origin to other domain.
188
+ *
189
+ * This is necessary when you developing locally, this will take pictures from the DEV server by CORS.
190
+ *
191
+ * Also, this parameter must be specified if the component works in the microfront.
192
+ * Then you need to specify the address to the server with pictures.
193
+ *
194
+ * Example:
195
+ * Image.imgOrigin = https://tb.mts.ru
182
196
  *
183
197
  */
184
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-binary-expression
185
198
  Image.imgOrigin = void 0;
199
+ Image.isAvif = null;
200
+ Image.isWebP = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mts-pjsc/image-optimize",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "React component for image optimizer",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",