@mts-pjsc/image-optimize 1.2.1 → 1.3.0

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/README.md CHANGED
@@ -17,12 +17,20 @@ Features:
17
17
  ### Before use
18
18
  [The optimization microservice](https://github.com/MobileTeleSystems/image-optimize) must be deployed on the server along the path `/optimizer`. React component will use it.
19
19
 
20
+ ### Instalation
21
+ Run script:
22
+ ```
23
+ npm i @mts-pjsc/image-optimize
24
+ ```
25
+
20
26
  ### Using
21
27
 
22
28
  Just replace the \<img\> element with the Image component from the package. The component is fully compatible with the \<img\> element. Next, the component will do all the magic on its own.
23
29
 
24
30
  Sample:
25
31
  ```typescript
32
+ import {Image} from "@mts-pjsc/image-optimize";
33
+
26
34
  <Image
27
35
  alt="Sample of work Image Optimizer"
28
36
  src="/static/landing/images-getmeback/phone-fon.png"
@@ -1,4 +1,4 @@
1
- import { Component } from "react";
1
+ import React, { Component, JSX } from "react";
2
2
  export interface IImageOptions extends React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> {
3
3
  src: string;
4
4
  alt: string;
@@ -1,3 +1,6 @@
1
+ /* eslint-disable react/jsx-no-bind */
2
+ /* eslint-disable react/destructuring-assignment */
3
+ /* eslint-disable react/sort-comp */
1
4
  // For Next.js 13 and react 18. Switch component for support server components later.
2
5
  "use client";
3
6
  var __rest = (this && this.__rest) || function (s, e) {
@@ -11,8 +14,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
14
  }
12
15
  return t;
13
16
  };
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
- import { Component } from "react";
17
+ import React, { Component } from "react";
16
18
  import { getFormatFeatures } from "../helpers/get-format-features.js";
17
19
  export class Image extends Component {
18
20
  constructor(props) {
@@ -49,7 +51,7 @@ export class Image extends Component {
49
51
  render() {
50
52
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
53
  const _a = this.props, { offset, quality, setRef, src, alt } = _a, props = __rest(_a, ["offset", "quality", "setRef", "src", "alt"]);
52
- return (_jsx("img", Object.assign({}, props, { alt: alt, onLoad: () => requestAnimationFrame(() => this.checkImage()), ref: (elem) => {
54
+ return (React.createElement("img", Object.assign({}, props, { alt: alt, onLoad: () => requestAnimationFrame(() => this.checkImage()), ref: (elem) => {
53
55
  var _a, _b;
54
56
  this.thisComponent = elem;
55
57
  (_b = (_a = this.props).setRef) === null || _b === void 0 ? void 0 : _b.call(_a, elem);
@@ -129,6 +131,7 @@ export class Image extends Component {
129
131
  return url;
130
132
  }
131
133
  extractImageFormat(path) {
134
+ // eslint-disable-next-line no-useless-assignment
132
135
  let format = "";
133
136
  const match = this.extensionsRegexp.exec(path);
134
137
  if (Image.isAvif === true) {
@@ -177,6 +180,7 @@ export class Image extends Component {
177
180
  ].join(" "));
178
181
  }
179
182
  }
183
+ // eslint-disable-next-line class-methods-use-this
180
184
  async initImageFormats() {
181
185
  const format = await getFormatFeatures();
182
186
  if (Image.isAvif === null || Image.isWebP === null) {
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@mts-pjsc/image-optimize",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "React component for image optimizer",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "esnext": "dist/index.js",
8
8
  "type": "module",
9
9
  "scripts": {
10
- "eslint": "eslint --fix -c .eslintrc.cjs --ext .tsx,.ts,.jsx,.js ./src/",
10
+ "eslint": "eslint --fix -c eslint.config.js --ext .tsx,.ts,.jsx,.js ./src/",
11
11
  "test": "echo \"Error: no test specified. For test need deployed microservice part\" && exit 1",
12
12
  "test:module": "node ./dist/index.js",
13
13
  "build": "rm -rf dist/ && tsc --project tsconfig.json && npm run test:module",
14
+ "release": "cliff-jumper --name 'ts-fetch' --package-path '.' --no-skip-changelog --no-skip-tag",
14
15
  "prepare": "husky install"
15
16
  },
16
17
  "repository": {
@@ -23,7 +24,7 @@
23
24
  ],
24
25
  "lint-staged": {
25
26
  "./src/**/*.(ts|tsx|js|jsx)": [
26
- "eslint --fix -c .eslintrc.cjs --ext .tsx,.ts,.jsx,.js"
27
+ "eslint --fix -c eslint.config.js --ext .tsx,.ts,.jsx,.js"
27
28
  ]
28
29
  },
29
30
  "author": "MobileTeleSystems",
@@ -36,11 +37,12 @@
36
37
  "react": ">=16.0.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@labeg/code-style": "^2.0.51",
40
- "@types/node": "^18.11.9",
41
- "@types/react": "^18.0.25",
42
- "husky": "^8.0.2",
43
- "lint-staged": "^13.0.3",
44
- "typescript": "^4.9.3"
40
+ "@labeg/code-style": "^6.5.0",
41
+ "@types/node": "^24.0.15",
42
+ "@types/react": "^19.1.8",
43
+ "@favware/cliff-jumper": "^6.0.0",
44
+ "husky": "^9.1.7",
45
+ "lint-staged": "^16.1.2",
46
+ "typescript": "^5.8.3"
45
47
  }
46
48
  }