decky-frontend-lib icon indicating copy to clipboard operation
decky-frontend-lib copied to clipboard

Steam client reference

Open FlashyReese opened this issue 2 years ago • 13 comments

Using the SDH Discord server, GitHub, and personal findings, I have attempted to document as many functions as possible within the SteamClient object. Feedback is greatly appreciated. If you come across any functions that are not documented and you already understand their purpose, please consider leaving a comment or suggestion.

To do list will be done on a separate PR. ~~To-Do List:~~ ~~- [ ] Verify the functionality of all documented functions.~~ ~~- [ ] Organize and restructure all the interfaces for better readability.~~

FlashyReese avatar Aug 27 '23 11:08 FlashyReese

After reading the latest commit message, how are you detecting the interface changes so quickly?

AAGaming00 avatar Sep 22 '23 16:09 AAGaming00

After reading the latest commit message, how are you detecting the interface changes so quickly?

Using the CEF debugger console, I've written this function to quickly extract every method for any object.

function mapFunctions(obj) {
  const methods = {};

  function extractMethods(obj, path = []) {
    for (const key in obj) {
      if (typeof obj[key] === 'function') {
        if (!methods[path.join('.')]) {
          methods[path.join('.')] = [];
        }
        methods[path.join('.')].push(key);
      } else if (typeof obj[key] === 'object' && obj[key] !== null) {
        extractMethods(obj[key], [...path, key]);
      }
    }
  }

  extractMethods(obj);

  return methods;
}

Then I simply apply this to the SteamClient object, deserialize it as JSON, and compare it to a previous version using git's diff tool.

FlashyReese avatar Sep 22 '23 17:09 FlashyReese

That's awesome, I'll add this to my update diff system if you don't mind

AAGaming00 avatar Sep 22 '23 18:09 AAGaming00

That's awesome, I'll add this to my update diff system if you don't mind

That would be awesome!

I think we can write a tool to generate the aforementioned TypeScript interfaces from it. This could prove useful, as it can be utilized anywhere. Unfortunately, native code does not provide parameters for these functions. This means documenting parameters must be done manually, unless someone is aware of a method I am not familiar with.

Edit: I decided to spend some time and write one: https://gist.github.com/FlashyReese/05748e25b9feabe14e62ef873a8058cb

FlashyReese avatar Sep 22 '23 18:09 FlashyReese

Edit: I decided to spend some time and write one: https://gist.github.com/FlashyReese/05748e25b9feabe14e62ef873a8058cb

Noticed you weren't able to get the name of the object from the object. If it's a global object then this should work Object.getOwnPropertyNames(window).filter(name => window[name] === obj)[0]. Probably not actually useful though.

PartyWumpus avatar Nov 18 '23 13:11 PartyWumpus

is this ready for review yet? (at least to have it merged until we can have this as a separate package)

AAGaming00 avatar Jun 27 '24 03:06 AAGaming00

Also please retarget to v4-dev

AAGaming00 avatar Jun 27 '24 03:06 AAGaming00

I've rebased to the v4-dev branch. This should be ready for review.

FlashyReese avatar Jun 29 '24 14:06 FlashyReese