~technomancy/fennel-lang.org

ref: 2e6bbe04b6200769ca1df065a4b5dca4a537e446 fennel-lang.org/repl.fnl -rw-r--r-- 3.5 KiB
migrating repl to a web worker with fallback

Hello,

This patch suggests using a Web Worker for the web REPL. We had an issue
with the last one (https://lists.sr.ht/~technomancy/fennel/patches/12080).

The problem was that we had missing files in the upload process inside
the makefile. This patch solves these problems, and I improved it to
ensure a compatible fallback for browsers that do not support Web
Workers. Also, the shim.lua test still works.

I uploaded a version to make testing easier:
https://gbaptista.com/fennel/ (fennel / 123)

Tested on: Luakit, Nyxt, Chromium, Firefox, Brave, and Opera.

Included in this patch:

makefile:
Adds new files into the upload process.

repl-worker.js:

Fengari does not have a straightforward way to deal with Web Workers;
This file evaluates the Worker written in Lua and makes it accessible
in pure js for the Web Worker.

repl-worker.lua:

The Web Worker source code; It's responsible for receiving messages
from the UI and sending the evaluated responses.

repl.fnl:

The Lua pane toggle was removed to make possible to run the full REPL
inside a Web Worker.

init.lua:

Instead of using REPL directly, it communicates via messages with the
Web Worker to avoid freezing the page.

I introduced a "fake loader" that gives the feeling that something is
happening to avoid let the user think that something is broken. This
loader simulates percentage progress for 10 seconds waiting time.

The Lua pane toggle was moved to this file.

Also, there are compatible modes that make possible to use the REPL in
old browsers or to run tests without any browser.
Revert "migrating repl to a web worker"

This reverts commit 20f6744439fbdec4c9d0d1a138e86551bb3dadbf.
migrating repl to a web worker

This patch suggests using a Web Worker for the web REPL. I tried to
modify as little code as possible.

Tested on: Chromium, Firefox, Brave, and Opera.

Included in this patch:

repl-worker.js:

Fengari does not have a straightforward way to deal with Web Workers;
This file evaluates the Worker written in Lua and makes it accessible
in pure js for the Web Worker.

repl-worker.lua:

The Web Worker source code; It's responsible for receiving messages
from the UI and sending the evaluated responses.

repl.fnl:

The Lua pane toggle was removed to make possible to run the full REPL
inside a Web Worker.

shim.lua:

A small adjustment to avoid breaking the test.

init.lua:

Instead of using REPL directly, it communicates via messages with the
Web Worker to avoid freezing the page.

I introduced a "fake loader" that gives the feeling that something is
happening to avoid let the user think that something is broken. This
loader simulates percentage progress for 10 seconds waiting time.

The Lua pane toggle was moved to this file.

Also, there is a loadReplWithoutWebWorker function to keep the shim.lua
working.
Remove separate fennelfriend module; it's part of the compiler now.
Use pcall when compiling lua equivalent for the panel.

This fixes #21, but not in a great way; it would be better to pass the
real scope into the call to compileString.
Wire fennelview and fennelfriend into the web repl.
Merge pull request #20 from jaawerth/fix-web-repl-metadata

fix docstring usage in web REPL
Corrected metadata usage in web REPL

Ensured moduleName is "fennel/fennel" in both repl and compileString,
and useMetadata is enabled in compileString
248b15bf — Benjamín Buccianti 2 years ago
improved toggle btn, onclick function and makeLine made local
1a8fa3e8 — Benjamín Buccianti 2 years ago
added lua pane, toggle btn and errors color red
2134d461 — Benjamín Buccianti 2 years ago
updated fengari-web.js and fixed requires of fennel
bfa9257b — Phil Hagelberg 2 years ago
Merge pull request #10 from doesntgolf/patch-1

Fix check for `add` function
Fix check for `add` function in local scope
28852ec6 — Phil Hagelberg 2 years ago
Merge pull request #9 from doesntgolf/patch-1

Change function instruction from global to local.
Change function instruction from global to local.
faa067e1 — Phil Hagelberg 2 years ago
Merge pull request #8 from doesntgolf/patch-2

Replace `defn`s with `fn` since defn was removed.
Replace `defn`s with `fn` since defn was removed.
7749cf76 — Phil Hagelberg 2 years ago
Merge pull request #5 from doesntgolf/patch-1

Fix match? check for "hello world" in tutorial.
Fix match? check for "hello world" in tutorial.
Add sample; tweak CSS sizes.
Next