Skip to content

Commit

Permalink
docs: 更新README和API文档,添加平台检测功能
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Dec 21, 2024
1 parent ebf9cae commit 2c236f0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ JsEngine 基于 ScriptX 和 QuickJs 实现,支持在 EndStone 中运行 JavaSc

## 开发

项目没有提供任何开发文档,仅提供了类型定义文件,你可以通过查看类型定义文件来了解 JsEngine 的 API。

您可以参考项目 `test` 目录下的示例代码来了解如何使用 JsEngine。
目前项目没有任何开发文档,您可以阅读 `types` 目录下的类型定义文件,了解 JsEngine 的 API。

## 关于项目

Expand All @@ -25,24 +23,22 @@ JsEngine 基于 ScriptX 和 QuickJs 实现,支持在 EndStone 中运行 JavaSc
| Platform | Backend | Version | ECMA Version | Support |
| :------- | :------ | :--------- | :----------- | :------ |
| Windows | QuickJs | 2021-03-27 | 2020 | y |
| Linux | QuickJs | 2024-01-13 | 2023 | x |
| Linux | QuickJs | 2024-01-13 | 2023 | y |

### 从源码编译

#### Windows
在编译之前,确保您已经安装了以下工具链:

- Xmake
- MSVC++ 2019 或更高版本 (仅限 Windows)
- LLVM 15 (附带 Clang、libc++) (仅限 Linux)

```bash
git clone --depth=1 https://github.com/engsr6982/JS_Engine.git
cd JS_Engine
xmake -y
```

#### Linux(Ubuntu)

暂不支持,具体情况见 build-linux 分支

> 由于一些玄学问题,目前无法编译 Linux 平台,请等待后续更新(欢迎提交 PR)
## 贡献

欢迎提交 Issue 和 Pull Request。
13 changes: 13 additions & 0 deletions src/API/JSEAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,18 @@ Local<Value> JSEAPI::debug(Arguments const& args) {
Catch;
}

Local<Value> JSEAPI::isWindows(const Arguments& args) {
#if defined(_WIN32) || defined(WIN32)
return Boolean::newBoolean(true);
#endif
return Boolean::newBoolean(false);
}

Local<Value> JSEAPI::isLinux(const Arguments& args) {
#if defined(__linux__)
return Boolean::newBoolean(true);
#endif
return Boolean::newBoolean(false);
}

} // namespace jse
12 changes: 8 additions & 4 deletions src/API/JSEAPI.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#pragma once

#include "Utils/Defines.h"
#include "Utils/Using.h"

namespace jse {

class JSEAPI {
public:
static Local<Value> registerPlugin(Arguments const& args); // 注册插件
static METHODS(registerPlugin);

static METHODS(getPlugin);

static METHODS(debug);

static Local<Value> getPlugin(Arguments const& args);
static METHODS(isLinux);

static Local<Value> debug(Arguments const& args);
static METHODS(isWindows);


static ClassDefine<void> builder;
Expand Down
3 changes: 1 addition & 2 deletions src/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ class PluginDescriptionBuilderImpl : public endstone::detail::PluginDescriptionB
public:
PluginDescriptionBuilderImpl() {
description = "JavaScript Engine";
authors = {"engsr6982"};
contributors = {"engsr6982", "zimuya4153"}; // Github Username
contributors = {"engsr6982", "zimuya4153", "killcerr"}; // Github Username
website = "https://github.com/engsr6982/Js_Engine";
}
};
Expand Down
6 changes: 6 additions & 0 deletions types/API/JSE.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,10 @@ declare class JSE {

/** 输出调试信息 */
static debug(...args: any[]): void;

/** 当前引擎是否运行在 Linux 平台 */
static isLinux(): boolean;

/** 当前引擎是否运行在 Windows 平台 */
static isWindows(): boolean;
}

0 comments on commit 2c236f0

Please sign in to comment.