sfml.js 1.0.0 → 1.1.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 +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 +40 -48
- 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
|
@@ -55,16 +55,18 @@ class FileInputStream extends input_stream_1.InputStream {
|
|
|
55
55
|
}
|
|
56
56
|
return this.enqueue(() => {
|
|
57
57
|
const file = this.file;
|
|
58
|
-
if (!file)
|
|
58
|
+
if (!file) {
|
|
59
59
|
return undefined;
|
|
60
|
+
}
|
|
60
61
|
if (!Number.isSafeInteger(this.position + data.byteLength)) {
|
|
61
62
|
throw new RangeError('Read exceeds Node filesystem offset precision');
|
|
62
63
|
}
|
|
63
64
|
// FileHandle owns the fd; the queue retains it until this read finishes.
|
|
64
65
|
return new Promise(resolve => {
|
|
65
66
|
(0, node_fs_1.read)(file.fd, data, 0, data.byteLength, this.position, (error, bytesRead) => {
|
|
66
|
-
if (error)
|
|
67
|
+
if (error) {
|
|
67
68
|
return resolve(undefined);
|
|
69
|
+
}
|
|
68
70
|
this.position += bytesRead;
|
|
69
71
|
resolve(BigInt(bytesRead));
|
|
70
72
|
});
|
|
@@ -87,8 +89,9 @@ class FileInputStream extends input_stream_1.InputStream {
|
|
|
87
89
|
throw new RangeError('Expected an offset from 0 to 2^53 - 1');
|
|
88
90
|
}
|
|
89
91
|
return this.enqueue(() => {
|
|
90
|
-
if (!this.file)
|
|
92
|
+
if (!this.file) {
|
|
91
93
|
return undefined;
|
|
94
|
+
}
|
|
92
95
|
this.position = Number(position);
|
|
93
96
|
return position;
|
|
94
97
|
});
|
|
@@ -114,8 +117,9 @@ class FileInputStream extends input_stream_1.InputStream {
|
|
|
114
117
|
*/
|
|
115
118
|
getSize() {
|
|
116
119
|
return this.enqueue(async () => {
|
|
117
|
-
if (!this.file)
|
|
120
|
+
if (!this.file) {
|
|
118
121
|
return undefined;
|
|
122
|
+
}
|
|
119
123
|
try {
|
|
120
124
|
return (await this.file.stat({ bigint: true })).size;
|
|
121
125
|
}
|
|
@@ -29,8 +29,9 @@ class MemoryInputStream extends InputStream {
|
|
|
29
29
|
constructor(data) {
|
|
30
30
|
super();
|
|
31
31
|
this.position = 0;
|
|
32
|
-
if (data !== undefined)
|
|
32
|
+
if (data !== undefined) {
|
|
33
33
|
this.open(data);
|
|
34
|
+
}
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Retain data by reference and reset the read position to zero without
|
|
@@ -57,8 +58,9 @@ class MemoryInputStream extends InputStream {
|
|
|
57
58
|
* 스트림 끝에서는 0n, 열리지 않은 경우 undefined를 반환한다.
|
|
58
59
|
*/
|
|
59
60
|
read(destination) {
|
|
60
|
-
if (!this.data)
|
|
61
|
+
if (!this.data) {
|
|
61
62
|
return undefined;
|
|
63
|
+
}
|
|
62
64
|
const count = Math.min(destination.length, this.data.length - this.position);
|
|
63
65
|
destination.set(this.data.subarray(this.position, this.position + count));
|
|
64
66
|
this.position += count;
|
|
@@ -78,8 +80,9 @@ class MemoryInputStream extends InputStream {
|
|
|
78
80
|
if (typeof position !== 'bigint' || position < 0n) {
|
|
79
81
|
throw new RangeError('Expected a non-negative bigint position');
|
|
80
82
|
}
|
|
81
|
-
if (!this.data)
|
|
83
|
+
if (!this.data) {
|
|
82
84
|
return undefined;
|
|
85
|
+
}
|
|
83
86
|
this.position = Number(position > BigInt(this.data.length)
|
|
84
87
|
? BigInt(this.data.length) : position);
|
|
85
88
|
return BigInt(this.position);
|
|
@@ -12,7 +12,7 @@ import { IpAddress } from '../network/ip-address';
|
|
|
12
12
|
import { Bvec2, Bvec3 } from '../graphics/boolean-vector';
|
|
13
13
|
import { type ScalarType, type Scalar } from '../internal/scalar';
|
|
14
14
|
import { type ReadonlyValue as R } from '../internal/value-storage';
|
|
15
|
-
type Intersect<U> = (U extends unknown ? (value: U) => void : never) extends (
|
|
15
|
+
type Intersect<U> = (U extends unknown ? (value: U) => void : never) extends (value: infer I) => void ? I : never;
|
|
16
16
|
type VectorAddition = Intersect<{
|
|
17
17
|
[T in ScalarType]: {
|
|
18
18
|
(left: R<Vector2<T>>, right: R<Vector2<T>>): Vector2<T>;
|
package/dist/system/operators.js
CHANGED
|
@@ -17,23 +17,30 @@ const glsl_value_1 = require("../internal/glsl-value");
|
|
|
17
17
|
const scalar_1 = require("../internal/scalar");
|
|
18
18
|
const value_storage_1 = require("../internal/value-storage");
|
|
19
19
|
function storage(value) {
|
|
20
|
-
if (value instanceof boolean_vector_1.BooleanVector)
|
|
20
|
+
if (value instanceof boolean_vector_1.BooleanVector) {
|
|
21
21
|
return value[glsl_value_1.glslStorage];
|
|
22
|
-
|
|
22
|
+
}
|
|
23
|
+
if (value instanceof color_1.Color) {
|
|
23
24
|
return value[value_storage_1.colorStorage];
|
|
24
|
-
|
|
25
|
+
}
|
|
26
|
+
if (value instanceof angle_1.Angle) {
|
|
25
27
|
return value[value_storage_1.angleStorage];
|
|
26
|
-
|
|
28
|
+
}
|
|
29
|
+
if (value instanceof vector2_1.Vector2) {
|
|
27
30
|
return value[value_storage_1.vector2Storage];
|
|
28
|
-
|
|
31
|
+
}
|
|
32
|
+
if (value instanceof vector3_1.Vector3) {
|
|
29
33
|
return value[value_storage_1.vector3Storage];
|
|
34
|
+
}
|
|
30
35
|
throw new TypeError('Expected an Angle, Color, Vector2 or Vector3');
|
|
31
36
|
}
|
|
32
37
|
function scalarType(value) {
|
|
33
|
-
if (value instanceof boolean_vector_1.BooleanVector)
|
|
38
|
+
if (value instanceof boolean_vector_1.BooleanVector) {
|
|
34
39
|
return 'bool';
|
|
35
|
-
|
|
40
|
+
}
|
|
41
|
+
if (value instanceof angle_1.Angle) {
|
|
36
42
|
return 'f32';
|
|
43
|
+
}
|
|
37
44
|
if (value instanceof vector2_1.Vector2 || value instanceof vector3_1.Vector3) {
|
|
38
45
|
return value.scalarType;
|
|
39
46
|
}
|
|
@@ -58,32 +65,45 @@ function checkPair(left, right) {
|
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
function copy(value) {
|
|
61
|
-
if (value instanceof boolean_vector_1.Bvec2)
|
|
68
|
+
if (value instanceof boolean_vector_1.Bvec2) {
|
|
62
69
|
return new boolean_vector_1.Bvec2(value);
|
|
63
|
-
|
|
70
|
+
}
|
|
71
|
+
if (value instanceof boolean_vector_1.Bvec3) {
|
|
64
72
|
return new boolean_vector_1.Bvec3(value);
|
|
65
|
-
|
|
73
|
+
}
|
|
74
|
+
if (value instanceof time_1.Time) {
|
|
66
75
|
return new time_1.Time(value);
|
|
67
|
-
|
|
76
|
+
}
|
|
77
|
+
if (value instanceof color_1.Color) {
|
|
68
78
|
return new color_1.Color(value);
|
|
69
|
-
|
|
79
|
+
}
|
|
80
|
+
if (value instanceof angle_1.Angle) {
|
|
70
81
|
return new angle_1.Angle(value);
|
|
71
|
-
|
|
82
|
+
}
|
|
83
|
+
if (value instanceof vector2_1.Vector2i) {
|
|
72
84
|
return new vector2_1.Vector2i(value);
|
|
73
|
-
|
|
85
|
+
}
|
|
86
|
+
if (value instanceof vector2_1.Vector2u) {
|
|
74
87
|
return new vector2_1.Vector2u(value);
|
|
75
|
-
|
|
88
|
+
}
|
|
89
|
+
if (value instanceof vector2_1.Vector2f) {
|
|
76
90
|
return new vector2_1.Vector2f(value);
|
|
77
|
-
|
|
91
|
+
}
|
|
92
|
+
if (value instanceof vector3_1.Vector3i) {
|
|
78
93
|
return new vector3_1.Vector3i(value);
|
|
79
|
-
|
|
94
|
+
}
|
|
95
|
+
if (value instanceof vector3_1.Vector3u) {
|
|
80
96
|
return new vector3_1.Vector3u(value);
|
|
81
|
-
|
|
97
|
+
}
|
|
98
|
+
if (value instanceof vector3_1.Vector3f) {
|
|
82
99
|
return new vector3_1.Vector3f(value);
|
|
83
|
-
|
|
100
|
+
}
|
|
101
|
+
if (value instanceof vector2_1.Vector2) {
|
|
84
102
|
return new vector2_1.Vector2(value);
|
|
85
|
-
|
|
103
|
+
}
|
|
104
|
+
if (value instanceof vector3_1.Vector3) {
|
|
86
105
|
return new vector3_1.Vector3(value);
|
|
106
|
+
}
|
|
87
107
|
throw new TypeError('Expected an Angle, Color, Vector2 or Vector3');
|
|
88
108
|
}
|
|
89
109
|
function checkMutable(value) {
|
|
@@ -102,11 +122,14 @@ function combine(left, right, operation) {
|
|
|
102
122
|
}
|
|
103
123
|
const leftData = storage(left);
|
|
104
124
|
const rightData = storage(right);
|
|
105
|
-
if (leftData instanceof BigInt64Array ||
|
|
125
|
+
if (leftData instanceof BigInt64Array ||
|
|
126
|
+
leftData instanceof BigUint64Array) {
|
|
106
127
|
const b = rightData;
|
|
107
128
|
for (let index = 0; index < leftData.length; index++) {
|
|
108
|
-
leftData[index] =
|
|
109
|
-
|
|
129
|
+
leftData[index] =
|
|
130
|
+
operation === 'add'
|
|
131
|
+
? leftData[index] + b[index]
|
|
132
|
+
: leftData[index] - b[index];
|
|
110
133
|
}
|
|
111
134
|
return left;
|
|
112
135
|
}
|
|
@@ -115,10 +138,12 @@ function combine(left, right, operation) {
|
|
|
115
138
|
const isColor = left instanceof color_1.Color;
|
|
116
139
|
const isBoolean = left instanceof boolean_vector_1.BooleanVector;
|
|
117
140
|
for (let index = 0; index < a.length; index++) {
|
|
118
|
-
const result = operation === 'add'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
: isBoolean
|
|
141
|
+
const result = operation === 'add' ? a[index] + b[index] : a[index] - b[index];
|
|
142
|
+
a[index] = isColor
|
|
143
|
+
? Math.min(255, Math.max(0, result))
|
|
144
|
+
: isBoolean
|
|
145
|
+
? Number(result !== 0)
|
|
146
|
+
: result;
|
|
122
147
|
}
|
|
123
148
|
return left;
|
|
124
149
|
}
|
|
@@ -131,7 +156,7 @@ function modulate(left, right) {
|
|
|
131
156
|
const b = right[value_storage_1.colorStorage];
|
|
132
157
|
for (let index = 0; index < 4; index++) {
|
|
133
158
|
// Uint8Array truncates the nonnegative quotient, matching SFML.
|
|
134
|
-
a[index] = a[index] * b[index] / 255;
|
|
159
|
+
a[index] = (a[index] * b[index]) / 255;
|
|
135
160
|
}
|
|
136
161
|
return left;
|
|
137
162
|
}
|
|
@@ -144,13 +169,15 @@ function scale(left, right, operation) {
|
|
|
144
169
|
if (operation === 'divide' && !right) {
|
|
145
170
|
throw new RangeError('Cannot divide by zero');
|
|
146
171
|
}
|
|
147
|
-
if (!right)
|
|
172
|
+
if (!right) {
|
|
148
173
|
left[glsl_value_1.glslStorage].fill(0);
|
|
174
|
+
}
|
|
149
175
|
return left;
|
|
150
176
|
}
|
|
151
177
|
if (left instanceof time_1.Time) {
|
|
152
|
-
if (typeof right === 'boolean')
|
|
178
|
+
if (typeof right === 'boolean') {
|
|
153
179
|
throw new TypeError('Expected a scalar');
|
|
180
|
+
}
|
|
154
181
|
left[value_storage_1.timeStorage] = (0, time_1.scaleTime)(left, right, operation);
|
|
155
182
|
return left;
|
|
156
183
|
}
|
|
@@ -159,28 +186,33 @@ function scale(left, right, operation) {
|
|
|
159
186
|
}
|
|
160
187
|
const type = scalarType(left);
|
|
161
188
|
if ((0, scalar_1.isBigIntScalar)(type)) {
|
|
162
|
-
if (typeof right !== 'bigint')
|
|
189
|
+
if (typeof right !== 'bigint') {
|
|
163
190
|
throw new TypeError('Expected a bigint scalar');
|
|
191
|
+
}
|
|
164
192
|
const scalar = (0, scalar_1.convertScalar)(type, right);
|
|
165
193
|
if (operation === 'divide' && scalar === 0n) {
|
|
166
194
|
throw new RangeError('Cannot divide by zero');
|
|
167
195
|
}
|
|
168
196
|
const data = storage(left);
|
|
169
197
|
for (let i = 0; i < data.length; i++) {
|
|
170
|
-
data[i] =
|
|
198
|
+
data[i] =
|
|
199
|
+
operation === 'multiply' ? data[i] * scalar : data[i] / scalar;
|
|
171
200
|
}
|
|
172
201
|
return left;
|
|
173
202
|
}
|
|
174
|
-
if (typeof right !== 'number')
|
|
203
|
+
if (typeof right !== 'number') {
|
|
175
204
|
throw new TypeError('Expected a scalar');
|
|
205
|
+
}
|
|
176
206
|
const scalar = (0, scalar_1.toScalar)(type, right);
|
|
177
207
|
if (operation === 'divide' && scalar === 0) {
|
|
178
208
|
throw new RangeError('Cannot divide by zero');
|
|
179
209
|
}
|
|
180
210
|
const a = storage(left);
|
|
181
211
|
for (let index = 0; index < a.length; index++) {
|
|
182
|
-
a[index] =
|
|
183
|
-
|
|
212
|
+
a[index] =
|
|
213
|
+
operation === 'multiply'
|
|
214
|
+
? (0, scalar_1.scalarProduct)(type, a[index], scalar)
|
|
215
|
+
: a[index] / scalar;
|
|
184
216
|
}
|
|
185
217
|
return left;
|
|
186
218
|
}
|
|
@@ -240,8 +272,9 @@ exports.negate = ((value) => {
|
|
|
240
272
|
}
|
|
241
273
|
const data = storage(result);
|
|
242
274
|
if (!(result instanceof boolean_vector_1.BooleanVector)) {
|
|
243
|
-
for (let index = 0; index < data.length; index++)
|
|
275
|
+
for (let index = 0; index < data.length; index++) {
|
|
244
276
|
data[index] = -data[index];
|
|
277
|
+
}
|
|
245
278
|
}
|
|
246
279
|
return result;
|
|
247
280
|
});
|
|
@@ -256,8 +289,9 @@ exports.negate = ((value) => {
|
|
|
256
289
|
*/
|
|
257
290
|
exports.multiply = ((left, right) => {
|
|
258
291
|
if (left instanceof transform_1.Transform) {
|
|
259
|
-
if (right instanceof transform_1.Transform)
|
|
292
|
+
if (right instanceof transform_1.Transform) {
|
|
260
293
|
return new transform_1.Transform(left).combine(right);
|
|
294
|
+
}
|
|
261
295
|
if (right instanceof vector2_1.Vector2 && right.scalarType === 'f32') {
|
|
262
296
|
return left.transformPoint(right);
|
|
263
297
|
}
|
|
@@ -269,9 +303,11 @@ exports.multiply = ((left, right) => {
|
|
|
269
303
|
if (left instanceof color_1.Color && right instanceof color_1.Color) {
|
|
270
304
|
return modulate(new color_1.Color(left), right);
|
|
271
305
|
}
|
|
272
|
-
const leftScalar = typeof left === 'number' ||
|
|
306
|
+
const leftScalar = typeof left === 'number' ||
|
|
307
|
+
typeof left === 'bigint' ||
|
|
273
308
|
typeof left === 'boolean';
|
|
274
|
-
const rightScalar = typeof right === 'number' ||
|
|
309
|
+
const rightScalar = typeof right === 'number' ||
|
|
310
|
+
typeof right === 'bigint' ||
|
|
275
311
|
typeof right === 'boolean';
|
|
276
312
|
if (leftScalar && !rightScalar) {
|
|
277
313
|
return scale(copy(right), left, 'multiply');
|
|
@@ -302,7 +338,8 @@ exports.multiplyAssign = ((left, right) => {
|
|
|
302
338
|
if (left instanceof color_1.Color || right instanceof color_1.Color) {
|
|
303
339
|
return modulate(left, right);
|
|
304
340
|
}
|
|
305
|
-
if (typeof right !== 'number' &&
|
|
341
|
+
if (typeof right !== 'number' &&
|
|
342
|
+
typeof right !== 'bigint' &&
|
|
306
343
|
typeof right !== 'boolean') {
|
|
307
344
|
throw new TypeError('Expected a scalar');
|
|
308
345
|
}
|
|
@@ -326,7 +363,8 @@ exports.divideAssign = ((left, right) => scale(left, right, 'divide'));
|
|
|
326
363
|
* 수치 비율을 반환한다.
|
|
327
364
|
*/
|
|
328
365
|
exports.divide = ((left, right) => {
|
|
329
|
-
if (typeof right === 'number' ||
|
|
366
|
+
if (typeof right === 'number' ||
|
|
367
|
+
typeof right === 'bigint' ||
|
|
330
368
|
typeof right === 'boolean') {
|
|
331
369
|
return scale(copy(left), right, 'divide');
|
|
332
370
|
}
|
|
@@ -342,8 +380,9 @@ exports.divide = ((left, right) => {
|
|
|
342
380
|
if (!(left instanceof angle_1.Angle) || !(right instanceof angle_1.Angle)) {
|
|
343
381
|
throw new TypeError('Only two angles can be divided to obtain a ratio');
|
|
344
382
|
}
|
|
345
|
-
if (right.asRadians() === 0)
|
|
383
|
+
if (right.asRadians() === 0) {
|
|
346
384
|
throw new RangeError('Cannot divide by zero');
|
|
385
|
+
}
|
|
347
386
|
return Math.fround(left.asRadians() / right.asRadians());
|
|
348
387
|
});
|
|
349
388
|
function modulo(left, right) {
|
|
@@ -386,22 +425,22 @@ function equals(left, right) {
|
|
|
386
425
|
if (!(left instanceof blend_mode_1.BlendMode) || !(right instanceof blend_mode_1.BlendMode)) {
|
|
387
426
|
throw new TypeError('BlendMode equality requires two blend modes');
|
|
388
427
|
}
|
|
389
|
-
return left.colorSrcFactor === right.colorSrcFactor &&
|
|
428
|
+
return (left.colorSrcFactor === right.colorSrcFactor &&
|
|
390
429
|
left.colorDstFactor === right.colorDstFactor &&
|
|
391
430
|
left.colorEquation === right.colorEquation &&
|
|
392
431
|
left.alphaSrcFactor === right.alphaSrcFactor &&
|
|
393
432
|
left.alphaDstFactor === right.alphaDstFactor &&
|
|
394
|
-
left.alphaEquation === right.alphaEquation;
|
|
433
|
+
left.alphaEquation === right.alphaEquation);
|
|
395
434
|
}
|
|
396
435
|
if (left instanceof stencil_mode_1.StencilMode || right instanceof stencil_mode_1.StencilMode) {
|
|
397
436
|
if (!(left instanceof stencil_mode_1.StencilMode) || !(right instanceof stencil_mode_1.StencilMode)) {
|
|
398
437
|
throw new TypeError('StencilMode equality requires two stencil modes');
|
|
399
438
|
}
|
|
400
|
-
return left.stencilComparison === right.stencilComparison &&
|
|
439
|
+
return (left.stencilComparison === right.stencilComparison &&
|
|
401
440
|
left.stencilUpdateOperation === right.stencilUpdateOperation &&
|
|
402
441
|
left.stencilReference.value === right.stencilReference.value &&
|
|
403
442
|
left.stencilMask.value === right.stencilMask.value &&
|
|
404
|
-
left.stencilOnly === right.stencilOnly;
|
|
443
|
+
left.stencilOnly === right.stencilOnly);
|
|
405
444
|
}
|
|
406
445
|
if (left instanceof transform_1.Transform || right instanceof transform_1.Transform) {
|
|
407
446
|
if (!(left instanceof transform_1.Transform) || !(right instanceof transform_1.Transform)) {
|
|
@@ -412,14 +451,14 @@ function equals(left, right) {
|
|
|
412
451
|
return transformElements.every(index => a[index] === b[index]);
|
|
413
452
|
}
|
|
414
453
|
if (left instanceof rect_1.Rect || right instanceof rect_1.Rect) {
|
|
415
|
-
if (!(left instanceof rect_1.Rect) ||
|
|
454
|
+
if (!(left instanceof rect_1.Rect) ||
|
|
455
|
+
!(right instanceof rect_1.Rect) ||
|
|
416
456
|
left.scalarType !== right.scalarType) {
|
|
417
457
|
throw new TypeError('Rect operands must have the same scalar type');
|
|
418
458
|
}
|
|
419
459
|
const a = left[value_storage_1.rectStorage];
|
|
420
460
|
const b = right[value_storage_1.rectStorage];
|
|
421
|
-
return a[0] === b[0] && a[1] === b[1] &&
|
|
422
|
-
a[2] === b[2] && a[3] === b[3];
|
|
461
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
|
|
423
462
|
}
|
|
424
463
|
checkPair(left, right);
|
|
425
464
|
if (left instanceof time_1.Time && right instanceof time_1.Time) {
|
|
@@ -428,8 +467,9 @@ function equals(left, right) {
|
|
|
428
467
|
const a = storage(left);
|
|
429
468
|
const b = storage(right);
|
|
430
469
|
for (let index = 0; index < a.length; index++) {
|
|
431
|
-
if (a[index] !== b[index])
|
|
470
|
+
if (a[index] !== b[index]) {
|
|
432
471
|
return false;
|
|
472
|
+
}
|
|
433
473
|
}
|
|
434
474
|
return true;
|
|
435
475
|
}
|
package/dist/system/sleep.js
CHANGED
|
@@ -11,11 +11,13 @@ const maximumDelay = 2147483647n;
|
|
|
11
11
|
* @ko 비동기 대기. 호출 스레드는 계속 이벤트 루프에서 사용할 수 있다.
|
|
12
12
|
*/
|
|
13
13
|
async function sleep(duration) {
|
|
14
|
-
if (!(duration instanceof time_1.Time))
|
|
14
|
+
if (!(duration instanceof time_1.Time)) {
|
|
15
15
|
throw new TypeError('Expected a Time');
|
|
16
|
+
}
|
|
16
17
|
const microseconds = duration.asMicroseconds();
|
|
17
|
-
if (microseconds <= 0n)
|
|
18
|
+
if (microseconds <= 0n) {
|
|
18
19
|
return;
|
|
20
|
+
}
|
|
19
21
|
// Round positive fractions up to a millisecond. Snapshot before the await.
|
|
20
22
|
let remaining = (microseconds + 999n) / 1000n;
|
|
21
23
|
while (remaining > 0n) {
|
package/dist/system/time.js
CHANGED
|
@@ -6,8 +6,9 @@ const value_storage_1 = require("../internal/value-storage");
|
|
|
6
6
|
const minInt64 = -(2n ** 63n);
|
|
7
7
|
const maxInt64 = 2n ** 63n - 1n;
|
|
8
8
|
function checkedMicroseconds(value) {
|
|
9
|
-
if (typeof value !== 'bigint')
|
|
9
|
+
if (typeof value !== 'bigint') {
|
|
10
10
|
throw new TypeError('Expected a bigint');
|
|
11
|
+
}
|
|
11
12
|
if (value < minInt64 || value > maxInt64) {
|
|
12
13
|
throw new RangeError('Time must fit in a signed 64-bit microsecond count');
|
|
13
14
|
}
|
|
@@ -19,11 +20,13 @@ exports.checkedMicroseconds = checkedMicroseconds;
|
|
|
19
20
|
/* eslint-disable no-bitwise */
|
|
20
21
|
function int64AsFloat(value) {
|
|
21
22
|
const magnitude = value < 0n ? -value : value;
|
|
22
|
-
if (magnitude <= 9007199254740991n)
|
|
23
|
+
if (magnitude <= 9007199254740991n) {
|
|
23
24
|
return Math.fround(Number(value));
|
|
25
|
+
}
|
|
24
26
|
let exponent = Math.floor(Math.log2(Number(magnitude)));
|
|
25
|
-
if (magnitude < (1n << BigInt(exponent)))
|
|
27
|
+
if (magnitude < (1n << BigInt(exponent))) {
|
|
26
28
|
exponent--;
|
|
29
|
+
}
|
|
27
30
|
const shift = BigInt(exponent - 23);
|
|
28
31
|
let significand = magnitude >> shift;
|
|
29
32
|
const remainder = magnitude - (significand << shift);
|
|
@@ -37,8 +40,9 @@ function int64AsFloat(value) {
|
|
|
37
40
|
}
|
|
38
41
|
/* eslint-enable no-bitwise */
|
|
39
42
|
function floatScalar(value) {
|
|
40
|
-
if (typeof value !== 'number')
|
|
43
|
+
if (typeof value !== 'number') {
|
|
41
44
|
throw new TypeError('Expected a number');
|
|
45
|
+
}
|
|
42
46
|
const result = Math.fround(value);
|
|
43
47
|
if (!Number.isFinite(result)) {
|
|
44
48
|
throw new RangeError('Time requires a finite float32 value');
|
|
@@ -135,8 +139,9 @@ exports.seconds = seconds;
|
|
|
135
139
|
* 32비트 정수 범위 내여야 한다.
|
|
136
140
|
*/
|
|
137
141
|
function milliseconds(amount) {
|
|
138
|
-
if (typeof amount !== 'number')
|
|
142
|
+
if (typeof amount !== 'number') {
|
|
139
143
|
throw new TypeError('Expected a number');
|
|
144
|
+
}
|
|
140
145
|
const integer = Math.trunc(amount);
|
|
141
146
|
if (!Number.isFinite(integer) ||
|
|
142
147
|
integer < -2147483648 || integer > 2147483647) {
|
|
@@ -178,8 +183,9 @@ exports.scaleTime = scaleTime;
|
|
|
178
183
|
function remainderTime(left, right) {
|
|
179
184
|
const lhs = left.asMicroseconds();
|
|
180
185
|
const rhs = right.asMicroseconds();
|
|
181
|
-
if (rhs === 0n)
|
|
186
|
+
if (rhs === 0n) {
|
|
182
187
|
throw new RangeError('Cannot divide by zero');
|
|
188
|
+
}
|
|
183
189
|
if (lhs === minInt64 && rhs === -1n) {
|
|
184
190
|
throw new RangeError('Time remainder quotient exceeds the int64 range');
|
|
185
191
|
}
|
package/dist/system/vector2.js
CHANGED
|
@@ -16,9 +16,10 @@ const scalar_1 = require("../internal/scalar");
|
|
|
16
16
|
class Vector2 {
|
|
17
17
|
constructor(typeOrSource, ...args) {
|
|
18
18
|
this[_a] = true;
|
|
19
|
-
this.type =
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
this.type =
|
|
20
|
+
typeof typeOrSource === 'string'
|
|
21
|
+
? typeOrSource
|
|
22
|
+
: typeOrSource.scalarType;
|
|
22
23
|
(0, scalar_1.validateScalar)(this.type);
|
|
23
24
|
const type = this.type;
|
|
24
25
|
this.state = new lazy_value_1.LazyValue(new scalar_1.scalarArrays[type](2), buffer => native_1.native.wrapVector2(type, buffer));
|
|
@@ -163,8 +164,7 @@ class Vector2 {
|
|
|
163
164
|
dot(rhs) {
|
|
164
165
|
this.checkScalarType(rhs);
|
|
165
166
|
if (typeof this.x === 'bigint') {
|
|
166
|
-
return (0, scalar_1.convertScalar)(this.type, this.x * rhs.x +
|
|
167
|
-
this.y * rhs.y);
|
|
167
|
+
return (0, scalar_1.convertScalar)(this.type, this.x * rhs.x + this.y * rhs.y);
|
|
168
168
|
}
|
|
169
169
|
return (0, scalar_1.toScalar)(this.type, (0, scalar_1.scalarProduct)(this.type, this.x, rhs.x) +
|
|
170
170
|
(0, scalar_1.scalarProduct)(this.type, this.y, rhs.y));
|
|
@@ -181,8 +181,7 @@ class Vector2 {
|
|
|
181
181
|
cross(rhs) {
|
|
182
182
|
this.checkScalarType(rhs);
|
|
183
183
|
if (typeof this.x === 'bigint') {
|
|
184
|
-
return (0, scalar_1.convertScalar)(this.type, this.x * rhs.y -
|
|
185
|
-
this.y * rhs.x);
|
|
184
|
+
return (0, scalar_1.convertScalar)(this.type, this.x * rhs.y - this.y * rhs.x);
|
|
186
185
|
}
|
|
187
186
|
return (0, scalar_1.toScalar)(this.type, (0, scalar_1.scalarProduct)(this.type, this.x, rhs.y) -
|
|
188
187
|
(0, scalar_1.scalarProduct)(this.type, this.y, rhs.x));
|
package/dist/system/vector3.js
CHANGED
|
@@ -15,8 +15,10 @@ const scalar_1 = require("../internal/scalar");
|
|
|
15
15
|
class Vector3 {
|
|
16
16
|
constructor(typeOrSource, ...args) {
|
|
17
17
|
this[_a] = true;
|
|
18
|
-
this.type =
|
|
19
|
-
|
|
18
|
+
this.type =
|
|
19
|
+
typeof typeOrSource === 'string'
|
|
20
|
+
? typeOrSource
|
|
21
|
+
: typeOrSource.scalarType;
|
|
20
22
|
const type = this.type;
|
|
21
23
|
(0, scalar_1.validateScalar)(type);
|
|
22
24
|
this.state = new lazy_value_1.LazyValue(new scalar_1.scalarArrays[type](3), buffer => native_1.native.wrapVector3(type, buffer));
|
|
@@ -147,8 +149,7 @@ class Vector3 {
|
|
|
147
149
|
}
|
|
148
150
|
const xy = (0, scalar_1.toScalar)(this.type, (0, scalar_1.scalarProduct)(this.type, this.x, rhs.x) +
|
|
149
151
|
(0, scalar_1.scalarProduct)(this.type, this.y, rhs.y));
|
|
150
|
-
return (0, scalar_1.toScalar)(this.type, xy +
|
|
151
|
-
(0, scalar_1.scalarProduct)(this.type, this.z, rhs.z));
|
|
152
|
+
return (0, scalar_1.toScalar)(this.type, xy + (0, scalar_1.scalarProduct)(this.type, this.z, rhs.z));
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* Return the cross product with vector rhs of the same type, following
|
|
@@ -197,8 +198,12 @@ class Vector3 {
|
|
|
197
198
|
*/
|
|
198
199
|
componentWiseDiv(rhs) {
|
|
199
200
|
this.checkScalarType(rhs);
|
|
200
|
-
if (rhs.x === 0 ||
|
|
201
|
-
rhs.
|
|
201
|
+
if (rhs.x === 0 ||
|
|
202
|
+
rhs.y === 0 ||
|
|
203
|
+
rhs.z === 0 ||
|
|
204
|
+
rhs.x === 0n ||
|
|
205
|
+
rhs.y === 0n ||
|
|
206
|
+
rhs.z === 0n) {
|
|
202
207
|
throw new RangeError('Vector3.componentWiseDiv() cannot divide by zero');
|
|
203
208
|
}
|
|
204
209
|
if (typeof this.x === 'bigint') {
|
package/dist/window/clipboard.js
CHANGED
|
@@ -19,8 +19,9 @@ exports.getString = getString;
|
|
|
19
19
|
* @ko 시스템 클립보드 텍스트를 text로 교체한다.
|
|
20
20
|
*/
|
|
21
21
|
function setString(text) {
|
|
22
|
-
if (typeof text !== 'string')
|
|
22
|
+
if (typeof text !== 'string') {
|
|
23
23
|
throw new TypeError('Expected clipboard text');
|
|
24
|
+
}
|
|
24
25
|
native_1.native.setClipboardString(text);
|
|
25
26
|
}
|
|
26
27
|
exports.setString = setString;
|
package/dist/window/context.js
CHANGED
|
@@ -7,8 +7,9 @@ const context_settings_1 = require("./context-settings");
|
|
|
7
7
|
const video_mode_1 = require("./video-mode");
|
|
8
8
|
const contexts = new Map();
|
|
9
9
|
const collected = new FinalizationRegistry(key => {
|
|
10
|
-
if (!contexts.get(key)?.deref())
|
|
10
|
+
if (!contexts.get(key)?.deref()) {
|
|
11
11
|
contexts.delete(key);
|
|
12
|
+
}
|
|
12
13
|
});
|
|
13
14
|
function remember(key, context) {
|
|
14
15
|
contexts.set(key, new WeakRef(context));
|
|
@@ -47,8 +48,9 @@ class Context {
|
|
|
47
48
|
* 활성화 또는 비활성화한 뒤 성공 여부를 반환한다.
|
|
48
49
|
*/
|
|
49
50
|
setActive(active) {
|
|
50
|
-
if (typeof active !== 'boolean')
|
|
51
|
+
if (typeof active !== 'boolean') {
|
|
51
52
|
throw new TypeError('Expected a boolean');
|
|
53
|
+
}
|
|
52
54
|
(0, graphics_state_1.flushGraphics)();
|
|
53
55
|
return native_1.native.setContextActive(this[graphics_state_1.graphicsNative], active);
|
|
54
56
|
}
|
|
@@ -72,14 +74,17 @@ class Context {
|
|
|
72
74
|
*/
|
|
73
75
|
static getActiveContext() {
|
|
74
76
|
const key = native_1.native.getActiveContextKey();
|
|
75
|
-
if (key === undefined)
|
|
77
|
+
if (key === undefined) {
|
|
76
78
|
return undefined;
|
|
79
|
+
}
|
|
77
80
|
const existing = contexts.get(key)?.deref();
|
|
78
|
-
if (existing)
|
|
81
|
+
if (existing) {
|
|
79
82
|
return existing;
|
|
83
|
+
}
|
|
80
84
|
const mapping = native_1.native.referenceActiveContext();
|
|
81
|
-
if (!mapping)
|
|
85
|
+
if (!mapping) {
|
|
82
86
|
return undefined;
|
|
87
|
+
}
|
|
83
88
|
const context = Object.create(Context.prototype);
|
|
84
89
|
Object.defineProperties(context, {
|
|
85
90
|
[graphics_state_1.graphicsNative]: { value: mapping.handle },
|
package/dist/window/cursor.js
CHANGED
|
@@ -40,8 +40,9 @@ class Cursor {
|
|
|
40
40
|
constructor(source, size, hotspot) {
|
|
41
41
|
const handle = typeof source === 'number' ? systemCursor(source)
|
|
42
42
|
: pixelCursor(source, size, hotspot);
|
|
43
|
-
if (!handle)
|
|
43
|
+
if (!handle) {
|
|
44
44
|
throw new error_1.SFMLError('Failed to create cursor');
|
|
45
|
+
}
|
|
45
46
|
this[graphics_state_1.graphicsNative] = handle;
|
|
46
47
|
}
|
|
47
48
|
/**
|
package/dist/window/event.js
CHANGED
|
@@ -21,10 +21,12 @@ class Event {
|
|
|
21
21
|
for (const key of Object.keys(copy)) {
|
|
22
22
|
const value = copy[key];
|
|
23
23
|
if (value instanceof vector2_1.Vector2 || value instanceof vector3_1.Vector3) {
|
|
24
|
-
copy[key] =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
:
|
|
24
|
+
copy[key] =
|
|
25
|
+
value instanceof vector3_1.Vector3
|
|
26
|
+
? new vector3_1.Vector3f(value)
|
|
27
|
+
: value.scalarType === 'u32'
|
|
28
|
+
? new vector2_1.Vector2u(value)
|
|
29
|
+
: new vector2_1.Vector2i(value);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
this.data = copy;
|
|
@@ -72,7 +74,9 @@ function windowEvent(raw) {
|
|
|
72
74
|
if (data.kind === 'Resized') {
|
|
73
75
|
data.size = new vector2_1.Vector2u(...raw.size);
|
|
74
76
|
}
|
|
75
|
-
if ('position' in data &&
|
|
77
|
+
if ('position' in data &&
|
|
78
|
+
'position' in raw &&
|
|
79
|
+
Array.isArray(raw.position)) {
|
|
76
80
|
data.position = new vector2_1.Vector2i(...raw.position);
|
|
77
81
|
}
|
|
78
82
|
if (data.kind === 'MouseMovedRaw' && raw.kind === 'MouseMovedRaw') {
|
package/dist/window/mouse.js
CHANGED
|
@@ -10,10 +10,12 @@ Object.defineProperty(exports, "Button", { enumerable: true, get: function () {
|
|
|
10
10
|
Object.defineProperty(exports, "Wheel", { enumerable: true, get: function () { return constants_1.MouseWheel; } });
|
|
11
11
|
Object.defineProperty(exports, "ButtonCount", { enumerable: true, get: function () { return constants_1.MouseButtonCount; } });
|
|
12
12
|
function windowHandle(window) {
|
|
13
|
-
if (window === undefined)
|
|
13
|
+
if (window === undefined) {
|
|
14
14
|
return undefined;
|
|
15
|
-
|
|
15
|
+
}
|
|
16
|
+
if (!(window instanceof window_1.Window)) {
|
|
16
17
|
throw new TypeError('Expected a Window');
|
|
18
|
+
}
|
|
17
19
|
return window[graphics_state_1.graphicsNative];
|
|
18
20
|
}
|
|
19
21
|
/**
|