From 7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sun, 19 Sep 2021 19:43:11 +0200 Subject: :boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime --- public/docs/Code Documentation/Design/index.html | 574 ++++++++++++ .../Modules/CompileAndRun/index.html | 816 +++++++++++++++++ public/docs/Code Documentation/Run/index.html | 754 ++++++++++++++++ public/docs/Code Documentation/SocketIO/index.html | 989 +++++++++++++++++++++ 4 files changed, 3133 insertions(+) create mode 100644 public/docs/Code Documentation/Design/index.html create mode 100644 public/docs/Code Documentation/Modules/CompileAndRun/index.html create mode 100644 public/docs/Code Documentation/Run/index.html create mode 100644 public/docs/Code Documentation/SocketIO/index.html (limited to 'public/docs/Code Documentation') diff --git a/public/docs/Code Documentation/Design/index.html b/public/docs/Code Documentation/Design/index.html new file mode 100644 index 0000000..2c0bc9d --- /dev/null +++ b/public/docs/Code Documentation/Design/index.html @@ -0,0 +1,574 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Design - Luxcena Neo Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content + + + +
+ +
+ +
+ + + + +
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ +
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/docs/Code Documentation/Modules/CompileAndRun/index.html b/public/docs/Code Documentation/Modules/CompileAndRun/index.html new file mode 100644 index 0000000..e842528 --- /dev/null +++ b/public/docs/Code Documentation/Modules/CompileAndRun/index.html @@ -0,0 +1,816 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CompileAndRun - Luxcena Neo Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content + + + +
+ +
+ +
+ + + + +
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + + +

CompileAndRun

+ +

Index

+
+

Locals

+

var pythonSupportFiles

+

Points to the files for our python support code. They should be in a subdir of the module itself.

+

Exported

+

class Python

+

This is exported as Python, just so that we could add other languages later. Used to build and run python-scripts with our support-code.

+

method Python.constructor

+

Takes one parameter, which is the full path to the folder where the script is located.

+

When initializing the class, this will be called. Can be done like this:

+
1
new compileRun.Python(global.DirSwap + "/usrData/usrCode/example");
+
+
+ +

method Python.compile

+

This deletes old build-folder, and makes a new one. It then moves all required files into the build-folder, making us ready for running the script.

+

method Python.run

+

Spawns a new process, starting entry.py in our build-folder. It also attaches event-listners on our class-object. All of them is in the example below:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
let sc = new compileRun.Python(global.DirSwap + "/usrData/usrCode/example");
+
+// When data is printed from the python-script
+sc.on("stdout::data", (_stdout) => { });
+// Last write when script closes, any exiting messages
+sc.on("stdout::end", (_stdout) => { });
+// When something is printed from the python-script to the error-out. Usually when a `throw` is called
+sc.on("stderr::out", (_stderr) => { });
+// Last words when process is dying from an error :`(
+sc.on("stderr::end", (_stderr) => { });
+// When script exits, _code is the exit-code
+sc.on("close", (_code) => { });
+
+
+ +

Python

+

This is the support-files for user-made scripts.

+

Entry.py

+

The entry-point when running a script. A file called script.py, containing the user-script, should be placed next to this file. Starting it should be done like this (Where app-root is where our app.js is located):

+
1
python entry.py <pathToAppRoot>
+
+
+ + + + + + + + + +
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/docs/Code Documentation/Run/index.html b/public/docs/Code Documentation/Run/index.html new file mode 100644 index 0000000..bb572c2 --- /dev/null +++ b/public/docs/Code Documentation/Run/index.html @@ -0,0 +1,754 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Run - Luxcena Neo Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content + + + +
+ +
+ +
+ + + + +
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + + +

Run when developing

+

I have made a simple script, that can be run both on a rPI and a normal computer. +(You will obviously not get any script to do anything on you pc)

+

I have only tested this on my mac...

+

To start it run: +
1
npm run dev
+
+
+You have to run these commands beforehand: +
1
+2
npm i
+pip3 install mkdocs mkdocs-gitbook pygments pymdown-extensions
+
+

+
+

Starting

+

It will when starting freak out a little. All the filewatchers fires an event for every file, +they find for some reason. But node should be killed each time, and when you end up with +only two processes, it should work as you'd expect.

+
+

This will create a folder named tmp in you working directory. where all the user-files will be stored.

+

Build watcher.

+

It starts to watch these directories: +
1
- /build/
+
+
+If a change is detected, it runs: +
1
mkdocs build
+
+

+

Node watcher

+

It starts to watch these directories: +
1
+2
- src/ (Except /src/public/ and /src/js/)
+- app.js
+
+

+

It then shuts down node and starts it again: +
1
node app.js <WORKING_DIR>/tmp/
+
+

+

webpack

+

It just starts this command, witch rebundles when anything is changed: +
1
npx webpack -p -w --mode=development
+
+

+
+

Tip

+

All the log-windows respond to holding your cursor over and scrolling.

+
+

Exit

+

The script will exit when pressing q, s, escape, Control+c. +It will then send a kill signal to all processes, wait 10 seconds and then exit.

+

Edit file-watchers.

+

Each of the file-watchers have explanatory names: watcher_node and watcher_docs.

+

To add files or paths they should watch, find the init of the variable, and modify that code: +
1
+2
+3
+4
+5
+6
e.g.
+let; watcher_node = chokidar.watch([
+    "app.js",
+    'src/'  // Add new entrys here
+
+]).on('all', (event, path) => { // ...
+
+

+

For the node-watcher, specify paths it should ignore in the path.includes block.

+ + + + + + + + + +
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/docs/Code Documentation/SocketIO/index.html b/public/docs/Code Documentation/SocketIO/index.html new file mode 100644 index 0000000..edcf9b1 --- /dev/null +++ b/public/docs/Code Documentation/SocketIO/index.html @@ -0,0 +1,989 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Socket-IO - Luxcena Neo Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Skip to content + + + +
+ +
+ +
+ + + + +
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + + +

SocketIO

+

Client

+

Socketio is setup in the file globals. +This means, import globals, and then you can use Socket from there.

+

Connect

+
    +
  1. Client first needs to get an Authentication token, + this can be obtained by doing this: +
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    import {setCookie} from "../../../cookies";
    +let CryptoJS = require("crypto-js");
    +let passwordHash = CryptoJS.SHA256(<PASSWORD>;).toString();
    +
    +Socket.emit("authenticate", <USERNAME>, passwordHash, (token) => {
    +    // Token will be a string if username/password combo is right,
    +    // if not, it is false.
    +    setCookie("session_token", token, 500);
    +};)
    +
    +
  2. +
  3. Then the user can authenticate like this: +
    1
    +2
    +3
    +4
    +5
    +6
    +7
    import {getCookie} from "../../../cookies";
    +let cookieToken = getCookie("session_token");
    +
    +Socket.emit("authenticateToken", cookieToken, (res) => {
    +    // Res is true if we got authenticated,
    +    // If not, it is false.
    +});
    +
    +
  4. +
  5. We are now authenticated, and all actions and events are available to the client.
  6. +
+

"Actions"

+
1
+2
Socket.emit(Action, *Arguments, (Return) => {
+};)
+
+
+ +
NeoRuntime/status
+ + + + + + + + + + + + + + + +
NameTypeDescription
statusobject
+
Return/status + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
currentScriptstring"None"/Name of current script
scriptIsExitedboolean
uptimenumber
+
+
NeoRuntime/Script/Create
+
Arguments + + + + + + + + + + + + + + +
NameTypeDescription
scriptPathstringPath of the new script, local/example
+
+
Return + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
resbooleansuccess
resMsgstringif fail, errorMessage
+
+
NeoRuntime/Script/Delete
+
Arguments + + + + + + + + + + + + + + +
NameTypeDescription
scriptPathstringPath of the script to delete, local/example
+
+
Return + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
resbooleansuccess
resMsgstringif fail, errorMessage
+
+
NeoRuntime/Script/Select
+
Arguments + + + + + + + + + + + + + + +
NameTypeDescription
scriptPathstringPath of the script to start, local/example
+
+
NeoRuntime/Scripts/get
+
Return + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
locallistlocal scripts
remotelistremote scripts
+
+

"Events"

+

1
+2
+3
+4
+5
// Listen for a event
+Socket.emit(event + "::join");
+Socket.on(event, (*Return); => {
+
+})
+
+
+
1
+2
// Stop listening for an event
+Socket.emit(event + "::leave")
+
+

+

Server

+ + + + + + + + + +
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3