@pwrs/lit-css 3.0.0 → 3.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.
Files changed (2) hide show
  1. package/lit-css.cjs +117 -119
  2. 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": require,
62
- ".json": require,
63
- ".cjs": require,
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 mod = await import(id);
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 require(id);
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
- throw new Error(`No loader specified for extension "${ext}"`);
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
- while (true) {
164
- if (cache) {
165
- const r = searchCache.get(dir);
166
- if (r !== void 0) {
167
- for (const p of visited)
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
- for (const searchPlace of searchPlaces) {
174
- const filepath = path.join(dir, searchPlace);
175
- try {
176
- await fs.promises.access(filepath);
177
- } catch (e) {
178
- continue;
179
- }
180
- const content = String(await fsReadFileAsync(filepath));
181
- const loaderKey = path.extname(searchPlace) || "noExt";
182
- const loader = loaders[loaderKey];
183
- if (searchPlace === "package.json") {
184
- const pkg = await loader(filepath, content);
185
- const maybeConfig = getPackageProp(packageProp, pkg);
186
- if (maybeConfig != null) {
187
- result.config = maybeConfig;
188
- result.filepath = filepath;
189
- break dirLoop;
190
- }
191
- continue;
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
- result.filepath = filepath;
204
- break dirLoop;
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
- if (dir === stopDir || dir === parentDir(dir))
207
- break dirLoop;
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
- while (true) {
303
- if (cache) {
304
- const r = searchCache.get(dir);
305
- if (r !== void 0) {
306
- for (const p of visited)
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
- for (const searchPlace of searchPlaces) {
313
- const filepath = path.join(dir, searchPlace);
314
- try {
315
- fs.accessSync(filepath);
316
- } catch (e) {
317
- continue;
318
- }
319
- const loaderKey = path.extname(searchPlace) || "noExt";
320
- const loader = loaders[loaderKey];
321
- const content = String(fs.readFileSync(filepath));
322
- if (searchPlace === "package.json") {
323
- const pkg = loader(filepath, content);
324
- const maybeConfig = getPackageProp(packageProp, pkg);
325
- if (maybeConfig != null) {
326
- result.config = maybeConfig;
327
- result.filepath = filepath;
328
- break dirLoop;
329
- }
330
- continue;
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
- result.filepath = filepath;
343
- break dirLoop;
322
+ continue;
344
323
  }
345
- if (dir === stopDir || dir === parentDir(dir))
346
- break dirLoop;
347
- dir = parentDir(dir);
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);
332
+ }
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
- return 0;
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,19 @@ var require_src3 = __commonJS({
2424
2409
  },
2425
2410
  cssDeclarationSorter: {
2426
2411
  keepOverrides: true
2412
+ },
2413
+ svgo: {
2414
+ plugins: [
2415
+ {
2416
+ name: "preset-default",
2417
+ params: {
2418
+ overrides: {
2419
+ removeViewBox: false,
2420
+ removeTitle: false
2421
+ }
2422
+ }
2423
+ }
2424
+ ]
2427
2425
  }
2428
2426
  };
2429
2427
  return plugins.map(([plugin, opt]) => {
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": "3.0.0",
4
+ "version": "3.0.1",
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": "^6.1.2"
33
+ "cssnano": "^7.0.6"
34
34
  }
35
35
  }