Discussion:
[fpc-pascal] First pas2js public release
Michael Van Canneyt
2017-12-16 16:36:14 UTC
Permalink
Hello fellow Pascal enthousiasts,

It is with great pleasure that I can finally announce the first publicly
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow) development.

pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser, and
in Node.js.

It is open source, and part of FPC/Lazarus.
This makes Free Pascal a full-stack development environment for Web Development:
You can use it to program the server and the browser alike, all from within
the environment you love so much :)

What does pas2js include ?
--------------------------

* On the language level:

It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.

This is just the first version, we of course want to add the same language
features that exist in Delphi and FPC today.

* On the runtime level:

Beside the compiler itself, there is a basic Object Pascal RTL,
and several units from the FPC Packages are also available:

system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp

* Debugging:

Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.

* Demoes ?

The package has several demoes, including FPReport, TDataset, JQuery and
Bootstrap.

* Documentation ?

As befits an open source project, docs are lagging behind :/

But a WIKI page has been started, it will be expanded as time permits:

http://wiki.freepascal.org/pas2js

* Sources ?

The pas2js compiler sources and RTL sources have been checked in in FPC's
subversion repository. The page describes where to find it in SVN.

* Binaries ?

A snapshot is available:
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip

* Reporting bugs ?

The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.

* Can you help ?

Yes, of course. There is still a lot of work to be done.
Feel free to contact me or Mattias Gaertner with questions.

What about Lazarus ?
--------------------

Lazarus "understands" the extensions to object pascal (for importing Javascript
classes) that were borrowed from the JVM version of the compiler, so the
code completion will continue to work.

Using the pre-compiler command, CTRL-F9 just works. On error, you will be
shown the error location etc.

Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration.
Later on, a real widget set for the browser can (and hopefully will) be created.

But that is not all !
---------------------

In the very near future, a major Delphi component vendor will announce a
complete package for RAD web development in the Delphi IDE.
The expectation is that later on, the exact same components will be usable
in Lazarus. In essence, the component developer has created a complete browser
widgetset. More than 100 controls are available.

Using this, you can design a web application as you design a desktop app;
Fully RAD, as you are used to. But even more, you can bind controls on a
form to existing tags in a web page, thus preserving the style in the web page.

The first demoes for a selected audience have evoked very positive feedback
indeed.

All this is based on pas2js.

As soon as I receive permission, I will announce here where it becomes
available.

Lastly!
-------

On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
finishing what has been started a long time ago.

Without him, none of this would have been possible.

The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more years to
finish this.

It is - for me - a long standing dream finally come true.

Enjoy !

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.f
code dz
2017-12-17 07:00:57 UTC
Permalink
good news & thanks for the effort

is it similar to Emscripten ?
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pa
Sven Barth via fpc-pascal
2017-12-17 08:23:01 UTC
Permalink
Am 17.12.2017 08:01 schrieb "code dz" <***@gmail.com>:

good news & thanks for the effort

is it similar to Emscripten ?


Not really. Emscripten (and WebAsm) has the goal to convert native programs
that rely on pointers. It is essentially an assembly language in
JavaScript. Pas2JS is on the other hand a transpiler and does not - as
Michael explained - support native features like pointers. Also if you look
at the generated code you can still understand it without much effort.

Regards,
Sven
Michael Van Canneyt
2017-12-17 08:29:28 UTC
Permalink
Post by code dz
good news & thanks for the effort
is it similar to Emscripten ?
Not really. Emscripten (and WebAsm) has the goal to convert native programs
that rely on pointers. It is essentially an assembly language in
JavaScript. Pas2JS is on the other hand a transpiler and does not - as
Michael explained - support native features like pointers. Also if you look
at the generated code you can still understand it without much effort.
Completely correct.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailma
Snorkl e
2017-12-17 15:54:32 UTC
Permalink
Wow, nice job 😀
Post by Michael Van Canneyt
Post by code dz
good news & thanks for the effort
is it similar to Emscripten ?
Not really. Emscripten (and WebAsm) has the goal to convert native programs
that rely on pointers. It is essentially an assembly language in
JavaScript. Pas2JS is on the other hand a transpiler and does not - as
Michael explained - support native features like pointers. Also if you look
at the generated code you can still understand it without much effort.
Completely correct.
Michael.
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
2017-12-17 17:22:32 UTC
Permalink
Well done to everybody involve. This is truly impressive news!
Post by Michael Van Canneyt
Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.
Now that is impressive and very welcome news.


Good job to all.


Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key: http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.fre
Ingemar Ragnemalm
2017-12-20 11:29:25 UTC
Permalink
This is great news, something that I have been longing for for years!
There have been some related efforts but none that really solved my
problem. Best Christmas present this year!

After some initial fiddling, I realized that there was a misspelling in
the wiki, and Hello World worked once I use -Jirtl.js rather than
-jirtl.js. And then I got some of the provided demos running too and
managed to write one of my own. So it looks good!

Here is an early result, expressing my feelings for this release:

http://ragnemalm.se/images/santa/santa.html

I couldn't get sound working, but otherwise it seems to work as it
should! (I hope it does for the rest of you.)

/Ingemar
Subject: [fpc-pascal] First pas2js public release
Content-Type: text/plain; format=flowed; charset=US-ASCII
Hello fellow Pascal enthousiasts,
It is with great pleasure that I can finally announce the first publicly
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow) development.
pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser, and
in Node.js.
It is open source, and part of FPC/Lazarus.
You can use it to program the server and the browser alike, all from within
the environment you love so much:)
What does pas2js include ?
--------------------------
It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.
This is just the first version, we of course want to add the same language
features that exist in Delphi and FPC today.
Beside the compiler itself, there is a basic Object Pascal RTL,
system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp
Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.
* Demoes ?
The package has several demoes, including FPReport, TDataset, JQuery and
Bootstrap.
* Documentation ?
As befits an open source project, docs are lagging behind :/
http://wiki.freepascal.org/pas2js
* Sources ?
The pas2js compiler sources and RTL sources have been checked in in FPC's
subversion repository. The page describes where to find it in SVN.
* Binaries ?
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip
* Reporting bugs ?
The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.
* Can you help ?
Yes, of course. There is still a lot of work to be done.
Feel free to contact me or Mattias Gaertner with questions.
What about Lazarus ?
--------------------
Lazarus "understands" the extensions to object pascal (for importing Javascript
classes) that were borrowed from the JVM version of the compiler, so the
code completion will continue to work.
Using the pre-compiler command, CTRL-F9 just works. On error, you will be
shown the error location etc.
Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration.
Later on, a real widget set for the browser can (and hopefully will) be created.
But that is not all !
---------------------
In the very near future, a major Delphi component vendor will announce a
complete package for RAD web development in the Delphi IDE.
The expectation is that later on, the exact same components will be usable
in Lazarus. In essence, the component developer has created a complete browser
widgetset. More than 100 controls are available.
Using this, you can design a web application as you design a desktop app;
Fully RAD, as you are used to. But even more, you can bind controls on a
form to existing tags in a web page, thus preserving the style in the web page.
The first demoes for a selected audience have evoked very positive feedback
indeed.
All this is based on pas2js.
As soon as I receive permission, I will announce here where it becomes
available.
Lastly!
-------
On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
finishing what has been started a long time ago.
Without him, none of this would have been possible.
The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more years to
finish this.
It is - for me - a long standing dream finally come true.
Enjoy !
Michael.
Mattias Gaertner
2017-12-20 11:59:49 UTC
Permalink
On Wed, 20 Dec 2017 12:29:25 +0100
Post by Ingemar Ragnemalm
[...]
After some initial fiddling, I realized that there was a misspelling in
the wiki, and Hello World worked once I use -Jirtl.js rather than
-jirtl.js.
Fixed.
Post by Ingemar Ragnemalm
And then I got some of the provided demos running too and
managed to write one of my own. So it looks good!
http://ragnemalm.se/images/santa/santa.html
I couldn't get sound working, but otherwise it seems to work as it
should! (I hope it does for the rest of you.)
Beautiful.
Can I add the URL as an example?


Mattias
Post by Ingemar Ragnemalm
/Ingemar
Subject: [fpc-pascal] First pas2js public release
Content-Type: text/plain; format=flowed; charset=US-ASCII
Hello fellow Pascal enthousiasts,
It is with great pleasure that I can finally announce the first publicly
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow) development.
pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser, and
in Node.js.
It is open source, and part of FPC/Lazarus.
You can use it to program the server and the browser alike, all from within
the environment you love so much:)
What does pas2js include ?
--------------------------
It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.
This is just the first version, we of course want to add the same language
features that exist in Delphi and FPC today.
Beside the compiler itself, there is a basic Object Pascal RTL,
system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp
Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means that
if the browser finds the source file, it will display the original source
file instead of the javascript. You can debug Object pascal in the browser.
* Demoes ?
The package has several demoes, including FPReport, TDataset, JQuery and
Bootstrap.
* Documentation ?
As befits an open source project, docs are lagging behind :/
http://wiki.freepascal.org/pas2js
* Sources ?
The pas2js compiler sources and RTL sources have been checked in in FPC's
subversion repository. The page describes where to find it in SVN.
* Binaries ?
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip
* Reporting bugs ?
The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.
* Can you help ?
Yes, of course. There is still a lot of work to be done.
Feel free to contact me or Mattias Gaertner with questions.
What about Lazarus ?
--------------------
Lazarus "understands" the extensions to object pascal (for importing Javascript
classes) that were borrowed from the JVM version of the compiler, so the
code completion will continue to work.
Using the pre-compiler command, CTRL-F9 just works. On error, you will be
shown the error location etc.
Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration.
Later on, a real widget set for the browser can (and hopefully will) be created.
But that is not all !
---------------------
In the very near future, a major Delphi component vendor will announce a
complete package for RAD web development in the Delphi IDE.
The expectation is that later on, the exact same components will be usable
in Lazarus. In essence, the component developer has created a complete browser
widgetset. More than 100 controls are available.
Using this, you can design a web application as you design a desktop app;
Fully RAD, as you are used to. But even more, you can bind controls on a
form to existing tags in a web page, thus preserving the style in the web page.
The first demoes for a selected audience have evoked very positive feedback
indeed.
All this is based on pas2js.
As soon as I receive permission, I will announce here where it becomes
available.
Lastly!
-------
On a more personal note, I wish to explicitly thank Mattias Gaertner for finally
finishing what has been started a long time ago.
Without him, none of this would have been possible.
The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more years to
finish this.
It is - for me - a long standing dream finally come true.
Enjoy !
Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.fre
Dave Connolly
2017-12-20 12:09:46 UTC
Permalink
This is fantastic. Great work everyone.
Post by Mattias Gaertner
On Wed, 20 Dec 2017 12:29:25 +0100
Post by Ingemar Ragnemalm
[...]
After some initial fiddling, I realized that there was a misspelling in
the wiki, and Hello World worked once I use -Jirtl.js rather than
-jirtl.js.
Fixed.
Post by Ingemar Ragnemalm
And then I got some of the provided demos running too and
managed to write one of my own. So it looks good!
http://ragnemalm.se/images/santa/santa.html
I couldn't get sound working, but otherwise it seems to work as it
should! (I hope it does for the rest of you.)
Beautiful.
Can I add the URL as an example?
Mattias
Post by Ingemar Ragnemalm
/Ingemar
Subject: [fpc-pascal] First pas2js public release
Content-Type: text/plain; format=flowed; charset=US-ASCII
Hello fellow Pascal enthousiasts,
It is with great pleasure that I can finally announce the first
publicly
Post by Ingemar Ragnemalm
available version of pas2js. A "beta" version, version 0.8.39.
The endpoint (for the time being) of nearly 10 years of (slow)
development.
Post by Ingemar Ragnemalm
pas2js is a Object Pascal to Javascript transpiler. It compiles Object
pascal, and emits Javascript. The javascript is usable in the browser,
and
Post by Ingemar Ragnemalm
in Node.js.
It is open source, and part of FPC/Lazarus.
This makes Free Pascal a full-stack development environment for Web
You can use it to program the server and the browser alike, all from
within
Post by Ingemar Ragnemalm
the environment you love so much:)
What does pas2js include ?
--------------------------
It supports basically Delphi 7 syntax, interfaces excepted.
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.
This is just the first version, we of course want to add the same
language
Post by Ingemar Ragnemalm
features that exist in Delphi and FPC today.
Beside the compiler itself, there is a basic Object Pascal RTL,
system
sysutils
Math
strutils
rtlconst
classes
contnrs
DB (yes, TDataset)
fpcunit testsuite
custapp
restconnection
js (javascript system objects)
web (browser provided objects)
libjquery (jquery is available too)
nodejs (basic node runtime environment)
typeinfo
objpas
browserconsole (support for writeln)
dateutils
browserapp
nodejsapp
Obviously, the browser debugger can be used to debug the Javascript.
But there is more: the compiler can emit a source map, and this means
that
Post by Ingemar Ragnemalm
if the browser finds the source file, it will display the original
source
Post by Ingemar Ragnemalm
file instead of the javascript. You can debug Object pascal in the
browser.
Post by Ingemar Ragnemalm
* Demoes ?
The package has several demoes, including FPReport, TDataset, JQuery
and
Post by Ingemar Ragnemalm
Bootstrap.
* Documentation ?
As befits an open source project, docs are lagging behind :/
http://wiki.freepascal.org/pas2js
* Sources ?
The pas2js compiler sources and RTL sources have been checked in in
FPC's
Post by Ingemar Ragnemalm
subversion repository. The page describes where to find it in SVN.
* Binaries ?
http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip
* Reporting bugs ?
The FPC bugtracker has now a 'pas2js' project, it can be used to report
bugs.
* Can you help ?
Yes, of course. There is still a lot of work to be done.
Feel free to contact me or Mattias Gaertner with questions.
What about Lazarus ?
--------------------
Lazarus "understands" the extensions to object pascal (for importing
Javascript
Post by Ingemar Ragnemalm
classes) that were borrowed from the JVM version of the compiler, so
the
Post by Ingemar Ragnemalm
code completion will continue to work.
Using the pre-compiler command, CTRL-F9 just works. On error, you will
be
Post by Ingemar Ragnemalm
shown the error location etc.
Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration.
Later on, a real widget set for the browser can (and hopefully will)
be created.
Post by Ingemar Ragnemalm
But that is not all !
---------------------
In the very near future, a major Delphi component vendor will announce
a
Post by Ingemar Ragnemalm
complete package for RAD web development in the Delphi IDE.
The expectation is that later on, the exact same components will be
usable
Post by Ingemar Ragnemalm
in Lazarus. In essence, the component developer has created a complete
browser
Post by Ingemar Ragnemalm
widgetset. More than 100 controls are available.
Using this, you can design a web application as you design a desktop
app;
Post by Ingemar Ragnemalm
Fully RAD, as you are used to. But even more, you can bind controls on
a
Post by Ingemar Ragnemalm
form to existing tags in a web page, thus preserving the style in the
web page.
Post by Ingemar Ragnemalm
The first demoes for a selected audience have evoked very positive
feedback
Post by Ingemar Ragnemalm
indeed.
All this is based on pas2js.
As soon as I receive permission, I will announce here where it becomes
available.
Lastly!
-------
On a more personal note, I wish to explicitly thank Mattias Gaertner
for finally
Post by Ingemar Ragnemalm
finishing what has been started a long time ago.
Without him, none of this would have been possible.
The same is true for Detlef Overbeek, editor of Blaise Pascal magazine,
without his moral and financial help, it would have taken many more
years to
Post by Ingemar Ragnemalm
finish this.
It is - for me - a long standing dream finally come true.
Enjoy !
Michael.
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
2017-12-20 13:13:30 UTC
Permalink
Post by Ingemar Ragnemalm
http://ragnemalm.se/images/santa/santa.html
I couldn't get sound working, but otherwise it seems to work as it
should! (I hope it does for the rest of you.)
Awesome - I still have to get my head around this whose Pas2JS
functionality. It seems very impressive thus far. :)

ps:
I tested your Santa demo under 64-bit FreeBSD with Firefox. Worked
perfectly.

Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key: http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listi
Ingemar Ragnemalm
2017-12-20 14:14:50 UTC
Permalink
Post by Mattias Gaertner
On Wed, 20 Dec 2017 12:29:25 +0100
Post by Ingemar Ragnemalm
And then I got some of the provided demos running too and
managed to write one of my own. So it looks good!
http://ragnemalm.se/images/santa/santa.html
I couldn't get sound working, but otherwise it seems to work as it
should! (I hope it does for the rest of you.)
Beautiful.
Can I add the URL as an example?
Absolutely, and I don't mind sharing the code. It is in the same folder!
Very small and simple program, and all FPC. :)

Although I would like to make some improvements - who doesn't? To be
precise, I want to figure out a way to play sounds, and I want image
loading directly in the code and not dependent on the HTML. Any ideas
about that?

It feels really nice to have my first Pascal web application running!
Well, I could do it in Java before but that isn't as universal as
JavaScript.

/Ingemar
Reimar Grabowski
2017-12-20 16:30:54 UTC
Permalink
On Wed, 20 Dec 2017 15:14:50 +0100
Post by Ingemar Ragnemalm
Although I would like to make some improvements - who doesn't? To be
precise, I want to figure out a way to play sounds, and I want image
loading directly in the code and not dependent on the HTML. Any ideas
about that?
First of all I know nothing about pas2js, but...
As your code is running solely in the browser there is no option to load it from file for security reasons.
But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
Once you have the data put it into a blob, create an url and finally use that as you image url.
So you need pascal code that will produce this JS code:

var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
var url = URL.createObjectURL(blob);
var image = new Image();
image.src = url;

But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.

While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
Post by Ingemar Ragnemalm
It feels really nice to have my first Pascal web application running!
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
Post by Ingemar Ragnemalm
Well, I could do it in Java before but that isn't as universal as
JavaScript.
For this concrete project you could have done it with pure JS which would be about 950 lines less of JS code. ;)

Nonetheless, nice work.

R.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailm
Michael Schnell
2017-12-21 14:49:01 UTC
Permalink
Post by Reimar Grabowski
Not dissing you or your work or pas2js but I fail to see the web
application part. There is no communication between client and server.
Actually there is no server side code at all and there is no
interactivity.
Rather obviously this would not be a compiler issue ("fpc development"),
but would needed to be provided by the library (e.g. Lazarus or mse) .

There are some post about this in the fpc-devel mailing list (where they
don't belong either, of course).

-Michael

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/list
Reimar Grabowski
2017-12-22 14:14:51 UTC
Permalink
On Thu, 21 Dec 2017 15:49:01 +0100
Post by Michael Schnell
Rather obviously this
<snip>
Post by Michael Schnell
would needed to be provided by the library (e.g. Lazarus or mse).
LOL, no.

R.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/l
Michael Van Canneyt
2017-12-22 07:53:03 UTC
Permalink
Post by Reimar Grabowski
On Wed, 20 Dec 2017 15:14:50 +0100
Post by Ingemar Ragnemalm
Although I would like to make some improvements - who doesn't? To be
precise, I want to figure out a way to play sounds, and I want image
loading directly in the code and not dependent on the HTML. Any ideas
about that?
First of all I know nothing about pas2js, but...
As your code is running solely in the browser there is no option to load it from file for security reasons.
But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
Once you have the data put it into a blob, create an url and finally use that as you image url.
var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
var url = URL.createObjectURL(blob);
var image = new Image();
image.src = url;
But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.
While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
Post by Ingemar Ragnemalm
It feels really nice to have my first Pascal web application running!
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
That is one of the points of pas2js. To allow you to program the browser.

There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.

See the browser as a desktop. Your program runs in that desktop.
If need be, this program can contact a server - the classical
client/server model, using HTTP as the protocol - but this is by no means a necessity.

In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinf
Reimar Grabowski
2017-12-22 14:12:18 UTC
Permalink
On Fri, 22 Dec 2017 08:53:03 +0100 (CET)
That is one of the points of pas2js. To allow you to program the browser [in pascal].
Fixed that for you.
And yes, that's what most transpilers to javascript are meant for.
There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.
Really, that's amazing?
See the browser as a desktop. Your program runs in that desktop.
If need be, this program can contact a server - the classical
client/server model, using HTTP as the protocol - but this is by no means a necessity.
If you say so.
In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...
<!DOCTYPE html>
<html>
<head>
<title>Mighty web app</title>
</head>
<body>
</body>
<script>
alert("I am such a mighty web application");
</script>
</html>

Ok, if this is nowadays a 'web application' I seriously get old.
But whatever, every HTML page with a script is a web app now. Lesson learned.

R.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freep
Ryan Joseph
2017-12-21 11:53:23 UTC
Permalink
Absolutely, and I don't mind sharing the code. It is in the same folder! Very small and simple program, and all FPC. :)
Can you post the code? I haven’t actually seen any examples so I have no idea how it works.

Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org
el es
2017-12-21 12:59:20 UTC
Permalink
Post by Ryan Joseph
Absolutely, and I don't mind sharing the code. It is in the same folder! Very small and simple program, and all FPC. :)
Can you post the code? I haven’t actually seen any examples so I have no idea how it works.
Regards,
Ryan Joseph
Code seems to be in http://ragnemalm.se/images/santa/
(there is no 'index' page so it shows files)

-L.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/
Ingemar Ragnemalm
2017-12-24 09:20:07 UTC
Permalink
Post by Michael Van Canneyt
Post by Reimar Grabowski
On Wed, 20 Dec 2017 15:14:50 +0100
Post by Ingemar Ragnemalm
Although I would like to make some improvements - who doesn't? To be
precise, I want to figure out a way to play sounds, and I want image
loading directly in the code and not dependent on the HTML. Any ideas
about that?
First of all I know nothing about pas2js, but...
As your code is running solely in the browser there is no option to load it from file for security reasons.
But you can embed the binary image data in the code (as Uint8Array) or you can use XHR (pas2js will surely support this somehow) to fetch the image data via HTTP.
Once you have the data put it into a blob, create an url and finally use that as you image url.
var blob = new Blob([data], { type: "image/png" }); // where data is your Uint8Array
var url = URL.createObjectURL(blob);
var image = new Image();
image.src = url;
Yes, something like that. I have found JS examples that does this but
can't see how to make pas2js do it.
Post by Michael Van Canneyt
Post by Reimar Grabowski
But I don't see anything wrong with putting them in the HTML. For more flexibility you could create the HTML via a template engine or something but I would only load them from JS if there is a good reason to do so.
One reason is to collect information in one place. Making HTML load it
gives me two steps to the file instead of one. More chances to do it wrong.
Post by Michael Van Canneyt
Post by Reimar Grabowski
While you are updating your code you can remove the two dependencies on bootstrap (as they are not satisfied anyway and I think the whole fpReport dir is superflous) and perhaps do something about the flickering of the text (although this may be a little bit too much asked).
Ah. They just remained from an example I worked from.

Text flicker is most likely caused by not double buffering. I need to
generate an image off-screen. Nothing strange with that, just one more
thing to figure out in the JS environment.
Post by Michael Van Canneyt
Post by Reimar Grabowski
Post by Ingemar Ragnemalm
It feels really nice to have my first Pascal web application running!
Not dissing you or your work or pas2js but I fail to see the web application part. There is no communication between client and server. Actually there is no server side code at all and there is no interactivity. In my book this is a static page, but perhaps I miss something.
There is no interactivity, and no client-server communication, but this is my *first*, my "proof of concept" for the platform, like Hello World but with some more features (animation, random numbers, graphics elements). Doing *something* with it myself, showing myself the potential, making a kind of "thanks" for it and a Christmas greeting atthe same time. Interactivity is the next step, and the ability to save data somewhere.
Post by Michael Van Canneyt
That is one of the points of pas2js. To allow you to program the browser.
There is no need for a server. You can make e.g. a chess application that runs
100% in the browser, using a single HTML file. You can embed the JS and
images in the HTML itself, and thus your HTML file is the 'executable'.
See the browser as a desktop. Your program runs in that desktop.
If need be, this program can contact a server - the classical
client/server model, using HTTP as the protocol - but this is by no means a necessity.
In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...
Exactly. I get a cross-platform solution with no installations, in a way
that users are increasingly used to. And I can write it in FPC, which I
am a lot more happy with than a rubbish language like JavaScript! For me
it opens a lot of possibilities!

But let me get back to my current problems. I can accept loading images
through HTML for now, but how can I load and play sounds? There is an
"Audio" API in JavaScript but it seems that pas2js doesn't support it,
it can't find play(). I have searched web.pas and a few others for it.
Where do I start to fix that?

/Ingemar
Michael Van Canneyt
2017-12-24 09:36:05 UTC
Permalink
Post by Michael Van Canneyt
In that sense, the demo demonstrates this. The server is just there for you
to be able to download the "program"...
Exactly. I get a cross-platform solution with no installations, in a way that
users are increasingly used to. And I can write it in FPC, which I am a lot
more happy with than a rubbish language like JavaScript! For me it opens a
lot of possibilities!
But let me get back to my current problems. I can accept loading images
through HTML for now, but how can I load and play sounds? There is an "Audio"
API in JavaScript but it seems that pas2js doesn't support it, it can't find
play(). I have searched web.pas and a few others for it. Where do I start to
fix that?
You go to e.g. MDN, look at the API, and write a series of import classes.

This looks like a good starting point:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_AP

If it was standard on all browsers (it is not on IE), then we could add it to
web.pas. But since IE does not support it, the classes can then be added
to a new units websound.pas.

The WIKI page of pas2js contains a rudimentary example that explains the
principle of an import class.

There is a demo (democlasstopas) that helps you to create a skeleton definition,
I will add some documentation to the WIKI or maybe make it into a unit.

If you need help, mail me in private and I will do a few sample conversions.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.fr
Graeme Geldenhuys
2017-12-26 11:20:22 UTC
Permalink
Post by Michael Van Canneyt
If it was standard on all browsers (it is not on IE), then we could add it to
web.pas. But since IE does not support it, the classes can then be added
to a new units websound.pas.
Sounds like a good candidate for a Decorator or Factory Method/Class
design pattern to have a single sound API for Pas2JS usage - no matter
the web browser.

On a side note:
Your posted web audio URL gives me a 404 error. I did find another URL
though. Not sure how new or old that information is, but being on
w3.org, I assume it is still relevant.

https://www.w3.org/TR/webaudio/


Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key: http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-p
el_es
2017-12-27 08:54:32 UTC
Permalink
[...]
Post by Ingemar Ragnemalm
Post by Reimar Grabowski
While you are updating your code you can remove the two
dependencies on bootstrap (as they are not satisfied anyway and I
think the whole fpReport dir is superflous) and perhaps do
something about the flickering of the text (although this may be
a little bit too much asked).
Ah. They just remained from an example I worked from.
Text flicker is most likely caused by not double buffering. I need to
generate an image off-screen. Nothing strange with that, just one
more thing to figure out in the JS environment.
Could be hw / sw dependant - no text flicker here, on Firefox 57 under Linux Debian Stretch (32bit),
Intel graphics (i915), KDE Plasma desktop.

[...]
Post by Ingemar Ragnemalm
/Ingemar
-L.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/

Loading...