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.
Files changed (313) hide show
  1. package/README.ja.md +10 -9
  2. package/README.ko.md +10 -9
  3. package/README.md +10 -9
  4. package/README.zh-CN.md +10 -9
  5. package/binding.gyp +23 -16
  6. package/dist/audio/effect-processor.js +9 -3
  7. package/dist/audio/input-sound-file.js +41 -15
  8. package/dist/audio/listener.js +33 -11
  9. package/dist/audio/music.js +41 -18
  10. package/dist/audio/output-sound-file.js +4 -2
  11. package/dist/audio/playback-device.js +11 -3
  12. package/dist/audio/sound-buffer-recorder.js +8 -5
  13. package/dist/audio/sound-buffer.js +40 -17
  14. package/dist/audio/sound-file-factory.js +21 -9
  15. package/dist/audio/sound-file-reader.js +21 -7
  16. package/dist/audio/sound-recorder.js +36 -15
  17. package/dist/audio/sound-source.js +117 -40
  18. package/dist/audio/sound-stream.js +14 -5
  19. package/dist/audio/sound.js +9 -4
  20. package/dist/audio/value.js +42 -16
  21. package/dist/graphics/blend-mode.js +2 -1
  22. package/dist/graphics/boolean-vector.d.ts +1 -2
  23. package/dist/graphics/boolean-vector.js +19 -9
  24. package/dist/graphics/color.js +2 -1
  25. package/dist/graphics/convex-shape.js +7 -3
  26. package/dist/graphics/font.js +52 -23
  27. package/dist/graphics/glsl-matrix.js +8 -3
  28. package/dist/graphics/glsl.js +47 -16
  29. package/dist/graphics/glyph.js +27 -10
  30. package/dist/graphics/image.js +30 -14
  31. package/dist/graphics/rect.js +15 -8
  32. package/dist/graphics/render-states.js +18 -9
  33. package/dist/graphics/render-target.js +49 -23
  34. package/dist/graphics/render-texture.js +24 -12
  35. package/dist/graphics/render-window.js +6 -3
  36. package/dist/graphics/shader.js +67 -32
  37. package/dist/graphics/shape.js +25 -13
  38. package/dist/graphics/sprite.js +19 -9
  39. package/dist/graphics/stencil-mode.js +10 -6
  40. package/dist/graphics/swap.js +2 -1
  41. package/dist/graphics/text.js +123 -48
  42. package/dist/graphics/texture.js +48 -24
  43. package/dist/graphics/transform.js +29 -13
  44. package/dist/graphics/transformable.js +2 -1
  45. package/dist/graphics/vertex-array.js +40 -18
  46. package/dist/graphics/vertex-buffer.js +39 -19
  47. package/dist/graphics/vertex.js +6 -3
  48. package/dist/graphics/view.js +30 -14
  49. package/dist/index.d.ts +4 -4
  50. package/dist/internal/audio-codec-registry.js +12 -6
  51. package/dist/internal/audio-input-stream.js +2 -1
  52. package/dist/internal/audio-music-pump.js +58 -24
  53. package/dist/internal/audio-recorder-session.js +17 -7
  54. package/dist/internal/audio-worker-session.js +28 -10
  55. package/dist/internal/audio-worker.js +40 -21
  56. package/dist/internal/glsl-value.d.ts +3 -1
  57. package/dist/internal/glsl-value.js +18 -8
  58. package/dist/internal/graphics-state.js +29 -15
  59. package/dist/internal/input-stream.d.ts +3 -1
  60. package/dist/internal/input-stream.js +16 -7
  61. package/dist/internal/numeric-properties.js +2 -1
  62. package/dist/internal/render-states.js +2 -1
  63. package/dist/internal/scalar.js +22 -13
  64. package/dist/internal/shaped-glyph.d.ts +3 -1
  65. package/dist/internal/shaped-glyph.js +12 -4
  66. package/dist/internal/struct-view.d.ts +3 -1
  67. package/dist/internal/struct-view.js +3 -1
  68. package/dist/internal/transformable.js +2 -1
  69. package/dist/network/common.js +23 -11
  70. package/dist/network/dns.js +25 -17
  71. package/dist/network/ftp.js +43 -18
  72. package/dist/network/http.js +126 -56
  73. package/dist/network/ip-address.js +50 -25
  74. package/dist/network/packet.js +63 -25
  75. package/dist/network/sftp.js +175 -74
  76. package/dist/network/socket-selector.js +28 -14
  77. package/dist/network/socket.js +71 -30
  78. package/dist/network/tcp-listener.js +42 -19
  79. package/dist/network/tcp-socket.js +111 -53
  80. package/dist/network/tls-material.js +2 -1
  81. package/dist/network/udp-socket.js +68 -33
  82. package/dist/system/angle.js +2 -1
  83. package/dist/system/clock.js +4 -2
  84. package/dist/system/err.js +5 -2
  85. package/dist/system/file-input-stream.js +8 -4
  86. package/dist/system/input-stream.js +6 -3
  87. package/dist/system/operators.d.ts +1 -1
  88. package/dist/system/operators.js +90 -50
  89. package/dist/system/sleep.js +4 -2
  90. package/dist/system/time.js +12 -6
  91. package/dist/system/vector2.js +6 -7
  92. package/dist/system/vector3.js +11 -6
  93. package/dist/window/clipboard.js +2 -1
  94. package/dist/window/context.js +10 -5
  95. package/dist/window/cursor.js +2 -1
  96. package/dist/window/event.js +9 -5
  97. package/dist/window/mouse.js +4 -2
  98. package/dist/window/video-mode.js +2 -1
  99. package/dist/window/window.js +19 -12
  100. package/native/addon.cc +25 -12
  101. package/native/audio-binding.cc +266 -126
  102. package/native/audio-codec-binding.cc +147 -77
  103. package/native/audio-device-binding.cc +76 -49
  104. package/native/audio-file-binding.cc +116 -67
  105. package/native/audio-recorder-binding.cc +147 -98
  106. package/native/audio-recorder.h +1 -1
  107. package/native/audio-state.h +53 -30
  108. package/native/audio-stream-binding.cc +148 -94
  109. package/native/audio-stream.h +5 -4
  110. package/native/audio-worker-binding.cc +163 -81
  111. package/native/audio-worker.h +35 -19
  112. package/native/batch-drawable.cc +29 -16
  113. package/native/batch-drawable.h +11 -8
  114. package/native/context-binding.cc +40 -27
  115. package/native/context-settings.h +15 -8
  116. package/native/deferred-delete.cc +9 -6
  117. package/native/deferred-delete.h +7 -8
  118. package/native/error-stream-binding.cc +42 -28
  119. package/native/font-binding.cc +89 -48
  120. package/native/graphics-binding.cc +122 -72
  121. package/native/graphics-state.h +50 -36
  122. package/native/image-binding.cc +38 -24
  123. package/native/image-state.h +26 -18
  124. package/native/input-binding.cc +42 -27
  125. package/native/render-window-binding.cc +38 -23
  126. package/native/shader-binding.cc +115 -50
  127. package/native/shape-binding.cc +94 -49
  128. package/native/shape-state.h +18 -9
  129. package/native/shaped-glyph-storage.h +9 -5
  130. package/native/stream-binding.cc +143 -117
  131. package/native/system-binding.cc +17 -12
  132. package/native/text-binding.cc +68 -35
  133. package/native/text-state.h +25 -18
  134. package/native/texture-binding.cc +42 -33
  135. package/native/texture-resource.h +20 -12
  136. package/native/time-value.h +3 -1
  137. package/native/transformable-binding.cc +12 -6
  138. package/native/transformable-state.h +6 -6
  139. package/native/value-binding.h +46 -28
  140. package/native/value-layout.h +10 -10
  141. package/native/values-binding.cc +29 -23
  142. package/native/vertex-binding.cc +18 -12
  143. package/native/vertex-buffer-binding.cc +38 -24
  144. package/native/vertex-storage.h +2 -2
  145. package/native/view-data.h +4 -3
  146. package/native/window-binding.cc +75 -45
  147. package/native/window-event.h +20 -11
  148. package/native/window-owner.h +15 -12
  149. package/package.json +40 -48
  150. package/src/audio/effect-processor.ts +9 -3
  151. package/src/audio/input-sound-file.ts +108 -36
  152. package/src/audio/listener.ts +39 -13
  153. package/src/audio/music.ts +112 -47
  154. package/src/audio/output-sound-file.ts +40 -11
  155. package/src/audio/playback-device.ts +23 -8
  156. package/src/audio/sound-buffer-recorder.ts +35 -13
  157. package/src/audio/sound-buffer.ts +166 -58
  158. package/src/audio/sound-file-factory.ts +127 -49
  159. package/src/audio/sound-file-reader.ts +49 -15
  160. package/src/audio/sound-recorder.ts +100 -34
  161. package/src/audio/sound-source.ts +142 -45
  162. package/src/audio/sound-stream.ts +15 -5
  163. package/src/audio/sound.ts +12 -4
  164. package/src/audio/value.ts +89 -26
  165. package/src/graphics/blend-mode.ts +3 -1
  166. package/src/graphics/boolean-vector.ts +56 -26
  167. package/src/graphics/color.ts +3 -1
  168. package/src/graphics/convex-shape.ts +10 -3
  169. package/src/graphics/font.ts +171 -50
  170. package/src/graphics/glsl-matrix.ts +9 -3
  171. package/src/graphics/glsl.ts +81 -35
  172. package/src/graphics/glyph.ts +67 -26
  173. package/src/graphics/image.ts +119 -45
  174. package/src/graphics/rect.ts +56 -24
  175. package/src/graphics/render-states.ts +31 -14
  176. package/src/graphics/render-target.ts +197 -81
  177. package/src/graphics/render-texture.ts +36 -12
  178. package/src/graphics/render-window.ts +9 -3
  179. package/src/graphics/shader.ts +186 -61
  180. package/src/graphics/shape.ts +93 -35
  181. package/src/graphics/sprite.ts +64 -25
  182. package/src/graphics/stencil-mode.ts +12 -6
  183. package/src/graphics/swap.ts +3 -2
  184. package/src/graphics/text.ts +229 -74
  185. package/src/graphics/texture.ts +180 -61
  186. package/src/graphics/transform.ts +132 -47
  187. package/src/graphics/transformable.ts +3 -1
  188. package/src/graphics/vertex-array.ts +87 -35
  189. package/src/graphics/vertex-buffer.ts +97 -33
  190. package/src/graphics/vertex.ts +9 -3
  191. package/src/graphics/view.ts +59 -21
  192. package/src/index.ts +101 -23
  193. package/src/internal/audio-codec-registry.ts +18 -6
  194. package/src/internal/audio-input-stream.ts +6 -2
  195. package/src/internal/audio-music-pump.ts +116 -41
  196. package/src/internal/audio-native.ts +249 -96
  197. package/src/internal/audio-recorder-session.ts +68 -24
  198. package/src/internal/audio-worker-session.ts +65 -21
  199. package/src/internal/audio-worker.ts +85 -41
  200. package/src/internal/glsl-value.ts +26 -11
  201. package/src/internal/graphics-state.ts +57 -20
  202. package/src/internal/input-stream.ts +23 -10
  203. package/src/internal/native.ts +252 -99
  204. package/src/internal/numeric-properties.ts +2 -1
  205. package/src/internal/render-states.ts +3 -1
  206. package/src/internal/scalar.ts +33 -14
  207. package/src/internal/shaped-glyph.ts +25 -12
  208. package/src/internal/struct-view.ts +40 -13
  209. package/src/internal/transformable.ts +3 -1
  210. package/src/network/common.ts +35 -11
  211. package/src/network/dns.ts +95 -38
  212. package/src/network/ftp.ts +129 -47
  213. package/src/network/http.ts +232 -77
  214. package/src/network/ip-address.ts +118 -48
  215. package/src/network/packet.ts +161 -54
  216. package/src/network/sftp.ts +498 -168
  217. package/src/network/socket-selector.ts +66 -26
  218. package/src/network/socket.ts +133 -46
  219. package/src/network/tcp-listener.ts +78 -29
  220. package/src/network/tcp-socket.ts +240 -95
  221. package/src/network/tls-material.ts +6 -2
  222. package/src/network/udp-socket.ts +147 -53
  223. package/src/system/angle.ts +3 -1
  224. package/src/system/clock.ts +12 -4
  225. package/src/system/err.ts +5 -2
  226. package/src/system/file-input-stream.ts +12 -4
  227. package/src/system/input-stream.ts +9 -3
  228. package/src/system/operators.ts +290 -115
  229. package/src/system/sleep.ts +6 -2
  230. package/src/system/time.ts +18 -6
  231. package/src/system/timeout-with-predicate.ts +19 -8
  232. package/src/system/vector2.ts +101 -49
  233. package/src/system/vector3.ts +85 -36
  234. package/src/window/clipboard.ts +3 -1
  235. package/src/window/context.ts +15 -5
  236. package/src/window/cursor.ts +3 -1
  237. package/src/window/event.ts +26 -12
  238. package/src/window/mouse.ts +6 -2
  239. package/src/window/video-mode.ts +3 -1
  240. package/src/window/window.ts +119 -37
  241. package/test/native/audio-probes.cc +74 -36
  242. package/test/native/deferred-delete-probes.cc +17 -11
  243. package/test/native/drawable-probes.cc +70 -36
  244. package/test/native/exception-probes.cc +14 -9
  245. package/test/native/image-probes.cc +20 -10
  246. package/test/native/matrix-probes.cc +8 -4
  247. package/test/native/network-oracle.cc +17 -11
  248. package/test/native/render-texture-probes.cc +33 -24
  249. package/test/native/shader-probes.cc +9 -9
  250. package/test/native/shape-probes.cc +37 -23
  251. package/test/native/sprite-probes.cc +41 -25
  252. package/test/native/system-probes.cc +58 -35
  253. package/test/native/text-probes.cc +77 -44
  254. package/test/native/texture-probes.cc +43 -26
  255. package/test/native/time-probes.cc +18 -12
  256. package/test/native/transform-probes.cc +15 -10
  257. package/test/native/transformable-probes.cc +23 -17
  258. package/test/native/value-oracle.h +9 -4
  259. package/test/native/value-probes.cc +31 -23
  260. package/test/native/vertex-array-probes.cc +22 -14
  261. package/test/native/vertex-buffer-probes.cc +28 -17
  262. package/test/native/view-probes.cc +29 -17
  263. package/test/native/window-probes.cc +66 -33
  264. package/tools/ensure-sfml.cjs +9 -0
  265. package/tools/generate-network-constants.cjs +11 -6
  266. package/tools/generate-window-constants.cjs +31 -12
  267. package/docs/README.ja.md +0 -30
  268. package/docs/README.ko.md +0 -30
  269. package/docs/README.md +0 -30
  270. package/docs/README.zh-CN.md +0 -30
  271. package/docs/api.ja.md +0 -84
  272. package/docs/api.ko.md +0 -84
  273. package/docs/api.md +0 -81
  274. package/docs/api.zh-CN.md +0 -81
  275. package/docs/audio.ja.md +0 -249
  276. package/docs/audio.ko.md +0 -251
  277. package/docs/audio.md +0 -252
  278. package/docs/audio.zh-CN.md +0 -252
  279. package/docs/concepts.ja.md +0 -130
  280. package/docs/concepts.ko.md +0 -130
  281. package/docs/concepts.md +0 -131
  282. package/docs/concepts.zh-CN.md +0 -131
  283. package/docs/development.ja.md +0 -144
  284. package/docs/development.ko.md +0 -144
  285. package/docs/development.md +0 -146
  286. package/docs/development.zh-CN.md +0 -146
  287. package/docs/getting-started.ja.md +0 -154
  288. package/docs/getting-started.ko.md +0 -154
  289. package/docs/getting-started.md +0 -156
  290. package/docs/getting-started.zh-CN.md +0 -156
  291. package/docs/graphics.ja.md +0 -256
  292. package/docs/graphics.ko.md +0 -254
  293. package/docs/graphics.md +0 -255
  294. package/docs/graphics.zh-CN.md +0 -257
  295. package/docs/network.ja.md +0 -214
  296. package/docs/network.ko.md +0 -216
  297. package/docs/network.md +0 -218
  298. package/docs/network.zh-CN.md +0 -218
  299. package/docs/system.ja.md +0 -169
  300. package/docs/system.ko.md +0 -171
  301. package/docs/system.md +0 -173
  302. package/docs/system.zh-CN.md +0 -173
  303. package/docs/window.ja.md +0 -138
  304. package/docs/window.ko.md +0 -140
  305. package/docs/window.md +0 -141
  306. package/docs/window.zh-CN.md +0 -141
  307. package/native/exception-boundary.h +0 -97
  308. package/native/numeric-fields.h +0 -96
  309. package/native/shared-handle.h +0 -107
  310. package/test/tsconfig.json +0 -8
  311. package/tools/configure-lsp.cjs +0 -23
  312. package/tools/lib_downloader.cjs +0 -92
  313. package/tools/lib_downloader_urls.cjs +0 -23
@@ -190,18 +190,38 @@ export enum SoundStatus {
190
190
  * @ko 16비트 인터리브 PCM의 읽기 전용 타입 뷰로,
191
191
  * 기반 네이티브 저장소를 유지합니다.
192
192
  */
193
- export type ReadonlySamples = Readonly<Pick<Int16Array,
194
- number | 'length' | 'byteLength' | 'byteOffset' | typeof Symbol.iterator |
195
- 'slice' | 'entries' | 'keys' | 'values'>>;
193
+ export type ReadonlySamples = Readonly<
194
+ Pick<
195
+ Int16Array,
196
+ | number
197
+ | 'length'
198
+ | 'byteLength'
199
+ | 'byteOffset'
200
+ | typeof Symbol.iterator
201
+ | 'slice'
202
+ | 'entries'
203
+ | 'keys'
204
+ | 'values'
205
+ >
206
+ >;
196
207
  /**
197
208
  * Read-only view of channel positions in interleaved order.
198
209
  * @zh 按交错顺序排列的声道位置只读视图。
199
210
  * @ja インターリーブ順に並ぶチャンネル位置の読み取り専用ビュー。
200
211
  * @ko 인터리브 순서로 나열된 채널 위치의 읽기 전용 뷰입니다.
201
212
  */
202
- export type ChannelMap = Readonly<Pick<Int32Array,
203
- number | 'length' | typeof Symbol.iterator | 'slice' | 'entries' |
204
- 'keys' | 'values'>>;
213
+ export type ChannelMap = Readonly<
214
+ Pick<
215
+ Int32Array,
216
+ | number
217
+ | 'length'
218
+ | typeof Symbol.iterator
219
+ | 'slice'
220
+ | 'entries'
221
+ | 'keys'
222
+ | 'values'
223
+ >
224
+ >;
205
225
 
206
226
  /**
207
227
  * Directional cone parameters for a spatial sound source or listener.
@@ -241,7 +261,9 @@ export interface ConeInput {
241
261
  * @ko 부동 소수점 필드로 노출되는 네이티브 sf::SoundSource::Cone입니다.
242
262
  */
243
263
  export class Cone {
244
- private readonly values = new Float32Array(audioNative.createAudioValue(0));
264
+ private readonly values = new Float32Array(
265
+ audioNative.createAudioValue(0),
266
+ );
245
267
  /**
246
268
  * Create a cone with zero angles and gain, or copy the given parameters.
247
269
  * @zh 创建角度和增益均为零的方向锥,或复制给定参数。
@@ -261,42 +283,54 @@ export class Cone {
261
283
  * @ja 内側コーンの全角のコピー。
262
284
  * @ko 내부 원뿔 전체 각도의 복사본입니다.
263
285
  */
264
- get innerAngle(): Angle { return radians(this.values[0]); }
286
+ get innerAngle(): Angle {
287
+ return radians(this.values[0]);
288
+ }
265
289
  /**
266
290
  * Copy the inner cone angle.
267
291
  * @zh 复制内锥角度。
268
292
  * @ja 内側コーンの角度をコピーします。
269
293
  * @ko 내부 원뿔 각도를 복사합니다.
270
294
  */
271
- set innerAngle(value: R<Angle>) { this.values[0] = angle(value); }
295
+ set innerAngle(value: R<Angle>) {
296
+ this.values[0] = angle(value);
297
+ }
272
298
  /**
273
299
  * Copy of the full outer cone angle.
274
300
  * @zh 外锥完整角度的副本。
275
301
  * @ja 外側コーンの全角のコピー。
276
302
  * @ko 외부 원뿔 전체 각도의 복사본입니다.
277
303
  */
278
- get outerAngle(): Angle { return radians(this.values[1]); }
304
+ get outerAngle(): Angle {
305
+ return radians(this.values[1]);
306
+ }
279
307
  /**
280
308
  * Copy the outer cone angle.
281
309
  * @zh 复制外锥角度。
282
310
  * @ja 外側コーンの角度をコピーします。
283
311
  * @ko 외부 원뿔 각도를 복사합니다.
284
312
  */
285
- set outerAngle(value: R<Angle>) { this.values[1] = angle(value); }
313
+ set outerAngle(value: R<Angle>) {
314
+ this.values[1] = angle(value);
315
+ }
286
316
  /**
287
317
  * Gain multiplier outside the outer cone.
288
318
  * @zh 外锥之外的增益倍率。
289
319
  * @ja 外側コーンの外でのゲイン倍率。
290
320
  * @ko 외부 원뿔 바깥의 게인 배율입니다.
291
321
  */
292
- get outerGain(): number { return this.values[2]; }
322
+ get outerGain(): number {
323
+ return this.values[2];
324
+ }
293
325
  /**
294
326
  * Set the outer cone gain multiplier.
295
327
  * @zh 设置外锥增益倍率。
296
328
  * @ja 外側コーンのゲイン倍率を設定します。
297
329
  * @ko 외부 원뿔의 게인 배율을 설정합니다.
298
330
  */
299
- set outerGain(value: number) { this.values[2] = float(value); }
331
+ set outerGain(value: number) {
332
+ this.values[2] = float(value);
333
+ }
300
334
  }
301
335
 
302
336
  /**
@@ -328,7 +362,9 @@ export interface TimeSpanInput {
328
362
  * @ko 정확한 마이크로초 단위로 저장되는 변경 가능한 오디오 시간 구간입니다.
329
363
  */
330
364
  export class TimeSpan {
331
- private readonly values = new BigInt64Array(audioNative.createAudioValue(1));
365
+ private readonly values = new BigInt64Array(
366
+ audioNative.createAudioValue(1),
367
+ );
332
368
  /**
333
369
  * Create a span with zero offset and length, or copy the given parameters.
334
370
  * @zh 创建零偏移、零长度的时间段,或复制给定参数。
@@ -336,7 +372,10 @@ export class TimeSpan {
336
372
  * @ko 오프셋과 길이가 0인 구간을 생성하거나 지정한 매개변수를 복사합니다.
337
373
  */
338
374
  constructor(value?: Readonly<TimeSpanInput>) {
339
- if (value) { this.offset = value.offset; this.length = value.length; }
375
+ if (value) {
376
+ this.offset = value.offset;
377
+ this.length = value.length;
378
+ }
340
379
  }
341
380
  /**
342
381
  * Copy of the starting offset.
@@ -344,36 +383,48 @@ export class TimeSpan {
344
383
  * @ja 開始オフセットのコピー。
345
384
  * @ko 시작 오프셋의 복사본입니다.
346
385
  */
347
- get offset(): Time { return new Time(this.values[0]); }
386
+ get offset(): Time {
387
+ return new Time(this.values[0]);
388
+ }
348
389
  /**
349
390
  * Copy the starting offset.
350
391
  * @zh 复制起点偏移。
351
392
  * @ja 開始オフセットをコピーします。
352
393
  * @ko 시작 오프셋을 복사합니다.
353
394
  */
354
- set offset(value: R<Time>) { this.values[0] = duration(value); }
395
+ set offset(value: R<Time>) {
396
+ this.values[0] = duration(value);
397
+ }
355
398
  /**
356
399
  * Copy of the duration.
357
400
  * @zh 时长的副本。
358
401
  * @ja 長さのコピー。
359
402
  * @ko 길이의 복사본입니다.
360
403
  */
361
- get length(): Time { return new Time(this.values[1]); }
404
+ get length(): Time {
405
+ return new Time(this.values[1]);
406
+ }
362
407
  /**
363
408
  * Copy the time span length.
364
409
  * @zh 复制时间段长度。
365
410
  * @ja 時間範囲の長さをコピーします。
366
411
  * @ko 시간 구간의 길이를 복사합니다.
367
412
  */
368
- set length(value: R<Time>) { this.values[1] = duration(value); }
413
+ set length(value: R<Time>) {
414
+ this.values[1] = duration(value);
415
+ }
369
416
  }
370
417
 
371
418
  export function float(value: number): number {
372
- if (typeof value !== 'number') throw new TypeError('Expected a number');
419
+ if (typeof value !== 'number') {
420
+ throw new TypeError('Expected a number');
421
+ }
373
422
  return Math.fround(value);
374
423
  }
375
424
  export function flag(value: boolean): number {
376
- if (typeof value !== 'boolean') throw new TypeError('Expected a boolean');
425
+ if (typeof value !== 'boolean') {
426
+ throw new TypeError('Expected a boolean');
427
+ }
377
428
  return +value;
378
429
  }
379
430
  export function unsigned(value: number): number {
@@ -383,11 +434,15 @@ export function unsigned(value: number): number {
383
434
  return value;
384
435
  }
385
436
  export function duration(value: R<Time>): bigint {
386
- if (!(value instanceof Time)) throw new TypeError('Expected a Time');
437
+ if (!(value instanceof Time)) {
438
+ throw new TypeError('Expected a Time');
439
+ }
387
440
  return value.asMicroseconds();
388
441
  }
389
442
  export function angle(value: R<Angle>): number {
390
- if (!(value instanceof Angle)) throw new TypeError('Expected an Angle');
443
+ if (!(value instanceof Angle)) {
444
+ throw new TypeError('Expected an Angle');
445
+ }
391
446
  return value.asRadians();
392
447
  }
393
448
  export function vector(value: R<Vector3<'f32'>>): void {
@@ -397,12 +452,20 @@ export function vector(value: R<Vector3<'f32'>>): void {
397
452
  }
398
453
  export function channels(map: Iterable<SoundChannel>): Int32Array {
399
454
  const values = Array.from(map);
400
- if (values.some(value => !Number.isInteger(value) || value < 0 ||
401
- value > SoundChannel.TopBackCenter)) {
455
+ if (
456
+ values.some(
457
+ value =>
458
+ !Number.isInteger(value) ||
459
+ value < 0 ||
460
+ value > SoundChannel.TopBackCenter,
461
+ )
462
+ ) {
402
463
  throw new RangeError('Unknown sound channel');
403
464
  }
404
465
  return Int32Array.from(values);
405
466
  }
406
467
  export function samples(value: Int16Array): void {
407
- if (!(value instanceof Int16Array)) throw new TypeError('Expected an Int16Array');
468
+ if (!(value instanceof Int16Array)) {
469
+ throw new TypeError('Expected an Int16Array');
470
+ }
408
471
  }
@@ -212,7 +212,9 @@ export class BlendMode {
212
212
  alphaDstFactor: BlendFactor.OneMinusSrcAlpha,
213
213
  alphaEquation: BlendEquation.Add,
214
214
  });
215
- if (args.length === 0) return;
215
+ if (args.length === 0) {
216
+ return;
217
+ }
216
218
  if (args.length === 1 && args[0] instanceof BlendMode) {
217
219
  const source = args[0];
218
220
  this.colorSrcFactor = source.colorSrcFactor;
@@ -11,12 +11,17 @@ import type { ScalarType } from '../internal/scalar';
11
11
  * @ja ブールベクトル演算の基底クラス。数値結果の非ゼロを true に変換します。
12
12
  * @ko 불리언 벡터 연산의 기반 클래스입니다. 숫자 결과가 0이 아니면 true로 변환합니다.
13
13
  */
14
- export abstract class BooleanVector<K extends 'vector2' | 'vector3'>
15
- extends BooleanComponents<K> {
14
+ export abstract class BooleanVector<
15
+ K extends 'vector2' | 'vector3',
16
+ > extends BooleanComponents<K> {
16
17
  protected checkPair(rhs: R<BooleanVector<K>>): void {
17
- if (!(rhs instanceof BooleanVector) ||
18
- this[glslStorage].length !== rhs[glslStorage].length) {
19
- throw new TypeError('Boolean vector operands must have the same dimension');
18
+ if (
19
+ !(rhs instanceof BooleanVector) ||
20
+ this[glslStorage].length !== rhs[glslStorage].length
21
+ ) {
22
+ throw new TypeError(
23
+ 'Boolean vector operands must have the same dimension',
24
+ );
20
25
  }
21
26
  }
22
27
 
@@ -32,7 +37,9 @@ export abstract class BooleanVector<K extends 'vector2' | 'vector3'>
32
37
  const a = this[glslStorage];
33
38
  const b = rhs[glslStorage];
34
39
  let sum = 0;
35
- for (let i = 0; i < a.length; i++) sum += a[i] * b[i];
40
+ for (let i = 0; i < a.length; i++) {
41
+ sum += a[i] * b[i];
42
+ }
36
43
  return sum !== 0;
37
44
  }
38
45
 
@@ -55,7 +62,7 @@ export abstract class BooleanVector<K extends 'vector2' | 'vector3'>
55
62
  }
56
63
 
57
64
  type Source2 = R<Bvec2> | R<Vector2<ScalarType>>;
58
- type Arguments2 = [] | [ x: boolean, y: boolean ] | [ source: Source2 ];
65
+ type Arguments2 = [] | [x: boolean, y: boolean] | [source: Source2];
59
66
 
60
67
  /**
61
68
  * sf::Vector2<bool>; each component occupies one canonical 0/1 byte.
@@ -73,16 +80,25 @@ export class Bvec2 extends BooleanVector<'vector2'> {
73
80
  */
74
81
  constructor(...args: Arguments2) {
75
82
  const source = args[0];
76
- const components = args.length === 0 || (args.length === 2 &&
77
- typeof source === 'boolean' && typeof args[1] === 'boolean');
78
- const copy = args.length === 1 &&
83
+ const components =
84
+ args.length === 0 ||
85
+ (args.length === 2 &&
86
+ typeof source === 'boolean' &&
87
+ typeof args[1] === 'boolean');
88
+ const copy =
89
+ args.length === 1 &&
79
90
  (source instanceof Bvec2 || source instanceof Vector2);
80
91
  if (!components && !copy) {
81
- throw new TypeError('Expected a boolean pair or a two-dimensional vector');
92
+ throw new TypeError(
93
+ 'Expected a boolean pair or a two-dimensional vector',
94
+ );
82
95
  }
83
- super(typeof source === 'object'
84
- ? [ source.x, source.y ] : [ source ?? false, args[1] ?? false ],
85
- buffer => native.wrapVector2('bool', buffer));
96
+ super(
97
+ typeof source === 'object'
98
+ ? [ source.x, source.y ]
99
+ : [ source ?? false, args[1] ?? false ],
100
+ buffer => native.wrapVector2('bool', buffer),
101
+ );
86
102
  }
87
103
 
88
104
  /**
@@ -136,7 +152,9 @@ export class Bvec2 extends BooleanVector<'vector2'> {
136
152
 
137
153
  type Source3 = R<Bvec3> | R<Vector3<ScalarType>>;
138
154
  type Arguments3 =
139
- [] | [ x: boolean, y: boolean, z: boolean ] | [ source: Source3 ];
155
+ | []
156
+ | [x: boolean, y: boolean, z: boolean]
157
+ | [source: Source3];
140
158
 
141
159
  /**
142
160
  * sf::Vector3<bool>, sharing the same native family as numeric Vector3.
@@ -154,18 +172,26 @@ export class Bvec3 extends BooleanVector<'vector3'> {
154
172
  */
155
173
  constructor(...args: Arguments3) {
156
174
  const source = args[0];
157
- const components = args.length === 0 || (args.length === 3 &&
158
- typeof source === 'boolean' && typeof args[1] === 'boolean' &&
159
- typeof args[2] === 'boolean');
160
- const copy = args.length === 1 &&
175
+ const components =
176
+ args.length === 0 ||
177
+ (args.length === 3 &&
178
+ typeof source === 'boolean' &&
179
+ typeof args[1] === 'boolean' &&
180
+ typeof args[2] === 'boolean');
181
+ const copy =
182
+ args.length === 1 &&
161
183
  (source instanceof Bvec3 || source instanceof Vector3);
162
184
  if (!components && !copy) {
163
- throw new TypeError('Expected a boolean triple or a three-dimensional vector');
185
+ throw new TypeError(
186
+ 'Expected a boolean triple or a three-dimensional vector',
187
+ );
164
188
  }
165
- super(typeof source === 'object'
166
- ? [ source.x, source.y, source.z ]
167
- : [ source ?? false, args[1] ?? false, args[2] ?? false ],
168
- buffer => native.wrapVector3('bool', buffer));
189
+ super(
190
+ typeof source === 'object'
191
+ ? [ source.x, source.y, source.z ]
192
+ : [ source ?? false, args[1] ?? false, args[2] ?? false ],
193
+ buffer => native.wrapVector3('bool', buffer),
194
+ );
169
195
  }
170
196
 
171
197
  /**
@@ -174,14 +200,18 @@ export class Bvec3 extends BooleanVector<'vector3'> {
174
200
  * @ja Z ブール成分。
175
201
  * @ko Z 불리언 성분입니다.
176
202
  */
177
- get z(): boolean { return this[glslStorage][2] !== 0; }
203
+ get z(): boolean {
204
+ return this[glslStorage][2] !== 0;
205
+ }
178
206
  /**
179
207
  * Sets the Z component, stored as a 0/1 byte.
180
208
  * @zh 设置 Z 分量,按 0/1 字节存储。
181
209
  * @ja Z 成分を設定し、0/1 のバイトで格納します。
182
210
  * @ko Z 성분을 설정하며 0/1 바이트로 저장합니다.
183
211
  */
184
- set z(value: boolean) { this[glslStorage][2] = value ? 1 : 0; }
212
+ set z(value: boolean) {
213
+ this[glslStorage][2] = value ? 1 : 0;
214
+ }
185
215
 
186
216
  /**
187
217
  * Computes the 3D cross product and converts each nonzero component to true.
@@ -91,7 +91,9 @@ export class Color {
91
91
  green?: number, blue?: number, alpha = 255,
92
92
  ) {
93
93
  this.state.values[3] = 255;
94
- if (redOrSource === undefined) return;
94
+ if (redOrSource === undefined) {
95
+ return;
96
+ }
95
97
  if (redOrSource instanceof Color) {
96
98
  this[colorStorage].set(redOrSource[colorStorage]);
97
99
  } else if (typeof redOrSource === 'number') {
@@ -26,8 +26,11 @@ export class ConvexShape extends Shape {
26
26
  */
27
27
  constructor(source: R<ConvexShape>);
28
28
  constructor(source: number | R<ConvexShape> = 0) {
29
- if (source instanceof ConvexShape) super({ kind: 3, source });
30
- else super({ kind: 3, x: shapeCount(source as number) });
29
+ if (source instanceof ConvexShape) {
30
+ super({ kind: 3, source });
31
+ } else {
32
+ super({ kind: 3, x: shapeCount(source as number) });
33
+ }
31
34
  }
32
35
 
33
36
  /**
@@ -58,7 +61,11 @@ export class ConvexShape extends Shape {
58
61
  * @ko 로컬 꼭짓점 좌표를 복사합니다. 인덱스는 0부터 시작하며 꼭짓점은 윤곽 순서로 볼록 다각형을 구성해야 합니다.
59
62
  */
60
63
  setPoint(this: ConvexShape, index: number, point: R<Vector2f>): void {
61
- if (!Number.isInteger(index) || index < 0 || index >= this.getPointCount()) {
64
+ if (
65
+ !Number.isInteger(index) ||
66
+ index < 0 ||
67
+ index >= this.getPointCount()
68
+ ) {
62
69
  throw new RangeError('Shape point index is out of bounds');
63
70
  }
64
71
  this.changeGeometry(5, index, ...shapeVector(point));