immersive-web / webxr

Repository for the WebXR Device API Specification.
https://immersive-web.github.io/webxr/
Other
2.95k stars 374 forks source link

Typescript definitions #953

Open NellWaliczek opened 4 years ago

NellWaliczek commented 4 years ago

When I've been feeling up for it, I've puttering with using threejs in a typescript project of mine and noticed that the WebXR types haven't been added to the built in typescript definitions. I'm not super familiar with how this is done, but it looks like it might be with this tool?

https://github.com/microsoft/TSJS-lib-generator

Perhaps someone wants to do that?

klausw commented 4 years ago

In case it's helpful, model-viewer uses Typescript, and I had updated its copy of types/webxr.ts as part of updating its WebXR support. That was fully manual, and only covered the parts of the API used by this application, so if there's a more automated way to generate the type mappings that would be strongly preferable. Is there a way to get this from IDL files directly?

RaananW commented 4 years ago

We at Babylon.js maintain a webxr.d.ts as well - https://github.com/BabylonJS/Babylon.js/blob/master/src/LibDeclarations/webxr.d.ts. I don't think there is a way to automate that process using a js or ts libs, as this is a native browser API and nothing we compile ourselves. Having said that, if the webxr polyfill is updated to the current specs, it is possible to generate declaration file(s) for the polyfill and use it as webxr.d.ts.

I will be happy to maintain the .d.ts file for webxr according to current specs

ManuelGraf commented 4 years ago

add them at @types package https://www.npmjs.com/package/@types/npm but ideally, those should be part of immersive web package...

fordacious commented 3 years ago

I happen to have a reasonably up to date one I whipped up for the webxr implementation on noclip.website. I'll look into adding it to the registry. Not sure how out of date it is.

RaananW commented 3 years ago

We (babylonjs) will be distributing 4.2 with the following declaration file:

https://github.com/BabylonJS/Babylon.js/blob/master/src/LibDeclarations/webxr.d.ts

Does someone want to review it, or will it be helpful if I submit it somewhere (like @types/webxr)?

Manishearth commented 3 years ago

@RaananW If you can create a repo for the package (to be published as @types/webxr) and transfer it to immersive-web that would be great! We can move forward from there.

I can do a more in depth review later, it looks mostly fine for now.

RaananW commented 3 years ago

@Manishearth - I am preparing the repository right now. It seems however, that the fastest (and safest) way to get the typings to @types is to submit it to [DefinitelyTyped] (https://github.com/DefinitelyTyped/DefinitelyTyped) (As explained here). I will submit a PR there once I am done with a bit of cleanup and documentation.

Manishearth commented 3 years ago

That works, thanks!

Manishearth commented 3 years ago

@RaananW please CC me when you make a PR, I would like to review some of the stuff there

RaananW commented 3 years ago

@Manishearth - of course. PR is coming Monday after i finished working on doc comments and a few cleanups.

msub2 commented 2 years ago

Is there anything to still be done here? It looks like the types were added a while ago and are pretty much up to date. https://www.npmjs.com/package/@types/webxr https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webxr

RaananW commented 2 years ago

The specs are constantly changing, there are a few things added and modified since the last update