<commit_before>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Basic 2-dimensional vector
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  var dot = require( 'DOT/dot' );

  var inherit = require( 'PHET_CORE/inherit' );
  var Poolable = require( 'PHET_CORE/Poolable' );
  require( 'DOT/Util' );
  // require( 'DOT/Vector3' ); // commented out since Require.js complains about the circular dependency

  dot.Vector2 = function Vector2( x, y ) {
    // allow optional parameters
    this.x = x !== undefined ? x : 0;
    this.y = y !== undefined ? y : 0;

    assert && assert( typeof this.x === 'number', 'x needs to be a number' );
    assert && assert( typeof this.y === 'number', 'y needs to be a number' );

    phetAllocation && phetAllocation( 'Vector2' );
  };
  var Vector2 = dot.Vector2;

  Vector2.createPolar = function( magnitude, angle ) {
    return new Vector2().setPolar( magnitude, angle );
  };

  Vector2.prototype = {
    constructor: Vector2,
    isVector2: true,
    dimension: 2,

    magnitude: function() {
      return Math.sqrt( this.magnitudeSquared() );
    },

    magnitudeSquared: function() {
      return this.x * this.x + this.y * this.y;
    },

    // the distance between this vector (treated as a point) and another point
    distance: function( point ) {
      return Math.sqrt( this.distanceSquared( point ) );
    },

    // the distance between this vector (treated as a point) and another point specified as x:Number, y:Number
    distanceXY: function( x, y ) {
      var dx = this.x - x;
      var dy = this.y - y;
      return Math.sqrt( dx * dx + dy * dy );
    },

    // the squared distance between this vector (treated as a point) and another point
    distanceSquared: function( point ) {
      var dx = this.x - point.x;
      var dy = this.y - point.y;
      return dx * dx + dy * dy;
    },

    // the squared distance between this vector (treated as a point) and another point as (x,y)
    distanceSquaredXY: function( x, y ) {
      var dx = this.x - x;
      var dy = this.y - y;
      return dx * dx + dy * dy;
    },

    dot: function( v ) {
      return this.x * v.x + this.y * v.y;
    },

    dotXY: function( vx, vy ) {
      return this.x * vx + this.y * vy;
    },

    equals: function( other ) {
      return this.x === other.x && this.y === other.y;
    },

    equalsEpsilon: function( other, epsilon ) {
      if ( !epsilon ) {
        epsilon = 0;
      }
      return Math.max( Math.abs( this.x - other.x ), Math.abs( this.y - other.y ) ) <= epsilon;
    },

    isFinite: function() {
      return isFinite( this.x ) && isFinite( this.y );
    },

    /*---------------------------------------------------------------------------*
     * Immutables
     *----------------------------------------------------------------------------*/

    // create a copy, or if a vector is passed in, set that vector to our value
    copy: function( vector ) {
      if ( vector ) {
        return vector.set( this );
      }
      else {
        return new Vector2( this.x, this.y );
      }
    },

    // z component of the equivalent 3-dimensional cross product (this.x, this.y,0) x (v.x, v.y, 0)
    crossScalar: function( v ) {
      return this.x * v.y - this.y * v.x;
    },

    normalized: function() {
      var mag = this.magnitude();
      if ( mag === 0 ) {
        throw new Error( "Cannot normalize a zero-magnitude vector" );
      }
      else {
        return new Vector2( this.x / mag, this.y / mag );
      }
    },

    withMagnitude: function( magnitude ) {
      return this.copy().setMagnitude( magnitude );
    },

    timesScalar: function( scalar ) {
      return new Vector2( this.x * scalar, this.y * scalar );
    },

    times: function( scalar ) {
      // make sure it's not a vector!
      assert && assert( scalar.dimension === undefined );
      return this.timesScalar( scalar );
    },

    componentTimes: function( v ) {
      return new Vector2( this.x * v.x, this.y * v.y );
    },

    plus: function( v ) {
      return new Vector2( this.x + v.x, this.y + v.y );
    },

    plusXY: function( x, y ) {
      return new Vector2( this.x + x, this.y + y );
    },

    plusScalar: function( scalar ) {
      return new Vector2( this.x + scalar, this.y + scalar );
    },

    minus: function( v ) {
      return new Vector2( this.x - v.x, this.y - v.y );
    },

    minusXY: function( x, y ) {
      return new Vector2( this.x - x, this.y - y );
    },

    minusScalar: function( scalar ) {
      return new Vector2( this.x - scalar, this.y - scalar );
    },

    dividedScalar: function( scalar ) {
      return new Vector2( this.x / scalar, this.y / scalar );
    },

    negated: function() {
      return new Vector2( -this.x, -this.y );
    },

    angle: function() {
      return Math.atan2( this.y, this.x );
    },

    // equivalent to a -PI/2 rotation (right hand rotation)
    perpendicular: function() {
      return new Vector2( this.y, -this.x );
    },

    angleBetween: function( v ) {
      var thisMagnitude = this.magnitude();
      var vMagnitude = v.magnitude();
      return Math.acos( dot.clamp( ( this.x * v.x + this.y * v.y ) / ( thisMagnitude * vMagnitude ), -1, 1 ) );
    },

    rotated: function( angle ) {
      var newAngle = this.angle() + angle;
      var mag = this.magnitude();
      return new Vector2( mag * Math.cos( newAngle ), mag * Math.sin( newAngle ) );
    },

    // linear interpolation from this (ratio=0) to vector (ratio=1)
    blend: function( vector, ratio ) {
      return new Vector2( this.x + (vector.x - this.x) * ratio, this.y + (vector.y - this.y) * ratio );
    },

    // average position between this and the provided vector
    average: function( vector ) {
      return this.blend( vector, 0.5 );
    },

    toString: function() {
      return 'Vector2(' + this.x + ', ' + this.y + ')';
    },

    toVector3: function() {
      return new dot.Vector3( this.x, this.y );
    },

    /*---------------------------------------------------------------------------*
     * Mutables
     *----------------------------------------------------------------------------*/

    // our core three functions which all mutation should go through
    setXY: function( x, y ) {
      this.x = x;
      this.y = y;
      return this;
    },
    setX: function( x ) {
      this.x = x;
      return this;
    },
    setY: function( y ) {
      this.y = y;
      return this;
    },

    set: function( v ) {
      return this.setXY( v.x, v.y );
    },

    //Sets the magnitude of the vector, keeping the same direction (though a negative magnitude will flip the vector direction)
    setMagnitude: function( m ) {
      var scale = m / this.magnitude();
      return this.multiplyScalar( scale );
    },

    add: function( v ) {
      return this.setXY( this.x + v.x, this.y + v.y );
    },

    addXY: function( x, y ) {
      return this.setXY( this.x + x, this.y + y );
    },

    addScalar: function( scalar ) {
      return this.setXY( this.x + scalar, this.y + scalar );
    },

    subtract: function( v ) {
      return this.setXY( this.x - v.x, this.y - v.y );
    },

    subtractScalar: function( scalar ) {
      return this.setXY( this.x - scalar, this.y - scalar );
    },

    multiplyScalar: function( scalar ) {
      return this.setXY( this.x * scalar, this.y * scalar );
    },

    multiply: function( scalar ) {
      // make sure it's not a vector!
      assert && assert( scalar.dimension === undefined );
      return this.multiplyScalar( scalar );
    },

    componentMultiply: function( v ) {
      return this.setXY( this.x * v.x, this.y * v.y );
    },

    divideScalar: function( scalar ) {
      return this.setXY( this.x / scalar, this.y / scalar );
    },

    negate: function() {
      return this.setXY( -this.x, -this.y );
    },

    normalize: function() {
      var mag = this.magnitude();
      if ( mag === 0 ) {
        throw new Error( "Cannot normalize a zero-magnitude vector" );
      }
      else {
        return this.divideScalar( mag );
      }
    },

    rotate: function( angle ) {
      var newAngle = this.angle() + angle;
      var mag = this.magnitude();
      return this.setXY( mag * Math.cos( newAngle ), mag * Math.sin( newAngle ) );
    },

    setPolar: function( magnitude, angle ) {
      return this.setXY( magnitude * Math.cos( angle ), magnitude * Math.sin( angle ) );
    },

    // support for serialization
    toStateObject: function() {
      return { x: this.x, y: this.y };
    }
  };

  Poolable.mixin( Vector2, {
    defaultFactory: function() { return new Vector2(); },
    constructorDuplicateFactory: function( pool ) {
      return function( x, y ) {
        if ( pool.length ) {
          return pool.pop().setXY( x, y );
        }
        else {
          return new Vector2( x, y );
        }
      };
    }
  } );

  /*---------------------------------------------------------------------------*
   * Immutable Vector form
   *----------------------------------------------------------------------------*/
  Vector2.Immutable = function ImmutableVector2( x, y ) {
    Vector2.call( this, x, y );
  };
  var Immutable = Vector2.Immutable;

  inherit( Vector2, Immutable );

  // throw errors whenever a mutable method is called on our immutable vector
  Immutable.mutableOverrideHelper = function( mutableFunctionName ) {
    Immutable.prototype[ mutableFunctionName ] = function() {
      throw new Error( "Cannot call mutable method '" + mutableFunctionName + "' on immutable Vector2" );
    };
  };

  // TODO: better way to handle this list?
  Immutable.mutableOverrideHelper( 'setXY' );
  Immutable.mutableOverrideHelper( 'setX' );
  Immutable.mutableOverrideHelper( 'setY' );

  // helpful immutable constants
  Vector2.ZERO = new Immutable( 0, 0 );
  Vector2.X_UNIT = new Immutable( 1, 0 );
  Vector2.Y_UNIT = new Immutable( 0, 1 );

  // support for deserialization
  Vector2.fromStateObject = function( stateObject ) {
    return new Vector2( stateObject.x, stateObject.y );
  };

  return Vector2;
} );
<commit_msg>moved toStateObject from Vector2 to together, see https://github.com/phetsims/together/issues/176<commit_after>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Basic 2-dimensional vector
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  var dot = require( 'DOT/dot' );

  var inherit = require( 'PHET_CORE/inherit' );
  var Poolable = require( 'PHET_CORE/Poolable' );
  require( 'DOT/Util' );
  // require( 'DOT/Vector3' ); // commented out since Require.js complains about the circular dependency

  dot.Vector2 = function Vector2( x, y ) {
    // allow optional parameters
    this.x = x !== undefined ? x : 0;
    this.y = y !== undefined ? y : 0;

    assert && assert( typeof this.x === 'number', 'x needs to be a number' );
    assert && assert( typeof this.y === 'number', 'y needs to be a number' );

    phetAllocation && phetAllocation( 'Vector2' );
  };
  var Vector2 = dot.Vector2;

  Vector2.createPolar = function( magnitude, angle ) {
    return new Vector2().setPolar( magnitude, angle );
  };

  Vector2.prototype = {
    constructor: Vector2,
    isVector2: true,
    dimension: 2,

    magnitude: function() {
      return Math.sqrt( this.magnitudeSquared() );
    },

    magnitudeSquared: function() {
      return this.x * this.x + this.y * this.y;
    },

    // the distance between this vector (treated as a point) and another point
    distance: function( point ) {
      return Math.sqrt( this.distanceSquared( point ) );
    },

    // the distance between this vector (treated as a point) and another point specified as x:Number, y:Number
    distanceXY: function( x, y ) {
      var dx = this.x - x;
      var dy = this.y - y;
      return Math.sqrt( dx * dx + dy * dy );
    },

    // the squared distance between this vector (treated as a point) and another point
    distanceSquared: function( point ) {
      var dx = this.x - point.x;
      var dy = this.y - point.y;
      return dx * dx + dy * dy;
    },

    // the squared distance between this vector (treated as a point) and another point as (x,y)
    distanceSquaredXY: function( x, y ) {
      var dx = this.x - x;
      var dy = this.y - y;
      return dx * dx + dy * dy;
    },

    dot: function( v ) {
      return this.x * v.x + this.y * v.y;
    },

    dotXY: function( vx, vy ) {
      return this.x * vx + this.y * vy;
    },

    equals: function( other ) {
      return this.x === other.x && this.y === other.y;
    },

    equalsEpsilon: function( other, epsilon ) {
      if ( !epsilon ) {
        epsilon = 0;
      }
      return Math.max( Math.abs( this.x - other.x ), Math.abs( this.y - other.y ) ) <= epsilon;
    },

    isFinite: function() {
      return isFinite( this.x ) && isFinite( this.y );
    },

    /*---------------------------------------------------------------------------*
     * Immutables
     *----------------------------------------------------------------------------*/

    // create a copy, or if a vector is passed in, set that vector to our value
    copy: function( vector ) {
      if ( vector ) {
        return vector.set( this );
      }
      else {
        return new Vector2( this.x, this.y );
      }
    },

    // z component of the equivalent 3-dimensional cross product (this.x, this.y,0) x (v.x, v.y, 0)
    crossScalar: function( v ) {
      return this.x * v.y - this.y * v.x;
    },

    normalized: function() {
      var mag = this.magnitude();
      if ( mag === 0 ) {
        throw new Error( "Cannot normalize a zero-magnitude vector" );
      }
      else {
        return new Vector2( this.x / mag, this.y / mag );
      }
    },

    withMagnitude: function( magnitude ) {
      return this.copy().setMagnitude( magnitude );
    },

    timesScalar: function( scalar ) {
      return new Vector2( this.x * scalar, this.y * scalar );
    },

    times: function( scalar ) {
      // make sure it's not a vector!
      assert && assert( scalar.dimension === undefined );
      return this.timesScalar( scalar );
    },

    componentTimes: function( v ) {
      return new Vector2( this.x * v.x, this.y * v.y );
    },

    plus: function( v ) {
      return new Vector2( this.x + v.x, this.y + v.y );
    },

    plusXY: function( x, y ) {
      return new Vector2( this.x + x, this.y + y );
    },

    plusScalar: function( scalar ) {
      return new Vector2( this.x + scalar, this.y + scalar );
    },

    minus: function( v ) {
      return new Vector2( this.x - v.x, this.y - v.y );
    },

    minusXY: function( x, y ) {
      return new Vector2( this.x - x, this.y - y );
    },

    minusScalar: function( scalar ) {
      return new Vector2( this.x - scalar, this.y - scalar );
    },

    dividedScalar: function( scalar ) {
      return new Vector2( this.x / scalar, this.y / scalar );
    },

    negated: function() {
      return new Vector2( -this.x, -this.y );
    },

    angle: function() {
      return Math.atan2( this.y, this.x );
    },

    // equivalent to a -PI/2 rotation (right hand rotation)
    perpendicular: function() {
      return new Vector2( this.y, -this.x );
    },

    angleBetween: function( v ) {
      var thisMagnitude = this.magnitude();
      var vMagnitude = v.magnitude();
      return Math.acos( dot.clamp( ( this.x * v.x + this.y * v.y ) / ( thisMagnitude * vMagnitude ), -1, 1 ) );
    },

    rotated: function( angle ) {
      var newAngle = this.angle() + angle;
      var mag = this.magnitude();
      return new Vector2( mag * Math.cos( newAngle ), mag * Math.sin( newAngle ) );
    },

    // linear interpolation from this (ratio=0) to vector (ratio=1)
    blend: function( vector, ratio ) {
      return new Vector2( this.x + (vector.x - this.x) * ratio, this.y + (vector.y - this.y) * ratio );
    },

    // average position between this and the provided vector
    average: function( vector ) {
      return this.blend( vector, 0.5 );
    },

    toString: function() {
      return 'Vector2(' + this.x + ', ' + this.y + ')';
    },

    toVector3: function() {
      return new dot.Vector3( this.x, this.y );
    },

    /*---------------------------------------------------------------------------*
     * Mutables
     *----------------------------------------------------------------------------*/

    // our core three functions which all mutation should go through
    setXY: function( x, y ) {
      this.x = x;
      this.y = y;
      return this;
    },
    setX: function( x ) {
      this.x = x;
      return this;
    },
    setY: function( y ) {
      this.y = y;
      return this;
    },

    set: function( v ) {
      return this.setXY( v.x, v.y );
    },

    //Sets the magnitude of the vector, keeping the same direction (though a negative magnitude will flip the vector direction)
    setMagnitude: function( m ) {
      var scale = m / this.magnitude();
      return this.multiplyScalar( scale );
    },

    add: function( v ) {
      return this.setXY( this.x + v.x, this.y + v.y );
    },

    addXY: function( x, y ) {
      return this.setXY( this.x + x, this.y + y );
    },

    addScalar: function( scalar ) {
      return this.setXY( this.x + scalar, this.y + scalar );
    },

    subtract: function( v ) {
      return this.setXY( this.x - v.x, this.y - v.y );
    },

    subtractScalar: function( scalar ) {
      return this.setXY( this.x - scalar, this.y - scalar );
    },

    multiplyScalar: function( scalar ) {
      return this.setXY( this.x * scalar, this.y * scalar );
    },

    multiply: function( scalar ) {
      // make sure it's not a vector!
      assert && assert( scalar.dimension === undefined );
      return this.multiplyScalar( scalar );
    },

    componentMultiply: function( v ) {
      return this.setXY( this.x * v.x, this.y * v.y );
    },

    divideScalar: function( scalar ) {
      return this.setXY( this.x / scalar, this.y / scalar );
    },

    negate: function() {
      return this.setXY( -this.x, -this.y );
    },

    normalize: function() {
      var mag = this.magnitude();
      if ( mag === 0 ) {
        throw new Error( "Cannot normalize a zero-magnitude vector" );
      }
      else {
        return this.divideScalar( mag );
      }
    },

    rotate: function( angle ) {
      var newAngle = this.angle() + angle;
      var mag = this.magnitude();
      return this.setXY( mag * Math.cos( newAngle ), mag * Math.sin( newAngle ) );
    },

    setPolar: function( magnitude, angle ) {
      return this.setXY( magnitude * Math.cos( angle ), magnitude * Math.sin( angle ) );
    }
  };

  Poolable.mixin( Vector2, {
    defaultFactory: function() { return new Vector2(); },
    constructorDuplicateFactory: function( pool ) {
      return function( x, y ) {
        if ( pool.length ) {
          return pool.pop().setXY( x, y );
        }
        else {
          return new Vector2( x, y );
        }
      };
    }
  } );

  /*---------------------------------------------------------------------------*
   * Immutable Vector form
   *----------------------------------------------------------------------------*/
  Vector2.Immutable = function ImmutableVector2( x, y ) {
    Vector2.call( this, x, y );
  };
  var Immutable = Vector2.Immutable;

  inherit( Vector2, Immutable );

  // throw errors whenever a mutable method is called on our immutable vector
  Immutable.mutableOverrideHelper = function( mutableFunctionName ) {
    Immutable.prototype[ mutableFunctionName ] = function() {
      throw new Error( "Cannot call mutable method '" + mutableFunctionName + "' on immutable Vector2" );
    };
  };

  // TODO: better way to handle this list?
  Immutable.mutableOverrideHelper( 'setXY' );
  Immutable.mutableOverrideHelper( 'setX' );
  Immutable.mutableOverrideHelper( 'setY' );

  // helpful immutable constants
  Vector2.ZERO = new Immutable( 0, 0 );
  Vector2.X_UNIT = new Immutable( 1, 0 );
  Vector2.Y_UNIT = new Immutable( 0, 1 );

  // support for deserialization
  Vector2.fromStateObject = function( stateObject ) {
    return new Vector2( stateObject.x, stateObject.y );
  };

  return Vector2;
} );
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const APP_DIR = path.resolve('./src');
const BUILD_DIR = path.resolve('./public');

module.exports = {

  entry: [
    'babel-polyfill',
    'webpack-dev-server/client?http://localhost:8080',
    'webpack/hot/only-dev-server',
    APP_DIR + '/index.jsx'
  ],

  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      include: APP_DIR,
      loader: 'react-hot!babel'
    }, {
      test: /\.css$/,
      loader: 'style-loader!css-loader?importLoaders=1'
    }, {
      test: /\.(png|woff|woff2|eot|ttf|svg)$/,
      loader: 'url-loader?limit=100000'
    }]
  },

  resolve: {
    extensions: ['', '.js', '.jsx']
  },

  output: {
    path: BUILD_DIR,
    filename: 'bundle.js',
    publicPath: '/public/'
  },

  devServer: {
    contentBase: BUILD_DIR,
    hot: true
  },

  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
};
<commit_msg>fixed public path<commit_after>const path = require('path');
const webpack = require('webpack');
const APP_DIR = path.resolve('./src');
const BUILD_DIR = path.resolve('./public');

module.exports = {

  entry: [
    'babel-polyfill',
    'webpack-dev-server/client?http://localhost:8080',
    'webpack/hot/only-dev-server',
    APP_DIR + '/index.jsx'
  ],

  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      include: APP_DIR,
      loader: 'react-hot!babel'
    }, {
      test: /\.css$/,
      loader: 'style-loader!css-loader?importLoaders=1'
    }, {
      test: /\.(png|woff|woff2|eot|ttf|svg)$/,
      loader: 'url-loader?limit=100000'
    }]
  },

  resolve: {
    extensions: ['', '.js', '.jsx']
  },

  output: {
    path: BUILD_DIR,
    filename: 'bundle.js',
    publicPath: '/'
  },

  devServer: {
    contentBase: BUILD_DIR,
    hot: true
  },

  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
};
<|endoftext|>


<commit_before>// Document view

'use strict';

var includes              = require('es5-ext/array/#/contains')
  , normalizeOptions      = require('es5-ext/object/normalize-options')
  , syncStyle             = require('dom-ext/html-element/#/sync-style')
  , _                     = require('mano').i18n.bind('View: Component: Documents')
  , isReadOnlyRender      = require('mano/client/utils/is-read-only-render')
  , getArrayIndex         = require('../../utils/get-observable-array-index')
  , docMimeTypes          = require('../../utils/microsoft-word-doc-mime-types')
  , pathToUrl             = require('../../utils/upload-path-to-url')
  , reactiveSibling       = require('../utils/reactive-document-sibling')
  , syncHeight            = require('../utils/sync-height')
  , isMobileView          = require('../utils/is-mobile-view')
  , getCertificates       = require('../utils/get-certificates-list')
  , getUploads            = require('../utils/get-uploads-list')
  , getResolveDocumentUrl = require('../utils/get-resolve-document-url');

var getFilePreview = function (file) {
	var type = file.type;
	if (includes.call(docMimeTypes, type)) {
		return img({ class: 'document-preview-new-word-document', src: '/img/word-doc-icon.png' });
	}
	if (!isReadOnlyRender && (type === 'application/pdf')) {
		return iframe({
			src: '/pdfjs/web/viewer.html?file=' + encodeURIComponent('/' + file.path)
		});
	}
	return img({
		zoomOnHover: true,
		src: mmap(or(file.previewPath, file.thumbPath), function (path) {
			if (path) return stUrl(pathToUrl(path));
		})
	});
};

module.exports = function (context, documentData/*, options*/) {
	var options          = normalizeOptions(arguments[2])
	  , mainContent      = options.mainContent
	  , businessProcess  = context.businessProcess
	  , collectionTarget = options.uploadsResolver || businessProcess
	  , kind             = context.documentKind

	  , collection, nextDocumentUrl, previousDocumentUrl, docPreviewElement, sideContentContainer
	  , defaultResolveDocumentUrl, resolveDocumentUrl;

	if (kind === 'certificate') {
		collection = getCertificates(collectionTarget.certificates, context.appName);
	} else if (kind === 'requirementUpload') {
		collection = getUploads(collectionTarget.requirementUploads, context.appName);
	} else {
		collection = getUploads(collectionTarget.paymentReceiptUploads, context.appName);
	}

	defaultResolveDocumentUrl = getResolveDocumentUrl(kind, collection, options);
	resolveDocumentUrl = function (data) {
		var resolvedUrl = defaultResolveDocumentUrl(data);

		return resolvedUrl && resolvedUrl + '#submitted-box';
	};

	nextDocumentUrl = reactiveSibling.next(collection, context.documentUniqueKey)
		.map(resolveDocumentUrl);
	previousDocumentUrl = reactiveSibling.previous(collection, context.documentUniqueKey)
		.map(resolveDocumentUrl);

	var result = [
		div({ id: 'submitted-box', class: 'document-preview-box' },
			div({ class: 'document-preview-box-header' },

				// Label
				div({ class: 'document-preview-box-header-document-title' },
					documentData.label),

				// Links to previous and next document
				div({ class: 'document-preview-box-controls' },
					div({ class: 'document-preview-label-doc-type' }, _('Document')),
					_if(previousDocumentUrl,
						a({ href: previousDocumentUrl,
							class: 'hint-optional hint-optional-left',
							'data-hint': _('Previous document') },
							i({ class: 'fa fa-angle-left' }))),
					_if(nextDocumentUrl,
						a({ href: nextDocumentUrl,
							class: 'hint-optional hint-optional-left', 'data-hint': _('Next document') },
							i({ class: 'fa fa-angle-right' }))))),

			options.prependContent),

		// Document preview
		div({ class: 'document-preview-selected-document' },

			// Main content
			mainContent || _if(documentData.filesSize, function () {
				var moreThanOneFile = gt(documentData.filesSize, 1);

				return div({ id: 'selection-preview', class: 'document-preview-file' },

					div({ class: 'document-preview-external-link' },

						// Open file in new window link
						span({ id: 'doc-open-links',
							class: 'document-preview-open-link' },
							list(documentData.files, function (file) {
								var linkAttributes = { target: '_blank', href: stUrl(pathToUrl(file.path)),
									class: _if(eq(file, getArrayIndex(documentData.files, 0)), 'active') };

								if (includes.call(docMimeTypes, file.type)) {
									linkAttributes.download = file.path;
								} else if (!isReadOnlyRender && (file.type === 'application/pdf')) {
									linkAttributes.href = '/pdfjs/web/viewer.html?file=' +
										encodeURIComponent('/' + file.path);
								}

								return a(linkAttributes, _("Open file in new window"));
							})),

						// Download document link
						a({ href: _if(documentData.filesSize,
							_if(eq(documentData.filesSize, 1),
								mmap(resolve(getArrayIndex(documentData.files, 0), 'path'), function (path) {
									if (path) return stUrl(pathToUrl(path));
								}),
								'/' + documentData.archiveUrl)),
							download: _if(documentData.filesSize,
								_if(eq(documentData.filesSize, 1),
									resolve(getArrayIndex(documentData.files, 0), 'path'),
									documentData.archiveUrl)) }, _("Download document"))),

					// Document files navigation (top)
					_if(moreThanOneFile, div(
						{ class: 'document-preview-navigation' },
						div({ id: 'submitted-preview-new-navigation-top' },
							a({ class: 'previous' }, span({ class: 'fa fa-chevron-circle-left' },
								_("Previous"))),
							span(span({ class: 'current-index' }, "1"), " / ", documentData.filesSize),
							a({ class: 'next' }, span({ class: 'fa fa-chevron-circle-right' }, _("Next"))))
					)),

					// Document file preview (usually zoomable)
					docPreviewElement = ul({
						id: 'doc-previews',
						class: 'document-preview-image-placeholder'
					}, documentData.files, function (file) {
						return li({ class: _if(eq(file, getArrayIndex(documentData.files, 0)), 'active') },
							getFilePreview(file));
					}),

					// Document files navigation (bottom)
					_if(moreThanOneFile, div(
						{ class: 'document-preview-navigation' },
						div({ id: 'submitted-preview-new-navigation-bottom' },
							a({ class: 'previous' }, span({ class: 'fa fa-chevron-circle-left' },
								_("Previous"))),
							span(span({ class: 'current-index' }, "1"), " / ", documentData.filesSize),
							a({ class: 'next' }, span({ class: 'fa fa-chevron-circle-right' }, _("Next"))))
					)),

					// Legacy scripts
					_if(moreThanOneFile, [
						legacy('hashNavOrderedListControls', 'submitted-preview-new-navigation-top',
							'doc-previews', 'doc-preview'),
						legacy('hashNavOrderedListControls', 'submitted-preview-new-navigation-bottom',
							'doc-previews', 'doc-preview'),
						legacy('hashNavDocumentLink', 'doc-open-links', 'doc-preview'),
						legacy('hashNavOrderedList', 'doc-previews', 'doc-preview')
					]));
			},

				// When no files in document
				div({ class: 'document-preview-missing' },
					p(_("This document does not have any physical file attached to it.")))),

			// Side content
			sideContentContainer = div(
				{ class: 'document-preview-data business-process-submitted-data' },
				options.sideContent
			))
	];

	if (docPreviewElement) {
		// 'syncHeight' ensures that document file preview is enforced to be displayed with
		// A4 proportions, and with respect to VR (its height is in all cases multiplication of 22px)
		syncHeight(docPreviewElement);
		// `syncStyle` ensures that side content has exactly same height as main content
		syncStyle.call(sideContentContainer, docPreviewElement, 'height', isMobileView);
	}

	return result;
};
<commit_msg>Fixes Vianney's point 7<commit_after>// Document view

'use strict';

var includes              = require('es5-ext/array/#/contains')
  , normalizeOptions      = require('es5-ext/object/normalize-options')
  , syncStyle             = require('dom-ext/html-element/#/sync-style')
  , _                     = require('mano').i18n.bind('View: Component: Documents')
  , isReadOnlyRender      = require('mano/client/utils/is-read-only-render')
  , getArrayIndex         = require('../../utils/get-observable-array-index')
  , docMimeTypes          = require('../../utils/microsoft-word-doc-mime-types')
  , pathToUrl             = require('../../utils/upload-path-to-url')
  , reactiveSibling       = require('../utils/reactive-document-sibling')
  , syncHeight            = require('../utils/sync-height')
  , isMobileView          = require('../utils/is-mobile-view')
  , getCertificates       = require('../utils/get-certificates-list')
  , getUploads            = require('../utils/get-uploads-list')
  , getResolveDocumentUrl = require('../utils/get-resolve-document-url');

var getFilePreview = function (file) {
	var type = file.type;
	if (includes.call(docMimeTypes, type)) {
		return img({ class: 'document-preview-new-word-document', src: '/img/word-doc-icon.png' });
	}
	if (!isReadOnlyRender && (type === 'application/pdf')) {
		return iframe({
			src: '/pdfjs/web/viewer.html?file=' + encodeURIComponent('/' + file.path)
		});
	}
	return img({
		zoomOnHover: true,
		src: mmap(or(file.previewPath, file.thumbPath), function (path) {
			if (path) return stUrl(pathToUrl(path));
		})
	});
};

module.exports = function (context, documentData/*, options*/) {
	var options          = normalizeOptions(arguments[2])
	  , mainContent      = options.mainContent
	  , businessProcess  = context.businessProcess
	  , collectionTarget = options.uploadsResolver || businessProcess
	  , kind             = context.documentKind

	  , collection, nextDocumentUrl, previousDocumentUrl, docPreviewElement, sideContentContainer
	  , defaultResolveDocumentUrl, resolveDocumentUrl;

	if (kind === 'certificate') {
		collection = getCertificates(collectionTarget.certificates, context.appName);
	} else if (kind === 'requirementUpload') {
		collection = getUploads(collectionTarget.requirementUploads, context.appName);
	} else {
		collection = getUploads(collectionTarget.paymentReceiptUploads, context.appName);
	}

	defaultResolveDocumentUrl = getResolveDocumentUrl(kind, collection, options);
	resolveDocumentUrl = function (data) {
		var resolvedUrl = defaultResolveDocumentUrl(data);

		return resolvedUrl && resolvedUrl + '#submitted-box';
	};

	nextDocumentUrl = reactiveSibling.next(collection, context.documentUniqueKey)
		.map(resolveDocumentUrl);
	previousDocumentUrl = reactiveSibling.previous(collection, context.documentUniqueKey)
		.map(resolveDocumentUrl);

	var result = [
		div({ id: 'submitted-box', class: 'document-preview-box' },
			div({ class: 'document-preview-box-header' },

				// Label
				div({ class: 'document-preview-box-header-document-title' },
					documentData.label),

				// Links to previous and next document
				div({ class: 'document-preview-box-controls' },
					div({ class: 'document-preview-label-doc-type' },
						_if(kind === 'certificate', _('Certificate'),
							_if(kind === 'requirementUpload', _('Document'),
								_('Payment receipt')))),
					_if(previousDocumentUrl,
						a({ href: previousDocumentUrl,
							class: 'hint-optional hint-optional-left',
							'data-hint': _('Previous document') },
							i({ class: 'fa fa-angle-left' }))),
					_if(nextDocumentUrl,
						a({ href: nextDocumentUrl,
							class: 'hint-optional hint-optional-left', 'data-hint': _('Next document') },
							i({ class: 'fa fa-angle-right' }))))),

			options.prependContent),

		// Document preview
		div({ class: 'document-preview-selected-document' },

			// Main content
			mainContent || _if(documentData.filesSize, function () {
				var moreThanOneFile = gt(documentData.filesSize, 1);

				return div({ id: 'selection-preview', class: 'document-preview-file' },

					div({ class: 'document-preview-external-link' },

						// Open file in new window link
						span({ id: 'doc-open-links',
							class: 'document-preview-open-link' },
							list(documentData.files, function (file) {
								var linkAttributes = { target: '_blank', href: stUrl(pathToUrl(file.path)),
									class: _if(eq(file, getArrayIndex(documentData.files, 0)), 'active') };

								if (includes.call(docMimeTypes, file.type)) {
									linkAttributes.download = file.path;
								} else if (!isReadOnlyRender && (file.type === 'application/pdf')) {
									linkAttributes.href = '/pdfjs/web/viewer.html?file=' +
										encodeURIComponent('/' + file.path);
								}

								return a(linkAttributes, _("Open file in new window"));
							})),

						// Download document link
						a({ href: _if(documentData.filesSize,
							_if(eq(documentData.filesSize, 1),
								mmap(resolve(getArrayIndex(documentData.files, 0), 'path'), function (path) {
									if (path) return stUrl(pathToUrl(path));
								}),
								'/' + documentData.archiveUrl)),
							download: _if(documentData.filesSize,
								_if(eq(documentData.filesSize, 1),
									resolve(getArrayIndex(documentData.files, 0), 'path'),
									documentData.archiveUrl)) }, _("Download document"))),

					// Document files navigation (top)
					_if(moreThanOneFile, div(
						{ class: 'document-preview-navigation' },
						div({ id: 'submitted-preview-new-navigation-top' },
							a({ class: 'previous' }, span({ class: 'fa fa-chevron-circle-left' },
								_("Previous"))),
							span(span({ class: 'current-index' }, "1"), " / ", documentData.filesSize),
							a({ class: 'next' }, span({ class: 'fa fa-chevron-circle-right' }, _("Next"))))
					)),

					// Document file preview (usually zoomable)
					docPreviewElement = ul({
						id: 'doc-previews',
						class: 'document-preview-image-placeholder'
					}, documentData.files, function (file) {
						return li({ class: _if(eq(file, getArrayIndex(documentData.files, 0)), 'active') },
							getFilePreview(file));
					}),

					// Document files navigation (bottom)
					_if(moreThanOneFile, div(
						{ class: 'document-preview-navigation' },
						div({ id: 'submitted-preview-new-navigation-bottom' },
							a({ class: 'previous' }, span({ class: 'fa fa-chevron-circle-left' },
								_("Previous"))),
							span(span({ class: 'current-index' }, "1"), " / ", documentData.filesSize),
							a({ class: 'next' }, span({ class: 'fa fa-chevron-circle-right' }, _("Next"))))
					)),

					// Legacy scripts
					_if(moreThanOneFile, [
						legacy('hashNavOrderedListControls', 'submitted-preview-new-navigation-top',
							'doc-previews', 'doc-preview'),
						legacy('hashNavOrderedListControls', 'submitted-preview-new-navigation-bottom',
							'doc-previews', 'doc-preview'),
						legacy('hashNavDocumentLink', 'doc-open-links', 'doc-preview'),
						legacy('hashNavOrderedList', 'doc-previews', 'doc-preview')
					]));
			},

				// When no files in document
				div({ class: 'document-preview-missing' },
					p(_("This document does not have any physical file attached to it.")))),

			// Side content
			sideContentContainer = div(
				{ class: 'document-preview-data business-process-submitted-data' },
				options.sideContent
			))
	];

	if (docPreviewElement) {
		// 'syncHeight' ensures that document file preview is enforced to be displayed with
		// A4 proportions, and with respect to VR (its height is in all cases multiplication of 22px)
		syncHeight(docPreviewElement);
		// `syncStyle` ensures that side content has exactly same height as main content
		syncStyle.call(sideContentContainer, docPreviewElement, 'height', isMobileView);
	}

	return result;
};
<|endoftext|>


<commit_before>class Welcome {

    constructor() {
        this.baseURL = "http://api.schedulestorm.com:5000/v1/";

        // We want to get the list of Unis
        this.getUnis();
    }

    /*
        Obtains the University list from the API server
    */
    getUnis() {
        // empty the parent
        $("#uniModalList").find("#dataList").empty();

        var thisobj = this;

        $("#welcomeModal").modal({
            backdrop: 'static',
            keyboard: false
        });

        // Add the loading animation
        var loading = new Loading($("#uniModalList").find("#dataList"), "Loading University Data...");

        $.getJSON(this.baseURL + "unis", function(data) {
            // remove the loading animation
            loading.remove(function () {
                // Populate the dropdown in the top right
                thisobj.populateUniDropdown(data);

                window.unis = data;
                thisobj.unis = data;

                // Check to see if they have already selected a Uni and Term in localstorage
                if (localStorage.getItem("uni") != undefined && localStorage.getItem("term") != undefined) {
                    // Hide the modal
                    $("#welcomeModal").modal('hide');

                    // Set this uni
                    thisobj.uni = localStorage.getItem("uni");

                    // Populate the top right dropdown
                    $("#MyUniversity").hide().html(thisobj.unis[thisobj.uni]["name"] + " ").fadeIn('slow');

                    // Load up the classes
                    window.classList = new ClassList(localStorage.getItem("uni"), localStorage.getItem("term"));
                    window.mycourses = new MyCourses(localStorage.getItem("uni"), localStorage.getItem("term"));
                }
                else {
                    $("#uniModalList").find("#dataList").hide();

                    // New user with nothing selected, show them welcome prompts
                    thisobj.populateUnis(data);
                }
            });
        });
    }

    /*
        Populates the top right university dropdown (when the modal isn't showing) and handles the click events
    */
    populateUniDropdown(data) {
        var self = this;

        // Get the dropdown element
        var dropdown  = $("#MyUniversity").parent().find('.dropdown-menu');

        for (var uni in data) {
            // Add this Uni to the dropdown

            var uniobj = data[uni];
            var html = $('
' + uniobj["name"] +'
');

            // Bind an onclick event to it
            html.click(function () {

                // Get the selected uni code (UCalgary, etc...)
                self.uni = $(this).find("a").attr("uni");

                // Change the text of the element
                $("#MyUniversity").hide().html(self.unis[self.uni]["name"] + " ").fadeIn('slow');

                // Make sure the modal is active
                $("#welcomeModal").modal({
                    backdrop: 'static',
                    keyboard: false
                });

                // Let the user choose what term they want
                self.displayTerms(self.uni);
            })

            // Append it
            dropdown.append(html);
        }
    }

    /*
        Populates the modal with the Unis
    */
    populateUnis(unis) {
        var thisobj = this;

        var list = $("#uniModalList").find("#dataList");
        var wantedText = $("#uniModalList").find("#wantedData");

        wantedText.text("Please choose your University:");

        // Iterate through the unis and add the buttons
        for (var uni in unis) {
            var button = $(this.createButton(unis[uni]["name"], uni));
            button.click(function() {

                thisobj.uni = $(this).attr("value");

                $("#MyUniversity").hide().html($(this).text() + " ").fadeIn('slow');

                $("#uniModalList").slideUp(function () {
                    thisobj.displayTerms(thisobj.uni);
                });
            });

            list.append(button);
        }

        list.slideDown();
    }

    /*
        Displays the terms to the user
    */
    displayTerms(uni) {
        var thisobj = this; // Keep the reference

        var list = $("#uniModalList").find("#dataList");
        list.empty();
        var wantedText = $("#uniModalList").find("#wantedData");

        wantedText.text("Please choose your term:");

        for (var term in this.unis[uni]["terms"]) {
            var button = $(this.createButton(this.unis[uni]["terms"][term], term));

            button.click(function() {

                thisobj.term = $(this).attr("value");

                window.classList = new ClassList(thisobj.uni, thisobj.term);
                window.mycourses = new MyCourses(thisobj.uni, thisobj.term);

                // reset the calendar
                window.calendar.resetCalendar();

                // hide the modal
                $("#welcomeModal").modal('hide');
            });
            list.append(button);
        }

        $("#uniModalList").slideDown();
    }

    /*
        Returns the text for an HTML button given text, value
    */
    createButton(text, value) {
        return '<button type="button" class="btn btn-default" value="' + value +'">' + text + '</button>'
    }
}

<commit_msg>Support for saved deleted term or uni sessions<commit_after>class Welcome {

    constructor() {
        this.baseURL = "http://api.schedulestorm.com:5000/v1/";

        // We want to get the list of Unis
        this.getUnis();
    }

    /*
        Obtains the University list from the API server
    */
    getUnis() {
        // empty the parent
        $("#uniModalList").find("#dataList").empty();

        var thisobj = this;

        $("#welcomeModal").modal({
            backdrop: 'static',
            keyboard: false
        });

        // Add the loading animation
        var loading = new Loading($("#uniModalList").find("#dataList"), "Loading University Data...");

        $.getJSON(this.baseURL + "unis", function(data) {
            // remove the loading animation
            loading.remove(function () {
                // Populate the dropdown in the top right
                thisobj.populateUniDropdown(data);

                window.unis = data;
                thisobj.unis = data;

                var localUni = localStorage.getItem("uni");
                var localTerm = localStorage.getItem("term");

                // Check to see if they have already selected a Uni and Term in localstorage
                if (thisobj.unis[localUni] != undefined && thisobj.unis[localUni]["terms"][localTerm] != undefined) {
                    // Hide the modal
                    $("#welcomeModal").modal('hide');

                    // Set this uni
                    thisobj.uni = localUni;

                    // Populate the top right dropdown
                    $("#MyUniversity").hide().html(thisobj.unis[thisobj.uni]["name"] + " ").fadeIn('slow');

                    // Load up the classes
                    window.classList = new ClassList(localUni, localTerm);
                    window.mycourses = new MyCourses(localUni, localTerm);
                }
                else {
                    $("#uniModalList").find("#dataList").hide();

                    // New user with nothing selected, show them welcome prompts
                    thisobj.populateUnis(data);
                }
            });
        });
    }

    /*
        Populates the top right university dropdown (when the modal isn't showing) and handles the click events
    */
    populateUniDropdown(data) {
        var self = this;

        // Get the dropdown element
        var dropdown  = $("#MyUniversity").parent().find('.dropdown-menu');

        for (var uni in data) {
            // Add this Uni to the dropdown

            var uniobj = data[uni];
            var html = $('
' + uniobj["name"] +'
');

            // Bind an onclick event to it
            html.click(function () {

                // Get the selected uni code (UCalgary, etc...)
                self.uni = $(this).find("a").attr("uni");

                // Change the text of the element
                $("#MyUniversity").hide().html(self.unis[self.uni]["name"] + " ").fadeIn('slow');

                // Make sure the modal is active
                $("#welcomeModal").modal({
                    backdrop: 'static',
                    keyboard: false
                });

                // Let the user choose what term they want
                self.displayTerms(self.uni);
            })

            // Append it
            dropdown.append(html);
        }
    }

    /*
        Populates the modal with the Unis
    */
    populateUnis(unis) {
        var thisobj = this;

        var list = $("#uniModalList").find("#dataList");
        var wantedText = $("#uniModalList").find("#wantedData");

        wantedText.text("Please choose your University:");

        // Iterate through the unis and add the buttons
        for (var uni in unis) {
            var button = $(this.createButton(unis[uni]["name"], uni));
            button.click(function() {

                thisobj.uni = $(this).attr("value");

                $("#MyUniversity").hide().html($(this).text() + " ").fadeIn('slow');

                $("#uniModalList").slideUp(function () {
                    thisobj.displayTerms(thisobj.uni);
                });
            });

            list.append(button);
        }

        list.slideDown();
    }

    /*
        Displays the terms to the user
    */
    displayTerms(uni) {
        var thisobj = this; // Keep the reference

        var list = $("#uniModalList").find("#dataList");
        list.empty();
        var wantedText = $("#uniModalList").find("#wantedData");

        wantedText.text("Please choose your term:");

        for (var term in this.unis[uni]["terms"]) {
            var button = $(this.createButton(this.unis[uni]["terms"][term], term));

            button.click(function() {

                thisobj.term = $(this).attr("value");

                window.classList = new ClassList(thisobj.uni, thisobj.term);
                window.mycourses = new MyCourses(thisobj.uni, thisobj.term);

                // reset the calendar
                window.calendar.resetCalendar();

                // hide the modal
                $("#welcomeModal").modal('hide');
            });
            list.append(button);
        }

        $("#uniModalList").slideDown();
    }

    /*
        Returns the text for an HTML button given text, value
    */
    createButton(text, value) {
        return '<button type="button" class="btn btn-default" value="' + value +'">' + text + '</button>'
    }
}

<|endoftext|>


<commit_before>var path = require('path')
var libraryName = 'futil-js'
var outputFile = libraryName + '.js'

module.exports = {
  devtool: 'source-map',
  entry: path.join(__dirname, 'src/index.js'),
  output: {
    path: path.join(__dirname, 'lib'),
    filename: outputFile,
    library: libraryName,
    libraryTarget: 'umd'
  },
  module: {
    loaders: [{
      test: /(\.jsx|\.js)$/,
      loader: 'babel-loader',
      exclude: /(node_modules|bower_components)/
    }]
  },
  externals: {
    'lodash/fp': 'lodash/fp'
  }
}
<commit_msg>generalize library name location<commit_after>var path = require('path')
var libraryName = require('./package.json').name
var outputFile = libraryName + '.js'

module.exports = {
  devtool: 'source-map',
  entry: path.join(__dirname, 'src/index.js'),
  output: {
    path: path.join(__dirname, 'lib'),
    filename: outputFile,
    library: libraryName,
    libraryTarget: 'umd'
  },
  module: {
    loaders: [{
      test: /(\.jsx|\.js)$/,
      loader: 'babel-loader',
      exclude: /(node_modules|bower_components)/
    }]
  },
  externals: {
    'lodash/fp': 'lodash/fp'
  }
}
<|endoftext|>


<commit_before>const webpack           = require('webpack')
const { join }          = require('path')

module.exports = {
  entry: join(__dirname, 'src', 'index'),

  output: {
    path: '/',
    filename: 'dist.js',
    publicPath: 'http://localhost:8080/'
  },

  resolve: {
    extensions: [ '.js' ],
    alias: {
      '@slup/ripple': join(__dirname, 'packages', 'Ripple', 'src', 'index'),
      '@slup/slider': join(__dirname, 'packages', 'Slider', 'src', 'index'),
      '@slup/buttons': join(__dirname, 'packages', 'Buttons', 'src', 'index'),
      '@slup/lists': join(__dirname, 'packages', 'Lists', 'src', 'index'),
      '@slup/navbar': join(__dirname, 'packages', 'Navbar', 'src', 'index'),
      '@slup/controls': join(__dirname, 'packages', 'Controls', 'src', 'index'),
      '@slup/sidenav': join(__dirname, 'packages', 'Sidenav', 'src', 'index'),
      '@slup/grid': join(__dirname, 'packages', 'Grid', 'src', 'index'),

      // Aliases needed for styled-components
      'react': 'inferno-compat',
      'react-dom': 'inferno-compat'
    }
  },

  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      }
    ]
  },

	devServer: {
		contentBase: './',
		port: 8080,
		noInfo: false,
		hot: true,
		inline: true,
		proxy: {
			'/': {
				bypass: function (req, res, proxyOptions) {
					return '/src/index.html'
				}
			}
		}
  },

	plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.optimize.ModuleConcatenationPlugin()
	],

  devtool: 'source-map',
  target: 'web'
}
<commit_msg>:bug: Update webpack<commit_after>const webpack           = require('webpack')
const { join }          = require('path')

module.exports = {
  entry: join(__dirname, 'src', 'index'),

  output: {
    path: '/',
    filename: 'dist.js',
    publicPath: 'http://localhost:8080/'
  },

  resolve: {
    extensions: [ '.js' ],
    alias: {
      '@slup/ripple': join(__dirname, 'packages', 'Ripple', 'src', 'index'),
      '@slup/slider': join(__dirname, 'packages', 'Slider', 'src', 'index'),
      '@slup/buttons': join(__dirname, 'packages', 'Buttons', 'src', 'index'),
      '@slup/lists': join(__dirname, 'packages', 'Lists', 'src', 'index'),
      '@slup/navbar': join(__dirname, 'packages', 'Navbar', 'src', 'index'),
      '@slup/controls': join(__dirname, 'packages', 'Controls', 'src', 'index'),
      '@slup/sidenav': join(__dirname, 'packages', 'Sidenav', 'src', 'index'),
      '@slup/grid': join(__dirname, 'packages', 'Grid', 'src', 'index'),
      '@slup/theming': join(__dirname, 'packages', 'Theming', 'src', 'index'),

      // Aliases needed for styled-components
      'react': 'inferno-compat',
      'react-dom': 'inferno-compat'
    }
  },

  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      }
    ]
  },

	devServer: {
		contentBase: './',
		port: 8080,
		noInfo: false,
		hot: true,
		inline: true,
		proxy: {
			'/': {
				bypass: function (req, res, proxyOptions) {
					return '/src/index.html'
				}
			}
		}
  },

	plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.optimize.ModuleConcatenationPlugin()
	],

  devtool: 'source-map',
  target: 'web'
}
<|endoftext|>


<commit_before>const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'floating-point-converter.js',
    path: path.resolve(__dirname, 'dist')
  }
};
<commit_msg>Add dev server<commit_after>const path = require('path');

module.exports = {
  entry: './src/index.js',
  devtool: 'inline-source-map',
  devServer: {
    contentBase: './dist',
    hot: true
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
};
<|endoftext|>


<commit_before>var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var env = process.env.MIX_ENV || 'dev';
var isProduction = (env === 'prod');

var plugins = [
  new ExtractTextPlugin('app.css'),
  new CopyWebpackPlugin([
    { from: './deps/phoenix_html/web/static/js/phoenix_html.js',
      to: 'js/phoenix_html.js'
    }
  ])
];

// This is necessary to get the sass @import's working
var stylePathResolves = (
    'includePaths[]=' + path.resolve('./') + '&' +
    'includePaths[]=' + path.resolve('./node_modules')
  );

if (isProduction) {
  plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}));
}

module.exports = {
  entry: './web/static/js/index.js',
  output: {
    path: './priv/static/js',
    filename: 'app.js'
  },
  resolve: {
    alias: {
      phoenix: __dirname + '/deps/phoenix/web/static/js/phoenix.js'
    }
  },
  module: {
        loaders: [
            {
              test: /\.jsx?$/,
              exclude: /(node_modules|bower_components)/,
              loader: 'babel',
              query: {
                presets: ['es2015', 'react']
              }
            },
            {
              test: /\.scss$/,
              loader: ExtractTextPlugin.extract(
                'style',
                'css' + '!sass?outputStyle=expanded&' + stylePathResolves
              )
            }

        ]
  },
  plugins: plugins
};<commit_msg>bundle phoenix.js<commit_after>var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

var env = process.env.MIX_ENV || 'dev';
var isProduction = (env === 'prod');

var plugins = [
  new ExtractTextPlugin('app.css'),
  new CopyWebpackPlugin([
    { from: './deps/phoenix_html/web/static/js/phoenix_html.js',
      to: 'js/phoenix_html.js'
    }
  ])
];

// This is necessary to get the sass @import's working
var stylePathResolves = (
    'includePaths[]=' + path.resolve('./') + '&' +
    'includePaths[]=' + path.resolve('./node_modules')
  );

if (isProduction) {
  plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}));
}

module.exports = {
  entry: ['./web/static/js/index.js', './deps/phoenix/web/static/js/phoenix.js'],
  output: {
    path: './priv/static/js',
    filename: 'app.js'
  },
  resolve: {
    alias: {
      phoenix: __dirname + '/deps/phoenix/web/static/js/phoenix.js'
    }
  },
  module: {
        loaders: [
            {
              test: /\.jsx?$/,
              exclude: /(node_modules|bower_components)/,
              loader: 'babel',
              query: {
                presets: ['es2015', 'react']
              }
            },
            {
              test: /\.scss$/,
              loader: ExtractTextPlugin.extract(
                'style',
                'css' + '!sass?outputStyle=expanded&' + stylePathResolves
              )
            }

        ]
  },
  plugins: plugins
};<|endoftext|>


<commit_before>const path = require('path')
const join = path.join
const createConfig = require('hjs-webpack')

// PostCSS plugins
const precss = require('precss')
const cssnano = require('cssnano')
const autoprefixer = require('autoprefixer')

// paths
const root = path.resolve(__dirname)
const src = join(root, 'src')
const dist = join(root, 'dist')
const nodeModules = join(root, 'node_modules')

// env
const NODE_ENV = process.env.NODE_ENV
const isDev = NODE_ENV === 'development'

// config
const config = createConfig({
  isDev,
  in: join(src, 'app.js'),
  out: dist,
  clearBeforeBuild: true
})

// CSS Modules
const cssModuleNames = `${isDev ? '[path][name]__[local]__' : ''}[hash:base64:5]`
const matchCssLoader = /(^|!)(css-loader)($|!)/

// find the old CSS loader
const findCssLoader = (loaders, match) => {
  const found = loaders.filter(l => l && l.loader && l.loader.match(match))

  return found ? found[0] : null
}

const oldCssLoader = findCssLoader(config.module.loaders, matchCssLoader)

// create the new CSS loader
const newCssMatch = `$1$2?modules&localIdentName=${cssModuleNames}$3`
const newCssLoader = Object.assign({}, oldCssLoader, {
  test: /\.module\.css$/,
  include: [src],
  loader: oldCssLoader.loader.replace(matchCssLoader, newCssMatch)
})

// add to the existing loaders
config.module.loaders.push(newCssLoader)

// modify the old loader
oldCssLoader.test = new RegExp(`[^module]${oldCssLoader.test.source}`)
oldCssLoader.loader = newCssLoader.loader

// create another css loader to load css from node_modules
config.module.loaders.push({
  test: /\.css$/,
  include: [nodeModules],
  loader: 'style!css'
})

// PostCSS
config.postcss = [].concat([
  precss(),
  autoprefixer({
    browsers: ['last 2 versions']
  }),
  cssnano()
])

module.exports = config
<commit_msg>relative url alias<commit_after>const path = require('path')
const join = path.join
const createConfig = require('hjs-webpack')

// PostCSS plugins
const precss = require('precss')
const cssnano = require('cssnano')
const autoprefixer = require('autoprefixer')

// paths
const root = path.resolve(__dirname)
const src = join(root, 'src')
const dist = join(root, 'dist')
const nodeModules = join(root, 'node_modules')

// env
const NODE_ENV = process.env.NODE_ENV
const isDev = NODE_ENV === 'development'

// config
const config = createConfig({
  isDev,
  in: join(src, 'app.js'),
  out: dist,
  clearBeforeBuild: true
})

// reference paths with alias
config.resolve.root = [src, nodeModules]
config.resolve.alias = {
  styles: join(src, 'styles'),
  components: join(src, 'components'),
  utils: join(src, 'components')
}

// CSS Modules
const cssModuleNames = `${isDev ? '[path][name]__[local]__' : ''}[hash:base64:5]`
const matchCssLoader = /(^|!)(css-loader)($|!)/

// find the old CSS loader
const findCssLoader = (loaders, match) => {
  const found = loaders.filter(l => l && l.loader && l.loader.match(match))

  return found ? found[0] : null
}

const oldCssLoader = findCssLoader(config.module.loaders, matchCssLoader)

// create the new CSS loader
const newCssMatch = `$1$2?modules&localIdentName=${cssModuleNames}$3`
const newCssLoader = Object.assign({}, oldCssLoader, {
  test: /\.module\.css$/,
  include: [src],
  loader: oldCssLoader.loader.replace(matchCssLoader, newCssMatch)
})

// add to the existing loaders
config.module.loaders.push(newCssLoader)

// modify the old loader
oldCssLoader.test = new RegExp(`[^module]${oldCssLoader.test.source}`)
oldCssLoader.loader = newCssLoader.loader

// create another css loader to load css from node_modules
config.module.loaders.push({
  test: /\.css$/,
  include: [nodeModules],
  loader: 'style!css'
})

// PostCSS
config.postcss = [].concat([
  precss(),
  autoprefixer({
    browsers: ['last 2 versions']
  }),
  cssnano()
])

module.exports = config
<|endoftext|>


<commit_before>const webpack = require('webpack');
const RebuildChangedPlugin = require('rebuild-changed-entrypoints-webpack-plugin');

const plugins = [
	// By default, moment loads aaaall the locale files, which bloats the bundle size
	// This plugin forces moment to only load the German locale
	new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /de/),
];

const devPlugins = [
	// Rebuild onlyl changed files
	new RebuildChangedPlugin({
		cacheDirectory: __dirname,
	}),
];

if (process.env.NODE_ENV !== 'production') {
	plugins.push(...devPlugins);
}

module.exports = {
	mode: 'production',
	module: {
		rules: [
			// All files that end on .js or .jsx are transpilled by babel
			{
				test: /\.(js|jsx)$/,
				exclude: /(node_modules)/,
				loader: 'babel-loader',
				query: {
					presets: [['@babel/preset-env']],
					plugins: [
						'@babel/plugin-transform-react-jsx',
						'@babel/plugin-transform-runtime',
					],
				},
			},
			// moment needs to be globally exposed in order to work with fullcalendar
			{ test: require.resolve('moment'), loader: 'expose-loader?moment' },
		],
	},
	optimization: {
		splitChunks: {
			cacheGroups: {
				// Bundle react & react-dom into separate vendor-react bundle
				react: {
					test: /[\\/]node_modules[\\/](react-dom|react)[\\/]/,
					name: 'vendor-react',
					chunks: 'all',
				},
			},
		},
	},
	externals: {
		jquery: 'jQuery',
		'jquery-mousewheel': 'jQuery',
	},
	output: {
		path: '/',
		filename: '[name].js',
	},
	plugins,
};
<commit_msg>minify only in production mode<commit_after>const webpack = require('webpack');
const RebuildChangedPlugin = require('rebuild-changed-entrypoints-webpack-plugin');

let minimize = true;

const plugins = [
	// By default, moment loads aaaall the locale files, which bloats the bundle size
	// This plugin forces moment to only load the German locale
	new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /de/),
];

const devPlugins = [
	// Rebuild onlyl changed files
	new RebuildChangedPlugin({
		cacheDirectory: __dirname,
	}),
];

if (process.env.NODE_ENV !== 'production') {
	minimize = false;
	plugins.push(...devPlugins);
}

module.exports = {
	mode: 'production',
	module: {
		rules: [
			// All files that end on .js or .jsx are transpilled by babel
			{
				test: /\.(js|jsx)$/,
				exclude: /(node_modules)/,
				loader: 'babel-loader',
				query: {
					presets: [['@babel/preset-env']],
					plugins: [
						'@babel/plugin-transform-react-jsx',
						'@babel/plugin-transform-runtime',
					],
				},
			},
			// moment needs to be globally exposed in order to work with fullcalendar
			{ test: require.resolve('moment'), loader: 'expose-loader?moment' },
		],
	},
	optimization: {
		minimize,
		splitChunks: {
			cacheGroups: {
				// Bundle react & react-dom into separate vendor-react bundle
				react: {
					test: /[\\/]node_modules[\\/](react-dom|react)[\\/]/,
					name: 'vendor-react',
					chunks: 'all',
				},
			},
		},
	},
	externals: {
		jquery: 'jQuery',
		'jquery-mousewheel': 'jQuery',
	},
	output: {
		path: '/',
		filename: '[name].js',
	},
	plugins,
};
<|endoftext|>


<commit_before>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')

const DEBUG = !(process.env.NODE_ENV === 'production')
const VERBOSE = process.argv.includes('--verbose')
const HOT_DEPLOY = !!process.env.HOT_DEPLOY
let CONTEXT_PATH = `${(process.env.CONTEXT_PATH || '')}`

module.exports = {
  context: __dirname + '/src/main/client',
  entry: {
    'js/bundle': [...(HOT_DEPLOY ? ['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'] : []), './index.js']
  },
  output: {
    path: __dirname + '/src/main/resources/static',
    filename: 'assets/[name].js',
    publicPath: `${CONTEXT_PATH}/`
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devtool: DEBUG ? 'cheap-module-eval-source-map' : false,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.CONTEXT_PATH': `"${CONTEXT_PATH}"`,
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || (DEBUG ? 'development' : 'production')}"`
    }),
    ...(HOT_DEPLOY ? [new webpack.HotModuleReplacementPlugin()] : []),
    ...(DEBUG ? [] : [new webpack.optimize.AggressiveMergingPlugin(),
      new webpack.optimize.UglifyJsPlugin({ compress: { screw_ie8: true, warnings: VERBOSE } })
    ]),
    new HtmlWebpackPlugin({
      title: 'himawari',
      template: 'index.ejs'
    }),
    new CopyWebpackPlugin([
      { from: 'assets'}
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.ejs$/,
        loader: 'ejs-loader'
      }
    ]
  }
}
<commit_msg>venderのjsは外出しに(調整中)<commit_after>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')

const DEBUG = !(process.env.NODE_ENV === 'production')
const VERBOSE = process.argv.includes('--verbose')
const HOT_DEPLOY = !!process.env.HOT_DEPLOY
let CONTEXT_PATH = `${(process.env.CONTEXT_PATH || '')}`

module.exports = {
  context: __dirname + '/src/main/client',
  entry: {
    vender: ['react', 'redux', 'material-ui'],
    'js/bundle': [...(HOT_DEPLOY ? ['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'] : []), './index.js']
  },
  output: {
    path: __dirname + '/src/main/resources/static',
    filename: 'assets/[name].js',
    publicPath: `${CONTEXT_PATH}/`
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devtool: DEBUG ? 'cheap-module-eval-source-map' : false,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.CONTEXT_PATH': `"${CONTEXT_PATH}"`,
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || (DEBUG ? 'development' : 'production')}"`
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vender',
      minChunks: Infinity
    }),
    ...(HOT_DEPLOY ? [new webpack.HotModuleReplacementPlugin()] : []),
    ...(DEBUG ? [] : [new webpack.optimize.AggressiveMergingPlugin(),
      new webpack.optimize.UglifyJsPlugin({ compress: { screw_ie8: true, warnings: VERBOSE } })
    ]),
    new HtmlWebpackPlugin({
      title: 'himawari',
      template: 'index.ejs'
    }),
    new CopyWebpackPlugin([
      { from: 'assets'}
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.ejs$/,
        loader: 'ejs-loader'
      }
    ]
  }
}
<|endoftext|>


<commit_before>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');

// Phaser webpack config
const phaserModule = path.join(__dirname, '/node_modules/phaser-ce/');
const phaser = path.join(phaserModule, 'build/custom/phaser-split.js');
const pixi = path.join(phaserModule, 'build/custom/pixi.js');
const p2 = path.join(phaserModule, 'build/custom/p2.js');
const Dotenv = require('dotenv-webpack');

// Expose mode argument to unify our config options.
module.exports = (env, argv) => {
	const production = (argv && argv.mode === 'production') || process.env.NODE_ENV === 'production';

	return {
		entry: ['babel-polyfill', path.resolve(__dirname, 'src', 'script.js')],
		output: {
			path: path.resolve(__dirname, 'deploy'),
			filename: 'ancientbeast.js',
			// chunkFilename: '[id].chunk.js',
			// publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
		},
		devtool: production ? 'none' : 'source-map',
		module: {
			rules: [
				{ test: /pixi\.js/, use: ['expose-loader?PIXI'] },
				{ test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
				{ test: /p2\.js/, use: ['expose-loader?p2'] },
				{ test: /\.js$/, use: ['babel-loader'], exclude: /node_modules/ },
				{
					test: /\.html$/,
					use: ['html-loader'],
				},
				{
					test: /\.less$/,
					use: ['style-loader', 'css-loader', 'less-loader'],
				},
				{
					test: /\.css$/,
					use: ['style-loader', 'css-loader'],
				},
				{
					test: /\.(png|jpg|gif|svg|ogg|ico|cur|woff|woff2)$/,
					loader: 'file-loader',
					options: {
						name(resourcePath, resourceQuery) {
							if (production) {
								return 'assets/[contenthash].[ext]';
							}
							return '[path][name].[ext]';
						},
						esModule: false,
					},
				},
			],
		},
		resolve: {
			alias: {
				pixi: pixi,
				p2: p2,
				phaser: phaser,
				assets: path.resolve(__dirname, 'assets/'),
				modules: path.join(__dirname, 'node_modules'),
			},
		},
		devServer: {
			contentBase: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
			port: 8080,
			proxy: {
				'/api': 'x.x.x.x:7350',
			},
		},
		plugins: [
			new CopyPlugin([{ from: 'static' }]),
			new HtmlWebpackPlugin({
				template: path.resolve(__dirname, 'src', 'index.ejs'),
				favicon: path.resolve(__dirname, 'assets', 'favicon.png'),
				production,
			}),
			new Dotenv(),
		],
		node: {
			fs: 'empty',
		},
	};
};
<commit_msg>enabling online multiplayer, hopefully<commit_after>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');

// Phaser webpack config
const phaserModule = path.join(__dirname, '/node_modules/phaser-ce/');
const phaser = path.join(phaserModule, 'build/custom/phaser-split.js');
const pixi = path.join(phaserModule, 'build/custom/pixi.js');
const p2 = path.join(phaserModule, 'build/custom/p2.js');
const Dotenv = require('dotenv-webpack');

// Expose mode argument to unify our config options.
module.exports = (env, argv) => {
	const production = (argv && argv.mode === 'production') || process.env.NODE_ENV === 'production';

	return {
		entry: ['babel-polyfill', path.resolve(__dirname, 'src', 'script.js')],
		output: {
			path: path.resolve(__dirname, 'deploy'),
			filename: 'ancientbeast.js',
			// chunkFilename: '[id].chunk.js',
			// publicPath: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
		},
		devtool: production ? 'none' : 'source-map',
		module: {
			rules: [
				{ test: /pixi\.js/, use: ['expose-loader?PIXI'] },
				{ test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
				{ test: /p2\.js/, use: ['expose-loader?p2'] },
				{ test: /\.js$/, use: ['babel-loader'], exclude: /node_modules/ },
				{
					test: /\.html$/,
					use: ['html-loader'],
				},
				{
					test: /\.less$/,
					use: ['style-loader', 'css-loader', 'less-loader'],
				},
				{
					test: /\.css$/,
					use: ['style-loader', 'css-loader'],
				},
				{
					test: /\.(png|jpg|gif|svg|ogg|ico|cur|woff|woff2)$/,
					loader: 'file-loader',
					options: {
						name(resourcePath, resourceQuery) {
							if (production) {
								return 'assets/[contenthash].[ext]';
							}
							return '[path][name].[ext]';
						},
						esModule: false,
					},
				},
			],
		},
		resolve: {
			alias: {
				pixi: pixi,
				p2: p2,
				phaser: phaser,
				assets: path.resolve(__dirname, 'assets/'),
				modules: path.join(__dirname, 'node_modules'),
			},
		},
		devServer: {
			contentBase: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : '/',
			port: 8080,
			proxy: {
				'/api': 'online.ancientbeast.com:7350',
			},
		},
		plugins: [
			new CopyPlugin([{ from: 'static' }]),
			new HtmlWebpackPlugin({
				template: path.resolve(__dirname, 'src', 'index.ejs'),
				favicon: path.resolve(__dirname, 'assets', 'favicon.png'),
				production,
			}),
			new Dotenv(),
		],
		node: {
			fs: 'empty',
		},
	};
};
<|endoftext|>


<commit_before>// @flow weak

const path = require('path');
const webpack = require('webpack');
const BundleInspector = require('bundle-inspector-webpack-plugin');

const libraryName = 'resonance';

const baseConfig = {
  entry: {
    [libraryName]: path.join(__dirname, 'src/index.js'),
  },
  output: {
    path: path.join(__dirname, 'build/dist'),
    library: libraryName,
    libraryTarget: 'umd',
    umdNamedDefine: true,
  },
  externals: [
    {
      react: {
        root: 'React',
        commonjs2: './react',
        commonjs: ['./react'],
        amd: 'react',
      },
    },
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /(node_modules)/,
        query: {
          cacheDirectory: true,
        },
      },
    ],
  },
  resolve: {
    modules: [
      path.resolve(__dirname, 'src'),
      'node_modules',
    ],
  },
  plugins: [],
};

let config;

if (process.env.NODE_ENV === 'production') {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.min.js`,
    }),
    plugins: baseConfig.plugins.concat([
      new webpack.DefinePlugin({
        'process.env.NODE_ENV': JSON.stringify('production'),
      }),
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false,
          screw_ie8: true,
        },
      }),
      new BundleInspector(),
    ]),
  });
} else {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.js`,
    }),
  });
}

module.exports = config;
<commit_msg>update webpack.config<commit_after>// @flow weak

const path = require("path");
const webpack = require("webpack");
const BundleInspector = require("bundle-inspector-webpack-plugin");

const libraryName = "resonance";

const baseConfig = {
  entry: {
    [libraryName]: path.join(__dirname, "src/index.js")
  },
  output: {
    path: path.join(__dirname, "build/dist"),
    library: libraryName,
    libraryTarget: "umd",
    umdNamedDefine: true
  },
  externals: [
    {
      react: {
        root: "React",
        commonjs2: "./react",
        commonjs: ["./react"],
        amd: "react"
      }
    }
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: "babel-loader",
        exclude: /(node_modules)/,
        query: {
          cacheDirectory: true
        }
      }
    ]
  },
  resolve: {
    modules: [path.resolve(__dirname, "src"), "node_modules"]
  },
  plugins: []
};

let config;

if (process.env.NODE_ENV === "production") {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.min.js`
    }),
    plugins: baseConfig.plugins.concat([
      new webpack.DefinePlugin({
        "process.env.NODE_ENV": JSON.stringify("production")
      }),
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false,
          screw_ie8: true
        }
      }),
      new BundleInspector()
    ])
  });
} else {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.js`
    })
  });
}

module.exports = config;
<|endoftext|>


<commit_before>/*
 * This is a very simple mock of TwitterStreamChannels for offline test purposes
 * To test only the init of the StreamChannels object (before any call to twitter)
 */

var StreamChannels = require('../lib/StreamChannels');

StreamChannels.prototype.start = function(){
  return this;
};

StreamChannels.prototype.stop = function(){
  return this;
};

/*
 * Mock for the twitter api client twit
 * No oAuth request will be made
 */
var TwitMock = function(credentials){

};

/*
 * Mocking stream with an empty function so that no call will be made
 */
TwitMock.prototype.stream = function(path, params){

};

var TwitterStreamChannelsMock = function(credentials){
  this.apiClient = new TwitMock(credentials);
};

/*
 * Mocks the streamChannels method of TwitterStreamChannels to return a StreamChannels object with the correct options
 */
TwitterStreamChannelsMock.prototype.streamChannels = function(options){
  return new StreamChannels(this.apiClient, options);
};

module.exports = TwitterStreamChannelsMock;<commit_msg>fixed mock to work with offline unit-tests<commit_after>/*
 * This is a very simple mock of TwitterStreamChannels for offline test purposes
 * To test only the init of the StreamChannels object (before any call to twitter)
 */

var StreamChannels = require('../lib/StreamChannels');

StreamChannels.prototype.start = function(){
  return this;
};

StreamChannels.prototype.stop = function(){
  return this;
};

/*
 * Mock for the twitter api client twit
 * No oAuth request will be made
 */
var TwitMock = function(credentials){

};

/*
 * Mocking stream with an empty function so that no call will be made
 */
TwitMock.prototype.stream = function(path, params){
  return {
    on: function(){

    }
  };
};

var TwitterStreamChannelsMock = function(credentials){
  this.apiClient = new TwitMock(credentials);
};

/*
 * Mocks the streamChannels method of TwitterStreamChannels to return a StreamChannels object with the correct options
 */
TwitterStreamChannelsMock.prototype.streamChannels = function(options){
  return new StreamChannels(this.apiClient, options);
};

module.exports = TwitterStreamChannelsMock;<|endoftext|>


<commit_before>const Bandori = require("../mods/node-dori");
const Api = new Bandori({region: "jp"});

const region = "jp";

module.exports = {
    time: "00 * * * * *",
    timezone: "Asia/Tokyo",
    task: (Kokoro) => {
        console.log("[Event JP] Checking for new events...");
        Api.getCurrentEvent()
            .then(event => {
                var guild = Kokoro.settings.get("guild");
                var cache = Kokoro.settings.get("cache");
                if (cache.events[region] === null) {
                    cache.events[region] = { event: { id: 0 } };
                }
                if (cache.events[region].event.id != event.id) {
                    Object.keys(guild).forEach(id => {
                        if (!guild[id].eventChannelJP) return;
                        var channel = Kokoro.guilds.get(id)
                            .channels.get(guild[id].eventChannelJP);
                        channel.send(guild[id].eventMsgJP);
                        Kokoro.invoke(channel, ["gbp", "event", region, "--force"]);
                    });
                }
            })
            .catch(error => {
                throw new Error(error.stack);
            });
    }
}<commit_msg>fix jp event check time<commit_after>const Bandori = require("../mods/node-dori");
const Api = new Bandori({region: "jp"});

const region = "jp";

module.exports = {
    time: "00 00 15 * * *",
    timezone: "Asia/Tokyo",
    task: (Kokoro) => {
        console.log("[Event JP] Checking for new events...");
        Api.getCurrentEvent()
            .then(event => {
                var guild = Kokoro.settings.get("guild");
                var cache = Kokoro.settings.get("cache");
                if (cache.events[region] === null) {
                    cache.events[region] = { event: { id: 0 } };
                }
                if (cache.events[region].event.id != event.id) {
                    Object.keys(guild).forEach(id => {
                        if (!guild[id].eventChannelJP) return;
                        var channel = Kokoro.guilds.get(id)
                            .channels.get(guild[id].eventChannelJP);
                        channel.send(guild[id].eventMsgJP);
                        Kokoro.invoke(channel, ["gbp", "event", region, "--force"]);
                    });
                }
            })
            .catch(error => {
                throw new Error(error.stack);
            });
    }
}<|endoftext|>


<commit_before>const path = require('path');
const webpack = require(path.join(require("os").homedir(), '.npm-packages/lib/node_modules/webpack'));
/**
 * @type {import("webpack").Configuration}
 */
module.exports = {
  watch: false,
  entry: {
    "bundled1": path.resolve(__dirname, './webpack-libs-bundle.js'),
    "morgan": require.resolve("morgan"),
    "compiled": path.resolve(__dirname, './src/server.js')
  },
  output: {
    filename: '[name]-lib.js',
    path: path.resolve(__dirname, './lib'),
    library: "[name]",
    libraryTarget: "commonjs2"
  },
  plugins: [
    new webpack.DefinePlugin({
      GENTLY: false,
      global: { GENTLY: false }
    })
  ],
  mode: false ? "development" : "production",
  target: 'node',
  node: {
    __dirname: true,
    __filename: true
  },
  externals: {
    'utf-8-validate': 'commonjs utf-8-validate',
    'bufferutil': 'commonjs bufferutil',
  }
};<commit_msg>Update webpack.config.js<commit_after>const path = require('path');
const webpack = module.parent.require("webpack");
/**
 * @type {import("webpack").Configuration}
 */
module.exports = {
  watch: false,
  entry: {
    "bundled1": path.resolve(__dirname, './webpack-libs-bundle.js'),
    "morgan": require.resolve("morgan"),
    "compiled": path.resolve(__dirname, './src/server.js')
  },
  output: {
    filename: '[name]-lib.js',
    path: path.resolve(__dirname, './lib'),
    library: "[name]",
    libraryTarget: "commonjs2"
  },
  plugins: [
    new webpack.DefinePlugin({
      GENTLY: false,
      global: { GENTLY: false }
    })
  ],
  mode: false ? "development" : "production",
  target: 'node',
  node: {
    __dirname: true,
    __filename: true
  },
  externals: {
    'utf-8-validate': 'commonjs utf-8-validate',
    'bufferutil': 'commonjs bufferutil',
  }
};<|endoftext|>