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
|
@@ -89,7 +89,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
89
89
|
* @ja ローカルポートを返し、未割り当てなら 0 を返します。
|
|
90
90
|
* @ko 로컬 포트를 반환하며 아직 할당되지 않았으면 0입니다.
|
|
91
91
|
*/
|
|
92
|
-
getLocalPort() {
|
|
92
|
+
getLocalPort() {
|
|
93
|
+
return this.transport?.localPort ?? 0;
|
|
94
|
+
}
|
|
93
95
|
/**
|
|
94
96
|
* Return the peer address, or undefined when not connected.
|
|
95
97
|
* @zh 返回对端地址,未连接时为 undefined。
|
|
@@ -97,7 +99,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
97
99
|
* @ko 상대 주소를 반환하며 연결되지 않았으면 undefined입니다.
|
|
98
100
|
*/
|
|
99
101
|
getRemoteAddress() {
|
|
100
|
-
const address = this.connected
|
|
102
|
+
const address = this.connected
|
|
103
|
+
? this.transport?.remoteAddress
|
|
104
|
+
: undefined;
|
|
101
105
|
return address ? ip_address_1.IpAddress.fromString(address) : undefined;
|
|
102
106
|
}
|
|
103
107
|
/**
|
|
@@ -107,7 +111,7 @@ class TcpSocket extends socket_1.Socket {
|
|
|
107
111
|
* @ko 상대 포트를 반환하며 연결되지 않았으면 0입니다.
|
|
108
112
|
*/
|
|
109
113
|
getRemotePort() {
|
|
110
|
-
return this.connected ? this.transport?.remotePort ?? 0 : 0;
|
|
114
|
+
return this.connected ? (this.transport?.remotePort ?? 0) : 0;
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
117
|
* Start a TCP connection; wait for completion by default, or return NotReady
|
|
@@ -120,31 +124,39 @@ class TcpSocket extends socket_1.Socket {
|
|
|
120
124
|
* NotReady를 반환합니다. Time.Zero는 제한 시간이 없습니다.
|
|
121
125
|
*/
|
|
122
126
|
async connect(address, port, timeout = time_1.Time.Zero) {
|
|
123
|
-
if (!(address instanceof ip_address_1.IpAddress))
|
|
127
|
+
if (!(address instanceof ip_address_1.IpAddress)) {
|
|
124
128
|
throw new TypeError('Expected IpAddress');
|
|
129
|
+
}
|
|
125
130
|
(0, common_1.uint)(port, 65535);
|
|
126
131
|
const milliseconds = (0, common_1.millisecondsOf)(timeout);
|
|
127
132
|
this.create(address.getType());
|
|
128
133
|
const generation = this.epoch;
|
|
129
134
|
const socket = this.transport;
|
|
130
135
|
let timer;
|
|
131
|
-
const done = (0, common_1.waitFor)(this[socket_1.socketEvents], () => this.connected || this.ended ||
|
|
132
|
-
|
|
133
|
-
if (timer)
|
|
136
|
+
const done = (0, common_1.waitFor)(this[socket_1.socketEvents], () => this.connected || this.ended || this.epoch !== generation).then(() => {
|
|
137
|
+
if (timer) {
|
|
134
138
|
clearTimeout(timer);
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
}
|
|
140
|
+
return this.epoch !== generation
|
|
141
|
+
? socket_1.SocketStatus.Disconnected
|
|
142
|
+
: this.connected
|
|
143
|
+
? socket_1.SocketStatus.Done
|
|
144
|
+
: socket_1.SocketStatus.Error;
|
|
137
145
|
});
|
|
138
146
|
if (milliseconds) {
|
|
139
147
|
timer = setTimeout(() => {
|
|
140
|
-
if (this.epoch !== generation)
|
|
148
|
+
if (this.epoch !== generation) {
|
|
141
149
|
return;
|
|
150
|
+
}
|
|
142
151
|
this.failure = new Error('Connection timed out');
|
|
143
152
|
socket.destroy(this.failure);
|
|
144
153
|
}, milliseconds);
|
|
145
154
|
}
|
|
146
|
-
socket.connect({
|
|
147
|
-
|
|
155
|
+
socket.connect({
|
|
156
|
+
host: address.toString(),
|
|
157
|
+
port,
|
|
158
|
+
family: address.isV4() ? 4 : 6,
|
|
159
|
+
});
|
|
148
160
|
return this.blocking ? done : socket_1.SocketStatus.NotReady;
|
|
149
161
|
}
|
|
150
162
|
/**
|
|
@@ -153,7 +165,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
153
165
|
* @ja 接続を即座に閉じ、未完了のパケット送受信状態を消去します。
|
|
154
166
|
* @ko 즉시 연결을 닫고 미완료 패킷 송수신 상태를 지웁니다.
|
|
155
167
|
*/
|
|
156
|
-
disconnect() {
|
|
168
|
+
disconnect() {
|
|
169
|
+
this.close();
|
|
170
|
+
}
|
|
157
171
|
/**
|
|
158
172
|
* Reject UDP or listener transports before adoption.
|
|
159
173
|
* @zh 接管前拒绝 UDP 或监听传输。
|
|
@@ -161,8 +175,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
161
175
|
* @ko 인수 전에 UDP 또는 리스너 전송 객체를 거부합니다.
|
|
162
176
|
*/
|
|
163
177
|
validateHandle(handle) {
|
|
164
|
-
if (!(handle instanceof node_net_1.Socket))
|
|
178
|
+
if (!(handle instanceof node_net_1.Socket)) {
|
|
165
179
|
throw new TypeError('Expected Node TCP');
|
|
180
|
+
}
|
|
166
181
|
}
|
|
167
182
|
/**
|
|
168
183
|
* Integrate the handle allocated or adopted by protected create into
|
|
@@ -213,12 +228,16 @@ class TcpSocket extends socket_1.Socket {
|
|
|
213
228
|
* 기본적으로 검증하며 CA 바이트는 PEM 또는 DER를 지원합니다.
|
|
214
229
|
*/
|
|
215
230
|
async setupTlsClient(hostname, verifyOrCa = true) {
|
|
216
|
-
if (typeof hostname !== 'string')
|
|
231
|
+
if (typeof hostname !== 'string') {
|
|
217
232
|
throw new TypeError('Expected hostname');
|
|
233
|
+
}
|
|
218
234
|
return this.setupTls(() => (0, node_tls_1.connect)({
|
|
219
|
-
socket: this.transport,
|
|
235
|
+
socket: this.transport,
|
|
236
|
+
servername: hostname,
|
|
220
237
|
rejectUnauthorized: verifyOrCa !== false,
|
|
221
|
-
ca: typeof verifyOrCa === 'boolean'
|
|
238
|
+
ca: typeof verifyOrCa === 'boolean'
|
|
239
|
+
? undefined
|
|
240
|
+
: (0, tls_material_1.tlsCertificate)(verifyOrCa),
|
|
222
241
|
}), 'secureConnect');
|
|
223
242
|
}
|
|
224
243
|
/**
|
|
@@ -251,14 +270,17 @@ class TcpSocket extends socket_1.Socket {
|
|
|
251
270
|
getCurrentCiphersuiteName() {
|
|
252
271
|
return this.tlsStatus === TlsStatus.HandshakeComplete &&
|
|
253
272
|
this.transport instanceof node_tls_1.TLSSocket
|
|
254
|
-
? this.transport.getCipher()?.standardName ??
|
|
255
|
-
this.transport.getCipher()?.name
|
|
273
|
+
? (this.transport.getCipher()?.standardName ??
|
|
274
|
+
this.transport.getCipher()?.name)
|
|
275
|
+
: undefined;
|
|
256
276
|
}
|
|
257
277
|
send(data) {
|
|
258
278
|
const generation = this.epoch;
|
|
259
279
|
// Snapshot at call time, including for nonblocking writes accepted by Node.
|
|
260
280
|
const snapshot = data instanceof packet_1.Packet
|
|
261
|
-
? this.outgoing?.packet === data
|
|
281
|
+
? this.outgoing?.packet === data
|
|
282
|
+
? undefined
|
|
283
|
+
: Buffer.from(data[packet_1.packetSend]())
|
|
262
284
|
: Buffer.from((0, common_1.bytes)(data));
|
|
263
285
|
return this.writes.run(async () => {
|
|
264
286
|
const packet = data instanceof packet_1.Packet ? data : undefined;
|
|
@@ -281,15 +303,19 @@ class TcpSocket extends socket_1.Socket {
|
|
|
281
303
|
this.outgoing = { packet, data: wire, position: 0 };
|
|
282
304
|
}
|
|
283
305
|
const input = this.outgoing
|
|
284
|
-
? this.outgoing.data.subarray(this.outgoing.position)
|
|
306
|
+
? this.outgoing.data.subarray(this.outgoing.position)
|
|
307
|
+
: snapshot;
|
|
285
308
|
const socket = this.transport;
|
|
286
|
-
if (!input.length)
|
|
309
|
+
if (!input.length) {
|
|
287
310
|
return result(socket_1.SocketStatus.Done);
|
|
288
|
-
|
|
311
|
+
}
|
|
312
|
+
const room = this.blocking
|
|
313
|
+
? input.length
|
|
289
314
|
: Math.max(0, socket.writableHighWaterMark - socket.writableLength);
|
|
290
315
|
const count = Math.min(input.length, room);
|
|
291
|
-
if (!count)
|
|
316
|
+
if (!count) {
|
|
292
317
|
return result(socket_1.SocketStatus.NotReady);
|
|
318
|
+
}
|
|
293
319
|
const completion = new Promise(resolve => {
|
|
294
320
|
socket.write(input.subarray(0, count), error => resolve(error ? socket_1.SocketStatus.Error : socket_1.SocketStatus.Done));
|
|
295
321
|
});
|
|
@@ -300,11 +326,14 @@ class TcpSocket extends socket_1.Socket {
|
|
|
300
326
|
}
|
|
301
327
|
}
|
|
302
328
|
const status = this.blocking
|
|
303
|
-
? await this.awaitWrite(completion, generation)
|
|
304
|
-
|
|
329
|
+
? await this.awaitWrite(completion, generation)
|
|
330
|
+
: socket_1.SocketStatus.Done;
|
|
331
|
+
if (generation !== this.epoch) {
|
|
305
332
|
return result(socket_1.SocketStatus.Disconnected, count);
|
|
333
|
+
}
|
|
306
334
|
return result(status === socket_1.SocketStatus.Done && count < input.length
|
|
307
|
-
? socket_1.SocketStatus.Partial
|
|
335
|
+
? socket_1.SocketStatus.Partial
|
|
336
|
+
: status, count);
|
|
308
337
|
});
|
|
309
338
|
}
|
|
310
339
|
receive(destination) {
|
|
@@ -314,7 +343,8 @@ class TcpSocket extends socket_1.Socket {
|
|
|
314
343
|
if (destination instanceof packet_1.Packet) {
|
|
315
344
|
for (;;) {
|
|
316
345
|
const header = this.packetSize === undefined;
|
|
317
|
-
const needed = header
|
|
346
|
+
const needed = header
|
|
347
|
+
? 4 - this.prefixSize
|
|
318
348
|
: this.packetSize - this.packetBytes;
|
|
319
349
|
if (!needed && !header) {
|
|
320
350
|
const payload = Buffer.concat(this.packetChunks, this.packetBytes);
|
|
@@ -323,8 +353,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
323
353
|
return socket_1.SocketStatus.Done;
|
|
324
354
|
}
|
|
325
355
|
const chunk = await this.readChunk(needed, generation);
|
|
326
|
-
if (typeof chunk === 'number')
|
|
356
|
+
if (typeof chunk === 'number') {
|
|
327
357
|
return chunk;
|
|
358
|
+
}
|
|
328
359
|
if (header) {
|
|
329
360
|
chunk.copy(this.prefix, this.prefixSize);
|
|
330
361
|
this.prefixSize += chunk.length;
|
|
@@ -346,11 +377,13 @@ class TcpSocket extends socket_1.Socket {
|
|
|
346
377
|
if (this.prefixSize || this.packetSize !== undefined) {
|
|
347
378
|
throw new Error('Finish receiving the pending Packet first');
|
|
348
379
|
}
|
|
349
|
-
if (!output.length)
|
|
380
|
+
if (!output.length) {
|
|
350
381
|
return { status: socket_1.SocketStatus.Error, received: 0 };
|
|
382
|
+
}
|
|
351
383
|
const chunk = await this.readChunk(output.length, generation);
|
|
352
|
-
if (typeof chunk === 'number')
|
|
384
|
+
if (typeof chunk === 'number') {
|
|
353
385
|
return { status: chunk, received: 0 };
|
|
386
|
+
}
|
|
354
387
|
chunk.copy(output);
|
|
355
388
|
return { status: socket_1.SocketStatus.Done, received: chunk.length };
|
|
356
389
|
});
|
|
@@ -361,7 +394,9 @@ class TcpSocket extends socket_1.Socket {
|
|
|
361
394
|
* @ja TCP トランスポートの生存状態を返します。派生クラスで拡張できます。
|
|
362
395
|
* @ko TCP 전송 객체의 활성 상태를 반환하며 파생 클래스에서 확장할 수 있습니다.
|
|
363
396
|
*/
|
|
364
|
-
isAlive() {
|
|
397
|
+
isAlive() {
|
|
398
|
+
return !!this.transport && !this.ended;
|
|
399
|
+
}
|
|
365
400
|
/**
|
|
366
401
|
* Return readiness bits for receiving, sending, and the TLS handshake.
|
|
367
402
|
* @zh 返回接收、发送及 TLS 握手对应的就绪位。
|
|
@@ -371,13 +406,19 @@ class TcpSocket extends socket_1.Socket {
|
|
|
371
406
|
getReadiness(mask) {
|
|
372
407
|
const socket = this.transport;
|
|
373
408
|
const receive = socket && (socket.readableLength > 0 || this.ended) ? 1 : 0;
|
|
374
|
-
const send = this.connected &&
|
|
375
|
-
|
|
376
|
-
|
|
409
|
+
const send = this.connected &&
|
|
410
|
+
socket &&
|
|
411
|
+
!socket.destroyed &&
|
|
412
|
+
!socket.writableNeedDrain &&
|
|
413
|
+
this.tlsStatus !== TlsStatus.HandshakeStarted
|
|
414
|
+
? 2
|
|
415
|
+
: 0;
|
|
377
416
|
// eslint-disable-next-line no-bitwise
|
|
378
417
|
return (receive | send) & mask;
|
|
379
418
|
}
|
|
380
|
-
getNativeHandle() {
|
|
419
|
+
getNativeHandle() {
|
|
420
|
+
return this.transport;
|
|
421
|
+
}
|
|
381
422
|
/** 重置 Packet 分帧累积状态。 */
|
|
382
423
|
resetPacket() {
|
|
383
424
|
this.prefixSize = 0;
|
|
@@ -387,17 +428,19 @@ class TcpSocket extends socket_1.Socket {
|
|
|
387
428
|
}
|
|
388
429
|
/** 异步读取最多 max 字节,含代际校验。 */
|
|
389
430
|
async readChunk(max, generation) {
|
|
390
|
-
const available = () => this.ended ||
|
|
391
|
-
(this.transport?.readableLength ?? 0) > 0;
|
|
431
|
+
const available = () => this.ended || (this.transport?.readableLength ?? 0) > 0;
|
|
392
432
|
await this.awaitReady(available, generation);
|
|
393
|
-
if (generation !== this.epoch)
|
|
433
|
+
if (generation !== this.epoch) {
|
|
394
434
|
return socket_1.SocketStatus.Disconnected;
|
|
435
|
+
}
|
|
395
436
|
const socket = this.transport;
|
|
396
437
|
const count = Math.min(max, socket?.readableLength ?? 0);
|
|
397
|
-
if (count)
|
|
438
|
+
if (count) {
|
|
398
439
|
return socket.read(count);
|
|
399
|
-
|
|
440
|
+
}
|
|
441
|
+
if (this.ended) {
|
|
400
442
|
return this.failure ? socket_1.SocketStatus.Error : socket_1.SocketStatus.Disconnected;
|
|
443
|
+
}
|
|
401
444
|
return socket_1.SocketStatus.NotReady;
|
|
402
445
|
}
|
|
403
446
|
/** 绑定套接字事件监听并设置 TCP_NODELAY。 */
|
|
@@ -408,35 +451,43 @@ class TcpSocket extends socket_1.Socket {
|
|
|
408
451
|
socket.setNoDelay(true);
|
|
409
452
|
const generation = this.epoch;
|
|
410
453
|
const current = () => socket === this.transport && generation === this.epoch;
|
|
411
|
-
const readable = () => {
|
|
412
|
-
|
|
454
|
+
const readable = () => {
|
|
455
|
+
if (current()) {
|
|
456
|
+
this.changed();
|
|
457
|
+
}
|
|
458
|
+
};
|
|
413
459
|
const connected = () => {
|
|
414
|
-
if (!current())
|
|
460
|
+
if (!current()) {
|
|
415
461
|
return;
|
|
462
|
+
}
|
|
416
463
|
this.connected = true;
|
|
417
464
|
this.changed();
|
|
418
465
|
};
|
|
419
466
|
const ended = () => {
|
|
420
|
-
if (!current())
|
|
467
|
+
if (!current()) {
|
|
421
468
|
return;
|
|
469
|
+
}
|
|
422
470
|
this.connected = false;
|
|
423
471
|
this.ended = true;
|
|
424
472
|
this.changed();
|
|
425
473
|
};
|
|
426
474
|
const error = (error) => {
|
|
427
|
-
if (!current())
|
|
475
|
+
if (!current()) {
|
|
428
476
|
return;
|
|
477
|
+
}
|
|
429
478
|
this.failure = error;
|
|
430
479
|
ended();
|
|
431
480
|
};
|
|
432
|
-
socket
|
|
481
|
+
socket
|
|
482
|
+
.on('readable', readable)
|
|
433
483
|
.on('drain', readable)
|
|
434
484
|
.on('connect', connected)
|
|
435
485
|
.on('end', ended)
|
|
436
486
|
.on('close', ended)
|
|
437
487
|
.on('error', error);
|
|
438
488
|
this.detach = () => {
|
|
439
|
-
socket
|
|
489
|
+
socket
|
|
490
|
+
.off('readable', readable)
|
|
440
491
|
.off('drain', readable)
|
|
441
492
|
.off('connect', connected)
|
|
442
493
|
.off('end', ended)
|
|
@@ -446,11 +497,13 @@ class TcpSocket extends socket_1.Socket {
|
|
|
446
497
|
}
|
|
447
498
|
/** 将空闲连接升级为 TLS 并等待握手完成。 */
|
|
448
499
|
async setupTls(create, event) {
|
|
449
|
-
if (!this.connected)
|
|
500
|
+
if (!this.connected) {
|
|
450
501
|
return TlsStatus.NotConnected;
|
|
502
|
+
}
|
|
451
503
|
const generation = this.epoch;
|
|
452
504
|
if (this.tlsStatus === TlsStatus.NotConnected) {
|
|
453
|
-
if (this.transport.readableLength ||
|
|
505
|
+
if (this.transport.readableLength ||
|
|
506
|
+
this.transport.writableLength) {
|
|
454
507
|
throw new Error('TLS upgrade requires an empty plaintext queue');
|
|
455
508
|
}
|
|
456
509
|
try {
|
|
@@ -459,14 +512,18 @@ class TcpSocket extends socket_1.Socket {
|
|
|
459
512
|
this.attach(socket);
|
|
460
513
|
this.tlsStatus = TlsStatus.HandshakeStarted;
|
|
461
514
|
const secure = () => {
|
|
462
|
-
if (socket !== this.transport || generation !== this.epoch)
|
|
515
|
+
if (socket !== this.transport || generation !== this.epoch) {
|
|
463
516
|
return;
|
|
517
|
+
}
|
|
464
518
|
this.tlsStatus = TlsStatus.HandshakeComplete;
|
|
465
519
|
this.changed();
|
|
466
520
|
};
|
|
467
521
|
socket.once(event, secure);
|
|
468
522
|
const detach = this.detach;
|
|
469
|
-
this.detach = () => {
|
|
523
|
+
this.detach = () => {
|
|
524
|
+
detach?.();
|
|
525
|
+
socket.off(event, secure);
|
|
526
|
+
};
|
|
470
527
|
}
|
|
471
528
|
catch (error) {
|
|
472
529
|
this.failure = error;
|
|
@@ -479,7 +536,8 @@ class TcpSocket extends socket_1.Socket {
|
|
|
479
536
|
this.tlsStatus !== TlsStatus.HandshakeStarted ||
|
|
480
537
|
generation !== this.epoch);
|
|
481
538
|
}
|
|
482
|
-
return this.ended || generation !== this.epoch
|
|
539
|
+
return this.ended || generation !== this.epoch
|
|
540
|
+
? TlsStatus.Error
|
|
483
541
|
: this.tlsStatus;
|
|
484
542
|
}
|
|
485
543
|
}
|
|
@@ -13,8 +13,9 @@ const common_1 = require("./common");
|
|
|
13
13
|
* Node TLS가 허용하는 PEM으로 변환합니다.
|
|
14
14
|
*/
|
|
15
15
|
function tlsCertificate(input) {
|
|
16
|
-
if (typeof input === 'string')
|
|
16
|
+
if (typeof input === 'string') {
|
|
17
17
|
return input;
|
|
18
|
+
}
|
|
18
19
|
const data = (0, common_1.bytes)(input);
|
|
19
20
|
return data.includes('-----BEGIN CERTIFICATE-----')
|
|
20
21
|
? data : new node_crypto_1.X509Certificate(data).toString();
|
|
@@ -60,17 +60,20 @@ class UdpSocket extends socket_1.Socket {
|
|
|
60
60
|
*/
|
|
61
61
|
async bind(port, address = ip_address_1.IpAddress.Any) {
|
|
62
62
|
(0, common_1.uint)(port, 65535);
|
|
63
|
-
if (!(address instanceof ip_address_1.IpAddress))
|
|
63
|
+
if (!(address instanceof ip_address_1.IpAddress)) {
|
|
64
64
|
throw new TypeError('Expected IpAddress');
|
|
65
|
+
}
|
|
65
66
|
this.create(address.getType());
|
|
66
67
|
const socket = this.transport;
|
|
67
68
|
const generation = this.epoch;
|
|
68
|
-
const ready = (0, common_1.waitFor)(this[socket_1.socketEvents], () => this.bound ||
|
|
69
|
-
!!this.failure || this.epoch !== generation);
|
|
69
|
+
const ready = (0, common_1.waitFor)(this[socket_1.socketEvents], () => this.bound || !!this.failure || this.epoch !== generation);
|
|
70
70
|
socket.bind(port, address.toString());
|
|
71
71
|
await ready;
|
|
72
|
-
return this.epoch !== generation
|
|
73
|
-
|
|
72
|
+
return this.epoch !== generation
|
|
73
|
+
? socket_1.SocketStatus.Disconnected
|
|
74
|
+
: this.bound
|
|
75
|
+
? socket_1.SocketStatus.Done
|
|
76
|
+
: socket_1.SocketStatus.Error;
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
76
79
|
* Reject non-UDP Node transports before adoption.
|
|
@@ -79,8 +82,9 @@ class UdpSocket extends socket_1.Socket {
|
|
|
79
82
|
* @ko 인수 전에 UDP가 아닌 Node 전송 객체를 거부합니다.
|
|
80
83
|
*/
|
|
81
84
|
validateHandle(handle) {
|
|
82
|
-
if (!(handle instanceof node_dgram_1.Socket))
|
|
85
|
+
if (!(handle instanceof node_dgram_1.Socket)) {
|
|
83
86
|
throw new TypeError('Expected Node UDP');
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* Integrate an allocated or adopted UDP handle into the same datagram queue
|
|
@@ -99,14 +103,16 @@ class UdpSocket extends socket_1.Socket {
|
|
|
99
103
|
this.family = type === 'udp4' ? 4 : 6;
|
|
100
104
|
const current = () => this.transport === socket && this.epoch === generation;
|
|
101
105
|
const error = (error) => {
|
|
102
|
-
if (!current())
|
|
106
|
+
if (!current()) {
|
|
103
107
|
return;
|
|
108
|
+
}
|
|
104
109
|
this.failure = error;
|
|
105
110
|
this.changed();
|
|
106
111
|
};
|
|
107
112
|
const message = (data, peer) => {
|
|
108
|
-
if (!current())
|
|
113
|
+
if (!current()) {
|
|
109
114
|
return;
|
|
115
|
+
}
|
|
110
116
|
if (this.pendingBytes + data.length <= 8 * 1024 * 1024 &&
|
|
111
117
|
this.pending.length < 4096) {
|
|
112
118
|
this.pending.push({ data, peer });
|
|
@@ -115,25 +121,30 @@ class UdpSocket extends socket_1.Socket {
|
|
|
115
121
|
}
|
|
116
122
|
};
|
|
117
123
|
const listening = () => {
|
|
118
|
-
if (!current())
|
|
124
|
+
if (!current()) {
|
|
119
125
|
return;
|
|
126
|
+
}
|
|
120
127
|
this.bound = true;
|
|
121
|
-
if (this.family === 4)
|
|
128
|
+
if (this.family === 4) {
|
|
122
129
|
socket.setBroadcast(true);
|
|
130
|
+
}
|
|
123
131
|
this.changed();
|
|
124
132
|
};
|
|
125
133
|
const closed = () => {
|
|
126
|
-
if (!current())
|
|
134
|
+
if (!current()) {
|
|
127
135
|
return;
|
|
136
|
+
}
|
|
128
137
|
this.bound = false;
|
|
129
138
|
this.changed();
|
|
130
139
|
};
|
|
131
|
-
socket
|
|
140
|
+
socket
|
|
141
|
+
.on('error', error)
|
|
132
142
|
.on('message', message)
|
|
133
143
|
.on('listening', listening)
|
|
134
144
|
.on('close', closed);
|
|
135
145
|
this.detach = () => {
|
|
136
|
-
socket
|
|
146
|
+
socket
|
|
147
|
+
.off('error', error)
|
|
137
148
|
.off('message', message)
|
|
138
149
|
.off('listening', listening)
|
|
139
150
|
.off('close', closed);
|
|
@@ -152,7 +163,9 @@ class UdpSocket extends socket_1.Socket {
|
|
|
152
163
|
* @ja UDP トランスポートを閉じ、受信待ちのデータグラムを消去します。
|
|
153
164
|
* @ko UDP 전송 객체를 닫고 수신 대기 중인 데이터그램을 비웁니다.
|
|
154
165
|
*/
|
|
155
|
-
unbind() {
|
|
166
|
+
unbind() {
|
|
167
|
+
this.close();
|
|
168
|
+
}
|
|
156
169
|
/**
|
|
157
170
|
* Clear the old transport's binding state and datagrams;
|
|
158
171
|
* the generation change cancels old reads.
|
|
@@ -178,30 +191,37 @@ class UdpSocket extends socket_1.Socket {
|
|
|
178
191
|
*/
|
|
179
192
|
send(data, address, port) {
|
|
180
193
|
(0, common_1.uint)(port, 65535);
|
|
181
|
-
if (!(address instanceof ip_address_1.IpAddress))
|
|
194
|
+
if (!(address instanceof ip_address_1.IpAddress)) {
|
|
182
195
|
throw new TypeError('Expected IpAddress');
|
|
196
|
+
}
|
|
183
197
|
const input = Buffer.from(data instanceof packet_1.Packet ? data[packet_1.packetSend]() : (0, common_1.bytes)(data));
|
|
184
|
-
if (input.length > UdpSocket.MaxDatagramSize)
|
|
198
|
+
if (input.length > UdpSocket.MaxDatagramSize) {
|
|
185
199
|
return Promise.resolve(socket_1.SocketStatus.Error);
|
|
186
|
-
|
|
200
|
+
}
|
|
201
|
+
if (!this.transport) {
|
|
187
202
|
this.create(address.getType());
|
|
203
|
+
}
|
|
188
204
|
const generation = this.epoch;
|
|
189
205
|
return this.writes.run(() => this.sendBytes(input, address, port, generation));
|
|
190
206
|
}
|
|
191
207
|
/** 发送字节数据报,未绑定时自动绑定。 */
|
|
192
208
|
async sendBytes(input, address, port, generation) {
|
|
193
|
-
if (generation !== this.epoch)
|
|
209
|
+
if (generation !== this.epoch) {
|
|
194
210
|
return socket_1.SocketStatus.Disconnected;
|
|
195
|
-
|
|
211
|
+
}
|
|
212
|
+
if (this.family !== (address.isV4() ? 4 : 6)) {
|
|
196
213
|
return socket_1.SocketStatus.Error;
|
|
214
|
+
}
|
|
197
215
|
const socket = this.transport;
|
|
198
216
|
let onError;
|
|
199
217
|
const completion = new Promise(resolve => {
|
|
200
218
|
const done = (error) => {
|
|
201
|
-
if (generation !== this.epoch)
|
|
219
|
+
if (generation !== this.epoch) {
|
|
202
220
|
return resolve(socket_1.SocketStatus.Disconnected);
|
|
203
|
-
|
|
221
|
+
}
|
|
222
|
+
if (error) {
|
|
204
223
|
this.failure = error;
|
|
224
|
+
}
|
|
205
225
|
resolve(error ? socket_1.SocketStatus.Error : socket_1.SocketStatus.Done);
|
|
206
226
|
};
|
|
207
227
|
// Node 在 bind 失败时丢弃排队的 send 回调,必须监听 error 完成它。
|
|
@@ -236,24 +256,35 @@ class UdpSocket extends socket_1.Socket {
|
|
|
236
256
|
const output = destination instanceof packet_1.Packet ? undefined : (0, common_1.bytes)(destination);
|
|
237
257
|
const generation = this.epoch;
|
|
238
258
|
return this.reads.run(async () => {
|
|
239
|
-
const result = (status) => ({
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
259
|
+
const result = (status) => ({
|
|
260
|
+
status,
|
|
261
|
+
received: 0,
|
|
262
|
+
remotePort: 0,
|
|
263
|
+
});
|
|
264
|
+
await this.awaitReady(() => this.pending.length > 0 || !this.bound || !!this.failure, generation);
|
|
265
|
+
if (generation !== this.epoch || !this.bound) {
|
|
243
266
|
return result(socket_1.SocketStatus.Error);
|
|
267
|
+
}
|
|
244
268
|
const item = this.pending.shift();
|
|
245
|
-
if (!item)
|
|
269
|
+
if (!item) {
|
|
246
270
|
return result(this.failure ? socket_1.SocketStatus.Error : socket_1.SocketStatus.NotReady);
|
|
271
|
+
}
|
|
247
272
|
this.pendingBytes -= item.data.length;
|
|
248
|
-
if (output && output.length < item.data.length)
|
|
273
|
+
if (output && output.length < item.data.length) {
|
|
249
274
|
return result(socket_1.SocketStatus.Error);
|
|
250
|
-
|
|
275
|
+
}
|
|
276
|
+
if (destination instanceof packet_1.Packet) {
|
|
251
277
|
destination[packet_1.packetReceive](item.data);
|
|
252
|
-
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
253
280
|
item.data.copy(output);
|
|
254
|
-
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
status: socket_1.SocketStatus.Done,
|
|
284
|
+
received: item.data.length,
|
|
255
285
|
remoteAddress: ip_address_1.IpAddress.fromString(item.peer.address),
|
|
256
|
-
remotePort: item.peer.port
|
|
286
|
+
remotePort: item.peer.port,
|
|
287
|
+
};
|
|
257
288
|
});
|
|
258
289
|
}
|
|
259
290
|
/**
|
|
@@ -262,7 +293,9 @@ class UdpSocket extends socket_1.Socket {
|
|
|
262
293
|
* @ja バインド状態を返します。派生クラスで拡張できます。
|
|
263
294
|
* @ko 바인딩 상태를 반환하며 파생 클래스에서 확장할 수 있습니다.
|
|
264
295
|
*/
|
|
265
|
-
isAlive() {
|
|
296
|
+
isAlive() {
|
|
297
|
+
return this.bound;
|
|
298
|
+
}
|
|
266
299
|
/**
|
|
267
300
|
* Return readiness bits for pending datagrams and the current binding.
|
|
268
301
|
* @zh 返回待接收数据报和当前绑定对应的就绪位。
|
|
@@ -273,7 +306,9 @@ class UdpSocket extends socket_1.Socket {
|
|
|
273
306
|
// eslint-disable-next-line no-bitwise
|
|
274
307
|
return ((this.pending.length ? 1 : 0) | (this.bound ? 2 : 0)) & mask;
|
|
275
308
|
}
|
|
276
|
-
getNativeHandle() {
|
|
309
|
+
getNativeHandle() {
|
|
310
|
+
return this.transport;
|
|
311
|
+
}
|
|
277
312
|
}
|
|
278
313
|
/**
|
|
279
314
|
* Maximum UDP datagram payload size in bytes allowed by this implementation.
|
package/dist/system/angle.js
CHANGED
|
@@ -14,8 +14,9 @@ const tau = Math.fround(pi * 2);
|
|
|
14
14
|
* @ko SFML의 float32 나머지. 소수부를 버린 몫은 int32 범위 내여야 한다.
|
|
15
15
|
*/
|
|
16
16
|
function positiveRemainder(a, b) {
|
|
17
|
-
if (!(b > 0))
|
|
17
|
+
if (!(b > 0)) {
|
|
18
18
|
throw new RangeError('Angle modulus must be positive');
|
|
19
|
+
}
|
|
19
20
|
// C++ int has no negative zero, unlike Math.trunc().
|
|
20
21
|
const truncated = Math.trunc(Math.fround(a / b));
|
|
21
22
|
const quotient = truncated === 0 ? 0 : truncated;
|
package/dist/system/clock.js
CHANGED
|
@@ -21,8 +21,9 @@ class Clock {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(source) {
|
|
23
23
|
if (source !== undefined) {
|
|
24
|
-
if (!(source instanceof Clock))
|
|
24
|
+
if (!(source instanceof Clock)) {
|
|
25
25
|
throw new TypeError('Expected a Clock');
|
|
26
|
+
}
|
|
26
27
|
this.reference = source.reference;
|
|
27
28
|
this.stopped = source.stopped;
|
|
28
29
|
}
|
|
@@ -67,8 +68,9 @@ class Clock {
|
|
|
67
68
|
* @ko 누적 시간을 유지하며 측정을 일시 정지한다.
|
|
68
69
|
*/
|
|
69
70
|
stop() {
|
|
70
|
-
if (this.stopped === undefined)
|
|
71
|
+
if (this.stopped === undefined) {
|
|
71
72
|
this.stopped = node_process_1.hrtime.bigint();
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* Clear and start timing, returning the previous accumulated running time.
|
package/dist/system/err.js
CHANGED
|
@@ -47,8 +47,11 @@ function setErrorOutput(target) {
|
|
|
47
47
|
throw new TypeError('Expected an open Writable');
|
|
48
48
|
}
|
|
49
49
|
// Native retains this destination until all bytes captured for it drain.
|
|
50
|
-
// Buffers can split UTF-8 sequences; consumers decode them
|
|
51
|
-
|
|
50
|
+
// Buffers can split UTF-8 sequences; consumers decode them
|
|
51
|
+
// as a byte stream.
|
|
52
|
+
native_1.native.setErrorOutput((bytes) => {
|
|
53
|
+
target.write(bytes);
|
|
54
|
+
});
|
|
52
55
|
if (!listening) {
|
|
53
56
|
process.on('beforeExit', drainBeforeExit);
|
|
54
57
|
listening = true;
|