diff --git a/app/assets/index.html b/app/assets/index.html index e567686..3ecdba3 100644 --- a/app/assets/index.html +++ b/app/assets/index.html @@ -1,35 +1,132 @@ - - + basic-style - + - - + + + + + + -
-
+
+

basic-style

+ +
-
-
-

Welcome

+
+
$black
+
$white
+
$gray-lighter
+
$gray-light
+
$gray
+
$gray-dark
+
$color-light
+
$color
+
$color-dark
+
$highlight-light
+
$highlight
+
$highlight-dark
+
$alternate-light
+
$alternate
+
$alternate-dark
+
+ + + +
.container +
.inner-w + +
.block +
.image-w + +
+
.text-w +

example

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel architecto dolorem asperiores, veritatis ab nulla quam similique mollitia. Nihil ducimus, placeat dolores rem consectetur dolorem quia, quo ipsam debitis et.

+
+
+ +
.block +
.image-w + +
+
.text-w +

example

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel architecto dolorem asperiores, veritatis ab nulla quam similique mollitia. Nihil ducimus, placeat dolores rem consectetur dolorem quia, quo ipsam debitis et.

+
+
+ +
.block +
.image-w + +
+
.text-w +

example

+

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel architecto dolorem asperiores, veritatis ab nulla quam similique mollitia. Nihil ducimus, placeat dolores rem consectetur dolorem quia, quo ipsam debitis et.

+
+
+ +
+
+ +
+ +

Heading level 1

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Praesentium, amet libero tenetur fuga quis voluptas ipsam deserunt. Dicta, animi! Minima, eos eius deserunt est ipsum reiciendis laboriosam blanditiis vitae fugiat.

+ +

Heading level 2

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore delectus veniam voluptas sint quo, magnam impedit. Dicta accusantium, in et ab distinctio. Esse quisquam fugit molestiae atque deleniti vitae animi!

+ +

Heading level 3

+ +

Heading level 4

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque dicta, atque. Nostrum voluptatibus, tenetur iste, reiciendis architecto eum distinctio praesentium, saepe numquam natus veritatis officia quo cum magni sunt necessitatibus!

+ +
Heading level 5
+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis pariatur, reprehenderit fuga accusamus quae, molestiae voluptas culpa beatae illo alias. Enim hic quasi perferendis cumque dolorem debitis aliquam eum fugit!

+ +
Heading level 6
+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet quaerat similique nihil architecto, accusantium minima temporibus! Aliquam eius, voluptatum earum neque ad, a consectetur excepturi harum consequatur provident libero beatae.

+ + + +
+ +
+
+ + + + +
+ + - \ No newline at end of file + diff --git a/app/stylus/_basic.styl b/app/stylus/_basic.styl index 520d273..31c6af6 100644 --- a/app/stylus/_basic.styl +++ b/app/stylus/_basic.styl @@ -1,7 +1,10 @@ // box-model reset +html + box-sizing border-box + *, *:before, *:after - box-sizing border-box + box-sizing inherit // clear-fix clear-fix() @@ -12,7 +15,6 @@ clear-fix() // body body - margin 0 clear-fix() -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-tap-highlight-color: transparent; @@ -56,10 +58,10 @@ center-block() // that invisible column .inner-w center-block() - max-width 800px // arbitrary + max-width 800px // arbitrary: override in _style clear-fix() -full-width() // keep it in the styles +full-width() // to keep it in the styles when possible max-width 100% padding 0 diff --git a/app/stylus/_break-points.styl b/app/stylus/_break-points.styl index 9bf6e8f..165b1c8 100644 --- a/app/stylus/_break-points.styl +++ b/app/stylus/_break-points.styl @@ -1,11 +1,29 @@ -$thing = 15em // arbitrary break point unit +/* +break-points -breakpoint-1 = "screen and ( min-width: ($thing*2.2) )" -breakpoint-2 = "screen and ( min-width: ($thing*3.5) )" -breakpoint-3 = "screen and ( min-width: ($thing*4.5) )" -breakpoint-4 = "screen and ( min-width: ($thing*6) )" +base these on when things get ugly +and not any 'ipad' device specific stuff... +*/ +$bp-1 = 500px +$bp-2 = 700px +$bp-3 = 1000px +$bp-4 = 1300px +$bp-5 = 1700px +$bp-6 = 2100px +$bp-7 = 2400px +$bp-8 = 2700px +$bp-9 = 3000px +break-point-1 = 'screen and ( min-width: ($bp-1) )' +break-point-2 = 'screen and ( min-width: ($bp-2) )' +break-point-3 = 'screen and ( min-width: ($bp-3) )' +break-point-4 = 'screen and ( min-width: ($bp-4) )' +break-point-5 = 'screen and ( min-width: ($bp-5) )' +break-point-6 = 'screen and ( min-width: ($bp-6) )' +break-point-7 = 'screen and ( min-width: ($bp-7) )' +break-point-8 = 'screen and ( min-width: ($bp-8) )' +break-point-9 = 'screen and ( min-width: ($bp-9) )' diff --git a/app/stylus/_components.styl b/app/stylus/_components.styl index 4aed944..ee4e6d0 100644 --- a/app/stylus/_components.styl +++ b/app/stylus/_components.styl @@ -10,13 +10,9 @@ tap-area() min-width 160px text-align center + &.light + background $color + &.dark + background $highlight -// styles -.one - background $color - -.two - background $gray-light - -.thing - color red +// reusable components can live here... diff --git a/app/stylus/_dev-helpers.styl b/app/stylus/_dev-helpers.styl new file mode 100644 index 0000000..8e87b92 --- /dev/null +++ b/app/stylus/_dev-helpers.styl @@ -0,0 +1,4 @@ + +/*! development helpers */ +@import 'helpers/_type-hierarchy-helper' +@import 'helpers/_break-point-helper' diff --git a/app/stylus/_icons.styl b/app/stylus/_icons.styl index 44b597f..89cc90f 100644 --- a/app/stylus/_icons.styl +++ b/app/stylus/_icons.styl @@ -1,5 +1,5 @@ -// base icons styles +// base icons styles (fontastic.me) [class^="icon-"], [class*=" icon-"] display inline-block fill currentColor @@ -37,6 +37,3 @@ $extra-large-icon-size = 90px extra-large-icon() width $extra-large-icon-size height $extra-large-icon-size - - - diff --git a/app/stylus/_mixins.styl b/app/stylus/_mixins.styl index bb57f8e..10bcd4d 100644 --- a/app/stylus/_mixins.styl +++ b/app/stylus/_mixins.styl @@ -1,5 +1,5 @@ -// wireframes +// set temp wireframes true/false wire-frames(wire-frames-on = false) if wire-frames-on border 1px solid rgba(0,0,0,.05) @@ -8,10 +8,10 @@ wire-frames(wire-frames-on = false) margin-bottom $padding border 1px solid rgba(0,0,0,.1) -* // set wireframes +* // set temp frames to everything wire-frames() -// simplify position syntax +// simplified position syntax static() position static @@ -26,12 +26,13 @@ fixed() // vertically align buddy elements balance() - float none // to be sure there is no float + float none // to be *sure there is no float display inline-block vertical-align middle // absolutly center center-center() + float none absolute() margin auto top 50% @@ -47,4 +48,3 @@ $tap = 44px tap-area() min-width $tap min-height $tap - diff --git a/app/stylus/_style-guide.styl b/app/stylus/_style-guide.styl index a9ac5c7..b0fb8a1 100644 --- a/app/stylus/_style-guide.styl +++ b/app/stylus/_style-guide.styl @@ -1,154 +1,109 @@ -// color-swatches -.color-swatches - // - .block-list - // - .block - split-in(2) - min-height ($padding*10) - bp(m) - split-in(3) - bp(m-plus) - split-in(4) - -.black - background $black - -.white - background $white - -.gray - background $gray - - -.gray-light - background $gray-light - -.gray - background $gray - -.gray-dark - background $gray-dark - - -.color-light - background $color-light - -.color - background $color - -.color-dark - background $color-dark - - -.highlight-light - background $highlight-light - -.highlight - background $highlight - -.highlight-dark - background $highlight-dark - - -.alternate-light - background $alternate-light - -.alternate - background $alternate - -.alternate-dark - background $alternate-dark - - -// type -.heading-type - font-family $heading-font - -.base-type - font-family $base-font - -.extra-small-type - extra-small-type() - -.small-type - small-type() - -.standard-type - standard-type() - -.medium-type - medium-type() - -.large-type - large-type() - -.extra-large-type - extra-large-type() - - -// icons -.extra-small-icon - extra-small-icon() - -.small-icon - small-icon() - -.standard-icon - standard-icon() - -.medium-icon - medium-icon() - -.large-icon - large-icon() - -.extra-large-icon - extra-large-icon() - - -// basic +// basic example structure $colorz = rgba(0,0,0,.04) -.basic-example.container - border 1px solid rgba(0,0,0,.2) - padding $padding - background $colorz +$widthz = 2px +$stylez = dotted - * - padding $padding +// border(colour) +// border $widthz $styles colour +basic-example() + padding $pad + background $colorz +.container.basic-example + basic-example() + border 1px $stylez red + span // + border 1px $stylez red .inner-w - border 1px solid rgba(0,0,0,.2) - margin-bottom ($padding*2) - background $colorz - + basic-example() + margin-bottom ($pad*2) + border 1px $stylez $color-dark + span // + border 1px $stylez $color-dark .block-list - border 1px solid rgba(0,0,0,.2) - background $colorz - + basic-example() + border 1px $stylez $hightlight-dark + span // + border 1px $stylez $highlight-dark .block - border 1px solid rgba(0,0,0,.2) - margin-bottom ($padding*3) - background $colorz - - .image-w, - border 1px solid rgba(0,0,0,.2) - padding $padding 0 0 0 - background $colorz - + basic-example() + margin-bottom ($pad*5) + border 1px $stylez $alternate-dark + span // + border 1px $stylez $alternate-dark + .image-w + relative() + basic-example() + padding 0 + margin-bottom ($pad*2) + border 1px $stylez $color-dark + span // + absolute() + top 0 + left ($pad/2) + transform translate( $pad, -50% ) + border 1px $stylez $color-dark .text-w - border 1px solid rgba(0,0,0,.2) - background $colorz - - - span - display block - transform translate( ($padding/2), -83%) - - - - - - - + basic-example() + border 1px $stylez $highlight-dark + span // + border 1px $stylez $highlight-dark + span // + display inline-block + transform translate( ($pad/2), -83%) + color $highlight-dark + background $gray-lighter + font-size 12px + border $widthz $stylez $borderz + padding .5rem + +.basic-swatches + padding-bottom 30px + div // + width 100% + float left + padding .3rem + text-shadow 0 0 2px alpha(white, .5) + transition .3s padding ease-in + + @media break-point-1 + padding .6rem + split-in(3) + + @media break-point-2 + padding .9rem + + @media break-point-3 + split-in(6) + + &.black + background $black + &.white + background $white + &.gray-dark + background $gray-dark + &.gray + background $gray + &.gray-light + background $gray-light + &.gray-lighter + background $gray-lighter + &.color-light + background $color-light + &.color + background $color + &.color-dark + background $color-dark + &.highlight-light + background $highlight-light + &.highlight + background $highlight + &.highlight-dark + background $highlight-dark + &.alternate-light + background $alternate-light + &.alternate + background $alternate + &.alternate-dark + background $alternate-dark diff --git a/app/stylus/_styles.styl b/app/stylus/_styles.styl index fa167f9..5f4eab4 100644 --- a/app/stylus/_styles.styl +++ b/app/stylus/_styles.styl @@ -1,70 +1,19 @@ ////////////////////////////////////////// -// ERASE THIS WHOLE PAGE AND START FRESH +// ERASE THIS WHOLE PAGE AND START FRESH :) ////////////////////////////////////////// -// colors -// ===================================== - -// $black = #222222 -// $white = #ffffff - -// $gray = gray -// $color = #C85B6D -// $highlight = #81C1D5 -// $alternate = #D7A088 - -// $gray-light = tint($gray, 50%) -// $gray-dark = shade($gray, 50%) -// $gray-lighter = tint($gray-light, 80%) - -// $color-light = tint($color, 50%) -// $color-dark = shade($color, 50%) - -// $highlight-light = tint($highlight, 50%) -// $highlight-dark = shade($highlight, 25%) - -// $alternate-light = tint($alternate, 50%) -// $alternate-dark = shade($alternate, 25%) - -// ===================================== - - -// style -// ===================================== - -// $padding = 0.6rem -// $corner = 5px -// ===================================== - - -// global -// ===================================== -body +body // background white + font-family helvetica .inner-w max-width 800px padding $padding -// section +// sections // ===================================== -.welcome - background $color - color $black - .site-title - font-size 34px - .current-page - color $color - - - - - - - - diff --git a/app/stylus/_type.styl b/app/stylus/_type.styl index 199663f..4a3baf3 100644 --- a/app/stylus/_type.styl +++ b/app/stylus/_type.styl @@ -6,93 +6,117 @@ h1, h2, h3, h4, h5, h6, li, p font-weight 400 // font stack -$heading-font = arial -$base-font = georgia +$heading-font-stack = 'Quicksand', sans-serif +$base-font-stack = 'Georgia', serif + +heading() + font-family $heading-font-stack + color red!important + +copy() + font-family $base-font-stack // text selection reset ::-moz-selection { - background transparent - color $color + background transparent + color $color-dark } ::selection { - background transparent - color $color + background transparent + color $color-dark } -// type patterns +// simplified font-size syntax +size($font-size) + font-size ($font-size)px + +// type size patterns extra-small-type() - font-size 10px + copy() + size(10) line-height 1.4 color $gray - bp(m) - font-size 11px + @media break-point-2 + size(11) small-type() - font-size 13px + copy() + size(13) line-height 1.4 color $gray-dark - bp(m) - font-size 14px + @media break-point-2 + size(14) standard-type() - font-size 16px + copy() + size(16) line-height 1.4 color $black - bp(m) - font-size 17px + @media break-point-2 + size(17) medium-type() - font-size 19px + size(19) line-height 1.4 color $color font-weight bold - bp(m) - font-size 20px + @media break-point-2 + size(20) large-type() - font-size 24px + size(24) line-height 1.4 - color $contrast - bp(m) - font-size 26px + color $alternate + @media break-point-2 + size(26) extra-large-type() - font-size 34px + font-family $heading-font + size(34) line-height 1.4 color $highlight - bp(m) - font-size 38px - - - + @media break-point-2 + size(38) + +// case +lowercase() + text-transform lowercase + +capitalize() + text-transform sentencecase + +uppercase() + text-transform uppercase + +// style ALL editorial type here / within some scoped class... article // - h1 + h1 // extra-large-type() color $black margin-bottom $padding - h2 + h2 // large-type() color $color margin-bottom $padding p + h2 margin-top ($padding*3) - h3 + h3 // medium-type() color $highlight margin-bottom $padding p + h3 margin-top ($padding*3) - h4 + h4 // medium-type() margin-bottom $padding p + h4 margin-top ($padding*3) - h5 + h5 // standard-type() font-weight bold margin-bottom $padding @@ -101,15 +125,11 @@ article p + h5 margin-top ($padding*3) - p + p // standard-type() margin-bottom $padding ul, ol padding $padding 0 $padding ($padding*1.7) - li + li // margin-bottom ($padding/2) - -// yo - - diff --git a/app/stylus/_user-reset.styl b/app/stylus/_user-reset.styl index f38d474..3189562 100644 --- a/app/stylus/_user-reset.styl +++ b/app/stylus/_user-reset.styl @@ -1,12 +1,15 @@ -// links +body // + margin 0 + +// links reset to inherit styles by default a text-decoration none color inherit &:hover - cursor pointer // just in case ? + cursor pointer // just in case -// cursor +// cursor reset / stops blinking issues html, body cursor default @@ -22,7 +25,3 @@ input[type="checkbox"] button[disabled], input[disabled] cursor default - - - - diff --git a/app/stylus/_variables.styl b/app/stylus/_variables.styl index 924fb9b..6fa7c97 100644 --- a/app/stylus/_variables.styl +++ b/app/stylus/_variables.styl @@ -1,7 +1,11 @@ // colors -$black = #222222 -$white = #ffffff +$black = #222222 +$white = #efefef +$gray = gray +$color = lightgreen +$highlight = lightblue +$alternate = lavender // shade shade($color, $percent) @@ -11,17 +15,13 @@ shade($color, $percent) tint($color, $percent) mix($white, $color, $percent) -$gray = gray -$color = #C85B6D -$highlight = #81C1D5 -$alternate = #D7A088 - -$gray-light = tint($gray, 50%) -$gray-dark = shade($gray, 50%) -$gray-lighter = tint($gray-light, 80%) +// variations +$gray-light = tint($gray, 50%) +$gray-dark = shade($gray, 50%) +$gray-lighter = tint($gray-light, 80%) -$color-light = tint($color, 50%) -$color-dark = shade($color, 50%) +$color-light = tint($color, 50%) +$color-dark = shade($color, 50%) $highlight-light = tint($highlight, 50%) $highlight-dark = shade($highlight, 25%) @@ -29,7 +29,7 @@ $highlight-dark = shade($highlight, 25%) $alternate-light = tint($alternate, 50%) $alternate-dark = shade($alternate, 25%) -// style +// layout $padding = 0.6rem +$pad = $padding $corner = 5px - diff --git a/app/stylus/app.styl b/app/stylus/app.styl index 200232b..1d64ce9 100644 --- a/app/stylus/app.styl +++ b/app/stylus/app.styl @@ -1,34 +1,41 @@ -@charset "UTF-8"; +/*! this style-sheet is generated with stylus */ + +/*! set charicter set */ +@charset 'UTF-8' /*! user reset */ -@import "_user-reset"; +@import '_user-reset' -/*! user variables */ -@import "_variables"; +// user variables +@import '_variables' -/*! mixins */ -@import "_mixins"; +// mixins +@import '_mixins' /*! basic */ -@import "_basic"; +@import '_basic' -/*! break points */ -@import "_break-points"; +// break points +@import '_break-points' /*! type */ -@import "_type"; +@import '_type' /*! icons */ -@import "_icons"; +@import '_icons' /*! components */ -@import "_components"; +@import '_components' -/*! style-guide */ -@import "_style-guide"; +// development helpers +@import '_dev-helpers' +/*! style-guide */ +@import '_style-guide' +/* this is just an example + i would just delete it. */ /*! styles */ -@import "_styles"; +@import '_styles' diff --git a/app/stylus/helpers/_break-point-helper.styl b/app/stylus/helpers/_break-point-helper.styl new file mode 100644 index 0000000..7ec9470 --- /dev/null +++ b/app/stylus/helpers/_break-point-helper.styl @@ -0,0 +1,48 @@ + +/* +adds a little triangle to show you +what break-point you're at + +you must add: + +
+ +just before your in your html + +*/ + +$no = transparent +.media-size-helper + fixed() + right 0 + bottom 0 + // some crazy triangle madness + width 0 + height 0 + border-style solid + border-width 0 0 50px 50px + border-color $no $no rgba(20,20,20,.1) $no + &:after + fixed() + right $pad + bottom ($pad/2) + content '0' + color $black + @media break-point-1 + content '1' + @media break-point-2 + content '2' + @media break-point-3 + content '3' + @media break-point-4 + content '4' + @media break-point-5 + content '5' + @media break-point-6 + content '6' + @media break-point-7 + content '7' + @media break-point-8 + content '8' + @media break-point-9 + content '9' diff --git a/app/stylus/helpers/_type-hierarchy-helper.styl b/app/stylus/helpers/_type-hierarchy-helper.styl new file mode 100644 index 0000000..16e3a63 --- /dev/null +++ b/app/stylus/helpers/_type-hierarchy-helper.styl @@ -0,0 +1,27 @@ + +// $content hierarchy helpers +h1:after, h2:after, h3:after, h4:after, +h5:after, h6:after, p:after + color inherit + opacity .1 + +h1:after + content '-h1' + +h2:after + content '-h2' + +h3:after + content '-h3' + +h4:after + content '-h4' + +h5:after + content '-h5' + +h6:after + content '-h6' + +p:after + content '-p' diff --git a/bower.json b/bower.json new file mode 100755 index 0000000..9e417cb --- /dev/null +++ b/bower.json @@ -0,0 +1,7 @@ +{ + "name": "basic-brunch", + "version": "0.0.1", + "main": "public/app.js", + "dependencies": {}, + "overrides": {} +} diff --git a/brunch-config.js b/brunch-config.js index 178d95f..cfceb91 100644 --- a/brunch-config.js +++ b/brunch-config.js @@ -2,7 +2,12 @@ exports.config = { files: { stylesheets: { - joinTo: 'styles/basic.css' + joinTo: 'stylesheets/app.css' + }, + javascripts: { + joinTo: { + 'javascripts/vendor.js': /^bower_components/ + } } }, sourceMaps: false, diff --git a/node_modules/.bin/autoprefixer b/node_modules/.bin/autoprefixer new file mode 120000 index 0000000..d8848c2 --- /dev/null +++ b/node_modules/.bin/autoprefixer @@ -0,0 +1 @@ +../autoprefixer/autoprefixer \ No newline at end of file diff --git a/node_modules/auto-reload-brunch/CHANGELOG.md b/node_modules/auto-reload-brunch/CHANGELOG.md new file mode 100644 index 0000000..c50a449 --- /dev/null +++ b/node_modules/auto-reload-brunch/CHANGELOG.md @@ -0,0 +1,82 @@ +# auto-reload-brunch 1.7.8 (5 March 2015) +* Added support for wss. Specify your SSL cert like this: `keyPath` and `certPath` +* Added support for `data-autoreload=false` on `` stylesheets. + +# auto-reload-brunch 1.7.7 (4 March 2015) +* Updated `ws` to 0.7. +* Added `host` option. +* Added `forceRepaint` option. +* Fixed repaints for the latest chrome + +# auto-reload-brunch 1.7.6 (26 January 2015) +* Automatically use `localhost` as the host if not specified by the user + and `window.location.hostname` does not resolve to anything. + * Makes it work with NW.js (fka node-webkit) out of the box + +# auto-reload-brunch 1.7.5 (18 October 2014) +* Fix bug with custom port arrays and recent 0.11.x versions of node.js + +# auto-reload-brunch 1.7.4 (26 September 2014) +* Fix automatic port collision resolution +* Explicitly trigger browser repaint on style updates + +# auto-reload-brunch 1.7.3 (27 February 2014) +* Fix include script regression bug + +# auto-reload-brunch 1.7.2 (26 February 2014) +* Updated `ws` module. + +# auto-reload-brunch 1.7.1 (2 November 2013) +* Added `delay` option + +# auto-reload-brunch 1.7.0 (28 September 2013) +* Automatically change port setting on client-side to match server's +* Client auto-reconnect, so manual refresh is not needed after a brunch restart +* Fine-grained enable settings to customize what types of changes trigger an + auto-reload. +* Port setting can be an array for automatic recovery from port conflicts + +# auto-reload-brunch 1.6.5 (28 August 2013) +* Added `enabled` option. + +# auto-reload-brunch 1.6.4 (24 July 2013) +* Handled more WebSocketServer errors. + +# auto-reload-brunch 1.6.3 (11 May 2013) +* Added `teardown` API support. + +# auto-reload-brunch 1.6.2 (6 May 2013) +* Fixed styles reloading in brunch 1.6.4+. + +# auto-reload-brunch 1.6.1 (18 April 2013) +* Moved configuration to `config.plugins.autoReload` from `config.autoReload`. + +# auto-reload-brunch 1.6.0 (7 April 2013) +* Enabled plugin by default. + +# auto-reload-brunch 1.5.2 (19 March 2013) +* Added node 0.10 support, removed coffee-script dependency. + +# auto-reload-brunch 1.5.1 (30 January 2013) +* Plugin is now disabled in production environment (w / --optimize). + +# auto-reload-brunch 1.5.0 (13 January 2013) +* Improved installation process. + +# auto-reload-brunch 1.4.0 (26 November 2012) +* Added ability to customize websocket server ip & port and remote server ip. + +# auto-reload-brunch 1.3.2 (15 July 2012) +* Updated `ws` dependency to 0.4.20. + +# auto-reload-brunch 1.3.1 (29 June 2012) +* Fixed `config.persistent` bug. + +# auto-reload-brunch 1.3.0 (29 June 2012) +* Reloading became smarter. If you change stylesheet, the page itself +won't be reloaded etc. +* Added node.js 0.8 and 0.9 support. +* Package is now precompiled before every publishing to npm. + +# auto-reload-brunch 1.2.0 (18 May 2012) +* Initial release. diff --git a/node_modules/auto-reload-brunch/README.md b/node_modules/auto-reload-brunch/README.md index 813c514..b008592 100644 --- a/node_modules/auto-reload-brunch/README.md +++ b/node_modules/auto-reload-brunch/README.md @@ -17,7 +17,9 @@ Or, do manual install: ## Usage In most cases, auto-reload-brunch works out of the box without any further configuration. Stylesheet changes will be applied seamlessly, and any other -changes will trigger a page refresh. +changes will trigger a page refresh. To prevent a stylesheet from being reloaded +automatically, set the ```data-autoreload="false"``` attribute on the stylesheet's +link tag. ### Brunch plugin settings If customization is needed or desired, settings can be modified in your brunch @@ -40,11 +42,20 @@ config file (such as `brunch-config.coffee`): * If your system is having race-condition type problems when the browser tries to reload immediately after a compile, use this to set a delay before the reload signal is sent. +* __host__: (Default: '0.0.0.0') Server's host address. +* __forceRepaint__: (Default: false) forcefully repaint the page after stylesheets + refresh. Enabled in Chrome by default to mitigate the issue when it doesn't + always update styles. +* __keyPath__: Optional, no default. + * Path to private key used for SSL. +* __certPath__: Optional, no default. + * Path to public x509 certificate. **Example:** ```coffeescript exports.config = ... + # Every setting is optional. plugins: autoReload: enabled: @@ -53,6 +64,8 @@ exports.config = assets: off port: [1234, 2345, 3456] delay: 200 if require('os').platform() is 'win32' + keyPath: 'path/to/ssl.key' + certPath: 'path/to/ssl.crt' ``` ### Client-side settings diff --git a/node_modules/auto-reload-brunch/index.js b/node_modules/auto-reload-brunch/index.js index 8d2187b..a2f1c73 100644 --- a/node_modules/auto-reload-brunch/index.js +++ b/node_modules/auto-reload-brunch/index.js @@ -1,9 +1,12 @@ var sysPath = require('path'); -var WebSocketServer = (require('ws')).Server; +var fs = require('fs'); +var https = require('https'); +var WebSocketServer = require('ws').Server; var isWorker = require('cluster').isWorker; var isCss = function(file) { return sysPath.extname(file.path) === '.css'; }; +var startingPort = 9485; function AutoReloader(config) { if (config == null) config = {}; @@ -16,7 +19,7 @@ function AutoReloader(config) { var ports = []; if (cfg.port == null) { - for (var i = 0; i < 11; i++) ports.push(9485 + i); + for (var i = 0; i < 11; i++) ports.push(startingPort + i); } else { ports = Array.isArray(cfg.port) ? cfg.port.slice() : [cfg.port]; } @@ -27,14 +30,23 @@ function AutoReloader(config) { this.delay = cfg.delay; var conns = this.connections = []; + var host = cfg.host || '0.0.0.0'; var port = this.port = ports.shift(); + var key, cert; + if (cfg.keyPath && cfg.certPath) { + this.ssl = true; + key = fs.readFileSync(cfg.keyPath); + cert = fs.readFileSync(cfg.certPath); + if (key && cert) { + this.httpsServer = https.createServer({key: key, cert: cert}).listen(port, host); + } + } + var startServer = (function() { this.port = port; - var server = this.server = new WebSocketServer({ - host: '0.0.0.0', - port: port - }); + var args = this.httpsServer ? {server: this.httpsServer} : {host: host, port: port} + var server = this.server = new WebSocketServer(args); server.on('connection', function(conn) { conns.push(conn); conn.on('close', function() { @@ -95,21 +107,28 @@ AutoReloader.prototype.onCompile = function(changedFiles) { }); }; - (this.delay) ? setTimeout(sendMessage, this.delay) : sendMessage(); + this.delay ? setTimeout(sendMessage, this.delay) : sendMessage(); }; -var incPath = sysPath.join(__dirname, 'vendor', 'auto-reload.js'); +var fileName = 'auto-reload.js'; AutoReloader.prototype.include = function() { - return this.enabled ? [incPath] : []; + return this.enabled ? + [sysPath.join(__dirname, 'vendor', fileName)] : []; }; AutoReloader.prototype.teardown = function() { if (this.server) this.server.close(); + if (this.httpsServer) this.httpsServer.close(); }; AutoReloader.prototype.compile = function(params, callback) { - if (this.enabled && this.port !== 9485 && sysPath.basename(params.path) === 'auto-reload.js') { - params.data = params.data.replace(9485, this.port); + if (this.enabled && + this.port !== startingPort && + sysPath.basename(params.path) === fileName) { + params.data = params.data.replace(startingPort, this.port); + } + if (this.enabled && this.ssl) { + params.data = params.data.replace('ws://', 'wss://'); } return callback(null, params); }; diff --git a/node_modules/auto-reload-brunch/node_modules/.bin/wscat b/node_modules/auto-reload-brunch/node_modules/.bin/wscat deleted file mode 120000 index 06c3b74..0000000 --- a/node_modules/auto-reload-brunch/node_modules/.bin/wscat +++ /dev/null @@ -1 +0,0 @@ -../ws/bin/wscat \ No newline at end of file diff --git a/node_modules/auto-reload-brunch/node_modules/ws/History.md b/node_modules/auto-reload-brunch/node_modules/ws/History.md deleted file mode 100644 index 63cf0ea..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/History.md +++ /dev/null @@ -1,312 +0,0 @@ -v0.4.31 - September 23th, 2013 -===================== - -* Component support - -v0.4.30 - August 30th, 2013 -===================== - -* BufferedAmount could be undefined, default to 0 [TooTallNate] -* Support protocols as second argument and options as third [TooTallNate] -* Proper browserify shim [mcollina] -* Broadcasting example in README [stefanocudini] - -v0.4.29 - August 23th, 2013 -===================== -* Small clean up of the Node 0.11 support by using NAN from the NPM registry [kkoopa] -* Support for custom `Agent`'s through the options. [gramakri] & [TooTallNate] -* Support for custom headers through the options [3rd-Eden] -* Added a `gypfile` flag to the package.json for compiled module discovery [wolfeidau] - -v0.4.28 - August 16th, 2013 -===================== -* Node 0.11 support. [kkoopa] -* Authorization headers are sent when basic auth is used in the url [jcrugzz] -* Origin header will now include the port number [Jason Plum] -* Race condition fixed where data was received before the readyState was updated. [saschagehlich] - -v0.4.27 - June 27th, 2013 -===================== -* Frames are no longer masked in `wscat`. [slaskis] -* Don't retrain reference to large slab buffers. [jmatthewsr-msi] -* Don't use Buffer.byteLength for ArrayBuffer's. [Anthony Pesch] -* Fix browser field in package.json. [shtylman] -* Client-side certificate support & documentation improvements. [Lukas Berns] -* WebSocket readyState's is added to the prototype for spec compatiblity. [BallBearing] -* Use Object.defineProperty. [arlolra] -* Autodetect ArrayBuffers as binary when sending. [BallBearing] -* Check instanceof Buffer for binary data. [arlolra] -* Emit the close event before destroying the internal socket. [3rd-Eden] -* Don't setup multiply timeouts for one connection. [AndreasMadsen] -* Allow support for binding to ethereal port. [wpreul] -* Fix broken terminate reference. [3rd-Eden] -* Misc node 0.10 test fixes and documentation improvements. [3rd-Eden] -* Ensure ssl options are propagated to request. [einaros] -* Add 'Host' and 'Origin' to request header. [Lars-Magnus Skog] -* Subprotocol support. [kanaka] -* Honor ArrayBufferView's byteOffset when sending. [Anthony Pesch] -* Added target attribute for events. [arlolra] - -v0.4.26 - Skipped -===================== - -v0.4.25 - December 17th, 2012 -===================== -* Removed install.js. [shtylman] -* Added browser field to package.json. [shtylman] -* Support overwriting host header. [Raynos] -* Emit 'listening' also with custom http server. [sebiq] - -v0.4.24 - December 6th, 2012 -===================== -* Yet another intermediate release, to not delay minor features any longer. -* Native support installation issues further circumvented. [einaros] - -v0.4.23 - November 19th, 2012 -===================== -* Service release - last before major upgrade. -* Changes default host from 127.0.0.1 to 0.0.0.0. [einaros] - -v0.4.22 - October 3rd, 2012 -===================== -* clear failsafe cleanup timeout once cleanup is called [AndreasMadsen] -* added w3c compatible CloseEvent for onclose / addEventListener("close", ...). [einaros] -* fix the sub protocol header handler [sonnyp] -* fix unhandled exception if socket closes and 'error' is emitted [jmatthewsr-ms] - -v0.4.21 - July 14th, 2012 -===================== -* Emit error if server reponds with anything other than status code 101. [einaros] -* Added 'headers' event to server. [rauchg] -* path.exists moved to fs.exists. [blakmatrix] - -v0.4.20 - June 26th, 2012 -===================== -* node v0.8.0 compatibility release. - -v0.4.19 - June 19th, 2012 -===================== -* Change sender to merge buffers for relatively small payloads, may improve perf in some cases [einaros] -* Avoid EventEmitter for Receiver classes. As above this may improve perf. [einaros] -* Renamed fallback files from the somewhat misleading '*Windows'. [einaros] - -v0.4.18 - June 14th 2012 -===================== -* Fixed incorrect md5 digest encoding in Hixie handshake [nicokaiser] -* Added example of use with Express 3 [einaros] -* Change installation procedure to not require --ws:native to build native extensions. They will now build if a compiler is available. [einaros] - -v0.4.17 - June 13th 2012 -===================== -* Improve error handling during connection handshaking [einaros] -* Ensure that errors are caught also after connection teardown [nicokaiser] -* Update 'mocha' version to 1.1.0. [einaros] -* Stop showing 'undefined' for some error logs. [tricknotes] -* Update 'should' version to 0.6.3 [tricknotes] - -v0.4.16 - June 1st 2012 -===================== -* Build fix for Windows. [einaros] - -v0.4.15 - May 20th 2012 -===================== -* Enable fauxe streaming for hixie tansport. [einaros] -* Allow hixie sender to deal with buffers. [einaros/pigne] -* Allow error code 1011. [einaros] -* Fix framing for empty packets (empty pings and pongs might break). [einaros] -* Improve error and close handling, to avoid connections lingering in CLOSING state. [einaros] - -v0.4.14 - Apr 30th 2012 -===================== -* use node-gyp instead of node-waf [TooTallNate] -* remove old windows compatibility makefile, and silently fall back to native modules [einaros] -* ensure connection status [nicokaiser] -* websocket client updated to use port 443 by default for wss:// connections [einaros] -* support unix sockets [kschzt] - -v0.4.13 - Apr 12th 2012 -===================== - -* circumvent node 0.6+ related memory leak caused by Object.defineProperty [nicokaiser] -* improved error handling, improving stability in massive load use cases [nicokaiser] - -v0.4.12 - Mar 30th 2012 -===================== - -* various memory leak / possible memory leak cleanups [einaros] -* api documentation [nicokaiser] -* add option to disable client tracking [nicokaiser] - -v0.4.11 - Mar 24th 2012 -===================== - -* node v0.7 compatibillity release -* gyp support [TooTallNate] -* commander dependency update [jwueller] -* loadbalancer support [nicokaiser] - -v0.4.10 - Mar 22th 2012 -===================== - -* Final hixie close frame fixes. [nicokaiser] - -v0.4.9 - Mar 21st 2012 -===================== - -* Various hixie bugfixes (such as proper close frame handling). [einaros] - -v0.4.8 - Feb 29th 2012 -===================== - -* Allow verifyClient to run asynchronously [karlsequin] -* Various bugfixes and cleanups. [einaros] - -v0.4.7 - Feb 21st 2012 -===================== - -* Exposed bytesReceived from websocket client object, which makes it possible to implement bandwidth sampling. [einaros] -* Updated browser based file upload example to include and output per websocket channel bandwidth sampling. [einaros] -* Changed build scripts to check which architecture is currently in use. Required after the node.js changes to have prebuilt packages target ia32 by default. [einaros] - -v0.4.6 - Feb 9th 2012 -===================== - -* Added browser based file upload example. [einaros] -* Added server-to-browser status push example. [einaros] -* Exposed pause() and resume() on WebSocket object, to enable client stream shaping. [einaros] - -v0.4.5 - Feb 7th 2012 -===================== - -* Corrected regression bug in handling of connections with the initial frame delivered across both http upgrade head and a standalone packet. This would lead to a race condition, which in some cases could cause message corruption. [einaros] - -v0.4.4 - Feb 6th 2012 -===================== - -* Pass original request object to verifyClient, for cookie or authentication verifications. [einaros] -* Implemented addEventListener and slightly improved the emulation API by adding a MessageEvent with a readonly data attribute. [aslakhellesoy] -* Rewrite parts of hybi receiver to avoid stack overflows for large amounts of packets bundled in the same buffer / packet. [einaros] - -v0.4.3 - Feb 4th 2012 -===================== - -* Prioritized update: Corrected issue which would cause sockets to stay open longer than necessary, and resource leakage because of this. [einaros] - -v0.4.2 - Feb 4th 2012 -===================== - -* Breaking change: WebSocketServer's verifyOrigin option has been renamed to verifyClient. [einaros] -* verifyClient now receives { origin: 'origin header', secure: true/false }, where 'secure' will be true for ssl connections. [einaros] -* Split benchmark, in preparation for more thorough case. [einaros] -* Introduced hixie-76 draft support for server, since Safari (iPhone / iPad / OS X) and Opera still aren't updated to use Hybi. [einaros] -* Expose 'supports' object from WebSocket, to indicate e.g. the underlying transport's support for binary data. [einaros] -* Test and code cleanups. [einaros] - -v0.4.1 - Jan 25th 2012 -===================== - -* Use readline in wscat [tricknotes] -* Refactor _state away, in favor of the new _readyState [tricknotes] -* travis-ci integration [einaros] -* Fixed race condition in testsuite, causing a few tests to fail (without actually indicating errors) on travis [einaros] -* Expose pong event [paddybyers] -* Enabled running of WebSocketServer in noServer-mode, meaning that upgrades are passed in manually. [einaros] -* Reworked connection procedure for WebSocketServer, and cleaned up tests. [einaros] - -v0.4.0 - Jan 2nd 2012 -===================== - -* Windows compatibility [einaros] -* Windows compatible test script [einaros] - -v0.3.9 - Jan 1st 2012 -====================== - -* Improved protocol framing performance [einaros] -* WSS support [kazuyukitanimura] -* WSS tests [einaros] -* readyState exposed [justinlatimer, tricknotes] -* url property exposed [justinlatimer] -* Removed old 'state' property [einaros] -* Test cleanups [einaros] - -v0.3.8 - Dec 27th 2011 -====================== - -* Made it possible to listen on specific paths, which is especially good to have for precreated http servers [einaros] -* Extensive WebSocket / WebSocketServer cleanup, including changing all internal properties to unconfigurable, unenumerable properties [einaros] -* Receiver modifications to ensure even better performance with fragmented sends [einaros] -* Fixed issue in sender.js, which would cause SlowBuffer instances (such as returned from the crypto library's randomBytes) to be copied (and thus be dead slow) [einaros] -* Removed redundant buffer copy in sender.js, which should improve server performance [einaros] - -v0.3.7 - Dec 25nd 2011 -====================== - -* Added a browser based API which uses EventEmitters internally [3rd-Eden] -* Expose request information from upgrade event for websocket server clients [mmalecki] - -v0.3.6 - Dec 19th 2011 -====================== - -* Added option to let WebSocket.Server use an already existing http server [mmalecki] -* Migrating various option structures to use options.js module [einaros] -* Added a few more tests, options and handshake verifications to ensure that faulty connections are dealt with [einaros] -* Code cleanups in Sender and Receiver, to ensure even faster parsing [einaros] - -v0.3.5 - Dec 13th 2011 -====================== - -* Optimized Sender.js, Receiver.js and bufferutil.cc: - * Apply loop-unrolling-like small block copies rather than use node.js Buffer#copy() (which is slow). - * Mask blocks of data using combination of 32bit xor and loop-unrolling, instead of single bytes. - * Keep pre-made send buffer for small transfers. -* Leak fixes and code cleanups. - -v0.3.3 - Dec 12th 2011 -====================== - -* Compile fix for Linux. -* Rewrote parts of WebSocket.js, to avoid try/catch and thus avoid optimizer bailouts. - -v0.3.2 - Dec 11th 2011 -====================== - -* Further performance updates, including the additions of a native BufferUtil module, which deals with several of the cpu intensive WebSocket operations. - -v0.3.1 - Dec 8th 2011 -====================== - -* Service release, fixing broken tests. - -v0.3.0 - Dec 8th 2011 -====================== - -* Node.js v0.4.x compatibility. -* Code cleanups and efficiency improvements. -* WebSocket server added, although this will still mainly be a client library. -* WebSocket server certified to pass the Autobahn test suite. -* Protocol improvements and corrections - such as handling (redundant) masks for empty fragments. -* 'wscat' command line utility added, which can act as either client or server. - -v0.2.6 - Dec 3rd 2011 -====================== - -* Renamed to 'ws'. Big woop, right -- but easy-websocket really just doesn't cut it anymore! - -v0.2.5 - Dec 3rd 2011 -====================== - - * Rewrote much of the WebSocket parser, to ensure high speed for highly fragmented messages. - * Added a BufferPool, as a start to more efficiently deal with allocations for WebSocket connections. More work to come, in that area. - * Updated the Autobahn report, at http://einaros.github.com/easy-websocket, with comparisons against WebSocket-Node 1.0.2 and Chrome 16. - -v0.2.0 - Nov 25th 2011 -====================== - - * Major rework to make sure all the Autobahn test cases pass. Also updated the internal tests to cover more corner cases. - -v0.1.2 - Nov 14th 2011 -====================== - - * Back and forth, back and forth: now settled on keeping the api (event names, methods) closer to the websocket browser api. This will stick now. - * Started keeping this history record. Better late than never, right? diff --git a/node_modules/auto-reload-brunch/node_modules/ws/Makefile b/node_modules/auto-reload-brunch/node_modules/ws/Makefile index 151aa2b..00f19fa 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/Makefile +++ b/node_modules/auto-reload-brunch/node_modules/ws/Makefile @@ -9,7 +9,7 @@ clean: run-tests: @./node_modules/.bin/mocha \ - -t 2000 \ + -t 5000 \ -s 2400 \ $(TESTFLAGS) \ $(TESTS) diff --git a/node_modules/auto-reload-brunch/node_modules/ws/README.md b/node_modules/auto-reload-brunch/node_modules/ws/README.md index cf1f1fb..fef2fe6 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/README.md +++ b/node_modules/auto-reload-brunch/node_modules/ws/README.md @@ -1,151 +1,165 @@ -[![Build Status](https://secure.travis-ci.org/einaros/ws.png)](http://travis-ci.org/einaros/ws) +# ws: a node.js websocket library -# ws: a node.js websocket library # +[![Build Status](https://travis-ci.org/einaros/ws.svg?branch=master)](https://travis-ci.org/einaros/ws) -`ws` is a simple to use websocket implementation, up-to-date against RFC-6455, and [probably the fastest WebSocket library for node.js](http://web.archive.org/web/20130314230536/http://hobbycoding.posterous.com/the-fastest-websocket-module-for-nodejs). +`ws` is a simple to use WebSocket implementation, up-to-date against RFC-6455, +and [probably the fastest WebSocket library for node.js][archive]. -Passes the quite extensive Autobahn test suite. See http://einaros.github.com/ws for the full reports. +Passes the quite extensive Autobahn test suite. See http://einaros.github.com/ws +for the full reports. -Comes with a command line utility, `wscat`, which can either act as a server (--listen), or client (--connect); Use it to debug simple websocket services. +## Protocol support -## Protocol support ## +* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera. + Added to ws version 0.4.2, but server only. Can be disabled by setting the + `disableHixie` option to true.) +* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`) +* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`) -* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera. Added to ws version 0.4.2, but server only. Can be disabled by setting the `disableHixie` option to true.) -* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`, or argument `-p 8` for wscat) -* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`, or argument `-p 13` for wscat) +### Installing -_See the echo.websocket.org example below for how to use the `protocolVersion` option._ - -## Usage ## - -### Installing ### - -`npm install ws` +``` +npm install --save ws +``` -### Sending and receiving text data ### +### Sending and receiving text data ```js var WebSocket = require('ws'); var ws = new WebSocket('ws://www.host.com/path'); -ws.on('open', function() { - ws.send('something'); + +ws.on('open', function open() { + ws.send('something'); }); + ws.on('message', function(data, flags) { - // flags.binary will be set if a binary data is received - // flags.masked will be set if the data was masked + // flags.binary will be set if a binary data is received. + // flags.masked will be set if the data was masked. }); ``` -### Sending binary data ### +### Sending binary data ```js var WebSocket = require('ws'); var ws = new WebSocket('ws://www.host.com/path'); -ws.on('open', function() { - var array = new Float32Array(5); - for (var i = 0; i < array.length; ++i) array[i] = i / 2; - ws.send(array, {binary: true, mask: true}); + +ws.on('open', function open() { + var array = new Float32Array(5); + + for (var i = 0; i < array.length; ++i) { + array[i] = i / 2; + } + + ws.send(array, { binary: true, mask: true }); }); ``` -Setting `mask`, as done for the send options above, will cause the data to be masked according to the websocket protocol. The same option applies for text data. +Setting `mask`, as done for the send options above, will cause the data to be +masked according to the WebSocket protocol. The same option applies for text +data. -### Server example ### +### Server example ```js var WebSocketServer = require('ws').Server - , wss = new WebSocketServer({port: 8080}); -wss.on('connection', function(ws) { - ws.on('message', function(message) { - console.log('received: %s', message); - }); - ws.send('something'); + , wss = new WebSocketServer({ port: 8080 }); + +wss.on('connection', function connection(ws) { + ws.on('message', function incoming(message) { + console.log('received: %s', message); + }); + + ws.send('something'); }); ``` -### Server sending broadcast data ### +### Server sending broadcast data ```js var WebSocketServer = require('ws').Server - , wss = new WebSocketServer({port: 8080}); - -wss.broadcast = function(data) { - for(var i in this.clients) - this.clients[i].send(data); + , wss = new WebSocketServer({ port: 8080 }); + +wss.broadcast = function broadcast(data) { + wss.clients.forEach(function each(client) { + client.send(data); + }); }; ``` -### Error handling best practices ### +### Error handling best practices ```js // If the WebSocket is closed before the following send is attempted ws.send('something'); -// Errors (both immediate and async write errors) can be detected in an optional callback. -// The callback is also the only way of being notified that data has actually been sent. -ws.send('something', function(error) { - // if error is null, the send has been completed, - // otherwise the error object will indicate what failed. +// Errors (both immediate and async write errors) can be detected in an optional +// callback. The callback is also the only way of being notified that data has +// actually been sent. +ws.send('something', function ack(error) { + // if error is not defined, the send has been completed, + // otherwise the error object will indicate what failed. }); -// Immediate errors can also be handled with try/catch-blocks, but **note** -// that since sends are inherently asynchronous, socket write failures will *not* -// be captured when this technique is used. -try { - ws.send('something'); -} -catch (e) { - // handle error -} +// Immediate errors can also be handled with try/catch-blocks, but **note** that +// since sends are inherently asynchronous, socket write failures will *not* be +// captured when this technique is used. +try { ws.send('something'); } +catch (e) { /* handle error */ } ``` -### echo.websocket.org demo ### +### echo.websocket.org demo ```js var WebSocket = require('ws'); -var ws = new WebSocket('ws://echo.websocket.org/', {protocolVersion: 8, origin: 'http://websocket.org'}); -ws.on('open', function() { - console.log('connected'); - ws.send(Date.now().toString(), {mask: true}); +var ws = new WebSocket('ws://echo.websocket.org/', { + protocolVersion: 8, + origin: 'http://websocket.org' }); -ws.on('close', function() { - console.log('disconnected'); + +ws.on('open', function open() { + console.log('connected'); + ws.send(Date.now().toString(), {mask: true}); }); -ws.on('message', function(data, flags) { - console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags); - setTimeout(function() { - ws.send(Date.now().toString(), {mask: true}); - }, 500); + +ws.on('close', function close() { + console.log('disconnected'); }); -``` -### wscat against echo.websocket.org ### +ws.on('message', function message(data, flags) { + console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags); - $ npm install -g ws - $ wscat -c ws://echo.websocket.org - connected (press CTRL+C to quit) - > hi there - < hi there - > are you a happy parrot? - < are you a happy parrot? + setTimeout(function timeout() { + ws.send(Date.now().toString(), {mask: true}); + }, 500); +}); +``` -### Other examples ### +### Other examples -For a full example with a browser client communicating with a ws server, see the examples folder. +For a full example with a browser client communicating with a ws server, see the +examples folder. -Note that the usage together with Express 3.0 is quite different from Express 2.x. The difference is expressed in the two different serverstats-examples. +Note that the usage together with Express 3.0 is quite different from Express +2.x. The difference is expressed in the two different serverstats-examples. Otherwise, see the test cases. -### Running the tests ### +### Running the tests -`make test` +``` +make test +``` -## API Docs ## +## API Docs See the doc/ directory for Node.js-like docs for the ws classes. -## License ## +## Changelog + +We're using the GitHub `releases` for changelog entries. + +## License (The MIT License) @@ -169,3 +183,5 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +[archive]: http://web.archive.org/web/20130314230536/http://hobbycoding.posterous.com/the-fastest-websocket-module-for-nodejs diff --git a/node_modules/auto-reload-brunch/node_modules/ws/bin/wscat b/node_modules/auto-reload-brunch/node_modules/ws/bin/wscat deleted file mode 100755 index 7c66600..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/bin/wscat +++ /dev/null @@ -1,222 +0,0 @@ -#!/usr/bin/env node - -/*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var WebSocket = require('../') - , fs = require('fs') - , program = require('commander') - , util = require('util') - , events = require('events') - , readline = require('readline'); - -/** - * InputReader - processes console input - */ - -function Console() { - this.stdin = process.stdin; - this.stdout = process.stdout; - - this.readlineInterface = readline.createInterface(this.stdin, this.stdout); - - var self = this; - this.readlineInterface.on('line', function(data) { - self.emit('line', data); - }); - this.readlineInterface.on('close', function() { - self.emit('close'); - }); - - this._resetInput = function() { - self.clear(); - } -} -util.inherits(Console, events.EventEmitter); - -Console.Colors = { - Red: '\033[31m', - Green: '\033[32m', - Yellow: '\033[33m', - Blue: '\033[34m', - Default: '\033[39m' -}; - -Console.prototype.prompt = function() { - this.readlineInterface.prompt(); -} - -Console.prototype.print = function(msg, color) { - this.clear(); - color = color || Console.Colors.Default; - this.stdout.write(color + msg + Console.Colors.Default + '\n'); - this.prompt(); -} - -Console.prototype.clear = function() { - this.stdout.write('\033[2K\033[E'); -} - -Console.prototype.pause = function() { - this.stdin.on('keypress', this._resetInput); -} - -Console.prototype.resume = function() { - this.stdin.removeListener('keypress', this._resetInput); -} - -function appender(xs) { - xs = xs || []; - return function (x) { - xs.push(x); - return xs; - } -} - -function into(obj, kvals) { - kvals.forEach(function (kv) { - obj[kv[0]] = kv[1]; - }); - return obj; -} - -function splitOnce(sep, str) { // sep can be either String or RegExp - var tokens = str.split(sep); - return [tokens[0], str.replace(sep, '').substr(tokens[0].length)]; -} - -/** - * The actual application - */ - -var version = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version; -program - .version(version) - .usage('[options] ') - .option('-l, --listen ', 'listen on port') - .option('-c, --connect ', 'connect to a websocket server') - .option('-p, --protocol ', 'optional protocol version') - .option('-o, --origin ', 'optional origin') - .option('--host ', 'optional host') - .option('-s, --subprotocol ', 'optional subprotocol') - .option('-n, --no-check', 'Do not check for unauthorized certificates') - .option('-H, --header ', 'Set an HTTP header. Repeat to set multiple. (--connect only)', appender(), []) - .option('--auth ', 'Add basic HTTP authentication header. (--connect only)') - .parse(process.argv); - -if (program.listen && program.connect) { - console.error('\033[33merror: use either --listen or --connect\033[39m'); - process.exit(-1); -} -else if (program.listen) { - var wsConsole = new Console(); - wsConsole.pause(); - var options = {}; - if (program.protocol) options.protocolVersion = program.protocol; - if (program.origin) options.origin = program.origin; - if (program.subprotocol) options.protocol = program.subprotocol; - if (!program.check) options.rejectUnauthorized = program.check; - var ws = null; - var wss = new WebSocket.Server({port: program.listen}, function() { - wsConsole.print('listening on port ' + program.listen + ' (press CTRL+C to quit)', Console.Colors.Green); - wsConsole.clear(); - }); - wsConsole.on('close', function() { - if (ws) { - try { - ws.close(); - } - catch (e) {} - } - process.exit(0); - }); - wsConsole.on('line', function(data) { - if (ws) { - ws.send(data, {mask: false}); - wsConsole.prompt(); - } - }); - wss.on('connection', function(newClient) { - if (ws) { - // limit to one client - newClient.terminate(); - return; - }; - ws = newClient; - wsConsole.resume(); - wsConsole.prompt(); - wsConsole.print('client connected', Console.Colors.Green); - ws.on('close', function() { - wsConsole.print('disconnected', Console.Colors.Green); - wsConsole.clear(); - wsConsole.pause(); - ws = null; - }); - ws.on('error', function(code, description) { - wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow); - }); - ws.on('message', function(data, flags) { - wsConsole.print('< ' + data, Console.Colors.Blue); - }); - }); - wss.on('error', function(error) { - wsConsole.print('error: ' + error.toString(), Console.Colors.Yellow); - process.exit(-1); - }); -} -else if (program.connect) { - var wsConsole = new Console(); - var options = {}; - if (program.protocol) options.protocolVersion = program.protocol; - if (program.origin) options.origin = program.origin; - if (program.subprotocol) options.protocol = program.subprotocol; - if (program.host) options.host = program.host; - if (!program.check) options.rejectUnauthorized = program.check; - var headers = into({}, (program.header || []).map(function (s) { - return splitOnce(':', s) - })); - if (program.auth) { - headers['Authorization'] = 'Basic ' + new Buffer(program.auth).toString('base64'); - } - options.headers = headers; - var ws = new WebSocket(program.connect, options); - ws.on('open', function() { - wsConsole.print('connected (press CTRL+C to quit)', Console.Colors.Green); - wsConsole.on('line', function(data) { - ws.send(data, {mask: true}); - wsConsole.prompt(); - }); - }); - ws.on('close', function() { - wsConsole.print('disconnected', Console.Colors.Green); - wsConsole.clear(); - process.exit(); - }); - ws.on('error', function(code, description) { - wsConsole.print('error: ' + code + (description ? ' ' + description : ''), Console.Colors.Yellow); - process.exit(-1); - }); - ws.on('message', function(data, flags) { - wsConsole.print('< ' + data, Console.Colors.Blue); - }); - wsConsole.on('close', function() { - if (ws) { - try { - ws.close(); - } - catch(e) {} - process.exit(); - } - }); -} -else { - console.error('\033[33merror: use either --listen or --connect\033[39m'); - process.exit(-1); -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/bufferutil.node b/node_modules/auto-reload-brunch/node_modules/ws/build/Release/bufferutil.node deleted file mode 100755 index d7bc60a..0000000 Binary files a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/bufferutil.node and /dev/null differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/bufferutil/src/bufferutil.o b/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/bufferutil/src/bufferutil.o deleted file mode 100644 index 135f6c1..0000000 Binary files a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/bufferutil/src/bufferutil.o and /dev/null differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/validation/src/validation.o b/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/validation/src/validation.o deleted file mode 100644 index 415d8e6..0000000 Binary files a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/obj.target/validation/src/validation.o and /dev/null differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/validation.node b/node_modules/auto-reload-brunch/node_modules/ws/build/Release/validation.node deleted file mode 100755 index 5f319d2..0000000 Binary files a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/validation.node and /dev/null differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/index.js b/node_modules/auto-reload-brunch/node_modules/ws/index.js index 3423ff2..a7e8644 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/index.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/index.js @@ -1,26 +1,49 @@ +'use strict'; + /*! * ws: a node.js websocket client * Copyright(c) 2011 Einar Otto Stangvik * MIT Licensed */ -module.exports = require('./lib/WebSocket'); -module.exports.Server = require('./lib/WebSocketServer'); -module.exports.Sender = require('./lib/Sender'); -module.exports.Receiver = require('./lib/Receiver'); +var WS = module.exports = require('./lib/WebSocket'); + +WS.Server = require('./lib/WebSocketServer'); +WS.Sender = require('./lib/Sender'); +WS.Receiver = require('./lib/Receiver'); + +/** + * Create a new WebSocket server. + * + * @param {Object} options Server options + * @param {Function} fn Optional connection listener. + * @returns {WS.Server} + * @api public + */ +WS.createServer = function createServer(options, fn) { + var server = new WS.Server(options); -module.exports.createServer = function (options, connectionListener) { - var server = new module.exports.Server(options); - if (typeof connectionListener === 'function') { - server.on('connection', connectionListener); + if (typeof fn === 'function') { + server.on('connection', fn); } + return server; }; -module.exports.connect = module.exports.createConnection = function (address, openListener) { - var client = new module.exports(address); - if (typeof openListener === 'function') { - client.on('open', openListener); +/** + * Create a new WebSocket connection. + * + * @param {String} address The URL/address we need to connect to. + * @param {Function} fn Open listener. + * @returns {WS} + * @api public + */ +WS.connect = WS.createConnection = function connect(address, fn) { + var client = new WS(address); + + if (typeof fn === 'function') { + client.on('open', fn); } + return client; }; diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/BufferUtil.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/BufferUtil.js index 15d35b9..18c6998 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/BufferUtil.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/BufferUtil.js @@ -1,3 +1,5 @@ +'use strict'; + /*! * ws: a node.js websocket client * Copyright(c) 2011 Einar Otto Stangvik @@ -5,12 +7,7 @@ */ try { - module.exports = require('../build/Release/bufferutil'); -} catch (e) { try { - module.exports = require('../build/default/bufferutil'); -} catch (e) { try { - module.exports = require('./BufferUtil.fallback'); + module.exports = require('bufferutil'); } catch (e) { - console.error('bufferutil.node seems to not have been built. Run npm install.'); - throw e; -}}} + module.exports = require('./BufferUtil.fallback'); +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/Extensions.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/Extensions.js new file mode 100644 index 0000000..a465ace --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/Extensions.js @@ -0,0 +1,70 @@ + +var util = require('util'); + +/** + * Module exports. + */ + +exports.parse = parse; +exports.format = format; + +/** + * Parse extensions header value + */ + +function parse(value) { + value = value || ''; + + var extensions = {}; + + value.split(',').forEach(function(v) { + var params = v.split(';'); + var token = params.shift().trim(); + var paramsList = extensions[token] = extensions[token] || []; + var parsedParams = {}; + + params.forEach(function(param) { + var parts = param.trim().split('='); + var key = parts[0]; + var value = parts[1]; + if (typeof value === 'undefined') { + value = true; + } else { + // unquote value + if (value[0] === '"') { + value = value.slice(1); + } + if (value[value.length - 1] === '"') { + value = value.slice(0, value.length - 1); + } + } + (parsedParams[key] = parsedParams[key] || []).push(value); + }); + + paramsList.push(parsedParams); + }); + + return extensions; +} + +/** + * Format extensions header value + */ + +function format(value) { + return Object.keys(value).map(function(token) { + var paramsList = value[token]; + if (!util.isArray(paramsList)) { + paramsList = [paramsList]; + } + return paramsList.map(function(params) { + return [token].concat(Object.keys(params).map(function(k) { + var p = params[k]; + if (!util.isArray(p)) p = [p]; + return p.map(function(v) { + return v === true ? k : k + '=' + v; + }).join('; '); + })).join('; '); + }).join(', '); + }).join(', '); +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/PerMessageDeflate.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/PerMessageDeflate.js new file mode 100644 index 0000000..f735977 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/PerMessageDeflate.js @@ -0,0 +1,289 @@ + +var zlib = require('zlib'); + +var AVAILABLE_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]; +var DEFAULT_WINDOW_BITS = 15; +var DEFAULT_MEM_LEVEL = 8; + +PerMessageDeflate.extensionName = 'permessage-deflate'; + +/** + * Per-message Compression Extensions implementation + */ + +function PerMessageDeflate(options, isServer) { + this._options = options || {}; + this._isServer = !!isServer; + this._inflate = null; + this._deflate = null; + this.params = null; +} + +/** + * Create extension parameters offer + * + * @api public + */ + +PerMessageDeflate.prototype.offer = function() { + var params = {}; + if (this._options.serverNoContextTakeover) { + params.server_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover) { + params.client_no_context_takeover = true; + } + if (this._options.serverMaxWindowBits) { + params.server_max_window_bits = this._options.serverMaxWindowBits; + } + if (this._options.clientMaxWindowBits) { + params.client_max_window_bits = this._options.clientMaxWindowBits; + } else if (this._options.clientMaxWindowBits == null) { + params.client_max_window_bits = true; + } + return params; +}; + +/** + * Accept extension offer + * + * @api public + */ + +PerMessageDeflate.prototype.accept = function(paramsList) { + paramsList = this.normalizeParams(paramsList); + + var params; + if (this._isServer) { + params = this.acceptAsServer(paramsList); + } else { + params = this.acceptAsClient(paramsList); + } + + this.params = params; + return params; +}; + +/** + * Accept extension offer from client + * + * @api private + */ + +PerMessageDeflate.prototype.acceptAsServer = function(paramsList) { + var accepted = {}; + var result = paramsList.some(function(params) { + accepted = {}; + if (this._options.serverNoContextTakeover === false && params.server_no_context_takeover) { + return; + } + if (this._options.serverMaxWindowBits === false && params.server_max_window_bits) { + return; + } + if (typeof this._options.serverMaxWindowBits === 'number' && + typeof params.server_max_window_bits === 'number' && + this._options.serverMaxWindowBits > params.server_max_window_bits) { + return; + } + if (typeof this._options.clientMaxWindowBits === 'number' && !params.client_max_window_bits) { + return; + } + + if (this._options.serverNoContextTakeover || params.server_no_context_takeover) { + accepted.server_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover) { + accepted.client_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover !== false && params.client_no_context_takeover) { + accepted.client_no_context_takeover = true; + } + if (typeof this._options.serverMaxWindowBits === 'number') { + accepted.server_max_window_bits = this._options.serverMaxWindowBits; + } else if (typeof params.server_max_window_bits === 'number') { + accepted.server_max_window_bits = params.server_max_window_bits; + } + if (typeof this._options.clientMaxWindowBits === 'number') { + accepted.client_max_window_bits = this._options.clientMaxWindowBits; + } else if (this._options.clientMaxWindowBits !== false && typeof params.client_max_window_bits === 'number') { + accepted.client_max_window_bits = params.client_max_window_bits; + } + return true; + }, this); + + if (!result) { + throw new Error('Doesn\'t support the offered configuration'); + } + + return accepted; +}; + +/** + * Accept extension response from server + * + * @api privaye + */ + +PerMessageDeflate.prototype.acceptAsClient = function(paramsList) { + var params = paramsList[0]; + if (this._options.clientNoContextTakeover != null) { + if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { + throw new Error('Invalid value for "client_no_context_takeover"'); + } + } + if (this._options.clientMaxWindowBits != null) { + if (this._options.clientMaxWindowBits === false && params.client_max_window_bits) { + throw new Error('Invalid value for "client_max_window_bits"'); + } + if (typeof this._options.clientMaxWindowBits === 'number' && + (!params.client_max_window_bits || params.client_max_window_bits > this._options.clientMaxWindowBits)) { + throw new Error('Invalid value for "client_max_window_bits"'); + } + } + return params; +}; + +/** + * Normalize extensions parameters + * + * @api private + */ + +PerMessageDeflate.prototype.normalizeParams = function(paramsList) { + return paramsList.map(function(params) { + Object.keys(params).forEach(function(key) { + var value = params[key]; + if (value.length > 1) { + throw new Error('Multiple extension parameters for ' + key); + } + + value = value[0]; + + switch (key) { + case 'server_no_context_takeover': + case 'client_no_context_takeover': + if (value !== true) { + throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); + } + params[key] = true; + break; + case 'server_max_window_bits': + case 'client_max_window_bits': + if (typeof value === 'string') { + value = parseInt(value, 10); + if (!~AVAILABLE_WINDOW_BITS.indexOf(value)) { + throw new Error('invalid extension parameter value for ' + key + ' (' + value + ')'); + } + } + if (!this._isServer && value === true) { + throw new Error('Missing extension parameter value for ' + key); + } + params[key] = value; + break; + default: + throw new Error('Not defined extension parameter (' + key + ')'); + } + }, this); + return params; + }, this); +}; + +/** + * Decompress message + * + * @api public + */ + +PerMessageDeflate.prototype.decompress = function (data, fin, callback) { + var endpoint = this._isServer ? 'client' : 'server'; + + if (!this._inflate) { + var maxWindowBits = this.params[endpoint + '_max_window_bits']; + this._inflate = zlib.createInflateRaw({ + windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS + }); + } + + var self = this; + var buffers = []; + + this._inflate.on('error', onError).on('data', onData); + this._inflate.write(data); + if (fin) { + this._inflate.write(new Buffer([0x00, 0x00, 0xff, 0xff])); + } + this._inflate.flush(function() { + cleanup(); + callback(null, Buffer.concat(buffers)); + }); + + function onError(err) { + cleanup(); + callback(err); + } + + function onData(data) { + buffers.push(data); + } + + function cleanup() { + self._inflate.removeListener('error', onError); + self._inflate.removeListener('data', onData); + if (fin && self.params[endpoint + '_no_context_takeover']) { + self._inflate = null; + } + } +}; + +/** + * Compress message + * + * @api public + */ + +PerMessageDeflate.prototype.compress = function (data, fin, callback) { + var endpoint = this._isServer ? 'server' : 'client'; + + if (!this._deflate) { + var maxWindowBits = this.params[endpoint + '_max_window_bits']; + this._deflate = zlib.createDeflateRaw({ + flush: zlib.Z_SYNC_FLUSH, + windowBits: 'number' === typeof maxWindowBits ? maxWindowBits : DEFAULT_WINDOW_BITS, + memLevel: this._options.memLevel || DEFAULT_MEM_LEVEL + }); + } + + var self = this; + var buffers = []; + + this._deflate.on('error', onError).on('data', onData); + this._deflate.write(data); + this._deflate.flush(function() { + cleanup(); + var data = Buffer.concat(buffers); + if (fin) { + data = data.slice(0, data.length - 4); + } + callback(null, data); + }); + + function onError(err) { + cleanup(); + callback(err); + } + + function onData(data) { + buffers.push(data); + } + + function cleanup() { + self._deflate.removeListener('error', onError); + self._deflate.removeListener('data', onData); + if (fin && self.params[endpoint + '_no_context_takeover']) { + self._deflate = null; + } + } +}; + +module.exports = PerMessageDeflate; + diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/Receiver.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/Receiver.js index 004cd32..1ae1c4e 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/Receiver.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/Receiver.js @@ -8,13 +8,14 @@ var util = require('util') , Validation = require('./Validation').Validation , ErrorCodes = require('./ErrorCodes') , BufferPool = require('./BufferPool') - , bufferUtil = require('./BufferUtil').BufferUtil; + , bufferUtil = require('./BufferUtil').BufferUtil + , PerMessageDeflate = require('./PerMessageDeflate'); /** * HyBi Receiver implementation */ -function Receiver () { +function Receiver (extensions) { // memory pool for fragmented messages var fragmentedPoolPrevUsed = -1; this.fragmentedBufferPool = new BufferPool(1024, function(db, length) { @@ -35,6 +36,7 @@ function Receiver () { db.used; }); + this.extensions = extensions || {}; this.state = { activeFragmentedOperation: null, lastFragment: false, @@ -48,8 +50,10 @@ function Receiver () { this.expectBuffer = null; this.expectHandler = null; this.currentMessage = []; + this.messageHandlers = []; this.expectHeader(2, this.processPacket); this.dead = false; + this.processing = false; this.onerror = function() {}; this.ontext = function() {}; @@ -177,14 +181,26 @@ Receiver.prototype.allocateFromPool = function(length, isFragmented) { */ Receiver.prototype.processPacket = function (data) { - if ((data[0] & 0x70) != 0) { - this.error('reserved fields must be empty', 1002); - return; + if (this.extensions[PerMessageDeflate.extensionName]) { + if ((data[0] & 0x30) != 0) { + this.error('reserved fields (2, 3) must be empty', 1002); + return; + } + } else { + if ((data[0] & 0x70) != 0) { + this.error('reserved fields must be empty', 1002); + return; + } } this.state.lastFragment = (data[0] & 0x80) == 0x80; this.state.masked = (data[1] & 0x80) == 0x80; + var compressed = (data[0] & 0x40) == 0x40; var opcode = data[0] & 0xf; if (opcode === 0) { + if (compressed) { + this.error('continuation frame cannot have the Per-message Compressed bits', 1002); + return; + } // continuation frame this.state.fragmentedOperation = true; this.state.opcode = this.state.activeFragmentedOperation; @@ -198,6 +214,11 @@ Receiver.prototype.processPacket = function (data) { this.error('data frames after the initial data frame must have opcode 0', 1002); return; } + if (opcode >= 8 && compressed) { + this.error('control frames cannot have the Per-message Compressed bits', 1002); + return; + } + this.state.compressed = compressed; this.state.opcode = opcode; if (this.state.lastFragment === false) { this.state.fragmentedOperation = true; @@ -256,6 +277,7 @@ Receiver.prototype.reset = function() { this.expectHandler = null; this.overflow = []; this.currentMessage = []; + this.messageHandlers = []; }; /** @@ -296,6 +318,49 @@ Receiver.prototype.error = function (reason, protocolErrorCode) { return this; }; +/** + * Execute message handler buffers + * + * @api private + */ + +Receiver.prototype.flush = function() { + if (this.processing || this.dead) return; + + var handler = this.messageHandlers.shift(); + if (!handler) return; + + this.processing = true; + var self = this; + + handler(function() { + self.processing = false; + self.flush(); + }); +}; + +/** + * Apply extensions to message + * + * @api private + */ + +Receiver.prototype.applyExtensions = function(messageBuffer, fin, compressed, callback) { + var self = this; + if (compressed) { + this.extensions[PerMessageDeflate.extensionName].decompress(messageBuffer, fin, function(err, buffer) { + if (self.dead) return; + if (err) { + callback(new Error('invalid compressed data')); + return; + } + callback(null, buffer); + }); + } else { + callback(null, messageBuffer); + } +}; + /** * Buffer utilities */ @@ -334,6 +399,16 @@ function fastCopy(length, srcBuffer, dstBuffer, dstOffset) { } } +function clone(obj) { + var cloned = {}; + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + cloned[k] = obj[k]; + } + } + return cloned; +} + /** * Opcode handlers */ @@ -380,17 +455,27 @@ var opcodes = { } }, finish: function(mask, data) { - var packet = this.unmask(mask, data, true); - if (packet != null) this.currentMessage.push(packet); - if (this.state.lastFragment) { - var messageBuffer = this.concatBuffers(this.currentMessage); - if (!Validation.isValidUTF8(messageBuffer)) { - this.error('invalid utf8 sequence', 1007); - return; - } - this.ontext(messageBuffer.toString('utf8'), {masked: this.state.masked, buffer: messageBuffer}); - this.currentMessage = []; - } + var self = this; + var packet = this.unmask(mask, data, true) || new Buffer(0); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { + if (err) return self.error(err.message, 1007); + if (buffer != null) self.currentMessage.push(buffer); + + if (state.lastFragment) { + var messageBuffer = self.concatBuffers(self.currentMessage); + self.currentMessage = []; + if (!Validation.isValidUTF8(messageBuffer)) { + self.error('invalid utf8 sequence', 1007); + return; + } + self.ontext(messageBuffer.toString('utf8'), {masked: state.masked, buffer: messageBuffer}); + } + callback(); + }); + }); + this.flush(); this.endPacket(); } }, @@ -435,13 +520,22 @@ var opcodes = { } }, finish: function(mask, data) { - var packet = this.unmask(mask, data, true); - if (packet != null) this.currentMessage.push(packet); - if (this.state.lastFragment) { - var messageBuffer = this.concatBuffers(this.currentMessage); - this.onbinary(messageBuffer, {masked: this.state.masked, buffer: messageBuffer}); - this.currentMessage = []; - } + var self = this; + var packet = this.unmask(mask, data, true) || new Buffer(0); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.applyExtensions(packet, state.lastFragment, state.compressed, function(err, buffer) { + if (err) return self.error(err.message, 1007); + if (buffer != null) self.currentMessage.push(buffer); + if (state.lastFragment) { + var messageBuffer = self.concatBuffers(self.currentMessage); + self.currentMessage = []; + self.onbinary(messageBuffer, {masked: state.masked, buffer: messageBuffer}); + } + callback(); + }); + }); + this.flush(); this.endPacket(); } }, @@ -482,26 +576,31 @@ var opcodes = { finish: function(mask, data) { var self = this; data = self.unmask(mask, data, true); - if (data && data.length == 1) { - self.error('close packets with data must be at least two bytes long', 1002); - return; - } - var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; - if (!ErrorCodes.isValidErrorCode(code)) { - self.error('invalid error code', 1002); - return; - } - var message = ''; - if (data && data.length > 2) { - var messageBuffer = data.slice(2); - if (!Validation.isValidUTF8(messageBuffer)) { - self.error('invalid utf8 sequence', 1007); + + var state = clone(this.state); + this.messageHandlers.push(function() { + if (data && data.length == 1) { + self.error('close packets with data must be at least two bytes long', 1002); return; } - message = messageBuffer.toString('utf8'); - } - this.onclose(code, message, {masked: self.state.masked}); - this.reset(); + var code = data && data.length > 1 ? readUInt16BE.call(data, 0) : 1000; + if (!ErrorCodes.isValidErrorCode(code)) { + self.error('invalid error code', 1002); + return; + } + var message = ''; + if (data && data.length > 2) { + var messageBuffer = data.slice(2); + if (!Validation.isValidUTF8(messageBuffer)) { + self.error('invalid utf8 sequence', 1007); + return; + } + message = messageBuffer.toString('utf8'); + } + self.onclose(code, message, {masked: state.masked}); + self.reset(); + }); + this.flush(); }, }, // ping @@ -539,7 +638,14 @@ var opcodes = { } }, finish: function(mask, data) { - this.onping(this.unmask(mask, data, true), {masked: this.state.masked, binary: true}); + var self = this; + data = this.unmask(mask, data, true); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.onping(data, {masked: state.masked, binary: true}); + callback(); + }); + this.flush(); this.endPacket(); } }, @@ -578,7 +684,14 @@ var opcodes = { } }, finish: function(mask, data) { - this.onpong(this.unmask(mask, data, true), {masked: this.state.masked, binary: true}); + var self = this; + data = self.unmask(mask, data, true); + var state = clone(this.state); + this.messageHandlers.push(function(callback) { + self.onpong(data, {masked: state.masked, binary: true}); + callback(); + }); + this.flush(); this.endPacket(); } } diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.hixie.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.hixie.js index c715dbd..fd2fd25 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.hixie.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.hixie.js @@ -13,6 +13,8 @@ var events = require('events') */ function Sender(socket) { + events.EventEmitter.call(this); + this.socket = socket; this.continuationFrame = false; this.isClosed = false; diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.js index bc6ea73..f346748 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/Sender.js @@ -8,15 +8,22 @@ var events = require('events') , util = require('util') , EventEmitter = events.EventEmitter , ErrorCodes = require('./ErrorCodes') - , bufferUtil = require('./BufferUtil').BufferUtil; + , bufferUtil = require('./BufferUtil').BufferUtil + , PerMessageDeflate = require('./PerMessageDeflate'); /** * HyBi Sender implementation */ -function Sender(socket) { +function Sender(socket, extensions) { + events.EventEmitter.call(this); + this._socket = socket; + this.extensions = extensions || {}; this.firstFragment = true; + this.compress = false; + this.messageHandlers = []; + this.processing = false; } /** @@ -31,7 +38,7 @@ util.inherits(Sender, events.EventEmitter); * @api public */ -Sender.prototype.close = function(code, data, mask) { +Sender.prototype.close = function(code, data, mask, cb) { if (typeof code !== 'undefined') { if (typeof code !== 'number' || !ErrorCodes.isValidErrorCode(code)) throw new Error('first argument must be a valid error code number'); @@ -40,7 +47,14 @@ Sender.prototype.close = function(code, data, mask) { var dataBuffer = new Buffer(2 + (data ? Buffer.byteLength(data) : 0)); writeUInt16BE.call(dataBuffer, code, 0); if (dataBuffer.length > 2) dataBuffer.write(data, 2); - this.frameAndSend(0x8, dataBuffer, true, mask); + + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0x8, dataBuffer, true, mask); + callback(); + if (typeof cb == 'function') cb(); + }); + this.flush(); }; /** @@ -51,7 +65,12 @@ Sender.prototype.close = function(code, data, mask) { Sender.prototype.ping = function(data, options) { var mask = options && options.mask; - this.frameAndSend(0x9, data || '', true, mask); + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0x9, data || '', true, mask); + callback(); + }); + this.flush(); }; /** @@ -62,7 +81,12 @@ Sender.prototype.ping = function(data, options) { Sender.prototype.pong = function(data, options) { var mask = options && options.mask; - this.frameAndSend(0xa, data || '', true, mask); + var self = this; + this.messageHandlers.push(function(callback) { + self.frameAndSend(0xa, data || '', true, mask); + callback(); + }); + this.flush(); }; /** @@ -74,11 +98,32 @@ Sender.prototype.pong = function(data, options) { Sender.prototype.send = function(data, options, cb) { var finalFragment = options && options.fin === false ? false : true; var mask = options && options.mask; + var compress = options && options.compress; var opcode = options && options.binary ? 2 : 1; - if (this.firstFragment === false) opcode = 0; - else this.firstFragment = false; + if (this.firstFragment === false) { + opcode = 0; + compress = false; + } else { + this.firstFragment = false; + this.compress = compress; + } if (finalFragment) this.firstFragment = true - this.frameAndSend(opcode, data, finalFragment, mask, cb); + + var compressFragment = this.compress; + + var self = this; + this.messageHandlers.push(function(callback) { + self.applyExtensions(data, finalFragment, compressFragment, function(err, data) { + if (err) { + if (typeof cb == 'function') cb(err); + else self.emit('error', err); + return; + } + self.frameAndSend(opcode, data, finalFragment, mask, compress, cb); + callback(); + }); + }); + this.flush(); }; /** @@ -87,7 +132,7 @@ Sender.prototype.send = function(data, options, cb) { * @api private */ -Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, cb) { +Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, compressed, cb) { var canModifyData = false; if (!data) { @@ -127,6 +172,7 @@ Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, var totalLength = mergeBuffers ? dataLength + dataOffset : dataOffset; var outputBuffer = new Buffer(totalLength); outputBuffer[0] = finalFragment ? opcode | 0x80 : opcode; + if (compressed) outputBuffer[0] |= 0x40; switch (secondByte) { case 126: @@ -191,6 +237,42 @@ Sender.prototype.frameAndSend = function(opcode, data, finalFragment, maskData, } }; +/** + * Execute message handler buffers + * + * @api private + */ + +Sender.prototype.flush = function() { + if (this.processing) return; + + var handler = this.messageHandlers.shift(); + if (!handler) return; + + this.processing = true; + + var self = this; + + handler(function() { + self.processing = false; + self.flush(); + }); +}; + +/** + * Apply extensions to message + * + * @api private + */ + +Sender.prototype.applyExtensions = function(data, fin, compress, callback) { + if (compress && data) { + this.extensions[PerMessageDeflate.extensionName].compress(data, fin, callback); + } else { + callback(null, data); + } +}; + module.exports = Sender; function writeUInt16BE(value, offset) { diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/Validation.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/Validation.js index 0f3109a..0795fb7 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/Validation.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/Validation.js @@ -1,3 +1,5 @@ +'use strict'; + /*! * ws: a node.js websocket client * Copyright(c) 2011 Einar Otto Stangvik @@ -5,12 +7,7 @@ */ try { - module.exports = require('../build/Release/validation'); -} catch (e) { try { - module.exports = require('../build/default/validation'); -} catch (e) { try { - module.exports = require('./Validation.fallback'); + module.exports = require('utf-8-validate'); } catch (e) { - console.error('validation.node seems to not have been built. Run npm install.'); - throw e; -}}} + module.exports = require('./Validation.fallback'); +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocket.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocket.js index 8c304eb..bc3f84a 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocket.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocket.js @@ -1,21 +1,26 @@ +'use strict'; + /*! * ws: a node.js websocket client * Copyright(c) 2011 Einar Otto Stangvik * MIT Licensed */ -var util = require('util') - , events = require('events') +var url = require('url') + , util = require('util') , http = require('http') , https = require('https') , crypto = require('crypto') - , url = require('url') , stream = require('stream') + , Ultron = require('ultron') , Options = require('options') , Sender = require('./Sender') , Receiver = require('./Receiver') , SenderHixie = require('./Sender.hixie') - , ReceiverHixie = require('./Receiver.hixie'); + , ReceiverHixie = require('./Receiver.hixie') + , Extensions = require('./Extensions') + , PerMessageDeflate = require('./PerMessageDeflate') + , EventEmitter = require('events').EventEmitter; /** * Constants @@ -27,31 +32,41 @@ var protocolVersion = 13; // Close timeout -var closeTimeout = 30000; // Allow 5 seconds to terminate the connection cleanly +var closeTimeout = 30 * 1000; // Allow 30 seconds to terminate the connection cleanly /** * WebSocket implementation + * + * @constructor + * @param {String} address Connection address. + * @param {String|Array} protocols WebSocket protocols. + * @param {Object} options Additional connection options. + * @api public */ - function WebSocket(address, protocols, options) { + EventEmitter.call(this); - if (protocols && !Array.isArray(protocols) && 'object' == typeof protocols) { + if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) { // accept the "options" Object as the 2nd argument options = protocols; protocols = null; } - if ('string' == typeof protocols) { + + if ('string' === typeof protocols) { protocols = [ protocols ]; } + if (!Array.isArray(protocols)) { protocols = []; } - // TODO: actually handle the `Sub-Protocols` part of the WebSocket client this._socket = null; + this._ultron = null; + this._closeReceived = false; this.bytesReceived = 0; this.readyState = null; this.supports = {}; + this.extensions = {}; if (Array.isArray(address)) { initAsServerClient.apply(this, address.concat(options)); @@ -63,14 +78,12 @@ function WebSocket(address, protocols, options) { /** * Inherits from EventEmitter. */ - -util.inherits(WebSocket, events.EventEmitter); +util.inherits(WebSocket, EventEmitter); /** * Ready States */ - -["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function (state, index) { +["CONNECTING", "OPEN", "CLOSING", "CLOSED"].forEach(function each(state, index) { WebSocket.prototype[state] = WebSocket[state] = index; }); @@ -80,38 +93,53 @@ util.inherits(WebSocket, events.EventEmitter); * @param {Object} data to be sent to the server * @api public */ +WebSocket.prototype.close = function close(code, data) { + if (this.readyState === WebSocket.CLOSED) return; -WebSocket.prototype.close = function(code, data) { - if (this.readyState == WebSocket.CLOSING || this.readyState == WebSocket.CLOSED) return; - if (this.readyState == WebSocket.CONNECTING) { + if (this.readyState === WebSocket.CONNECTING) { this.readyState = WebSocket.CLOSED; return; } + + if (this.readyState === WebSocket.CLOSING) { + if (this._closeReceived && this._isServer) { + this.terminate(); + } + return; + } + + var self = this; try { this.readyState = WebSocket.CLOSING; this._closeCode = code; this._closeMessage = data; var mask = !this._isServer; - this._sender.close(code, data, mask); - } - catch (e) { + this._sender.close(code, data, mask, function(err) { + if (err) self.emit('error', err); + + if (self._closeReceived && self._isServer) { + self.terminate(); + } else { + // ensure that the connection is cleaned up even when no response of closing handshake. + clearTimeout(self._closeTimer); + self._closeTimer = setTimeout(cleanupWebsocketResources.bind(self, true), closeTimeout); + } + }); + } catch (e) { this.emit('error', e); } - finally { - this.terminate(); - } -} +}; /** * Pause the client stream * * @api public */ +WebSocket.prototype.pause = function pauser() { + if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); -WebSocket.prototype.pause = function() { - if (this.readyState != WebSocket.OPEN) throw new Error('not opened'); return this._socket.pause(); -} +}; /** * Sends a ping @@ -121,16 +149,18 @@ WebSocket.prototype.pause = function() { * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open * @api public */ - -WebSocket.prototype.ping = function(data, options, dontFailWhenClosed) { - if (this.readyState != WebSocket.OPEN) { +WebSocket.prototype.ping = function ping(data, options, dontFailWhenClosed) { + if (this.readyState !== WebSocket.OPEN) { if (dontFailWhenClosed === true) return; throw new Error('not opened'); } + options = options || {}; - if (typeof options.mask == 'undefined') options.mask = !this._isServer; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + this._sender.ping(data, options); -} +}; /** * Sends a pong @@ -140,56 +170,62 @@ WebSocket.prototype.ping = function(data, options, dontFailWhenClosed) { * @param {boolean} dontFailWhenClosed indicates whether or not to throw if the connection isnt open * @api public */ - WebSocket.prototype.pong = function(data, options, dontFailWhenClosed) { - if (this.readyState != WebSocket.OPEN) { + if (this.readyState !== WebSocket.OPEN) { if (dontFailWhenClosed === true) return; throw new Error('not opened'); } + options = options || {}; - if (typeof options.mask == 'undefined') options.mask = !this._isServer; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + this._sender.pong(data, options); -} +}; /** * Resume the client stream * * @api public */ +WebSocket.prototype.resume = function resume() { + if (this.readyState !== WebSocket.OPEN) throw new Error('not opened'); -WebSocket.prototype.resume = function() { - if (this.readyState != WebSocket.OPEN) throw new Error('not opened'); return this._socket.resume(); -} +}; /** * Sends a piece of data * * @param {Object} data to be sent to the server - * @param {Object} Members - mask: boolean, binary: boolean + * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean * @param {function} Optional callback which is executed after the send completes * @api public */ -WebSocket.prototype.send = function(data, options, cb) { - if (typeof options == 'function') { +WebSocket.prototype.send = function send(data, options, cb) { + if (typeof options === 'function') { cb = options; options = {}; } - if (this.readyState != WebSocket.OPEN) { - if (typeof cb == 'function') cb(new Error('not opened')); + + if (this.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); else throw new Error('not opened'); return; } + if (!data) data = ''; if (this._queue) { var self = this; this._queue.push(function() { self.send(data, options, cb); }); return; } + options = options || {}; options.fin = true; - if (typeof options.binary == 'undefined') { + + if (typeof options.binary === 'undefined') { options.binary = (data instanceof ArrayBuffer || data instanceof Buffer || data instanceof Uint8Array || data instanceof Uint16Array || @@ -200,78 +236,103 @@ WebSocket.prototype.send = function(data, options, cb) { data instanceof Float32Array || data instanceof Float64Array); } - if (typeof options.mask == 'undefined') options.mask = !this._isServer; - var readable = typeof stream.Readable == 'function' ? stream.Readable : stream.Stream; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + if (typeof options.compress === 'undefined') options.compress = true; + if (!this.extensions[PerMessageDeflate.extensionName]) { + options.compress = false; + } + + var readable = typeof stream.Readable === 'function' + ? stream.Readable + : stream.Stream; + if (data instanceof readable) { startQueue(this); var self = this; - sendStream(this, data, options, function(error) { - process.nextTick(function() { executeQueueSends(self); }); - if (typeof cb == 'function') cb(error); + + sendStream(this, data, options, function send(error) { + process.nextTick(function tock() { + executeQueueSends(self); + }); + + if (typeof cb === 'function') cb(error); }); + } else { + this._sender.send(data, options, cb); } - else this._sender.send(data, options, cb); -} +}; /** * Streams data through calls to a user supplied function * - * @param {Object} Members - mask: boolean, binary: boolean + * @param {Object} Members - mask: boolean, binary: boolean, compress: boolean * @param {function} 'function (error, send)' which is executed on successive ticks of which send is 'function (data, final)'. * @api public */ - -WebSocket.prototype.stream = function(options, cb) { - if (typeof options == 'function') { +WebSocket.prototype.stream = function stream(options, cb) { + if (typeof options === 'function') { cb = options; options = {}; } + var self = this; - if (typeof cb != 'function') throw new Error('callback must be provided'); - if (this.readyState != WebSocket.OPEN) { - if (typeof cb == 'function') cb(new Error('not opened')); + + if (typeof cb !== 'function') throw new Error('callback must be provided'); + + if (this.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); else throw new Error('not opened'); return; } + if (this._queue) { - this._queue.push(function() { self.stream(options, cb); }); + this._queue.push(function () { self.stream(options, cb); }); return; } + options = options || {}; - if (typeof options.mask == 'undefined') options.mask = !this._isServer; + + if (typeof options.mask === 'undefined') options.mask = !this._isServer; + if (typeof options.compress === 'undefined') options.compress = true; + if (!this.extensions[PerMessageDeflate.extensionName]) { + options.compress = false; + } + startQueue(this); - var send = function(data, final) { + + function send(data, final) { try { - if (self.readyState != WebSocket.OPEN) throw new Error('not opened'); + if (self.readyState !== WebSocket.OPEN) throw new Error('not opened'); options.fin = final === true; self._sender.send(data, options); if (!final) process.nextTick(cb.bind(null, null, send)); else executeQueueSends(self); - } - catch (e) { - if (typeof cb == 'function') cb(e); + } catch (e) { + if (typeof cb === 'function') cb(e); else { delete self._queue; self.emit('error', e); } } } + process.nextTick(cb.bind(null, null, send)); -} +}; /** * Immediately shuts down the connection * * @api public */ +WebSocket.prototype.terminate = function terminate() { + if (this.readyState === WebSocket.CLOSED) return; -WebSocket.prototype.terminate = function() { - if (this.readyState == WebSocket.CLOSED) return; if (this._socket) { - try { - // End the connection - this._socket.end(); - } + this.readyState = WebSocket.CLOSING; + + // End the connection + try { this._socket.end(); } catch (e) { // Socket error during end() call, so just destroy it right now cleanupWebsocketResources.call(this, true); @@ -281,9 +342,12 @@ WebSocket.prototype.terminate = function() { // Add a timeout to ensure that the connection is completely // cleaned up within 30 seconds, even if the clean close procedure // fails for whatever reason + // First cleanup any pre-existing timeout from an earlier "terminate" call, + // if one exists. Otherwise terminate calls in quick succession will leak timeouts + // and hold the program open for `closeTimout` time. + if (this._closeTimer) { clearTimeout(this._closeTimer); } this._closeTimer = setTimeout(cleanupWebsocketResources.bind(this, true), closeTimeout); - } - else if (this.readyState == WebSocket.CONNECTING) { + } else if (this.readyState === WebSocket.CONNECTING) { cleanupWebsocketResources.call(this, true); } }; @@ -293,7 +357,6 @@ WebSocket.prototype.terminate = function() { * * @api public */ - Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { get: function get() { var amount = 0; @@ -310,7 +373,6 @@ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { * @see http://dev.w3.org/html5/websockets/#the-websocket-interface * @api public */ - ['open', 'error', 'close', 'message'].forEach(function(method) { Object.defineProperty(WebSocket.prototype, 'on' + method, { /** @@ -319,7 +381,6 @@ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { * @returns {Mixed} the set function or undefined * @api public */ - get: function get() { var listener = this.listeners(method)[0]; return listener ? (listener._listener ? listener._listener : listener) : undefined; @@ -332,7 +393,6 @@ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { * @returns {Mixed} the set function or undefined * @api public */ - set: function set(listener) { this.removeAllListeners(method); this.addEventListener(method, listener); @@ -349,41 +409,50 @@ Object.defineProperty(WebSocket.prototype, 'bufferedAmount', { */ WebSocket.prototype.addEventListener = function(method, listener) { var target = this; + + function onMessage (data, flags) { + listener.call(target, new MessageEvent(data, flags.binary ? 'Binary' : 'Text', target)); + } + + function onClose (code, message) { + listener.call(target, new CloseEvent(code, message, target)); + } + + function onError (event) { + event.target = target; + listener.call(target, event); + } + + function onOpen () { + listener.call(target, new OpenEvent(target)); + } + if (typeof listener === 'function') { if (method === 'message') { - function onMessage (data, flags) { - listener.call(this, new MessageEvent(data, flags.binary ? 'Binary' : 'Text', target)); - } - // store a reference so we can return the original function from the addEventListener hook + // store a reference so we can return the original function from the + // addEventListener hook onMessage._listener = listener; this.on(method, onMessage); } else if (method === 'close') { - function onClose (code, message) { - listener.call(this, new CloseEvent(code, message, target)); - } - // store a reference so we can return the original function from the addEventListener hook + // store a reference so we can return the original function from the + // addEventListener hook onClose._listener = listener; this.on(method, onClose); } else if (method === 'error') { - function onError (event) { - event.target = target; - listener.call(this, event); - } - // store a reference so we can return the original function from the addEventListener hook + // store a reference so we can return the original function from the + // addEventListener hook onError._listener = listener; this.on(method, onError); } else if (method === 'open') { - function onOpen () { - listener.call(this, new OpenEvent(target)); - } - // store a reference so we can return the original function from the addEventListener hook + // store a reference so we can return the original function from the + // addEventListener hook onOpen._listener = listener; this.on(method, onOpen); } else { this.on(method, listener); } } -} +}; module.exports = WebSocket; @@ -391,9 +460,9 @@ module.exports = WebSocket; * W3C MessageEvent * * @see http://www.w3.org/TR/html5/comms.html + * @constructor * @api private */ - function MessageEvent(dataArg, typeArg, target) { this.data = dataArg; this.type = typeArg; @@ -404,11 +473,11 @@ function MessageEvent(dataArg, typeArg, target) { * W3C CloseEvent * * @see http://www.w3.org/TR/html5/comms.html + * @constructor * @api private */ - function CloseEvent(code, reason, target) { - this.wasClean = (typeof code == 'undefined' || code == 1000); + this.wasClean = (typeof code === 'undefined' || code === 1000); this.code = code; this.reason = reason; this.target = target; @@ -418,9 +487,9 @@ function CloseEvent(code, reason, target) { * W3C OpenEvent * * @see http://www.w3.org/TR/html5/comms.html + * @constructor * @api private */ - function OpenEvent(target) { this.target = target; } @@ -429,24 +498,28 @@ function OpenEvent(target) { * Entirely private apis, * which may or may not be bound to a sepcific WebSocket instance. */ - function initAsServerClient(req, socket, upgradeHead, options) { options = new Options({ protocolVersion: protocolVersion, - protocol: null + protocol: null, + extensions: {} }).merge(options); // expose state properties this.protocol = options.value.protocol; this.protocolVersion = options.value.protocolVersion; - this.supports.binary = (this.protocolVersion != 'hixie-76'); + this.extensions = options.value.extensions; + this.supports.binary = (this.protocolVersion !== 'hixie-76'); this.upgradeReq = req; this.readyState = WebSocket.CONNECTING; this._isServer = true; // establish connection - if (options.value.protocolVersion == 'hixie-76') establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); - else establishConnection.call(this, Receiver, Sender, socket, upgradeHead); + if (options.value.protocolVersion === 'hixie-76') { + establishConnection.call(this, ReceiverHixie, SenderHixie, socket, upgradeHead); + } else { + establishConnection.call(this, Receiver, Sender, socket, upgradeHead); + } } function initAsClient(address, protocols, options) { @@ -455,7 +528,7 @@ function initAsClient(address, protocols, options) { protocolVersion: protocolVersion, host: null, headers: null, - protocol: null, + protocol: protocols.join(','), agent: null, // ssl-related options @@ -465,13 +538,15 @@ function initAsClient(address, protocols, options) { cert: null, ca: null, ciphers: null, - rejectUnauthorized: null + rejectUnauthorized: null, + perMessageDeflate: true }).merge(options); - if (options.value.protocolVersion != 8 && options.value.protocolVersion != 13) { + + if (options.value.protocolVersion !== 8 && options.value.protocolVersion !== 13) { throw new Error('unsupported protocol version'); } - // verify url and establish http class + // verify URL and establish http class var serverUrl = url.parse(address); var isUnixSocket = serverUrl.protocol === 'ws+unix:'; if (!serverUrl.host && !isUnixSocket) throw new Error('invalid url'); @@ -480,11 +555,19 @@ function initAsClient(address, protocols, options) { var port = serverUrl.port || (isSecure ? 443 : 80); var auth = serverUrl.auth; + // prepare extensions + var extensionsOffer = {}; + var perMessageDeflate; + if (options.value.perMessageDeflate) { + perMessageDeflate = new PerMessageDeflate(typeof options.value.perMessageDeflate !== true ? options.value.perMessageDeflate : {}, false); + extensionsOffer[PerMessageDeflate.extensionName] = perMessageDeflate.offer(); + } + // expose state properties this._isServer = false; this.url = address; this.protocolVersion = options.value.protocolVersion; - this.supports.binary = (this.protocolVersion != 'hixie-76'); + this.supports.binary = (this.protocolVersion !== 'hixie-76'); // begin handshake var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64'); @@ -495,9 +578,10 @@ function initAsClient(address, protocols, options) { var agent = options.value.agent; var headerHost = serverUrl.hostname; - // Append port number to Host and Origin header, only if specified in the url and non-default - if(serverUrl.port) { - if((isSecure && (port != 443)) || (!isSecure && (port != 80))){ + // Append port number to Host and Origin header, only if specified in the url + // and non-default + if (serverUrl.port) { + if ((isSecure && (port !== 443)) || (!isSecure && (port !== 80))){ headerHost = headerHost + ':' + port; } } @@ -517,7 +601,7 @@ function initAsClient(address, protocols, options) { // If we have basic auth. if (auth) { - requestOptions.headers['Authorization'] = 'Basic ' + new Buffer(auth).toString('base64'); + requestOptions.headers.Authorization = 'Basic ' + new Buffer(auth).toString('base64'); } if (options.value.protocol) { @@ -525,7 +609,7 @@ function initAsClient(address, protocols, options) { } if (options.value.host) { - requestOptions.headers['Host'] = options.value.host; + requestOptions.headers.Host = options.value.host; } if (options.value.headers) { @@ -536,6 +620,10 @@ function initAsClient(address, protocols, options) { } } + if (Object.keys(extensionsOffer).length) { + requestOptions.headers['Sec-WebSocket-Extensions'] = Extensions.format(extensionsOffer); + } + if (options.isDefinedAndNonNull('pfx') || options.isDefinedAndNonNull('key') || options.isDefinedAndNonNull('passphrase') @@ -569,36 +657,40 @@ function initAsClient(address, protocols, options) { } if (options.value.origin) { if (options.value.protocolVersion < 13) requestOptions.headers['Sec-WebSocket-Origin'] = options.value.origin; - else requestOptions.headers['Origin'] = options.value.origin; + else requestOptions.headers.Origin = options.value.origin; } var self = this; var req = httpObj.request(requestOptions); - req.on('error', function(error) { + req.on('error', function onerror(error) { self.emit('error', error); cleanupWebsocketResources.call(this, error); }); - req.once('response', function(res) { + req.once('response', function response(res) { + var error; + if (!self.emit('unexpected-response', req, res)) { - var error = new Error('unexpected server response (' + res.statusCode + ')'); + error = new Error('unexpected server response (' + res.statusCode + ')'); req.abort(); self.emit('error', error); } + cleanupWebsocketResources.call(this, error); }); - req.once('upgrade', function(res, socket, upgradeHead) { - if (self.readyState == WebSocket.CLOSED) { + req.once('upgrade', function upgrade(res, socket, upgradeHead) { + if (self.readyState === WebSocket.CLOSED) { // client closed before server accepted connection self.emit('close'); self.removeAllListeners(); socket.end(); return; } + var serverKey = res.headers['sec-websocket-accept']; - if (typeof serverKey == 'undefined' || serverKey !== expectedServerKey) { + if (typeof serverKey === 'undefined' || serverKey !== expectedServerKey) { self.emit('error', 'invalid server key'); self.removeAllListeners(); socket.end(); @@ -608,20 +700,35 @@ function initAsClient(address, protocols, options) { var serverProt = res.headers['sec-websocket-protocol']; var protList = (options.value.protocol || "").split(/, */); var protError = null; + if (!options.value.protocol && serverProt) { - protError = 'server sent a subprotocol even though none requested'; + protError = 'server sent a subprotocol even though none requested'; } else if (options.value.protocol && !serverProt) { - protError = 'server sent no subprotocol even though requested'; + protError = 'server sent no subprotocol even though requested'; } else if (serverProt && protList.indexOf(serverProt) === -1) { - protError = 'server responded with an invalid protocol'; + protError = 'server responded with an invalid protocol'; } + if (protError) { - self.emit('error', protError); + self.emit('error', protError); + self.removeAllListeners(); + socket.end(); + return; + } else if (serverProt) { + self.protocol = serverProt; + } + + var serverExtensions = Extensions.parse(res.headers['sec-websocket-extensions']); + if (perMessageDeflate && serverExtensions[PerMessageDeflate.extensionName]) { + try { + perMessageDeflate.accept(serverExtensions[PerMessageDeflate.extensionName]); + } catch (err) { + self.emit('error', 'invalid extension parameter'); self.removeAllListeners(); socket.end(); return; - } else if (serverProt) { - self.protocol = serverProt; + } + self.extensions[PerMessageDeflate.extensionName] = perMessageDeflate; } establishConnection.call(self, Receiver, Sender, socket, upgradeHead); @@ -637,38 +744,46 @@ function initAsClient(address, protocols, options) { } function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { + var ultron = this._ultron = new Ultron(socket); this._socket = socket; + socket.setTimeout(0); socket.setNoDelay(true); var self = this; - this._receiver = new ReceiverClass(); + this._receiver = new ReceiverClass(this.extensions); // socket cleanup handlers - socket.on('end', cleanupWebsocketResources.bind(this)); - socket.on('close', cleanupWebsocketResources.bind(this)); - socket.on('error', cleanupWebsocketResources.bind(this)); + ultron.on('end', cleanupWebsocketResources.bind(this)); + ultron.on('close', cleanupWebsocketResources.bind(this)); + ultron.on('error', cleanupWebsocketResources.bind(this)); // ensure that the upgradeHead is added to the receiver function firstHandler(data) { - if (self.readyState != WebSocket.OPEN) return; + if (self.readyState !== WebSocket.OPEN && self.readyState !== WebSocket.CLOSING) return; + if (upgradeHead && upgradeHead.length > 0) { self.bytesReceived += upgradeHead.length; var head = upgradeHead; upgradeHead = null; self._receiver.add(head); } + dataHandler = realHandler; + if (data) { self.bytesReceived += data.length; self._receiver.add(data); } } + // subsequent packets are pushed straight to the receiver function realHandler(data) { if (data) self.bytesReceived += data.length; self._receiver.add(data); } + var dataHandler = firstHandler; + // if data was passed along with the http upgrade, // this will schedule a push of that on to the receiver. // this has to be done on next tick, since the caller @@ -677,43 +792,58 @@ function establishConnection(ReceiverClass, SenderClass, socket, upgradeHead) { process.nextTick(firstHandler); // receiver event handlers - self._receiver.ontext = function (data, flags) { + self._receiver.ontext = function ontext(data, flags) { flags = flags || {}; + self.emit('message', data, flags); }; - self._receiver.onbinary = function (data, flags) { + + self._receiver.onbinary = function onbinary(data, flags) { flags = flags || {}; + flags.binary = true; self.emit('message', data, flags); }; - self._receiver.onping = function(data, flags) { + + self._receiver.onping = function onping(data, flags) { flags = flags || {}; - self.pong(data, {mask: !self._isServer, binary: flags.binary === true}, true); + + self.pong(data, { + mask: !self._isServer, + binary: flags.binary === true + }, true); + self.emit('ping', data, flags); }; - self._receiver.onpong = function(data, flags) { - self.emit('pong', data, flags); + + self._receiver.onpong = function onpong(data, flags) { + self.emit('pong', data, flags || {}); }; - self._receiver.onclose = function(code, data, flags) { + + self._receiver.onclose = function onclose(code, data, flags) { flags = flags || {}; + + self._closeReceived = true; self.close(code, data); }; - self._receiver.onerror = function(reason, errorCode) { + + self._receiver.onerror = function onerror(reason, errorCode) { // close the connection when the receiver reports a HyBi error code - self.close(typeof errorCode != 'undefined' ? errorCode : 1002, ''); + self.close(typeof errorCode !== 'undefined' ? errorCode : 1002, ''); self.emit('error', reason, errorCode); }; // finalize the client - this._sender = new SenderClass(socket); - this._sender.on('error', function(error) { + this._sender = new SenderClass(socket, this.extensions); + this._sender.on('error', function onerror(error) { self.close(1002, ''); self.emit('error', error); }); + this.readyState = WebSocket.OPEN; this.emit('open'); - socket.on('data', dataHandler); + ultron.on('data', dataHandler); } function startQueue(instance) { @@ -722,7 +852,8 @@ function startQueue(instance) { function executeQueueSends(instance) { var queue = instance._queue; - if (typeof queue == 'undefined') return; + if (typeof queue === 'undefined') return; + delete instance._queue; for (var i = 0, l = queue.length; i < l; ++i) { queue[i](); @@ -730,65 +861,77 @@ function executeQueueSends(instance) { } function sendStream(instance, stream, options, cb) { - stream.on('data', function(data) { - if (instance.readyState != WebSocket.OPEN) { - if (typeof cb == 'function') cb(new Error('not opened')); + stream.on('data', function incoming(data) { + if (instance.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); else { delete instance._queue; instance.emit('error', new Error('not opened')); } return; } + options.fin = false; instance._sender.send(data, options); }); - stream.on('end', function() { - if (instance.readyState != WebSocket.OPEN) { - if (typeof cb == 'function') cb(new Error('not opened')); + + stream.on('end', function end() { + if (instance.readyState !== WebSocket.OPEN) { + if (typeof cb === 'function') cb(new Error('not opened')); else { delete instance._queue; instance.emit('error', new Error('not opened')); } return; } + options.fin = true; instance._sender.send(null, options); - if (typeof cb == 'function') cb(null); + + if (typeof cb === 'function') cb(null); }); } function cleanupWebsocketResources(error) { - if (this.readyState == WebSocket.CLOSED) return; - var emitClose = this.readyState != WebSocket.CONNECTING; + if (this.readyState === WebSocket.CLOSED) return; + + var emitClose = this.readyState !== WebSocket.CONNECTING; this.readyState = WebSocket.CLOSED; clearTimeout(this._closeTimer); this._closeTimer = null; - if (emitClose) this.emit('close', this._closeCode || 1000, this._closeMessage || ''); + + if (emitClose) { + this.emit('close', this._closeCode || 1000, this._closeMessage || ''); + } if (this._socket) { - this._socket.removeAllListeners(); - // catch all socket error after removing all standard handlers - var socket = this._socket; - this._socket.on('error', function() { - try { socket.destroy(); } catch (e) {} + if (this._ultron) this._ultron.destroy(); + this._socket.on('error', function onerror() { + try { this.destroy(); } + catch (e) {} }); + try { if (!error) this._socket.end(); else this._socket.destroy(); - } - catch (e) { /* Ignore termination errors */ } + } catch (e) { /* Ignore termination errors */ } + this._socket = null; + this._ultron = null; } + if (this._sender) { this._sender.removeAllListeners(); this._sender = null; } + if (this._receiver) { this._receiver.cleanup(); this._receiver = null; } + this.removeAllListeners(); - this.on('error', function() {}); // catch all errors after this + this.on('error', function onerror() {}); // catch all errors after this delete this._queue; } diff --git a/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocketServer.js b/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocketServer.js index 5cbd195..a2f3a61 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocketServer.js +++ b/node_modules/auto-reload-brunch/node_modules/ws/lib/WebSocketServer.js @@ -10,6 +10,8 @@ var util = require('util') , crypto = require('crypto') , Options = require('options') , WebSocket = require('./WebSocket') + , Extensions = require('./Extensions') + , PerMessageDeflate = require('./PerMessageDeflate') , tls = require('tls') , url = require('url'); @@ -18,6 +20,8 @@ var util = require('util') */ function WebSocketServer(options, callback) { + events.EventEmitter.call(this); + options = new Options({ host: '0.0.0.0', port: null, @@ -27,7 +31,8 @@ function WebSocketServer(options, callback) { path: null, noServer: false, disableHixie: false, - clientTracking: true + clientTracking: true, + perMessageDeflate: true }).merge(options); if (!options.isDefinedAndNonNull('port') && !options.isDefinedAndNonNull('server') && !options.value.noServer) { @@ -182,6 +187,9 @@ function handleHybiUpgrade(req, socket, upgradeHead, cb) { req.headers['sec-websocket-origin'] : req.headers['origin']; + // handle extensions offer + var extensionsOffer = Extensions.parse(req.headers['sec-websocket-extensions']); + // handler to call when the connection sequence completes var self = this; var completeHybiUpgrade2 = function(protocol) { @@ -203,6 +211,22 @@ function handleHybiUpgrade(req, socket, upgradeHead, cb) { headers.push('Sec-WebSocket-Protocol: ' + protocol); } + var extensions = {}; + try { + extensions = acceptExtensions.call(self, extensionsOffer); + } catch (err) { + abortConnection(socket, 400, 'Bad Request'); + return; + } + + if (Object.keys(extensions).length) { + var serverExtensions = {}; + Object.keys(extensions).forEach(function(token) { + serverExtensions[token] = [extensions[token].params] + }); + headers.push('Sec-WebSocket-Extensions: ' + Extensions.format(serverExtensions)); + } + // allows external modification/inspection of handshake headers self.emit('headers', headers); @@ -219,7 +243,8 @@ function handleHybiUpgrade(req, socket, upgradeHead, cb) { var client = new WebSocket([req, socket, upgradeHead], { protocolVersion: version, - protocol: protocol + protocol: protocol, + extensions: extensions }); if (self.options.clientTracking) { @@ -246,7 +271,7 @@ function handleHybiUpgrade(req, socket, upgradeHead, cb) { var callbackCalled = false; var res = self.options.handleProtocols(protList, function(result, protocol) { callbackCalled = true; - if (!result) abortConnection(socket, 404, 'Unauthorized') + if (!result) abortConnection(socket, 401, 'Unauthorized'); else completeHybiUpgrade2(protocol); }); if (!callbackCalled) { @@ -449,6 +474,17 @@ function handleHixieUpgrade(req, socket, upgradeHead, cb) { onClientVerified(); } +function acceptExtensions(offer) { + var extensions = {}; + var options = this.options.perMessageDeflate; + if (options && offer[PerMessageDeflate.extensionName]) { + var perMessageDeflate = new PerMessageDeflate(options !== true ? options : {}, true); + perMessageDeflate.accept(offer[PerMessageDeflate.extensionName]); + extensions[PerMessageDeflate.extensionName] = perMessageDeflate; + } + return extensions; +} + function abortConnection(socket, code, name) { try { var response = [ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/.npmignore b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/.npmignore similarity index 55% rename from node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/.npmignore rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/.npmignore index 6bfffbb..0c90f67 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/.npmignore +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/.npmignore @@ -1,5 +1,3 @@ npm-debug.log node_modules -.*.swp -.lock-* -build/ +build diff --git a/node_modules/auto-reload-brunch/node_modules/ws/binding.gyp b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/binding.gyp similarity index 52% rename from node_modules/auto-reload-brunch/node_modules/ws/binding.gyp rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/binding.gyp index 600f9d1..31f41a6 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/binding.gyp +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/binding.gyp @@ -1,11 +1,5 @@ { 'targets': [ - { - 'target_name': 'validation', - 'include_dirs': [" + * MIT Licensed + */ + +module.exports.BufferUtil = { + merge: function(mergedBuffer, buffers) { + var offset = 0; + + for (var i = 0, l = buffers.length; i < l; ++i) { + var buf = buffers[i]; + buf.copy(mergedBuffer, offset); + offset += buf.length; + } + }, + mask: function(source, mask, output, offset, length) { + var maskNum = mask.readUInt32LE(0, true); + var i = 0; + + for (; i < length - 3; i += 4) { + var num = maskNum ^ source.readUInt32LE(i, true); + if (num < 0) num = 4294967296 + num; + output.writeUInt32LE(num, offset + i, true); + } + + switch (length % 4) { + case 3: output[offset + i + 2] = source[i + 2] ^ mask[2]; + case 2: output[offset + i + 1] = source[i + 1] ^ mask[1]; + case 1: output[offset + i] = source[i] ^ mask[0]; + } + }, + unmask: function(data, mask) { + var maskNum = mask.readUInt32LE(0, true); + var length = data.length; + var i = 0; + + for (; i < length - 3; i += 4) { + var num = maskNum ^ data.readUInt32LE(i, true); + if (num < 0) num = 4294967296 + num; + data.writeUInt32LE(num, i, true); + } + + switch (length % 4) { + case 3: data[i + 2] = data[i + 2] ^ mask[2]; + case 2: data[i + 1] = data[i + 1] ^ mask[1]; + case 1: data[i] = data[i] ^ mask[0]; + } + } +}; diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/index.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/index.js new file mode 100644 index 0000000..00c607c --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/index.js @@ -0,0 +1,7 @@ +'use strict'; + +try { + module.exports = require('bindings')('bufferutil'); +} catch (e) { + module.exports = require('./fallback'); +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/README.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/README.md new file mode 100644 index 0000000..585cf51 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/README.md @@ -0,0 +1,97 @@ +node-bindings +============= +### Helper module for loading your native module's .node file + +This is a helper module for authors of Node.js native addon modules. +It is basically the "swiss army knife" of `require()`ing your native module's +`.node` file. + +Throughout the course of Node's native addon history, addons have ended up being +compiled in a variety of different places, depending on which build tool and which +version of node was used. To make matters worse, now the _gyp_ build tool can +produce either a _Release_ or _Debug_ build, each being built into different +locations. + +This module checks _all_ the possible locations that a native addon would be built +at, and returns the first one that loads successfully. + + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install bindings +``` + +Or add it to the `"dependencies"` section of your _package.json_ file. + + +Example +------- + +`require()`ing the proper bindings file for the current node version, platform +and architecture is as simple as: + +``` js +var bindings = require('bindings')('binding.node') + +// Use your bindings defined in your C files +bindings.your_c_function() +``` + + +Nice Error Output +----------------- + +When the `.node` file could not be loaded, `node-bindings` throws an Error with +a nice error message telling you exactly what was tried. You can also check the +`err.tries` Array property. + +``` +Error: Could not load the bindings file. Tried: + → /Users/nrajlich/ref/build/binding.node + → /Users/nrajlich/ref/build/Debug/binding.node + → /Users/nrajlich/ref/build/Release/binding.node + → /Users/nrajlich/ref/out/Debug/binding.node + → /Users/nrajlich/ref/Debug/binding.node + → /Users/nrajlich/ref/out/Release/binding.node + → /Users/nrajlich/ref/Release/binding.node + → /Users/nrajlich/ref/build/default/binding.node + → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node + at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13) + at Object. (/Users/nrajlich/ref/lib/ref.js:5:47) + at Module._compile (module.js:449:26) + at Object.Module._extensions..js (module.js:467:10) + at Module.load (module.js:356:32) + at Function.Module._load (module.js:312:12) + ... +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/bindings.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/bindings.js new file mode 100644 index 0000000..93dcf85 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/bindings/bindings.js @@ -0,0 +1,166 @@ + +/** + * Module dependencies. + */ + +var fs = require('fs') + , path = require('path') + , join = path.join + , dirname = path.dirname + , exists = fs.existsSync || path.existsSync + , defaults = { + arrow: process.env.NODE_BINDINGS_ARROW || ' → ' + , compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' + , platform: process.platform + , arch: process.arch + , version: process.versions.node + , bindings: 'bindings.node' + , try: [ + // node-gyp's linked version in the "build" dir + [ 'module_root', 'build', 'bindings' ] + // node-waf and gyp_addon (a.k.a node-gyp) + , [ 'module_root', 'build', 'Debug', 'bindings' ] + , [ 'module_root', 'build', 'Release', 'bindings' ] + // Debug files, for development (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Debug', 'bindings' ] + , [ 'module_root', 'Debug', 'bindings' ] + // Release files, but manually compiled (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Release', 'bindings' ] + , [ 'module_root', 'Release', 'bindings' ] + // Legacy from node-waf, node <= 0.4.x + , [ 'module_root', 'build', 'default', 'bindings' ] + // Production "Release" buildtype binary (meh...) + , [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ] + ] + } + +/** + * The main `bindings()` function loads the compiled bindings for a given module. + * It uses V8's Error API to determine the parent filename that this function is + * being invoked from, which is then used to find the root directory. + */ + +function bindings (opts) { + + // Argument surgery + if (typeof opts == 'string') { + opts = { bindings: opts } + } else if (!opts) { + opts = {} + } + opts.__proto__ = defaults + + // Get the module root + if (!opts.module_root) { + opts.module_root = exports.getRoot(exports.getFileName()) + } + + // Ensure the given bindings name ends with .node + if (path.extname(opts.bindings) != '.node') { + opts.bindings += '.node' + } + + var tries = [] + , i = 0 + , l = opts.try.length + , n + , b + , err + + for (; i` 49259af + - Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179 + - Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9 + +### 1.5.2 Jan 23 2015 + + - Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4 + - Bugfix: Readded missing String constructors 18d828f + - Bugfix: Add overload handling NanNew(..) 5ef813b + - Bugfix: Fix uv_work_cb versioning 997e4ae + - Bugfix: Add function factory and test 4eca89c + - Bugfix: Add object template factory and test cdcb951 + - Correctness: Lifted an io.js related typedef c9490be + - Correctness: Make explicit downcasts of String lengths 00074e6 + - Windows: Limit the scope of disabled warning C4530 83d7deb + +### 1.5.1 Jan 15 2015 + + - Build: version bump + +### 1.4.3 Jan 15 2015 + + - Build: version bump + +### 1.4.2 Jan 15 2015 + + - Feature: Support io.js 0dbc5e8 + +### 1.5.0 Jan 14 2015 + + - Feature: Support io.js b003843 + - Correctness: Improved NanNew internals 9cd4f6a + - Feature: Implement progress to NanAsyncWorker 8d6a160 + +### 1.4.1 Nov 8 2014 + + - Bugfix: Handle DEBUG definition correctly + - Bugfix: Accept int as Boolean + +### 1.4.0 Nov 1 2014 + + - Feature: Added NAN_GC_CALLBACK 6a5c245 + - Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8 + - Correctness: Added constness to references in NanHasInstance 02c61cd + - Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6 + - Windoze: Shut Visual Studio up when compiling 8d558c1 + - License: Switch to plain MIT from custom hacked MIT license 11de983 + - Build: Added test target to Makefile e232e46 + - Performance: Removed superfluous scope in NanAsyncWorker f4b7821 + - Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208 + - Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450 + +### 1.3.0 Aug 2 2014 + + - Added NanNew(std::string) + - Added NanNew(std::string&) + - Added NanAsciiString helper class + - Added NanUtf8String helper class + - Added NanUcs2String helper class + - Deprecated NanRawString() + - Deprecated NanCString() + - Added NanGetIsolateData(v8::Isolate *isolate) + - Added NanMakeCallback(v8::Handle target, v8::Handle func, int argc, v8::Handle* argv) + - Added NanMakeCallback(v8::Handle target, v8::Handle symbol, int argc, v8::Handle* argv) + - Added NanMakeCallback(v8::Handle target, const char* method, int argc, v8::Handle* argv) + - Added NanSetTemplate(v8::Handle templ, v8::Handle name , v8::Handle value, v8::PropertyAttribute attributes) + - Added NanSetPrototypeTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) + - Added NanSetInstanceTemplate(v8::Local templ, const char *name, v8::Handle value) + - Added NanSetInstanceTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) + +### 1.2.0 Jun 5 2014 + + - Add NanSetPrototypeTemplate + - Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class, + introduced _NanWeakCallbackDispatcher + - Removed -Wno-unused-local-typedefs from test builds + - Made test builds Windows compatible ('Sleep()') + +### 1.1.2 May 28 2014 + + - Release to fix more stuff-ups in 1.1.1 + +### 1.1.1 May 28 2014 + + - Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0 + +### 1.1.0 May 25 2014 + + - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead + - Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]), + (uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*, + v8::String::ExternalAsciiStringResource* + - Deprecate NanSymbol() + - Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker + +### 1.0.0 May 4 2014 + + - Heavy API changes for V8 3.25 / Node 0.11.13 + - Use cpplint.py + - Removed NanInitPersistent + - Removed NanPersistentToLocal + - Removed NanFromV8String + - Removed NanMakeWeak + - Removed NanNewLocal + - Removed NAN_WEAK_CALLBACK_OBJECT + - Removed NAN_WEAK_CALLBACK_DATA + - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions + - Introduce NanUndefined, NanNull, NanTrue and NanFalse + - Introduce NanEscapableScope and NanEscapeScope + - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node) + - Introduce NanMakeCallback for node::MakeCallback + - Introduce NanSetTemplate + - Introduce NanGetCurrentContext + - Introduce NanCompileScript and NanRunScript + - Introduce NanAdjustExternalMemory + - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback + - Introduce NanGetHeapStatistics + - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent() + +### 0.8.0 Jan 9 2014 + + - NanDispose -> NanDisposePersistent, deprecate NanDispose + - Extract _NAN_*_RETURN_TYPE, pull up NAN_*() + +### 0.7.1 Jan 9 2014 + + - Fixes to work against debug builds of Node + - Safer NanPersistentToLocal (avoid reinterpret_cast) + - Speed up common NanRawString case by only extracting flattened string when necessary + +### 0.7.0 Dec 17 2013 + + - New no-arg form of NanCallback() constructor. + - NanCallback#Call takes Handle rather than Local + - Removed deprecated NanCallback#Run method, use NanCallback#Call instead + - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS + - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call() + - Introduce NanRawString() for char* (or appropriate void*) from v8::String + (replacement for NanFromV8String) + - Introduce NanCString() for null-terminated char* from v8::String + +### 0.6.0 Nov 21 2013 + + - Introduce NanNewLocal(v8::Handle value) for use in place of + v8::Local::New(...) since v8 started requiring isolate in Node 0.11.9 + +### 0.5.2 Nov 16 2013 + + - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public + +### 0.5.1 Nov 12 2013 + + - Use node::MakeCallback() instead of direct v8::Function::Call() + +### 0.5.0 Nov 11 2013 + + - Added @TooTallNate as collaborator + - New, much simpler, "include_dirs" for binding.gyp + - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros + +### 0.4.4 Nov 2 2013 + + - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+ + +### 0.4.3 Nov 2 2013 + + - Include node_object_wrap.h, removed from node.h for Node 0.11.8. + +### 0.4.2 Nov 2 2013 + + - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for + Node 0.11.8 release. + +### 0.4.1 Sep 16 2013 + + - Added explicit `#include ` as it was removed from node.h for v0.11.8 + +### 0.4.0 Sep 2 2013 + + - Added NAN_INLINE and NAN_DEPRECATED and made use of them + - Added NanError, NanTypeError and NanRangeError + - Cleaned up code + +### 0.3.2 Aug 30 2013 + + - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent + in NanAsyncWorker + +### 0.3.1 Aug 20 2013 + + - fix "not all control paths return a value" compile warning on some platforms + +### 0.3.0 Aug 19 2013 + + - Made NAN work with NPM + - Lots of fixes to NanFromV8String, pulling in features from new Node core + - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API + - Added optional error number argument for NanThrowError() + - Added NanInitPersistent() + - Added NanReturnNull() and NanReturnEmptyString() + - Added NanLocker and NanUnlocker + - Added missing scopes + - Made sure to clear disposed Persistent handles + - Changed NanAsyncWorker to allocate error messages on the heap + - Changed NanThrowError(Local) to NanThrowError(Handle) + - Fixed leak in NanAsyncWorker when errmsg is used + +### 0.2.2 Aug 5 2013 + + - Fixed usage of undefined variable with node::BASE64 in NanFromV8String() + +### 0.2.1 Aug 5 2013 + + - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for + NanFromV8String() + +### 0.2.0 Aug 5 2013 + + - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR, + NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY + - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS, + _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS, + _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS, + _NAN_PROPERTY_QUERY_ARGS + - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer + - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT, + NAN_WEAK_CALLBACK_DATA, NanMakeWeak + - Renamed THROW_ERROR to _NAN_THROW_ERROR + - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*) + - Added NanBufferUse(char*, uint32_t) + - Added NanNewContextHandle(v8::ExtensionConfiguration*, + v8::Handle, v8::Handle) + - Fixed broken NanCallback#GetFunction() + - Added optional encoding and size arguments to NanFromV8String() + - Added NanGetPointerSafe() and NanSetPointerSafe() + - Added initial test suite (to be expanded) + - Allow NanUInt32OptionValue to convert any Number object + +### 0.1.0 Jul 21 2013 + + - Added `NAN_GETTER`, `NAN_SETTER` + - Added `NanThrowError` with single Local argument + - Added `NanNewBufferHandle` with single uint32_t argument + - Added `NanHasInstance(Persistent&, Handle)` + - Added `Local NanCallback#GetFunction()` + - Added `NanCallback#Call(int, Local[])` + - Deprecated `NanCallback#Run(int, Local[])` in favour of Call diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/LICENSE.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/LICENSE.md new file mode 100644 index 0000000..95c2eb5 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/LICENSE.md @@ -0,0 +1,13 @@ +The MIT License (MIT) +===================== + +Copyright (c) 2015 NAN contributors +----------------------------------- + +*NAN contributors listed at * + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/appveyor.yml b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/appveyor.yml new file mode 100644 index 0000000..1777107 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/appveyor.yml @@ -0,0 +1,37 @@ +# http://www.appveyor.com/docs/appveyor-yml + +# Test against these versions of Io.js and Node.js. +environment: + matrix: + # node.js + - nodejs_version: "0.8" + - nodejs_version: "0.10" + - nodejs_version: "0.11" + # io.js + - nodejs_version: "1" + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node 0.STABLE.latest + - ps: if($env:nodejs_version -eq "0.8") {Install-Product node $env:nodejs_version} + - ps: if($env:nodejs_version -ne "0.8") {Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)} + - IF NOT %nodejs_version% == 1 npm -g install npm + - IF NOT %nodejs_version% == 1 set PATH=%APPDATA%\npm;%PATH% + # Typical npm stuff. + - npm install + - IF %nodejs_version% == 0.8 node node_modules\node-gyp\bin\node-gyp.js rebuild --directory test + - IF NOT %nodejs_version% == 0.8 npm run rebuild-tests + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - node --version + - npm --version + # run tests + - npm test + +# Don't actually build. +build: off + +# Set build version format here instead of in the admin panel. +version: "{build}" diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/include_dirs.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/include_dirs.js similarity index 100% rename from node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/include_dirs.js rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/include_dirs.js diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/nan.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan.h similarity index 53% rename from node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/nan.h rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan.h index bc544f5..e95a3b3 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/nan.h +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan.h @@ -1,151 +1,18 @@ -/********************************************************************************** +/********************************************************************* * NAN - Native Abstractions for Node.js * - * Copyright (c) 2014 NAN contributors: + * Copyright (c) 2015 NAN contributors: * - Rod Vagg * - Benjamin Byholm * - Trevor Norris * - Nathan Rajlich * - Brett Lawson * - Ben Noordhuis + * - David Siegel * - * MIT +no-false-attribs License + * MIT License * - * Version 1.0.0 (current Node unstable: 0.11.13, Node stable: 0.10.28) - * - * ChangeLog: - * * 1.0.0 May 4 2014 - * - Heavy API changes for V8 3.25 / Node 0.11.13 - * - Use cpplint.py - * - Removed NanInitPersistent - * - Removed NanPersistentToLocal - * - Removed NanFromV8String - * - Removed NanMakeWeak - * - Removed NanNewLocal - * - Removed NAN_WEAK_CALLBACK_OBJECT - * - Removed NAN_WEAK_CALLBACK_DATA - * - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions - * - Introduce NanUndefined, NanNull, NanTrue and NanFalse - * - Introduce NanEscapableScope and NanEscapeScope - * - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node) - * - Introduce NanMakeCallback for node::MakeCallback - * - Introduce NanSetTemplate - * - Introduce NanGetCurrentContext - * - Introduce NanCompileScript and NanRunScript - * - Introduce NanAdjustExternalMemory - * - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback - * - Introduce NanGetHeapStatistics - * - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent() - * - * * 0.8.0 Jan 9 2014 - * - NanDispose -> NanDisposePersistent, deprecate NanDispose - * - Extract _NAN_*_RETURN_TYPE, pull up NAN_*() - * - * * 0.7.1 Jan 9 2014 - * - Fixes to work against debug builds of Node - * - Safer NanPersistentToLocal (avoid reinterpret_cast) - * - Speed up common NanRawString case by only extracting flattened string when necessary - * - * * 0.7.0 Dec 17 2013 - * - New no-arg form of NanCallback() constructor. - * - NanCallback#Call takes Handle rather than Local - * - Removed deprecated NanCallback#Run method, use NanCallback#Call instead - * - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS - * - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call() - * - Introduce NanRawString() for char* (or appropriate void*) from v8::String - * (replacement for NanFromV8String) - * - Introduce NanCString() for null-terminated char* from v8::String - * - * * 0.6.0 Nov 21 2013 - * - Introduce NanNewLocal(v8::Handle value) for use in place of - * v8::Local::New(...) since v8 started requiring isolate in Node 0.11.9 - * - * * 0.5.2 Nov 16 2013 - * - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public - * - * * 0.5.1 Nov 12 2013 - * - Use node::MakeCallback() instead of direct v8::Function::Call() - * - * * 0.5.0 Nov 11 2013 - * - Added @TooTallNate as collaborator - * - New, much simpler, "include_dirs" for binding.gyp - * - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros - * - * * 0.4.4 Nov 2 2013 - * - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+ - * - * * 0.4.3 Nov 2 2013 - * - Include node_object_wrap.h, removed from node.h for Node 0.11.8. - * - * * 0.4.2 Nov 2 2013 - * - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for - * Node 0.11.8 release. - * - * * 0.4.1 Sep 16 2013 - * - Added explicit `#include ` as it was removed from node.h for v0.11.8 - * - * * 0.4.0 Sep 2 2013 - * - Added NAN_INLINE and NAN_DEPRECATED and made use of them - * - Added NanError, NanTypeError and NanRangeError - * - Cleaned up code - * - * * 0.3.2 Aug 30 2013 - * - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent - * in NanAsyncWorker - * - * * 0.3.1 Aug 20 2013 - * - fix "not all control paths return a value" compile warning on some platforms - * - * * 0.3.0 Aug 19 2013 - * - Made NAN work with NPM - * - Lots of fixes to NanFromV8String, pulling in features from new Node core - * - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API - * - Added optional error number argument for NanThrowError() - * - Added NanInitPersistent() - * - Added NanReturnNull() and NanReturnEmptyString() - * - Added NanLocker and NanUnlocker - * - Added missing scopes - * - Made sure to clear disposed Persistent handles - * - Changed NanAsyncWorker to allocate error messages on the heap - * - Changed NanThrowError(Local) to NanThrowError(Handle) - * - Fixed leak in NanAsyncWorker when errmsg is used - * - * * 0.2.2 Aug 5 2013 - * - Fixed usage of undefined variable with node::BASE64 in NanFromV8String() - * - * * 0.2.1 Aug 5 2013 - * - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for - * NanFromV8String() - * - * * 0.2.0 Aug 5 2013 - * - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR, - * NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY - * - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS, - * _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS, - * _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS, - * _NAN_PROPERTY_QUERY_ARGS - * - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer - * - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT, - * NAN_WEAK_CALLBACK_DATA, NanMakeWeak - * - Renamed THROW_ERROR to _NAN_THROW_ERROR - * - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*) - * - Added NanBufferUse(char*, uint32_t) - * - Added NanNewContextHandle(v8::ExtensionConfiguration*, - * v8::Handle, v8::Handle) - * - Fixed broken NanCallback#GetFunction() - * - Added optional encoding and size arguments to NanFromV8String() - * - Added NanGetPointerSafe() and NanSetPointerSafe() - * - Added initial test suite (to be expanded) - * - Allow NanUInt32OptionValue to convert any Number object - * - * * 0.1.0 Jul 21 2013 - * - Added `NAN_GETTER`, `NAN_SETTER` - * - Added `NanThrowError` with single Local argument - * - Added `NanNewBufferHandle` with single uint32_t argument - * - Added `NanHasInstance(Persistent&, Handle)` - * - Added `Local NanCallback#GetFunction()` - * - Added `NanCallback#Call(int, Local[])` - * - Deprecated `NanCallback#Run(int, Local[])` in favour of Call + * Version 1.6.2: current Node unstable: 0.11.16, Node stable: 0.10.36, io.js: 1.1.0 * * See https://github.com/rvagg/nan for the latest update to this file **********************************************************************************/ @@ -158,24 +25,75 @@ #include #include #include -#include +#include +#include +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif -#if defined(__GNUC__) && !defined(DEBUG) +#if defined(__GNUC__) && !(defined(DEBUG) && DEBUG) # define NAN_INLINE inline __attribute__((always_inline)) -#elif defined(_MSC_VER) && !defined(DEBUG) +#elif defined(_MSC_VER) && !(defined(DEBUG) && DEBUG) # define NAN_INLINE __forceinline #else # define NAN_INLINE inline #endif -#if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS +#if defined(__GNUC__) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) # define NAN_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS +#elif defined(_MSC_VER) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) # define NAN_DEPRECATED __declspec(deprecated) #else # define NAN_DEPRECATED #endif +#if (NODE_MODULE_VERSION < 12) +typedef v8::InvocationCallback NanFunctionCallback; +typedef v8::Script NanUnboundScript; +typedef v8::Script NanBoundScript; +#else +typedef v8::FunctionCallback NanFunctionCallback; +typedef v8::UnboundScript NanUnboundScript; +typedef v8::Script NanBoundScript; +#endif + +#if (NODE_MODULE_VERSION < 42) +typedef v8::String::ExternalAsciiStringResource + NanExternalOneByteStringResource; +#else // io.js v1.0.0 +typedef v8::String::ExternalOneByteStringResource + NanExternalOneByteStringResource; +#endif + +#include "nan_new.h" // NOLINT(build/include) + +// uv helpers +#ifdef UV_VERSION_MAJOR +#ifndef UV_VERSION_PATCH +#define UV_VERSION_PATCH 0 +#endif +#define NAUV_UVVERSION ((UV_VERSION_MAJOR << 16) | \ + (UV_VERSION_MINOR << 8) | \ + (UV_VERSION_PATCH)) +#else +#define NAUV_UVVERSION 0x000b00 +#endif + + +#if NAUV_UVVERSION < 0x000b17 +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async, int) +#else +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async) +#endif + // some generic helpers template NAN_INLINE bool NanSetPointerSafe( @@ -235,8 +153,78 @@ NAN_INLINE uint32_t NanUInt32OptionValue( : def; } +template +v8::Local NanNew(v8::Handle); + +template +NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) { + return NanNew(val); +} + +template +NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) { + return val; +} + +/* io.js 1.0 */ +#if NODE_MODULE_VERSION >= 42 || NODE_VERSION_AT_LEAST(0, 11, 15) + NAN_INLINE + void NanSetCounterFunction(v8::CounterLookupCallback cb) { + v8::Isolate::GetCurrent()->SetCounterFunction(cb); + } + + NAN_INLINE + void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::Isolate::GetCurrent()->SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb); + } + + NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) { + return v8::Isolate::GetCurrent()->IdleNotification(idle_time_in_ms); + } + + NAN_INLINE void NanLowMemoryNotification() { + v8::Isolate::GetCurrent()->LowMemoryNotification(); + } + + NAN_INLINE void NanContextDisposedNotification() { + v8::Isolate::GetCurrent()->ContextDisposedNotification(); + } +#else + NAN_INLINE + void NanSetCounterFunction(v8::CounterLookupCallback cb) { + v8::V8::SetCounterFunction(cb); + } + + NAN_INLINE + void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::V8::SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::V8::SetAddHistogramSampleFunction(cb); + } + + NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) { + return v8::V8::IdleNotification(idle_time_in_ms); + } + + NAN_INLINE void NanLowMemoryNotification() { + v8::V8::LowMemoryNotification(); + } + + NAN_INLINE void NanContextDisposedNotification() { + v8::V8::ContextDisposedNotification(); + } +#endif + #if (NODE_MODULE_VERSION > 0x000B) -// Node 0.11+ (0.11.3 and below won't compile with these) +// Node 0.11+ (0.11.12 and below won't compile with these) # define _NAN_METHOD_ARGS_TYPE const v8::FunctionCallbackInfo& # define _NAN_METHOD_ARGS _NAN_METHOD_ARGS_TYPE args @@ -301,340 +289,140 @@ NAN_INLINE uint32_t NanUInt32OptionValue( # define _NAN_INDEX_QUERY_ARGS _NAN_INDEX_QUERY_ARGS_TYPE args # define _NAN_INDEX_QUERY_RETURN_TYPE void -typedef v8::FunctionCallback NanFunctionCallback; -static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent(); - -# define NanUndefined() v8::Undefined(nan_isolate) -# define NanNull() v8::Null(nan_isolate) -# define NanTrue() v8::True(nan_isolate) -# define NanFalse() v8::False(nan_isolate) -# define NanAdjustExternalMemory(amount) \ - nan_isolate->AdjustAmountOfExternalAllocatedMemory(amount) -# define NanSetTemplate(templ, name, value) templ->Set(nan_isolate, name, value) -# define NanGetCurrentContext() nan_isolate->GetCurrentContext() -# define NanMakeCallback(target, func, argc, argv) \ - node::MakeCallback(nan_isolate, target, func, argc, argv) -# define NanGetInternalFieldPointer(object, index) \ - object->GetAlignedPointerFromInternalField(index) -# define NanSetInternalFieldPointer(object, index, value) \ - object->SetAlignedPointerInInternalField(index, value) - - template - NAN_INLINE v8::Local NanNew() { - return T::New(nan_isolate); - } - - template - NAN_INLINE v8::Local NanNew(P arg1) { - return T::New(nan_isolate, arg1); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle receiver - , int argc - , v8::Handle argv[] = 0) { - return v8::Signature::New(nan_isolate, receiver, argc, argv); - } - - template - NAN_INLINE v8::Local NanNew( - NanFunctionCallback callback - , v8::Handle data = v8::Handle() - , v8::Handle signature = v8::Handle()) { - return T::New(nan_isolate, callback, data, signature); - } - - template - NAN_INLINE v8::Local NanNew(v8::Handle arg1) { - return v8::Local::New(nan_isolate, arg1); - } - - template - NAN_INLINE v8::Local NanNew(const v8::Persistent &arg1) { - return v8::Local::New(nan_isolate, arg1); - } - - template - NAN_INLINE v8::Local NanNew(P arg1, int arg2) { - return T::New(nan_isolate, arg1, arg2); - } - - template<> - NAN_INLINE v8::Local NanNew() { - return v8::Array::New(nan_isolate); - } - - template<> - NAN_INLINE v8::Local NanNew(int length) { - return v8::Array::New(nan_isolate, length); - } - - template<> - NAN_INLINE v8::Local NanNew(double time) { - return v8::Date::New(nan_isolate, time).As(); - } - - template<> - NAN_INLINE v8::Local NanNew(int time) { - return v8::Date::New(nan_isolate, time).As(); - } - - typedef v8::UnboundScript NanUnboundScript; - typedef v8::Script NanBoundScript; - - template - NAN_INLINE v8::Local NanNew( - P s - , const v8::ScriptOrigin& origin - ) { - v8::ScriptCompiler::Source source(s, origin); - return v8::ScriptCompiler::CompileUnbound(nan_isolate, &source); - } - - template<> - NAN_INLINE v8::Local NanNew( - v8::Local s - ) { - v8::ScriptCompiler::Source source(s); - return v8::ScriptCompiler::CompileUnbound(nan_isolate, &source); - } - - NAN_INLINE v8::Local NanNew( - v8::String::ExternalStringResource *resource) { - return v8::String::NewExternal(nan_isolate, resource); - } - - NAN_INLINE v8::Local NanNew( - v8::String::ExternalAsciiStringResource *resource) { - return v8::String::NewExternal(nan_isolate, resource); - } - - template<> - NAN_INLINE v8::Local NanNew(bool value) { - return v8::BooleanObject::New(value).As(); - } - - template<> - NAN_INLINE v8::Local - NanNew >( - v8::Local value) { - return v8::StringObject::New(value).As(); - } - - template<> - NAN_INLINE v8::Local - NanNew >( - v8::Handle value) { - return v8::StringObject::New(value).As(); - } - - template<> - NAN_INLINE v8::Local NanNew(double val) { - return v8::NumberObject::New(nan_isolate, val).As(); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Local pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Local pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template<> - NAN_INLINE v8::Local NanNew(int32_t val) { - return v8::Uint32::NewFromUnsigned(nan_isolate, val)->ToUint32(); - } - - template<> - NAN_INLINE v8::Local NanNew(uint32_t val) { - return v8::Uint32::NewFromUnsigned(nan_isolate, val)->ToUint32(); - } +# define NanScope() v8::HandleScope scope(v8::Isolate::GetCurrent()) +# define NanEscapableScope() \ + v8::EscapableHandleScope scope(v8::Isolate::GetCurrent()) - template<> - NAN_INLINE v8::Local NanNew(int32_t val) { - return v8::Int32::New(nan_isolate, val)->ToInt32(); - } - - template<> - NAN_INLINE v8::Local NanNew(uint32_t val) { - return v8::Int32::New(nan_isolate, val)->ToInt32(); - } +# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val)) +# define NanLocker() v8::Locker locker(v8::Isolate::GetCurrent()) +# define NanUnlocker() v8::Unlocker unlocker(v8::Isolate::GetCurrent()) +# define NanReturnValue(value) return args.GetReturnValue().Set(value) +# define NanReturnUndefined() return +# define NanReturnHolder() NanReturnValue(args.Holder()) +# define NanReturnThis() NanReturnValue(args.This()) +# define NanReturnNull() return args.GetReturnValue().SetNull() +# define NanReturnEmptyString() return args.GetReturnValue().SetEmptyString() - template<> - NAN_INLINE v8::Local NanNew( - char *arg - , int length) { - return v8::String::NewFromUtf8( - nan_isolate - , arg - , v8::String::kNormalString - , length); - } +# define NanObjectWrapHandle(obj) obj->handle() - template<> - NAN_INLINE v8::Local NanNew( - const char *arg - , int length) { - return v8::String::NewFromUtf8( - nan_isolate - , arg - , v8::String::kNormalString - , length); + NAN_INLINE v8::Local NanUndefined() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent()))); } - template<> - NAN_INLINE v8::Local NanNew(char *arg) { - return v8::String::NewFromUtf8(nan_isolate, arg); + NAN_INLINE v8::Local NanNull() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent()))); } - template<> - NAN_INLINE v8::Local NanNew( - const char *arg) { - return v8::String::NewFromUtf8(nan_isolate, arg); + NAN_INLINE v8::Local NanTrue() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent()))); } - template<> - NAN_INLINE v8::Local NanNew( - uint8_t *arg - , int length) { - return v8::String::NewFromOneByte( - nan_isolate - , arg - , v8::String::kNormalString - , length); + NAN_INLINE v8::Local NanFalse() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent()))); } - template<> - NAN_INLINE v8::Local NanNew( - const uint8_t *arg - , int length) { - return v8::String::NewFromOneByte( - nan_isolate - , arg - , v8::String::kNormalString - , length); + NAN_INLINE int NanAdjustExternalMemory(int bc) { + return static_cast( + v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(bc)); } - template<> - NAN_INLINE v8::Local NanNew(uint8_t *arg) { - return v8::String::NewFromOneByte(nan_isolate, arg); + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , const char *name + , v8::Handle value) { + templ->Set(v8::Isolate::GetCurrent(), name, value); } - template<> - NAN_INLINE v8::Local NanNew( - const uint8_t *arg) { - return v8::String::NewFromOneByte(nan_isolate, arg); + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); } - template<> - NAN_INLINE v8::Local NanNew( - uint16_t *arg - , int length) { - return v8::String::NewFromTwoByte( - nan_isolate - , arg - , v8::String::kNormalString - , length); + NAN_INLINE v8::Local NanGetCurrentContext() { + return v8::Isolate::GetCurrent()->GetCurrentContext(); } - template<> - NAN_INLINE v8::Local NanNew( - const uint16_t *arg - , int length) { - return v8::String::NewFromTwoByte( - nan_isolate - , arg - , v8::String::kNormalString - , length); - } - template<> - NAN_INLINE v8::Local NanNew( - uint16_t *arg) { - return v8::String::NewFromTwoByte(nan_isolate, arg); + NAN_INLINE void* NanGetInternalFieldPointer( + v8::Handle object + , int index) { + return object->GetAlignedPointerFromInternalField(index); } - template<> - NAN_INLINE v8::Local NanNew( - const uint16_t *arg) { - return v8::String::NewFromTwoByte(nan_isolate, arg); + NAN_INLINE void NanSetInternalFieldPointer( + v8::Handle object + , int index + , void* value) { + object->SetAlignedPointerInInternalField(index, value); } - template<> - NAN_INLINE v8::Local NanNew() { - return v8::String::Empty(nan_isolate); - } +# define NAN_GC_CALLBACK(name) \ + void name(v8::Isolate *isolate, v8::GCType type, v8::GCCallbackFlags flags) NAN_INLINE void NanAddGCEpilogueCallback( v8::Isolate::GCEpilogueCallback callback , v8::GCType gc_type_filter = v8::kGCTypeAll) { - nan_isolate->AddGCEpilogueCallback(callback, gc_type_filter); + v8::Isolate::GetCurrent()->AddGCEpilogueCallback(callback, gc_type_filter); } NAN_INLINE void NanRemoveGCEpilogueCallback( v8::Isolate::GCEpilogueCallback callback) { - nan_isolate->RemoveGCEpilogueCallback(callback); + v8::Isolate::GetCurrent()->RemoveGCEpilogueCallback(callback); } NAN_INLINE void NanAddGCPrologueCallback( v8::Isolate::GCPrologueCallback callback , v8::GCType gc_type_filter = v8::kGCTypeAll) { - nan_isolate->AddGCPrologueCallback(callback, gc_type_filter); + v8::Isolate::GetCurrent()->AddGCPrologueCallback(callback, gc_type_filter); } NAN_INLINE void NanRemoveGCPrologueCallback( v8::Isolate::GCPrologueCallback callback) { - nan_isolate->RemoveGCPrologueCallback(callback); + v8::Isolate::GetCurrent()->RemoveGCPrologueCallback(callback); } NAN_INLINE void NanGetHeapStatistics( v8::HeapStatistics *heap_statistics) { - nan_isolate->GetHeapStatistics(heap_statistics); + v8::Isolate::GetCurrent()->GetHeapStatistics(heap_statistics); } -# define NanSymbol(value) NanNew(value) + NAN_DEPRECATED NAN_INLINE v8::Local NanSymbol( + const char* data, int length = -1) { + return NanNew(data, length); + } template NAN_INLINE void NanAssignPersistent( v8::Persistent& handle , v8::Handle obj) { - handle.Reset(nan_isolate, obj); + handle.Reset(v8::Isolate::GetCurrent(), obj); } template NAN_INLINE void NanAssignPersistent( v8::Persistent& handle , const v8::Persistent& obj) { - handle.Reset(nan_isolate, obj); + handle.Reset(v8::Isolate::GetCurrent(), obj); } + template + class _NanWeakCallbackData; + template struct _NanWeakCallbackInfo { - typedef void (*Callback)( - const v8::WeakCallbackData >& data); - _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) + typedef void (*Callback)(const _NanWeakCallbackData& data); + NAN_INLINE _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) : parameter(param), callback(cb) { NanAssignPersistent(persistent, handle); } - ~_NanWeakCallbackInfo() { + NAN_INLINE ~_NanWeakCallbackInfo() { persistent.Reset(); } @@ -646,67 +434,69 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent(); template class _NanWeakCallbackData { public: - _NanWeakCallbackData(_NanWeakCallbackInfo *info) + NAN_INLINE _NanWeakCallbackData(_NanWeakCallbackInfo *info) : info_(info) { } NAN_INLINE v8::Local GetValue() const { return NanNew(info_->persistent); } + NAN_INLINE P* GetParameter() const { return info_->parameter; } - NAN_INLINE void Revive() const { - info_->persistent.SetWeak(info_, info_->callback); + + NAN_INLINE bool IsNearDeath() const { + return info_->persistent.IsNearDeath(); } - NAN_INLINE void Dispose() const { - delete info_; + NAN_INLINE void Revive() const; + + NAN_INLINE _NanWeakCallbackInfo* GetCallbackInfo() const { + return info_; + } + + NAN_DEPRECATED NAN_INLINE void Dispose() const { } private: _NanWeakCallbackInfo* info_; }; -// do not use for declaration -# define NAN_WEAK_CALLBACK(name) \ - template \ - static void name( \ - const v8::WeakCallbackData > &data) { \ - _NanWeakCallbackData wcbd( \ - data.GetParameter()); \ - _Nan_Weak_Callback_ ## name(wcbd); \ - } \ - \ - template \ - NAN_INLINE void _Nan_Weak_Callback_ ## name( \ - const _NanWeakCallbackData &data) - -# define NanScope() v8::HandleScope scope(nan_isolate) -# define NanEscapableScope() v8::EscapableHandleScope scope(nan_isolate) -# define NanEscapeScope(val) scope.Escape(val) -# define NanLocker() v8::Locker locker(nan_isolate) -# define NanUnlocker() v8::Unlocker unlocker(nan_isolate) -# define NanReturnValue(value) return args.GetReturnValue().Set(value) -# define NanReturnUndefined() return -# define NanReturnNull() return args.GetReturnValue().SetNull() -# define NanReturnEmptyString() return args.GetReturnValue().SetEmptyString() + template + static void _NanWeakCallbackDispatcher( + const v8::WeakCallbackData > &data) { + _NanWeakCallbackInfo *info = data.GetParameter(); + _NanWeakCallbackData wcbd(info); + info->callback(wcbd); + if (wcbd.IsNearDeath()) { + delete wcbd.GetCallbackInfo(); + } + } -# define NanObjectWrapHandle(obj) obj->handle() + template + NAN_INLINE void _NanWeakCallbackData::Revive() const { + info_->persistent.SetWeak(info_, &_NanWeakCallbackDispatcher); + } template -void NAN_INLINE NanMakeWeakPersistent( +NAN_INLINE _NanWeakCallbackInfo* NanMakeWeakPersistent( v8::Handle handle , P* parameter , typename _NanWeakCallbackInfo::Callback callback) { _NanWeakCallbackInfo *cbinfo = new _NanWeakCallbackInfo(handle, parameter, callback); - cbinfo->persistent.SetWeak(cbinfo, callback); + cbinfo->persistent.SetWeak(cbinfo, &_NanWeakCallbackDispatcher); + return cbinfo; } +# define NAN_WEAK_CALLBACK(name) \ + template \ + static void name(const _NanWeakCallbackData &data) + # define _NAN_ERROR(fun, errmsg) fun(NanNew(errmsg)) # define _NAN_THROW_ERROR(fun, errmsg) \ do { \ NanScope(); \ - nan_isolate->ThrowException(_NAN_ERROR(fun, errmsg)); \ + v8::Isolate::GetCurrent()->ThrowException(_NAN_ERROR(fun, errmsg)); \ } while (0); NAN_INLINE v8::Local NanError(const char* errmsg) { @@ -719,7 +509,7 @@ void NAN_INLINE NanMakeWeakPersistent( NAN_INLINE void NanThrowError(v8::Handle error) { NanScope(); - nan_isolate->ThrowException(error); + v8::Isolate::GetCurrent()->ThrowException(error); } NAN_INLINE v8::Local NanError( @@ -728,7 +518,7 @@ void NAN_INLINE NanMakeWeakPersistent( ) { v8::Local err = v8::Exception::Error(NanNew(msg)); v8::Local obj = err.As(); - obj->Set(NanSymbol("code"), NanNew(errorNumber)); + obj->Set(NanNew("code"), NanNew(errorNumber)); return err; } @@ -767,42 +557,44 @@ void NAN_INLINE NanMakeWeakPersistent( , node::smalloc::FreeCallback callback , void *hint ) { - return node::Buffer::New(nan_isolate, data, length, callback, hint); + return node::Buffer::New( + v8::Isolate::GetCurrent(), data, length, callback, hint); } NAN_INLINE v8::Local NanNewBufferHandle ( const char *data , uint32_t size ) { - return node::Buffer::New(nan_isolate, data, size); + return node::Buffer::New(v8::Isolate::GetCurrent(), data, size); } NAN_INLINE v8::Local NanNewBufferHandle (uint32_t size) { - return node::Buffer::New(nan_isolate, size); + return node::Buffer::New(v8::Isolate::GetCurrent(), size); } NAN_INLINE v8::Local NanBufferUse( char* data , uint32_t size ) { - return node::Buffer::Use(nan_isolate, data, size); + return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size); } NAN_INLINE bool NanHasInstance( - v8::Persistent& function_template + const v8::Persistent& function_template , v8::Handle value ) { return NanNew(function_template)->HasInstance(value); } - NAN_INLINE v8::Local NanNewContextHandle( + NAN_DEPRECATED NAN_INLINE v8::Local NanNewContextHandle( v8::ExtensionConfiguration* extensions = NULL , v8::Handle tmpl = v8::Handle() , v8::Handle obj = v8::Handle() ) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); return v8::Local::New( - nan_isolate - , v8::Context::New(nan_isolate, extensions, tmpl, obj) + isolate + , v8::Context::New(isolate, extensions, tmpl, obj) ); } @@ -811,28 +603,170 @@ void NAN_INLINE NanMakeWeakPersistent( , const v8::ScriptOrigin& origin ) { v8::ScriptCompiler::Source source(s, origin); - return v8::ScriptCompiler::Compile(nan_isolate, &source); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); } NAN_INLINE v8::Local NanCompileScript( v8::Local s ) { v8::ScriptCompiler::Source source(s); - return v8::ScriptCompiler::Compile(nan_isolate, &source); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); } NAN_INLINE v8::Local NanRunScript( - v8::Local script + v8::Handle script ) { return script->BindToCurrentContext()->Run(); } NAN_INLINE v8::Local NanRunScript( - v8::Local script + v8::Handle script ) { return script->Run(); } + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle func + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, func, argc, argv)); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle symbol + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, symbol, argc, argv)); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , const char* method + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, method, argc, argv)); + } + + template + NAN_INLINE void NanSetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(0, data); + } + + template + NAN_INLINE T *NanGetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData(0)); + } + + class NanAsciiString { + public: + NAN_INLINE explicit NanAsciiString(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new char[size + 1]; + size = toStr->WriteOneByte(reinterpret_cast(buf)); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanAsciiString() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanAsciiString(const NanAsciiString&); + void operator=(const NanAsciiString&); + + char *buf; + int size; + }; + + class NanUtf8String { + public: + NAN_INLINE explicit NanUtf8String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Utf8Length(); + buf = new char[size + 1]; + toStr->WriteUtf8(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanUtf8String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUtf8String(const NanUtf8String&); + void operator=(const NanUtf8String&); + + char *buf; + int size; + }; + + class NanUcs2String { + public: + NAN_INLINE explicit NanUcs2String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new uint16_t[size + 1]; + toStr->Write(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE uint16_t* operator*() { return buf; } + NAN_INLINE const uint16_t* operator*() const { return buf; } + + NAN_INLINE ~NanUcs2String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUcs2String(const NanUcs2String&); + void operator=(const NanUcs2String&); + + uint16_t *buf; + int size; + }; + #else // Node 0.8 and 0.10 @@ -880,254 +814,90 @@ void NAN_INLINE NanMakeWeakPersistent( # define _NAN_INDEX_ENUMERATOR_ARGS _NAN_INDEX_ENUMERATOR_ARGS_TYPE args # define _NAN_INDEX_ENUMERATOR_RETURN_TYPE v8::Handle -# define _NAN_INDEX_DELETER_ARGS_TYPE const v8::AccessorInfo& -# define _NAN_INDEX_DELETER_ARGS _NAN_INDEX_DELETER_ARGS_TYPE args -# define _NAN_INDEX_DELETER_RETURN_TYPE v8::Handle - -# define _NAN_INDEX_QUERY_ARGS_TYPE const v8::AccessorInfo& -# define _NAN_INDEX_QUERY_ARGS _NAN_INDEX_QUERY_ARGS_TYPE args -# define _NAN_INDEX_QUERY_RETURN_TYPE v8::Handle - -typedef v8::InvocationCallback NanFunctionCallback; - -# define NanUndefined() v8::Undefined() -# define NanNull() v8::Null() -# define NanTrue() v8::True() -# define NanFalse() v8::False() -# define NanAdjustExternalMemory(amount) \ - v8::V8::AdjustAmountOfExternalAllocatedMemory(amount) -# define NanSetTemplate(templ, name, value) templ->Set(name, value) -# define NanGetCurrentContext() v8::Context::GetCurrent() -# if NODE_VERSION_AT_LEAST(0, 8, 0) -# define NanMakeCallback(target, func, argc, argv) \ - node::MakeCallback(target, func, argc, argv) -# else -# define NanMakeCallback(target, func, argc, argv) \ - do { \ - v8::TryCatch try_catch; \ - func->Call(target, argc, argv); \ - if (try_catch.HasCaught()) { \ - v8::FatalException(try_catch); \ - } \ - } while (0) -# endif - -# define NanSymbol(value) v8::String::NewSymbol(value) - - template - NAN_INLINE v8::Local NanNew() { - return v8::Local::New(T::New()); - } - - template - NAN_INLINE v8::Local NanNew(v8::Handle arg) { - return v8::Local::New(arg); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle receiver - , int argc - , v8::Handle argv[] = 0) { - return v8::Signature::New(receiver, argc, argv); - } - - template - NAN_INLINE v8::Local NanNew( - NanFunctionCallback callback - , v8::Handle data = v8::Handle() - , v8::Handle signature = v8::Handle()) { - return T::New(callback, data, signature); - } - - template - NAN_INLINE v8::Local NanNew(const v8::Persistent &arg) { - return v8::Local::New(arg); - } - - template - NAN_INLINE v8::Local NanNew(P arg) { - return v8::Local::New(T::New(arg)); - } - - template - NAN_INLINE v8::Local NanNew(P arg, int length) { - return v8::Local::New(T::New(arg, length)); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Local pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Handle pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template - NAN_INLINE v8::Local NanNew( - v8::Local pattern, v8::RegExp::Flags flags) { - return v8::RegExp::New(pattern, flags); - } - - template<> - NAN_INLINE v8::Local NanNew() { - return v8::Array::New(); - } - - template<> - NAN_INLINE v8::Local NanNew(int length) { - return v8::Array::New(length); - } - - - template<> - NAN_INLINE v8::Local NanNew(double time) { - return v8::Date::New(time).As(); - } - - template<> - NAN_INLINE v8::Local NanNew(int time) { - return v8::Date::New(time).As(); - } - - typedef v8::Script NanUnboundScript; - typedef v8::Script NanBoundScript; - - template - NAN_INLINE v8::Local NanNew( - P s - , const v8::ScriptOrigin& origin - ) { - return v8::Script::New(s, const_cast(&origin)); - } - - template<> - NAN_INLINE v8::Local NanNew( - v8::Local s - ) { - return v8::Script::New(s); - } +# define _NAN_INDEX_DELETER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_DELETER_ARGS _NAN_INDEX_DELETER_ARGS_TYPE args +# define _NAN_INDEX_DELETER_RETURN_TYPE v8::Handle - NAN_INLINE v8::Local NanNew( - v8::String::ExternalStringResource *resource) { - return v8::String::NewExternal(resource); - } +# define _NAN_INDEX_QUERY_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_QUERY_ARGS _NAN_INDEX_QUERY_ARGS_TYPE args +# define _NAN_INDEX_QUERY_RETURN_TYPE v8::Handle - NAN_INLINE v8::Local NanNew( - v8::String::ExternalAsciiStringResource *resource) { - return v8::String::NewExternal(resource); + NAN_DEPRECATED NAN_INLINE v8::Local NanSymbol( + const char* data, int length = -1) { + return v8::String::NewSymbol(data, length); } - template<> - NAN_INLINE v8::Local NanNew(bool value) { - return v8::BooleanObject::New(value).As(); - } +# define NanScope() v8::HandleScope scope +# define NanEscapableScope() v8::HandleScope scope +# define NanEscapeScope(val) scope.Close(val) +# define NanLocker() v8::Locker locker +# define NanUnlocker() v8::Unlocker unlocker +# define NanReturnValue(value) return scope.Close(value) +# define NanReturnHolder() NanReturnValue(args.Holder()) +# define NanReturnThis() NanReturnValue(args.This()) +# define NanReturnUndefined() return v8::Undefined() +# define NanReturnNull() return v8::Null() +# define NanReturnEmptyString() return v8::String::Empty() +# define NanObjectWrapHandle(obj) v8::Local::New(obj->handle_) - template<> - NAN_INLINE v8::Local - NanNew >( - v8::Local value) { - return v8::StringObject::New(value).As(); + NAN_INLINE v8::Local NanUndefined() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Undefined())); } - template<> - NAN_INLINE v8::Local - NanNew >( - v8::Handle value) { - return v8::StringObject::New(value).As(); + NAN_INLINE v8::Local NanNull() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Null())); } - template<> - NAN_INLINE v8::Local NanNew(double val) { - return v8::NumberObject::New(val).As(); + NAN_INLINE v8::Local NanTrue() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::True())); } - template<> - NAN_INLINE v8::Local NanNew(int32_t val) { - return v8::Uint32::NewFromUnsigned(val)->ToUint32(); + NAN_INLINE v8::Local NanFalse() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::False())); } - template<> - NAN_INLINE v8::Local NanNew(uint32_t val) { - return v8::Uint32::NewFromUnsigned(val)->ToUint32(); + NAN_INLINE int NanAdjustExternalMemory(int bc) { + return static_cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(bc)); } - template<> - NAN_INLINE v8::Local NanNew(int32_t val) { - return v8::Int32::New(val)->ToInt32(); + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , const char *name + , v8::Handle value) { + templ->Set(name, value); } - template<> - NAN_INLINE v8::Local NanNew(uint32_t val) { - return v8::Int32::New(val)->ToInt32(); + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); } - template<> - NAN_INLINE v8::Local NanNew( - uint8_t *arg - , int length) { - uint16_t *warg = new uint16_t[length]; - for (int i = 0; i < length; i++) { - warg[i] = arg[i]; - } - v8::Local retval = v8::String::New(warg, length); - delete[] warg; - return retval; - } - - template<> - NAN_INLINE v8::Local NanNew( - const uint8_t *arg - , int length) { - uint16_t *warg = new uint16_t[length]; - for (int i = 0; i < length; i++) { - warg[i] = arg[i]; - } - v8::Local retval = v8::String::New(warg, length); - delete[] warg; - return retval; + NAN_INLINE v8::Local NanGetCurrentContext() { + return v8::Context::GetCurrent(); } - template<> - NAN_INLINE v8::Local NanNew(uint8_t *arg) { - int length = strlen(reinterpret_cast(arg)); - uint16_t *warg = new uint16_t[length]; - for (int i = 0; i < length; i++) { - warg[i] = arg[i]; - } - - v8::Local retval = v8::String::New(warg, length); - delete[] warg; - return retval; + NAN_INLINE void* NanGetInternalFieldPointer( + v8::Handle object + , int index) { + return object->GetPointerFromInternalField(index); } - template<> - NAN_INLINE v8::Local NanNew( - const uint8_t *arg) { - int length = strlen(reinterpret_cast(arg)); - uint16_t *warg = new uint16_t[length]; - for (int i = 0; i < length; i++) { - warg[i] = arg[i]; - } - v8::Local retval = v8::String::New(warg, length); - delete[] warg; - return retval; + NAN_INLINE void NanSetInternalFieldPointer( + v8::Handle object + , int index + , void* value) { + object->SetPointerInInternalField(index, value); } - template<> - NAN_INLINE v8::Local NanNew() { - return v8::String::Empty(); - } +# define NAN_GC_CALLBACK(name) \ + void name(v8::GCType type, v8::GCCallbackFlags flags) NAN_INLINE void NanAddGCEpilogueCallback( v8::GCEpilogueCallback callback @@ -1160,15 +930,18 @@ typedef v8::InvocationCallback NanFunctionCallback; handle = v8::Persistent::New(obj); } + template + class _NanWeakCallbackData; + template struct _NanWeakCallbackInfo { - typedef void (*Callback)(v8::Persistent object, void* parameter); - _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) : - parameter(param) + typedef void (*Callback)(const _NanWeakCallbackData &data); + NAN_INLINE _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) + : parameter(param) , callback(cb) , persistent(v8::Persistent::New(handle)) { } - ~_NanWeakCallbackInfo() { + NAN_INLINE ~_NanWeakCallbackInfo() { persistent.Dispose(); persistent.Clear(); } @@ -1181,63 +954,67 @@ typedef v8::InvocationCallback NanFunctionCallback; template class _NanWeakCallbackData { public: - _NanWeakCallbackData(_NanWeakCallbackInfo *info) + NAN_INLINE _NanWeakCallbackData(_NanWeakCallbackInfo *info) : info_(info) { } NAN_INLINE v8::Local GetValue() const { return NanNew(info_->persistent); } + NAN_INLINE P* GetParameter() const { return info_->parameter; } - NAN_INLINE void Revive() const { - info_->persistent.MakeWeak(info_, info_->callback); + + NAN_INLINE bool IsNearDeath() const { + return info_->persistent.IsNearDeath(); + } + + NAN_INLINE void Revive() const; + + NAN_INLINE _NanWeakCallbackInfo* GetCallbackInfo() const { + return info_; } - NAN_INLINE void Dispose() const { - delete info_; + + NAN_DEPRECATED NAN_INLINE void Dispose() const { } private: _NanWeakCallbackInfo* info_; }; -# define NanGetInternalFieldPointer(object, index) \ - object->GetPointerFromInternalField(index) -# define NanSetInternalFieldPointer(object, index, value) \ - object->SetPointerInInternalField(index, value) + template + static void _NanWeakPersistentDispatcher( + v8::Persistent object, void *data) { + _NanWeakCallbackInfo* info = + static_cast<_NanWeakCallbackInfo*>(data); + _NanWeakCallbackData wcbd(info); + info->callback(wcbd); + if (wcbd.IsNearDeath()) { + delete wcbd.GetCallbackInfo(); + } + } -// do not use for declaration -# define NAN_WEAK_CALLBACK(name) \ - template \ - static void name( \ - v8::Persistent object, void *data) { \ - _NanWeakCallbackData wcbd( \ - static_cast<_NanWeakCallbackInfo*>(data)); \ - _Nan_Weak_Callback_ ## name(wcbd); \ - } \ - \ - template \ - NAN_INLINE void _Nan_Weak_Callback_ ## name( \ - const _NanWeakCallbackData &data) + template + NAN_INLINE void _NanWeakCallbackData::Revive() const { + info_->persistent.MakeWeak( + info_ + , &_NanWeakPersistentDispatcher); + } template - NAN_INLINE void NanMakeWeakPersistent( + NAN_INLINE _NanWeakCallbackInfo* NanMakeWeakPersistent( v8::Handle handle , P* parameter , typename _NanWeakCallbackInfo::Callback callback) { _NanWeakCallbackInfo *cbinfo = new _NanWeakCallbackInfo(handle, parameter, callback); - cbinfo->persistent.MakeWeak(cbinfo, callback); + cbinfo->persistent.MakeWeak( + cbinfo + , &_NanWeakPersistentDispatcher); + return cbinfo; } -# define NanScope() v8::HandleScope scope -# define NanEscapableScope() v8::HandleScope scope -# define NanEscapeScope(val) scope.Close(val) -# define NanLocker() v8::Locker locker -# define NanUnlocker() v8::Unlocker unlocker -# define NanReturnValue(value) return scope.Close(value) -# define NanReturnUndefined() return v8::Undefined() -# define NanReturnNull() return v8::Null() -# define NanReturnEmptyString() return v8::String::Empty() -# define NanObjectWrapHandle(obj) v8::Local::New(obj->handle_) +# define NAN_WEAK_CALLBACK(name) \ + template \ + static void name(const _NanWeakCallbackData &data) # define _NAN_ERROR(fun, errmsg) \ fun(v8::String::New(errmsg)) @@ -1316,7 +1093,7 @@ typedef v8::InvocationCallback NanFunctionCallback; , node::Buffer::free_callback callback , void *hint ) { - return NanNew( + return NanNew( node::Buffer::New(data, length, callback, hint)->handle_); } @@ -1325,15 +1102,15 @@ typedef v8::InvocationCallback NanFunctionCallback; , uint32_t size ) { #if NODE_MODULE_VERSION >= 0x000B - return NanNew(node::Buffer::New(data, size)->handle_); + return NanNew(node::Buffer::New(data, size)->handle_); #else - return NanNew( + return NanNew( node::Buffer::New(const_cast(data), size)->handle_); #endif } NAN_INLINE v8::Local NanNewBufferHandle (uint32_t size) { - return NanNew(node::Buffer::New(size)->handle_); + return NanNew(node::Buffer::New(size)->handle_); } NAN_INLINE void FreeData(char *data, void *hint) { @@ -1344,24 +1121,24 @@ typedef v8::InvocationCallback NanFunctionCallback; char* data , uint32_t size ) { - return NanNew( + return NanNew( node::Buffer::New(data, size, FreeData, NULL)->handle_); } NAN_INLINE bool NanHasInstance( - v8::Persistent& function_template + const v8::Persistent& function_template , v8::Handle value ) { return function_template->HasInstance(value); } - NAN_INLINE v8::Local NanNewContextHandle( + NAN_DEPRECATED NAN_INLINE v8::Local NanNewContextHandle( v8::ExtensionConfiguration* extensions = NULL , v8::Handle tmpl = v8::Handle() , v8::Handle obj = v8::Handle() ) { v8::Persistent ctx = v8::Context::New(extensions, tmpl, obj); - v8::Local lctx = NanNew(ctx); + v8::Local lctx = NanNew(ctx); ctx.Dispose(); return lctx; } @@ -1379,10 +1156,167 @@ typedef v8::InvocationCallback NanFunctionCallback; return v8::Script::Compile(s); } - NAN_INLINE v8::Local NanRunScript(v8::Local script) { + NAN_INLINE v8::Local NanRunScript(v8::Handle script) { return script->Run(); } + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle func + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, func, argc, argv)); +# else + v8::TryCatch try_catch; + v8::Local result = func->Call(target, argc, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + return result; +# endif + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle symbol + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, symbol, argc, argv)); +# else + v8::Local callback = target->Get(symbol).As(); + return NanMakeCallback(target, callback, argc, argv); +# endif + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , const char* method + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, method, argc, argv)); +# else + return NanMakeCallback(target, NanNew(method), argc, argv); +# endif + } + + template + NAN_INLINE void NanSetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(data); + } + + template + NAN_INLINE T *NanGetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData()); + } + + class NanAsciiString { + public: + NAN_INLINE explicit NanAsciiString(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new char[size + 1]; + size = toStr->WriteAscii(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanAsciiString() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanAsciiString(const NanAsciiString&); + void operator=(const NanAsciiString&); + + char *buf; + int size; + }; + + class NanUtf8String { + public: + NAN_INLINE explicit NanUtf8String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Utf8Length(); + buf = new char[size + 1]; + toStr->WriteUtf8(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanUtf8String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUtf8String(const NanUtf8String&); + void operator=(const NanUtf8String&); + + char *buf; + int size; + }; + + class NanUcs2String { + public: + NAN_INLINE explicit NanUcs2String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new uint16_t[size + 1]; + toStr->Write(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE uint16_t* operator*() { return buf; } + NAN_INLINE const uint16_t* operator*() const { return buf; } + + NAN_INLINE ~NanUcs2String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUcs2String(const NanUcs2String&); + void operator=(const NanUcs2String&); + + uint16_t *buf; + int size; + }; + #endif // NODE_MODULE_VERSION typedef void (*NanFreeCallback)(char *data, void *hint); @@ -1454,51 +1388,62 @@ class NanCallback { NAN_INLINE void SetFunction(const v8::Handle &fn) { NanScope(); - NanNew(handle)->Set(NanSymbol("callback"), fn); + NanNew(handle)->Set(kCallbackIndex, fn); } - NAN_INLINE v8::Local GetFunction () { - return NanNew(handle)->Get(NanSymbol("callback")) - .As(); + NAN_INLINE v8::Local GetFunction() const { + NanEscapableScope(); + return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex) + .As()); } - void Call(int argc, v8::Handle argv[]) { + NAN_INLINE bool IsEmpty() const { NanScope(); + return NanNew(handle)->Get(kCallbackIndex)->IsUndefined(); + } + + v8::Handle Call(int argc, v8::Handle argv[]) const { + NanEscapableScope(); #if (NODE_MODULE_VERSION > 0x000B) // 0.11.12+ + v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Local callback = NanNew(handle)-> - Get(NanSymbol("callback")).As(); - node::MakeCallback( - nan_isolate - , nan_isolate->GetCurrentContext()->Global() + Get(kCallbackIndex).As(); + return NanEscapeScope(node::MakeCallback( + isolate + , isolate->GetCurrentContext()->Global() , callback , argc , argv - ); + )); #else #if NODE_VERSION_AT_LEAST(0, 8, 0) - v8::Local callback = NanNew(handle)-> - Get(NanSymbol("callback")).As(); - node::MakeCallback( + v8::Local callback = handle-> + Get(kCallbackIndex).As(); + return NanEscapeScope(node::MakeCallback( v8::Context::GetCurrent()->Global() , callback , argc , argv - ); + )); #else - node::MakeCallback(handle, "callback", argc, argv); + v8::Local callback = handle-> + Get(kCallbackIndex).As(); + return NanEscapeScope(NanMakeCallback( + v8::Context::GetCurrent()->Global(), callback, argc, argv)); #endif #endif } private: v8::Persistent handle; + static const uint32_t kCallbackIndex = 0; }; /* abstract */ class NanAsyncWorker { public: - explicit NanAsyncWorker(NanCallback *callback) : callback(callback) { + explicit NanAsyncWorker(NanCallback *callback_) + : callback(callback_), errmsg_(NULL) { request.data = this; - errmsg = NULL; NanScope(); v8::Local obj = NanNew(); @@ -1512,14 +1457,14 @@ class NanCallback { NanDisposePersistent(persistentHandle); if (callback) delete callback; - if (errmsg) - delete errmsg; + if (errmsg_) + delete[] errmsg_; } virtual void WorkComplete() { NanScope(); - if (errmsg == NULL) + if (errmsg_ == NULL) HandleOKCallback(); else HandleErrorCallback(); @@ -1527,29 +1472,31 @@ class NanCallback { callback = NULL; } - NAN_INLINE void SaveToPersistent(const char *key, v8::Local &obj) { + NAN_INLINE void SaveToPersistent( + const char *key, const v8::Local &obj) { v8::Local handle = NanNew(persistentHandle); - handle->Set(NanSymbol(key), obj); + handle->Set(NanNew(key), obj); } - v8::Local GetFromPersistent(const char *key) { + v8::Local GetFromPersistent(const char *key) const { NanEscapableScope(); v8::Local handle = NanNew(persistentHandle); - return NanEscapeScope(handle->Get(NanSymbol(key)).As()); + return NanEscapeScope(handle->Get(NanNew(key)).As()); } virtual void Execute() = 0; uv_work_t request; + virtual void Destroy() { + delete this; + } + protected: v8::Persistent persistentHandle; NanCallback *callback; - const char *errmsg; virtual void HandleOKCallback() { - NanScope(); - callback->Call(0, NULL); } @@ -1557,10 +1504,133 @@ class NanCallback { NanScope(); v8::Local argv[] = { - v8::Exception::Error(NanNew(errmsg)) + v8::Exception::Error(NanNew(ErrorMessage())) }; callback->Call(1, argv); } + + void SetErrorMessage(const char *msg) { + if (errmsg_) { + delete[] errmsg_; + } + + size_t size = strlen(msg) + 1; + errmsg_ = new char[size]; + memcpy(errmsg_, msg, size); + } + + const char* ErrorMessage() const { + return errmsg_; + } + + private: + char *errmsg_; +}; + +/* abstract */ class NanAsyncProgressWorker : public NanAsyncWorker { + public: + explicit NanAsyncProgressWorker(NanCallback *callback_) + : NanAsyncWorker(callback_), asyncdata_(NULL), asyncsize_(0) { + async = new uv_async_t; + uv_async_init( + uv_default_loop() + , async + , AsyncProgress_ + ); + async->data = this; + + uv_mutex_init(&async_lock); + } + + virtual ~NanAsyncProgressWorker() { + uv_mutex_destroy(&async_lock); + + if (asyncdata_) { + delete[] asyncdata_; + } + } + + void WorkProgress() { + uv_mutex_lock(&async_lock); + char *data = asyncdata_; + size_t size = asyncsize_; + asyncdata_ = NULL; + uv_mutex_unlock(&async_lock); + + // Dont send progress events after we've already completed. + if (callback) { + HandleProgressCallback(data, size); + } + delete[] data; + } + + class ExecutionProgress { + friend class NanAsyncProgressWorker; + public: + // You could do fancy generics with templates here. + void Send(const char* data, size_t size) const { + that_->SendProgress_(data, size); + } + + private: + explicit ExecutionProgress(NanAsyncProgressWorker* that) : that_(that) {} + // Prohibit copying and assignment. + ExecutionProgress(const ExecutionProgress&); + void operator=(const ExecutionProgress&); + #if __cplusplus >= 201103L + // Prohibit C++11 move semantics. + ExecutionProgress(ExecutionProgress&&) = delete; + void operator=(ExecutionProgress&&) = delete; + #endif + NanAsyncProgressWorker* const that_; + }; + + virtual void Execute(const ExecutionProgress& progress) = 0; + virtual void HandleProgressCallback(const char *data, size_t size) = 0; + + virtual void Destroy() { + uv_close(reinterpret_cast(async), AsyncClose_); + } + + private: + void Execute() /*final override*/ { + ExecutionProgress progress(this); + Execute(progress); + } + + void SendProgress_(const char *data, size_t size) { + char *new_data = new char[size]; + memcpy(new_data, data, size); + + uv_mutex_lock(&async_lock); + char *old_data = asyncdata_; + asyncdata_ = new_data; + asyncsize_ = size; + uv_mutex_unlock(&async_lock); + + if (old_data) { + delete[] old_data; + } + uv_async_send(async); + } + + NAN_INLINE static NAUV_WORK_CB(AsyncProgress_) { + NanAsyncProgressWorker *worker = + static_cast(async->data); + worker->WorkProgress(); + } + + NAN_INLINE static void AsyncClose_(uv_handle_t* handle) { + NanAsyncProgressWorker *worker = + static_cast(handle->data); + delete reinterpret_cast(handle); + delete worker; + } + + uv_async_t *async; + uv_mutex_t async_lock; + char *asyncdata_; + size_t asyncsize_; }; NAN_INLINE void NanAsyncExecute (uv_work_t* req) { @@ -1571,7 +1641,7 @@ NAN_INLINE void NanAsyncExecute (uv_work_t* req) { NAN_INLINE void NanAsyncExecuteComplete (uv_work_t* req) { NanAsyncWorker* worker = static_cast(req->data); worker->WorkComplete(); - delete worker; + worker->Destroy(); } NAN_INLINE void NanAsyncQueueWorker (NanAsyncWorker* worker) { @@ -1711,6 +1781,30 @@ template static size_t _nan_hex_decode( return i; } +namespace NanIntern { + +inline +NanExternalOneByteStringResource const* +GetExternalResource(v8::Local str) { +#if NODE_MODULE_VERSION < 42 + return str->GetExternalAsciiStringResource(); +#else // io.js v1.0.0 + return str->GetExternalOneByteStringResource(); +#endif +} + +inline +bool +IsExternal(v8::Local str) { +#if NODE_MODULE_VERSION < 42 + return str->IsExternalAscii(); +#else // io.js v1.0.0 + return str->IsExternalOneByte(); +#endif +} + +} // end of namespace NanIntern + static bool _NanGetExternalParts( v8::Handle val , const char** data @@ -1723,16 +1817,17 @@ static bool _NanGetExternalParts( } assert(val->IsString()); - v8::Local str = NanNew(val.As()); + v8::Local str = NanNew(val.As()); - if (str->IsExternalAscii()) { - const v8::String::ExternalAsciiStringResource* ext; - ext = str->GetExternalAsciiStringResource(); + if (NanIntern::IsExternal(str)) { + const NanExternalOneByteStringResource* ext; + ext = NanIntern::GetExternalResource(str); *data = ext->data(); *len = ext->length(); return true; + } - } else if (str->IsExternal()) { + if (str->IsExternal()) { const v8::String::ExternalStringResource* ext; ext = str->GetExternalStringResource(); *data = reinterpret_cast(ext->data()); @@ -1747,7 +1842,86 @@ namespace Nan { enum Encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER}; } -NAN_INLINE void* NanRawString( +#if !NODE_VERSION_AT_LEAST(0, 10, 0) +# include "nan_string_bytes.h" // NOLINT(build/include) +#endif + +NAN_INLINE v8::Local NanEncode( + const void *buf, size_t len, enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION >= 42) + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + node::encoding node_enc = static_cast(encoding); + + if (encoding == Nan::UCS2) { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len / 2); + } else { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len + , node_enc); + } +#elif (NODE_MODULE_VERSION > 0x000B) + return node::Encode( + v8::Isolate::GetCurrent() + , buf, len + , static_cast(encoding)); +#else +# if NODE_VERSION_AT_LEAST(0, 10, 0) + return node::Encode(buf, len, static_cast(encoding)); +# else + return NanIntern::Encode(reinterpret_cast(buf), len, encoding); +# endif +#endif +} + +NAN_INLINE ssize_t NanDecodeBytes( + v8::Handle val, enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION > 0x000B) + return node::DecodeBytes( + v8::Isolate::GetCurrent() + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < 0x000B) + if (encoding == Nan::BUFFER) { + return node::DecodeBytes(val, node::BINARY); + } +# endif + return node::DecodeBytes(val, static_cast(encoding)); +#endif +} + +NAN_INLINE ssize_t NanDecodeWrite( + char *buf + , size_t len + , v8::Handle val + , enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION > 0x000B) + return node::DecodeWrite( + v8::Isolate::GetCurrent() + , buf + , len + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < 0x000B) + if (encoding == Nan::BUFFER) { + return node::DecodeWrite(buf, len, val, node::BINARY); + } +# endif + return node::DecodeWrite( + buf + , len + , val + , static_cast(encoding)); +#endif +} + +/* NAN_DEPRECATED */ NAN_INLINE void* _NanRawString( v8::Handle from , enum Nan::Encoding encoding , size_t *datalen @@ -1801,15 +1975,15 @@ NAN_INLINE void* NanRawString( { uint16_t* twobytebuf = new uint16_t[sz_ + term_len]; - size_t len = toStr->Write(twobytebuf, 0, + size_t somelen = toStr->Write(twobytebuf, 0, static_cast(sz_ + term_len), flags); - for (size_t i = 0; i < sz_ + term_len && i < len + term_len; i++) { + for (size_t i = 0; i < sz_ + term_len && i < somelen + term_len; i++) { unsigned char *b = reinterpret_cast(&twobytebuf[i]); to[i] = *b; } - NanSetPointerSafe(datalen, len); + NanSetPointerSafe(datalen, somelen); delete[] twobytebuf; return to; @@ -1895,7 +2069,19 @@ NAN_INLINE void* NanRawString( return to; } -NAN_INLINE char* NanCString( +NAN_DEPRECATED NAN_INLINE void* NanRawString( + v8::Handle from + , enum Nan::Encoding encoding + , size_t *datalen + , void *buf + , size_t buflen + , int flags +) { + return _NanRawString(from, encoding, datalen, buf, buflen, flags); +} + + +NAN_DEPRECATED NAN_INLINE char* NanCString( v8::Handle from , size_t *datalen , char *buf = NULL @@ -1903,8 +2089,86 @@ NAN_INLINE char* NanCString( , int flags = v8::String::NO_OPTIONS ) { return static_cast( - NanRawString(from, Nan::UTF8, datalen, buf, buflen, flags) + _NanRawString(from, Nan::UTF8, datalen, buf, buflen, flags) ); } +NAN_INLINE void NanSetPrototypeTemplate( + v8::Local templ + , const char *name + , v8::Handle value +) { + NanSetTemplate(templ->PrototypeTemplate(), name, value); +} + +NAN_INLINE void NanSetPrototypeTemplate( + v8::Local templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes +) { + NanSetTemplate(templ->PrototypeTemplate(), name, value, attributes); +} + +NAN_INLINE void NanSetInstanceTemplate( + v8::Local templ + , const char *name + , v8::Handle value +) { + NanSetTemplate(templ->InstanceTemplate(), name, value); +} + +NAN_INLINE void NanSetInstanceTemplate( + v8::Local templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes +) { + NanSetTemplate(templ->InstanceTemplate(), name, value, attributes); +} + +//=== Export ================================================================== + +inline +void +NanExport(v8::Handle target, const char * name, + NanFunctionCallback f) { + target->Set(NanNew(name), + NanNew(f)->GetFunction()); +} + +//=== Tap Reverse Binding ===================================================== + +struct NanTap { + explicit NanTap(v8::Handle t) : t_() { + NanAssignPersistent(t_, t->ToObject()); + } + + ~NanTap() { NanDisposePersistent(t_); } // not sure if neccessary + + inline void plan(int i) { + v8::Handle arg = NanNew(i); + NanMakeCallback(NanNew(t_), "plan", 1, &arg); + } + + inline void ok(bool isOk, const char * msg = NULL) { + v8::Handle args[2]; + args[0] = NanNew(isOk); + if (msg) args[1] = NanNew(msg); + NanMakeCallback(NanNew(t_), "ok", msg ? 2 : 1, args); + } + + private: + v8::Persistent t_; +}; + +#define NAN_STRINGIZE2(x) #x +#define NAN_STRINGIZE(x) NAN_STRINGIZE2(x) +#define NAN_TEST_EXPRESSION(expression) \ + ( expression ), __FILE__ ":" NAN_STRINGIZE(__LINE__) ": " #expression + +#define return_NanValue(v) NanReturnValue(v) +#define return_NanUndefined() NanReturnUndefined() +#define NAN_EXPORT(target, function) NanExport(target, #function, function) + #endif // NAN_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_12_inl.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_12_inl.h new file mode 100644 index 0000000..ff63ec0 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_12_inl.h @@ -0,0 +1,262 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_12_INL_H_ +#define NAN_IMPLEMENTATION_12_INL_H_ +//============================================================================== +// node v0.11 implementation +//============================================================================== + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif + +namespace NanIntern { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(v8::Isolate::GetCurrent()); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(v8::Isolate::GetCurrent(), length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(v8::Isolate::GetCurrent(), value); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Handle tmpl + , v8::Handle obj) { + return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj); +} + +//=== Date ===================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Date::New(v8::Isolate::GetCurrent(), value).As(); +} + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(v8::Isolate::GetCurrent(), value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data) { + return v8::Function::New( v8::Isolate::GetCurrent() + , callback + , data); +} + +//=== Function Template ======================================================== + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data + , v8::Handle signature) { + return v8::FunctionTemplate::New( v8::Isolate::GetCurrent() + , callback + , data + , signature); +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(v8::Isolate::GetCurrent(), value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New( v8::Isolate::GetCurrent() + , value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(v8::Isolate::GetCurrent(), value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(v8::Isolate::GetCurrent()); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(v8::Isolate::GetCurrent()); +} + +//=== RegExp =================================================================== + +Factory::return_t +Factory::New( + v8::Handle pattern + , v8::RegExp::Flags flags) { + return v8::RegExp::New(pattern, flags); +} + +//=== Script =================================================================== + +Factory::return_t +Factory::New( v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src); +} + +//=== Signature ================================================================ + +Factory::return_t +Factory::New( Factory::FTH receiver + , int argc + , Factory::FTH argv[]) { + return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return v8::String::Empty(v8::Isolate::GetCurrent()); +} + +Factory::return_t +Factory::New(const char * value, int length) { + return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(std::string const& value) { + assert(value.size() <= INT_MAX && "string too long"); + return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), + value.data(), v8::String::kNormalString, static_cast(value.size())); +} + +Factory::return_t +Factory::New(const uint8_t * value, int length) { + return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return v8::String::NewExternal(v8::Isolate::GetCurrent(), value); +} + +Factory::return_t +Factory::New(NanExternalOneByteStringResource * value) { + return v8::String::NewExternal(v8::Isolate::GetCurrent(), value); +} + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Handle value) { + return v8::StringObject::New(value).As(); +} + +//=== Unbound Script =========================================================== + +Factory::return_t +Factory::New(v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src); +} + +} // end of namespace NanIntern + +//=== Presistents and Handles ================================================== + +template +inline v8::Local NanNew(v8::Handle h) { + return v8::Local::New(v8::Isolate::GetCurrent(), h); +} + +template +inline v8::Local NanNew(v8::Persistent const& p) { + return v8::Local::New(v8::Isolate::GetCurrent(), p); +} + +#endif // NAN_IMPLEMENTATION_12_INL_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_pre_12_inl.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_pre_12_inl.h new file mode 100644 index 0000000..85dd275 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_implementation_pre_12_inl.h @@ -0,0 +1,268 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_ +#define NAN_IMPLEMENTATION_PRE_12_INL_H_ + +#include + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# include +# pragma warning( default : 4530 ) +#else +# include +# include +#endif + +//============================================================================== +// node v0.10 implementation +//============================================================================== + +namespace NanIntern { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(value)->ToBoolean(); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Handle tmpl + , v8::Handle obj) { + v8::Persistent ctx = v8::Context::New(extensions, tmpl, obj); + v8::Local lctx = v8::Local::New(ctx); + ctx.Dispose(); + return lctx; +} + +//=== Date ===================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Date::New(value).As(); +} + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data) { + return Factory::New( callback + , data + , v8::Handle() + )->GetFunction(); +} + + +//=== FunctionTemplate ========================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data + , v8::Handle signature) { + // Note(agnat): Emulate length argument here. Unfortunately, I couldn't find + // a way. Have at it though... + return v8::FunctionTemplate::New( callback + , data + , signature); +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New(value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(); +} + +//=== RegExp =================================================================== + +Factory::return_t +Factory::New( + v8::Handle pattern + , v8::RegExp::Flags flags) { + return v8::RegExp::New(pattern, flags); +} + +//=== Script =================================================================== + +Factory::return_t +Factory::New( v8::Local source) { + return v8::Script::New(source); +} +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + return v8::Script::New(source, const_cast(&origin)); +} + +//=== Signature ================================================================ + +Factory::return_t +Factory::New( Factory::FTH receiver + , int argc + , Factory::FTH argv[]) { + return v8::Signature::New(receiver, argc, argv); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return v8::String::Empty(); +} + +Factory::return_t +Factory::New(const char * value, int length) { + return v8::String::New(value, length); +} + +Factory::return_t +Factory::New(std::string const& value) { + assert(value.size() <= INT_MAX && "string too long"); + return v8::String::New( value.data(), static_cast(value.size())); +} + +inline +void +widenString(std::vector *ws, const uint8_t *s, int l = -1) { + size_t len = static_cast(l); + if (l < 0) { + len = strlen(reinterpret_cast(s)); + } + assert(len <= INT_MAX && "string too long"); + ws->resize(len); + std::copy(s, s + len, ws->begin()); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return v8::String::New(value, length); +} + +Factory::return_t +Factory::New(const uint8_t * value, int length) { + std::vector wideString; + widenString(&wideString, value, length); + if (wideString.size() == 0) { + return v8::String::Empty(); + } else { + return v8::String::New(&wideString.front() + , static_cast(wideString.size())); + } +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return v8::String::NewExternal(value); +} + +Factory::return_t +Factory::New(v8::String::ExternalAsciiStringResource * value) { + return v8::String::NewExternal(value); +} + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Handle value) { + return v8::StringObject::New(value).As(); +} + +} // end of namespace NanIntern + +//=== Presistents and Handles ================================================== + +template +inline v8::Local NanNew(v8::Handle h) { + return v8::Local::New(h); +} + +template +inline v8::Local NanNew(v8::Persistent const& p) { + return v8::Local::New(p); +} + +#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_new.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_new.h new file mode 100644 index 0000000..95b6b51 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_new.h @@ -0,0 +1,329 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_NEW_H_ +#define NAN_NEW_H_ + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif + +namespace NanIntern { // scnr + +// TODO(agnat): Generalize +template v8::Local To(v8::Handle i); + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToInteger(); } + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToInt32(); } + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToUint32(); } + +template struct FactoryBase { typedef v8::Local return_t; }; + +template struct Factory; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); + static inline return_t New(int length); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( v8::ExtensionConfiguration* extensions = NULL + , v8::Handle tmpl = v8::Handle() + , v8::Handle obj = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(void *value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( NanFunctionCallback callback + , v8::Handle data = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( NanFunctionCallback callback = NULL + , v8::Handle data = v8::Handle() + , v8::Handle signature = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template +struct IntegerFactory : FactoryBase { + typedef typename FactoryBase::return_t return_t; + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New( + v8::Handle pattern, v8::RegExp::Flags flags); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +template <> +struct Factory : FactoryBase { + typedef v8::Handle FTH; + static inline + return_t + New( FTH receiver = FTH(), int argc = 0, FTH argv[] = NULL ); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); + static inline return_t New(const char *value, int length = -1); + static inline return_t New(const uint16_t *value, int length = -1); + static inline return_t New(std::string const& value); + + static inline return_t New(v8::String::ExternalStringResource * value); + static inline return_t New(NanExternalOneByteStringResource * value); + + // TODO(agnat): Deprecate. + static inline return_t New(const uint8_t * value, int length = -1); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(v8::Handle value); +}; + +} // end of namespace NanIntern + +#if (NODE_MODULE_VERSION >= 12) + +namespace NanIntern { + +template <> +struct Factory : FactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +} // end of namespace NanIntern + +# include "nan_implementation_12_inl.h" + +#else // NODE_MODULE_VERSION >= 12 + +# include "nan_implementation_pre_12_inl.h" + +#endif + +//=== API ====================================================================== + +template +typename NanIntern::Factory::return_t +NanNew() { + return NanIntern::Factory::New(); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0) { + return NanIntern::Factory::New(arg0); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1) { + return NanIntern::Factory::New(arg0, arg1); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1, A2 arg2) { + return NanIntern::Factory::New(arg0, arg1, arg2); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1, A2 arg2, A3 arg3) { + return NanIntern::Factory::New(arg0, arg1, arg2, arg3); +} + +// Note(agnat): When passing overloaded function pointers to template functions +// as generic arguments the compiler needs help in picking the right overload. +// These two functions handle NanNew and NanNew with +// all argument variations. + +// v8::Function and v8::FunctionTemplate with one or two arguments +template +typename NanIntern::Factory::return_t +NanNew( NanFunctionCallback callback + , v8::Handle data = v8::Handle()) { + return NanIntern::Factory::New(callback, data); +} + +// v8::Function and v8::FunctionTemplate with three arguments +template +typename NanIntern::Factory::return_t +NanNew( NanFunctionCallback callback + , v8::Handle data = v8::Handle() + , A2 a2 = A2()) { + return NanIntern::Factory::New(callback, data, a2); +} + +// Convenience + +template inline v8::Local NanNew(v8::Handle h); +template inline v8::Local NanNew(v8::Persistent const& p); + +inline +NanIntern::Factory::return_t +NanNew(bool value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(int32_t value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(uint32_t value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(double value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(std::string const& value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const char * value, int length) { + return NanNew(value, length); +} + +inline +NanIntern::Factory::return_t +NanNew(const char * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const uint8_t * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const uint16_t * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(v8::String::ExternalStringResource * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(NanExternalOneByteStringResource * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(v8::Handle pattern, v8::RegExp::Flags flags) { + return NanNew(pattern, flags); +} + +#endif // NAN_NEW_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_string_bytes.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_string_bytes.h new file mode 100644 index 0000000..9deecfb --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/nan_string_bytes.h @@ -0,0 +1,312 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef NAN_STRING_BYTES_H_ +#define NAN_STRING_BYTES_H_ + +// Decodes a v8::Handle or Buffer to a raw char* + +#include +#include +#include +#include // memcpy +#include + +namespace NanIntern { + +using v8::Local; +using v8::Handle; +using v8::Object; +using v8::String; +using v8::Value; + + +//// Base 64 //// + +#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) + + + +//// Nan::HEX //// + +static bool contains_non_ascii_slow(const char* buf, size_t len) { + for (size_t i = 0; i < len; ++i) { + if (buf[i] & 0x80) return true; + } + return false; +} + + +static bool contains_non_ascii(const char* src, size_t len) { + if (len < 16) { + return contains_non_ascii_slow(src, len); + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned unaligned = reinterpret_cast(src) & align_mask; + + if (unaligned > 0) { + const unsigned n = bytes_per_word - unaligned; + if (contains_non_ascii_slow(src, n)) return true; + src += n; + len -= n; + } + + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = 0x8080808080808080ll; +#else + const uintptr_t mask = 0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + if (srcw[i] & mask) return true; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + if (contains_non_ascii_slow(src + offset, remainder)) return true; + } + + return false; +} + + +static void force_ascii_slow(const char* src, char* dst, size_t len) { + for (size_t i = 0; i < len; ++i) { + dst[i] = src[i] & 0x7f; + } +} + + +static void force_ascii(const char* src, char* dst, size_t len) { + if (len < 16) { + force_ascii_slow(src, dst, len); + return; + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned src_unalign = reinterpret_cast(src) & align_mask; + const unsigned dst_unalign = reinterpret_cast(dst) & align_mask; + + if (src_unalign > 0) { + if (src_unalign == dst_unalign) { + const unsigned unalign = bytes_per_word - src_unalign; + force_ascii_slow(src, dst, unalign); + src += unalign; + dst += unalign; + len -= src_unalign; + } else { + force_ascii_slow(src, dst, len); + return; + } + } + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = ~0x8080808080808080ll; +#else + const uintptr_t mask = ~0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + uintptr_t* dstw = reinterpret_cast(dst); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + dstw[i] = srcw[i] & mask; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + force_ascii_slow(src + offset, dst + offset, remainder); + } +} + + +static size_t base64_encode(const char* src, + size_t slen, + char* dst, + size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= base64_encoded_size(slen) && + "not enough space provided for base64 encode"); + + dlen = base64_encoded_size(slen); + + unsigned a; + unsigned b; + unsigned c; + unsigned i; + unsigned k; + unsigned n; + + static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + i = 0; + k = 0; + n = slen / 3 * 3; + + while (i < n) { + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + c = src[i + 2] & 0xff; + + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)]; + dst[k + 3] = table[c & 0x3f]; + + i += 3; + k += 4; + } + + if (n != slen) { + switch (slen - n) { + case 1: + a = src[i + 0] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[(a & 3) << 4]; + dst[k + 2] = '='; + dst[k + 3] = '='; + break; + + case 2: + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[(b & 0x0f) << 2]; + dst[k + 3] = '='; + break; + } + } + + return dlen; +} + + +static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= slen * 2 && + "not enough space provided for hex encode"); + + dlen = slen * 2; + for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) { + static const char hex[] = "0123456789abcdef"; + uint8_t val = static_cast(src[i]); + dst[k + 0] = hex[val >> 4]; + dst[k + 1] = hex[val & 15]; + } + + return dlen; +} + + + +static Local Encode(const char* buf, + size_t buflen, + enum Nan::Encoding encoding) { + assert(buflen <= node::Buffer::kMaxLength); + if (!buflen && encoding != Nan::BUFFER) + return NanNew(""); + + Local val; + switch (encoding) { + case Nan::BUFFER: + return NanNewBufferHandle(buf, buflen); + + case Nan::ASCII: + if (contains_non_ascii(buf, buflen)) { + char* out = new char[buflen]; + force_ascii(buf, out, buflen); + val = NanNew(out, buflen); + delete[] out; + } else { + val = NanNew(buf, buflen); + } + break; + + case Nan::UTF8: + val = NanNew(buf, buflen); + break; + + case Nan::BINARY: { + // TODO(isaacs) use ExternalTwoByteString? + const unsigned char *cbuf = reinterpret_cast(buf); + uint16_t * twobytebuf = new uint16_t[buflen]; + for (size_t i = 0; i < buflen; i++) { + // XXX is the following line platform independent? + twobytebuf[i] = cbuf[i]; + } + val = NanNew(twobytebuf, buflen); + delete[] twobytebuf; + break; + } + + case Nan::BASE64: { + size_t dlen = base64_encoded_size(buflen); + char* dst = new char[dlen]; + + size_t written = base64_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = NanNew(dst, dlen); + delete[] dst; + break; + } + + case Nan::UCS2: { + const uint16_t* data = reinterpret_cast(buf); + val = NanNew(data, buflen / 2); + break; + } + + case Nan::HEX: { + size_t dlen = buflen * 2; + char* dst = new char[dlen]; + size_t written = hex_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = NanNew(dst, dlen); + delete[] dst; + break; + } + + default: + assert(0 && "unknown encoding"); + break; + } + + return val; +} + +#undef base64_encoded_size + +} // namespace NanIntern + +#endif // NAN_STRING_BYTES_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/package.json new file mode 100644 index 0000000..55f0dc4 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/node_modules/nan/package.json @@ -0,0 +1,89 @@ +{ + "name": "nan", + "version": "1.6.2", + "description": "Native Abstractions for Node.js: C++ header for Node 0.8->0.12 compatibility", + "main": "include_dirs.js", + "repository": { + "type": "git", + "url": "git://github.com/rvagg/nan.git" + }, + "scripts": { + "test": "tap --gc test/js/*-test.js", + "rebuild-tests": "pangyp rebuild --directory test" + }, + "contributors": [ + { + "name": "Rod Vagg", + "email": "r@va.gg", + "url": "https://github.com/rvagg" + }, + { + "name": "Benjamin Byholm", + "email": "bbyholm@abo.fi", + "url": "https://github.com/kkoopa/" + }, + { + "name": "Trevor Norris", + "email": "trev.norris@gmail.com", + "url": "https://github.com/trevnorris" + }, + { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "https://github.com/TooTallNate" + }, + { + "name": "Brett Lawson", + "email": "brett19@gmail.com", + "url": "https://github.com/brett19" + }, + { + "name": "Ben Noordhuis", + "email": "info@bnoordhuis.nl", + "url": "https://github.com/bnoordhuis" + }, + { + "name": "David Siegel", + "email": "david@artcom.de", + "url": "https://github.com/agnat" + } + ], + "devDependencies": { + "bindings": "~1.2.1", + "node-gyp": "~1.0.2", + "pangyp": "~2.0.1", + "tap": "~0.5.0", + "xtend": "~4.0.0" + }, + "license": "MIT", + "gitHead": "ab0e5eed8d4aa36111bf8f44cf75644ece327e98", + "bugs": { + "url": "https://github.com/rvagg/nan/issues" + }, + "homepage": "https://github.com/rvagg/nan", + "_id": "nan@1.6.2", + "_shasum": "2657d1c43b00f1e847e083832285b7d8f5ba8ec8", + "_from": "nan@1.6.2", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "kkoopa", + "email": "bbyholm@abo.fi" + }, + "maintainers": [ + { + "name": "rvagg", + "email": "rod@vagg.org" + }, + { + "name": "kkoopa", + "email": "bbyholm@abo.fi" + } + ], + "dist": { + "shasum": "2657d1c43b00f1e847e083832285b7d8f5ba8ec8", + "tarball": "http://registry.npmjs.org/nan/-/nan-1.6.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/nan/-/nan-1.6.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/package.json new file mode 100644 index 0000000..c483e3c --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/package.json @@ -0,0 +1,54 @@ +{ + "name": "bufferutil", + "version": "1.0.1", + "description": "WebSocket buffer utils", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "install": "node-gyp rebuild" + }, + "repository": { + "type": "git", + "url": "https://github.com/websockets/bufferutil" + }, + "keywords": [ + "bufferutil" + ], + "author": { + "name": "Einar Otto Stangvik", + "email": "einaros@gmail.com", + "url": "http://2x.io" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/websockets/bufferutil/issues" + }, + "homepage": "https://github.com/websockets/bufferutil", + "dependencies": { + "bindings": "1.2.x", + "nan": "1.6.x" + }, + "gypfile": true, + "gitHead": "3bbb6f23193fae7683b61e2cae1f85ede5fb4469", + "_id": "bufferutil@1.0.1", + "_shasum": "0c53a9ffe8d616c4e2df27d00b808f7a25501e3b", + "_from": "bufferutil@1.0.x", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + } + ], + "dist": { + "shasum": "0c53a9ffe8d616c4e2df27d00b808f7a25501e3b", + "tarball": "http://registry.npmjs.org/bufferutil/-/bufferutil-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-1.0.1.tgz" +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/src/bufferutil.cc b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/src/bufferutil.cc similarity index 92% rename from node_modules/auto-reload-brunch/node_modules/ws/src/bufferutil.cc rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/src/bufferutil.cc index 7f99bd6..bd6f368 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/src/bufferutil.cc +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil/src/bufferutil.cc @@ -1,11 +1,12 @@ /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik + * bufferutil: WebSocket buffer utils + * Copyright(c) 2015 Einar Otto Stangvik * MIT Licensed */ #include #include +#include #include #include #include @@ -29,7 +30,7 @@ class BufferUtil : public ObjectWrap NODE_SET_METHOD(t, "unmask", BufferUtil::Unmask); NODE_SET_METHOD(t, "mask", BufferUtil::Mask); NODE_SET_METHOD(t, "merge", BufferUtil::Merge); - target->Set(NanSymbol("BufferUtil"), t->GetFunction()); + target->Set(NanNew("BufferUtil"), t->GetFunction()); } protected: @@ -107,7 +108,10 @@ class BufferUtil : public ObjectWrap } }; -extern "C" void init (Handle target) +#if !NODE_VERSION_AT_LEAST(0,10,0) +extern "C" +#endif +void init (Handle target) { NanScope(); BufferUtil::Initialize(target); diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/Readme.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/Readme.md deleted file mode 100644 index d164401..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/Readme.md +++ /dev/null @@ -1,195 +0,0 @@ -# Commander.js - - The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander). - - [![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js) - -## Installation - - $ npm install commander - -## Option parsing - - Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options. - -```js -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var program = require('commander'); - -program - .version('0.0.1') - .option('-p, --peppers', 'Add peppers') - .option('-P, --pineapple', 'Add pineapple') - .option('-b, --bbq', 'Add bbq sauce') - .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble') - .parse(process.argv); - -console.log('you ordered a pizza with:'); -if (program.peppers) console.log(' - peppers'); -if (program.pineapple) console.log(' - pineapple'); -if (program.bbq) console.log(' - bbq'); -console.log(' - %s cheese', program.cheese); -``` - - Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. - -## Automated --help - - The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free: - -``` - $ ./examples/pizza --help - - Usage: pizza [options] - - Options: - - -V, --version output the version number - -p, --peppers Add peppers - -P, --pineapple Add pineapple - -b, --bbq Add bbq sauce - -c, --cheese Add the specified type of cheese [marble] - -h, --help output usage information - -``` - -## Coercion - -```js -function range(val) { - return val.split('..').map(Number); -} - -function list(val) { - return val.split(','); -} - -program - .version('0.0.1') - .usage('[options] ') - .option('-i, --integer ', 'An integer argument', parseInt) - .option('-f, --float ', 'A float argument', parseFloat) - .option('-r, --range ..', 'A range', range) - .option('-l, --list ', 'A list', list) - .option('-o, --optional [value]', 'An optional value') - .parse(process.argv); - -console.log(' int: %j', program.integer); -console.log(' float: %j', program.float); -console.log(' optional: %j', program.optional); -program.range = program.range || []; -console.log(' range: %j..%j', program.range[0], program.range[1]); -console.log(' list: %j', program.list); -console.log(' args: %j', program.args); -``` - -## Custom help - - You can display arbitrary `-h, --help` information - by listening for "--help". Commander will automatically - exit once you are done so that the remainder of your program - does not execute causing undesired behaviours, for example - in the following executable "stuff" will not output when - `--help` is used. - -```js -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var program = require('../'); - -function list(val) { - return val.split(',').map(Number); -} - -program - .version('0.0.1') - .option('-f, --foo', 'enable some foo') - .option('-b, --bar', 'enable some bar') - .option('-B, --baz', 'enable some baz'); - -// must be before .parse() since -// node's emit() is immediate - -program.on('--help', function(){ - console.log(' Examples:'); - console.log(''); - console.log(' $ custom-help --help'); - console.log(' $ custom-help -h'); - console.log(''); -}); - -program.parse(process.argv); - -console.log('stuff'); -``` - -yielding the following help output: - -``` - -Usage: custom-help [options] - -Options: - - -h, --help output usage information - -V, --version output the version number - -f, --foo enable some foo - -b, --bar enable some bar - -B, --baz enable some baz - -Examples: - - $ custom-help --help - $ custom-help -h - -``` - -## .outputHelp() - - Output help information without exiting. - -## .help() - - Output help information and exit immediately. - -## Links - - - [API documentation](http://visionmedia.github.com/commander.js/) - - [ascii tables](https://github.com/LearnBoost/cli-table) - - [progress bars](https://github.com/visionmedia/node-progress) - - [more progress bars](https://github.com/substack/node-multimeter) - - [examples](https://github.com/visionmedia/commander.js/tree/master/examples) - -## License - -(The MIT License) - -Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/index.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/index.js deleted file mode 100644 index 790a751..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/index.js +++ /dev/null @@ -1,851 +0,0 @@ - -/** - * Module dependencies. - */ - -var EventEmitter = require('events').EventEmitter; -var spawn = require('child_process').spawn; -var fs = require('fs'); -var exists = fs.existsSync; -var path = require('path'); -var dirname = path.dirname; -var basename = path.basename; - -/** - * Expose the root command. - */ - -exports = module.exports = new Command; - -/** - * Expose `Command`. - */ - -exports.Command = Command; - -/** - * Expose `Option`. - */ - -exports.Option = Option; - -/** - * Initialize a new `Option` with the given `flags` and `description`. - * - * @param {String} flags - * @param {String} description - * @api public - */ - -function Option(flags, description) { - this.flags = flags; - this.required = ~flags.indexOf('<'); - this.optional = ~flags.indexOf('['); - this.bool = !~flags.indexOf('-no-'); - flags = flags.split(/[ ,|]+/); - if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift(); - this.long = flags.shift(); - this.description = description || ''; -} - -/** - * Return option name. - * - * @return {String} - * @api private - */ - -Option.prototype.name = function(){ - return this.long - .replace('--', '') - .replace('no-', ''); -}; - -/** - * Check if `arg` matches the short or long flag. - * - * @param {String} arg - * @return {Boolean} - * @api private - */ - -Option.prototype.is = function(arg){ - return arg == this.short - || arg == this.long; -}; - -/** - * Initialize a new `Command`. - * - * @param {String} name - * @api public - */ - -function Command(name) { - this.commands = []; - this.options = []; - this._execs = []; - this._args = []; - this._name = name; -} - -/** - * Inherit from `EventEmitter.prototype`. - */ - -Command.prototype.__proto__ = EventEmitter.prototype; - -/** - * Add command `name`. - * - * The `.action()` callback is invoked when the - * command `name` is specified via __ARGV__, - * and the remaining arguments are applied to the - * function for access. - * - * When the `name` is "*" an un-matched command - * will be passed as the first arg, followed by - * the rest of __ARGV__ remaining. - * - * Examples: - * - * program - * .version('0.0.1') - * .option('-C, --chdir ', 'change the working directory') - * .option('-c, --config ', 'set config path. defaults to ./deploy.conf') - * .option('-T, --no-tests', 'ignore test hook') - * - * program - * .command('setup') - * .description('run remote setup commands') - * .action(function(){ - * console.log('setup'); - * }); - * - * program - * .command('exec ') - * .description('run the given remote command') - * .action(function(cmd){ - * console.log('exec "%s"', cmd); - * }); - * - * program - * .command('*') - * .description('deploy the given env') - * .action(function(env){ - * console.log('deploying "%s"', env); - * }); - * - * program.parse(process.argv); - * - * @param {String} name - * @param {String} [desc] - * @return {Command} the new command - * @api public - */ - -Command.prototype.command = function(name, desc){ - var args = name.split(/ +/); - var cmd = new Command(args.shift()); - if (desc) cmd.description(desc); - if (desc) this.executables = true; - if (desc) this._execs[cmd._name] = true; - this.commands.push(cmd); - cmd.parseExpectedArgs(args); - cmd.parent = this; - if (desc) return this; - return cmd; -}; - -/** - * Add an implicit `help [cmd]` subcommand - * which invokes `--help` for the given command. - * - * @api private - */ - -Command.prototype.addImplicitHelpCommand = function() { - this.command('help [cmd]', 'display help for [cmd]'); -}; - -/** - * Parse expected `args`. - * - * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`. - * - * @param {Array} args - * @return {Command} for chaining - * @api public - */ - -Command.prototype.parseExpectedArgs = function(args){ - if (!args.length) return; - var self = this; - args.forEach(function(arg){ - switch (arg[0]) { - case '<': - self._args.push({ required: true, name: arg.slice(1, -1) }); - break; - case '[': - self._args.push({ required: false, name: arg.slice(1, -1) }); - break; - } - }); - return this; -}; - -/** - * Register callback `fn` for the command. - * - * Examples: - * - * program - * .command('help') - * .description('display verbose help') - * .action(function(){ - * // output help here - * }); - * - * @param {Function} fn - * @return {Command} for chaining - * @api public - */ - -Command.prototype.action = function(fn){ - var self = this; - this.parent.on(this._name, function(args, unknown){ - // Parse any so-far unknown options - unknown = unknown || []; - var parsed = self.parseOptions(unknown); - - // Output help if necessary - outputHelpIfNecessary(self, parsed.unknown); - - // If there are still any unknown options, then we simply - // die, unless someone asked for help, in which case we give it - // to them, and then we die. - if (parsed.unknown.length > 0) { - self.unknownOption(parsed.unknown[0]); - } - - // Leftover arguments need to be pushed back. Fixes issue #56 - if (parsed.args.length) args = parsed.args.concat(args); - - self._args.forEach(function(arg, i){ - if (arg.required && null == args[i]) { - self.missingArgument(arg.name); - } - }); - - // Always append ourselves to the end of the arguments, - // to make sure we match the number of arguments the user - // expects - if (self._args.length) { - args[self._args.length] = self; - } else { - args.push(self); - } - - fn.apply(this, args); - }); - return this; -}; - -/** - * Define option with `flags`, `description` and optional - * coercion `fn`. - * - * The `flags` string should contain both the short and long flags, - * separated by comma, a pipe or space. The following are all valid - * all will output this way when `--help` is used. - * - * "-p, --pepper" - * "-p|--pepper" - * "-p --pepper" - * - * Examples: - * - * // simple boolean defaulting to false - * program.option('-p, --pepper', 'add pepper'); - * - * --pepper - * program.pepper - * // => Boolean - * - * // simple boolean defaulting to false - * program.option('-C, --no-cheese', 'remove cheese'); - * - * program.cheese - * // => true - * - * --no-cheese - * program.cheese - * // => true - * - * // required argument - * program.option('-C, --chdir ', 'change the working directory'); - * - * --chdir /tmp - * program.chdir - * // => "/tmp" - * - * // optional argument - * program.option('-c, --cheese [type]', 'add cheese [marble]'); - * - * @param {String} flags - * @param {String} description - * @param {Function|Mixed} fn or default - * @param {Mixed} defaultValue - * @return {Command} for chaining - * @api public - */ - -Command.prototype.option = function(flags, description, fn, defaultValue){ - var self = this - , option = new Option(flags, description) - , oname = option.name() - , name = camelcase(oname); - - // default as 3rd arg - if ('function' != typeof fn) defaultValue = fn, fn = null; - - // preassign default value only for --no-*, [optional], or - if (false == option.bool || option.optional || option.required) { - // when --no-* we make sure default is true - if (false == option.bool) defaultValue = true; - // preassign only if we have a default - if (undefined !== defaultValue) self[name] = defaultValue; - } - - // register the option - this.options.push(option); - - // when it's passed assign the value - // and conditionally invoke the callback - this.on(oname, function(val){ - // coercion - if (null != val && fn) val = fn(val); - - // unassigned or bool - if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) { - // if no value, bool true, and we have a default, then use it! - if (null == val) { - self[name] = option.bool - ? defaultValue || true - : false; - } else { - self[name] = val; - } - } else if (null !== val) { - // reassign - self[name] = val; - } - }); - - return this; -}; - -/** - * Parse `argv`, settings options and invoking commands when defined. - * - * @param {Array} argv - * @return {Command} for chaining - * @api public - */ - -Command.prototype.parse = function(argv){ - // implicit help - if (this.executables) this.addImplicitHelpCommand(); - - // store raw args - this.rawArgs = argv; - - // guess name - this._name = this._name || basename(argv[1]); - - // process argv - var parsed = this.parseOptions(this.normalize(argv.slice(2))); - var args = this.args = parsed.args; - - var result = this.parseArgs(this.args, parsed.unknown); - - // executable sub-commands - var name = result.args[0]; - if (this._execs[name]) return this.executeSubCommand(argv, args, parsed.unknown); - - return result; -}; - -/** - * Execute a sub-command executable. - * - * @param {Array} argv - * @param {Array} args - * @param {Array} unknown - * @api private - */ - -Command.prototype.executeSubCommand = function(argv, args, unknown) { - args = args.concat(unknown); - - if (!args.length) this.help(); - if ('help' == args[0] && 1 == args.length) this.help(); - - // --help - if ('help' == args[0]) { - args[0] = args[1]; - args[1] = '--help'; - } - - // executable - var dir = dirname(argv[1]); - var bin = basename(argv[1]) + '-' + args[0]; - - // check for ./ first - var local = path.join(dir, bin); - - // run it - args = args.slice(1); - var proc = spawn(local, args, { stdio: 'inherit', customFds: [0, 1, 2] }); - proc.on('error', function(err){ - if (err.code == "ENOENT") { - console.error('\n %s(1) does not exist, try --help\n', bin); - } else if (err.code == "EACCES") { - console.error('\n %s(1) not executable. try chmod or run with root\n', bin); - } - }); - - this.runningCommand = proc; -}; - -/** - * Normalize `args`, splitting joined short flags. For example - * the arg "-abc" is equivalent to "-a -b -c". - * This also normalizes equal sign and splits "--abc=def" into "--abc def". - * - * @param {Array} args - * @return {Array} - * @api private - */ - -Command.prototype.normalize = function(args){ - var ret = [] - , arg - , lastOpt - , index; - - for (var i = 0, len = args.length; i < len; ++i) { - arg = args[i]; - i > 0 && (lastOpt = this.optionFor(args[i-1])); - - if (lastOpt && lastOpt.required) { - ret.push(arg); - } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) { - arg.slice(1).split('').forEach(function(c){ - ret.push('-' + c); - }); - } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) { - ret.push(arg.slice(0, index), arg.slice(index + 1)); - } else { - ret.push(arg); - } - } - - return ret; -}; - -/** - * Parse command `args`. - * - * When listener(s) are available those - * callbacks are invoked, otherwise the "*" - * event is emitted and those actions are invoked. - * - * @param {Array} args - * @return {Command} for chaining - * @api private - */ - -Command.prototype.parseArgs = function(args, unknown){ - var cmds = this.commands - , len = cmds.length - , name; - - if (args.length) { - name = args[0]; - if (this.listeners(name).length) { - this.emit(args.shift(), args, unknown); - } else { - this.emit('*', args); - } - } else { - outputHelpIfNecessary(this, unknown); - - // If there were no args and we have unknown options, - // then they are extraneous and we need to error. - if (unknown.length > 0) { - this.unknownOption(unknown[0]); - } - } - - return this; -}; - -/** - * Return an option matching `arg` if any. - * - * @param {String} arg - * @return {Option} - * @api private - */ - -Command.prototype.optionFor = function(arg){ - for (var i = 0, len = this.options.length; i < len; ++i) { - if (this.options[i].is(arg)) { - return this.options[i]; - } - } -}; - -/** - * Parse options from `argv` returning `argv` - * void of these options. - * - * @param {Array} argv - * @return {Array} - * @api public - */ - -Command.prototype.parseOptions = function(argv){ - var args = [] - , len = argv.length - , literal - , option - , arg; - - var unknownOptions = []; - - // parse options - for (var i = 0; i < len; ++i) { - arg = argv[i]; - - // literal args after -- - if ('--' == arg) { - literal = true; - continue; - } - - if (literal) { - args.push(arg); - continue; - } - - // find matching Option - option = this.optionFor(arg); - - // option is defined - if (option) { - // requires arg - if (option.required) { - arg = argv[++i]; - if (null == arg) return this.optionMissingArgument(option); - this.emit(option.name(), arg); - // optional arg - } else if (option.optional) { - arg = argv[i+1]; - if (null == arg || ('-' == arg[0] && '-' != arg)) { - arg = null; - } else { - ++i; - } - this.emit(option.name(), arg); - // bool - } else { - this.emit(option.name()); - } - continue; - } - - // looks like an option - if (arg.length > 1 && '-' == arg[0]) { - unknownOptions.push(arg); - - // If the next argument looks like it might be - // an argument for this option, we pass it on. - // If it isn't, then it'll simply be ignored - if (argv[i+1] && '-' != argv[i+1][0]) { - unknownOptions.push(argv[++i]); - } - continue; - } - - // arg - args.push(arg); - } - - return { args: args, unknown: unknownOptions }; -}; - -/** - * Argument `name` is missing. - * - * @param {String} name - * @api private - */ - -Command.prototype.missingArgument = function(name){ - console.error(); - console.error(" error: missing required argument `%s'", name); - console.error(); - process.exit(1); -}; - -/** - * `Option` is missing an argument, but received `flag` or nothing. - * - * @param {String} option - * @param {String} flag - * @api private - */ - -Command.prototype.optionMissingArgument = function(option, flag){ - console.error(); - if (flag) { - console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag); - } else { - console.error(" error: option `%s' argument missing", option.flags); - } - console.error(); - process.exit(1); -}; - -/** - * Unknown option `flag`. - * - * @param {String} flag - * @api private - */ - -Command.prototype.unknownOption = function(flag){ - console.error(); - console.error(" error: unknown option `%s'", flag); - console.error(); - process.exit(1); -}; - - -/** - * Set the program version to `str`. - * - * This method auto-registers the "-V, --version" flag - * which will print the version number when passed. - * - * @param {String} str - * @param {String} flags - * @return {Command} for chaining - * @api public - */ - -Command.prototype.version = function(str, flags){ - if (0 == arguments.length) return this._version; - this._version = str; - flags = flags || '-V, --version'; - this.option(flags, 'output the version number'); - this.on('version', function(){ - console.log(str); - process.exit(0); - }); - return this; -}; - -/** - * Set the description `str`. - * - * @param {String} str - * @return {String|Command} - * @api public - */ - -Command.prototype.description = function(str){ - if (0 == arguments.length) return this._description; - this._description = str; - return this; -}; - -/** - * Set / get the command usage `str`. - * - * @param {String} str - * @return {String|Command} - * @api public - */ - -Command.prototype.usage = function(str){ - var args = this._args.map(function(arg){ - return arg.required - ? '<' + arg.name + '>' - : '[' + arg.name + ']'; - }); - - var usage = '[options' - + (this.commands.length ? '] [command' : '') - + ']' - + (this._args.length ? ' ' + args : ''); - - if (0 == arguments.length) return this._usage || usage; - this._usage = str; - - return this; -}; - -/** - * Return the largest option length. - * - * @return {Number} - * @api private - */ - -Command.prototype.largestOptionLength = function(){ - return this.options.reduce(function(max, option){ - return Math.max(max, option.flags.length); - }, 0); -}; - -/** - * Return help for options. - * - * @return {String} - * @api private - */ - -Command.prototype.optionHelp = function(){ - var width = this.largestOptionLength(); - - // Prepend the help information - return [pad('-h, --help', width) + ' ' + 'output usage information'] - .concat(this.options.map(function(option){ - return pad(option.flags, width) - + ' ' + option.description; - })) - .join('\n'); -}; - -/** - * Return command help documentation. - * - * @return {String} - * @api private - */ - -Command.prototype.commandHelp = function(){ - if (!this.commands.length) return ''; - return [ - '' - , ' Commands:' - , '' - , this.commands.map(function(cmd){ - var args = cmd._args.map(function(arg){ - return arg.required - ? '<' + arg.name + '>' - : '[' + arg.name + ']'; - }).join(' '); - - return pad(cmd._name - + (cmd.options.length - ? ' [options]' - : '') + ' ' + args, 22) - + (cmd.description() - ? ' ' + cmd.description() - : ''); - }).join('\n').replace(/^/gm, ' ') - , '' - ].join('\n'); -}; - -/** - * Return program help documentation. - * - * @return {String} - * @api private - */ - -Command.prototype.helpInformation = function(){ - return [ - '' - , ' Usage: ' + this._name + ' ' + this.usage() - , '' + this.commandHelp() - , ' Options:' - , '' - , '' + this.optionHelp().replace(/^/gm, ' ') - , '' - , '' - ].join('\n'); -}; - -/** - * Output help information for this command - * - * @api public - */ - -Command.prototype.outputHelp = function(){ - process.stdout.write(this.helpInformation()); - this.emit('--help'); -}; - -/** - * Output help information and exit. - * - * @api public - */ - -Command.prototype.help = function(){ - this.outputHelp(); - process.exit(); -}; - -/** - * Camel-case the given `flag` - * - * @param {String} flag - * @return {String} - * @api private - */ - -function camelcase(flag) { - return flag.split('-').reduce(function(str, word){ - return str + word[0].toUpperCase() + word.slice(1); - }); -} - -/** - * Pad `str` to `width`. - * - * @param {String} str - * @param {Number} width - * @return {String} - * @api private - */ - -function pad(str, width) { - var len = Math.max(0, width - str.length); - return str + Array(len + 1).join(' '); -} - -/** - * Output help information if necessary - * - * @param {Command} command to output help for - * @param {Array} array of options to search for -h or --help - * @api private - */ - -function outputHelpIfNecessary(cmd, options) { - options = options || []; - for (var i = 0; i < options.length; i++) { - if (options[i] == '--help' || options[i] == '-h') { - cmd.outputHelp(); - process.exit(0); - } - } -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/package.json deleted file mode 100644 index 66edeb1..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/commander/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "commander", - "version": "2.1.0", - "description": "the complete solution for node.js command-line programs", - "keywords": [ - "command", - "option", - "parser", - "prompt", - "stdin" - ], - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "repository": { - "type": "git", - "url": "https://github.com/visionmedia/commander.js.git" - }, - "devDependencies": { - "should": ">= 0.0.1" - }, - "scripts": { - "test": "make test" - }, - "main": "index", - "engines": { - "node": ">= 0.6.x" - }, - "files": [ - "index.js" - ], - "bugs": { - "url": "https://github.com/visionmedia/commander.js/issues" - }, - "homepage": "https://github.com/visionmedia/commander.js", - "_id": "commander@2.1.0", - "dist": { - "shasum": "d121bbae860d9992a3d517ba96f56588e47c6781", - "tarball": "http://registry.npmjs.org/commander/-/commander-2.1.0.tgz" - }, - "_from": "commander@~2.1.0", - "_npmVersion": "1.3.14", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "directories": {}, - "_shasum": "d121bbae860d9992a3d517ba96f56588e47c6781", - "_resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz", - "readme": "# Commander.js\n\n The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/visionmedia/commander).\n\n [![Build Status](https://secure.travis-ci.org/visionmedia/commander.js.png)](http://travis-ci.org/visionmedia/commander.js)\n\n## Installation\n\n $ npm install commander\n\n## Option parsing\n\n Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n .version('0.0.1')\n .option('-p, --peppers', 'Add peppers')\n .option('-P, --pineapple', 'Add pineapple')\n .option('-b, --bbq', 'Add bbq sauce')\n .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')\n .parse(process.argv);\n\nconsole.log('you ordered a pizza with:');\nif (program.peppers) console.log(' - peppers');\nif (program.pineapple) console.log(' - pineapple');\nif (program.bbq) console.log(' - bbq');\nconsole.log(' - %s cheese', program.cheese);\n```\n\n Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as \"--template-engine\" are camel-cased, becoming `program.templateEngine` etc.\n\n## Automated --help\n\n The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:\n\n``` \n $ ./examples/pizza --help\n\n Usage: pizza [options]\n\n Options:\n\n -V, --version output the version number\n -p, --peppers Add peppers\n -P, --pineapple Add pineapple\n -b, --bbq Add bbq sauce\n -c, --cheese Add the specified type of cheese [marble]\n -h, --help output usage information\n\n```\n\n## Coercion\n\n```js\nfunction range(val) {\n return val.split('..').map(Number);\n}\n\nfunction list(val) {\n return val.split(',');\n}\n\nprogram\n .version('0.0.1')\n .usage('[options] ')\n .option('-i, --integer ', 'An integer argument', parseInt)\n .option('-f, --float ', 'A float argument', parseFloat)\n .option('-r, --range ..', 'A range', range)\n .option('-l, --list ', 'A list', list)\n .option('-o, --optional [value]', 'An optional value')\n .parse(process.argv);\n\nconsole.log(' int: %j', program.integer);\nconsole.log(' float: %j', program.float);\nconsole.log(' optional: %j', program.optional);\nprogram.range = program.range || [];\nconsole.log(' range: %j..%j', program.range[0], program.range[1]);\nconsole.log(' list: %j', program.list);\nconsole.log(' args: %j', program.args);\n```\n\n## Custom help\n\n You can display arbitrary `-h, --help` information\n by listening for \"--help\". Commander will automatically\n exit once you are done so that the remainder of your program\n does not execute causing undesired behaviours, for example\n in the following executable \"stuff\" will not output when\n `--help` is used.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('../');\n\nfunction list(val) {\n return val.split(',').map(Number);\n}\n\nprogram\n .version('0.0.1')\n .option('-f, --foo', 'enable some foo')\n .option('-b, --bar', 'enable some bar')\n .option('-B, --baz', 'enable some baz');\n\n// must be before .parse() since\n// node's emit() is immediate\n\nprogram.on('--help', function(){\n console.log(' Examples:');\n console.log('');\n console.log(' $ custom-help --help');\n console.log(' $ custom-help -h');\n console.log('');\n});\n\nprogram.parse(process.argv);\n\nconsole.log('stuff');\n```\n\nyielding the following help output:\n\n```\n\nUsage: custom-help [options]\n\nOptions:\n\n -h, --help output usage information\n -V, --version output the version number\n -f, --foo enable some foo\n -b, --bar enable some bar\n -B, --baz enable some baz\n\nExamples:\n\n $ custom-help --help\n $ custom-help -h\n\n```\n\n## .outputHelp()\n\n Output help information without exiting.\n\n## .help()\n\n Output help information and exit immediately.\n\n## Links\n\n - [API documentation](http://visionmedia.github.com/commander.js/)\n - [ascii tables](https://github.com/LearnBoost/cli-table)\n - [progress bars](https://github.com/visionmedia/node-progress)\n - [more progress bars](https://github.com/substack/node-multimeter)\n - [examples](https://github.com/visionmedia/commander.js/tree/master/examples)\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", - "readmeFilename": "Readme.md" -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/.dntrc b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/.dntrc deleted file mode 100644 index 1c3e624..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/.dntrc +++ /dev/null @@ -1,36 +0,0 @@ -## DNT config file -## see https://github.com/rvagg/dnt - -NODE_VERSIONS="\ - master \ - v0.11.13 \ - v0.11.10 \ - v0.11.9 \ - v0.11.8 \ - v0.11.7 \ - v0.11.6 \ - v0.11.5 \ - v0.11.4 \ - v0.10.26 \ - v0.10.25 \ - v0.10.24 \ - v0.10.23 \ - v0.10.22 \ - v0.10.21 \ - v0.10.20 \ - v0.10.19 \ - v0.10.18 \ - v0.8.26 \ - v0.8.25 \ - v0.8.24 \ - v0.8.23 \ - v0.8.22 \ -" -OUTPUT_PREFIX="nan-" -TEST_CMD="\ - cd /dnt/test/ && \ - npm install && \ - node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild && \ - node_modules/.bin/tap --gc js/*-test.js; \ -" - diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/LICENSE b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/LICENSE deleted file mode 100644 index d502e18..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/LICENSE +++ /dev/null @@ -1,46 +0,0 @@ -Copyright 2013, NAN contributors: - - Rod Vagg - - Benjamin Byholm - - Trevor Norris - - Nathan Rajlich - - Brett Lawson - - Ben Noordhuis -(the "Original Author") -All rights reserved. - -MIT +no-false-attribs License - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -Distributions of all or part of the Software intended to be used -by the recipients as they would use the unmodified Software, -containing modifications that substantially alter, remove, or -disable functionality of the Software, outside of the documented -configuration mechanisms provided by the Software, shall be -modified such that the Original Author's bug reporting email -addresses and urls are either replaced with the contact information -of the parties responsible for the changes, or removed entirely. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - - -Except where noted, this license applies to any and all software -programs and associated documentation files created by the -Original Author, when distributed with the Software. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/README.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/README.md deleted file mode 100644 index 7c8d688..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/README.md +++ /dev/null @@ -1,947 +0,0 @@ -Native Abstractions for Node.js -=============================== - -**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10 and 0.11, and eventually 0.12.** - -***Current version: 1.0.0*** *(See [nan.h](https://github.com/rvagg/nan/blob/master/nan.h) for complete ChangeLog)* - -[![NPM](https://nodei.co/npm/nan.png?downloads=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6)](https://nodei.co/npm/nan/) - -Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.11/0.12, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle. - -This project also contains some helper utilities that make addon development a bit more pleasant. - - * **[News & Updates](#news)** - * **[Usage](#usage)** - * **[Example](#example)** - * **[API](#api)** - - -## News & Updates - -### May-2013: Major changes for V8 3.25 / Node 0.11.13 - -Node 0.11.11 and 0.11.12 were both broken releases for native add-ons, you simply can't properly compile against either of them for different reasons. But we now have a 0.11.13 release that jumps a couple of versions of V8 ahead and includes some more, major (traumatic) API changes. - -Because we are now nearing Node 0.12 and estimate that the version of V8 we are using in Node 0.11.13 will be close to the API we get for 0.12, we have taken the opportunity to not only *fix* NAN for 0.11.13 but make some major changes to improve the NAN API. - -We have **removed support for Node 0.11 versions prior to 0.11.13**, (although our tests are still passing for 0.11.10). As usual, our tests are run against (and pass) the last 5 versions of Node 0.8 and Node 0.10. We also include Node 0.11.13 obviously. - -The major change is something that [Benjamin Byholm](kkoopa) has put many hours in to. We now have a fantastic new `NanNew(args)` interface for creating new `Local`s, this replaces `NanNewLocal()` and much more. If you look in [./nan.h](nan.h) you'll see a large number of overloaded versions of this method. In general you should be able to `NanNew(arguments)` for any type you want to make a `Local` from. This includes `Persistent` types, so we now have a `Local NanNew(const Persistent arg)` to replace `NanPersistentToLocal()`. - -We also now have `NanUndefined()`, `NanNull()`, `NanTrue()` and `NanFalse()`. Mainly because of the new requirement for an `Isolate` argument for each of the native V8 versions of this. - -V8 has now introduced an `EscapableHandleScope` from which you `scope.Escape(Local value)` to *return* a value from a one scope to another. This replaces the standard `HandleScope` and `scope.Close(Local value)`, although `HandleScope` still exists for when you don't need to return a handle to the caller. For NAN we are exposing it as `NanEscapableScope()` and `NanEscapeScope()`, while `NanScope()` is still how you create a new scope that doesn't need to return handles. For older versions of Node/V8, it'll still map to the older `HandleScope` functionality. - -`NanFromV8String()` was deprecated and has now been removed. You should use `NanCString()` or `NanRawString()` instead. - -Because `node::MakeCallback()` now takes an `Isolate`, and because it doesn't exist in older versions of Node, we've introduced `NanMakeCallabck()`. You should *always* use this when calling a JavaScript function from C++. - -There's lots more, check out the Changelog in nan.h or look through [#86](https://github.com/rvagg/nan/pull/86) for all the gory details. - -### Dec-2013: NanCString and NanRawString - -Two new functions have been introduced to replace the functionality that's been provided by `NanFromV8String` until now. NanCString has sensible defaults so it's super easy to fetch a null-terminated c-style string out of a `v8::String`. `NanFromV8String` is still around and has defaults that allow you to pass a single handle to fetch a `char*` while `NanRawString` requires a little more attention to arguments. - -### Nov-2013: Node 0.11.9+ breaking V8 change - -The version of V8 that's shipping with Node 0.11.9+ has changed the signature for new `Local`s to: `v8::Local::New(isolate, value)`, i.e. introducing the `isolate` argument and therefore breaking all new `Local` declarations for previous versions. NAN 0.6+ now includes a `NanNewLocal(value)` that can be used in place to work around this incompatibility and maintain compatibility with 0.8->0.11.9+ (minus a few early 0.11 releases). - -For example, if you wanted to return a `null` on a callback you will have to change the argument from `v8::Local::New(v8::Null())` to `NanNewLocal(v8::Null())`. - -### Nov-2013: Change to binding.gyp `"include_dirs"` for NAN - -Inclusion of NAN in a project's binding.gyp is now greatly simplified. You can now just use `" -## Usage - -Simply add **NAN** as a dependency in the *package.json* of your Node addon: - -``` bash -$ npm install --save nan -``` - -Pull in the path to **NAN** in your *binding.gyp* so that you can use `#include ` in your *.cpp* files: - -``` python -"include_dirs" : [ - "` when compiling your addon. - - -## Example - -See **[LevelDOWN](https://github.com/rvagg/node-leveldown/pull/48)** for a full example of **NAN** in use. - -For a simpler example, see the **[async pi estimation example](https://github.com/rvagg/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**. - -Compare to the current 0.10 version of this example, found in the [node-addon-examples](https://github.com/rvagg/node-addon-examples/tree/master/9_async_work) repository and also a 0.11 version of the same found [here](https://github.com/kkoopa/node-addon-examples/tree/5c01f58fc993377a567812597e54a83af69686d7/9_async_work). - -Note that there is no embedded version sniffing going on here and also the async work is made much simpler, see below for details on the `NanAsyncWorker` class. - -```c++ -// addon.cc -#include -#include -// ... - -using v8::FunctionTemplate; -using v8::Handle; -using v8::Object; - -void InitAll(Handle exports) { - exports->Set(NanSymbol("calculateSync"), - NanNew(CalculateSync)->GetFunction()); - - exports->Set(NanSymbol("calculateAsync"), - NanNew(CalculateAsync)->GetFunction()); -} - -NODE_MODULE(addon, InitAll) -``` - -```c++ -// sync.h -#include -#include - -NAN_METHOD(CalculateSync); -``` - -```c++ -// sync.cc -#include -#include -#include "./sync.h" -// ... - -using v8::Number; - -// Simple synchronous access to the `Estimate()` function -NAN_METHOD(CalculateSync) { - NanScope(); - - // expect a number as the first argument - int points = args[0]->Uint32Value(); - double est = Estimate(points); - - NanReturnValue(NanNew(est)); -} -``` - -```c++ -// async.cc -#include -#include -#include "./async.h" - -// ... - -using v8::Function; -using v8::Local; -using v8::Null; -using v8::Number; -using v8::Value; - -class PiWorker : public NanAsyncWorker { - public: - PiWorker(NanCallback *callback, int points) - : NanAsyncWorker(callback), points(points) {} - ~PiWorker() {} - - // Executed inside the worker-thread. - // It is not safe to access V8, or V8 data structures - // here, so everything we need for input and output - // should go on `this`. - void Execute () { - estimate = Estimate(points); - } - - // Executed when the async work is complete - // this function will be run inside the main event loop - // so it is safe to use V8 again - void HandleOKCallback () { - NanScope(); - - Local argv[] = { - NanNew(NanNull()) - , NanNew(estimate) - }; - - callback->Call(2, argv); - }; - - private: - int points; - double estimate; -}; - -// Asynchronous access to the `Estimate()` function -NAN_METHOD(CalculateAsync) { - NanScope(); - - int points = args[0]->Uint32Value(); - NanCallback *callback = new NanCallback(args[1].As()); - - NanAsyncQueueWorker(new PiWorker(callback, points)); - NanReturnUndefined(); -} -``` - - -## API - - * NAN_METHOD - * NAN_GETTER - * NAN_SETTER - * NAN_PROPERTY_GETTER - * NAN_PROPERTY_SETTER - * NAN_PROPERTY_ENUMERATOR - * NAN_PROPERTY_DELETER - * NAN_PROPERTY_QUERY - * NAN_INDEX_GETTER - * NAN_INDEX_SETTER - * NAN_INDEX_ENUMERATOR - * NAN_INDEX_DELETER - * NAN_INDEX_QUERY - * NAN_WEAK_CALLBACK - * NAN_DEPRECATED - * NAN_INLINE - * NanNew - * NanUndefined - * NanNull - * NanTrue - * NanFalse - * NanReturnValue - * NanReturnUndefined - * NanReturnNull - * NanReturnEmptyString - * NanScope - * NanEscapableScope - * NanEscapeScope - * NanLocker - * NanUnlocker - * NanGetInternalFieldPointer - * NanSetInternalFieldPointer - * NanObjectWrapHandle - * NanSymbol - * NanGetPointerSafe - * NanSetPointerSafe - * NanRawString - * NanCString - * NanBooleanOptionValue - * NanUInt32OptionValue - * NanError, NanTypeError, NanRangeError - * NanThrowError, NanThrowTypeError, NanThrowRangeError, NanThrowError(Handle), NanThrowError(Handle, int) - * NanNewBufferHandle(char *, size_t, FreeCallback, void *), NanNewBufferHandle(char *, uint32_t), NanNewBufferHandle(uint32_t) - * NanBufferUse(char *, uint32_t) - * NanNewContextHandle - * NanGetCurrentContext - * NanHasInstance - * NanDisposePersistent - * NanAssignPersistent - * NanMakeWeakPersistent - * NanSetTemplate - * NanMakeCallback - * NanCompileScript - * NanRunScript - * NanAdjustExternalMemory - * NanAddGCEpilogueCallback - * NanAddGCPrologueCallback - * NanRemoveGCEpilogueCallback - * NanRemoveGCPrologueCallback - * NanGetHeapStatistics - * NanCallback - * NanAsyncWorker - * NanAsyncQueueWorker - - -### NAN_METHOD(methodname) - -Use `NAN_METHOD` to define your V8 accessible methods: - -```c++ -// .h: -class Foo : public node::ObjectWrap { - ... - - static NAN_METHOD(Bar); - static NAN_METHOD(Baz); -} - - -// .cc: -NAN_METHOD(Foo::Bar) { - ... -} - -NAN_METHOD(Foo::Baz) { - ... -} -``` - -The reason for this macro is because of the method signature change in 0.11: - -```c++ -// 0.10 and below: -Handle name(const Arguments& args) - -// 0.11 and above -void name(const FunctionCallbackInfo& args) -``` - -The introduction of `FunctionCallbackInfo` brings additional complications: - - -### NAN_GETTER(methodname) - -Use `NAN_GETTER` to declare your V8 accessible getters. You get a `Local` `property` and an appropriately typed `args` object that can act like the `args` argument to a `NAN_METHOD` call. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_GETTER`. - - -### NAN_SETTER(methodname) - -Use `NAN_SETTER` to declare your V8 accessible setters. Same as `NAN_GETTER` but you also get a `Local` `value` object to work with. - - -### NAN_PROPERTY_GETTER(cbname) -Use `NAN_PROPERTY_GETTER` to declare your V8 accessible property getters. You get a `Local` `property` and an appropriately typed `args` object that can act similar to the `args` argument to a `NAN_METHOD` call. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_GETTER`. - - -### NAN_PROPERTY_SETTER(cbname) -Use `NAN_PROPERTY_SETTER` to declare your V8 accessible property setters. Same as `NAN_PROPERTY_GETTER` but you also get a `Local` `value` object to work with. - - -### NAN_PROPERTY_ENUMERATOR(cbname) -Use `NAN_PROPERTY_ENUMERATOR` to declare your V8 accessible property enumerators. You get an appropriately typed `args` object like the `args` argument to a `NAN_PROPERTY_GETTER` call. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_ENUMERATOR`. - - -### NAN_PROPERTY_DELETER(cbname) -Use `NAN_PROPERTY_DELETER` to declare your V8 accessible property deleters. Same as `NAN_PROPERTY_GETTER`. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_DELETER`. - - -### NAN_PROPERTY_QUERY(cbname) -Use `NAN_PROPERTY_QUERY` to declare your V8 accessible property queries. Same as `NAN_PROPERTY_GETTER`. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_QUERY`. - - -### NAN_INDEX_GETTER(cbname) -Use `NAN_INDEX_GETTER` to declare your V8 accessible index getters. You get a `uint32_t` `index` and an appropriately typed `args` object that can act similar to the `args` argument to a `NAN_METHOD` call. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_GETTER`. - - -### NAN_INDEX_SETTER(cbname) -Use `NAN_INDEX_SETTER` to declare your V8 accessible index setters. Same as `NAN_INDEX_GETTER` but you also get a `Local` `value` object to work with. - - -### NAN_INDEX_ENUMERATOR(cbname) -Use `NAN_INDEX_ENUMERATOR` to declare your V8 accessible index enumerators. You get an appropriately typed `args` object like the `args` argument to a `NAN_INDEX_GETTER` call. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_ENUMERATOR`. - - -### NAN_INDEX_DELETER(cbname) -Use `NAN_INDEX_DELETER` to declare your V8 accessible index deleters. Same as `NAN_INDEX_GETTER`. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_DELETER`. - - -### NAN_INDEX_QUERY(cbname) -Use `NAN_INDEX_QUERY` to declare your V8 accessible index queries. Same as `NAN_INDEX_GETTER`. - -You can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_QUERY`. - - -### NAN_WEAK_CALLBACK(cbname) - -Use `NAN_WEAK_CALLBACK` to define your V8 WeakReference callbacks. Do not use for declaration. There is an argument object `const _NanWeakCallbackData &data` allowing access to the weak object and the supplied parameter through its `GetValue` and `GetParameter` methods. - -```c++ -NAN_WEAK_CALLBACK(weakCallback) { - int *parameter = data.GetParameter(); - NanMakeCallback(NanGetCurrentContext()->Global(), data.GetValue(), 0, NULL); - if ((*parameter)++ == 0) { - data.Revive(); - } else { - delete parameter; - data.Dispose(); - } -} -``` - - -### NAN_DEPRECATED -Declares a function as deprecated. - -```c++ -static NAN_DEPRECATED NAN_METHOD(foo) { - ... -} -``` - - -### NAN_INLINE -Inlines a function. - -```c++ -NAN_INLINE int foo(int bar) { - ... -} -``` - - -### Local<T> NanNew<T>( ... ) - -Use `NanNew` to construct almost all v8 objects and make new local handles. - -```c++ -Local s = NanNew("value"); - -... - -Persistent o; - -... - -Local lo = NanNew(o); - -``` - - -### Handle<Primitive> NanUndefined() - -Use instead of `Undefined()` - - -### Handle<Primitive> NanNull() - -Use instead of `Null()` - - -### Handle<Primitive> NanTrue() - -Use instead of `True()` - - -### Handle<Primitive> NanFalse() - -Use instead of `False()` - - -### NanReturnValue(Handle<Value>) - -Use `NanReturnValue` when you want to return a value from your V8 accessible method: - -```c++ -NAN_METHOD(Foo::Bar) { - ... - - NanReturnValue(NanNew("FooBar!")); -} -``` - -No `return` statement required. - - -### NanReturnUndefined() - -Use `NanReturnUndefined` when you don't want to return anything from your V8 accessible method: - -```c++ -NAN_METHOD(Foo::Baz) { - ... - - NanReturnUndefined(); -} -``` - - -### NanReturnNull() - -Use `NanReturnNull` when you want to return `Null` from your V8 accessible method: - -```c++ -NAN_METHOD(Foo::Baz) { - ... - - NanReturnNull(); -} -``` - - -### NanReturnEmptyString() - -Use `NanReturnEmptyString` when you want to return an empty `String` from your V8 accessible method: - -```c++ -NAN_METHOD(Foo::Baz) { - ... - - NanReturnEmptyString(); -} -``` - - -### NanScope() - -The introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanScope()` necessary, use it in place of `HandleScope scope`: - -```c++ -NAN_METHOD(Foo::Bar) { - NanScope(); - - NanReturnValue(NanNew("FooBar!")); -} -``` - - -### NanEscapableScope() - -The separation of handle scopes into escapable and inescapable scopes makes `NanEscapableScope()` necessary, use it in place of `HandleScope scope` when you later wish to `Close()` the scope: - -```c++ -Handle Foo::Bar() { - NanEscapableScope(); - - return NanEscapeScope(NanNew("FooBar!")); -} -``` - - -### Local<T> NanEscapeScope(Handle<T> value); -Use together with `NanEscapableScope` to escape the scope. Corresponds to `HandleScope::Close` or `EscapableHandleScope::Escape`. - - -### NanLocker() - -The introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanLocker()` necessary, use it in place of `Locker locker`: - -```c++ -NAN_METHOD(Foo::Bar) { - NanLocker(); - ... - NanUnlocker(); -} -``` - - -### NanUnlocker() - -The introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanUnlocker()` necessary, use it in place of `Unlocker unlocker`: - -```c++ -NAN_METHOD(Foo::Bar) { - NanLocker(); - ... - NanUnlocker(); -} -``` - - -### void * NanGetInternalFieldPointer(Handle<Object>, int) - -Gets a pointer to the internal field with at `index` from a V8 `Object` handle. - -```c++ -Local obj; -... -NanGetInternalFieldPointer(obj, 0); -``` - -### void NanSetInternalFieldPointer(Handle<Object>, int, void *) - -Sets the value of the internal field at `index` on a V8 `Object` handle. - -```c++ -static Persistent dataWrapperCtor; -... -Local wrapper = NanPersistentToLocal(dataWrapperCtor)->NewInstance(); -NanSetInternalFieldPointer(wrapper, 0, this); -``` - - -### Local<Object> NanObjectWrapHandle(Object) - -When you want to fetch the V8 object handle from a native object you've wrapped with Node's `ObjectWrap`, you should use `NanObjectWrapHandle`: - -```c++ -NanObjectWrapHandle(iterator)->Get(NanSymbol("end")) -``` - - -### String NanSymbol(char *) - -Use to create string symbol objects (i.e. `v8::String::NewSymbol(x)`), for getting and setting object properties, or names of objects. - -```c++ -bool foo = false; -if (obj->Has(NanSymbol("foo"))) - foo = optionsObj->Get(NanSymbol("foo"))->BooleanValue() -``` - - -### Type NanGetPointerSafe(Type *[, Type]) - -A helper for getting values from optional pointers. If the pointer is `NULL`, the function returns the optional default value, which defaults to `0`. Otherwise, the function returns the value the pointer points to. - -```c++ -char *plugh(uint32_t *optional) { - char res[] = "xyzzy"; - uint32_t param = NanGetPointerSafe(optional, 0x1337); - switch (param) { - ... - } - NanSetPointerSafe(optional, 0xDEADBEEF); -} -``` - - -### bool NanSetPointerSafe(Type *, Type) - -A helper for setting optional argument pointers. If the pointer is `NULL`, the function simply returns `false`. Otherwise, the value is assigned to the variable the pointer points to. - -```c++ -const char *plugh(size_t *outputsize) { - char res[] = "xyzzy"; - if !(NanSetPointerSafe(outputsize, strlen(res) + 1)) { - ... - } - - ... -} -``` - - -### void* NanRawString(Handle<Value>, enum Nan::Encoding, size_t *, void *, size_t, int) - -When you want to convert a V8 `String` to a `char*` buffer, use `NanRawString`. You have to supply an encoding as well as a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows setting `String::WriteOptions`. -Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer: - -```c++ -size_t count; -void* decoded = NanRawString(args[1], Nan::BASE64, &count, NULL, 0, String::HINT_MANY_WRITES_EXPECTED); -char param_copy[count]; -memcpy(param_copy, decoded, count); -delete[] decoded; -``` - - -### char* NanCString(Handle<Value>, size_t *[, char *, size_t, int]) - -When you want to convert a V8 `String` to a null-terminated C `char*` use `NanCString`. The resulting `char*` will be UTF-8-encoded, and you need to supply a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows optionally setting `String::WriteOptions`, which default to `v8::String::NO_OPTIONS`. -Just remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer: - -```c++ -size_t count; -char* name = NanCString(args[0], &count); -``` - - -### bool NanBooleanOptionValue(Handle<Value>, Handle<String>[, bool]) - -When you have an "options" object that you need to fetch properties from, boolean options can be fetched with this pair. They check first if the object exists (`IsEmpty`), then if the object has the given property (`Has`) then they get and convert/coerce the property to a `bool`. - -The optional last parameter is the *default* value, which is `false` if left off: - -```c++ -// `foo` is false unless the user supplies a truthy value for it -bool foo = NanBooleanOptionValue(optionsObj, NanSymbol("foo")); -// `bar` is true unless the user supplies a falsy value for it -bool bar = NanBooleanOptionValueDefTrue(optionsObj, NanSymbol("bar"), true); -``` - - -### uint32_t NanUInt32OptionValue(Handle<Value>, Handle<String>, uint32_t) - -Similar to `NanBooleanOptionValue`, use `NanUInt32OptionValue` to fetch an integer option from your options object. Can be any kind of JavaScript `Number` and it will be coerced to an unsigned 32-bit integer. - -Requires all 3 arguments as a default is not optional: - -```c++ -uint32_t count = NanUInt32OptionValue(optionsObj, NanSymbol("count"), 1024); -``` - - -### NanError(message), NanTypeError(message), NanRangeError(message) - -For making `Error`, `TypeError` and `RangeError` objects. - -```c++ -Local res = NanError("you must supply a callback argument"); -``` - - -### NanThrowError(message), NanThrowTypeError(message), NanThrowRangeError(message), NanThrowError(Local<Value>), NanThrowError(Local<Value>, int) - -For throwing `Error`, `TypeError` and `RangeError` objects. You should `return` this call: - -```c++ -return NanThrowError("you must supply a callback argument"); -``` - -Can also handle any custom object you may want to throw. If used with the error code argument, it will add the supplied error code to the error object as a property called `code`. - - -### Local<Object> NanNewBufferHandle(char *, uint32_t), Local<Object> NanNewBufferHandle(uint32_t) - -The `Buffer` API has changed a little in Node 0.11, this helper provides consistent access to `Buffer` creation: - -```c++ -NanNewBufferHandle((char*)value.data(), value.size()); -``` - -Can also be used to initialize a `Buffer` with just a `size` argument. - -Can also be supplied with a `NanFreeCallback` and a hint for the garbage collector. - - -### Local<Object> NanBufferUse(char*, uint32_t) - -`Buffer::New(char*, uint32_t)` prior to 0.11 would make a copy of the data. -While it was possible to get around this, it required a shim by passing a -callback. So the new API `Buffer::Use(char*, uint32_t)` was introduced to remove -needing to use this shim. - -`NanBufferUse` uses the `char*` passed as the backing data, and will free the -memory automatically when the weak callback is called. Keep this in mind, as -careless use can lead to "double free or corruption" and other cryptic failures. - - -### bool NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>) - -Can be used to check the type of an object to determine it is of a particular class you have already defined and have a `Persistent` handle for. - - -### Local<Context> NanNewContextHandle([ExtensionConfiguration*, Handle<ObjectTemplate>, Handle<Value>]) -Creates a new `Local` handle. - -```c++ -Local ftmpl = NanNew(); -Local otmpl = ftmpl->InstanceTemplate(); -Local ctx = NanNewContextHandle(NULL, otmpl); -``` - - -### Local NanGetCurrentContext() - -Gets the current context. - -```c++ -Local ctx = NanGetCurrentContext(); -``` - - -### void NanDisposePersistent(Persistent<T> &) - -Use `NanDisposePersistent` to dispose a `Persistent` handle. - -```c++ -NanDisposePersistent(persistentHandle); -``` - - -### NanAssignPersistent(type, handle, object) - -Use `NanAssignPersistent` to assign a non-`Persistent` handle to a `Persistent` one. You can no longer just declare a `Persistent` handle and assign directly to it later, you have to `Reset` it in Node 0.11, so this makes it easier. - -In general it is now better to place anything you want to protect from V8's garbage collector as properties of a generic `Object` and then assign that to a `Persistent`. This works in older versions of Node also if you use `NanAssignPersistent`: - -```c++ -Persistent persistentHandle; - -... - -Local obj = NanNew(); -obj->Set(NanSymbol("key"), keyHandle); // where keyHandle might be a Local -NanAssignPersistent(Object, persistentHandle, obj) -``` - - -### NanMakeWeakPersistent(Handle<T> handle, P* parameter, _NanWeakCallbackInfo<T, P>::Callback callback) - -Creates a weak persistent handle with the supplied parameter and `NAN_WEAK_CALLBACK`. The callback has to be fully specialized to work on all versions of Node. - -```c++ -NAN_WEAK_CALLBACK(weakCallback) { - -... - -} - -Local func; - -... - -int *parameter = new int(0); -NanMakeWeakPersistent(func, parameter, &weakCallback); -``` - - -### NanSetTemplate(templ, name, value) - -Use to add properties on object and function templates. - - -### NanMakeCallback(target, func, argc, argv) - -Use instead of `node::MakeCallback` to call javascript functions. This is the only proper way of calling functions. - - -### NanCompileScript(Handle s [, const ScriptOrigin& origin]) - -Use to create new scripts bound to the current context. - - -### NanRunScript(script) - -Use to run both bound and unbound scripts. - - -### NanAdjustExternalMemory(int change_in_bytes) - -Simply does `AdjustAmountOfExternalAllocatedMemory` - - -### NanAddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll) - -Simply does `AddGCEpilogueCallback` - - -### NanAddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll) - -Simply does `AddGCPrologueCallback` - - -### NanRemoveGCEpilogueCallback(GCEpilogueCallback callback) - -Simply does `RemoveGCEpilogueCallback` - - -### NanRemoveGCPrologueCallback(GCPrologueCallback callback) - -Simply does `RemoveGCPrologueCallback` - - -### NanGetHeapStatistics(HeapStatistics *heap_statistics) - -Simply does `GetHeapStatistics` - - -### NanCallback - -Because of the difficulties imposed by the changes to `Persistent` handles in V8 in Node 0.11, creating `Persistent` versions of your `Handle` is annoyingly tricky. `NanCallback` makes it easier by taking your handle, making it persistent until the `NanCallback` is deleted and even providing a handy `Call()` method to fetch and execute the callback `Function`. - -```c++ -Local callbackHandle = args[0].As(); -NanCallback *callback = new NanCallback(callbackHandle); -// pass `callback` around and it's safe from GC until you: -delete callback; -``` - -You can execute the callback like so: - -```c++ -// no arguments: -callback->Call(0, NULL); - -// an error argument: -Handle argv[] = { - NanError(NanNew("fail!")) -}; -callback->Call(1, argv); - -// a success argument: -Handle argv[] = { - NanNull(), - NanNew("w00t!") -}; -callback->Call(2, argv); -``` - -`NanCallback` also has a `Local GetCallback()` method that you can use -to fetch a local handle to the underlying callback function, as well as a -`void SetFunction(Handle)` for setting the callback on the -`NanCallback`. Additionally a generic constructor is available for using -`NanCallback` without performing heap allocations. - - -### NanAsyncWorker - -`NanAsyncWorker` is an abstract class that you can subclass to have much of the annoying async queuing and handling taken care of for you. It can even store arbitrary V8 objects for you and have them persist while the async work is in progress. - -See a rough outline of the implementation: - -```c++ -class NanAsyncWorker { -public: - NanAsyncWorker (NanCallback *callback); - - // Clean up persistent handles and delete the *callback - virtual ~NanAsyncWorker (); - - // Check the `char *errmsg` property and call HandleOKCallback() - // or HandleErrorCallback depending on whether it has been set or not - virtual void WorkComplete (); - - // You must implement this to do some async work. If there is an - // error then allocate `errmsg` to a message and the callback will - // be passed that string in an Error object - virtual void Execute (); - - // Save a V8 object in a Persistent handle to protect it from GC - void SavePersistent(const char *key, Local &obj); - - // Fetch a stored V8 object (don't call from within `Execute()`) - Local GetFromPersistent(const char *key); - -protected: - // Set this if there is an error, otherwise it's NULL - const char *errmsg; - - // Default implementation calls the callback function with no arguments. - // Override this to return meaningful data - virtual void HandleOKCallback (); - - // Default implementation calls the callback function with an Error object - // wrapping the `errmsg` string - virtual void HandleErrorCallback (); -}; -``` - - -### NanAsyncQueueWorker(NanAsyncWorker *) - -`NanAsyncQueueWorker` will run a `NanAsyncWorker` asynchronously via libuv. Both the *execute* and *after_work* steps are taken care of for you—most of the logic for this is embedded in `NanAsyncWorker`. - -### Contributors - -NAN is only possible due to the excellent work of the following contributors: - - - - - - - - -
Rod VaggGitHub/rvaggTwitter/@rvagg
Benjamin ByholmGitHub/kkoopa
Trevor NorrisGitHub/trevnorrisTwitter/@trevnorris
Nathan RajlichGitHub/TooTallNateTwitter/@TooTallNate
Brett LawsonGitHub/brett19Twitter/@brett19x
Ben NoordhuisGitHub/bnoordhuisTwitter/@bnoordhuis
- -Licence & copyright ------------------------ - -Copyright (c) 2014 NAN contributors (listed above). - -Native Abstractions for Node.js is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/build/config.gypi b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/build/config.gypi deleted file mode 100644 index e085a50..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/build/config.gypi +++ /dev/null @@ -1,38 +0,0 @@ -# Do not edit. File was generated by node-gyp's "configure" step -{ - "target_defaults": { - "cflags": [], - "default_configuration": "Release", - "defines": [], - "include_dirs": [], - "libraries": [] - }, - "variables": { - "clang": 0, - "gcc_version": 47, - "host_arch": "x64", - "node_install_npm": "true", - "node_prefix": "", - "node_shared_cares": "false", - "node_shared_http_parser": "false", - "node_shared_libuv": "false", - "node_shared_openssl": "false", - "node_shared_v8": "false", - "node_shared_zlib": "false", - "node_tag": "", - "node_unsafe_optimizations": 0, - "node_use_dtrace": "false", - "node_use_etw": "false", - "node_use_openssl": "true", - "node_use_perfctr": "false", - "node_use_systemtap": "false", - "python": "/usr/bin/python", - "target_arch": "x64", - "v8_enable_gdbjit": 0, - "v8_no_strict_aliasing": 1, - "v8_use_snapshot": "true", - "nodedir": "/home/rvagg/.node-gyp/0.10.21", - "copy_dev_lib": "true", - "standalone_static_library": 1 - } -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/package.json deleted file mode 100644 index 2ca80f1..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/nan/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "nan", - "version": "1.0.0", - "description": "Native Abstractions for Node.js: C++ header for Node 0.8->0.12 compatibility", - "main": "include_dirs.js", - "repository": { - "type": "git", - "url": "git://github.com/rvagg/nan.git" - }, - "contributors": [ - { - "name": "Rod Vagg", - "email": "r@va.gg", - "url": "https://github.com/rvagg" - }, - { - "name": "Benjamin Byholm", - "email": "bbyholm@abo.fi", - "url": "https://github.com/kkoopa/" - }, - { - "name": "Trevor Norris", - "email": "trev.norris@gmail.com", - "url": "https://github.com/trevnorris" - }, - { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "https://github.com/TooTallNate" - }, - { - "name": "Brett Lawson", - "email": "brett19@gmail.com", - "url": "https://github.com/brett19" - }, - { - "name": "Ben Noordhuis", - "email": "info@bnoordhuis.nl", - "url": "https://github.com/bnoordhuis" - } - ], - "license": "MIT", - "readme": "Native Abstractions for Node.js\n===============================\n\n**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10 and 0.11, and eventually 0.12.**\n\n***Current version: 1.0.0*** *(See [nan.h](https://github.com/rvagg/nan/blob/master/nan.h) for complete ChangeLog)*\n\n[![NPM](https://nodei.co/npm/nan.png?downloads=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6)](https://nodei.co/npm/nan/)\n\nThanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.11/0.12, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle.\n\nThis project also contains some helper utilities that make addon development a bit more pleasant.\n\n * **[News & Updates](#news)**\n * **[Usage](#usage)**\n * **[Example](#example)**\n * **[API](#api)**\n\n\n## News & Updates\n\n### May-2013: Major changes for V8 3.25 / Node 0.11.13\n\nNode 0.11.11 and 0.11.12 were both broken releases for native add-ons, you simply can't properly compile against either of them for different reasons. But we now have a 0.11.13 release that jumps a couple of versions of V8 ahead and includes some more, major (traumatic) API changes.\n\nBecause we are now nearing Node 0.12 and estimate that the version of V8 we are using in Node 0.11.13 will be close to the API we get for 0.12, we have taken the opportunity to not only *fix* NAN for 0.11.13 but make some major changes to improve the NAN API.\n\nWe have **removed support for Node 0.11 versions prior to 0.11.13**, (although our tests are still passing for 0.11.10). As usual, our tests are run against (and pass) the last 5 versions of Node 0.8 and Node 0.10. We also include Node 0.11.13 obviously.\n\nThe major change is something that [Benjamin Byholm](kkoopa) has put many hours in to. We now have a fantastic new `NanNew(args)` interface for creating new `Local`s, this replaces `NanNewLocal()` and much more. If you look in [./nan.h](nan.h) you'll see a large number of overloaded versions of this method. In general you should be able to `NanNew(arguments)` for any type you want to make a `Local` from. This includes `Persistent` types, so we now have a `Local NanNew(const Persistent arg)` to replace `NanPersistentToLocal()`.\n\nWe also now have `NanUndefined()`, `NanNull()`, `NanTrue()` and `NanFalse()`. Mainly because of the new requirement for an `Isolate` argument for each of the native V8 versions of this.\n\nV8 has now introduced an `EscapableHandleScope` from which you `scope.Escape(Local value)` to *return* a value from a one scope to another. This replaces the standard `HandleScope` and `scope.Close(Local value)`, although `HandleScope` still exists for when you don't need to return a handle to the caller. For NAN we are exposing it as `NanEscapableScope()` and `NanEscapeScope()`, while `NanScope()` is still how you create a new scope that doesn't need to return handles. For older versions of Node/V8, it'll still map to the older `HandleScope` functionality.\n\n`NanFromV8String()` was deprecated and has now been removed. You should use `NanCString()` or `NanRawString()` instead.\n\nBecause `node::MakeCallback()` now takes an `Isolate`, and because it doesn't exist in older versions of Node, we've introduced `NanMakeCallabck()`. You should *always* use this when calling a JavaScript function from C++.\n\nThere's lots more, check out the Changelog in nan.h or look through [#86](https://github.com/rvagg/nan/pull/86) for all the gory details.\n\n### Dec-2013: NanCString and NanRawString\n\nTwo new functions have been introduced to replace the functionality that's been provided by `NanFromV8String` until now. NanCString has sensible defaults so it's super easy to fetch a null-terminated c-style string out of a `v8::String`. `NanFromV8String` is still around and has defaults that allow you to pass a single handle to fetch a `char*` while `NanRawString` requires a little more attention to arguments.\n\n### Nov-2013: Node 0.11.9+ breaking V8 change\n\nThe version of V8 that's shipping with Node 0.11.9+ has changed the signature for new `Local`s to: `v8::Local::New(isolate, value)`, i.e. introducing the `isolate` argument and therefore breaking all new `Local` declarations for previous versions. NAN 0.6+ now includes a `NanNewLocal(value)` that can be used in place to work around this incompatibility and maintain compatibility with 0.8->0.11.9+ (minus a few early 0.11 releases).\n\nFor example, if you wanted to return a `null` on a callback you will have to change the argument from `v8::Local::New(v8::Null())` to `NanNewLocal(v8::Null())`.\n\n### Nov-2013: Change to binding.gyp `\"include_dirs\"` for NAN\n\nInclusion of NAN in a project's binding.gyp is now greatly simplified. You can now just use `\"\n## Usage\n\nSimply add **NAN** as a dependency in the *package.json* of your Node addon:\n\n``` bash\n$ npm install --save nan\n```\n\nPull in the path to **NAN** in your *binding.gyp* so that you can use `#include ` in your *.cpp* files:\n\n``` python\n\"include_dirs\" : [\n \"` when compiling your addon.\n\n\n## Example\n\nSee **[LevelDOWN](https://github.com/rvagg/node-leveldown/pull/48)** for a full example of **NAN** in use.\n\nFor a simpler example, see the **[async pi estimation example](https://github.com/rvagg/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**.\n\nCompare to the current 0.10 version of this example, found in the [node-addon-examples](https://github.com/rvagg/node-addon-examples/tree/master/9_async_work) repository and also a 0.11 version of the same found [here](https://github.com/kkoopa/node-addon-examples/tree/5c01f58fc993377a567812597e54a83af69686d7/9_async_work).\n\nNote that there is no embedded version sniffing going on here and also the async work is made much simpler, see below for details on the `NanAsyncWorker` class.\n\n```c++\n// addon.cc\n#include \n#include \n// ...\n\nusing v8::FunctionTemplate;\nusing v8::Handle;\nusing v8::Object;\n\nvoid InitAll(Handle exports) {\n exports->Set(NanSymbol(\"calculateSync\"),\n NanNew(CalculateSync)->GetFunction());\n\n exports->Set(NanSymbol(\"calculateAsync\"),\n NanNew(CalculateAsync)->GetFunction());\n}\n\nNODE_MODULE(addon, InitAll)\n```\n\n```c++\n// sync.h\n#include \n#include \n\nNAN_METHOD(CalculateSync);\n```\n\n```c++\n// sync.cc\n#include \n#include \n#include \"./sync.h\"\n// ...\n\nusing v8::Number;\n\n// Simple synchronous access to the `Estimate()` function\nNAN_METHOD(CalculateSync) {\n NanScope();\n\n // expect a number as the first argument\n int points = args[0]->Uint32Value();\n double est = Estimate(points);\n\n NanReturnValue(NanNew(est));\n}\n```\n\n```c++\n// async.cc\n#include \n#include \n#include \"./async.h\"\n\n// ...\n\nusing v8::Function;\nusing v8::Local;\nusing v8::Null;\nusing v8::Number;\nusing v8::Value;\n\nclass PiWorker : public NanAsyncWorker {\n public:\n PiWorker(NanCallback *callback, int points)\n : NanAsyncWorker(callback), points(points) {}\n ~PiWorker() {}\n\n // Executed inside the worker-thread.\n // It is not safe to access V8, or V8 data structures\n // here, so everything we need for input and output\n // should go on `this`.\n void Execute () {\n estimate = Estimate(points);\n }\n\n // Executed when the async work is complete\n // this function will be run inside the main event loop\n // so it is safe to use V8 again\n void HandleOKCallback () {\n NanScope();\n\n Local argv[] = {\n NanNew(NanNull())\n , NanNew(estimate)\n };\n\n callback->Call(2, argv);\n };\n\n private:\n int points;\n double estimate;\n};\n\n// Asynchronous access to the `Estimate()` function\nNAN_METHOD(CalculateAsync) {\n NanScope();\n\n int points = args[0]->Uint32Value();\n NanCallback *callback = new NanCallback(args[1].As());\n\n NanAsyncQueueWorker(new PiWorker(callback, points));\n NanReturnUndefined();\n}\n```\n\n\n## API\n\n * NAN_METHOD\n * NAN_GETTER\n * NAN_SETTER\n * NAN_PROPERTY_GETTER\n * NAN_PROPERTY_SETTER\n * NAN_PROPERTY_ENUMERATOR\n * NAN_PROPERTY_DELETER\n * NAN_PROPERTY_QUERY\n * NAN_INDEX_GETTER\n * NAN_INDEX_SETTER\n * NAN_INDEX_ENUMERATOR\n * NAN_INDEX_DELETER\n * NAN_INDEX_QUERY\n * NAN_WEAK_CALLBACK\n * NAN_DEPRECATED\n * NAN_INLINE\n * NanNew\n * NanUndefined\n * NanNull\n * NanTrue\n * NanFalse\n * NanReturnValue\n * NanReturnUndefined\n * NanReturnNull\n * NanReturnEmptyString\n * NanScope\n * NanEscapableScope\n * NanEscapeScope\n * NanLocker\n * NanUnlocker\n * NanGetInternalFieldPointer\n * NanSetInternalFieldPointer\n * NanObjectWrapHandle\n * NanSymbol\n * NanGetPointerSafe\n * NanSetPointerSafe\n * NanRawString\n * NanCString\n * NanBooleanOptionValue\n * NanUInt32OptionValue\n * NanError, NanTypeError, NanRangeError\n * NanThrowError, NanThrowTypeError, NanThrowRangeError, NanThrowError(Handle), NanThrowError(Handle, int)\n * NanNewBufferHandle(char *, size_t, FreeCallback, void *), NanNewBufferHandle(char *, uint32_t), NanNewBufferHandle(uint32_t)\n * NanBufferUse(char *, uint32_t)\n * NanNewContextHandle\n * NanGetCurrentContext\n * NanHasInstance\n * NanDisposePersistent\n * NanAssignPersistent\n * NanMakeWeakPersistent\n * NanSetTemplate\n * NanMakeCallback\n * NanCompileScript\n * NanRunScript\n * NanAdjustExternalMemory\n * NanAddGCEpilogueCallback\n * NanAddGCPrologueCallback\n * NanRemoveGCEpilogueCallback\n * NanRemoveGCPrologueCallback\n * NanGetHeapStatistics\n * NanCallback\n * NanAsyncWorker\n * NanAsyncQueueWorker\n\n\n### NAN_METHOD(methodname)\n\nUse `NAN_METHOD` to define your V8 accessible methods:\n\n```c++\n// .h:\nclass Foo : public node::ObjectWrap {\n ...\n\n static NAN_METHOD(Bar);\n static NAN_METHOD(Baz);\n}\n\n\n// .cc:\nNAN_METHOD(Foo::Bar) {\n ...\n}\n\nNAN_METHOD(Foo::Baz) {\n ...\n}\n```\n\nThe reason for this macro is because of the method signature change in 0.11:\n\n```c++\n// 0.10 and below:\nHandle name(const Arguments& args)\n\n// 0.11 and above\nvoid name(const FunctionCallbackInfo& args)\n```\n\nThe introduction of `FunctionCallbackInfo` brings additional complications:\n\n\n### NAN_GETTER(methodname)\n\nUse `NAN_GETTER` to declare your V8 accessible getters. You get a `Local` `property` and an appropriately typed `args` object that can act like the `args` argument to a `NAN_METHOD` call.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_GETTER`.\n\n\n### NAN_SETTER(methodname)\n\nUse `NAN_SETTER` to declare your V8 accessible setters. Same as `NAN_GETTER` but you also get a `Local` `value` object to work with.\n\n\n### NAN_PROPERTY_GETTER(cbname)\nUse `NAN_PROPERTY_GETTER` to declare your V8 accessible property getters. You get a `Local` `property` and an appropriately typed `args` object that can act similar to the `args` argument to a `NAN_METHOD` call.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_GETTER`.\n\n\n### NAN_PROPERTY_SETTER(cbname)\nUse `NAN_PROPERTY_SETTER` to declare your V8 accessible property setters. Same as `NAN_PROPERTY_GETTER` but you also get a `Local` `value` object to work with.\n\n\n### NAN_PROPERTY_ENUMERATOR(cbname)\nUse `NAN_PROPERTY_ENUMERATOR` to declare your V8 accessible property enumerators. You get an appropriately typed `args` object like the `args` argument to a `NAN_PROPERTY_GETTER` call.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_ENUMERATOR`.\n\n\n### NAN_PROPERTY_DELETER(cbname)\nUse `NAN_PROPERTY_DELETER` to declare your V8 accessible property deleters. Same as `NAN_PROPERTY_GETTER`.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_DELETER`.\n\n\n### NAN_PROPERTY_QUERY(cbname)\nUse `NAN_PROPERTY_QUERY` to declare your V8 accessible property queries. Same as `NAN_PROPERTY_GETTER`.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_PROPERTY_QUERY`.\n\n\n### NAN_INDEX_GETTER(cbname)\nUse `NAN_INDEX_GETTER` to declare your V8 accessible index getters. You get a `uint32_t` `index` and an appropriately typed `args` object that can act similar to the `args` argument to a `NAN_METHOD` call.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_GETTER`.\n\n\n### NAN_INDEX_SETTER(cbname)\nUse `NAN_INDEX_SETTER` to declare your V8 accessible index setters. Same as `NAN_INDEX_GETTER` but you also get a `Local` `value` object to work with.\n\n\n### NAN_INDEX_ENUMERATOR(cbname)\nUse `NAN_INDEX_ENUMERATOR` to declare your V8 accessible index enumerators. You get an appropriately typed `args` object like the `args` argument to a `NAN_INDEX_GETTER` call.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_ENUMERATOR`.\n\n\n### NAN_INDEX_DELETER(cbname)\nUse `NAN_INDEX_DELETER` to declare your V8 accessible index deleters. Same as `NAN_INDEX_GETTER`.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_DELETER`.\n\n\n### NAN_INDEX_QUERY(cbname)\nUse `NAN_INDEX_QUERY` to declare your V8 accessible index queries. Same as `NAN_INDEX_GETTER`.\n\nYou can use `NanReturnNull()`, `NanReturnEmptyString()`, `NanReturnUndefined()` and `NanReturnValue()` in a `NAN_INDEX_QUERY`.\n\n\n### NAN_WEAK_CALLBACK(cbname)\n\nUse `NAN_WEAK_CALLBACK` to define your V8 WeakReference callbacks. Do not use for declaration. There is an argument object `const _NanWeakCallbackData &data` allowing access to the weak object and the supplied parameter through its `GetValue` and `GetParameter` methods.\n\n```c++\nNAN_WEAK_CALLBACK(weakCallback) {\n int *parameter = data.GetParameter();\n NanMakeCallback(NanGetCurrentContext()->Global(), data.GetValue(), 0, NULL);\n if ((*parameter)++ == 0) {\n data.Revive();\n } else {\n delete parameter;\n data.Dispose();\n }\n}\n```\n\n\n### NAN_DEPRECATED\nDeclares a function as deprecated.\n\n```c++\nstatic NAN_DEPRECATED NAN_METHOD(foo) {\n ...\n}\n```\n\n\n### NAN_INLINE\nInlines a function.\n\n```c++\nNAN_INLINE int foo(int bar) {\n ...\n}\n```\n\n\n### Local<T> NanNew<T>( ... )\n\nUse `NanNew` to construct almost all v8 objects and make new local handles.\n\n```c++\nLocal s = NanNew(\"value\");\n\n...\n\nPersistent o;\n\n...\n\nLocal lo = NanNew(o);\n\n```\n\n\n### Handle<Primitive> NanUndefined()\n\nUse instead of `Undefined()`\n\n\n### Handle<Primitive> NanNull()\n\nUse instead of `Null()`\n\n\n### Handle<Primitive> NanTrue()\n\nUse instead of `True()`\n\n\n### Handle<Primitive> NanFalse()\n\nUse instead of `False()`\n\n\n### NanReturnValue(Handle<Value>)\n\nUse `NanReturnValue` when you want to return a value from your V8 accessible method:\n\n```c++\nNAN_METHOD(Foo::Bar) {\n ...\n\n NanReturnValue(NanNew(\"FooBar!\"));\n}\n```\n\nNo `return` statement required.\n\n\n### NanReturnUndefined()\n\nUse `NanReturnUndefined` when you don't want to return anything from your V8 accessible method:\n\n```c++\nNAN_METHOD(Foo::Baz) {\n ...\n\n NanReturnUndefined();\n}\n```\n\n\n### NanReturnNull()\n\nUse `NanReturnNull` when you want to return `Null` from your V8 accessible method:\n\n```c++\nNAN_METHOD(Foo::Baz) {\n ...\n\n NanReturnNull();\n}\n```\n\n\n### NanReturnEmptyString()\n\nUse `NanReturnEmptyString` when you want to return an empty `String` from your V8 accessible method:\n\n```c++\nNAN_METHOD(Foo::Baz) {\n ...\n\n NanReturnEmptyString();\n}\n```\n\n\n### NanScope()\n\nThe introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanScope()` necessary, use it in place of `HandleScope scope`:\n\n```c++\nNAN_METHOD(Foo::Bar) {\n NanScope();\n\n NanReturnValue(NanNew(\"FooBar!\"));\n}\n```\n\n\n### NanEscapableScope()\n\nThe separation of handle scopes into escapable and inescapable scopes makes `NanEscapableScope()` necessary, use it in place of `HandleScope scope` when you later wish to `Close()` the scope:\n\n```c++\nHandle Foo::Bar() {\n NanEscapableScope();\n\n return NanEscapeScope(NanNew(\"FooBar!\"));\n}\n```\n\n\n### Local<T> NanEscapeScope(Handle<T> value);\nUse together with `NanEscapableScope` to escape the scope. Corresponds to `HandleScope::Close` or `EscapableHandleScope::Escape`.\n\n\n### NanLocker()\n\nThe introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanLocker()` necessary, use it in place of `Locker locker`:\n\n```c++\nNAN_METHOD(Foo::Bar) {\n NanLocker();\n ...\n NanUnlocker();\n}\n```\n\n\n### NanUnlocker()\n\nThe introduction of `isolate` references for many V8 calls in Node 0.11 makes `NanUnlocker()` necessary, use it in place of `Unlocker unlocker`:\n\n```c++\nNAN_METHOD(Foo::Bar) {\n NanLocker();\n ...\n NanUnlocker();\n}\n```\n\n\n### void * NanGetInternalFieldPointer(Handle<Object>, int)\n\nGets a pointer to the internal field with at `index` from a V8 `Object` handle.\n\n```c++\nLocal obj;\n...\nNanGetInternalFieldPointer(obj, 0);\n```\n\n### void NanSetInternalFieldPointer(Handle<Object>, int, void *)\n\nSets the value of the internal field at `index` on a V8 `Object` handle.\n\n```c++\nstatic Persistent dataWrapperCtor;\n...\nLocal wrapper = NanPersistentToLocal(dataWrapperCtor)->NewInstance();\nNanSetInternalFieldPointer(wrapper, 0, this);\n```\n\n\n### Local<Object> NanObjectWrapHandle(Object)\n\nWhen you want to fetch the V8 object handle from a native object you've wrapped with Node's `ObjectWrap`, you should use `NanObjectWrapHandle`:\n\n```c++\nNanObjectWrapHandle(iterator)->Get(NanSymbol(\"end\"))\n```\n\n\n### String NanSymbol(char *)\n\nUse to create string symbol objects (i.e. `v8::String::NewSymbol(x)`), for getting and setting object properties, or names of objects.\n\n```c++\nbool foo = false;\nif (obj->Has(NanSymbol(\"foo\")))\n foo = optionsObj->Get(NanSymbol(\"foo\"))->BooleanValue()\n```\n\n\n### Type NanGetPointerSafe(Type *[, Type])\n\nA helper for getting values from optional pointers. If the pointer is `NULL`, the function returns the optional default value, which defaults to `0`. Otherwise, the function returns the value the pointer points to.\n\n```c++\nchar *plugh(uint32_t *optional) {\n char res[] = \"xyzzy\";\n uint32_t param = NanGetPointerSafe(optional, 0x1337);\n switch (param) {\n ...\n }\n NanSetPointerSafe(optional, 0xDEADBEEF);\n} \n```\n\n\n### bool NanSetPointerSafe(Type *, Type)\n\nA helper for setting optional argument pointers. If the pointer is `NULL`, the function simply returns `false`. Otherwise, the value is assigned to the variable the pointer points to.\n\n```c++\nconst char *plugh(size_t *outputsize) {\n char res[] = \"xyzzy\";\n if !(NanSetPointerSafe(outputsize, strlen(res) + 1)) {\n ...\n }\n\n ...\n}\n```\n\n\n### void* NanRawString(Handle<Value>, enum Nan::Encoding, size_t *, void *, size_t, int)\n\nWhen you want to convert a V8 `String` to a `char*` buffer, use `NanRawString`. You have to supply an encoding as well as a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows setting `String::WriteOptions`.\nJust remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:\n\n```c++\nsize_t count;\nvoid* decoded = NanRawString(args[1], Nan::BASE64, &count, NULL, 0, String::HINT_MANY_WRITES_EXPECTED);\nchar param_copy[count];\nmemcpy(param_copy, decoded, count);\ndelete[] decoded;\n```\n\n\n### char* NanCString(Handle<Value>, size_t *[, char *, size_t, int])\n\nWhen you want to convert a V8 `String` to a null-terminated C `char*` use `NanCString`. The resulting `char*` will be UTF-8-encoded, and you need to supply a pointer to a variable that will be assigned the number of bytes in the returned string. It is also possible to supply a buffer and its length to the function in order not to have a new buffer allocated. The final argument allows optionally setting `String::WriteOptions`, which default to `v8::String::NO_OPTIONS`.\nJust remember that you'll end up with an object that you'll need to `delete[]` at some point unless you supply your own buffer:\n\n```c++\nsize_t count;\nchar* name = NanCString(args[0], &count);\n```\n\n\n### bool NanBooleanOptionValue(Handle<Value>, Handle<String>[, bool])\n\nWhen you have an \"options\" object that you need to fetch properties from, boolean options can be fetched with this pair. They check first if the object exists (`IsEmpty`), then if the object has the given property (`Has`) then they get and convert/coerce the property to a `bool`.\n\nThe optional last parameter is the *default* value, which is `false` if left off:\n\n```c++\n// `foo` is false unless the user supplies a truthy value for it\nbool foo = NanBooleanOptionValue(optionsObj, NanSymbol(\"foo\"));\n// `bar` is true unless the user supplies a falsy value for it\nbool bar = NanBooleanOptionValueDefTrue(optionsObj, NanSymbol(\"bar\"), true);\n```\n\n\n### uint32_t NanUInt32OptionValue(Handle<Value>, Handle<String>, uint32_t)\n\nSimilar to `NanBooleanOptionValue`, use `NanUInt32OptionValue` to fetch an integer option from your options object. Can be any kind of JavaScript `Number` and it will be coerced to an unsigned 32-bit integer.\n\nRequires all 3 arguments as a default is not optional:\n\n```c++\nuint32_t count = NanUInt32OptionValue(optionsObj, NanSymbol(\"count\"), 1024);\n```\n\n\n### NanError(message), NanTypeError(message), NanRangeError(message)\n\nFor making `Error`, `TypeError` and `RangeError` objects.\n\n```c++\nLocal res = NanError(\"you must supply a callback argument\");\n```\n\n\n### NanThrowError(message), NanThrowTypeError(message), NanThrowRangeError(message), NanThrowError(Local<Value>), NanThrowError(Local<Value>, int)\n\nFor throwing `Error`, `TypeError` and `RangeError` objects. You should `return` this call:\n\n```c++\nreturn NanThrowError(\"you must supply a callback argument\");\n```\n\nCan also handle any custom object you may want to throw. If used with the error code argument, it will add the supplied error code to the error object as a property called `code`.\n\n\n### Local<Object> NanNewBufferHandle(char *, uint32_t), Local<Object> NanNewBufferHandle(uint32_t)\n\nThe `Buffer` API has changed a little in Node 0.11, this helper provides consistent access to `Buffer` creation:\n\n```c++\nNanNewBufferHandle((char*)value.data(), value.size());\n```\n\nCan also be used to initialize a `Buffer` with just a `size` argument.\n\nCan also be supplied with a `NanFreeCallback` and a hint for the garbage collector.\n\n\n### Local<Object> NanBufferUse(char*, uint32_t)\n\n`Buffer::New(char*, uint32_t)` prior to 0.11 would make a copy of the data.\nWhile it was possible to get around this, it required a shim by passing a\ncallback. So the new API `Buffer::Use(char*, uint32_t)` was introduced to remove\nneeding to use this shim.\n\n`NanBufferUse` uses the `char*` passed as the backing data, and will free the\nmemory automatically when the weak callback is called. Keep this in mind, as\ncareless use can lead to \"double free or corruption\" and other cryptic failures.\n\n\n### bool NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)\n\nCan be used to check the type of an object to determine it is of a particular class you have already defined and have a `Persistent` handle for.\n\n\n### Local<Context> NanNewContextHandle([ExtensionConfiguration*, Handle<ObjectTemplate>, Handle<Value>])\nCreates a new `Local` handle.\n\n```c++\nLocal ftmpl = NanNew();\nLocal otmpl = ftmpl->InstanceTemplate();\nLocal ctx = NanNewContextHandle(NULL, otmpl);\n```\n\n\n### Local NanGetCurrentContext()\n\nGets the current context.\n\n```c++\nLocal ctx = NanGetCurrentContext();\n```\n\n\n### void NanDisposePersistent(Persistent<T> &)\n\nUse `NanDisposePersistent` to dispose a `Persistent` handle.\n\n```c++\nNanDisposePersistent(persistentHandle);\n```\n\n\n### NanAssignPersistent(type, handle, object)\n\nUse `NanAssignPersistent` to assign a non-`Persistent` handle to a `Persistent` one. You can no longer just declare a `Persistent` handle and assign directly to it later, you have to `Reset` it in Node 0.11, so this makes it easier.\n\nIn general it is now better to place anything you want to protect from V8's garbage collector as properties of a generic `Object` and then assign that to a `Persistent`. This works in older versions of Node also if you use `NanAssignPersistent`:\n\n```c++\nPersistent persistentHandle;\n\n...\n\nLocal obj = NanNew();\nobj->Set(NanSymbol(\"key\"), keyHandle); // where keyHandle might be a Local\nNanAssignPersistent(Object, persistentHandle, obj)\n```\n\n\n### NanMakeWeakPersistent(Handle<T> handle, P* parameter, _NanWeakCallbackInfo<T, P>::Callback callback)\n\nCreates a weak persistent handle with the supplied parameter and `NAN_WEAK_CALLBACK`. The callback has to be fully specialized to work on all versions of Node.\n\n```c++\nNAN_WEAK_CALLBACK(weakCallback) {\n\n...\n\n}\n\nLocal func;\n\n...\n\nint *parameter = new int(0);\nNanMakeWeakPersistent(func, parameter, &weakCallback);\n```\n\n\n### NanSetTemplate(templ, name, value)\n\nUse to add properties on object and function templates.\n\n\n### NanMakeCallback(target, func, argc, argv)\n\nUse instead of `node::MakeCallback` to call javascript functions. This is the only proper way of calling functions.\n\n\n### NanCompileScript(Handle s [, const ScriptOrigin& origin])\n\nUse to create new scripts bound to the current context.\n\n\n### NanRunScript(script)\n\nUse to run both bound and unbound scripts.\n\n\n### NanAdjustExternalMemory(int change_in_bytes)\n\nSimply does `AdjustAmountOfExternalAllocatedMemory`\n\n\n### NanAddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)\n\nSimply does `AddGCEpilogueCallback`\n\n\n### NanAddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)\n\nSimply does `AddGCPrologueCallback`\n\n\n### NanRemoveGCEpilogueCallback(GCEpilogueCallback callback)\n\nSimply does `RemoveGCEpilogueCallback`\n\n\n### NanRemoveGCPrologueCallback(GCPrologueCallback callback)\n\nSimply does `RemoveGCPrologueCallback`\n\n\n### NanGetHeapStatistics(HeapStatistics *heap_statistics)\n\nSimply does `GetHeapStatistics`\n\n\n### NanCallback\n\nBecause of the difficulties imposed by the changes to `Persistent` handles in V8 in Node 0.11, creating `Persistent` versions of your `Handle` is annoyingly tricky. `NanCallback` makes it easier by taking your handle, making it persistent until the `NanCallback` is deleted and even providing a handy `Call()` method to fetch and execute the callback `Function`.\n\n```c++\nLocal callbackHandle = args[0].As();\nNanCallback *callback = new NanCallback(callbackHandle);\n// pass `callback` around and it's safe from GC until you:\ndelete callback;\n```\n\nYou can execute the callback like so:\n\n```c++\n// no arguments:\ncallback->Call(0, NULL);\n\n// an error argument:\nHandle argv[] = {\n NanError(NanNew(\"fail!\"))\n};\ncallback->Call(1, argv);\n\n// a success argument:\nHandle argv[] = {\n NanNull(),\n NanNew(\"w00t!\")\n};\ncallback->Call(2, argv);\n```\n\n`NanCallback` also has a `Local GetCallback()` method that you can use\nto fetch a local handle to the underlying callback function, as well as a\n`void SetFunction(Handle)` for setting the callback on the\n`NanCallback`. Additionally a generic constructor is available for using\n`NanCallback` without performing heap allocations.\n\n\n### NanAsyncWorker\n\n`NanAsyncWorker` is an abstract class that you can subclass to have much of the annoying async queuing and handling taken care of for you. It can even store arbitrary V8 objects for you and have them persist while the async work is in progress.\n\nSee a rough outline of the implementation:\n\n```c++\nclass NanAsyncWorker {\npublic:\n NanAsyncWorker (NanCallback *callback);\n\n // Clean up persistent handles and delete the *callback\n virtual ~NanAsyncWorker ();\n\n // Check the `char *errmsg` property and call HandleOKCallback()\n // or HandleErrorCallback depending on whether it has been set or not\n virtual void WorkComplete ();\n\n // You must implement this to do some async work. If there is an\n // error then allocate `errmsg` to a message and the callback will\n // be passed that string in an Error object\n virtual void Execute ();\n\n // Save a V8 object in a Persistent handle to protect it from GC\n void SavePersistent(const char *key, Local &obj);\n\n // Fetch a stored V8 object (don't call from within `Execute()`)\n Local GetFromPersistent(const char *key);\n\nprotected:\n // Set this if there is an error, otherwise it's NULL\n const char *errmsg;\n\n // Default implementation calls the callback function with no arguments.\n // Override this to return meaningful data\n virtual void HandleOKCallback ();\n\n // Default implementation calls the callback function with an Error object\n // wrapping the `errmsg` string\n virtual void HandleErrorCallback ();\n};\n```\n\n\n### NanAsyncQueueWorker(NanAsyncWorker *)\n\n`NanAsyncQueueWorker` will run a `NanAsyncWorker` asynchronously via libuv. Both the *execute* and *after_work* steps are taken care of for you—most of the logic for this is embedded in `NanAsyncWorker`.\n\n### Contributors\n\nNAN is only possible due to the excellent work of the following contributors:\n\n\n\n\n\n\n\n\n
Rod VaggGitHub/rvaggTwitter/@rvagg
Benjamin ByholmGitHub/kkoopa
Trevor NorrisGitHub/trevnorrisTwitter/@trevnorris
Nathan RajlichGitHub/TooTallNateTwitter/@TooTallNate
Brett LawsonGitHub/brett19Twitter/@brett19x
Ben NoordhuisGitHub/bnoordhuisTwitter/@bnoordhuis
\n\nLicence & copyright\n-----------------------\n\nCopyright (c) 2014 NAN contributors (listed above).\n\nNative Abstractions for Node.js is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/rvagg/nan/issues" - }, - "homepage": "https://github.com/rvagg/nan", - "_id": "nan@1.0.0", - "_from": "nan@~1.0.0" -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/options/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/options/package.json index bb26c80..7a62d8e 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/options/package.json +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/options/package.json @@ -22,12 +22,30 @@ "devDependencies": { "mocha": "latest" }, - "readme": "# options.js #\n\nA very light-weight in-code option parsers for node.js.\n\n## Usage ##\n\n``` js\nvar Options = require(\"options\");\n\n// Create an Options object\nfunction foo(options) {\n var default_options = {\n foo : \"bar\"\n };\n \n // Create an option object with default value\n var opts = new Options(default_options);\n \n // Merge options\n opts = opts.merge(options);\n \n // Reset to default value\n opts.reset();\n \n // Copy selected attributes out\n var seled_att = opts.copy(\"foo\");\n \n // Read json options from a file. \n opts.read(\"options.file\"); // Sync\n opts.read(\"options.file\", function(err){ // Async\n if(err){ // If error occurs\n console.log(\"File error.\");\n }else{\n // No error\n }\n });\n \n // Attributes defined or not\n opts.isDefinedAndNonNull(\"foobar\");\n opts.isDefined(\"foobar\");\n}\n\n```\n\n\n## License ##\n\n(The MIT License)\n\nCopyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", - "readmeFilename": "README.md", + "gitHead": "ff53d0a092c897cb95964232a96fe17da65c11af", "bugs": { "url": "https://github.com/einaros/options.js/issues" }, "homepage": "https://github.com/einaros/options.js", "_id": "options@0.0.6", - "_from": "options@>=0.0.5" + "_shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", + "_from": "options@>=0.0.5", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "einaros", + "email": "einaros@gmail.com" + }, + "maintainers": [ + { + "name": "einaros", + "email": "einaros@gmail.com" + } + ], + "dist": { + "shasum": "ec22d312806bb53e731773e7cdaefcf1c643128f", + "tarball": "http://registry.npmjs.org/options/-/options-0.0.6.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/README.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/README.md deleted file mode 100644 index 55eb3c1..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# tinycolor # - -This is a no-fuzz, barebone, zero muppetry color module for node.js. \ No newline at end of file diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/example.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/example.js deleted file mode 100644 index f754046..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/example.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./tinycolor'); -console.log('this should be red and have an underline!'.grey.underline); -console.log('this should have a blue background!'.bgBlue); \ No newline at end of file diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/package.json deleted file mode 100644 index 98637b2..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "author": { - "name": "Einar Otto Stangvik", - "email": "einaros@gmail.com", - "url": "http://2x.io" - }, - "name": "tinycolor", - "description": "a to-the-point color module for node", - "version": "0.0.1", - "repository": { - "type": "git", - "url": "git://github.com/einaros/tinycolor.git" - }, - "engines": { - "node": ">=0.4.0" - }, - "dependencies": {}, - "devDependencies": {}, - "main": "tinycolor", - "readme": "# tinycolor #\n\nThis is a no-fuzz, barebone, zero muppetry color module for node.js.", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/einaros/tinycolor/issues" - }, - "homepage": "https://github.com/einaros/tinycolor", - "_id": "tinycolor@0.0.1", - "_from": "tinycolor@0.x", - "scripts": {} -} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/tinycolor.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/tinycolor.js deleted file mode 100644 index 36e552c..0000000 --- a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/tinycolor/tinycolor.js +++ /dev/null @@ -1,31 +0,0 @@ -var styles = { - 'bold': ['\033[1m', '\033[22m'], - 'italic': ['\033[3m', '\033[23m'], - 'underline': ['\033[4m', '\033[24m'], - 'inverse': ['\033[7m', '\033[27m'], - 'black': ['\033[30m', '\033[39m'], - 'red': ['\033[31m', '\033[39m'], - 'green': ['\033[32m', '\033[39m'], - 'yellow': ['\033[33m', '\033[39m'], - 'blue': ['\033[34m', '\033[39m'], - 'magenta': ['\033[35m', '\033[39m'], - 'cyan': ['\033[36m', '\033[39m'], - 'white': ['\033[37m', '\033[39m'], - 'default': ['\033[39m', '\033[39m'], - 'grey': ['\033[90m', '\033[39m'], - 'bgBlack': ['\033[40m', '\033[49m'], - 'bgRed': ['\033[41m', '\033[49m'], - 'bgGreen': ['\033[42m', '\033[49m'], - 'bgYellow': ['\033[43m', '\033[49m'], - 'bgBlue': ['\033[44m', '\033[49m'], - 'bgMagenta': ['\033[45m', '\033[49m'], - 'bgCyan': ['\033[46m', '\033[49m'], - 'bgWhite': ['\033[47m', '\033[49m'], - 'bgDefault': ['\033[49m', '\033[49m'] -} -Object.keys(styles).forEach(function(style) { - Object.defineProperty(String.prototype, style, { - get: function() { return styles[style][0] + this + styles[style][1]; }, - enumerable: false - }); -}); diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.npmignore b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.npmignore new file mode 100644 index 0000000..66210a2 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.npmignore @@ -0,0 +1,3 @@ +node_modules +coverage +.tern-port diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.travis.yml b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.travis.yml new file mode 100644 index 0000000..a6e9741 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/.travis.yml @@ -0,0 +1,17 @@ +language: node_js +node_js: + - "0.8" + - "0.10" + - "0.11" +before_install: + - "npm install -g npm@1.4.x" +script: + - "npm run test-travis" +after_script: + - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls" +notifications: + irc: + channels: + - "irc.freenode.org#unshift" + on_success: change + on_failure: change diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/README.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/README.md new file mode 100644 index 0000000..84fa3f2 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/README.md @@ -0,0 +1,97 @@ +# Ultron + +[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/ultron.svg?style=flat-square)](http://browsenpm.org/package/ultron)[![Build Status](http://img.shields.io/travis/unshiftio/ultron/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/ultron)[![Dependencies](https://img.shields.io/david/unshiftio/ultron.svg?style=flat-square)](https://david-dm.org/unshiftio/ultron)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/ultron/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/ultron?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift) + +Ultron is a high-intelligence robot. It gathers intelligence so it can start +improving upon his rudimentary design. It will learn your event emitting +patterns and find ways to exterminate them. Allowing you to remove only the +event emitters that **you** assigned and not the ones that your users or +developers assigned. This can prevent race conditions, memory leaks and even file +descriptor leaks from ever happening as you won't remove clean up processes. + +## Installation + +The module is designed to be used in browsers using browserify and in Node.js. +You can install the module through the public npm registry by running the +following command in CLI: + +``` +npm install --save ultron +``` + +## Usage + +In all examples we assume that you've required the library as following: + +```js +'use strict'; + +var Ultron = require('ultron'); +``` + +Now that we've required the library we can construct our first `Ultron` instance. +The constructor requires one argument which should be the `EventEmitter` +instance that we need to operate upon. This can be the `EventEmitter` module +that ships with Node.js or `EventEmitter3` or anything else as long as it +follow the same API and internal structure as these 2. So with that in mind we +can create the instance: + +```js +// +// For the sake of this example we're going to construct an empty EventEmitter +// +var EventEmitter = require('events').EventEmitter; // or require('eventmitter3'); +var events = new EventEmitter(); + +var ultron = new Ultron(events); +``` + +You can now use the following API's from the Ultron instance: + +### Ultron.on + +Register a new event listener for the given event. It follows the exact same API +as `EventEmitter.on` but it will return itself instead of returning the +EventEmitter instance. If you are using EventEmitter3 it also supports the +context param: + +```js +ultron.on('event-name', handler, { custom: 'function context' }); +``` + +### Ultron.once + +Exactly the same as the [Ultron.on](#ultronon) but it only allows the execution +once. + +### Ultron.remove + +This is where all the magic happens and the safe removal starts. This function +accepts different argument styles: + +- No arguments, assume that all events need to be removed so it will work as + `removeAllListeners()` API. +- 1 argument, when it's a string it will be split on ` ` and `,` to create a + list of events that need to be cleared. +- Multiple arguments, we assume that they are all names of events that need to + be cleared. + +```js +ultron.remove('foo, bar baz'); // Removes foo, bar and baz. +ultron.remove('foo', 'bar', 'baz'); // Removes foo, bar and baz. +ultron.remove(); // Removes everything. +``` + +If you just want to remove a single event listener using a function reference +you can still use the EventEmitter's `removeListener(event, fn)` API: + +```js +function foo() {} + +ulton.on('foo', foo); +events.removeListener('foo', foo); +``` + +## License + +MIT diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/index.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/index.js new file mode 100644 index 0000000..f0e8113 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/index.js @@ -0,0 +1,125 @@ +'use strict'; + +/** + * An auto incrementing id which we can use to create "unique" Ultron instances + * so we can track the event emitters that are added through the Ultron + * interface. + * + * @type {Number} + * @private + */ +var id = 0; + +/** + * Ultron is high-intelligence robot. It gathers intelligence so it can start improving + * upon his rudimentary design. It will learn from your EventEmitting patterns + * and exterminate them. + * + * @constructor + * @param {EventEmitter} ee EventEmitter instance we need to wrap. + * @api public + */ +function Ultron(ee) { + if (!(this instanceof Ultron)) return new Ultron(ee); + + this.id = id++; + this.ee = ee; +} + +/** + * Register a new EventListener for the given event. + * + * @param {String} event Name of the event. + * @param {Functon} fn Callback function. + * @param {Mixed} context The context of the function. + * @returns {Ultron} + * @api public + */ +Ultron.prototype.on = function on(event, fn, context) { + fn.__ultron = this.id; + this.ee.on(event, fn, context); + + return this; +}; +/** + * Add an EventListener that's only called once. + * + * @param {String} event Name of the event. + * @param {Function} fn Callback function. + * @param {Mixed} context The context of the function. + * @returns {Ultron} + * @api public + */ +Ultron.prototype.once = function once(event, fn, context) { + fn.__ultron = this.id; + this.ee.once(event, fn, context); + + return this; +}; + +/** + * Remove the listeners we assigned for the given event. + * + * @returns {Ultron} + * @api public + */ +Ultron.prototype.remove = function remove() { + var args = arguments + , event; + + // + // When no event names are provided we assume that we need to clear all the + // events that were assigned through us. + // + if (args.length === 1 && 'string' === typeof args[0]) { + args = args[0].split(/[, ]+/); + } else if (!args.length) { + args = []; + + for (event in this.ee._events) { + if (this.ee._events.hasOwnProperty(event)) { + args.push(event); + } + } + } + + for (var i = 0; i < args.length; i++) { + var listeners = this.ee.listeners(args[i]); + + for (var j = 0; j < listeners.length; j++) { + event = listeners[j]; + + if (event.listener) { + if (event.listener.__ultron !== this.id) continue; + delete event.listener.__ultron; + } else { + if (event.__ultron !== this.id) continue; + delete event.__ultron; + } + + this.ee.removeListener(args[i], event); + } + } + + return this; +}; + +/** + * Destroy the Ultron instance, remove all listeners and release all references. + * + * @returns {Boolean} + * @api public + */ +Ultron.prototype.destroy = function destroy() { + if (!this.ee) return false; + + this.remove(); + this.ee = null; + + return true; +}; + +// +// Expose the module. +// +module.exports = Ultron; diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/package.json new file mode 100644 index 0000000..291b759 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/package.json @@ -0,0 +1,68 @@ +{ + "name": "ultron", + "version": "1.0.1", + "description": "Ultron is high-intelligence robot. It gathers intel so it can start improving upon his rudimentary design", + "main": "index.js", + "scripts": { + "test": "mocha --reporter spec --ui bdd test.js", + "watch": "mocha --watch --reporter spec --ui bdd test.js", + "coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js", + "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/unshiftio/ultron" + }, + "keywords": [ + "Ultron", + "robot", + "gather", + "intelligence", + "event", + "events", + "eventemitter", + "emitter", + "cleanup" + ], + "author": { + "name": "Arnout Kazemier" + }, + "license": "MIT", + "devDependencies": { + "assume": "0.0.x", + "eventemitter3": "0.1.x", + "istanbul": "0.3.x", + "mocha": "2.0.x", + "pre-commit": "0.0.x" + }, + "bugs": { + "url": "https://github.com/unshiftio/ultron/issues" + }, + "homepage": "https://github.com/unshiftio/ultron", + "gitHead": "1aae6f07661ebb69a60c466ef50b9798cfb7f631", + "_id": "ultron@1.0.1", + "_shasum": "c9d8d86c9cf2823028eb45629ab725897dd65dc5", + "_from": "ultron@1.0.x", + "_npmVersion": "1.4.28", + "_npmUser": { + "name": "V1", + "email": "info@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "V1", + "email": "info@3rd-Eden.com" + }, + { + "name": "unshift", + "email": "npm@unshift.io" + } + ], + "dist": { + "shasum": "c9d8d86c9cf2823028eb45629ab725897dd65dc5", + "tarball": "http://registry.npmjs.org/ultron/-/ultron-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/test.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/test.js new file mode 100644 index 0000000..1fd4f1b --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/ultron/test.js @@ -0,0 +1,327 @@ +/* istanbul ignore next */ +describe('Ultron', function () { + 'use strict'; + + var EventEmitter = require('eventemitter3') + , EE = require('events').EventEmitter + , assume = require('assume') + , Ultron = require('./') + , ultron + , ee; + + beforeEach(function () { + ee = new EventEmitter(); + ultron = new Ultron(ee); + }); + + afterEach(function () { + ultron.destroy(); + ee.removeAllListeners(); + }); + + it('is exposed as a function', function () { + assume(Ultron).is.a('function'); + }); + + it('can be initialized without the new keyword', function () { + assume(Ultron(ee)).is.instanceOf(Ultron); + }); + + it('assigns a unique id to every instance', function () { + for (var i = 0; i < 100; i++) { + assume(ultron.id).does.not.equal((new Ultron()).id); + } + }); + + it('allows removal through the event emitter', function () { + function foo() {} + function bar() {} + + ultron.on('foo', foo); + ultron.once('foo', bar); + + assume(foo.__ultron).equals(ultron.id); + assume(bar.__ultron).equals(ultron.id); + assume(ee.listeners('foo').length).equals(2); + + ee.removeListener('foo', foo); + assume(ee.listeners('foo').length).equals(1); + + ee.removeListener('foo', bar); + assume(ee.listeners('foo').length).equals(0); + }); + + describe('#on', function () { + it('assigns a listener', function () { + assume(ee.listeners('foo').length).equals(0); + + function foo() {} + + ultron.on('foo', foo); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('tags the assigned function', function () { + assume(ee.listeners('foo').length).equals(0); + + ultron.on('foo', function () {}); + assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); + }); + + it('also passes in the context', function (next) { + var context = 1313; + + ultron.on('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + assume(this).equals(context); + + next(); + }, context); + + ee.emit('foo', 'a', 'b', 'c'); + }); + + it('works with regular eventemitters as well', function (next) { + var ee = new EE() + , ultron = new Ultron(ee); + + ultron.on('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + next(); + }); + + ee.emit('foo', 'a', 'b', 'c'); + }); + }); + + describe('#once', function () { + it('assigns a listener', function () { + assume(ee.listeners('foo').length).equals(0); + + function foo() {} + ultron.once('foo', foo); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('tags the assigned function', function () { + assume(ee.listeners('foo').length).equals(0); + + ultron.once('foo', function () {}); + assume(ee.listeners('foo')[0].__ultron).equals(ultron.id); + }); + + it('also passes in the context', function (next) { + var context = 1313; + + ultron.once('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + assume(this).equals(context); + + next(); + }, context); + + ee.emit('foo', 'a', 'b', 'c'); + ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute + }); + + it('works with regular eventemitters as well', function (next) { + var ee = new EE() + , ultron = new Ultron(ee); + + ultron.once('foo', function (a, b, c) { + assume(a).equals('a'); + assume(b).equals('b'); + assume(c).equals('c'); + + next(); + }); + + ee.emit('foo', 'a', 'b', 'c'); + ee.emit('foo', 'a', 'b', 'c'); // Ensure that we don't double execute + }); + }); + + describe('#remove', function () { + it('removes only our assigned `on` listeners', function () { + function foo() {} + function bar() {} + + ee.on('foo', foo); + ultron.on('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('removes our private __ultron references', function () { + function once() {} + function on() {} + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.on('foo', on); + ultron.once('bar', once); + + assume('__ultron' in once).is.true(); + assume('__ultron' in on).is.true(); + + ultron.remove('foo, bar'); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.destroy(); + + ee = new EE(); + ultron = new Ultron(ee); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + + ultron.on('foo', on); + ultron.once('bar', once); + + assume('__ultron' in once).is.true(); + assume('__ultron' in on).is.true(); + + ultron.remove('foo, bar'); + + assume('__ultron' in once).is.false(); + assume('__ultron' in on).is.false(); + }); + + it('removes only our assigned `once` listeners', function () { + function foo() {} + function bar() {} + + ee.once('foo', foo); + ultron.once('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0]).equals(foo); + }); + + it('removes only our assigned `once` listeners from regular EE', function () { + var ee = new EE() + , ultron = new Ultron(ee); + + function foo() {} + function bar() {} + + ee.once('foo', foo); + ultron.once('foo', bar); + assume(ee.listeners('foo').length).equals(2); + + ultron.remove('foo'); + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('foo')[0].listener).equals(foo); + }); + + it('removes all assigned events if called without args', function () { + function foo() {} + function bar() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + + ultron.remove(); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + }); + + it('removes multiple listeners based on args', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.remove('foo', 'bar'); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(1); + }); + + it('removes multiple listeners if first arg is seperated string', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.remove('foo, bar'); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(1); + }); + }); + + describe('#destroy', function () { + it('removes all listeners', function () { + function foo() {} + function bar() {} + function baz() {} + + ultron.on('foo', foo); + ultron.on('bar', bar); + ultron.on('baz', baz); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + assume(ee.listeners('baz').length).equals(1); + + ultron.destroy(); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); + assume(ee.listeners('baz').length).equals(0); + }); + + it('removes the .ee reference', function () { + assume(ultron.ee).equals(ee); + ultron.destroy(); + assume(ultron.ee).equals(null); + }); + + it('returns booleans for state indication', function () { + assume(ultron.destroy()).is.true(); + assume(ultron.destroy()).is.false(); + assume(ultron.destroy()).is.false(); + assume(ultron.destroy()).is.false(); + }); + }); +}); diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/.npmignore b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/.npmignore new file mode 100644 index 0000000..0c90f67 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/.npmignore @@ -0,0 +1,3 @@ +npm-debug.log +node_modules +build diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/binding.gyp b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/binding.gyp new file mode 100644 index 0000000..2c5c882 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/binding.gyp @@ -0,0 +1,10 @@ +{ + 'targets': [ + { + 'target_name': 'validation', + 'include_dirs': ["> $(depfile) +# Add extra rules as in (2). +# We remove slashes and replace spaces with new lines; +# remove blank lines; +# delete the first line and append a colon to the remaining lines. +sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ + grep -v '^$$' |\ + sed -e 1d -e 's|$$|:|' \ + >> $(depfile) +rm $(depfile).raw +endef + +# Command definitions: +# - cmd_foo is the actual command to run; +# - quiet_cmd_foo is the brief-output summary of the command. + +quiet_cmd_cc = CC($(TOOLSET)) $@ +cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< + +quiet_cmd_cxx = CXX($(TOOLSET)) $@ +cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< + +quiet_cmd_objc = CXX($(TOOLSET)) $@ +cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< + +quiet_cmd_objcxx = CXX($(TOOLSET)) $@ +cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< + +# Commands for precompiled header files. +quiet_cmd_pch_c = CXX($(TOOLSET)) $@ +cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< +quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ +cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< +quiet_cmd_pch_m = CXX($(TOOLSET)) $@ +cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< +quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ +cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< + +# gyp-mac-tool is written next to the root Makefile by gyp. +# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd +# already. +quiet_cmd_mac_tool = MACTOOL $(4) $< +cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" + +quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ +cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) + +quiet_cmd_infoplist = INFOPLIST $@ +cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" + +quiet_cmd_touch = TOUCH $@ +cmd_touch = touch $@ + +quiet_cmd_copy = COPY $@ +# send stderr to /dev/null to ignore messages when linking directories. +cmd_copy = rm -rf "$@" && cp -af "$<" "$@" + +quiet_cmd_alink = LIBTOOL-STATIC $@ +cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) + +quiet_cmd_link = LINK($(TOOLSET)) $@ +cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink = SOLINK($(TOOLSET)) $@ +cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ +cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) + + +# Define an escape_quotes function to escape single quotes. +# This allows us to handle quotes properly as long as we always use +# use single quotes and escape_quotes. +escape_quotes = $(subst ','\'',$(1)) +# This comment is here just to include a ' to unconfuse syntax highlighting. +# Define an escape_vars function to escape '$' variable syntax. +# This allows us to read/write command lines with shell variables (e.g. +# $LD_LIBRARY_PATH), without triggering make substitution. +escape_vars = $(subst $$,$$$$,$(1)) +# Helper that expands to a shell command to echo a string exactly as it is in +# make. This uses printf instead of echo because printf's behaviour with respect +# to escape sequences is more portable than echo's across different shells +# (e.g., dash, bash). +exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' + +# Helper to compare the command we're about to run against the command +# we logged the last time we ran the command. Produces an empty +# string (false) when the commands match. +# Tricky point: Make has no string-equality test function. +# The kernel uses the following, but it seems like it would have false +# positives, where one string reordered its arguments. +# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ +# $(filter-out $(cmd_$@), $(cmd_$(1)))) +# We instead substitute each for the empty string into the other, and +# say they're equal if both substitutions produce the empty string. +# .d files contain ? instead of spaces, take that into account. +command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ + $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) + +# Helper that is non-empty when a prerequisite changes. +# Normally make does this implicitly, but we force rules to always run +# so we can check their command lines. +# $? -- new prerequisites +# $| -- order-only dependencies +prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) + +# Helper that executes all postbuilds until one fails. +define do_postbuilds + @E=0;\ + for p in $(POSTBUILDS); do\ + eval $$p;\ + E=$$?;\ + if [ $$E -ne 0 ]; then\ + break;\ + fi;\ + done;\ + if [ $$E -ne 0 ]; then\ + rm -rf "$@";\ + exit $$E;\ + fi +endef + +# do_cmd: run a command via the above cmd_foo names, if necessary. +# Should always run for a given target to handle command-line changes. +# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. +# Third argument, if non-zero, makes it do POSTBUILDS processing. +# Note: We intentionally do NOT call dirx for depfile, since it contains ? for +# spaces already and dirx strips the ? characters. +define do_cmd +$(if $(or $(command_changed),$(prereq_changed)), + @$(call exact_echo, $($(quiet)cmd_$(1))) + @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" + $(if $(findstring flock,$(word 2,$(cmd_$1))), + @$(cmd_$(1)) + @echo " $(quiet_cmd_$(1)): Finished", + @$(cmd_$(1)) + ) + @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) + @$(if $(2),$(fixup_dep)) + $(if $(and $(3), $(POSTBUILDS)), + $(call do_postbuilds) + ) +) +endef + +# Declare the "all" target first so it is the default, +# even though we don't have the deps yet. +.PHONY: all +all: + +# make looks for ways to re-generate included makefiles, but in our case, we +# don't have a direct way. Explicitly telling make that it has nothing to do +# for them makes it go faster. +%.d: ; + +# Use FORCE_DO_CMD to force a target to run. Should be coupled with +# do_cmd. +.PHONY: FORCE_DO_CMD +FORCE_DO_CMD: + +TOOLSET := target +# Suffix rules, putting all outputs into $(obj). +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + +# Try building from generated source, too. +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + +$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + + +ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ + $(findstring $(join ^,$(prefix)),\ + $(join ^,validation.target.mk)))),) + include validation.target.mk +endif + +quiet_cmd_regen_makefile = ACTION Regenerating $@ +cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/sheriff/Sites/projects/basic-style/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/sheriff/.node-gyp/0.10.33/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/sheriff/.node-gyp/0.10.33" "-Dmodule_root_dir=/Users/sheriff/Sites/projects/basic-style/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate" binding.gyp +Makefile: $(srcdir)/../../../../../../../../../.node-gyp/0.10.33/common.gypi $(srcdir)/../../../../../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp + $(call do_cmd,regen_makefile) + +# "all" is a concatenation of the "all" targets from all the included +# sub-makefiles. This is just here to clarify. +all: + +# Add in dependency-tracking rules. $(all_deps) is the list of every single +# target in our tree. Only consider the ones with .d (dependency) info: +d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) +ifneq ($(d_files),) + include $(d_files) +endif diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/.deps/Release/obj.target/validation/src/validation.o.d b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/.deps/Release/obj.target/validation/src/validation.o.d similarity index 88% rename from node_modules/auto-reload-brunch/node_modules/ws/build/Release/.deps/Release/obj.target/validation/src/validation.o.d rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/.deps/Release/obj.target/validation/src/validation.o.d index 50f9987..5000136 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/.deps/Release/obj.target/validation/src/validation.o.d +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/.deps/Release/obj.target/validation/src/validation.o.d @@ -8,9 +8,10 @@ Release/obj.target/validation/src/validation.o: ../src/validation.cc \ /Users/sheriff/.node-gyp/0.10.33/deps/uv/include/uv-private/ngx-queue.h \ /Users/sheriff/.node-gyp/0.10.33/deps/uv/include/uv-private/uv-darwin.h \ /Users/sheriff/.node-gyp/0.10.33/src/node_object_wrap.h \ + /Users/sheriff/.node-gyp/0.10.33/src/node_version.h \ /Users/sheriff/.node-gyp/0.10.33/src/node_buffer.h \ - ../node_modules/nan/nan.h \ - /Users/sheriff/.node-gyp/0.10.33/src/node_version.h + ../node_modules/nan/nan.h ../node_modules/nan/nan_new.h \ + ../node_modules/nan/nan_implementation_pre_12_inl.h ../src/validation.cc: /Users/sheriff/.node-gyp/0.10.33/deps/v8/include/v8.h: /Users/sheriff/.node-gyp/0.10.33/deps/v8/include/v8stdint.h: @@ -20,6 +21,8 @@ Release/obj.target/validation/src/validation.o: ../src/validation.cc \ /Users/sheriff/.node-gyp/0.10.33/deps/uv/include/uv-private/ngx-queue.h: /Users/sheriff/.node-gyp/0.10.33/deps/uv/include/uv-private/uv-darwin.h: /Users/sheriff/.node-gyp/0.10.33/src/node_object_wrap.h: +/Users/sheriff/.node-gyp/0.10.33/src/node_version.h: /Users/sheriff/.node-gyp/0.10.33/src/node_buffer.h: ../node_modules/nan/nan.h: -/Users/sheriff/.node-gyp/0.10.33/src/node_version.h: +../node_modules/nan/nan_new.h: +../node_modules/nan/nan_implementation_pre_12_inl.h: diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/Release/.deps/Release/validation.node.d b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/.deps/Release/validation.node.d similarity index 100% rename from node_modules/auto-reload-brunch/node_modules/ws/build/Release/.deps/Release/validation.node.d rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/.deps/Release/validation.node.d diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/linker.lock b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/linker.lock new file mode 100644 index 0000000..e69de29 diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/obj.target/validation/src/validation.o b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/obj.target/validation/src/validation.o new file mode 100644 index 0000000..09c8eac Binary files /dev/null and b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/obj.target/validation/src/validation.o differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/validation.node b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/validation.node new file mode 100755 index 0000000..dfb38ac Binary files /dev/null and b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/Release/validation.node differ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/binding.Makefile b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/binding.Makefile new file mode 100644 index 0000000..c7aead9 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/binding.Makefile @@ -0,0 +1,6 @@ +# This file is generated by gyp; do not edit. + +export builddir_name ?= ./build/. +.PHONY: all +all: + $(MAKE) validation diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/config.gypi b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/config.gypi new file mode 100644 index 0000000..3162587 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/config.gypi @@ -0,0 +1,120 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [] + }, + "variables": { + "clang": 1, + "host_arch": "x64", + "node_install_npm": "true", + "node_prefix": "", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_openssl": "false", + "node_shared_v8": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_unsafe_optimizations": 0, + "node_use_dtrace": "true", + "node_use_etw": "false", + "node_use_openssl": "true", + "node_use_perfctr": "false", + "openssl_no_asm": 0, + "python": "/usr/bin/python", + "target_arch": "x64", + "v8_enable_gdbjit": 0, + "v8_no_strict_aliasing": 1, + "v8_use_snapshot": "false", + "want_separate_host_toolset": 0, + "nodedir": "/Users/sheriff/.node-gyp/0.10.33", + "copy_dev_lib": "true", + "standalone_static_library": 1, + "save_dev": "", + "browser": "", + "viewer": "man", + "rollback": "true", + "usage": "", + "globalignorefile": "/usr/local/etc/npmignore", + "init_author_url": "", + "shell": "/bin/bash", + "parseable": "", + "shrinkwrap": "true", + "email": "", + "init_license": "ISC", + "cache_max": "Infinity", + "init_author_email": "", + "sign_git_tag": "", + "cert": "", + "git_tag_version": "true", + "local_address": "", + "long": "", + "registry": "https://registry.npmjs.org/", + "fetch_retries": "2", + "npat": "", + "key": "", + "message": "%s", + "versions": "", + "globalconfig": "/usr/local/etc/npmrc", + "always_auth": "", + "spin": "true", + "cache_lock_retries": "10", + "cafile": "", + "heading": "npm", + "fetch_retry_mintimeout": "10000", + "proprietary_attribs": "true", + "json": "", + "description": "true", + "engine_strict": "", + "https_proxy": "", + "init_module": "/Users/sheriff/.npm-init.js", + "userconfig": "/Users/sheriff/.npmrc", + "node_version": "0.10.33", + "user": "501", + "editor": "vi", + "save": "", + "tag": "latest", + "global": "", + "optional": "true", + "username": "", + "bin_links": "true", + "force": "", + "searchopts": "", + "depth": "Infinity", + "rebuild_bundle": "true", + "searchsort": "name", + "unicode": "true", + "fetch_retry_maxtimeout": "60000", + "ca": "", + "save_prefix": "^", + "strict_ssl": "true", + "dev": "", + "fetch_retry_factor": "10", + "group": "20", + "save_exact": "", + "cache_lock_stale": "60000", + "version": "", + "cache_min": "10", + "cache": "/Users/sheriff/.npm", + "searchexclude": "", + "color": "true", + "save_optional": "", + "user_agent": "npm/1.4.28 node/v0.10.33 darwin x64", + "ignore_scripts": "", + "cache_lock_wait": "10000", + "production": "", + "save_bundle": "", + "umask": "18", + "git": "git", + "init_author_name": "", + "onload_script": "", + "tmp": "/var/folders/jt/9s9qxxs55xj50lxnxl6qb1g40000gn/T", + "unsafe_perm": "true", + "link": "", + "prefix": "/usr/local" + } +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/gyp-mac-tool b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/gyp-mac-tool new file mode 100755 index 0000000..7abfed5 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/gyp-mac-tool @@ -0,0 +1,512 @@ +#!/usr/bin/env python +# Generated by gyp. Do not edit. +# Copyright (c) 2012 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Utility functions to perform Xcode-style build steps. + +These functions are executed via gyp-mac-tool when using the Makefile generator. +""" + +import fcntl +import fnmatch +import glob +import json +import os +import plistlib +import re +import shutil +import string +import subprocess +import sys +import tempfile + + +def main(args): + executor = MacTool() + exit_code = executor.Dispatch(args) + if exit_code is not None: + sys.exit(exit_code) + + +class MacTool(object): + """This class performs all the Mac tooling steps. The methods can either be + executed directly, or dispatched from an argument list.""" + + def Dispatch(self, args): + """Dispatches a string command to a method.""" + if len(args) < 1: + raise Exception("Not enough arguments") + + method = "Exec%s" % self._CommandifyName(args[0]) + return getattr(self, method)(*args[1:]) + + def _CommandifyName(self, name_string): + """Transforms a tool name like copy-info-plist to CopyInfoPlist""" + return name_string.title().replace('-', '') + + def ExecCopyBundleResource(self, source, dest): + """Copies a resource file to the bundle/Resources directory, performing any + necessary compilation on each resource.""" + extension = os.path.splitext(source)[1].lower() + if os.path.isdir(source): + # Copy tree. + # TODO(thakis): This copies file attributes like mtime, while the + # single-file branch below doesn't. This should probably be changed to + # be consistent with the single-file branch. + if os.path.exists(dest): + shutil.rmtree(dest) + shutil.copytree(source, dest) + elif extension == '.xib': + return self._CopyXIBFile(source, dest) + elif extension == '.storyboard': + return self._CopyXIBFile(source, dest) + elif extension == '.strings': + self._CopyStringsFile(source, dest) + else: + shutil.copy(source, dest) + + def _CopyXIBFile(self, source, dest): + """Compiles a XIB file with ibtool into a binary plist in the bundle.""" + + # ibtool sometimes crashes with relative paths. See crbug.com/314728. + base = os.path.dirname(os.path.realpath(__file__)) + if os.path.relpath(source): + source = os.path.join(base, source) + if os.path.relpath(dest): + dest = os.path.join(base, dest) + + args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', + '--output-format', 'human-readable-text', '--compile', dest, source] + ibtool_section_re = re.compile(r'/\*.*\*/') + ibtool_re = re.compile(r'.*note:.*is clipping its content') + ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE) + current_section_header = None + for line in ibtoolout.stdout: + if ibtool_section_re.match(line): + current_section_header = line + elif not ibtool_re.match(line): + if current_section_header: + sys.stdout.write(current_section_header) + current_section_header = None + sys.stdout.write(line) + return ibtoolout.returncode + + def _CopyStringsFile(self, source, dest): + """Copies a .strings file using iconv to reconvert the input into UTF-16.""" + input_code = self._DetectInputEncoding(source) or "UTF-8" + + # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call + # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints + # CFPropertyListCreateFromXMLData(): Old-style plist parser: missing + # semicolon in dictionary. + # on invalid files. Do the same kind of validation. + import CoreFoundation + s = open(source, 'rb').read() + d = CoreFoundation.CFDataCreate(None, s, len(s)) + _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None) + if error: + return + + fp = open(dest, 'wb') + fp.write(s.decode(input_code).encode('UTF-16')) + fp.close() + + def _DetectInputEncoding(self, file_name): + """Reads the first few bytes from file_name and tries to guess the text + encoding. Returns None as a guess if it can't detect it.""" + fp = open(file_name, 'rb') + try: + header = fp.read(3) + except e: + fp.close() + return None + fp.close() + if header.startswith("\xFE\xFF"): + return "UTF-16" + elif header.startswith("\xFF\xFE"): + return "UTF-16" + elif header.startswith("\xEF\xBB\xBF"): + return "UTF-8" + else: + return None + + def ExecCopyInfoPlist(self, source, dest, *keys): + """Copies the |source| Info.plist to the destination directory |dest|.""" + # Read the source Info.plist into memory. + fd = open(source, 'r') + lines = fd.read() + fd.close() + + # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). + plist = plistlib.readPlistFromString(lines) + if keys: + plist = dict(plist.items() + json.loads(keys[0]).items()) + lines = plistlib.writePlistToString(plist) + + # Go through all the environment variables and replace them as variables in + # the file. + IDENT_RE = re.compile('[/\s]') + for key in os.environ: + if key.startswith('_'): + continue + evar = '${%s}' % key + evalue = os.environ[key] + lines = string.replace(lines, evar, evalue) + + # Xcode supports various suffices on environment variables, which are + # all undocumented. :rfc1034identifier is used in the standard project + # template these days, and :identifier was used earlier. They are used to + # convert non-url characters into things that look like valid urls -- + # except that the replacement character for :identifier, '_' isn't valid + # in a URL either -- oops, hence :rfc1034identifier was born. + evar = '${%s:identifier}' % key + evalue = IDENT_RE.sub('_', os.environ[key]) + lines = string.replace(lines, evar, evalue) + + evar = '${%s:rfc1034identifier}' % key + evalue = IDENT_RE.sub('-', os.environ[key]) + lines = string.replace(lines, evar, evalue) + + # Remove any keys with values that haven't been replaced. + lines = lines.split('\n') + for i in range(len(lines)): + if lines[i].strip().startswith("${"): + lines[i] = None + lines[i - 1] = None + lines = '\n'.join(filter(lambda x: x is not None, lines)) + + # Write out the file with variables replaced. + fd = open(dest, 'w') + fd.write(lines) + fd.close() + + # Now write out PkgInfo file now that the Info.plist file has been + # "compiled". + self._WritePkgInfo(dest) + + def _WritePkgInfo(self, info_plist): + """This writes the PkgInfo file from the data stored in Info.plist.""" + plist = plistlib.readPlist(info_plist) + if not plist: + return + + # Only create PkgInfo for executable types. + package_type = plist['CFBundlePackageType'] + if package_type != 'APPL': + return + + # The format of PkgInfo is eight characters, representing the bundle type + # and bundle signature, each four characters. If that is missing, four + # '?' characters are used instead. + signature_code = plist.get('CFBundleSignature', '????') + if len(signature_code) != 4: # Wrong length resets everything, too. + signature_code = '?' * 4 + + dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') + fp = open(dest, 'w') + fp.write('%s%s' % (package_type, signature_code)) + fp.close() + + def ExecFlock(self, lockfile, *cmd_list): + """Emulates the most basic behavior of Linux's flock(1).""" + # Rely on exception handling to report errors. + fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) + fcntl.flock(fd, fcntl.LOCK_EX) + return subprocess.call(cmd_list) + + def ExecFilterLibtool(self, *cmd_list): + """Calls libtool and filters out '/path/to/libtool: file: foo.o has no + symbols'.""" + libtool_re = re.compile(r'^.*libtool: file: .* has no symbols$') + libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE) + _, err = libtoolout.communicate() + for line in err.splitlines(): + if not libtool_re.match(line): + print >>sys.stderr, line + return libtoolout.returncode + + def ExecPackageFramework(self, framework, version): + """Takes a path to Something.framework and the Current version of that and + sets up all the symlinks.""" + # Find the name of the binary based on the part before the ".framework". + binary = os.path.basename(framework).split('.')[0] + + CURRENT = 'Current' + RESOURCES = 'Resources' + VERSIONS = 'Versions' + + if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): + # Binary-less frameworks don't seem to contain symlinks (see e.g. + # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). + return + + # Move into the framework directory to set the symlinks correctly. + pwd = os.getcwd() + os.chdir(framework) + + # Set up the Current version. + self._Relink(version, os.path.join(VERSIONS, CURRENT)) + + # Set up the root symlinks. + self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) + self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) + + # Back to where we were before! + os.chdir(pwd) + + def _Relink(self, dest, link): + """Creates a symlink to |dest| named |link|. If |link| already exists, + it is overwritten.""" + if os.path.lexists(link): + os.remove(link) + os.symlink(dest, link) + + def ExecCodeSignBundle(self, key, resource_rules, entitlements, provisioning): + """Code sign a bundle. + + This function tries to code sign an iOS bundle, following the same + algorithm as Xcode: + 1. copy ResourceRules.plist from the user or the SDK into the bundle, + 2. pick the provisioning profile that best match the bundle identifier, + and copy it into the bundle as embedded.mobileprovision, + 3. copy Entitlements.plist from user or SDK next to the bundle, + 4. code sign the bundle. + """ + resource_rules_path = self._InstallResourceRules(resource_rules) + substitutions, overrides = self._InstallProvisioningProfile( + provisioning, self._GetCFBundleIdentifier()) + entitlements_path = self._InstallEntitlements( + entitlements, substitutions, overrides) + subprocess.check_call([ + 'codesign', '--force', '--sign', key, '--resource-rules', + resource_rules_path, '--entitlements', entitlements_path, + os.path.join( + os.environ['TARGET_BUILD_DIR'], + os.environ['FULL_PRODUCT_NAME'])]) + + def _InstallResourceRules(self, resource_rules): + """Installs ResourceRules.plist from user or SDK into the bundle. + + Args: + resource_rules: string, optional, path to the ResourceRules.plist file + to use, default to "${SDKROOT}/ResourceRules.plist" + + Returns: + Path to the copy of ResourceRules.plist into the bundle. + """ + source_path = resource_rules + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['CONTENTS_FOLDER_PATH'], + 'ResourceRules.plist') + if not source_path: + source_path = os.path.join( + os.environ['SDKROOT'], 'ResourceRules.plist') + shutil.copy2(source_path, target_path) + return target_path + + def _InstallProvisioningProfile(self, profile, bundle_identifier): + """Installs embedded.mobileprovision into the bundle. + + Args: + profile: string, optional, short name of the .mobileprovision file + to use, if empty or the file is missing, the best file installed + will be used + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + + Returns: + A tuple containing two dictionary: variables substitutions and values + to overrides when generating the entitlements file. + """ + source_path, provisioning_data, team_id = self._FindProvisioningProfile( + profile, bundle_identifier) + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['CONTENTS_FOLDER_PATH'], + 'embedded.mobileprovision') + shutil.copy2(source_path, target_path) + substitutions = self._GetSubstitutions(bundle_identifier, team_id + '.') + return substitutions, provisioning_data['Entitlements'] + + def _FindProvisioningProfile(self, profile, bundle_identifier): + """Finds the .mobileprovision file to use for signing the bundle. + + Checks all the installed provisioning profiles (or if the user specified + the PROVISIONING_PROFILE variable, only consult it) and select the most + specific that correspond to the bundle identifier. + + Args: + profile: string, optional, short name of the .mobileprovision file + to use, if empty or the file is missing, the best file installed + will be used + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + + Returns: + A tuple of the path to the selected provisioning profile, the data of + the embedded plist in the provisioning profile and the team identifier + to use for code signing. + + Raises: + SystemExit: if no .mobileprovision can be used to sign the bundle. + """ + profiles_dir = os.path.join( + os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles') + if not os.path.isdir(profiles_dir): + print >>sys.stderr, ( + 'cannot find mobile provisioning for %s' % bundle_identifier) + sys.exit(1) + provisioning_profiles = None + if profile: + profile_path = os.path.join(profiles_dir, profile + '.mobileprovision') + if os.path.exists(profile_path): + provisioning_profiles = [profile_path] + if not provisioning_profiles: + provisioning_profiles = glob.glob( + os.path.join(profiles_dir, '*.mobileprovision')) + valid_provisioning_profiles = {} + for profile_path in provisioning_profiles: + profile_data = self._LoadProvisioningProfile(profile_path) + app_id_pattern = profile_data.get( + 'Entitlements', {}).get('application-identifier', '') + for team_identifier in profile_data.get('TeamIdentifier', []): + app_id = '%s.%s' % (team_identifier, bundle_identifier) + if fnmatch.fnmatch(app_id, app_id_pattern): + valid_provisioning_profiles[app_id_pattern] = ( + profile_path, profile_data, team_identifier) + if not valid_provisioning_profiles: + print >>sys.stderr, ( + 'cannot find mobile provisioning for %s' % bundle_identifier) + sys.exit(1) + # If the user has multiple provisioning profiles installed that can be + # used for ${bundle_identifier}, pick the most specific one (ie. the + # provisioning profile whose pattern is the longest). + selected_key = max(valid_provisioning_profiles, key=lambda v: len(v)) + return valid_provisioning_profiles[selected_key] + + def _LoadProvisioningProfile(self, profile_path): + """Extracts the plist embedded in a provisioning profile. + + Args: + profile_path: string, path to the .mobileprovision file + + Returns: + Content of the plist embedded in the provisioning profile as a dictionary. + """ + with tempfile.NamedTemporaryFile() as temp: + subprocess.check_call([ + 'security', 'cms', '-D', '-i', profile_path, '-o', temp.name]) + return self._LoadPlistMaybeBinary(temp.name) + + def _LoadPlistMaybeBinary(self, plist_path): + """Loads into a memory a plist possibly encoded in binary format. + + This is a wrapper around plistlib.readPlist that tries to convert the + plist to the XML format if it can't be parsed (assuming that it is in + the binary format). + + Args: + plist_path: string, path to a plist file, in XML or binary format + + Returns: + Content of the plist as a dictionary. + """ + try: + # First, try to read the file using plistlib that only supports XML, + # and if an exception is raised, convert a temporary copy to XML and + # load that copy. + return plistlib.readPlist(plist_path) + except: + pass + with tempfile.NamedTemporaryFile() as temp: + shutil.copy2(plist_path, temp.name) + subprocess.check_call(['plutil', '-convert', 'xml1', temp.name]) + return plistlib.readPlist(temp.name) + + def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix): + """Constructs a dictionary of variable substitutions for Entitlements.plist. + + Args: + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + app_identifier_prefix: string, value for AppIdentifierPrefix + + Returns: + Dictionary of substitutions to apply when generating Entitlements.plist. + """ + return { + 'CFBundleIdentifier': bundle_identifier, + 'AppIdentifierPrefix': app_identifier_prefix, + } + + def _GetCFBundleIdentifier(self): + """Extracts CFBundleIdentifier value from Info.plist in the bundle. + + Returns: + Value of CFBundleIdentifier in the Info.plist located in the bundle. + """ + info_plist_path = os.path.join( + os.environ['TARGET_BUILD_DIR'], + os.environ['INFOPLIST_PATH']) + info_plist_data = self._LoadPlistMaybeBinary(info_plist_path) + return info_plist_data['CFBundleIdentifier'] + + def _InstallEntitlements(self, entitlements, substitutions, overrides): + """Generates and install the ${BundleName}.xcent entitlements file. + + Expands variables "$(variable)" pattern in the source entitlements file, + add extra entitlements defined in the .mobileprovision file and the copy + the generated plist to "${BundlePath}.xcent". + + Args: + entitlements: string, optional, path to the Entitlements.plist template + to use, defaults to "${SDKROOT}/Entitlements.plist" + substitutions: dictionary, variable substitutions + overrides: dictionary, values to add to the entitlements + + Returns: + Path to the generated entitlements file. + """ + source_path = entitlements + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['PRODUCT_NAME'] + '.xcent') + if not source_path: + source_path = os.path.join( + os.environ['SDKROOT'], + 'Entitlements.plist') + shutil.copy2(source_path, target_path) + data = self._LoadPlistMaybeBinary(target_path) + data = self._ExpandVariables(data, substitutions) + if overrides: + for key in overrides: + if key not in data: + data[key] = overrides[key] + plistlib.writePlist(data, target_path) + return target_path + + def _ExpandVariables(self, data, substitutions): + """Expands variables "$(variable)" in data. + + Args: + data: object, can be either string, list or dictionary + substitutions: dictionary, variable substitutions to perform + + Returns: + Copy of data where each references to "$(variable)" has been replaced + by the corresponding value found in substitutions, or left intact if + the key was not found. + """ + if isinstance(data, str): + for key, value in substitutions.iteritems(): + data = data.replace('$(%s)' % key, value) + return data + if isinstance(data, list): + return [self._ExpandVariables(v, substitutions) for v in data] + if isinstance(data, dict): + return dict((k, self._ExpandVariables(data[k], + substitutions)) for k in data) + return data + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/node_modules/auto-reload-brunch/node_modules/ws/build/validation.target.mk b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/validation.target.mk similarity index 100% rename from node_modules/auto-reload-brunch/node_modules/ws/build/validation.target.mk rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/build/validation.target.mk diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/fallback.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/fallback.js new file mode 100644 index 0000000..f929d77 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/fallback.js @@ -0,0 +1,13 @@ +'use strict'; + +/*! + * UTF-8 validate: UTF-8 validation for WebSockets. + * Copyright(c) 2015 Einar Otto Stangvik + * MIT Licensed + */ + +module.exports.Validation = { + isValidUTF8: function(buffer) { + return true; + } +}; diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/index.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/index.js new file mode 100644 index 0000000..e7bfde8 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/index.js @@ -0,0 +1,7 @@ +'use strict'; + +try { + module.exports = require('bindings')('validation'); +} catch (e) { + module.exports = require('./fallback'); +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/README.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/README.md new file mode 100644 index 0000000..585cf51 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/README.md @@ -0,0 +1,97 @@ +node-bindings +============= +### Helper module for loading your native module's .node file + +This is a helper module for authors of Node.js native addon modules. +It is basically the "swiss army knife" of `require()`ing your native module's +`.node` file. + +Throughout the course of Node's native addon history, addons have ended up being +compiled in a variety of different places, depending on which build tool and which +version of node was used. To make matters worse, now the _gyp_ build tool can +produce either a _Release_ or _Debug_ build, each being built into different +locations. + +This module checks _all_ the possible locations that a native addon would be built +at, and returns the first one that loads successfully. + + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install bindings +``` + +Or add it to the `"dependencies"` section of your _package.json_ file. + + +Example +------- + +`require()`ing the proper bindings file for the current node version, platform +and architecture is as simple as: + +``` js +var bindings = require('bindings')('binding.node') + +// Use your bindings defined in your C files +bindings.your_c_function() +``` + + +Nice Error Output +----------------- + +When the `.node` file could not be loaded, `node-bindings` throws an Error with +a nice error message telling you exactly what was tried. You can also check the +`err.tries` Array property. + +``` +Error: Could not load the bindings file. Tried: + → /Users/nrajlich/ref/build/binding.node + → /Users/nrajlich/ref/build/Debug/binding.node + → /Users/nrajlich/ref/build/Release/binding.node + → /Users/nrajlich/ref/out/Debug/binding.node + → /Users/nrajlich/ref/Debug/binding.node + → /Users/nrajlich/ref/out/Release/binding.node + → /Users/nrajlich/ref/Release/binding.node + → /Users/nrajlich/ref/build/default/binding.node + → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node + at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13) + at Object. (/Users/nrajlich/ref/lib/ref.js:5:47) + at Module._compile (module.js:449:26) + at Object.Module._extensions..js (module.js:467:10) + at Module.load (module.js:356:32) + at Function.Module._load (module.js:312:12) + ... +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/bindings.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/bindings.js new file mode 100644 index 0000000..93dcf85 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/bindings/bindings.js @@ -0,0 +1,166 @@ + +/** + * Module dependencies. + */ + +var fs = require('fs') + , path = require('path') + , join = path.join + , dirname = path.dirname + , exists = fs.existsSync || path.existsSync + , defaults = { + arrow: process.env.NODE_BINDINGS_ARROW || ' → ' + , compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' + , platform: process.platform + , arch: process.arch + , version: process.versions.node + , bindings: 'bindings.node' + , try: [ + // node-gyp's linked version in the "build" dir + [ 'module_root', 'build', 'bindings' ] + // node-waf and gyp_addon (a.k.a node-gyp) + , [ 'module_root', 'build', 'Debug', 'bindings' ] + , [ 'module_root', 'build', 'Release', 'bindings' ] + // Debug files, for development (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Debug', 'bindings' ] + , [ 'module_root', 'Debug', 'bindings' ] + // Release files, but manually compiled (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Release', 'bindings' ] + , [ 'module_root', 'Release', 'bindings' ] + // Legacy from node-waf, node <= 0.4.x + , [ 'module_root', 'build', 'default', 'bindings' ] + // Production "Release" buildtype binary (meh...) + , [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ] + ] + } + +/** + * The main `bindings()` function loads the compiled bindings for a given module. + * It uses V8's Error API to determine the parent filename that this function is + * being invoked from, which is then used to find the root directory. + */ + +function bindings (opts) { + + // Argument surgery + if (typeof opts == 'string') { + opts = { bindings: opts } + } else if (!opts) { + opts = {} + } + opts.__proto__ = defaults + + // Get the module root + if (!opts.module_root) { + opts.module_root = exports.getRoot(exports.getFileName()) + } + + // Ensure the given bindings name ends with .node + if (path.extname(opts.bindings) != '.node') { + opts.bindings += '.node' + } + + var tries = [] + , i = 0 + , l = opts.try.length + , n + , b + , err + + for (; i` 49259af + - Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179 + - Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9 + +### 1.5.2 Jan 23 2015 + + - Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4 + - Bugfix: Readded missing String constructors 18d828f + - Bugfix: Add overload handling NanNew(..) 5ef813b + - Bugfix: Fix uv_work_cb versioning 997e4ae + - Bugfix: Add function factory and test 4eca89c + - Bugfix: Add object template factory and test cdcb951 + - Correctness: Lifted an io.js related typedef c9490be + - Correctness: Make explicit downcasts of String lengths 00074e6 + - Windows: Limit the scope of disabled warning C4530 83d7deb + +### 1.5.1 Jan 15 2015 + + - Build: version bump + +### 1.4.3 Jan 15 2015 + + - Build: version bump + +### 1.4.2 Jan 15 2015 + + - Feature: Support io.js 0dbc5e8 + +### 1.5.0 Jan 14 2015 + + - Feature: Support io.js b003843 + - Correctness: Improved NanNew internals 9cd4f6a + - Feature: Implement progress to NanAsyncWorker 8d6a160 + +### 1.4.1 Nov 8 2014 + + - Bugfix: Handle DEBUG definition correctly + - Bugfix: Accept int as Boolean + +### 1.4.0 Nov 1 2014 + + - Feature: Added NAN_GC_CALLBACK 6a5c245 + - Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8 + - Correctness: Added constness to references in NanHasInstance 02c61cd + - Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6 + - Windoze: Shut Visual Studio up when compiling 8d558c1 + - License: Switch to plain MIT from custom hacked MIT license 11de983 + - Build: Added test target to Makefile e232e46 + - Performance: Removed superfluous scope in NanAsyncWorker f4b7821 + - Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208 + - Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450 + +### 1.3.0 Aug 2 2014 + + - Added NanNew(std::string) + - Added NanNew(std::string&) + - Added NanAsciiString helper class + - Added NanUtf8String helper class + - Added NanUcs2String helper class + - Deprecated NanRawString() + - Deprecated NanCString() + - Added NanGetIsolateData(v8::Isolate *isolate) + - Added NanMakeCallback(v8::Handle target, v8::Handle func, int argc, v8::Handle* argv) + - Added NanMakeCallback(v8::Handle target, v8::Handle symbol, int argc, v8::Handle* argv) + - Added NanMakeCallback(v8::Handle target, const char* method, int argc, v8::Handle* argv) + - Added NanSetTemplate(v8::Handle templ, v8::Handle name , v8::Handle value, v8::PropertyAttribute attributes) + - Added NanSetPrototypeTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) + - Added NanSetInstanceTemplate(v8::Local templ, const char *name, v8::Handle value) + - Added NanSetInstanceTemplate(v8::Local templ, v8::Handle name, v8::Handle value, v8::PropertyAttribute attributes) + +### 1.2.0 Jun 5 2014 + + - Add NanSetPrototypeTemplate + - Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class, + introduced _NanWeakCallbackDispatcher + - Removed -Wno-unused-local-typedefs from test builds + - Made test builds Windows compatible ('Sleep()') + +### 1.1.2 May 28 2014 + + - Release to fix more stuff-ups in 1.1.1 + +### 1.1.1 May 28 2014 + + - Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0 + +### 1.1.0 May 25 2014 + + - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead + - Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]), + (uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*, + v8::String::ExternalAsciiStringResource* + - Deprecate NanSymbol() + - Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker + +### 1.0.0 May 4 2014 + + - Heavy API changes for V8 3.25 / Node 0.11.13 + - Use cpplint.py + - Removed NanInitPersistent + - Removed NanPersistentToLocal + - Removed NanFromV8String + - Removed NanMakeWeak + - Removed NanNewLocal + - Removed NAN_WEAK_CALLBACK_OBJECT + - Removed NAN_WEAK_CALLBACK_DATA + - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions + - Introduce NanUndefined, NanNull, NanTrue and NanFalse + - Introduce NanEscapableScope and NanEscapeScope + - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node) + - Introduce NanMakeCallback for node::MakeCallback + - Introduce NanSetTemplate + - Introduce NanGetCurrentContext + - Introduce NanCompileScript and NanRunScript + - Introduce NanAdjustExternalMemory + - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback + - Introduce NanGetHeapStatistics + - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent() + +### 0.8.0 Jan 9 2014 + + - NanDispose -> NanDisposePersistent, deprecate NanDispose + - Extract _NAN_*_RETURN_TYPE, pull up NAN_*() + +### 0.7.1 Jan 9 2014 + + - Fixes to work against debug builds of Node + - Safer NanPersistentToLocal (avoid reinterpret_cast) + - Speed up common NanRawString case by only extracting flattened string when necessary + +### 0.7.0 Dec 17 2013 + + - New no-arg form of NanCallback() constructor. + - NanCallback#Call takes Handle rather than Local + - Removed deprecated NanCallback#Run method, use NanCallback#Call instead + - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS + - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call() + - Introduce NanRawString() for char* (or appropriate void*) from v8::String + (replacement for NanFromV8String) + - Introduce NanCString() for null-terminated char* from v8::String + +### 0.6.0 Nov 21 2013 + + - Introduce NanNewLocal(v8::Handle value) for use in place of + v8::Local::New(...) since v8 started requiring isolate in Node 0.11.9 + +### 0.5.2 Nov 16 2013 + + - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public + +### 0.5.1 Nov 12 2013 + + - Use node::MakeCallback() instead of direct v8::Function::Call() + +### 0.5.0 Nov 11 2013 + + - Added @TooTallNate as collaborator + - New, much simpler, "include_dirs" for binding.gyp + - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros + +### 0.4.4 Nov 2 2013 + + - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+ + +### 0.4.3 Nov 2 2013 + + - Include node_object_wrap.h, removed from node.h for Node 0.11.8. + +### 0.4.2 Nov 2 2013 + + - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for + Node 0.11.8 release. + +### 0.4.1 Sep 16 2013 + + - Added explicit `#include ` as it was removed from node.h for v0.11.8 + +### 0.4.0 Sep 2 2013 + + - Added NAN_INLINE and NAN_DEPRECATED and made use of them + - Added NanError, NanTypeError and NanRangeError + - Cleaned up code + +### 0.3.2 Aug 30 2013 + + - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent + in NanAsyncWorker + +### 0.3.1 Aug 20 2013 + + - fix "not all control paths return a value" compile warning on some platforms + +### 0.3.0 Aug 19 2013 + + - Made NAN work with NPM + - Lots of fixes to NanFromV8String, pulling in features from new Node core + - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API + - Added optional error number argument for NanThrowError() + - Added NanInitPersistent() + - Added NanReturnNull() and NanReturnEmptyString() + - Added NanLocker and NanUnlocker + - Added missing scopes + - Made sure to clear disposed Persistent handles + - Changed NanAsyncWorker to allocate error messages on the heap + - Changed NanThrowError(Local) to NanThrowError(Handle) + - Fixed leak in NanAsyncWorker when errmsg is used + +### 0.2.2 Aug 5 2013 + + - Fixed usage of undefined variable with node::BASE64 in NanFromV8String() + +### 0.2.1 Aug 5 2013 + + - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for + NanFromV8String() + +### 0.2.0 Aug 5 2013 + + - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR, + NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY + - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS, + _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS, + _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS, + _NAN_PROPERTY_QUERY_ARGS + - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer + - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT, + NAN_WEAK_CALLBACK_DATA, NanMakeWeak + - Renamed THROW_ERROR to _NAN_THROW_ERROR + - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*) + - Added NanBufferUse(char*, uint32_t) + - Added NanNewContextHandle(v8::ExtensionConfiguration*, + v8::Handle, v8::Handle) + - Fixed broken NanCallback#GetFunction() + - Added optional encoding and size arguments to NanFromV8String() + - Added NanGetPointerSafe() and NanSetPointerSafe() + - Added initial test suite (to be expanded) + - Allow NanUInt32OptionValue to convert any Number object + +### 0.1.0 Jul 21 2013 + + - Added `NAN_GETTER`, `NAN_SETTER` + - Added `NanThrowError` with single Local argument + - Added `NanNewBufferHandle` with single uint32_t argument + - Added `NanHasInstance(Persistent&, Handle)` + - Added `Local NanCallback#GetFunction()` + - Added `NanCallback#Call(int, Local[])` + - Deprecated `NanCallback#Run(int, Local[])` in favour of Call diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/LICENSE.md b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/LICENSE.md new file mode 100644 index 0000000..95c2eb5 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/LICENSE.md @@ -0,0 +1,13 @@ +The MIT License (MIT) +===================== + +Copyright (c) 2015 NAN contributors +----------------------------------- + +*NAN contributors listed at * + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/appveyor.yml b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/appveyor.yml new file mode 100644 index 0000000..1777107 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/appveyor.yml @@ -0,0 +1,37 @@ +# http://www.appveyor.com/docs/appveyor-yml + +# Test against these versions of Io.js and Node.js. +environment: + matrix: + # node.js + - nodejs_version: "0.8" + - nodejs_version: "0.10" + - nodejs_version: "0.11" + # io.js + - nodejs_version: "1" + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node 0.STABLE.latest + - ps: if($env:nodejs_version -eq "0.8") {Install-Product node $env:nodejs_version} + - ps: if($env:nodejs_version -ne "0.8") {Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)} + - IF NOT %nodejs_version% == 1 npm -g install npm + - IF NOT %nodejs_version% == 1 set PATH=%APPDATA%\npm;%PATH% + # Typical npm stuff. + - npm install + - IF %nodejs_version% == 0.8 node node_modules\node-gyp\bin\node-gyp.js rebuild --directory test + - IF NOT %nodejs_version% == 0.8 npm run rebuild-tests + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - node --version + - npm --version + # run tests + - npm test + +# Don't actually build. +build: off + +# Set build version format here instead of in the admin panel. +version: "{build}" diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/include_dirs.js b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/include_dirs.js new file mode 100644 index 0000000..4f1dfb4 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/include_dirs.js @@ -0,0 +1 @@ +console.log(require('path').relative('.', __dirname)); diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan.h new file mode 100644 index 0000000..e95a3b3 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan.h @@ -0,0 +1,2174 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors: + * - Rod Vagg + * - Benjamin Byholm + * - Trevor Norris + * - Nathan Rajlich + * - Brett Lawson + * - Ben Noordhuis + * - David Siegel + * + * MIT License + * + * Version 1.6.2: current Node unstable: 0.11.16, Node stable: 0.10.36, io.js: 1.1.0 + * + * See https://github.com/rvagg/nan for the latest update to this file + **********************************************************************************/ + +#ifndef NAN_H_ +#define NAN_H_ + +#include +#include +#include +#include +#include +#include +#include +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif + +#if defined(__GNUC__) && !(defined(DEBUG) && DEBUG) +# define NAN_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) && !(defined(DEBUG) && DEBUG) +# define NAN_INLINE __forceinline +#else +# define NAN_INLINE inline +#endif + +#if defined(__GNUC__) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) +# define NAN_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) +# define NAN_DEPRECATED __declspec(deprecated) +#else +# define NAN_DEPRECATED +#endif + +#if (NODE_MODULE_VERSION < 12) +typedef v8::InvocationCallback NanFunctionCallback; +typedef v8::Script NanUnboundScript; +typedef v8::Script NanBoundScript; +#else +typedef v8::FunctionCallback NanFunctionCallback; +typedef v8::UnboundScript NanUnboundScript; +typedef v8::Script NanBoundScript; +#endif + +#if (NODE_MODULE_VERSION < 42) +typedef v8::String::ExternalAsciiStringResource + NanExternalOneByteStringResource; +#else // io.js v1.0.0 +typedef v8::String::ExternalOneByteStringResource + NanExternalOneByteStringResource; +#endif + +#include "nan_new.h" // NOLINT(build/include) + +// uv helpers +#ifdef UV_VERSION_MAJOR +#ifndef UV_VERSION_PATCH +#define UV_VERSION_PATCH 0 +#endif +#define NAUV_UVVERSION ((UV_VERSION_MAJOR << 16) | \ + (UV_VERSION_MINOR << 8) | \ + (UV_VERSION_PATCH)) +#else +#define NAUV_UVVERSION 0x000b00 +#endif + + +#if NAUV_UVVERSION < 0x000b17 +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async, int) +#else +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async) +#endif + +// some generic helpers + +template NAN_INLINE bool NanSetPointerSafe( + T *var + , T val +) { + if (var) { + *var = val; + return true; + } else { + return false; + } +} + +template NAN_INLINE T NanGetPointerSafe( + T *var + , T fallback = reinterpret_cast(0) +) { + if (var) { + return *var; + } else { + return fallback; + } +} + +NAN_INLINE bool NanBooleanOptionValue( + v8::Local optionsObj + , v8::Handle opt, bool def +) { + if (def) { + return optionsObj.IsEmpty() + || !optionsObj->Has(opt) + || optionsObj->Get(opt)->BooleanValue(); + } else { + return !optionsObj.IsEmpty() + && optionsObj->Has(opt) + && optionsObj->Get(opt)->BooleanValue(); + } +} + +NAN_INLINE bool NanBooleanOptionValue( + v8::Local optionsObj + , v8::Handle opt +) { + return NanBooleanOptionValue(optionsObj, opt, false); +} + +NAN_INLINE uint32_t NanUInt32OptionValue( + v8::Local optionsObj + , v8::Handle opt + , uint32_t def +) { + return !optionsObj.IsEmpty() + && optionsObj->Has(opt) + && optionsObj->Get(opt)->IsNumber() + ? optionsObj->Get(opt)->Uint32Value() + : def; +} + +template +v8::Local NanNew(v8::Handle); + +template +NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) { + return NanNew(val); +} + +template +NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) { + return val; +} + +/* io.js 1.0 */ +#if NODE_MODULE_VERSION >= 42 || NODE_VERSION_AT_LEAST(0, 11, 15) + NAN_INLINE + void NanSetCounterFunction(v8::CounterLookupCallback cb) { + v8::Isolate::GetCurrent()->SetCounterFunction(cb); + } + + NAN_INLINE + void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::Isolate::GetCurrent()->SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb); + } + + NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) { + return v8::Isolate::GetCurrent()->IdleNotification(idle_time_in_ms); + } + + NAN_INLINE void NanLowMemoryNotification() { + v8::Isolate::GetCurrent()->LowMemoryNotification(); + } + + NAN_INLINE void NanContextDisposedNotification() { + v8::Isolate::GetCurrent()->ContextDisposedNotification(); + } +#else + NAN_INLINE + void NanSetCounterFunction(v8::CounterLookupCallback cb) { + v8::V8::SetCounterFunction(cb); + } + + NAN_INLINE + void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::V8::SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::V8::SetAddHistogramSampleFunction(cb); + } + + NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) { + return v8::V8::IdleNotification(idle_time_in_ms); + } + + NAN_INLINE void NanLowMemoryNotification() { + v8::V8::LowMemoryNotification(); + } + + NAN_INLINE void NanContextDisposedNotification() { + v8::V8::ContextDisposedNotification(); + } +#endif + +#if (NODE_MODULE_VERSION > 0x000B) +// Node 0.11+ (0.11.12 and below won't compile with these) + +# define _NAN_METHOD_ARGS_TYPE const v8::FunctionCallbackInfo& +# define _NAN_METHOD_ARGS _NAN_METHOD_ARGS_TYPE args +# define _NAN_METHOD_RETURN_TYPE void + +# define _NAN_GETTER_ARGS_TYPE const v8::PropertyCallbackInfo& +# define _NAN_GETTER_ARGS _NAN_GETTER_ARGS_TYPE args +# define _NAN_GETTER_RETURN_TYPE void + +# define _NAN_SETTER_ARGS_TYPE const v8::PropertyCallbackInfo& +# define _NAN_SETTER_ARGS _NAN_SETTER_ARGS_TYPE args +# define _NAN_SETTER_RETURN_TYPE void + +# define _NAN_PROPERTY_GETTER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_PROPERTY_GETTER_ARGS _NAN_PROPERTY_GETTER_ARGS_TYPE args +# define _NAN_PROPERTY_GETTER_RETURN_TYPE void + +# define _NAN_PROPERTY_SETTER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_PROPERTY_SETTER_ARGS _NAN_PROPERTY_SETTER_ARGS_TYPE args +# define _NAN_PROPERTY_SETTER_RETURN_TYPE void + +# define _NAN_PROPERTY_ENUMERATOR_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_PROPERTY_ENUMERATOR_ARGS _NAN_PROPERTY_ENUMERATOR_ARGS_TYPE args +# define _NAN_PROPERTY_ENUMERATOR_RETURN_TYPE void + +# define _NAN_PROPERTY_DELETER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_PROPERTY_DELETER_ARGS \ + _NAN_PROPERTY_DELETER_ARGS_TYPE args +# define _NAN_PROPERTY_DELETER_RETURN_TYPE void + +# define _NAN_PROPERTY_QUERY_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_PROPERTY_QUERY_ARGS _NAN_PROPERTY_QUERY_ARGS_TYPE args +# define _NAN_PROPERTY_QUERY_RETURN_TYPE void + +# define _NAN_INDEX_GETTER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_INDEX_GETTER_ARGS _NAN_INDEX_GETTER_ARGS_TYPE args +# define _NAN_INDEX_GETTER_RETURN_TYPE void + +# define _NAN_INDEX_SETTER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_INDEX_SETTER_ARGS _NAN_INDEX_SETTER_ARGS_TYPE args +# define _NAN_INDEX_SETTER_RETURN_TYPE void + +# define _NAN_INDEX_ENUMERATOR_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_INDEX_ENUMERATOR_ARGS _NAN_INDEX_ENUMERATOR_ARGS_TYPE args +# define _NAN_INDEX_ENUMERATOR_RETURN_TYPE void + +# define _NAN_INDEX_DELETER_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_INDEX_DELETER_ARGS _NAN_INDEX_DELETER_ARGS_TYPE args +# define _NAN_INDEX_DELETER_RETURN_TYPE void + +# define _NAN_INDEX_QUERY_ARGS_TYPE \ + const v8::PropertyCallbackInfo& +# define _NAN_INDEX_QUERY_ARGS _NAN_INDEX_QUERY_ARGS_TYPE args +# define _NAN_INDEX_QUERY_RETURN_TYPE void + +# define NanScope() v8::HandleScope scope(v8::Isolate::GetCurrent()) +# define NanEscapableScope() \ + v8::EscapableHandleScope scope(v8::Isolate::GetCurrent()) + +# define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val)) +# define NanLocker() v8::Locker locker(v8::Isolate::GetCurrent()) +# define NanUnlocker() v8::Unlocker unlocker(v8::Isolate::GetCurrent()) +# define NanReturnValue(value) return args.GetReturnValue().Set(value) +# define NanReturnUndefined() return +# define NanReturnHolder() NanReturnValue(args.Holder()) +# define NanReturnThis() NanReturnValue(args.This()) +# define NanReturnNull() return args.GetReturnValue().SetNull() +# define NanReturnEmptyString() return args.GetReturnValue().SetEmptyString() + +# define NanObjectWrapHandle(obj) obj->handle() + + NAN_INLINE v8::Local NanUndefined() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent()))); + } + + NAN_INLINE v8::Local NanNull() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent()))); + } + + NAN_INLINE v8::Local NanTrue() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent()))); + } + + NAN_INLINE v8::Local NanFalse() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent()))); + } + + NAN_INLINE int NanAdjustExternalMemory(int bc) { + return static_cast( + v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(bc)); + } + + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , const char *name + , v8::Handle value) { + templ->Set(v8::Isolate::GetCurrent(), name, value); + } + + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); + } + + NAN_INLINE v8::Local NanGetCurrentContext() { + return v8::Isolate::GetCurrent()->GetCurrentContext(); + } + + NAN_INLINE void* NanGetInternalFieldPointer( + v8::Handle object + , int index) { + return object->GetAlignedPointerFromInternalField(index); + } + + NAN_INLINE void NanSetInternalFieldPointer( + v8::Handle object + , int index + , void* value) { + object->SetAlignedPointerInInternalField(index, value); + } + +# define NAN_GC_CALLBACK(name) \ + void name(v8::Isolate *isolate, v8::GCType type, v8::GCCallbackFlags flags) + + NAN_INLINE void NanAddGCEpilogueCallback( + v8::Isolate::GCEpilogueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::Isolate::GetCurrent()->AddGCEpilogueCallback(callback, gc_type_filter); + } + + NAN_INLINE void NanRemoveGCEpilogueCallback( + v8::Isolate::GCEpilogueCallback callback) { + v8::Isolate::GetCurrent()->RemoveGCEpilogueCallback(callback); + } + + NAN_INLINE void NanAddGCPrologueCallback( + v8::Isolate::GCPrologueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::Isolate::GetCurrent()->AddGCPrologueCallback(callback, gc_type_filter); + } + + NAN_INLINE void NanRemoveGCPrologueCallback( + v8::Isolate::GCPrologueCallback callback) { + v8::Isolate::GetCurrent()->RemoveGCPrologueCallback(callback); + } + + NAN_INLINE void NanGetHeapStatistics( + v8::HeapStatistics *heap_statistics) { + v8::Isolate::GetCurrent()->GetHeapStatistics(heap_statistics); + } + + NAN_DEPRECATED NAN_INLINE v8::Local NanSymbol( + const char* data, int length = -1) { + return NanNew(data, length); + } + + template + NAN_INLINE void NanAssignPersistent( + v8::Persistent& handle + , v8::Handle obj) { + handle.Reset(v8::Isolate::GetCurrent(), obj); + } + + template + NAN_INLINE void NanAssignPersistent( + v8::Persistent& handle + , const v8::Persistent& obj) { + handle.Reset(v8::Isolate::GetCurrent(), obj); + } + + template + class _NanWeakCallbackData; + + template + struct _NanWeakCallbackInfo { + typedef void (*Callback)(const _NanWeakCallbackData& data); + NAN_INLINE _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) + : parameter(param), callback(cb) { + NanAssignPersistent(persistent, handle); + } + + NAN_INLINE ~_NanWeakCallbackInfo() { + persistent.Reset(); + } + + P* const parameter; + Callback const callback; + v8::Persistent persistent; + }; + + template + class _NanWeakCallbackData { + public: + NAN_INLINE _NanWeakCallbackData(_NanWeakCallbackInfo *info) + : info_(info) { } + + NAN_INLINE v8::Local GetValue() const { + return NanNew(info_->persistent); + } + + NAN_INLINE P* GetParameter() const { return info_->parameter; } + + NAN_INLINE bool IsNearDeath() const { + return info_->persistent.IsNearDeath(); + } + + NAN_INLINE void Revive() const; + + NAN_INLINE _NanWeakCallbackInfo* GetCallbackInfo() const { + return info_; + } + + NAN_DEPRECATED NAN_INLINE void Dispose() const { + } + + private: + _NanWeakCallbackInfo* info_; + }; + + template + static void _NanWeakCallbackDispatcher( + const v8::WeakCallbackData > &data) { + _NanWeakCallbackInfo *info = data.GetParameter(); + _NanWeakCallbackData wcbd(info); + info->callback(wcbd); + if (wcbd.IsNearDeath()) { + delete wcbd.GetCallbackInfo(); + } + } + + template + NAN_INLINE void _NanWeakCallbackData::Revive() const { + info_->persistent.SetWeak(info_, &_NanWeakCallbackDispatcher); + } + +template +NAN_INLINE _NanWeakCallbackInfo* NanMakeWeakPersistent( + v8::Handle handle + , P* parameter + , typename _NanWeakCallbackInfo::Callback callback) { + _NanWeakCallbackInfo *cbinfo = + new _NanWeakCallbackInfo(handle, parameter, callback); + cbinfo->persistent.SetWeak(cbinfo, &_NanWeakCallbackDispatcher); + return cbinfo; +} + +# define NAN_WEAK_CALLBACK(name) \ + template \ + static void name(const _NanWeakCallbackData &data) + +# define _NAN_ERROR(fun, errmsg) fun(NanNew(errmsg)) + +# define _NAN_THROW_ERROR(fun, errmsg) \ + do { \ + NanScope(); \ + v8::Isolate::GetCurrent()->ThrowException(_NAN_ERROR(fun, errmsg)); \ + } while (0); + + NAN_INLINE v8::Local NanError(const char* errmsg) { + return _NAN_ERROR(v8::Exception::Error, errmsg); + } + + NAN_INLINE void NanThrowError(const char* errmsg) { + _NAN_THROW_ERROR(v8::Exception::Error, errmsg); + } + + NAN_INLINE void NanThrowError(v8::Handle error) { + NanScope(); + v8::Isolate::GetCurrent()->ThrowException(error); + } + + NAN_INLINE v8::Local NanError( + const char *msg + , const int errorNumber + ) { + v8::Local err = v8::Exception::Error(NanNew(msg)); + v8::Local obj = err.As(); + obj->Set(NanNew("code"), NanNew(errorNumber)); + return err; + } + + NAN_INLINE void NanThrowError( + const char *msg + , const int errorNumber + ) { + NanThrowError(NanError(msg, errorNumber)); + } + + NAN_INLINE v8::Local NanTypeError(const char* errmsg) { + return _NAN_ERROR(v8::Exception::TypeError, errmsg); + } + + NAN_INLINE void NanThrowTypeError(const char* errmsg) { + _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg); + } + + NAN_INLINE v8::Local NanRangeError(const char* errmsg) { + return _NAN_ERROR(v8::Exception::RangeError, errmsg); + } + + NAN_INLINE void NanThrowRangeError(const char* errmsg) { + _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg); + } + + template NAN_INLINE void NanDisposePersistent( + v8::Persistent &handle + ) { + handle.Reset(); + } + + NAN_INLINE v8::Local NanNewBufferHandle ( + char *data + , size_t length + , node::smalloc::FreeCallback callback + , void *hint + ) { + return node::Buffer::New( + v8::Isolate::GetCurrent(), data, length, callback, hint); + } + + NAN_INLINE v8::Local NanNewBufferHandle ( + const char *data + , uint32_t size + ) { + return node::Buffer::New(v8::Isolate::GetCurrent(), data, size); + } + + NAN_INLINE v8::Local NanNewBufferHandle (uint32_t size) { + return node::Buffer::New(v8::Isolate::GetCurrent(), size); + } + + NAN_INLINE v8::Local NanBufferUse( + char* data + , uint32_t size + ) { + return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size); + } + + NAN_INLINE bool NanHasInstance( + const v8::Persistent& function_template + , v8::Handle value + ) { + return NanNew(function_template)->HasInstance(value); + } + + NAN_DEPRECATED NAN_INLINE v8::Local NanNewContextHandle( + v8::ExtensionConfiguration* extensions = NULL + , v8::Handle tmpl = v8::Handle() + , v8::Handle obj = v8::Handle() + ) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + return v8::Local::New( + isolate + , v8::Context::New(isolate, extensions, tmpl, obj) + ); + } + + NAN_INLINE v8::Local NanCompileScript( + v8::Local s + , const v8::ScriptOrigin& origin + ) { + v8::ScriptCompiler::Source source(s, origin); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); + } + + NAN_INLINE v8::Local NanCompileScript( + v8::Local s + ) { + v8::ScriptCompiler::Source source(s); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); + } + + NAN_INLINE v8::Local NanRunScript( + v8::Handle script + ) { + return script->BindToCurrentContext()->Run(); + } + + NAN_INLINE v8::Local NanRunScript( + v8::Handle script + ) { + return script->Run(); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle func + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, func, argc, argv)); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle symbol + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, symbol, argc, argv)); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , const char* method + , int argc + , v8::Handle* argv) { + return NanNew(node::MakeCallback( + v8::Isolate::GetCurrent(), target, method, argc, argv)); + } + + template + NAN_INLINE void NanSetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(0, data); + } + + template + NAN_INLINE T *NanGetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData(0)); + } + + class NanAsciiString { + public: + NAN_INLINE explicit NanAsciiString(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new char[size + 1]; + size = toStr->WriteOneByte(reinterpret_cast(buf)); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanAsciiString() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanAsciiString(const NanAsciiString&); + void operator=(const NanAsciiString&); + + char *buf; + int size; + }; + + class NanUtf8String { + public: + NAN_INLINE explicit NanUtf8String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Utf8Length(); + buf = new char[size + 1]; + toStr->WriteUtf8(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanUtf8String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUtf8String(const NanUtf8String&); + void operator=(const NanUtf8String&); + + char *buf; + int size; + }; + + class NanUcs2String { + public: + NAN_INLINE explicit NanUcs2String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new uint16_t[size + 1]; + toStr->Write(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE uint16_t* operator*() { return buf; } + NAN_INLINE const uint16_t* operator*() const { return buf; } + + NAN_INLINE ~NanUcs2String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUcs2String(const NanUcs2String&); + void operator=(const NanUcs2String&); + + uint16_t *buf; + int size; + }; + +#else +// Node 0.8 and 0.10 + +# define _NAN_METHOD_ARGS_TYPE const v8::Arguments& +# define _NAN_METHOD_ARGS _NAN_METHOD_ARGS_TYPE args +# define _NAN_METHOD_RETURN_TYPE v8::Handle + +# define _NAN_GETTER_ARGS_TYPE const v8::AccessorInfo & +# define _NAN_GETTER_ARGS _NAN_GETTER_ARGS_TYPE args +# define _NAN_GETTER_RETURN_TYPE v8::Handle + +# define _NAN_SETTER_ARGS_TYPE const v8::AccessorInfo & +# define _NAN_SETTER_ARGS _NAN_SETTER_ARGS_TYPE args +# define _NAN_SETTER_RETURN_TYPE void + +# define _NAN_PROPERTY_GETTER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_PROPERTY_GETTER_ARGS _NAN_PROPERTY_GETTER_ARGS_TYPE args +# define _NAN_PROPERTY_GETTER_RETURN_TYPE v8::Handle + +# define _NAN_PROPERTY_SETTER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_PROPERTY_SETTER_ARGS _NAN_PROPERTY_SETTER_ARGS_TYPE args +# define _NAN_PROPERTY_SETTER_RETURN_TYPE v8::Handle + +# define _NAN_PROPERTY_ENUMERATOR_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_PROPERTY_ENUMERATOR_ARGS _NAN_PROPERTY_ENUMERATOR_ARGS_TYPE args +# define _NAN_PROPERTY_ENUMERATOR_RETURN_TYPE v8::Handle + +# define _NAN_PROPERTY_DELETER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_PROPERTY_DELETER_ARGS _NAN_PROPERTY_DELETER_ARGS_TYPE args +# define _NAN_PROPERTY_DELETER_RETURN_TYPE v8::Handle + +# define _NAN_PROPERTY_QUERY_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_PROPERTY_QUERY_ARGS _NAN_PROPERTY_QUERY_ARGS_TYPE args +# define _NAN_PROPERTY_QUERY_RETURN_TYPE v8::Handle + +# define _NAN_INDEX_GETTER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_GETTER_ARGS _NAN_INDEX_GETTER_ARGS_TYPE args +# define _NAN_INDEX_GETTER_RETURN_TYPE v8::Handle + +# define _NAN_INDEX_SETTER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_SETTER_ARGS _NAN_INDEX_SETTER_ARGS_TYPE args +# define _NAN_INDEX_SETTER_RETURN_TYPE v8::Handle + +# define _NAN_INDEX_ENUMERATOR_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_ENUMERATOR_ARGS _NAN_INDEX_ENUMERATOR_ARGS_TYPE args +# define _NAN_INDEX_ENUMERATOR_RETURN_TYPE v8::Handle + +# define _NAN_INDEX_DELETER_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_DELETER_ARGS _NAN_INDEX_DELETER_ARGS_TYPE args +# define _NAN_INDEX_DELETER_RETURN_TYPE v8::Handle + +# define _NAN_INDEX_QUERY_ARGS_TYPE const v8::AccessorInfo& +# define _NAN_INDEX_QUERY_ARGS _NAN_INDEX_QUERY_ARGS_TYPE args +# define _NAN_INDEX_QUERY_RETURN_TYPE v8::Handle + + NAN_DEPRECATED NAN_INLINE v8::Local NanSymbol( + const char* data, int length = -1) { + return v8::String::NewSymbol(data, length); + } + +# define NanScope() v8::HandleScope scope +# define NanEscapableScope() v8::HandleScope scope +# define NanEscapeScope(val) scope.Close(val) +# define NanLocker() v8::Locker locker +# define NanUnlocker() v8::Unlocker unlocker +# define NanReturnValue(value) return scope.Close(value) +# define NanReturnHolder() NanReturnValue(args.Holder()) +# define NanReturnThis() NanReturnValue(args.This()) +# define NanReturnUndefined() return v8::Undefined() +# define NanReturnNull() return v8::Null() +# define NanReturnEmptyString() return v8::String::Empty() +# define NanObjectWrapHandle(obj) v8::Local::New(obj->handle_) + + NAN_INLINE v8::Local NanUndefined() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Undefined())); + } + + NAN_INLINE v8::Local NanNull() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::Null())); + } + + NAN_INLINE v8::Local NanTrue() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::True())); + } + + NAN_INLINE v8::Local NanFalse() { + NanEscapableScope(); + return NanEscapeScope(NanNew(v8::False())); + } + + NAN_INLINE int NanAdjustExternalMemory(int bc) { + return static_cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(bc)); + } + + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , const char *name + , v8::Handle value) { + templ->Set(name, value); + } + + NAN_INLINE void NanSetTemplate( + v8::Handle templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); + } + + NAN_INLINE v8::Local NanGetCurrentContext() { + return v8::Context::GetCurrent(); + } + + NAN_INLINE void* NanGetInternalFieldPointer( + v8::Handle object + , int index) { + return object->GetPointerFromInternalField(index); + } + + NAN_INLINE void NanSetInternalFieldPointer( + v8::Handle object + , int index + , void* value) { + object->SetPointerInInternalField(index, value); + } + +# define NAN_GC_CALLBACK(name) \ + void name(v8::GCType type, v8::GCCallbackFlags flags) + + NAN_INLINE void NanAddGCEpilogueCallback( + v8::GCEpilogueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::V8::AddGCEpilogueCallback(callback, gc_type_filter); + } + NAN_INLINE void NanRemoveGCEpilogueCallback( + v8::GCEpilogueCallback callback) { + v8::V8::RemoveGCEpilogueCallback(callback); + } + NAN_INLINE void NanAddGCPrologueCallback( + v8::GCPrologueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::V8::AddGCPrologueCallback(callback, gc_type_filter); + } + NAN_INLINE void NanRemoveGCPrologueCallback( + v8::GCPrologueCallback callback) { + v8::V8::RemoveGCPrologueCallback(callback); + } + NAN_INLINE void NanGetHeapStatistics( + v8::HeapStatistics *heap_statistics) { + v8::V8::GetHeapStatistics(heap_statistics); + } + + template + NAN_INLINE void NanAssignPersistent( + v8::Persistent& handle + , v8::Handle obj) { + handle.Dispose(); + handle = v8::Persistent::New(obj); + } + + template + class _NanWeakCallbackData; + + template + struct _NanWeakCallbackInfo { + typedef void (*Callback)(const _NanWeakCallbackData &data); + NAN_INLINE _NanWeakCallbackInfo(v8::Handle handle, P* param, Callback cb) + : parameter(param) + , callback(cb) + , persistent(v8::Persistent::New(handle)) { } + + NAN_INLINE ~_NanWeakCallbackInfo() { + persistent.Dispose(); + persistent.Clear(); + } + + P* const parameter; + Callback const callback; + v8::Persistent persistent; + }; + + template + class _NanWeakCallbackData { + public: + NAN_INLINE _NanWeakCallbackData(_NanWeakCallbackInfo *info) + : info_(info) { } + + NAN_INLINE v8::Local GetValue() const { + return NanNew(info_->persistent); + } + + NAN_INLINE P* GetParameter() const { return info_->parameter; } + + NAN_INLINE bool IsNearDeath() const { + return info_->persistent.IsNearDeath(); + } + + NAN_INLINE void Revive() const; + + NAN_INLINE _NanWeakCallbackInfo* GetCallbackInfo() const { + return info_; + } + + NAN_DEPRECATED NAN_INLINE void Dispose() const { + } + + private: + _NanWeakCallbackInfo* info_; + }; + + template + static void _NanWeakPersistentDispatcher( + v8::Persistent object, void *data) { + _NanWeakCallbackInfo* info = + static_cast<_NanWeakCallbackInfo*>(data); + _NanWeakCallbackData wcbd(info); + info->callback(wcbd); + if (wcbd.IsNearDeath()) { + delete wcbd.GetCallbackInfo(); + } + } + + template + NAN_INLINE void _NanWeakCallbackData::Revive() const { + info_->persistent.MakeWeak( + info_ + , &_NanWeakPersistentDispatcher); + } + + template + NAN_INLINE _NanWeakCallbackInfo* NanMakeWeakPersistent( + v8::Handle handle + , P* parameter + , typename _NanWeakCallbackInfo::Callback callback) { + _NanWeakCallbackInfo *cbinfo = + new _NanWeakCallbackInfo(handle, parameter, callback); + cbinfo->persistent.MakeWeak( + cbinfo + , &_NanWeakPersistentDispatcher); + return cbinfo; + } + +# define NAN_WEAK_CALLBACK(name) \ + template \ + static void name(const _NanWeakCallbackData &data) + +# define _NAN_ERROR(fun, errmsg) \ + fun(v8::String::New(errmsg)) + +# define _NAN_THROW_ERROR(fun, errmsg) \ + do { \ + NanScope(); \ + return v8::Local::New( \ + v8::ThrowException(_NAN_ERROR(fun, errmsg))); \ + } while (0); + + NAN_INLINE v8::Local NanError(const char* errmsg) { + return _NAN_ERROR(v8::Exception::Error, errmsg); + } + + NAN_INLINE v8::Local NanThrowError(const char* errmsg) { + _NAN_THROW_ERROR(v8::Exception::Error, errmsg); + } + + NAN_INLINE v8::Local NanThrowError( + v8::Handle error + ) { + NanScope(); + return v8::Local::New(v8::ThrowException(error)); + } + + NAN_INLINE v8::Local NanError( + const char *msg + , const int errorNumber + ) { + v8::Local err = v8::Exception::Error(v8::String::New(msg)); + v8::Local obj = err.As(); + obj->Set(v8::String::New("code"), v8::Int32::New(errorNumber)); + return err; + } + + NAN_INLINE v8::Local NanThrowError( + const char *msg + , const int errorNumber + ) { + return NanThrowError(NanError(msg, errorNumber)); + } + + NAN_INLINE v8::Local NanTypeError(const char* errmsg) { + return _NAN_ERROR(v8::Exception::TypeError, errmsg); + } + + NAN_INLINE v8::Local NanThrowTypeError( + const char* errmsg + ) { + _NAN_THROW_ERROR(v8::Exception::TypeError, errmsg); + } + + NAN_INLINE v8::Local NanRangeError( + const char* errmsg + ) { + return _NAN_ERROR(v8::Exception::RangeError, errmsg); + } + + NAN_INLINE v8::Local NanThrowRangeError( + const char* errmsg + ) { + _NAN_THROW_ERROR(v8::Exception::RangeError, errmsg); + } + + template + NAN_INLINE void NanDisposePersistent( + v8::Persistent &handle) { // NOLINT(runtime/references) + handle.Dispose(); + handle.Clear(); + } + + NAN_INLINE v8::Local NanNewBufferHandle ( + char *data + , size_t length + , node::Buffer::free_callback callback + , void *hint + ) { + return NanNew( + node::Buffer::New(data, length, callback, hint)->handle_); + } + + NAN_INLINE v8::Local NanNewBufferHandle ( + const char *data + , uint32_t size + ) { +#if NODE_MODULE_VERSION >= 0x000B + return NanNew(node::Buffer::New(data, size)->handle_); +#else + return NanNew( + node::Buffer::New(const_cast(data), size)->handle_); +#endif + } + + NAN_INLINE v8::Local NanNewBufferHandle (uint32_t size) { + return NanNew(node::Buffer::New(size)->handle_); + } + + NAN_INLINE void FreeData(char *data, void *hint) { + delete[] data; + } + + NAN_INLINE v8::Local NanBufferUse( + char* data + , uint32_t size + ) { + return NanNew( + node::Buffer::New(data, size, FreeData, NULL)->handle_); + } + + NAN_INLINE bool NanHasInstance( + const v8::Persistent& function_template + , v8::Handle value + ) { + return function_template->HasInstance(value); + } + + NAN_DEPRECATED NAN_INLINE v8::Local NanNewContextHandle( + v8::ExtensionConfiguration* extensions = NULL + , v8::Handle tmpl = v8::Handle() + , v8::Handle obj = v8::Handle() + ) { + v8::Persistent ctx = v8::Context::New(extensions, tmpl, obj); + v8::Local lctx = NanNew(ctx); + ctx.Dispose(); + return lctx; + } + + NAN_INLINE v8::Local NanCompileScript( + v8::Local s + , const v8::ScriptOrigin& origin + ) { + return v8::Script::Compile(s, const_cast(&origin)); + } + + NAN_INLINE v8::Local NanCompileScript( + v8::Local s + ) { + return v8::Script::Compile(s); + } + + NAN_INLINE v8::Local NanRunScript(v8::Handle script) { + return script->Run(); + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle func + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, func, argc, argv)); +# else + v8::TryCatch try_catch; + v8::Local result = func->Call(target, argc, argv); + if (try_catch.HasCaught()) { + node::FatalException(try_catch); + } + return result; +# endif + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , v8::Handle symbol + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, symbol, argc, argv)); +# else + v8::Local callback = target->Get(symbol).As(); + return NanMakeCallback(target, callback, argc, argv); +# endif + } + + NAN_INLINE v8::Local NanMakeCallback( + v8::Handle target + , const char* method + , int argc + , v8::Handle* argv) { +# if NODE_VERSION_AT_LEAST(0, 8, 0) + return NanNew(node::MakeCallback(target, method, argc, argv)); +# else + return NanMakeCallback(target, NanNew(method), argc, argv); +# endif + } + + template + NAN_INLINE void NanSetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(data); + } + + template + NAN_INLINE T *NanGetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData()); + } + + class NanAsciiString { + public: + NAN_INLINE explicit NanAsciiString(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new char[size + 1]; + size = toStr->WriteAscii(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanAsciiString() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanAsciiString(const NanAsciiString&); + void operator=(const NanAsciiString&); + + char *buf; + int size; + }; + + class NanUtf8String { + public: + NAN_INLINE explicit NanUtf8String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Utf8Length(); + buf = new char[size + 1]; + toStr->WriteUtf8(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE char* operator*() { return buf; } + NAN_INLINE const char* operator*() const { return buf; } + + NAN_INLINE ~NanUtf8String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUtf8String(const NanUtf8String&); + void operator=(const NanUtf8String&); + + char *buf; + int size; + }; + + class NanUcs2String { + public: + NAN_INLINE explicit NanUcs2String(v8::Handle from) { + v8::Local toStr = from->ToString(); + size = toStr->Length(); + buf = new uint16_t[size + 1]; + toStr->Write(buf); + } + + NAN_DEPRECATED NAN_INLINE int Size() const { + return size; + } + + NAN_INLINE int length() const { + return size; + } + + NAN_INLINE uint16_t* operator*() { return buf; } + NAN_INLINE const uint16_t* operator*() const { return buf; } + + NAN_INLINE ~NanUcs2String() { + delete[] buf; + } + + private: + // disallow copying and assigning + NanUcs2String(const NanUcs2String&); + void operator=(const NanUcs2String&); + + uint16_t *buf; + int size; + }; + +#endif // NODE_MODULE_VERSION + +typedef void (*NanFreeCallback)(char *data, void *hint); + +#define NAN_METHOD(name) _NAN_METHOD_RETURN_TYPE name(_NAN_METHOD_ARGS) +#define NAN_GETTER(name) \ + _NAN_GETTER_RETURN_TYPE name( \ + v8::Local property \ + , _NAN_GETTER_ARGS) +#define NAN_SETTER(name) \ + _NAN_SETTER_RETURN_TYPE name( \ + v8::Local property \ + , v8::Local value \ + , _NAN_SETTER_ARGS) +#define NAN_PROPERTY_GETTER(name) \ + _NAN_PROPERTY_GETTER_RETURN_TYPE name( \ + v8::Local property \ + , _NAN_PROPERTY_GETTER_ARGS) +#define NAN_PROPERTY_SETTER(name) \ + _NAN_PROPERTY_SETTER_RETURN_TYPE name( \ + v8::Local property \ + , v8::Local value \ + , _NAN_PROPERTY_SETTER_ARGS) +#define NAN_PROPERTY_ENUMERATOR(name) \ + _NAN_PROPERTY_ENUMERATOR_RETURN_TYPE name(_NAN_PROPERTY_ENUMERATOR_ARGS) +#define NAN_PROPERTY_DELETER(name) \ + _NAN_PROPERTY_DELETER_RETURN_TYPE name( \ + v8::Local property \ + , _NAN_PROPERTY_DELETER_ARGS) +#define NAN_PROPERTY_QUERY(name) \ + _NAN_PROPERTY_QUERY_RETURN_TYPE name( \ + v8::Local property \ + , _NAN_PROPERTY_QUERY_ARGS) +# define NAN_INDEX_GETTER(name) \ + _NAN_INDEX_GETTER_RETURN_TYPE name(uint32_t index, _NAN_INDEX_GETTER_ARGS) +#define NAN_INDEX_SETTER(name) \ + _NAN_INDEX_SETTER_RETURN_TYPE name( \ + uint32_t index \ + , v8::Local value \ + , _NAN_INDEX_SETTER_ARGS) +#define NAN_INDEX_ENUMERATOR(name) \ + _NAN_INDEX_ENUMERATOR_RETURN_TYPE name(_NAN_INDEX_ENUMERATOR_ARGS) +#define NAN_INDEX_DELETER(name) \ + _NAN_INDEX_DELETER_RETURN_TYPE name( \ + uint32_t index \ + , _NAN_INDEX_DELETER_ARGS) +#define NAN_INDEX_QUERY(name) \ + _NAN_INDEX_QUERY_RETURN_TYPE name(uint32_t index, _NAN_INDEX_QUERY_ARGS) + +class NanCallback { + public: + NanCallback() { + NanScope(); + v8::Local obj = NanNew(); + NanAssignPersistent(handle, obj); + } + + explicit NanCallback(const v8::Handle &fn) { + NanScope(); + v8::Local obj = NanNew(); + NanAssignPersistent(handle, obj); + SetFunction(fn); + } + + ~NanCallback() { + if (handle.IsEmpty()) return; + NanDisposePersistent(handle); + } + + NAN_INLINE void SetFunction(const v8::Handle &fn) { + NanScope(); + NanNew(handle)->Set(kCallbackIndex, fn); + } + + NAN_INLINE v8::Local GetFunction() const { + NanEscapableScope(); + return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex) + .As()); + } + + NAN_INLINE bool IsEmpty() const { + NanScope(); + return NanNew(handle)->Get(kCallbackIndex)->IsUndefined(); + } + + v8::Handle Call(int argc, v8::Handle argv[]) const { + NanEscapableScope(); +#if (NODE_MODULE_VERSION > 0x000B) // 0.11.12+ + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Local callback = NanNew(handle)-> + Get(kCallbackIndex).As(); + return NanEscapeScope(node::MakeCallback( + isolate + , isolate->GetCurrentContext()->Global() + , callback + , argc + , argv + )); +#else +#if NODE_VERSION_AT_LEAST(0, 8, 0) + v8::Local callback = handle-> + Get(kCallbackIndex).As(); + return NanEscapeScope(node::MakeCallback( + v8::Context::GetCurrent()->Global() + , callback + , argc + , argv + )); +#else + v8::Local callback = handle-> + Get(kCallbackIndex).As(); + return NanEscapeScope(NanMakeCallback( + v8::Context::GetCurrent()->Global(), callback, argc, argv)); +#endif +#endif + } + + private: + v8::Persistent handle; + static const uint32_t kCallbackIndex = 0; +}; + +/* abstract */ class NanAsyncWorker { + public: + explicit NanAsyncWorker(NanCallback *callback_) + : callback(callback_), errmsg_(NULL) { + request.data = this; + + NanScope(); + v8::Local obj = NanNew(); + NanAssignPersistent(persistentHandle, obj); + } + + virtual ~NanAsyncWorker() { + NanScope(); + + if (!persistentHandle.IsEmpty()) + NanDisposePersistent(persistentHandle); + if (callback) + delete callback; + if (errmsg_) + delete[] errmsg_; + } + + virtual void WorkComplete() { + NanScope(); + + if (errmsg_ == NULL) + HandleOKCallback(); + else + HandleErrorCallback(); + delete callback; + callback = NULL; + } + + NAN_INLINE void SaveToPersistent( + const char *key, const v8::Local &obj) { + v8::Local handle = NanNew(persistentHandle); + handle->Set(NanNew(key), obj); + } + + v8::Local GetFromPersistent(const char *key) const { + NanEscapableScope(); + v8::Local handle = NanNew(persistentHandle); + return NanEscapeScope(handle->Get(NanNew(key)).As()); + } + + virtual void Execute() = 0; + + uv_work_t request; + + virtual void Destroy() { + delete this; + } + + protected: + v8::Persistent persistentHandle; + NanCallback *callback; + + virtual void HandleOKCallback() { + callback->Call(0, NULL); + } + + virtual void HandleErrorCallback() { + NanScope(); + + v8::Local argv[] = { + v8::Exception::Error(NanNew(ErrorMessage())) + }; + callback->Call(1, argv); + } + + void SetErrorMessage(const char *msg) { + if (errmsg_) { + delete[] errmsg_; + } + + size_t size = strlen(msg) + 1; + errmsg_ = new char[size]; + memcpy(errmsg_, msg, size); + } + + const char* ErrorMessage() const { + return errmsg_; + } + + private: + char *errmsg_; +}; + +/* abstract */ class NanAsyncProgressWorker : public NanAsyncWorker { + public: + explicit NanAsyncProgressWorker(NanCallback *callback_) + : NanAsyncWorker(callback_), asyncdata_(NULL), asyncsize_(0) { + async = new uv_async_t; + uv_async_init( + uv_default_loop() + , async + , AsyncProgress_ + ); + async->data = this; + + uv_mutex_init(&async_lock); + } + + virtual ~NanAsyncProgressWorker() { + uv_mutex_destroy(&async_lock); + + if (asyncdata_) { + delete[] asyncdata_; + } + } + + void WorkProgress() { + uv_mutex_lock(&async_lock); + char *data = asyncdata_; + size_t size = asyncsize_; + asyncdata_ = NULL; + uv_mutex_unlock(&async_lock); + + // Dont send progress events after we've already completed. + if (callback) { + HandleProgressCallback(data, size); + } + delete[] data; + } + + class ExecutionProgress { + friend class NanAsyncProgressWorker; + public: + // You could do fancy generics with templates here. + void Send(const char* data, size_t size) const { + that_->SendProgress_(data, size); + } + + private: + explicit ExecutionProgress(NanAsyncProgressWorker* that) : that_(that) {} + // Prohibit copying and assignment. + ExecutionProgress(const ExecutionProgress&); + void operator=(const ExecutionProgress&); + #if __cplusplus >= 201103L + // Prohibit C++11 move semantics. + ExecutionProgress(ExecutionProgress&&) = delete; + void operator=(ExecutionProgress&&) = delete; + #endif + NanAsyncProgressWorker* const that_; + }; + + virtual void Execute(const ExecutionProgress& progress) = 0; + virtual void HandleProgressCallback(const char *data, size_t size) = 0; + + virtual void Destroy() { + uv_close(reinterpret_cast(async), AsyncClose_); + } + + private: + void Execute() /*final override*/ { + ExecutionProgress progress(this); + Execute(progress); + } + + void SendProgress_(const char *data, size_t size) { + char *new_data = new char[size]; + memcpy(new_data, data, size); + + uv_mutex_lock(&async_lock); + char *old_data = asyncdata_; + asyncdata_ = new_data; + asyncsize_ = size; + uv_mutex_unlock(&async_lock); + + if (old_data) { + delete[] old_data; + } + uv_async_send(async); + } + + NAN_INLINE static NAUV_WORK_CB(AsyncProgress_) { + NanAsyncProgressWorker *worker = + static_cast(async->data); + worker->WorkProgress(); + } + + NAN_INLINE static void AsyncClose_(uv_handle_t* handle) { + NanAsyncProgressWorker *worker = + static_cast(handle->data); + delete reinterpret_cast(handle); + delete worker; + } + + uv_async_t *async; + uv_mutex_t async_lock; + char *asyncdata_; + size_t asyncsize_; +}; + +NAN_INLINE void NanAsyncExecute (uv_work_t* req) { + NanAsyncWorker *worker = static_cast(req->data); + worker->Execute(); +} + +NAN_INLINE void NanAsyncExecuteComplete (uv_work_t* req) { + NanAsyncWorker* worker = static_cast(req->data); + worker->WorkComplete(); + worker->Destroy(); +} + +NAN_INLINE void NanAsyncQueueWorker (NanAsyncWorker* worker) { + uv_queue_work( + uv_default_loop() + , &worker->request + , NanAsyncExecute + , (uv_after_work_cb)NanAsyncExecuteComplete + ); +} + +//// Base 64 //// + +#define _nan_base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) + +// Doesn't check for padding at the end. Can be 1-2 bytes over. +NAN_INLINE size_t _nan_base64_decoded_size_fast(size_t size) { + size_t remainder = size % 4; + + size = (size / 4) * 3; + if (remainder) { + if (size == 0 && remainder == 1) { + // special case: 1-byte input cannot be decoded + size = 0; + } else { + // non-padded input, add 1 or 2 extra bytes + size += 1 + (remainder == 3); + } + } + + return size; +} + +template +NAN_INLINE size_t _nan_base64_decoded_size( + const T* src + , size_t size +) { + if (size == 0) + return 0; + + if (src[size - 1] == '=') + size--; + if (size > 0 && src[size - 1] == '=') + size--; + + return _nan_base64_decoded_size_fast(size); +} + +// supports regular and URL-safe base64 +static const int _nan_unbase64_table[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -2, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63 + , 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1 + , -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 + , 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63 + , -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 + , 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; + +#define _nan_unbase64(x) _nan_unbase64_table[(uint8_t)(x)] + +template static size_t _nan_base64_decode( + char* buf + , size_t len + , const T* src + , const size_t srcLen +) { + char* dst = buf; + char* dstEnd = buf + len; + const T* srcEnd = src + srcLen; + + while (src < srcEnd && dst < dstEnd) { + ptrdiff_t remaining = srcEnd - src; + char a, b, c, d; + + while (_nan_unbase64(*src) < 0 && src < srcEnd) src++, remaining--; + if (remaining == 0 || *src == '=') break; + a = _nan_unbase64(*src++); + + while (_nan_unbase64(*src) < 0 && src < srcEnd) src++, remaining--; + if (remaining <= 1 || *src == '=') break; + b = _nan_unbase64(*src++); + + *dst++ = (a << 2) | ((b & 0x30) >> 4); + if (dst == dstEnd) break; + + while (_nan_unbase64(*src) < 0 && src < srcEnd) src++, remaining--; + if (remaining <= 2 || *src == '=') break; + c = _nan_unbase64(*src++); + + *dst++ = ((b & 0x0F) << 4) | ((c & 0x3C) >> 2); + if (dst == dstEnd) break; + + while (_nan_unbase64(*src) < 0 && src < srcEnd) src++, remaining--; + if (remaining <= 3 || *src == '=') break; + d = _nan_unbase64(*src++); + + *dst++ = ((c & 0x03) << 6) | (d & 0x3F); + } + + return dst - buf; +} + +//// HEX //// + +template unsigned _nan_hex2bin(T c) { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'A' && c <= 'F') return 10 + (c - 'A'); + if (c >= 'a' && c <= 'f') return 10 + (c - 'a'); + return static_cast(-1); +} + +template static size_t _nan_hex_decode( + char* buf + , size_t len + , const T* src + , const size_t srcLen +) { + size_t i; + for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) { + unsigned a = _nan_hex2bin(src[i * 2 + 0]); + unsigned b = _nan_hex2bin(src[i * 2 + 1]); + if (!~a || !~b) return i; + buf[i] = a * 16 + b; + } + + return i; +} + +namespace NanIntern { + +inline +NanExternalOneByteStringResource const* +GetExternalResource(v8::Local str) { +#if NODE_MODULE_VERSION < 42 + return str->GetExternalAsciiStringResource(); +#else // io.js v1.0.0 + return str->GetExternalOneByteStringResource(); +#endif +} + +inline +bool +IsExternal(v8::Local str) { +#if NODE_MODULE_VERSION < 42 + return str->IsExternalAscii(); +#else // io.js v1.0.0 + return str->IsExternalOneByte(); +#endif +} + +} // end of namespace NanIntern + +static bool _NanGetExternalParts( + v8::Handle val + , const char** data + , size_t* len +) { + if (node::Buffer::HasInstance(val)) { + *data = node::Buffer::Data(val.As()); + *len = node::Buffer::Length(val.As()); + return true; + } + + assert(val->IsString()); + v8::Local str = NanNew(val.As()); + + if (NanIntern::IsExternal(str)) { + const NanExternalOneByteStringResource* ext; + ext = NanIntern::GetExternalResource(str); + *data = ext->data(); + *len = ext->length(); + return true; + } + + if (str->IsExternal()) { + const v8::String::ExternalStringResource* ext; + ext = str->GetExternalStringResource(); + *data = reinterpret_cast(ext->data()); + *len = ext->length(); + return true; + } + + return false; +} + +namespace Nan { + enum Encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER}; +} + +#if !NODE_VERSION_AT_LEAST(0, 10, 0) +# include "nan_string_bytes.h" // NOLINT(build/include) +#endif + +NAN_INLINE v8::Local NanEncode( + const void *buf, size_t len, enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION >= 42) + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + node::encoding node_enc = static_cast(encoding); + + if (encoding == Nan::UCS2) { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len / 2); + } else { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len + , node_enc); + } +#elif (NODE_MODULE_VERSION > 0x000B) + return node::Encode( + v8::Isolate::GetCurrent() + , buf, len + , static_cast(encoding)); +#else +# if NODE_VERSION_AT_LEAST(0, 10, 0) + return node::Encode(buf, len, static_cast(encoding)); +# else + return NanIntern::Encode(reinterpret_cast(buf), len, encoding); +# endif +#endif +} + +NAN_INLINE ssize_t NanDecodeBytes( + v8::Handle val, enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION > 0x000B) + return node::DecodeBytes( + v8::Isolate::GetCurrent() + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < 0x000B) + if (encoding == Nan::BUFFER) { + return node::DecodeBytes(val, node::BINARY); + } +# endif + return node::DecodeBytes(val, static_cast(encoding)); +#endif +} + +NAN_INLINE ssize_t NanDecodeWrite( + char *buf + , size_t len + , v8::Handle val + , enum Nan::Encoding encoding = Nan::BINARY) { +#if (NODE_MODULE_VERSION > 0x000B) + return node::DecodeWrite( + v8::Isolate::GetCurrent() + , buf + , len + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < 0x000B) + if (encoding == Nan::BUFFER) { + return node::DecodeWrite(buf, len, val, node::BINARY); + } +# endif + return node::DecodeWrite( + buf + , len + , val + , static_cast(encoding)); +#endif +} + +/* NAN_DEPRECATED */ NAN_INLINE void* _NanRawString( + v8::Handle from + , enum Nan::Encoding encoding + , size_t *datalen + , void *buf + , size_t buflen + , int flags +) { + NanScope(); + + size_t sz_; + size_t term_len = !(flags & v8::String::NO_NULL_TERMINATION); + char *data = NULL; + size_t len; + bool is_extern = _NanGetExternalParts( + from + , const_cast(&data) + , &len); + + if (is_extern && !term_len) { + NanSetPointerSafe(datalen, len); + return data; + } + + v8::Local toStr = from->ToString(); + + char *to = static_cast(buf); + + switch (encoding) { + case Nan::ASCII: +#if NODE_MODULE_VERSION < 0x000C + sz_ = toStr->Length(); + if (to == NULL) { + to = new char[sz_ + term_len]; + } else { + assert(buflen >= sz_ + term_len && "too small buffer"); + } + NanSetPointerSafe( + datalen + , toStr->WriteAscii(to, 0, static_cast(sz_ + term_len), flags)); + return to; +#endif + case Nan::BINARY: + case Nan::BUFFER: + sz_ = toStr->Length(); + if (to == NULL) { + to = new char[sz_ + term_len]; + } else { + assert(buflen >= sz_ + term_len && "too small buffer"); + } +#if NODE_MODULE_VERSION < 0x000C + { + uint16_t* twobytebuf = new uint16_t[sz_ + term_len]; + + size_t somelen = toStr->Write(twobytebuf, 0, + static_cast(sz_ + term_len), flags); + + for (size_t i = 0; i < sz_ + term_len && i < somelen + term_len; i++) { + unsigned char *b = reinterpret_cast(&twobytebuf[i]); + to[i] = *b; + } + + NanSetPointerSafe(datalen, somelen); + + delete[] twobytebuf; + return to; + } +#else + NanSetPointerSafe( + datalen, + toStr->WriteOneByte( + reinterpret_cast(to) + , 0 + , static_cast(sz_ + term_len) + , flags)); + return to; +#endif + case Nan::UTF8: + sz_ = toStr->Utf8Length(); + if (to == NULL) { + to = new char[sz_ + term_len]; + } else { + assert(buflen >= sz_ + term_len && "too small buffer"); + } + NanSetPointerSafe( + datalen + , toStr->WriteUtf8(to, static_cast(sz_ + term_len) + , NULL, flags) + - term_len); + return to; + case Nan::BASE64: + { + v8::String::Value value(toStr); + sz_ = _nan_base64_decoded_size(*value, value.length()); + if (to == NULL) { + to = new char[sz_ + term_len]; + } else { + assert(buflen >= sz_ + term_len); + } + NanSetPointerSafe( + datalen + , _nan_base64_decode(to, sz_, *value, value.length())); + if (term_len) { + to[sz_] = '\0'; + } + return to; + } + case Nan::UCS2: + { + sz_ = toStr->Length(); + if (to == NULL) { + to = new char[(sz_ + term_len) * 2]; + } else { + assert(buflen >= (sz_ + term_len) * 2 && "too small buffer"); + } + + int bc = 2 * toStr->Write( + reinterpret_cast(to) + , 0 + , static_cast(sz_ + term_len) + , flags); + NanSetPointerSafe(datalen, bc); + return to; + } + case Nan::HEX: + { + v8::String::Value value(toStr); + sz_ = value.length(); + assert(!(sz_ & 1) && "bad hex data"); + if (to == NULL) { + to = new char[sz_ / 2 + term_len]; + } else { + assert(buflen >= sz_ / 2 + term_len && "too small buffer"); + } + NanSetPointerSafe( + datalen + , _nan_hex_decode(to, sz_ / 2, *value, value.length())); + } + if (term_len) { + to[sz_ / 2] = '\0'; + } + return to; + default: + assert(0 && "unknown encoding"); + } + return to; +} + +NAN_DEPRECATED NAN_INLINE void* NanRawString( + v8::Handle from + , enum Nan::Encoding encoding + , size_t *datalen + , void *buf + , size_t buflen + , int flags +) { + return _NanRawString(from, encoding, datalen, buf, buflen, flags); +} + + +NAN_DEPRECATED NAN_INLINE char* NanCString( + v8::Handle from + , size_t *datalen + , char *buf = NULL + , size_t buflen = 0 + , int flags = v8::String::NO_OPTIONS +) { + return static_cast( + _NanRawString(from, Nan::UTF8, datalen, buf, buflen, flags) + ); +} + +NAN_INLINE void NanSetPrototypeTemplate( + v8::Local templ + , const char *name + , v8::Handle value +) { + NanSetTemplate(templ->PrototypeTemplate(), name, value); +} + +NAN_INLINE void NanSetPrototypeTemplate( + v8::Local templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes +) { + NanSetTemplate(templ->PrototypeTemplate(), name, value, attributes); +} + +NAN_INLINE void NanSetInstanceTemplate( + v8::Local templ + , const char *name + , v8::Handle value +) { + NanSetTemplate(templ->InstanceTemplate(), name, value); +} + +NAN_INLINE void NanSetInstanceTemplate( + v8::Local templ + , v8::Handle name + , v8::Handle value + , v8::PropertyAttribute attributes +) { + NanSetTemplate(templ->InstanceTemplate(), name, value, attributes); +} + +//=== Export ================================================================== + +inline +void +NanExport(v8::Handle target, const char * name, + NanFunctionCallback f) { + target->Set(NanNew(name), + NanNew(f)->GetFunction()); +} + +//=== Tap Reverse Binding ===================================================== + +struct NanTap { + explicit NanTap(v8::Handle t) : t_() { + NanAssignPersistent(t_, t->ToObject()); + } + + ~NanTap() { NanDisposePersistent(t_); } // not sure if neccessary + + inline void plan(int i) { + v8::Handle arg = NanNew(i); + NanMakeCallback(NanNew(t_), "plan", 1, &arg); + } + + inline void ok(bool isOk, const char * msg = NULL) { + v8::Handle args[2]; + args[0] = NanNew(isOk); + if (msg) args[1] = NanNew(msg); + NanMakeCallback(NanNew(t_), "ok", msg ? 2 : 1, args); + } + + private: + v8::Persistent t_; +}; + +#define NAN_STRINGIZE2(x) #x +#define NAN_STRINGIZE(x) NAN_STRINGIZE2(x) +#define NAN_TEST_EXPRESSION(expression) \ + ( expression ), __FILE__ ":" NAN_STRINGIZE(__LINE__) ": " #expression + +#define return_NanValue(v) NanReturnValue(v) +#define return_NanUndefined() NanReturnUndefined() +#define NAN_EXPORT(target, function) NanExport(target, #function, function) + +#endif // NAN_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_12_inl.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_12_inl.h new file mode 100644 index 0000000..ff63ec0 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_12_inl.h @@ -0,0 +1,262 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_12_INL_H_ +#define NAN_IMPLEMENTATION_12_INL_H_ +//============================================================================== +// node v0.11 implementation +//============================================================================== + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif + +namespace NanIntern { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(v8::Isolate::GetCurrent()); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(v8::Isolate::GetCurrent(), length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(v8::Isolate::GetCurrent(), value); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Handle tmpl + , v8::Handle obj) { + return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj); +} + +//=== Date ===================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Date::New(v8::Isolate::GetCurrent(), value).As(); +} + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(v8::Isolate::GetCurrent(), value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data) { + return v8::Function::New( v8::Isolate::GetCurrent() + , callback + , data); +} + +//=== Function Template ======================================================== + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data + , v8::Handle signature) { + return v8::FunctionTemplate::New( v8::Isolate::GetCurrent() + , callback + , data + , signature); +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(v8::Isolate::GetCurrent(), value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New( v8::Isolate::GetCurrent() + , value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(v8::Isolate::GetCurrent(), value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(v8::Isolate::GetCurrent()); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(v8::Isolate::GetCurrent()); +} + +//=== RegExp =================================================================== + +Factory::return_t +Factory::New( + v8::Handle pattern + , v8::RegExp::Flags flags) { + return v8::RegExp::New(pattern, flags); +} + +//=== Script =================================================================== + +Factory::return_t +Factory::New( v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src); +} + +//=== Signature ================================================================ + +Factory::return_t +Factory::New( Factory::FTH receiver + , int argc + , Factory::FTH argv[]) { + return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return v8::String::Empty(v8::Isolate::GetCurrent()); +} + +Factory::return_t +Factory::New(const char * value, int length) { + return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(std::string const& value) { + assert(value.size() <= INT_MAX && "string too long"); + return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), + value.data(), v8::String::kNormalString, static_cast(value.size())); +} + +Factory::return_t +Factory::New(const uint8_t * value, int length) { + return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value, + v8::String::kNormalString, length); +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return v8::String::NewExternal(v8::Isolate::GetCurrent(), value); +} + +Factory::return_t +Factory::New(NanExternalOneByteStringResource * value) { + return v8::String::NewExternal(v8::Isolate::GetCurrent(), value); +} + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Handle value) { + return v8::StringObject::New(value).As(); +} + +//=== Unbound Script =========================================================== + +Factory::return_t +Factory::New(v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src); +} + +} // end of namespace NanIntern + +//=== Presistents and Handles ================================================== + +template +inline v8::Local NanNew(v8::Handle h) { + return v8::Local::New(v8::Isolate::GetCurrent(), h); +} + +template +inline v8::Local NanNew(v8::Persistent const& p) { + return v8::Local::New(v8::Isolate::GetCurrent(), p); +} + +#endif // NAN_IMPLEMENTATION_12_INL_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_pre_12_inl.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_pre_12_inl.h new file mode 100644 index 0000000..85dd275 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_implementation_pre_12_inl.h @@ -0,0 +1,268 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_ +#define NAN_IMPLEMENTATION_PRE_12_INL_H_ + +#include + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# include +# pragma warning( default : 4530 ) +#else +# include +# include +#endif + +//============================================================================== +// node v0.10 implementation +//============================================================================== + +namespace NanIntern { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(value)->ToBoolean(); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Handle tmpl + , v8::Handle obj) { + v8::Persistent ctx = v8::Context::New(extensions, tmpl, obj); + v8::Local lctx = v8::Local::New(ctx); + ctx.Dispose(); + return lctx; +} + +//=== Date ===================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Date::New(value).As(); +} + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data) { + return Factory::New( callback + , data + , v8::Handle() + )->GetFunction(); +} + + +//=== FunctionTemplate ========================================================= + +Factory::return_t +Factory::New( NanFunctionCallback callback + , v8::Handle data + , v8::Handle signature) { + // Note(agnat): Emulate length argument here. Unfortunately, I couldn't find + // a way. Have at it though... + return v8::FunctionTemplate::New( callback + , data + , signature); +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New(value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(); +} + +//=== RegExp =================================================================== + +Factory::return_t +Factory::New( + v8::Handle pattern + , v8::RegExp::Flags flags) { + return v8::RegExp::New(pattern, flags); +} + +//=== Script =================================================================== + +Factory::return_t +Factory::New( v8::Local source) { + return v8::Script::New(source); +} +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + return v8::Script::New(source, const_cast(&origin)); +} + +//=== Signature ================================================================ + +Factory::return_t +Factory::New( Factory::FTH receiver + , int argc + , Factory::FTH argv[]) { + return v8::Signature::New(receiver, argc, argv); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return v8::String::Empty(); +} + +Factory::return_t +Factory::New(const char * value, int length) { + return v8::String::New(value, length); +} + +Factory::return_t +Factory::New(std::string const& value) { + assert(value.size() <= INT_MAX && "string too long"); + return v8::String::New( value.data(), static_cast(value.size())); +} + +inline +void +widenString(std::vector *ws, const uint8_t *s, int l = -1) { + size_t len = static_cast(l); + if (l < 0) { + len = strlen(reinterpret_cast(s)); + } + assert(len <= INT_MAX && "string too long"); + ws->resize(len); + std::copy(s, s + len, ws->begin()); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return v8::String::New(value, length); +} + +Factory::return_t +Factory::New(const uint8_t * value, int length) { + std::vector wideString; + widenString(&wideString, value, length); + if (wideString.size() == 0) { + return v8::String::Empty(); + } else { + return v8::String::New(&wideString.front() + , static_cast(wideString.size())); + } +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return v8::String::NewExternal(value); +} + +Factory::return_t +Factory::New(v8::String::ExternalAsciiStringResource * value) { + return v8::String::NewExternal(value); +} + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Handle value) { + return v8::StringObject::New(value).As(); +} + +} // end of namespace NanIntern + +//=== Presistents and Handles ================================================== + +template +inline v8::Local NanNew(v8::Handle h) { + return v8::Local::New(h); +} + +template +inline v8::Local NanNew(v8::Persistent const& p) { + return v8::Local::New(p); +} + +#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_new.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_new.h new file mode 100644 index 0000000..95b6b51 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_new.h @@ -0,0 +1,329 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2015 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_NEW_H_ +#define NAN_NEW_H_ + +#if defined(_MSC_VER) +# pragma warning( disable : 4530 ) +# include +# pragma warning( default : 4530 ) +#else +# include +#endif + +namespace NanIntern { // scnr + +// TODO(agnat): Generalize +template v8::Local To(v8::Handle i); + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToInteger(); } + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToInt32(); } + +template <> +inline +v8::Local +To(v8::Handle i) { return i->ToUint32(); } + +template struct FactoryBase { typedef v8::Local return_t; }; + +template struct Factory; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); + static inline return_t New(int length); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( v8::ExtensionConfiguration* extensions = NULL + , v8::Handle tmpl = v8::Handle() + , v8::Handle obj = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(void *value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( NanFunctionCallback callback + , v8::Handle data = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( NanFunctionCallback callback = NULL + , v8::Handle data = v8::Handle() + , v8::Handle signature = v8::Handle()); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template +struct IntegerFactory : FactoryBase { + typedef typename FactoryBase::return_t return_t; + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New( + v8::Handle pattern, v8::RegExp::Flags flags); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +template <> +struct Factory : FactoryBase { + typedef v8::Handle FTH; + static inline + return_t + New( FTH receiver = FTH(), int argc = 0, FTH argv[] = NULL ); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); + static inline return_t New(const char *value, int length = -1); + static inline return_t New(const uint16_t *value, int length = -1); + static inline return_t New(std::string const& value); + + static inline return_t New(v8::String::ExternalStringResource * value); + static inline return_t New(NanExternalOneByteStringResource * value); + + // TODO(agnat): Deprecate. + static inline return_t New(const uint8_t * value, int length = -1); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(v8::Handle value); +}; + +} // end of namespace NanIntern + +#if (NODE_MODULE_VERSION >= 12) + +namespace NanIntern { + +template <> +struct Factory : FactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +} // end of namespace NanIntern + +# include "nan_implementation_12_inl.h" + +#else // NODE_MODULE_VERSION >= 12 + +# include "nan_implementation_pre_12_inl.h" + +#endif + +//=== API ====================================================================== + +template +typename NanIntern::Factory::return_t +NanNew() { + return NanIntern::Factory::New(); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0) { + return NanIntern::Factory::New(arg0); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1) { + return NanIntern::Factory::New(arg0, arg1); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1, A2 arg2) { + return NanIntern::Factory::New(arg0, arg1, arg2); +} + +template +typename NanIntern::Factory::return_t +NanNew(A0 arg0, A1 arg1, A2 arg2, A3 arg3) { + return NanIntern::Factory::New(arg0, arg1, arg2, arg3); +} + +// Note(agnat): When passing overloaded function pointers to template functions +// as generic arguments the compiler needs help in picking the right overload. +// These two functions handle NanNew and NanNew with +// all argument variations. + +// v8::Function and v8::FunctionTemplate with one or two arguments +template +typename NanIntern::Factory::return_t +NanNew( NanFunctionCallback callback + , v8::Handle data = v8::Handle()) { + return NanIntern::Factory::New(callback, data); +} + +// v8::Function and v8::FunctionTemplate with three arguments +template +typename NanIntern::Factory::return_t +NanNew( NanFunctionCallback callback + , v8::Handle data = v8::Handle() + , A2 a2 = A2()) { + return NanIntern::Factory::New(callback, data, a2); +} + +// Convenience + +template inline v8::Local NanNew(v8::Handle h); +template inline v8::Local NanNew(v8::Persistent const& p); + +inline +NanIntern::Factory::return_t +NanNew(bool value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(int32_t value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(uint32_t value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(double value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(std::string const& value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const char * value, int length) { + return NanNew(value, length); +} + +inline +NanIntern::Factory::return_t +NanNew(const char * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const uint8_t * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(const uint16_t * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(v8::String::ExternalStringResource * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(NanExternalOneByteStringResource * value) { + return NanNew(value); +} + +inline +NanIntern::Factory::return_t +NanNew(v8::Handle pattern, v8::RegExp::Flags flags) { + return NanNew(pattern, flags); +} + +#endif // NAN_NEW_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_string_bytes.h b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_string_bytes.h new file mode 100644 index 0000000..9deecfb --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/nan_string_bytes.h @@ -0,0 +1,312 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef NAN_STRING_BYTES_H_ +#define NAN_STRING_BYTES_H_ + +// Decodes a v8::Handle or Buffer to a raw char* + +#include +#include +#include +#include // memcpy +#include + +namespace NanIntern { + +using v8::Local; +using v8::Handle; +using v8::Object; +using v8::String; +using v8::Value; + + +//// Base 64 //// + +#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) + + + +//// Nan::HEX //// + +static bool contains_non_ascii_slow(const char* buf, size_t len) { + for (size_t i = 0; i < len; ++i) { + if (buf[i] & 0x80) return true; + } + return false; +} + + +static bool contains_non_ascii(const char* src, size_t len) { + if (len < 16) { + return contains_non_ascii_slow(src, len); + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned unaligned = reinterpret_cast(src) & align_mask; + + if (unaligned > 0) { + const unsigned n = bytes_per_word - unaligned; + if (contains_non_ascii_slow(src, n)) return true; + src += n; + len -= n; + } + + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = 0x8080808080808080ll; +#else + const uintptr_t mask = 0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + if (srcw[i] & mask) return true; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + if (contains_non_ascii_slow(src + offset, remainder)) return true; + } + + return false; +} + + +static void force_ascii_slow(const char* src, char* dst, size_t len) { + for (size_t i = 0; i < len; ++i) { + dst[i] = src[i] & 0x7f; + } +} + + +static void force_ascii(const char* src, char* dst, size_t len) { + if (len < 16) { + force_ascii_slow(src, dst, len); + return; + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned src_unalign = reinterpret_cast(src) & align_mask; + const unsigned dst_unalign = reinterpret_cast(dst) & align_mask; + + if (src_unalign > 0) { + if (src_unalign == dst_unalign) { + const unsigned unalign = bytes_per_word - src_unalign; + force_ascii_slow(src, dst, unalign); + src += unalign; + dst += unalign; + len -= src_unalign; + } else { + force_ascii_slow(src, dst, len); + return; + } + } + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = ~0x8080808080808080ll; +#else + const uintptr_t mask = ~0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + uintptr_t* dstw = reinterpret_cast(dst); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + dstw[i] = srcw[i] & mask; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + force_ascii_slow(src + offset, dst + offset, remainder); + } +} + + +static size_t base64_encode(const char* src, + size_t slen, + char* dst, + size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= base64_encoded_size(slen) && + "not enough space provided for base64 encode"); + + dlen = base64_encoded_size(slen); + + unsigned a; + unsigned b; + unsigned c; + unsigned i; + unsigned k; + unsigned n; + + static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + i = 0; + k = 0; + n = slen / 3 * 3; + + while (i < n) { + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + c = src[i + 2] & 0xff; + + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)]; + dst[k + 3] = table[c & 0x3f]; + + i += 3; + k += 4; + } + + if (n != slen) { + switch (slen - n) { + case 1: + a = src[i + 0] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[(a & 3) << 4]; + dst[k + 2] = '='; + dst[k + 3] = '='; + break; + + case 2: + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[(b & 0x0f) << 2]; + dst[k + 3] = '='; + break; + } + } + + return dlen; +} + + +static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= slen * 2 && + "not enough space provided for hex encode"); + + dlen = slen * 2; + for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) { + static const char hex[] = "0123456789abcdef"; + uint8_t val = static_cast(src[i]); + dst[k + 0] = hex[val >> 4]; + dst[k + 1] = hex[val & 15]; + } + + return dlen; +} + + + +static Local Encode(const char* buf, + size_t buflen, + enum Nan::Encoding encoding) { + assert(buflen <= node::Buffer::kMaxLength); + if (!buflen && encoding != Nan::BUFFER) + return NanNew(""); + + Local val; + switch (encoding) { + case Nan::BUFFER: + return NanNewBufferHandle(buf, buflen); + + case Nan::ASCII: + if (contains_non_ascii(buf, buflen)) { + char* out = new char[buflen]; + force_ascii(buf, out, buflen); + val = NanNew(out, buflen); + delete[] out; + } else { + val = NanNew(buf, buflen); + } + break; + + case Nan::UTF8: + val = NanNew(buf, buflen); + break; + + case Nan::BINARY: { + // TODO(isaacs) use ExternalTwoByteString? + const unsigned char *cbuf = reinterpret_cast(buf); + uint16_t * twobytebuf = new uint16_t[buflen]; + for (size_t i = 0; i < buflen; i++) { + // XXX is the following line platform independent? + twobytebuf[i] = cbuf[i]; + } + val = NanNew(twobytebuf, buflen); + delete[] twobytebuf; + break; + } + + case Nan::BASE64: { + size_t dlen = base64_encoded_size(buflen); + char* dst = new char[dlen]; + + size_t written = base64_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = NanNew(dst, dlen); + delete[] dst; + break; + } + + case Nan::UCS2: { + const uint16_t* data = reinterpret_cast(buf); + val = NanNew(data, buflen / 2); + break; + } + + case Nan::HEX: { + size_t dlen = buflen * 2; + char* dst = new char[dlen]; + size_t written = hex_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = NanNew(dst, dlen); + delete[] dst; + break; + } + + default: + assert(0 && "unknown encoding"); + break; + } + + return val; +} + +#undef base64_encoded_size + +} // namespace NanIntern + +#endif // NAN_STRING_BYTES_H_ diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/package.json new file mode 100644 index 0000000..55f0dc4 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/node_modules/nan/package.json @@ -0,0 +1,89 @@ +{ + "name": "nan", + "version": "1.6.2", + "description": "Native Abstractions for Node.js: C++ header for Node 0.8->0.12 compatibility", + "main": "include_dirs.js", + "repository": { + "type": "git", + "url": "git://github.com/rvagg/nan.git" + }, + "scripts": { + "test": "tap --gc test/js/*-test.js", + "rebuild-tests": "pangyp rebuild --directory test" + }, + "contributors": [ + { + "name": "Rod Vagg", + "email": "r@va.gg", + "url": "https://github.com/rvagg" + }, + { + "name": "Benjamin Byholm", + "email": "bbyholm@abo.fi", + "url": "https://github.com/kkoopa/" + }, + { + "name": "Trevor Norris", + "email": "trev.norris@gmail.com", + "url": "https://github.com/trevnorris" + }, + { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "https://github.com/TooTallNate" + }, + { + "name": "Brett Lawson", + "email": "brett19@gmail.com", + "url": "https://github.com/brett19" + }, + { + "name": "Ben Noordhuis", + "email": "info@bnoordhuis.nl", + "url": "https://github.com/bnoordhuis" + }, + { + "name": "David Siegel", + "email": "david@artcom.de", + "url": "https://github.com/agnat" + } + ], + "devDependencies": { + "bindings": "~1.2.1", + "node-gyp": "~1.0.2", + "pangyp": "~2.0.1", + "tap": "~0.5.0", + "xtend": "~4.0.0" + }, + "license": "MIT", + "gitHead": "ab0e5eed8d4aa36111bf8f44cf75644ece327e98", + "bugs": { + "url": "https://github.com/rvagg/nan/issues" + }, + "homepage": "https://github.com/rvagg/nan", + "_id": "nan@1.6.2", + "_shasum": "2657d1c43b00f1e847e083832285b7d8f5ba8ec8", + "_from": "nan@1.6.2", + "_npmVersion": "2.0.0", + "_npmUser": { + "name": "kkoopa", + "email": "bbyholm@abo.fi" + }, + "maintainers": [ + { + "name": "rvagg", + "email": "rod@vagg.org" + }, + { + "name": "kkoopa", + "email": "bbyholm@abo.fi" + } + ], + "dist": { + "shasum": "2657d1c43b00f1e847e083832285b7d8f5ba8ec8", + "tarball": "http://registry.npmjs.org/nan/-/nan-1.6.2.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/nan/-/nan-1.6.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/package.json b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/package.json new file mode 100644 index 0000000..b8c3d55 --- /dev/null +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/package.json @@ -0,0 +1,62 @@ +{ + "name": "utf-8-validate", + "version": "1.0.1", + "description": "Validate UTF-8 for Web", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "install": "node-gyp rebuild" + }, + "repository": { + "type": "git", + "url": "https://github.com/websockets/utf-8-validate" + }, + "keywords": [ + "utf-8-validate" + ], + "author": { + "name": "Einar Otto Stangvik", + "email": "einaros@gmail.com", + "url": "http://2x.io" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/websockets/utf-8-validate/issues" + }, + "homepage": "https://github.com/websockets/utf-8-validate", + "dependencies": { + "bindings": "1.2.x", + "nan": "1.6.x" + }, + "gypfile": true, + "gitHead": "1c0a74c3f2a8bb9e5b14df235404faa3760abce3", + "_id": "utf-8-validate@1.0.1", + "_shasum": "d15eb67e28f6bb93c9401eeb7eac7030a183e8d1", + "_from": "utf-8-validate@1.0.x", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "einaros", + "email": "einaros@gmail.com" + }, + { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + { + "name": "v1", + "email": "info@3rd-Eden.com" + } + ], + "dist": { + "shasum": "d15eb67e28f6bb93c9401eeb7eac7030a183e8d1", + "tarball": "http://registry.npmjs.org/utf-8-validate/-/utf-8-validate-1.0.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-1.0.1.tgz" +} diff --git a/node_modules/auto-reload-brunch/node_modules/ws/src/validation.cc b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/src/validation.cc similarity index 93% rename from node_modules/auto-reload-brunch/node_modules/ws/src/validation.cc rename to node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/src/validation.cc index 0d9e242..264edcd 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/src/validation.cc +++ b/node_modules/auto-reload-brunch/node_modules/ws/node_modules/utf-8-validate/src/validation.cc @@ -1,11 +1,12 @@ /*! - * ws: a node.js websocket client - * Copyright(c) 2011 Einar Otto Stangvik + * UTF-8 validate: UTF-8 validation for WebSockets. + * Copyright(c) 2015 Einar Otto Stangvik * MIT Licensed */ #include #include +#include #include #include #include @@ -109,7 +110,7 @@ class Validation : public ObjectWrap Local t = NanNew(New); t->InstanceTemplate()->SetInternalFieldCount(1); NODE_SET_METHOD(t, "isValidUTF8", Validation::IsValidUTF8); - target->Set(NanSymbol("Validation"), t->GetFunction()); + target->Set(NanNew("Validation"), t->GetFunction()); } protected: @@ -134,8 +135,10 @@ class Validation : public ObjectWrap NanReturnValue(is_valid_utf8(buffer_length, buffer_data) == 1 ? NanTrue() : NanFalse()); } }; - -extern "C" void init (Handle target) +#if !NODE_VERSION_AT_LEAST(0,10,0) +extern "C" +#endif +void init (Handle target) { NanScope(); Validation::Initialize(target); diff --git a/node_modules/auto-reload-brunch/node_modules/ws/package.json b/node_modules/auto-reload-brunch/node_modules/ws/package.json index fbfd001..3648d43 100644 --- a/node_modules/auto-reload-brunch/node_modules/ws/package.json +++ b/node_modules/auto-reload-brunch/node_modules/ws/package.json @@ -6,7 +6,8 @@ }, "name": "ws", "description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455", - "version": "0.4.32", + "version": "0.7.1", + "license": "MIT", "keywords": [ "Hixie", "HyBi", @@ -18,30 +19,28 @@ ], "repository": { "type": "git", - "url": "git://github.com/einaros/ws.git" - }, - "bin": { - "wscat": "./bin/wscat" + "url": "git://github.com/websockets/ws.git" }, "scripts": { - "test": "make test", - "install": "(node-gyp rebuild 2> builderror.log) || (exit 0)" - }, - "engines": { - "node": ">=0.4.0" + "test": "make test" }, "dependencies": { - "commander": "~2.1.0", - "nan": "~1.0.0", - "tinycolor": "0.x", - "options": ">=0.0.5" + "options": ">=0.0.5", + "ultron": "1.0.x", + "bufferutil": "1.0.x", + "utf-8-validate": "1.0.x" + }, + "optionalDependencies": { + "bufferutil": "1.0.x", + "utf-8-validate": "1.0.x" }, "devDependencies": { - "mocha": "1.12.0", - "should": "1.2.x", - "expect.js": "0.2.x", + "ansi": "0.3.x", "benchmark": "0.3.x", - "ansi": "latest" + "expect.js": "0.3.x", + "mocha": "2.0.x", + "should": "4.3.x", + "tinycolor": "0.0.x" }, "browser": "./lib/browser.js", "component": { @@ -50,12 +49,38 @@ } }, "gypfile": true, - "readme": "[![Build Status](https://secure.travis-ci.org/einaros/ws.png)](http://travis-ci.org/einaros/ws)\n\n# ws: a node.js websocket library #\n\n`ws` is a simple to use websocket implementation, up-to-date against RFC-6455, and [probably the fastest WebSocket library for node.js](http://web.archive.org/web/20130314230536/http://hobbycoding.posterous.com/the-fastest-websocket-module-for-nodejs).\n\nPasses the quite extensive Autobahn test suite. See http://einaros.github.com/ws for the full reports.\n\nComes with a command line utility, `wscat`, which can either act as a server (--listen), or client (--connect); Use it to debug simple websocket services.\n\n## Protocol support ##\n\n* **Hixie draft 76** (Old and deprecated, but still in use by Safari and Opera. Added to ws version 0.4.2, but server only. Can be disabled by setting the `disableHixie` option to true.)\n* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`, or argument `-p 8` for wscat)\n* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`, or argument `-p 13` for wscat)\n\n_See the echo.websocket.org example below for how to use the `protocolVersion` option._\n\n## Usage ##\n\n### Installing ###\n\n`npm install ws`\n\n### Sending and receiving text data ###\n\n```js\nvar WebSocket = require('ws');\nvar ws = new WebSocket('ws://www.host.com/path');\nws.on('open', function() {\n ws.send('something');\n});\nws.on('message', function(data, flags) {\n // flags.binary will be set if a binary data is received\n // flags.masked will be set if the data was masked\n});\n```\n\n### Sending binary data ###\n\n```js\nvar WebSocket = require('ws');\nvar ws = new WebSocket('ws://www.host.com/path');\nws.on('open', function() {\n var array = new Float32Array(5);\n for (var i = 0; i < array.length; ++i) array[i] = i / 2;\n ws.send(array, {binary: true, mask: true});\n});\n```\n\nSetting `mask`, as done for the send options above, will cause the data to be masked according to the websocket protocol. The same option applies for text data.\n\n### Server example ###\n\n```js\nvar WebSocketServer = require('ws').Server\n , wss = new WebSocketServer({port: 8080});\nwss.on('connection', function(ws) {\n ws.on('message', function(message) {\n console.log('received: %s', message);\n });\n ws.send('something');\n});\n```\n\n### Server sending broadcast data ###\n\n```js\nvar WebSocketServer = require('ws').Server\n , wss = new WebSocketServer({port: 8080});\n \nwss.broadcast = function(data) {\n\tfor(var i in this.clients)\n\t\tthis.clients[i].send(data);\n};\n```\n\n### Error handling best practices ###\n\n```js\n// If the WebSocket is closed before the following send is attempted\nws.send('something');\n\n// Errors (both immediate and async write errors) can be detected in an optional callback.\n// The callback is also the only way of being notified that data has actually been sent.\nws.send('something', function(error) {\n // if error is null, the send has been completed,\n // otherwise the error object will indicate what failed.\n});\n\n// Immediate errors can also be handled with try/catch-blocks, but **note**\n// that since sends are inherently asynchronous, socket write failures will *not*\n// be captured when this technique is used.\ntry {\n ws.send('something');\n}\ncatch (e) {\n // handle error\n}\n```\n\n### echo.websocket.org demo ###\n\n```js\nvar WebSocket = require('ws');\nvar ws = new WebSocket('ws://echo.websocket.org/', {protocolVersion: 8, origin: 'http://websocket.org'});\nws.on('open', function() {\n console.log('connected');\n ws.send(Date.now().toString(), {mask: true});\n});\nws.on('close', function() {\n console.log('disconnected');\n});\nws.on('message', function(data, flags) {\n console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags);\n setTimeout(function() {\n ws.send(Date.now().toString(), {mask: true});\n }, 500);\n});\n```\n\n### wscat against echo.websocket.org ###\n\n $ npm install -g ws\n $ wscat -c ws://echo.websocket.org \n connected (press CTRL+C to quit)\n > hi there\n < hi there\n > are you a happy parrot?\n < are you a happy parrot?\n\n### Other examples ###\n\nFor a full example with a browser client communicating with a ws server, see the examples folder.\n\nNote that the usage together with Express 3.0 is quite different from Express 2.x. The difference is expressed in the two different serverstats-examples.\n\nOtherwise, see the test cases.\n\n### Running the tests ###\n\n`make test`\n\n## API Docs ##\n\nSee the doc/ directory for Node.js-like docs for the ws classes.\n\n## License ##\n\n(The MIT License)\n\nCopyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", - "readmeFilename": "README.md", + "gitHead": "608df82a333de45905f05ca60f18a625b4c3293b", "bugs": { - "url": "https://github.com/einaros/ws/issues" + "url": "https://github.com/websockets/ws/issues" + }, + "homepage": "https://github.com/websockets/ws", + "_id": "ws@0.7.1", + "_shasum": "8f1c7864ca08081be3cd0ac330df0d29c5fcd0da", + "_from": "ws@~0.7.1", + "_npmVersion": "2.3.0", + "_nodeVersion": "0.10.35", + "_npmUser": { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + }, + "maintainers": [ + { + "name": "einaros", + "email": "einaros@gmail.com" + }, + { + "name": "v1", + "email": "info@3rd-Eden.com" + }, + { + "name": "3rdeden", + "email": "npm@3rd-Eden.com" + } + ], + "dist": { + "shasum": "8f1c7864ca08081be3cd0ac330df0d29c5fcd0da", + "tarball": "http://registry.npmjs.org/ws/-/ws-0.7.1.tgz" }, - "homepage": "https://github.com/einaros/ws", - "_id": "ws@0.4.32", - "_from": "ws@~0.4.31" + "directories": {}, + "_resolved": "https://registry.npmjs.org/ws/-/ws-0.7.1.tgz" } diff --git a/node_modules/auto-reload-brunch/package.json b/node_modules/auto-reload-brunch/package.json index dd6e9f6..9fd21a5 100644 --- a/node_modules/auto-reload-brunch/package.json +++ b/node_modules/auto-reload-brunch/package.json @@ -1,6 +1,6 @@ { "name": "auto-reload-brunch", - "version": "1.7.6", + "version": "1.7.8", "description": "Adds automatic browser reloading support to brunch.", "author": { "name": "Paul Miller", @@ -21,23 +21,24 @@ "test": "mocha" }, "dependencies": { - "ws": "~0.4.31" + "ws": "~0.7.1" }, "devDependencies": { "mocha": "1.11.0", "chai": "1.7.0" }, - "gitHead": "37dedad368d1a73925be57bf533807ff0092b6bd", + "gitHead": "d66e6b8448622e290b7739cc0d3de0feb7a00fd3", "bugs": { "url": "https://github.com/brunch/auto-reload-brunch/issues" }, - "_id": "auto-reload-brunch@1.7.6", - "_shasum": "a9f68c44fb4bb2f36f52155bd2294d8dbbcf1359", - "_from": "auto-reload-brunch@^1.7.6", - "_npmVersion": "1.4.28", + "_id": "auto-reload-brunch@1.7.8", + "_shasum": "bbe193b26ad84656695cc9a9c0b7b26555992b1e", + "_from": "auto-reload-brunch@1.7.8", + "_npmVersion": "2.5.1", + "_nodeVersion": "0.10.36", "_npmUser": { - "name": "es128", - "email": "elan.shanker+npm@gmail.com" + "name": "paulmillr", + "email": "paul@paulmillr.com" }, "maintainers": [ { @@ -50,10 +51,9 @@ } ], "dist": { - "shasum": "a9f68c44fb4bb2f36f52155bd2294d8dbbcf1359", - "tarball": "http://registry.npmjs.org/auto-reload-brunch/-/auto-reload-brunch-1.7.6.tgz" + "shasum": "bbe193b26ad84656695cc9a9c0b7b26555992b1e", + "tarball": "http://registry.npmjs.org/auto-reload-brunch/-/auto-reload-brunch-1.7.8.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/auto-reload-brunch/-/auto-reload-brunch-1.7.6.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/auto-reload-brunch/-/auto-reload-brunch-1.7.8.tgz" } diff --git a/node_modules/auto-reload-brunch/vendor/auto-reload.js b/node_modules/auto-reload-brunch/vendor/auto-reload.js index 911a3d9..5c175e1 100644 --- a/node_modules/auto-reload-brunch/vendor/auto-reload.js +++ b/node_modules/auto-reload-brunch/vendor/auto-reload.js @@ -10,6 +10,9 @@ return url + (url.indexOf('?') >= 0 ? '&' : '?') +'cacheBuster=' + date; }; + var browser = navigator.userAgent.toLowerCase(); + var forceRepaint = ar.forceRepaint || browser.indexOf('chrome') > -1; + var reloaders = { page: function(){ window.location.reload(true); @@ -17,20 +20,13 @@ stylesheet: function(){ [].slice - .call(document.querySelectorAll('link[rel="stylesheet"]')) - .filter(function(link){ - return (link != null && link.href != null); - }) + .call(document.querySelectorAll('link[rel="stylesheet"][href]:not([data-autoreload="false"]')) .forEach(function(link) { link.href = cacheBuster(link.href); }); - // hack to force page repaint - var el = document.body; - var bodyDisplay = el.style.display || 'block'; - el.style.display = 'none'; - el.offsetHeight; - el.style.display = bodyDisplay; + // Hack to force page repaint after 25ms. + if (forceRepaint) setTimeout(function() { document.body.offsetHeight; }, 25); } }; var port = ar.port || 9485; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/ChangeLog.md b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/ChangeLog.md index 33a9db1..0c7781e 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/ChangeLog.md +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/ChangeLog.md @@ -1,3 +1,43 @@ +## 5.1.7 +* Fix placeholder selector (by Vincent De Oliveira). + +## 5.1.6 +* Use official `::placeholder-shown` selector (by Vincent De Oliveira). + +## 5.1.5 +* Add transition support for CSS Masks properties. + +## 5.1.4 +* Use `-webkit-` prefix for Opera Mobile 24. + +## 5.1.3 +* Add IE support for `image-rendering: crisp-edges`. + +## 5.1.2 +* Add never existed `@-ms-keyframes` to common mistake. + +## 5.1.1 +* Safer value split in `flex` hack. + +## 5.1 “Jianyuan” +* Add support for resolution media query (by 一丝). +* Higher accuracy while removing prefixes in values. +* Add support for logical properties (by 一丝). +* Add `@viewport` support. +* Add `text-overflow` support (by 一丝). +* Add `text-emphasis` support (by 一丝). +* Add `image-rendering: crisp-edges` support. +* Add `text-align-last` support. +* Return `autoprefixer.defaults` as alias to current `browserslist.defaults`. +* Save code style while adding prefixes to `@keyframes` and `@viewport`. +* Do not remove `-webkit-background-clip` with non-spec `text` value. +* Fix `-webkit-filter` in `transition`. +* Better support for browser versions joined on Can I Use + like `ios_saf 7.0-7.1` (by Vincent De Oliveira). +* Fix compatibility with `postcss-import` (by Jason Kuhrt). +* Fix Flexbox prefixes for BlackBerry and UC Browser. +* Fix gradient prefixes for old Chrome. + ## 5.0 “Pravda vítězí” * Use PostCSS 4.0. * Use Browserslist to parse browsers queries. @@ -6,6 +46,7 @@ * Add `object-fit` and `object-position` properties support. * Add CSS Shape properties support. * Fix UC Browser name in debug info. +* Remove `autoprefixer.defaults` and use defaults from Browserslist. ## 4.0.2 * Remove `o-border-radius`, which is common mistake in legacy CSS. diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/browsers.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/browsers.js deleted file mode 100644 index 9fad8d6..0000000 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/browsers.js +++ /dev/null @@ -1,64 +0,0 @@ -(function() { - var convert, data, intervals, major, name, names, normalize, _ref; - - names = ['firefox', 'chrome', 'safari', 'ios_saf', 'opera', 'ie', 'bb', 'android']; - - major = ['firefox', 'chrome', 'safari', 'ios_saf', 'opera', 'android', 'ie', 'ie_mob']; - - normalize = function(array) { - return array.reverse().filter(function(i) { - return i; - }); - }; - - intervals = function(array) { - var i, interval, result, splited, sub, _i, _len; - result = []; - for (_i = 0, _len = array.length; _i < _len; _i++) { - interval = array[_i]; - splited = interval.split('-'); - splited = splited.sort().reverse(); - sub = (function() { - var _j, _len1, _results; - _results = []; - for (_j = 0, _len1 = splited.length; _j < _len1; _j++) { - i = splited[_j]; - _results.push([i, interval, splited.length]); - } - return _results; - })(); - result = result.concat(sub); - } - return result; - }; - - convert = function(name, data) { - var future, result, versions; - future = normalize(data.versions.slice(-3)); - versions = intervals(normalize(data.versions.slice(0, -3))); - result = {}; - result.prefix = name === 'opera' ? '-o-' : "-" + data.prefix + "-"; - if (major.indexOf(name) === -1) { - result.minor = true; - } - if (future.length) { - result.future = future; - } - result.versions = versions.map(function(i) { - return i[0]; - }); - result.popularity = versions.map(function(i) { - return data.usage_global[i[1]] / i[2]; - }); - return result; - }; - - module.exports = {}; - - _ref = require('caniuse-db/data').agents; - for (name in _ref) { - data = _ref[name]; - module.exports[name] = convert(name, data); - } - -}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/prefixes.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/prefixes.js index af1f644..99664d8 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/prefixes.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/data/prefixes.js @@ -1,32 +1,9 @@ (function() { - var browsers, feature, map, prefix, textDecoration, - __slice = [].slice; + var add, crispedges, feature, flexbox, gradients, logicalProps, prefix, resolution, result, sort, textDecoration, + slice = [].slice; - browsers = require('./browsers'); - - feature = function(data, opts, callback) { - var browser, interval, match, need, sorted, support, version, versions, _i, _len, _ref, _ref1, _ref2; - if (!callback) { - _ref = [opts, {}], callback = _ref[0], opts = _ref[1]; - } - match = opts.full ? /y\sx($|\s)/ : /\sx($|\s)/; - need = []; - _ref1 = data.stats; - for (browser in _ref1) { - versions = _ref1[browser]; - for (interval in versions) { - support = versions[interval]; - _ref2 = interval.split('-'); - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - version = _ref2[_i]; - if (browsers[browser] && support.match(match)) { - version = version.replace(/\.0$/, ''); - need.push(browser + ' ' + version); - } - } - } - } - sorted = need.sort(function(a, b) { + sort = function(array) { + return array.sort(function(a, b) { a = a.split(' '); b = b.split(' '); if (a[0] > b[0]) { @@ -37,51 +14,80 @@ return parseFloat(a[1]) - parseFloat(b[1]); } }); - return callback(sorted); }; - map = function(browsers, callback) { - var browser, name, version, _i, _len, _ref, _results; - _results = []; - for (_i = 0, _len = browsers.length; _i < _len; _i++) { - browser = browsers[_i]; - _ref = browser.split(' '), name = _ref[0], version = _ref[1]; - version = parseFloat(version); - _results.push(callback(browser, name, version)); + feature = function(data, opts, callback) { + var browser, match, need, ref, ref1, support, version, versions; + if (!callback) { + ref = [opts, {}], callback = ref[0], opts = ref[1]; + } + match = opts.match || /\sx($|\s)/; + need = []; + ref1 = data.stats; + for (browser in ref1) { + versions = ref1[browser]; + for (version in versions) { + support = versions[version]; + if (support.match(match)) { + need.push(browser + ' ' + version); + } + } } - return _results; + return callback(sort(need)); }; + result = {}; + prefix = function() { - var data, name, names, _i, _j, _len, _results; - names = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), data = arguments[_i++]; - _results = []; - for (_j = 0, _len = names.length; _j < _len; _j++) { - name = names[_j]; - _results.push(module.exports[name] = data); + var data, i, j, k, len, name, names, results; + names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++]; + results = []; + for (k = 0, len = names.length; k < len; k++) { + name = names[k]; + result[name] = {}; + results.push((function() { + var results1; + results1 = []; + for (i in data) { + results1.push(result[name][i] = data[i]); + } + return results1; + })()); } - return _results; + return results; }; - module.exports = {}; + add = function() { + var data, j, k, len, name, names, results; + names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++]; + results = []; + for (k = 0, len = names.length; k < len; k++) { + name = names[k]; + results.push(result[name].browsers = sort(result[name].browsers.concat(data.browsers))); + } + return results; + }; + + module.exports = result; feature(require('caniuse-db/features-json/border-radius'), function(browsers) { return prefix('border-radius', 'border-top-left-radius', 'border-top-right-radius', 'border-bottom-right-radius', 'border-bottom-left-radius', { mistakes: ['-ms-', '-o-'], - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); }); feature(require('caniuse-db/features-json/css-boxshadow'), function(browsers) { return prefix('box-shadow', { - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); }); feature(require('caniuse-db/features-json/css-animation'), function(browsers) { return prefix('animation', 'animation-name', 'animation-duration', 'animation-delay', 'animation-direction', 'animation-fill-mode', 'animation-iteration-count', 'animation-play-state', 'animation-timing-function', '@keyframes', { + mistakes: ['-ms-'], browsers: browsers }); }); @@ -95,29 +101,26 @@ feature(require('caniuse-db/features-json/transforms2d'), function(browsers) { return prefix('transform', 'transform-origin', { - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); }); feature(require('caniuse-db/features-json/transforms3d'), function(browsers) { prefix('perspective', 'perspective-origin', { - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); return prefix('transform-style', 'backface-visibility', { browsers: browsers }); }); - feature(require('caniuse-db/features-json/css-gradients'), function(browsers) { - browsers = map(browsers, function(browser, name, version) { - if (name === 'android' && version < 4 || name === 'ios_saf' && version < 5 || name === 'safari' && version < 5.1) { - return browser + ' old'; - } else { - return browser; - } - }); + gradients = require('caniuse-db/features-json/css-gradients'); + + feature(gradients, { + match: /y\sx/ + }, function(browsers) { return prefix('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', { props: ['background', 'background-image', 'border-image', 'list-style', 'list-style-image', 'content'], mistakes: ['-ms-'], @@ -125,6 +128,21 @@ }); }); + feature(gradients, { + match: /a\sx/ + }, function(browsers) { + browsers = browsers.map(function(i) { + if (/op/.test(i)) { + return i; + } else { + return i + " old"; + } + }); + return add('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', { + browsers: browsers + }); + }); + feature(require('caniuse-db/features-json/css3-boxsizing'), function(browsers) { return prefix('box-sizing', { browsers: browsers @@ -133,15 +151,15 @@ feature(require('caniuse-db/features-json/css-filters'), function(browsers) { return prefix('filter', { - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); }); feature(require('caniuse-db/features-json/multicolumn'), function(browsers) { prefix('columns', 'column-width', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-width', { - browsers: browsers, - transition: true + transition: true, + browsers: browsers }); return prefix('column-count', 'column-rule-style', 'column-span', 'column-fill', 'break-before', 'break-after', 'break-inside', { browsers: browsers @@ -154,18 +172,16 @@ }); }); - feature(require('caniuse-db/features-json/flexbox'), function(browsers) { - browsers = map(browsers, function(browser, name, version) { - if (name === 'safari' && version < 6.1) { - return browser + ' 2009'; - } else if (name === 'ios_saf' && version < 7) { - return browser + ' 2009'; - } else if (name === 'chrome' && version < 21) { - return browser + ' 2009'; - } else if (name === 'android' && version < 4.4) { - return browser + ' 2009'; + flexbox = require('caniuse-db/features-json/flexbox'); + + feature(flexbox, { + match: /a\sx/ + }, function(browsers) { + browsers = browsers.map(function(i) { + if (/ie|firefox/.test(i)) { + return i; } else { - return browser; + return i + " 2009"; } }); prefix('display-flex', 'inline-flex', { @@ -181,6 +197,20 @@ }); }); + feature(flexbox, { + match: /y\sx/ + }, function(browsers) { + add('display-flex', 'inline-flex', { + browsers: browsers + }); + add('flex', 'flex-grow', 'flex-shrink', 'flex-basis', { + browsers: browsers + }); + return add('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', { + browsers: browsers + }); + }); + feature(require('caniuse-db/features-json/calc'), function(browsers) { return prefix('calc', { props: ['*'], @@ -214,14 +244,16 @@ }); feature(require('caniuse-db/features-json/css-placeholder'), function(browsers) { - browsers = map(browsers, function(browser, name, version) { - if (name === 'firefox' && version <= 18) { - return browser + ' old'; + browsers = browsers.map(function(i) { + var name, ref, version; + ref = i.split(' '), name = ref[0], version = ref[1]; + if (name === 'firefox' && parseFloat(version) <= 18) { + return i + ' old'; } else { - return browser; + return i; } }); - return prefix('::placeholder', { + return prefix(':placeholder-shown', '::placeholder', { selector: true, browsers: browsers }); @@ -286,7 +318,7 @@ }); feature(textDecoration, { - full: true + match: /y\sx($|\s)/ }, function(browsers) { return prefix('text-decoration-line', 'text-decoration-color', { browsers: browsers @@ -300,7 +332,11 @@ }); feature(require('caniuse-db/features-json/css-masks'), function(browsers) { - return prefix('clip-path', 'mask', 'mask-clip', 'mask-composite', 'mask-image', 'mask-origin', 'mask-position', 'mask-repeat', 'mask-size', { + prefix('mask-clip', 'mask-composite', 'mask-image', 'mask-origin', 'mask-repeat', { + browsers: browsers + }); + return prefix('clip-path', 'mask', 'mask-position', 'mask-size', { + transition: true, browsers: browsers }); }); @@ -323,4 +359,75 @@ }); }); + feature(require('caniuse-db/features-json/text-overflow'), function(browsers) { + return prefix('text-overflow', { + browsers: browsers + }); + }); + + feature(require('caniuse-db/features-json/text-emphasis'), function(browsers) { + return prefix('text-emphasis', { + browsers: browsers + }); + }); + + feature(require('caniuse-db/features-json/css-deviceadaptation'), function(browsers) { + return prefix('@viewport', { + browsers: browsers + }); + }); + + resolution = require('caniuse-db/features-json/css-media-resolution'); + + feature(resolution, { + match: /( x($| )|a #3)/ + }, function(browsers) { + return prefix('@resolution', { + browsers: browsers + }); + }); + + feature(require('caniuse-db/features-json/css-text-align-last'), function(browsers) { + return prefix('text-align-last', { + browsers: browsers + }); + }); + + crispedges = require('caniuse-db/features-json/css-crisp-edges'); + + feature(crispedges, { + match: /y x/ + }, function(browsers) { + return prefix('crisp-edges', { + props: ['image-rendering'], + browsers: browsers + }); + }); + + feature(crispedges, { + match: /a x/ + }, function(browsers) { + return prefix('image-rendering', { + browsers: browsers + }); + }); + + logicalProps = require('caniuse-db/features-json/css-logical-props'); + + feature(logicalProps, function(browsers) { + return prefix('border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', { + transition: true, + browsers: browsers + }); + }); + + feature(logicalProps, { + match: /x\s#2/ + }, function(browsers) { + return prefix('border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', { + transition: true, + browsers: browsers + }); + }); + }).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/at-rule.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/at-rule.js new file mode 100644 index 0000000..9b51076 --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/at-rule.js @@ -0,0 +1,51 @@ +(function() { + var AtRule, Prefixer, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Prefixer = require('./prefixer'); + + AtRule = (function(superClass) { + extend(AtRule, superClass); + + function AtRule() { + return AtRule.__super__.constructor.apply(this, arguments); + } + + AtRule.prototype.add = function(rule, prefix) { + var already, cloned, prefixed; + prefixed = prefix + rule.name; + already = rule.parent.some(function(i) { + return i.name === prefixed && i.params === rule.params; + }); + if (already) { + return; + } + cloned = this.clone(rule, { + name: prefixed + }); + return rule.parent.insertBefore(rule, cloned); + }; + + AtRule.prototype.process = function(node) { + var j, len, parent, prefix, ref, results; + parent = this.parentPrefix(node); + ref = this.prefixes; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + prefix = ref[j]; + if (parent && parent !== prefix) { + continue; + } + results.push(this.add(node, prefix)); + } + return results; + }; + + return AtRule; + + })(Prefixer); + + module.exports = AtRule; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/autoprefixer.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/autoprefixer.js index 7d2da2d..1e41c04 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/autoprefixer.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/autoprefixer.js @@ -1,7 +1,9 @@ (function() { - var Autoprefixer, Browsers, Prefixes, autoprefixer, infoCache, isPlainObject, postcss, - __slice = [].slice, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + var Autoprefixer, Browsers, Prefixes, autoprefixer, browserslist, infoCache, isPlainObject, postcss, + slice = [].slice, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + browserslist = require('browserslist'); postcss = require('postcss'); @@ -17,7 +19,7 @@ autoprefixer = function() { var options, reqs; - reqs = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + reqs = 1 <= arguments.length ? slice.call(arguments, 0) : []; if (reqs.length === 1 && isPlainObject(reqs[0])) { options = reqs[0]; reqs = void 0; @@ -36,16 +38,16 @@ }; autoprefixer.data = { - browsers: require('../data/browsers'), + browsers: require('caniuse-db/data').agents, prefixes: require('../data/prefixes') }; Autoprefixer = (function() { - function Autoprefixer(data, reqs, options) { + function Autoprefixer(data, reqs1, options1) { this.data = data; - this.reqs = reqs; - this.options = options != null ? options : {}; - this.postcss = __bind(this.postcss, this); + this.reqs = reqs1; + this.options = options1 != null ? options1 : {}; + this.postcss = bind(this.postcss, this); } Autoprefixer.prototype.process = function(str, options) { @@ -81,10 +83,10 @@ })(); + autoprefixer.defaults = browserslist.defaults; + autoprefixer.loadDefault = function() { - return this.defaultCache || (this.defaultCache = autoprefixer({ - browsers: this["default"] - })); + return this.defaultCache || (this.defaultCache = autoprefixer()); }; autoprefixer.process = function(str, options) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/browsers.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/browsers.js index 1971ce1..45906b7 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/browsers.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/browsers.js @@ -11,15 +11,15 @@ if (this.prefixesCache) { return this.prefixesCache; } - data = require('../data/browsers'); + data = require('caniuse-db/data').agents; return this.prefixesCache = utils.uniq((function() { - var _results; - _results = []; + var results; + results = []; for (name in data) { i = data[name]; - _results.push(i.prefix); + results.push("-" + i.prefix + "-"); } - return _results; + return results; })()).sort(function(a, b) { return b.length - a.length; }); @@ -32,27 +32,27 @@ return this.prefixesRegexp.test(value); }; - function Browsers(data, requirements, options) { - this.data = data; + function Browsers(data1, requirements, options) { + this.data = data1; this.options = options; this.selected = this.parse(requirements); } Browsers.prototype.parse = function(requirements) { - var _ref; + var ref; return browserslist(requirements, { - path: (_ref = this.options) != null ? _ref.from : void 0 + path: (ref = this.options) != null ? ref.from : void 0 }); }; Browsers.prototype.browsers = function(criteria) { - var browser, data, selected, versions, _ref; + var browser, data, ref, selected, versions; selected = []; - _ref = this.data; - for (browser in _ref) { - data = _ref[browser]; + ref = this.data; + for (browser in ref) { + data = ref[browser]; versions = criteria(data).map(function(version) { - return "" + browser + " " + version; + return browser + " " + version; }); selected = selected.concat(versions); } @@ -60,31 +60,20 @@ }; Browsers.prototype.prefix = function(browser) { - var name, version, _ref; - _ref = browser.split(' '), name = _ref[0], version = _ref[1]; - if (name === 'opera' && parseFloat(version) >= 15) { - return '-webkit-'; - } else { - return this.data[name].prefix; + var data, name, prefix, ref, version; + ref = browser.split(' '), name = ref[0], version = ref[1]; + data = this.data[name]; + if (data.prefix_exceptions) { + prefix = data.prefix_exceptions[version]; } + prefix || (prefix = data.prefix); + return '-' + prefix + '-'; }; Browsers.prototype.isSelected = function(browser) { return this.selected.indexOf(browser) !== -1; }; - Browsers.prototype.byName = function(name) { - var data; - name = name.toLowerCase(); - name = this.aliases[name] || name; - data = this.data[name]; - if (!data) { - utils.error("Unknown browser " + browser); - } - data.name = name; - return data; - }; - return Browsers; })(); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/declaration.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/declaration.js index a8a0214..91b411d 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/declaration.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/declaration.js @@ -1,7 +1,7 @@ (function() { var Browsers, Declaration, Prefixer, utils, vendor, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Prefixer = require('./prefixer'); @@ -11,8 +11,8 @@ utils = require('./utils'); - Declaration = (function(_super) { - __extends(Declaration, _super); + Declaration = (function(superClass) { + extend(Declaration, superClass); function Declaration() { return Declaration.__super__.constructor.apply(this, arguments); @@ -31,10 +31,10 @@ }; Declaration.prototype.otherPrefixes = function(value, prefix) { - var other, _i, _len, _ref; - _ref = Browsers.prefixes(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - other = _ref[_i]; + var j, len, other, ref; + ref = Browsers.prefixes(); + for (j = 0, len = ref.length; j < len; j++) { + other = ref[j]; if (other === prefix) { continue; } @@ -55,13 +55,13 @@ }; Declaration.prototype.maxPrefixed = function(prefixes, decl) { - var max, prefix, _i, _len; + var j, len, max, prefix; if (decl._autoprefixerMax) { return decl._autoprefixerMax; } max = 0; - for (_i = 0, _len = prefixes.length; _i < _len; _i++) { - prefix = prefixes[_i]; + for (j = 0, len = prefixes.length; j < len; j++) { + prefix = prefixes[j]; prefix = utils.removeNote(prefix); if (prefix.length > max) { max = prefix.length; @@ -71,14 +71,14 @@ }; Declaration.prototype.calcBefore = function(prefixes, decl, prefix) { - var before, diff, i, max, _i; + var before, diff, i, j, max, ref; if (prefix == null) { prefix = ''; } before = decl.style('before'); max = this.maxPrefixed(prefixes, decl); diff = max - utils.removeNote(prefix).length; - for (i = _i = 0; 0 <= diff ? _i < diff : _i > diff; i = 0 <= diff ? ++_i : --_i) { + for (i = j = 0, ref = diff; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { before += ' '; } return before; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-content.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-content.js index 7488537..627c91e 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-content.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-content.js @@ -1,14 +1,14 @@ (function() { var AlignContent, Declaration, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - AlignContent = (function(_super) { - __extends(AlignContent, _super); + AlignContent = (function(superClass) { + extend(AlignContent, superClass); function AlignContent() { return AlignContent.__super__.constructor.apply(this, arguments); @@ -24,8 +24,8 @@ }; AlignContent.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012) { return prefix + 'flex-line-pack'; } else { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-items.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-items.js index 71144d5..cae3ef1 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-items.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-items.js @@ -1,14 +1,14 @@ (function() { var AlignItems, Declaration, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - AlignItems = (function(_super) { - __extends(AlignItems, _super); + AlignItems = (function(superClass) { + extend(AlignItems, superClass); function AlignItems() { return AlignItems.__super__.constructor.apply(this, arguments); @@ -22,8 +22,8 @@ }; AlignItems.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return prefix + 'box-align'; } else if (spec === 2012) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-self.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-self.js index fa7e81c..7103cf7 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-self.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/align-self.js @@ -1,14 +1,14 @@ (function() { var AlignSelf, Declaration, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - AlignSelf = (function(_super) { - __extends(AlignSelf, _super); + AlignSelf = (function(superClass) { + extend(AlignSelf, superClass); function AlignSelf() { return AlignSelf.__super__.constructor.apply(this, arguments); @@ -22,8 +22,8 @@ }; AlignSelf.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012) { return prefix + 'flex-item-align'; } else { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/background-size.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/background-size.js index 6ea1595..6109b0a 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/background-size.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/background-size.js @@ -1,12 +1,12 @@ (function() { var BackgroundSize, Declaration, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - BackgroundSize = (function(_super) { - __extends(BackgroundSize, _super); + BackgroundSize = (function(superClass) { + extend(BackgroundSize, superClass); function BackgroundSize() { return BackgroundSize.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/block-logical.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/block-logical.js new file mode 100644 index 0000000..261cab2 --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/block-logical.js @@ -0,0 +1,35 @@ +(function() { + var BlockLogical, Declaration, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Declaration = require('../declaration'); + + BlockLogical = (function(superClass) { + extend(BlockLogical, superClass); + + function BlockLogical() { + return BlockLogical.__super__.constructor.apply(this, arguments); + } + + BlockLogical.names = ['border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', 'border-before', 'border-after', 'margin-before', 'margin-after', 'padding-before', 'padding-after']; + + BlockLogical.prototype.prefixed = function(prop, prefix) { + return prefix + (prop.indexOf('-start') !== -1 ? prop.replace('-block-start', '-before') : prop.replace('-block-end', '-after')); + }; + + BlockLogical.prototype.normalize = function(prop) { + if (prop.indexOf('-before') !== -1) { + return prop.replace('-before', '-block-start'); + } else { + return prop.replace('-after', '-block-end'); + } + }; + + return BlockLogical; + + })(Declaration); + + module.exports = BlockLogical; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-image.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-image.js index 95b430f..a08f36b 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-image.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-image.js @@ -1,12 +1,12 @@ (function() { var BorderImage, Declaration, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - BorderImage = (function(_super) { - __extends(BorderImage, _super); + BorderImage = (function(superClass) { + extend(BorderImage, superClass); function BorderImage() { return BorderImage.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-radius.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-radius.js index 97bcfa3..71452e3 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-radius.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/border-radius.js @@ -1,14 +1,14 @@ (function() { var BorderRadius, Declaration, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - BorderRadius = (function(_super) { - var hor, mozilla, normal, ver, _i, _j, _len, _len1, _ref, _ref1; + BorderRadius = (function(superClass) { + var hor, i, j, len, len1, mozilla, normal, ref, ref1, ver; - __extends(BorderRadius, _super); + extend(BorderRadius, superClass); function BorderRadius() { return BorderRadius.__super__.constructor.apply(this, arguments); @@ -20,12 +20,12 @@ BorderRadius.toNormal = {}; - _ref = ['top', 'bottom']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - ver = _ref[_i]; - _ref1 = ['left', 'right']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - hor = _ref1[_j]; + ref = ['top', 'bottom']; + for (i = 0, len = ref.length; i < len; i++) { + ver = ref[i]; + ref1 = ['left', 'right']; + for (j = 0, len1 = ref1.length; j < len1; j++) { + hor = ref1[j]; normal = "border-" + ver + "-" + hor + "-radius"; mozilla = "border-radius-" + ver + hor; BorderRadius.names.push(normal); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/break-inside.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/break-inside.js index baeafaf..2122aac 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/break-inside.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/break-inside.js @@ -1,12 +1,12 @@ (function() { var BreakInside, Declaration, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - BreakInside = (function(_super) { - __extends(BreakInside, _super); + BreakInside = (function(superClass) { + extend(BreakInside, superClass); function BreakInside() { return BreakInside.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/crisp-edges.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/crisp-edges.js new file mode 100644 index 0000000..bb04dc0 --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/crisp-edges.js @@ -0,0 +1,31 @@ +(function() { + var CrispEdges, Value, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Value = require('../value'); + + CrispEdges = (function(superClass) { + extend(CrispEdges, superClass); + + function CrispEdges() { + return CrispEdges.__super__.constructor.apply(this, arguments); + } + + CrispEdges.names = ['crisp-edges']; + + CrispEdges.prototype.replace = function(string, prefix) { + if (prefix === '-webkit-') { + return string.replace(this.regexp(), '$1-webkit-optimize-contrast'); + } else { + return CrispEdges.__super__.replace.apply(this, arguments); + } + }; + + return CrispEdges; + + })(Value); + + module.exports = CrispEdges; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/display-flex.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/display-flex.js index 39bf302..87a1455 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/display-flex.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/display-flex.js @@ -1,7 +1,7 @@ (function() { var DisplayFlex, OldDisplayFlex, OldValue, Value, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); @@ -9,11 +9,12 @@ Value = require('../value'); - OldDisplayFlex = (function(_super) { - __extends(OldDisplayFlex, _super); + OldDisplayFlex = (function(superClass) { + extend(OldDisplayFlex, superClass); - function OldDisplayFlex(name) { - this.name = name; + function OldDisplayFlex(unprefixed, prefixed1) { + this.unprefixed = unprefixed; + this.prefixed = prefixed1; } OldDisplayFlex.prototype.check = function(value) { @@ -24,8 +25,8 @@ })(OldValue); - DisplayFlex = (function(_super) { - __extends(DisplayFlex, _super); + DisplayFlex = (function(superClass) { + extend(DisplayFlex, superClass); DisplayFlex.names = ['display-flex', 'inline-flex']; @@ -41,8 +42,8 @@ }; DisplayFlex.prototype.prefixed = function(prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; return prefix + (spec === 2009 ? this.name === 'flex' ? 'box' : 'inline-box' : spec === 2012 ? this.name === 'flex' ? 'flexbox' : 'inline-flexbox' : spec === 'final' ? this.name : void 0); }; @@ -54,7 +55,7 @@ var prefixed; prefixed = this.prefixed(prefix); if (prefixed) { - return new OldValue(prefixed); + return new OldValue(this.name, prefixed); } }; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fill-available.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fill-available.js index f959465..f7d92c9 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fill-available.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fill-available.js @@ -1,14 +1,14 @@ (function() { var FillAvailable, OldValue, Value, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; OldValue = require('../old-value'); Value = require('../value'); - FillAvailable = (function(_super) { - __extends(FillAvailable, _super); + FillAvailable = (function(superClass) { + extend(FillAvailable, superClass); function FillAvailable() { return FillAvailable.__super__.constructor.apply(this, arguments); @@ -26,7 +26,7 @@ FillAvailable.prototype.old = function(prefix) { if (prefix === '-moz-') { - return new OldValue('-moz-available'); + return new OldValue(this.name, '-moz-available'); } else { return FillAvailable.__super__.old.apply(this, arguments); } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter-value.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter-value.js index 88d75f2..40c4b44 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter-value.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter-value.js @@ -1,12 +1,42 @@ (function() { - var FilterValue, Value, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + var FilterValue, OldFilterValue, OldValue, Value, utils, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + OldValue = require('../old-value'); Value = require('../value'); - FilterValue = (function(_super) { - __extends(FilterValue, _super); + utils = require('../utils'); + + OldFilterValue = (function(superClass) { + extend(OldFilterValue, superClass); + + function OldFilterValue() { + return OldFilterValue.__super__.constructor.apply(this, arguments); + } + + OldFilterValue.prototype.clean = function(decl) { + return decl.value = utils.editList(decl.value, (function(_this) { + return function(props) { + if (props.every(function(i) { + return i.indexOf(_this.unprefixed) !== 0; + })) { + return props; + } + return props.filter(function(i) { + return i.indexOf(_this.prefixed) === -1; + }); + }; + })(this)); + }; + + return OldFilterValue; + + })(OldValue); + + FilterValue = (function(superClass) { + extend(FilterValue, superClass); function FilterValue() { return FilterValue.__super__.constructor.apply(this, arguments); @@ -26,6 +56,10 @@ } }; + FilterValue.prototype.old = function(prefix) { + return new OldFilterValue(this.name, prefix + this.name); + }; + return FilterValue; })(Value); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter.js index e7be7e2..213cb13 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/filter.js @@ -1,12 +1,12 @@ (function() { var Declaration, Filter, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - Filter = (function(_super) { - __extends(Filter, _super); + Filter = (function(superClass) { + extend(Filter, superClass); function Filter() { return Filter.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-basis.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-basis.js index 1aaa3f4..62ec0f9 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-basis.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-basis.js @@ -1,14 +1,14 @@ (function() { var Declaration, FlexBasis, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - FlexBasis = (function(_super) { - __extends(FlexBasis, _super); + FlexBasis = (function(superClass) { + extend(FlexBasis, superClass); function FlexBasis() { return FlexBasis.__super__.constructor.apply(this, arguments); @@ -21,8 +21,8 @@ }; FlexBasis.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012) { return prefix + 'flex-preferred-size'; } else { @@ -31,8 +31,8 @@ }; FlexBasis.prototype.set = function(decl, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012 || spec === 'final') { return FlexBasis.__super__.set.apply(this, arguments); } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-direction.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-direction.js index bf2fd30..e0f3cfa 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-direction.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-direction.js @@ -1,14 +1,14 @@ (function() { var Declaration, FlexDirection, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - FlexDirection = (function(_super) { - __extends(FlexDirection, _super); + FlexDirection = (function(superClass) { + extend(FlexDirection, superClass); function FlexDirection() { return FlexDirection.__super__.constructor.apply(this, arguments); @@ -21,8 +21,8 @@ }; FlexDirection.prototype.insert = function(decl, prefix, prefixes) { - var already, cloned, dir, orient, spec, value, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var already, cloned, dir, orient, ref, spec, value; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { already = decl.parent.some(function(i) { return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction'; @@ -53,8 +53,8 @@ }; FlexDirection.prototype.old = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return [prefix + 'box-orient', prefix + 'box-direction']; } else { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-flow.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-flow.js index 011199b..a929cbe 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-flow.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-flow.js @@ -1,14 +1,14 @@ (function() { var Declaration, FlexFlow, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - FlexFlow = (function(_super) { - __extends(FlexFlow, _super); + FlexFlow = (function(superClass) { + extend(FlexFlow, superClass); function FlexFlow() { return FlexFlow.__super__.constructor.apply(this, arguments); @@ -17,8 +17,8 @@ FlexFlow.names = ['flex-flow']; FlexFlow.prototype.set = function(decl, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012) { return FlexFlow.__super__.set.apply(this, arguments); } else if (spec === 'final') { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-grow.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-grow.js index 7bbcada..5bd598f 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-grow.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-grow.js @@ -1,14 +1,14 @@ (function() { var Declaration, Flex, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - Flex = (function(_super) { - __extends(Flex, _super); + Flex = (function(superClass) { + extend(Flex, superClass); function Flex() { return Flex.__super__.constructor.apply(this, arguments); @@ -21,8 +21,8 @@ }; Flex.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return prefix + 'box-flex'; } else if (spec === 2012) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-shrink.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-shrink.js index 2b48910..66610d6 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-shrink.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-shrink.js @@ -1,14 +1,14 @@ (function() { var Declaration, FlexShrink, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - FlexShrink = (function(_super) { - __extends(FlexShrink, _super); + FlexShrink = (function(superClass) { + extend(FlexShrink, superClass); function FlexShrink() { return FlexShrink.__super__.constructor.apply(this, arguments); @@ -21,8 +21,8 @@ }; FlexShrink.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012) { return prefix + 'flex-negative'; } else { @@ -31,8 +31,8 @@ }; FlexShrink.prototype.set = function(decl, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2012 || spec === 'final') { return FlexShrink.__super__.set.apply(this, arguments); } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-values.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-values.js new file mode 100644 index 0000000..856c783 --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-values.js @@ -0,0 +1,37 @@ +(function() { + var FlexValues, OldValue, Value, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + OldValue = require('../old-value'); + + Value = require('../value'); + + FlexValues = (function(superClass) { + extend(FlexValues, superClass); + + function FlexValues() { + return FlexValues.__super__.constructor.apply(this, arguments); + } + + FlexValues.names = ['flex', 'flex-grow', 'flex-shrink', 'flex-basis']; + + FlexValues.prototype.prefixed = function(prefix) { + return this.all.prefixed(this.name, prefix); + }; + + FlexValues.prototype.replace = function(string, prefix) { + return string.replace(this.regexp(), '$1' + this.prefixed(prefix) + '$3'); + }; + + FlexValues.prototype.old = function(prefix) { + return new OldValue(this.name, this.prefixed(prefix)); + }; + + return FlexValues; + + })(Value); + + module.exports = FlexValues; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-wrap.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-wrap.js index f7ffddc..6d13542 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-wrap.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex-wrap.js @@ -1,14 +1,14 @@ (function() { var Declaration, FlexWrap, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - FlexWrap = (function(_super) { - __extends(FlexWrap, _super); + FlexWrap = (function(superClass) { + extend(FlexWrap, superClass); function FlexWrap() { return FlexWrap.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex.js index 8d63426..baee68a 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/flex.js @@ -1,14 +1,16 @@ (function() { - var Declaration, Flex, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + var Declaration, Flex, flexSpec, list, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - Flex = (function(_super) { - __extends(Flex, _super); + list = require('postcss/lib/list'); + + Flex = (function(superClass) { + extend(Flex, superClass); function Flex() { return Flex.__super__.constructor.apply(this, arguments); @@ -22,8 +24,8 @@ }; Flex.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return prefix + 'box-flex'; } else { @@ -39,7 +41,7 @@ var spec; spec = flexSpec(prefix)[0]; if (spec === 2009) { - decl.value = decl.value.split(' ')[0]; + decl.value = list.space(decl.value)[0]; decl.value = Flex.oldValues[decl.value] || decl.value; return Flex.__super__.set.call(this, decl, prefix); } else { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fullscreen.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fullscreen.js index f8a601f..d7a3ccd 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fullscreen.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/fullscreen.js @@ -1,12 +1,12 @@ (function() { var Fullscreen, Selector, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Selector = require('../selector'); - Fullscreen = (function(_super) { - __extends(Fullscreen, _super); + Fullscreen = (function(superClass) { + extend(Fullscreen, superClass); function Fullscreen() { return Fullscreen.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/gradient.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/gradient.js index a7ae243..6989536 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/gradient.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/gradient.js @@ -1,7 +1,7 @@ (function() { var Gradient, OldValue, Value, isDirection, list, utils, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; OldValue = require('../old-value'); @@ -13,8 +13,8 @@ isDirection = /top|left|right|bottom/gi; - Gradient = (function(_super) { - __extends(Gradient, _super); + Gradient = (function(superClass) { + extend(Gradient, superClass); function Gradient() { return Gradient.__super__.constructor.apply(this, arguments); @@ -74,13 +74,13 @@ if (first.indexOf('to ') === -1 && isDirection.test(first)) { first = first.split(' '); first = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = first.length; _i < _len; _i++) { - value = first[_i]; - _results.push(this.directions[value.toLowerCase()] || value); + var j, len, results; + results = []; + for (j = 0, len = first.length; j < len; j++) { + value = first[j]; + results.push(this.directions[value.toLowerCase()] || value); } - return _results; + return results; }).call(this); params[0] = 'to ' + first.join(' '); } @@ -122,13 +122,13 @@ param = param.split(' '); param.splice(0, 1); param = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = param.length; _i < _len; _i++) { - value = param[_i]; - _results.push(this.directions[value.toLowerCase()] || value); + var j, len, results; + results = []; + for (j = 0, len = param.length; j < len; j++) { + value = param[j]; + results.push(this.directions[value.toLowerCase()] || value); } - return _results; + return results; }).call(this); return param.join(' '); }; @@ -141,7 +141,7 @@ param = parseFloat(param); param = Math.abs(450 - param) % 360; param = this.roundFloat(param, 3); - return "" + param + "deg"; + return param + "deg"; }; Gradient.prototype.oldDirection = function(params) { @@ -162,11 +162,11 @@ Gradient.prototype.colorStops = function(params) { return params.map(function(param, i) { - var color, match, position, _ref; + var color, match, position, ref; if (i === 0) { return param; } - _ref = list.space(param), color = _ref[0], position = _ref[1]; + ref = list.space(param), color = ref[0], position = ref[1]; if (position == null) { match = param.match(/^(.*\))(\d.*)$/); if (match) { @@ -202,7 +202,7 @@ type = this.name === 'linear-gradient' ? 'linear' : 'radial'; string = '-gradient'; regexp = utils.regexp("-webkit-(" + type + "-gradient|gradient\\(\\s*" + type + ")", false); - return new OldValue(prefix + this.name, string, regexp); + return new OldValue(this.name, prefix + this.name, string, regexp); } else { return Gradient.__super__.old.apply(this, arguments); } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/image-rendering.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/image-rendering.js new file mode 100644 index 0000000..b1ccd9a --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/image-rendering.js @@ -0,0 +1,49 @@ +(function() { + var Declaration, ImageRendering, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Declaration = require('../declaration'); + + ImageRendering = (function(superClass) { + extend(ImageRendering, superClass); + + function ImageRendering() { + return ImageRendering.__super__.constructor.apply(this, arguments); + } + + ImageRendering.names = ['image-rendering', 'interpolation-mode']; + + ImageRendering.prototype.check = function(decl) { + return decl.value === 'crisp-edges'; + }; + + ImageRendering.prototype.prefixed = function(prop, prefix) { + if (prefix === '-ms-') { + return '-ms-interpolation-mode'; + } else { + return ImageRendering.__super__.prefixed.apply(this, arguments); + } + }; + + ImageRendering.prototype.set = function(decl, prefix) { + if (prefix === '-ms-') { + decl.prop = '-ms-interpolation-mode'; + decl.value = 'nearest-neighbor'; + return decl; + } else { + return ImageRendering.__super__.set.apply(this, arguments); + } + }; + + ImageRendering.prototype.normalize = function(prop) { + return 'image-rendering'; + }; + + return ImageRendering; + + })(Declaration); + + module.exports = ImageRendering; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/inline-logical.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/inline-logical.js new file mode 100644 index 0000000..7a698fe --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/inline-logical.js @@ -0,0 +1,31 @@ +(function() { + var Declaration, InlineLogical, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Declaration = require('../declaration'); + + InlineLogical = (function(superClass) { + extend(InlineLogical, superClass); + + function InlineLogical() { + return InlineLogical.__super__.constructor.apply(this, arguments); + } + + InlineLogical.names = ['border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', 'border-start', 'border-end', 'margin-start', 'margin-end', 'padding-start', 'padding-end']; + + InlineLogical.prototype.prefixed = function(prop, prefix) { + return prefix + prop.replace('-inline', ''); + }; + + InlineLogical.prototype.normalize = function(prop) { + return prop.replace(/(margin|padding|border)-(start|end)/, '$1-inline-$2'); + }; + + return InlineLogical; + + })(Declaration); + + module.exports = InlineLogical; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/justify-content.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/justify-content.js index 1a7554b..eed29eb 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/justify-content.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/justify-content.js @@ -1,14 +1,14 @@ (function() { var Declaration, JustifyContent, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - JustifyContent = (function(_super) { - __extends(JustifyContent, _super); + JustifyContent = (function(superClass) { + extend(JustifyContent, superClass); function JustifyContent() { return JustifyContent.__super__.constructor.apply(this, arguments); @@ -24,8 +24,8 @@ }; JustifyContent.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return prefix + 'box-pack'; } else if (spec === 2012) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/order.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/order.js index 4a1c619..592b064 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/order.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/order.js @@ -1,14 +1,14 @@ (function() { var Declaration, Order, flexSpec, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; flexSpec = require('./flex-spec'); Declaration = require('../declaration'); - Order = (function(_super) { - __extends(Order, _super); + Order = (function(superClass) { + extend(Order, superClass); function Order() { return Order.__super__.constructor.apply(this, arguments); @@ -17,8 +17,8 @@ Order.names = ['order', 'flex-order', 'box-ordinal-group']; Order.prototype.prefixed = function(prop, prefix) { - var spec, _ref; - _ref = flexSpec(prefix), spec = _ref[0], prefix = _ref[1]; + var ref, spec; + ref = flexSpec(prefix), spec = ref[0], prefix = ref[1]; if (spec === 2009) { return prefix + 'box-ordinal-group'; } else if (spec === 2012) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/placeholder.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/placeholder.js index 16b9f3b..423d202 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/placeholder.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/placeholder.js @@ -1,18 +1,18 @@ (function() { var Placeholder, Selector, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Selector = require('../selector'); - Placeholder = (function(_super) { - __extends(Placeholder, _super); + Placeholder = (function(superClass) { + extend(Placeholder, superClass); function Placeholder() { return Placeholder.__super__.constructor.apply(this, arguments); } - Placeholder.names = ['::placeholder']; + Placeholder.names = [':placeholder-shown', '::placeholder']; Placeholder.prototype.possible = function() { return Placeholder.__super__.possible.apply(this, arguments).concat('-moz- old'); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-decl.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-decl.js index 1d5e09f..295a6ec 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-decl.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-decl.js @@ -1,12 +1,12 @@ (function() { var Declaration, TransformDecl, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Declaration = require('../declaration'); - TransformDecl = (function(_super) { - __extends(TransformDecl, _super); + TransformDecl = (function(superClass) { + extend(TransformDecl, superClass); function TransformDecl() { return TransformDecl.__super__.constructor.apply(this, arguments); @@ -29,14 +29,14 @@ }; TransformDecl.prototype.contain3d = function(decl) { - var func, _i, _len, _ref; + var func, i, len, ref; if (decl.prop === 'transform-origin') { return false; } - _ref = TransformDecl.functions3d; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - func = _ref[_i]; - if (decl.value.indexOf("" + func + "(") !== -1) { + ref = TransformDecl.functions3d; + for (i = 0, len = ref.length; i < len; i++) { + func = ref[i]; + if (decl.value.indexOf(func + "(") !== -1) { return true; } } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-value.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-value.js index 5242f9d..8f74d65 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-value.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transform-value.js @@ -1,12 +1,12 @@ (function() { var TransformValue, Value, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Value = require('../value'); - TransformValue = (function(_super) { - __extends(TransformValue, _super); + TransformValue = (function(superClass) { + extend(TransformValue, superClass); function TransformValue() { return TransformValue.__super__.constructor.apply(this, arguments); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transition.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transition.js deleted file mode 100644 index 70306f3..0000000 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/hacks/transition.js +++ /dev/null @@ -1,37 +0,0 @@ -(function() { - var OldValue, Transition, Value, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - OldValue = require('../old-value'); - - Value = require('../value'); - - Transition = (function(_super) { - __extends(Transition, _super); - - function Transition() { - return Transition.__super__.constructor.apply(this, arguments); - } - - Transition.names = ['flex', 'flex-grow', 'flex-shrink', 'flex-basis']; - - Transition.prototype.prefixed = function(prefix) { - return this.all.prefixed(this.name, prefix); - }; - - Transition.prototype.replace = function(string, prefix) { - return string.replace(this.regexp(), '$1' + this.prefixed(prefix) + '$3'); - }; - - Transition.prototype.old = function(prefix) { - return new OldValue(this.prefixed(prefix)); - }; - - return Transition; - - })(Value); - - module.exports = Transition; - -}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/info.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/info.js index ee4af61..b6bb1a3 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/info.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/info.js @@ -27,15 +27,15 @@ }; module.exports = function(prefixes) { - var atrules, browser, data, list, name, needTransition, out, props, selector, selectors, string, transitionProp, useTransition, value, values, version, versions, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; + var atrules, browser, data, j, k, l, len, len1, len2, list, name, needTransition, out, props, ref, ref1, ref2, ref3, ref4, ref5, ref6, selector, selectors, string, transitionProp, useTransition, value, values, version, versions; if (prefixes.browsers.selected.length === 0) { return "No browsers selected"; } versions = []; - _ref = prefixes.browsers.selected; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - browser = _ref[_i]; - _ref1 = browser.split(' '), name = _ref1[0], version = _ref1[1]; + ref = prefixes.browsers.selected; + for (j = 0, len = ref.length; j < len; j++) { + browser = ref[j]; + ref1 = browser.split(' '), name = ref1[0], version = ref1[1]; name = names[name] || capitalize(name); if (versions[name]) { versions[name].push(version); @@ -52,9 +52,9 @@ out += ' ' + browser + ': ' + list.join(', ') + "\n"; } atrules = ''; - _ref2 = prefixes.add; - for (name in _ref2) { - data = _ref2[name]; + ref2 = prefixes.add; + for (name in ref2) { + data = ref2[name]; if (name[0] === '@' && data.prefixes) { atrules += prefix(name, false, data.prefixes); } @@ -63,9 +63,9 @@ out += "\nAt-Rules:\n" + atrules; } selectors = ''; - _ref3 = prefixes.add.selectors; - for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { - selector = _ref3[_j]; + ref3 = prefixes.add.selectors; + for (k = 0, len1 = ref3.length; k < len1; k++) { + selector = ref3[k]; if (selector.prefixes) { selectors += prefix(selector.name, false, selector.prefixes); } @@ -76,10 +76,10 @@ values = ''; props = ''; useTransition = false; - needTransition = (_ref4 = prefixes.add.transition) != null ? _ref4.prefixes : void 0; - _ref5 = prefixes.add; - for (name in _ref5) { - data = _ref5[name]; + needTransition = (ref4 = prefixes.add.transition) != null ? ref4.prefixes : void 0; + ref5 = prefixes.add; + for (name in ref5) { + data = ref5[name]; if (name[0] !== '@' && data.prefixes) { transitionProp = needTransition && prefixes.data[name].transition; if (transitionProp) { @@ -95,9 +95,9 @@ })) { continue; } - _ref6 = data.values; - for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { - value = _ref6[_k]; + ref6 = data.values; + for (l = 0, len2 = ref6.length; l < len2; l++) { + value = ref6[l]; string = prefix(value.name, false, value.prefixes); if (values.indexOf(string) === -1) { values += string; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/keyframes.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/keyframes.js deleted file mode 100644 index 28f75be..0000000 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/keyframes.js +++ /dev/null @@ -1,51 +0,0 @@ -(function() { - var Keyframes, Prefixer, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - - Prefixer = require('./prefixer'); - - Keyframes = (function(_super) { - __extends(Keyframes, _super); - - function Keyframes() { - return Keyframes.__super__.constructor.apply(this, arguments); - } - - Keyframes.prototype.add = function(atRule, prefix) { - var already, cloned, prefixed; - prefixed = prefix + atRule.name; - already = atRule.parent.some(function(i) { - return i.name === prefixed && i.params === atRule.params; - }); - if (already) { - return; - } - cloned = this.clone(atRule, { - name: prefixed - }); - return atRule.parent.insertBefore(atRule, cloned); - }; - - Keyframes.prototype.process = function(node) { - var parent, prefix, _i, _len, _ref, _results; - parent = this.parentPrefix(node); - _ref = this.prefixes; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - prefix = _ref[_i]; - if (parent && parent !== prefix) { - continue; - } - _results.push(this.add(node, prefix)); - } - return _results; - }; - - return Keyframes; - - })(Prefixer); - - module.exports = Keyframes; - -}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-selector.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-selector.js index 1b3e18c..732d9dc 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-selector.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-selector.js @@ -2,15 +2,15 @@ var OldSelector; OldSelector = (function() { - function OldSelector(selector, prefix) { - var _i, _len, _ref; - this.prefix = prefix; + function OldSelector(selector, prefix1) { + var i, len, prefix, ref; + this.prefix = prefix1; this.prefixed = selector.prefixed(this.prefix); this.regexp = selector.regexp(this.prefix); this.prefixeds = []; - _ref = selector.possible(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - prefix = _ref[_i]; + ref = selector.possible(); + for (i = 0, len = ref.length; i < len; i++) { + prefix = ref[i]; this.prefixeds.push([selector.prefixed(prefix), selector.regexp(prefix)]); } this.unprefixed = selector.name; @@ -18,7 +18,7 @@ } OldSelector.prototype.isHack = function(rule) { - var before, index, regexp, rules, some, string, _i, _len, _ref, _ref1; + var before, i, index, len, ref, ref1, regexp, rules, some, string; index = rule.parent.index(rule) + 1; rules = rule.parent.nodes; while (index < rules.length) { @@ -30,9 +30,9 @@ return false; } some = false; - _ref = this.prefixeds; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - _ref1 = _ref[_i], string = _ref1[0], regexp = _ref1[1]; + ref = this.prefixeds; + for (i = 0, len = ref.length; i < len; i++) { + ref1 = ref[i], string = ref1[0], regexp = ref1[1]; if (before.indexOf(string) !== -1 && before.match(regexp)) { some = true; break; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-value.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-value.js index 38819e2..58651e6 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-value.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/old-value.js @@ -4,12 +4,13 @@ utils = require('./utils'); OldValue = (function() { - function OldValue(name, string, regexp) { - this.name = name; + function OldValue(unprefixed, prefixed, string, regexp) { + this.unprefixed = unprefixed; + this.prefixed = prefixed; this.string = string; this.regexp = regexp; - this.regexp || (this.regexp = utils.regexp(this.name)); - this.string || (this.string = this.name); + this.regexp || (this.regexp = utils.regexp(this.prefixed)); + this.string || (this.string = this.prefixed); } OldValue.prototype.check = function(value) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixer.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixer.js index 0ef08f8..b8966ca 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixer.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixer.js @@ -1,28 +1,55 @@ (function() { - var Browsers, Prefixer, utils, vendor; + var Browsers, Prefixer, clone, utils, vendor, + hasProp = {}.hasOwnProperty; Browsers = require('./browsers'); + utils = require('./utils'); + vendor = require('postcss/lib/vendor'); - utils = require('./utils'); + clone = function(obj, parent) { + var cloned, i, value; + if (typeof obj !== 'object') { + return obj; + } + cloned = new obj.constructor(); + for (i in obj) { + if (!hasProp.call(obj, i)) continue; + value = obj[i]; + if (i === 'parent' && typeof value === 'object') { + if (parent) { + cloned[i] = parent; + } + } else if (i === 'source') { + cloned[i] = value; + } else if (value instanceof Array) { + cloned[i] = value.map(function(i) { + return clone(i, cloned); + }); + } else if (i !== '_autoprefixerPrefix' && i !== '_autoprefixerValues') { + cloned[i] = clone(value, cloned); + } + } + return cloned; + }; Prefixer = (function() { Prefixer.hack = function(klass) { - var name, _i, _len, _ref, _results; + var j, len, name, ref, results; this.hacks || (this.hacks = {}); - _ref = klass.names; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; - _results.push(this.hacks[name] = klass); + ref = klass.names; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + name = ref[j]; + results.push(this.hacks[name] = klass); } - return _results; + return results; }; Prefixer.load = function(name, prefixes, all) { - var klass, _ref; - klass = (_ref = this.hacks) != null ? _ref[name] : void 0; + var klass, ref; + klass = (ref = this.hacks) != null ? ref[name] : void 0; if (klass) { return new klass(name, prefixes, all); } else { @@ -31,21 +58,18 @@ }; Prefixer.clone = function(node, overrides) { - var cloned; - cloned = node.clone(overrides); - if (node.type === 'decl') { - cloned.between = node.between; - cloned.before = node.before; + var cloned, name; + cloned = clone(node); + for (name in overrides) { + cloned[name] = overrides[name]; } - delete cloned._autoprefixerPrefix; - delete cloned._autoprefixerValues; return cloned; }; - function Prefixer(name, prefixes, all) { - this.name = name; - this.prefixes = prefixes; - this.all = all; + function Prefixer(name1, prefixes1, all1) { + this.name = name1; + this.prefixes = prefixes1; + this.all = all1; } Prefixer.prototype.parentPrefix = function(node) { @@ -58,23 +82,23 @@ }; Prefixer.prototype.process = function(node) { - var added, parent, prefix, prefixes, _i, _j, _len, _len1, _ref; + var added, j, k, len, len1, parent, prefix, prefixes, ref; if (!this.check(node)) { return; } parent = this.parentPrefix(node); prefixes = []; - _ref = this.prefixes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - prefix = _ref[_i]; + ref = this.prefixes; + for (j = 0, len = ref.length; j < len; j++) { + prefix = ref[j]; if (parent && parent !== utils.removeNote(prefix)) { continue; } prefixes.push(prefix); } added = []; - for (_j = 0, _len1 = prefixes.length; _j < _len1; _j++) { - prefix = prefixes[_j]; + for (k = 0, len1 = prefixes.length; k < len1; k++) { + prefix = prefixes[k]; if (this.add(node, prefix, added.concat([prefix]))) { added.push(prefix); } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixes.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixes.js index 5eff191..e55d852 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixes.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/prefixes.js @@ -1,15 +1,11 @@ (function() { - var Browsers, Declaration, Keyframes, Prefixes, Processor, Selector, Supports, Value, declsCache, utils, vendor; - - utils = require('./utils'); - - vendor = require('postcss/lib/vendor'); + var AtRule, Browsers, Declaration, Prefixes, Processor, Resolution, Selector, Supports, Value, declsCache, utils, vendor; Declaration = require('./declaration'); - Processor = require('./processor'); + Resolution = require('./resolution'); - Keyframes = require('./keyframes'); + Processor = require('./processor'); Supports = require('./supports'); @@ -17,8 +13,14 @@ Selector = require('./selector'); + AtRule = require('./at-rule'); + Value = require('./value'); + utils = require('./utils'); + + vendor = require('postcss/lib/vendor'); + Selector.hack(require('./hacks/fullscreen')); Selector.hack(require('./hacks/placeholder')); @@ -51,17 +53,25 @@ Declaration.hack(require('./hacks/border-radius')); + Declaration.hack(require('./hacks/block-logical')); + + Declaration.hack(require('./hacks/inline-logical')); + Declaration.hack(require('./hacks/transform-decl')); Declaration.hack(require('./hacks/flex-direction')); + Declaration.hack(require('./hacks/image-rendering')); + Declaration.hack(require('./hacks/justify-content')); Declaration.hack(require('./hacks/background-size')); Value.hack(require('./hacks/gradient')); - Value.hack(require('./hacks/transition')); + Value.hack(require('./hacks/crisp-edges')); + + Value.hack(require('./hacks/flex-values')); Value.hack(require('./hacks/display-flex')); @@ -74,12 +84,12 @@ declsCache = {}; Prefixes = (function() { - function Prefixes(data, browsers, options) { - var _ref; - this.data = data; + function Prefixes(data1, browsers, options) { + var ref; + this.data = data1; this.browsers = browsers; this.options = options != null ? options : {}; - _ref = this.preprocess(this.select(this.data)), this.add = _ref[0], this.remove = _ref[1]; + ref = this.preprocess(this.select(this.data)), this.add = ref[0], this.remove = ref[1]; this.processor = new Processor(this); } @@ -176,24 +186,26 @@ }; Prefixes.prototype.preprocess = function(selected) { - var add, name, old, olds, prefix, prefixed, prefixes, prop, props, remove, selector, value, values, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _len6, _m, _n, _o, _ref, _ref1, _ref2; + var add, j, k, l, len, len1, len2, len3, len4, len5, len6, m, n, name, o, old, olds, p, prefix, prefixed, prefixes, prop, props, ref, ref1, ref2, remove, selector, value, values; add = { selectors: [], '@supports': new Supports(this) }; - _ref = selected.add; - for (name in _ref) { - prefixes = _ref[name]; - if (name === '@keyframes') { - add[name] = new Keyframes(name, prefixes, this); + ref = selected.add; + for (name in ref) { + prefixes = ref[name]; + if (name === '@keyframes' || name === '@viewport') { + add[name] = new AtRule(name, prefixes, this); + } else if (name === '@resolution') { + add[name] = new Resolution(name, prefixes, this); } else if (this.data[name].selector) { add.selectors.push(Selector.load(name, prefixes, this)); } else { props = this.data[name].transition ? this.transitionProps : this.data[name].props; if (props) { value = Value.load(name, prefixes, this); - for (_i = 0, _len = props.length; _i < _len; _i++) { - prop = props[_i]; + for (j = 0, len = props.length; j < len; j++) { + prop = props[j]; if (!add[prop]) { add[prop] = { values: [] @@ -203,7 +215,7 @@ } } if (!this.data[name].props) { - values = ((_ref1 = add[name]) != null ? _ref1.values : void 0) || []; + values = ((ref1 = add[name]) != null ? ref1.values : void 0) || []; add[name] = Declaration.load(name, prefixes, this); add[name].values = values; } @@ -212,33 +224,35 @@ remove = { selectors: [] }; - _ref2 = selected.remove; - for (name in _ref2) { - prefixes = _ref2[name]; + ref2 = selected.remove; + for (name in ref2) { + prefixes = ref2[name]; if (this.data[name].selector) { selector = Selector.load(name, prefixes); - for (_j = 0, _len1 = prefixes.length; _j < _len1; _j++) { - prefix = prefixes[_j]; + for (k = 0, len1 = prefixes.length; k < len1; k++) { + prefix = prefixes[k]; remove.selectors.push(selector.old(prefix)); } - } else if (name[0] === '@') { - for (_k = 0, _len2 = prefixes.length; _k < _len2; _k++) { - prefix = prefixes[_k]; + } else if (name === '@keyframes' || name === '@viewport') { + for (l = 0, len2 = prefixes.length; l < len2; l++) { + prefix = prefixes[l]; prefixed = '@' + prefix + name.slice(1); remove[prefixed] = { remove: true }; } + } else if (name === '@resolution') { + remove[name] = new Resolution(name, prefixes, this); } else { props = this.data[name].transition ? this.transitionProps : this.data[name].props; if (props) { value = Value.load(name, [], this); - for (_l = 0, _len3 = prefixes.length; _l < _len3; _l++) { - prefix = prefixes[_l]; + for (m = 0, len3 = prefixes.length; m < len3; m++) { + prefix = prefixes[m]; old = value.old(prefix); if (old) { - for (_m = 0, _len4 = props.length; _m < _len4; _m++) { - prop = props[_m]; + for (n = 0, len4 = props.length; n < len4; n++) { + prop = props[n]; if (!remove[prop]) { remove[prop] = {}; } @@ -251,12 +265,12 @@ } } if (!this.data[name].props) { - for (_n = 0, _len5 = prefixes.length; _n < _len5; _n++) { - prefix = prefixes[_n]; + for (o = 0, len5 = prefixes.length; o < len5; o++) { + prefix = prefixes[o]; prop = vendor.unprefixed(name); olds = this.decl(name).old(name, prefix); - for (_o = 0, _len6 = olds.length; _o < _len6; _o++) { - prefixed = olds[_o]; + for (p = 0, len6 = olds.length; p < len6; p++) { + prefixed = olds[p]; if (!remove[prefixed]) { remove[prefixed] = {}; } @@ -290,10 +304,10 @@ }; Prefixes.prototype.values = function(type, prop) { - var data, global, values, _ref, _ref1; + var data, global, ref, ref1, values; data = this[type]; - global = (_ref = data['*']) != null ? _ref.values : void 0; - values = (_ref1 = data[prop]) != null ? _ref1.values : void 0; + global = (ref = data['*']) != null ? ref.values : void 0; + values = (ref1 = data[prop]) != null ? ref1.values : void 0; if (global && values) { return utils.uniq(global.concat(values)); } else { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/processor.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/processor.js index f383b22..6f27b49 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/processor.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/processor.js @@ -13,8 +13,10 @@ } Processor.prototype.add = function(css) { - var keyframes, supports; + var keyframes, resolution, supports, viewport; + resolution = this.prefixes.add['@resolution']; keyframes = this.prefixes.add['@keyframes']; + viewport = this.prefixes.add['@viewport']; supports = this.prefixes.add['@supports']; css.eachAtRule((function(_this) { return function(rule) { @@ -22,26 +24,34 @@ if (!_this.disabled(rule)) { return keyframes != null ? keyframes.process(rule) : void 0; } + } else if (rule.name === 'viewport') { + if (!_this.disabled(rule)) { + return viewport != null ? viewport.process(rule) : void 0; + } } else if (rule.name === 'supports') { if (!_this.disabled(rule)) { return supports.process(rule); } + } else if (rule.name === 'media' && rule.params.indexOf('-resolution') !== -1) { + if (!_this.disabled(rule)) { + return resolution != null ? resolution.process(rule) : void 0; + } } }; })(this)); css.eachRule((function(_this) { return function(rule) { - var selector, _i, _len, _ref, _results; + var j, len, ref, results, selector; if (_this.disabled(rule)) { return; } - _ref = _this.prefixes.add.selectors; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - selector = _ref[_i]; - _results.push(selector.process(rule)); + ref = _this.prefixes.add.selectors; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + selector = ref[j]; + results.push(selector.process(rule)); } - return _results; + return results; }; })(this)); css.eachDecl((function(_this) { @@ -57,14 +67,14 @@ })(this)); return css.eachDecl((function(_this) { return function(decl) { - var unprefixed, value, _i, _len, _ref; + var j, len, ref, unprefixed, value; if (_this.disabled(decl)) { return; } unprefixed = _this.prefixes.unprefixed(decl.prop); - _ref = _this.prefixes.values('add', unprefixed); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - value = _ref[_i]; + ref = _this.prefixes.values('add', unprefixed); + for (j = 0, len = ref.length; j < len; j++) { + value = ref[j]; value.process(decl); } return Value.save(_this.prefixes, decl); @@ -73,19 +83,22 @@ }; Processor.prototype.remove = function(css) { - var checker, _i, _len, _ref; + var checker, j, len, ref, resolution; + resolution = this.prefixes.remove['@resolution']; css.eachAtRule((function(_this) { return function(rule, i) { if (_this.prefixes.remove['@' + rule.name]) { if (!_this.disabled(rule)) { return rule.parent.remove(i); } + } else if (rule.name === 'media' && rule.params.indexOf('-resolution') !== -1) { + return resolution != null ? resolution.clean(rule) : void 0; } }; })(this)); - _ref = this.prefixes.remove.selectors; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - checker = _ref[_i]; + ref = this.prefixes.remove.selectors; + for (j = 0, len = ref.length; j < len; j++) { + checker = ref[j]; css.eachRule((function(_this) { return function(rule, i) { if (checker.check(rule)) { @@ -98,36 +111,49 @@ } return css.eachDecl((function(_this) { return function(decl, i) { - var notHack, rule, unprefixed, _j, _len1, _ref1, _ref2; + var k, len1, notHack, ref1, ref2, rule, unprefixed; if (_this.disabled(decl)) { return; } rule = decl.parent; unprefixed = _this.prefixes.unprefixed(decl.prop); - if ((_ref1 = _this.prefixes.remove[decl.prop]) != null ? _ref1.remove : void 0) { + if ((ref1 = _this.prefixes.remove[decl.prop]) != null ? ref1.remove : void 0) { notHack = _this.prefixes.group(decl).down(function(other) { return other.prop === unprefixed; }); - if (notHack) { - if (decl.before.indexOf("\n") > -1) { + if (notHack && !_this.withHackValue(decl)) { + if (decl.style('before').indexOf("\n") > -1) { _this.reduceSpaces(decl); } rule.remove(i); return; } } - _ref2 = _this.prefixes.values('remove', unprefixed); - for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { - checker = _ref2[_j]; + ref2 = _this.prefixes.values('remove', unprefixed); + for (k = 0, len1 = ref2.length; k < len1; k++) { + checker = ref2[k]; if (checker.check(decl.value)) { - rule.remove(i); - return; + unprefixed = checker.unprefixed; + notHack = _this.prefixes.group(decl).down(function(other) { + return other.value.indexOf(unprefixed) !== -1; + }); + if (notHack) { + rule.remove(i); + return; + } else if (checker.clean) { + checker.clean(decl); + return; + } } } }; })(this)); }; + Processor.prototype.withHackValue = function(decl) { + return decl.prop === '-webkit-background-clip' && decl.value === 'text'; + }; + Processor.prototype.disabled = function(node) { var status; if (node._autoprefixerDisabled != null) { @@ -161,12 +187,12 @@ if (stop) { return; } - parts = decl.before.split("\n"); + parts = decl.style('before').split("\n"); prevMin = parts[parts.length - 1].length; diff = false; return this.prefixes.group(decl).down(function(other) { var last; - parts = other.before.split("\n"); + parts = other.style('before').split("\n"); last = parts.length - 1; if (parts[last].length > prevMin) { if (diff === false) { diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/resolution.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/resolution.js new file mode 100644 index 0000000..44147ce --- /dev/null +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/resolution.js @@ -0,0 +1,98 @@ +(function() { + var Prefixer, Resolution, n2f, regexp, split, utils, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + Prefixer = require('./prefixer'); + + utils = require('./utils'); + + n2f = require('num2fraction'); + + regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi; + + split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i; + + Resolution = (function(superClass) { + extend(Resolution, superClass); + + function Resolution() { + return Resolution.__super__.constructor.apply(this, arguments); + } + + Resolution.prototype.prefixName = function(prefix, name) { + return name = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio'; + }; + + Resolution.prototype.prefixQuery = function(prefix, name, colon, value, units) { + if (units === 'dpi') { + value = Number(value / 96); + } + if (prefix === '-o-') { + value = n2f(value); + } + return this.prefixName(prefix, name) + colon + value; + }; + + Resolution.prototype.clean = function(rule) { + var j, len, prefix, ref; + if (!this.bad) { + this.bad = []; + ref = this.prefixes; + for (j = 0, len = ref.length; j < len; j++) { + prefix = ref[j]; + this.bad.push(this.prefixName(prefix, 'min')); + this.bad.push(this.prefixName(prefix, 'max')); + } + } + return rule.params = utils.editList(rule.params, (function(_this) { + return function(queries) { + return queries.filter(function(query) { + return _this.bad.every(function(i) { + return query.indexOf(i) === -1; + }); + }); + }; + })(this)); + }; + + Resolution.prototype.process = function(rule) { + var parent, prefixes; + parent = this.parentPrefix(rule); + prefixes = parent ? [parent] : this.prefixes; + return rule.params = utils.editList(rule.params, (function(_this) { + return function(origin, prefixed) { + var j, k, len, len1, prefix, processed, query; + for (j = 0, len = origin.length; j < len; j++) { + query = origin[j]; + if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) { + prefixed.push(query); + continue; + } + for (k = 0, len1 = prefixes.length; k < len1; k++) { + prefix = prefixes[k]; + if (prefix === '-moz-' && rule.params.indexOf('dpi') !== -1) { + continue; + } else { + processed = query.replace(regexp, function(str) { + var parts; + parts = str.match(split); + return _this.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]); + }); + prefixed.push(processed); + } + } + prefixed.push(query); + } + return utils.uniq(prefixed); + }; + })(this)); + }; + + return Resolution; + + })(Prefixer); + + module.exports = Resolution; + +}).call(this); diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/selector.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/selector.js index 50d243d..07866fd 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/selector.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/selector.js @@ -1,7 +1,7 @@ (function() { var Browsers, OldSelector, Prefixer, Selector, utils, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; OldSelector = require('./old-selector'); @@ -11,11 +11,11 @@ utils = require('./utils'); - Selector = (function(_super) { - __extends(Selector, _super); + Selector = (function(superClass) { + extend(Selector, superClass); - function Selector(name, prefixes, all) { - this.name = name; + function Selector(name1, prefixes, all) { + this.name = name1; this.prefixes = prefixes; this.all = all; this.regexpCache = {}; @@ -47,14 +47,14 @@ }; Selector.prototype.prefixeds = function(rule) { - var prefix, prefixeds, _i, _len, _ref; + var i, len, prefix, prefixeds, ref; if (rule._autoprefixerPrefixeds) { return rule._autoprefixerPrefixeds; } prefixeds = {}; - _ref = this.possible(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - prefix = _ref[_i]; + ref = this.possible(); + for (i = 0, len = ref.length; i < len; i++) { + prefix = ref[i]; prefixeds[prefix] = this.replace(rule.selector, prefix); } return rule._autoprefixerPrefixeds = prefixeds; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/supports.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/supports.js index 900e7c9..b89476a 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/supports.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/supports.js @@ -18,8 +18,8 @@ findCondition = /(not\s*)?\(\s*([^\(\):]+)\s*:\s*(.+?(?!\s*or\s*).+?)\s*\)*\s*\)\s*or\s*/gi; Supports = (function() { - function Supports(all) { - this.all = all; + function Supports(all1) { + this.all = all1; } Supports.prototype.virtual = function(prop, value) { @@ -34,7 +34,7 @@ }; Supports.prototype.prefixed = function(prop, value) { - var decl, prefixer, rule, _i, _j, _len, _len1, _ref, _ref1; + var decl, j, k, len, len1, prefixer, ref, ref1, rule; rule = this.virtual(prop, value); prefixer = this.all.add[prop]; if (prefixer != null) { @@ -42,12 +42,12 @@ prefixer.process(rule.first); } } - _ref = rule.nodes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - decl = _ref[_i]; - _ref1 = this.all.values('add', prop); - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - value = _ref1[_j]; + ref = rule.nodes; + for (j = 0, len = ref.length; j < len; j++) { + decl = ref[j]; + ref1 = this.all.values('add', prop); + for (k = 0, len1 = ref1.length; k < len1; k++) { + value = ref1[k]; value.process(decl); } Value.save(this.all, decl); @@ -58,21 +58,21 @@ Supports.prototype.clean = function(params) { return params.replace(findCondition, (function(_this) { return function(all) { - var check, checker, prop, unprefixed, value, _, _i, _len, _ref, _ref1, _ref2; + var _, check, checker, j, len, prop, ref, ref1, ref2, unprefixed, value; if (all.slice(0, 3).toLowerCase() === 'not') { return all; } - _ref = all.match(split), _ = _ref[0], prop = _ref[1], value = _ref[2]; + ref = all.match(split), _ = ref[0], prop = ref[1], value = ref[2]; unprefixed = _this.all.unprefixed(prop); - if ((_ref1 = _this.all.cleaner().remove[prop]) != null ? _ref1.remove : void 0) { + if ((ref1 = _this.all.cleaner().remove[prop]) != null ? ref1.remove : void 0) { check = new RegExp('(\\(|\\s)' + utils.escapeRegexp(unprefixed) + ':'); if (check.test(params)) { return ''; } } - _ref2 = _this.all.cleaner().values('remove', unprefixed); - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - checker = _ref2[_i]; + ref2 = _this.all.cleaner().values('remove', unprefixed); + for (j = 0, len = ref2.length; j < len; j++) { + checker = ref2[j]; if (checker.check(value)) { return ''; } @@ -88,14 +88,14 @@ return function(all, prop, value) { var i, stringed; stringed = (function() { - var _i, _len, _ref, _results; - _ref = this.prefixed(prop, value); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - i = _ref[_i]; - _results.push("(" + i.prop + ": " + i.value + ")"); + var j, len, ref, results; + ref = this.prefixed(prop, value); + results = []; + for (j = 0, len = ref.length; j < len; j++) { + i = ref[j]; + results.push("(" + i.prop + ": " + i.value + ")"); } - return _results; + return results; }).call(_this); if (stringed.length === 1) { return stringed[0]; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/utils.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/utils.js index 3256816..4334cca 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/utils.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/utils.js @@ -1,4 +1,8 @@ (function() { + var list; + + list = require('postcss/lib/list'); + module.exports = { error: function(text) { var err; @@ -7,10 +11,10 @@ throw err; }, uniq: function(array) { - var filtered, i, _i, _len; + var filtered, i, j, len; filtered = []; - for (_i = 0, _len = array.length; _i < _len; _i++) { - i = array[_i]; + for (j = 0, len = array.length; j < len; j++) { + i = array[j]; if (filtered.indexOf(i) === -1) { filtered.push(i); } @@ -35,6 +39,18 @@ word = this.escapeRegexp(word); } return RegExp("(^|[\\s,(])(" + word + "($|[\\s(,]))", "gi"); + }, + editList: function(value, callback) { + var changed, join, origin; + origin = list.comma(value); + changed = callback(origin, []); + if (origin === changed) { + return value; + } else { + join = value.match(/,\s*/); + join = join ? join[0] : ', '; + return changed.join(join); + } } }; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/value.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/value.js index c2601c2..6f9bd52 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/value.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/lib/value.js @@ -1,7 +1,7 @@ (function() { var OldValue, Prefixer, Value, utils, vendor, - __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; Prefixer = require('./prefixer'); @@ -11,25 +11,25 @@ vendor = require('postcss/lib/vendor'); - Value = (function(_super) { - __extends(Value, _super); + Value = (function(superClass) { + extend(Value, superClass); function Value() { return Value.__super__.constructor.apply(this, arguments); } Value.save = function(prefixes, decl) { - var already, cloned, prefix, prefixed, propPrefix, rule, trimmed, value, _ref, _results; - _ref = decl._autoprefixerValues; - _results = []; - for (prefix in _ref) { - value = _ref[prefix]; + var already, cloned, prefix, prefixed, propPrefix, ref, results, rule, trimmed, value; + ref = decl._autoprefixerValues; + results = []; + for (prefix in ref) { + value = ref[prefix]; if (value === decl.value) { continue; } propPrefix = vendor.prefix(decl.prop); if (propPrefix === prefix) { - _results.push(decl.value = value); + results.push(decl.value = value); } else if (propPrefix === '-pie-') { continue; } else { @@ -43,19 +43,23 @@ return i.prop === decl.prop && i.value.replace(/\s+/, ' ') === trimmed; }); if (!already) { - cloned = this.clone(decl, { - value: value - }); - _results.push(decl.parent.insertBefore(decl, cloned)); + if (value.indexOf('-webkit-filter') !== -1 && (decl.prop === 'transition' || decl.prop === 'trasition-property')) { + results.push(decl.value = value); + } else { + cloned = this.clone(decl, { + value: value + }); + results.push(decl.parent.insertBefore(decl, cloned)); + } } else { - _results.push(void 0); + results.push(void 0); } } else { - _results.push(void 0); + results.push(void 0); } } } - return _results; + return results; }; Value.prototype.check = function(decl) { @@ -77,9 +81,9 @@ }; Value.prototype.add = function(decl, prefix) { - var value, _ref; + var ref, value; decl._autoprefixerValues || (decl._autoprefixerValues = {}); - value = decl._autoprefixerValues[prefix] || ((_ref = decl._value) != null ? _ref.raw : void 0) || decl.value; + value = decl._autoprefixerValues[prefix] || ((ref = decl._value) != null ? ref.raw : void 0) || decl.value; value = this.replace(value, prefix); if (value) { return decl._autoprefixerValues[prefix] = value; @@ -87,7 +91,7 @@ }; Value.prototype.old = function(prefix) { - return new OldValue(prefix + this.name); + return new OldValue(this.name, prefix + this.name); }; return Value; diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/ChangeLog.md b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/ChangeLog.md index 78c9335..fe4ee0c 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/ChangeLog.md +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/ChangeLog.md @@ -1,3 +1,6 @@ +## 0.2 +* Return Can I Use joined versions as `ios_saf 7.0-7.1`. + ## 0.1.3 * Better work with Can I Use joined versions like `ios_saf 7.0-7.1`. * Browserslist now understands `ios_saf 7.0` or `ios_saf 7`. diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/README.md b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/README.md index bcd8ccb..dd95701 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/README.md +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/README.md @@ -11,8 +11,8 @@ with a usage of over 5% in global usage statistics: ```js browserslist('> 5%, last 1 version'); -//=> ['safari 8', 'opera 26', 'ios_saf 8.1', 'ie_mob 11', 'ie 11', 'and_chr 39', -// 'firefox 33', 'firefox 32', 'chrome 39', 'chrome 38', 'chrome 37'] +//=> ['and_chr 40', 'chrome 40', 'chrome 39', 'firefox 35', 'firefox 34', +// 'ie 11', 'ie_mob 11', 'ios_saf 8.1', 'opera 26', 'safari 8'] ``` If you don't provide an argument, Browserslist will look for a `browserslist` @@ -91,7 +91,7 @@ or and array `['> 5%', 'last 1 version']`. Browserslist’s config should be named `browserslist` and have browsers queries split by a new line. You can write a comment after `#`: -``` +```yaml # Browsers that we support > 1% diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/index.js b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/index.js index 0c6f388..17f82e8 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/index.js +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/index.js @@ -10,6 +10,15 @@ var uniq = function (array) { return filtered; }; +normalizeVersion = function (data, version) { + if ( data.versions.indexOf(version) != -1 ) { + return version; + } else { + var alias = browserslist.versionAliases[data.name][version]; + if ( alias ) return alias; + } +}; + // Return array of browsers by selection queries: // // browserslist('IE >= 10, IE 8') //=> ['ie 11', 'ie 10', 'ie 8'] @@ -255,22 +264,21 @@ browserslist.queries = { direct: { regexp: /^(\w+) ([\d\.]+)$/, select: function (name, version) { - var data = browserslist.byName(name); - if ( data.versions.indexOf(version) == -1 ) { - var alias = browserslist.versionAliases[data.name][version]; + var data = browserslist.byName(name); + var alias = normalizeVersion(data, version); + if ( alias ) { + version = alias; + } else { + if ( version.indexOf('.') == -1 ) { + alias = version + '.0'; + } else if ( /\.0$/.test(version) ) { + alias = version.replace(/\.0$/, ''); + } + alias = normalizeVersion(data, alias); if ( alias ) { version = alias; } else { - if ( version.indexOf('.') == -1 ) { - alias = version + '.0'; - } else if ( /\.0$/.test(version) ) { - alias = version.replace(/\.0$/, ''); - } - if ( alias && data.versions.indexOf(alias) != -1 ) { - version = alias; - } else { - throw 'Unknown version ' + version + ' of ' + name; - } + throw 'Unknown version ' + version + ' of ' + name; } } @@ -282,22 +290,15 @@ browserslist.queries = { // Get and convert Can I Use data -var normalizeVersion = function (version) { - var interval = version.split('-'); - return interval[0]; -}; - var normalize = function (versions) { - return versions - .filter(function (version) { - return typeof(version) == 'string'; - }) - .map(normalizeVersion); + return versions.filter(function (version) { + return typeof(version) == 'string'; + }); }; var fillUsage = function (result, name, data) { for ( var i in data ) { - result[name + ' ' + normalizeVersion(i)] = data[i]; + result[name + ' ' + i] = data[i]; } }; @@ -312,10 +313,13 @@ for ( var name in caniuse ) { browserslist.versionAliases[name] = { }; for ( var i = 0; i < caniuse[name].versions.length; i++ ) { if ( !caniuse[name].versions[i] ) continue; - var interval = caniuse[name].versions[i].split('-'); + var full = caniuse[name].versions[i]; - for ( var j = 1; j < interval.length; j++ ) { - browserslist.versionAliases[name][ interval[j] ] = interval[0]; + if ( full.indexOf('-') != -1 ) { + var interval = full.split('-'); + for ( var j = 0; j < interval.length; j++ ) { + browserslist.versionAliases[name][ interval[j] ] = full; + } } } } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/package.json b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/package.json index 74b73bc..85317ff 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/package.json +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/browserslist/package.json @@ -1,6 +1,6 @@ { "name": "browserslist", - "version": "0.1.3", + "version": "0.2.0", "description": "Get browsers versions that matches given criterias like in Autoprefixer", "keywords": [ "caniuse", @@ -29,14 +29,14 @@ "scripts": { "test": "gulp" }, - "gitHead": "0a1378994059af5fef338c473ded1bd69925c9e1", + "gitHead": "c6b2e8770f7dace8e2ba0642bcd85aa5c923579e", "bugs": { "url": "https://github.com/ai/browserslist/issues" }, "homepage": "https://github.com/ai/browserslist", - "_id": "browserslist@0.1.3", - "_shasum": "2f67975c24bb357b6b48b4bc46e7c39a1f0b3b5b", - "_from": "browserslist@0.1.3", + "_id": "browserslist@0.2.0", + "_shasum": "e5b7cf311cccb70772cd22d4f61c7bb80523ecd2", + "_from": "browserslist@0.2.0", "_npmVersion": "2.1.18", "_nodeVersion": "0.10.33", "_npmUser": { @@ -50,10 +50,10 @@ } ], "dist": { - "shasum": "2f67975c24bb357b6b48b4bc46e7c39a1f0b3b5b", - "tarball": "http://registry.npmjs.org/browserslist/-/browserslist-0.1.3.tgz" + "shasum": "e5b7cf311cccb70772cd22d4f61c7bb80523ecd2", + "tarball": "http://registry.npmjs.org/browserslist/-/browserslist-0.2.0.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/browserslist/-/browserslist-0.1.3.tgz", + "_resolved": "https://registry.npmjs.org/browserslist/-/browserslist-0.2.0.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/caniuse-db/data.json b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/caniuse-db/data.json index 16c5e39..dbcd6ef 100644 --- a/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/caniuse-db/data.json +++ b/node_modules/autoprefixer-brunch/node_modules/autoprefixer-core/node_modules/caniuse-db/data.json @@ -1 +1 @@ -{"eras":{"e-36":"36 versions back","e-35":"35 versions back","e-34":"34 versions back","e-33":"33 versions back","e-32":"32 versions back","e-31":"31 versions back","e-30":"30 versions back","e-29":"29 versions back","e-28":"28 versions back","e-27":"27 versions back","e-26":"26 versions back","e-25":"25 versions back","e-24":"24 versions back","e-23":"23 versions back","e-22":"22 versions back","e-21":"21 versions back","e-20":"20 versions back","e-19":"19 versions back","e-18":"18 versions back","e-17":"17 versions back","e-16":"16 versions back","e-15":"15 versions back","e-14":"14 versions back","e-13":"13 versions back","e-12":"12 versions back","e-11":"11 versions back","e-10":"10 versions back","e-9":"9 versions back","e-8":"8 versions back","e-7":"7 versions back","e-6":"6 versions back","e-5":"5 versions back","e-4":"4 versions back","e-3":"3 versions back","e-2":"2 versions back","e-1":"Previous version","e0":"Current","e1":"Near future","e2":"Farther future","e3":"3 versions ahead"},"agents":{"ie":{"browser":"IE","abbr":"IE","prefix":"ms","type":"desktop","usage_global":{"5.5":0.009298,"6":0.0737794,"7":0.187802,"8":4.07799,"9":2.1329,"10":1.63656,"11":8.33707,"TP":0},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"5.5","6","7","8","9","10","11","TP",null,null]},"firefox":{"browser":"Firefox","abbr":"FF","prefix":"moz","type":"desktop","usage_global":{"2":0.006597,"3":0.026388,"3.5":0.013194,"3.6":0.092358,"4":0.026388,"5":0.013194,"6":0.026388,"7":0.013194,"8":0.046179,"9":0.013194,"10":0.026388,"11":0.046179,"12":0.059373,"13":0.026388,"14":0.026388,"15":0.032985,"16":0.052776,"17":0.039582,"18":0.032985,"19":0.026388,"20":0.032985,"21":0.039582,"22":0.032985,"23":0.046179,"24":0.079164,"25":0.052776,"26":0.059373,"27":0.098955,"28":0.059373,"29":0.092358,"30":0.151731,"31":0.448596,"32":0.369432,"33":2.90928,"34":6.50464,"35":0.237492,"36":0.006597,"37":0.006597,"38":0},"versions":[null,"2","3","3.5","3.6","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38"]},"chrome":{"browser":"Chrome","abbr":"Chr.","prefix":"webkit","type":"desktop","usage_global":{"4":0.026388,"5":0.013194,"6":0.019791,"7":0.013194,"8":0.013194,"9":0.013194,"10":0.019791,"11":0.098955,"12":0.039582,"13":0.026388,"14":0.026388,"15":0.026388,"16":0.019791,"17":0.013194,"18":0.032985,"19":0.013194,"20":0.013194,"21":0.072567,"22":0.059373,"23":0.032985,"24":0.039582,"25":0.032985,"26":0.052776,"27":0.072567,"28":0.079164,"29":0.06597,"30":0.13194,"31":0.752058,"32":0.145134,"33":0.46179,"34":0.32985,"35":0.613521,"36":0.890595,"37":1.02253,"38":1.326,"39":25.3919,"40":0.125343,"41":0.184716,"42":0,"43":0},"versions":["4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43"]},"safari":{"browser":"Safari","abbr":"Saf.","prefix":"webkit","type":"desktop","usage_global":{"3.1":0,"3.2":0.008692,"4":0.052776,"5":0.125343,"5.1":0.409014,"6":0.098955,"6.1":0.277074,"7":0.448596,"7.1":0.567342,"8":1.00274},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"3.1","3.2","4","5","5.1","6","6.1","7","7.1","8",null,null,null]},"opera":{"browser":"Opera","abbr":"Op.","prefix":"webkit","type":"desktop","usage_global":{"9.5-9.6":0.00685,"10.0-10.1":0.013194,"10.5":0.008392,"10.6":0.007296,"11":0.014996,"11.1":0.008219,"11.5":0.00685,"11.6":0.013194,"12":0.013194,"12.1":0.19791,"15":0.00685,"16":0.00685,"17":0.00685,"18":0.013194,"19":0.006597,"20":0.013194,"21":0.006597,"22":0.006597,"23":0.013434,"24":0.013194,"25":0.026388,"26":0.606924,"27":0.006597,"28":0,"29":0},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"9.5-9.6","10.0-10.1","10.5","10.6","11","11.1","11.5","11.6","12","12.1","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29",null],"prefix_exceptions":{"9.5-9.6":"o","10.0-10.1":"o","10.5":"o","10.6":"o","11":"o","11.1":"o","11.5":"o","11.6":"o","12":"o","12.1":"o"}},"ios_saf":{"browser":"iOS Safari","abbr":"iOS","prefix":"webkit","type":"mobile","usage_global":{"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0.0454654,"6.0-6.1":0.188026,"7.0-7.1":2.22703,"8":0.631121,"8.1":4.58892},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"3.2","4.0-4.1","4.2-4.3","5.0-5.1","6.0-6.1","7.0-7.1","8","8.1",null,null,null]},"op_mini":{"browser":"Opera Mini","abbr":"O.Mini","prefix":"o","type":"mobile","usage_global":{"5.0-8.0":3.0738},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"5.0-8.0",null,null,null]},"android":{"browser":"Android Browser","abbr":"And.","prefix":"webkit","type":"mobile","usage_global":{"2.1":0,"2.2":0.00527484,"2.3":0.148355,"3":0,"4":0.305941,"4.1":0.937603,"4.2-4.3":1.49344,"4.4":2.50621,"4.4.3-4.4.4":1.02464,"37":0},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"2.1","2.2","2.3","3","4","4.1","4.2-4.3","4.4","4.4.3-4.4.4","37",null,null,null]},"op_mob":{"browser":"Opera Mobile","abbr":"O.Mob","prefix":"o","type":"mobile","usage_global":{"10":0,"11.5":0,"12":0.00438935,"12.1":0.0219467,"24":0},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"10",null,null,"11.5","12","12.1","24",null,null,null],"prefix_exceptions":{"24":"webkit"}},"bb":{"browser":"Blackberry Browser","abbr":"BB","prefix":"webkit","type":"mobile","usage_global":{"7":0.0935825,"10":0},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"7","10",null,null,null]},"and_chr":{"browser":"Chrome for Android","abbr":"Chr/And.","prefix":"webkit","type":"mobile","usage_global":{"40":10.5231},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"40",null,null,null]},"and_ff":{"browser":"Firefox for Android","abbr":"FF/And.","prefix":"moz","type":"mobile","usage_global":{"33":0.129314},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"33",null,null,null]},"ie_mob":{"browser":"IE Mobile","abbr":"IE.Mob","prefix":"ms","type":"mobile","usage_global":{"10":0.331242,"11":0.400403},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"10","11",null,null,null]},"and_uc":{"browser":"UC Browser for Android","abbr":"UC","prefix":"webkit","type":"mobile","usage_global":{"9.9":3.77733},"versions":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"9.9",null,null,null],"prefix_exceptions":{"9.9":"webkit"}}},"statuses":{"rec":"W3C Recommendation","pr":"W3C Proposed Recommendation","cr":"W3C Candidate Recommendation","wd":"W3C Working Draft","ls":"WHATWG Living Standard","other":"Other","unoff":"Unofficial / Note"},"cats":{"CSS":["CSS","CSS2","CSS3"],"HTML5":["Canvas","HTML5"],"JS API":["JS API"],"Other":["PNG","Other","DOM"],"SVG":["SVG"]},"updated":1422423430,"data":{"png-alpha":{"title":"PNG alpha transparency","description":"Semi-transparent areas in PNG files","spec":"http://www.w3.org/TR/PNG/","status":"rec","links":[{"url":"http://en.wikipedia.org/wiki/Portable_Network_Graphics","title":"Wikipedia"},{"url":"http://dillerdesign.com/experiment/DD_belatedPNG/","title":"Workaround for IE6"}],"categories":["PNG"],"stats":{"ie":{"5.5":"n","6":"p","7":"y","8":"y","9":"y","10":"y","11":"y","TP":"y"},"firefox":{"2":"y","3":"y","3.5":"y","3.6":"y","4":"y","5":"y","6":"y","7":"y","8":"y","9":"y","10":"y","11":"y","12":"y","13":"y","14":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y","30":"y","31":"y","32":"y","33":"y","34":"y","35":"y","36":"y","37":"y","38":"y"},"chrome":{"4":"y","5":"y","6":"y","7":"y","8":"y","9":"y","10":"y","11":"y","12":"y","13":"y","14":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y","30":"y","31":"y","32":"y","33":"y","34":"y","35":"y","36":"y","37":"y","38":"y","39":"y","40":"y","41":"y","42":"y","43":"y"},"safari":{"3.1":"y","3.2":"y","4":"y","5":"y","5.1":"y","6":"y","6.1":"y","7":"y","7.1":"y","8":"y"},"opera":{"9":"y","9.5-9.6":"y","10.0-10.1":"y","10.5":"y","10.6":"y","11":"y","11.1":"y","11.5":"y","11.6":"y","12":"y","12.1":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y"},"ios_saf":{"3.2":"y","4.0-4.1":"y","4.2-4.3":"y","5.0-5.1":"y","6.0-6.1":"y","7.0-7.1":"y","8":"y","8.1":"y"},"op_mini":{"5.0-8.0":"y"},"android":{"2.1":"y","2.2":"y","2.3":"y","3":"y","4":"y","4.1":"y","4.2-4.3":"y","4.4":"y","4.4.3-4.4.4":"y","37":"y"},"bb":{"7":"y","10":"y"},"op_mob":{"10":"y","11":"y","11.1":"y","11.5":"y","12":"y","12.1":"y","24":"y"},"and_chr":{"40":"y"},"and_ff":{"33":"y"},"ie_mob":{"10":"y","11":"y"},"and_uc":{"9.9":"y"}},"notes":"IE6 does support full transparency in 8-bit PNGs, which can sometimes be an alternative to 24-bit PNGs.","notes_by_num":{},"usage_perc_y":97.04,"usage_perc_a":0,"ucprefix":false,"parent":"","keywords":"","ie_id":"","chrome_id":""},"apng":{"title":"Animated PNG (APNG)","description":"Like animated GIFs, but allowing 24-bit colors and alpha transparency","spec":"https://wiki.mozilla.org/APNG_Specification","status":"unoff","links":[{"url":"http://en.wikipedia.org/wiki/APNG","title":"Wikipedia"},{"url":"https://github.com/davidmz/apng-canvas","title":"Polyfill using canvas"},{"url":"https://chrome.google.com/webstore/detail/ehkepjiconegkhpodgoaeamnpckdbblp","title":"Chrome extension providing support"}],"categories":["PNG"],"stats":{"ie":{"5.5":"n","6":"n","7":"n","8":"n","9":"n","10":"n","11":"n","TP":"n"},"firefox":{"2":"n","3":"y","3.5":"y","3.6":"y","4":"y","5":"y","6":"y","7":"y","8":"y","9":"y","10":"y","11":"y","12":"y","13":"y","14":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y","30":"y","31":"y","32":"y","33":"y","34":"y","35":"y","36":"y","37":"y","38":"y"},"chrome":{"4":"n","5":"n","6":"n","7":"n","8":"n","9":"n","10":"n","11":"n","12":"n","13":"n","14":"n","15":"n","16":"n","17":"n","18":"n","19":"n","20":"n","21":"n","22":"n","23":"n","24":"n","25":"n","26":"n","27":"n","28":"n","29":"n","30":"n","31":"n","32":"n","33":"n","34":"n","35":"n","36":"n","37":"n","38":"n","39":"n","40":"n","41":"n","42":"n","43":"n"},"safari":{"3.1":"n","3.2":"n","4":"n","5":"n","5.1":"n","6":"n","6.1":"n","7":"n","7.1":"n","8":"y"},"opera":{"9":"n","9.5-9.6":"y","10.0-10.1":"y","10.5":"y","10.6":"y","11":"y","11.1":"y","11.5":"y","11.6":"y","12":"y","12.1":"y","15":"n","16":"n","17":"n","18":"n","19":"n","20":"n","21":"n","22":"n","23":"n","24":"n","25":"n","26":"n","27":"n","28":"n","29":"n"},"ios_saf":{"3.2":"n","4.0-4.1":"n","4.2-4.3":"n","5.0-5.1":"n","6.0-6.1":"n","7.0-7.1":"n","8":"y","8.1":"y"},"op_mini":{"5.0-8.0":"n"},"android":{"2.1":"n","2.2":"n","2.3":"n","3":"n","4":"n","4.1":"n","4.2-4.3":"n","4.4":"n","4.4.3-4.4.4":"n","37":"n"},"bb":{"7":"n","10":"n"},"op_mob":{"10":"y","11":"y","11.1":"y","11.5":"y","12":"y","12.1":"y","24":"n"},"and_chr":{"40":"n"},"and_ff":{"33":"y"},"ie_mob":{"10":"n","11":"n"},"and_uc":{"9.9":"n"}},"notes":"Where support for APNG is missing, only the first frame is displayed","notes_by_num":{},"usage_perc_y":18.54,"usage_perc_a":0,"ucprefix":false,"parent":"","keywords":"","ie_id":"","chrome_id":""},"video":{"title":"Video element","description":"Method of playing videos on webpages (without requiring a plug-in).","spec":"https://html.spec.whatwg.org/multipage/embedded-content.html#the-video-element","status":"ls","links":[{"url":"https://dev.opera.com/articles/view/everything-you-need-to-know-about-html5-video-and-audio/","title":"Detailed article on video/audio elements"},{"url":"http://webmproject.org","title":"WebM format information"},{"url":"http://camendesign.co.uk/code/video_for_everybody","title":"Video for Everybody"},{"url":"http://diveintohtml5.info/video.html","title":"Video on the Web - includes info on Android support"},{"url":"https://raw.github.com/phiggins42/has.js/master/detect/video.js#video","title":"has.js test"},{"url":"http://docs.webplatform.org/wiki/html/elements/video","title":"WebPlatform Docs"}],"categories":["HTML5"],"stats":{"ie":{"5.5":"n","6":"n","7":"n","8":"n","9":"y","10":"y","11":"y","TP":"y"},"firefox":{"2":"n","3":"n","3.5":"y","3.6":"y","4":"y","5":"y","6":"y","7":"y","8":"y","9":"y","10":"y","11":"y","12":"y","13":"y","14":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y","30":"y","31":"y","32":"y","33":"y","34":"y","35":"y","36":"y","37":"y","38":"y"},"chrome":{"4":"y","5":"y","6":"y","7":"y","8":"y","9":"y","10":"y","11":"y","12":"y","13":"y","14":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y","30":"y","31":"y","32":"y","33":"y","34":"y","35":"y","36":"y","37":"y","38":"y","39":"y","40":"y","41":"y","42":"y","43":"y"},"safari":{"3.1":"n","3.2":"n","4":"y","5":"y","5.1":"y","6":"y","6.1":"y","7":"y","7.1":"y","8":"y"},"opera":{"9":"n","9.5-9.6":"n","10.0-10.1":"n","10.5":"y","10.6":"y","11":"y","11.1":"y","11.5":"y","11.6":"y","12":"y","12.1":"y","15":"y","16":"y","17":"y","18":"y","19":"y","20":"y","21":"y","22":"y","23":"y","24":"y","25":"y","26":"y","27":"y","28":"y","29":"y"},"ios_saf":{"3.2":"y","4.0-4.1":"y","4.2-4.3":"y","5.0-5.1":"y","6.0-6.1":"y","7.0-7.1":"y","8":"y","8.1":"y"},"op_mini":{"5.0-8.0":"n"},"android":{"2.1":"a","2.2":"a","2.3":"y","3":"y","4":"y","4.1":"y","4.2-4.3":"y","4.4":"y","4.4.3-4.4.4":"y","37":"y"},"bb":{"7":"y","10":"y"},"op_mob":{"10":"n","11":"y","11.1":"y","11.5":"y","12":"y","12.1":"y","24":"y"},"and_chr":{"40":"y"},"and_ff":{"33":"y"},"ie_mob":{"10":"y","11":"y"},"and_uc":{"9.9":"y"}},"notes":"Different browsers have support for different video formats, see sub-features for details. \r\n\r\nThe Android browser (before 2.3) requires [specific handling](http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/) to run the video element.","notes_by_num":{},"usage_perc_y":89.62,"usage_perc_a":0.01,"ucprefix":false,"parent":"","keywords":"