sfml.js 1.0.0 → 1.2.1
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 +10 -9
- package/README.ko.md +10 -9
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +44 -51
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -144
- package/docs/development.ko.md +0 -144
- package/docs/development.md +0 -146
- package/docs/development.zh-CN.md +0 -146
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -107
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#include "graphics-state.h"
|
|
2
|
-
#include "exception-boundary.h"
|
|
3
|
-
#include "shared-handle.h"
|
|
4
|
-
|
|
5
1
|
#include <cstring>
|
|
6
2
|
#include <exception>
|
|
7
3
|
#include <vector>
|
|
4
|
+
|
|
5
|
+
#include "exception-boundary.h"
|
|
6
|
+
#include "graphics-state.h"
|
|
7
|
+
#include "shared-handle.h"
|
|
8
8
|
#include <SFML/Window/Context.hpp>
|
|
9
9
|
#define GL_SILENCE_DEPRECATION
|
|
10
10
|
#include <SFML/OpenGL.hpp>
|
|
@@ -31,12 +31,14 @@ struct GlAccess : sf::GlResource {
|
|
|
31
31
|
struct UploadContext {
|
|
32
32
|
const bool transient = sf::Context::getActiveContextId() == 0;
|
|
33
33
|
const GlAccess::Lock lock;
|
|
34
|
-
~UploadContext() {
|
|
34
|
+
~UploadContext() {
|
|
35
|
+
if (transient) glFlush();
|
|
36
|
+
}
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
bool ValidCount(v8::Local<v8::Value> value) {
|
|
38
40
|
return value->IsUint32() &&
|
|
39
|
-
|
|
41
|
+
Nan::To<std::uint32_t>(value).FromJust() <= sfmljs::kMaxVertices;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
NAN_METHOD(CreateVertexBuffer) {
|
|
@@ -54,9 +56,12 @@ NAN_METHOD(CreateVertexBuffer) {
|
|
|
54
56
|
try {
|
|
55
57
|
auto owner = context->owner();
|
|
56
58
|
const auto id = owner->nextId++;
|
|
57
|
-
auto buffer = sfmljs::MakeThreadOwned<State>(
|
|
59
|
+
auto buffer = sfmljs::MakeThreadOwned<State>(
|
|
60
|
+
owner,
|
|
61
|
+
id,
|
|
58
62
|
static_cast<sf::PrimitiveType>(Nan::To<unsigned>(info[1]).FromJust()),
|
|
59
|
-
static_cast<sf::VertexBuffer::Usage>(
|
|
63
|
+
static_cast<sf::VertexBuffer::Usage>(
|
|
64
|
+
Nan::To<unsigned>(info[2]).FromJust()));
|
|
60
65
|
const UploadContext upload;
|
|
61
66
|
if (source && source->owner()->getVertexCount() != 0 &&
|
|
62
67
|
(!buffer->create(source->owner()->getVertexCount()) ||
|
|
@@ -65,15 +70,21 @@ NAN_METHOD(CreateVertexBuffer) {
|
|
|
65
70
|
}
|
|
66
71
|
owner->vertexBuffers.emplace(id, buffer);
|
|
67
72
|
auto result = Nan::New<v8::Object>();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
Nan::Set(
|
|
74
|
+
result,
|
|
75
|
+
Nan::New("info").ToLocalChecked(),
|
|
76
|
+
sfmljs::NumericFields()
|
|
77
|
+
.Add("count",
|
|
78
|
+
sfmljs::Field<sfmljs::BufferCount>(*buffer),
|
|
79
|
+
sizeof(std::size_t) == 8 ? "size64" : "u32")
|
|
80
|
+
.Add("primitiveType", sfmljs::Field<sfmljs::BufferType>(*buffer))
|
|
81
|
+
.Add("usage", sfmljs::Field<sfmljs::BufferUsage>(*buffer))
|
|
82
|
+
.Add("nativeHandle", sfmljs::Field<sfmljs::BufferId>(*buffer))
|
|
83
|
+
.Map(buffer))
|
|
84
|
+
.FromJust();
|
|
85
|
+
Nan::Set(
|
|
86
|
+
result, Nan::New("handle").ToLocalChecked(), Handle::Create(buffer))
|
|
87
|
+
.FromJust();
|
|
77
88
|
Nan::Set(result, Nan::New("id").ToLocalChecked(), Nan::New(id)).FromJust();
|
|
78
89
|
info.GetReturnValue().Set(result);
|
|
79
90
|
} catch (const std::exception& error) {
|
|
@@ -148,9 +159,11 @@ NAN_METHOD(CopyVertexBuffer) {
|
|
|
148
159
|
if (buffer.getVertexCount() != input.getVertexCount()) {
|
|
149
160
|
// SFML 3.1.0's GPU-copy path assumes equal allocation sizes and does
|
|
150
161
|
// not update its count. Allocate first, preserving destination modes.
|
|
151
|
-
sf::VertexBuffer replacement(buffer.getPrimitiveType(),
|
|
162
|
+
sf::VertexBuffer replacement(buffer.getPrimitiveType(),
|
|
163
|
+
buffer.getUsage());
|
|
152
164
|
if (!replacement.create(input.getVertexCount()) ||
|
|
153
|
-
!replacement.update(input))
|
|
165
|
+
!replacement.update(input))
|
|
166
|
+
return;
|
|
154
167
|
buffer.swap(replacement);
|
|
155
168
|
} else if (!buffer.update(input)) {
|
|
156
169
|
return;
|
|
@@ -179,8 +192,8 @@ NAN_METHOD(AssignVertexBuffer) {
|
|
|
179
192
|
sf::VertexBuffer replacement(input.getPrimitiveType(), input.getUsage());
|
|
180
193
|
// Allocate the exact size before copying; SFML's update(buffer) assumes
|
|
181
194
|
// matching allocations. An empty source also replaces the target's modes.
|
|
182
|
-
if (input.getVertexCount() &&
|
|
183
|
-
|
|
195
|
+
if (input.getVertexCount() && (!replacement.create(input.getVertexCount()) ||
|
|
196
|
+
!replacement.update(input))) {
|
|
184
197
|
return sfmljs::ThrowError("Could not copy vertex buffer");
|
|
185
198
|
}
|
|
186
199
|
target->owner()->swap(replacement);
|
|
@@ -202,8 +215,8 @@ NAN_METHOD(SetVertexBufferUsage) {
|
|
|
202
215
|
if (!info[1]->IsUint32() || Nan::To<unsigned>(info[1]).FromJust() > 2) {
|
|
203
216
|
return Nan::ThrowRangeError("Invalid vertex buffer usage");
|
|
204
217
|
}
|
|
205
|
-
handle->owner()->setUsage(
|
|
206
|
-
|
|
218
|
+
handle->owner()->setUsage(static_cast<sf::VertexBuffer::Usage>(
|
|
219
|
+
Nan::To<unsigned>(info[1]).FromJust()));
|
|
207
220
|
}
|
|
208
221
|
|
|
209
222
|
NAN_METHOD(BindVertexBuffer) {
|
|
@@ -225,7 +238,8 @@ NAN_MODULE_INIT(InitializeVertexBuffer) {
|
|
|
225
238
|
sfmljs::SetMethod<CopyVertexBuffer>(target, "copyVertexBuffer");
|
|
226
239
|
sfmljs::SetMethod<SwapVertexBuffers>(target, "swapVertexBuffers");
|
|
227
240
|
sfmljs::SetMethod<AssignVertexBuffer>(target, "assignVertexBuffer");
|
|
228
|
-
sfmljs::SetMethod<SetVertexBufferPrimitiveType>(
|
|
241
|
+
sfmljs::SetMethod<SetVertexBufferPrimitiveType>(
|
|
242
|
+
target, "setVertexBufferPrimitiveType");
|
|
229
243
|
sfmljs::SetMethod<SetVertexBufferUsage>(target, "setVertexBufferUsage");
|
|
230
244
|
sfmljs::SetMethod<BindVertexBuffer>(target, "bindVertexBuffer");
|
|
231
245
|
sfmljs::SetMethod<IsVertexBufferAvailable>(target, "isVertexBufferAvailable");
|
package/native/vertex-storage.h
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <SFML/Graphics/Vertex.hpp>
|
|
4
|
-
|
|
5
3
|
#include <cstddef>
|
|
6
4
|
#include <memory>
|
|
7
5
|
#include <vector>
|
|
8
6
|
|
|
7
|
+
#include <SFML/Graphics/Vertex.hpp>
|
|
8
|
+
|
|
9
9
|
namespace sfmljs {
|
|
10
10
|
|
|
11
11
|
// Every slot contains a live sf::Vertex. Never resize a mapped allocation:
|
package/native/view-data.h
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <SFML/Graphics/View.hpp>
|
|
4
3
|
#include <span>
|
|
5
4
|
|
|
5
|
+
#include <SFML/Graphics/View.hpp>
|
|
6
|
+
|
|
6
7
|
namespace sfmljs {
|
|
7
8
|
|
|
8
9
|
// Center, size, rotation, normalized viewport and normalized scissor.
|
|
9
10
|
inline bool ValidView(std::span<const float, 13> values) {
|
|
10
11
|
const auto x = values[9], y = values[10];
|
|
11
12
|
const auto width = values[11], height = values[12];
|
|
12
|
-
return x >= 0 && x <= 1 && y >= 0 && y <= 1 &&
|
|
13
|
-
|
|
13
|
+
return x >= 0 && x <= 1 && y >= 0 && y <= 1 && width >= 0 && height >= 0 &&
|
|
14
|
+
x + width <= 1 && y + height <= 1;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
inline sf::View MakeView(std::span<const float, 13> values) {
|
package/native/window-binding.cc
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
#include
|
|
2
|
-
#include
|
|
1
|
+
#include <limits>
|
|
2
|
+
#include <string>
|
|
3
|
+
#include <type_traits>
|
|
4
|
+
|
|
3
5
|
#include "context-settings.h"
|
|
6
|
+
#include "exception-boundary.h"
|
|
7
|
+
#include "shared-handle.h"
|
|
4
8
|
#include "time-value.h"
|
|
5
9
|
#include "window-event.h"
|
|
6
10
|
#include "window-owner.h"
|
|
7
|
-
|
|
11
|
+
#include <SFML/System/String.hpp>
|
|
8
12
|
#include <SFML/Window/Cursor.hpp>
|
|
9
|
-
#include <SFML/Window/Window.hpp>
|
|
10
13
|
#include <SFML/Window/VideoMode.hpp>
|
|
11
|
-
#include <SFML/
|
|
12
|
-
#include <limits>
|
|
13
|
-
#include <string>
|
|
14
|
-
#include <type_traits>
|
|
14
|
+
#include <SFML/Window/Window.hpp>
|
|
15
15
|
|
|
16
16
|
namespace {
|
|
17
17
|
|
|
@@ -22,21 +22,27 @@ using OwnedWindow = sfmljs::OwnedWindow<sf::Window>;
|
|
|
22
22
|
|
|
23
23
|
template <typename T>
|
|
24
24
|
T NativePointer(std::uint64_t value) {
|
|
25
|
-
if constexpr (std::is_pointer_v<T>)
|
|
26
|
-
|
|
25
|
+
if constexpr (std::is_pointer_v<T>)
|
|
26
|
+
return reinterpret_cast<T>(value);
|
|
27
|
+
else
|
|
28
|
+
return static_cast<T>(value);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
template <typename T>
|
|
30
32
|
v8::Local<v8::BigInt> PointerValue(v8::Isolate* isolate, T value) {
|
|
31
33
|
if constexpr (std::is_pointer_v<T>) {
|
|
32
34
|
return v8::BigInt::NewFromUnsigned(isolate,
|
|
33
|
-
|
|
34
|
-
} else
|
|
35
|
+
reinterpret_cast<std::uintptr_t>(value));
|
|
36
|
+
} else {
|
|
37
|
+
return v8::BigInt::NewFromUnsigned(isolate, value);
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
bool ReadPointer(v8::Local<v8::Value> value,
|
|
41
|
+
bool ReadPointer(v8::Local<v8::Value> value,
|
|
42
|
+
std::uint64_t& output) { // NOLINT(runtime/references)
|
|
38
43
|
bool lossless = false;
|
|
39
|
-
if (value->IsBigInt())
|
|
44
|
+
if (value->IsBigInt())
|
|
45
|
+
output = value.As<v8::BigInt>()->Uint64Value(&lossless);
|
|
40
46
|
if (!lossless || output > std::numeric_limits<std::uintptr_t>::max()) {
|
|
41
47
|
Nan::ThrowRangeError("Expected a native pointer represented by a bigint");
|
|
42
48
|
return false;
|
|
@@ -49,7 +55,9 @@ sf::String WindowTitle(v8::Local<v8::Value> value) {
|
|
|
49
55
|
return sf::String::fromUtf8(*title, *title + title.length());
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
bool ReadSize(v8::Local<v8::Value> x,
|
|
58
|
+
bool ReadSize(v8::Local<v8::Value> x,
|
|
59
|
+
v8::Local<v8::Value> y,
|
|
60
|
+
sf::Vector2u& size) { // NOLINT(runtime/references)
|
|
53
61
|
if (!x->IsUint32() || !y->IsUint32()) {
|
|
54
62
|
Nan::ThrowRangeError("Expected positive integer window dimensions");
|
|
55
63
|
return false;
|
|
@@ -74,7 +82,8 @@ const std::uint8_t* Pixels(v8::Local<v8::Value> value, sf::Vector2u size) {
|
|
|
74
82
|
return nullptr;
|
|
75
83
|
}
|
|
76
84
|
return static_cast<const std::uint8_t*>(
|
|
77
|
-
|
|
85
|
+
bytes->Buffer()->GetBackingStore()->Data()) +
|
|
86
|
+
bytes->ByteOffset();
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
NAN_METHOD(CreateSfmlWindow) {
|
|
@@ -87,7 +96,8 @@ NAN_METHOD(OpenWindow) {
|
|
|
87
96
|
if (!window) return;
|
|
88
97
|
sf::Vector2u size;
|
|
89
98
|
if (!ReadSize(info[1], info[2], size)) return;
|
|
90
|
-
if (!info[3]->IsString())
|
|
99
|
+
if (!info[3]->IsString())
|
|
100
|
+
return Nan::ThrowTypeError("Expected a window title");
|
|
91
101
|
if (!info[4]->IsUint32() || !info[5]->IsUint32() || !info[6]->IsUint32()) {
|
|
92
102
|
return Nan::ThrowTypeError("Expected video mode, style and state");
|
|
93
103
|
}
|
|
@@ -104,7 +114,10 @@ NAN_METHOD(OpenWindow) {
|
|
|
104
114
|
try {
|
|
105
115
|
window->owner()->create(
|
|
106
116
|
sf::VideoMode(size, Nan::To<std::uint32_t>(info[4]).FromJust()),
|
|
107
|
-
WindowTitle(info[3]),
|
|
117
|
+
WindowTitle(info[3]),
|
|
118
|
+
style,
|
|
119
|
+
static_cast<sf::State>(state),
|
|
120
|
+
settings);
|
|
108
121
|
} catch (const std::exception& error) {
|
|
109
122
|
sfmljs::ThrowError(error.what());
|
|
110
123
|
}
|
|
@@ -139,9 +152,10 @@ NAN_METHOD(TakeWindowNotification) {
|
|
|
139
152
|
const auto notification = notifications->front();
|
|
140
153
|
// Consume before calling any JS hook, including one which throws or reenters.
|
|
141
154
|
notifications->pop_front();
|
|
142
|
-
info.GetReturnValue().Set(
|
|
143
|
-
notification == sfmljs::WindowNotification::Create
|
|
144
|
-
|
|
155
|
+
info.GetReturnValue().Set(
|
|
156
|
+
Nan::New(notification == sfmljs::WindowNotification::Create ? "create"
|
|
157
|
+
: "resize")
|
|
158
|
+
.ToLocalChecked());
|
|
145
159
|
}
|
|
146
160
|
|
|
147
161
|
NAN_METHOD(IsWindowOpen) {
|
|
@@ -161,14 +175,16 @@ NAN_METHOD(GetWindowSize) {
|
|
|
161
175
|
|
|
162
176
|
NAN_METHOD(GetWindowPosition) {
|
|
163
177
|
auto* window = WindowHandle::From(info[0]);
|
|
164
|
-
if (window)
|
|
165
|
-
|
|
178
|
+
if (window)
|
|
179
|
+
info.GetReturnValue().Set(
|
|
180
|
+
sfmljs::EventValue(window->owner()->getPosition()));
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
NAN_METHOD(GetWindowNativeHandle) {
|
|
169
184
|
auto* window = WindowHandle::From(info[0]);
|
|
170
|
-
if (window)
|
|
171
|
-
|
|
185
|
+
if (window)
|
|
186
|
+
info.GetReturnValue().Set(
|
|
187
|
+
PointerValue(info.GetIsolate(), window->owner()->getNativeHandle()));
|
|
172
188
|
}
|
|
173
189
|
|
|
174
190
|
NAN_METHOD(HasWindowFocus) {
|
|
@@ -197,8 +213,8 @@ NAN_METHOD(WindowCommand) {
|
|
|
197
213
|
if (!info[2]->IsInt32() || !info[3]->IsInt32()) {
|
|
198
214
|
return Nan::ThrowTypeError("Expected integer coordinates");
|
|
199
215
|
}
|
|
200
|
-
window.setPosition(
|
|
201
|
-
|
|
216
|
+
window.setPosition(
|
|
217
|
+
{Nan::To<int>(info[2]).FromJust(), Nan::To<int>(info[3]).FromJust()});
|
|
202
218
|
} else if (command == "size" || command == "minimumSize" ||
|
|
203
219
|
command == "maximumSize") {
|
|
204
220
|
std::optional<sf::Vector2u> size;
|
|
@@ -207,9 +223,12 @@ NAN_METHOD(WindowCommand) {
|
|
|
207
223
|
if (!ReadSize(info[2], info[3], value)) return;
|
|
208
224
|
size = value;
|
|
209
225
|
}
|
|
210
|
-
if (command == "size")
|
|
211
|
-
|
|
212
|
-
else
|
|
226
|
+
if (command == "size")
|
|
227
|
+
window.setSize(*size);
|
|
228
|
+
else if (command == "minimumSize")
|
|
229
|
+
window.setMinimumSize(size);
|
|
230
|
+
else
|
|
231
|
+
window.setMaximumSize(size);
|
|
213
232
|
} else if (command == "title") {
|
|
214
233
|
if (!info[2]->IsString()) return Nan::ThrowTypeError("Expected title");
|
|
215
234
|
window.setTitle(WindowTitle(info[2]));
|
|
@@ -219,17 +238,24 @@ NAN_METHOD(WindowCommand) {
|
|
|
219
238
|
if (!info[2]->IsNumber()) return Nan::ThrowTypeError("Expected threshold");
|
|
220
239
|
window.setJoystickThreshold(Nan::To<double>(info[2]).FromJust());
|
|
221
240
|
} else if (command == "framerateLimit") {
|
|
222
|
-
if (!info[2]->IsUint32())
|
|
241
|
+
if (!info[2]->IsUint32())
|
|
242
|
+
return Nan::ThrowRangeError("Expected frame limit");
|
|
223
243
|
window.setFramerateLimit(Nan::To<std::uint32_t>(info[2]).FromJust());
|
|
224
244
|
} else {
|
|
225
245
|
if (!info[2]->IsBoolean()) return Nan::ThrowTypeError("Expected a boolean");
|
|
226
246
|
const bool value = info[2]->IsTrue();
|
|
227
|
-
if (command == "visible")
|
|
228
|
-
|
|
229
|
-
else if (command == "
|
|
230
|
-
|
|
231
|
-
else if (command == "
|
|
232
|
-
|
|
247
|
+
if (command == "visible")
|
|
248
|
+
window.setVisible(value);
|
|
249
|
+
else if (command == "cursorVisible")
|
|
250
|
+
window.setMouseCursorVisible(value);
|
|
251
|
+
else if (command == "cursorGrabbed")
|
|
252
|
+
window.setMouseCursorGrabbed(value);
|
|
253
|
+
else if (command == "keyRepeat")
|
|
254
|
+
window.setKeyRepeatEnabled(value);
|
|
255
|
+
else if (command == "verticalSync")
|
|
256
|
+
window.setVerticalSyncEnabled(value);
|
|
257
|
+
else
|
|
258
|
+
Nan::ThrowTypeError("Unknown window command");
|
|
233
259
|
}
|
|
234
260
|
}
|
|
235
261
|
|
|
@@ -289,7 +315,7 @@ NAN_METHOD(CreatePixelCursor) {
|
|
|
289
315
|
return Nan::ThrowTypeError("Expected cursor hotspot");
|
|
290
316
|
}
|
|
291
317
|
const sf::Vector2u hotspot{Nan::To<std::uint32_t>(info[3]).FromJust(),
|
|
292
|
-
|
|
318
|
+
Nan::To<std::uint32_t>(info[4]).FromJust()};
|
|
293
319
|
if (hotspot.x >= size.x || hotspot.y >= size.y) {
|
|
294
320
|
return Nan::ThrowRangeError("Cursor hotspot is outside the cursor");
|
|
295
321
|
}
|
|
@@ -326,21 +352,24 @@ NAN_METHOD(IsVideoModeValid) {
|
|
|
326
352
|
for (int i = 0; i < 3; ++i) {
|
|
327
353
|
if (!info[i]->IsUint32()) return Nan::ThrowRangeError("Invalid video mode");
|
|
328
354
|
}
|
|
329
|
-
info.GetReturnValue().Set(
|
|
330
|
-
{Nan::To<std::uint32_t>(info[0]).FromJust(),
|
|
331
|
-
|
|
332
|
-
|
|
355
|
+
info.GetReturnValue().Set(
|
|
356
|
+
sf::VideoMode({Nan::To<std::uint32_t>(info[0]).FromJust(),
|
|
357
|
+
Nan::To<std::uint32_t>(info[1]).FromJust()},
|
|
358
|
+
Nan::To<std::uint32_t>(info[2]).FromJust())
|
|
359
|
+
.isValid());
|
|
333
360
|
}
|
|
334
361
|
|
|
335
362
|
NAN_METHOD(CreateWindowVulkanSurface) {
|
|
336
363
|
auto* window = WindowHandle::From(info[0]);
|
|
337
364
|
if (!window) return;
|
|
338
365
|
std::uint64_t instance{}, allocator{};
|
|
339
|
-
if (!ReadPointer(info[1], instance) || !ReadPointer(info[2], allocator))
|
|
366
|
+
if (!ReadPointer(info[1], instance) || !ReadPointer(info[2], allocator))
|
|
367
|
+
return;
|
|
340
368
|
if (!instance) return Nan::ThrowRangeError("Expected a nonzero VkInstance");
|
|
341
369
|
VkSurfaceKHR surface{};
|
|
342
370
|
if (window->owner()->createVulkanSurface(
|
|
343
|
-
NativePointer<VkInstance>(instance),
|
|
371
|
+
NativePointer<VkInstance>(instance),
|
|
372
|
+
surface,
|
|
344
373
|
NativePointer<const VkAllocationCallbacks*>(allocator))) {
|
|
345
374
|
info.GetReturnValue().Set(PointerValue(info.GetIsolate(), surface));
|
|
346
375
|
}
|
|
@@ -384,5 +413,6 @@ NAN_MODULE_INIT(InitializeWindow) {
|
|
|
384
413
|
sfmljs::SetMethod<GetDesktopVideoMode>(target, "getDesktopVideoMode");
|
|
385
414
|
sfmljs::SetMethod<GetFullscreenVideoModes>(target, "getFullscreenVideoModes");
|
|
386
415
|
sfmljs::SetMethod<IsVideoModeValid>(target, "isVideoModeValid");
|
|
387
|
-
sfmljs::SetMethod<CreateWindowVulkanSurface>(target,
|
|
416
|
+
sfmljs::SetMethod<CreateWindowVulkanSurface>(target,
|
|
417
|
+
"createWindowVulkanSurface");
|
|
388
418
|
}
|
package/native/window-event.h
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <nan.h>
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
#include <type_traits>
|
|
6
6
|
|
|
7
|
+
#include <SFML/Window/Event.hpp>
|
|
8
|
+
|
|
7
9
|
namespace sfmljs {
|
|
8
10
|
|
|
9
11
|
template <typename T>
|
|
10
12
|
inline v8::Local<v8::Value> EventValue(T value) {
|
|
11
|
-
if constexpr (std::is_same_v<T, bool>)
|
|
12
|
-
|
|
13
|
+
if constexpr (std::is_same_v<T, bool>)
|
|
14
|
+
return Nan::New(value);
|
|
15
|
+
else
|
|
16
|
+
return Nan::New(static_cast<double>(value));
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
template <typename T>
|
|
@@ -34,8 +38,10 @@ inline v8::Local<v8::Object> WindowEvent(const sf::Event& event) {
|
|
|
34
38
|
event.visit([&](const auto& data) {
|
|
35
39
|
using T = std::decay_t<decltype(data)>;
|
|
36
40
|
const char* kind;
|
|
37
|
-
#define EVENT_KIND(name)
|
|
38
|
-
|
|
41
|
+
#define EVENT_KIND(name) \
|
|
42
|
+
if constexpr (std::is_same_v<T, sf::Event::name>) \
|
|
43
|
+
kind = #name; \
|
|
44
|
+
else
|
|
39
45
|
EVENT_KIND(Closed)
|
|
40
46
|
EVENT_KIND(Resized)
|
|
41
47
|
EVENT_KIND(FocusLost)
|
|
@@ -61,12 +67,15 @@ inline v8::Local<v8::Object> WindowEvent(const sf::Event& event) {
|
|
|
61
67
|
EVENT_KIND(SensorChanged)
|
|
62
68
|
static_assert(!sizeof(T), "Unmapped SFML event subtype");
|
|
63
69
|
#undef EVENT_KIND
|
|
64
|
-
Nan::Set(result,
|
|
65
|
-
Nan::New(kind).ToLocalChecked()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
Nan::Set(result,
|
|
71
|
+
Nan::New("kind").ToLocalChecked(),
|
|
72
|
+
Nan::New(kind).ToLocalChecked())
|
|
73
|
+
.FromJust();
|
|
74
|
+
#define EVENT_FIELD(name) \
|
|
75
|
+
if constexpr (requires { data.name; }) { \
|
|
76
|
+
Nan::Set(result, Nan::New(#name).ToLocalChecked(), EventValue(data.name)) \
|
|
77
|
+
.FromJust(); \
|
|
78
|
+
}
|
|
70
79
|
EVENT_FIELD(size)
|
|
71
80
|
EVENT_FIELD(unicode)
|
|
72
81
|
EVENT_FIELD(code)
|
package/native/window-owner.h
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <deque>
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
3
6
|
#include "shared-handle.h"
|
|
4
7
|
#include <SFML/Window/Cursor.hpp>
|
|
5
8
|
#include <SFML/Window/Window.hpp>
|
|
6
|
-
#include <deque>
|
|
7
|
-
#include <memory>
|
|
8
9
|
|
|
9
10
|
namespace sfmljs {
|
|
10
11
|
|
|
@@ -49,23 +50,25 @@ template <typename T>
|
|
|
49
50
|
v8::Local<v8::Object> MakeWindowHandle(const std::shared_ptr<T>& owner) {
|
|
50
51
|
auto handle = SharedHandle<sf::Window>::Create(owner);
|
|
51
52
|
// This member pointer stays valid for as long as the owning handle exists.
|
|
52
|
-
Nan::SetPrivate(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
Nan::SetPrivate(
|
|
54
|
+
handle, WindowCursorKey(), Nan::New<v8::External>(&owner->cursor))
|
|
55
|
+
.FromJust();
|
|
56
|
+
Nan::SetPrivate(handle,
|
|
57
|
+
WindowNotificationsKey(),
|
|
58
|
+
Nan::New<v8::External>(&owner->notifications))
|
|
59
|
+
.FromJust();
|
|
56
60
|
return handle;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
inline WindowNotifications* GetWindowNotifications(v8::Local<v8::Value> value) {
|
|
60
64
|
if (!SharedHandle<sf::Window>::From(value)) return nullptr;
|
|
61
|
-
auto slot = Nan::GetPrivate(value.As<v8::Object>(),
|
|
62
|
-
|
|
65
|
+
auto slot = Nan::GetPrivate(value.As<v8::Object>(), WindowNotificationsKey())
|
|
66
|
+
.ToLocalChecked();
|
|
63
67
|
if (!slot->IsExternal()) {
|
|
64
68
|
Nan::ThrowTypeError("Expected an owned window handle");
|
|
65
69
|
return nullptr;
|
|
66
70
|
}
|
|
67
|
-
return static_cast<WindowNotifications*>(
|
|
68
|
-
slot.As<v8::External>()->Value());
|
|
71
|
+
return static_cast<WindowNotifications*>(slot.As<v8::External>()->Value());
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
inline void RetainWindowCursor(v8::Local<v8::Object> handle,
|
|
@@ -74,8 +77,8 @@ inline void RetainWindowCursor(v8::Local<v8::Object> handle,
|
|
|
74
77
|
if (!slot->IsExternal()) {
|
|
75
78
|
return Nan::ThrowTypeError("Expected an owned window handle");
|
|
76
79
|
}
|
|
77
|
-
*static_cast<std::shared_ptr<sf::Cursor>*>(
|
|
78
|
-
|
|
80
|
+
*static_cast<std::shared_ptr<sf::Cursor>*>(slot.As<v8::External>()->Value()) =
|
|
81
|
+
std::move(cursor);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
} // namespace sfmljs
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfml.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "SFML's Node.js binding.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/XadillaX/
|
|
7
|
+
"url": "git+https://github.com/XadillaX/sfml.js.git",
|
|
8
|
+
"directory": "packages/sfml.js"
|
|
8
9
|
},
|
|
9
10
|
"author": "XadillaX <i@2333.moe>",
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/XadillaX/
|
|
13
|
+
"url": "https://github.com/XadillaX/sfml.js/issues"
|
|
13
14
|
},
|
|
14
|
-
"homepage": "https://
|
|
15
|
+
"homepage": "https://sfml.js.org",
|
|
15
16
|
"type": "commonjs",
|
|
16
17
|
"main": "./dist/index.js",
|
|
17
18
|
"types": "./dist/index.d.ts",
|
|
@@ -21,62 +22,21 @@
|
|
|
21
22
|
"default": "./dist/index.js"
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"install": "npm run build:native",
|
|
26
|
-
"prepare": "npm run build:ts",
|
|
27
|
-
"download:sfml": "node tools/lib_downloader.cjs",
|
|
28
|
-
"generate:window": "node tools/generate-window-constants.cjs",
|
|
29
|
-
"generate:network": "node tools/generate-network-constants.cjs",
|
|
30
|
-
"prebuild:native": "npm run download:sfml",
|
|
31
|
-
"build:native": "npm run generate:window && node-gyp rebuild",
|
|
32
|
-
"postbuild:native": "npm run configure:lsp",
|
|
33
|
-
"configure:lsp": "node tools/configure-lsp.cjs",
|
|
34
|
-
"prebuild:ts": "npm run download:sfml",
|
|
35
|
-
"build:ts": "npm run generate:window && npm run generate:network && tsc -p tsconfig.json",
|
|
36
|
-
"build": "npm run build:native && npm run build:ts",
|
|
37
|
-
"build:docs": "npm --prefix site run build",
|
|
38
|
-
"build:reference": "node tools/typedoc/build.mjs",
|
|
39
|
-
"docs:dev": "npm --prefix site run dev --",
|
|
40
|
-
"docs:preview": "npm --prefix site run preview --",
|
|
41
|
-
"demo": "npm run build && node examples/sprites.cjs",
|
|
42
|
-
"demo:breakout": "npm run build && node examples/breakout.cjs",
|
|
43
|
-
"demo:types": "npm run build && node examples/all-types.cjs",
|
|
44
|
-
"demo:image": "npm run build && node examples/image.cjs",
|
|
45
|
-
"demo:texture": "npm run build && node examples/texture.cjs",
|
|
46
|
-
"demo:sprite": "npm run build && node examples/sprite.cjs",
|
|
47
|
-
"demo:render-texture": "npm run build && node examples/render-texture.cjs",
|
|
48
|
-
"demo:drawable": "npm run build && node examples/drawable.cjs",
|
|
49
|
-
"demo:vertices": "npm run build && node examples/vertex-array.cjs",
|
|
50
|
-
"demo:text": "npm run build && node examples/text.cjs",
|
|
51
|
-
"demo:window": "npm run build && node examples/window.cjs",
|
|
52
|
-
"demo:system-window": "npm run build && node examples/system-window.cjs",
|
|
53
|
-
"demo:sleep-err": "npm run build && node examples/sleep-err.cjs",
|
|
54
|
-
"demo:audio": "npm run build && node examples/audio.cjs",
|
|
55
|
-
"demo:network": "npm run build:ts && node examples/network.cjs",
|
|
56
|
-
"demo:ported": "npm run build:ts && node examples/ported/render_window.cjs",
|
|
57
|
-
"lint": "eslint --ext .ts,.js,.cjs,.mjs . && eslint --no-ignore site/.vitepress/theme/hero-light.mjs",
|
|
58
|
-
"jslint": "npm run lint",
|
|
59
|
-
"test:types": "tsc -p test/tsconfig.json",
|
|
60
|
-
"test:runtime": "node tools/run-tests.cjs",
|
|
61
|
-
"test": "npm run lint && npm run build && npm run test:types && npm run test:runtime"
|
|
62
|
-
},
|
|
63
25
|
"files": [
|
|
64
26
|
"binding.gyp",
|
|
65
27
|
"dist/",
|
|
66
28
|
"native/",
|
|
67
29
|
"src/",
|
|
68
30
|
"test/native/",
|
|
69
|
-
"tools/lib_downloader*.cjs",
|
|
70
31
|
"tools/generate-*-constants.cjs",
|
|
71
32
|
"tools/constant-docs.cjs",
|
|
72
33
|
"tools/constant-docs.json",
|
|
73
|
-
"tools/configure-lsp.cjs",
|
|
74
34
|
"tsconfig.json",
|
|
75
|
-
"docs/",
|
|
76
35
|
"assets/branding/sfml-js-symbol-pentagon.svg",
|
|
77
36
|
"assets/branding/sfml-js-wordmark.svg",
|
|
78
37
|
"assets/branding/sfml-js-wordmark-dark.svg",
|
|
79
|
-
"assets/breakout.png"
|
|
38
|
+
"assets/breakout.png",
|
|
39
|
+
"tools/ensure-sfml.cjs"
|
|
80
40
|
],
|
|
81
41
|
"engines": {
|
|
82
42
|
"node": "^18.19.0 || >=20.5.0"
|
|
@@ -87,7 +47,8 @@
|
|
|
87
47
|
"ipaddr.js": "2.5.0",
|
|
88
48
|
"nan": "2.29.0",
|
|
89
49
|
"node-gyp": "11.5.0",
|
|
90
|
-
"ssh2": "1.17.0"
|
|
50
|
+
"ssh2": "1.17.0",
|
|
51
|
+
"sfml.js-interop": "^1.2.1"
|
|
91
52
|
},
|
|
92
53
|
"devDependencies": {
|
|
93
54
|
"@types/node": "20.19.0",
|
|
@@ -95,14 +56,46 @@
|
|
|
95
56
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
96
57
|
"@typescript-eslint/parser": "^7.18.0",
|
|
97
58
|
"@wettstein/nodegl": "1.2.1",
|
|
59
|
+
"cpplint.js": "2.0.1",
|
|
98
60
|
"eslint": "^8.57.1",
|
|
99
61
|
"eslint-config-egg": "^14.1.0",
|
|
100
62
|
"eslint-plugin-import": "^2.32.0",
|
|
101
63
|
"eslint-plugin-jsdoc": "^46.9.1",
|
|
102
64
|
"eslint-plugin-node": "^11.1.0",
|
|
103
|
-
"typedoc": "0.28.3",
|
|
104
|
-
"typedoc-material-theme": "1.4.0",
|
|
105
65
|
"typescript": "5.0.4",
|
|
106
66
|
"x11": "4.3.1"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"download:sfml": "node tools/ensure-sfml.cjs",
|
|
70
|
+
"generate:window": "node tools/generate-window-constants.cjs",
|
|
71
|
+
"generate:network": "node tools/generate-network-constants.cjs",
|
|
72
|
+
"prebuild:native": "npm run download:sfml",
|
|
73
|
+
"build:native": "npm run generate:window && node ../../tools/native-build.cjs",
|
|
74
|
+
"postbuild:native": "node ../../tools/configure-lsp.cjs",
|
|
75
|
+
"prebuild:ts": "npm run download:sfml",
|
|
76
|
+
"build:ts": "npm run generate:window && npm run generate:network && tsc -p tsconfig.json",
|
|
77
|
+
"build": "npm run build:native && npm run build:ts",
|
|
78
|
+
"demo": "npm run build && node examples/sprites.cjs",
|
|
79
|
+
"demo:breakout": "npm run build && node examples/breakout.cjs",
|
|
80
|
+
"demo:types": "npm run build && node examples/all-types.cjs",
|
|
81
|
+
"demo:image": "npm run build && node examples/image.cjs",
|
|
82
|
+
"demo:texture": "npm run build && node examples/texture.cjs",
|
|
83
|
+
"demo:sprite": "npm run build && node examples/sprite.cjs",
|
|
84
|
+
"demo:render-texture": "npm run build && node examples/render-texture.cjs",
|
|
85
|
+
"demo:drawable": "npm run build && node examples/drawable.cjs",
|
|
86
|
+
"demo:vertices": "npm run build && node examples/vertex-array.cjs",
|
|
87
|
+
"demo:text": "npm run build && node examples/text.cjs",
|
|
88
|
+
"demo:window": "npm run build && node examples/window.cjs",
|
|
89
|
+
"demo:system-window": "npm run build && node examples/system-window.cjs",
|
|
90
|
+
"demo:sleep-err": "npm run build && node examples/sleep-err.cjs",
|
|
91
|
+
"demo:audio": "npm run build && node examples/audio.cjs",
|
|
92
|
+
"demo:network": "npm run build:ts && node examples/network.cjs",
|
|
93
|
+
"demo:ported": "npm run build:ts && node examples/ported/render_window.cjs",
|
|
94
|
+
"lint": "eslint --ext .ts,.js,.cjs,.mjs .",
|
|
95
|
+
"jslint": "npm run lint",
|
|
96
|
+
"cpplint": "cpplint native/*.cc native/*.h test/native/*.cc test/native/*.h",
|
|
97
|
+
"test:types": "tsc -p test/tsconfig.json",
|
|
98
|
+
"test:runtime": "node tools/run-tests.cjs",
|
|
99
|
+
"test": "npm run lint && npm run build && npm run test:types && npm run test:runtime"
|
|
107
100
|
}
|
|
108
|
-
}
|
|
101
|
+
}
|