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