@pwrs/lit-css 3.0.0 → 4.0.0
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/lit-css.cjs +122 -120
- package/package.json +2 -2
package/lit-css.cjs
CHANGED
|
@@ -35,6 +35,7 @@ var require_src = __commonJS({
|
|
|
35
35
|
var path = require("path");
|
|
36
36
|
var fs = require("fs");
|
|
37
37
|
var os = require("os");
|
|
38
|
+
var url = require("url");
|
|
38
39
|
var fsReadFileAsync = fs.promises.readFile;
|
|
39
40
|
function getDefaultSearchPlaces(name, sync) {
|
|
40
41
|
return [
|
|
@@ -57,20 +58,25 @@ var require_src = __commonJS({
|
|
|
57
58
|
return path.dirname(p) || path.sep;
|
|
58
59
|
}
|
|
59
60
|
var jsonLoader = (_, content) => JSON.parse(content);
|
|
61
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
60
62
|
var defaultLoadersSync = Object.freeze({
|
|
61
|
-
".js":
|
|
62
|
-
".json":
|
|
63
|
-
".cjs":
|
|
63
|
+
".js": requireFunc,
|
|
64
|
+
".json": requireFunc,
|
|
65
|
+
".cjs": requireFunc,
|
|
64
66
|
noExt: jsonLoader
|
|
65
67
|
});
|
|
66
68
|
module2.exports.defaultLoadersSync = defaultLoadersSync;
|
|
67
69
|
var dynamicImport = async (id) => {
|
|
68
70
|
try {
|
|
69
|
-
const
|
|
71
|
+
const fileUrl = url.pathToFileURL(id).href;
|
|
72
|
+
const mod = await import(
|
|
73
|
+
/* webpackIgnore: true */
|
|
74
|
+
fileUrl
|
|
75
|
+
);
|
|
70
76
|
return mod.default;
|
|
71
77
|
} catch (e) {
|
|
72
78
|
try {
|
|
73
|
-
return
|
|
79
|
+
return requireFunc(id);
|
|
74
80
|
} catch (requireE) {
|
|
75
81
|
if (requireE.code === "ERR_REQUIRE_ESM" || requireE instanceof SyntaxError && requireE.toString().includes("Cannot use import statement outside a module")) {
|
|
76
82
|
throw e;
|
|
@@ -116,26 +122,21 @@ var require_src = __commonJS({
|
|
|
116
122
|
return conf;
|
|
117
123
|
}
|
|
118
124
|
function getPackageProp(props, obj) {
|
|
119
|
-
if (typeof props === "string" && props in obj)
|
|
120
|
-
return obj[props];
|
|
125
|
+
if (typeof props === "string" && props in obj) return obj[props];
|
|
121
126
|
return (Array.isArray(props) ? props : props.split(".")).reduce(
|
|
122
127
|
(acc, prop) => acc === void 0 ? acc : acc[prop],
|
|
123
128
|
obj
|
|
124
129
|
) || null;
|
|
125
130
|
}
|
|
126
131
|
function validateFilePath(filepath) {
|
|
127
|
-
if (!filepath)
|
|
128
|
-
throw new Error("load must pass a non-empty string");
|
|
132
|
+
if (!filepath) throw new Error("load must pass a non-empty string");
|
|
129
133
|
}
|
|
130
134
|
function validateLoader(loader, ext) {
|
|
131
|
-
if (!loader)
|
|
132
|
-
|
|
133
|
-
if (typeof loader !== "function")
|
|
134
|
-
throw new Error("loader is not a function");
|
|
135
|
+
if (!loader) throw new Error(`No loader specified for extension "${ext}"`);
|
|
136
|
+
if (typeof loader !== "function") throw new Error("loader is not a function");
|
|
135
137
|
}
|
|
136
138
|
var makeEmplace = (enableCache) => (c, filepath, res) => {
|
|
137
|
-
if (enableCache)
|
|
138
|
-
c.set(filepath, res);
|
|
139
|
+
if (enableCache) c.set(filepath, res);
|
|
139
140
|
return res;
|
|
140
141
|
};
|
|
141
142
|
module2.exports.lilconfig = function lilconfig(name, options) {
|
|
@@ -159,61 +160,56 @@ var require_src = __commonJS({
|
|
|
159
160
|
};
|
|
160
161
|
const visited = /* @__PURE__ */ new Set();
|
|
161
162
|
let dir = searchFrom;
|
|
162
|
-
dirLoop:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
searchCache.set(p, r);
|
|
169
|
-
return r;
|
|
170
|
-
}
|
|
171
|
-
visited.add(dir);
|
|
163
|
+
dirLoop: while (true) {
|
|
164
|
+
if (cache) {
|
|
165
|
+
const r = searchCache.get(dir);
|
|
166
|
+
if (r !== void 0) {
|
|
167
|
+
for (const p of visited) searchCache.set(p, r);
|
|
168
|
+
return r;
|
|
172
169
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
const isEmpty = content.trim() === "";
|
|
194
|
-
if (isEmpty && ignoreEmptySearchPlaces)
|
|
195
|
-
continue;
|
|
196
|
-
if (isEmpty) {
|
|
197
|
-
result.isEmpty = true;
|
|
198
|
-
result.config = void 0;
|
|
199
|
-
} else {
|
|
200
|
-
validateLoader(loader, loaderKey);
|
|
201
|
-
result.config = await loader(filepath, content);
|
|
170
|
+
visited.add(dir);
|
|
171
|
+
}
|
|
172
|
+
for (const searchPlace of searchPlaces) {
|
|
173
|
+
const filepath = path.join(dir, searchPlace);
|
|
174
|
+
try {
|
|
175
|
+
await fs.promises.access(filepath);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const content = String(await fsReadFileAsync(filepath));
|
|
180
|
+
const loaderKey = path.extname(searchPlace) || "noExt";
|
|
181
|
+
const loader = loaders[loaderKey];
|
|
182
|
+
if (searchPlace === "package.json") {
|
|
183
|
+
const pkg = await loader(filepath, content);
|
|
184
|
+
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
185
|
+
if (maybeConfig != null) {
|
|
186
|
+
result.config = maybeConfig;
|
|
187
|
+
result.filepath = filepath;
|
|
188
|
+
break dirLoop;
|
|
202
189
|
}
|
|
203
|
-
|
|
204
|
-
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const isEmpty = content.trim() === "";
|
|
193
|
+
if (isEmpty && ignoreEmptySearchPlaces) continue;
|
|
194
|
+
if (isEmpty) {
|
|
195
|
+
result.isEmpty = true;
|
|
196
|
+
result.config = void 0;
|
|
197
|
+
} else {
|
|
198
|
+
validateLoader(loader, loaderKey);
|
|
199
|
+
result.config = await loader(filepath, content);
|
|
205
200
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
dir = parentDir(dir);
|
|
201
|
+
result.filepath = filepath;
|
|
202
|
+
break dirLoop;
|
|
209
203
|
}
|
|
204
|
+
if (dir === stopDir || dir === parentDir(dir)) break dirLoop;
|
|
205
|
+
dir = parentDir(dir);
|
|
206
|
+
}
|
|
210
207
|
const transformed = (
|
|
211
208
|
// not found
|
|
212
209
|
result.filepath === "" && result.config === null ? transform2(null) : transform2(result)
|
|
213
210
|
);
|
|
214
211
|
if (cache) {
|
|
215
|
-
for (const p of visited)
|
|
216
|
-
searchCache.set(p, transformed);
|
|
212
|
+
for (const p of visited) searchCache.set(p, transformed);
|
|
217
213
|
}
|
|
218
214
|
return transformed;
|
|
219
215
|
},
|
|
@@ -262,12 +258,10 @@ var require_src = __commonJS({
|
|
|
262
258
|
);
|
|
263
259
|
},
|
|
264
260
|
clearLoadCache() {
|
|
265
|
-
if (cache)
|
|
266
|
-
loadCache.clear();
|
|
261
|
+
if (cache) loadCache.clear();
|
|
267
262
|
},
|
|
268
263
|
clearSearchCache() {
|
|
269
|
-
if (cache)
|
|
270
|
-
searchCache.clear();
|
|
264
|
+
if (cache) searchCache.clear();
|
|
271
265
|
},
|
|
272
266
|
clearCaches() {
|
|
273
267
|
if (cache) {
|
|
@@ -298,61 +292,56 @@ var require_src = __commonJS({
|
|
|
298
292
|
};
|
|
299
293
|
const visited = /* @__PURE__ */ new Set();
|
|
300
294
|
let dir = searchFrom;
|
|
301
|
-
dirLoop:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
searchCache.set(p, r);
|
|
308
|
-
return r;
|
|
309
|
-
}
|
|
310
|
-
visited.add(dir);
|
|
295
|
+
dirLoop: while (true) {
|
|
296
|
+
if (cache) {
|
|
297
|
+
const r = searchCache.get(dir);
|
|
298
|
+
if (r !== void 0) {
|
|
299
|
+
for (const p of visited) searchCache.set(p, r);
|
|
300
|
+
return r;
|
|
311
301
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
const isEmpty = content.trim() === "";
|
|
333
|
-
if (isEmpty && ignoreEmptySearchPlaces)
|
|
334
|
-
continue;
|
|
335
|
-
if (isEmpty) {
|
|
336
|
-
result.isEmpty = true;
|
|
337
|
-
result.config = void 0;
|
|
338
|
-
} else {
|
|
339
|
-
validateLoader(loader, loaderKey);
|
|
340
|
-
result.config = loader(filepath, content);
|
|
302
|
+
visited.add(dir);
|
|
303
|
+
}
|
|
304
|
+
for (const searchPlace of searchPlaces) {
|
|
305
|
+
const filepath = path.join(dir, searchPlace);
|
|
306
|
+
try {
|
|
307
|
+
fs.accessSync(filepath);
|
|
308
|
+
} catch (e) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const loaderKey = path.extname(searchPlace) || "noExt";
|
|
312
|
+
const loader = loaders[loaderKey];
|
|
313
|
+
const content = String(fs.readFileSync(filepath));
|
|
314
|
+
if (searchPlace === "package.json") {
|
|
315
|
+
const pkg = loader(filepath, content);
|
|
316
|
+
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
317
|
+
if (maybeConfig != null) {
|
|
318
|
+
result.config = maybeConfig;
|
|
319
|
+
result.filepath = filepath;
|
|
320
|
+
break dirLoop;
|
|
341
321
|
}
|
|
342
|
-
|
|
343
|
-
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const isEmpty = content.trim() === "";
|
|
325
|
+
if (isEmpty && ignoreEmptySearchPlaces) continue;
|
|
326
|
+
if (isEmpty) {
|
|
327
|
+
result.isEmpty = true;
|
|
328
|
+
result.config = void 0;
|
|
329
|
+
} else {
|
|
330
|
+
validateLoader(loader, loaderKey);
|
|
331
|
+
result.config = loader(filepath, content);
|
|
344
332
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
dir = parentDir(dir);
|
|
333
|
+
result.filepath = filepath;
|
|
334
|
+
break dirLoop;
|
|
348
335
|
}
|
|
336
|
+
if (dir === stopDir || dir === parentDir(dir)) break dirLoop;
|
|
337
|
+
dir = parentDir(dir);
|
|
338
|
+
}
|
|
349
339
|
const transformed = (
|
|
350
340
|
// not found
|
|
351
341
|
result.filepath === "" && result.config === null ? transform2(null) : transform2(result)
|
|
352
342
|
);
|
|
353
343
|
if (cache) {
|
|
354
|
-
for (const p of visited)
|
|
355
|
-
searchCache.set(p, transformed);
|
|
344
|
+
for (const p of visited) searchCache.set(p, transformed);
|
|
356
345
|
}
|
|
357
346
|
return transformed;
|
|
358
347
|
},
|
|
@@ -397,12 +386,10 @@ var require_src = __commonJS({
|
|
|
397
386
|
);
|
|
398
387
|
},
|
|
399
388
|
clearLoadCache() {
|
|
400
|
-
if (cache)
|
|
401
|
-
loadCache.clear();
|
|
389
|
+
if (cache) loadCache.clear();
|
|
402
390
|
},
|
|
403
391
|
clearSearchCache() {
|
|
404
|
-
if (cache)
|
|
405
|
-
searchCache.clear();
|
|
392
|
+
if (cache) searchCache.clear();
|
|
406
393
|
},
|
|
407
394
|
clearCaches() {
|
|
408
395
|
if (cache) {
|
|
@@ -1005,10 +992,8 @@ var require_main = __commonJS({
|
|
|
1005
992
|
return function(a, b) {
|
|
1006
993
|
a = removeVendorPrefix(a);
|
|
1007
994
|
b = removeVendorPrefix(b);
|
|
1008
|
-
if (shorthandData2[a] && shorthandData2[a].includes(b))
|
|
1009
|
-
|
|
1010
|
-
if (shorthandData2[b] && shorthandData2[b].includes(a))
|
|
1011
|
-
return 0;
|
|
995
|
+
if (shorthandData2[a] && shorthandData2[a].includes(b)) return 0;
|
|
996
|
+
if (shorthandData2[b] && shorthandData2[b].includes(a)) return 0;
|
|
1012
997
|
return comparator(a, b);
|
|
1013
998
|
};
|
|
1014
999
|
};
|
|
@@ -2424,6 +2409,22 @@ var require_src3 = __commonJS({
|
|
|
2424
2409
|
},
|
|
2425
2410
|
cssDeclarationSorter: {
|
|
2426
2411
|
keepOverrides: true
|
|
2412
|
+
},
|
|
2413
|
+
minifySelectors: {
|
|
2414
|
+
sort: true
|
|
2415
|
+
},
|
|
2416
|
+
svgo: {
|
|
2417
|
+
plugins: [
|
|
2418
|
+
{
|
|
2419
|
+
name: "preset-default",
|
|
2420
|
+
params: {
|
|
2421
|
+
overrides: {
|
|
2422
|
+
removeViewBox: false,
|
|
2423
|
+
removeTitle: false
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
]
|
|
2427
2428
|
}
|
|
2428
2429
|
};
|
|
2429
2430
|
return plugins.map(([plugin, opt]) => {
|
|
@@ -2485,6 +2486,7 @@ var require_src4 = __commonJS({
|
|
|
2485
2486
|
var path = require("path");
|
|
2486
2487
|
var postcss = require("postcss");
|
|
2487
2488
|
var { lilconfigSync } = require_src();
|
|
2489
|
+
var defaultPreset = require_src3();
|
|
2488
2490
|
var cssnano2 = "cssnano";
|
|
2489
2491
|
function isResolvable(moduleId) {
|
|
2490
2492
|
try {
|
|
@@ -2507,7 +2509,7 @@ var require_src4 = __commonJS({
|
|
|
2507
2509
|
return fn.plugins;
|
|
2508
2510
|
}
|
|
2509
2511
|
if (fn === "default") {
|
|
2510
|
-
return
|
|
2512
|
+
return defaultPreset(options).plugins;
|
|
2511
2513
|
}
|
|
2512
2514
|
if (typeof fn === "function") {
|
|
2513
2515
|
return fn(options).plugins;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pwrs/lit-css",
|
|
3
3
|
"description": "Import CSS files as css tagged-template literals",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lit-css.js",
|
|
7
7
|
"types": "lit-css.d.ts",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"lit-css.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"cssnano": "^
|
|
33
|
+
"cssnano": "^7.0.7"
|
|
34
34
|
}
|
|
35
35
|
}
|