steam-theming-utils 3.1.2 → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steam-theming-utils",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "A collection of scripts for easier Steam theming",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  "types": "./src/api.d.ts",
14
14
  "exports": {
15
15
  ".": "./src/api.js",
16
- "./postcss-plugin": "./src/postcss_plugin.js"
16
+ "./postcss-plugins": "./src/postcss_plugins/index.js"
17
17
  },
18
18
  "dependencies": {
19
19
  "chrome-remote-interface": "^0.33.2",
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {object} PluginOptions
3
+ *
4
+ * @property {RegExp[]} filter
5
+ * List of paths to ignore.
6
+ */
7
+
8
+ /** @type {PluginOptions} */
9
+ const DEFAULT_OPTIONS = {
10
+ filter: [],
11
+ };
12
+
13
+ /**
14
+ * Appends `!important` to all declarations. Filter paths with
15
+ * {@link PluginOptions.filter}.
16
+ */
17
+ export const appendImportantPlugin =
18
+ (opts = DEFAULT_OPTIONS) =>
19
+ (css) => {
20
+ css.walkRules((rule) => {
21
+ const nodes = rule.nodes.filter(
22
+ (node) => !opts.filter.some((e) => e.test(node.parent.selector)),
23
+ );
24
+ for (const node of nodes) {
25
+ node.important = true;
26
+ }
27
+ });
28
+ };
29
+ appendImportantPlugin.postcss = true;
@@ -0,0 +1,4 @@
1
+ import { appendImportantPlugin } from "./append_important.js";
2
+ import { selectorReplacerPlugin } from "./selector_replacer.js";
3
+
4
+ export { appendImportantPlugin, selectorReplacerPlugin };
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  // Not a dependency because postcss already depends on it.
4
4
  import yargs from "yargs";
5
- import { config } from "./api.js";
5
+ import { config } from "../api.js";
6
6
 
7
7
  const PAGES = [
8
8
  "accountpreferences",