-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from sidi762/master
Added web app demo
- Loading branch information
Showing
15 changed files
with
2,059 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,8 @@ | |
|
||
__如果有好的意见或建议,欢迎联系我们!__ | ||
|
||
* __[email protected]__ (ValKmjolnir) | ||
|
||
* __[email protected]__ (Sidi) | ||
- __[email protected]__ (ValKmjolnir) | ||
- __[email protected]__ (Sidi) | ||
|
||
## __简介__ | ||
|
||
|
@@ -428,3 +427,57 @@ Nasal REPL interpreter version 11.1 (Nov 1 2023 23:37:30) | |
|
||
>>> | ||
``` | ||
## __Web 界面__ | ||
|
||
现已提供基于 Web 的库以及示例界面,您可以直接在浏览器中编写和运行 Nasal 代码。该界面包括代码编辑器和交互式 REPL(未完成)。 | ||
|
||
### __Web 代码编辑器__ | ||
|
||
- **语法高亮:** 使用 CodeMirror 提供增强的编码体验。 | ||
- **错误高亮和格式化:** 清晰显示语法和运行时错误。 | ||
- **示例程序:** 预加载的示例,帮助您快速上手。 | ||
- **执行时间显示选项:** 可选择查看代码执行所需时间。 | ||
- **可配置的执行时间限制:** 设置时间限制以防止代码长时间运行。 | ||
- **提示:** 在线解释器的安全性尚未得到广泛测试,建议配合沙盒机制等安全措施使用。 | ||
|
||
### __Web REPL__ | ||
|
||
- **重要提示:** REPL 中的代码执行时间限制尚未正确实现。此 REPL 库目前不稳定,请勿在生产环境中使用。 | ||
- **交互式命令行界面:** 在浏览器中体验熟悉的 REPL 环境。 | ||
- **多行输入支持:** 使用 `>>>` 和 `...` 提示符无缝输入多行代码。 | ||
- **命令历史导航:** 使用箭头键轻松浏览命令历史。 | ||
- **格式化的错误处理:** 接收清晰且格式化的错误消息,助力调试。 | ||
- **快速测试的示例代码片段:** 访问并运行示例代码片段,快速测试功能。 | ||
|
||
### __运行 Web 界面__ | ||
|
||
1. **构建 Nasal 共享库:** | ||
|
||
```bash | ||
cmake -DBUILD_SHARED_LIBS=ON . | ||
make nasal-web | ||
``` | ||
|
||
2. **设置并运行 Web 应用:** | ||
|
||
**代码编辑器:** | ||
|
||
```bash | ||
cd nasal-web-app | ||
npm install | ||
node server.js | ||
``` | ||
|
||
在浏览器中访问 `http://127.0.0.1:3000/` 以使用代码编辑器。 | ||
|
||
**REPL:** | ||
|
||
```bash | ||
cd nasal-web-app | ||
npm install | ||
node server_repl.js | ||
``` | ||
|
||
在浏览器中访问 `http://127.0.0.1:3001/repl.html` 以使用 REPL 界面。 | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "nasal-web-app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.21.1", | ||
"ffi-napi": "^4.0.3", | ||
"yargs": "^17.7.2" | ||
} | ||
} |
Oops, something went wrong.