css-typed-vars 0.4.1 → 0.4.3
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/{chunk-Z7K77FZI.js → chunk-CCFKX6NQ.js} +1 -1
- package/dist/chunk-LYWWAGNR.js +65 -0
- package/dist/{chunk-B6LVS5G7.js → chunk-Y6U2ERL3.js} +1 -1
- package/dist/cli.cjs +10 -3
- package/dist/cli.js +11 -4
- package/dist/esbuild.cjs +44 -36
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/rollup.cjs +44 -36
- package/dist/rollup.js +2 -2
- package/dist/unplugin.cjs +44 -36
- package/dist/unplugin.js +2 -2
- package/dist/vite.cjs +44 -36
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +44 -36
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-PKKMLIWX.js +0 -57
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__dirname,
|
|
3
|
+
generateDeclaration,
|
|
4
|
+
generateJs,
|
|
5
|
+
scanVarNames
|
|
6
|
+
} from "./chunk-Y6U2ERL3.js";
|
|
7
|
+
|
|
8
|
+
// src/unplugin.ts
|
|
9
|
+
import { createUnplugin } from "unplugin";
|
|
10
|
+
import { writeFile } from "fs/promises";
|
|
11
|
+
import { join, resolve } from "path";
|
|
12
|
+
var VIRTUAL_ID = "css-typed-vars/vars";
|
|
13
|
+
var RESOLVED_ID = "\0css-typed-vars/vars";
|
|
14
|
+
function getDtsPath(options) {
|
|
15
|
+
if (options.dts === false) return null;
|
|
16
|
+
return options.dts ? resolve(process.cwd(), options.dts) : join(__dirname, "generated.d.ts");
|
|
17
|
+
}
|
|
18
|
+
var unplugin_default = createUnplugin((options) => {
|
|
19
|
+
let cachedNames = null;
|
|
20
|
+
return {
|
|
21
|
+
name: "css-typed-vars",
|
|
22
|
+
vite: {
|
|
23
|
+
enforce: "pre",
|
|
24
|
+
configureServer(server) {
|
|
25
|
+
const handle = async (file) => {
|
|
26
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
27
|
+
cachedNames = null;
|
|
28
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
29
|
+
const dtsPath = getDtsPath(options);
|
|
30
|
+
if (dtsPath) {
|
|
31
|
+
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
32
|
+
}
|
|
33
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
34
|
+
if (mod) {
|
|
35
|
+
server.moduleGraph.invalidateModule(mod);
|
|
36
|
+
server.ws.send({ type: "full-reload" });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
server.watcher.on("change", handle);
|
|
40
|
+
server.watcher.on("add", handle);
|
|
41
|
+
server.watcher.on("unlink", handle);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async buildStart() {
|
|
45
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
46
|
+
const dtsPath = getDtsPath(options);
|
|
47
|
+
if (!dtsPath) return;
|
|
48
|
+
const names = await cachedNames;
|
|
49
|
+
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
50
|
+
},
|
|
51
|
+
resolveId(id) {
|
|
52
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
53
|
+
},
|
|
54
|
+
async load(id) {
|
|
55
|
+
if (id === RESOLVED_ID) {
|
|
56
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
57
|
+
return generateJs(names, options.prefix, options.naming);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
unplugin_default
|
|
65
|
+
};
|
package/dist/cli.cjs
CHANGED
|
@@ -74,7 +74,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
);
|
|
77
|
-
return [...all];
|
|
77
|
+
return [...all].sort();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/generator.ts
|
|
@@ -159,6 +159,13 @@ var getArg = (flag) => {
|
|
|
159
159
|
const i = args.indexOf(flag);
|
|
160
160
|
return i !== -1 ? args[i + 1] : void 0;
|
|
161
161
|
};
|
|
162
|
+
var getArgs = (flag) => {
|
|
163
|
+
const result = [];
|
|
164
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
165
|
+
if (args[i] === flag) result.push(args[i + 1]);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
162
169
|
var watchMode = args.includes("--watch");
|
|
163
170
|
async function loadConfig() {
|
|
164
171
|
const candidates = [
|
|
@@ -197,8 +204,8 @@ async function main() {
|
|
|
197
204
|
const exclude = getArg("--exclude") ?? config.exclude;
|
|
198
205
|
const prefix = getArg("--prefix") ?? config.prefix;
|
|
199
206
|
const naming = getArg("--naming") ?? config.naming;
|
|
200
|
-
const
|
|
201
|
-
const selectors =
|
|
207
|
+
const selectorArgs = getArgs("--selector");
|
|
208
|
+
const selectors = selectorArgs.length > 0 ? selectorArgs : config.selectors;
|
|
202
209
|
if (!input || !output) {
|
|
203
210
|
console.error("Usage: css-typed-vars --input <glob> --output <file> [--watch]");
|
|
204
211
|
console.error("Or add a css-typed-vars.config.js file with input and output fields.");
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
generate
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-CCFKX6NQ.js";
|
|
5
|
+
import "./chunk-Y6U2ERL3.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { readFile } from "fs/promises";
|
|
@@ -14,6 +14,13 @@ var getArg = (flag) => {
|
|
|
14
14
|
const i = args.indexOf(flag);
|
|
15
15
|
return i !== -1 ? args[i + 1] : void 0;
|
|
16
16
|
};
|
|
17
|
+
var getArgs = (flag) => {
|
|
18
|
+
const result = [];
|
|
19
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
20
|
+
if (args[i] === flag) result.push(args[i + 1]);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
17
24
|
var watchMode = args.includes("--watch");
|
|
18
25
|
async function loadConfig() {
|
|
19
26
|
const candidates = [
|
|
@@ -52,8 +59,8 @@ async function main() {
|
|
|
52
59
|
const exclude = getArg("--exclude") ?? config.exclude;
|
|
53
60
|
const prefix = getArg("--prefix") ?? config.prefix;
|
|
54
61
|
const naming = getArg("--naming") ?? config.naming;
|
|
55
|
-
const
|
|
56
|
-
const selectors =
|
|
62
|
+
const selectorArgs = getArgs("--selector");
|
|
63
|
+
const selectors = selectorArgs.length > 0 ? selectorArgs : config.selectors;
|
|
57
64
|
if (!input || !output) {
|
|
58
65
|
console.error("Usage: css-typed-vars --input <glob> --output <file> [--watch]");
|
|
59
66
|
console.error("Or add a css-typed-vars.config.js file with input and output fields.");
|
package/dist/esbuild.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
|
-
return [...all];
|
|
79
|
+
return [...all].sort();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/generator.ts
|
|
@@ -130,42 +130,50 @@ function getDtsPath(options) {
|
|
|
130
130
|
if (options.dts === false) return null;
|
|
131
131
|
return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
|
|
132
132
|
}
|
|
133
|
-
var unplugin_default = (0, import_unplugin.createUnplugin)((options) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
server.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
|
|
134
|
+
let cachedNames = null;
|
|
135
|
+
return {
|
|
136
|
+
name: "css-typed-vars",
|
|
137
|
+
vite: {
|
|
138
|
+
enforce: "pre",
|
|
139
|
+
configureServer(server) {
|
|
140
|
+
const handle = async (file) => {
|
|
141
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
142
|
+
cachedNames = null;
|
|
143
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
144
|
+
const dtsPath = getDtsPath(options);
|
|
145
|
+
if (dtsPath) {
|
|
146
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
147
|
+
}
|
|
148
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
149
|
+
if (mod) {
|
|
150
|
+
server.moduleGraph.invalidateModule(mod);
|
|
151
|
+
server.ws.send({ type: "full-reload" });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
server.watcher.on("change", handle);
|
|
155
|
+
server.watcher.on("add", handle);
|
|
156
|
+
server.watcher.on("unlink", handle);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async buildStart() {
|
|
160
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
|
+
const dtsPath = getDtsPath(options);
|
|
162
|
+
if (!dtsPath) return;
|
|
163
|
+
const names = await cachedNames;
|
|
164
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
165
|
+
},
|
|
166
|
+
resolveId(id) {
|
|
167
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
168
|
+
},
|
|
169
|
+
async load(id) {
|
|
170
|
+
if (id === RESOLVED_ID) {
|
|
171
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
172
|
+
return generateJs(names, options.prefix, options.naming);
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
}
|
|
168
|
-
})
|
|
175
|
+
};
|
|
176
|
+
});
|
|
169
177
|
|
|
170
178
|
// src/esbuild.ts
|
|
171
179
|
var esbuild_default = unplugin_default.esbuild;
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CCFKX6NQ.js";
|
|
4
4
|
import {
|
|
5
5
|
generateCode,
|
|
6
6
|
generateDeclaration,
|
|
7
7
|
generateJs,
|
|
8
8
|
parseVarNames,
|
|
9
9
|
scanVarNames
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Y6U2ERL3.js";
|
|
11
11
|
export {
|
|
12
12
|
generate,
|
|
13
13
|
generateCode,
|
package/dist/rollup.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
|
-
return [...all];
|
|
79
|
+
return [...all].sort();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/generator.ts
|
|
@@ -130,42 +130,50 @@ function getDtsPath(options) {
|
|
|
130
130
|
if (options.dts === false) return null;
|
|
131
131
|
return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
|
|
132
132
|
}
|
|
133
|
-
var unplugin_default = (0, import_unplugin.createUnplugin)((options) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
server.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
|
|
134
|
+
let cachedNames = null;
|
|
135
|
+
return {
|
|
136
|
+
name: "css-typed-vars",
|
|
137
|
+
vite: {
|
|
138
|
+
enforce: "pre",
|
|
139
|
+
configureServer(server) {
|
|
140
|
+
const handle = async (file) => {
|
|
141
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
142
|
+
cachedNames = null;
|
|
143
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
144
|
+
const dtsPath = getDtsPath(options);
|
|
145
|
+
if (dtsPath) {
|
|
146
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
147
|
+
}
|
|
148
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
149
|
+
if (mod) {
|
|
150
|
+
server.moduleGraph.invalidateModule(mod);
|
|
151
|
+
server.ws.send({ type: "full-reload" });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
server.watcher.on("change", handle);
|
|
155
|
+
server.watcher.on("add", handle);
|
|
156
|
+
server.watcher.on("unlink", handle);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async buildStart() {
|
|
160
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
|
+
const dtsPath = getDtsPath(options);
|
|
162
|
+
if (!dtsPath) return;
|
|
163
|
+
const names = await cachedNames;
|
|
164
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
165
|
+
},
|
|
166
|
+
resolveId(id) {
|
|
167
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
168
|
+
},
|
|
169
|
+
async load(id) {
|
|
170
|
+
if (id === RESOLVED_ID) {
|
|
171
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
172
|
+
return generateJs(names, options.prefix, options.naming);
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
}
|
|
168
|
-
})
|
|
175
|
+
};
|
|
176
|
+
});
|
|
169
177
|
|
|
170
178
|
// src/rollup.ts
|
|
171
179
|
var rollup_default = unplugin_default.rollup;
|
package/dist/rollup.js
CHANGED
package/dist/unplugin.cjs
CHANGED
|
@@ -74,7 +74,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
);
|
|
77
|
-
return [...all];
|
|
77
|
+
return [...all].sort();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/generator.ts
|
|
@@ -128,39 +128,47 @@ function getDtsPath(options) {
|
|
|
128
128
|
if (options.dts === false) return null;
|
|
129
129
|
return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
|
|
130
130
|
}
|
|
131
|
-
var unplugin_default = (0, import_unplugin.createUnplugin)((options) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
server.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
131
|
+
var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
|
|
132
|
+
let cachedNames = null;
|
|
133
|
+
return {
|
|
134
|
+
name: "css-typed-vars",
|
|
135
|
+
vite: {
|
|
136
|
+
enforce: "pre",
|
|
137
|
+
configureServer(server) {
|
|
138
|
+
const handle = async (file) => {
|
|
139
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
140
|
+
cachedNames = null;
|
|
141
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
142
|
+
const dtsPath = getDtsPath(options);
|
|
143
|
+
if (dtsPath) {
|
|
144
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
145
|
+
}
|
|
146
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
147
|
+
if (mod) {
|
|
148
|
+
server.moduleGraph.invalidateModule(mod);
|
|
149
|
+
server.ws.send({ type: "full-reload" });
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
server.watcher.on("change", handle);
|
|
153
|
+
server.watcher.on("add", handle);
|
|
154
|
+
server.watcher.on("unlink", handle);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async buildStart() {
|
|
158
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
159
|
+
const dtsPath = getDtsPath(options);
|
|
160
|
+
if (!dtsPath) return;
|
|
161
|
+
const names = await cachedNames;
|
|
162
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
163
|
+
},
|
|
164
|
+
resolveId(id) {
|
|
165
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
166
|
+
},
|
|
167
|
+
async load(id) {
|
|
168
|
+
if (id === RESOLVED_ID) {
|
|
169
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
170
|
+
return generateJs(names, options.prefix, options.naming);
|
|
171
|
+
}
|
|
164
172
|
}
|
|
165
|
-
}
|
|
166
|
-
})
|
|
173
|
+
};
|
|
174
|
+
});
|
package/dist/unplugin.js
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
|
-
return [...all];
|
|
79
|
+
return [...all].sort();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/generator.ts
|
|
@@ -130,42 +130,50 @@ function getDtsPath(options) {
|
|
|
130
130
|
if (options.dts === false) return null;
|
|
131
131
|
return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
|
|
132
132
|
}
|
|
133
|
-
var unplugin_default = (0, import_unplugin.createUnplugin)((options) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
server.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
|
|
134
|
+
let cachedNames = null;
|
|
135
|
+
return {
|
|
136
|
+
name: "css-typed-vars",
|
|
137
|
+
vite: {
|
|
138
|
+
enforce: "pre",
|
|
139
|
+
configureServer(server) {
|
|
140
|
+
const handle = async (file) => {
|
|
141
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
142
|
+
cachedNames = null;
|
|
143
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
144
|
+
const dtsPath = getDtsPath(options);
|
|
145
|
+
if (dtsPath) {
|
|
146
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
147
|
+
}
|
|
148
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
149
|
+
if (mod) {
|
|
150
|
+
server.moduleGraph.invalidateModule(mod);
|
|
151
|
+
server.ws.send({ type: "full-reload" });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
server.watcher.on("change", handle);
|
|
155
|
+
server.watcher.on("add", handle);
|
|
156
|
+
server.watcher.on("unlink", handle);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async buildStart() {
|
|
160
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
|
+
const dtsPath = getDtsPath(options);
|
|
162
|
+
if (!dtsPath) return;
|
|
163
|
+
const names = await cachedNames;
|
|
164
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
165
|
+
},
|
|
166
|
+
resolveId(id) {
|
|
167
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
168
|
+
},
|
|
169
|
+
async load(id) {
|
|
170
|
+
if (id === RESOLVED_ID) {
|
|
171
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
172
|
+
return generateJs(names, options.prefix, options.naming);
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
}
|
|
168
|
-
})
|
|
175
|
+
};
|
|
176
|
+
});
|
|
169
177
|
|
|
170
178
|
// src/vite.ts
|
|
171
179
|
var vite_default = unplugin_default.vite;
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function scanVarNames(patterns, exclude, selectors) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
);
|
|
79
|
-
return [...all];
|
|
79
|
+
return [...all].sort();
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/generator.ts
|
|
@@ -130,42 +130,50 @@ function getDtsPath(options) {
|
|
|
130
130
|
if (options.dts === false) return null;
|
|
131
131
|
return options.dts ? (0, import_node_path.resolve)(process.cwd(), options.dts) : (0, import_node_path.join)(__dirname, "generated.d.ts");
|
|
132
132
|
}
|
|
133
|
-
var unplugin_default = (0, import_unplugin.createUnplugin)((options) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
server.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
|
|
134
|
+
let cachedNames = null;
|
|
135
|
+
return {
|
|
136
|
+
name: "css-typed-vars",
|
|
137
|
+
vite: {
|
|
138
|
+
enforce: "pre",
|
|
139
|
+
configureServer(server) {
|
|
140
|
+
const handle = async (file) => {
|
|
141
|
+
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
142
|
+
cachedNames = null;
|
|
143
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
144
|
+
const dtsPath = getDtsPath(options);
|
|
145
|
+
if (dtsPath) {
|
|
146
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
147
|
+
}
|
|
148
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
149
|
+
if (mod) {
|
|
150
|
+
server.moduleGraph.invalidateModule(mod);
|
|
151
|
+
server.ws.send({ type: "full-reload" });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
server.watcher.on("change", handle);
|
|
155
|
+
server.watcher.on("add", handle);
|
|
156
|
+
server.watcher.on("unlink", handle);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async buildStart() {
|
|
160
|
+
cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
|
+
const dtsPath = getDtsPath(options);
|
|
162
|
+
if (!dtsPath) return;
|
|
163
|
+
const names = await cachedNames;
|
|
164
|
+
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
165
|
+
},
|
|
166
|
+
resolveId(id) {
|
|
167
|
+
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
168
|
+
},
|
|
169
|
+
async load(id) {
|
|
170
|
+
if (id === RESOLVED_ID) {
|
|
171
|
+
const names = await (cachedNames ?? scanVarNames(options.input, options.exclude, options.selectors));
|
|
172
|
+
return generateJs(names, options.prefix, options.naming);
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
}
|
|
168
|
-
})
|
|
175
|
+
};
|
|
176
|
+
});
|
|
169
177
|
|
|
170
178
|
// src/webpack.ts
|
|
171
179
|
var webpack_default = unplugin_default.webpack;
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
package/dist/chunk-PKKMLIWX.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__dirname,
|
|
3
|
-
generateDeclaration,
|
|
4
|
-
generateJs,
|
|
5
|
-
scanVarNames
|
|
6
|
-
} from "./chunk-B6LVS5G7.js";
|
|
7
|
-
|
|
8
|
-
// src/unplugin.ts
|
|
9
|
-
import { createUnplugin } from "unplugin";
|
|
10
|
-
import { writeFile } from "fs/promises";
|
|
11
|
-
import { join, resolve } from "path";
|
|
12
|
-
var VIRTUAL_ID = "css-typed-vars/vars";
|
|
13
|
-
var RESOLVED_ID = "\0css-typed-vars/vars";
|
|
14
|
-
function getDtsPath(options) {
|
|
15
|
-
if (options.dts === false) return null;
|
|
16
|
-
return options.dts ? resolve(process.cwd(), options.dts) : join(__dirname, "generated.d.ts");
|
|
17
|
-
}
|
|
18
|
-
var unplugin_default = createUnplugin((options) => ({
|
|
19
|
-
name: "css-typed-vars",
|
|
20
|
-
vite: {
|
|
21
|
-
enforce: "pre",
|
|
22
|
-
configureServer(server) {
|
|
23
|
-
server.watcher.on("change", async (file) => {
|
|
24
|
-
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
25
|
-
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
26
|
-
const dtsPath = getDtsPath(options);
|
|
27
|
-
if (dtsPath) {
|
|
28
|
-
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
29
|
-
}
|
|
30
|
-
const mod = server.moduleGraph.getModuleById(RESOLVED_ID);
|
|
31
|
-
if (mod) {
|
|
32
|
-
server.moduleGraph.invalidateModule(mod);
|
|
33
|
-
server.ws.send({ type: "full-reload" });
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
async buildStart() {
|
|
39
|
-
const dtsPath = getDtsPath(options);
|
|
40
|
-
if (!dtsPath) return;
|
|
41
|
-
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
42
|
-
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
43
|
-
},
|
|
44
|
-
resolveId(id) {
|
|
45
|
-
if (id === VIRTUAL_ID) return RESOLVED_ID;
|
|
46
|
-
},
|
|
47
|
-
async load(id) {
|
|
48
|
-
if (id === RESOLVED_ID) {
|
|
49
|
-
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
50
|
-
return generateJs(names, options.prefix, options.naming);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
unplugin_default
|
|
57
|
-
};
|