diff --git a/lib/bindings.js b/lib/bindings.js new file mode 100644 index 0000000..bd348e3 --- /dev/null +++ b/lib/bindings.js @@ -0,0 +1,10 @@ +/** + * Compat for changes from node 0.4.x to 0.6.x. + */ +try { + module.exports = require('../build/Release/canvas'); +} catch (e) { try { + module.exports = require('../build/default/canvas'); +} catch (e) { + throw e; +}} diff --git a/lib/canvas.js b/lib/canvas.js index 8f2f07c..d1971ec 100644 --- a/lib/canvas.js +++ b/lib/canvas.js @@ -9,7 +9,7 @@ * Module dependencies. */ -var canvas = require('../build/default/canvas') +var canvas = require('./bindings') , Canvas = canvas.Canvas , Image = canvas.Image , cairoVersion = canvas.cairoVersion diff --git a/lib/context2d.js b/lib/context2d.js index 84c96bb..0202645 100644 --- a/lib/context2d.js +++ b/lib/context2d.js @@ -9,7 +9,7 @@ * Module dependencies. */ -var canvas = require('../build/default/canvas') +var canvas = require('./bindings') , Context2d = canvas.CanvasRenderingContext2d , CanvasGradient = canvas.CanvasGradient , ImageData = canvas.ImageData @@ -320,4 +320,4 @@ Context2d.prototype.createImageData = function(width, height){ width = width.width; } return new ImageData(new PixelArray(width, height)); -}; \ No newline at end of file +}; diff --git a/lib/image.js b/lib/image.js index fa0040a..558472b 100644 --- a/lib/image.js +++ b/lib/image.js @@ -9,7 +9,7 @@ * Module dependencies. */ -var Canvas = require('../build/default/canvas') +var Canvas = require('./bindings') , Image = Canvas.Image; /** @@ -57,4 +57,4 @@ Image.prototype.inspect = function(){ + (this.src ? ' ' + this.src : '') + (this.complete ? ' complete' : '') + ']'; -}; \ No newline at end of file +}; diff --git a/lib/pixelarray.js b/lib/pixelarray.js index 7f191f4..ff10cee 100644 --- a/lib/pixelarray.js +++ b/lib/pixelarray.js @@ -9,7 +9,7 @@ * Module dependencies. */ -var Canvas = require('../build/default/canvas') +var Canvas = require('./bindings') , PixelArray = Canvas.CanvasPixelArray; /**