sfml.js 0.0.1-preview.38 → 0.0.1-preview.41

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 (53) hide show
  1. package/README.md +2 -4
  2. package/binding.gyp +34 -0
  3. package/lib/color.js +5 -2
  4. package/lib/image.js +17 -4
  5. package/lib/keyboard.js +3 -1
  6. package/lib/rect.js +28 -8
  7. package/lib/render_window.js +3 -1
  8. package/lib/vector2.js +26 -12
  9. package/lib/vertex.js +4 -2
  10. package/lib/video_mode.js +14 -4
  11. package/package.json +8 -3
  12. package/src/color.cc +4 -6
  13. package/src/drawable/package_plugin-inl.h +4 -3
  14. package/src/drawable/rectangle_shape.cc +3 -2
  15. package/src/drawable/shape.cc +3 -1
  16. package/src/drawable/vertex_array.cc +3 -3
  17. package/src/font.cc +6 -4
  18. package/src/image.cc +4 -5
  19. package/src/image.h +1 -1
  20. package/src/mouse.cc +2 -1
  21. package/src/plugins/transformable_plugin-inl.h +2 -2
  22. package/src/rect-inl.h +12 -8
  23. package/src/rect.h +1 -1
  24. package/src/render_window.cc +4 -3
  25. package/src/resizable_buffer.h +18 -2
  26. package/src/texture.cc +2 -2
  27. package/src/utils-inl.h +2 -2
  28. package/src/vector2-inl.h +13 -13
  29. package/src/vector2.h +3 -3
  30. package/src/vertex.cc +66 -28
  31. package/src/vertex.h +2 -2
  32. package/third_party/sfml/platform/win64/bin/openal32.dll +0 -0
  33. package/third_party/sfml/platform/win64/bin/sfml-audio-2.dll +0 -0
  34. package/third_party/sfml/platform/win64/bin/sfml-graphics-2.dll +0 -0
  35. package/third_party/sfml/platform/win64/bin/sfml-network-2.dll +0 -0
  36. package/third_party/sfml/platform/win64/bin/sfml-system-2.dll +0 -0
  37. package/third_party/sfml/platform/win64/bin/sfml-window-2.dll +0 -0
  38. package/third_party/sfml/platform/win64/lib/flac.lib +0 -0
  39. package/third_party/sfml/platform/win64/lib/freetype.lib +0 -0
  40. package/third_party/sfml/platform/win64/lib/ogg.lib +0 -0
  41. package/third_party/sfml/platform/win64/lib/openal32.lib +0 -0
  42. package/third_party/sfml/platform/win64/lib/sfml-audio.lib +0 -0
  43. package/third_party/sfml/platform/win64/lib/sfml-graphics.lib +0 -0
  44. package/third_party/sfml/platform/win64/lib/sfml-main.lib +0 -0
  45. package/third_party/sfml/platform/win64/lib/sfml-network.lib +0 -0
  46. package/third_party/sfml/platform/win64/lib/sfml-system.lib +0 -0
  47. package/third_party/sfml/platform/win64/lib/sfml-window.lib +0 -0
  48. package/third_party/sfml/platform/win64/lib/vorbis.lib +0 -0
  49. package/third_party/sfml/platform/win64/lib/vorbisenc.lib +0 -0
  50. package/third_party/sfml/platform/win64/lib/vorbisfile.lib +0 -0
  51. package/tools/keycode.js +31 -20
  52. package/tools/mouse_button.js +52 -35
  53. package/tools/symlinks.js +15 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![](https://www.sfml-dev.org/images/logo.png)
4
4
 
5
- SFML's Node.js binding.
5
+ A cross-platform SFML's Node.js binding.
6
6
 
7
7
  > Under developing.
8
8
 
@@ -10,6 +10,4 @@ SFML's Node.js binding.
10
10
 
11
11
  ```bash
12
12
  $ node-gyp rebuild
13
- ```
14
-
15
- > Current only support Linux and macOS.
13
+ ```
package/binding.gyp CHANGED
@@ -55,8 +55,42 @@
55
55
  "../third_party/sfml/platform/linux/lib/libsfml-window.so",
56
56
  "../third_party/sfml/platform/linux/lib/libsfml-network.so",
57
57
  "../third_party/sfml/platform/linux/lib/libsfml-graphics.so"
58
+ ],
59
+ "ldflags": [
60
+ "-Wl,-rpath='$$ORIGIN/../../third_party/sfml/platform/linux/lib'"
58
61
  ]
59
62
  }],
63
+ ["OS==\"win\"", {
64
+ "defines": [
65
+ "NOMINMAX"
66
+ ],
67
+ "copies": [{
68
+ "destination": "<(module_root_dir)/build/Release/",
69
+ "files": [
70
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/openal32.dll",
71
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/sfml-audio-2.dll",
72
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/sfml-graphics-2.dll",
73
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/sfml-network-2.dll",
74
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/sfml-system-2.dll",
75
+ "<(module_root_dir)/third_party/sfml/platform/win64/bin/sfml-window-2.dll"
76
+ ]
77
+ }],
78
+ "libraries": [
79
+ "../third_party/sfml/platform/win64/lib/flac.lib",
80
+ "../third_party/sfml/platform/win64/lib/freetype.lib",
81
+ "../third_party/sfml/platform/win64/lib/ogg.lib",
82
+ "../third_party/sfml/platform/win64/lib/openal32.lib",
83
+ "../third_party/sfml/platform/win64/lib/sfml-audio.lib",
84
+ "../third_party/sfml/platform/win64/lib/sfml-graphics.lib",
85
+ "../third_party/sfml/platform/win64/lib/sfml-main.lib",
86
+ "../third_party/sfml/platform/win64/lib/sfml-network.lib",
87
+ "../third_party/sfml/platform/win64/lib/sfml-system.lib",
88
+ "../third_party/sfml/platform/win64/lib/sfml-window.lib",
89
+ "../third_party/sfml/platform/win64/lib/vorbis.lib",
90
+ "../third_party/sfml/platform/win64/lib/vorbisenc.lib",
91
+ "../third_party/sfml/platform/win64/lib/vorbisfile.lib",
92
+ ],
93
+ }],
60
94
  ["OS==\"mac\"", {
61
95
  "libraries": [
62
96
  "../third_party/sfml/platform/macOS/lib/libsfml-audio.dylib",
package/lib/color.js CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  const util = require('util');
4
4
 
5
- const { Color: _Color, setRealColorConstructor } = require('../build/Release/binding.node');
5
+ const {
6
+ Color: _Color,
7
+ setRealColorConstructor,
8
+ } = require('../build/Release/binding.node');
6
9
  const { validateTypeOf } = require('./common');
7
10
 
8
11
  const TO_INTEGER = Symbol('Color::toInteger');
@@ -90,6 +93,6 @@ class Color extends _Color {
90
93
  }
91
94
  }
92
95
 
93
- setRealColorConstructor(Color);
96
+ setRealColorConstructor((...args) => new Color(...args));
94
97
 
95
98
  module.exports = { Color };
package/lib/image.js CHANGED
@@ -13,7 +13,11 @@ class Image extends _Image {
13
13
  validateTypeOf(src, 'src', _Image);
14
14
  validateTypeOf(destX, 'destX', 'number');
15
15
  validateTypeOf(destY, 'destY', 'number');
16
- validateTypeOf(sourceRect, 'sourceRectOrApplyAlpha', [ 'boolean', IntRect ], true);
16
+ validateTypeOf(
17
+ sourceRect,
18
+ 'sourceRectOrApplyAlpha',
19
+ [ 'boolean', IntRect ],
20
+ true);
17
21
  validateTypeOf(applyAlpha, 'applyAlpha', 'boolean', true);
18
22
 
19
23
  if (sourceRect === undefined && applyAlpha === undefined) {
@@ -30,7 +34,14 @@ class Image extends _Image {
30
34
  create(width, height, colorOrPixels) {
31
35
  validateTypeOf(width, 'width', 'number');
32
36
  validateTypeOf(height, 'height', 'number');
33
- validateTypeOf(colorOrPixels, 'colorOrPixels', [ Color, Buffer, Array, ArrayBuffer, Uint8Array, 'number' ]);
37
+ validateTypeOf(colorOrPixels, 'colorOrPixels', [
38
+ Color,
39
+ Buffer,
40
+ Array,
41
+ ArrayBuffer,
42
+ Uint8Array,
43
+ 'number',
44
+ ]);
34
45
 
35
46
  if (typeof colorOrPixels === 'number') {
36
47
  colorOrPixels = new Color(colorOrPixels);
@@ -122,13 +133,15 @@ class Image extends _Image {
122
133
  });
123
134
 
124
135
  if (err) {
125
- process.nextTick(() => { reject(err); });
136
+ process.nextTick(() => {
137
+ reject(err);
138
+ });
126
139
  }
127
140
 
128
141
  return promise;
129
142
  }
130
143
  }
131
144
 
132
- Image.setRealConstructor(Image);
145
+ Image.setRealConstructor((...args) => new Image(...args));
133
146
 
134
147
  module.exports = { Image };
package/lib/keyboard.js CHANGED
@@ -6,7 +6,9 @@ const {
6
6
  Keys,
7
7
  } = require('../build/Release/binding.node');
8
8
 
9
- exports.setVirtualKeyboardVisible = function setVirtualKeyboardVisible(visible) {
9
+ exports.setVirtualKeyboardVisible = function setVirtualKeyboardVisible(
10
+ visible
11
+ ) {
10
12
  _setVirtualKeyboardVisible(!!visible);
11
13
  };
12
14
 
package/lib/rect.js CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  const util = require('util');
4
4
 
5
- const { FloatRect: _FloatRect, IntRect: _IntRect } = require('../build/Release/binding.node');
5
+ const {
6
+ FloatRect: _FloatRect,
7
+ IntRect: _IntRect,
8
+ } = require('../build/Release/binding.node');
6
9
  const { validateTypeOf } = require('./common');
7
10
  const { Vector2F, Vector2I } = require('./vector2');
8
11
 
@@ -15,7 +18,12 @@ function createClass(name, BaseClz, Vector) {
15
18
  }
16
19
 
17
20
  toJSON() {
18
- return { left: this.left, top: this.top, width: this.width, height: this.height };
21
+ return {
22
+ left: this.left,
23
+ top: this.top,
24
+ width: this.width,
25
+ height: this.height,
26
+ };
19
27
  }
20
28
 
21
29
  constructor(leftOrPosition, topOrSize, width, height) {
@@ -42,25 +50,37 @@ function createClass(name, BaseClz, Vector) {
42
50
  }
43
51
  }
44
52
 
45
- get top() { return super.top; }
53
+ get top() {
54
+ return super.top;
55
+ }
56
+
46
57
  set top(val) {
47
58
  validateTypeOf(val, 'top', 'number');
48
59
  super.top = val;
49
60
  }
50
61
 
51
- get left() { return super.left; }
62
+ get left() {
63
+ return super.left;
64
+ }
65
+
52
66
  set left(val) {
53
67
  validateTypeOf(val, 'left', 'number');
54
68
  super.left = val;
55
69
  }
56
70
 
57
- get width() { return super.width; }
71
+ get width() {
72
+ return super.width;
73
+ }
74
+
58
75
  set width(val) {
59
76
  validateTypeOf(val, 'width', 'number');
60
77
  super.width = val;
61
78
  }
62
79
 
63
- get height() { return super.height; }
80
+ get height() {
81
+ return super.height;
82
+ }
83
+
64
84
  set height(val) {
65
85
  validateTypeOf(val, 'height', 'number');
66
86
  super.height = val;
@@ -91,9 +111,9 @@ function createClass(name, BaseClz, Vector) {
91
111
  }
92
112
 
93
113
  const IntRect = createClass('IntRect', _IntRect, Vector2I);
94
- _IntRect.setRealConstructor(IntRect);
114
+ _IntRect.setRealConstructor((...args) => new IntRect(...args));
95
115
 
96
116
  const FloatRect = createClass('FloatRect', _FloatRect, Vector2F);
97
- _FloatRect.setRealConstructor(FloatRect);
117
+ _FloatRect.setRealConstructor((...args) => new FloatRect(...args));
98
118
 
99
119
  module.exports = { FloatRect, IntRect };
@@ -2,7 +2,9 @@
2
2
 
3
3
  const { Color } = require('./color');
4
4
  const { Drawable } = require('./drawable/drawable');
5
- const { RenderWindow: _RenderWindow } = require('../build/Release/binding.node');
5
+ const {
6
+ RenderWindow: _RenderWindow,
7
+ } = require('../build/Release/binding.node');
6
8
  const { validateTypeOf } = require('./common');
7
9
  const { VideoMode } = require('./video_mode');
8
10
 
package/lib/vector2.js CHANGED
@@ -43,14 +43,20 @@ function createClass(name, BaseClz, checkRange, formatBaseValue = v => v) {
43
43
  }
44
44
  }
45
45
 
46
- get x() { return super.x; }
46
+ get x() {
47
+ return super.x;
48
+ }
49
+
47
50
  set x(val) {
48
51
  validateTypeOf(val, 'x', 'number');
49
52
  checkRange(val);
50
53
  super.x = formatBaseValue(val);
51
54
  }
52
55
 
53
- get y() { return super.y; }
56
+ get y() {
57
+ return super.y;
58
+ }
59
+
54
60
  set y(val) {
55
61
  validateTypeOf(val, 'y', 'number');
56
62
  checkRange(val);
@@ -111,17 +117,25 @@ function createClass(name, BaseClz, checkRange, formatBaseValue = v => v) {
111
117
  };
112
118
  }
113
119
 
114
- const Vector2I = createClass('Vector2I', _Vector2I, () => true, v => parseInt(v));
115
- _Vector2I.setRealConstructor(Vector2I);
116
-
117
- const Vector2U = createClass('Vector2U', _Vector2U, v => {
118
- if (v < 0) {
119
- throw new Error('Value should greater than or equal to 0.');
120
- }
121
- }, v => parseInt(v));
122
- _Vector2U.setRealConstructor(Vector2U);
120
+ const Vector2I = createClass(
121
+ 'Vector2I',
122
+ _Vector2I,
123
+ () => true,
124
+ v => parseInt(v));
125
+ _Vector2I.setRealConstructor((...args) => new Vector2I(...args));
126
+
127
+ const Vector2U = createClass(
128
+ 'Vector2U',
129
+ _Vector2U,
130
+ v => {
131
+ if (v < 0) {
132
+ throw new Error('Value should greater than or equal to 0.');
133
+ }
134
+ },
135
+ v => parseInt(v));
136
+ _Vector2U.setRealConstructor((...args) => new Vector2U(...args));
123
137
 
124
138
  const Vector2F = createClass('Vector2F', _Vector2F, () => true);
125
- _Vector2F.setRealConstructor(Vector2F);
139
+ _Vector2F.setRealConstructor((...args) => new Vector2F(...args));
126
140
 
127
141
  module.exports = { Vector2I, Vector2U, Vector2F };
package/lib/vertex.js CHANGED
@@ -67,7 +67,9 @@ class Vertex extends _Vertex {
67
67
 
68
68
  [UNINJECT](object, properties) {
69
69
  for (const property of properties) {
70
- const origDesc = Object.getOwnPropertyDescriptor(object, `orig$$${property}`);
70
+ const origDesc = Object.getOwnPropertyDescriptor(
71
+ object,
72
+ `orig$$${property}`);
71
73
  origDesc.enumerable = true;
72
74
  Object.defineProperty(object, property, origDesc);
73
75
  delete object[`orig$$${property}`];
@@ -170,6 +172,6 @@ class Vertex extends _Vertex {
170
172
  }
171
173
  }
172
174
 
173
- _Vertex.setRealConstructor(Vertex);
175
+ _Vertex.setRealConstructor((...args) => new Vertex(...args));
174
176
 
175
177
  module.exports = { Vertex };
package/lib/video_mode.js CHANGED
@@ -25,7 +25,11 @@ class VideoMode {
25
25
  }
26
26
 
27
27
  toJSON() {
28
- return { width: this.width, height: this.height, bitsPerPixel: this.bitsPerPixel };
28
+ return {
29
+ width: this.width,
30
+ height: this.height,
31
+ bitsPerPixel: this.bitsPerPixel,
32
+ };
29
33
  }
30
34
 
31
35
  constructor(modeWidth, modeHeight, modeBitsPerPixel) {
@@ -42,13 +46,19 @@ class VideoMode {
42
46
  this[RAW_VIDEO_MODE] = new _VideoMode();
43
47
  return;
44
48
  } else if (modeHeight === undefined) {
45
- throw new Error('modeHeight cannot be undefined while modeWidth is not undefined.');
49
+ throw new Error(
50
+ 'modeHeight cannot be undefined while modeWidth is not undefined.');
46
51
  }
47
52
 
48
53
  if (modeBitsPerPixel === undefined) {
49
- this[RAW_VIDEO_MODE] = new _VideoMode(parseInt(modeWidth), parseInt(modeHeight));
54
+ this[RAW_VIDEO_MODE] = new _VideoMode(
55
+ parseInt(modeWidth),
56
+ parseInt(modeHeight));
50
57
  } else {
51
- this[RAW_VIDEO_MODE] = new _VideoMode(parseInt(modeWidth), parseInt(modeHeight), parseInt(modeBitsPerPixel));
58
+ this[RAW_VIDEO_MODE] = new _VideoMode(
59
+ parseInt(modeWidth),
60
+ parseInt(modeHeight),
61
+ parseInt(modeBitsPerPixel));
52
62
  }
53
63
  }
54
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfml.js",
3
- "version": "0.0.1-preview.38",
3
+ "version": "0.0.1-preview.41",
4
4
  "description": "SFML's Node.js binding.",
5
5
  "main": "lib/sfml.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "clang-format": "./tools/clang_format.js --style=file -i ./src/*.cc ./src/*.h ./src/drawable/*.cc ./src/drawable/*.h ./src/sound/*.cc ./src/sound/*.h ./src/workers/*.h",
10
10
  "preinstall": "node tools/symlinks.js",
11
11
  "cpplint": "./third_party/cpplint/cpplint.py src/**/*",
12
- "jslint": "eslint .",
12
+ "jslint": "./node_modules/.bin/eslint ./**/*.js",
13
13
  "install": "node-gyp rebuild"
14
14
  },
15
15
  "repository": {
@@ -29,9 +29,12 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^16.11.6",
32
- "eslint": "^6.0.0",
32
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
33
+ "eslint": "^7.0.0",
33
34
  "eslint-config-egg": "^9.0.0",
34
35
  "eslint-plugin-import": "^2.25.2",
36
+ "eslint-plugin-jsdoc": "^37.0.3",
37
+ "eslint-plugin-node": "^11.1.0",
35
38
  "typescript": "~4.0.0"
36
39
  },
37
40
  "files": [
@@ -51,6 +54,8 @@
51
54
  "third_party/sfml/platform/macOS/lib/libsfml-network.2.5.1.dylib",
52
55
  "third_party/sfml/platform/macOS/lib/libsfml-graphics.2.5.1.dylib",
53
56
  "third_party/sfml/platform/macOS/Frameworks/**/*",
57
+ "third_party/sfml/platform/win64/lib/*.lib",
58
+ "third_party/sfml/platform/win64/bin/*.dll",
54
59
  "tools/*",
55
60
  "tsconfig.json"
56
61
  ]
package/src/color.cc CHANGED
@@ -3,7 +3,6 @@
3
3
  namespace node_sfml {
4
4
  namespace color {
5
5
 
6
- using v8::Context;
7
6
  using v8::EscapableHandleScope;
8
7
  using v8::Function;
9
8
  using v8::FunctionTemplate;
@@ -28,18 +27,17 @@ MaybeLocal<Object> Color::NewRealColorInstance(Isolate* isolate,
28
27
  }
29
28
 
30
29
  Local<Function> func = real_constructor.Get(isolate);
31
- Local<Context> context = isolate->GetCurrentContext();
32
30
  Local<Value> argv[] = {Nan::New(val)};
33
31
 
34
32
  Nan::TryCatch try_catch;
35
- ret = func->NewInstance(context, 1, argv).ToLocalChecked();
33
+ MaybeLocal<Value> maybe = Nan::Call(func, func, 1, argv);
36
34
  if (try_catch.HasCaught()) {
37
35
  try_catch.ReThrow();
38
36
  Local<Object> empty;
39
37
  return scope.Escape(empty);
40
38
  }
41
39
 
42
- return scope.Escape(ret);
40
+ return scope.Escape(maybe.ToLocalChecked().As<Object>());
43
41
  }
44
42
 
45
43
  NAN_METHOD(SetRealColorConstructor) {
@@ -151,7 +149,7 @@ NAN_METHOD(Color::ToInteger) {
151
149
 
152
150
  #define V(name, lowercase) \
153
151
  NAN_METHOD(Color::name##Getter) { \
154
- Color* color = Nan::ObjectWrap::Unwrap<Color>(info.Holder()); \
152
+ Color* color = Nan::ObjectWrap::Unwrap<Color>(info.This()); \
155
153
  info.GetReturnValue().Set(color->_color->lowercase); \
156
154
  } \
157
155
  \
@@ -167,7 +165,7 @@ NAN_METHOD(Color::ToInteger) {
167
165
  return; \
168
166
  } \
169
167
  \
170
- Color* color = Nan::ObjectWrap::Unwrap<Color>(info.Holder()); \
168
+ Color* color = Nan::ObjectWrap::Unwrap<Color>(info.This()); \
171
169
  color->_color->lowercase = val; \
172
170
  }
173
171
 
@@ -59,7 +59,7 @@ inline static NAN_METHOD(GetTextureRect) {
59
59
  };
60
60
 
61
61
  Nan::TryCatch try_catch;
62
- v8::MaybeLocal<v8::Object> maybe_rect =
62
+ v8::MaybeLocal<v8::Value> maybe_rect =
63
63
  rect::IntRect::NewRealInstance(info.GetIsolate(), argc, argv);
64
64
  if (maybe_rect.IsEmpty()) {
65
65
  try_catch.ReThrow();
@@ -88,14 +88,15 @@ inline void SetPrototype(v8::Local<v8::FunctionTemplate>* _tpl) {
88
88
  sf::FloatRect rect = drawable->raw<T>().get##type##Bounds(); \
89
89
  \
90
90
  Nan::TryCatch try_catch; \
91
- v8::MaybeLocal<v8::Object> maybe_rect = \
91
+ v8::MaybeLocal<v8::Value> maybe_rect = \
92
92
  rect::FloatRect::NewRealInstance(info.GetIsolate()); \
93
93
  if (try_catch.HasCaught()) { \
94
94
  try_catch.ReThrow(); \
95
95
  return; \
96
96
  } \
97
97
  \
98
- v8::Local<v8::Object> node_rect = maybe_rect.ToLocalChecked(); \
98
+ v8::Local<v8::Object> node_rect = \
99
+ maybe_rect.ToLocalChecked().As<v8::Object>(); \
99
100
  sf::FloatRect& ret = \
100
101
  Nan::ObjectWrap::Unwrap<rect::FloatRect>(node_rect)->rect(); \
101
102
  ret.top = rect.top; \
@@ -1,6 +1,6 @@
1
1
  #include <SFML/Graphics/RectangleShape.hpp>
2
2
 
3
- #include "../vector2.h"
3
+ #include "../vector2-inl.h"
4
4
  #include "drawable-inl.h"
5
5
  #include "rectangle_shape.h"
6
6
 
@@ -11,6 +11,7 @@ using v8::FunctionTemplate;
11
11
  using v8::Local;
12
12
  using v8::MaybeLocal;
13
13
  using v8::Object;
14
+ using v8::Value;
14
15
 
15
16
  const char rectangle_shape_name[] = "RectangleShape";
16
17
 
@@ -42,7 +43,7 @@ NAN_METHOD(RectangleShape::GetSize) {
42
43
  sf::Vector2f vec = shape->raw<sf::RectangleShape>().getSize();
43
44
 
44
45
  Nan::TryCatch try_catch;
45
- MaybeLocal<Object> maybe_vec =
46
+ MaybeLocal<Value> maybe_vec =
46
47
  vector2::Vector2F::NewRealInstance(info.GetIsolate(), vec);
47
48
  if (maybe_vec.IsEmpty()) {
48
49
  try_catch.ReThrow();
@@ -9,7 +9,9 @@ namespace node_sfml {
9
9
  namespace drawable {
10
10
 
11
11
  using v8::Local;
12
+ using v8::MaybeLocal;
12
13
  using v8::Object;
14
+ using v8::Value;
13
15
 
14
16
  void Shape::SetPrototype(v8::Local<v8::FunctionTemplate>* _tpl) {
15
17
  v8::Local<v8::FunctionTemplate>& tpl = *_tpl;
@@ -41,7 +43,7 @@ NAN_METHOD(Shape::GetPoint) {
41
43
  sf::Vector2f point = raw.getPoint(Nan::To<sf::Uint32>(info[0]).FromJust());
42
44
 
43
45
  Nan::TryCatch try_catch;
44
- v8::MaybeLocal<v8::Object> maybe_vec =
46
+ MaybeLocal<Value> maybe_vec =
45
47
  vector2::Vector2F::NewRealInstance(info.GetIsolate(), point);
46
48
  if (maybe_vec.IsEmpty()) {
47
49
  try_catch.ReThrow();
@@ -127,14 +127,14 @@ NAN_METHOD(VertexArray::GetBounds) {
127
127
  sf::FloatRect rect = va->raw<sf::VertexArray>().getBounds();
128
128
 
129
129
  Nan::TryCatch try_catch;
130
- v8::MaybeLocal<v8::Object> maybe_rect =
130
+ v8::MaybeLocal<v8::Value> maybe_rect =
131
131
  rect::FloatRect::NewRealInstance(info.GetIsolate());
132
132
  if (try_catch.HasCaught()) {
133
133
  try_catch.ReThrow();
134
134
  return;
135
135
  }
136
136
 
137
- v8::Local<v8::Object> node_rect = maybe_rect.ToLocalChecked();
137
+ v8::Local<v8::Object> node_rect = maybe_rect.ToLocalChecked().As<Object>();
138
138
  sf::FloatRect& ret =
139
139
  Nan::ObjectWrap::Unwrap<rect::FloatRect>(node_rect)->rect();
140
140
  ret.top = rect.top;
@@ -167,7 +167,7 @@ NAN_METHOD(VertexArray::DuplicateVertex) {
167
167
  const sf::Vertex& vertex = raw[idx];
168
168
 
169
169
  Nan::TryCatch try_catch;
170
- MaybeLocal<Object> maybe_ret =
170
+ MaybeLocal<Value> maybe_ret =
171
171
  vertex::Vertex::NewRealInstance(info.GetIsolate(), vertex);
172
172
  if (maybe_ret.IsEmpty()) {
173
173
  try_catch.ReThrow();
package/src/font.cc CHANGED
@@ -122,13 +122,14 @@ NAN_METHOD(Font::GetGlyph) {
122
122
  Nan::New<Number>(static_cast<double>(glyph.advance)));
123
123
 
124
124
  Nan::TryCatch try_catch;
125
- MaybeLocal<Object> maybe_float_rect_object =
125
+ MaybeLocal<Value> maybe_float_rect_object =
126
126
  rect::FloatRect::NewRealInstance(info.GetIsolate());
127
127
  if (maybe_float_rect_object.IsEmpty()) {
128
128
  try_catch.ReThrow();
129
129
  return;
130
130
  }
131
- Local<Object> float_rect_object = maybe_float_rect_object.ToLocalChecked();
131
+ Local<Object> float_rect_object =
132
+ maybe_float_rect_object.ToLocalChecked().As<Object>();
132
133
  rect::FloatRect* float_rect =
133
134
  Nan::ObjectWrap::Unwrap<rect::FloatRect>(float_rect_object);
134
135
  sf::FloatRect& float_rect_inner = float_rect->rect();
@@ -138,13 +139,14 @@ NAN_METHOD(Font::GetGlyph) {
138
139
  float_rect_inner.height = glyph.bounds.height;
139
140
  Nan::Set(ret, Nan::New<String>("bounds").ToLocalChecked(), float_rect_object);
140
141
 
141
- MaybeLocal<Object> maybe_int_rect_object =
142
+ MaybeLocal<Value> maybe_int_rect_object =
142
143
  rect::IntRect::NewRealInstance(info.GetIsolate());
143
144
  if (maybe_int_rect_object.IsEmpty()) {
144
145
  try_catch.ReThrow();
145
146
  return;
146
147
  }
147
- Local<Object> int_rect_object = maybe_int_rect_object.ToLocalChecked();
148
+ Local<Object> int_rect_object =
149
+ maybe_int_rect_object.ToLocalChecked().As<Object>();
148
150
  rect::IntRect* int_rect =
149
151
  Nan::ObjectWrap::Unwrap<rect::IntRect>(int_rect_object);
150
152
  sf::IntRect& int_rect_inner = int_rect->rect();
package/src/image.cc CHANGED
@@ -26,10 +26,9 @@ NAN_METHOD(SetRealConstructor) {
26
26
  real_constructor.Reset(info[0].As<v8::Function>());
27
27
  }
28
28
 
29
- MaybeLocal<Object> Image::NewRealInstance(Isolate* isolate) {
30
- v8::Local<v8::Function> cons = real_constructor.Get(isolate);
31
- v8::MaybeLocal<v8::Object> maybe_ret =
32
- cons->NewInstance(isolate->GetCurrentContext());
29
+ MaybeLocal<Value> Image::NewRealInstance(Isolate* isolate) {
30
+ Local<Function> cons = real_constructor.Get(isolate);
31
+ MaybeLocal<Value> maybe_ret = Nan::Call(cons, cons, 0, nullptr);
33
32
  return maybe_ret;
34
33
  }
35
34
 
@@ -160,7 +159,7 @@ NAN_METHOD(Image::GetSize) {
160
159
  sf::Vector2u size = image->_image.getSize();
161
160
 
162
161
  Nan::TryCatch try_catch;
163
- MaybeLocal<Object> size_obj =
162
+ MaybeLocal<Value> size_obj =
164
163
  vector2::Vector2<sf::Uint32, sf::Uint32, v8::Uint32>::NewRealInstance(
165
164
  info.GetIsolate(), size);
166
165
  if (size_obj.IsEmpty()) {
package/src/image.h CHANGED
@@ -15,7 +15,7 @@ namespace image {
15
15
  class Image : public Nan::ObjectWrap, public BaseClassWithLoading {
16
16
  public:
17
17
  static NAN_MODULE_INIT(Init);
18
- static v8::MaybeLocal<v8::Object> NewRealInstance(v8::Isolate* isolate);
18
+ static v8::MaybeLocal<v8::Value> NewRealInstance(v8::Isolate* isolate);
19
19
 
20
20
  public:
21
21
  static NAN_METHOD(New);
package/src/mouse.cc CHANGED
@@ -15,6 +15,7 @@ using v8::Local;
15
15
  using v8::MaybeLocal;
16
16
  using v8::Object;
17
17
  using v8::String;
18
+ using v8::Value;
18
19
 
19
20
  NAN_MODULE_INIT(Init) {
20
21
  gen::InitMouseButton();
@@ -65,7 +66,7 @@ NAN_METHOD(GetPosition) {
65
66
  }
66
67
 
67
68
  Nan::TryCatch try_catch;
68
- MaybeLocal<Object> ret =
69
+ MaybeLocal<Value> ret =
69
70
  vector2::Vector2I::NewRealInstance(info.GetIsolate(), pos);
70
71
  if (ret.IsEmpty()) {
71
72
  try_catch.ReThrow();
@@ -1,7 +1,7 @@
1
1
  #ifndef SRC_PLUGINS_TRANSFORMABLE_PLUGIN_INL_H_
2
2
  #define SRC_PLUGINS_TRANSFORMABLE_PLUGIN_INL_H_
3
3
 
4
- #include "../vector2.h"
4
+ #include "../vector2-inl.h"
5
5
  #include "transformable_plugin.h"
6
6
 
7
7
  namespace node_sfml {
@@ -96,7 +96,7 @@ inline NAN_METHOD(Rotate) {
96
96
  const sf::Vector2f& vec = target->transformable().get##name(); \
97
97
  \
98
98
  Nan::TryCatch try_catch; \
99
- v8::MaybeLocal<v8::Object> maybe_vec = \
99
+ v8::MaybeLocal<v8::Value> maybe_vec = \
100
100
  vector2::Vector2F::NewRealInstance(info.GetIsolate(), vec); \
101
101
  if (maybe_vec.IsEmpty()) { \
102
102
  try_catch.ReThrow(); \