@docusaurus/plugin-ideal-image 0.0.0-4317 → 0.0.0-4328
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 +3 -2
- package/lib/index.js +18 -5
- package/package.json +6 -5
- package/src/index.ts +27 -6
- package/src/plugin-ideal-image.d.ts +4 -0
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +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 { LoadContext, Plugin } from '@docusaurus/types';
|
|
7
|
+
import type { LoadContext, Plugin, OptionValidationContext, ValidationResult } from '@docusaurus/types';
|
|
8
8
|
import type { PluginOptions } from '@docusaurus/plugin-ideal-image';
|
|
9
|
-
export default function (_context: LoadContext, options: PluginOptions): Plugin<void>;
|
|
9
|
+
export default function pluginIdealImage(_context: LoadContext, options: PluginOptions): Plugin<void>;
|
|
10
|
+
export declare function validateOptions({ validate, options, }: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions>;
|
package/lib/index.js
CHANGED
|
@@ -6,16 +6,22 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
9
|
+
exports.validateOptions = void 0;
|
|
9
10
|
const tslib_1 = require('tslib');
|
|
11
|
+
const utils_validation_1 = require('@docusaurus/utils-validation');
|
|
10
12
|
const path_1 = (0, tslib_1.__importDefault)(require('path'));
|
|
11
|
-
function
|
|
13
|
+
function pluginIdealImage(_context, options) {
|
|
12
14
|
return {
|
|
13
15
|
name: 'docusaurus-plugin-ideal-image',
|
|
14
16
|
getThemePath() {
|
|
15
|
-
return path_1.default.resolve(__dirname, '
|
|
17
|
+
return path_1.default.resolve(__dirname, '../lib/theme');
|
|
18
|
+
},
|
|
19
|
+
getTypeScriptThemePath() {
|
|
20
|
+
return path_1.default.resolve(__dirname, '../src/theme');
|
|
16
21
|
},
|
|
17
22
|
configureWebpack(_config, isServer) {
|
|
18
|
-
|
|
23
|
+
const {disableInDev, ...loaderOptions} = options;
|
|
24
|
+
if (disableInDev && process.env.NODE_ENV !== 'production') {
|
|
19
25
|
return {};
|
|
20
26
|
}
|
|
21
27
|
return {
|
|
@@ -35,7 +41,7 @@ function default_1(_context, options) {
|
|
|
35
41
|
// eslint-disable-next-line global-require
|
|
36
42
|
adapter: require('@docusaurus/responsive-loader/sharp'),
|
|
37
43
|
name: 'assets/ideal-img/[name].[hash:hex:7].[width].[ext]',
|
|
38
|
-
...
|
|
44
|
+
...loaderOptions,
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
],
|
|
@@ -46,4 +52,11 @@ function default_1(_context, options) {
|
|
|
46
52
|
},
|
|
47
53
|
};
|
|
48
54
|
}
|
|
49
|
-
exports.default =
|
|
55
|
+
exports.default = pluginIdealImage;
|
|
56
|
+
function validateOptions({validate, options}) {
|
|
57
|
+
const pluginOptionsSchema = utils_validation_1.Joi.object({
|
|
58
|
+
disableInDev: utils_validation_1.Joi.boolean().default(true),
|
|
59
|
+
}).unknown();
|
|
60
|
+
return validate(pluginOptionsSchema, options);
|
|
61
|
+
}
|
|
62
|
+
exports.validateOptions = validateOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-ideal-image",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4328",
|
|
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,9 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/lqip-loader": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4328",
|
|
25
|
+
"@docusaurus/lqip-loader": "0.0.0-4328",
|
|
26
26
|
"@docusaurus/responsive-loader": "1.5.0",
|
|
27
|
+
"@docusaurus/utils-validation": "0.0.0-4328",
|
|
27
28
|
"@endiliey/react-ideal-image": "^0.0.11",
|
|
28
29
|
"react-waypoint": "^10.1.0",
|
|
29
30
|
"sharp": "^0.29.1",
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
"webpack": "^5.61.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/types": "0.0.0-
|
|
35
|
+
"@docusaurus/types": "0.0.0-4328",
|
|
35
36
|
"fs-extra": "^10.0.0"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": ">=14"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "fff574bab7bd31cf3b86f66f0ba7c49b5cd4d61e"
|
|
45
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
|
+
LoadContext,
|
|
10
|
+
Plugin,
|
|
11
|
+
OptionValidationContext,
|
|
12
|
+
ValidationResult,
|
|
13
|
+
} from '@docusaurus/types';
|
|
9
14
|
import type {PluginOptions} from '@docusaurus/plugin-ideal-image';
|
|
10
|
-
import {Configuration} from 'webpack';
|
|
15
|
+
import type {Configuration} from 'webpack';
|
|
16
|
+
import {Joi} from '@docusaurus/utils-validation';
|
|
11
17
|
|
|
12
18
|
import path from 'path';
|
|
13
19
|
|
|
14
|
-
export default function (
|
|
20
|
+
export default function pluginIdealImage(
|
|
15
21
|
_context: LoadContext,
|
|
16
22
|
options: PluginOptions,
|
|
17
23
|
): Plugin<void> {
|
|
@@ -19,11 +25,16 @@ export default function (
|
|
|
19
25
|
name: 'docusaurus-plugin-ideal-image',
|
|
20
26
|
|
|
21
27
|
getThemePath() {
|
|
22
|
-
return path.resolve(__dirname, '
|
|
28
|
+
return path.resolve(__dirname, '../lib/theme');
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getTypeScriptThemePath() {
|
|
32
|
+
return path.resolve(__dirname, '../src/theme');
|
|
23
33
|
},
|
|
24
34
|
|
|
25
35
|
configureWebpack(_config: Configuration, isServer: boolean) {
|
|
26
|
-
|
|
36
|
+
const {disableInDev, ...loaderOptions} = options;
|
|
37
|
+
if (disableInDev && process.env.NODE_ENV !== 'production') {
|
|
27
38
|
return {};
|
|
28
39
|
}
|
|
29
40
|
|
|
@@ -44,7 +55,7 @@ export default function (
|
|
|
44
55
|
// eslint-disable-next-line global-require
|
|
45
56
|
adapter: require('@docusaurus/responsive-loader/sharp'),
|
|
46
57
|
name: 'assets/ideal-img/[name].[hash:hex:7].[width].[ext]',
|
|
47
|
-
...
|
|
58
|
+
...loaderOptions,
|
|
48
59
|
},
|
|
49
60
|
},
|
|
50
61
|
],
|
|
@@ -55,3 +66,13 @@ export default function (
|
|
|
55
66
|
},
|
|
56
67
|
};
|
|
57
68
|
}
|
|
69
|
+
|
|
70
|
+
export function validateOptions({
|
|
71
|
+
validate,
|
|
72
|
+
options,
|
|
73
|
+
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
|
|
74
|
+
const pluginOptionsSchema = Joi.object({
|
|
75
|
+
disableInDev: Joi.boolean().default(true),
|
|
76
|
+
}).unknown();
|
|
77
|
+
return validate(pluginOptionsSchema, options);
|
|
78
|
+
}
|