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
|
@@ -28,7 +28,8 @@ function matrixView(values) {
|
|
|
28
28
|
const view = new Array(16);
|
|
29
29
|
for (let i = 0; i < 16; i++) {
|
|
30
30
|
Object.defineProperty(view, i, {
|
|
31
|
-
enumerable: true,
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: () => values[i],
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
return Object.freeze(view);
|
|
@@ -103,8 +104,9 @@ class Transform {
|
|
|
103
104
|
const q = minor(a[15], a[4], a[7], a[12]);
|
|
104
105
|
const r = minor(a[13], a[4], a[5], a[12]);
|
|
105
106
|
const determinant = f(f(f(a[0] * p) - f(a[1] * q)) + f(a[3] * r));
|
|
106
|
-
if (determinant === 0)
|
|
107
|
+
if (determinant === 0) {
|
|
107
108
|
return new Transform();
|
|
109
|
+
}
|
|
108
110
|
return new Transform(p / determinant, -q / determinant, r / determinant, -minor(a[15], a[1], a[3], a[13]) / determinant, minor(a[15], a[0], a[3], a[12]) / determinant, -minor(a[13], a[0], a[1], a[12]) / determinant, minor(a[7], a[1], a[3], a[5]) / determinant, -minor(a[7], a[0], a[3], a[4]) / determinant, minor(a[5], a[0], a[1], a[4]) / determinant);
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
@@ -143,14 +145,18 @@ class Transform {
|
|
|
143
145
|
const x = pointCoordinate(a[0], px, a[4], py, a[12]);
|
|
144
146
|
const y = pointCoordinate(a[1], px, a[5], py, a[13]);
|
|
145
147
|
// Ordered comparisons preserve SFML's NaN and signed-zero behavior.
|
|
146
|
-
if (x < minX)
|
|
148
|
+
if (x < minX) {
|
|
147
149
|
minX = x;
|
|
148
|
-
|
|
150
|
+
}
|
|
151
|
+
else if (x > maxX) {
|
|
149
152
|
maxX = x;
|
|
150
|
-
|
|
153
|
+
}
|
|
154
|
+
if (y < minY) {
|
|
151
155
|
minY = y;
|
|
152
|
-
|
|
156
|
+
}
|
|
157
|
+
else if (y > maxY) {
|
|
153
158
|
maxY = y;
|
|
159
|
+
}
|
|
154
160
|
}
|
|
155
161
|
const result = new rect_1.FloatRect();
|
|
156
162
|
const values = result[value_storage_1.rectStorage];
|
|
@@ -194,8 +200,9 @@ class Transform {
|
|
|
194
200
|
*/
|
|
195
201
|
scale(factors, center) {
|
|
196
202
|
requireVector(factors);
|
|
197
|
-
if (center !== undefined)
|
|
203
|
+
if (center !== undefined) {
|
|
198
204
|
requireVector(center);
|
|
205
|
+
}
|
|
199
206
|
return this.combineMatrix(factors.x, 0, center === undefined ? 0 : f(center.x * f(1 - factors.x)), 0, factors.y, center === undefined ? 0 : f(center.y * f(1 - factors.y)), 0, 0, 1);
|
|
200
207
|
}
|
|
201
208
|
/**
|
|
@@ -206,15 +213,19 @@ class Transform {
|
|
|
206
213
|
* @ko center(기본값은 원점)를 중심으로 하는 회전 행렬을 제자리에서 오른쪽에 곱하고 this를 반환합니다.
|
|
207
214
|
*/
|
|
208
215
|
rotate(angle, center) {
|
|
209
|
-
if (!(angle instanceof angle_1.Angle))
|
|
216
|
+
if (!(angle instanceof angle_1.Angle)) {
|
|
210
217
|
throw new TypeError('Expected an Angle');
|
|
211
|
-
|
|
218
|
+
}
|
|
219
|
+
if (center !== undefined) {
|
|
212
220
|
requireVector(center);
|
|
221
|
+
}
|
|
213
222
|
const cos = f(Math.cos(angle.asRadians()));
|
|
214
223
|
const sin = f(Math.sin(angle.asRadians()));
|
|
215
|
-
const tx = center === undefined
|
|
224
|
+
const tx = center === undefined
|
|
225
|
+
? 0
|
|
216
226
|
: f(f(center.x * f(1 - cos)) + f(center.y * sin));
|
|
217
|
-
const ty = center === undefined
|
|
227
|
+
const ty = center === undefined
|
|
228
|
+
? 0
|
|
218
229
|
: f(f(center.y * f(1 - cos)) - f(center.x * sin));
|
|
219
230
|
return this.combineMatrix(cos, -sin, tx, sin, cos, ty, 0, 0, 1);
|
|
220
231
|
}
|
|
@@ -259,8 +270,13 @@ class Transform {
|
|
|
259
270
|
values[3] = a20;
|
|
260
271
|
values[7] = a21;
|
|
261
272
|
values[15] = a22;
|
|
262
|
-
values[2] =
|
|
263
|
-
values[
|
|
273
|
+
values[2] =
|
|
274
|
+
values[6] =
|
|
275
|
+
values[8] =
|
|
276
|
+
values[9] =
|
|
277
|
+
values[11] =
|
|
278
|
+
values[14] =
|
|
279
|
+
0;
|
|
264
280
|
values[10] = 1;
|
|
265
281
|
}
|
|
266
282
|
}
|
|
@@ -21,8 +21,9 @@ class TransformableResource {
|
|
|
21
21
|
}
|
|
22
22
|
const { handle, buffer } = native_1.native.createTransformable();
|
|
23
23
|
const values = new Float32Array(buffer);
|
|
24
|
-
if (source)
|
|
24
|
+
if (source) {
|
|
25
25
|
values.set(source[transformable_1.transformableState].values);
|
|
26
|
+
}
|
|
26
27
|
this[transformable_1.transformableState] = { handle, values };
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -39,8 +39,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
39
39
|
this.coordinates = new Float32Array(mapping.buffer);
|
|
40
40
|
this.count = count;
|
|
41
41
|
this.primitiveType = type;
|
|
42
|
-
if (copy)
|
|
42
|
+
if (copy) {
|
|
43
43
|
this.bytes.set(copy.bytes.subarray(0, count * 20));
|
|
44
|
+
}
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Returns the current vertex count.
|
|
@@ -51,10 +52,18 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
51
52
|
getVertexCount() {
|
|
52
53
|
return this.count;
|
|
53
54
|
}
|
|
54
|
-
get count() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
set
|
|
55
|
+
get count() {
|
|
56
|
+
return this.metadata[0];
|
|
57
|
+
}
|
|
58
|
+
set count(value) {
|
|
59
|
+
this.metadata[0] = value;
|
|
60
|
+
}
|
|
61
|
+
get primitiveType() {
|
|
62
|
+
return this.metadata[1];
|
|
63
|
+
}
|
|
64
|
+
set primitiveType(value) {
|
|
65
|
+
this.metadata[1] = value;
|
|
66
|
+
}
|
|
58
67
|
get [graphics_state_1.vertexArrayBytes]() {
|
|
59
68
|
return this.bytes.subarray(0, this.count * 20);
|
|
60
69
|
}
|
|
@@ -86,8 +95,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
86
95
|
*/
|
|
87
96
|
setVertex(index, value) {
|
|
88
97
|
this.checkIndex(index);
|
|
89
|
-
if (!(value instanceof vertex_1.Vertex))
|
|
98
|
+
if (!(value instanceof vertex_1.Vertex)) {
|
|
90
99
|
throw new TypeError('Expected a Vertex');
|
|
100
|
+
}
|
|
91
101
|
this.bytes.set(value[value_storage_1.vertexStorage], index * 20);
|
|
92
102
|
}
|
|
93
103
|
/**
|
|
@@ -115,8 +125,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
115
125
|
}
|
|
116
126
|
if (vertexCount < this.count) {
|
|
117
127
|
for (const index of this.views.keys()) {
|
|
118
|
-
if (index >= vertexCount)
|
|
128
|
+
if (index >= vertexCount) {
|
|
119
129
|
this.views.delete(index);
|
|
130
|
+
}
|
|
120
131
|
}
|
|
121
132
|
}
|
|
122
133
|
this.count = vertexCount;
|
|
@@ -128,8 +139,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
128
139
|
* @ko 꼭짓점 복사본을 끝에 추가하며 용량이 부족하면 저장 공간을 재할당합니다.
|
|
129
140
|
*/
|
|
130
141
|
append(vertex) {
|
|
131
|
-
if (!(vertex instanceof vertex_1.Vertex))
|
|
142
|
+
if (!(vertex instanceof vertex_1.Vertex)) {
|
|
132
143
|
throw new TypeError('Expected a Vertex');
|
|
144
|
+
}
|
|
133
145
|
validateCount(this.count + 1);
|
|
134
146
|
this.ensureCapacity(this.count + 1);
|
|
135
147
|
this.bytes.set(vertex[value_storage_1.vertexStorage], this.count * 20);
|
|
@@ -162,8 +174,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
162
174
|
* @ko 모든 꼭짓점 위치의 축 정렬 경계 상자를 반환합니다. 빈 배열은 0 사각형을 반환합니다.
|
|
163
175
|
*/
|
|
164
176
|
getBounds() {
|
|
165
|
-
if (this.count === 0)
|
|
177
|
+
if (this.count === 0) {
|
|
166
178
|
return new rect_1.FloatRect();
|
|
179
|
+
}
|
|
167
180
|
const data = this.coordinates;
|
|
168
181
|
let left = data[0];
|
|
169
182
|
let top = data[1];
|
|
@@ -172,14 +185,18 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
172
185
|
for (let i = 1; i < this.count; i++) {
|
|
173
186
|
const x = data[i * 5];
|
|
174
187
|
const y = data[i * 5 + 1];
|
|
175
|
-
if (x < left)
|
|
188
|
+
if (x < left) {
|
|
176
189
|
left = x;
|
|
177
|
-
|
|
190
|
+
}
|
|
191
|
+
else if (x > right) {
|
|
178
192
|
right = x;
|
|
179
|
-
|
|
193
|
+
}
|
|
194
|
+
if (y < top) {
|
|
180
195
|
top = y;
|
|
181
|
-
|
|
196
|
+
}
|
|
197
|
+
else if (y > bottom) {
|
|
182
198
|
bottom = y;
|
|
199
|
+
}
|
|
183
200
|
}
|
|
184
201
|
return new rect_1.FloatRect(new vector2_1.Vector2f(left, top), new vector2_1.Vector2f(right - left, bottom - top));
|
|
185
202
|
}
|
|
@@ -190,17 +207,20 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
190
207
|
* @ko 인덱스 순서로 꼭짓점 공유 뷰를 순회합니다.
|
|
191
208
|
*/
|
|
192
209
|
*[Symbol.iterator]() {
|
|
193
|
-
for (let i = 0; i < this.count; i++)
|
|
210
|
+
for (let i = 0; i < this.count; i++) {
|
|
194
211
|
yield this.getVertex(i);
|
|
212
|
+
}
|
|
195
213
|
}
|
|
196
214
|
draw(target, states) {
|
|
197
215
|
target[graphics_state_1.recordVertices](this.bytes.subarray(0, this.count * 20), this.primitiveType, states);
|
|
198
216
|
}
|
|
199
217
|
[graphics_state_1.dispatchDrawable](target, states) {
|
|
200
|
-
if (this.draw === VertexArray.prototype.draw)
|
|
218
|
+
if (this.draw === VertexArray.prototype.draw) {
|
|
201
219
|
this.draw(target, states);
|
|
202
|
-
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
203
222
|
super[graphics_state_1.dispatchDrawable](target, states);
|
|
223
|
+
}
|
|
204
224
|
}
|
|
205
225
|
checkIndex(index) {
|
|
206
226
|
if (!Number.isInteger(index) || index < 0 || index >= this.count) {
|
|
@@ -208,8 +228,9 @@ class VertexArray extends drawable_1.Drawable {
|
|
|
208
228
|
}
|
|
209
229
|
}
|
|
210
230
|
ensureCapacity(count) {
|
|
211
|
-
if (count <= this.bytes.byteLength / 20)
|
|
231
|
+
if (count <= this.bytes.byteLength / 20) {
|
|
212
232
|
return;
|
|
233
|
+
}
|
|
213
234
|
const capacity = Math.min(maxVertices, Math.max(count, 4, this.bytes.byteLength / 10));
|
|
214
235
|
const mapping = native_1.native.createVertexStorage(capacity);
|
|
215
236
|
const bytes = new Uint8Array(mapping.buffer);
|
|
@@ -227,7 +248,8 @@ exports.VertexArray = VertexArray;
|
|
|
227
248
|
bytes: new Uint8Array(mapping.buffer),
|
|
228
249
|
coordinates: new Float32Array(mapping.buffer),
|
|
229
250
|
metadata: new Uint32Array([
|
|
230
|
-
mapping.buffer.byteLength / 20,
|
|
251
|
+
mapping.buffer.byteLength / 20,
|
|
252
|
+
primitive_type_1.PrimitiveType.Triangles,
|
|
231
253
|
]),
|
|
232
254
|
views: new Map(),
|
|
233
255
|
});
|
|
@@ -40,16 +40,20 @@ var VertexBufferUsage;
|
|
|
40
40
|
VertexBufferUsage["Static"] = "static";
|
|
41
41
|
})(VertexBufferUsage = exports.VertexBufferUsage || (exports.VertexBufferUsage = {}));
|
|
42
42
|
const usages = [
|
|
43
|
-
VertexBufferUsage.Stream,
|
|
43
|
+
VertexBufferUsage.Stream,
|
|
44
|
+
VertexBufferUsage.Dynamic,
|
|
45
|
+
VertexBufferUsage.Static,
|
|
44
46
|
];
|
|
45
47
|
function usageIndex(usage) {
|
|
46
48
|
const index = usages.indexOf(usage);
|
|
47
|
-
if (index === -1)
|
|
49
|
+
if (index === -1) {
|
|
48
50
|
throw new RangeError('Invalid vertex buffer usage');
|
|
51
|
+
}
|
|
49
52
|
return index;
|
|
50
53
|
}
|
|
51
54
|
function validateCount(count) {
|
|
52
|
-
if (!Number.isInteger(count) ||
|
|
55
|
+
if (!Number.isInteger(count) ||
|
|
56
|
+
count < 0 ||
|
|
53
57
|
count > Math.floor(0x7fffffff / 20)) {
|
|
54
58
|
throw new RangeError('Vertex count exceeds the buffer limit');
|
|
55
59
|
}
|
|
@@ -65,10 +69,16 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
65
69
|
constructor(source = primitive_type_1.PrimitiveType.Points, usage = VertexBufferUsage.Stream) {
|
|
66
70
|
super();
|
|
67
71
|
const copy = source instanceof VertexBuffer ? source : undefined;
|
|
68
|
-
const type = copy
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
const type = copy
|
|
73
|
+
? copy.getPrimitiveType()
|
|
74
|
+
: typeof source === 'string'
|
|
75
|
+
? primitive_type_1.PrimitiveType.Points
|
|
76
|
+
: source;
|
|
77
|
+
const selectedUsage = copy
|
|
78
|
+
? copy.getUsage()
|
|
79
|
+
: typeof source === 'string'
|
|
80
|
+
? source
|
|
81
|
+
: usage;
|
|
72
82
|
(0, primitive_type_1.validatePrimitiveType)(type);
|
|
73
83
|
const mapping = native_1.native.createVertexBuffer((0, graphics_state_1.graphicsContext)(), type, usageIndex(selectedUsage), copy?.[graphics_state_1.graphicsNative]);
|
|
74
84
|
this[graphics_state_1.graphicsNative] = mapping.handle;
|
|
@@ -85,7 +95,8 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
85
95
|
create(vertexCount) {
|
|
86
96
|
validateCount(vertexCount);
|
|
87
97
|
(0, graphics_state_1.flushGraphics)();
|
|
88
|
-
return native_1.native.allocateVertexBuffer(this[graphics_state_1.graphicsNative], vertexCount) !==
|
|
98
|
+
return (native_1.native.allocateVertexBuffer(this[graphics_state_1.graphicsNative], vertexCount) !==
|
|
99
|
+
undefined);
|
|
89
100
|
}
|
|
90
101
|
/**
|
|
91
102
|
* Returns the allocated vertex count.
|
|
@@ -102,7 +113,7 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
102
113
|
throw new TypeError('Buffer copies do not accept a vertex range');
|
|
103
114
|
}
|
|
104
115
|
(0, graphics_state_1.flushGraphics)();
|
|
105
|
-
return native_1.native.copyVertexBuffer(this[graphics_state_1.graphicsNative], source[graphics_state_1.graphicsNative]) !== undefined;
|
|
116
|
+
return (native_1.native.copyVertexBuffer(this[graphics_state_1.graphicsNative], source[graphics_state_1.graphicsNative]) !== undefined);
|
|
106
117
|
}
|
|
107
118
|
const count = vertexCount ?? this.info.count;
|
|
108
119
|
validateCount(count);
|
|
@@ -117,24 +128,28 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
130
|
else {
|
|
120
|
-
if (!Array.isArray(source))
|
|
131
|
+
if (!Array.isArray(source)) {
|
|
121
132
|
throw new TypeError('Expected vertex data');
|
|
122
|
-
|
|
133
|
+
}
|
|
134
|
+
if (count > source.length) {
|
|
123
135
|
throw new RangeError('Not enough source vertices');
|
|
136
|
+
}
|
|
124
137
|
bytes = new Uint8Array(count * 20);
|
|
125
138
|
for (let i = 0; i < count; i++) {
|
|
126
139
|
const vertex = source[i];
|
|
127
|
-
if (!(vertex instanceof vertex_1.Vertex) ||
|
|
140
|
+
if (!(vertex instanceof vertex_1.Vertex) ||
|
|
141
|
+
vertex[value_storage_1.vertexStorage].byteLength !== 20) {
|
|
128
142
|
throw new TypeError('Expected attached Vertex values');
|
|
129
143
|
}
|
|
130
144
|
bytes.set(vertex[value_storage_1.vertexStorage], i * 20);
|
|
131
145
|
}
|
|
132
146
|
}
|
|
133
147
|
if (!this.info.nativeHandle ||
|
|
134
|
-
(offset !== 0 && offset + count > this.info.count))
|
|
148
|
+
(offset !== 0 && offset + count > this.info.count)) {
|
|
135
149
|
return false;
|
|
150
|
+
}
|
|
136
151
|
(0, graphics_state_1.flushGraphics)();
|
|
137
|
-
return native_1.native.updateVertexBuffer(this[graphics_state_1.graphicsNative], bytes, count, offset) !== undefined;
|
|
152
|
+
return (native_1.native.updateVertexBuffer(this[graphics_state_1.graphicsNative], bytes, count, offset) !== undefined);
|
|
138
153
|
}
|
|
139
154
|
/**
|
|
140
155
|
* Swaps data and settings of two buffers, first submitting queued draws to
|
|
@@ -144,10 +159,12 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
144
159
|
* @ko 두 버퍼의 데이터와 설정을 교환합니다. 스냅샷 의미를 유지하기 위해 대기 중인 그리기를 먼저 제출합니다.
|
|
145
160
|
*/
|
|
146
161
|
swap(other) {
|
|
147
|
-
if (!(other instanceof VertexBuffer))
|
|
162
|
+
if (!(other instanceof VertexBuffer)) {
|
|
148
163
|
throw new TypeError('Expected a VertexBuffer');
|
|
149
|
-
|
|
164
|
+
}
|
|
165
|
+
if (other === this) {
|
|
150
166
|
return;
|
|
167
|
+
}
|
|
151
168
|
(0, graphics_state_1.flushGraphics)();
|
|
152
169
|
native_1.native.swapVertexBuffers(this[graphics_state_1.graphicsNative], other[graphics_state_1.graphicsNative]);
|
|
153
170
|
}
|
|
@@ -162,8 +179,9 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
162
179
|
if (!(source instanceof VertexBuffer)) {
|
|
163
180
|
throw new TypeError('Expected a VertexBuffer');
|
|
164
181
|
}
|
|
165
|
-
if (source === this)
|
|
182
|
+
if (source === this) {
|
|
166
183
|
return this;
|
|
184
|
+
}
|
|
167
185
|
(0, graphics_state_1.flushGraphics)();
|
|
168
186
|
native_1.native.assignVertexBuffer(this[graphics_state_1.graphicsNative], source[graphics_state_1.graphicsNative]);
|
|
169
187
|
return this;
|
|
@@ -240,10 +258,12 @@ class VertexBuffer extends drawable_1.Drawable {
|
|
|
240
258
|
target[graphics_state_1.recordVertexBuffer](this, 0, this.info.count, states);
|
|
241
259
|
}
|
|
242
260
|
[graphics_state_1.dispatchDrawable](target, states) {
|
|
243
|
-
if (this.draw === VertexBuffer.prototype.draw)
|
|
261
|
+
if (this.draw === VertexBuffer.prototype.draw) {
|
|
244
262
|
this.draw(target, states);
|
|
245
|
-
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
246
265
|
super[graphics_state_1.dispatchDrawable](target, states);
|
|
266
|
+
}
|
|
247
267
|
}
|
|
248
268
|
}
|
|
249
269
|
/**
|
package/dist/graphics/vertex.js
CHANGED
|
@@ -19,8 +19,9 @@ class Vertex {
|
|
|
19
19
|
this.state = new lazy_value_1.LazyValue(new Uint8Array(20), buffer => native_1.native.wrapVertex(buffer));
|
|
20
20
|
this.coordinates = new Float32Array(this.state.values.buffer);
|
|
21
21
|
this.state.values.fill(255, 8, 12);
|
|
22
|
-
if (args.length === 0)
|
|
22
|
+
if (args.length === 0) {
|
|
23
23
|
return;
|
|
24
|
+
}
|
|
24
25
|
const source = args[0];
|
|
25
26
|
if (source instanceof Vertex && args.length === 1) {
|
|
26
27
|
// Copy bytes so RGBA and floating-point bit patterns remain intact.
|
|
@@ -31,10 +32,12 @@ class Vertex {
|
|
|
31
32
|
throw new TypeError('Vertex requires a Vertex or a Vector2f position');
|
|
32
33
|
}
|
|
33
34
|
this.position = source;
|
|
34
|
-
if (args[1] !== undefined)
|
|
35
|
+
if (args[1] !== undefined) {
|
|
35
36
|
this.color = args[1];
|
|
36
|
-
|
|
37
|
+
}
|
|
38
|
+
if (args[2] !== undefined) {
|
|
37
39
|
this.texCoords = args[2];
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
42
|
get [(_a = value_storage_1.mutableValue, value_storage_1.vertexStorage)]() {
|
|
40
43
|
return this.state.values;
|
package/dist/graphics/view.js
CHANGED
|
@@ -14,8 +14,9 @@ function vector(value) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
function rectangle(value) {
|
|
17
|
-
if (!(value instanceof rect_1.FloatRect))
|
|
17
|
+
if (!(value instanceof rect_1.FloatRect)) {
|
|
18
18
|
throw new TypeError('Expected a FloatRect');
|
|
19
|
+
}
|
|
19
20
|
}
|
|
20
21
|
function constantRectangle() {
|
|
21
22
|
const result = new rect_1.FloatRect(new vector2_1.Vector2f(), new vector2_1.Vector2f(1, 1));
|
|
@@ -23,15 +24,18 @@ function constantRectangle() {
|
|
|
23
24
|
const position = result.position;
|
|
24
25
|
const size = result.size;
|
|
25
26
|
Object.defineProperties(position, {
|
|
26
|
-
x: { get: () => data[0] },
|
|
27
|
+
x: { get: () => data[0] },
|
|
28
|
+
y: { get: () => data[1] },
|
|
27
29
|
});
|
|
28
30
|
Object.defineProperties(size, {
|
|
29
|
-
x: { get: () => data[2] },
|
|
31
|
+
x: { get: () => data[2] },
|
|
32
|
+
y: { get: () => data[3] },
|
|
30
33
|
});
|
|
31
34
|
Object.freeze(position);
|
|
32
35
|
Object.freeze(size);
|
|
33
36
|
Object.defineProperties(result, {
|
|
34
|
-
position: { value: position },
|
|
37
|
+
position: { value: position },
|
|
38
|
+
size: { value: size },
|
|
35
39
|
});
|
|
36
40
|
return Object.freeze(result);
|
|
37
41
|
}
|
|
@@ -53,8 +57,9 @@ class View {
|
|
|
53
57
|
transformDirty: true,
|
|
54
58
|
inverseDirty: true,
|
|
55
59
|
};
|
|
56
|
-
if (source instanceof View && size === undefined)
|
|
60
|
+
if (source instanceof View && size === undefined) {
|
|
57
61
|
(0, exports.copyView)(this, source);
|
|
62
|
+
}
|
|
58
63
|
else if (source instanceof rect_1.FloatRect && size === undefined) {
|
|
59
64
|
this.setCenter(source.getCenter());
|
|
60
65
|
this.setSize(source.size);
|
|
@@ -119,8 +124,9 @@ class View {
|
|
|
119
124
|
*/
|
|
120
125
|
setRotation(angle) {
|
|
121
126
|
this.checkWritable();
|
|
122
|
-
if (!(angle instanceof angle_1.Angle))
|
|
127
|
+
if (!(angle instanceof angle_1.Angle)) {
|
|
123
128
|
throw new TypeError('Expected an Angle');
|
|
129
|
+
}
|
|
124
130
|
this.state.data[4] = angle.wrapUnsigned().asRadians();
|
|
125
131
|
this.invalidate();
|
|
126
132
|
}
|
|
@@ -166,9 +172,14 @@ class View {
|
|
|
166
172
|
this.checkWritable();
|
|
167
173
|
rectangle(scissor);
|
|
168
174
|
const [x, y, width, height] = scissor[value_storage_1.rectStorage];
|
|
169
|
-
if (!(x >= 0 &&
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
if (!(x >= 0 &&
|
|
176
|
+
y >= 0 &&
|
|
177
|
+
x <= 1 &&
|
|
178
|
+
y <= 1 &&
|
|
179
|
+
width >= 0 &&
|
|
180
|
+
height >= 0 &&
|
|
181
|
+
f(x + width) <= 1 &&
|
|
182
|
+
f(y + height) <= 1)) {
|
|
172
183
|
throw new RangeError('Scissor rectangle must lie within [0, 1]');
|
|
173
184
|
}
|
|
174
185
|
this.state.scissor[value_storage_1.rectStorage].set(scissor[value_storage_1.rectStorage]);
|
|
@@ -203,8 +214,9 @@ class View {
|
|
|
203
214
|
* @ko 현재 뷰 각도에 angle을 더합니다.
|
|
204
215
|
*/
|
|
205
216
|
rotate(angle) {
|
|
206
|
-
if (!(angle instanceof angle_1.Angle))
|
|
217
|
+
if (!(angle instanceof angle_1.Angle)) {
|
|
207
218
|
throw new TypeError('Expected an Angle');
|
|
219
|
+
}
|
|
208
220
|
this.setRotation((0, angle_1.radians)(f(this.state.data[4] + angle.asRadians())));
|
|
209
221
|
}
|
|
210
222
|
/**
|
|
@@ -216,8 +228,9 @@ class View {
|
|
|
216
228
|
*/
|
|
217
229
|
zoom(factor) {
|
|
218
230
|
this.checkWritable();
|
|
219
|
-
if (typeof factor !== 'number')
|
|
231
|
+
if (typeof factor !== 'number') {
|
|
220
232
|
throw new TypeError('Expected a number');
|
|
233
|
+
}
|
|
221
234
|
const value = f(factor);
|
|
222
235
|
this.state.data[2] *= value;
|
|
223
236
|
this.state.data[3] *= value;
|
|
@@ -270,8 +283,9 @@ class View {
|
|
|
270
283
|
this.state.transformDirty = this.state.inverseDirty = true;
|
|
271
284
|
}
|
|
272
285
|
checkWritable() {
|
|
273
|
-
if (Object.isFrozen(this))
|
|
286
|
+
if (Object.isFrozen(this)) {
|
|
274
287
|
throw new TypeError('Cannot modify a const View');
|
|
288
|
+
}
|
|
275
289
|
}
|
|
276
290
|
}
|
|
277
291
|
exports.View = View;
|
|
@@ -284,11 +298,13 @@ _a = value_storage_1.mutableValue;
|
|
|
284
298
|
destination.state.data.set(source.state.data);
|
|
285
299
|
destination.state.viewport[value_storage_1.rectStorage].set(source.state.viewport[value_storage_1.rectStorage]);
|
|
286
300
|
destination.state.scissor[value_storage_1.rectStorage].set(source.state.scissor[value_storage_1.rectStorage]);
|
|
287
|
-
destination.state.transformDirty =
|
|
301
|
+
destination.state.transformDirty =
|
|
302
|
+
destination.state.inverseDirty = true;
|
|
288
303
|
};
|
|
289
304
|
exports.writeView = (source, destination, offset) => {
|
|
290
|
-
if (!(source instanceof View))
|
|
305
|
+
if (!(source instanceof View)) {
|
|
291
306
|
throw new TypeError('Expected a View');
|
|
307
|
+
}
|
|
292
308
|
destination.set(source.state.data, offset);
|
|
293
309
|
destination.set(source.state.viewport[value_storage_1.rectStorage], offset + 5);
|
|
294
310
|
destination.set(source.state.scissor[value_storage_1.rectStorage], offset + 9);
|
package/dist/index.d.ts
CHANGED
|
@@ -7,13 +7,13 @@ export type { PacketValues, PacketType } from './network/packet';
|
|
|
7
7
|
export { Socket, SocketStatus, SocketType } from './network/socket';
|
|
8
8
|
export type { SocketHandle } from './network/socket';
|
|
9
9
|
export { TcpSocket, TlsStatus } from './network/tcp-socket';
|
|
10
|
-
export type { SocketTransfer, SocketSendResult } from './network/tcp-socket';
|
|
10
|
+
export type { SocketTransfer, SocketSendResult, } from './network/tcp-socket';
|
|
11
11
|
export { TcpListener } from './network/tcp-listener';
|
|
12
12
|
export { UdpSocket } from './network/udp-socket';
|
|
13
13
|
export type { DatagramResult } from './network/udp-socket';
|
|
14
14
|
export { SocketSelector, ReadinessType } from './network/socket-selector';
|
|
15
15
|
export type { ReadyCallback } from './network/socket-selector';
|
|
16
|
-
export { Http, HttpRequest, HttpResponse, HttpMethod, HttpStatus } from './network/http';
|
|
16
|
+
export { Http, HttpRequest, HttpResponse, HttpMethod, HttpStatus, } from './network/http';
|
|
17
17
|
export { Ftp, FtpResponse, FtpDirectoryResponse, FtpListingResponse, FtpStatus, TransferMode, } from './network/ftp';
|
|
18
18
|
export { Sftp, SftpResult, SftpPathResult, SftpAttributesResult, SftpListingResult, SftpResultValue, SftpHostKeyType, FileType, } from './network/sftp';
|
|
19
19
|
export type { SftpAttributes, SftpSessionInfo, SftpTimeout, SftpDownloadCallback, SftpUploadCallback, SftpUploadChunk, } from './network/sftp';
|
|
@@ -30,13 +30,13 @@ export { Sound } from './audio/sound';
|
|
|
30
30
|
export { Music } from './audio/music';
|
|
31
31
|
export { InputSoundFile } from './audio/input-sound-file';
|
|
32
32
|
export { OutputSoundFile } from './audio/output-sound-file';
|
|
33
|
-
export { SoundFileReader, SoundFileReaderInfo } from './audio/sound-file-reader';
|
|
33
|
+
export { SoundFileReader, SoundFileReaderInfo, } from './audio/sound-file-reader';
|
|
34
34
|
export type { SoundFileReaderInfoInput, SoundFileReaderConstructor, } from './audio/sound-file-reader';
|
|
35
35
|
export { SoundFileWriter } from './audio/sound-file-writer';
|
|
36
36
|
export type { SoundFileWriterConstructor } from './audio/sound-file-writer';
|
|
37
37
|
export { SoundFileFactory } from './audio/sound-file-factory';
|
|
38
38
|
export { Cone, TimeSpan, SoundChannel, SoundStatus } from './audio/value';
|
|
39
|
-
export type { ConeInput, TimeSpanInput, ReadonlySamples, ChannelMap } from './audio/value';
|
|
39
|
+
export type { ConeInput, TimeSpanInput, ReadonlySamples, ChannelMap, } from './audio/value';
|
|
40
40
|
export * as Listener from './audio/listener';
|
|
41
41
|
export * as PlaybackDevice from './audio/playback-device';
|
|
42
42
|
export { err, setErrorOutput } from './system/err';
|
|
@@ -7,15 +7,17 @@ exports.audioReaders = new Set();
|
|
|
7
7
|
exports.audioWriters = new Set();
|
|
8
8
|
async function findAudioReader(stream) {
|
|
9
9
|
for (const Reader of [...exports.audioReaders].reverse()) {
|
|
10
|
-
if (await stream.seek(0n) !== 0n)
|
|
10
|
+
if (await stream.seek(0n) !== 0n) {
|
|
11
11
|
return undefined;
|
|
12
|
+
}
|
|
12
13
|
const matches = await Reader.check(stream);
|
|
13
14
|
if (typeof matches !== 'boolean') {
|
|
14
15
|
throw new TypeError('Reader.check must return a boolean');
|
|
15
16
|
}
|
|
16
17
|
if (matches) {
|
|
17
|
-
if (await stream.seek(0n) !== 0n)
|
|
18
|
+
if (await stream.seek(0n) !== 0n) {
|
|
18
19
|
return undefined;
|
|
20
|
+
}
|
|
19
21
|
return new Reader();
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -29,21 +31,24 @@ async function findAudioWriter(filename) {
|
|
|
29
31
|
if (typeof matches !== 'boolean') {
|
|
30
32
|
throw new TypeError('Writer.check must return a boolean');
|
|
31
33
|
}
|
|
32
|
-
if (matches)
|
|
34
|
+
if (matches) {
|
|
33
35
|
return new Writer();
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
return undefined;
|
|
36
39
|
}
|
|
37
40
|
exports.findAudioWriter = findAudioWriter;
|
|
38
41
|
async function findAudioReaderInput(input) {
|
|
39
|
-
if (!exports.audioReaders.size)
|
|
42
|
+
if (!exports.audioReaders.size) {
|
|
40
43
|
return undefined;
|
|
44
|
+
}
|
|
41
45
|
let owned;
|
|
42
46
|
let stream;
|
|
43
47
|
if (typeof input === 'string') {
|
|
44
48
|
owned = new file_input_stream_1.FileInputStream();
|
|
45
|
-
if (!await owned.open(input))
|
|
49
|
+
if (!await owned.open(input)) {
|
|
46
50
|
return undefined;
|
|
51
|
+
}
|
|
47
52
|
stream = owned;
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
@@ -51,8 +56,9 @@ async function findAudioReaderInput(input) {
|
|
|
51
56
|
}
|
|
52
57
|
try {
|
|
53
58
|
const reader = await findAudioReader(stream);
|
|
54
|
-
if (reader)
|
|
59
|
+
if (reader) {
|
|
55
60
|
return { reader, stream, owned };
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
catch (error) {
|
|
58
64
|
await owned?.close();
|
|
@@ -27,8 +27,9 @@ class AudioInputStream {
|
|
|
27
27
|
return await action();
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
|
-
if (this.failure.failed)
|
|
30
|
+
if (this.failure.failed) {
|
|
31
31
|
throw this.failure.error;
|
|
32
|
+
}
|
|
32
33
|
if (this.closed && error instanceof Error &&
|
|
33
34
|
error.message === 'Audio InputStream closed') {
|
|
34
35
|
cancellations.add(error);
|