@docusaurus/plugin-ideal-image 2.0.0-beta.17 → 2.0.0-beta.18

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.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import type { LoadContext, Plugin, OptionValidationContext, ValidationResult } from '@docusaurus/types';
7
+ import type { LoadContext, Plugin, OptionValidationContext } from '@docusaurus/types';
8
8
  import type { PluginOptions } from '@docusaurus/plugin-ideal-image';
9
9
  export default function pluginIdealImage(context: LoadContext, options: PluginOptions): Plugin<void>;
10
- export declare function validateOptions({ validate, options, }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions>;
10
+ export declare function validateOptions({ validate, options, }: OptionValidationContext<PluginOptions, PluginOptions>): PluginOptions;
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)({
@@ -41,7 +39,7 @@ function pluginIdealImage(context, options) {
41
39
  module: {
42
40
  rules: [
43
41
  {
44
- test: /\.(?:png|jpe?g|gif)$/i,
42
+ test: /\.(?:png|jpe?g)$/i,
45
43
  use: [
46
44
  require.resolve('@docusaurus/lqip-loader'),
47
45
  {
@@ -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": "2.0.0-beta.17",
3
+ "version": "2.0.0-beta.18",
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,20 +21,20 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@docusaurus/core": "2.0.0-beta.17",
25
- "@docusaurus/lqip-loader": "2.0.0-beta.17",
24
+ "@docusaurus/core": "2.0.0-beta.18",
25
+ "@docusaurus/lqip-loader": "2.0.0-beta.18",
26
26
  "@docusaurus/responsive-loader": "^1.7.0",
27
- "@docusaurus/theme-translations": "2.0.0-beta.17",
28
- "@docusaurus/utils-validation": "2.0.0-beta.17",
27
+ "@docusaurus/theme-translations": "2.0.0-beta.18",
28
+ "@docusaurus/utils-validation": "2.0.0-beta.18",
29
29
  "@endiliey/react-ideal-image": "^0.0.11",
30
30
  "react-waypoint": "^10.1.0",
31
- "sharp": "^0.30.1",
31
+ "sharp": "^0.30.3",
32
32
  "tslib": "^2.3.1",
33
- "webpack": "^5.69.1"
33
+ "webpack": "^5.70.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@docusaurus/module-type-aliases": "2.0.0-beta.17",
37
- "@docusaurus/types": "2.0.0-beta.17",
36
+ "@docusaurus/module-type-aliases": "2.0.0-beta.18",
37
+ "@docusaurus/types": "2.0.0-beta.18",
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": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
53
+ "gitHead": "1a945d06993d53376e61bed2c942799fe07dc336"
54
54
  }
package/src/deps.d.ts CHANGED
@@ -68,7 +68,7 @@ declare module '@endiliey/react-ideal-image' {
68
68
  * from material design, Implemented as React components with the SVG
69
69
  * element. You can customize icons
70
70
  */
71
- icons?: Partial<Record<IconKey, ComponentType>>;
71
+ icons?: Partial<{[icon in IconKey]: ComponentType}>;
72
72
  /**
73
73
  * This prop takes one of the 2 options, xhr and image.
74
74
  * Read more about it:
@@ -102,7 +102,7 @@ declare module '@endiliey/react-ideal-image' {
102
102
  * inline styles, but it is also possible to use CSS modules and override
103
103
  * all styles.
104
104
  */
105
- theme?: Partial<Record<ThemeKey, string | CSSProperties>>;
105
+ theme?: Partial<{[key in ThemeKey]: string | CSSProperties}>;
106
106
  /**
107
107
  * Tells how much to wait in milliseconds until consider the download to be
108
108
  * slow.
package/src/index.ts CHANGED
@@ -9,14 +9,11 @@ import type {
9
9
  LoadContext,
10
10
  Plugin,
11
11
  OptionValidationContext,
12
- ValidationResult,
13
12
  } from '@docusaurus/types';
14
13
  import type {PluginOptions} from '@docusaurus/plugin-ideal-image';
15
14
  import {Joi} from '@docusaurus/utils-validation';
16
15
  import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
17
16
 
18
- import path from 'path';
19
-
20
17
  export default function pluginIdealImage(
21
18
  context: LoadContext,
22
19
  options: PluginOptions,
@@ -29,11 +26,11 @@ export default function pluginIdealImage(
29
26
  name: 'docusaurus-plugin-ideal-image',
30
27
 
31
28
  getThemePath() {
32
- return path.resolve(__dirname, '../lib/theme');
29
+ return '../lib/theme';
33
30
  },
34
31
 
35
32
  getTypeScriptThemePath() {
36
- return path.resolve(__dirname, '../src/theme');
33
+ return '../src/theme';
37
34
  },
38
35
 
39
36
  getDefaultCodeTranslationMessages() {
@@ -56,7 +53,7 @@ export default function pluginIdealImage(
56
53
  module: {
57
54
  rules: [
58
55
  {
59
- test: /\.(?:png|jpe?g|gif)$/i,
56
+ test: /\.(?:png|jpe?g)$/i,
60
57
  use: [
61
58
  require.resolve('@docusaurus/lqip-loader'),
62
59
  {
@@ -81,7 +78,7 @@ export default function pluginIdealImage(
81
78
  export function validateOptions({
82
79
  validate,
83
80
  options,
84
- }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
81
+ }: OptionValidationContext<PluginOptions, PluginOptions>): PluginOptions {
85
82
  const pluginOptionsSchema = Joi.object({
86
83
  disableInDev: Joi.boolean().default(true),
87
84
  }).unknown();
@@ -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;