2211 lines
197 KiB
JavaScript
2211 lines
197 KiB
JavaScript
|
|
(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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||
|
|
require('../modules/es6.object.to-string');
|
||
|
|
require('../modules/es6.string.iterator');
|
||
|
|
require('../modules/web.dom.iterable');
|
||
|
|
require('../modules/es6.map');
|
||
|
|
module.exports = require('../modules/$.core').Map;
|
||
|
|
},{"../modules/$.core":10,"../modules/es6.map":50,"../modules/es6.object.to-string":51,"../modules/es6.string.iterator":53,"../modules/web.dom.iterable":55}],2:[function(require,module,exports){
|
||
|
|
require('../modules/es6.object.to-string');
|
||
|
|
require('../modules/es6.string.iterator');
|
||
|
|
require('../modules/web.dom.iterable');
|
||
|
|
require('../modules/es6.set');
|
||
|
|
module.exports = require('../modules/$.core').Set;
|
||
|
|
},{"../modules/$.core":10,"../modules/es6.object.to-string":51,"../modules/es6.set":52,"../modules/es6.string.iterator":53,"../modules/web.dom.iterable":55}],3:[function(require,module,exports){
|
||
|
|
require('../modules/es6.symbol');
|
||
|
|
module.exports = require('../modules/$.core').Symbol;
|
||
|
|
},{"../modules/$.core":10,"../modules/es6.symbol":54}],4:[function(require,module,exports){
|
||
|
|
module.exports = function(it){
|
||
|
|
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
|
||
|
|
return it;
|
||
|
|
};
|
||
|
|
},{}],5:[function(require,module,exports){
|
||
|
|
var isObject = require('./$.is-object');
|
||
|
|
module.exports = function(it){
|
||
|
|
if(!isObject(it))throw TypeError(it + ' is not an object!');
|
||
|
|
return it;
|
||
|
|
};
|
||
|
|
},{"./$.is-object":23}],6:[function(require,module,exports){
|
||
|
|
// getting tag from 19.1.3.6 Object.prototype.toString()
|
||
|
|
var cof = require('./$.cof')
|
||
|
|
, TAG = require('./$.wks')('toStringTag')
|
||
|
|
// ES3 wrong here
|
||
|
|
, ARG = cof(function(){ return arguments; }()) == 'Arguments';
|
||
|
|
|
||
|
|
module.exports = function(it){
|
||
|
|
var O, T, B;
|
||
|
|
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
||
|
|
// @@toStringTag case
|
||
|
|
: typeof (T = (O = Object(it))[TAG]) == 'string' ? T
|
||
|
|
// builtinTag case
|
||
|
|
: ARG ? cof(O)
|
||
|
|
// ES3 arguments fallback
|
||
|
|
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
||
|
|
};
|
||
|
|
},{"./$.cof":7,"./$.wks":47}],7:[function(require,module,exports){
|
||
|
|
var toString = {}.toString;
|
||
|
|
|
||
|
|
module.exports = function(it){
|
||
|
|
return toString.call(it).slice(8, -1);
|
||
|
|
};
|
||
|
|
},{}],8:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var $ = require('./$')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, ctx = require('./$.ctx')
|
||
|
|
, species = require('./$.species')
|
||
|
|
, strictNew = require('./$.strict-new')
|
||
|
|
, defined = require('./$.defined')
|
||
|
|
, forOf = require('./$.for-of')
|
||
|
|
, step = require('./$.iter-step')
|
||
|
|
, ID = require('./$.uid')('id')
|
||
|
|
, $has = require('./$.has')
|
||
|
|
, isObject = require('./$.is-object')
|
||
|
|
, isExtensible = Object.isExtensible || isObject
|
||
|
|
, SUPPORT_DESC = require('./$.support-desc')
|
||
|
|
, SIZE = SUPPORT_DESC ? '_s' : 'size'
|
||
|
|
, id = 0;
|
||
|
|
|
||
|
|
var fastKey = function(it, create){
|
||
|
|
// return primitive with prefix
|
||
|
|
if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
||
|
|
if(!$has(it, ID)){
|
||
|
|
// can't set id to frozen object
|
||
|
|
if(!isExtensible(it))return 'F';
|
||
|
|
// not necessary to add id
|
||
|
|
if(!create)return 'E';
|
||
|
|
// add missing object id
|
||
|
|
hide(it, ID, ++id);
|
||
|
|
// return object id with prefix
|
||
|
|
} return 'O' + it[ID];
|
||
|
|
};
|
||
|
|
|
||
|
|
var getEntry = function(that, key){
|
||
|
|
// fast case
|
||
|
|
var index = fastKey(key), entry;
|
||
|
|
if(index !== 'F')return that._i[index];
|
||
|
|
// frozen object case
|
||
|
|
for(entry = that._f; entry; entry = entry.n){
|
||
|
|
if(entry.k == key)return entry;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
module.exports = {
|
||
|
|
getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
|
||
|
|
var C = wrapper(function(that, iterable){
|
||
|
|
strictNew(that, C, NAME);
|
||
|
|
that._i = $.create(null); // index
|
||
|
|
that._f = undefined; // first entry
|
||
|
|
that._l = undefined; // last entry
|
||
|
|
that[SIZE] = 0; // size
|
||
|
|
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
|
||
|
|
});
|
||
|
|
require('./$.mix')(C.prototype, {
|
||
|
|
// 23.1.3.1 Map.prototype.clear()
|
||
|
|
// 23.2.3.2 Set.prototype.clear()
|
||
|
|
clear: function clear(){
|
||
|
|
for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
|
||
|
|
entry.r = true;
|
||
|
|
if(entry.p)entry.p = entry.p.n = undefined;
|
||
|
|
delete data[entry.i];
|
||
|
|
}
|
||
|
|
that._f = that._l = undefined;
|
||
|
|
that[SIZE] = 0;
|
||
|
|
},
|
||
|
|
// 23.1.3.3 Map.prototype.delete(key)
|
||
|
|
// 23.2.3.4 Set.prototype.delete(value)
|
||
|
|
'delete': function(key){
|
||
|
|
var that = this
|
||
|
|
, entry = getEntry(that, key);
|
||
|
|
if(entry){
|
||
|
|
var next = entry.n
|
||
|
|
, prev = entry.p;
|
||
|
|
delete that._i[entry.i];
|
||
|
|
entry.r = true;
|
||
|
|
if(prev)prev.n = next;
|
||
|
|
if(next)next.p = prev;
|
||
|
|
if(that._f == entry)that._f = next;
|
||
|
|
if(that._l == entry)that._l = prev;
|
||
|
|
that[SIZE]--;
|
||
|
|
} return !!entry;
|
||
|
|
},
|
||
|
|
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
|
||
|
|
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
|
||
|
|
forEach: function forEach(callbackfn /*, that = undefined */){
|
||
|
|
var f = ctx(callbackfn, arguments[1], 3)
|
||
|
|
, entry;
|
||
|
|
while(entry = entry ? entry.n : this._f){
|
||
|
|
f(entry.v, entry.k, this);
|
||
|
|
// revert to the last existing entry
|
||
|
|
while(entry && entry.r)entry = entry.p;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 23.1.3.7 Map.prototype.has(key)
|
||
|
|
// 23.2.3.7 Set.prototype.has(value)
|
||
|
|
has: function has(key){
|
||
|
|
return !!getEntry(this, key);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
if(SUPPORT_DESC)$.setDesc(C.prototype, 'size', {
|
||
|
|
get: function(){
|
||
|
|
return defined(this[SIZE]);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return C;
|
||
|
|
},
|
||
|
|
def: function(that, key, value){
|
||
|
|
var entry = getEntry(that, key)
|
||
|
|
, prev, index;
|
||
|
|
// change existing entry
|
||
|
|
if(entry){
|
||
|
|
entry.v = value;
|
||
|
|
// create new entry
|
||
|
|
} else {
|
||
|
|
that._l = entry = {
|
||
|
|
i: index = fastKey(key, true), // <- index
|
||
|
|
k: key, // <- key
|
||
|
|
v: value, // <- value
|
||
|
|
p: prev = that._l, // <- previous entry
|
||
|
|
n: undefined, // <- next entry
|
||
|
|
r: false // <- removed
|
||
|
|
};
|
||
|
|
if(!that._f)that._f = entry;
|
||
|
|
if(prev)prev.n = entry;
|
||
|
|
that[SIZE]++;
|
||
|
|
// add to index
|
||
|
|
if(index !== 'F')that._i[index] = entry;
|
||
|
|
} return that;
|
||
|
|
},
|
||
|
|
getEntry: getEntry,
|
||
|
|
setStrong: function(C, NAME, IS_MAP){
|
||
|
|
// add .keys, .values, .entries, [@@iterator]
|
||
|
|
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
|
||
|
|
require('./$.iter-define')(C, NAME, function(iterated, kind){
|
||
|
|
this._t = iterated; // target
|
||
|
|
this._k = kind; // kind
|
||
|
|
this._l = undefined; // previous
|
||
|
|
}, function(){
|
||
|
|
var that = this
|
||
|
|
, kind = that._k
|
||
|
|
, entry = that._l;
|
||
|
|
// revert to the last existing entry
|
||
|
|
while(entry && entry.r)entry = entry.p;
|
||
|
|
// get next entry
|
||
|
|
if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
|
||
|
|
// or finish the iteration
|
||
|
|
that._t = undefined;
|
||
|
|
return step(1);
|
||
|
|
}
|
||
|
|
// return step by kind
|
||
|
|
if(kind == 'keys' )return step(0, entry.k);
|
||
|
|
if(kind == 'values')return step(0, entry.v);
|
||
|
|
return step(0, [entry.k, entry.v]);
|
||
|
|
}, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
|
||
|
|
|
||
|
|
// add [@@species], 23.1.2.2, 23.2.2.2
|
||
|
|
species(C);
|
||
|
|
species(require('./$.core')[NAME]); // for wrapper
|
||
|
|
}
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.core":10,"./$.ctx":11,"./$.defined":13,"./$.for-of":16,"./$.has":19,"./$.hide":20,"./$.is-object":23,"./$.iter-define":26,"./$.iter-step":28,"./$.mix":33,"./$.species":37,"./$.strict-new":38,"./$.support-desc":40,"./$.uid":45}],9:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var global = require('./$.global')
|
||
|
|
, $def = require('./$.def')
|
||
|
|
, forOf = require('./$.for-of')
|
||
|
|
, strictNew = require('./$.strict-new');
|
||
|
|
|
||
|
|
module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
|
||
|
|
var Base = global[NAME]
|
||
|
|
, C = Base
|
||
|
|
, ADDER = IS_MAP ? 'set' : 'add'
|
||
|
|
, proto = C && C.prototype
|
||
|
|
, O = {};
|
||
|
|
var fixMethod = function(KEY){
|
||
|
|
var fn = proto[KEY];
|
||
|
|
require('./$.redef')(proto, KEY,
|
||
|
|
KEY == 'delete' ? function(a){ return fn.call(this, a === 0 ? 0 : a); }
|
||
|
|
: KEY == 'has' ? function has(a){ return fn.call(this, a === 0 ? 0 : a); }
|
||
|
|
: KEY == 'get' ? function get(a){ return fn.call(this, a === 0 ? 0 : a); }
|
||
|
|
: KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
|
||
|
|
: function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
|
||
|
|
);
|
||
|
|
};
|
||
|
|
if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !require('./$.fails')(function(){
|
||
|
|
new C().entries().next();
|
||
|
|
}))){
|
||
|
|
// create collection constructor
|
||
|
|
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
||
|
|
require('./$.mix')(C.prototype, methods);
|
||
|
|
} else {
|
||
|
|
var inst = new C
|
||
|
|
, chain = inst[ADDER](IS_WEAK ? {} : -0, 1)
|
||
|
|
, buggyZero;
|
||
|
|
// wrap for init collections from iterable
|
||
|
|
if(!require('./$.iter-detect')(function(iter){ new C(iter); })){ // eslint-disable-line no-new
|
||
|
|
C = wrapper(function(target, iterable){
|
||
|
|
strictNew(target, C, NAME);
|
||
|
|
var that = new Base;
|
||
|
|
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
|
||
|
|
return that;
|
||
|
|
});
|
||
|
|
C.prototype = proto;
|
||
|
|
proto.constructor = C;
|
||
|
|
}
|
||
|
|
IS_WEAK || inst.forEach(function(val, key){
|
||
|
|
buggyZero = 1 / key === -Infinity;
|
||
|
|
});
|
||
|
|
// fix converting -0 key to +0
|
||
|
|
if(buggyZero){
|
||
|
|
fixMethod('delete');
|
||
|
|
fixMethod('has');
|
||
|
|
IS_MAP && fixMethod('get');
|
||
|
|
}
|
||
|
|
// + fix .add & .set for chaining
|
||
|
|
if(buggyZero || chain !== inst)fixMethod(ADDER);
|
||
|
|
// weak collections should not contains .clear method
|
||
|
|
if(IS_WEAK && proto.clear)delete proto.clear;
|
||
|
|
}
|
||
|
|
|
||
|
|
require('./$.tag')(C, NAME);
|
||
|
|
|
||
|
|
O[NAME] = C;
|
||
|
|
$def($def.G + $def.W + $def.F * (C != Base), O);
|
||
|
|
|
||
|
|
if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
|
||
|
|
|
||
|
|
return C;
|
||
|
|
};
|
||
|
|
},{"./$.def":12,"./$.fails":15,"./$.for-of":16,"./$.global":18,"./$.iter-detect":27,"./$.mix":33,"./$.redef":35,"./$.strict-new":38,"./$.tag":41}],10:[function(require,module,exports){
|
||
|
|
var core = module.exports = {};
|
||
|
|
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
|
||
|
|
},{}],11:[function(require,module,exports){
|
||
|
|
// optional / simple context binding
|
||
|
|
var aFunction = require('./$.a-function');
|
||
|
|
module.exports = function(fn, that, length){
|
||
|
|
aFunction(fn);
|
||
|
|
if(that === undefined)return fn;
|
||
|
|
switch(length){
|
||
|
|
case 1: return function(a){
|
||
|
|
return fn.call(that, a);
|
||
|
|
};
|
||
|
|
case 2: return function(a, b){
|
||
|
|
return fn.call(that, a, b);
|
||
|
|
};
|
||
|
|
case 3: return function(a, b, c){
|
||
|
|
return fn.call(that, a, b, c);
|
||
|
|
};
|
||
|
|
} return function(/* ...args */){
|
||
|
|
return fn.apply(that, arguments);
|
||
|
|
};
|
||
|
|
};
|
||
|
|
},{"./$.a-function":4}],12:[function(require,module,exports){
|
||
|
|
var global = require('./$.global')
|
||
|
|
, core = require('./$.core')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, $redef = require('./$.redef')
|
||
|
|
, PROTOTYPE = 'prototype';
|
||
|
|
var ctx = function(fn, that){
|
||
|
|
return function(){
|
||
|
|
return fn.apply(that, arguments);
|
||
|
|
};
|
||
|
|
};
|
||
|
|
var $def = function(type, name, source){
|
||
|
|
var key, own, out, exp
|
||
|
|
, isGlobal = type & $def.G
|
||
|
|
, isProto = type & $def.P
|
||
|
|
, target = isGlobal ? global : type & $def.S
|
||
|
|
? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
|
||
|
|
, exports = isGlobal ? core : core[name] || (core[name] = {});
|
||
|
|
if(isGlobal)source = name;
|
||
|
|
for(key in source){
|
||
|
|
// contains in native
|
||
|
|
own = !(type & $def.F) && target && key in target;
|
||
|
|
// export native or passed
|
||
|
|
out = (own ? target : source)[key];
|
||
|
|
// bind timers to global for call from export context
|
||
|
|
if(type & $def.B && own)exp = ctx(out, global);
|
||
|
|
else exp = isProto && typeof out == 'function' ? ctx(Function.call, out) : out;
|
||
|
|
// extend global
|
||
|
|
if(target && !own)$redef(target, key, out);
|
||
|
|
// export
|
||
|
|
if(exports[key] != out)hide(exports, key, exp);
|
||
|
|
if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
global.core = core;
|
||
|
|
// type bitmap
|
||
|
|
$def.F = 1; // forced
|
||
|
|
$def.G = 2; // global
|
||
|
|
$def.S = 4; // static
|
||
|
|
$def.P = 8; // proto
|
||
|
|
$def.B = 16; // bind
|
||
|
|
$def.W = 32; // wrap
|
||
|
|
module.exports = $def;
|
||
|
|
},{"./$.core":10,"./$.global":18,"./$.hide":20,"./$.redef":35}],13:[function(require,module,exports){
|
||
|
|
// 7.2.1 RequireObjectCoercible(argument)
|
||
|
|
module.exports = function(it){
|
||
|
|
if(it == undefined)throw TypeError("Can't call method on " + it);
|
||
|
|
return it;
|
||
|
|
};
|
||
|
|
},{}],14:[function(require,module,exports){
|
||
|
|
// all enumerable object keys, includes symbols
|
||
|
|
var $ = require('./$');
|
||
|
|
module.exports = function(it){
|
||
|
|
var keys = $.getKeys(it)
|
||
|
|
, getSymbols = $.getSymbols;
|
||
|
|
if(getSymbols){
|
||
|
|
var symbols = getSymbols(it)
|
||
|
|
, isEnum = $.isEnum
|
||
|
|
, i = 0
|
||
|
|
, key;
|
||
|
|
while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key);
|
||
|
|
}
|
||
|
|
return keys;
|
||
|
|
};
|
||
|
|
},{"./$":30}],15:[function(require,module,exports){
|
||
|
|
module.exports = function(exec){
|
||
|
|
try {
|
||
|
|
return !!exec();
|
||
|
|
} catch(e){
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
},{}],16:[function(require,module,exports){
|
||
|
|
var ctx = require('./$.ctx')
|
||
|
|
, call = require('./$.iter-call')
|
||
|
|
, isArrayIter = require('./$.is-array-iter')
|
||
|
|
, anObject = require('./$.an-object')
|
||
|
|
, toLength = require('./$.to-length')
|
||
|
|
, getIterFn = require('./core.get-iterator-method');
|
||
|
|
module.exports = function(iterable, entries, fn, that){
|
||
|
|
var iterFn = getIterFn(iterable)
|
||
|
|
, f = ctx(fn, that, entries ? 2 : 1)
|
||
|
|
, index = 0
|
||
|
|
, length, step, iterator;
|
||
|
|
if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
|
||
|
|
// fast case for arrays with default iterator
|
||
|
|
if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
|
||
|
|
entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
||
|
|
} else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
|
||
|
|
call(iterator, f, step.value, entries);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
},{"./$.an-object":5,"./$.ctx":11,"./$.is-array-iter":22,"./$.iter-call":24,"./$.to-length":44,"./core.get-iterator-method":48}],17:[function(require,module,exports){
|
||
|
|
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
|
||
|
|
var toString = {}.toString
|
||
|
|
, toIObject = require('./$.to-iobject')
|
||
|
|
, getNames = require('./$').getNames;
|
||
|
|
|
||
|
|
var windowNames = typeof window == 'object' && Object.getOwnPropertyNames
|
||
|
|
? Object.getOwnPropertyNames(window) : [];
|
||
|
|
|
||
|
|
var getWindowNames = function(it){
|
||
|
|
try {
|
||
|
|
return getNames(it);
|
||
|
|
} catch(e){
|
||
|
|
return windowNames.slice();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
module.exports.get = function getOwnPropertyNames(it){
|
||
|
|
if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it);
|
||
|
|
return getNames(toIObject(it));
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.to-iobject":43}],18:[function(require,module,exports){
|
||
|
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
||
|
|
var UNDEFINED = 'undefined';
|
||
|
|
var global = module.exports = typeof window != UNDEFINED && window.Math == Math
|
||
|
|
? window : typeof self != UNDEFINED && self.Math == Math ? self : Function('return this')();
|
||
|
|
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
|
||
|
|
},{}],19:[function(require,module,exports){
|
||
|
|
var hasOwnProperty = {}.hasOwnProperty;
|
||
|
|
module.exports = function(it, key){
|
||
|
|
return hasOwnProperty.call(it, key);
|
||
|
|
};
|
||
|
|
},{}],20:[function(require,module,exports){
|
||
|
|
var $ = require('./$')
|
||
|
|
, createDesc = require('./$.property-desc');
|
||
|
|
module.exports = require('./$.support-desc') ? function(object, key, value){
|
||
|
|
return $.setDesc(object, key, createDesc(1, value));
|
||
|
|
} : function(object, key, value){
|
||
|
|
object[key] = value;
|
||
|
|
return object;
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.property-desc":34,"./$.support-desc":40}],21:[function(require,module,exports){
|
||
|
|
// indexed object, fallback for non-array-like ES3 strings
|
||
|
|
var cof = require('./$.cof');
|
||
|
|
module.exports = 0 in Object('z') ? Object : function(it){
|
||
|
|
return cof(it) == 'String' ? it.split('') : Object(it);
|
||
|
|
};
|
||
|
|
},{"./$.cof":7}],22:[function(require,module,exports){
|
||
|
|
// check on default Array iterator
|
||
|
|
var Iterators = require('./$.iterators')
|
||
|
|
, ITERATOR = require('./$.wks')('iterator');
|
||
|
|
module.exports = function(it){
|
||
|
|
return (Iterators.Array || Array.prototype[ITERATOR]) === it;
|
||
|
|
};
|
||
|
|
},{"./$.iterators":29,"./$.wks":47}],23:[function(require,module,exports){
|
||
|
|
// http://jsperf.com/core-js-isobject
|
||
|
|
module.exports = function(it){
|
||
|
|
return it !== null && (typeof it == 'object' || typeof it == 'function');
|
||
|
|
};
|
||
|
|
},{}],24:[function(require,module,exports){
|
||
|
|
// call something on iterator step with safe closing on error
|
||
|
|
var anObject = require('./$.an-object');
|
||
|
|
module.exports = function(iterator, fn, value, entries){
|
||
|
|
try {
|
||
|
|
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
|
||
|
|
// 7.4.6 IteratorClose(iterator, completion)
|
||
|
|
} catch(e){
|
||
|
|
var ret = iterator['return'];
|
||
|
|
if(ret !== undefined)anObject(ret.call(iterator));
|
||
|
|
throw e;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
},{"./$.an-object":5}],25:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var $ = require('./$')
|
||
|
|
, IteratorPrototype = {};
|
||
|
|
|
||
|
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
||
|
|
require('./$.hide')(IteratorPrototype, require('./$.wks')('iterator'), function(){ return this; });
|
||
|
|
|
||
|
|
module.exports = function(Constructor, NAME, next){
|
||
|
|
Constructor.prototype = $.create(IteratorPrototype, {next: require('./$.property-desc')(1,next)});
|
||
|
|
require('./$.tag')(Constructor, NAME + ' Iterator');
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.hide":20,"./$.property-desc":34,"./$.tag":41,"./$.wks":47}],26:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var LIBRARY = require('./$.library')
|
||
|
|
, $def = require('./$.def')
|
||
|
|
, $redef = require('./$.redef')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, has = require('./$.has')
|
||
|
|
, SYMBOL_ITERATOR = require('./$.wks')('iterator')
|
||
|
|
, Iterators = require('./$.iterators')
|
||
|
|
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
|
||
|
|
, FF_ITERATOR = '@@iterator'
|
||
|
|
, KEYS = 'keys'
|
||
|
|
, VALUES = 'values';
|
||
|
|
var returnThis = function(){ return this; };
|
||
|
|
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){
|
||
|
|
require('./$.iter-create')(Constructor, NAME, next);
|
||
|
|
var createMethod = function(kind){
|
||
|
|
switch(kind){
|
||
|
|
case KEYS: return function keys(){ return new Constructor(this, kind); };
|
||
|
|
case VALUES: return function values(){ return new Constructor(this, kind); };
|
||
|
|
} return function entries(){ return new Constructor(this, kind); };
|
||
|
|
};
|
||
|
|
var TAG = NAME + ' Iterator'
|
||
|
|
, proto = Base.prototype
|
||
|
|
, _native = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
|
||
|
|
, _default = _native || createMethod(DEFAULT)
|
||
|
|
, methods, key;
|
||
|
|
// Fix native
|
||
|
|
if(_native){
|
||
|
|
var IteratorPrototype = require('./$').getProto(_default.call(new Base));
|
||
|
|
// Set @@toStringTag to native iterators
|
||
|
|
require('./$.tag')(IteratorPrototype, TAG, true);
|
||
|
|
// FF fix
|
||
|
|
if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, SYMBOL_ITERATOR, returnThis);
|
||
|
|
}
|
||
|
|
// Define iterator
|
||
|
|
if(!LIBRARY || FORCE)hide(proto, SYMBOL_ITERATOR, _default);
|
||
|
|
// Plug for library
|
||
|
|
Iterators[NAME] = _default;
|
||
|
|
Iterators[TAG] = returnThis;
|
||
|
|
if(DEFAULT){
|
||
|
|
methods = {
|
||
|
|
keys: IS_SET ? _default : createMethod(KEYS),
|
||
|
|
values: DEFAULT == VALUES ? _default : createMethod(VALUES),
|
||
|
|
entries: DEFAULT != VALUES ? _default : createMethod('entries')
|
||
|
|
};
|
||
|
|
if(FORCE)for(key in methods){
|
||
|
|
if(!(key in proto))$redef(proto, key, methods[key]);
|
||
|
|
} else $def($def.P + $def.F * BUGGY, NAME, methods);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.def":12,"./$.has":19,"./$.hide":20,"./$.iter-create":25,"./$.iterators":29,"./$.library":32,"./$.redef":35,"./$.tag":41,"./$.wks":47}],27:[function(require,module,exports){
|
||
|
|
var SYMBOL_ITERATOR = require('./$.wks')('iterator')
|
||
|
|
, SAFE_CLOSING = false;
|
||
|
|
try {
|
||
|
|
var riter = [7][SYMBOL_ITERATOR]();
|
||
|
|
riter['return'] = function(){ SAFE_CLOSING = true; };
|
||
|
|
Array.from(riter, function(){ throw 2; });
|
||
|
|
} catch(e){ /* empty */ }
|
||
|
|
module.exports = function(exec){
|
||
|
|
if(!SAFE_CLOSING)return false;
|
||
|
|
var safe = false;
|
||
|
|
try {
|
||
|
|
var arr = [7]
|
||
|
|
, iter = arr[SYMBOL_ITERATOR]();
|
||
|
|
iter.next = function(){ safe = true; };
|
||
|
|
arr[SYMBOL_ITERATOR] = function(){ return iter; };
|
||
|
|
exec(arr);
|
||
|
|
} catch(e){ /* empty */ }
|
||
|
|
return safe;
|
||
|
|
};
|
||
|
|
},{"./$.wks":47}],28:[function(require,module,exports){
|
||
|
|
module.exports = function(done, value){
|
||
|
|
return {value: value, done: !!done};
|
||
|
|
};
|
||
|
|
},{}],29:[function(require,module,exports){
|
||
|
|
module.exports = {};
|
||
|
|
},{}],30:[function(require,module,exports){
|
||
|
|
var $Object = Object;
|
||
|
|
module.exports = {
|
||
|
|
create: $Object.create,
|
||
|
|
getProto: $Object.getPrototypeOf,
|
||
|
|
isEnum: {}.propertyIsEnumerable,
|
||
|
|
getDesc: $Object.getOwnPropertyDescriptor,
|
||
|
|
setDesc: $Object.defineProperty,
|
||
|
|
setDescs: $Object.defineProperties,
|
||
|
|
getKeys: $Object.keys,
|
||
|
|
getNames: $Object.getOwnPropertyNames,
|
||
|
|
getSymbols: $Object.getOwnPropertySymbols,
|
||
|
|
each: [].forEach
|
||
|
|
};
|
||
|
|
},{}],31:[function(require,module,exports){
|
||
|
|
var $ = require('./$')
|
||
|
|
, toIObject = require('./$.to-iobject');
|
||
|
|
module.exports = function(object, el){
|
||
|
|
var O = toIObject(object)
|
||
|
|
, keys = $.getKeys(O)
|
||
|
|
, length = keys.length
|
||
|
|
, index = 0
|
||
|
|
, key;
|
||
|
|
while(length > index)if(O[key = keys[index++]] === el)return key;
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.to-iobject":43}],32:[function(require,module,exports){
|
||
|
|
module.exports = false;
|
||
|
|
},{}],33:[function(require,module,exports){
|
||
|
|
var $redef = require('./$.redef');
|
||
|
|
module.exports = function(target, src){
|
||
|
|
for(var key in src)$redef(target, key, src[key]);
|
||
|
|
return target;
|
||
|
|
};
|
||
|
|
},{"./$.redef":35}],34:[function(require,module,exports){
|
||
|
|
module.exports = function(bitmap, value){
|
||
|
|
return {
|
||
|
|
enumerable : !(bitmap & 1),
|
||
|
|
configurable: !(bitmap & 2),
|
||
|
|
writable : !(bitmap & 4),
|
||
|
|
value : value
|
||
|
|
};
|
||
|
|
};
|
||
|
|
},{}],35:[function(require,module,exports){
|
||
|
|
// add fake Function#toString
|
||
|
|
// for correct work wrapped methods / constructors with methods like LoDash isNative
|
||
|
|
var global = require('./$.global')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, SRC = require('./$.uid')('src')
|
||
|
|
, TO_STRING = 'toString'
|
||
|
|
, $toString = Function[TO_STRING]
|
||
|
|
, TPL = ('' + $toString).split(TO_STRING);
|
||
|
|
|
||
|
|
require('./$.core').inspectSource = function(it){
|
||
|
|
return $toString.call(it);
|
||
|
|
};
|
||
|
|
|
||
|
|
(module.exports = function(O, key, val, safe){
|
||
|
|
if(typeof val == 'function'){
|
||
|
|
hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
|
||
|
|
if(!('name' in val))val.name = key;
|
||
|
|
}
|
||
|
|
if(O === global){
|
||
|
|
O[key] = val;
|
||
|
|
} else {
|
||
|
|
if(!safe)delete O[key];
|
||
|
|
hide(O, key, val);
|
||
|
|
}
|
||
|
|
})(Function.prototype, TO_STRING, function toString(){
|
||
|
|
return typeof this == 'function' && this[SRC] || $toString.call(this);
|
||
|
|
});
|
||
|
|
},{"./$.core":10,"./$.global":18,"./$.hide":20,"./$.uid":45}],36:[function(require,module,exports){
|
||
|
|
var global = require('./$.global')
|
||
|
|
, SHARED = '__core-js_shared__'
|
||
|
|
, store = global[SHARED] || (global[SHARED] = {});
|
||
|
|
module.exports = function(key){
|
||
|
|
return store[key] || (store[key] = {});
|
||
|
|
};
|
||
|
|
},{"./$.global":18}],37:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var $ = require('./$')
|
||
|
|
, SPECIES = require('./$.wks')('species');
|
||
|
|
module.exports = function(C){
|
||
|
|
if(require('./$.support-desc') && !(SPECIES in C))$.setDesc(C, SPECIES, {
|
||
|
|
configurable: true,
|
||
|
|
get: function(){ return this; }
|
||
|
|
});
|
||
|
|
};
|
||
|
|
},{"./$":30,"./$.support-desc":40,"./$.wks":47}],38:[function(require,module,exports){
|
||
|
|
module.exports = function(it, Constructor, name){
|
||
|
|
if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!");
|
||
|
|
return it;
|
||
|
|
};
|
||
|
|
},{}],39:[function(require,module,exports){
|
||
|
|
// true -> String#at
|
||
|
|
// false -> String#codePointAt
|
||
|
|
var toInteger = require('./$.to-integer')
|
||
|
|
, defined = require('./$.defined');
|
||
|
|
module.exports = function(TO_STRING){
|
||
|
|
return function(that, pos){
|
||
|
|
var s = String(defined(that))
|
||
|
|
, i = toInteger(pos)
|
||
|
|
, l = s.length
|
||
|
|
, a, b;
|
||
|
|
if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
|
||
|
|
a = s.charCodeAt(i);
|
||
|
|
return a < 0xd800 || a > 0xdbff || i + 1 === l
|
||
|
|
|| (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
||
|
|
? TO_STRING ? s.charAt(i) : a
|
||
|
|
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
},{"./$.defined":13,"./$.to-integer":42}],40:[function(require,module,exports){
|
||
|
|
// Thank's IE8 for his funny defineProperty
|
||
|
|
module.exports = !require('./$.fails')(function(){
|
||
|
|
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
|
||
|
|
});
|
||
|
|
},{"./$.fails":15}],41:[function(require,module,exports){
|
||
|
|
var has = require('./$.has')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, TAG = require('./$.wks')('toStringTag');
|
||
|
|
|
||
|
|
module.exports = function(it, tag, stat){
|
||
|
|
if(it && !has(it = stat ? it : it.prototype, TAG))hide(it, TAG, tag);
|
||
|
|
};
|
||
|
|
},{"./$.has":19,"./$.hide":20,"./$.wks":47}],42:[function(require,module,exports){
|
||
|
|
// 7.1.4 ToInteger
|
||
|
|
var ceil = Math.ceil
|
||
|
|
, floor = Math.floor;
|
||
|
|
module.exports = function(it){
|
||
|
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
||
|
|
};
|
||
|
|
},{}],43:[function(require,module,exports){
|
||
|
|
// to indexed object, toObject with fallback for non-array-like ES3 strings
|
||
|
|
var IObject = require('./$.iobject')
|
||
|
|
, defined = require('./$.defined');
|
||
|
|
module.exports = function(it){
|
||
|
|
return IObject(defined(it));
|
||
|
|
};
|
||
|
|
},{"./$.defined":13,"./$.iobject":21}],44:[function(require,module,exports){
|
||
|
|
// 7.1.15 ToLength
|
||
|
|
var toInteger = require('./$.to-integer')
|
||
|
|
, min = Math.min;
|
||
|
|
module.exports = function(it){
|
||
|
|
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
|
||
|
|
};
|
||
|
|
},{"./$.to-integer":42}],45:[function(require,module,exports){
|
||
|
|
var id = 0
|
||
|
|
, px = Math.random();
|
||
|
|
module.exports = function(key){
|
||
|
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
||
|
|
};
|
||
|
|
},{}],46:[function(require,module,exports){
|
||
|
|
// 22.1.3.31 Array.prototype[@@unscopables]
|
||
|
|
var UNSCOPABLES = require('./$.wks')('unscopables');
|
||
|
|
if(!(UNSCOPABLES in []))require('./$.hide')(Array.prototype, UNSCOPABLES, {});
|
||
|
|
module.exports = function(key){
|
||
|
|
[][UNSCOPABLES][key] = true;
|
||
|
|
};
|
||
|
|
},{"./$.hide":20,"./$.wks":47}],47:[function(require,module,exports){
|
||
|
|
var store = require('./$.shared')('wks')
|
||
|
|
, Symbol = require('./$.global').Symbol;
|
||
|
|
module.exports = function(name){
|
||
|
|
return store[name] || (store[name] =
|
||
|
|
Symbol && Symbol[name] || (Symbol || require('./$.uid'))('Symbol.' + name));
|
||
|
|
};
|
||
|
|
},{"./$.global":18,"./$.shared":36,"./$.uid":45}],48:[function(require,module,exports){
|
||
|
|
var classof = require('./$.classof')
|
||
|
|
, ITERATOR = require('./$.wks')('iterator')
|
||
|
|
, Iterators = require('./$.iterators');
|
||
|
|
module.exports = require('./$.core').getIteratorMethod = function(it){
|
||
|
|
if(it != undefined)return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
|
||
|
|
};
|
||
|
|
},{"./$.classof":6,"./$.core":10,"./$.iterators":29,"./$.wks":47}],49:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var setUnscope = require('./$.unscope')
|
||
|
|
, step = require('./$.iter-step')
|
||
|
|
, Iterators = require('./$.iterators')
|
||
|
|
, toIObject = require('./$.to-iobject');
|
||
|
|
|
||
|
|
// 22.1.3.4 Array.prototype.entries()
|
||
|
|
// 22.1.3.13 Array.prototype.keys()
|
||
|
|
// 22.1.3.29 Array.prototype.values()
|
||
|
|
// 22.1.3.30 Array.prototype[@@iterator]()
|
||
|
|
require('./$.iter-define')(Array, 'Array', function(iterated, kind){
|
||
|
|
this._t = toIObject(iterated); // target
|
||
|
|
this._i = 0; // next index
|
||
|
|
this._k = kind; // kind
|
||
|
|
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
|
||
|
|
}, function(){
|
||
|
|
var O = this._t
|
||
|
|
, kind = this._k
|
||
|
|
, index = this._i++;
|
||
|
|
if(!O || index >= O.length){
|
||
|
|
this._t = undefined;
|
||
|
|
return step(1);
|
||
|
|
}
|
||
|
|
if(kind == 'keys' )return step(0, index);
|
||
|
|
if(kind == 'values')return step(0, O[index]);
|
||
|
|
return step(0, [index, O[index]]);
|
||
|
|
}, 'values');
|
||
|
|
|
||
|
|
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
|
||
|
|
Iterators.Arguments = Iterators.Array;
|
||
|
|
|
||
|
|
setUnscope('keys');
|
||
|
|
setUnscope('values');
|
||
|
|
setUnscope('entries');
|
||
|
|
},{"./$.iter-define":26,"./$.iter-step":28,"./$.iterators":29,"./$.to-iobject":43,"./$.unscope":46}],50:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var strong = require('./$.collection-strong');
|
||
|
|
|
||
|
|
// 23.1 Map Objects
|
||
|
|
require('./$.collection')('Map', function(get){
|
||
|
|
return function Map(){ return get(this, arguments[0]); };
|
||
|
|
}, {
|
||
|
|
// 23.1.3.6 Map.prototype.get(key)
|
||
|
|
get: function get(key){
|
||
|
|
var entry = strong.getEntry(this, key);
|
||
|
|
return entry && entry.v;
|
||
|
|
},
|
||
|
|
// 23.1.3.9 Map.prototype.set(key, value)
|
||
|
|
set: function set(key, value){
|
||
|
|
return strong.def(this, key === 0 ? 0 : key, value);
|
||
|
|
}
|
||
|
|
}, strong, true);
|
||
|
|
},{"./$.collection":9,"./$.collection-strong":8}],51:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
// 19.1.3.6 Object.prototype.toString()
|
||
|
|
var classof = require('./$.classof')
|
||
|
|
, test = {};
|
||
|
|
test[require('./$.wks')('toStringTag')] = 'z';
|
||
|
|
if(test + '' != '[object z]'){
|
||
|
|
require('./$.redef')(Object.prototype, 'toString', function toString(){
|
||
|
|
return '[object ' + classof(this) + ']';
|
||
|
|
}, true);
|
||
|
|
}
|
||
|
|
},{"./$.classof":6,"./$.redef":35,"./$.wks":47}],52:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var strong = require('./$.collection-strong');
|
||
|
|
|
||
|
|
// 23.2 Set Objects
|
||
|
|
require('./$.collection')('Set', function(get){
|
||
|
|
return function Set(){ return get(this, arguments[0]); };
|
||
|
|
}, {
|
||
|
|
// 23.2.3.1 Set.prototype.add(value)
|
||
|
|
add: function add(value){
|
||
|
|
return strong.def(this, value = value === 0 ? 0 : value, value);
|
||
|
|
}
|
||
|
|
}, strong);
|
||
|
|
},{"./$.collection":9,"./$.collection-strong":8}],53:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
var $at = require('./$.string-at')(true);
|
||
|
|
|
||
|
|
// 21.1.3.27 String.prototype[@@iterator]()
|
||
|
|
require('./$.iter-define')(String, 'String', function(iterated){
|
||
|
|
this._t = String(iterated); // target
|
||
|
|
this._i = 0; // next index
|
||
|
|
// 21.1.5.2.1 %StringIteratorPrototype%.next()
|
||
|
|
}, function(){
|
||
|
|
var O = this._t
|
||
|
|
, index = this._i
|
||
|
|
, point;
|
||
|
|
if(index >= O.length)return {value: undefined, done: true};
|
||
|
|
point = $at(O, index);
|
||
|
|
this._i += point.length;
|
||
|
|
return {value: point, done: false};
|
||
|
|
});
|
||
|
|
},{"./$.iter-define":26,"./$.string-at":39}],54:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
// ECMAScript 6 symbols shim
|
||
|
|
var $ = require('./$')
|
||
|
|
, global = require('./$.global')
|
||
|
|
, has = require('./$.has')
|
||
|
|
, SUPPORT_DESC = require('./$.support-desc')
|
||
|
|
, $def = require('./$.def')
|
||
|
|
, $redef = require('./$.redef')
|
||
|
|
, shared = require('./$.shared')
|
||
|
|
, setTag = require('./$.tag')
|
||
|
|
, uid = require('./$.uid')
|
||
|
|
, wks = require('./$.wks')
|
||
|
|
, keyOf = require('./$.keyof')
|
||
|
|
, $names = require('./$.get-names')
|
||
|
|
, enumKeys = require('./$.enum-keys')
|
||
|
|
, isObject = require('./$.is-object')
|
||
|
|
, anObject = require('./$.an-object')
|
||
|
|
, toIObject = require('./$.to-iobject')
|
||
|
|
, createDesc = require('./$.property-desc')
|
||
|
|
, getDesc = $.getDesc
|
||
|
|
, setDesc = $.setDesc
|
||
|
|
, _create = $.create
|
||
|
|
, getNames = $names.get
|
||
|
|
, $Symbol = global.Symbol
|
||
|
|
, setter = false
|
||
|
|
, HIDDEN = wks('_hidden')
|
||
|
|
, isEnum = $.isEnum
|
||
|
|
, SymbolRegistry = shared('symbol-registry')
|
||
|
|
, AllSymbols = shared('symbols')
|
||
|
|
, useNative = typeof $Symbol == 'function'
|
||
|
|
, ObjectProto = Object.prototype;
|
||
|
|
|
||
|
|
var setSymbolDesc = SUPPORT_DESC ? function(){ // fallback for old Android
|
||
|
|
try {
|
||
|
|
return _create(setDesc({}, HIDDEN, {
|
||
|
|
get: function(){
|
||
|
|
return setDesc(this, HIDDEN, {value: false})[HIDDEN];
|
||
|
|
}
|
||
|
|
}))[HIDDEN] || setDesc;
|
||
|
|
} catch(e){
|
||
|
|
return function(it, key, D){
|
||
|
|
var protoDesc = getDesc(ObjectProto, key);
|
||
|
|
if(protoDesc)delete ObjectProto[key];
|
||
|
|
setDesc(it, key, D);
|
||
|
|
if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}() : setDesc;
|
||
|
|
|
||
|
|
var wrap = function(tag){
|
||
|
|
var sym = AllSymbols[tag] = _create($Symbol.prototype);
|
||
|
|
sym._k = tag;
|
||
|
|
SUPPORT_DESC && setter && setSymbolDesc(ObjectProto, tag, {
|
||
|
|
configurable: true,
|
||
|
|
set: function(value){
|
||
|
|
if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
|
||
|
|
setSymbolDesc(this, tag, createDesc(1, value));
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return sym;
|
||
|
|
};
|
||
|
|
|
||
|
|
var $defineProperty = function defineProperty(it, key, D){
|
||
|
|
if(D && has(AllSymbols, key)){
|
||
|
|
if(!D.enumerable){
|
||
|
|
if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {}));
|
||
|
|
it[HIDDEN][key] = true;
|
||
|
|
} else {
|
||
|
|
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
|
||
|
|
D = _create(D, {enumerable: createDesc(0, false)});
|
||
|
|
} return setSymbolDesc(it, key, D);
|
||
|
|
} return setDesc(it, key, D);
|
||
|
|
};
|
||
|
|
var $defineProperties = function defineProperties(it, P){
|
||
|
|
anObject(it);
|
||
|
|
var keys = enumKeys(P = toIObject(P))
|
||
|
|
, i = 0
|
||
|
|
, l = keys.length
|
||
|
|
, key;
|
||
|
|
while(l > i)$defineProperty(it, key = keys[i++], P[key]);
|
||
|
|
return it;
|
||
|
|
};
|
||
|
|
var $create = function create(it, P){
|
||
|
|
return P === undefined ? _create(it) : $defineProperties(_create(it), P);
|
||
|
|
};
|
||
|
|
var $propertyIsEnumerable = function propertyIsEnumerable(key){
|
||
|
|
var E = isEnum.call(this, key);
|
||
|
|
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key]
|
||
|
|
? E : true;
|
||
|
|
};
|
||
|
|
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
|
||
|
|
var D = getDesc(it = toIObject(it), key);
|
||
|
|
if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
|
||
|
|
return D;
|
||
|
|
};
|
||
|
|
var $getOwnPropertyNames = function getOwnPropertyNames(it){
|
||
|
|
var names = getNames(toIObject(it))
|
||
|
|
, result = []
|
||
|
|
, i = 0
|
||
|
|
, key;
|
||
|
|
while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key);
|
||
|
|
return result;
|
||
|
|
};
|
||
|
|
var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
|
||
|
|
var names = getNames(toIObject(it))
|
||
|
|
, result = []
|
||
|
|
, i = 0
|
||
|
|
, key;
|
||
|
|
while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);
|
||
|
|
return result;
|
||
|
|
};
|
||
|
|
|
||
|
|
// 19.4.1.1 Symbol([description])
|
||
|
|
if(!useNative){
|
||
|
|
$Symbol = function Symbol(){
|
||
|
|
if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor');
|
||
|
|
return wrap(uid(arguments[0]));
|
||
|
|
};
|
||
|
|
$redef($Symbol.prototype, 'toString', function toString(){
|
||
|
|
return this._k;
|
||
|
|
});
|
||
|
|
|
||
|
|
$.create = $create;
|
||
|
|
$.isEnum = $propertyIsEnumerable;
|
||
|
|
$.getDesc = $getOwnPropertyDescriptor;
|
||
|
|
$.setDesc = $defineProperty;
|
||
|
|
$.setDescs = $defineProperties;
|
||
|
|
$.getNames = $names.get = $getOwnPropertyNames;
|
||
|
|
$.getSymbols = $getOwnPropertySymbols;
|
||
|
|
|
||
|
|
if(SUPPORT_DESC && !require('./$.library')){
|
||
|
|
$redef(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// MS Edge converts symbol values to JSON as {}
|
||
|
|
// WebKit converts symbol values in objects to JSON as null
|
||
|
|
if(!useNative || require('./$.fails')(function(){
|
||
|
|
return JSON.stringify([{a: $Symbol()}, [$Symbol()]]) != '[{},[null]]';
|
||
|
|
}))$redef($Symbol.prototype, 'toJSON', function toJSON(){
|
||
|
|
if(useNative && isObject(this))return this;
|
||
|
|
});
|
||
|
|
|
||
|
|
var symbolStatics = {
|
||
|
|
// 19.4.2.1 Symbol.for(key)
|
||
|
|
'for': function(key){
|
||
|
|
return has(SymbolRegistry, key += '')
|
||
|
|
? SymbolRegistry[key]
|
||
|
|
: SymbolRegistry[key] = $Symbol(key);
|
||
|
|
},
|
||
|
|
// 19.4.2.5 Symbol.keyFor(sym)
|
||
|
|
keyFor: function keyFor(key){
|
||
|
|
return keyOf(SymbolRegistry, key);
|
||
|
|
},
|
||
|
|
useSetter: function(){ setter = true; },
|
||
|
|
useSimple: function(){ setter = false; }
|
||
|
|
};
|
||
|
|
// 19.4.2.2 Symbol.hasInstance
|
||
|
|
// 19.4.2.3 Symbol.isConcatSpreadable
|
||
|
|
// 19.4.2.4 Symbol.iterator
|
||
|
|
// 19.4.2.6 Symbol.match
|
||
|
|
// 19.4.2.8 Symbol.replace
|
||
|
|
// 19.4.2.9 Symbol.search
|
||
|
|
// 19.4.2.10 Symbol.species
|
||
|
|
// 19.4.2.11 Symbol.split
|
||
|
|
// 19.4.2.12 Symbol.toPrimitive
|
||
|
|
// 19.4.2.13 Symbol.toStringTag
|
||
|
|
// 19.4.2.14 Symbol.unscopables
|
||
|
|
$.each.call((
|
||
|
|
'hasInstance,isConcatSpreadable,iterator,match,replace,search,' +
|
||
|
|
'species,split,toPrimitive,toStringTag,unscopables'
|
||
|
|
).split(','), function(it){
|
||
|
|
var sym = wks(it);
|
||
|
|
symbolStatics[it] = useNative ? sym : wrap(sym);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
setter = true;
|
||
|
|
|
||
|
|
$def($def.G + $def.W, {Symbol: $Symbol});
|
||
|
|
|
||
|
|
$def($def.S, 'Symbol', symbolStatics);
|
||
|
|
|
||
|
|
$def($def.S + $def.F * !useNative, 'Object', {
|
||
|
|
// 19.1.2.2 Object.create(O [, Properties])
|
||
|
|
create: $create,
|
||
|
|
// 19.1.2.4 Object.defineProperty(O, P, Attributes)
|
||
|
|
defineProperty: $defineProperty,
|
||
|
|
// 19.1.2.3 Object.defineProperties(O, Properties)
|
||
|
|
defineProperties: $defineProperties,
|
||
|
|
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
|
||
|
|
getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
|
||
|
|
// 19.1.2.7 Object.getOwnPropertyNames(O)
|
||
|
|
getOwnPropertyNames: $getOwnPropertyNames,
|
||
|
|
// 19.1.2.8 Object.getOwnPropertySymbols(O)
|
||
|
|
getOwnPropertySymbols: $getOwnPropertySymbols
|
||
|
|
});
|
||
|
|
|
||
|
|
// 19.4.3.5 Symbol.prototype[@@toStringTag]
|
||
|
|
setTag($Symbol, 'Symbol');
|
||
|
|
// 20.2.1.9 Math[@@toStringTag]
|
||
|
|
setTag(Math, 'Math', true);
|
||
|
|
// 24.3.3 JSON[@@toStringTag]
|
||
|
|
setTag(global.JSON, 'JSON', true);
|
||
|
|
},{"./$":30,"./$.an-object":5,"./$.def":12,"./$.enum-keys":14,"./$.fails":15,"./$.get-names":17,"./$.global":18,"./$.has":19,"./$.is-object":23,"./$.keyof":31,"./$.library":32,"./$.property-desc":34,"./$.redef":35,"./$.shared":36,"./$.support-desc":40,"./$.tag":41,"./$.to-iobject":43,"./$.uid":45,"./$.wks":47}],55:[function(require,module,exports){
|
||
|
|
require('./es6.array.iterator');
|
||
|
|
var global = require('./$.global')
|
||
|
|
, hide = require('./$.hide')
|
||
|
|
, Iterators = require('./$.iterators')
|
||
|
|
, ITERATOR = require('./$.wks')('iterator')
|
||
|
|
, NL = global.NodeList
|
||
|
|
, HTC = global.HTMLCollection
|
||
|
|
, NLProto = NL && NL.prototype
|
||
|
|
, HTCProto = HTC && HTC.prototype
|
||
|
|
, ArrayValues = Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array;
|
||
|
|
if(NL && !(ITERATOR in NLProto))hide(NLProto, ITERATOR, ArrayValues);
|
||
|
|
if(HTC && !(ITERATOR in HTCProto))hide(HTCProto, ITERATOR, ArrayValues);
|
||
|
|
},{"./$.global":18,"./$.hide":20,"./$.iterators":29,"./$.wks":47,"./es6.array.iterator":49}],56:[function(require,module,exports){
|
||
|
|
// shim for using process in browser
|
||
|
|
|
||
|
|
var process = module.exports = {};
|
||
|
|
var queue = [];
|
||
|
|
var draining = false;
|
||
|
|
var currentQueue;
|
||
|
|
var queueIndex = -1;
|
||
|
|
|
||
|
|
function cleanUpNextTick() {
|
||
|
|
draining = false;
|
||
|
|
if (currentQueue.length) {
|
||
|
|
queue = currentQueue.concat(queue);
|
||
|
|
} else {
|
||
|
|
queueIndex = -1;
|
||
|
|
}
|
||
|
|
if (queue.length) {
|
||
|
|
drainQueue();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function drainQueue() {
|
||
|
|
if (draining) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var timeout = setTimeout(cleanUpNextTick);
|
||
|
|
draining = true;
|
||
|
|
|
||
|
|
var len = queue.length;
|
||
|
|
while(len) {
|
||
|
|
currentQueue = queue;
|
||
|
|
queue = [];
|
||
|
|
while (++queueIndex < len) {
|
||
|
|
if (currentQueue) {
|
||
|
|
currentQueue[queueIndex].run();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
queueIndex = -1;
|
||
|
|
len = queue.length;
|
||
|
|
}
|
||
|
|
currentQueue = null;
|
||
|
|
draining = false;
|
||
|
|
clearTimeout(timeout);
|
||
|
|
}
|
||
|
|
|
||
|
|
process.nextTick = function (fun) {
|
||
|
|
var args = new Array(arguments.length - 1);
|
||
|
|
if (arguments.length > 1) {
|
||
|
|
for (var i = 1; i < arguments.length; i++) {
|
||
|
|
args[i - 1] = arguments[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
queue.push(new Item(fun, args));
|
||
|
|
if (queue.length === 1 && !draining) {
|
||
|
|
setTimeout(drainQueue, 0);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
// v8 likes predictible objects
|
||
|
|
function Item(fun, array) {
|
||
|
|
this.fun = fun;
|
||
|
|
this.array = array;
|
||
|
|
}
|
||
|
|
Item.prototype.run = function () {
|
||
|
|
this.fun.apply(null, this.array);
|
||
|
|
};
|
||
|
|
process.title = 'browser';
|
||
|
|
process.browser = true;
|
||
|
|
process.env = {};
|
||
|
|
process.argv = [];
|
||
|
|
process.version = ''; // empty string to avoid regexp issues
|
||
|
|
process.versions = {};
|
||
|
|
|
||
|
|
function noop() {}
|
||
|
|
|
||
|
|
process.on = noop;
|
||
|
|
process.addListener = noop;
|
||
|
|
process.once = noop;
|
||
|
|
process.off = noop;
|
||
|
|
process.removeListener = noop;
|
||
|
|
process.removeAllListeners = noop;
|
||
|
|
process.emit = noop;
|
||
|
|
|
||
|
|
process.binding = function (name) {
|
||
|
|
throw new Error('process.binding is not supported');
|
||
|
|
};
|
||
|
|
|
||
|
|
process.cwd = function () { return '/' };
|
||
|
|
process.chdir = function (dir) {
|
||
|
|
throw new Error('process.chdir is not supported');
|
||
|
|
};
|
||
|
|
process.umask = function() { return 0; };
|
||
|
|
|
||
|
|
},{}],57:[function(require,module,exports){
|
||
|
|
/*
|
||
|
|
Creates instances of the Jazz plugin if necessary. Initially the MIDIAccess creates one main Jazz instance that is used
|
||
|
|
to query all initially connected devices, and to track the devices that are being connected or disconnected at runtime.
|
||
|
|
|
||
|
|
For every MIDIInput and MIDIOutput that is created, MIDIAccess queries the getJazzInstance() method for a Jazz instance
|
||
|
|
that still have an available input or output. Because Jazz only allows one input and one output per instance, we
|
||
|
|
need to create new instances if more than one MIDI input or output device gets connected.
|
||
|
|
|
||
|
|
Note that an existing Jazz instance doesn't get deleted when both its input and output device are disconnected; instead it
|
||
|
|
will be reused if a new device gets connected.
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
/*
|
||
|
|
The require statements are only needed for Internet Explorer. They have to be put here;
|
||
|
|
if you put them at the top entry point (shim.js) it doesn't work (weird quirck in IE?).
|
||
|
|
|
||
|
|
Note that you can remove the require statements if you don't need (or want) to support Internet Explorer:
|
||
|
|
that will shrink the filesize of the WebMIDIAPIShim to about 50%.
|
||
|
|
|
||
|
|
If you are building for Nodejs platform you can comment these lines, then run the buildscript like so:
|
||
|
|
'npm run build-nodejs' -> the build file (approx. 15K) will be saved in the web-midi-api folder
|
||
|
|
*/
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
exports.createJazzInstance = createJazzInstance;
|
||
|
|
exports.getJazzInstance = getJazzInstance;
|
||
|
|
|
||
|
|
var _util = require('./util');
|
||
|
|
|
||
|
|
require('babelify/node_modules/babel-core/node_modules/core-js/es6/map');
|
||
|
|
require('babelify/node_modules/babel-core/node_modules/core-js/es6/set');
|
||
|
|
require('babelify/node_modules/babel-core/node_modules/core-js/es6/symbol');
|
||
|
|
|
||
|
|
var jazzPluginInitTime = 100; // milliseconds
|
||
|
|
|
||
|
|
var jazzInstanceNumber = 0;
|
||
|
|
var jazzInstances = new Map();
|
||
|
|
|
||
|
|
function createJazzInstance(callback) {
|
||
|
|
|
||
|
|
var id = 'jazz_' + jazzInstanceNumber++ + '' + Date.now();
|
||
|
|
var instance = undefined;
|
||
|
|
var objRef = undefined,
|
||
|
|
activeX = undefined;
|
||
|
|
|
||
|
|
if ((0, _util.getDevice)().nodejs === true) {
|
||
|
|
objRef = new jazzMidi.MIDI();
|
||
|
|
} else {
|
||
|
|
var o1 = document.createElement('object');
|
||
|
|
o1.id = id + 'ie';
|
||
|
|
o1.classid = 'CLSID:1ACE1618-1C7D-4561-AEE1-34842AA85E90';
|
||
|
|
activeX = o1;
|
||
|
|
|
||
|
|
var o2 = document.createElement('object');
|
||
|
|
o2.id = id;
|
||
|
|
o2.type = 'audio/x-jazz';
|
||
|
|
o1.appendChild(o2);
|
||
|
|
objRef = o2;
|
||
|
|
|
||
|
|
var e = document.createElement('p');
|
||
|
|
e.appendChild(document.createTextNode('This page requires the '));
|
||
|
|
|
||
|
|
var a = document.createElement('a');
|
||
|
|
a.appendChild(document.createTextNode('Jazz plugin'));
|
||
|
|
a.href = 'http://jazz-soft.net/';
|
||
|
|
|
||
|
|
e.appendChild(a);
|
||
|
|
e.appendChild(document.createTextNode('.'));
|
||
|
|
o2.appendChild(e);
|
||
|
|
|
||
|
|
var insertionPoint = document.getElementById('MIDIPlugin');
|
||
|
|
if (!insertionPoint) {
|
||
|
|
// Create hidden element
|
||
|
|
insertionPoint = document.createElement('div');
|
||
|
|
insertionPoint.id = 'MIDIPlugin';
|
||
|
|
insertionPoint.style.position = 'absolute';
|
||
|
|
insertionPoint.style.visibility = 'hidden';
|
||
|
|
insertionPoint.style.left = '-9999px';
|
||
|
|
insertionPoint.style.top = '-9999px';
|
||
|
|
document.body.appendChild(insertionPoint);
|
||
|
|
}
|
||
|
|
insertionPoint.appendChild(o1);
|
||
|
|
}
|
||
|
|
|
||
|
|
setTimeout(function () {
|
||
|
|
if (objRef.isJazz === true) {
|
||
|
|
instance = objRef;
|
||
|
|
} else if (activeX.isJazz === true) {
|
||
|
|
instance = activeX;
|
||
|
|
}
|
||
|
|
if (instance !== undefined) {
|
||
|
|
instance._perfTimeZero = performance.now();
|
||
|
|
jazzInstances.set(id, instance);
|
||
|
|
}
|
||
|
|
callback(instance);
|
||
|
|
}, jazzPluginInitTime);
|
||
|
|
}
|
||
|
|
|
||
|
|
function getJazzInstance(type, callback) {
|
||
|
|
var instance = null;
|
||
|
|
var key = type === 'input' ? 'inputInUse' : 'outputInUse';
|
||
|
|
|
||
|
|
var _iteratorNormalCompletion = true;
|
||
|
|
var _didIteratorError = false;
|
||
|
|
var _iteratorError = undefined;
|
||
|
|
|
||
|
|
try {
|
||
|
|
for (var _iterator = jazzInstances.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||
|
|
var inst = _step.value;
|
||
|
|
|
||
|
|
if (inst[key] !== true) {
|
||
|
|
instance = inst;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} catch (err) {
|
||
|
|
_didIteratorError = true;
|
||
|
|
_iteratorError = err;
|
||
|
|
} finally {
|
||
|
|
try {
|
||
|
|
if (!_iteratorNormalCompletion && _iterator['return']) {
|
||
|
|
_iterator['return']();
|
||
|
|
}
|
||
|
|
} finally {
|
||
|
|
if (_didIteratorError) {
|
||
|
|
throw _iteratorError;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (instance === null) {
|
||
|
|
createJazzInstance(callback);
|
||
|
|
} else {
|
||
|
|
callback(instance);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
},{"./util":64,"babelify/node_modules/babel-core/node_modules/core-js/es6/map":1,"babelify/node_modules/babel-core/node_modules/core-js/es6/set":2,"babelify/node_modules/babel-core/node_modules/core-js/es6/symbol":3}],58:[function(require,module,exports){
|
||
|
|
/*
|
||
|
|
Creates a MIDIAccess instance:
|
||
|
|
- Creates MIDIInput and MIDIOutput instances for the initially connected MIDI devices.
|
||
|
|
- Keeps track of newly connected devices and creates the necessary instances of MIDIInput and MIDIOutput.
|
||
|
|
- Keeps track of disconnected devices and removes them from the inputs and/or outputs map.
|
||
|
|
- Creates a unique id for every device and stores these ids by the name of the device:
|
||
|
|
so when a device gets disconnected and reconnected again, it will still have the same id. This
|
||
|
|
is in line with the behaviour of the native MIDIAccess object.
|
||
|
|
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
|
||
|
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||
|
|
|
||
|
|
exports.createMIDIAccess = createMIDIAccess;
|
||
|
|
exports.dispatchEvent = dispatchEvent;
|
||
|
|
exports.closeAllMIDIInputs = closeAllMIDIInputs;
|
||
|
|
exports.getMIDIDeviceId = getMIDIDeviceId;
|
||
|
|
|
||
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
|
||
|
|
var _jazz_instance = require('./jazz_instance');
|
||
|
|
|
||
|
|
var _midi_input = require('./midi_input');
|
||
|
|
|
||
|
|
var _midi_output = require('./midi_output');
|
||
|
|
|
||
|
|
var _midiconnection_event = require('./midiconnection_event');
|
||
|
|
|
||
|
|
var _util = require('./util');
|
||
|
|
|
||
|
|
var midiAccess = undefined;
|
||
|
|
var jazzInstance = undefined;
|
||
|
|
var midiInputs = new Map();
|
||
|
|
var midiOutputs = new Map();
|
||
|
|
var midiInputIds = new Map();
|
||
|
|
var midiOutputIds = new Map();
|
||
|
|
var listeners = new Set();
|
||
|
|
|
||
|
|
var MIDIAccess = (function () {
|
||
|
|
function MIDIAccess(midiInputs, midiOutputs) {
|
||
|
|
_classCallCheck(this, MIDIAccess);
|
||
|
|
|
||
|
|
this.sysexEnabled = true;
|
||
|
|
this.inputs = midiInputs;
|
||
|
|
this.outputs = midiOutputs;
|
||
|
|
}
|
||
|
|
|
||
|
|
_createClass(MIDIAccess, [{
|
||
|
|
key: 'addEventListener',
|
||
|
|
value: function addEventListener(type, listener, useCapture) {
|
||
|
|
if (type !== 'statechange') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (listeners.has(listener) === false) {
|
||
|
|
listeners.add(listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'removeEventListener',
|
||
|
|
value: function removeEventListener(type, listener, useCapture) {
|
||
|
|
if (type !== 'statechange') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (listeners.has(listener) === true) {
|
||
|
|
listeners['delete'](listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}]);
|
||
|
|
|
||
|
|
return MIDIAccess;
|
||
|
|
})();
|
||
|
|
|
||
|
|
function createMIDIAccess() {
|
||
|
|
|
||
|
|
return new Promise(function executor(resolve, reject) {
|
||
|
|
|
||
|
|
if (midiAccess !== undefined) {
|
||
|
|
resolve(midiAccess);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ((0, _util.getDevice)().browser === 'ie9') {
|
||
|
|
reject({ message: 'WebMIDIAPIShim supports Internet Explorer 10 and above.' });
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
(0, _jazz_instance.createJazzInstance)(function (instance) {
|
||
|
|
if (instance === undefined) {
|
||
|
|
reject({ message: 'No access to MIDI devices: browser does not support the WebMIDI API and the Jazz plugin is not installed.' });
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
jazzInstance = instance;
|
||
|
|
|
||
|
|
createMIDIPorts(function () {
|
||
|
|
setupListeners();
|
||
|
|
midiAccess = new MIDIAccess(midiInputs, midiOutputs);
|
||
|
|
resolve(midiAccess);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// create MIDIInput and MIDIOutput instances for all initially connected MIDI devices
|
||
|
|
function createMIDIPorts(callback) {
|
||
|
|
var inputs = jazzInstance.MidiInList();
|
||
|
|
var outputs = jazzInstance.MidiOutList();
|
||
|
|
var numInputs = inputs.length;
|
||
|
|
var numOutputs = outputs.length;
|
||
|
|
|
||
|
|
loopCreateMIDIPort(0, numInputs, 'input', inputs, function () {
|
||
|
|
loopCreateMIDIPort(0, numOutputs, 'output', outputs, callback);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function loopCreateMIDIPort(index, max, type, list, callback) {
|
||
|
|
if (index < max) {
|
||
|
|
var _name = list[index++];
|
||
|
|
createMIDIPort(type, _name, function () {
|
||
|
|
loopCreateMIDIPort(index, max, type, list, callback);
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
callback();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function createMIDIPort(type, name, callback) {
|
||
|
|
(0, _jazz_instance.getJazzInstance)(type, function (instance) {
|
||
|
|
var port = undefined;
|
||
|
|
var info = [name, '', ''];
|
||
|
|
if (type === 'input') {
|
||
|
|
if (instance.Support('MidiInInfo')) {
|
||
|
|
info = instance.MidiInInfo(name);
|
||
|
|
}
|
||
|
|
port = new _midi_input.MIDIInput(info, instance);
|
||
|
|
midiInputs.set(port.id, port);
|
||
|
|
} else if (type === 'output') {
|
||
|
|
if (instance.Support('MidiOutInfo')) {
|
||
|
|
info = instance.MidiOutInfo(name);
|
||
|
|
}
|
||
|
|
port = new _midi_output.MIDIOutput(info, instance);
|
||
|
|
midiOutputs.set(port.id, port);
|
||
|
|
}
|
||
|
|
callback(port);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// lookup function: Jazz gives us the name of the connected/disconnected MIDI devices but we have stored them by id
|
||
|
|
function getPortByName(ports, name) {
|
||
|
|
var port = undefined;
|
||
|
|
var _iteratorNormalCompletion = true;
|
||
|
|
var _didIteratorError = false;
|
||
|
|
var _iteratorError = undefined;
|
||
|
|
|
||
|
|
try {
|
||
|
|
for (var _iterator = ports.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||
|
|
port = _step.value;
|
||
|
|
|
||
|
|
if (port.name === name) {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} catch (err) {
|
||
|
|
_didIteratorError = true;
|
||
|
|
_iteratorError = err;
|
||
|
|
} finally {
|
||
|
|
try {
|
||
|
|
if (!_iteratorNormalCompletion && _iterator['return']) {
|
||
|
|
_iterator['return']();
|
||
|
|
}
|
||
|
|
} finally {
|
||
|
|
if (_didIteratorError) {
|
||
|
|
throw _iteratorError;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return port;
|
||
|
|
}
|
||
|
|
|
||
|
|
// keep track of connected/disconnected MIDI devices
|
||
|
|
function setupListeners() {
|
||
|
|
jazzInstance.OnDisconnectMidiIn(function (name) {
|
||
|
|
var port = getPortByName(midiInputs, name);
|
||
|
|
if (port !== undefined) {
|
||
|
|
port.state = 'disconnected';
|
||
|
|
port.close();
|
||
|
|
port._jazzInstance.inputInUse = false;
|
||
|
|
midiInputs['delete'](port.id);
|
||
|
|
dispatchEvent(port);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
jazzInstance.OnDisconnectMidiOut(function (name) {
|
||
|
|
var port = getPortByName(midiOutputs, name);
|
||
|
|
if (port !== undefined) {
|
||
|
|
port.state = 'disconnected';
|
||
|
|
port.close();
|
||
|
|
port._jazzInstance.outputInUse = false;
|
||
|
|
midiOutputs['delete'](port.id);
|
||
|
|
dispatchEvent(port);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
jazzInstance.OnConnectMidiIn(function (name) {
|
||
|
|
createMIDIPort('input', name, function (port) {
|
||
|
|
dispatchEvent(port);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
jazzInstance.OnConnectMidiOut(function (name) {
|
||
|
|
createMIDIPort('output', name, function (port) {
|
||
|
|
dispatchEvent(port);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// when a device gets connected/disconnected both the port and MIDIAccess dispatch a MIDIConnectionEvent
|
||
|
|
// therefor we call the ports dispatchEvent function here as well
|
||
|
|
|
||
|
|
function dispatchEvent(port) {
|
||
|
|
port.dispatchEvent(new _midiconnection_event.MIDIConnectionEvent(port, port));
|
||
|
|
|
||
|
|
var evt = new _midiconnection_event.MIDIConnectionEvent(midiAccess, port);
|
||
|
|
|
||
|
|
if (typeof midiAccess.onstatechange === 'function') {
|
||
|
|
midiAccess.onstatechange(evt);
|
||
|
|
}
|
||
|
|
var _iteratorNormalCompletion2 = true;
|
||
|
|
var _didIteratorError2 = false;
|
||
|
|
var _iteratorError2 = undefined;
|
||
|
|
|
||
|
|
try {
|
||
|
|
for (var _iterator2 = listeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||
|
|
var listener = _step2.value;
|
||
|
|
|
||
|
|
listener(evt);
|
||
|
|
}
|
||
|
|
} catch (err) {
|
||
|
|
_didIteratorError2 = true;
|
||
|
|
_iteratorError2 = err;
|
||
|
|
} finally {
|
||
|
|
try {
|
||
|
|
if (!_iteratorNormalCompletion2 && _iterator2['return']) {
|
||
|
|
_iterator2['return']();
|
||
|
|
}
|
||
|
|
} finally {
|
||
|
|
if (_didIteratorError2) {
|
||
|
|
throw _iteratorError2;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function closeAllMIDIInputs() {
|
||
|
|
midiInputs.forEach(function (input) {
|
||
|
|
//input.close();
|
||
|
|
input._jazzInstance.MidiInClose();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// check if we have already created a unique id for this device, if so: reuse it, if not: create a new id and store it
|
||
|
|
|
||
|
|
function getMIDIDeviceId(name, type) {
|
||
|
|
var id = undefined;
|
||
|
|
if (type === 'input') {
|
||
|
|
id = midiInputIds.get(name);
|
||
|
|
if (id === undefined) {
|
||
|
|
id = (0, _util.generateUUID)();
|
||
|
|
midiInputIds.set(name, id);
|
||
|
|
}
|
||
|
|
} else if (type === 'output') {
|
||
|
|
id = midiOutputIds.get(name);
|
||
|
|
if (id === undefined) {
|
||
|
|
id = (0, _util.generateUUID)();
|
||
|
|
midiOutputIds.set(name, id);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return id;
|
||
|
|
}
|
||
|
|
|
||
|
|
},{"./jazz_instance":57,"./midi_input":59,"./midi_output":60,"./midiconnection_event":61,"./util":64}],59:[function(require,module,exports){
|
||
|
|
/*
|
||
|
|
MIDIInput is a wrapper around an input of a Jazz instance
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
|
||
|
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||
|
|
|
||
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
|
||
|
|
var _util = require('./util');
|
||
|
|
|
||
|
|
var _midimessage_event = require('./midimessage_event');
|
||
|
|
|
||
|
|
var _midiconnection_event = require('./midiconnection_event');
|
||
|
|
|
||
|
|
var _midi_access = require('./midi_access');
|
||
|
|
|
||
|
|
var midiProc = undefined;
|
||
|
|
var nodejs = (0, _util.getDevice)().nodejs;
|
||
|
|
|
||
|
|
var MIDIInput = (function () {
|
||
|
|
function MIDIInput(info, instance) {
|
||
|
|
_classCallCheck(this, MIDIInput);
|
||
|
|
|
||
|
|
this.id = (0, _midi_access.getMIDIDeviceId)(info[0], 'input');
|
||
|
|
this.name = info[0];
|
||
|
|
this.manufacturer = info[1];
|
||
|
|
this.version = info[2];
|
||
|
|
this.type = 'input';
|
||
|
|
this.state = 'connected';
|
||
|
|
this.connection = 'pending';
|
||
|
|
|
||
|
|
this.onstatechange = null;
|
||
|
|
this._onmidimessage = null;
|
||
|
|
// because we need to implicitly open the device when an onmidimessage handler gets added
|
||
|
|
// we define a setter that opens the device if the set value is a function
|
||
|
|
Object.defineProperty(this, 'onmidimessage', {
|
||
|
|
set: function set(value) {
|
||
|
|
this._onmidimessage = value;
|
||
|
|
if (typeof value === 'function') {
|
||
|
|
this.open();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
this._listeners = new Map().set('midimessage', new Set()).set('statechange', new Set());
|
||
|
|
this._inLongSysexMessage = false;
|
||
|
|
this._sysexBuffer = new Uint8Array();
|
||
|
|
|
||
|
|
this._jazzInstance = instance;
|
||
|
|
this._jazzInstance.inputInUse = true;
|
||
|
|
|
||
|
|
// on Linux opening and closing Jazz instances causes the plugin to crash a lot so we open
|
||
|
|
// the device here and don't close it when close() is called, see below
|
||
|
|
if ((0, _util.getDevice)().platform === 'linux') {
|
||
|
|
this._jazzInstance.MidiInOpen(this.name, midiProc.bind(this));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
_createClass(MIDIInput, [{
|
||
|
|
key: 'addEventListener',
|
||
|
|
value: function addEventListener(type, listener, useCapture) {
|
||
|
|
var listeners = this._listeners.get(type);
|
||
|
|
if (listeners === undefined) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (listeners.has(listener) === false) {
|
||
|
|
listeners.add(listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'removeEventListener',
|
||
|
|
value: function removeEventListener(type, listener, useCapture) {
|
||
|
|
var listeners = this._listeners.get(type);
|
||
|
|
if (listeners === undefined) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (listeners.has(listener) === false) {
|
||
|
|
listeners['delete'](listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'dispatchEvent',
|
||
|
|
value: function dispatchEvent(evt) {
|
||
|
|
var listeners = this._listeners.get(evt.type);
|
||
|
|
listeners.forEach(function (listener) {
|
||
|
|
listener(evt);
|
||
|
|
});
|
||
|
|
|
||
|
|
if (evt.type === 'midimessage') {
|
||
|
|
if (this._onmidimessage !== null) {
|
||
|
|
this._onmidimessage(evt);
|
||
|
|
}
|
||
|
|
} else if (evt.type === 'statechange') {
|
||
|
|
if (this.onstatechange !== null) {
|
||
|
|
this.onstatechange(evt);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'open',
|
||
|
|
value: function open() {
|
||
|
|
if (this.connection === 'open') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ((0, _util.getDevice)().platform !== 'linux') {
|
||
|
|
this._jazzInstance.MidiInOpen(this.name, midiProc.bind(this));
|
||
|
|
}
|
||
|
|
this.connection = 'open';
|
||
|
|
(0, _midi_access.dispatchEvent)(this); // dispatch MIDIConnectionEvent via MIDIAccess
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'close',
|
||
|
|
value: function close() {
|
||
|
|
if (this.connection === 'closed') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ((0, _util.getDevice)().platform !== 'linux') {
|
||
|
|
this._jazzInstance.MidiInClose();
|
||
|
|
}
|
||
|
|
this.connection = 'closed';
|
||
|
|
(0, _midi_access.dispatchEvent)(this); // dispatch MIDIConnectionEvent via MIDIAccess
|
||
|
|
this._onmidimessage = null;
|
||
|
|
this.onstatechange = null;
|
||
|
|
this._listeners.get('midimessage').clear();
|
||
|
|
this._listeners.get('statechange').clear();
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: '_appendToSysexBuffer',
|
||
|
|
value: function _appendToSysexBuffer(data) {
|
||
|
|
var oldLength = this._sysexBuffer.length;
|
||
|
|
var tmpBuffer = new Uint8Array(oldLength + data.length);
|
||
|
|
tmpBuffer.set(this._sysexBuffer);
|
||
|
|
tmpBuffer.set(data, oldLength);
|
||
|
|
this._sysexBuffer = tmpBuffer;
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: '_bufferLongSysex',
|
||
|
|
value: function _bufferLongSysex(data, initialOffset) {
|
||
|
|
var j = initialOffset;
|
||
|
|
while (j < data.length) {
|
||
|
|
if (data[j] == 0xF7) {
|
||
|
|
// end of sysex!
|
||
|
|
j++;
|
||
|
|
this._appendToSysexBuffer(data.slice(initialOffset, j));
|
||
|
|
return j;
|
||
|
|
}
|
||
|
|
j++;
|
||
|
|
}
|
||
|
|
// didn't reach the end; just tack it on.
|
||
|
|
this._appendToSysexBuffer(data.slice(initialOffset, j));
|
||
|
|
this._inLongSysexMessage = true;
|
||
|
|
return j;
|
||
|
|
}
|
||
|
|
}]);
|
||
|
|
|
||
|
|
return MIDIInput;
|
||
|
|
})();
|
||
|
|
|
||
|
|
exports.MIDIInput = MIDIInput;
|
||
|
|
|
||
|
|
midiProc = function (timestamp, data) {
|
||
|
|
var length = 0;
|
||
|
|
var i = undefined;
|
||
|
|
var isSysexMessage = false;
|
||
|
|
|
||
|
|
// Jazz sometimes passes us multiple messages at once, so we need to parse them out and pass them one at a time.
|
||
|
|
|
||
|
|
for (i = 0; i < data.length; i += length) {
|
||
|
|
var isValidMessage = true;
|
||
|
|
if (this._inLongSysexMessage) {
|
||
|
|
i = this._bufferLongSysex(data, i);
|
||
|
|
if (data[i - 1] != 0xf7) {
|
||
|
|
// ran off the end without hitting the end of the sysex message
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
isSysexMessage = true;
|
||
|
|
} else {
|
||
|
|
isSysexMessage = false;
|
||
|
|
switch (data[i] & 0xF0) {
|
||
|
|
case 0x00:
|
||
|
|
// Chew up spurious 0x00 bytes. Fixes a Windows problem.
|
||
|
|
length = 1;
|
||
|
|
isValidMessage = false;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 0x80: // note off
|
||
|
|
case 0x90: // note on
|
||
|
|
case 0xA0: // polyphonic aftertouch
|
||
|
|
case 0xB0: // control change
|
||
|
|
case 0xE0:
|
||
|
|
// channel mode
|
||
|
|
length = 3;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 0xC0: // program change
|
||
|
|
case 0xD0:
|
||
|
|
// channel aftertouch
|
||
|
|
length = 2;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 0xF0:
|
||
|
|
switch (data[i]) {
|
||
|
|
case 0xf0:
|
||
|
|
// letiable-length sysex.
|
||
|
|
i = this._bufferLongSysex(data, i);
|
||
|
|
if (data[i - 1] != 0xf7) {
|
||
|
|
// ran off the end without hitting the end of the sysex message
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
isSysexMessage = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 0xF1: // MTC quarter frame
|
||
|
|
case 0xF3:
|
||
|
|
// song select
|
||
|
|
length = 2;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 0xF2:
|
||
|
|
// song position pointer
|
||
|
|
length = 3;
|
||
|
|
break;
|
||
|
|
|
||
|
|
default:
|
||
|
|
length = 1;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!isValidMessage) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
var evt = {};
|
||
|
|
evt.receivedTime = parseFloat(timestamp.toString()) + this._jazzInstance._perfTimeZero;
|
||
|
|
|
||
|
|
if (isSysexMessage || this._inLongSysexMessage) {
|
||
|
|
evt.data = new Uint8Array(this._sysexBuffer);
|
||
|
|
this._sysexBuffer = new Uint8Array(0);
|
||
|
|
this._inLongSysexMessage = false;
|
||
|
|
} else {
|
||
|
|
evt.data = new Uint8Array(data.slice(i, length + i));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (nodejs) {
|
||
|
|
if (this._onmidimessage) {
|
||
|
|
this._onmidimessage(evt);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
var e = new _midimessage_event.MIDIMessageEvent(this, evt.data, evt.receivedTime);
|
||
|
|
this.dispatchEvent(e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
},{"./midi_access":58,"./midiconnection_event":61,"./midimessage_event":62,"./util":64}],60:[function(require,module,exports){
|
||
|
|
/*
|
||
|
|
MIDIOutput is a wrapper around an output of a Jazz instance
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
|
||
|
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||
|
|
|
||
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
|
||
|
|
var _util = require('./util');
|
||
|
|
|
||
|
|
var _midi_access = require('./midi_access');
|
||
|
|
|
||
|
|
var MIDIOutput = (function () {
|
||
|
|
function MIDIOutput(info, instance) {
|
||
|
|
_classCallCheck(this, MIDIOutput);
|
||
|
|
|
||
|
|
this.id = (0, _midi_access.getMIDIDeviceId)(info[0], 'output');
|
||
|
|
this.name = info[0];
|
||
|
|
this.manufacturer = info[1];
|
||
|
|
this.version = info[2];
|
||
|
|
this.type = 'output';
|
||
|
|
this.state = 'connected';
|
||
|
|
this.connection = 'pending';
|
||
|
|
this.onmidimessage = null;
|
||
|
|
this.onstatechange = null;
|
||
|
|
|
||
|
|
this._listeners = new Set();
|
||
|
|
this._inLongSysexMessage = false;
|
||
|
|
this._sysexBuffer = new Uint8Array();
|
||
|
|
|
||
|
|
this._jazzInstance = instance;
|
||
|
|
this._jazzInstance.outputInUse = true;
|
||
|
|
if ((0, _util.getDevice)().platform === 'linux') {
|
||
|
|
this._jazzInstance.MidiOutOpen(this.name);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
_createClass(MIDIOutput, [{
|
||
|
|
key: 'open',
|
||
|
|
value: function open() {
|
||
|
|
if (this.connection === 'open') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ((0, _util.getDevice)().platform !== 'linux') {
|
||
|
|
this._jazzInstance.MidiOutOpen(this.name);
|
||
|
|
}
|
||
|
|
this.connection = 'open';
|
||
|
|
(0, _midi_access.dispatchEvent)(this); // dispatch MIDIConnectionEvent via MIDIAccess
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'close',
|
||
|
|
value: function close() {
|
||
|
|
if (this.connection === 'closed') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if ((0, _util.getDevice)().platform !== 'linux') {
|
||
|
|
this._jazzInstance.MidiOutClose();
|
||
|
|
}
|
||
|
|
this.connection = 'closed';
|
||
|
|
(0, _midi_access.dispatchEvent)(this); // dispatch MIDIConnectionEvent via MIDIAccess
|
||
|
|
this.onstatechange = null;
|
||
|
|
this._listeners.clear();
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'send',
|
||
|
|
value: function send(data, timestamp) {
|
||
|
|
var _this = this;
|
||
|
|
|
||
|
|
var delayBeforeSend = 0;
|
||
|
|
|
||
|
|
if (data.length === 0) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (timestamp) {
|
||
|
|
delayBeforeSend = Math.floor(timestamp - performance.now());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (timestamp && delayBeforeSend > 1) {
|
||
|
|
setTimeout(function () {
|
||
|
|
_this._jazzInstance.MidiOutLong(data);
|
||
|
|
}, delayBeforeSend);
|
||
|
|
} else {
|
||
|
|
this._jazzInstance.MidiOutLong(data);
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'clear',
|
||
|
|
value: function clear() {
|
||
|
|
// to be implemented
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'addEventListener',
|
||
|
|
value: function addEventListener(type, listener, useCapture) {
|
||
|
|
if (type !== 'statechange') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this._listeners.has(listener) === false) {
|
||
|
|
this._listeners.add(listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'removeEventListener',
|
||
|
|
value: function removeEventListener(type, listener, useCapture) {
|
||
|
|
if (type !== 'statechange') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (this._listeners.has(listener) === false) {
|
||
|
|
this._listeners['delete'](listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}, {
|
||
|
|
key: 'dispatchEvent',
|
||
|
|
value: function dispatchEvent(evt) {
|
||
|
|
this._listeners.forEach(function (listener) {
|
||
|
|
listener(evt);
|
||
|
|
});
|
||
|
|
|
||
|
|
if (this.onstatechange !== null) {
|
||
|
|
this.onstatechange(evt);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}]);
|
||
|
|
|
||
|
|
return MIDIOutput;
|
||
|
|
})();
|
||
|
|
|
||
|
|
exports.MIDIOutput = MIDIOutput;
|
||
|
|
|
||
|
|
},{"./midi_access":58,"./util":64}],61:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
|
||
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
|
||
|
|
var MIDIConnectionEvent = function MIDIConnectionEvent(midiAccess, port) {
|
||
|
|
_classCallCheck(this, MIDIConnectionEvent);
|
||
|
|
|
||
|
|
this.bubbles = false;
|
||
|
|
this.cancelBubble = false;
|
||
|
|
this.cancelable = false;
|
||
|
|
this.currentTarget = midiAccess;
|
||
|
|
this.defaultPrevented = false;
|
||
|
|
this.eventPhase = 0;
|
||
|
|
this.path = [];
|
||
|
|
this.port = port;
|
||
|
|
this.returnValue = true;
|
||
|
|
this.srcElement = midiAccess;
|
||
|
|
this.target = midiAccess;
|
||
|
|
this.timeStamp = Date.now();
|
||
|
|
this.type = 'statechange';
|
||
|
|
};
|
||
|
|
|
||
|
|
exports.MIDIConnectionEvent = MIDIConnectionEvent;
|
||
|
|
|
||
|
|
},{}],62:[function(require,module,exports){
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
|
||
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
|
||
|
|
var MIDIMessageEvent = function MIDIMessageEvent(port, data, receivedTime) {
|
||
|
|
_classCallCheck(this, MIDIMessageEvent);
|
||
|
|
|
||
|
|
this.bubbles = false;
|
||
|
|
this.cancelBubble = false;
|
||
|
|
this.cancelable = false;
|
||
|
|
this.currentTarget = port;
|
||
|
|
this.data = data;
|
||
|
|
this.defaultPrevented = false;
|
||
|
|
this.eventPhase = 0;
|
||
|
|
this.path = [];
|
||
|
|
this.receivedTime = receivedTime;
|
||
|
|
this.returnValue = true;
|
||
|
|
this.srcElement = port;
|
||
|
|
this.target = port;
|
||
|
|
this.timeStamp = Date.now();
|
||
|
|
this.type = 'midimessage';
|
||
|
|
};
|
||
|
|
|
||
|
|
exports.MIDIMessageEvent = MIDIMessageEvent;
|
||
|
|
|
||
|
|
},{}],63:[function(require,module,exports){
|
||
|
|
/*
|
||
|
|
Top entry point
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
var _midi_access = require('./midi_access');
|
||
|
|
|
||
|
|
var _util = require('./util');
|
||
|
|
|
||
|
|
var midiAccess = undefined;
|
||
|
|
|
||
|
|
(function () {
|
||
|
|
if (!navigator.requestMIDIAccess) {
|
||
|
|
(0, _util.polyfill)();
|
||
|
|
navigator.requestMIDIAccess = function () {
|
||
|
|
// singleton-ish, no need to create multiple instances of MIDIAccess
|
||
|
|
if (midiAccess === undefined) {
|
||
|
|
midiAccess = (0, _midi_access.createMIDIAccess)();
|
||
|
|
}
|
||
|
|
return midiAccess;
|
||
|
|
};
|
||
|
|
if ((0, _util.getDevice)().nodejs === true) {
|
||
|
|
navigator.close = function () {
|
||
|
|
// Need to close MIDI input ports, otherwise Node.js will wait for MIDI input forever.
|
||
|
|
(0, _midi_access.closeAllMIDIInputs)();
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})();
|
||
|
|
|
||
|
|
},{"./midi_access":58,"./util":64}],64:[function(require,module,exports){
|
||
|
|
(function (process,global){
|
||
|
|
/*
|
||
|
|
A collection of handy util methods
|
||
|
|
*/
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
Object.defineProperty(exports, '__esModule', {
|
||
|
|
value: true
|
||
|
|
});
|
||
|
|
exports.getDevice = getDevice;
|
||
|
|
exports.polyfillPerformance = polyfillPerformance;
|
||
|
|
exports.generateUUID = generateUUID;
|
||
|
|
exports.polyfillPromise = polyfillPromise;
|
||
|
|
exports.polyfill = polyfill;
|
||
|
|
var device = undefined;
|
||
|
|
|
||
|
|
// check on what type of device we are running, note that in this context a device is a computer not a MIDI device
|
||
|
|
|
||
|
|
function getDevice() {
|
||
|
|
|
||
|
|
if (device !== undefined) {
|
||
|
|
return device;
|
||
|
|
}
|
||
|
|
|
||
|
|
var platform = 'undetected',
|
||
|
|
browser = 'undetected',
|
||
|
|
nodejs = false;
|
||
|
|
|
||
|
|
if (navigator.nodejs) {
|
||
|
|
platform = process.platform;
|
||
|
|
device = {
|
||
|
|
platform: platform,
|
||
|
|
nodejs: true,
|
||
|
|
mobile: platform === 'ios' || platform === 'android'
|
||
|
|
};
|
||
|
|
return device;
|
||
|
|
}
|
||
|
|
|
||
|
|
var ua = navigator.userAgent;
|
||
|
|
|
||
|
|
if (ua.match(/(iPad|iPhone|iPod)/g)) {
|
||
|
|
platform = 'ios';
|
||
|
|
} else if (ua.indexOf('Android') !== -1) {
|
||
|
|
platform = 'android';
|
||
|
|
} else if (ua.indexOf('Linux') !== -1) {
|
||
|
|
platform = 'linux';
|
||
|
|
} else if (ua.indexOf('Macintosh') !== -1) {
|
||
|
|
platform = 'osx';
|
||
|
|
} else if (ua.indexOf('Windows') !== -1) {
|
||
|
|
platform = 'windows';
|
||
|
|
}
|
||
|
|
|
||
|
|
if (ua.indexOf('Chrome') !== -1) {
|
||
|
|
// chrome, chromium and canary
|
||
|
|
browser = 'chrome';
|
||
|
|
|
||
|
|
if (ua.indexOf('OPR') !== -1) {
|
||
|
|
browser = 'opera';
|
||
|
|
} else if (ua.indexOf('Chromium') !== -1) {
|
||
|
|
browser = 'chromium';
|
||
|
|
}
|
||
|
|
} else if (ua.indexOf('Safari') !== -1) {
|
||
|
|
browser = 'safari';
|
||
|
|
} else if (ua.indexOf('Firefox') !== -1) {
|
||
|
|
browser = 'firefox';
|
||
|
|
} else if (ua.indexOf('Trident') !== -1) {
|
||
|
|
browser = 'ie';
|
||
|
|
if (ua.indexOf('MSIE 9') !== -1) {
|
||
|
|
browser = 'ie9';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (platform === 'ios') {
|
||
|
|
if (ua.indexOf('CriOS') !== -1) {
|
||
|
|
browser = 'chrome';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
device = {
|
||
|
|
platform: platform,
|
||
|
|
browser: browser,
|
||
|
|
mobile: platform === 'ios' || platform === 'android',
|
||
|
|
nodejs: false
|
||
|
|
};
|
||
|
|
return device;
|
||
|
|
}
|
||
|
|
|
||
|
|
function polyfillPerformance() {
|
||
|
|
if (performance === undefined) {
|
||
|
|
performance = {};
|
||
|
|
}
|
||
|
|
Date.now = Date.now || function () {
|
||
|
|
return new Date().getTime();
|
||
|
|
};
|
||
|
|
|
||
|
|
if (performance.now === undefined) {
|
||
|
|
(function () {
|
||
|
|
var nowOffset = Date.now();
|
||
|
|
if (performance.timing !== undefined && performance.timing.navigationStart !== undefined) {
|
||
|
|
nowOffset = performance.timing.navigationStart;
|
||
|
|
}
|
||
|
|
performance.now = function now() {
|
||
|
|
return Date.now() - nowOffset;
|
||
|
|
};
|
||
|
|
})();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function generateUUID() {
|
||
|
|
var d = new Date().getTime();
|
||
|
|
var uuid = new Array(64).join('x');; //'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
||
|
|
uuid = uuid.replace(/[xy]/g, function (c) {
|
||
|
|
var r = (d + Math.random() * 16) % 16 | 0;
|
||
|
|
d = Math.floor(d / 16);
|
||
|
|
return (c == 'x' ? r : r & 0x3 | 0x8).toString(16).toUpperCase();
|
||
|
|
});
|
||
|
|
return uuid;
|
||
|
|
}
|
||
|
|
|
||
|
|
// a very simple implementation of a Promise for Internet Explorer and Nodejs
|
||
|
|
|
||
|
|
function polyfillPromise(scope) {
|
||
|
|
if (typeof scope.Promise !== 'function') {
|
||
|
|
|
||
|
|
scope.Promise = function (executor) {
|
||
|
|
this.executor = executor;
|
||
|
|
};
|
||
|
|
|
||
|
|
scope.Promise.prototype.then = function (accept, reject) {
|
||
|
|
if (typeof accept !== 'function') {
|
||
|
|
accept = function () {};
|
||
|
|
}
|
||
|
|
if (typeof reject !== 'function') {
|
||
|
|
reject = function () {};
|
||
|
|
}
|
||
|
|
this.executor(accept, reject);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function polyfill() {
|
||
|
|
var device = getDevice();
|
||
|
|
if (device.browser === 'ie') {
|
||
|
|
polyfillPromise(window);
|
||
|
|
} else if (device.nodejs === true) {
|
||
|
|
polyfillPromise(global);
|
||
|
|
}
|
||
|
|
polyfillPerformance();
|
||
|
|
}
|
||
|
|
|
||
|
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
|
|
|
||
|
|
},{"_process":56}]},{},[63])
|
||
|
|
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvZXM2L21hcC5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9lczYvc2V0LmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL2VzNi9zeW1ib2wuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmEtZnVuY3Rpb24uanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmFuLW9iamVjdC5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuY2xhc3NvZi5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuY29mLmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5jb2xsZWN0aW9uLXN0cm9uZy5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuY29sbGVjdGlvbi5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuY29yZS5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuY3R4LmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5kZWYuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmRlZmluZWQuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmVudW0ta2V5cy5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuZmFpbHMuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmZvci1vZi5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuZ2V0LW5hbWVzLmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5nbG9iYWwuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmhhcy5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaGlkZS5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaW9iamVjdC5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaXMtYXJyYXktaXRlci5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaXMtb2JqZWN0LmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5pdGVyLWNhbGwuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLml0ZXItY3JlYXRlLmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5pdGVyLWRlZmluZS5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaXRlci1kZXRlY3QuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLml0ZXItc3RlcC5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQuaXRlcmF0b3JzLmpzIiwibm9kZV9tb2R1bGVzL2JhYmVsaWZ5L25vZGVfbW9kdWxlcy9iYWJlbC1jb3JlL25vZGVfbW9kdWxlcy9jb3JlLWpzL21vZHVsZXMvJC5qcyIsIm5vZGVfbW9kdWxlcy9iYWJlbGlmeS9ub2RlX21vZHVsZXMvYmFiZWwtY29yZS9ub2RlX21vZHVsZXMvY29yZS1qcy9tb2R1bGVzLyQua2V5b2YuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9kdWxlcy8kLmxpYnJhcnkuanMiLCJub2RlX21vZHVsZXMvYmFiZWxpZnkvbm9kZV9tb2R1bGVzL2JhYmVsLWNvcmUvbm9kZV9tb2R1bGVzL2NvcmUtanMvbW9
|