@docusaurus/plugin-ideal-image 0.0.0-4726 → 0.0.0-4730

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/lib/index.js CHANGED
@@ -7,10 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, '__esModule', {value: true});
9
9
  exports.validateOptions = void 0;
10
- const tslib_1 = require('tslib');
11
10
  const utils_validation_1 = require('@docusaurus/utils-validation');
12
11
  const theme_translations_1 = require('@docusaurus/theme-translations');
13
- const path_1 = tslib_1.__importDefault(require('path'));
14
12
  function pluginIdealImage(context, options) {
15
13
  const {
16
14
  i18n: {currentLocale},
@@ -18,10 +16,10 @@ function pluginIdealImage(context, options) {
18
16
  return {
19
17
  name: 'docusaurus-plugin-ideal-image',
20
18
  getThemePath() {
21
- return path_1.default.resolve(__dirname, '../lib/theme');
19
+ return '../lib/theme';
22
20
  },
23
21
  getTypeScriptThemePath() {
24
- return path_1.default.resolve(__dirname, '../src/theme');
22
+ return '../src/theme';
25
23
  },
26
24
  getDefaultCodeTranslationMessages() {
27
25
  return (0, theme_translations_1.readDefaultCodeTranslationMessages)({
@@ -8,7 +8,7 @@ import React from 'react';
8
8
  import ReactIdealImage from '@endiliey/react-ideal-image';
9
9
  import {translate} from '@docusaurus/Translate';
10
10
  // Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/helpers.js#L59-L65
11
- const bytesToSize = (bytes) => {
11
+ function bytesToSize(bytes) {
12
12
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
13
13
  if (bytes === 0) {
14
14
  return 'n/a';
@@ -18,9 +18,9 @@ const bytesToSize = (bytes) => {
18
18
  return `${bytes} ${sizes[scale]}`;
19
19
  }
20
20
  return `${(bytes / 1024 ** scale).toFixed(1)} ${sizes[scale]}`;
21
- };
21
+ }
22
22
  // Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/IdealImage/index.js#L43-L75
23
- const getMessage = (icon, state) => {
23
+ function getMessage(icon, state) {
24
24
  switch (icon) {
25
25
  case 'noicon':
26
26
  case 'loaded':
@@ -70,7 +70,7 @@ const getMessage = (icon, state) => {
70
70
  default:
71
71
  throw new Error(`Wrong icon: ${icon}`);
72
72
  }
73
- };
73
+ }
74
74
  export default function IdealImage(props) {
75
75
  const {alt, className, img} = props;
76
76
  // In dev env just use regular img with original file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-ideal-image",
3
- "version": "0.0.0-4726",
3
+ "version": "0.0.0-4730",
4
4
  "description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder).",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-ideal-image.d.ts",
@@ -21,11 +21,11 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4726",
25
- "@docusaurus/lqip-loader": "0.0.0-4726",
24
+ "@docusaurus/core": "0.0.0-4730",
25
+ "@docusaurus/lqip-loader": "0.0.0-4730",
26
26
  "@docusaurus/responsive-loader": "^1.7.0",
27
- "@docusaurus/theme-translations": "0.0.0-4726",
28
- "@docusaurus/utils-validation": "0.0.0-4726",
27
+ "@docusaurus/theme-translations": "0.0.0-4730",
28
+ "@docusaurus/utils-validation": "0.0.0-4730",
29
29
  "@endiliey/react-ideal-image": "^0.0.11",
30
30
  "react-waypoint": "^10.1.0",
31
31
  "sharp": "^0.30.3",
@@ -33,8 +33,8 @@
33
33
  "webpack": "^5.70.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@docusaurus/module-type-aliases": "0.0.0-4726",
37
- "@docusaurus/types": "0.0.0-4726",
36
+ "@docusaurus/module-type-aliases": "0.0.0-4730",
37
+ "@docusaurus/types": "0.0.0-4730",
38
38
  "fs-extra": "^10.0.1"
39
39
  },
40
40
  "peerDependencies": {
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=14"
52
52
  },
53
- "gitHead": "f0fd448c4509295ecdfe665dcc017980c4b5153b"
53
+ "gitHead": "65b87b9d9f21c7904877ed1fade98e0b9fb61b56"
54
54
  }
package/src/index.ts CHANGED
@@ -15,8 +15,6 @@ import type {PluginOptions} from '@docusaurus/plugin-ideal-image';
15
15
  import {Joi} from '@docusaurus/utils-validation';
16
16
  import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
17
17
 
18
- import path from 'path';
19
-
20
18
  export default function pluginIdealImage(
21
19
  context: LoadContext,
22
20
  options: PluginOptions,
@@ -29,11 +27,11 @@ export default function pluginIdealImage(
29
27
  name: 'docusaurus-plugin-ideal-image',
30
28
 
31
29
  getThemePath() {
32
- return path.resolve(__dirname, '../lib/theme');
30
+ return '../lib/theme';
33
31
  },
34
32
 
35
33
  getTypeScriptThemePath() {
36
- return path.resolve(__dirname, '../src/theme');
34
+ return '../src/theme';
37
35
  },
38
36
 
39
37
  getDefaultCodeTranslationMessages() {
@@ -14,8 +14,7 @@ declare module '@docusaurus/plugin-ideal-image' {
14
14
  /**
15
15
  * Specify all widths you want to use; if a specified size exceeds the
16
16
  * original image's width, the latter will be used (i.e. images won't be
17
- * scaled up). You may also declare a default sizes array in the loader
18
- * options in your webpack.config.js.
17
+ * scaled up).
19
18
  */
20
19
  sizes?: number[];
21
20
  /**
@@ -25,16 +24,17 @@ declare module '@docusaurus/plugin-ideal-image' {
25
24
  */
26
25
  size?: number;
27
26
  /**
28
- * As an alternative to manually specifying sizes, you can specify min, max
29
- * and steps, and the sizes will be generated for you.
27
+ * As an alternative to manually specifying `sizes`, you can specify `min`,
28
+ * `max` and `steps`, and the `sizes` will be generated for you.
30
29
  */
31
30
  min?: number;
32
31
  /**
33
- * See min above
32
+ * @see {@link PluginOptions.min}
34
33
  */
35
34
  max?: number;
36
35
  /**
37
- * Configure the number of images generated between min and max (inclusive)
36
+ * Configure the number of images generated between `min` and `max`
37
+ * (inclusive)
38
38
  */
39
39
  steps?: number;
40
40
  /**
@@ -42,7 +42,8 @@ declare module '@docusaurus/plugin-ideal-image' {
42
42
  */
43
43
  quality?: number;
44
44
  /**
45
- * Just use regular images in dev mode
45
+ * You can test ideal image behavior in dev mode by setting this to `false`.
46
+ * Tip: use network throttling in your browser to simulate slow networks.
46
47
  */
47
48
  disableInDev?: boolean;
48
49
  };
@@ -15,7 +15,7 @@ import {translate} from '@docusaurus/Translate';
15
15
  import type {Props} from '@theme/IdealImage';
16
16
 
17
17
  // Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/helpers.js#L59-L65
18
- const bytesToSize = (bytes: number) => {
18
+ function bytesToSize(bytes: number) {
19
19
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
20
20
  if (bytes === 0) {
21
21
  return 'n/a';
@@ -25,10 +25,10 @@ const bytesToSize = (bytes: number) => {
25
25
  return `${bytes} ${sizes[scale]}`;
26
26
  }
27
27
  return `${(bytes / 1024 ** scale).toFixed(1)} ${sizes[scale]}`;
28
- };
28
+ }
29
29
 
30
30
  // Adopted from https://github.com/endiliey/react-ideal-image/blob/master/src/components/IdealImage/index.js#L43-L75
31
- const getMessage = (icon: IconKey, state: State) => {
31
+ function getMessage(icon: IconKey, state: State) {
32
32
  switch (icon) {
33
33
  case 'noicon':
34
34
  case 'loaded':
@@ -78,7 +78,7 @@ const getMessage = (icon: IconKey, state: State) => {
78
78
  default:
79
79
  throw new Error(`Wrong icon: ${icon}`);
80
80
  }
81
- };
81
+ }
82
82
 
83
83
  export default function IdealImage(props: Props): JSX.Element {
84
84
  const {alt, className, img} = props;