Difference between revisions of "lazarus pas2js integration"
(→Atom package options)
|Line 67:||Line 67:|
== Atom package options ==
== Atom package options ==
== Project options ==
== Project options ==
Revision as of 12:05, 22 December 2020
English (en) │
русский (ru) │
Lazarus pas2JS integration
Requires Lazarus 1.9+ and pas2js (see here). Installation procedure:
1. Click on menu Package - Install/Uninstall Packages
2. Choose the package pas2jsdsgn then restart the IDE.
The Lazarus pas2js integration has 3 parts to it:
In the Tools/Options... dialog, the Pas2JS section allows you to set some options that affect the IDE integration. It looks like this:
The following settings are available:
- Path of pas2js
- This is the compiler binary used when setting up a new project.
It will be searched in the PATH if no absolute path is set. Corresponds to IDE macro Pas2JSJS.
- Change Path of pas2js to C:\lazarus\pas2js\bin\pas2js.exe
- Path of simpleserver
- This is the webserver that is started when a project is run that needs a webserver.
This is by default the simpleserver application from the FPC project. The program can be found in the FPC sources in the directory fpcsrc\packages\fcl-web\examples\simpleserver and has to be compiled manually.
- You may also use any other webserver, as long as it accepts the -p option to set the path, and it serves files from the directory in which it was started.
- Change $MakeExe(IDE,simpleserver) to C:\lazarus\pas2js\bin\compileserver.exe
- Port numbers to start allocating from
- Every time you start a new webserver project, a new port number is allocated for the webserver. (you can still edit this in the new project dialog).
- Browser to use when opening HTML page
- The IDE will use this browser to open your HTML page.
It will be searched in the PATH if no absolute path is set. Corresponds to IDE macro Pas2JSBrowser.
- Node.js executable
- The IDE will use this Node.js executable to start a Node.js project.
It will be searched in the PATH if no absolute path is set. Corresponds to IDE macro Pas2JSNodeJS.
The pas2js support is in the pas2jsdsgn.lpk package, which you can find in the components/pas2js directory. It registers 2 wizards in the 'New project' dialog:
- Web Browser Application
- Node.js Application
Besides creating an initial project source, both options will also
- Set up the compiler command for compiling with pas2js
- change the 'Run' command so the 'Run without debugging' option works: it will open a project in the browser or run it with nodejs.
New Web Browser application
This wizard will ask for some options before generating a new project. The dialog is shown below.
The following options are available:
- Create initial HTML page. This is self-explanatory,
the IDE will generate a template HTML page which includes all that is necessary to run the pas2js code.
The page is included in the project description, so you can open and edit it from within the IDE.
- Maintain HTML page.
If you change the name of the project, the IDE will update the references in the HTML File.
(all your changes will be lost)
- Run rtl in document.onReady. By default the script tag that starts the ball rolling will call
Checking this option changes the script, so the
rtl.runis run in the HTML
This is necessary if your code contains startup code that references elements in the HTML.
The elements will only be available after the onReady event.
- Use Browser Application object.
This changes the code to use the
This is a
TCustomApplicationdescendent which offers support for query parameters etc. as if they were command-line parameters.
- Use Browser Console unit.
Checking this will simply include the browserconsole unit in the uses clause.
This hooks into the system units writeln command: any output will be appended to the HTML.
the generated HTML has a div with the correct ID to which the output is appended.
- Project needs a HTTP server.
If the project needs a HTTP server, then the IDE can start one for you, or you can indicate the URL to use when the 'Run without debugging' command is used.
Atom package options
The New Atom Package wizard will create a template for an atom package.
You must enter the following information:
- Directory (it will be created if it does not exist)
- A description
- A package name (must contain letters and can contain dashes)
- A package class name. This is the name of the application class.
The following information is optional:
- Commands: a series of command names and command functions. They will be inserted in the application class and code will be created to register them within atom.
- License: The license to be used. This is inserted in the package.json file.
- Keywords: Keywords to insert in the package.json file.
- Activation commands: keystrokes and commands that activate the package.
- The generated code can be configured, with the following files:
* glue.js contains the glue code for the Atom package. This is the file that starts the Atom package. * keymap.json contains the default JSON file with the keymap. * menu.json contains the default menu file with the menu entries. * package.less contains the default css file for your package.
The location for the default files can be set in the global pas2js options dialog.
You can change the settings chosen in the new project wizard in the Project Settings dialog. It also allows you to convert any existing (simple) project to a web application project.
The project options are located at the bottom "Web Project (pas2js)'
The checkbox at the top marks the project as web browser project.
All other options have the same meaning as their counter parts in the 'New project' wizard.
The ```Reset compile command``` and ```Reset run command``` set the respective commands to thei ddefault values.
As you start projects from various directories, the IDE will start webservers as needed. After some time, there can be several webservers running. An overview of running webservers can be shown using the the View/Debug Windows/Pas2JS Webservers menu item.
It shows a list of processes started by the IDE:
Support for stopping/starting processes will still be added, as well as statistics for number of requests etc.