I must say FPC/Lazarus is turning into a mighty powerful language/tool, it is offering so much out of the box(or a small download away), I am still baffled at why ObjectPascal and Lazarus hasn't received more attention from mainstream developers. Maybe it's more popular in Europe, while here in the west it is more seen as a legacy language from the past. Anyways, back to pas2js!
I noticed that work is being done to potentially allow Lazarus forms to be brought to the web through a few different projects. Last night I had an idea which might work as method to bring LCL Widgets to the web with as little friction as possible. If I had better understanding on the LCL, and how pas2js actually transpiles, I might work on this myself.
The basic idea here is to use HTML5 Canvas technology to draw the LCL Widgets as we do in some other platforms using custom drawn. If we could get custom drawn to draw it's widgets onto an HTML5 Canvas, and set the appropriate events onto the HTML5 Canvas, it could easily act as as form. While this approach will not keep the general look-and-feel of a typical web form, using LCL Widgets on top of an HTML5 Canvas gives us access to a wider array of widgets which would otherwise not be possible in pure HTML forms. Since the main idea of pas2js is to create Web Applications using pascal, and every consumer browser supports HTML5 Canvas', and we don't really need to support say Lynx, I don't see why using an HTML5 Canvas for rendering the LCL Widgetset a problem.
I have two potential solutions on how it could be rendered. The most ideal way, and one which could be quicker is to have a Unit in pas2js which has procedures which work with LFM files directly. The sole duty of this Unit is to parse an LFM file and render it to a HTML5 Canvas, and then attach the events within the LFM to their transpiled JavaScript code. The other solution is much more aligned with how Lazarus currently compiles machine code, where the LFM is transpiled into JavaScript to render our HTML5 Canvas and connect the callback events.
In theory, this should allow some basic Lazarus programs which don't use IO or sockets, such as a text editor/view, a calculator, and other simple programs to be cross-compiled in pas2js with minimal code changes. It would be nice if in the future pas2js could work with server-side code, or even generate a server-side Pascal application automatically based on the code. There are also tools which allow regular socket connections through HTML5 WebSocket connections, but this wouldn't be ideal for say database programs, you would want some sort of server between the web application and the database for security reasons.
In the far future, I'd love to see GLES Lazarus programs be easily ported to WebGL, but one can only dream.