zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
1.01k stars 126 forks source link

[FEAT] ImportLibrary() and Proper Typescript Support #15

Open zalo opened 3 years ago

zalo commented 3 years ago

This PR properly transpiles the editor code from typescript back to javascript, allowing for inline type specification and increased usability/robustness.

This PR also adds support for importing libraries from external URLs with IntelliSense, so users can use alternative "Standard Libraries" that meet their needs without having to fork the editor entirely.

Here is an example of a library being imported with IntelliSense.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/zalo/cascade-studio/6SMWdmNkaJTwSrqsWYEf86KaU2gZ
✅ Preview: https://cascade-studio-git-feat-typescript-zalo.vercel.app

brad-jones commented 3 years ago

Instead of ImportLibrary(['../Libraries/InvoluteGear.ts']); it would be way better IMO if we could use standard ES6 imports.

eg: import { foo, bar } from "../Libraries/InvoluteGear"

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

zalo commented 3 years ago

@Irev-Dev I'm primarily worried the Typescript PR just makes everything slower; the way I have it architected now has all of the library imports strung out as a series of dependent requests. To get it merged, I'll probably want to add some kind of prefetching, caching, and loading mechanism...

(Also some rough edges around clicking to the source in the intellisense documentation and caching preventing changes from propagating...)