From 19a2a7308c9abca9ea8294e48dc3fcf56977db04 Mon Sep 17 00:00:00 2001 From: Ian McGregor Date: Tue, 27 Sep 2016 08:45:30 +0100 Subject: [PATCH 1/3] Convert to es6 and rollup --- .eslintrc | 115 + .jshintrc | 89 - .travis.yml | 4 +- README.md | 18 +- bower.json | 2 +- dist/sono.js | 5523 ++++++++++++++------------- dist/sono.js.map | 74 +- dist/sono.min.js | 4 +- examples/css/player.css | 2 +- examples/css/styles.css | 32 +- examples/js/example.js | 1043 ++--- examples/js/recorder.js | 197 +- examples/js/three.js | 24 +- examples/js/threed.js | 63 +- examples/js/ui.js | 708 ++-- gulpfile.js | 153 +- karma.conf.js | 125 +- package.json | 66 +- rollup.config.js | 38 + src/lib/effect.js | 430 ++- src/lib/effect/analyser.js | 327 +- src/lib/effect/distortion.js | 43 +- src/lib/effect/echo.js | 38 +- src/lib/effect/fake-context.js | 26 +- src/lib/effect/filter.js | 38 +- src/lib/effect/flanger.js | 128 +- src/lib/effect/panner.js | 135 +- src/lib/effect/phaser.js | 67 +- src/lib/effect/recorder.js | 119 +- src/lib/effect/reverb.js | 86 +- src/lib/group.js | 170 +- src/lib/sound.js | 232 +- src/lib/source/buffer-source.js | 120 +- src/lib/source/media-source.js | 144 +- src/lib/source/microphone-source.js | 62 +- src/lib/source/oscillator-source.js | 65 +- src/lib/source/script-source.js | 82 +- src/lib/utils/browser.js | 54 +- src/lib/utils/emitter.js | 35 +- src/lib/utils/file.js | 186 +- src/lib/utils/loader.js | 312 +- src/lib/utils/microphone.js | 41 +- src/lib/utils/sound-group.js | 32 +- src/lib/utils/utils.js | 126 +- src/lib/utils/validify.js | 18 +- src/lib/utils/waveform.js | 55 +- src/lib/utils/waveformer.js | 260 +- src/sono.js | 323 +- test/api.spec.js | 170 +- test/destroy.spec.js | 13 +- test/effect.spec.js | 250 +- test/file.spec.js | 61 +- test/group.spec.js | 24 +- test/helper.js | 1 + test/loader.spec.js | 173 +- test/playback.spec.js | 165 +- test/sound.spec.js | 97 +- test/source.spec.js | 244 +- test/utils.spec.js | 34 +- 59 files changed, 6851 insertions(+), 6415 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jshintrc mode change 100755 => 100644 dist/sono.min.js create mode 100644 rollup.config.js create mode 100644 test/helper.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..0b7c96b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,115 @@ +{ + "parser": "babel-eslint", + "env": { + "browser": true, + "es6": true, + "mocha": true, + "node": true + }, + "globals": { + "sono": true, + "expect": true, + "it": true + }, + "plugins": [], + "parserOptions": { + "ecmaVersion": 6, + "jsx": true, + "sourceType": "module" + }, + "rules": { + "array-bracket-spacing": [2, "never"], + "block-scoped-var": 0, + "block-spacing": 2, + "brace-style": [2, "1tbs"], + "callback-return": [2, ["cb", "callback", "next"]], + "camelcase": [2, {"properties": "never"}], + "comma-dangle": [2, "never"], + "comma-spacing": 2, + "comma-style": [2, "last"], + "consistent-return": 2, + "curly": [2, "all"], + "default-case": 2, + "dot-location": [2, "property"], + "dot-notation": [2, {"allowKeywords": true}], + "eol-last": 2, + "eqeqeq": 2, + "func-style": [2, "declaration"], + "guard-for-in": 2, + "indent": [2, 4, {"SwitchCase": 1}], + "key-spacing": [2, {"beforeColon": false, "afterColon": true}], + "keyword-spacing": 2, + "max-len": [1, 120], + "new-cap": 0, + "new-parens": 2, + "no-alert": 2, + "no-array-constructor": 2, + "no-caller": 2, + "no-confusing-arrow": 2, + "no-console": 0, + "no-const-assign": 2, + "no-constant-condition": 2, + "no-delete-var": 2, + "no-empty": ["error", { "allowEmptyCatch": true }], + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-extra-semi": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-invalid-this": 2, + "no-iterator": 2, + "no-label-var": 2, + "no-labels": [2, {"allowLoop": true, "allowSwitch": true}], + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-mixed-spaces-and-tabs": [2, false], + "no-multi-spaces": 2, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-nested-ternary": 2, + "no-new-func": 2, + "no-new-object": 2, + "no-new-wrappers": 2, + "no-new": 2, + "no-octal-escape": 2, + "no-octal": 2, + "no-process-exit": 2, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-sequences": 2, + "no-shadow-restricted-names": 2, + "no-shadow": 2, + "no-spaced-func": 2, + "no-trailing-spaces": 2, + "no-undef-init": 2, + "no-undef": 2, + "no-undefined": 2, + "no-underscore-dangle": 0, + "no-unused-expressions": 0, + "no-unused-vars": [2, {"vars": "all", "args": "after-used"}], + "no-use-before-define": 2, + "no-useless-concat": 2, + "no-var": 2, + "no-with": 2, + "object-curly-spacing": [2, "never"], + "prefer-const": 2, + "quotes": [2, "single"], + "radix": 2, + "require-jsdoc": 0, + "semi-spacing": [2, {"before": false, "after": true}], + "semi": 2, + "space-before-blocks": 2, + "space-before-function-paren": [0, "never"], + "space-infix-ops": 2, + "space-unary-ops": [2, {"words": true, "nonwords": false}], + "spaced-comment": [0, "always", {"exceptions": ["-"]}], + "strict": [1, "global"], + "valid-jsdoc": [0, {"prefer": { "return": "returns"}}], + "wrap-iife": 2, + "yoda": [2, "never"] + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 4cb357f..0000000 --- a/.jshintrc +++ /dev/null @@ -1,89 +0,0 @@ -{ - // JSHint Default Configuration File (as on JSHint website) - // See http://jshint.com/docs/ for more details - - "maxerr" : 50, // {int} Maximum error before stopping - - // Enforcing - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : false, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. - "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 4, // {int} Number of spaces to use for indentation - "latedef" : false, // true: Require variables/functions to be defined before being used - "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : false, // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : true, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line - - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : true, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "noyield" : false, // true: Tolerate generator functions with no yield statement in them. - "notypeof" : false, // true: Tolerate invalid typeof operator values - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - // Environments - "browser" : true, // Web Browser (window, document, etc) - "browserify" : true, // Browserify (node.js code in the browser) - "couch" : false, // CouchDB - "devel" : true, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine - "jquery" : false, // jQuery - "mocha" : true, // Mocha - "mootools" : false, // MooTools - "node" : false, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "qunit" : false, // QUnit - "rhino" : false, // Rhino - "shelljs" : false, // ShellJS - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface - - // Custom Globals (additional predefined global variables) - "globals" : { - "expect": false - } -} diff --git a/.travis.yml b/.travis.yml index 347e2e0..db5b40a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: - - 0.12.7 + - 6 addons: - firefox: "39.0" + firefox: "latest" before_install: - 'npm install -g karma-cli' before_script: diff --git a/README.md b/README.md index 773b684..2abc60e 100644 --- a/README.md +++ b/README.md @@ -101,15 +101,27 @@ echo.feedback = 0.9; ## Dev setup -To install dependencies: +Install dependencies: ``` $ npm install ``` -To run tests: +Run tests: ``` $ npm install -g karma-cli -$ karma start +$ npm test +``` + +Build bundles: + +``` +$ npm run build +``` + +Watch and continuous tests: + +``` +$ npm start ``` diff --git a/bower.json b/bower.json index b4009f0..a7177a7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "sono", - "version": "0.1.2", + "version": "0.1.8", "homepage": "https://github.com/Stinkdigital/sono", "authors": [ "Ian McGregor " diff --git a/dist/sono.js b/dist/sono.js index 79b5d74..0e0d20e 100755 --- a/dist/sono.js +++ b/dist/sono.js @@ -1,822 +1,571 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.sono = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o