-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript mode doesn't work with more than one .pde file #26
Comments
No, JS mode does of course support multiple tabs. Their content will be concatenated into one .js file as part of the pre-processing (same as normal Processing does). You seem to experience some other problem which is hard to debug here because you give hardly any information beyond ranting. Please email me your sketch and i will have a look at what is not working. |
You're right. I was experiencing another problem. I didn't realise the files were being merged. However, instead of merging the files into one monolitic file, it would be much better to keep the files as they are and include all them in the data-processing-sources parameter. That way, the source code would remain as is. Of course this implies also creating one link per file to the source code in the html. Should I file a separate issue or edit the title of this one? |
There is no need to file an issue: merging the files into one was done to speed up start-up time for sketches because one file loads faster than many. |
What about a configurable option? |
In this case, both JS & CS Modes are doing exactly what Java Mode would do: |
@GoToLoop that's almost a good point, but there's a catch.
With the difference that in Java mode that's invisible: the ultimate result of exporting the sketch is a jar, anyway.
then they wouldn't be portable any more. You don't do that just because you want separate files. You do that when you want:
That's a completely different use case. |
|
There's a way for the PJS to work w/ separate files w/o concatenating them: |
Yeah, so what? Is your point that I was wrong because I said "invisible"? C'mon, I meant it's an internal intermediate compilation step, that has no relevance to the user. Note that the .java file is not just the concatenation of the pde files, it's also preprocessed into java code. That's comparable to the js function (except that the latter doesn't need to be stored into the file). The source is the source, and when publishing the source it would be nice to publish it unmodified. PJS is able to run the sketch from the separate .pde files and doesn't need to have them merged, so the most elegant way to publish the sketch with its source is to publish the source files as they were written. It's the most elegant way, but not the fastest to run, so it makes sense to have both options. Note, btw, that when you export a sketch as a java application, it creates a "source" folder where the source .pde files are copied unaltered. |
|
P.S.: Both JS & CS modes transpiles all ".pde" tabs as a unified ".js" file, rather than have that ".pde" to ".js" transpilation happening at ".html" runtime! |
I guess it's gonna need some modifications in the generated "index.html" template in order to list each ".pde" file I guess: <p id="sources">Source code: <a href="Ball_in_the_Chamber.pde">Ball_in_the_Chamber</a> </p> |
There's no .js file at all, neither one nor many. The only actual .js file is processing.js, which is "unmutable", it's just processing.js as you would download it from Processingjs.org. I have no idea about CS, but in PJS there's no such things as generated .js files. The html runs has a <script src="processing.js">. When processing.js runs, it loads the .pde file, or fileS, indicated in the canvas's data-processing-sources attribute, and translates them into js code which is not stored in any file (that would be almost impossible, as this all happens in the browser) and is run on the fly.
Yes, obviously. That's what I'm asking for. |
Oh you're right. I guess I've only studied the CS mode's generated "web-export". <canvas id="BallintheChamber" data-processing-sources="Ball_in_the_Chamber.pde" width="640" height="440"> But since it is so, I've got my doubts whether the PJS framework would be capable of running multiple ".pde" files as 1 sketch. |
In order to see the ".js" output outta the ".pde" source, paste some here: P.S.: CS Mode also relies on PJS framework. Generated ".js" is almost the same! |
Man, I'm telling you it does. I've tried it. You just put this in the html:
and the result is exactly the same as if all the code was in one file (I haven't looked at the source code, but I think it just loads all files, concatenates them into a string, and processes it). |
Oh that's fantastic! Only thing left is modifying how JS mode deals w/ its "index.html" template to accommodate multiple ".pde" files both in the data-processing-sources attribute and |
Exactly |
Locking this issue. Please do not go off topic like this and do not just rename the issues. I openend another issue #29 for this. |
It seems you didn't take into account that Processing supports sketches made of more than one .pde file, e.g. with one main sketch file plus one file per class definition. You can add files from the IDE.
In Java mode they are compiled together.
processing.js also supports that by simply inserting the list of files in the data-processing-sources attribute of the canvas node.
However, JavaScript mode ignores that, only copies the one main .pde file into the web-export folder, and only includes that one in the data-processing-sources attribute.
This renders JavaScript mode useless for sketches including more than one file.
Additionally, since the web-export folder is wiped out every time the sketch is exported, there doesn't even seem to be an easy workaround.
JavaScript mode should copy all .pde files, not only the one with the same name as the folder, into web-export, and include all of them in the data-processing-sources attribute (I don't remember if they need to be separated by commas or spaces or what)
The text was updated successfully, but these errors were encountered: