@shuvi/shared 1.0.23 → 1.0.25
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/esm/plugins.d.ts +7 -1
- package/esm/plugins.js +19 -6
- package/lib/plugins.d.ts +7 -1
- package/lib/plugins.js +19 -6
- package/package.json +2 -2
package/esm/plugins.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ import { HookMap, Setup, IPluginHandlers, PluginOptions as _PluginOptions, IPlug
|
|
|
2
2
|
export declare const GROUP_BEFORE_USER = -1;
|
|
3
3
|
export declare const GROUP_USER = 0;
|
|
4
4
|
export declare const GROUP_AFTER_USER = 1;
|
|
5
|
-
export declare type PluginOptions =
|
|
5
|
+
export declare type PluginOptions = {
|
|
6
|
+
name?: _PluginOptions['name'];
|
|
7
|
+
before?: _PluginOptions['before'];
|
|
8
|
+
after?: _PluginOptions['after'];
|
|
9
|
+
conflict?: _PluginOptions['conflict'];
|
|
10
|
+
required?: _PluginOptions['required'];
|
|
11
|
+
};
|
|
6
12
|
export interface PluginFunc<HM extends HookMap, C> {
|
|
7
13
|
(handler: IPluginHandlers<HM, C> & {
|
|
8
14
|
setup?: Setup;
|
package/esm/plugins.js
CHANGED
|
@@ -4,14 +4,27 @@ export const GROUP_USER = 0;
|
|
|
4
4
|
export const GROUP_AFTER_USER = 1;
|
|
5
5
|
export function createPluginCreator() {
|
|
6
6
|
const createOptions = (group, opt = {}) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
pre: opt.pre,
|
|
10
|
-
post: opt.post,
|
|
11
|
-
rivals: opt.rivals,
|
|
12
|
-
required: opt.required,
|
|
7
|
+
const { name, before, after, conflict, required } = opt;
|
|
8
|
+
const result = {
|
|
13
9
|
group
|
|
14
10
|
};
|
|
11
|
+
// avoid undefined value because undefined value will override default value
|
|
12
|
+
if (name !== undefined) {
|
|
13
|
+
result.name = name;
|
|
14
|
+
}
|
|
15
|
+
if (before !== undefined) {
|
|
16
|
+
result.before = before;
|
|
17
|
+
}
|
|
18
|
+
if (after !== undefined) {
|
|
19
|
+
result.after = after;
|
|
20
|
+
}
|
|
21
|
+
if (conflict !== undefined) {
|
|
22
|
+
result.conflict = conflict;
|
|
23
|
+
}
|
|
24
|
+
if (required !== undefined) {
|
|
25
|
+
result.required = required;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
15
28
|
};
|
|
16
29
|
return {
|
|
17
30
|
createPluginBefore(handler, options) {
|
package/lib/plugins.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ import { HookMap, Setup, IPluginHandlers, PluginOptions as _PluginOptions, IPlug
|
|
|
2
2
|
export declare const GROUP_BEFORE_USER = -1;
|
|
3
3
|
export declare const GROUP_USER = 0;
|
|
4
4
|
export declare const GROUP_AFTER_USER = 1;
|
|
5
|
-
export declare type PluginOptions =
|
|
5
|
+
export declare type PluginOptions = {
|
|
6
|
+
name?: _PluginOptions['name'];
|
|
7
|
+
before?: _PluginOptions['before'];
|
|
8
|
+
after?: _PluginOptions['after'];
|
|
9
|
+
conflict?: _PluginOptions['conflict'];
|
|
10
|
+
required?: _PluginOptions['required'];
|
|
11
|
+
};
|
|
6
12
|
export interface PluginFunc<HM extends HookMap, C> {
|
|
7
13
|
(handler: IPluginHandlers<HM, C> & {
|
|
8
14
|
setup?: Setup;
|
package/lib/plugins.js
CHANGED
|
@@ -7,14 +7,27 @@ exports.GROUP_USER = 0;
|
|
|
7
7
|
exports.GROUP_AFTER_USER = 1;
|
|
8
8
|
function createPluginCreator() {
|
|
9
9
|
const createOptions = (group, opt = {}) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
pre: opt.pre,
|
|
13
|
-
post: opt.post,
|
|
14
|
-
rivals: opt.rivals,
|
|
15
|
-
required: opt.required,
|
|
10
|
+
const { name, before, after, conflict, required } = opt;
|
|
11
|
+
const result = {
|
|
16
12
|
group
|
|
17
13
|
};
|
|
14
|
+
// avoid undefined value because undefined value will override default value
|
|
15
|
+
if (name !== undefined) {
|
|
16
|
+
result.name = name;
|
|
17
|
+
}
|
|
18
|
+
if (before !== undefined) {
|
|
19
|
+
result.before = before;
|
|
20
|
+
}
|
|
21
|
+
if (after !== undefined) {
|
|
22
|
+
result.after = after;
|
|
23
|
+
}
|
|
24
|
+
if (conflict !== undefined) {
|
|
25
|
+
result.conflict = conflict;
|
|
26
|
+
}
|
|
27
|
+
if (required !== undefined) {
|
|
28
|
+
result.required = required;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
18
31
|
};
|
|
19
32
|
return {
|
|
20
33
|
createPluginBefore(handler, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"node": ">= 16.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@shuvi/hook": "1.0.
|
|
36
|
+
"@shuvi/hook": "1.0.25"
|
|
37
37
|
}
|
|
38
38
|
}
|