sfml.js 1.0.0-rc.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +6 -2
- package/README.ko.md +6 -2
- package/README.md +6 -2
- package/README.zh-CN.md +6 -2
- package/assets/breakout.png +0 -0
- package/docs/development.ja.md +2 -6
- package/docs/development.ko.md +2 -6
- package/docs/development.md +2 -6
- package/docs/development.zh-CN.md +2 -6
- package/native/shared-handle.h +41 -3
- package/package.json +5 -4
package/README.ja.md
CHANGED
|
@@ -136,9 +136,13 @@ node examples/all-types.cjs --frames=120
|
|
|
136
136
|
node examples/network.cjs
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
[
|
|
139
|
+
[機能サンプル](examples/features/README.ja.md) · [公式サンプル](examples/official/README.ja.md) · [ゲームとアプリ](examples/projects/README.ja.md)
|
|
140
140
|
|
|
141
|
-
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos)
|
|
141
|
+
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos) には、sfml.js で実装した Bomberman、Breakout、Tetris、Doodle Jump、Arkanoid が含まれています。インストールと起動の手順は[ゲームプロジェクト](examples/projects/README.ja.md#node-sfml-demos)を参照してください。
|
|
142
|
+
|
|
143
|
+
[16-sfml.js-games-ported](https://github.com/XadillaX/16-sfml.js-games-ported) は、[jsyqrt/games](https://github.com/jsyqrt/games) の C++ と SFML で作られた全 16 ゲームを、ClojureScript と sfml.js に移植したものです。ゲーム一覧と nbb の起動コマンドは[16 ゲーム](examples/projects/README.ja.md#16-games)を参照してください。
|
|
144
|
+
|
|
145
|
+
[play-nes](examples/projects/README.ja.md#play-nes) — sfml.js と JSNES で構築されたデスクトップ NES エミュレータ。
|
|
142
146
|
|
|
143
147
|
## コントリビュート
|
|
144
148
|
|
package/README.ko.md
CHANGED
|
@@ -136,9 +136,13 @@ node examples/all-types.cjs --frames=120
|
|
|
136
136
|
node examples/network.cjs
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
[
|
|
139
|
+
[기능 예제](examples/features/README.ko.md) · [공식 예제](examples/official/README.ko.md) · [게임과 앱](examples/projects/README.ko.md)
|
|
140
140
|
|
|
141
|
-
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos)
|
|
141
|
+
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos)에는 sfml.js로 구현한 Bomberman, Breakout, Tetris, Doodle Jump, Arkanoid가 포함되어 있습니다. 설치 및 실행 명령은 [게임 프로젝트](examples/projects/README.ko.md#node-sfml-demos)를 참고하세요.
|
|
142
|
+
|
|
143
|
+
[16-sfml.js-games-ported](https://github.com/XadillaX/16-sfml.js-games-ported)는 [jsyqrt/games](https://github.com/jsyqrt/games)의 C++과 SFML로 작성된 원본 게임 16개를 모두 ClojureScript와 sfml.js로 이식한 프로젝트입니다. 게임 목록과 nbb 실행 명령은 [게임 16개](examples/projects/README.ko.md#16-games)를 참고하세요.
|
|
144
|
+
|
|
145
|
+
[play-nes](examples/projects/README.ko.md#play-nes) — sfml.js와 JSNES로 구축된 데스크톱 NES 에뮬레이터.
|
|
142
146
|
|
|
143
147
|
## 기여하기
|
|
144
148
|
|
package/README.md
CHANGED
|
@@ -136,9 +136,13 @@ node examples/all-types.cjs --frames=120
|
|
|
136
136
|
node examples/network.cjs
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
[Feature examples](examples/features/README.md) · [Official examples](examples/official/README.md) · [Games and applications](examples/projects/README.md)
|
|
140
140
|
|
|
141
|
-
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos) and [
|
|
141
|
+
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos) contains Bomberman, Breakout, Tetris, Doodle Jump and Arkanoid implementations using sfml.js. See [game setup](examples/projects/README.md#node-sfml-demos) for installation and launch commands.
|
|
142
|
+
|
|
143
|
+
[16-sfml.js-games-ported](https://github.com/XadillaX/16-sfml.js-games-ported) ports all 16 games from [jsyqrt/games](https://github.com/jsyqrt/games), originally written in C++ with SFML, to ClojureScript with sfml.js. See [16 games](examples/projects/README.md#16-games) for the game list and nbb launch commands.
|
|
144
|
+
|
|
145
|
+
[play-nes](examples/projects/README.md#play-nes) — a desktop NES emulator built with sfml.js and JSNES.
|
|
142
146
|
|
|
143
147
|
## Contributing
|
|
144
148
|
|
package/README.zh-CN.md
CHANGED
|
@@ -136,9 +136,13 @@ node examples/all-types.cjs --frames=120
|
|
|
136
136
|
node examples/network.cjs
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
[
|
|
139
|
+
[功能示例](examples/features/README.zh-CN.md) · [官方示例](examples/official/README.zh-CN.md) · [游戏与应用](examples/projects/README.zh-CN.md)
|
|
140
140
|
|
|
141
|
-
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos) 和 [
|
|
141
|
+
[node-sfml-demos](https://github.com/XadillaX/node-sfml-demos) 包含使用 sfml.js 实现的 Bomberman、Breakout、Tetris、Doodle Jump 和 Arkanoid。安装与启动命令见 [游戏项目](examples/projects/README.zh-CN.md#node-sfml-demos)。
|
|
142
|
+
|
|
143
|
+
[16-sfml.js-games-ported](https://github.com/XadillaX/16-sfml.js-games-ported) 将 [jsyqrt/games](https://github.com/jsyqrt/games) 中原本使用 C++ 和 SFML 编写的全部 16 个游戏迁移为 ClojureScript + sfml.js。游戏清单与 nbb 启动命令见 [16 个游戏](examples/projects/README.zh-CN.md#16-games)。
|
|
144
|
+
|
|
145
|
+
[play-nes](examples/projects/README.zh-CN.md#play-nes) — 基于 sfml.js 和 JSNES 的桌面 NES 模拟器。
|
|
142
146
|
|
|
143
147
|
## 参与贡献
|
|
144
148
|
|
package/assets/breakout.png
CHANGED
|
Binary file
|
package/docs/development.ja.md
CHANGED
|
@@ -36,7 +36,6 @@ npm ci
|
|
|
36
36
|
| `npm run test:types` | TypeScript のインターフェースを検証 |
|
|
37
37
|
| `npm run test:runtime` | ランタイムテストを直列に実行。事前にビルドが必要 |
|
|
38
38
|
| `npm test` | lint、ビルド、型検査、ランタイムテストを順に実行 |
|
|
39
|
-
| `npm run test:ported` | 移植済みサンプルを検証し、成功と未対応を区別して報告 |
|
|
40
39
|
| `npm pack --dry-run` | npm パッケージのファイル一覧を確認 |
|
|
41
40
|
|
|
42
41
|
TypeScript だけを変更した場合は `npm run build:ts`、ネイティブ部分を変更した場合は `npm run build` を実行します。ランタイムテストは自動的に再ビルドしないため、実行前にビルド結果とソースコードが一致していることを確認してください。
|
|
@@ -46,10 +45,9 @@ TypeScript だけを変更した場合は `npm run build:ts`、ネイティブ
|
|
|
46
45
|
|
|
47
46
|
```sh
|
|
48
47
|
npm test
|
|
49
|
-
npm run test:ported
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
`npm test` は lint、ネイティブ部分と TypeScript のビルド、型検査、ランタイムテストを実行します。
|
|
50
|
+
`npm test` は lint、ネイティブ部分と TypeScript のビルド、型検査、ランタイムテストを実行します。
|
|
53
51
|
|
|
54
52
|
ランタイムテストはファイル単位で直列に実行し、公開インターフェース、ネイティブ SFML との比較、実際に描画されたピクセル、非同期 I/O、スナップショット、ライフサイクルを検証します。型テストは `test/*.types.ts`、ランタイムテストは `test/*.test.cjs`、ネイティブ比較テストは `test/native/` にあります。
|
|
55
53
|
|
|
@@ -116,9 +114,7 @@ npm run demo:audio
|
|
|
116
114
|
npm run demo:network
|
|
117
115
|
```
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
旧版の `drawAsync`/`displayAsync` を使う 2 つのサンプルは、未対応であることを明示的に報告します。詳細は[移植に関する説明](../examples/ported/README.ja.md)を参照してください。
|
|
117
|
+
サンプルは[概要](../examples/README.ja.md)、[機能](../examples/features/README.ja.md)、[公式](../examples/official/README.ja.md)、[ゲームとアプリ](../examples/projects/README.ja.md)に分かれています。コマンドと[撮影機能](../examples/features/README.ja.md#screenshots)は各入口で説明しています。ビルド後はスクリプトを直接実行し、`--frames` は対応する入口にだけ渡してください。
|
|
122
118
|
|
|
123
119
|
## ソースコードと生成ファイル
|
|
124
120
|
|
package/docs/development.ko.md
CHANGED
|
@@ -36,7 +36,6 @@ npm ci
|
|
|
36
36
|
| `npm run test:types` | TypeScript 인터페이스 검증 |
|
|
37
37
|
| `npm run test:runtime` | 런타임 테스트를 직렬 실행. 사전 빌드 필요 |
|
|
38
38
|
| `npm test` | lint, 빌드, 타입 검사, 런타임 테스트를 순서대로 실행 |
|
|
39
|
-
| `npm run test:ported` | 포팅된 예제를 검증하고 통과와 미지원을 구분해 보고 |
|
|
40
39
|
| `npm pack --dry-run` | npm 패키지 파일 목록 확인 |
|
|
41
40
|
|
|
42
41
|
TypeScript만 수정했다면 `npm run build:ts`를 실행할 수 있습니다. 네이티브 코드를 수정했다면 `npm run build`를 실행하세요. 런타임 테스트는 자동으로 다시 빌드하지 않으므로, 실행 전에 빌드 결과가 소스와 일치하는지 확인해야 합니다.
|
|
@@ -46,10 +45,9 @@ TypeScript만 수정했다면 `npm run build:ts`를 실행할 수 있습니다.
|
|
|
46
45
|
|
|
47
46
|
```sh
|
|
48
47
|
npm test
|
|
49
|
-
npm run test:ported
|
|
50
48
|
```
|
|
51
49
|
|
|
52
|
-
`npm test`는 lint, 네이티브 및 TypeScript 빌드, 타입 검사, 런타임 테스트를 실행합니다.
|
|
50
|
+
`npm test`는 lint, 네이티브 및 TypeScript 빌드, 타입 검사, 런타임 테스트를 실행합니다.
|
|
53
51
|
|
|
54
52
|
런타임 테스트는 파일별로 직렬 실행되며 공개 인터페이스, 네이티브 SFML 대조, 실제 렌더링 픽셀, 비동기 I/O, 스냅샷, 수명 주기를 검증합니다. 타입 테스트는 `test/*.types.ts`, 런타임 테스트는 `test/*.test.cjs`, 네이티브 대조 테스트는 `test/native/`에 있습니다.
|
|
55
53
|
|
|
@@ -116,9 +114,7 @@ npm run demo:audio
|
|
|
116
114
|
npm run demo:network
|
|
117
115
|
```
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
이전 버전의 `drawAsync`/`displayAsync` 예제 두 개는 미지원 상태를 명시적으로 보고합니다. 자세한 내용은 [포팅 안내](../examples/ported/README.ko.md)를 참고하세요.
|
|
117
|
+
예제는 [개요](../examples/README.ko.md), [기능 예제](../examples/features/README.ko.md), [공식 예제](../examples/official/README.ko.md), [게임과 앱](../examples/projects/README.ko.md)으로 나뉩니다. 명령과 [캡처 지원](../examples/features/README.ko.md#screenshots)은 각 진입점에 설명되어 있습니다. 빌드 후 스크립트를 직접 실행하고 지원하는 진입점에만 `--frames`를 전달하세요.
|
|
122
118
|
|
|
123
119
|
## 소스와 생성 파일
|
|
124
120
|
|
package/docs/development.md
CHANGED
|
@@ -37,7 +37,6 @@ Run these commands from the repository root:
|
|
|
37
37
|
| `npm run test:types` | Validate TypeScript APIs |
|
|
38
38
|
| `npm run test:runtime` | Run runtime tests serially; requires a prior build |
|
|
39
39
|
| `npm test` | Run lint, build, type checks and runtime tests in sequence |
|
|
40
|
-
| `npm run test:ported` | Validate ported examples, reporting passes and unsupported cases separately |
|
|
41
40
|
| `npm pack --dry-run` | Inspect the npm package file list |
|
|
42
41
|
|
|
43
42
|
For TypeScript-only changes, run `npm run build:ts`; after native changes, run `npm run build`. Runtime tests do not rebuild automatically, so ensure the build matches the source before running them.
|
|
@@ -48,10 +47,9 @@ For TypeScript-only changes, run `npm run build:ts`; after native changes, run `
|
|
|
48
47
|
|
|
49
48
|
```sh
|
|
50
49
|
npm test
|
|
51
|
-
npm run test:ported
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
`npm test` runs lint, native and TypeScript builds, type checks and runtime tests.
|
|
52
|
+
`npm test` runs lint, native and TypeScript builds, type checks and runtime tests.
|
|
55
53
|
|
|
56
54
|
Runtime tests run serially by file, covering public APIs, comparisons with native SFML, actual rendered pixels, asynchronous I/O, snapshots and lifetimes. Type tests are in `test/*.types.ts`, runtime tests in `test/*.test.cjs`, and native comparisons in `test/native/`.
|
|
57
55
|
|
|
@@ -118,9 +116,7 @@ npm run demo:audio
|
|
|
118
116
|
npm run demo:network
|
|
119
117
|
```
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
The two legacy `drawAsync`/`displayAsync` examples explicitly report that they are unsupported; see the [ported examples](../examples/ported/README.md).
|
|
119
|
+
The examples are organized into [overview](../examples/README.md), [feature examples](../examples/features/README.md), [official examples](../examples/official/README.md) and [games and applications](../examples/projects/README.md). Commands and [screenshot support](../examples/features/README.md#screenshots) are documented with their entry points. After building, run the script directly; pass `--frames` only where supported.
|
|
124
120
|
|
|
125
121
|
## Source and generated files
|
|
126
122
|
|
|
@@ -37,7 +37,6 @@ npm ci
|
|
|
37
37
|
| `npm run test:types` | 验证 TypeScript 接口 |
|
|
38
38
|
| `npm run test:runtime` | 串行运行运行时测试,需要先构建 |
|
|
39
39
|
| `npm test` | 依次执行 lint、构建、类型检查和运行时测试 |
|
|
40
|
-
| `npm run test:ported` | 验证迁移示例,分别报告通过和不支持 |
|
|
41
40
|
| `npm pack --dry-run` | 检查 npm 包文件清单 |
|
|
42
41
|
|
|
43
42
|
只修改 TypeScript 时可执行 `npm run build:ts`;修改 Native 后执行 `npm run build`。运行时测试不会自动重建,运行前确保构建与源码一致。
|
|
@@ -48,10 +47,9 @@ npm ci
|
|
|
48
47
|
|
|
49
48
|
```sh
|
|
50
49
|
npm test
|
|
51
|
-
npm run test:ported
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
`npm test` 执行 lint、Native 与 TypeScript 构建、类型检查和运行时测试。
|
|
52
|
+
`npm test` 执行 lint、Native 与 TypeScript 构建、类型检查和运行时测试。
|
|
55
53
|
|
|
56
54
|
运行时测试按文件串行运行,覆盖公开接口、原生 SFML 对照、实际渲染像素、异步 I/O、快照及生命周期。类型测试位于 `test/*.types.ts`,运行时测试为 `test/*.test.cjs`,原生对照在 `test/native/`。
|
|
57
55
|
|
|
@@ -118,9 +116,7 @@ npm run demo:audio
|
|
|
118
116
|
npm run demo:network
|
|
119
117
|
```
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
旧版 `drawAsync`/`displayAsync` 两个示例明确报告不支持,详情见 [迁移说明](../examples/ported/README.zh-CN.md)。
|
|
119
|
+
示例分为 [总览](../examples/README.zh-CN.md)、[功能示例](../examples/features/README.zh-CN.md)、[官方示例](../examples/official/README.zh-CN.md) 和 [游戏与应用](../examples/projects/README.zh-CN.md)。命令和 [截图支持](../examples/features/README.zh-CN.md#screenshots) 随入口说明。构建后直接运行脚本,仅对支持的入口传入 `--frames`。
|
|
124
120
|
|
|
125
121
|
## 源码与生成文件
|
|
126
122
|
|
package/native/shared-handle.h
CHANGED
|
@@ -3,17 +3,55 @@
|
|
|
3
3
|
#include <nan.h>
|
|
4
4
|
|
|
5
5
|
#include <memory>
|
|
6
|
+
#include <unordered_map>
|
|
6
7
|
#include <utility>
|
|
7
8
|
|
|
8
9
|
namespace sfmljs {
|
|
9
10
|
|
|
11
|
+
// V8 retains instantiated template metadata in its native context. Reuse one
|
|
12
|
+
// shape per Node environment, and release its persistent before isolate teardown.
|
|
13
|
+
// All handle types have the same layout; the private marker below checks T.
|
|
14
|
+
class SharedHandleTemplate final {
|
|
15
|
+
public:
|
|
16
|
+
static v8::Local<v8::ObjectTemplate> Get() {
|
|
17
|
+
auto* environment = node::GetCurrentEnvironment(Nan::GetCurrentContext());
|
|
18
|
+
auto found = templates_.find(environment);
|
|
19
|
+
if (found == templates_.end()) {
|
|
20
|
+
auto* cache = new SharedHandleTemplate(environment);
|
|
21
|
+
found = templates_.emplace(environment, cache).first;
|
|
22
|
+
node::AddEnvironmentCleanupHook(v8::Isolate::GetCurrent(), Cleanup, cache);
|
|
23
|
+
}
|
|
24
|
+
return Nan::New(found->second->shape_);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
explicit SharedHandleTemplate(node::Environment* environment)
|
|
29
|
+
: environment_(environment) {
|
|
30
|
+
auto shape = Nan::New<v8::ObjectTemplate>();
|
|
31
|
+
shape->SetInternalFieldCount(1);
|
|
32
|
+
shape_.Reset(shape);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static void Cleanup(void* data) {
|
|
36
|
+
auto* cache = static_cast<SharedHandleTemplate*>(data);
|
|
37
|
+
cache->shape_.Reset();
|
|
38
|
+
templates_.erase(cache->environment_);
|
|
39
|
+
delete cache;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Worker threads must never share V8 handles. The cleanup hook also removes
|
|
43
|
+
// entries when an environment is replaced on the same thread.
|
|
44
|
+
inline static thread_local
|
|
45
|
+
std::unordered_map<node::Environment*, SharedHandleTemplate*> templates_;
|
|
46
|
+
node::Environment* environment_;
|
|
47
|
+
Nan::Persistent<v8::ObjectTemplate> shape_;
|
|
48
|
+
};
|
|
49
|
+
|
|
10
50
|
template <typename T>
|
|
11
51
|
class SharedHandle final : public Nan::ObjectWrap {
|
|
12
52
|
public:
|
|
13
53
|
static v8::Local<v8::Object> Create(std::shared_ptr<T> owner) {
|
|
14
|
-
auto
|
|
15
|
-
shape->SetInternalFieldCount(1);
|
|
16
|
-
auto object = Nan::NewInstance(shape).ToLocalChecked();
|
|
54
|
+
auto object = Nan::NewInstance(SharedHandleTemplate::Get()).ToLocalChecked();
|
|
17
55
|
auto* handle = new SharedHandle(std::move(owner));
|
|
18
56
|
handle->Wrap(object);
|
|
19
57
|
Nan::SetPrivate(object, Key(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfml.js",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "SFML's Node.js binding.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,8 +54,7 @@
|
|
|
54
54
|
"demo:audio": "npm run build && node examples/audio.cjs",
|
|
55
55
|
"demo:network": "npm run build:ts && node examples/network.cjs",
|
|
56
56
|
"demo:ported": "npm run build:ts && node examples/ported/render_window.cjs",
|
|
57
|
-
"
|
|
58
|
-
"lint": "eslint --ext .ts,.cjs src tools test examples .eslintrc.cjs",
|
|
57
|
+
"lint": "eslint --ext .ts,.js,.cjs,.mjs . && eslint --no-ignore site/.vitepress/theme/hero-light.mjs",
|
|
59
58
|
"jslint": "npm run lint",
|
|
60
59
|
"test:types": "tsc -p test/tsconfig.json",
|
|
61
60
|
"test:runtime": "node tools/run-tests.cjs",
|
|
@@ -95,6 +94,7 @@
|
|
|
95
94
|
"@types/ssh2": "1.15.6",
|
|
96
95
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
97
96
|
"@typescript-eslint/parser": "^7.18.0",
|
|
97
|
+
"@wettstein/nodegl": "1.2.1",
|
|
98
98
|
"eslint": "^8.57.1",
|
|
99
99
|
"eslint-config-egg": "^14.1.0",
|
|
100
100
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"eslint-plugin-node": "^11.1.0",
|
|
103
103
|
"typedoc": "0.28.3",
|
|
104
104
|
"typedoc-material-theme": "1.4.0",
|
|
105
|
-
"typescript": "5.0.4"
|
|
105
|
+
"typescript": "5.0.4",
|
|
106
|
+
"x11": "4.3.1"
|
|
106
107
|
}
|
|
107
108
|
}
|