revojs 0.2.18 → 0.2.20
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/module/index.d.ts +2 -1
- package/dist/module/index.js +10 -6
- package/dist/package.js +1 -1
- package/dist/scope/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/module/index.d.ts
CHANGED
|
@@ -47,9 +47,10 @@ export interface Command<T extends ParseArgsOptionsConfig = ParseArgsOptionsConf
|
|
|
47
47
|
}
|
|
48
48
|
export type SourceFormat = "object" | "named";
|
|
49
49
|
export interface Source {
|
|
50
|
-
match: Array<string>;
|
|
51
50
|
from: Array<string>;
|
|
51
|
+
match: Array<string>;
|
|
52
52
|
format: SourceFormat;
|
|
53
|
+
consumers: Array<Consumer>;
|
|
53
54
|
}
|
|
54
55
|
export interface StringVariable {
|
|
55
56
|
type: "string";
|
package/dist/module/index.js
CHANGED
|
@@ -114,14 +114,16 @@ async function createConfig(inputConfig) {
|
|
|
114
114
|
},
|
|
115
115
|
sources: {
|
|
116
116
|
plugins: {
|
|
117
|
-
match: ["**/*.{js,ts}", "!**/*.d.ts"],
|
|
118
117
|
from: ["./plugins"],
|
|
119
|
-
|
|
118
|
+
match: ["**/*.{js,ts}", "!**/*.d.ts"],
|
|
119
|
+
format: "object",
|
|
120
|
+
consumers: ["client", "server"]
|
|
120
121
|
},
|
|
121
122
|
commands: {
|
|
122
|
-
match: ["**/*.{js,ts}", "!**/*.d.ts"],
|
|
123
123
|
from: ["./commands"],
|
|
124
|
-
|
|
124
|
+
match: ["**/*.{js,ts}", "!**/*.d.ts"],
|
|
125
|
+
format: "object",
|
|
126
|
+
consumers: ["server"]
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
129
|
templates: {},
|
|
@@ -158,7 +160,8 @@ async function core(config) {
|
|
|
158
160
|
const entries = new Array();
|
|
159
161
|
for (const files of resolved.values()) for (const entry of files) entries.push(entry);
|
|
160
162
|
const names = toExportNames(entries.map(([key]) => key));
|
|
161
|
-
addVirtual(config, name, () => {
|
|
163
|
+
addVirtual(config, name, (consumer) => {
|
|
164
|
+
if (!source.consumers.includes(consumer)) return "export {};";
|
|
162
165
|
const cwd = posixPath(resolve("."));
|
|
163
166
|
const lines = entries.map(([, path], index) => {
|
|
164
167
|
const entry = posixPath(relative(cwd, path));
|
|
@@ -171,7 +174,8 @@ async function core(config) {
|
|
|
171
174
|
return `declare module "#${name}" { ${declarations.join(" ")} }`;
|
|
172
175
|
});
|
|
173
176
|
} else if (source.format === "object") {
|
|
174
|
-
addVirtual(config, name, () => {
|
|
177
|
+
addVirtual(config, name, (consumer) => {
|
|
178
|
+
if (!source.consumers.includes(consumer)) return "export default {};";
|
|
175
179
|
const cwd = posixPath(resolve("."));
|
|
176
180
|
return `export default { ${[...resolved].map(([scope, files]) => {
|
|
177
181
|
return `"${scope}": { ${[...files].map(([key, path]) => {
|
package/dist/package.js
CHANGED
package/dist/scope/index.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export type Resolvable<T> = (scope: Scope) => T;
|
|
|
12
12
|
export type Source<T = unknown> = Record<string, Record<string, () => Promise<T>>>;
|
|
13
13
|
export type SourceScope<TSource extends Source> = Extract<keyof TSource, string>;
|
|
14
14
|
export type SourceValue<TSource extends Source, TScope extends SourceScope<TSource>> = Extract<keyof TSource[TScope], string>;
|
|
15
|
+
export type SourceValues<TSource extends Source> = {
|
|
16
|
+
[TScope in SourceScope<TSource>]: SourceValue<TSource, TScope>;
|
|
17
|
+
}[SourceScope<TSource>];
|
|
15
18
|
export type SourceType<TSource extends Source, TScope extends SourceScope<TSource>> = Intersection<Awaited<ReturnType<TSource[TScope][SourceValue<TSource, TScope>]>>>;
|
|
16
19
|
export type SourceTypeProperty<TSource extends Source, TScope extends SourceScope<TSource>, TProperty extends PropertyKey> = SourceType<TSource, TScope> extends Partial<Record<TProperty, infer TValue>> ? TValue : never;
|
|
17
20
|
export interface Plugin {
|