steam-theming-utils 3.2.0 → 3.3.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.
package/README.md CHANGED
@@ -1,51 +1,52 @@
1
- # steam-theming-utils
2
-
3
- A collection of scripts for easier (and future-proof) Steam theming.
4
-
5
- ## Usage
6
-
7
- ```sh
8
- $ npm i steam-theming-utils
9
- $ npx steam-theming-utils <script> <page>
10
- ```
11
-
12
- Note that running any script requires Steam running with `-cef-enable-debugging`.
13
-
14
- ## Scripts
15
-
16
- | Name | Description |
17
- | --------------------- | ----------------------------------------------------------------------------------------- |
18
- | build_class_modules | Generates a class map file for usage with other scripts. |
19
- | make_readable_classes | Adds readable versions of classes to the focused window/page. ![Preview][classes-preview] |
20
- | replace_old_classes | Replaces old classes with new ones for themes not using the [template][template]. |
21
-
22
- ## Pages
23
-
24
- | Name | Description |
25
- | ------------------ | ---------------------------------------------------------------------------- |
26
- | apppage | Related items & controller info in https://store.steampowered.com/app/666220 |
27
- | accountpreferences | https://store.steampowered.com/account |
28
- | client | The Steam client. The default. |
29
- | gameslist | https://steamcommunity.com/my/games |
30
- | notificationspage | https://steamcommunity.com/my/notifications |
31
- | profileedit | https://steamcommunity.com/my/edit |
32
- | shoppingcart | https://store.steampowered.com/cart |
33
-
34
- ## Errors
35
-
36
- | Name | Description |
37
- | ------------------------- | ------------------------------------------------------------------------------------------------- |
38
- | #ClassName is undefined | Typo or that class either got renamed or removed, and so you will have to update it yourself. |
39
- | [mod_name] no such module | Typo or that module either got renamed or removed, see diffs [here][diffs] depending on the page. |
40
- | [map_name] no such map | Use `npx steam-theming-utils build_class_modules map_name` to create it. |
41
-
42
- ## Config
43
-
44
- Configured through a `steam-theming-utils.config.js` (or the one from [here][config-files]) file that must `export default` an [object][config-docs]. It's optional and has defaults listed [here][config-defaults].
45
-
46
- [classes-preview]: ./img/readable_classes.png
47
- [config-defaults]: https://github.com/ricewind012/steam-theming-utils/blob/master/src/constants.js#L7-L11
48
- [config-docs]: https://github.com/ricewind012/steam-theming-utils/blob/master/src/api.d.ts#L4-L16
49
- [config-files]: https://github.com/cosmiconfig/cosmiconfig#usage-for-end-users
50
- [diffs]: https://github.com/ricewind012/steam-theming-utils/tree/master/cdp/db
51
- [template]: https://github.com/ricewind012/more-advanced-theme-template
1
+ # steam-theming-utils
2
+
3
+ A collection of scripts for easier (and future-proof) Steam theming.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ $ npm i steam-theming-utils
9
+ $ npx steam-theming-utils <script> <page>
10
+ ```
11
+
12
+ Note that running any script requires Steam running with `-cef-enable-debugging`.
13
+
14
+ ## Scripts
15
+
16
+ | Name | Description |
17
+ | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
18
+ | build_class_modules | Generates a class map file for usage with other scripts. |
19
+ | make_readable_classes | Adds readable versions of classes to the focused window/page. ![Preview][classes-preview] |
20
+ | migrate | _Try to_ migrate to using readable class names. Other rules that can't be sorted/found go in `_UNSORTED.css`/`_NOTFOUND.css` respectively. |
21
+ | replace_old_classes | Replaces old classes with new ones for themes not using the [template][template]. |
22
+
23
+ ## Pages
24
+
25
+ | Name | Description |
26
+ | ------------------ | ---------------------------------------------------------------------------- |
27
+ | apppage | Related items & controller info in https://store.steampowered.com/app/666220 |
28
+ | accountpreferences | https://store.steampowered.com/account |
29
+ | client | The Steam client. The default. |
30
+ | gameslist | https://steamcommunity.com/my/games |
31
+ | notificationspage | https://steamcommunity.com/my/notifications |
32
+ | profileedit | https://steamcommunity.com/my/edit |
33
+ | shoppingcart | https://store.steampowered.com/cart |
34
+
35
+ ## Errors
36
+
37
+ | Name | Description |
38
+ | ------------------------- | ------------------------------------------------------------------------------------------------- |
39
+ | #ClassName is undefined | Typo or that class either got renamed or removed, and so you will have to update it yourself. |
40
+ | [mod_name] no such module | Typo or that module either got renamed or removed, see diffs [here][diffs] depending on the page. |
41
+ | [map_name] no such map | Use `npx steam-theming-utils build_class_modules map_name` to create it. |
42
+
43
+ ## Config
44
+
45
+ Configured through a `steam-theming-utils.config.js` (or the one from [here][config-files]) file that must `export default` an [object][config-docs]. It's optional and has defaults listed [here][config-defaults].
46
+
47
+ [classes-preview]: ./img/readable_classes.png
48
+ [config-defaults]: https://github.com/ricewind012/steam-theming-utils/blob/master/src/constants.js#L7-L11
49
+ [config-docs]: https://github.com/ricewind012/steam-theming-utils/blob/master/src/api.d.ts#L4-L16
50
+ [config-files]: https://github.com/cosmiconfig/cosmiconfig#usage-for-end-users
51
+ [diffs]: https://github.com/ricewind012/steam-theming-utils/tree/master/cdp/db
52
+ [template]: https://github.com/ricewind012/more-advanced-theme-template
@@ -1,25 +1,25 @@
1
- classModules = {
2
- ...(window.specialModules || {}),
3
- ...(window.parsedModules
4
- ?.map((e) => ({ [e[0]]: e[1] }))
5
- .reduce((a, b) => Object.assign(a, b)) || {}),
6
- ...exportedModules
7
- .flatMap((a) => {
8
- const mod = findFirstModule(a[1], a[0]);
9
- if (!mod) {
10
- return {};
11
- }
12
-
13
- return {
14
- [a[0]]: Object.keys(mod || {})
15
- // Remove keys like "duration-app-launch"
16
- .filter((e) => !mod[e].match(/^\d+(\.\d+)?(\w{2})?$/))
17
- .map((e) => ({ [e]: mod[e] }))
18
- .reduce((a, b) => Object.assign(a, b)),
19
- };
20
- })
21
- .reduce((a, b) => Object.assign(a, b)),
22
- };
23
-
24
- // return
25
- classModules;
1
+ classModules = {
2
+ ...(window.specialModules || {}),
3
+ ...(window.parsedModules
4
+ ?.map((e) => ({ [e[0]]: e[1] }))
5
+ .reduce((a, b) => Object.assign(a, b)) || {}),
6
+ ...exportedModules
7
+ .flatMap((a) => {
8
+ const mod = findFirstModule(a[1], a[0]);
9
+ if (!mod) {
10
+ return {};
11
+ }
12
+
13
+ return {
14
+ [a[0]]: Object.keys(mod || {})
15
+ // Remove keys like "duration-app-launch"
16
+ .filter((e) => !mod[e].match(/^\d+(\.\d+)?(\w{2})?$/))
17
+ .map((e) => ({ [e]: mod[e] }))
18
+ .reduce((a, b) => Object.assign(a, b)),
19
+ };
20
+ })
21
+ .reduce((a, b) => Object.assign(a, b)),
22
+ };
23
+
24
+ // return
25
+ classModules;
@@ -1,64 +1,64 @@
1
- let initReq;
2
- const webpackCache = {};
3
- const webpackGlobal = Object.keys(window).find((e) => e.startsWith("webpack"));
4
- window[webpackGlobal].push([
5
- [Math.random()],
6
- {},
7
- (r) => {
8
- initReq = r;
9
- },
10
- ]);
11
- for (const i of Object.keys(initReq.m)) {
12
- webpackCache[i] = initReq(i);
13
- }
14
-
15
- // Leave only the relevant modules
16
- const allModules = Object.values(webpackCache).filter((e) => {
17
- if (!e || typeof e !== "object" || e.__esModule) {
18
- return false;
19
- }
20
-
21
- const keys = Object.keys(e);
22
- const first = keys[0];
23
- return (
24
- first &&
25
- first.length >= 2 &&
26
- !(
27
- keys.length === 1 &&
28
- (first === "duration-app-launch" ||
29
- first === "version" ||
30
- first.match(/^str[A-Z]/))
31
- ) &&
32
- keys.every((k) => typeof e[k] === "string")
33
- );
34
- });
35
-
36
- const findModule = (filter) => allModules.find(filter);
37
- const findAllModules = (filter) => allModules.filter(filter);
38
-
39
- function findFirstModule(filter, component) {
40
- const modules = findAllModules(filter);
41
- const printError = (msg) => {
42
- console.error("[%s] %s", component, msg);
43
- };
44
-
45
- if (modules.length === 0) {
46
- printError("found no modules");
47
- }
48
- if (modules.length > 1) {
49
- printError("found more than 1 module, returning first found");
50
- }
51
-
52
- return modules[0];
53
- }
54
-
55
- /**
56
- * Find a unique class name from multiple similiar class modules.
57
- *
58
- * @param key Class name.
59
- * @param index Array index.
60
- */
61
- const findUniqueKey = (key, index = 0) =>
62
- Object.keys(findAllModules((mod) => mod[key])[index]).find(
63
- (mod) => findAllModules((mod2) => mod2[mod]).length === 1,
64
- );
1
+ let initReq;
2
+ const webpackCache = {};
3
+ const webpackGlobal = Object.keys(window).find((e) => e.startsWith("webpack"));
4
+ window[webpackGlobal].push([
5
+ [Math.random()],
6
+ {},
7
+ (r) => {
8
+ initReq = r;
9
+ },
10
+ ]);
11
+ for (const i of Object.keys(initReq.m)) {
12
+ webpackCache[i] = initReq(i);
13
+ }
14
+
15
+ // Leave only the relevant modules
16
+ const allModules = Object.values(webpackCache).filter((e) => {
17
+ if (!e || typeof e !== "object" || e.__esModule) {
18
+ return false;
19
+ }
20
+
21
+ const keys = Object.keys(e);
22
+ const first = keys[0];
23
+ return (
24
+ first &&
25
+ first.length >= 2 &&
26
+ !(
27
+ keys.length === 1 &&
28
+ (first === "duration-app-launch" ||
29
+ first === "version" ||
30
+ first.match(/^str[A-Z]/))
31
+ ) &&
32
+ keys.every((k) => typeof e[k] === "string")
33
+ );
34
+ });
35
+
36
+ const findModule = (filter) => allModules.find(filter);
37
+ const findAllModules = (filter) => allModules.filter(filter);
38
+
39
+ function findFirstModule(filter, component) {
40
+ const modules = findAllModules(filter);
41
+ const printError = (msg) => {
42
+ console.error("[%s] %s", component, msg);
43
+ };
44
+
45
+ if (modules.length === 0) {
46
+ printError("found no modules");
47
+ }
48
+ if (modules.length > 1) {
49
+ printError("found more than 1 module, returning first found");
50
+ }
51
+
52
+ return modules[0];
53
+ }
54
+
55
+ /**
56
+ * Find a unique class name from multiple similiar class modules.
57
+ *
58
+ * @param key Class name.
59
+ * @param index Array index.
60
+ */
61
+ const findUniqueKey = (key, index = 0) =>
62
+ Object.keys(findAllModules((mod) => mod[key])[index]).find(
63
+ (mod) => findAllModules((mod2) => mod2[mod]).length === 1,
64
+ );
@@ -1,11 +1,11 @@
1
- // Note that every module is only available on the "family management" page.
2
- exportedModules = [
3
- ["authorizeddevices", (e) => e.AuthorizedDeviceGroup],
4
- ["cookies", (e) => e.CookieSection],
5
- ["familymanagement", (e) => e.FamilySettingsContainer],
6
- ["familymanagementtabs", (e) => e.GraphicalAssetsTabs],
7
- // TODO: shared with steam settings notif page
8
- ["notifications", (e) => e.NotificationSection],
9
- // TODO: gamepaddialog
10
- ["toggle", (e) => e.Field],
11
- ];
1
+ // Note that every module is only available on the "family management" page.
2
+ exportedModules = [
3
+ ["authorizeddevices", (e) => e.AuthorizedDeviceGroup],
4
+ ["cookies", (e) => e.CookieSection],
5
+ ["familymanagement", (e) => e.FamilySettingsContainer],
6
+ ["familymanagementtabs", (e) => e.GraphicalAssetsTabs],
7
+ // TODO: shared with steam settings notif page
8
+ ["notifications", (e) => e.NotificationSection],
9
+ // TODO: gamepaddialog
10
+ ["toggle", (e) => e.Field],
11
+ ];
package/cdp/db/apppage.js CHANGED
@@ -1,12 +1,12 @@
1
- exportedModules = [
2
- ["storeitemscarousel", (e) => e.StoreItemsCarousel],
3
- ["capsule", (e) => e.MainCapsuleImageContainer],
4
- ["capsulecontainer", (e) => e.ItemCount1],
5
- ["carousel", (e) => e.pipScrollerContainer],
6
- ["creatorhome", (e) => e.FollowBtnText],
7
- ["creatorhomecarousel", (e) => e.CreatorHomeWithItems],
8
- ["focusring", (e) => e.FocusRingRoot],
9
- ["gamehover", (e) => e.GameHoverCapsuleCtn],
10
- ["scrollsnapcarousel", (e) => e.ScrollSnapCarousel],
11
- ["sidebarcontrollerinfo", (e) => e.StoreSidebarContainer],
12
- ];
1
+ exportedModules = [
2
+ ["storeitemscarousel", (e) => e.StoreItemsCarousel],
3
+ ["capsule", (e) => e.MainCapsuleImageContainer],
4
+ ["capsulecontainer", (e) => e.SeeAllLink],
5
+ ["carousel", (e) => e.pipScrollerContainer],
6
+ ["creatorhome", (e) => e.FollowBtnText],
7
+ ["creatorhomecarousel", (e) => e.CreatorHomeWithItems],
8
+ ["focusring", (e) => e.FocusRingRoot],
9
+ ["gamehover", (e) => e.GameHoverCapsuleCtn],
10
+ ["scrollsnapcarousel", (e) => e.ScrollSnapCarousel],
11
+ ["sidebarcontrollerinfo", (e) => e.StoreSidebarContainer],
12
+ ];