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
@@ -26,12 +26,15 @@ class Glyph {
26
26
  this.floats = new Float32Array(this.state.values.buffer);
27
27
  this.integers = new Int32Array(this.state.values.buffer);
28
28
  if (source !== undefined) {
29
- if (!(source instanceof Glyph))
29
+ if (!(source instanceof Glyph)) {
30
30
  throw new TypeError('Expected a Glyph');
31
+ }
31
32
  this.state.values.set(source[value_storage_1.glyphStorage]);
32
33
  }
33
34
  }
34
- get [(_a = value_storage_1.mutableValue, value_storage_1.glyphStorage)]() { return this.state.values; }
35
+ get [(_a = value_storage_1.mutableValue, value_storage_1.glyphStorage)]() {
36
+ return this.state.values;
37
+ }
35
38
  get [value_storage_1.glyphNative]() {
36
39
  return (0, lazy_value_1.nativeValue)(this, value_storage_1.glyphNative, this.state);
37
40
  }
@@ -41,14 +44,18 @@ class Glyph {
41
44
  * @ja 描画後のペン位置の水平移動量。ピクセル単位。
42
45
  * @ko 그린 후 펜 위치의 수평 이동량이며 픽셀 단위입니다.
43
46
  */
44
- get advance() { return this.floats[0]; }
47
+ get advance() {
48
+ return this.floats[0];
49
+ }
45
50
  /**
46
51
  * Sets the horizontal advance in pixels.
47
52
  * @zh 设置水平前进量,单位为像素。
48
53
  * @ja 水平移動量をピクセル単位で設定します。
49
54
  * @ko 수평 이동량을 픽셀 단위로 설정합니다.
50
55
  */
51
- set advance(value) { this.floats[0] = value; }
56
+ set advance(value) {
57
+ this.floats[0] = value;
58
+ }
52
59
  /**
53
60
  * Difference in left side bearing before and after auto-hinting, in 1/64
54
61
  * pixels.
@@ -56,14 +63,18 @@ class Glyph {
56
63
  * @ja 自動ヒンティング前後の左サイドベアリングの差。1/64 ピクセル単位。
57
64
  * @ko 자동 힌팅 전후 왼쪽 사이드 베어링의 차이이며 1/64 픽셀 단위입니다.
58
65
  */
59
- get lsbDelta() { return this.integers[1]; }
66
+ get lsbDelta() {
67
+ return this.integers[1];
68
+ }
60
69
  /**
61
70
  * Sets the left side bearing hinting delta.
62
71
  * @zh 设置左侧边距微调差。
63
72
  * @ja 左サイドベアリングのヒンティング差を設定します。
64
73
  * @ko 왼쪽 사이드 베어링의 힌팅 차이를 설정합니다.
65
74
  */
66
- set lsbDelta(value) { this.integers[1] = value; }
75
+ set lsbDelta(value) {
76
+ this.integers[1] = value;
77
+ }
67
78
  /**
68
79
  * Difference in right side bearing before and after auto-hinting, in 1/64
69
80
  * pixels.
@@ -71,14 +82,18 @@ class Glyph {
71
82
  * @ja 自動ヒンティング前後の右サイドベアリングの差。1/64 ピクセル単位。
72
83
  * @ko 자동 힌팅 전후 오른쪽 사이드 베어링의 차이이며 1/64 픽셀 단위입니다.
73
84
  */
74
- get rsbDelta() { return this.integers[2]; }
85
+ get rsbDelta() {
86
+ return this.integers[2];
87
+ }
75
88
  /**
76
89
  * Sets the right side bearing hinting delta.
77
90
  * @zh 设置右侧边距微调差。
78
91
  * @ja 右サイドベアリングのヒンティング差を設定します。
79
92
  * @ko 오른쪽 사이드 베어링의 힌팅 차이를 설정합니다.
80
93
  */
81
- set rsbDelta(value) { this.integers[2] = value; }
94
+ set rsbDelta(value) {
95
+ this.integers[2] = value;
96
+ }
82
97
  /**
83
98
  * Pixel bounds relative to the baseline and pen position; a mutable shared
84
99
  * view.
@@ -97,8 +112,9 @@ class Glyph {
97
112
  * @ko 글리프 경계 상자를 복사합니다.
98
113
  */
99
114
  set bounds(value) {
100
- if (!(value instanceof rect_1.FloatRect))
115
+ if (!(value instanceof rect_1.FloatRect)) {
101
116
  throw new TypeError('Expected a FloatRect');
117
+ }
102
118
  this.floats.set(value[value_storage_1.rectStorage], 3);
103
119
  }
104
120
  /**
@@ -118,8 +134,9 @@ class Glyph {
118
134
  * @ko 글꼴 텍스처 안의 글리프 사각형을 복사합니다.
119
135
  */
120
136
  set textureRect(value) {
121
- if (!(value instanceof rect_1.IntRect))
137
+ if (!(value instanceof rect_1.IntRect)) {
122
138
  throw new TypeError('Expected an IntRect');
139
+ }
123
140
  this.integers.set(value[value_storage_1.rectStorage], 7);
124
141
  }
125
142
  }
@@ -15,10 +15,12 @@ function coordinates(value) {
15
15
  }
16
16
  }
17
17
  function content(value) {
18
- if (value instanceof color_1.Color)
18
+ if (value instanceof color_1.Color) {
19
19
  return value.toInteger();
20
- if (value instanceof Uint8Array)
20
+ }
21
+ if (value instanceof Uint8Array) {
21
22
  return value;
23
+ }
22
24
  throw new TypeError('Expected a Color or RGBA Uint8Array');
23
25
  }
24
26
  function view(mapping) {
@@ -106,8 +108,9 @@ class Image {
106
108
  */
107
109
  setPixel(coords, color) {
108
110
  const offset = this.offset(coords);
109
- if (!(color instanceof color_1.Color))
111
+ if (!(color instanceof color_1.Color)) {
110
112
  throw new TypeError('Expected a Color');
113
+ }
111
114
  this.pixels.set(color[value_storage_1.colorStorage], offset);
112
115
  }
113
116
  /**
@@ -118,10 +121,12 @@ class Image {
118
121
  * @ko color와 정확히 일치하는 픽셀의 알파를 alpha(기본값 0)로 설정하며 RGB는 유지합니다.
119
122
  */
120
123
  createMaskFromColor(color, alpha = 0) {
121
- if (!(color instanceof color_1.Color))
124
+ if (!(color instanceof color_1.Color)) {
122
125
  throw new TypeError('Expected a Color');
123
- if (typeof alpha !== 'number')
126
+ }
127
+ if (typeof alpha !== 'number') {
124
128
  throw new TypeError('Expected numeric alpha');
129
+ }
125
130
  // eslint-disable-next-line no-bitwise
126
131
  const byte = alpha & 255;
127
132
  native_1.native.maskImage(this[graphics_state_1.graphicsNative], color.toInteger(), byte);
@@ -136,8 +141,9 @@ class Image {
136
141
  * 반환합니다.
137
142
  */
138
143
  copy(source, dest, sourceRect, applyAlpha = false) {
139
- if (!(source instanceof Image))
144
+ if (!(source instanceof Image)) {
140
145
  throw new TypeError('Expected an Image');
146
+ }
141
147
  coordinates(dest);
142
148
  if (sourceRect !== undefined && !(sourceRect instanceof rect_1.IntRect)) {
143
149
  throw new TypeError('Expected an IntRect');
@@ -195,7 +201,9 @@ class Image {
195
201
  */
196
202
  async loadFromStream(stream) {
197
203
  let failure;
198
- const dispatch = (0, input_stream_1.streamDispatch)(stream, error => { failure = { error }; });
204
+ const dispatch = (0, input_stream_1.streamDispatch)(stream, error => {
205
+ failure = { error };
206
+ });
199
207
  try {
200
208
  return await this.load(callback => {
201
209
  native_1.native.loadImageStream(this[graphics_state_1.graphicsNative], dispatch, callback);
@@ -215,10 +223,12 @@ class Image {
215
223
  saveToFile(filename) {
216
224
  return new Promise((resolve, reject) => {
217
225
  native_1.native.saveImageFile(this[graphics_state_1.graphicsNative], filename, (error, result) => {
218
- if (error)
226
+ if (error) {
219
227
  reject(error);
220
- else
228
+ }
229
+ else {
221
230
  resolve(result);
231
+ }
222
232
  });
223
233
  });
224
234
  }
@@ -232,10 +242,12 @@ class Image {
232
242
  saveToMemory(format) {
233
243
  return new Promise((resolve, reject) => {
234
244
  native_1.native.saveImageMemory(this[graphics_state_1.graphicsNative], format, (error, result) => {
235
- if (error)
245
+ if (error) {
236
246
  reject(error);
237
- else
247
+ }
248
+ else {
238
249
  resolve(result);
250
+ }
239
251
  });
240
252
  });
241
253
  }
@@ -249,11 +261,13 @@ class Image {
249
261
  load(start) {
250
262
  return new Promise((resolve, reject) => {
251
263
  start((error, mapping) => {
252
- if (error)
264
+ if (error) {
253
265
  reject(error);
266
+ }
254
267
  else {
255
- if (mapping)
268
+ if (mapping) {
256
269
  this.state = view(mapping);
270
+ }
257
271
  resolve(mapping !== undefined);
258
272
  }
259
273
  });
@@ -278,7 +292,9 @@ exports.Image = Image;
278
292
  (() => {
279
293
  exports.imageFromMapping = mapping => {
280
294
  const image = Object.create(Image.prototype);
281
- Object.defineProperty(image, graphics_state_1.graphicsNative, { value: mapping.handle });
295
+ Object.defineProperty(image, graphics_state_1.graphicsNative, {
296
+ value: mapping.handle,
297
+ });
282
298
  image.state = view(mapping);
283
299
  return image;
284
300
  };
@@ -112,8 +112,10 @@ class Rect {
112
112
  const data = this[value_storage_1.rectStorage];
113
113
  const endX = (0, scalar_1.toScalar)(this.type, data[0] + data[2]);
114
114
  const endY = (0, scalar_1.toScalar)(this.type, data[1] + data[3]);
115
- return point.x >= min(data[0], endX) && point.x < max(data[0], endX) &&
116
- point.y >= min(data[1], endY) && point.y < max(data[1], endY);
115
+ return (point.x >= min(data[0], endX) &&
116
+ point.x < max(data[0], endX) &&
117
+ point.y >= min(data[1], endY) &&
118
+ point.y < max(data[1], endY));
117
119
  }
118
120
  /**
119
121
  * Returns a new rectangle intersecting this and a same-type rectangle;
@@ -124,7 +126,8 @@ class Rect {
124
126
  * 반환합니다.
125
127
  */
126
128
  findIntersection(rectangle) {
127
- if (!(rectangle instanceof Rect) || rectangle.scalarType !== this.type) {
129
+ if (!(rectangle instanceof Rect) ||
130
+ rectangle.scalarType !== this.type) {
128
131
  throw new TypeError('Rect operands must have the same scalar type');
129
132
  }
130
133
  const a = this[value_storage_1.rectStorage];
@@ -137,8 +140,9 @@ class Rect {
137
140
  const top = max(min(a[1], ay), min(b[1], by));
138
141
  const right = min(max(a[0], ax), max(b[0], bx));
139
142
  const bottom = min(max(a[1], ay), max(b[1], by));
140
- if (!(left < right && top < bottom))
143
+ if (!(left < right && top < bottom)) {
141
144
  return undefined;
145
+ }
142
146
  const result = this.createResult();
143
147
  const data = result[value_storage_1.rectStorage];
144
148
  data[0] = left;
@@ -158,8 +162,7 @@ class Rect {
158
162
  const data = this[value_storage_1.rectStorage];
159
163
  const x = data[0] + (0, scalar_1.toScalar)(this.type, data[2] / 2);
160
164
  const y = data[1] + (0, scalar_1.toScalar)(this.type, data[3] / 2);
161
- return (this.type === 'f32'
162
- ? new vector2_1.Vector2f(x, y) : new vector2_1.Vector2i(x, y));
165
+ return (this.type === 'f32' ? new vector2_1.Vector2f(x, y) : new vector2_1.Vector2i(x, y));
163
166
  }
164
167
  createResult() {
165
168
  return new Rect(this.type);
@@ -229,7 +232,9 @@ exports.IntRect = IntRect;
229
232
  */
230
233
  function intRectFromState(state) {
231
234
  return Object.assign(Object.create(IntRect.prototype), {
232
- [value_storage_1.mutableValue]: true, type: 'i32', state,
235
+ [value_storage_1.mutableValue]: true,
236
+ type: 'i32',
237
+ state,
233
238
  createResult: () => new IntRect(),
234
239
  });
235
240
  }
@@ -242,7 +247,9 @@ exports.intRectFromState = intRectFromState;
242
247
  */
243
248
  function floatRectFromState(state) {
244
249
  return Object.assign(Object.create(FloatRect.prototype), {
245
- [value_storage_1.mutableValue]: true, type: 'f32', state,
250
+ [value_storage_1.mutableValue]: true,
251
+ type: 'f32',
252
+ state,
246
253
  createResult: () => new FloatRect(),
247
254
  });
248
255
  }
@@ -47,32 +47,41 @@ class RenderStates {
47
47
  */
48
48
  constructor(source = defaultOptions) {
49
49
  let options;
50
- if (source === defaultOptions)
50
+ if (source === defaultOptions) {
51
51
  options = defaultOptions;
52
- else if (source instanceof RenderStates)
52
+ }
53
+ else if (source instanceof RenderStates) {
53
54
  options = source;
54
- else if (source instanceof transform_1.Transform)
55
+ }
56
+ else if (source instanceof transform_1.Transform) {
55
57
  options = { transform: source };
56
- else if (source instanceof blend_mode_1.BlendMode)
58
+ }
59
+ else if (source instanceof blend_mode_1.BlendMode) {
57
60
  options = { blendMode: source };
58
- else if (source instanceof stencil_mode_1.StencilMode)
61
+ }
62
+ else if (source instanceof stencil_mode_1.StencilMode) {
59
63
  options = { stencilMode: source };
60
- else if (source instanceof shader_1.Shader)
64
+ }
65
+ else if (source instanceof shader_1.Shader) {
61
66
  options = { shader: source };
67
+ }
62
68
  else if (source instanceof texture_1.Texture || source === null) {
63
69
  options = { texture: source };
64
70
  }
65
- else if (typeof source === 'object')
71
+ else if (typeof source === 'object') {
66
72
  options = source;
67
- else
73
+ }
74
+ else {
68
75
  throw new TypeError('Expected render states');
76
+ }
69
77
  if (options.shader != null && !(options.shader instanceof shader_1.Shader)) {
70
78
  throw new TypeError('Expected a Shader or null');
71
79
  }
72
80
  this.blendMode = new blend_mode_1.BlendMode(options.blendMode ?? blend_mode_1.BlendAlpha);
73
81
  this.stencilMode = new stencil_mode_1.StencilMode(options.stencilMode);
74
82
  const transform = options.transform;
75
- this.matrix = transform == null ? new transform_1.Transform() : new transform_1.Transform(transform);
83
+ this.matrix =
84
+ transform == null ? new transform_1.Transform() : new transform_1.Transform(transform);
76
85
  (0, numeric_properties_1.numericProperties)(this, { coordinateType: CoordinateType.Pixels });
77
86
  this.coordinateType = options.coordinateType ?? CoordinateType.Pixels;
78
87
  this.texture = options.texture ?? null;
@@ -58,8 +58,9 @@ class RenderTarget {
58
58
  * @ko 대기 중인 그리기를 제출하고 OpenGL 컨텍스트를 활성화하거나 비활성화합니다. 성공 여부를 반환합니다.
59
59
  */
60
60
  setActive(active = true) {
61
- if (typeof active !== 'boolean')
61
+ if (typeof active !== 'boolean') {
62
62
  throw new TypeError('Expected a boolean');
63
+ }
63
64
  this.flush();
64
65
  return this.activate(active);
65
66
  }
@@ -71,8 +72,9 @@ class RenderTarget {
71
72
  * @ko 이후 그리기에 사용할 뷰를 복사하여 설정합니다. 이미 기록된 그리기는 원래 뷰를 유지합니다.
72
73
  */
73
74
  setView(view) {
74
- if (!(view instanceof view_1.View))
75
+ if (!(view instanceof view_1.View)) {
75
76
  throw new TypeError('Expected a View');
77
+ }
76
78
  const offset = this.nextCommand();
77
79
  this.words[offset] = 5;
78
80
  (0, view_1.writeView)(view, this.floats, offset + 9);
@@ -104,8 +106,9 @@ class RenderTarget {
104
106
  * @ko view의 정규화된 뷰포트를 대상의 픽셀 사각형으로 변환합니다.
105
107
  */
106
108
  getViewport(view) {
107
- if (!(view instanceof view_1.View))
109
+ if (!(view instanceof view_1.View)) {
108
110
  throw new TypeError('Expected a View');
111
+ }
109
112
  return this.pixelRectangle(view.getViewport());
110
113
  }
111
114
  /**
@@ -115,8 +118,9 @@ class RenderTarget {
115
118
  * @ko view의 정규화된 시저 영역을 픽셀 사각형으로 변환합니다.
116
119
  */
117
120
  getScissor(view) {
118
- if (!(view instanceof view_1.View))
121
+ if (!(view instanceof view_1.View)) {
119
122
  throw new TypeError('Expected a View');
123
+ }
120
124
  return this.pixelRectangle(view.getScissor());
121
125
  }
122
126
  /**
@@ -133,7 +137,9 @@ class RenderTarget {
133
137
  const viewport = this.getViewport(view);
134
138
  const x = f(f(point.x) - f(viewport.position.x));
135
139
  const y = f(f(point.y) - f(viewport.position.y));
136
- return view.getInverseTransform().transformPoint(new vector2_1.Vector2f(f(-1 + f(f(2 * x) / f(viewport.size.x))), f(1 + f(f(-2 * y) / f(viewport.size.y)))));
140
+ return view
141
+ .getInverseTransform()
142
+ .transformPoint(new vector2_1.Vector2f(f(-1 + f(f(2 * x) / f(viewport.size.x))), f(1 + f(f(-2 * y) / f(viewport.size.y)))));
137
143
  }
138
144
  /**
139
145
  * Converts world coordinates to integer target pixel coordinates; uses the
@@ -206,8 +212,9 @@ class RenderTarget {
206
212
  * @ko 색상 지우기 명령을 기록하며 기본 색상은 검정입니다. stencil을 제공하면 스텐실 버퍼도 지웁니다.
207
213
  */
208
214
  clear(color = color_1.Color.Black, stencil) {
209
- if (!(color instanceof color_1.Color))
215
+ if (!(color instanceof color_1.Color)) {
210
216
  throw new TypeError('Expected a Color');
217
+ }
211
218
  const rgba = color.toInteger();
212
219
  const value = stencil === undefined ? 0 : new stencil_mode_1.StencilValue(stencil).value;
213
220
  const offset = this.nextCommand();
@@ -229,28 +236,34 @@ class RenderTarget {
229
236
  this.words[offset + 1] = value;
230
237
  }
231
238
  draw(drawable, statesOrType = render_states_1.defaultRenderStates, statesOrCount = render_states_1.defaultRenderStates, rangeStates = render_states_1.defaultRenderStates) {
232
- if (drawable instanceof vertex_buffer_1.VertexBuffer && typeof statesOrType === 'number') {
239
+ if (drawable instanceof vertex_buffer_1.VertexBuffer &&
240
+ typeof statesOrType === 'number') {
233
241
  const value = rangeStates instanceof render_states_2.RenderStates
234
- ? rangeStates : new render_states_2.RenderStates(rangeStates);
242
+ ? rangeStates
243
+ : new render_states_2.RenderStates(rangeStates);
235
244
  this[graphics_state_1.recordVertexBuffer](drawable, statesOrType, statesOrCount, value);
236
245
  return;
237
246
  }
238
247
  if (drawable instanceof drawable_1.Drawable) {
239
248
  const value = statesOrType instanceof render_states_2.RenderStates
240
- ? statesOrType : new render_states_2.RenderStates(statesOrType);
249
+ ? statesOrType
250
+ : new render_states_2.RenderStates(statesOrType);
241
251
  drawable[graphics_state_1.dispatchDrawable](this, value);
242
252
  return;
243
253
  }
244
- if (!Array.isArray(drawable))
254
+ if (!Array.isArray(drawable)) {
245
255
  throw new TypeError('Expected a Drawable');
256
+ }
246
257
  (0, primitive_type_1.validatePrimitiveType)(statesOrType);
247
258
  const value = statesOrCount instanceof render_states_2.RenderStates
248
- ? statesOrCount : new render_states_2.RenderStates(statesOrCount);
259
+ ? statesOrCount
260
+ : new render_states_2.RenderStates(statesOrCount);
249
261
  (0, render_states_1.validateRenderStates)(value);
250
262
  // Validate and capture every view before touching the command queue.
251
263
  const vertices = drawable.map(vertex => {
252
- if (!(vertex instanceof vertex_1.Vertex))
264
+ if (!(vertex instanceof vertex_1.Vertex)) {
253
265
  throw new TypeError('Expected a Vertex');
266
+ }
254
267
  return vertex[value_storage_1.vertexStorage];
255
268
  });
256
269
  // Array holes must not turn into partially initialized draw commands.
@@ -273,8 +286,9 @@ class RenderTarget {
273
286
  * @ko 외부 그래픽 작업 전에 대기 중인 그리기를 제출합니다.
274
287
  */
275
288
  flush() {
276
- if (this.count !== 0)
289
+ if (this.count !== 0) {
277
290
  this.submit(false);
291
+ }
278
292
  }
279
293
  [graphics_state_1.graphicsFlush]() {
280
294
  this.flush();
@@ -298,8 +312,9 @@ class RenderTarget {
298
312
  this.floats.set(matrix[value_storage_1.transformStorage], offset + 9);
299
313
  this.writeModes(offset, states);
300
314
  this.pendingShapes.add(shape);
301
- if (appearance.texture)
315
+ if (appearance.texture) {
302
316
  this.pendingTextures.add(appearance.texture);
317
+ }
303
318
  }
304
319
  [graphics_state_1.recordSprite](sprite, states) {
305
320
  // Validation precedes reservation so a rejected call leaves no command.
@@ -328,13 +343,18 @@ class RenderTarget {
328
343
  }
329
344
  [graphics_state_1.recordVertexBuffer](buffer, first, count, states) {
330
345
  (0, render_states_1.validateRenderStates)(states);
331
- if (!Number.isInteger(first) || first < 0 || first > 0xffffffff ||
332
- !Number.isInteger(count) || count < 0 || count > 0xffffffff) {
346
+ if (!Number.isInteger(first) ||
347
+ first < 0 ||
348
+ first > 0xffffffff ||
349
+ !Number.isInteger(count) ||
350
+ count < 0 ||
351
+ count > 0xffffffff) {
333
352
  throw new RangeError('Vertex range is out of bounds');
334
353
  }
335
354
  const available = buffer.getVertexCount();
336
- if (first >= available || count === 0)
355
+ if (first >= available || count === 0) {
337
356
  return;
357
+ }
338
358
  count = Math.min(count, available - first);
339
359
  (0, graphics_state_1.validateTextureRead)(this, states.texture);
340
360
  this.validateShaderReads(states);
@@ -349,8 +369,9 @@ class RenderTarget {
349
369
  this.floats.set(states.transform[value_storage_1.transformStorage], offset + 9);
350
370
  this.writeModes(offset, states);
351
371
  this.pendingBuffers.add(buffer);
352
- if (states.texture)
372
+ if (states.texture) {
353
373
  this.pendingTextures.add(states.texture);
374
+ }
354
375
  }
355
376
  writeModes(offset, states) {
356
377
  const b = states.blendMode;
@@ -375,19 +396,22 @@ class RenderTarget {
375
396
  }
376
397
  }
377
398
  validateShaderReads(states) {
378
- if (!states.shader)
399
+ if (!states.shader) {
379
400
  return;
401
+ }
380
402
  for (const texture of states.shader[graphics_state_1.shaderTextures].values()) {
381
403
  (0, graphics_state_1.validateTextureRead)(this, texture);
382
404
  }
383
405
  }
384
406
  writeVertices(count, type, states, copy) {
385
- if (!Number.isInteger(count) || count < 0 ||
407
+ if (!Number.isInteger(count) ||
408
+ count < 0 ||
386
409
  count > Math.floor(0x7fffffff / 20)) {
387
410
  throw new RangeError('Vertex count exceeds the buffer limit');
388
411
  }
389
- if (count === 0)
412
+ if (count === 0) {
390
413
  return;
414
+ }
391
415
  (0, graphics_state_1.validateTextureRead)(this, states.texture);
392
416
  this.validateShaderReads(states);
393
417
  const matrix = states.transform[value_storage_1.transformStorage];
@@ -412,8 +436,9 @@ class RenderTarget {
412
436
  this.floats.set(matrix, offset + 9);
413
437
  this.writeModes(offset, states);
414
438
  this.vertexCount += count;
415
- if (states.texture)
439
+ if (states.texture) {
416
440
  this.pendingTextures.add(states.texture);
441
+ }
417
442
  }
418
443
  submit(display) {
419
444
  this.submitCommands(this.count, display);
@@ -426,8 +451,9 @@ class RenderTarget {
426
451
  this.pendingShaders.clear();
427
452
  }
428
453
  nextCommand() {
429
- if (this.count === this.words.length / commandWords)
454
+ if (this.count === this.words.length / commandWords) {
430
455
  this.submit(false);
456
+ }
431
457
  return this.count++ * commandWords;
432
458
  }
433
459
  }
@@ -14,8 +14,9 @@ function coordinates(size) {
14
14
  }
15
15
  }
16
16
  function flag(value) {
17
- if (typeof value !== 'boolean')
17
+ if (typeof value !== 'boolean') {
18
18
  throw new TypeError('Expected a boolean');
19
+ }
19
20
  }
20
21
  /**
21
22
  * sf::RenderTexture: record clear/draw, submit when display is called.
@@ -25,16 +26,18 @@ function flag(value) {
25
26
  */
26
27
  class RenderTexture extends render_target_1.RenderTarget {
27
28
  constructor(size, settings = {}) {
28
- if (size !== undefined)
29
+ if (size !== undefined) {
29
30
  coordinates(size);
31
+ }
30
32
  const requested = (0, context_settings_1.contextSettings)(settings);
31
33
  const { handle, buffer, info, targetInfo } = native_1.native.createRenderTexture((0, graphics_state_1.graphicsContext)(), size?.x, size?.y, requested);
32
34
  super(buffer);
33
35
  this[graphics_state_1.graphicsNative] = handle;
34
36
  this.state = (0, struct_view_1.nativeStruct)(info);
35
37
  this.targetInfo = (0, struct_view_1.nativeStruct)(targetInfo);
36
- if (size)
38
+ if (size) {
37
39
  this.initializeViews(size);
40
+ }
38
41
  }
39
42
  /**
40
43
  * Returns a copy of the off-screen target's pixel size.
@@ -54,8 +57,9 @@ class RenderTexture extends render_target_1.RenderTarget {
54
57
  resize(size, settings = {}) {
55
58
  coordinates(size);
56
59
  const requested = (0, context_settings_1.contextSettings)(settings);
57
- if (this.texture)
60
+ if (this.texture) {
58
61
  (0, graphics_state_1.flushTextureReaders)(this);
62
+ }
59
63
  this.flush();
60
64
  const info = native_1.native.resizeRenderTexture(this[graphics_state_1.graphicsNative], size.x, size.y, requested);
61
65
  if (info) {
@@ -81,10 +85,12 @@ class RenderTexture extends render_target_1.RenderTarget {
81
85
  */
82
86
  setSmooth(smooth) {
83
87
  flag(smooth);
84
- if (smooth === this.state.smooth)
88
+ if (smooth === this.state.smooth) {
85
89
  return;
86
- if (this.texture)
90
+ }
91
+ if (this.texture) {
87
92
  (0, graphics_state_1.flushTextureReaders)(this);
93
+ }
88
94
  native_1.native.setRenderTextureSmooth(this[graphics_state_1.graphicsNative], smooth);
89
95
  }
90
96
  /**
@@ -104,10 +110,12 @@ class RenderTexture extends render_target_1.RenderTarget {
104
110
  */
105
111
  setRepeated(repeated) {
106
112
  flag(repeated);
107
- if (repeated === this.state.repeated)
113
+ if (repeated === this.state.repeated) {
108
114
  return;
109
- if (this.texture)
115
+ }
116
+ if (this.texture) {
110
117
  (0, graphics_state_1.flushTextureReaders)(this);
118
+ }
111
119
  native_1.native.setRenderTextureRepeated(this[graphics_state_1.graphicsNative], repeated);
112
120
  }
113
121
  /**
@@ -135,8 +143,9 @@ class RenderTexture extends render_target_1.RenderTarget {
135
143
  * @ko 그린 후 display()를 호출한 다음 해당 이미지의 mipmap을 생성합니다.
136
144
  */
137
145
  generateMipmap() {
138
- if (this.texture)
146
+ if (this.texture) {
139
147
  (0, graphics_state_1.flushTextureReaders)(this);
148
+ }
140
149
  return native_1.native.generateRenderTextureMipmap(this[graphics_state_1.graphicsNative]);
141
150
  }
142
151
  /**
@@ -146,13 +155,15 @@ class RenderTexture extends render_target_1.RenderTarget {
146
155
  * @ko OpenGL에 직접 접근하거나 비활성화하기 전에 기록된 작업을 완료합니다.
147
156
  */
148
157
  activate(active) {
149
- if (active && this.texture)
158
+ if (active && this.texture) {
150
159
  (0, graphics_state_1.flushTextureReaders)(this);
160
+ }
151
161
  return native_1.native.setRenderTextureActive(this[graphics_state_1.graphicsNative], active);
152
162
  }
153
163
  changeGLStates(operation) {
154
- if (this.texture)
164
+ if (this.texture) {
155
165
  (0, graphics_state_1.flushTextureReaders)(this);
166
+ }
156
167
  native_1.native.changeRenderTextureGLStates(this[graphics_state_1.graphicsNative], operation);
157
168
  }
158
169
  /**
@@ -176,8 +187,9 @@ class RenderTexture extends render_target_1.RenderTarget {
176
187
  this.submit(true);
177
188
  }
178
189
  submitCommands(count, display) {
179
- if (this.texture)
190
+ if (this.texture) {
180
191
  (0, graphics_state_1.flushTextureReaders)(this);
192
+ }
181
193
  native_1.native.submitRenderTexture(this[graphics_state_1.graphicsNative], count, display);
182
194
  }
183
195
  allocateVertexBuffer(capacity) {