@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.
- package/dist/components/Image.d.ts +18 -6
- package/dist/components/Image.js +22 -7
- package/package.json +1 -1
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
19
|
-
*
|
|
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;
|
package/dist/components/Image.js
CHANGED
|
@@ -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
|
-
*
|
|
177
|
+
* Image optimizer will take source url for show image.
|
|
176
178
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
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
|
-
*
|
|
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;
|