Search code examples
javascriptwindows-runtimeidl

Is there a machine-readable version of the WinRT API for JavaScript?


Is there a machine-readable version of the WinRT API?

I'm looking for something like a WebIDL, a classic IDL, or any other machine-readable format that would list all the classes, constants, methods, etc. for the WinRT that is accessible in JavaScript.

If it included one-liner descriptions for each of the above entries, and/or links to the relevant MSDN documentation page, that would be even better of course :-)

edit:

  • Windows.winmd contains descriptions, but not the rules when applying the IL for JavaScript, any official spec on that? for type conversions and naming?
  • What about the WinJS namespace? (it's not in Windows.winmd)


  • Solution

  • The windows.winmd file contains the API definitions for the winrt APIs - these are directly applicable to all three languages, and they are machine readable.

    As you mentioned in your comment, there are some slight differences based on how the language projection treats the types, but those transformations are strictly mechanical. For example, for Javascript, the projection changes are straightforward:

    1. Numeric types (int, float, double, etc) are projected as Number
    2. Strings are projected as String
    3. DateTime is projected as Date()
    4. Events are promoted as addEventListener("(event name)", eventHandler);
    5. If a method has multiple out parameters, the method returns an object whose property names match the names of the parameters to the method.

    There are undoubtedly other Javascript mappings that I've missed, but those are the most important ones. The other currently supported languages (C++, C#, low level C++) have similar mechanical transformations that are applied to the metadata.