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