<commit_before>////////////////////////////////////////////////////////////////////////////////
// GULP
////////////////////////////////////////////////////////////////////////////////

import { series, parallel, src, dest, watch } from 'gulp'

import autoprefixer from 'gulp-autoprefixer'
import stylelint from 'gulp-stylelint'
import imagemin from 'gulp-imagemin'
import favicon from 'gulp-favicons'
import concat from 'gulp-concat'
import rename from 'gulp-rename'
import uglify from 'gulp-uglify-es'
import eslint from 'gulp-eslint'
import gulpif from 'gulp-if'
import phpcs from 'gulp-phpcs'
import cache from 'gulp-cache'
import debug from 'gulp-debug'
import scss from 'gulp-sass'
import sass from 'node-sass'
import sync from 'browser-sync'
import del from 'del'
import config from './config'
import minimist from 'minimist'

// ARGS
const ARGS = minimist(process.argv.slice(2))
const PROD = (ARGS.prod) ? true : false
const DEBUG = (ARGS.debug) ? true : false

// PATHS
const path = prep(config.path)
const root_src = path.root_src
const root_dist = path.root_dist
const resources = path.resources

////////////////////////////////////////////////////////////////////////////////
// BROWSERSYNC
////////////////////////////////////////////////////////////////////////////////

const browser = sync.create()

function browsersync (done) {
  browser.init({
    host: config.host.local,
    proxy: config.host.local,
    logLevel: DEBUG ? 'debug' : 'info',
    logFileChanges: DEBUG ? true : false,
    logPrefix: 'portfolio-m',
    ghostMode: false,
    open: false,
    notify: false,
    ui: false,
    online: false,
    injectChanges: true,
    reloadDelay: 1000
  })
  done()
}

function reload (done) {
  browser.reload()
  done()
}

////////////////////////////////////////////////////////////////////////////////
// CACHE
////////////////////////////////////////////////////////////////////////////////

const clear = series(clean__cache)

// CLEAN -------------------------------------------------------------

function clean__cache () {
  return cache.clearAll()
}

////////////////////////////////////////////////////////////////////////////////
// VENDOR
////////////////////////////////////////////////////////////////////////////////

const vendor = series(clean__vendor, process__vendor_head, process__vendor)

// CLEAN -------------------------------------------------------------

function clean__vendor () {
  return del([config.vendor.dest + '{vendor.head,vendor}.min.js'])
}

// PROCESS -------------------------------------------------------------

function process__vendor_head () {
  return src(config.vendor.head)
    .pipe(gulpif(DEBUG, debug({ title: '## VENDOR_HEAD:' })))
    .pipe(concat('vendor.head.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(config.vendor.dest))
}

function process__vendor () {
  return src(config.vendor.src)
    .pipe(gulpif(DEBUG, debug({ title: '## VENDOR:' })))
    .pipe(concat('vendor.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(config.vendor.dest))
}

////////////////////////////////////////////////////////////////////////////////
// LOGIC
////////////////////////////////////////////////////////////////////////////////

const index__src = (root_src).replace('//', '/')
const index__dest = (root_dist).replace('//', '/')

const snippets__src = (root_src + path.snippets).replace('//', '/')
const snippets__dest = (root_dist + path.snippets).replace('//', '/')

const templates__src = (root_src + path.templates).replace('//', '/')
const templates__dest = (root_dist + path.templates).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__index () { return del([index__dest + 'index.php']) }
function clean__htaccess () { return del([index__dest + '.htaccess']) }
function clean__snippets () { return del([snippets__dest]) }
function clean__templates () { return del([templates__dest]) }

// LINT -------------------------------------------------------------

function lint__logic () {
  return src(['./app/{templates,snippets}/**/*.php', '!index.php'])
    // .pipe(gulpif(DEBUG, debug({ title: '## LOGIC:' })))
    .pipe(phpcs({ bin: 'vendor/bin/phpcs', standard: './phpcs.ruleset.xml' }))
    .pipe(phpcs.reporter('log'))
}

// COPY -------------------------------------------------------------

function copy__htaccess () {
  return src([index__src + '.htaccess'])
    // .pipe(gulpif(DEBUG, debug({ title: '## HTACCESS:' })))
    .pipe(dest(index__dest))
}

function copy__index () {
  return src([index__src + 'index.php'])
    // .pipe(gulpif(DEBUG, debug({ title: '## INDEX:' })))
    .pipe(dest(index__dest))
}

function copy__snippets () {
  return src([snippets__src + '**/*.php'])
    // .pipe(gulpif(DEBUG, debug({ title: '## SNIPPETS:' })))
    .pipe(dest(snippets__dest))
}

function copy__templates () {
  return src([templates__src + '**/*.php'])
    // .pipe(gulpif(DEBUG, debug({ title: '## TEMPLATES:' })))
    .pipe(dest(templates__dest))
}

// WATCH -------------------------------------------------------------

function watch__logic () {
  watch(index__src + 'index.php', series(index, reload))
  watch(index__src + '.htaccess', series(htaccess, reload))
  watch(snippets__src + '**/*.php', series(snippets, reload))
  watch(templates__src + '**/*.php', series(templates, reload))
}

// COMPOSITION -------------------------------------------------------------

const index = series(clean__index, copy__index)
const htaccess = series(clean__htaccess, copy__htaccess)
const snippets = series(clean__snippets, copy__snippets)
const templates = series(clean__templates, copy__templates)

////////////////////////////////////////////////////////////////////////////////
// ASSETS
////////////////////////////////////////////////////////////////////////////////

const assets__images__src = (root_src + resources + path.assets + path.images).replace('//', '/')
const assets__images__dest = (root_dist + path.assets + path.images).replace('//', '/')

const assets__icons__src = (root_src + resources + path.assets + path.icons).replace('//', '/')
const assets__icons__dest = (root_dist + path.assets + path.icons).replace('//', '/')

const assets__favicons__src = (root_src + resources + path.assets + path.favicons).replace('//', '/')
const assets__favicons__dest = (root_dist + path.assets + path.favicons).replace('//', '/')

const assets__fonts__src = (root_src + resources + path.assets + path.fonts).replace('//', '/')
const assets__fonts__dest = (root_dist + path.assets + path.fonts).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__images () { return del([assets__images__dest]) }
function clean__icons () { return del([assets__icons__dest]) }
function clean__favicons () { return del([assets__favicons__dest]) }
function clean__fonts () { return del([assets__fonts__dest]) }

// PROCESS -------------------------------------------------------------

function process__images () {
  return src(assets__images__src + '**/*.{png,jpg,jpeg,gif}')
    .pipe(gulpif(DEBUG, debug({ title: '## IMAGES:' })))
    .pipe(cache(imagemin([
      imagemin.gifsicle({ interlaced: true }),
      imagemin.jpegtran({ progressive: true }),
      imagemin.optipng({ optimizationLevel: 7 })
    ])))
    .pipe(dest(assets__images__dest))
}

function process__icons () {
  return src(assets__icons__src + '**/*.svg')
    .pipe(gulpif(DEBUG, debug({ title: '## ICONS:' })))
    .pipe(cache(imagemin([
      imagemin.svgo({
        plugins: [
          { removeTitle: true },
          { removeViewBox: false },
          { cleanupIDs: true },
          { removeXMLNS: false }
        ],
        verbose: DEBUG ? true : false
      })
    ])))
    .pipe(dest(assets__icons__dest))
}

function process__favicons () {
  return src([assets__favicons__src + 'favicon_src.png'])
    .pipe(favicon({
      background: '#FFFFFF',
      path: assets__favicons__dest,
      url: config.host.live,
      display: 'standalone',
      orientation: 'portrait',
      logging: DEBUG ? true : false,
      online: false,
      replace: true,
      icons: {
        android: PROD ? true : false,
        appleIcon: PROD ? true : false,
        appleStartup: PROD ? true : false,
        coast: PROD ? true : false,
        favicons: true,
        firefox: PROD ? true : false,
        windows: PROD ? true : false,
        yandex: PROD ? true : false
      }
    }))
    .pipe(gulpif(DEBUG, debug({ title: '## FAVICON:' })))
    .pipe(dest(assets__favicons__dest))
}

function copy__fonts () {
  return src([assets__fonts__src + '**/*.{woff,woff2}'])
    // .pipe(gulpif(DEBUG, debug({ title: '## FONTS:' })))
    .pipe(dest(assets__fonts__dest))
}

// WATCH -------------------------------------------------------------

function watch__assets () {
  watch(assets__images__src + '**/*.{png,jpg,jpeg,gif}', series(images, reload))
  watch(assets__icons__src + '**/*.svg', series(icons, reload))
  watch(assets__favicons__src + '**/favicon_src.png', series(favicons, reload))
  watch(assets__fonts__src + '**/*.{woff,woff2}', series(fonts, reload))
}

// COMPOSITION -------------------------------------------------------------

const images = series(clean__images, process__images)
const icons = series(clean__icons, process__icons)
const favicons = series(clean__favicons, process__favicons)
const fonts = series(clean__fonts, copy__fonts)

////////////////////////////////////////////////////////////////////////////////
// SCRIPT
////////////////////////////////////////////////////////////////////////////////

const scripts__src = (root_src + path.resources).replace('//', '/')
const scripts__dest = (root_dist).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__scripts__main () { return del(scripts__dest + 'main.min.{js,js.map}') }

// LINT -------------------------------------------------------------

function lint__scripts () {
  return src([scripts__src + 'main.js', snippets__src + '**/script.js'])
    // .pipe(gulpif(DEBUG, debug({ title: '## MAIN:' })))
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(gulpif(PROD, eslint.failAfterError()))
}

// PROCESS -------------------------------------------------------------

function process__scripts__main () {
  return src([scripts__src + 'main.js', snippets__src + '**/script.js'], { sourcemaps: !PROD ? true : false })
    // .pipe(gulpif(DEBUG, debug({ title: '## MAIN:' })))
    .pipe(concat('main.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(scripts__dest, { sourcemaps: !PROD ? '.' : false }))
}

// WATCH -------------------------------------------------------------

function watch__scripts () {
  watch([scripts__src + 'main.js', snippets__src + '**/script.js'], series(scripts__main, reload))
};

// COMPOSITION -------------------------------------------------------------

const scripts__main = series(clean__scripts__main, process__scripts__main)

////////////////////////////////////////////////////////////////////////////////
// STYLE
////////////////////////////////////////////////////////////////////////////////

const styles__src = (root_src + resources).replace('//', '/')
const styles__dest = (root_dist).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__styles () { return del(styles__dest + '*.min.{css,css.map}') }

// LINT -------------------------------------------------------------

function lint__styles () {
  return src([styles__src + '**/*.scss', snippets__src + '**/*.scss'])
    // .pipe(gulpif(DEBUG, debug({ title: '## STYLE:' })))
    .pipe(stylelint({ syntax: 'scss', reporters: [{ formatter: 'string', console: true }], failAfterError: PROD ? true : false }))
}

// PROCESS -------------------------------------------------------------

function process__styles () {
  scss.compiler = sass
  return src(styles__src + 'main.scss', { sourcemaps: !PROD ? true : false })
    // .pipe(gulpif(DEBUG, debug({ title: '## STYLE:' })))
    .pipe(scss({ outputStyle: PROD ? 'compressed' : 'expanded' }).on('error', scss.logError))
    .pipe(autoprefixer()).pipe(rename({ suffix: '.min' }))
    .pipe(dest(styles__dest, { sourcemaps: !PROD ? '.' : false }))
}

// WATCH -------------------------------------------------------------

function watch__styles () {
  watch(snippets__src + '**/*.scss', series(styles, reload))
  watch(styles__src + '**/*.scss', series(styles, reload))
}

// COMPOSITION -------------------------------------------------------------

const styles = series(clean__styles, process__styles)

////////////////////////////////////////////////////////////////////////////////
// COMPOSITION
////////////////////////////////////////////////////////////////////////////////

exports.clear = series(clear)

const LOGIC = series(parallel(index, htaccess, snippets, templates), vendor)
const STYLE = series(parallel(styles, scripts__main))
const ASSET = series(images, icons, favicons, fonts)
const LINT = series(lint__logic, lint__styles, lint__scripts)
const RUN = series(browsersync, parallel(watch__logic, watch__assets, watch__styles, watch__scripts))

if (PROD) {
  exports.default = series(LINT, LOGIC, STYLE, ASSET)
} else {
  exports.default = series(LOGIC, STYLE, ASSET, RUN)
}

////////////////////////////////////////////////////////////////////////////////
// HELPER
////////////////////////////////////////////////////////////////////////////////

function prep (paths) {
  for (var p in paths) {
    var value = paths[p]
    paths[p] = value.length ? value.replace(/\/?$/, '/') : value
  }
  return paths
}
<commit_msg>update(): gulp debug<commit_after>////////////////////////////////////////////////////////////////////////////////
// GULP
////////////////////////////////////////////////////////////////////////////////

import { series, parallel, src, dest, watch } from 'gulp'

import autoprefixer from 'gulp-autoprefixer'
import stylelint from 'gulp-stylelint'
import imagemin from 'gulp-imagemin'
import favicon from 'gulp-favicons'
import concat from 'gulp-concat'
import rename from 'gulp-rename'
import uglify from 'gulp-uglify-es'
import eslint from 'gulp-eslint'
import gulpif from 'gulp-if'
import phpcs from 'gulp-phpcs'
import cache from 'gulp-cache'
import debug from 'gulp-debug'
import scss from 'gulp-sass'
import sass from 'node-sass'
import sync from 'browser-sync'
import del from 'del'
import config from './config'
import minimist from 'minimist'

// ARGS
const ARGS = minimist(process.argv.slice(2))
const PROD = (ARGS.prod) ? true : false
const DEBUG = (ARGS.debug) ? true : false

// PATHS
const path = prep(config.path)
const root_src = path.root_src
const root_dist = path.root_dist
const resources = path.resources

////////////////////////////////////////////////////////////////////////////////
// BROWSERSYNC
////////////////////////////////////////////////////////////////////////////////

const browser = sync.create()

function browsersync (done) {
  browser.init({
    host: config.host.local,
    proxy: config.host.local,
    logLevel: DEBUG ? 'debug' : 'info',
    logFileChanges: DEBUG ? true : false,
    logPrefix: 'portfolio-m',
    ghostMode: false,
    open: false,
    notify: false,
    ui: false,
    online: false,
    injectChanges: true,
    reloadDelay: 1000
  })
  done()
}

function reload (done) {
  browser.reload()
  done()
}

////////////////////////////////////////////////////////////////////////////////
// CACHE
////////////////////////////////////////////////////////////////////////////////

const clear = series(clean__cache)

// CLEAN -------------------------------------------------------------

function clean__cache () {
  return cache.clearAll()
}

////////////////////////////////////////////////////////////////////////////////
// VENDOR
////////////////////////////////////////////////////////////////////////////////

const vendor = series(clean__vendor, process__vendor_head, process__vendor)

// CLEAN -------------------------------------------------------------

function clean__vendor () {
  return del([config.vendor.dest + '{vendor.head,vendor}.min.js'])
}

// PROCESS -------------------------------------------------------------

function process__vendor_head () {
  return src(config.vendor.head)
    .pipe(gulpif(DEBUG, debug({ title: '## VENDOR_HEAD:' })))
    .pipe(concat('vendor.head.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(config.vendor.dest))
}

function process__vendor () {
  return src(config.vendor.src)
    .pipe(gulpif(DEBUG, debug({ title: '## VENDOR:' })))
    .pipe(concat('vendor.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(config.vendor.dest))
}

////////////////////////////////////////////////////////////////////////////////
// LOGIC
////////////////////////////////////////////////////////////////////////////////

const index__src = (root_src).replace('//', '/')
const index__dest = (root_dist).replace('//', '/')

const snippets__src = (root_src + path.snippets).replace('//', '/')
const snippets__dest = (root_dist + path.snippets).replace('//', '/')

const templates__src = (root_src + path.templates).replace('//', '/')
const templates__dest = (root_dist + path.templates).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__index () { return del([index__dest + 'index.php']) }
function clean__htaccess () { return del([index__dest + '.htaccess']) }
function clean__snippets () { return del([snippets__dest]) }
function clean__templates () { return del([templates__dest]) }

// LINT -------------------------------------------------------------

function lint__logic () {
  return src(['./app/{templates,snippets}/**/*.php', '!index.php'])
    .pipe(gulpif(DEBUG, debug({ title: '## LOGIC:' })))
    .pipe(phpcs({ bin: 'vendor/bin/phpcs', standard: './phpcs.ruleset.xml' }))
    .pipe(phpcs.reporter('log'))
}

// COPY -------------------------------------------------------------

function copy__htaccess () {
  return src([index__src + '.htaccess'])
    .pipe(gulpif(DEBUG, debug({ title: '## HTACCESS:' })))
    .pipe(dest(index__dest))
}

function copy__index () {
  return src([index__src + 'index.php'])
    .pipe(gulpif(DEBUG, debug({ title: '## INDEX:' })))
    .pipe(dest(index__dest))
}

function copy__snippets () {
  return src([snippets__src + '**/*.php'])
    .pipe(gulpif(DEBUG, debug({ title: '## SNIPPETS:' })))
    .pipe(dest(snippets__dest))
}

function copy__templates () {
  return src([templates__src + '**/*.php'])
    .pipe(gulpif(DEBUG, debug({ title: '## TEMPLATES:' })))
    .pipe(dest(templates__dest))
}

// WATCH -------------------------------------------------------------

function watch__logic () {
  watch(index__src + 'index.php', series(index, reload))
  watch(index__src + '.htaccess', series(htaccess, reload))
  watch(snippets__src + '**/*.php', series(snippets, reload))
  watch(templates__src + '**/*.php', series(templates, reload))
}

// COMPOSITION -------------------------------------------------------------

const index = series(clean__index, copy__index)
const htaccess = series(clean__htaccess, copy__htaccess)
const snippets = series(clean__snippets, copy__snippets)
const templates = series(clean__templates, copy__templates)

////////////////////////////////////////////////////////////////////////////////
// ASSETS
////////////////////////////////////////////////////////////////////////////////

const assets__images__src = (root_src + resources + path.assets + path.images).replace('//', '/')
const assets__images__dest = (root_dist + path.assets + path.images).replace('//', '/')

const assets__icons__src = (root_src + resources + path.assets + path.icons).replace('//', '/')
const assets__icons__dest = (root_dist + path.assets + path.icons).replace('//', '/')

const assets__favicons__src = (root_src + resources + path.assets + path.favicons).replace('//', '/')
const assets__favicons__dest = (root_dist + path.assets + path.favicons).replace('//', '/')

const assets__fonts__src = (root_src + resources + path.assets + path.fonts).replace('//', '/')
const assets__fonts__dest = (root_dist + path.assets + path.fonts).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__images () { return del([assets__images__dest]) }
function clean__icons () { return del([assets__icons__dest]) }
function clean__favicons () { return del([assets__favicons__dest]) }
function clean__fonts () { return del([assets__fonts__dest]) }

// PROCESS -------------------------------------------------------------

function process__images () {
  return src(assets__images__src + '**/*.{png,jpg,jpeg,gif}')
    .pipe(debug({ title: '## IMAGES:' }))
    .pipe(cache(imagemin([
      imagemin.gifsicle({ interlaced: true }),
      imagemin.jpegtran({ progressive: true }),
      imagemin.optipng({ optimizationLevel: 7 })
    ])))
    .pipe(dest(assets__images__dest))
}

function process__icons () {
  return src(assets__icons__src + '**/*.svg')
    .pipe(debug({ title: '## ICONS:' }))
    .pipe(cache(imagemin([
      imagemin.svgo({
        plugins: [
          { removeTitle: true },
          { removeViewBox: false },
          { cleanupIDs: true },
          { removeXMLNS: false }
        ],
        verbose: true
      })
    ])))
    .pipe(dest(assets__icons__dest))
}

function process__favicons () {
  return src([assets__favicons__src + 'favicon_src.png'])
    .pipe(favicon({
      background: '#FFFFFF',
      path: assets__favicons__dest,
      url: config.host.live,
      display: 'standalone',
      orientation: 'portrait',
      logging: true,
      online: false,
      replace: true,
      icons: {
        android: PROD ? true : false,
        appleIcon: PROD ? true : false,
        appleStartup: PROD ? true : false,
        coast: PROD ? true : false,
        favicons: true,
        firefox: PROD ? true : false,
        windows: PROD ? true : false,
        yandex: PROD ? true : false
      }
    }))
    .pipe(gulpif(DEBUG, debug({ title: '## FAVICON:' })))
    .pipe(dest(assets__favicons__dest))
}

function copy__fonts () {
  return src([assets__fonts__src + '**/*.{woff,woff2}'])
    .pipe(gulpif(DEBUG, debug({ title: '## FONTS:' })))
    .pipe(dest(assets__fonts__dest))
}

// WATCH -------------------------------------------------------------

function watch__assets () {
  watch(assets__images__src + '**/*.{png,jpg,jpeg,gif}', series(images, reload))
  watch(assets__icons__src + '**/*.svg', series(icons, reload))
  watch(assets__favicons__src + '**/favicon_src.png', series(favicons, reload))
  watch(assets__fonts__src + '**/*.{woff,woff2}', series(fonts, reload))
}

// COMPOSITION -------------------------------------------------------------

const images = series(clean__images, process__images)
const icons = series(clean__icons, process__icons)
const favicons = series(clean__favicons, process__favicons)
const fonts = series(clean__fonts, copy__fonts)

////////////////////////////////////////////////////////////////////////////////
// SCRIPT
////////////////////////////////////////////////////////////////////////////////

const scripts__src = (root_src + path.resources).replace('//', '/')
const scripts__dest = (root_dist).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__scripts__main () { return del(scripts__dest + 'main.min.{js,js.map}') }

// LINT -------------------------------------------------------------

function lint__scripts () {
  return src([scripts__src + 'main.js', snippets__src + '**/script.js'])
    .pipe(gulpif(DEBUG, debug({ title: '## MAIN:' })))
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(gulpif(PROD, eslint.failAfterError()))
}

// PROCESS -------------------------------------------------------------

function process__scripts__main () {
  return src([scripts__src + 'main.js', snippets__src + '**/script.js'], { sourcemaps: !PROD ? true : false })
    .pipe(gulpif(DEBUG, debug({ title: '## MAIN:' })))
    .pipe(concat('main.js'))
    .pipe(gulpif(PROD, uglify()))
    .pipe(rename({ suffix: '.min' }))
    .pipe(dest(scripts__dest, { sourcemaps: !PROD ? '.' : false }))
}

// WATCH -------------------------------------------------------------

function watch__scripts () {
  watch([scripts__src + 'main.js', snippets__src + '**/script.js'], series(scripts__main, reload))
};

// COMPOSITION -------------------------------------------------------------

const scripts__main = series(clean__scripts__main, process__scripts__main)

////////////////////////////////////////////////////////////////////////////////
// STYLE
////////////////////////////////////////////////////////////////////////////////

const styles__src = (root_src + resources).replace('//', '/')
const styles__dest = (root_dist).replace('//', '/')

// CLEAN -------------------------------------------------------------

function clean__styles () { return del(styles__dest + '*.min.{css,css.map}') }

// LINT -------------------------------------------------------------

function lint__styles () {
  return src([styles__src + '**/*.scss', snippets__src + '**/*.scss'])
    .pipe(gulpif(DEBUG, debug({ title: '## STYLE:' })))
    .pipe(stylelint({ syntax: 'scss', reporters: [{ formatter: 'string', console: true }], failAfterError: PROD ? true : false }))
}

// PROCESS -------------------------------------------------------------

function process__styles () {
  scss.compiler = sass
  return src(styles__src + 'main.scss', { sourcemaps: !PROD ? true : false })
    .pipe(gulpif(DEBUG, debug({ title: '## STYLE:' })))
    .pipe(scss({ outputStyle: PROD ? 'compressed' : 'expanded' }).on('error', scss.logError))
    .pipe(autoprefixer()).pipe(rename({ suffix: '.min' }))
    .pipe(dest(styles__dest, { sourcemaps: !PROD ? '.' : false }))
}

// WATCH -------------------------------------------------------------

function watch__styles () {
  watch(snippets__src + '**/*.scss', series(styles, reload))
  watch(styles__src + '**/*.scss', series(styles, reload))
}

// COMPOSITION -------------------------------------------------------------

const styles = series(clean__styles, process__styles)

////////////////////////////////////////////////////////////////////////////////
// COMPOSITION
////////////////////////////////////////////////////////////////////////////////

exports.clear = series(clear)

const LOGIC = series(parallel(index, htaccess, snippets, templates), vendor)
const STYLE = series(parallel(styles, scripts__main))
const ASSET = series(images, icons, favicons, fonts)
const LINT = series(lint__logic, lint__styles, lint__scripts)
const RUN = series(browsersync, parallel(watch__logic, watch__assets, watch__styles, watch__scripts))

if (PROD) {
  exports.default = series(LINT, LOGIC, STYLE, ASSET)
} else {
  exports.default = series(LOGIC, STYLE, ASSET, RUN)
}

////////////////////////////////////////////////////////////////////////////////
// HELPER
////////////////////////////////////////////////////////////////////////////////

function prep (paths) {
  for (var p in paths) {
    var value = paths[p]
    paths[p] = value.length ? value.replace(/\/?$/, '/') : value
  }
  return paths
}
<|endoftext|>


<commit_before>// Wax for Google Maps API v3
// --------------------------

// Wax header
var wax = wax || {};
wax.g = wax.g || {};

// Wax Google Maps MapType: takes an object of options in the form
//
//     {
//       name: '',
//       alt: '',
//       minZoom: 0,
//       minZoom: 18,
//       baseUrl: 'a url',
//     }
wax.g.MapType = function(options) {
    options = options || {};
    this.name = options.name || '';
    this.alt = options.alt || '';
    this.maxZoom = options.maxZoom || 18;
    this.minZoom = options.minZoom || 0;
    this.baseUrl = options.baseUrl ||
        'http://a.tile.mapbox.com/1.0.0/world-light';
    this.blankImage = options.blankImage || '';

    // non-configurable options
    this.interactive = true;
    this.tileSize = new google.maps.Size(256, 256);

    // DOM element cache
    this.cache = {};
};

// Get a tile element from a coordinate, zoom level, and an ownerDocument.
wax.g.MapType.prototype.getTile = function(coord, zoom, ownerDocument) {
    var key = zoom + '/' + coord.x + '/' + coord.y;
    this.cache[key] = this.cache[key] || $('

')
        .addClass('interactive-div-' + zoom)
        .width(256).height(256)
        .data('gTileKey', key)
        .append(
            $('')
            .width(256).height(256)
            .attr('src', this.getTileUrl(coord, zoom))
            .error(function() { $(this).hide() })
        )[0];
    return this.cache[key];
};

// Remove a tile that has fallen out of the map's viewport.
//
// TODO: expire cache data in the gridmanager.
wax.g.MapType.prototype.releaseTile = function(tile) {
    var key = $(tile).data('gTileKey');
    this.cache[key] && delete this.cache[key];
    $(tile).remove();
};

// Get a tile url, based on x, y coordinates and a z value.
wax.g.MapType.prototype.getTileUrl = function(coord, z) {
    // Y coordinate is flipped in Mapbox, compared to Google
    var mod = Math.pow(2, z),
        y = (mod - 1) - coord.y,
        x = (coord.x % mod);
        x = (x < 0) ? (coord.x % mod) + mod : x;
    return (y >= 0)
        ? (this.baseUrl + '/' + z + '/' + x + '/' + y + '.png')
        : this.blankImage;
};
<commit_msg>Reworking Google Maps connector to align with the modest maps spec.<commit_after>// Wax for Google Maps API v3
// --------------------------

// Wax header
var wax = wax || {};
wax.g = wax.g || {};

// Wax Google Maps MapType: takes an object of options in the form
//
//     {
//       name: '',
//       filetype: '.png',
//       layerName: 'world-light',
//       alt: '',
//       zoomRange: [0, 18],
//       baseUrl: 'a url',
//     }
wax.g.MapType = function(options) {
    options = options || {};
    this.name = options.name || '';
    this.alt = options.alt || '';
    this.filetype = options.filetype || '.png';
    this.layerName = options.layerName || 'world-light';
    if (options.zoomRange) {
        this.minZoom = options.zoomRange[0];
        this.maxZoom = options.zoomRange[1];
    } else {
        this.minZoom = 0;
        this.maxZoom = 18;
    }
    this.baseUrl = options.baseUrl ||
        'http://a.tile.mapbox.com/';
    this.blankImage = options.blankImage || '';

    // non-configurable options
    this.interactive = true;
    this.tileSize = new google.maps.Size(256, 256);

    // DOM element cache
    this.cache = {};
};

// Get a tile element from a coordinate, zoom level, and an ownerDocument.
wax.g.MapType.prototype.getTile = function(coord, zoom, ownerDocument) {
    var key = zoom + '/' + coord.x + '/' + coord.y;
    this.cache[key] = this.cache[key] || $('

')
        .addClass('interactive-div-' + zoom)
        .width(256).height(256)
        .data('gTileKey', key)
        .append(
            $('')
            .width(256).height(256)
            .attr('src', this.getTileUrl(coord, zoom))
            .error(function() { $(this).hide() })
        )[0];
    return this.cache[key];
};

// Remove a tile that has fallen out of the map's viewport.
//
// TODO: expire cache data in the gridmanager.
wax.g.MapType.prototype.releaseTile = function(tile) {
    var key = $(tile).data('gTileKey');
    this.cache[key] && delete this.cache[key];
    $(tile).remove();
};

// Get a tile url, based on x, y coordinates and a z value.
wax.g.MapType.prototype.getTileUrl = function(coord, z) {
    // Y coordinate is flipped in Mapbox, compared to Google
    var mod = Math.pow(2, z),
        y = (mod - 1) - coord.y,
        x = (coord.x % mod);
        x = (x < 0) ? (coord.x % mod) + mod : x;

    return (y >= 0)
        ? (this.baseUrl + '1.0.0/' + this.layerName + '/' + z + '/' +
           x + '/' + y + this.filetype)
        : this.blankImage;
};
<|endoftext|>


<commit_before>'use strict';

/* global Connector */

Connector.playerSelector = '#page_sidebar';

Connector.getArtist = function() {
	var artists = $.map($('.player-track-artist').children(), function(artist) {
		return $.text(artist);
	});
	return artists.join(', ');
};

Connector.trackSelector = '.player-track-title';

Connector.trackArtImageSelector = '.player-cover img';

Connector.isPlaying = function () {
	return $('.control').hasClass('control-pause');
};
<commit_msg>Add current time/duration for Deezer connector<commit_after>'use strict';

/* global Connector */

Connector.playerSelector = '#page_sidebar';

Connector.getArtist = function() {
	var artists = $.map($('.player-track-artist').children(), function(artist) {
		return $.text(artist);
	});
	return artists.join(', ');
};

Connector.trackSelector = '.player-track-title';

Connector.currentTimeSelector = '.player-progress .progress-time';

Connector.durationSelector = '.player-progress .progress-length';

Connector.trackArtImageSelector = '.player-cover img';

Connector.isPlaying = function () {
	return $('.control').hasClass('control-pause');
};
<|endoftext|>


<commit_before>var SM = require('source-map'),
	fs = require('fs'),
	path = require('path'),
	wrench = require('wrench'),
	U = require('../../utils'),
	uglifyjs = require('uglify-js'),
	logger = require('../../common/logger'),
	_ = require('../../lib/alloy/underscore')._;

var lineSplitter = /(?:\r\n|\r|\n)/,
	mods = [
		'builtins',
		'optimizer',
		'compress'
	],
	modLocation = './ast/';

exports.OPTIONS_OUTPUT = {
	indent_start  : 0,     // start indentation on every line (only when `beautify`)
	indent_level  : 4,     // indentation level (only when `beautify`)
	quote_keys    : false, // quote all keys in object literals?
	space_colon   : true,  // add a space after colon signs?
	ascii_only    : false, // output ASCII-safe? (encodes Unicode characters as ASCII)
	inline_script : false, // escape "</script"?
	width         : 80,    // informative maximum line width (for beautified output)
	max_line_len  : 32000, // maximum line length (for non-beautified output)
	ie_proof      : false,  // output IE-safe code?
	beautify      : true, // beautify output?
	bracketize    : false, // use brackets every time?
	comments      : false, // output comments?
	semicolons    : true  // use semicolons to separate statements?
};

function mapLine(mapper, theMap, genMap, line) {
	mapper.addMapping({
		original: {
			line: theMap.count++,
			column: 0
		},
		generated: {
			line: genMap.count++,
			column: 0
		},
		source: theMap.filename
	});
	genMap.code += line + '\n';
}

function getTextFromGenerator(content, template) {
	if (typeof content !== 'undefined' && content !== null) {
		return content;
	} else {
		if (template && fs.existsSync(template)) {
			return fs.readFileSync(template,'utf8');
		} else {
			return '';
		}
	}
}

exports.generateCodeAndSourceMap = function(generator, compileConfig) {
	var target = generator.target;
	var data = generator.data;
	var markers = _.map(data, function(v,k) { return k });
	var mapper = new SM.SourceMapGenerator({ file: target.filename });
	var genMap = {
		file: target.filename,
		count: 1,
		code: ''
	}

	// initialize the rest of the generator properties
	target.count = 1;
	target.lines = getTextFromGenerator(target.templateContent,target.template).split(lineSplitter);
	_.each(markers, function(m) {
		var marker = data[m];
		marker.count = 1;
		marker.lines = getTextFromGenerator(marker.fileContent,marker.filepath).split(lineSplitter);
	});

	// generate the source map and composite code
	_.each(target.lines, function(line) {
		var trimmed = U.trim(line);
		if (_.contains(markers, trimmed)) {
			_.each(data[trimmed].lines, function(line) {
				mapLine(mapper, data[trimmed], genMap, line);
			});
		} else {
			mapLine(mapper, target, genMap, line);
		}
	});

	// parse composite code into an AST
	var ast = uglifyjs.parse(genMap.code, { filename: genMap.file });

	// process all AST operations
	_.each(mods, function(mod) {
		logger.trace('- Processing "' + mod + '" module...');
		ast.figure_out_scope();
		ast = require(modLocation+mod).process(ast, compileConfig) || ast;
	});

	// create uglify-js source map and stream it out
	var sourceMap = uglifyjs.SourceMap({
		file: target.filename,
		orig: mapper.toString()
	});
	var stream = uglifyjs.OutputStream(_.extend(_.clone(exports.OPTIONS_OUTPUT), {
		source_map: sourceMap
	}));
	ast.print(stream);

	// create the generated code and source map files
	var outfile = target.filepath;
	wrench.mkdirSyncRecursive(path.dirname(outfile), 0777);
	fs.writeFileSync(outfile, stream.toString());
	logger.info('  created:    "' + path.relative(compileConfig.dir.project,outfile) + '"');

	outfile = outfile + '.map';
	fs.writeFileSync(outfile, sourceMap.toString());
	logger.debug('  map:        "' + outfile + '"');
};<commit_msg>move source map files into PROJECT_DIR/.map folder<commit_after>var SM = require('source-map'),
	fs = require('fs'),
	path = require('path'),
	wrench = require('wrench'),
	U = require('../../utils'),
	CONST = require('../../common/constants'),
	uglifyjs = require('uglify-js'),
	logger = require('../../common/logger'),
	_ = require('../../lib/alloy/underscore')._;

var lineSplitter = /(?:\r\n|\r|\n)/,
	mods = [
		'builtins',
		'optimizer',
		'compress'
	],
	modLocation = './ast/';

exports.OPTIONS_OUTPUT = {
	indent_start  : 0,     // start indentation on every line (only when `beautify`)
	indent_level  : 4,     // indentation level (only when `beautify`)
	quote_keys    : false, // quote all keys in object literals?
	space_colon   : true,  // add a space after colon signs?
	ascii_only    : false, // output ASCII-safe? (encodes Unicode characters as ASCII)
	inline_script : false, // escape "</script"?
	width         : 80,    // informative maximum line width (for beautified output)
	max_line_len  : 32000, // maximum line length (for non-beautified output)
	ie_proof      : false,  // output IE-safe code?
	beautify      : true, // beautify output?
	bracketize    : false, // use brackets every time?
	comments      : false, // output comments?
	semicolons    : true  // use semicolons to separate statements?
};

function mapLine(mapper, theMap, genMap, line) {
	mapper.addMapping({
		original: {
			line: theMap.count++,
			column: 0
		},
		generated: {
			line: genMap.count++,
			column: 0
		},
		source: theMap.filename
	});
	genMap.code += line + '\n';
}

function getTextFromGenerator(content, template) {
	if (typeof content !== 'undefined' && content !== null) {
		return content;
	} else {
		if (template && fs.existsSync(template)) {
			return fs.readFileSync(template,'utf8');
		} else {
			return '';
		}
	}
}

exports.generateCodeAndSourceMap = function(generator, compileConfig) {
	var target = generator.target;
	var data = generator.data;
	var markers = _.map(data, function(v,k) { return k });
	var mapper = new SM.SourceMapGenerator({ file: target.filename });
	var genMap = {
		file: target.filename,
		count: 1,
		code: ''
	}

	// initialize the rest of the generator properties
	target.count = 1;
	target.lines = getTextFromGenerator(target.templateContent,target.template).split(lineSplitter);
	_.each(markers, function(m) {
		var marker = data[m];
		marker.count = 1;
		marker.lines = getTextFromGenerator(marker.fileContent,marker.filepath).split(lineSplitter);
	});

	// generate the source map and composite code
	_.each(target.lines, function(line) {
		var trimmed = U.trim(line);
		if (_.contains(markers, trimmed)) {
			_.each(data[trimmed].lines, function(line) {
				mapLine(mapper, data[trimmed], genMap, line);
			});
		} else {
			mapLine(mapper, target, genMap, line);
		}
	});

	// parse composite code into an AST
	var ast = uglifyjs.parse(genMap.code, { filename: genMap.file });

	// process all AST operations
	_.each(mods, function(mod) {
		logger.trace('- Processing "' + mod + '" module...');
		ast.figure_out_scope();
		ast = require(modLocation+mod).process(ast, compileConfig) || ast;
	});

	// create uglify-js source map and stream it out
	var sourceMap = uglifyjs.SourceMap({
		file: target.filename,
		orig: mapper.toString()
	});
	var stream = uglifyjs.OutputStream(_.extend(_.clone(exports.OPTIONS_OUTPUT), {
		source_map: sourceMap
	}));
	ast.print(stream);

	// create the generated code
	var outfile = target.filepath;
	var relativeOutfile = path.relative(compileConfig.dir.project,outfile);
	wrench.mkdirSyncRecursive(path.dirname(outfile), 0777);
	fs.writeFileSync(outfile, stream.toString());
	logger.info('  created:    "' + relativeOutfile + '"');

	// create source map for the generated file
	var mapDir = path.join(compileConfig.dir.project,CONST.DIR.MAP);
	outfile = path.join(mapDir,relativeOutfile) + '.' + CONST.FILE_EXT.MAP;
	relativeOutfile = path.relative(compileConfig.dir.project,outfile);
	wrench.mkdirSyncRecursive(path.dirname(outfile), 0777);
	fs.writeFileSync(outfile, sourceMap.toString());
	logger.debug('  map:        "' + relativeOutfile + '"');
};<|endoftext|>


<commit_before>import {ac} from 'vendors/AsyncComponent';

import AppRoot from 'examples/containers/AppRoot';

export default function configureRoutes(store) {

    return [{
        component: AppRoot,
        routes: [{
            path: '/landing',
            component: ac(store, () => import('containers/landing/Landing'))
        }, {
            path: '/components',
            component: ac(store, () => import('containers/app/App')),
            routes: [

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- buttons -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/RaisedButton',
                    component: ac(store, () => import('modules/buttons/RaisedButtonExamples'))
                }, {
                    path: '/components/FlatButton',
                    component: ac(store, () => import('modules/buttons/FlatButtonExamples'))
                }, {
                    path: '/components/GhostButton',
                    component: ac(store, () => import('modules/buttons/GhostButtonExamples'))
                }, {
                    path: '/components/IconButton',
                    component: ac(store, () => import('modules/buttons/IconButtonExamples'))
                }, {
                    path: '/components/AnchorButton',
                    component: ac(store, () => import('modules/buttons/AnchorButtonExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Anchor -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Anchor',
                    component: ac(store, () => import('modules/anchor/AnchorExamples'))
                }, {
                    path: '/components/IconAnchor',
                    component: ac(store, () => import('modules/anchor/IconAnchorExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- fields -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/CascaderField',
                    component: ac(store, () => import('modules/fields/CascaderFieldExamples'))
                }, {
                    path: '/components/TextField',
                    component: ac(store, () => import('modules/fields/TextFieldExamples'))
                }, {
                    path: '/components/TextArea',
                    component: ac(store, () => import('modules/fields/TextAreaExamples'))
                }, {
                    path: '/components/RemoteAutoComplete',
                    component: ac(store, () => import('modules/fields/RemoteAutoCompleteExamples'))
                }, {
                    path: '/components/LocalAutoComplete',
                    component: ac(store, () => import('modules/fields/LocalAutoCompleteExamples'))
                }, {
                    path: '/components/DropdownSelect',
                    component: ac(store, () => import('modules/fields/DropdownSelectExamples'))
                }, {
                    path: '/components/MultipleSelect',
                    component: ac(store, () => import('modules/fields/MultipleSelectExamples'))
                }, {
                    path: '/components/TreeSelect',
                    component: ac(store, () => import('modules/fields/TreeSelectExamples'))
                }, {
                    path: '/components/Checkbox',
                    component: ac(store, () => import('modules/fields/CheckboxExamples'))
                }, {
                    path: '/components/RadioGroup',
                    component: ac(store, () => import('modules/fields/RadioGroupExamples'))
                }, {
                    path: '/components/ButtonCheckbox',
                    component: ac(store, () => import('modules/fields/ButtonCheckboxExamples'))
                }, {
                    path: '/components/ButtonRadioGroup',
                    component: ac(store, () => import('modules/fields/ButtonRadioGroupExamples'))
                }, {
                    path: '/components/Switcher',
                    component: ac(store, () => import('modules/fields/SwitcherExamples'))
                }, {
                    path: '/components/Slider',
                    component: ac(store, () => import('modules/fields/SliderExamples'))
                }, {
                    path: '/components/EditableField',
                    component: ac(store, () => import('modules/fields/EditableFieldExamples'))
                }, {
                    path: '/components/FlashNumber',
                    component: ac(store, () => import('modules/fields/FlashNumberExamples'))
                }, {
                    path: '/components/Transfer',
                    component: ac(store, () => import('modules/fields/TransferExamples'))
                }, {
                    path: '/components/TagField',
                    component: ac(store, () => import('modules/fields/TagFieldExamples'))
                }, {
                    path: '/components/Rate',
                    component: ac(store, () => import('modules/fields/RateExamples'))
                }, {
                    path: '/components/EditableSelect',
                    component: ac(store, () => import('modules/fields/EditableSelectExamples'))
                }, {
                    path: '/components/MaterialTextField',
                    component: ac(store, () => import('modules/fields/MaterialTextFieldExamples'))
                }, {
                    path: '/components/MaterialDropdownSelect',
                    component: ac(store, () => import('modules/fields/MaterialDropdownSelectExamples'))
                }, {
                    path: '/components/MaterialLocalAutoComplete',
                    component: ac(store, () => import('modules/fields/MaterialLocalAutoCompleteExamples'))
                }, {
                    path: '/components/MaterialTextArea',
                    component: ac(store, () => import('modules/fields/MaterialTextAreaExamples'))
                }, {
                    path: '/components/MaterialEditableSelect',
                    component: ac(store, () => import('modules/fields/MaterialEditableSelectExamples'))
                }, {
                    path: '/components/MaterialTreeSelect',
                    component: ac(store, () => import('modules/fields/MaterialTreeSelectExamples'))
                }, {
                    path: '/components/DownloadField',
                    component: ac(store, () => import('modules/fields/DownloadFieldExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- filter -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DropdownFilter',
                    component: ac(store, () => import('modules/filter/DropdownFilterExamples'))
                }, {
                    path: '/components/MaterialDropdownFilter',
                    component: ac(store, () => import('modules/filter/MaterialDropdownFilterExamples'))
                }, {
                    path: '/components/AutoCompleteFilter',
                    component: ac(store, () => import('modules/filter/AutoCompleteFilterExamples'))
                }, {
                    path: '/components/MaterialAutoCompleteFilter',
                    component: ac(store, () => import('modules/filter/MaterialAutoCompleteFilterExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- date -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DatePicker',
                    component: ac(store, () => import('modules/date/DatePickerExamples'))
                }, {
                    path: '/components/MonthPicker',
                    component: ac(store, () => import('modules/date/MonthPickerExamples'))
                }, {
                    path: '/components/DateRangePicker',
                    component: ac(store, () => import('modules/date/DateRangePickerExamples'))
                }, {
                    path: '/components/TimePicker',
                    component: ac(store, () => import('modules/date/TimePickerExamples'))
                }, {
                    path: '/components/DateTimePicker',
                    component: ac(store, () => import('modules/date/DateTimePickerExamples'))
                },
                {
                    path: '/components/MaterialDatePicker',
                    component: ac(store, () => import('modules/date/MaterialDatePickerExamples'))
                },
                {
                    path: '/components/MaterialDateTimePicker',
                    component: ac(store, () => import('modules/date/MaterialDateTimePickerExamples'))
                },
                {
                    path: '/components/MaterialTimePicker',
                    component: ac(store, () => import('modules/date/MaterialTimePickerExamples'))
                },
                {
                    path: '/components/MaterialDateRangePicker',
                    component: ac(store, () => import('modules/date/MaterialDateRangePickerExamples'))
                },
                {
                    path: '/components/MaterialMonthPicker',
                    component: ac(store, () => import('modules/date/MaterialMonthPickerExamples'))
                },
                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- popup -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Dialog',
                    component: ac(store, () => import('modules/popup/DialogExamples'))
                }, {
                    path: '/components/Popup',
                    component: ac(store, () => import('modules/popup/PopupExamples'))
                }, {
                    path: '/components/Menu',
                    component: ac(store, () => import('modules/popup/MenuExamples'))
                }, {
                    path: '/components/Tip',
                    component: ac(store, () => import('modules/popup/TipExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- progresses -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/CircularProgress',
                    component: ac(store, () => import('modules/progress/CircularProgressExample'))
                }, {
                    path: '/components/LinearProgress',
                    component: ac(store, () => import('modules/progress/LinearProgressExample'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- layouts -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Crumbs',
                    component: ac(store, () => import('modules/layout/CrumbsExamples'))
                }, {
                    path: '/components/Paper',
                    component: ac(store, () => import('modules/layout/PaperExamples'))
                }, {
                    path: '/components/Widget',
                    component: ac(store, () => import('modules/layout/WidgetExamples'))
                }, {
                    path: '/components/List',
                    component: ac(store, () => import('modules/layout/ListExamples'))
                }, {
                    path: '/components/GroupList',
                    component: ac(store, () => import('modules/layout/GroupListExamples'))
                }, {
                    path: '/components/DynamicRenderList',
                    component: ac(store, () => import('modules/layout/DynamicRenderListExamples'))
                }, {
                    path: '/components/CascaderList',
                    component: ac(store, () => import('modules/layout/CascaderListExamples'))
                }, {
                    path: '/components/Tab',
                    component: ac(store, () => import('modules/layout/TabExamples'))
                }, {
                    path: '/components/Accordion',
                    component: ac(store, () => import('modules/layout/AccordionExamples'))
                }, {
                    path: '/components/Table',
                    component: ac(store, () => import('modules/layout/TableExamples'))
                }, {
                    path: '/components/Waterfall',
                    component: ac(store, () => import('modules/layout/WaterfallExamples'))
                }, {
                    path: '/components/Grid',
                    component: ac(store, () => import('modules/layout/GridExamples'))
                }, {
                    path: '/components/GroupGrid',
                    component: ac(store, () => import('modules/layout/GroupGridExamples'))
                }, {
                    path: '/components/Tree',
                    component: ac(store, () => import('modules/layout/TreeExamples'))
                }, {
                    path: '/components/Dropdown',
                    component: ac(store, () => import('modules/layout/DropdownExamples'))
                }, {
                    path: '/components/MaterialDropdown',
                    component: ac(store, () => import('modules/layout/MaterialDropdownExamples'))
                }, {
                    path: '/components/Pagging',
                    component: ac(store, () => import('modules/layout/PaggingExamples'))
                }, {
                    path: '/components/BriefPagging',
                    component: ac(store, () => import('modules/layout/BriefPaggingExamples'))
                }, {
                    path: '/components/MaterialProvider',
                    component: ac(store, () => import('modules/layout/MaterialProviderExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- draggable -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DraggableList',
                    component: ac(store, () => import('modules/draggable/DraggableListExamples'))
                }, {
                    path: '/components/DraggableGrid',
                    component: ac(store, () => import('modules/draggable/DraggableGridExamples'))
                }, {
                    path: '/components/DraggableTree',
                    component: ac(store, () => import('modules/draggable/DraggableTreeExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- steppers -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/ArrowStep',
                    component: ac(store, () => import('modules/stepper/ArrowStepExamples'))
                }, {
                    path: '/components/RoundStep',
                    component: ac(store, () => import('modules/stepper/RoundStepExamples'))
                }, {
                    path: '/components/ListStep',
                    component: ac(store, () => import('modules/stepper/ListStepExamples'))
                }, {
                    path: '/components/DotStep',
                    component: ac(store, () => import('modules/stepper/DotStepExamples'))
                }, {
                    path: '/components/PointStep',
                    component: ac(store, () => import('modules/stepper/PointStepExamples'))
                }, {
                    path: '/components/VerticalPointStep',
                    component: ac(store, () => import('modules/stepper/VerticalPointStepExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- messages -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Toast',
                    component: ac(store, () => import('modules/message/ToastExamples'))
                }, {
                    path: '/components/Notification',
                    component: ac(store, () => import('modules/message/NotificationExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- timeLine -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/TimeLine',
                    component: ac(store, () => import('modules/timeLine/TimeLineExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- loading -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/SpanLoading',
                    component: ac(store, () => import('modules/loading/SpanLoadingExamples'))
                }, {
                    path: '/components/CircularLoading',
                    component: ac(store, () => import('modules/loading/CircularLoadingExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- media -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/LazyImage',
                    component: ac(store, () => import('modules/media/LazyImageExamples'))
                }, {
                    path: '/components/ColorPicker',
                    component: ac(store, () => import('modules/media/ColorPickerExamples'))
                }, {
                    path: '/components/HuePicker',
                    component: ac(store, () => import('modules/media/HuePickerExamples'))
                }
            ]
        }]
    }];

}<commit_msg>update examples routes<commit_after>import ac from 'components/AsyncComponent';

import AppRoot from 'examples/containers/AppRoot';

export default function configureRoutes(store) {

    return [{
        component: AppRoot,
        routes: [{
            path: '/landing',
            component: ac(store, () => import('containers/landing/Landing'))
        }, {
            path: '/components',
            component: ac(store, () => import('containers/app/App')),
            routes: [

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- buttons -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/RaisedButton',
                    component: ac(store, () => import('modules/buttons/RaisedButtonExamples'))
                }, {
                    path: '/components/FlatButton',
                    component: ac(store, () => import('modules/buttons/FlatButtonExamples'))
                }, {
                    path: '/components/GhostButton',
                    component: ac(store, () => import('modules/buttons/GhostButtonExamples'))
                }, {
                    path: '/components/IconButton',
                    component: ac(store, () => import('modules/buttons/IconButtonExamples'))
                }, {
                    path: '/components/AnchorButton',
                    component: ac(store, () => import('modules/buttons/AnchorButtonExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Anchor -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Anchor',
                    component: ac(store, () => import('modules/anchor/AnchorExamples'))
                }, {
                    path: '/components/IconAnchor',
                    component: ac(store, () => import('modules/anchor/IconAnchorExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- fields -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/CascaderField',
                    component: ac(store, () => import('modules/fields/CascaderFieldExamples'))
                }, {
                    path: '/components/TextField',
                    component: ac(store, () => import('modules/fields/TextFieldExamples'))
                }, {
                    path: '/components/TextArea',
                    component: ac(store, () => import('modules/fields/TextAreaExamples'))
                }, {
                    path: '/components/RemoteAutoComplete',
                    component: ac(store, () => import('modules/fields/RemoteAutoCompleteExamples'))
                }, {
                    path: '/components/LocalAutoComplete',
                    component: ac(store, () => import('modules/fields/LocalAutoCompleteExamples'))
                }, {
                    path: '/components/DropdownSelect',
                    component: ac(store, () => import('modules/fields/DropdownSelectExamples'))
                }, {
                    path: '/components/MultipleSelect',
                    component: ac(store, () => import('modules/fields/MultipleSelectExamples'))
                }, {
                    path: '/components/TreeSelect',
                    component: ac(store, () => import('modules/fields/TreeSelectExamples'))
                }, {
                    path: '/components/Checkbox',
                    component: ac(store, () => import('modules/fields/CheckboxExamples'))
                }, {
                    path: '/components/RadioGroup',
                    component: ac(store, () => import('modules/fields/RadioGroupExamples'))
                }, {
                    path: '/components/ButtonCheckbox',
                    component: ac(store, () => import('modules/fields/ButtonCheckboxExamples'))
                }, {
                    path: '/components/ButtonRadioGroup',
                    component: ac(store, () => import('modules/fields/ButtonRadioGroupExamples'))
                }, {
                    path: '/components/Switcher',
                    component: ac(store, () => import('modules/fields/SwitcherExamples'))
                }, {
                    path: '/components/Slider',
                    component: ac(store, () => import('modules/fields/SliderExamples'))
                }, {
                    path: '/components/EditableField',
                    component: ac(store, () => import('modules/fields/EditableFieldExamples'))
                }, {
                    path: '/components/FlashNumber',
                    component: ac(store, () => import('modules/fields/FlashNumberExamples'))
                }, {
                    path: '/components/Transfer',
                    component: ac(store, () => import('modules/fields/TransferExamples'))
                }, {
                    path: '/components/TagField',
                    component: ac(store, () => import('modules/fields/TagFieldExamples'))
                }, {
                    path: '/components/Rate',
                    component: ac(store, () => import('modules/fields/RateExamples'))
                }, {
                    path: '/components/EditableSelect',
                    component: ac(store, () => import('modules/fields/EditableSelectExamples'))
                }, {
                    path: '/components/MaterialTextField',
                    component: ac(store, () => import('modules/fields/MaterialTextFieldExamples'))
                }, {
                    path: '/components/MaterialDropdownSelect',
                    component: ac(store, () => import('modules/fields/MaterialDropdownSelectExamples'))
                }, {
                    path: '/components/MaterialLocalAutoComplete',
                    component: ac(store, () => import('modules/fields/MaterialLocalAutoCompleteExamples'))
                }, {
                    path: '/components/MaterialTextArea',
                    component: ac(store, () => import('modules/fields/MaterialTextAreaExamples'))
                }, {
                    path: '/components/MaterialEditableSelect',
                    component: ac(store, () => import('modules/fields/MaterialEditableSelectExamples'))
                }, {
                    path: '/components/MaterialTreeSelect',
                    component: ac(store, () => import('modules/fields/MaterialTreeSelectExamples'))
                }, {
                    path: '/components/DownloadField',
                    component: ac(store, () => import('modules/fields/DownloadFieldExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- filter -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DropdownFilter',
                    component: ac(store, () => import('modules/filter/DropdownFilterExamples'))
                }, {
                    path: '/components/MaterialDropdownFilter',
                    component: ac(store, () => import('modules/filter/MaterialDropdownFilterExamples'))
                }, {
                    path: '/components/AutoCompleteFilter',
                    component: ac(store, () => import('modules/filter/AutoCompleteFilterExamples'))
                }, {
                    path: '/components/MaterialAutoCompleteFilter',
                    component: ac(store, () => import('modules/filter/MaterialAutoCompleteFilterExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- date -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DatePicker',
                    component: ac(store, () => import('modules/date/DatePickerExamples'))
                }, {
                    path: '/components/MonthPicker',
                    component: ac(store, () => import('modules/date/MonthPickerExamples'))
                }, {
                    path: '/components/DateRangePicker',
                    component: ac(store, () => import('modules/date/DateRangePickerExamples'))
                }, {
                    path: '/components/TimePicker',
                    component: ac(store, () => import('modules/date/TimePickerExamples'))
                }, {
                    path: '/components/DateTimePicker',
                    component: ac(store, () => import('modules/date/DateTimePickerExamples'))
                },
                {
                    path: '/components/MaterialDatePicker',
                    component: ac(store, () => import('modules/date/MaterialDatePickerExamples'))
                },
                {
                    path: '/components/MaterialDateTimePicker',
                    component: ac(store, () => import('modules/date/MaterialDateTimePickerExamples'))
                },
                {
                    path: '/components/MaterialTimePicker',
                    component: ac(store, () => import('modules/date/MaterialTimePickerExamples'))
                },
                {
                    path: '/components/MaterialDateRangePicker',
                    component: ac(store, () => import('modules/date/MaterialDateRangePickerExamples'))
                },
                {
                    path: '/components/MaterialMonthPicker',
                    component: ac(store, () => import('modules/date/MaterialMonthPickerExamples'))
                },
                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- popup -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Dialog',
                    component: ac(store, () => import('modules/popup/DialogExamples'))
                }, {
                    path: '/components/Popup',
                    component: ac(store, () => import('modules/popup/PopupExamples'))
                }, {
                    path: '/components/Menu',
                    component: ac(store, () => import('modules/popup/MenuExamples'))
                }, {
                    path: '/components/Tip',
                    component: ac(store, () => import('modules/popup/TipExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- progresses -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/CircularProgress',
                    component: ac(store, () => import('modules/progress/CircularProgressExample'))
                }, {
                    path: '/components/LinearProgress',
                    component: ac(store, () => import('modules/progress/LinearProgressExample'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- layouts -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Crumbs',
                    component: ac(store, () => import('modules/layout/CrumbsExamples'))
                }, {
                    path: '/components/Paper',
                    component: ac(store, () => import('modules/layout/PaperExamples'))
                }, {
                    path: '/components/Widget',
                    component: ac(store, () => import('modules/layout/WidgetExamples'))
                }, {
                    path: '/components/List',
                    component: ac(store, () => import('modules/layout/ListExamples'))
                }, {
                    path: '/components/GroupList',
                    component: ac(store, () => import('modules/layout/GroupListExamples'))
                }, {
                    path: '/components/DynamicRenderList',
                    component: ac(store, () => import('modules/layout/DynamicRenderListExamples'))
                }, {
                    path: '/components/CascaderList',
                    component: ac(store, () => import('modules/layout/CascaderListExamples'))
                }, {
                    path: '/components/Tab',
                    component: ac(store, () => import('modules/layout/TabExamples'))
                }, {
                    path: '/components/Accordion',
                    component: ac(store, () => import('modules/layout/AccordionExamples'))
                }, {
                    path: '/components/Table',
                    component: ac(store, () => import('modules/layout/TableExamples'))
                }, {
                    path: '/components/Waterfall',
                    component: ac(store, () => import('modules/layout/WaterfallExamples'))
                }, {
                    path: '/components/Grid',
                    component: ac(store, () => import('modules/layout/GridExamples'))
                }, {
                    path: '/components/GroupGrid',
                    component: ac(store, () => import('modules/layout/GroupGridExamples'))
                }, {
                    path: '/components/Tree',
                    component: ac(store, () => import('modules/layout/TreeExamples'))
                }, {
                    path: '/components/Dropdown',
                    component: ac(store, () => import('modules/layout/DropdownExamples'))
                }, {
                    path: '/components/MaterialDropdown',
                    component: ac(store, () => import('modules/layout/MaterialDropdownExamples'))
                }, {
                    path: '/components/Pagging',
                    component: ac(store, () => import('modules/layout/PaggingExamples'))
                }, {
                    path: '/components/BriefPagging',
                    component: ac(store, () => import('modules/layout/BriefPaggingExamples'))
                }, {
                    path: '/components/MaterialProvider',
                    component: ac(store, () => import('modules/layout/MaterialProviderExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- draggable -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/DraggableList',
                    component: ac(store, () => import('modules/draggable/DraggableListExamples'))
                }, {
                    path: '/components/DraggableGrid',
                    component: ac(store, () => import('modules/draggable/DraggableGridExamples'))
                }, {
                    path: '/components/DraggableTree',
                    component: ac(store, () => import('modules/draggable/DraggableTreeExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- steppers -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/ArrowStep',
                    component: ac(store, () => import('modules/stepper/ArrowStepExamples'))
                }, {
                    path: '/components/RoundStep',
                    component: ac(store, () => import('modules/stepper/RoundStepExamples'))
                }, {
                    path: '/components/ListStep',
                    component: ac(store, () => import('modules/stepper/ListStepExamples'))
                }, {
                    path: '/components/DotStep',
                    component: ac(store, () => import('modules/stepper/DotStepExamples'))
                }, {
                    path: '/components/PointStep',
                    component: ac(store, () => import('modules/stepper/PointStepExamples'))
                }, {
                    path: '/components/VerticalPointStep',
                    component: ac(store, () => import('modules/stepper/VerticalPointStepExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- messages -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/Toast',
                    component: ac(store, () => import('modules/message/ToastExamples'))
                }, {
                    path: '/components/Notification',
                    component: ac(store, () => import('modules/message/NotificationExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- timeLine -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/TimeLine',
                    component: ac(store, () => import('modules/timeLine/TimeLineExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- loading -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/SpanLoading',
                    component: ac(store, () => import('modules/loading/SpanLoadingExamples'))
                }, {
                    path: '/components/CircularLoading',
                    component: ac(store, () => import('modules/loading/CircularLoadingExamples'))
                },

                /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- media -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
                {
                    path: '/components/LazyImage',
                    component: ac(store, () => import('modules/media/LazyImageExamples'))
                }, {
                    path: '/components/ColorPicker',
                    component: ac(store, () => import('modules/media/ColorPickerExamples'))
                }, {
                    path: '/components/HuePicker',
                    component: ac(store, () => import('modules/media/HuePickerExamples'))
                }
            ]
        }]
    }];

}<|endoftext|>


<commit_before>/*
 * Copyright 2014 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Externs for ui-router.
 *
 * API Reference: http://angular-ui.github.io/ui-router/site/#/api/ui.router
 *
 * @externs
 */

/**
 * @type {Object}
 * @const
 */
var ui = {};

/**
 * @type {Object}
 * @const
 */
ui.router = {};

/**
 * @typedef {{
 *   params: Object,
 *   current: Object,
 *   transition: ?angular.$q.Promise,
 *   get: function(...),
 *   go: function(...),
 *   href: function(...),
 *   includes: function(...),
 *   is: function(...),
 *   reload: function(...),
 *   transitionTo: function(...)
 * }}
 */
ui.router.$state;

/**
 * @type {ui.router.State}
 */
ui.router.$state.current;

/**
 * @type {Object}
 */
ui.router.$state.params;

/**
 * @type {?angular.$q.Promise}
 */
ui.router.$state.transition;

/**
 * @param {?string|Object=} stateOrName
 * @param {?string|Object=} context
 * @return {Object|Array}
 */
ui.router.$state.get = function(stateOrName, context) {};

/**
 * @param {string} to
 * @param {Object=} params
 * @param {(ui.router.$state.GoOptions_|Object)=} options
 * @returns {angular.$q.Promise}
 */
ui.router.$state.go = function(to, params, options) {};

/**
 * @param {?string|Object} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 * @returns {string} compiled state url
 */
ui.router.$state.href = function(stateOrName, params, options) {};

/**
 * @param {?string} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 */
ui.router.$state.includes = function(stateOrName, params, options) {};

/**
 * @param {?string|Object} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 * @returns {boolean}
 */
ui.router.$state.is = function(stateOrName, params, options) {};

/**
 * @returns {angular.$q.Promise}
 */
ui.router.$state.reload = function() {};

/**
 * @param {string} to
 * @param {Object=} toParams
 * @param {Object=} options
 */
ui.router.$state.transitionTo = function(to, toParams, options) {};

/**
 * @typedef {{
 *   location: (boolean|string|undefined),
 *   inherit: (boolean|undefined),
 *   relative: (Object|undefined),
 *   notify: (boolean|undefined),
 *   reload: (boolean|undefined)
 * }}
 */
ui.router.$state.GoOptions_;

/**
 * @typedef {Object.<string, string>}
 */
ui.router.$stateParams;

/**
 * This is the object that the ui-router passes to callback functions listening
 * on ui router events such as {@code $stateChangeStart} or
 * {@code $stateChangeError} as the {@code toState} and {@code fromState}.
 * Example:
 * $rootScope.$on('$stateChangeStart', function(
 *     event, toState, toParams, fromState, fromParams){ ... });
 *
 * @typedef {{
 *     'abstract': (boolean|undefined),
 *     controller: (string|Function|undefined),
 *     controllerAs: (string|undefined),
 *     controllerProvider: (Function|undefined),
 *     data: (Object|undefined),
 *     name: string,
 *     onEnter: (Object|undefined),
 *     onExit: (Object|undefined),
 *     params: (Object|undefined),
 *     reloadOnSearch: (boolean|undefined),
 *     resolve: (Object.<string, !Function>|undefined),
 *     template: (string|Function|undefined),
 *     templateUrl: (string|Function|undefined),
 *     templateProvider: (Function|undefined),
 *     url: (string|undefined),
 *     views: (Object|undefined)
 * }}
 */
ui.router.State;

/**
 * @constructor
 */
ui.router.$urlMatcherFactory = function() {};

/**
 * @constructor
 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory
 */
ui.router.$urlRouterProvider = function($urlMatcherFactory) {};

/**
 * @param {string|RegExp} url
 * @param {string|function(...)|Array.<!Object>} route
 */
ui.router.$urlRouterProvider.prototype.when = function(url, route) {};

/**
 * @param {string|function(...)} path
 */
ui.router.$urlRouterProvider.prototype.otherwise = function(path) {};

/**
 * @param {function(...)} rule
 */
ui.router.$urlRouterProvider.prototype.rule = function(rule) {};

/**
 * @constructor
 * @param {!ui.router.$urlRouterProvider} $urlRouterProvider
 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory
 * @param {!angular.$locationProvider} $locationProvider
 */
ui.router.$stateProvider = function(
    $urlRouterProvider, $urlMatcherFactory, $locationProvider) {};

/**
 * @param {!string} name
 * @param {Object} definition
 * @return {!ui.router.$stateProvider}
 */
ui.router.$stateProvider.prototype.state = function(name, definition) {};
<commit_msg>Move the ui.router.$state.GoOptions_ definition prior to first reference.<commit_after>/*
 * Copyright 2014 The Closure Compiler Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Externs for ui-router.
 *
 * API Reference: http://angular-ui.github.io/ui-router/site/#/api/ui.router
 *
 * @externs
 */

/**
 * @type {Object}
 * @const
 */
var ui = {};

/**
 * @type {Object}
 * @const
 */
ui.router = {};

/**
 * @typedef {{
 *   params: Object,
 *   current: Object,
 *   transition: ?angular.$q.Promise,
 *   get: function(...),
 *   go: function(...),
 *   href: function(...),
 *   includes: function(...),
 *   is: function(...),
 *   reload: function(...),
 *   transitionTo: function(...)
 * }}
 */
ui.router.$state;

/**
 * @type {ui.router.State}
 */
ui.router.$state.current;

/**
 * @type {Object}
 */
ui.router.$state.params;

/**
 * @type {?angular.$q.Promise}
 */
ui.router.$state.transition;

/**
 * @param {?string|Object=} stateOrName
 * @param {?string|Object=} context
 * @return {Object|Array}
 */
ui.router.$state.get = function(stateOrName, context) {};

/**
 * @typedef {{
 *   location: (boolean|string|undefined),
 *   inherit: (boolean|undefined),
 *   relative: (Object|undefined),
 *   notify: (boolean|undefined),
 *   reload: (boolean|undefined)
 * }}
 */
ui.router.$state.GoOptions_;

/**
 * @param {string} to
 * @param {Object=} params
 * @param {(ui.router.$state.GoOptions_|Object)=} options
 * @returns {angular.$q.Promise}
 */
ui.router.$state.go = function(to, params, options) {};

/**
 * @param {?string|Object} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 * @returns {string} compiled state url
 */
ui.router.$state.href = function(stateOrName, params, options) {};

/**
 * @param {?string} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 */
ui.router.$state.includes = function(stateOrName, params, options) {};

/**
 * @param {?string|Object} stateOrName
 * @param {Object=} params
 * @param {Object=} options
 * @returns {boolean}
 */
ui.router.$state.is = function(stateOrName, params, options) {};

/**
 * @returns {angular.$q.Promise}
 */
ui.router.$state.reload = function() {};

/**
 * @param {string} to
 * @param {Object=} toParams
 * @param {Object=} options
 */
ui.router.$state.transitionTo = function(to, toParams, options) {};

/**
 * @typedef {Object.<string, string>}
 */
ui.router.$stateParams;

/**
 * This is the object that the ui-router passes to callback functions listening
 * on ui router events such as {@code $stateChangeStart} or
 * {@code $stateChangeError} as the {@code toState} and {@code fromState}.
 * Example:
 * $rootScope.$on('$stateChangeStart', function(
 *     event, toState, toParams, fromState, fromParams){ ... });
 *
 * @typedef {{
 *     'abstract': (boolean|undefined),
 *     controller: (string|Function|undefined),
 *     controllerAs: (string|undefined),
 *     controllerProvider: (Function|undefined),
 *     data: (Object|undefined),
 *     name: string,
 *     onEnter: (Object|undefined),
 *     onExit: (Object|undefined),
 *     params: (Object|undefined),
 *     reloadOnSearch: (boolean|undefined),
 *     resolve: (Object.<string, !Function>|undefined),
 *     template: (string|Function|undefined),
 *     templateUrl: (string|Function|undefined),
 *     templateProvider: (Function|undefined),
 *     url: (string|undefined),
 *     views: (Object|undefined)
 * }}
 */
ui.router.State;

/**
 * @constructor
 */
ui.router.$urlMatcherFactory = function() {};

/**
 * @constructor
 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory
 */
ui.router.$urlRouterProvider = function($urlMatcherFactory) {};

/**
 * @param {string|RegExp} url
 * @param {string|function(...)|Array.<!Object>} route
 */
ui.router.$urlRouterProvider.prototype.when = function(url, route) {};

/**
 * @param {string|function(...)} path
 */
ui.router.$urlRouterProvider.prototype.otherwise = function(path) {};

/**
 * @param {function(...)} rule
 */
ui.router.$urlRouterProvider.prototype.rule = function(rule) {};

/**
 * @constructor
 * @param {!ui.router.$urlRouterProvider} $urlRouterProvider
 * @param {!ui.router.$urlMatcherFactory} $urlMatcherFactory
 * @param {!angular.$locationProvider} $locationProvider
 */
ui.router.$stateProvider = function(
    $urlRouterProvider, $urlMatcherFactory, $locationProvider) {};

/**
 * @param {!string} name
 * @param {Object} definition
 * @return {!ui.router.$stateProvider}
 */
ui.router.$stateProvider.prototype.state = function(name, definition) {};
<|endoftext|>


<commit_before>var fs = require('fs')
var path = require('path')
var glob = require('glob')

// more popular packages should go here, maybe?
function isTestPkg (p) {
  return !!p.match(/^(expresso|mocha|tap|coffee-script|coco|streamline)$/)
}

function niceName (n) {
  return n.replace(/^node-|[.-]js$/g, '')
}

function readDeps (test) { return function (cb) {
  fs.readdir('node_modules', function (er, dir) {
    if (er) return cb()
    var deps = {}
    var n = dir.length
    if (n === 0) return cb(null, deps)
    dir.forEach(function (d) {
      if (d.match(/^\./)) return next()
      if (test !== isTestPkg(d))
        return next()

      var dp = path.join(dirname, 'node_modules', d, 'package.json')
      fs.readFile(dp, 'utf8', function (er, p) {
        if (er) return next()
        try { p = JSON.parse(p) }
        catch (e) { return next() }
        if (!p.version) return next()
        deps[d] = config.get('save-prefix') + p.version
        return next()
      })
    })
    function next () {
      if (--n === 0) return cb(null, deps)
    }
  })
}}

exports.name = prompt('name', package.name || basename)
exports.version = prompt('version', package.version || config.get('init.version') || '0.0.0')
if (!package.description) {
  exports.description = prompt('description')
}

if (!package.main) {
  exports.main = function (cb) {
    fs.readdir(dirname, function (er, f) {
      if (er) f = []

      f = f.filter(function (f) {
        return f.match(/\.js$/)
      })

      if (f.indexOf('index.js') !== -1)
        f = 'index.js'
      else if (f.indexOf('main.js') !== -1)
        f = 'main.js'
      else if (f.indexOf(basename + '.js') !== -1)
        f = basename + '.js'
      else
        f = f[0]

      return cb(null, prompt('entry point', f || 'index.js'))
    })
  }
}

if (!package.bin) {
  exports.bin = function (cb) {
    fs.readdir(path.resolve(dirname, 'bin'), function (er, d) {
      // no bins
      if (er) return cb()
      // just take the first js file we find there, or nada
      return cb(null, d.filter(function (f) {
        return f.match(/\.js$/)
      })[0])
    })
  }
}

exports.directories = function (cb) {
  fs.readdir(dirname, function (er, dirs) {
    if (er) return cb(er)
    var res = {}
    dirs.forEach(function (d) {
      switch (d) {
        case 'example': case 'examples': return res.example = d
        case 'test': case 'tests': return res.test = d
        case 'doc': case 'docs': return res.doc = d
        case 'man': return res.man = d
      }
    })
    if (Object.keys(res).length === 0) res = undefined
    return cb(null, res)
  })
}

if (!package.dependencies) {
  exports.dependencies = readDeps(false)
}

if (!package.devDependencies) {
  exports.devDependencies = readDeps(true)
}

// MUST have a test script!
var s = package.scripts || {}
var notest = 'echo "Error: no test specified" && exit 1'
if (!package.scripts) {
  exports.scripts = function (cb) {
    fs.readdir(path.join(dirname, 'node_modules'), function (er, d) {
      setupScripts(d || [], cb)
    })
  }
}
function setupScripts (d, cb) {
  // check to see what framework is in use, if any
  function tx (test) {
    return test || notest
  }

  if (!s.test || s.test === notest) {
    if (d.indexOf('tap') !== -1)
      s.test = prompt('test command', 'tap test/*.js', tx)
    else if (d.indexOf('expresso') !== -1)
      s.test = prompt('test command', 'expresso test', tx)
    else if (d.indexOf('mocha') !== -1)
      s.test = prompt('test command', 'mocha', tx)
    else
      s.test = prompt('test command', tx)
  }

  return cb(null, s)
}

if (!package.repository) {
  exports.repository = function (cb) {
    fs.readFile('.git/config', 'utf8', function (er, gconf) {
      if (er || !gconf) return cb(null, prompt('git repository'))

      gconf = gconf.split(/\r?\n/)
      var i = gconf.indexOf('[remote "origin"]')
      if (i !== -1) {
        var u = gconf[i + 1]
        if (!u.match(/^\s*url =/)) u = gconf[i + 2]
        if (!u.match(/^\s*url =/)) u = null
        else u = u.replace(/^\s*url = /, '')
      }
      if (u && u.match(/^git@github.com:/))
        u = u.replace(/^git@github.com:/, 'https://github.com/')

      return cb(null, prompt('git repository', u))
    })
  }
}

if (!package.keywords) {
  exports.keywords = prompt('keywords', function (s) {
    if (!s) return undefined
    if (Array.isArray(s)) s = s.join(' ')
    if (typeof s !== 'string') return s
    return s.split(/[\s,]+/)
  })
}

if (!package.author) {
  exports.author = config.get('init.author.name')
  ? {
      "name" : config.get('init.author.name'),
      "email" : config.get('init.author.email'),
      "url" : config.get('init.author.url')
    }
  : prompt('author')
}

exports.license = prompt('license', package.license ||
                         config.get('init.license') ||
                         'ISC')
<commit_msg>Default to version 1.0.0<commit_after>var fs = require('fs')
var path = require('path')
var glob = require('glob')

// more popular packages should go here, maybe?
function isTestPkg (p) {
  return !!p.match(/^(expresso|mocha|tap|coffee-script|coco|streamline)$/)
}

function niceName (n) {
  return n.replace(/^node-|[.-]js$/g, '')
}

function readDeps (test) { return function (cb) {
  fs.readdir('node_modules', function (er, dir) {
    if (er) return cb()
    var deps = {}
    var n = dir.length
    if (n === 0) return cb(null, deps)
    dir.forEach(function (d) {
      if (d.match(/^\./)) return next()
      if (test !== isTestPkg(d))
        return next()

      var dp = path.join(dirname, 'node_modules', d, 'package.json')
      fs.readFile(dp, 'utf8', function (er, p) {
        if (er) return next()
        try { p = JSON.parse(p) }
        catch (e) { return next() }
        if (!p.version) return next()
        deps[d] = config.get('save-prefix') + p.version
        return next()
      })
    })
    function next () {
      if (--n === 0) return cb(null, deps)
    }
  })
}}

exports.name = prompt('name', package.name || basename)
exports.version = prompt('version', package.version || config.get('init.version') || '1.0.0')
if (!package.description) {
  exports.description = prompt('description')
}

if (!package.main) {
  exports.main = function (cb) {
    fs.readdir(dirname, function (er, f) {
      if (er) f = []

      f = f.filter(function (f) {
        return f.match(/\.js$/)
      })

      if (f.indexOf('index.js') !== -1)
        f = 'index.js'
      else if (f.indexOf('main.js') !== -1)
        f = 'main.js'
      else if (f.indexOf(basename + '.js') !== -1)
        f = basename + '.js'
      else
        f = f[0]

      return cb(null, prompt('entry point', f || 'index.js'))
    })
  }
}

if (!package.bin) {
  exports.bin = function (cb) {
    fs.readdir(path.resolve(dirname, 'bin'), function (er, d) {
      // no bins
      if (er) return cb()
      // just take the first js file we find there, or nada
      return cb(null, d.filter(function (f) {
        return f.match(/\.js$/)
      })[0])
    })
  }
}

exports.directories = function (cb) {
  fs.readdir(dirname, function (er, dirs) {
    if (er) return cb(er)
    var res = {}
    dirs.forEach(function (d) {
      switch (d) {
        case 'example': case 'examples': return res.example = d
        case 'test': case 'tests': return res.test = d
        case 'doc': case 'docs': return res.doc = d
        case 'man': return res.man = d
      }
    })
    if (Object.keys(res).length === 0) res = undefined
    return cb(null, res)
  })
}

if (!package.dependencies) {
  exports.dependencies = readDeps(false)
}

if (!package.devDependencies) {
  exports.devDependencies = readDeps(true)
}

// MUST have a test script!
var s = package.scripts || {}
var notest = 'echo "Error: no test specified" && exit 1'
if (!package.scripts) {
  exports.scripts = function (cb) {
    fs.readdir(path.join(dirname, 'node_modules'), function (er, d) {
      setupScripts(d || [], cb)
    })
  }
}
function setupScripts (d, cb) {
  // check to see what framework is in use, if any
  function tx (test) {
    return test || notest
  }

  if (!s.test || s.test === notest) {
    if (d.indexOf('tap') !== -1)
      s.test = prompt('test command', 'tap test/*.js', tx)
    else if (d.indexOf('expresso') !== -1)
      s.test = prompt('test command', 'expresso test', tx)
    else if (d.indexOf('mocha') !== -1)
      s.test = prompt('test command', 'mocha', tx)
    else
      s.test = prompt('test command', tx)
  }

  return cb(null, s)
}

if (!package.repository) {
  exports.repository = function (cb) {
    fs.readFile('.git/config', 'utf8', function (er, gconf) {
      if (er || !gconf) return cb(null, prompt('git repository'))

      gconf = gconf.split(/\r?\n/)
      var i = gconf.indexOf('[remote "origin"]')
      if (i !== -1) {
        var u = gconf[i + 1]
        if (!u.match(/^\s*url =/)) u = gconf[i + 2]
        if (!u.match(/^\s*url =/)) u = null
        else u = u.replace(/^\s*url = /, '')
      }
      if (u && u.match(/^git@github.com:/))
        u = u.replace(/^git@github.com:/, 'https://github.com/')

      return cb(null, prompt('git repository', u))
    })
  }
}

if (!package.keywords) {
  exports.keywords = prompt('keywords', function (s) {
    if (!s) return undefined
    if (Array.isArray(s)) s = s.join(' ')
    if (typeof s !== 'string') return s
    return s.split(/[\s,]+/)
  })
}

if (!package.author) {
  exports.author = config.get('init.author.name')
  ? {
      "name" : config.get('init.author.name'),
      "email" : config.get('init.author.email'),
      "url" : config.get('init.author.url')
    }
  : prompt('author')
}

exports.license = prompt('license', package.license ||
                         config.get('init.license') ||
                         'ISC')
<|endoftext|>


<commit_before>var util = require('../util'),
  consts = require('../consts'),
  vl = require('vegalite');

module.exports = projections;

/**
 * fields
 * @param  {[type]} fields array of fields and query information
 * @return {[type]}        [description]
 */
function projections(fields, opt) {
  opt = vl.schema.util.extend(opt||{}, consts.gen.projections);
  // TODO support other mode of projections generation
  // powerset, chooseK, chooseKorLess are already included in the util
  // Right now just add one more field

  var selected = [], unselected = [], fieldSets = [];

  fields.forEach(function(field){
    if (field.selected) {
      selected.push(field);
    } else {
      unselected.push(field);
    }
  });

  var setsToAdd = util.chooseKorLess(unselected, 1);

  setsToAdd.forEach(function(setToAdd) {
    var fieldSet = selected.concat(setToAdd);
    if (fieldSet.length > 0) {
      if (fieldSet.length === 1 && vl.field.isCount(fieldSet[0])) {
        return;
      }
      // always append projection's key to each projection returned, d3 style.
      fieldSets.push(fieldSet);
    }
  });

  if (opt.addCountIfNothingIsSelected && selected.length===0) {
    var countField = vl.field.count();

    unselected.forEach(function(field) {
      if (!vl.field.isCount(field)) {
        fieldSets.push([field, countField]);
      }
    });
  }

  fieldSets.forEach(function(fieldSet) {
    fieldSet.key = projections.key(fieldSet);
  });

  return fieldSets;
}

projections.key = function(projection) {
  return projection.map(function(field) {
    return field.name;
  }).join(',');
};
<commit_msg>generate better key for count<commit_after>var util = require('../util'),
  consts = require('../consts'),
  vl = require('vegalite');

module.exports = projections;

/**
 * fields
 * @param  {[type]} fields array of fields and query information
 * @return {[type]}        [description]
 */
function projections(fields, opt) {
  opt = vl.schema.util.extend(opt||{}, consts.gen.projections);
  // TODO support other mode of projections generation
  // powerset, chooseK, chooseKorLess are already included in the util
  // Right now just add one more field

  var selected = [], unselected = [], fieldSets = [];

  fields.forEach(function(field){
    if (field.selected) {
      selected.push(field);
    } else {
      unselected.push(field);
    }
  });

  var setsToAdd = util.chooseKorLess(unselected, 1);

  setsToAdd.forEach(function(setToAdd) {
    var fieldSet = selected.concat(setToAdd);
    if (fieldSet.length > 0) {
      if (fieldSet.length === 1 && vl.field.isCount(fieldSet[0])) {
        return;
      }
      // always append projection's key to each projection returned, d3 style.
      fieldSets.push(fieldSet);
    }
  });

  if (opt.addCountIfNothingIsSelected && selected.length===0) {
    var countField = vl.field.count();

    unselected.forEach(function(field) {
      if (!vl.field.isCount(field)) {
        fieldSets.push([field, countField]);
      }
    });
  }

  fieldSets.forEach(function(fieldSet) {
    fieldSet.key = projections.key(fieldSet);
  });

  return fieldSets;
}

projections.key = function(projection) {
  return projection.map(function(field) {
    return vl.field.isCount(field) ? 'count' : field.name;
  }).join(',');
};
<|endoftext|>