Skip to content

Commit

Permalink
use browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jun 4, 2015
1 parent bc26469 commit 00251e5
Show file tree
Hide file tree
Showing 34 changed files with 256 additions and 128 deletions.
38 changes: 13 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@ module.exports = function(grunt) {
buildName: 'matter',
buildVersion: 'edge-master',
docVersion: 'v<%= pkg.version %>',
concat: {
build: {
options: {
process: function(src, filepath) {
return '// Begin ' + filepath + '\n\n' + src + '\n\n; // End ' + filepath + '\n\n';
}
},
src: ['src/**/*.js', '!src/module/*'],
dest: 'build/<%= buildName %>.js'
browserify: {
options: {
banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n',
},
pack: {
options: {
banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n'
},
src: ['src/module/Intro.js', 'build/<%= buildName %>.js', 'src/module/Outro.js'],
dest: 'build/<%= buildName %>.js'
}
'build/<%= buildName %>.js': ['src/module/main.js']
},
uglify: {
min: {
Expand Down Expand Up @@ -49,9 +37,9 @@ module.exports = function(grunt) {
},
copy: {
demo: {
src: 'build/<%= buildName %>.js',
dest: 'demo/js/lib/<%= buildName %>.js'
}
src: 'build/<%= buildName %>.js',
dest: 'demo/js/lib/<%= buildName %>.js'
}
},
jshint: {
options: {
Expand Down Expand Up @@ -110,7 +98,7 @@ module.exports = function(grunt) {
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
Expand All @@ -134,20 +122,20 @@ module.exports = function(grunt) {
if (isDev) {
grunt.config.set('buildName', 'matter-dev');
grunt.config.set('buildVersion', pkg.version + '-dev');
grunt.task.run('concat', 'uglify:dev', 'uglify:min', 'copy');
grunt.task.run('browserify', 'uglify:dev', 'uglify:min', 'copy');
}

// release build mode
if (isRelease) {
grunt.config.set('buildName', 'matter-' + pkg.version);
grunt.config.set('buildVersion', pkg.version + '-alpha');
grunt.task.run('concat', 'uglify:min', 'copy');
grunt.task.run('browserify', 'uglify:min', 'copy');
}

// edge build mode (default)
if (isEdge || (!isDev && !isRelease)) {
grunt.config.set('buildVersion', 'edge-master');
grunt.task.run('concat', 'preprocess', 'uglify:min');
grunt.task.run('browserify', 'preprocess', 'uglify:min');
}
});

Expand All @@ -158,11 +146,11 @@ module.exports = function(grunt) {

if (isEdge)
grunt.config.set('docVersion', 'edge version (master)');

grunt.task.run('yuidoc');
});

grunt.registerTask('set_config', 'Set a config property.', function(name, val) {
grunt.config.set(name, val);
});
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-browserify": "~3.7.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-jshint": "~0.6.3",
Expand Down
10 changes: 10 additions & 0 deletions src/body/Body.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
var Vertices = require('../geometry/Vertices');
var Vector = require('../geometry/Vector');
var Sleeping = require('../core/Sleeping');
var Render = require('../render/Render');
var Common = require('../core/Common');
var Bounds = require('../geometry/Bounds');
var Axes = require('../geometry/Axes');

/**
* The `Matter.Body` module contains methods for creating and manipulating body models.
* A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`.
Expand All @@ -11,6 +19,8 @@

var Body = {};

module.exports = Body;

(function() {

Body._inertiaScale = 4;
Expand Down
6 changes: 6 additions & 0 deletions src/body/Composite.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var Events = require('../core/Events');
var Common = require('../core/Common');
var Body = require('./Body');

/**
* The `Matter.Composite` module contains methods for creating and manipulating composite bodies.
* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure.
Expand All @@ -12,6 +16,8 @@

var Composite = {};

module.exports = Composite;

(function() {

/**
Expand Down
6 changes: 6 additions & 0 deletions src/body/World.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var Composite = require('./Composite');
var Constraint = require('../constraint/Constraint');
var Common = require('../core/Common');

/**
* The `Matter.World` module contains methods for creating and manipulating the world composite.
* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`.
Expand All @@ -14,6 +18,8 @@

var World = {};

module.exports = World;

(function() {

/**
Expand Down
2 changes: 2 additions & 0 deletions src/collision/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

var Contact = {};

module.exports = Contact;

(function() {

/**
Expand Down
6 changes: 6 additions & 0 deletions src/collision/Detector.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var SAT = require('./SAT');
var Pair = require('./Pair');
var Bounds = require('../geometry/Bounds');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
Expand All @@ -8,6 +12,8 @@

var Detector = {};

module.exports = Detector;

(function() {

/**
Expand Down
6 changes: 6 additions & 0 deletions src/collision/Grid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var Pair = require('./Pair');
var Detector = require('./Detector');
var Common = require('../core/Common');

/**
* See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js)
* and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples.
Expand All @@ -7,6 +11,8 @@

var Grid = {};

module.exports = Grid;

(function() {

/**
Expand Down
4 changes: 4 additions & 0 deletions src/collision/Pair.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var Contact = require('./Contact');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
Expand All @@ -6,6 +8,8 @@

var Pair = {};

module.exports = Pair;

(function() {

/**
Expand Down
5 changes: 5 additions & 0 deletions src/collision/Pairs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var Pair = require('./Pair');
var Common = require('../core/Common');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
Expand All @@ -6,6 +9,8 @@

var Pairs = {};

module.exports = Pairs;

(function() {

var _pairMaxIdleLife = 1000;
Expand Down
8 changes: 8 additions & 0 deletions src/collision/Query.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
var Vector = require('../geometry/Vector');
var SAT = require('./SAT');
var Bounds = require('../geometry/Bounds');
var Bodies = require('../factory/Bodies');
var Vertices = require('../geometry/Vertices');

/**
* The `Matter.Query` module contains methods for performing collision queries.
*
Expand All @@ -6,6 +12,8 @@

var Query = {};

module.exports = Query;

(function() {

/**
Expand Down
7 changes: 7 additions & 0 deletions src/collision/Resolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
var Vertices = require('../geometry/Vertices');
var Vector = require('../geometry/Vector');
var Common = require('../core/Common');
var Bounds = require('../geometry/Bounds');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
Expand All @@ -6,6 +11,8 @@

var Resolver = {};

module.exports = Resolver;

(function() {

Resolver._restingThresh = 4;
Expand Down
5 changes: 5 additions & 0 deletions src/collision/SAT.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var Vertices = require('../geometry/Vertices');
var Vector = require('../geometry/Vector');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
Expand All @@ -8,6 +11,8 @@

var SAT = {};

module.exports = SAT;

(function() {

/**
Expand Down
9 changes: 9 additions & 0 deletions src/constraint/Constraint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
var Vertices = require('../geometry/Vertices');
var Vector = require('../geometry/Vector');
var Sleeping = require('../core/Sleeping');
var Bounds = require('../geometry/Bounds');
var Axes = require('../geometry/Axes');
var Common = require('../core/Common');

/**
* The `Matter.Constraint` module contains methods for creating and manipulating constraints.
* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position).
Expand All @@ -19,6 +26,8 @@

var Constraint = {};

module.exports = Constraint;

(function() {

var _minLength = 0.000001,
Expand Down
12 changes: 12 additions & 0 deletions src/constraint/MouseConstraint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
var Vertices = require('../geometry/Vertices');
var Sleeping = require('../core/Sleeping');
var Mouse = require('../core/Mouse');
var Events = require('../core/Events');
var Detector = require('../collision/Detector');
var Constraint = require('./Constraint');
var Composite = require('../body/Composite');
var Common = require('../core/Common');
var Bounds = require('../geometry/Bounds');

/**
* The `Matter.MouseConstraint` module contains methods for creating mouse constraints.
* Mouse constraints are used for allowing user interaction, providing the ability to move bodies via the mouse or touch.
Expand All @@ -10,6 +20,8 @@

var MouseConstraint = {};

module.exports = MouseConstraint;

(function() {

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

var Common = {};

module.exports = Common;

(function() {

Common._nextId = 0;
Expand Down
15 changes: 15 additions & 0 deletions src/core/Engine.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
var World = require('../body/World');
var Sleeping = require('./Sleeping');
var Resolver = require('../collision/Resolver');
var Render = require('../render/Render');
var Pairs = require('../collision/Pairs');
var Metrics = require('./Metrics');
var Grid = require('../collision/Grid');
var Events = require('./Events');
var Composite = require('../body/Composite');
var Constraint = require('../constraint/Constraint');
var Common = require('./Common');
var Body = require('../body/Body');

/**
* The `Matter.Engine` module contains methods for creating and manipulating engines.
* An engine is a controller that manages updating and rendering the simulation of the world.
Expand All @@ -11,6 +24,8 @@

var Engine = {};

module.exports = Engine;

(function() {

var _fps = 60,
Expand Down
4 changes: 4 additions & 0 deletions src/core/Events.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var Common = require('./Common');

/**
* See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js)
* and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples.
Expand All @@ -7,6 +9,8 @@

var Events = {};

module.exports = Events;

(function() {

/**
Expand Down
4 changes: 4 additions & 0 deletions src/core/Metrics.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// @if DEBUG
var Composite = require('../body/Composite');

/**
* _Internal Class_, not generally used outside of the engine's internals.
*
*/

var Metrics = {};

module.exports = Metrics;

(function() {

/**
Expand Down
Loading

0 comments on commit 00251e5

Please sign in to comment.