mirror of
https://github.com/lhns/steam-frame-nix.git
synced 2026-10-06 10:00:24 +02:00
Runtime patches no longer use webpack module ids or minified export names, which change with every Steam UI build: - modules/lib/finders.js: finder library (getWebpackRequire, findModule/findExport by source text and shape, resolveAll with a per-page cache, findFiberUp/findFiberDown/findInReactTree), installed once per page as window.__sfuiFind. - modules/lib/signatures.json: the signatures, per patch, shared by the patches and the checker. lib/default.nix mkPatch wraps a patch `(find, sigs, opts) => ...` with the library, its signatures and options; exposed as steamFrame.uiPatches.lib. - Keyboard patch (VERSION 10): layouts module, current/enabled layout getters, arrow keys, VR keyboard status and VirtualKeyboardManager are found by signature; if one doesn't match it reports which and leaves Steam untouched. unpatch.js uses references the patch remembered. The helper logs inject results when they change. - launcher-menu launch/pinned-desktop use the library's fiber helpers; launch no longer depends on the bar popup's window name. - scripts/check-signatures.mjs (+ webpack-modules.mjs): extracts module factories from the installed bundles without a browser and checks every signature (found / ambiguous / missing, with module ids and export names). README: "Finders and signatures", "After a Steam update".
27 lines
1.1 KiB
Nix
27 lines
1.1 KiB
Nix
# Shared helpers of the runtime Steam UI patches.
|
|
# - finders.js: signature-based lookup of webpack modules/exports and React
|
|
# fibers (no module ids or minified names);
|
|
# - signatures.json: the signatures the patches use, per patch, also read by
|
|
# scripts/check-signatures.mjs (run it after a Steam update);
|
|
# - mkPatch: turns a patch written as a function expression
|
|
# `(find, sigs, opts) => …` into the single expression the injectors
|
|
# evaluate: (<patch>)(<finders.js>, <signatures>, <opts>).
|
|
{ pkgs }:
|
|
let
|
|
sigFile = builtins.fromJSON (builtins.readFile ./signatures.json);
|
|
in {
|
|
signatures = sigFile;
|
|
finders = ./finders.js;
|
|
|
|
# name: file name (and default signatures entry); src: the patch file;
|
|
# signatures: module signatures passed as `sigs` (default: the entry `name`
|
|
# of signatures.json, else none); opts: JSON-serialisable options.
|
|
mkPatch = { name, src, signatures ? sigFile.patches.${name}.modules or { }, opts ? { } }:
|
|
pkgs.writeText "${name}.js" ''
|
|
(${builtins.readFile src}
|
|
)(${builtins.readFile ./finders.js}
|
|
, ${builtins.toJSON signatures}
|
|
, ${builtins.toJSON opts})
|
|
'';
|
|
}
|