@eycraf/permission-kit-vite-plugin 0.0.1
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/dist/index.cjs +591 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +179 -0
- package/dist/index.d.ts +179 -0
- package/dist/index.js +560 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const PluginOptionsSchema: z.ZodObject<{
|
|
5
|
+
framework: z.ZodDefault<z.ZodEnum<["react", "vue"]>>;
|
|
6
|
+
componentName: z.ZodDefault<z.ZodString>;
|
|
7
|
+
importFrom: z.ZodDefault<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* 全局 include/exclude。
|
|
10
|
+
* transform/rewrite 没单独配置时,会回退使用这里。
|
|
11
|
+
*/
|
|
12
|
+
include: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
13
|
+
exclude: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
14
|
+
transform: z.ZodDefault<z.ZodObject<{
|
|
15
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
include: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
17
|
+
exclude: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
18
|
+
attributes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
modeAttribute: z.ZodDefault<z.ZodString>;
|
|
20
|
+
strategyAttribute: z.ZodDefault<z.ZodString>;
|
|
21
|
+
allowNested: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
attributes: string[];
|
|
25
|
+
modeAttribute: string;
|
|
26
|
+
strategyAttribute: string;
|
|
27
|
+
allowNested: boolean;
|
|
28
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
29
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
32
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
33
|
+
enabled?: boolean | undefined;
|
|
34
|
+
attributes?: string[] | undefined;
|
|
35
|
+
modeAttribute?: string | undefined;
|
|
36
|
+
strategyAttribute?: string | undefined;
|
|
37
|
+
allowNested?: boolean | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
rewrite: z.ZodDefault<z.ZodObject<{
|
|
40
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
/**
|
|
42
|
+
* false = dry-run,只打印会修改哪些文件
|
|
43
|
+
* true = 真实写回源文件
|
|
44
|
+
*/
|
|
45
|
+
write: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
include: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
47
|
+
exclude: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
48
|
+
/**
|
|
49
|
+
* rewrite 只在 serve/build 启动时跑一次。
|
|
50
|
+
* 默认 true,避免 HMR 时反复改文件。
|
|
51
|
+
*/
|
|
52
|
+
once: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
write: boolean;
|
|
56
|
+
once: boolean;
|
|
57
|
+
include?: string | string[] | undefined;
|
|
58
|
+
exclude?: string | string[] | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
include?: string | string[] | undefined;
|
|
61
|
+
exclude?: string | string[] | undefined;
|
|
62
|
+
enabled?: boolean | undefined;
|
|
63
|
+
write?: boolean | undefined;
|
|
64
|
+
once?: boolean | undefined;
|
|
65
|
+
}>>;
|
|
66
|
+
manifest: z.ZodDefault<z.ZodObject<{
|
|
67
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
output: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
output: string;
|
|
72
|
+
}, {
|
|
73
|
+
enabled?: boolean | undefined;
|
|
74
|
+
output?: string | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
dts: z.ZodDefault<z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
output: z.ZodDefault<z.ZodString>;
|
|
79
|
+
typeName: z.ZodDefault<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
output: string;
|
|
83
|
+
typeName: string;
|
|
84
|
+
}, {
|
|
85
|
+
enabled?: boolean | undefined;
|
|
86
|
+
output?: string | undefined;
|
|
87
|
+
typeName?: string | undefined;
|
|
88
|
+
}>>;
|
|
89
|
+
validate: z.ZodDefault<z.ZodObject<{
|
|
90
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
92
|
+
unknownPermission: z.ZodDefault<z.ZodEnum<["off", "warn", "error"]>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
permissions: string[];
|
|
96
|
+
unknownPermission: "off" | "warn" | "error";
|
|
97
|
+
}, {
|
|
98
|
+
enabled?: boolean | undefined;
|
|
99
|
+
permissions?: string[] | undefined;
|
|
100
|
+
unknownPermission?: "off" | "warn" | "error" | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
framework: "react" | "vue";
|
|
104
|
+
componentName: string;
|
|
105
|
+
importFrom: string;
|
|
106
|
+
transform: {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
attributes: string[];
|
|
109
|
+
modeAttribute: string;
|
|
110
|
+
strategyAttribute: string;
|
|
111
|
+
allowNested: boolean;
|
|
112
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
113
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
114
|
+
};
|
|
115
|
+
rewrite: {
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
write: boolean;
|
|
118
|
+
once: boolean;
|
|
119
|
+
include?: string | string[] | undefined;
|
|
120
|
+
exclude?: string | string[] | undefined;
|
|
121
|
+
};
|
|
122
|
+
manifest: {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
output: string;
|
|
125
|
+
};
|
|
126
|
+
dts: {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
output: string;
|
|
129
|
+
typeName: string;
|
|
130
|
+
};
|
|
131
|
+
validate: {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
permissions: string[];
|
|
134
|
+
unknownPermission: "off" | "warn" | "error";
|
|
135
|
+
};
|
|
136
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
137
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
framework?: "react" | "vue" | undefined;
|
|
140
|
+
componentName?: string | undefined;
|
|
141
|
+
importFrom?: string | undefined;
|
|
142
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
143
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
144
|
+
transform?: {
|
|
145
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
146
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
147
|
+
enabled?: boolean | undefined;
|
|
148
|
+
attributes?: string[] | undefined;
|
|
149
|
+
modeAttribute?: string | undefined;
|
|
150
|
+
strategyAttribute?: string | undefined;
|
|
151
|
+
allowNested?: boolean | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
rewrite?: {
|
|
154
|
+
include?: string | string[] | undefined;
|
|
155
|
+
exclude?: string | string[] | undefined;
|
|
156
|
+
enabled?: boolean | undefined;
|
|
157
|
+
write?: boolean | undefined;
|
|
158
|
+
once?: boolean | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
manifest?: {
|
|
161
|
+
enabled?: boolean | undefined;
|
|
162
|
+
output?: string | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
dts?: {
|
|
165
|
+
enabled?: boolean | undefined;
|
|
166
|
+
output?: string | undefined;
|
|
167
|
+
typeName?: string | undefined;
|
|
168
|
+
} | undefined;
|
|
169
|
+
validate?: {
|
|
170
|
+
enabled?: boolean | undefined;
|
|
171
|
+
permissions?: string[] | undefined;
|
|
172
|
+
unknownPermission?: "off" | "warn" | "error" | undefined;
|
|
173
|
+
} | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
type PermissionPluginOptions = z.input<typeof PluginOptionsSchema>;
|
|
176
|
+
|
|
177
|
+
declare function permissionPlugin(userOptions?: PermissionPluginOptions): Plugin;
|
|
178
|
+
|
|
179
|
+
export { permissionPlugin as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const PluginOptionsSchema: z.ZodObject<{
|
|
5
|
+
framework: z.ZodDefault<z.ZodEnum<["react", "vue"]>>;
|
|
6
|
+
componentName: z.ZodDefault<z.ZodString>;
|
|
7
|
+
importFrom: z.ZodDefault<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* 全局 include/exclude。
|
|
10
|
+
* transform/rewrite 没单独配置时,会回退使用这里。
|
|
11
|
+
*/
|
|
12
|
+
include: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
13
|
+
exclude: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
14
|
+
transform: z.ZodDefault<z.ZodObject<{
|
|
15
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
include: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
17
|
+
exclude: z.ZodOptional<z.ZodType<string | RegExp | (string | RegExp)[], z.ZodTypeDef, string | RegExp | (string | RegExp)[]>>;
|
|
18
|
+
attributes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
modeAttribute: z.ZodDefault<z.ZodString>;
|
|
20
|
+
strategyAttribute: z.ZodDefault<z.ZodString>;
|
|
21
|
+
allowNested: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
attributes: string[];
|
|
25
|
+
modeAttribute: string;
|
|
26
|
+
strategyAttribute: string;
|
|
27
|
+
allowNested: boolean;
|
|
28
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
29
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
32
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
33
|
+
enabled?: boolean | undefined;
|
|
34
|
+
attributes?: string[] | undefined;
|
|
35
|
+
modeAttribute?: string | undefined;
|
|
36
|
+
strategyAttribute?: string | undefined;
|
|
37
|
+
allowNested?: boolean | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
rewrite: z.ZodDefault<z.ZodObject<{
|
|
40
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
/**
|
|
42
|
+
* false = dry-run,只打印会修改哪些文件
|
|
43
|
+
* true = 真实写回源文件
|
|
44
|
+
*/
|
|
45
|
+
write: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
include: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
47
|
+
exclude: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
48
|
+
/**
|
|
49
|
+
* rewrite 只在 serve/build 启动时跑一次。
|
|
50
|
+
* 默认 true,避免 HMR 时反复改文件。
|
|
51
|
+
*/
|
|
52
|
+
once: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
write: boolean;
|
|
56
|
+
once: boolean;
|
|
57
|
+
include?: string | string[] | undefined;
|
|
58
|
+
exclude?: string | string[] | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
include?: string | string[] | undefined;
|
|
61
|
+
exclude?: string | string[] | undefined;
|
|
62
|
+
enabled?: boolean | undefined;
|
|
63
|
+
write?: boolean | undefined;
|
|
64
|
+
once?: boolean | undefined;
|
|
65
|
+
}>>;
|
|
66
|
+
manifest: z.ZodDefault<z.ZodObject<{
|
|
67
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
output: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
output: string;
|
|
72
|
+
}, {
|
|
73
|
+
enabled?: boolean | undefined;
|
|
74
|
+
output?: string | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
dts: z.ZodDefault<z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
output: z.ZodDefault<z.ZodString>;
|
|
79
|
+
typeName: z.ZodDefault<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
output: string;
|
|
83
|
+
typeName: string;
|
|
84
|
+
}, {
|
|
85
|
+
enabled?: boolean | undefined;
|
|
86
|
+
output?: string | undefined;
|
|
87
|
+
typeName?: string | undefined;
|
|
88
|
+
}>>;
|
|
89
|
+
validate: z.ZodDefault<z.ZodObject<{
|
|
90
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
92
|
+
unknownPermission: z.ZodDefault<z.ZodEnum<["off", "warn", "error"]>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
permissions: string[];
|
|
96
|
+
unknownPermission: "off" | "warn" | "error";
|
|
97
|
+
}, {
|
|
98
|
+
enabled?: boolean | undefined;
|
|
99
|
+
permissions?: string[] | undefined;
|
|
100
|
+
unknownPermission?: "off" | "warn" | "error" | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
framework: "react" | "vue";
|
|
104
|
+
componentName: string;
|
|
105
|
+
importFrom: string;
|
|
106
|
+
transform: {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
attributes: string[];
|
|
109
|
+
modeAttribute: string;
|
|
110
|
+
strategyAttribute: string;
|
|
111
|
+
allowNested: boolean;
|
|
112
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
113
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
114
|
+
};
|
|
115
|
+
rewrite: {
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
write: boolean;
|
|
118
|
+
once: boolean;
|
|
119
|
+
include?: string | string[] | undefined;
|
|
120
|
+
exclude?: string | string[] | undefined;
|
|
121
|
+
};
|
|
122
|
+
manifest: {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
output: string;
|
|
125
|
+
};
|
|
126
|
+
dts: {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
output: string;
|
|
129
|
+
typeName: string;
|
|
130
|
+
};
|
|
131
|
+
validate: {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
permissions: string[];
|
|
134
|
+
unknownPermission: "off" | "warn" | "error";
|
|
135
|
+
};
|
|
136
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
137
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
framework?: "react" | "vue" | undefined;
|
|
140
|
+
componentName?: string | undefined;
|
|
141
|
+
importFrom?: string | undefined;
|
|
142
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
143
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
144
|
+
transform?: {
|
|
145
|
+
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
146
|
+
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
147
|
+
enabled?: boolean | undefined;
|
|
148
|
+
attributes?: string[] | undefined;
|
|
149
|
+
modeAttribute?: string | undefined;
|
|
150
|
+
strategyAttribute?: string | undefined;
|
|
151
|
+
allowNested?: boolean | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
rewrite?: {
|
|
154
|
+
include?: string | string[] | undefined;
|
|
155
|
+
exclude?: string | string[] | undefined;
|
|
156
|
+
enabled?: boolean | undefined;
|
|
157
|
+
write?: boolean | undefined;
|
|
158
|
+
once?: boolean | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
manifest?: {
|
|
161
|
+
enabled?: boolean | undefined;
|
|
162
|
+
output?: string | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
dts?: {
|
|
165
|
+
enabled?: boolean | undefined;
|
|
166
|
+
output?: string | undefined;
|
|
167
|
+
typeName?: string | undefined;
|
|
168
|
+
} | undefined;
|
|
169
|
+
validate?: {
|
|
170
|
+
enabled?: boolean | undefined;
|
|
171
|
+
permissions?: string[] | undefined;
|
|
172
|
+
unknownPermission?: "off" | "warn" | "error" | undefined;
|
|
173
|
+
} | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
type PermissionPluginOptions = z.input<typeof PluginOptionsSchema>;
|
|
176
|
+
|
|
177
|
+
declare function permissionPlugin(userOptions?: PermissionPluginOptions): Plugin;
|
|
178
|
+
|
|
179
|
+
export { permissionPlugin as default };
|