sfml.js 1.0.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +10 -9
- package/README.ko.md +10 -9
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +44 -51
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -144
- package/docs/development.ko.md +0 -144
- package/docs/development.md +0 -146
- package/docs/development.zh-CN.md +0 -146
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -107
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
native,
|
|
2
|
+
native,
|
|
3
|
+
type NativeGraphicsHandle,
|
|
4
|
+
type NativeVertexBufferInfo,
|
|
3
5
|
} from '../internal/native';
|
|
4
6
|
import {
|
|
5
|
-
dispatchDrawable,
|
|
6
|
-
|
|
7
|
+
dispatchDrawable,
|
|
8
|
+
flushGraphics,
|
|
9
|
+
graphicsContext,
|
|
10
|
+
graphicsNative,
|
|
11
|
+
recordVertexBuffer,
|
|
12
|
+
vertexArrayBytes,
|
|
13
|
+
vertexBufferId,
|
|
7
14
|
} from '../internal/graphics-state';
|
|
8
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
vertexStorage,
|
|
17
|
+
type ReadonlyValue,
|
|
18
|
+
} from '../internal/value-storage';
|
|
9
19
|
import { nativeStruct } from '../internal/struct-view';
|
|
10
20
|
import { Drawable } from './drawable';
|
|
11
21
|
import { PrimitiveType, validatePrimitiveType } from './primitive-type';
|
|
@@ -45,19 +55,26 @@ export enum VertexBufferUsage {
|
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
const usages = [
|
|
48
|
-
VertexBufferUsage.Stream,
|
|
58
|
+
VertexBufferUsage.Stream,
|
|
59
|
+
VertexBufferUsage.Dynamic,
|
|
60
|
+
VertexBufferUsage.Static,
|
|
49
61
|
];
|
|
50
62
|
type Vertices = VertexArray | readonly ReadonlyValue<Vertex>[];
|
|
51
63
|
|
|
52
64
|
function usageIndex(usage: VertexBufferUsage): number {
|
|
53
65
|
const index = usages.indexOf(usage);
|
|
54
|
-
if (index === -1)
|
|
66
|
+
if (index === -1) {
|
|
67
|
+
throw new RangeError('Invalid vertex buffer usage');
|
|
68
|
+
}
|
|
55
69
|
return index;
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
function validateCount(count: number): void {
|
|
59
|
-
if (
|
|
60
|
-
|
|
73
|
+
if (
|
|
74
|
+
!Number.isInteger(count) ||
|
|
75
|
+
count < 0 ||
|
|
76
|
+
count > Math.floor(0x7fffffff / 20)
|
|
77
|
+
) {
|
|
61
78
|
throw new RangeError('Vertex count exceeds the buffer limit');
|
|
62
79
|
}
|
|
63
80
|
}
|
|
@@ -123,18 +140,31 @@ export class VertexBuffer extends Drawable {
|
|
|
123
140
|
*/
|
|
124
141
|
constructor(source: VertexBuffer);
|
|
125
142
|
constructor(
|
|
126
|
-
source:
|
|
143
|
+
source:
|
|
144
|
+
| PrimitiveType
|
|
145
|
+
| VertexBufferUsage
|
|
146
|
+
| VertexBuffer = PrimitiveType.Points,
|
|
127
147
|
usage = VertexBufferUsage.Stream,
|
|
128
148
|
) {
|
|
129
149
|
super();
|
|
130
150
|
const copy = source instanceof VertexBuffer ? source : undefined;
|
|
131
|
-
const type = copy
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
const type = copy
|
|
152
|
+
? copy.getPrimitiveType()
|
|
153
|
+
: typeof source === 'string'
|
|
154
|
+
? PrimitiveType.Points
|
|
155
|
+
: (source as PrimitiveType);
|
|
156
|
+
const selectedUsage = copy
|
|
157
|
+
? copy.getUsage()
|
|
158
|
+
: typeof source === 'string'
|
|
159
|
+
? source
|
|
160
|
+
: usage;
|
|
135
161
|
validatePrimitiveType(type);
|
|
136
162
|
const mapping = native.createVertexBuffer(
|
|
137
|
-
graphicsContext(),
|
|
163
|
+
graphicsContext(),
|
|
164
|
+
type,
|
|
165
|
+
usageIndex(selectedUsage),
|
|
166
|
+
copy?.[graphicsNative],
|
|
167
|
+
);
|
|
138
168
|
this[graphicsNative] = mapping.handle;
|
|
139
169
|
this[vertexBufferId] = mapping.id;
|
|
140
170
|
this.info = nativeStruct<NativeVertexBufferInfo>(mapping.info);
|
|
@@ -150,8 +180,10 @@ export class VertexBuffer extends Drawable {
|
|
|
150
180
|
create(vertexCount: number): boolean {
|
|
151
181
|
validateCount(vertexCount);
|
|
152
182
|
flushGraphics();
|
|
153
|
-
return
|
|
154
|
-
this[graphicsNative], vertexCount) !==
|
|
183
|
+
return (
|
|
184
|
+
native.allocateVertexBuffer(this[graphicsNative], vertexCount) !==
|
|
185
|
+
undefined
|
|
186
|
+
);
|
|
155
187
|
}
|
|
156
188
|
|
|
157
189
|
/**
|
|
@@ -187,15 +219,22 @@ export class VertexBuffer extends Drawable {
|
|
|
187
219
|
* @ko source의 GPU 꼭짓점 데이터를 복사하고 성공 여부를 반환합니다.
|
|
188
220
|
*/
|
|
189
221
|
update(source: VertexBuffer): boolean;
|
|
190
|
-
update(
|
|
191
|
-
|
|
222
|
+
update(
|
|
223
|
+
source: Vertices | VertexBuffer,
|
|
224
|
+
vertexCount?: number,
|
|
225
|
+
offset = 0,
|
|
226
|
+
): boolean {
|
|
192
227
|
if (source instanceof VertexBuffer) {
|
|
193
228
|
if (vertexCount !== undefined) {
|
|
194
229
|
throw new TypeError('Buffer copies do not accept a vertex range');
|
|
195
230
|
}
|
|
196
231
|
flushGraphics();
|
|
197
|
-
return
|
|
198
|
-
|
|
232
|
+
return (
|
|
233
|
+
native.copyVertexBuffer(
|
|
234
|
+
this[graphicsNative],
|
|
235
|
+
source[graphicsNative],
|
|
236
|
+
) !== undefined
|
|
237
|
+
);
|
|
199
238
|
}
|
|
200
239
|
const count = vertexCount ?? this.info.count;
|
|
201
240
|
validateCount(count);
|
|
@@ -209,22 +248,39 @@ export class VertexBuffer extends Drawable {
|
|
|
209
248
|
throw new RangeError('Not enough source vertices');
|
|
210
249
|
}
|
|
211
250
|
} else {
|
|
212
|
-
if (!Array.isArray(source))
|
|
213
|
-
|
|
251
|
+
if (!Array.isArray(source)) {
|
|
252
|
+
throw new TypeError('Expected vertex data');
|
|
253
|
+
}
|
|
254
|
+
if (count > source.length) {
|
|
255
|
+
throw new RangeError('Not enough source vertices');
|
|
256
|
+
}
|
|
214
257
|
bytes = new Uint8Array(count * 20);
|
|
215
258
|
for (let i = 0; i < count; i++) {
|
|
216
259
|
const vertex = source[i];
|
|
217
|
-
if (
|
|
260
|
+
if (
|
|
261
|
+
!(vertex instanceof Vertex) ||
|
|
262
|
+
vertex[vertexStorage].byteLength !== 20
|
|
263
|
+
) {
|
|
218
264
|
throw new TypeError('Expected attached Vertex values');
|
|
219
265
|
}
|
|
220
266
|
bytes.set(vertex[vertexStorage], i * 20);
|
|
221
267
|
}
|
|
222
268
|
}
|
|
223
|
-
if (
|
|
224
|
-
|
|
269
|
+
if (
|
|
270
|
+
!this.info.nativeHandle ||
|
|
271
|
+
(offset !== 0 && offset + count > this.info.count)
|
|
272
|
+
) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
225
275
|
flushGraphics();
|
|
226
|
-
return
|
|
227
|
-
|
|
276
|
+
return (
|
|
277
|
+
native.updateVertexBuffer(
|
|
278
|
+
this[graphicsNative],
|
|
279
|
+
bytes,
|
|
280
|
+
count,
|
|
281
|
+
offset,
|
|
282
|
+
) !== undefined
|
|
283
|
+
);
|
|
228
284
|
}
|
|
229
285
|
|
|
230
286
|
/**
|
|
@@ -235,8 +291,12 @@ export class VertexBuffer extends Drawable {
|
|
|
235
291
|
* @ko 두 버퍼의 데이터와 설정을 교환합니다. 스냅샷 의미를 유지하기 위해 대기 중인 그리기를 먼저 제출합니다.
|
|
236
292
|
*/
|
|
237
293
|
swap(other: VertexBuffer): void {
|
|
238
|
-
if (!(other instanceof VertexBuffer))
|
|
239
|
-
|
|
294
|
+
if (!(other instanceof VertexBuffer)) {
|
|
295
|
+
throw new TypeError('Expected a VertexBuffer');
|
|
296
|
+
}
|
|
297
|
+
if (other === this) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
240
300
|
flushGraphics();
|
|
241
301
|
native.swapVertexBuffers(this[graphicsNative], other[graphicsNative]);
|
|
242
302
|
}
|
|
@@ -252,7 +312,9 @@ export class VertexBuffer extends Drawable {
|
|
|
252
312
|
if (!(source instanceof VertexBuffer)) {
|
|
253
313
|
throw new TypeError('Expected a VertexBuffer');
|
|
254
314
|
}
|
|
255
|
-
if (source === this)
|
|
315
|
+
if (source === this) {
|
|
316
|
+
return this;
|
|
317
|
+
}
|
|
256
318
|
flushGraphics();
|
|
257
319
|
native.assignVertexBuffer(this[graphicsNative], source[graphicsNative]);
|
|
258
320
|
return this;
|
|
@@ -338,8 +400,10 @@ export class VertexBuffer extends Drawable {
|
|
|
338
400
|
}
|
|
339
401
|
|
|
340
402
|
[dispatchDrawable](target: RenderTarget, states: RenderStates): void {
|
|
341
|
-
if (this.draw === VertexBuffer.prototype.draw)
|
|
342
|
-
|
|
403
|
+
if (this.draw === VertexBuffer.prototype.draw) {
|
|
404
|
+
this.draw(target, states);
|
|
405
|
+
} else {
|
|
406
|
+
super[dispatchDrawable](target, states);
|
|
407
|
+
}
|
|
343
408
|
}
|
|
344
|
-
|
|
345
409
|
}
|
package/src/graphics/vertex.ts
CHANGED
|
@@ -93,7 +93,9 @@ export class Vertex {
|
|
|
93
93
|
constructor(...args: VertexArguments) {
|
|
94
94
|
this.coordinates = new Float32Array(this.state.values.buffer);
|
|
95
95
|
this.state.values.fill(255, 8, 12);
|
|
96
|
-
if (args.length === 0)
|
|
96
|
+
if (args.length === 0) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
97
99
|
const source = args[0];
|
|
98
100
|
if (source instanceof Vertex && args.length === 1) {
|
|
99
101
|
// Copy bytes so RGBA and floating-point bit patterns remain intact.
|
|
@@ -104,8 +106,12 @@ export class Vertex {
|
|
|
104
106
|
throw new TypeError('Vertex requires a Vertex or a Vector2f position');
|
|
105
107
|
}
|
|
106
108
|
this.position = source;
|
|
107
|
-
if (args[1] !== undefined)
|
|
108
|
-
|
|
109
|
+
if (args[1] !== undefined) {
|
|
110
|
+
this.color = args[1];
|
|
111
|
+
}
|
|
112
|
+
if (args[2] !== undefined) {
|
|
113
|
+
this.texCoords = args[2];
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
get [vertexStorage](): Uint8Array {
|
package/src/graphics/view.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
mutableValue,
|
|
2
|
+
mutableValue,
|
|
3
|
+
rectStorage,
|
|
4
|
+
transformStorage,
|
|
5
|
+
type ReadonlyValue as R,
|
|
3
6
|
} from '../internal/value-storage';
|
|
4
7
|
import { Angle, radians } from '../system/angle';
|
|
5
8
|
import { Vector2, Vector2f } from '../system/vector2';
|
|
@@ -15,7 +18,9 @@ function vector(value: R<Vector2f>): void {
|
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
function rectangle(value: R<FloatRect>): void {
|
|
18
|
-
if (!(value instanceof FloatRect))
|
|
21
|
+
if (!(value instanceof FloatRect)) {
|
|
22
|
+
throw new TypeError('Expected a FloatRect');
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
function constantRectangle(): R<FloatRect> {
|
|
@@ -24,15 +29,18 @@ function constantRectangle(): R<FloatRect> {
|
|
|
24
29
|
const position = result.position;
|
|
25
30
|
const size = result.size;
|
|
26
31
|
Object.defineProperties(position, {
|
|
27
|
-
x: { get: () => data[0] },
|
|
32
|
+
x: { get: () => data[0] },
|
|
33
|
+
y: { get: () => data[1] },
|
|
28
34
|
});
|
|
29
35
|
Object.defineProperties(size, {
|
|
30
|
-
x: { get: () => data[2] },
|
|
36
|
+
x: { get: () => data[2] },
|
|
37
|
+
y: { get: () => data[3] },
|
|
31
38
|
});
|
|
32
39
|
Object.freeze(position);
|
|
33
40
|
Object.freeze(size);
|
|
34
41
|
Object.defineProperties(result, {
|
|
35
|
-
position: { value: position },
|
|
42
|
+
position: { value: position },
|
|
43
|
+
size: { value: size },
|
|
36
44
|
});
|
|
37
45
|
return Object.freeze(result);
|
|
38
46
|
}
|
|
@@ -51,7 +59,9 @@ export let copyView: (destination: R<View>, source: R<View>) => void;
|
|
|
51
59
|
* @ko 내부 명령 인코딩 순서는 중심, 크기, 라디안, 뷰포트, 시저입니다.
|
|
52
60
|
*/
|
|
53
61
|
export let writeView: (
|
|
54
|
-
source: R<View>,
|
|
62
|
+
source: R<View>,
|
|
63
|
+
destination: Float32Array,
|
|
64
|
+
offset: number,
|
|
55
65
|
) => void;
|
|
56
66
|
|
|
57
67
|
/**
|
|
@@ -79,12 +89,18 @@ export class View {
|
|
|
79
89
|
}
|
|
80
90
|
destination.state.data.set(source.state.data);
|
|
81
91
|
destination.state.viewport[rectStorage].set(
|
|
82
|
-
source.state.viewport[rectStorage]
|
|
83
|
-
|
|
84
|
-
destination.state.
|
|
92
|
+
source.state.viewport[rectStorage],
|
|
93
|
+
);
|
|
94
|
+
destination.state.scissor[rectStorage].set(
|
|
95
|
+
source.state.scissor[rectStorage],
|
|
96
|
+
);
|
|
97
|
+
destination.state.transformDirty =
|
|
98
|
+
destination.state.inverseDirty = true;
|
|
85
99
|
};
|
|
86
100
|
writeView = (source, destination, offset) => {
|
|
87
|
-
if (!(source instanceof View))
|
|
101
|
+
if (!(source instanceof View)) {
|
|
102
|
+
throw new TypeError('Expected a View');
|
|
103
|
+
}
|
|
88
104
|
destination.set(source.state.data, offset);
|
|
89
105
|
destination.set(source.state.viewport[rectStorage], offset + 5);
|
|
90
106
|
destination.set(source.state.scissor[rectStorage], offset + 9);
|
|
@@ -120,9 +136,13 @@ export class View {
|
|
|
120
136
|
* @ko 월드 좌표의 중심과 크기로 뷰를 만듭니다.
|
|
121
137
|
*/
|
|
122
138
|
constructor(center: R<Vector2f>, size: R<Vector2f>);
|
|
123
|
-
constructor(
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
constructor(
|
|
140
|
+
source?: R<View> | R<FloatRect> | R<Vector2f>,
|
|
141
|
+
size?: R<Vector2f>,
|
|
142
|
+
) {
|
|
143
|
+
if (source instanceof View && size === undefined) {
|
|
144
|
+
copyView(this, source);
|
|
145
|
+
} else if (source instanceof FloatRect && size === undefined) {
|
|
126
146
|
this.setCenter(source.getCenter());
|
|
127
147
|
this.setSize(source.size);
|
|
128
148
|
} else if (source !== undefined && size !== undefined) {
|
|
@@ -189,7 +209,9 @@ export class View {
|
|
|
189
209
|
*/
|
|
190
210
|
setRotation(this: View, angle: R<Angle>): void {
|
|
191
211
|
this.checkWritable();
|
|
192
|
-
if (!(angle instanceof Angle))
|
|
212
|
+
if (!(angle instanceof Angle)) {
|
|
213
|
+
throw new TypeError('Expected an Angle');
|
|
214
|
+
}
|
|
193
215
|
this.state.data[4] = angle.wrapUnsigned().asRadians();
|
|
194
216
|
this.invalidate();
|
|
195
217
|
}
|
|
@@ -239,9 +261,18 @@ export class View {
|
|
|
239
261
|
this.checkWritable();
|
|
240
262
|
rectangle(scissor);
|
|
241
263
|
const [ x, y, width, height ] = scissor[rectStorage];
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
264
|
+
if (
|
|
265
|
+
!(
|
|
266
|
+
x >= 0 &&
|
|
267
|
+
y >= 0 &&
|
|
268
|
+
x <= 1 &&
|
|
269
|
+
y <= 1 &&
|
|
270
|
+
width >= 0 &&
|
|
271
|
+
height >= 0 &&
|
|
272
|
+
f(x + width) <= 1 &&
|
|
273
|
+
f(y + height) <= 1
|
|
274
|
+
)
|
|
275
|
+
) {
|
|
245
276
|
throw new RangeError('Scissor rectangle must lie within [0, 1]');
|
|
246
277
|
}
|
|
247
278
|
this.state.scissor[rectStorage].set(scissor[rectStorage]);
|
|
@@ -279,7 +310,9 @@ export class View {
|
|
|
279
310
|
* @ko 현재 뷰 각도에 angle을 더합니다.
|
|
280
311
|
*/
|
|
281
312
|
rotate(this: View, angle: R<Angle>): void {
|
|
282
|
-
if (!(angle instanceof Angle))
|
|
313
|
+
if (!(angle instanceof Angle)) {
|
|
314
|
+
throw new TypeError('Expected an Angle');
|
|
315
|
+
}
|
|
283
316
|
this.setRotation(radians(f(this.state.data[4] + angle.asRadians())));
|
|
284
317
|
}
|
|
285
318
|
|
|
@@ -292,7 +325,9 @@ export class View {
|
|
|
292
325
|
*/
|
|
293
326
|
zoom(this: View, factor: number): void {
|
|
294
327
|
this.checkWritable();
|
|
295
|
-
if (typeof factor !== 'number')
|
|
328
|
+
if (typeof factor !== 'number') {
|
|
329
|
+
throw new TypeError('Expected a number');
|
|
330
|
+
}
|
|
296
331
|
const value = f(factor);
|
|
297
332
|
this.state.data[2] *= value;
|
|
298
333
|
this.state.data[3] *= value;
|
|
@@ -339,7 +374,8 @@ export class View {
|
|
|
339
374
|
const state = this.state;
|
|
340
375
|
if (state.inverseDirty) {
|
|
341
376
|
state.inverse[transformStorage].set(
|
|
342
|
-
this.getTransform().getInverse()[transformStorage]
|
|
377
|
+
this.getTransform().getInverse()[transformStorage],
|
|
378
|
+
);
|
|
343
379
|
state.inverseDirty = false;
|
|
344
380
|
}
|
|
345
381
|
return state.inverse;
|
|
@@ -350,6 +386,8 @@ export class View {
|
|
|
350
386
|
}
|
|
351
387
|
|
|
352
388
|
private checkWritable(): void {
|
|
353
|
-
if (Object.isFrozen(this))
|
|
389
|
+
if (Object.isFrozen(this)) {
|
|
390
|
+
throw new TypeError('Cannot modify a const View');
|
|
391
|
+
}
|
|
354
392
|
}
|
|
355
393
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,23 +7,47 @@ 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 {
|
|
10
|
+
export type {
|
|
11
|
+
SocketTransfer,
|
|
12
|
+
SocketSendResult,
|
|
13
|
+
} from './network/tcp-socket';
|
|
11
14
|
export { TcpListener } from './network/tcp-listener';
|
|
12
15
|
export { UdpSocket } from './network/udp-socket';
|
|
13
16
|
export type { DatagramResult } from './network/udp-socket';
|
|
14
17
|
export { SocketSelector, ReadinessType } from './network/socket-selector';
|
|
15
18
|
export type { ReadyCallback } from './network/socket-selector';
|
|
16
|
-
export { Http, HttpRequest, HttpResponse, HttpMethod, HttpStatus } from './network/http';
|
|
17
19
|
export {
|
|
18
|
-
|
|
20
|
+
Http,
|
|
21
|
+
HttpRequest,
|
|
22
|
+
HttpResponse,
|
|
23
|
+
HttpMethod,
|
|
24
|
+
HttpStatus,
|
|
25
|
+
} from './network/http';
|
|
26
|
+
export {
|
|
27
|
+
Ftp,
|
|
28
|
+
FtpResponse,
|
|
29
|
+
FtpDirectoryResponse,
|
|
30
|
+
FtpListingResponse,
|
|
31
|
+
FtpStatus,
|
|
32
|
+
TransferMode,
|
|
19
33
|
} from './network/ftp';
|
|
20
34
|
export {
|
|
21
|
-
Sftp,
|
|
22
|
-
|
|
35
|
+
Sftp,
|
|
36
|
+
SftpResult,
|
|
37
|
+
SftpPathResult,
|
|
38
|
+
SftpAttributesResult,
|
|
39
|
+
SftpListingResult,
|
|
40
|
+
SftpResultValue,
|
|
41
|
+
SftpHostKeyType,
|
|
42
|
+
FileType,
|
|
23
43
|
} from './network/sftp';
|
|
24
44
|
export type {
|
|
25
|
-
SftpAttributes,
|
|
26
|
-
|
|
45
|
+
SftpAttributes,
|
|
46
|
+
SftpSessionInfo,
|
|
47
|
+
SftpTimeout,
|
|
48
|
+
SftpDownloadCallback,
|
|
49
|
+
SftpUploadCallback,
|
|
50
|
+
SftpUploadChunk,
|
|
27
51
|
} from './network/sftp';
|
|
28
52
|
export { SoundBuffer } from './audio/sound-buffer';
|
|
29
53
|
export type { ReadonlySoundBuffer } from './audio/sound-buffer';
|
|
@@ -34,23 +58,39 @@ export { SoundBufferRecorder } from './audio/sound-buffer-recorder';
|
|
|
34
58
|
export { EffectProcessor } from './audio/effect-processor';
|
|
35
59
|
export type { EffectProcessorOptions } from './audio/effect-processor';
|
|
36
60
|
export type {
|
|
37
|
-
AudioWorkerModule,
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
AudioWorkerModule,
|
|
62
|
+
AudioWorkerOptions,
|
|
63
|
+
AudioWorkerContext,
|
|
64
|
+
AudioWorkerStats,
|
|
65
|
+
SoundStreamOptions,
|
|
66
|
+
SoundStreamChunk,
|
|
67
|
+
SoundStreamCallbacks,
|
|
68
|
+
SoundRecorderCallbacks,
|
|
69
|
+
EffectFrames,
|
|
70
|
+
EffectProcessorCallbacks,
|
|
40
71
|
} from './audio/worker';
|
|
41
72
|
export { Sound } from './audio/sound';
|
|
42
73
|
export { Music } from './audio/music';
|
|
43
74
|
export { InputSoundFile } from './audio/input-sound-file';
|
|
44
75
|
export { OutputSoundFile } from './audio/output-sound-file';
|
|
45
|
-
export {
|
|
76
|
+
export {
|
|
77
|
+
SoundFileReader,
|
|
78
|
+
SoundFileReaderInfo,
|
|
79
|
+
} from './audio/sound-file-reader';
|
|
46
80
|
export type {
|
|
47
|
-
SoundFileReaderInfoInput,
|
|
81
|
+
SoundFileReaderInfoInput,
|
|
82
|
+
SoundFileReaderConstructor,
|
|
48
83
|
} from './audio/sound-file-reader';
|
|
49
84
|
export { SoundFileWriter } from './audio/sound-file-writer';
|
|
50
85
|
export type { SoundFileWriterConstructor } from './audio/sound-file-writer';
|
|
51
86
|
export { SoundFileFactory } from './audio/sound-file-factory';
|
|
52
87
|
export { Cone, TimeSpan, SoundChannel, SoundStatus } from './audio/value';
|
|
53
|
-
export type {
|
|
88
|
+
export type {
|
|
89
|
+
ConeInput,
|
|
90
|
+
TimeSpanInput,
|
|
91
|
+
ReadonlySamples,
|
|
92
|
+
ChannelMap,
|
|
93
|
+
} from './audio/value';
|
|
54
94
|
export * as Listener from './audio/listener';
|
|
55
95
|
export * as PlaybackDevice from './audio/playback-device';
|
|
56
96
|
export { err, setErrorOutput } from './system/err';
|
|
@@ -85,16 +125,34 @@ export * as Sensor from './window/sensor';
|
|
|
85
125
|
export * as Clipboard from './window/clipboard';
|
|
86
126
|
export * as Touch from './window/touch';
|
|
87
127
|
export type {
|
|
88
|
-
EventKind,
|
|
128
|
+
EventKind,
|
|
129
|
+
EventData,
|
|
130
|
+
EventPayloads,
|
|
131
|
+
EventHandlers,
|
|
132
|
+
EventVisitor,
|
|
89
133
|
} from './window/event';
|
|
90
134
|
export * from './window/gen/constants';
|
|
91
135
|
export { ContextAttribute } from './window/context-settings';
|
|
92
136
|
export type { ContextSettings } from './window/context-settings';
|
|
93
137
|
export type { ReadonlyValue } from './internal/value-storage';
|
|
94
138
|
export {
|
|
95
|
-
add,
|
|
96
|
-
|
|
97
|
-
|
|
139
|
+
add,
|
|
140
|
+
subtract,
|
|
141
|
+
negate,
|
|
142
|
+
addAssign,
|
|
143
|
+
subtractAssign,
|
|
144
|
+
multiply,
|
|
145
|
+
multiplyAssign,
|
|
146
|
+
divide,
|
|
147
|
+
divideAssign,
|
|
148
|
+
modulo,
|
|
149
|
+
moduloAssign,
|
|
150
|
+
equal,
|
|
151
|
+
notEqual,
|
|
152
|
+
less,
|
|
153
|
+
lessEqual,
|
|
154
|
+
greater,
|
|
155
|
+
greaterEqual,
|
|
98
156
|
} from './system/operators';
|
|
99
157
|
export { Texture } from './graphics/texture';
|
|
100
158
|
export type { ReadonlyTexture } from './graphics/texture';
|
|
@@ -105,10 +163,18 @@ export { Font } from './graphics/font';
|
|
|
105
163
|
export type { FontInfo, ReadonlyFont } from './graphics/font';
|
|
106
164
|
export { Glyph } from './graphics/glyph';
|
|
107
165
|
export {
|
|
108
|
-
Text,
|
|
166
|
+
Text,
|
|
167
|
+
TextStyle,
|
|
168
|
+
LineAlignment,
|
|
169
|
+
ClusterGrouping,
|
|
170
|
+
TextDirection,
|
|
171
|
+
TextOrientation,
|
|
109
172
|
} from './graphics/text';
|
|
110
173
|
export type {
|
|
111
|
-
TextOptions,
|
|
174
|
+
TextOptions,
|
|
175
|
+
ShapedGlyph,
|
|
176
|
+
GlyphAppearance,
|
|
177
|
+
GlyphPreProcessor,
|
|
112
178
|
} from './graphics/text';
|
|
113
179
|
export type { ReadonlyPixels } from './graphics/image';
|
|
114
180
|
export { Color } from './graphics/color';
|
|
@@ -132,14 +198,26 @@ export { Drawable } from './graphics/drawable';
|
|
|
132
198
|
export { RenderTarget } from './graphics/render-target';
|
|
133
199
|
export { RenderStates, CoordinateType } from './graphics/render-states';
|
|
134
200
|
export type {
|
|
135
|
-
RenderStatesInput,
|
|
201
|
+
RenderStatesInput,
|
|
202
|
+
RenderStatesOptions,
|
|
203
|
+
ReadonlyRenderStates,
|
|
136
204
|
} from './graphics/render-states';
|
|
137
205
|
export {
|
|
138
|
-
BlendMode,
|
|
139
|
-
|
|
206
|
+
BlendMode,
|
|
207
|
+
BlendFactor,
|
|
208
|
+
BlendEquation,
|
|
209
|
+
BlendAlpha,
|
|
210
|
+
BlendAdd,
|
|
211
|
+
BlendMultiply,
|
|
212
|
+
BlendMin,
|
|
213
|
+
BlendMax,
|
|
214
|
+
BlendNone,
|
|
140
215
|
} from './graphics/blend-mode';
|
|
141
216
|
export {
|
|
142
|
-
StencilMode,
|
|
217
|
+
StencilMode,
|
|
218
|
+
StencilValue,
|
|
219
|
+
StencilComparison,
|
|
220
|
+
StencilUpdateOperation,
|
|
143
221
|
} from './graphics/stencil-mode';
|
|
144
222
|
export type { StencilModeOptions } from './graphics/stencil-mode';
|
|
145
223
|
export { RenderTexture } from './graphics/render-texture';
|
|
@@ -14,13 +14,17 @@ export async function findAudioReader(
|
|
|
14
14
|
stream: InputStream,
|
|
15
15
|
): Promise<SoundFileReader | undefined> {
|
|
16
16
|
for (const Reader of [ ...audioReaders ].reverse()) {
|
|
17
|
-
if (await stream.seek(0n) !== 0n)
|
|
17
|
+
if (await stream.seek(0n) !== 0n) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
18
20
|
const matches = await Reader.check(stream);
|
|
19
21
|
if (typeof matches !== 'boolean') {
|
|
20
22
|
throw new TypeError('Reader.check must return a boolean');
|
|
21
23
|
}
|
|
22
24
|
if (matches) {
|
|
23
|
-
if (await stream.seek(0n) !== 0n)
|
|
25
|
+
if (await stream.seek(0n) !== 0n) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
24
28
|
return new Reader();
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -36,7 +40,9 @@ export async function findAudioWriter(
|
|
|
36
40
|
if (typeof matches !== 'boolean') {
|
|
37
41
|
throw new TypeError('Writer.check must return a boolean');
|
|
38
42
|
}
|
|
39
|
-
if (matches)
|
|
43
|
+
if (matches) {
|
|
44
|
+
return new Writer();
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
return undefined;
|
|
42
48
|
}
|
|
@@ -46,19 +52,25 @@ export async function findAudioReaderInput(
|
|
|
46
52
|
): Promise<{
|
|
47
53
|
reader: SoundFileReader; stream: InputStream; owned?: FileInputStream;
|
|
48
54
|
} | undefined> {
|
|
49
|
-
if (!audioReaders.size)
|
|
55
|
+
if (!audioReaders.size) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
50
58
|
let owned: FileInputStream | undefined;
|
|
51
59
|
let stream: InputStream;
|
|
52
60
|
if (typeof input === 'string') {
|
|
53
61
|
owned = new FileInputStream();
|
|
54
|
-
if (!await owned.open(input))
|
|
62
|
+
if (!await owned.open(input)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
55
65
|
stream = owned;
|
|
56
66
|
} else {
|
|
57
67
|
stream = input instanceof Uint8Array ? new MemoryInputStream(input) : input;
|
|
58
68
|
}
|
|
59
69
|
try {
|
|
60
70
|
const reader = await findAudioReader(stream);
|
|
61
|
-
if (reader)
|
|
71
|
+
if (reader) {
|
|
72
|
+
return { reader, stream, owned };
|
|
73
|
+
}
|
|
62
74
|
} catch (error) {
|
|
63
75
|
await owned?.close();
|
|
64
76
|
throw error;
|
|
@@ -26,8 +26,12 @@ export class AudioInputStream {
|
|
|
26
26
|
}
|
|
27
27
|
async run<T>(action: () => Promise<T>): Promise<T> {
|
|
28
28
|
this.failure.failed = false;
|
|
29
|
-
try {
|
|
30
|
-
|
|
29
|
+
try {
|
|
30
|
+
return await action();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (this.failure.failed) {
|
|
33
|
+
throw this.failure.error;
|
|
34
|
+
}
|
|
31
35
|
if (this.closed && error instanceof Error &&
|
|
32
36
|
error.message === 'Audio InputStream closed') {
|
|
33
37
|
cancellations.add(error);
|