Skip to content

Commit

Permalink
Support Node.js v12 (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbjornson authored Apr 24, 2019
1 parent d407151 commit 3982196
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 106 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
install:
- npm install --build-from-source
node_js:
- '12'
- '10'
- '8'
- '6'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Changed
* Use [simple-get](https://github.com/feross/simple-get) for fetching images, now supports redirects (#1398)
### Added
* Support Node.js v12
### Fixed

2.4.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
"types": "types",
"dependencies": {
"nan": "^2.12.1",
"nan": "^2.13.2",
"node-pre-gyp": "^0.11.0",
"simple-get": "^3.0.3"
},
Expand Down
3 changes: 2 additions & 1 deletion src/Backends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ void Backends::Initialize(Local<Object> target) {
PdfBackend::Initialize(obj);
SvgBackend::Initialize(obj);

target->Set(Nan::New<String>("Backends").ToLocalChecked(), obj);
Local<Context> v8ctx = Nan::GetCurrentContext();
target->Set(v8ctx, Nan::New<String>("Backends").ToLocalChecked(), obj);
}
33 changes: 20 additions & 13 deletions src/Canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ Canvas::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
// Class methods
Nan::SetMethod(ctor, "_registerFont", RegisterFont);

Nan::Set(target, Nan::New("Canvas").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target,
Nan::New("Canvas").ToLocalChecked(),
ctor->GetFunction(ctx).ToLocalChecked());
}

/*
Expand Down Expand Up @@ -241,25 +244,26 @@ Canvas::ToBufferAsyncAfter(uv_work_t *req) {

static void parsePNGArgs(Local<Value> arg, PngClosure& pngargs) {
if (arg->IsObject()) {
Local<Context> v8ctx = Nan::GetCurrentContext();
Local<Object> obj = Nan::To<Object>(arg).ToLocalChecked();

Local<Value> cLevel = obj->Get(Nan::New("compressionLevel").ToLocalChecked());
Local<Value> cLevel = obj->Get(v8ctx, Nan::New("compressionLevel").ToLocalChecked()).ToLocalChecked();
if (cLevel->IsUint32()) {
uint32_t val = Nan::To<uint32_t>(cLevel).FromMaybe(0);
// See quote below from spec section 4.12.5.5.
if (val <= 9) pngargs.compressionLevel = val;
}

Local<Value> rez = obj->Get(Nan::New("resolution").ToLocalChecked());
Local<Value> rez = obj->Get(v8ctx, Nan::New("resolution").ToLocalChecked()).ToLocalChecked();
if (rez->IsUint32()) {
uint32_t val = Nan::To<uint32_t>(rez).FromMaybe(0);
if (val > 0) pngargs.resolution = val;
}

Local<Value> filters = obj->Get(Nan::New("filters").ToLocalChecked());
Local<Value> filters = obj->Get(v8ctx, Nan::New("filters").ToLocalChecked()).ToLocalChecked();
if (filters->IsUint32()) pngargs.filters = Nan::To<uint32_t>(filters).FromMaybe(0);

Local<Value> palette = obj->Get(Nan::New("palette").ToLocalChecked());
Local<Value> palette = obj->Get(v8ctx, Nan::New("palette").ToLocalChecked()).ToLocalChecked();
if (palette->IsUint8ClampedArray()) {
Local<Uint8ClampedArray> palette_ta = palette.As<Uint8ClampedArray>();
pngargs.nPaletteColors = palette_ta->Length();
Expand All @@ -270,7 +274,7 @@ static void parsePNGArgs(Local<Value> arg, PngClosure& pngargs) {
Nan::TypedArrayContents<uint8_t> _paletteColors(palette_ta);
pngargs.palette = *_paletteColors;
// Optional background color index:
Local<Value> backgroundIndexVal = obj->Get(Nan::New("backgroundIndex").ToLocalChecked());
Local<Value> backgroundIndexVal = obj->Get(v8ctx, Nan::New("backgroundIndex").ToLocalChecked()).ToLocalChecked();
if (backgroundIndexVal->IsUint32()) {
pngargs.backgroundIndex = static_cast<uint8_t>(Nan::To<uint32_t>(backgroundIndexVal).FromMaybe(0));
}
Expand All @@ -283,25 +287,26 @@ static void parseJPEGArgs(Local<Value> arg, JpegClosure& jpegargs) {
// user agent must use its default quality value, as if the quality argument
// had not been given." - 4.12.5.5
if (arg->IsObject()) {
Local<Context> v8ctx = Nan::GetCurrentContext();
Local<Object> obj = Nan::To<Object>(arg).ToLocalChecked();

Local<Value> qual = obj->Get(Nan::New("quality").ToLocalChecked());
Local<Value> qual = obj->Get(v8ctx, Nan::New("quality").ToLocalChecked()).ToLocalChecked();
if (qual->IsNumber()) {
double quality = Nan::To<double>(qual).FromMaybe(0);
if (quality >= 0.0 && quality <= 1.0) {
jpegargs.quality = static_cast<uint32_t>(100.0 * quality);
}
}

Local<Value> chroma = obj->Get(Nan::New("chromaSubsampling").ToLocalChecked());
Local<Value> chroma = obj->Get(v8ctx, Nan::New("chromaSubsampling").ToLocalChecked()).ToLocalChecked();
if (chroma->IsBoolean()) {
bool subsample = Nan::To<bool>(chroma).FromMaybe(0);
jpegargs.chromaSubsampling = subsample ? 2 : 1;
} else if (chroma->IsNumber()) {
jpegargs.chromaSubsampling = Nan::To<uint32_t>(chroma).FromMaybe(0);
}

Local<Value> progressive = obj->Get(Nan::New("progressive").ToLocalChecked());
Local<Value> progressive = obj->Get(v8ctx, Nan::New("progressive").ToLocalChecked()).ToLocalChecked();
if (!progressive->IsUndefined()) {
jpegargs.progressive = Nan::To<bool>(progressive).FromMaybe(0);
}
Expand Down Expand Up @@ -721,9 +726,10 @@ NAN_METHOD(Canvas::RegisterFont) {
Local<String> weight_prop = Nan::New<String>("weight").ToLocalChecked();
Local<String> style_prop = Nan::New<String>("style").ToLocalChecked();

char *family = str_value(js_user_desc->Get(family_prop), NULL, false);
char *weight = str_value(js_user_desc->Get(weight_prop), "normal", true);
char *style = str_value(js_user_desc->Get(style_prop), "normal", false);
Local<Context> v8ctx = Nan::GetCurrentContext();
char *family = str_value(js_user_desc->Get(v8ctx, family_prop).ToLocalChecked(), NULL, false);
char *weight = str_value(js_user_desc->Get(v8ctx, weight_prop).ToLocalChecked(), "normal", true);
char *style = str_value(js_user_desc->Get(v8ctx, style_prop).ToLocalChecked(), "normal", false);

if (family && weight && style) {
pango_font_description_set_weight(user_desc, Canvas::GetWeightFromCSSString(weight));
Expand Down Expand Up @@ -895,7 +901,8 @@ Canvas::resurface(Local<Object> canvas) {
backend()->recreateSurface();

// Reset context
context = canvas->Get(Nan::New<String>("context").ToLocalChecked());
Local<Context> v8ctx = Nan::GetCurrentContext();
context = canvas->Get(v8ctx, Nan::New<String>("context").ToLocalChecked()).ToLocalChecked();
if (!context->IsUndefined()) {
Context2d *context2d = ObjectWrap::Unwrap<Context2d>(Nan::To<Object>(context).ToLocalChecked());
cairo_t *prev = context2d->context();
Expand Down
5 changes: 4 additions & 1 deletion src/CanvasGradient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ Gradient::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {

// Prototype
Nan::SetPrototypeMethod(ctor, "addColorStop", AddColorStop);
Nan::Set(target, Nan::New("CanvasGradient").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target,
Nan::New("CanvasGradient").ToLocalChecked(),
ctor->GetFunction(ctx).ToLocalChecked());
}

/*
Expand Down
5 changes: 4 additions & 1 deletion src/CanvasPattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ Pattern::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
ctor->SetClassName(Nan::New("CanvasPattern").ToLocalChecked());

// Prototype
Nan::Set(target, Nan::New("CanvasPattern").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target,
Nan::New("CanvasPattern").ToLocalChecked(),
ctor->GetFunction(ctx).ToLocalChecked());
}

/*
Expand Down
31 changes: 18 additions & 13 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ Context2d::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
SetProtoAccessor(proto, Nan::New("font").ToLocalChecked(), GetFont, SetFont, ctor);
SetProtoAccessor(proto, Nan::New("textBaseline").ToLocalChecked(), GetTextBaseline, SetTextBaseline, ctor);
SetProtoAccessor(proto, Nan::New("textAlign").ToLocalChecked(), GetTextAlign, SetTextAlign, ctor);
Nan::Set(target, Nan::New("CanvasRenderingContext2d").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target, Nan::New("CanvasRenderingContext2d").ToLocalChecked(), ctor->GetFunction(ctx).ToLocalChecked());
Nan::Set(target, Nan::New("CanvasRenderingContext2dInit").ToLocalChecked(), Nan::New<Function>(SaveExternalModules));
}

Expand Down Expand Up @@ -684,9 +685,10 @@ NAN_METHOD(Context2d::New) {
if (isImageBackend) {
cairo_format_t format = ImageBackend::DEFAULT_FORMAT;
if (info[1]->IsObject()) {
Local<Context> v8ctx = Nan::GetCurrentContext();
Local<Object> ctxAttributes = Nan::To<Object>(info[1]).ToLocalChecked();

Local<Value> pixelFormat = ctxAttributes->Get(Nan::New("pixelFormat").ToLocalChecked());
Local<Value> pixelFormat = ctxAttributes->Get(v8ctx, Nan::New("pixelFormat").ToLocalChecked()).ToLocalChecked();
if (pixelFormat->IsString()) {
Nan::Utf8String utf8PixelFormat(pixelFormat);
if (!strcmp(*utf8PixelFormat, "RGBA32")) format = CAIRO_FORMAT_ARGB32;
Expand All @@ -700,7 +702,7 @@ NAN_METHOD(Context2d::New) {
}

// alpha: false forces use of RGB24
Local<Value> alpha = ctxAttributes->Get(Nan::New("alpha").ToLocalChecked());
Local<Value> alpha = ctxAttributes->Get(v8ctx, Nan::New("alpha").ToLocalChecked()).ToLocalChecked();
if (alpha->IsBoolean() && !Nan::To<bool>(alpha).FromMaybe(false)) {
format = CAIRO_FORMAT_RGB24;
}
Expand Down Expand Up @@ -2681,21 +2683,22 @@ NAN_METHOD(Context2d::MeasureText) {
cairo_get_matrix(ctx, &matrix);
double y_offset = getBaselineAdjustment(layout, context->state->textBaseline);

obj->Set(Nan::New<String>("width").ToLocalChecked(),
Local<Context> v8ctx = Nan::GetCurrentContext();
obj->Set(v8ctx, Nan::New<String>("width").ToLocalChecked(),
Nan::New<Number>(logical_rect.width));
obj->Set(Nan::New<String>("actualBoundingBoxLeft").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("actualBoundingBoxLeft").ToLocalChecked(),
Nan::New<Number>(x_offset - PANGO_LBEARING(logical_rect)));
obj->Set(Nan::New<String>("actualBoundingBoxRight").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("actualBoundingBoxRight").ToLocalChecked(),
Nan::New<Number>(x_offset + PANGO_RBEARING(logical_rect)));
obj->Set(Nan::New<String>("actualBoundingBoxAscent").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("actualBoundingBoxAscent").ToLocalChecked(),
Nan::New<Number>(y_offset + PANGO_ASCENT(ink_rect)));
obj->Set(Nan::New<String>("actualBoundingBoxDescent").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("actualBoundingBoxDescent").ToLocalChecked(),
Nan::New<Number>(PANGO_DESCENT(ink_rect) - y_offset));
obj->Set(Nan::New<String>("emHeightAscent").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("emHeightAscent").ToLocalChecked(),
Nan::New<Number>(-(PANGO_ASCENT(logical_rect) - y_offset)));
obj->Set(Nan::New<String>("emHeightDescent").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("emHeightDescent").ToLocalChecked(),
Nan::New<Number>(PANGO_DESCENT(logical_rect) - y_offset));
obj->Set(Nan::New<String>("alphabeticBaseline").ToLocalChecked(),
obj->Set(v8ctx, Nan::New<String>("alphabeticBaseline").ToLocalChecked(),
Nan::New<Number>(-(pango_font_metrics_get_ascent(metrics) * inverse_pango_scale - y_offset)));

pango_font_metrics_unref(metrics);
Expand All @@ -2714,8 +2717,9 @@ NAN_METHOD(Context2d::SetLineDash) {
uint32_t dashes = dash->Length() & 1 ? dash->Length() * 2 : dash->Length();
uint32_t zero_dashes = 0;
std::vector<double> a(dashes);
Local<Context> v8ctx = Nan::GetCurrentContext();
for (uint32_t i=0; i<dashes; i++) {
Local<Value> d = dash->Get(i % dash->Length());
Local<Value> d = dash->Get(v8ctx, i % dash->Length()).ToLocalChecked();
if (!d->IsNumber()) return;
a[i] = Nan::To<double>(d).FromMaybe(0);
if (a[i] == 0) zero_dashes++;
Expand Down Expand Up @@ -2746,8 +2750,9 @@ NAN_METHOD(Context2d::GetLineDash) {
cairo_get_dash(ctx, a.data(), NULL);

Local<Array> dash = Nan::New<Array>(dashes);
Local<Context> v8ctx = Nan::GetCurrentContext();
for (int i=0; i<dashes; i++)
dash->Set(Nan::New<Number>(i), Nan::New<Number>(a[i]));
dash->Set(v8ctx, Nan::New<Number>(i), Nan::New<Number>(a[i]));

info.GetReturnValue().Set(dash);
}
Expand Down
19 changes: 12 additions & 7 deletions src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Image::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
ctor->Set(Nan::New("MODE_IMAGE").ToLocalChecked(), Nan::New<Number>(DATA_IMAGE));
ctor->Set(Nan::New("MODE_MIME").ToLocalChecked(), Nan::New<Number>(DATA_MIME));

Nan::Set(target, Nan::New("Image").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target, Nan::New("Image").ToLocalChecked(), ctor->GetFunction(ctx).ToLocalChecked());

// Used internally in lib/image.js
NAN_EXPORT(target, GetSource);
Expand All @@ -89,8 +90,9 @@ NAN_METHOD(Image::New) {
Image *img = new Image;
img->data_mode = DATA_IMAGE;
img->Wrap(info.This());
info.This()->Set(Nan::New("onload").ToLocalChecked(), Nan::Null());
info.This()->Set(Nan::New("onerror").ToLocalChecked(), Nan::Null());
Local<Context> v8ctx = Nan::GetCurrentContext();
info.This()->Set(v8ctx, Nan::New("onload").ToLocalChecked(), Nan::Null());
info.This()->Set(v8ctx, Nan::New("onerror").ToLocalChecked(), Nan::Null());
info.GetReturnValue().Set(info.This());
}

Expand Down Expand Up @@ -249,7 +251,8 @@ NAN_METHOD(Image::SetSource){
}

if (status) {
Local<Value> onerrorFn = info.This()->Get(Nan::New("onerror").ToLocalChecked());
Local<Context> v8ctx = Nan::GetCurrentContext();
Local<Value> onerrorFn = info.This()->Get(v8ctx, Nan::New("onerror").ToLocalChecked()).ToLocalChecked();
if (onerrorFn->IsFunction()) {
Local<Value> argv[1];
CanvasError errorInfo = img->errorInfo;
Expand All @@ -260,13 +263,15 @@ NAN_METHOD(Image::SetSource){
} else {
argv[0] = Nan::Error(Nan::New(cairo_status_to_string(status)).ToLocalChecked());
}
onerrorFn.As<Function>()->Call(Isolate::GetCurrent()->GetCurrentContext()->Global(), 1, argv);
Local<Context> ctx = Nan::GetCurrentContext();
onerrorFn.As<Function>()->Call(ctx, ctx->Global(), 1, argv);
}
} else {
img->loaded();
Local<Value> onloadFn = info.This()->Get(Nan::New("onload").ToLocalChecked());
Local<Context> v8ctx = Nan::GetCurrentContext();
Local<Value> onloadFn = info.This()->Get(v8ctx, Nan::New("onload").ToLocalChecked()).ToLocalChecked();
if (onloadFn->IsFunction()) {
onloadFn.As<Function>()->Call(Isolate::GetCurrent()->GetCurrentContext()->Global(), 0, NULL);
onloadFn.As<Function>()->Call(v8ctx, v8ctx->Global(), 0, NULL);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/ImageData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ImageData::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
Local<ObjectTemplate> proto = ctor->PrototypeTemplate();
SetProtoAccessor(proto, Nan::New("width").ToLocalChecked(), GetWidth, NULL, ctor);
SetProtoAccessor(proto, Nan::New("height").ToLocalChecked(), GetHeight, NULL, ctor);
Nan::Set(target, Nan::New("ImageData").ToLocalChecked(), ctor->GetFunction());
Local<Context> ctx = Nan::GetCurrentContext();
Nan::Set(target, Nan::New("ImageData").ToLocalChecked(), ctor->GetFunction(ctx).ToLocalChecked());
}

/*
Expand Down Expand Up @@ -116,7 +117,8 @@ NAN_METHOD(ImageData::New) {

ImageData *imageData = new ImageData(reinterpret_cast<uint8_t*>(*dataPtr), width, height);
imageData->Wrap(info.This());
info.This()->Set(Nan::New("data").ToLocalChecked(), dataArray);
Local<Context> v8ctx = Nan::GetCurrentContext();
info.This()->Set(v8ctx, Nan::New("data").ToLocalChecked(), dataArray);
info.GetReturnValue().Set(info.This());
}

Expand Down
5 changes: 4 additions & 1 deletion src/backend/ImageBackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ void ImageBackend::Initialize(Local<Object> target) {
ImageBackend::constructor.Reset(ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New<String>("ImageBackend").ToLocalChecked());
target->Set(Nan::New<String>("ImageBackend").ToLocalChecked(), ctor->GetFunction());
Local<Context> v8ctx = Nan::GetCurrentContext();
target->Set(v8ctx,
Nan::New<String>("ImageBackend").ToLocalChecked(),
ctor->GetFunction(v8ctx).ToLocalChecked());
}

NAN_METHOD(ImageBackend::New) {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/PdfBackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ void PdfBackend::Initialize(Local<Object> target) {
PdfBackend::constructor.Reset(ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New<String>("PdfBackend").ToLocalChecked());
target->Set(Nan::New<String>("PdfBackend").ToLocalChecked(), ctor->GetFunction());
Local<Context> v8ctx = Nan::GetCurrentContext();
target->Set(v8ctx,
Nan::New<String>("PdfBackend").ToLocalChecked(),
ctor->GetFunction(v8ctx).ToLocalChecked());
}

NAN_METHOD(PdfBackend::New) {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/SvgBackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ void SvgBackend::Initialize(Local<Object> target) {
SvgBackend::constructor.Reset(ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New<String>("SvgBackend").ToLocalChecked());
target->Set(Nan::New<String>("SvgBackend").ToLocalChecked(), ctor->GetFunction());
Local<Context> v8ctx = Nan::GetCurrentContext();
target->Set(v8ctx,
Nan::New<String>("SvgBackend").ToLocalChecked(),
ctor->GetFunction(v8ctx).ToLocalChecked());
}

NAN_METHOD(SvgBackend::New) {
Expand Down
12 changes: 7 additions & 5 deletions src/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ NAN_MODULE_INIT(init) {
Gradient::Initialize(target);
Pattern::Initialize(target);

target->Set(Nan::New<String>("cairoVersion").ToLocalChecked(), Nan::New<String>(cairo_version_string()).ToLocalChecked());
Local<Context> v8ctx = Nan::GetCurrentContext();

target->Set(v8ctx, Nan::New<String>("cairoVersion").ToLocalChecked(), Nan::New<String>(cairo_version_string()).ToLocalChecked());
#ifdef HAVE_JPEG

#ifndef JPEG_LIB_VERSION_MAJOR
Expand All @@ -67,22 +69,22 @@ NAN_MODULE_INIT(init) {
} else {
snprintf(jpeg_version, 10, "%d", JPEG_LIB_VERSION_MAJOR);
}
target->Set(Nan::New<String>("jpegVersion").ToLocalChecked(), Nan::New<String>(jpeg_version).ToLocalChecked());
target->Set(v8ctx, Nan::New<String>("jpegVersion").ToLocalChecked(), Nan::New<String>(jpeg_version).ToLocalChecked());
#endif

#ifdef HAVE_GIF
#ifndef GIF_LIB_VERSION
char gif_version[10];
snprintf(gif_version, 10, "%d.%d.%d", GIFLIB_MAJOR, GIFLIB_MINOR, GIFLIB_RELEASE);
target->Set(Nan::New<String>("gifVersion").ToLocalChecked(), Nan::New<String>(gif_version).ToLocalChecked());
target->Set(v8ctx, Nan::New<String>("gifVersion").ToLocalChecked(), Nan::New<String>(gif_version).ToLocalChecked());
#else
target->Set(Nan::New<String>("gifVersion").ToLocalChecked(), Nan::New<String>(GIF_LIB_VERSION).ToLocalChecked());
target->Set(v8ctx, Nan::New<String>("gifVersion").ToLocalChecked(), Nan::New<String>(GIF_LIB_VERSION).ToLocalChecked());
#endif
#endif

char freetype_version[10];
snprintf(freetype_version, 10, "%d.%d.%d", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH);
target->Set(Nan::New<String>("freetypeVersion").ToLocalChecked(), Nan::New<String>(freetype_version).ToLocalChecked());
target->Set(v8ctx, Nan::New<String>("freetypeVersion").ToLocalChecked(), Nan::New<String>(freetype_version).ToLocalChecked());
}

NODE_MODULE(canvas, init);
Loading

0 comments on commit 3982196

Please sign in to comment.