Debugging multiple script files
djigneo
Posts: 283
Any idea when the capability to debug scripts that include
other scripts will be added? Man would that be helpful for tracking down issues!
Comments
As for the question, I have no idea, but if scripts are your own, I suggest you create a bundle with all the required scripts.
As my rig is Windoze based I use Visual Studio Community to code my Daz Scripts, inside VS I have intellisense, strong type checking and on successful build it automagically generates muy bundle file, ready to be run inside Daz Studio.
I would certainly like to get there. I think I could get VS to edit *.dsa files with a JavaScript editor. That would be close, for sure. I'm already using TFS Online to source control my scripts.
When you say "strong type checking", how does intellisense know about the DAZ Script / Qt / etc types?
Making sure I understand your process correctly, you have a build that resolves
import
commands by concatenating the files together? That would indeed be a slick workaround for the debug issue, although fixing something in a "library" script would imply you'd have to recompile all scripts which use it.Requirements
The workflow involves the following,
TypeScript? From the home page:
TypeScript is part of VS.
You don't need to use any include or import statements, you just create a bundle which get updated according to your changes.
As for the strong type checking, I did some reflect like script to create the class declarations out of Daz runtime objects, at first started doing it manually but managed to make some time to develop something more usefull. Right now I have close to 180 classes. But even if you don't have any previous classes intellisense guesses as you type.
The obvious advantage is you end up writing more solid code, No more lengthy scripts, you can separate scripts, reuse, etc.
TypeScript class declarations look like this:
An example application class:
Ends up compiled into:
Let me know if you need more info.
Thanks, that's pretty slick. I haven't used Typescript before, but it seems pretty handy. Do you have any links for self-study on the "bundle bundle" step you mentioned? I think that's the only part I'm "thick" on. The rest seems fairly clear with a little internet searching.
Any chance I could trick you into open sourcing / adding me to your project for the DAZScript -> TypeScript definition code? That seems incredibly useful and I'd rather not reinvent the wheel if I don't have to.
You need to download the Bundler & Minifier extension from here
The tutorial for creating a bundle is here
I'll post the Daz Script typescript definitions later. Maybe we can join efforts to incorporate even more classes.
You're a boss, thanks. I am certainly interested. I'm no stranger to programming, but have only been using DAZ Script (and really, JavaScript) for a short while. Definitely looking forward to getting to the level of automation & sanity checking you're at.
On the provided link you'll find the current TypeScript type definitions for Daz Scripting projects.
You need to create an empty solution, with an empty project, add the "typings" folder and drop the provided definitions there. After that, add one or many typescript files for your project, and later bundle them.
Download from here
As you are typing you'll notice intellisense in action.
Thanks, I'm-a playing with them. I'll need a little time to get familiar with TypeScript, but I think I've already found a few bugs in some of my pre-existing scripts, so that's awesome!
I think I see a few areas in the typings which could use adjusting, and some classes I'm using are missing. I'll have to play with this a bit more later, I figure I'll bring up suggested adjustments in a PM.
You're the man!
No problem, keep in mind that this a WIP, right now I'am in the class collecting stage, so, might be a lot missing. In the next stage I'll be polishing classes, incorporate comments from what is documented so intellisense can show it. The beaty of this is that if you don't have a class an you need it badly, declare it as type any and you can access it like in the old fashioned Daz Script.
In case you need to create an instance of a undeclared class just: