Created
September 22, 2016 16:52
-
-
Save matthewmueller/bca6d225cd15c95a61939c77f1bb8648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | |
typeof define === 'function' && define.amd ? define(factory) : | |
(global.vcom = factory()); | |
}(this, (function () { | |
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | |
function createCommonjsModule(fn, module) { | |
return module = { exports: {} }, fn(module, module.exports), module.exports; | |
} | |
var index$4 = function (obj) { | |
return Object.prototype.toString.call(obj) === '[object Object]'; | |
}; | |
/* eslint-disable no-unused-vars */ | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var propIsEnumerable = Object.prototype.propertyIsEnumerable; | |
function toObject(val) { | |
if (val === null || val === undefined) { | |
throw new TypeError('Object.assign cannot be called with null or undefined'); | |
} | |
return Object(val); | |
} | |
function shouldUseNative() { | |
try { | |
if (!Object.assign) { | |
return false; | |
} | |
// Detect buggy property enumeration order in older V8 versions. | |
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 | |
var test1 = new String('abc'); // eslint-disable-line | |
test1[5] = 'de'; | |
if (Object.getOwnPropertyNames(test1)[0] === '5') { | |
return false; | |
} | |
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | |
var test2 = {}; | |
for (var i = 0; i < 10; i++) { | |
test2['_' + String.fromCharCode(i)] = i; | |
} | |
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { | |
return test2[n]; | |
}); | |
if (order2.join('') !== '0123456789') { | |
return false; | |
} | |
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | |
var test3 = {}; | |
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { | |
test3[letter] = letter; | |
}); | |
if (Object.keys(Object.assign({}, test3)).join('') !== | |
'abcdefghijklmnopqrst') { | |
return false; | |
} | |
return true; | |
} catch (e) { | |
// We don't expect any of the above to throw, but better to be safe. | |
return false; | |
} | |
} | |
var index$6 = shouldUseNative() ? Object.assign : function (target, source) { | |
var arguments$1 = arguments; | |
var from; | |
var to = toObject(target); | |
var symbols; | |
for (var s = 1; s < arguments.length; s++) { | |
from = Object(arguments$1[s]); | |
for (var key in from) { | |
if (hasOwnProperty.call(from, key)) { | |
to[key] = from[key]; | |
} | |
} | |
if (Object.getOwnPropertySymbols) { | |
symbols = Object.getOwnPropertySymbols(from); | |
for (var i = 0; i < symbols.length; i++) { | |
if (propIsEnumerable.call(from, symbols[i])) { | |
to[symbols[i]] = from[symbols[i]]; | |
} | |
} | |
} | |
} | |
return to; | |
}; | |
/** | |
* Export `freeze` | |
*/ | |
var freeze_1 = freeze$2 | |
/** | |
* Are we running in a production build? | |
*/ | |
var production = process && process.env && process.env.NODE_ENV === 'production' | |
/** | |
* Is Freezable? | |
* | |
* @param {Object} object | |
* @return {Boolean} | |
*/ | |
function isFreezable (object) { | |
if (object === null) { return false } | |
return Array.isArray(object) || | |
typeof object === 'object' | |
} | |
/** | |
* Check if we need to freeze this value | |
* | |
* @param {Object} object | |
* @return {Boolean} | |
*/ | |
function needsFreezing (object) { | |
return isFreezable(object) && !Object.isFrozen(object) | |
} | |
/** | |
* Recurse | |
* | |
* @param {Object} | |
* @return {Object} | |
*/ | |
function recur (object) { | |
Object.freeze(object) | |
Object.keys(object).forEach(function (key) { | |
var value = object[key] | |
if (needsFreezing(value)) { | |
recur(value) | |
} | |
}) | |
return object | |
} | |
/** | |
* Deeply freeze a plain javascript object. | |
* | |
* If `process.env.NODE_ENV === 'production'`, this returns the original object | |
* witout freezing. | |
* | |
* @function | |
* @sig a -> a | |
* @param {object} object Object to freeze. | |
* @return {object} Frozen object, unless in production, then the same object. | |
*/ | |
function freeze$2 (object) { | |
if (production) { return object } | |
if (needsFreezing(object)) { | |
recur(object) | |
} | |
return object | |
} | |
/** | |
* An Array.prototype.slice.call(arguments) alternative | |
* | |
* @param {Object} args something with a length | |
* @param {Number} slice | |
* @param {Number} sliceEnd | |
* @api public | |
*/ | |
var index$8 = function (args, slice, sliceEnd) { | |
var ret = []; | |
var len = args.length; | |
if (0 === len) { return ret; } | |
var start = slice < 0 | |
? Math.max(0, slice + len) | |
: slice || 0; | |
if (sliceEnd !== undefined) { | |
len = sliceEnd < 0 | |
? sliceEnd + len | |
: sliceEnd | |
} | |
while (len-- > start) { | |
ret[len - start] = args[len]; | |
} | |
return ret; | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var isPlainObject = index$4 | |
var assign = index$6 | |
var freeze$1 = freeze_1 | |
var sliced$1 = index$8 | |
var isArray$1 = Array.isArray | |
var keys = Object.keys | |
/** | |
* Export `update` | |
*/ | |
var update_1 = update$1 | |
/** | |
* Update the object or array | |
* | |
* @param {Mixed} original | |
* @param {Mixed, ...} updates | |
* @return {Mixed} | |
*/ | |
function update$1 (original, update) { | |
update = sliced$1(arguments, 2).reduce(function (o, n) { return resolve$1(o, n, true) }, update) | |
return freeze$1(resolve$1(original, update)) | |
} | |
/** | |
* Resolve the updates | |
* | |
* @param {Mixed} original | |
* @param {Array} updates | |
*/ | |
function resolve$1 (original, updates, keepNull) { | |
return isPlainObject(original) && isPlainObject(updates) | |
? object(original, updates, keepNull) | |
: isArray$1(original) && isArray$1(updates) | |
? array(original, updates) | |
: updates === undefined ? original : updates | |
} | |
/** | |
* Update objects | |
* | |
* @param {Object} original | |
* @param {Array} updates | |
* @return {Array} | |
*/ | |
function object (original, updates, keepNull) { | |
return keys(updates).reduce(function (obj, key, i) { | |
if (!keepNull && updates[key] === null) { | |
delete obj[key] | |
} else { | |
obj[key] = resolve$1(original[key], updates[key]) | |
} | |
return obj | |
}, assign({}, original)) | |
} | |
/** | |
* Update arrays | |
* | |
* @param {Array} original | |
* @param {Array} updates | |
* @return {Array} | |
*/ | |
function array (original, updates) { | |
return [].concat(updates) | |
} | |
/** | |
* Modules | |
*/ | |
/** | |
* Expose isFunction | |
*/ | |
var index$20 = isFunction$1['default'] = isFunction$1 | |
/** | |
* isFunction | |
*/ | |
function isFunction$1 (value) { | |
return typeof value === 'function' | |
} | |
/** | |
* Modules | |
*/ | |
var isFunction = index$20 | |
/** | |
* Expose isObject | |
*/ | |
var index$18 = isObject$1 | |
/** | |
* Constants | |
*/ | |
var objString = toString(Object) | |
/** | |
* Check for plain object. | |
* | |
* @param {Mixed} val | |
* @return {Boolean} | |
* @api private | |
*/ | |
function isObject$1 (val) { | |
return !!val && (val.constructor === Object || isObjectString(val.constructor)) | |
} | |
function isObjectString (val) { | |
return !!val && isFunction(val) && toString(val) === objString | |
} | |
function toString (val) { | |
return Function.prototype.toString.call(val) | |
} | |
/** | |
* Expose isArray | |
*/ | |
var index$22 = isArray$4['default'] = isArray$4 | |
/** | |
* isArray | |
*/ | |
function isArray$4 (val) { | |
return Array.isArray(val) | |
} | |
/** | |
* Expose forEach | |
*/ | |
var index$24 = forEach$2 | |
/** | |
* forEach | |
*/ | |
function forEach$2 (fn, obj) { | |
var this$1 = this; | |
if (!obj) { return } | |
var keys = Object.keys(obj) | |
for (var i = 0, len = keys.length; i < len; ++i) { | |
var key = keys[i] | |
fn.call(this$1, obj[key], key, i) | |
} | |
} | |
/** | |
* Expose forEach | |
*/ | |
var index$26 = forEach$3['default'] = forEach$3 | |
/** | |
* forEach | |
*/ | |
function forEach$3 (fn, arr) { | |
var this$1 = this; | |
if (!arr) { return } | |
for (var i = 0, len = arr.length; i < len; ++i) { | |
fn.call(this$1, arr[i], i) | |
} | |
} | |
/** | |
* Modules | |
*/ | |
var isObject = index$18 | |
var isArray$3 = index$22 | |
var forEachObj = index$24 | |
var forEachArr = index$26 | |
/** | |
* Expose foreach | |
*/ | |
var index$16 = forEach$1['default'] = forEach$1 | |
/** | |
* For each | |
* @param {Function} fn iterator | |
* @param {Object} obj object to iterate over | |
*/ | |
function forEach$1 (fn, a) { | |
if (isArray$3(a)) { return forEachArr.call(this, fn, a) } | |
if (isObject(a)) { return forEachObj.call(this, fn, a) } | |
} | |
/** | |
* Modules | |
*/ | |
var forEach = index$16 | |
/** | |
* Expose cloneObj | |
*/ | |
var index$14 = cloneObj$1['default'] = cloneObj$1 | |
/** | |
* Clone an object. | |
* @param {Object} obj Object to Clone | |
* @return {Object} | |
*/ | |
function cloneObj$1 (obj) { | |
var newObj = {} | |
forEach(function (val, key) { | |
newObj[key] = val | |
}, obj) | |
return newObj | |
} | |
/** | |
* Expose slice | |
*/ | |
var index$28 = slice | |
/** | |
* slice | |
*/ | |
function slice (array, begin, end) { | |
begin = begin || 0 | |
end = end || array.length | |
var arr = new Array(array.length) | |
for (var i = begin; i < end; ++i) { | |
arr[i - begin] = array[i] | |
} | |
return arr | |
} | |
/** | |
* Modules | |
*/ | |
var cloneObj = index$14 | |
var cloneArray = index$28 | |
var isArray$2 = index$22 | |
/** | |
* Expose cloneShallow | |
*/ | |
var index$12 = cloneShallow | |
/** | |
* Clone object or array shallow | |
* @param {Object|Array} a object to copy | |
* @return {Object|Array} | |
*/ | |
function cloneShallow (a) { | |
return isArray$2() | |
? cloneArray(a) | |
: cloneObj(a) | |
} | |
/** | |
* Expose toArray | |
*/ | |
var index$32 = toArray$1['default'] = toArray$1 | |
/** | |
* Convert to an array from array like | |
* @param {ArrayLike} arr | |
* @return {Array} | |
*/ | |
function toArray$1 (arr) { | |
var len = arr.length | |
var idx = -1 | |
var array = new Array(len) | |
while (++idx < len) { | |
array[idx] = arr[idx] | |
} | |
return array | |
} | |
/** | |
* Modules | |
*/ | |
var toArray = index$32 | |
/** | |
* Expose composeReducers | |
*/ | |
var index$30 = composeReducers$1['default'] = composeReducers$1 | |
/** | |
* composeReducers | |
*/ | |
function composeReducers$1 (/* arguments */) { | |
var args = toArray(arguments) | |
var len = args.length | |
return function (state, action) { | |
for (var i = 0; i < len; ++i) { | |
state = args[i](state, action) | |
} | |
return state | |
} | |
} | |
/** | |
* Modules | |
*/ | |
var clone = index$12 | |
var composeReducers = index$30 | |
/** | |
* Expose combineReducers | |
*/ | |
var index$10 = combineReducers['default'] = combineReducers | |
/** | |
* combineReducers | |
*/ | |
function combineReducers (reducers, defaultState) { | |
defaultState = defaultState || {} | |
return composeReducers.apply(null, Object | |
.keys(reducers) | |
.map(function (key) { | |
return scopeReducer(reducers[key], key, defaultState) | |
})) | |
} | |
function scopeReducer (reducer, prop, defaultState) { | |
return function (state, action) { | |
if (state === undefined) { state = defaultState } | |
var childState = reducer(state[prop], action) | |
if (childState !== state[prop]) { | |
state = clone(state) | |
state[prop] = childState | |
} | |
return state | |
} | |
} | |
var _hasOwnProperty = Object.prototype.hasOwnProperty; | |
function set$1(obj, path, value) { | |
if (path.length === 0) { | |
return; | |
} | |
var res = obj; | |
var last = path[path.length - 1]; | |
if (path.length === 1) { | |
if (isObject$2(res)) { | |
return res[last] = value; | |
} | |
return; | |
} | |
for (var i = 0; i < path.length - 1; i++) { | |
var key = path[i]; | |
if (!_hasOwnProperty.call(res, key) || !isObject$2(res[key])) { | |
res[key] = {}; | |
} | |
res = res[key]; | |
} | |
return res[last] = value; | |
} | |
var set_1 = set$1; | |
function isObject$2(value) { | |
return value != null && (typeof value === 'object' || typeof value === 'function'); | |
} | |
var index$34 = { | |
set: set_1 | |
}; | |
/** | |
* Module Dependencies | |
*/ | |
var set = index$34.set | |
/** | |
* Expose `handle` | |
*/ | |
var handle_1 = handle$2 | |
/** | |
* handle | |
*/ | |
function handle$2 (map) { | |
map = map || {} | |
return function (state, action) { | |
var keys = action.type.split(/[: ]/) | |
var handler = keys.shift() | |
var rest = keys.join('.') | |
// normalized path | |
var path = rest | |
? [handler].concat(rest).join(':') | |
: handler | |
if (map[path]) { return map[path](state, action.payload, map) } | |
var obj = {} | |
if (handler === 'set') { | |
if (!keys.length) { return action.payload } | |
set(obj, keys.join('.').split('.'), action.payload) | |
return obj | |
} | |
} | |
} | |
/** | |
* Module dependencies | |
*/ | |
var combine = index$10 | |
var handle$1 = handle_1 | |
var isobj$1 = index$4 | |
/** | |
* Export `Tree` | |
*/ | |
var tree$1 = Tree | |
/** | |
* Initialize `Tree` | |
* | |
* @param {Object} map | |
* @param {Function} | |
*/ | |
function Tree (tree) { | |
var obj = walk(tree, [], {}) | |
return handle$1(obj) | |
} | |
/** | |
* Walk the object tree | |
* | |
* @param {Object} tree | |
* @param {Array} trail | |
* @return {Function} | |
*/ | |
function walk (tree, tail, out) { | |
for (var key in tree) { | |
if (!tree.hasOwnProperty(key)) { continue } | |
else if (typeof tree[key] === 'function') { | |
var path = tail.length ? key + ':' + tail.join('.') : key | |
out[path] = tail.reduceRight(function (fn, k) { | |
var o = {} | |
o[k] = fn | |
return combine(o) | |
}, tree[key]) | |
} else if (isobj$1(tree[key])) { | |
walk(tree[key], tail.concat(key), out) | |
} | |
} | |
return out | |
} | |
/** | |
* Module dependencies | |
*/ | |
var update = update_1 | |
var tree = tree$1 | |
var isobj = index$4 | |
/** | |
* Export `reducer` | |
*/ | |
var reducer_1 = reducer$1 | |
/** | |
* Initialize `reducer` | |
* | |
* @param {Function|Object} fn | |
* @return {Function} | |
*/ | |
function reducer$1 (fn) { | |
fn = isobj(fn) ? tree(fn) : fn | |
return function reduce (state, action) { | |
var updates = fn(state, action) | |
return update(state, updates) | |
} | |
} | |
/** | |
* lodash 3.1.1 (Custom Build) <https://lodash.com/> | |
* Build: `lodash modularize exports="npm" -o ./` | |
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | |
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | |
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | |
* Available under MIT license <https://lodash.com/license> | |
*/ | |
/** `Object#toString` result references. */ | |
var errorTag = '[object Error]'; | |
/** Used for built-in method references. */ | |
var objectProto = Object.prototype; | |
/** | |
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | |
* of values. | |
*/ | |
var objectToString = objectProto.toString; | |
/** | |
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, | |
* `SyntaxError`, `TypeError`, or `URIError` object. | |
* | |
* @static | |
* @memberOf _ | |
* @category Lang | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is an error object, else `false`. | |
* @example | |
* | |
* _.isError(new Error); | |
* // => true | |
* | |
* _.isError(Error); | |
* // => false | |
*/ | |
function isError$1(value) { | |
if (!isObjectLike(value)) { | |
return false; | |
} | |
return (objectToString.call(value) == errorTag) || | |
(typeof value.message == 'string' && typeof value.name == 'string'); | |
} | |
/** | |
* Checks if `value` is object-like. A value is object-like if it's not `null` | |
* and has a `typeof` result of "object". | |
* | |
* @static | |
* @memberOf _ | |
* @category Lang | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | |
* @example | |
* | |
* _.isObjectLike({}); | |
* // => true | |
* | |
* _.isObjectLike([1, 2, 3]); | |
* // => true | |
* | |
* _.isObjectLike(_.noop); | |
* // => false | |
* | |
* _.isObjectLike(null); | |
* // => false | |
*/ | |
function isObjectLike(value) { | |
return !!value && typeof value == 'object'; | |
} | |
var index$36 = isError$1; | |
/** | |
* Module Dependencies | |
*/ | |
var isError = index$36 | |
var isobj$2 = index$4 | |
var keys$1 = Object.keys | |
/** | |
* Whitelisted keys | |
*/ | |
var whitelist = { | |
type: 1, | |
meta: 1, | |
error: 1, | |
payload: 1 | |
} | |
/** | |
* Export `isFSA` | |
*/ | |
var isFsa = isFSA$1 | |
/** | |
* Check if the value is an action | |
* | |
* Spec: https://github.com/acdlite/flux-standard-action#actions | |
* | |
* @param {Mixed} value | |
* @return {Boolean} | |
*/ | |
function isFSA$1 (value) { | |
// value must be an object and have a type | |
if (!isobj$2(value) || !value.type) { return false } | |
// if any properties on the object are | |
// not part of the whitelist fail then | |
// return false | |
var props = keys$1(value) | |
for (var i = 0, prop; (prop = props[i]); i++) { | |
if (!whitelist[prop]) { return false } | |
} | |
// lastly check that if value.error is "true" | |
// that our payload is an Error object | |
if (value.error === true && !isError(value.payload)) { | |
return false | |
} | |
return true | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var isFSA = isFsa | |
/** | |
* Export `middleware` | |
*/ | |
var resolve_1 = resolve$2 | |
/** | |
* Resolve promises, arrays, objects, etc. | |
*/ | |
function resolve$2 (store) { | |
return function (next) { | |
return function (action) { | |
return typeof action === 'function' | |
? next(FSACheck(action(store.getState()))) | |
: next(action) | |
} | |
} | |
} | |
/** | |
* Ensure that what's returned | |
* is a flux standard action | |
* | |
* @param {Mixed} mixed | |
* @return {Object} | |
*/ | |
function FSACheck (mixed) { | |
if (isFSA(mixed)) { return mixed } | |
throw new Error('resolved action (' + stringify(mixed) + ') is not the correct format. Please refer to the spec: https://github.com/acdlite/flux-standard-action#actions') | |
} | |
/** | |
* Serialize our value | |
* | |
* @param {Mixed} mixed | |
* @return {String} | |
*/ | |
function stringify (mixed) { | |
try { | |
return JSON.stringify(mixed) | |
} catch (e) { | |
return mixed | |
} | |
} | |
/** | |
* Creates a unary function that invokes `func` with its argument transformed. | |
* | |
* @private | |
* @param {Function} func The function to wrap. | |
* @param {Function} transform The argument transform. | |
* @returns {Function} Returns the new function. | |
*/ | |
function overArg(func, transform) { | |
return function(arg) { | |
return func(transform(arg)); | |
}; | |
} | |
/** Built-in value references. */ | |
var getPrototype = overArg(Object.getPrototypeOf, Object); | |
/** | |
* Checks if `value` is object-like. A value is object-like if it's not `null` | |
* and has a `typeof` result of "object". | |
* | |
* @static | |
* @memberOf _ | |
* @since 4.0.0 | |
* @category Lang | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | |
* @example | |
* | |
* _.isObjectLike({}); | |
* // => true | |
* | |
* _.isObjectLike([1, 2, 3]); | |
* // => true | |
* | |
* _.isObjectLike(_.noop); | |
* // => false | |
* | |
* _.isObjectLike(null); | |
* // => false | |
*/ | |
function isObjectLike$1(value) { | |
return value != null && typeof value == 'object'; | |
} | |
/** `Object#toString` result references. */ | |
var objectTag = '[object Object]'; | |
/** Used for built-in method references. */ | |
var funcProto = Function.prototype; | |
var objectProto$1 = Object.prototype; | |
/** Used to resolve the decompiled source of functions. */ | |
var funcToString = funcProto.toString; | |
/** Used to check objects for own properties. */ | |
var hasOwnProperty$1 = objectProto$1.hasOwnProperty; | |
/** Used to infer the `Object` constructor. */ | |
var objectCtorString = funcToString.call(Object); | |
/** | |
* Used to resolve the | |
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | |
* of values. | |
*/ | |
var objectToString$1 = objectProto$1.toString; | |
/** | |
* Checks if `value` is a plain object, that is, an object created by the | |
* `Object` constructor or one with a `[[Prototype]]` of `null`. | |
* | |
* @static | |
* @memberOf _ | |
* @since 0.8.0 | |
* @category Lang | |
* @param {*} value The value to check. | |
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`. | |
* @example | |
* | |
* function Foo() { | |
* this.a = 1; | |
* } | |
* | |
* _.isPlainObject(new Foo); | |
* // => false | |
* | |
* _.isPlainObject([1, 2, 3]); | |
* // => false | |
* | |
* _.isPlainObject({ 'x': 0, 'y': 0 }); | |
* // => true | |
* | |
* _.isPlainObject(Object.create(null)); | |
* // => true | |
*/ | |
function isPlainObject$1(value) { | |
if (!isObjectLike$1(value) || objectToString$1.call(value) != objectTag) { | |
return false; | |
} | |
var proto = getPrototype(value); | |
if (proto === null) { | |
return true; | |
} | |
var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor; | |
return (typeof Ctor == 'function' && | |
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); | |
} | |
var ponyfill = createCommonjsModule(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports['default'] = symbolObservablePonyfill; | |
function symbolObservablePonyfill(root) { | |
var result; | |
var _Symbol = root.Symbol; | |
if (typeof _Symbol === 'function') { | |
if (_Symbol.observable) { | |
result = _Symbol.observable; | |
} else { | |
result = _Symbol('observable'); | |
_Symbol.observable = result; | |
} | |
} else { | |
result = '@@observable'; | |
} | |
return result; | |
} | |
}); | |
var index$40 = createCommonjsModule(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _ponyfill = ponyfill; | |
var _ponyfill2 = _interopRequireDefault(_ponyfill); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | |
var root = undefined; /* global window */ | |
if (typeof commonjsGlobal !== 'undefined') { | |
root = commonjsGlobal; | |
} else if (typeof window !== 'undefined') { | |
root = window; | |
} | |
var result = (0, _ponyfill2['default'])(root); | |
exports['default'] = result; | |
}); | |
var index$39 = index$40; | |
/** | |
* These are private action types reserved by Redux. | |
* For any unknown actions, you must return the current state. | |
* If the current state is undefined, you must return the initial state. | |
* Do not reference these action types directly in your code. | |
*/ | |
var ActionTypes = { | |
INIT: '@@redux/INIT' | |
}; | |
/** | |
* Creates a Redux store that holds the state tree. | |
* The only way to change the data in the store is to call `dispatch()` on it. | |
* | |
* There should only be a single store in your app. To specify how different | |
* parts of the state tree respond to actions, you may combine several reducers | |
* into a single reducer function by using `combineReducers`. | |
* | |
* @param {Function} reducer A function that returns the next state tree, given | |
* the current state tree and the action to handle. | |
* | |
* @param {any} [preloadedState] The initial state. You may optionally specify it | |
* to hydrate the state from the server in universal apps, or to restore a | |
* previously serialized user session. | |
* If you use `combineReducers` to produce the root reducer function, this must be | |
* an object with the same shape as `combineReducers` keys. | |
* | |
* @param {Function} enhancer The store enhancer. You may optionally specify it | |
* to enhance the store with third-party capabilities such as middleware, | |
* time travel, persistence, etc. The only store enhancer that ships with Redux | |
* is `applyMiddleware()`. | |
* | |
* @returns {Store} A Redux store that lets you read the state, dispatch actions | |
* and subscribe to changes. | |
*/ | |
function createStore(reducer, preloadedState, enhancer) { | |
var _ref2; | |
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { | |
enhancer = preloadedState; | |
preloadedState = undefined; | |
} | |
if (typeof enhancer !== 'undefined') { | |
if (typeof enhancer !== 'function') { | |
throw new Error('Expected the enhancer to be a function.'); | |
} | |
return enhancer(createStore)(reducer, preloadedState); | |
} | |
if (typeof reducer !== 'function') { | |
throw new Error('Expected the reducer to be a function.'); | |
} | |
var currentReducer = reducer; | |
var currentState = preloadedState; | |
var currentListeners = []; | |
var nextListeners = currentListeners; | |
var isDispatching = false; | |
function ensureCanMutateNextListeners() { | |
if (nextListeners === currentListeners) { | |
nextListeners = currentListeners.slice(); | |
} | |
} | |
/** | |
* Reads the state tree managed by the store. | |
* | |
* @returns {any} The current state tree of your application. | |
*/ | |
function getState() { | |
return currentState; | |
} | |
/** | |
* Adds a change listener. It will be called any time an action is dispatched, | |
* and some part of the state tree may potentially have changed. You may then | |
* call `getState()` to read the current state tree inside the callback. | |
* | |
* You may call `dispatch()` from a change listener, with the following | |
* caveats: | |
* | |
* 1. The subscriptions are snapshotted just before every `dispatch()` call. | |
* If you subscribe or unsubscribe while the listeners are being invoked, this | |
* will not have any effect on the `dispatch()` that is currently in progress. | |
* However, the next `dispatch()` call, whether nested or not, will use a more | |
* recent snapshot of the subscription list. | |
* | |
* 2. The listener should not expect to see all state changes, as the state | |
* might have been updated multiple times during a nested `dispatch()` before | |
* the listener is called. It is, however, guaranteed that all subscribers | |
* registered before the `dispatch()` started will be called with the latest | |
* state by the time it exits. | |
* | |
* @param {Function} listener A callback to be invoked on every dispatch. | |
* @returns {Function} A function to remove this change listener. | |
*/ | |
function subscribe(listener) { | |
if (typeof listener !== 'function') { | |
throw new Error('Expected listener to be a function.'); | |
} | |
var isSubscribed = true; | |
ensureCanMutateNextListeners(); | |
nextListeners.push(listener); | |
return function unsubscribe() { | |
if (!isSubscribed) { | |
return; | |
} | |
isSubscribed = false; | |
ensureCanMutateNextListeners(); | |
var index = nextListeners.indexOf(listener); | |
nextListeners.splice(index, 1); | |
}; | |
} | |
/** | |
* Dispatches an action. It is the only way to trigger a state change. | |
* | |
* The `reducer` function, used to create the store, will be called with the | |
* current state tree and the given `action`. Its return value will | |
* be considered the **next** state of the tree, and the change listeners | |
* will be notified. | |
* | |
* The base implementation only supports plain object actions. If you want to | |
* dispatch a Promise, an Observable, a thunk, or something else, you need to | |
* wrap your store creating function into the corresponding middleware. For | |
* example, see the documentation for the `redux-thunk` package. Even the | |
* middleware will eventually dispatch plain object actions using this method. | |
* | |
* @param {Object} action A plain object representing “what changed”. It is | |
* a good idea to keep actions serializable so you can record and replay user | |
* sessions, or use the time travelling `redux-devtools`. An action must have | |
* a `type` property which may not be `undefined`. It is a good idea to use | |
* string constants for action types. | |
* | |
* @returns {Object} For convenience, the same action object you dispatched. | |
* | |
* Note that, if you use a custom middleware, it may wrap `dispatch()` to | |
* return something else (for example, a Promise you can await). | |
*/ | |
function dispatch(action) { | |
if (!isPlainObject$1(action)) { | |
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); | |
} | |
if (typeof action.type === 'undefined') { | |
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); | |
} | |
if (isDispatching) { | |
throw new Error('Reducers may not dispatch actions.'); | |
} | |
try { | |
isDispatching = true; | |
currentState = currentReducer(currentState, action); | |
} finally { | |
isDispatching = false; | |
} | |
var listeners = currentListeners = nextListeners; | |
for (var i = 0; i < listeners.length; i++) { | |
listeners[i](); | |
} | |
return action; | |
} | |
/** | |
* Replaces the reducer currently used by the store to calculate the state. | |
* | |
* You might need this if your app implements code splitting and you want to | |
* load some of the reducers dynamically. You might also need this if you | |
* implement a hot reloading mechanism for Redux. | |
* | |
* @param {Function} nextReducer The reducer for the store to use instead. | |
* @returns {void} | |
*/ | |
function replaceReducer(nextReducer) { | |
if (typeof nextReducer !== 'function') { | |
throw new Error('Expected the nextReducer to be a function.'); | |
} | |
currentReducer = nextReducer; | |
dispatch({ type: ActionTypes.INIT }); | |
} | |
/** | |
* Interoperability point for observable/reactive libraries. | |
* @returns {observable} A minimal observable of state changes. | |
* For more information, see the observable proposal: | |
* https://github.com/zenparsing/es-observable | |
*/ | |
function observable() { | |
var _ref; | |
var outerSubscribe = subscribe; | |
return _ref = { | |
/** | |
* The minimal observable subscription method. | |
* @param {Object} observer Any object that can be used as an observer. | |
* The observer object should have a `next` method. | |
* @returns {subscription} An object with an `unsubscribe` method that can | |
* be used to unsubscribe the observable from the store, and prevent further | |
* emission of values from the observable. | |
*/ | |
subscribe: function subscribe(observer) { | |
if (typeof observer !== 'object') { | |
throw new TypeError('Expected the observer to be an object.'); | |
} | |
function observeState() { | |
if (observer.next) { | |
observer.next(getState()); | |
} | |
} | |
observeState(); | |
var unsubscribe = outerSubscribe(observeState); | |
return { unsubscribe: unsubscribe }; | |
} | |
}, _ref[index$39] = function () { | |
return this; | |
}, _ref; | |
} | |
// When a store is created, an "INIT" action is dispatched so that every | |
// reducer returns their initial state. This effectively populates | |
// the initial state tree. | |
dispatch({ type: ActionTypes.INIT }); | |
return _ref2 = { | |
dispatch: dispatch, | |
subscribe: subscribe, | |
getState: getState, | |
replaceReducer: replaceReducer | |
}, _ref2[index$39] = observable, _ref2; | |
} | |
/** | |
* Prints a warning in the console if it exists. | |
* | |
* @param {String} message The warning message. | |
* @returns {void} | |
*/ | |
function warning(message) { | |
/* eslint-disable no-console */ | |
if (typeof console !== 'undefined' && typeof console.error === 'function') { | |
console.error(message); | |
} | |
/* eslint-enable no-console */ | |
try { | |
// This error was thrown as a convenience so that if you enable | |
// "break on all exceptions" in your console, | |
// it would pause the execution at this line. | |
throw new Error(message); | |
/* eslint-disable no-empty */ | |
} catch (e) {} | |
/* eslint-enable no-empty */ | |
} | |
function getUndefinedStateErrorMessage(key, action) { | |
var actionType = action && action.type; | |
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action'; | |
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.'; | |
} | |
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { | |
var reducerKeys = Object.keys(reducers); | |
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; | |
if (reducerKeys.length === 0) { | |
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; | |
} | |
if (!isPlainObject$1(inputState)) { | |
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'); | |
} | |
var unexpectedKeys = Object.keys(inputState).filter(function (key) { | |
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; | |
}); | |
unexpectedKeys.forEach(function (key) { | |
unexpectedKeyCache[key] = true; | |
}); | |
if (unexpectedKeys.length > 0) { | |
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.'); | |
} | |
} | |
function assertReducerSanity(reducers) { | |
Object.keys(reducers).forEach(function (key) { | |
var reducer = reducers[key]; | |
var initialState = reducer(undefined, { type: ActionTypes.INIT }); | |
if (typeof initialState === 'undefined') { | |
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined.'); | |
} | |
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.'); | |
if (typeof reducer(undefined, { type: type }) === 'undefined') { | |
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined.'); | |
} | |
}); | |
} | |
/** | |
* Turns an object whose values are different reducer functions, into a single | |
* reducer function. It will call every child reducer, and gather their results | |
* into a single state object, whose keys correspond to the keys of the passed | |
* reducer functions. | |
* | |
* @param {Object} reducers An object whose values correspond to different | |
* reducer functions that need to be combined into one. One handy way to obtain | |
* it is to use ES6 `import * as reducers` syntax. The reducers may never return | |
* undefined for any action. Instead, they should return their initial state | |
* if the state passed to them was undefined, and the current state for any | |
* unrecognized action. | |
* | |
* @returns {Function} A reducer function that invokes every reducer inside the | |
* passed object, and builds a state object with the same shape. | |
*/ | |
function combineReducers$1(reducers) { | |
var reducerKeys = Object.keys(reducers); | |
var finalReducers = {}; | |
for (var i = 0; i < reducerKeys.length; i++) { | |
var key = reducerKeys[i]; | |
if (process.env.NODE_ENV !== 'production') { | |
if (typeof reducers[key] === 'undefined') { | |
warning('No reducer provided for key "' + key + '"'); | |
} | |
} | |
if (typeof reducers[key] === 'function') { | |
finalReducers[key] = reducers[key]; | |
} | |
} | |
var finalReducerKeys = Object.keys(finalReducers); | |
if (process.env.NODE_ENV !== 'production') { | |
var unexpectedKeyCache = {}; | |
} | |
var sanityError; | |
try { | |
assertReducerSanity(finalReducers); | |
} catch (e) { | |
sanityError = e; | |
} | |
return function combination() { | |
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | |
var action = arguments[1]; | |
if (sanityError) { | |
throw sanityError; | |
} | |
if (process.env.NODE_ENV !== 'production') { | |
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache); | |
if (warningMessage) { | |
warning(warningMessage); | |
} | |
} | |
var hasChanged = false; | |
var nextState = {}; | |
for (var i = 0; i < finalReducerKeys.length; i++) { | |
var key = finalReducerKeys[i]; | |
var reducer = finalReducers[key]; | |
var previousStateForKey = state[key]; | |
var nextStateForKey = reducer(previousStateForKey, action); | |
if (typeof nextStateForKey === 'undefined') { | |
var errorMessage = getUndefinedStateErrorMessage(key, action); | |
throw new Error(errorMessage); | |
} | |
nextState[key] = nextStateForKey; | |
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; | |
} | |
return hasChanged ? nextState : state; | |
}; | |
} | |
function bindActionCreator(actionCreator, dispatch) { | |
return function () { | |
return dispatch(actionCreator.apply(undefined, arguments)); | |
}; | |
} | |
/** | |
* Turns an object whose values are action creators, into an object with the | |
* same keys, but with every function wrapped into a `dispatch` call so they | |
* may be invoked directly. This is just a convenience method, as you can call | |
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine. | |
* | |
* For convenience, you can also pass a single function as the first argument, | |
* and get a function in return. | |
* | |
* @param {Function|Object} actionCreators An object whose values are action | |
* creator functions. One handy way to obtain it is to use ES6 `import * as` | |
* syntax. You may also pass a single function. | |
* | |
* @param {Function} dispatch The `dispatch` function available on your Redux | |
* store. | |
* | |
* @returns {Function|Object} The object mimicking the original object, but with | |
* every action creator wrapped into the `dispatch` call. If you passed a | |
* function as `actionCreators`, the return value will also be a single | |
* function. | |
*/ | |
function bindActionCreators(actionCreators, dispatch) { | |
if (typeof actionCreators === 'function') { | |
return bindActionCreator(actionCreators, dispatch); | |
} | |
if (typeof actionCreators !== 'object' || actionCreators === null) { | |
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'); | |
} | |
var keys = Object.keys(actionCreators); | |
var boundActionCreators = {}; | |
for (var i = 0; i < keys.length; i++) { | |
var key = keys[i]; | |
var actionCreator = actionCreators[key]; | |
if (typeof actionCreator === 'function') { | |
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); | |
} | |
} | |
return boundActionCreators; | |
} | |
/** | |
* Composes single-argument functions from right to left. The rightmost | |
* function can take multiple arguments as it provides the signature for | |
* the resulting composite function. | |
* | |
* @param {...Function} funcs The functions to compose. | |
* @returns {Function} A function obtained by composing the argument functions | |
* from right to left. For example, compose(f, g, h) is identical to doing | |
* (...args) => f(g(h(...args))). | |
*/ | |
function compose() { | |
var arguments$1 = arguments; | |
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | |
funcs[_key] = arguments$1[_key]; | |
} | |
if (funcs.length === 0) { | |
return function (arg) { | |
return arg; | |
}; | |
} | |
if (funcs.length === 1) { | |
return funcs[0]; | |
} | |
var last = funcs[funcs.length - 1]; | |
var rest = funcs.slice(0, -1); | |
return function () { | |
return rest.reduceRight(function (composed, f) { | |
return f(composed); | |
}, last.apply(undefined, arguments)); | |
}; | |
} | |
var _extends = Object.assign || function (target) { | |
var arguments$1 = arguments; | |
for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
/** | |
* Creates a store enhancer that applies middleware to the dispatch method | |
* of the Redux store. This is handy for a variety of tasks, such as expressing | |
* asynchronous actions in a concise manner, or logging every action payload. | |
* | |
* See `redux-thunk` package as an example of the Redux middleware. | |
* | |
* Because middleware is potentially asynchronous, this should be the first | |
* store enhancer in the composition chain. | |
* | |
* Note that each middleware will be given the `dispatch` and `getState` functions | |
* as named arguments. | |
* | |
* @param {...Function} middlewares The middleware chain to be applied. | |
* @returns {Function} A store enhancer applying the middleware. | |
*/ | |
function applyMiddleware() { | |
var arguments$1 = arguments; | |
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { | |
middlewares[_key] = arguments$1[_key]; | |
} | |
return function (createStore) { | |
return function (reducer, preloadedState, enhancer) { | |
var store = createStore(reducer, preloadedState, enhancer); | |
var _dispatch = store.dispatch; | |
var chain = []; | |
var middlewareAPI = { | |
getState: store.getState, | |
dispatch: function dispatch(action) { | |
return _dispatch(action); | |
} | |
}; | |
chain = middlewares.map(function (middleware) { | |
return middleware(middlewareAPI); | |
}); | |
_dispatch = compose.apply(undefined, chain)(store.dispatch); | |
return _extends({}, store, { | |
dispatch: _dispatch | |
}); | |
}; | |
}; | |
} | |
/* | |
* This is a dummy function to check if the function name has been altered by minification. | |
* If the function has been minified and NODE_ENV !== 'production', warn the user. | |
*/ | |
function isCrushed() {} | |
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') { | |
warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.'); | |
} | |
var index$38 = Object.freeze({ | |
createStore: createStore, | |
combineReducers: combineReducers$1, | |
bindActionCreators: bindActionCreators, | |
applyMiddleware: applyMiddleware, | |
compose: compose | |
}); | |
var require$$0$10 = ( index$38 && index$38['default'] ) || index$38; | |
/** | |
* Module Dependencies | |
*/ | |
var reducer = reducer_1 | |
var resolve = resolve_1 | |
var freeze = freeze_1 | |
var handle = handle_1 | |
var sliced = index$8 | |
var redux = require$$0$10 | |
var isArray = Array.isArray | |
/** | |
* Redux methods | |
*/ | |
var Middleware = redux.applyMiddleware | |
var Store = redux.createStore | |
/** | |
* Export `Socrates` | |
*/ | |
var index$2 = Socrates | |
/** | |
* Initialize `Socrates` | |
* | |
* @param {Array} middlewares | |
* @param {Function} root reducer | |
* @return {Function} socrates | |
*/ | |
function Socrates (reduce) { | |
reduce = reduce || handle() | |
// create our redux client | |
var redux = Store(reducer(reduce), {}, Middleware(resolve)) | |
// initialize a store | |
function store (action) { | |
var arrayContext = isArray(this) | |
if (!arguments.length && !arrayContext) { return freeze(redux.getState()) } | |
var actions = arrayContext ? sliced(this) : sliced(arguments) | |
actions = wrapEmitterStyle(actions) | |
redux.dispatch.apply(redux, actions) | |
return redux.getState() | |
} | |
// subscribe to changes | |
store.subscribe = function subscribe (fn) { | |
return redux.subscribe(function listener () { | |
return fn(freeze(redux.getState())) | |
}) | |
} | |
return store | |
} | |
/** | |
* Maybe wrap the emitter style | |
* into a flux standard action | |
* | |
* @param {Array} actions | |
* @return {Array} | |
*/ | |
function wrapEmitterStyle (actions) { | |
if (actions.length !== 2) { return actions } | |
if (typeof actions[0] !== 'string') { return actions } | |
return [{ | |
type: actions[0], | |
payload: actions[1] | |
}] | |
} | |
var index$42 = createCommonjsModule(function (module, exports) { | |
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | |
typeof define === 'function' && define.amd ? define(factory) : | |
(global.afro = factory()); | |
}(commonjsGlobal, function () { | |
function interopDefault(ex) { | |
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; | |
} | |
function createCommonjsModule$$1(fn, module) { | |
return module = { exports: {} }, fn(module, module.exports), module.exports; | |
} | |
var walk = createCommonjsModule$$1(function (module) { | |
/** | |
* Export `walk` | |
*/ | |
module.exports = walk | |
/** | |
* Walk the AST calling `fn` | |
* | |
* @param {AST} node | |
* @param {Function} fn | |
*/ | |
function walk(node, fn) { | |
for (var i = 0, rule; rule = node.rules[i]; i++) { | |
rule.rules ? walk(rule, fn) : fn(rule, node) | |
} | |
} | |
}); | |
var walk$1 = interopDefault(walk); | |
var require$$1 = Object.freeze({ | |
default: walk$1 | |
}); | |
var hash = createCommonjsModule$$1(function (module) { | |
/** | |
* Export Hash | |
*/ | |
module.exports = Hash | |
/** | |
* Hash | |
* | |
* @param {Object} object | |
* @return {String} string | |
*/ | |
function Hash (object) { | |
return murmur(JSON.stringify(object)) | |
} | |
/** | |
* JS Implementation of MurmurHash2 | |
* | |
* @author <a href="mailto:[email protected]">Gary Court</a> | |
* @see http://github.com/garycourt/murmurhash-js | |
* @author <a href="mailto:[email protected]">Austin Appleby</a> | |
* @see http://sites.google.com/site/murmurhash/ | |
* | |
* @param {string} str ASCII only | |
* @return {string} Base 36 encoded hash result | |
*/ | |
function murmur (str) { | |
var l = str.length | |
var h = l | |
var i = 0 | |
var k = undefined | |
while (l >= 4) { | |
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24 | |
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16) | |
k ^= k >>> 24 | |
k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16) | |
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k | |
l -= 4 | |
++i | |
} | |
switch (l) { | |
case 3: | |
h ^= (str.charCodeAt(i + 2) & 0xff) << 16 | |
case 2: | |
h ^= (str.charCodeAt(i + 1) & 0xff) << 8 | |
case 1: | |
h ^= str.charCodeAt(i) & 0xff | |
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) | |
} | |
h ^= h >>> 13 | |
h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) | |
h ^= h >>> 15 | |
return (h >>> 0).toString(36) | |
} | |
}); | |
var hash$1 = interopDefault(hash); | |
var require$$0 = Object.freeze({ | |
default: hash$1 | |
}); | |
var analyze = createCommonjsModule$$1(function (module) { | |
/** | |
* Module dependencies | |
*/ | |
var walk = interopDefault(require$$1) | |
var Hash = interopDefault(require$$0) | |
/** | |
* Export `Analyze` | |
*/ | |
module.exports = Analyze | |
/** | |
* Initialize `Analyze` | |
*/ | |
function Analyze (ast) { | |
var classes = {} | |
// aggregate all the selectors | |
walk(ast, function (rule, node) { | |
if (rule.type !== 'rule') { return } | |
var selectors = split(rule.selectors) | |
selectors.forEach(function (selector) { | |
var psuedos = selector.split(':') | |
var tag = psuedos.shift() | |
// setup the attrs object | |
var attrs = classes[tag] = classes[tag] || {} | |
if (node.media) { | |
var media = "@media " + (node.media) | |
attrs = attrs[media] = attrs[media] || {} | |
} | |
if (psuedos.length) { | |
var psuedo = ":" + (psuedos.join(':')) | |
attrs = attrs[psuedo] = attrs[psuedo] || {} | |
} | |
rule.declarations.forEach(function (decl) { | |
attrs[decl.property] = decl.value | |
}) | |
}) | |
}) | |
for (var selector in classes) { | |
classes[selector] = '_' + Hash(classes[selector]) | |
} | |
return classes | |
} | |
/** | |
* Get all the classnames, ignore everything else | |
* | |
* @param {Array} selectors | |
* @return {Array} selectors | |
*/ | |
function split (selectors) { | |
return selectors.reduce(function (selectors, selector) { | |
selector.replace(/\.([^\s]+)/g, function (m, cls) { | |
selectors.push(cls) | |
}) | |
return selectors | |
}, []) | |
} | |
}); | |
var analyze$1 = interopDefault(analyze); | |
var require$$5 = Object.freeze({ | |
default: analyze$1 | |
}); | |
var prefixProps = createCommonjsModule$$1(function (module, exports) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = { "Webkit": { "transform": true, "transformOrigin": true, "transformOriginX": true, "transformOriginY": true, "backfaceVisibility": true, "perspective": true, "perspectiveOrigin": true, "transformStyle": true, "transformOriginZ": true, "animation": true, "animationDelay": true, "animationDirection": true, "animationFillMode": true, "animationDuration": true, "animationIterationCount": true, "animationName": true, "animationPlayState": true, "animationTimingFunction": true, "appearance": true, "userSelect": true, "fontKerning": true, "textEmphasisPosition": true, "textEmphasis": true, "textEmphasisStyle": true, "textEmphasisColor": true, "boxDecorationBreak": true, "clipPath": true, "maskImage": true, "maskMode": true, "maskRepeat": true, "maskPosition": true, "maskClip": true, "maskOrigin": true, "maskSize": true, "maskComposite": true, "mask": true, "maskBorderSource": true, "maskBorderMode": true, "maskBorderSlice": true, "maskBorderWidth": true, "maskBorderOutset": true, "maskBorderRepeat": true, "maskBorder": true, "maskType": true, "textDecorationStyle": true, "textDecorationSkip": true, "textDecorationLine": true, "textDecorationColor": true, "filter": true, "fontFeatureSettings": true, "breakAfter": true, "breakBefore": true, "breakInside": true, "columnCount": true, "columnFill": true, "columnGap": true, "columnRule": true, "columnRuleColor": true, "columnRuleStyle": true, "columnRuleWidth": true, "columns": true, "columnSpan": true, "columnWidth": true, "flex": true, "flexBasis": true, "flexDirection": true, "flexGrow": true, "flexFlow": true, "flexShrink": true, "flexWrap": true, "alignContent": true, "alignItems": true, "alignSelf": true, "justifyContent": true, "order": true, "transition": true, "transitionDelay": true, "transitionDuration": true, "transitionProperty": true, "transitionTimingFunction": true, "backdropFilter": true, "scrollSnapType": true, "scrollSnapPointsX": true, "scrollSnapPointsY": true, "scrollSnapDestination": true, "scrollSnapCoordinate": true, "shapeImageThreshold": true, "shapeImageMargin": true, "shapeImageOutside": true, "hyphens": true, "flowInto": true, "flowFrom": true, "regionFragment": true, "textSizeAdjust": true, "borderImage": true, "borderImageOutset": true, "borderImageRepeat": true, "borderImageSlice": true, "borderImageSource": true, "borderImageWidth": true, "tabSize": true, "objectFit": true, "objectPosition": true }, "Moz": { "appearance": true, "userSelect": true, "boxSizing": true, "textAlignLast": true, "textDecorationStyle": true, "textDecorationSkip": true, "textDecorationLine": true, "textDecorationColor": true, "tabSize": true, "hyphens": true, "fontFeatureSettings": true, "breakAfter": true, "breakBefore": true, "breakInside": true, "columnCount": true, "columnFill": true, "columnGap": true, "columnRule": true, "columnRuleColor": true, "columnRuleStyle": true, "columnRuleWidth": true, "columns": true, "columnSpan": true, "columnWidth": true }, "ms": { "flex": true, "flexBasis": false, "flexDirection": true, "flexGrow": false, "flexFlow": true, "flexShrink": false, "flexWrap": true, "alignContent": false, "alignItems": false, "alignSelf": false, "justifyContent": false, "order": false, "transform": true, "transformOrigin": true, "transformOriginX": true, "transformOriginY": true, "userSelect": true, "wrapFlow": true, "wrapThrough": true, "wrapMargin": true, "scrollSnapType": true, "scrollSnapPointsX": true, "scrollSnapPointsY": true, "scrollSnapDestination": true, "scrollSnapCoordinate": true, "touchAction": true, "hyphens": true, "flowInto": true, "flowFrom": true, "breakBefore": true, "breakAfter": true, "breakInside": true, "regionFragment": true, "gridTemplateColumns": true, "gridTemplateRows": true, "gridTemplateAreas": true, "gridTemplate": true, "gridAutoColumns": true, "gridAutoRows": true, "gridAutoFlow": true, "grid": true, "gridRowStart": true, "gridColumnStart": true, "gridRowEnd": true, "gridRow": true, "gridColumn": true, "gridColumnEnd": true, "gridColumnGap": true, "gridRowGap": true, "gridArea": true, "gridGap": true, "textSizeAdjust": true } }; | |
module.exports = exports["default"]; | |
}); | |
var prefixProps$1 = interopDefault(prefixProps); | |
var require$$0$3 = Object.freeze({ | |
default: prefixProps$1 | |
}); | |
var capitalizeString = createCommonjsModule$$1(function (module, exports) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
// helper to capitalize strings | |
exports.default = function (str) { | |
return str.charAt(0).toUpperCase() + str.slice(1); | |
}; | |
module.exports = exports["default"]; | |
}); | |
var capitalizeString$1 = interopDefault(capitalizeString); | |
var require$$2$1 = Object.freeze({ | |
default: capitalizeString$1 | |
}); | |
var joinPrefixedValue = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
// returns a style object with a single concated prefixed value string | |
exports.default = function (property, value) { | |
var replacer = arguments.length <= 2 || arguments[2] === undefined ? function (prefix, value) { | |
return prefix + value; | |
} : arguments[2]; | |
return _defineProperty({}, property, ['-webkit-', '-moz-', ''].map(function (prefix) { | |
return replacer(prefix, value); | |
})); | |
}; | |
module.exports = exports['default']; | |
}); | |
var joinPrefixedValue$1 = interopDefault(joinPrefixedValue); | |
var require$$1$2 = Object.freeze({ | |
default: joinPrefixedValue$1 | |
}); | |
var isPrefixedValue = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = function (value) { | |
if (Array.isArray(value)) { value = value.join(','); } | |
return value.match(/-webkit-|-moz-|-ms-/) !== null; | |
}; | |
module.exports = exports['default']; | |
}); | |
var isPrefixedValue$1 = interopDefault(isPrefixedValue); | |
var require$$1$3 = Object.freeze({ | |
default: isPrefixedValue$1 | |
}); | |
var calc = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = calc; | |
var _joinPrefixedValue = interopDefault(require$$1$2); | |
var _joinPrefixedValue2 = _interopRequireDefault(_joinPrefixedValue); | |
var _isPrefixedValue = interopDefault(require$$1$3); | |
var _isPrefixedValue2 = _interopRequireDefault(_isPrefixedValue); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function calc(property, value) { | |
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('calc(') > -1) { | |
return (0, _joinPrefixedValue2.default)(property, value, function (prefix, value) { | |
return value.replace(/calc\(/g, prefix + 'calc('); | |
}); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var calc$1 = interopDefault(calc); | |
var require$$7 = Object.freeze({ | |
default: calc$1 | |
}); | |
var cursor = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = cursor; | |
var _joinPrefixedValue = interopDefault(require$$1$2); | |
var _joinPrefixedValue2 = _interopRequireDefault(_joinPrefixedValue); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var values = { | |
'zoom-in': true, | |
'zoom-out': true, | |
grab: true, | |
grabbing: true | |
}; | |
function cursor(property, value) { | |
if (property === 'cursor' && values[value]) { | |
return (0, _joinPrefixedValue2.default)(property, value); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var cursor$1 = interopDefault(cursor); | |
var require$$6 = Object.freeze({ | |
default: cursor$1 | |
}); | |
var flex = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = flex; | |
var values = { flex: true, 'inline-flex': true }; | |
function flex(property, value) { | |
if (property === 'display' && values[value]) { | |
return { | |
display: ['-webkit-box', '-moz-box', '-ms-' + value + 'box', '-webkit-' + value, value] | |
}; | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var flex$1 = interopDefault(flex); | |
var require$$5$1 = Object.freeze({ | |
default: flex$1 | |
}); | |
var sizing = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = sizing; | |
var _joinPrefixedValue = interopDefault(require$$1$2); | |
var _joinPrefixedValue2 = _interopRequireDefault(_joinPrefixedValue); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var properties = { | |
maxHeight: true, | |
maxWidth: true, | |
width: true, | |
height: true, | |
columnWidth: true, | |
minWidth: true, | |
minHeight: true | |
}; | |
var values = { | |
'min-content': true, | |
'max-content': true, | |
'fill-available': true, | |
'fit-content': true, | |
'contain-floats': true | |
}; | |
function sizing(property, value) { | |
if (properties[property] && values[value]) { | |
return (0, _joinPrefixedValue2.default)(property, value); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var sizing$1 = interopDefault(sizing); | |
var require$$4$1 = Object.freeze({ | |
default: sizing$1 | |
}); | |
var gradient = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = gradient; | |
var _joinPrefixedValue = interopDefault(require$$1$2); | |
var _joinPrefixedValue2 = _interopRequireDefault(_joinPrefixedValue); | |
var _isPrefixedValue = interopDefault(require$$1$3); | |
var _isPrefixedValue2 = _interopRequireDefault(_isPrefixedValue); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var values = /linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/; | |
function gradient(property, value) { | |
if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.match(values) !== null) { | |
return (0, _joinPrefixedValue2.default)(property, value); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var gradient$1 = interopDefault(gradient); | |
var require$$3 = Object.freeze({ | |
default: gradient$1 | |
}); | |
var index$2 = createCommonjsModule$$1(function (module) { | |
'use strict'; | |
var uppercasePattern = /[A-Z]/g; | |
var msPattern = /^ms-/; | |
function hyphenateStyleName(string) { | |
return string | |
.replace(uppercasePattern, '-$&') | |
.toLowerCase() | |
.replace(msPattern, '-ms-'); | |
} | |
module.exports = hyphenateStyleName; | |
}); | |
var index$3 = interopDefault(index$2); | |
var require$$3$1 = Object.freeze({ | |
default: index$3 | |
}); | |
var transition = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = transition; | |
var _hyphenateStyleName = interopDefault(require$$3$1); | |
var _hyphenateStyleName2 = _interopRequireDefault(_hyphenateStyleName); | |
var _capitalizeString = interopDefault(require$$2$1); | |
var _capitalizeString2 = _interopRequireDefault(_capitalizeString); | |
var _isPrefixedValue = interopDefault(require$$1$3); | |
var _isPrefixedValue2 = _interopRequireDefault(_isPrefixedValue); | |
var _prefixProps = interopDefault(require$$0$3); | |
var _prefixProps2 = _interopRequireDefault(_prefixProps); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
var properties = { | |
transition: true, | |
transitionProperty: true, | |
WebkitTransition: true, | |
WebkitTransitionProperty: true | |
}; | |
function transition(property, value) { | |
// also check for already prefixed transitions | |
if (typeof value === 'string' && properties[property]) { | |
var _ref2; | |
var outputValue = prefixValue(value); | |
var webkitOutput = outputValue.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function (value) { | |
return value.match(/-moz-|-ms-/) === null; | |
}).join(','); | |
// if the property is already prefixed | |
if (property.indexOf('Webkit') > -1) { | |
return _defineProperty({}, property, webkitOutput); | |
} | |
return _ref2 = {}, _defineProperty(_ref2, 'Webkit' + (0, _capitalizeString2.default)(property), webkitOutput), _defineProperty(_ref2, property, outputValue), _ref2; | |
} | |
} | |
function prefixValue(value) { | |
if ((0, _isPrefixedValue2.default)(value)) { | |
return value; | |
} | |
// only split multi values, not cubic beziers | |
var multipleValues = value.split(/,(?![^()]*(?:\([^()]*\))?\))/g); | |
// iterate each single value and check for transitioned properties | |
// that need to be prefixed as well | |
multipleValues.forEach(function (val, index) { | |
multipleValues[index] = Object.keys(_prefixProps2.default).reduce(function (out, prefix) { | |
var dashCasePrefix = '-' + prefix.toLowerCase() + '-'; | |
Object.keys(_prefixProps2.default[prefix]).forEach(function (prop) { | |
var dashCaseProperty = (0, _hyphenateStyleName2.default)(prop); | |
if (val.indexOf(dashCaseProperty) > -1 && dashCaseProperty !== 'order') { | |
// join all prefixes and create a new value | |
out = val.replace(dashCaseProperty, dashCasePrefix + dashCaseProperty) + ',' + out; | |
} | |
}); | |
return out; | |
}, val); | |
}); | |
return multipleValues.join(','); | |
} | |
module.exports = exports['default']; | |
}); | |
var transition$1 = interopDefault(transition); | |
var require$$2$2 = Object.freeze({ | |
default: transition$1 | |
}); | |
var flexboxIE = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = flexboxIE; | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
var alternativeValues = { | |
'space-around': 'distribute', | |
'space-between': 'justify', | |
'flex-start': 'start', | |
'flex-end': 'end' | |
}; | |
var alternativeProps = { | |
alignContent: 'msFlexLinePack', | |
alignSelf: 'msFlexItemAlign', | |
alignItems: 'msFlexAlign', | |
justifyContent: 'msFlexPack', | |
order: 'msFlexOrder', | |
flexGrow: 'msFlexPositive', | |
flexShrink: 'msFlexNegative', | |
flexBasis: 'msPreferredSize' | |
}; | |
function flexboxIE(property, value) { | |
if (alternativeProps[property]) { | |
return _defineProperty({}, alternativeProps[property], alternativeValues[value] || value); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var flexboxIE$1 = interopDefault(flexboxIE); | |
var require$$1$4 = Object.freeze({ | |
default: flexboxIE$1 | |
}); | |
var flexboxOld = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = flexboxOld; | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
var alternativeValues = { | |
'space-around': 'justify', | |
'space-between': 'justify', | |
'flex-start': 'start', | |
'flex-end': 'end', | |
'wrap-reverse': 'multiple', | |
wrap: 'multiple' | |
}; | |
var alternativeProps = { | |
alignItems: 'WebkitBoxAlign', | |
justifyContent: 'WebkitBoxPack', | |
flexWrap: 'WebkitBoxLines' | |
}; | |
function flexboxOld(property, value) { | |
if (property === 'flexDirection') { | |
return { | |
WebkitBoxOrient: value.indexOf('column') > -1 ? 'vertical' : 'horizontal', | |
WebkitBoxDirection: value.indexOf('reverse') > -1 ? 'reverse' : 'normal' | |
}; | |
} | |
if (alternativeProps[property]) { | |
return _defineProperty({}, alternativeProps[property], alternativeValues[value] || value); | |
} | |
} | |
module.exports = exports['default']; | |
}); | |
var flexboxOld$1 = interopDefault(flexboxOld); | |
var require$$0$4 = Object.freeze({ | |
default: flexboxOld$1 | |
}); | |
var prefixAll = createCommonjsModule$$1(function (module, exports) { | |
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = prefixAll; | |
var _prefixProps = interopDefault(require$$0$3); | |
var _prefixProps2 = _interopRequireDefault(_prefixProps); | |
var _capitalizeString = interopDefault(require$$2$1); | |
var _capitalizeString2 = _interopRequireDefault(_capitalizeString); | |
var _calc = interopDefault(require$$7); | |
var _calc2 = _interopRequireDefault(_calc); | |
var _cursor = interopDefault(require$$6); | |
var _cursor2 = _interopRequireDefault(_cursor); | |
var _flex = interopDefault(require$$5$1); | |
var _flex2 = _interopRequireDefault(_flex); | |
var _sizing = interopDefault(require$$4$1); | |
var _sizing2 = _interopRequireDefault(_sizing); | |
var _gradient = interopDefault(require$$3); | |
var _gradient2 = _interopRequireDefault(_gradient); | |
var _transition = interopDefault(require$$2$2); | |
var _transition2 = _interopRequireDefault(_transition); | |
var _flexboxIE = interopDefault(require$$1$4); | |
var _flexboxIE2 = _interopRequireDefault(_flexboxIE); | |
var _flexboxOld = interopDefault(require$$0$4); | |
var _flexboxOld2 = _interopRequireDefault(_flexboxOld); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// special flexbox specifications | |
var plugins = [_calc2.default, _cursor2.default, _sizing2.default, _gradient2.default, _transition2.default, _flexboxIE2.default, _flexboxOld2.default, _flex2.default]; | |
/** | |
* Returns a prefixed version of the style object using all vendor prefixes | |
* @param {Object} styles - Style object that gets prefixed properties added | |
* @returns {Object} - Style object with prefixed properties and values | |
*/ | |
function prefixAll(styles) { | |
Object.keys(styles).forEach(function (property) { | |
var value = styles[property]; | |
if (value instanceof Object && !Array.isArray(value)) { | |
// recurse through nested style objects | |
styles[property] = prefixAll(value); | |
} else { | |
Object.keys(_prefixProps2.default).forEach(function (prefix) { | |
var properties = _prefixProps2.default[prefix]; | |
// add prefixes if needed | |
if (properties[property]) { | |
styles[prefix + (0, _capitalizeString2.default)(property)] = value; | |
} | |
}); | |
} | |
}); | |
Object.keys(styles).forEach(function (property) { | |
[].concat(styles[property]).forEach(function (value, index) { | |
// resolve every special plugins | |
plugins.forEach(function (plugin) { | |
return assignStyles(styles, plugin(property, value)); | |
}); | |
}); | |
}); | |
return styles; | |
} | |
function assignStyles(base) { | |
var extend = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | |
Object.keys(extend).forEach(function (property) { | |
var baseValue = base[property]; | |
if (Array.isArray(baseValue)) { | |
[].concat(extend[property]).forEach(function (value) { | |
var valueIndex = baseValue.indexOf(value); | |
if (valueIndex > -1) { | |
base[property].splice(valueIndex, 1); | |
} | |
base[property].push(value); | |
}); | |
} else { | |
base[property] = extend[property]; | |
} | |
}); | |
} | |
module.exports = exports['default']; | |
}); | |
var prefixAll$1 = interopDefault(prefixAll); | |
var require$$0$2 = Object.freeze({ | |
default: prefixAll$1 | |
}); | |
var _static = createCommonjsModule$$1(function (module) { | |
module.exports = interopDefault(require$$0$2) | |
}); | |
var _static$1 = interopDefault(_static); | |
var require$$2 = Object.freeze({ | |
default: _static$1 | |
}); | |
var index$8 = createCommonjsModule$$1(function (module) { | |
/** | |
* Export. | |
*/ | |
module.exports = toNoCase | |
/** | |
* Test whether a string is camel-case. | |
*/ | |
var hasSpace = /\s/ | |
var hasSeparator = /[\W_]/ | |
var hasCamel = /([a-z][A-Z]|[A-Z][a-z])/ | |
/** | |
* Remove any starting case from a `string`, like camel or snake, but keep | |
* spaces and punctuation that may be important otherwise. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function toNoCase(string) { | |
if (hasSpace.test(string)) { return string.toLowerCase() } | |
if (hasSeparator.test(string)) { return (unseparate(string) || string).toLowerCase() } | |
if (hasCamel.test(string)) { return uncamelize(string).toLowerCase() } | |
return string.toLowerCase() | |
} | |
/** | |
* Separator splitter. | |
*/ | |
var separatorSplitter = /[\W_]+(.|$)/g | |
/** | |
* Un-separate a `string`. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function unseparate(string) { | |
return string.replace(separatorSplitter, function (m, next) { | |
return next ? ' ' + next : '' | |
}) | |
} | |
/** | |
* Camelcase splitter. | |
*/ | |
var camelSplitter = /(.)([A-Z]+)/g | |
/** | |
* Un-camelcase a `string`. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function uncamelize(string) { | |
return string.replace(camelSplitter, function (m, previous, uppers) { | |
return previous + ' ' + uppers.toLowerCase().split('').join(' ') | |
}) | |
} | |
}); | |
var index$9 = interopDefault(index$8); | |
var require$$0$6 = Object.freeze({ | |
default: index$9 | |
}); | |
var index$6 = createCommonjsModule$$1(function (module) { | |
var clean = interopDefault(require$$0$6) | |
/** | |
* Export. | |
*/ | |
module.exports = toSpaceCase | |
/** | |
* Convert a `string` to space case. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function toSpaceCase(string) { | |
return clean(string).replace(/[\W_]+(.|$)/g, function (matches, match) { | |
return match ? ' ' + match : '' | |
}).trim() | |
} | |
}); | |
var index$7 = interopDefault(index$6); | |
var require$$0$5 = Object.freeze({ | |
default: index$7 | |
}); | |
var index$4 = createCommonjsModule$$1(function (module) { | |
var space = interopDefault(require$$0$5) | |
/** | |
* Export. | |
*/ | |
module.exports = toCamelCase | |
/** | |
* Convert a `string` to camel case. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function toCamelCase(string) { | |
return space(string).replace(/\s(\w)/g, function (matches, letter) { | |
return letter.toUpperCase() | |
}) | |
} | |
}); | |
var index$5 = interopDefault(index$4); | |
var require$$1$5 = Object.freeze({ | |
default: index$5 | |
}); | |
var index$10 = createCommonjsModule$$1(function (module) { | |
var toSpace = interopDefault(require$$0$5) | |
/** | |
* Export. | |
*/ | |
module.exports = toSlugCase | |
/** | |
* Convert a `string` to slug case. | |
* | |
* @param {String} string | |
* @return {String} | |
*/ | |
function toSlugCase(string) { | |
return toSpace(string).replace(/\s/g, '-') | |
} | |
}); | |
var index$11 = interopDefault(index$10); | |
var require$$0$7 = Object.freeze({ | |
default: index$11 | |
}); | |
var prefix = createCommonjsModule$$1(function (module) { | |
/** | |
* Module dependencies | |
*/ | |
var prefixes = interopDefault(require$$2) | |
var camel = interopDefault(require$$1$5) | |
var slug = interopDefault(require$$0$7) | |
/** | |
* Export `prefix` | |
*/ | |
module.exports = prefix | |
/** | |
* Initialize `prefix` | |
*/ | |
function prefix (key, value) { | |
key = camel(key) | |
var obj = {} | |
obj[key] = value | |
obj = prefixes(obj) | |
var out = {} | |
for (var k in obj) { | |
var str = slug(k) | |
// add hyphen in front of browser prefixes | |
str = ~str.search(/^(webkit|moz|ms)/) ? '-' + str : str | |
out[str] = obj[k] | |
} | |
return out | |
} | |
}); | |
var prefix$1 = interopDefault(prefix); | |
var require$$0$1 = Object.freeze({ | |
default: prefix$1 | |
}); | |
var stringify = createCommonjsModule$$1(function (module) { | |
/** | |
* Module Dependencies | |
*/ | |
var prefix = interopDefault(require$$0$1) | |
var isArray = Array.isArray | |
/** | |
* Export `stringify` | |
*/ | |
module.exports = stringify | |
/** | |
* Browser keyframes | |
*/ | |
var prefixes = [ | |
'-webkit-', | |
'-moz-', | |
'' | |
] | |
/** | |
* Selector | |
*/ | |
var rselector = /\.([^\s]+)/g | |
/** | |
* Stringify | |
*/ | |
function stringify (rule, classes, id) { | |
// handle rules | |
if (rule.type === 'rule') { | |
var selectors = rule.selectors.map(function (s) { | |
return selector(s, classes, id) | |
}).join(', ') | |
var decs = declarations(rule.declarations) | |
return (selectors + " { " + decs + " }") | |
} | |
// @media | |
if (rule.type === 'media') { | |
var rules = rule.rules.map(function (rule) { return stringify(rule, classes, id); }).join('\n') | |
return ("@media " + (rule.media) + " {\n" + rules + "\n}") | |
} | |
// handle @keyframes | |
if (rule.type === 'keyframes') { | |
return prefixes.reduce(function (keyframe, prefix) { | |
var keys = keyframes(rule.keyframes) | |
return keyframe.concat(("@" + prefix + "keyframes " + (rule.name) + " {\n" + keys + "}")) | |
}, []).join('\n') | |
} | |
// handle @font-faces | |
if (rule.type === 'font-face') { | |
return ("@font-face { " + (declarations(rule.declarations)) + " }") | |
} | |
} | |
function selector (selector, classes, id) { | |
return selector.replace(rselector, function (m, cls) { | |
var psuedos = cls.split(':') | |
var tag = psuedos.shift() | |
tag = classes[tag] && classes[tag][id] ? classes[tag][id] : tag | |
psuedos.unshift(tag) | |
return '.' + psuedos.join(':') | |
}) | |
} | |
function declarations (declarations) { | |
return declarations.reduce(function (decs, dec) { | |
if (dec.type === 'comment') { return decs } | |
var obj = prefix(dec.property, dec.value) | |
var loop = function ( k ) { | |
if (isArray(obj[k])) { | |
obj[k].forEach(function (v) { return decs.push((k + ": " + v + ";")); }) | |
} else { | |
decs.push((k + ": " + (obj[k]) + ";")) | |
} | |
}; | |
for (var k in obj) { loop( k ); } | |
return decs | |
}, []).join(' ') | |
} | |
function keyframes (keyframes) { | |
return keyframes.reduce(function (keys, keyframe) { | |
var values = keyframe.values.join(', ') | |
keys += values + " { " + (declarations(keyframe.declarations)) + " }\n" | |
return keys | |
}, '') | |
} | |
}); | |
var stringify$1 = interopDefault(stringify); | |
var require$$1$1 = Object.freeze({ | |
default: stringify$1 | |
}); | |
var render = createCommonjsModule$$1(function (module) { | |
/** | |
* Module dependencies | |
*/ | |
var stringify = interopDefault(require$$1$1) | |
var Hash = interopDefault(require$$0) | |
/** | |
* Export `Render` | |
*/ | |
module.exports = Render | |
/** | |
* Initialize `Render` | |
*/ | |
function Render (asts, classes) { | |
var styles = [] | |
var dedupe = {} | |
for (var i = 0, ast; ast = asts[i]; i++) { | |
for (var j = 0, rule; rule = ast.rules[j]; j++) { | |
if (rule.type === 'comment') { continue } | |
var compiled = stringify(rule, classes, ast.id) | |
var hash = Hash(compiled) | |
if (dedupe[hash]) { continue } | |
styles.push(compiled) | |
dedupe[hash] = true | |
} | |
} | |
return styles.join('\n') | |
} | |
}); | |
var render$1 = interopDefault(render); | |
var require$$4 = Object.freeze({ | |
default: render$1 | |
}); | |
var deepExtend = createCommonjsModule$$1(function (module) { | |
/*! | |
* @description Recursive object extending | |
* @author Viacheslav Lotsmanov <[email protected]> | |
* @license MIT | |
* | |
* The MIT License (MIT) | |
* | |
* Copyright (c) 2013-2015 Viacheslav Lotsmanov | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy of | |
* this software and associated documentation files (the "Software"), to deal in | |
* the Software without restriction, including without limitation the rights to | |
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
* the Software, and to permit persons to whom the Software is furnished to do so, | |
* subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in all | |
* copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
*/ | |
'use strict'; | |
function isSpecificValue(val) { | |
return ( | |
val instanceof Buffer | |
|| val instanceof Date | |
|| val instanceof RegExp | |
) ? true : false; | |
} | |
function cloneSpecificValue(val) { | |
if (val instanceof Buffer) { | |
var x = new Buffer(val.length); | |
val.copy(x); | |
return x; | |
} else if (val instanceof Date) { | |
return new Date(val.getTime()); | |
} else if (val instanceof RegExp) { | |
return new RegExp(val); | |
} else { | |
throw new Error('Unexpected situation'); | |
} | |
} | |
/** | |
* Recursive cloning array. | |
*/ | |
function deepCloneArray(arr) { | |
var clone = []; | |
arr.forEach(function (item, index) { | |
if (typeof item === 'object' && item !== null) { | |
if (Array.isArray(item)) { | |
clone[index] = deepCloneArray(item); | |
} else if (isSpecificValue(item)) { | |
clone[index] = cloneSpecificValue(item); | |
} else { | |
clone[index] = deepExtend({}, item); | |
} | |
} else { | |
clone[index] = item; | |
} | |
}); | |
return clone; | |
} | |
/** | |
* Extening object that entered in first argument. | |
* | |
* Returns extended object or false if have no target object or incorrect type. | |
* | |
* If you wish to clone source object (without modify it), just use empty new | |
* object as first argument, like this: | |
* deepExtend({}, yourObj_1, [yourObj_N]); | |
*/ | |
var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) { | |
if (arguments.length < 1 || typeof arguments[0] !== 'object') { | |
return false; | |
} | |
if (arguments.length < 2) { | |
return arguments[0]; | |
} | |
var target = arguments[0]; | |
// convert arguments to array and cut off target object | |
var args = Array.prototype.slice.call(arguments, 1); | |
var val, src, clone; | |
args.forEach(function (obj) { | |
// skip argument if it is array or isn't object | |
if (typeof obj !== 'object' || Array.isArray(obj)) { | |
return; | |
} | |
Object.keys(obj).forEach(function (key) { | |
src = target[key]; // source value | |
val = obj[key]; // new value | |
// recursion prevention | |
if (val === target) { | |
return; | |
/** | |
* if new value isn't object then just overwrite by new value | |
* instead of extending. | |
*/ | |
} else if (typeof val !== 'object' || val === null) { | |
target[key] = val; | |
return; | |
// just clone arrays (and recursive clone objects inside) | |
} else if (Array.isArray(val)) { | |
target[key] = deepCloneArray(val); | |
return; | |
// custom cloning and overwrite for specific objects | |
} else if (isSpecificValue(val)) { | |
target[key] = cloneSpecificValue(val); | |
return; | |
// overwrite by new value if source isn't object or array | |
} else if (typeof src !== 'object' || src === null || Array.isArray(src)) { | |
target[key] = deepExtend({}, val); | |
return; | |
// source value and new value is objects both, extending... | |
} else { | |
target[key] = deepExtend(src, val); | |
return; | |
} | |
}); | |
}); | |
return target; | |
} | |
}); | |
var deepExtend$1 = interopDefault(deepExtend); | |
var require$$3$2 = Object.freeze({ | |
default: deepExtend$1 | |
}); | |
var parse = createCommonjsModule$$1(function (module) { | |
// http://www.w3.org/TR/CSS21/grammar.html | |
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 | |
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g | |
/** | |
* Export `parse` | |
*/ | |
module.exports = parse | |
/** | |
* Parse | |
*/ | |
function parse (css, options) { | |
options = options || {} | |
/** | |
* Positional. | |
*/ | |
var lineno = 1 | |
var column = 1 | |
/** | |
* Update lineno and column based on `str`. | |
*/ | |
function updatePosition (str) { | |
var lines = str.match(/\n/g) | |
if (lines) { lineno += lines.length } | |
var i = str.lastIndexOf('\n') | |
column = ~i ? str.length - i : column + str.length | |
} | |
/** | |
* Mark position and patch `node.position`. | |
*/ | |
function position () { | |
return { line: lineno, column: column } | |
} | |
function markPosition (start, node) { | |
node.position = new Position(start) | |
whitespace() | |
return node | |
} | |
/** | |
* Store position information for a node | |
*/ | |
function Position (start) { | |
this.start = start | |
this.end = { line: lineno, column: column } | |
this.source = options.source | |
} | |
/** | |
* Non-enumerable source string | |
*/ | |
Position.prototype.content = css | |
/** | |
* Error `msg`. | |
*/ | |
var errorsList = [] | |
function error (msg) { | |
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg) | |
err.reason = msg | |
err.filename = options.source | |
err.line = lineno | |
err.column = column | |
err.source = css | |
if (options.silent) { | |
errorsList.push(err) | |
} else { | |
throw err | |
} | |
} | |
/** | |
* Parse stylesheet. | |
*/ | |
function stylesheet () { | |
var rulesList = rules() | |
return { | |
type: 'stylesheet', | |
stylesheet: { | |
source: options.source, | |
rules: rulesList, | |
parsingErrors: errorsList | |
} | |
} | |
} | |
/** | |
* Opening brace. | |
*/ | |
function open () { | |
return match(/^{\s*/) | |
} | |
/** | |
* Closing brace. | |
*/ | |
function close () { | |
return match(/^}/) | |
} | |
/** | |
* Parse ruleset. | |
*/ | |
function rules () { | |
var node | |
var rules = [] | |
whitespace() | |
comments(rules) | |
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) { | |
if (node !== false) { | |
rules.push(node) | |
comments(rules) | |
} | |
} | |
return rules | |
} | |
/** | |
* Match `re` and return captures. | |
*/ | |
function match (re) { | |
var m = re.exec(css) | |
if (!m) { return } | |
var str = m[0] | |
updatePosition(str) | |
css = css.slice(str.length) | |
return m | |
} | |
/** | |
* Parse whitespace. | |
*/ | |
function whitespace () { | |
match(/^\s*/) | |
} | |
/** | |
* Parse comments | |
*/ | |
function comments (rules) { | |
var c | |
rules = rules || [] | |
while (c = comment()) { | |
if (c !== false) { | |
rules.push(c) | |
} | |
} | |
return rules | |
} | |
/** | |
* Parse comment. | |
*/ | |
function comment () { | |
var pos = position() | |
if ('/' != css.charAt(0) || '*' != css.charAt(1)) { return } | |
var i = 2 | |
while ('' != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) { ++i } | |
i += 2 | |
if ('' === css.charAt(i - 1)) { | |
return error('End of comment missing') | |
} | |
var str = css.slice(2, i - 2) | |
column += 2 | |
updatePosition(str) | |
css = css.slice(i) | |
column += 2 | |
return markPosition(pos, { | |
type: 'comment', | |
comment: str | |
}) | |
} | |
/** | |
* Parse selector. | |
*/ | |
function selector () { | |
var m = match(/^([^{]+)/) | |
if (!m) { return } | |
/* @fix Remove all comments from selectors | |
* http://ostermiller.org/findcomment.html */ | |
return trim(m[0]) | |
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') | |
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) { | |
return m.replace(/,/g, '\u200C') | |
}) | |
.split(/\s*(?![^(]*\)),\s*/) | |
.map(function (s) { | |
return s.replace(/\u200C/g, ',') | |
}) | |
} | |
/** | |
* Parse declaration. | |
*/ | |
function declaration () { | |
var pos = position() | |
// prop | |
var prop = match(/^(\*?[-#\/\*\\@\w]+(\[[0-9a-z_-]+\])?)\s*/) | |
if (!prop) { return } | |
prop = trim(prop[0]) | |
// : | |
if (!match(/^:\s*/)) { return error("property missing ':'") } | |
// val | |
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/) | |
var ret = markPosition(pos, { | |
type: 'declaration', | |
property: prop.replace(commentre, ''), | |
value: val ? trim(val[0]).replace(commentre, '') : '' | |
}) | |
// | |
match(/^[;\s]*/) | |
return ret | |
} | |
/** | |
* Parse declarations. | |
*/ | |
function declarations () { | |
var decls = [] | |
if (!open()) { return error("missing '{'") } | |
comments(decls) | |
// declarations | |
var decl | |
while (decl = declaration()) { | |
if (decl !== false) { | |
decls.push(decl) | |
comments(decls) | |
} | |
} | |
if (!close()) { return error("missing '}'") } | |
return decls | |
} | |
/** | |
* Parse keyframe. | |
*/ | |
function keyframe () { | |
var m | |
var vals = [] | |
var pos = position() | |
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) { | |
vals.push(m[1]) | |
match(/^,\s*/) | |
} | |
if (!vals.length) { return } | |
return markPosition(pos, { | |
type: 'keyframe', | |
values: vals, | |
declarations: declarations() | |
}) | |
} | |
/** | |
* Parse keyframes. | |
*/ | |
function atkeyframes () { | |
var pos = position() | |
var m = match(/^@([-\w]+)?keyframes\s*/) | |
if (!m) { return } | |
var vendor = m[1] | |
// identifier | |
var m = match(/^([-\w]+)\s*/) | |
if (!m) { return error('@keyframes missing name') } | |
var name = m[1] | |
if (!open()) { return error("@keyframes missing '{'") } | |
var frame | |
var frames = comments() | |
while (frame = keyframe()) { | |
frames.push(frame) | |
frames = frames.concat(comments()) | |
} | |
if (!close()) { return error("@keyframes missing '}'") } | |
return markPosition(pos, { | |
type: 'keyframes', | |
name: name, | |
vendor: vendor, | |
keyframes: frames | |
}) | |
} | |
/** | |
* Parse supports. | |
*/ | |
function atsupports () { | |
var pos = position() | |
var m = match(/^@supports *([^{]+)/) | |
if (!m) { return } | |
var supports = trim(m[1]) | |
if (!open()) { return error("@supports missing '{'") } | |
var style = comments().concat(rules()) | |
if (!close()) { return error("@supports missing '}'") } | |
return markPosition(pos, { | |
type: 'supports', | |
supports: supports, | |
rules: style | |
}) | |
} | |
/** | |
* Parse host. | |
*/ | |
function athost () { | |
var pos = position() | |
var m = match(/^@host\s*/) | |
if (!m) { return } | |
if (!open()) { return error("@host missing '{'") } | |
var style = comments().concat(rules()) | |
if (!close()) { return error("@host missing '}'") } | |
return markPosition(pos, { | |
type: 'host', | |
rules: style | |
}) | |
} | |
/** | |
* Parse media. | |
*/ | |
function atmedia () { | |
var pos = position() | |
var m = match(/^@media *([^{]+)/) | |
if (!m) { return } | |
var media = trim(m[1]) | |
if (!open()) { return error("@media missing '{'") } | |
var style = comments().concat(rules()) | |
if (!close()) { return error("@media missing '}'") } | |
return markPosition(pos, { | |
type: 'media', | |
media: media, | |
rules: style | |
}) | |
} | |
/** | |
* Parse custom-media. | |
*/ | |
function atcustommedia () { | |
var pos = position() | |
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/) | |
if (!m) { return } | |
return markPosition(pos, { | |
type: 'custom-media', | |
name: trim(m[1]), | |
media: trim(m[2]) | |
}) | |
} | |
/** | |
* Parse paged media. | |
*/ | |
function atpage () { | |
var pos = position() | |
var m = match(/^@page */) | |
if (!m) { return } | |
var sel = selector() || [] | |
if (!open()) { return error("@page missing '{'") } | |
var decls = comments() | |
// declarations | |
var decl | |
while (decl = declaration()) { | |
decls.push(decl) | |
decls = decls.concat(comments()) | |
} | |
if (!close()) { return error("@page missing '}'") } | |
return markPosition(pos, { | |
type: 'page', | |
selectors: sel, | |
declarations: decls | |
}) | |
} | |
/** | |
* Parse document. | |
*/ | |
function atdocument () { | |
var pos = position() | |
var m = match(/^@([-\w]+)?document *([^{]+)/) | |
if (!m) { return } | |
var vendor = trim(m[1]) | |
var doc = trim(m[2]) | |
if (!open()) { return error("@document missing '{'") } | |
var style = comments().concat(rules()) | |
if (!close()) { return error("@document missing '}'") } | |
return markPosition(pos, { | |
type: 'document', | |
document: doc, | |
vendor: vendor, | |
rules: style | |
}) | |
} | |
/** | |
* Parse font-face. | |
*/ | |
function atfontface () { | |
var pos = position() | |
var m = match(/^@font-face\s*/) | |
if (!m) { return } | |
if (!open()) { return error("@font-face missing '{'") } | |
var decls = comments() | |
// declarations | |
var decl | |
while (decl = declaration()) { | |
decls.push(decl) | |
decls = decls.concat(comments()) | |
} | |
if (!close()) { return error("@font-face missing '}'") } | |
return markPosition(pos, { | |
type: 'font-face', | |
declarations: decls | |
}) | |
} | |
/** | |
* Parse import | |
*/ | |
var atimport = _compileAtrule('import') | |
/** | |
* Parse charset | |
*/ | |
var atcharset = _compileAtrule('charset') | |
/** | |
* Parse namespace | |
*/ | |
var atnamespace = _compileAtrule('namespace') | |
/** | |
* Parse non-block at-rules | |
*/ | |
function _compileAtrule (name) { | |
var re = new RegExp('^@' + name + '\\s*([^;]+);') | |
return function () { | |
var pos = position() | |
var m = match(re) | |
if (!m) { return } | |
var ret = { type: name } | |
ret[name] = m[1].trim() | |
return markPosition(pos, ret) | |
} | |
} | |
/** | |
* Parse at rule. | |
*/ | |
function atrule () { | |
if (css[0] != '@') { return } | |
return atkeyframes() | |
|| atmedia() | |
|| atcustommedia() | |
|| atsupports() | |
|| atimport() | |
|| atcharset() | |
|| atnamespace() | |
|| atdocument() | |
|| atpage() | |
|| athost() | |
|| atfontface() | |
} | |
/** | |
* Parse rule. | |
*/ | |
function rule () { | |
var pos = position() | |
var sel = selector() | |
if (!sel) { return error('selector missing') } | |
comments() | |
return markPosition(pos, { | |
type: 'rule', | |
selectors: sel, | |
declarations: declarations() | |
}) | |
} | |
return stylesheet() | |
} | |
/** | |
* Trim `str`. | |
*/ | |
function trim (str) { | |
return str ? str.trim() : '' | |
} | |
}); | |
var parse$1 = interopDefault(parse); | |
var require$$2$3 = Object.freeze({ | |
default: parse$1 | |
}); | |
var index$12 = createCommonjsModule$$1(function (module) { | |
/** | |
* An Array.prototype.slice.call(arguments) alternative | |
* | |
* @param {Object} args something with a length | |
* @param {Number} slice | |
* @param {Number} sliceEnd | |
* @api public | |
*/ | |
module.exports = function (args, slice, sliceEnd) { | |
var ret = []; | |
var len = args.length; | |
if (0 === len) { return ret; } | |
var start = slice < 0 | |
? Math.max(0, slice + len) | |
: slice || 0; | |
if (sliceEnd !== undefined) { | |
len = sliceEnd < 0 | |
? sliceEnd + len | |
: sliceEnd | |
} | |
while (len-- > start) { | |
ret[len - start] = args[len]; | |
} | |
return ret; | |
} | |
}); | |
var index$13 = interopDefault(index$12); | |
var require$$0$8 = Object.freeze({ | |
default: index$13 | |
}); | |
var index = createCommonjsModule$$1(function (module) { | |
'use strict' | |
/** | |
* Module dependencies | |
*/ | |
var analyze = interopDefault(require$$5) | |
var render = interopDefault(require$$4) | |
var extend = interopDefault(require$$3$2) | |
var parse = interopDefault(require$$2$3) | |
var hash = interopDefault(require$$0) | |
var slice = interopDefault(require$$0$8) | |
/** | |
* Browser | |
*/ | |
var browser = typeof document !== 'undefined' | |
/** | |
* Include inserted if we're in a | |
* browser environment | |
*/ | |
var head = browser && (document.head || document.getElementsByTagName('head')[0]) | |
/** | |
* Export `Afro` | |
*/ | |
module.exports = Afro | |
/** | |
* Initialize `Afro` | |
*/ | |
function Afro () { | |
var state = compose(slice(arguments)) | |
var injected = false | |
var output = null | |
var cache = {} | |
function compile (asts) { | |
if (asts) { return render(asts, state.map) } | |
if (output !== null) { return output } | |
output = render(state.asts, state.map) | |
return output | |
} | |
function inject () { | |
if (!browser || !head || injected || output !== null) { return } | |
var style = document.querySelector('style[afro]') | |
// create the style element if it doesn't exist already | |
if (!style) { | |
style = document.createElement('style') | |
style.setAttribute('afro', 'afro') | |
style.type = 'text/css' | |
head.appendChild(style) | |
} else if (style.hasAttribute('static')) { | |
return | |
} | |
// filter out any ast that's previously been injected | |
var asts = state.asts.filter(function (ast) { | |
return !ast.injected | |
}) | |
// compile the source | |
var src = compile() | |
// append styles | |
if (style.styleSheet) { | |
// IE | |
src = style.textContent + src | |
style.styleSheet.cssText = src | |
} else { | |
// the world | |
var node = style.firstChild | |
if (node) { | |
node.nodeValue = node.nodeValue + src | |
} else { | |
node = document.createTextNode(src) | |
style.appendChild(node) | |
} | |
} | |
// set all the asts that we compiled as injected | |
asts = asts.map(function (ast) { | |
ast.injected = true | |
}) | |
injected = true | |
} | |
function compose (args) { | |
return args.reduce(function (state, arg) { | |
var json = arg.toJSON ? arg.toJSON() : arg | |
if (json.asts && json.map) { | |
state.asts = state.asts.concat(json.asts) | |
state.map = extend(state.map, json.map) | |
return state | |
} | |
var ast = parse(arg).stylesheet | |
var classes = analyze(ast) | |
var id = hash(classes) | |
state.asts = state.asts.concat({ | |
rules: ast.rules, | |
injected: false, | |
id: id | |
}) | |
for (var name in classes) { | |
state.map[name] = state.map[name] || {} | |
state.map[name][id] = classes[name] | |
} | |
return state | |
}, { asts: [], map: {} }) | |
} | |
// css | |
function css () { | |
if (!arguments.length) { return compile() } | |
return Afro.apply(null, [css].concat(slice(arguments))) | |
} | |
// methods | |
css.toJSON = function () { return state; } | |
css.toString = compile | |
// define the getters | |
var loop = function ( name ) { | |
Object.defineProperty(css, name, { | |
get: function () { | |
// We're going to block render | |
// until the style is injected | |
// to prevent a FOUC | |
inject() | |
return classname(name) | |
} | |
}) | |
}; | |
for (var name in state.map) { loop( name ); } | |
/** | |
* Classname helper | |
*/ | |
function classname (selector) { | |
if (cache[selector]) { return cache[selector] } | |
var ids = state.map[selector] | |
if (!ids) { return } | |
var keys = Object.keys(ids) | |
if (keys.length > 1 && !same(keys, ids)) { | |
throw unsafe(selector, keys) | |
} | |
return cache[selector] = ids[keys[0]] | |
} | |
return css | |
} | |
/** | |
* Unsafe error | |
*/ | |
function unsafe (name, keys) { | |
return new Error(("\"" + name + "\" is unsafe to use because it provides different styles in " + (keys.length) + " different stylesheets")) | |
} | |
/** | |
* Check for sameness | |
*/ | |
function same (keys, ids) { | |
for (var i = 1, len = keys.length; i < len; i++) { | |
if (ids[keys[i]] !== ids[keys[i - 1]]) { return false } | |
} | |
return true | |
} | |
}); | |
var index$1 = interopDefault(index); | |
return index$1; | |
})); | |
}); | |
/** | |
* Export `flatten` | |
*/ | |
var flatten_1 = flatten$2 | |
/** | |
* Shallow Flatten | |
*/ | |
function flatten$2 (array) { | |
var length = array ? array.length : 0 | |
var result = [] | |
var index = -1 | |
while (++index < length) { | |
result = result.concat(array[index]) | |
} | |
return result | |
} | |
var toString$1 = Object.prototype.toString; | |
var index$44 = function (fn) { | |
if (typeof fn !== 'function') { | |
return false; | |
} | |
return (fn.constructor && fn.constructor.name === 'GeneratorFunction') || | |
toString$1.call(fn) === '[object GeneratorFunction]'; | |
}; | |
/** | |
* Export `Context` | |
*/ | |
var context = Context$1 | |
/** | |
* Initialize `Context` | |
*/ | |
function Context$1 (state) { | |
state = state || {} | |
var context = {} | |
// getter | |
Object.defineProperty(context, 'name', { | |
get: function () { return state.name } | |
}) | |
return context | |
} | |
/** | |
* slice() reference. | |
*/ | |
var slice$2 = Array.prototype.slice; | |
/** | |
* Expose `co`. | |
*/ | |
var index$46 = co$1['default'] = co$1.co = co$1; | |
/** | |
* Wrap the given generator `fn` into a | |
* function that returns a promise. | |
* This is a separate function so that | |
* every `co()` call doesn't create a new, | |
* unnecessary closure. | |
* | |
* @param {GeneratorFunction} fn | |
* @return {Function} | |
* @api public | |
*/ | |
co$1.wrap = function (fn) { | |
createPromise.__generatorFunction__ = fn; | |
return createPromise; | |
function createPromise() { | |
return co$1.call(this, fn.apply(this, arguments)); | |
} | |
}; | |
/** | |
* Execute the generator function or a generator | |
* and return a promise. | |
* | |
* @param {Function} fn | |
* @return {Promise} | |
* @api public | |
*/ | |
function co$1(gen) { | |
var ctx = this; | |
var args = slice$2.call(arguments, 1) | |
// we wrap everything in a promise to avoid promise chaining, | |
// which leads to memory leak errors. | |
// see https://github.com/tj/co/issues/180 | |
return new Promise(function(resolve, reject) { | |
if (typeof gen === 'function') { gen = gen.apply(ctx, args); } | |
if (!gen || typeof gen.next !== 'function') { return resolve(gen); } | |
onFulfilled(); | |
/** | |
* @param {Mixed} res | |
* @return {Promise} | |
* @api private | |
*/ | |
function onFulfilled(res) { | |
var ret; | |
try { | |
ret = gen.next(res); | |
} catch (e) { | |
return reject(e); | |
} | |
next(ret); | |
} | |
/** | |
* @param {Error} err | |
* @return {Promise} | |
* @api private | |
*/ | |
function onRejected(err) { | |
var ret; | |
try { | |
ret = gen.throw(err); | |
} catch (e) { | |
return reject(e); | |
} | |
next(ret); | |
} | |
/** | |
* Get the next value in the generator, | |
* return a promise. | |
* | |
* @param {Object} ret | |
* @return {Promise} | |
* @api private | |
*/ | |
function next(ret) { | |
if (ret.done) { return resolve(ret.value); } | |
var value = toPromise.call(ctx, ret.value); | |
if (value && isPromise(value)) { return value.then(onFulfilled, onRejected); } | |
return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, ' | |
+ 'but the following object was passed: "' + String(ret.value) + '"')); | |
} | |
}); | |
} | |
/** | |
* Convert a `yield`ed value into a promise. | |
* | |
* @param {Mixed} obj | |
* @return {Promise} | |
* @api private | |
*/ | |
function toPromise(obj) { | |
if (!obj) { return obj; } | |
if (isPromise(obj)) { return obj; } | |
if (isGeneratorFunction(obj) || isGenerator(obj)) { return co$1.call(this, obj); } | |
if ('function' == typeof obj) { return thunkToPromise.call(this, obj); } | |
if (Array.isArray(obj)) { return arrayToPromise.call(this, obj); } | |
if (isObject$3(obj)) { return objectToPromise.call(this, obj); } | |
return obj; | |
} | |
/** | |
* Convert a thunk to a promise. | |
* | |
* @param {Function} | |
* @return {Promise} | |
* @api private | |
*/ | |
function thunkToPromise(fn) { | |
var ctx = this; | |
return new Promise(function (resolve, reject) { | |
fn.call(ctx, function (err, res) { | |
if (err) { return reject(err); } | |
if (arguments.length > 2) { res = slice$2.call(arguments, 1); } | |
resolve(res); | |
}); | |
}); | |
} | |
/** | |
* Convert an array of "yieldables" to a promise. | |
* Uses `Promise.all()` internally. | |
* | |
* @param {Array} obj | |
* @return {Promise} | |
* @api private | |
*/ | |
function arrayToPromise(obj) { | |
return Promise.all(obj.map(toPromise, this)); | |
} | |
/** | |
* Convert an object of "yieldables" to a promise. | |
* Uses `Promise.all()` internally. | |
* | |
* @param {Object} obj | |
* @return {Promise} | |
* @api private | |
*/ | |
function objectToPromise(obj){ | |
var this$1 = this; | |
var results = new obj.constructor(); | |
var keys = Object.keys(obj); | |
var promises = []; | |
for (var i = 0; i < keys.length; i++) { | |
var key = keys[i]; | |
var promise = toPromise.call(this$1, obj[key]); | |
if (promise && isPromise(promise)) { defer(promise, key); } | |
else { results[key] = obj[key]; } | |
} | |
return Promise.all(promises).then(function () { | |
return results; | |
}); | |
function defer(promise, key) { | |
// predefine the key in the result | |
results[key] = undefined; | |
promises.push(promise.then(function (res) { | |
results[key] = res; | |
})); | |
} | |
} | |
/** | |
* Check if `obj` is a promise. | |
* | |
* @param {Object} obj | |
* @return {Boolean} | |
* @api private | |
*/ | |
function isPromise(obj) { | |
return 'function' == typeof obj.then; | |
} | |
/** | |
* Check if `obj` is a generator. | |
* | |
* @param {Mixed} obj | |
* @return {Boolean} | |
* @api private | |
*/ | |
function isGenerator(obj) { | |
return 'function' == typeof obj.next && 'function' == typeof obj.throw; | |
} | |
/** | |
* Check if `obj` is a generator function. | |
* | |
* @param {Mixed} obj | |
* @return {Boolean} | |
* @api private | |
*/ | |
function isGeneratorFunction(obj) { | |
var constructor = obj.constructor; | |
if (!constructor) { return false; } | |
if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) { return true; } | |
return isGenerator(constructor.prototype); | |
} | |
/** | |
* Check for plain object. | |
* | |
* @param {Mixed} val | |
* @return {Boolean} | |
* @api private | |
*/ | |
function isObject$3(val) { | |
return Object == val.constructor; | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var generator = index$44 | |
var Context = context | |
var co = index$46 | |
/** | |
* Export `Compose` | |
*/ | |
var compose_1 = compose$2 | |
/** | |
* Compose | |
*/ | |
function compose$2 (mw) { | |
return function (action, ctx) { | |
var index = -1 | |
function dispatch (p) { | |
if (p <= index) { throw new TypeError('`next()` called multiple times') } | |
index = p | |
var ctx, fn | |
if (mw[p]) { | |
ctx = new Context(mw[p].state) | |
fn = generator(mw[p].fn) | |
? co.wrap(mw[p].fn) | |
: mw[p].fn | |
} else { | |
fn = ident | |
ctx = new Context() | |
} | |
return new Promise(function (resolve) { | |
return resolve(fn(action, function next () { | |
return dispatch(p + 1) | |
}, ctx)) | |
}) | |
} | |
return dispatch(0) | |
} | |
} | |
/** | |
* Identity | |
*/ | |
function ident (i) { | |
return i | |
} | |
/** | |
* Export `isObject` | |
*/ | |
var isObject_1 = isObject$5 | |
/** | |
* Check if the value is an object | |
* | |
* @param {Mixed} object | |
* @return {Boolean} | |
*/ | |
function isObject$5 (mixed) { | |
return Object.prototype.toString.call(mixed) === '[object Object]' | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var isObject$4 = isObject_1 | |
var keys$2 = Object.keys | |
/** | |
* Whitelisted keys | |
*/ | |
var whitelist$1 = { | |
type: 1, | |
meta: 1, | |
error: 1, | |
payload: 1 | |
} | |
/** | |
* Export `isFSA` | |
*/ | |
var isFsa$2 = isFSA$3 | |
/** | |
* Check if the value is an action | |
* | |
* Spec: https://github.com/acdlite/flux-standard-action#actions | |
* | |
* @param {Mixed} value | |
* @return {Boolean} | |
*/ | |
function isFSA$3 (value) { | |
// value must be an object and have a type | |
if (!isObject$4(value) || !value.type) { return false } | |
// if any properties on the object are | |
// not part of the whitelist fail then | |
// return false | |
var props = keys$2(value) | |
for (var i = 0, prop; (prop = props[i]); i++) { | |
if (!whitelist$1[prop]) { return false } | |
} | |
// lastly check that if value.error is "true" | |
// that our payload is error-like | |
if (value.error === true) { | |
return value.payload.message && value.payload.name | |
} | |
return true | |
} | |
/*! | |
* noncharacters <https://github.com/jonschlinkert/noncharacters> | |
* | |
* Copyright (c) 2015, Jon Schlinkert. | |
* Licensed under the MIT License. | |
*/ | |
var index$50 = [ | |
'\uFFFF', | |
'\uFFFE', | |
'\uFDD1', | |
'\uFDD2', | |
'\uFDD3', | |
'\uFDD4', | |
'\uFDD5', | |
'\uFDD6', | |
'\uFDD7', | |
'\uFDD8', | |
'\uFDD9', | |
'\uFDDA', | |
'\uFDDB', | |
'\uFDDC', | |
'\uFDDD', | |
'\uFDDE', | |
'\uFDDF', | |
'\uFDE0', | |
'\uFDE1', | |
'\uFDE2', | |
'\uFDE3', | |
'\uFDE4', | |
'\uFDE5', | |
'\uFDE6', | |
'\uFDE7', | |
'\uFDE8', | |
'\uFDE9', | |
'\uFDEA', | |
'\uFDEB', | |
'\uFDEC', | |
'\uFDED', | |
'\uFDEE', | |
'\uFDEF' | |
]; | |
var nonchar = index$50[0]; | |
function split$1(str, ch) { | |
if (typeof str !== 'string') { | |
throw new TypeError('expected a string.'); | |
} | |
ch = ch || '.'; | |
var esc = str.split('\\' + ch).join(nonchar); | |
var segs = esc.split(ch); | |
var len = segs.length, i = -1; | |
var res = []; | |
while (++i < len) { | |
res.push(segs[i].split(nonchar).join(ch)); | |
} | |
return res; | |
} | |
/** | |
* expose `split` | |
*/ | |
var index$48 = split$1; | |
/** | |
* Module Dependencies | |
*/ | |
var split = index$48 | |
/** | |
* Export `Tree` | |
*/ | |
var tree$3 = Tree$2 | |
/** | |
* Create a tree of references | |
* | |
* @return {Function} | |
*/ | |
function Tree$2 (initial) { | |
var data = initial || {} | |
function tree (key, value) { | |
return arguments.length === 2 | |
? set(key, value) | |
: get(key) | |
} | |
function set (key, value) { | |
data[key] = value | |
} | |
function get (key) { | |
return data[key] | |
} | |
tree.up = function up (key) { | |
var parts = split(key, ':') | |
var parent = key | |
var keys = [] | |
while (parts.length) { | |
data[parent] && keys.push(data[parent]) | |
parts.pop() | |
parent = parts.join(':') | |
} | |
return keys.reverse() | |
} | |
tree.data = data | |
return tree | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var toString$2 = Object.prototype.toString | |
/** | |
* Export `isError` | |
*/ | |
var isError_1 = isError$3 | |
/** | |
* Check if the value is an Error | |
* | |
* @param {Mixed} mixed | |
* @return {Boolean} | |
*/ | |
function isError$3 (mixed) { | |
return toString$2.call(mixed) === '[object Error]' || | |
mixed instanceof Error | |
} | |
/** | |
* Module Dependencies | |
*/ | |
var assign$2 = index$6 | |
var isObject$6 = isObject_1 | |
var isError$2 = isError_1 | |
/** | |
* Export `fold` | |
*/ | |
var fold_1 = fold$1 | |
/** | |
* Fold the arguments into an action | |
*/ | |
function fold$1 (action) { | |
if (action.length === 1 && isObject$6(action[0])) { | |
action[0].payload = action[0].payload | |
return isError$2(action[0].payload) | |
? assign$2(action[0], error(action[0].payload)) | |
: action[0] | |
} else { | |
return action.reduce(folder, {}) | |
} | |
} | |
function folder (action, value) { | |
if (typeof value === 'string' && !action.type) { | |
action.type = value | |
action.payload = null | |
} else if (isObject$6(value)) { | |
action.payload = assign$2(action.payload || {}, value) | |
} else if (isError$2(value)) { | |
action = assign$2(action, error(value)) | |
} else { | |
action.payload = value | |
} | |
return action | |
} | |
/** | |
* Create an object from an error | |
*/ | |
function error (err) { | |
return { | |
error: true, | |
payload: { | |
message: err.message, | |
stack: err.stack, | |
name: err.name, | |
code: err.code | |
} | |
} | |
} | |
/** | |
* Module dependencies | |
*/ | |
var assign$1 = index$6 | |
var flatten$1 = flatten_1 | |
var compose$1 = compose_1 | |
var isFSA$2 = isFsa$2 | |
var slice$1 = index$8 | |
var Tree$1 = tree$3 | |
var fold = fold_1 | |
/** | |
* Export `Alley` | |
*/ | |
var alley = Alley | |
/** | |
* Initialize `Alley` | |
*/ | |
function Alley () { | |
var tree = Tree$1(merge(slice$1(arguments))) | |
var send = Send(tree) | |
var on = On(tree) | |
var use = Use({ | |
send: send, | |
on: on | |
}) | |
return { | |
send: send, | |
use: use, | |
on: on, | |
alley: true, | |
tree: tree | |
} | |
} | |
/** | |
* Send a value | |
*/ | |
function Send (tree) { | |
return function send (payload) { | |
var action = fold(slice$1(arguments)) | |
if (!isFSA$2(action)) { throw nonstandard(action) } | |
var root = tree.up('root') || [] | |
var parents = tree.up(action.type) || [] | |
var fn = compose$1(flatten$1(root.concat(parents))) | |
return fn(action).then(function () { return action; }) | |
} | |
} | |
/** | |
* On a function | |
*/ | |
function On (tree) { | |
return function on (name, fn) { | |
if (arguments.length === 1) { | |
fn = name | |
name = 'root' | |
} | |
var fns = tree(name) || [] | |
fns = fns.concat({ | |
fn: fn, | |
state: { | |
name: name | |
} | |
}) | |
tree(name, fns) | |
} | |
} | |
/** | |
* Use is for plugins | |
*/ | |
function Use (api) { | |
function use (fn) { fn(api) } | |
api.use = use | |
return use | |
} | |
/** | |
* Merge the incoming data | |
*/ | |
function merge (alleys) { | |
return alleys.reduce(function (data, alley) { | |
return assign$1(data, alley.tree.data) | |
}, {}) | |
} | |
/** | |
* Non-standard | |
* | |
* @param {Mixed} action | |
* @return {Error} | |
*/ | |
function nonstandard (action) { | |
return new Error('resolved action (' + JSON.stringify(action) + ') is not the correct format. Please refer to the spec: https://github.com/acdlite/flux-standard-action#actions') | |
} | |
var preact = createCommonjsModule(function (module, exports) { | |
!function(global, factory) { | |
'object' == typeof exports && 'undefined' != typeof module ? factory(exports) : 'function' == typeof define && define.amd ? define([ 'exports' ], factory) : factory(global.preact = global.preact || {}); | |
}(commonjsGlobal, function(exports) { | |
function VNode(nodeName, attributes, children) { | |
this.nodeName = nodeName; | |
this.attributes = attributes; | |
this.children = children; | |
this.key = attributes && attributes.key; | |
} | |
function extend(obj, props) { | |
if (props) { for (var i in props) { if (void 0 !== props[i]) { obj[i] = props[i]; } } } | |
return obj; | |
} | |
function clone(obj) { | |
return extend({}, obj); | |
} | |
function delve(obj, key) { | |
for (var p = key.split('.'), i = 0; i < p.length && obj; i++) { obj = obj[p[i]]; } | |
return obj; | |
} | |
function toArray(obj, offset) { | |
return [].slice.call(obj, offset); | |
} | |
function isFunction(obj) { | |
return 'function' == typeof obj; | |
} | |
function isString(obj) { | |
return 'string' == typeof obj; | |
} | |
function empty(x) { | |
return void 0 === x || null === x; | |
} | |
function falsey(value) { | |
return value === !1 || empty(value); | |
} | |
function hashToClassName(c) { | |
var str = ''; | |
for (var prop in c) { if (c[prop]) { | |
if (str) { str += ' '; } | |
str += prop; | |
} } | |
return str; | |
} | |
function h(nodeName, attributes, firstChild) { | |
var arguments$1 = arguments; | |
var children, arr, lastSimple, len = arguments.length; | |
if (len > 2) { | |
var type = typeof firstChild; | |
if (3 === len && 'object' !== type && 'function' !== type) { | |
if (!falsey(firstChild)) { children = [ String(firstChild) ]; } | |
} else { | |
children = []; | |
for (var i = 2; i < len; i++) { | |
var _p = arguments$1[i]; | |
if (!falsey(_p)) { | |
if (_p.join) { arr = _p; } else { (arr = SHARED_TEMP_ARRAY)[0] = _p; } | |
for (var j = 0; j < arr.length; j++) { | |
var child = arr[j], simple = !(falsey(child) || isFunction(child) || child instanceof VNode); | |
if (simple && !isString(child)) { child = String(child); } | |
if (simple && lastSimple) { children[children.length - 1] += child; } else if (!falsey(child)) { | |
children.push(child); | |
lastSimple = simple; | |
} | |
} | |
} else { } | |
} | |
} | |
} else if (attributes && attributes.children) { return h(nodeName, attributes, attributes.children); } | |
if (attributes) { | |
if (attributes.children) { delete attributes.children; } | |
if (!isFunction(nodeName)) { | |
if ('className' in attributes) { | |
attributes.class = attributes.className; | |
delete attributes.className; | |
} | |
lastSimple = attributes.class; | |
if (lastSimple && !isString(lastSimple)) { attributes.class = hashToClassName(lastSimple); } | |
} | |
} | |
var p = new VNode(nodeName, attributes || void 0, children); | |
if (options.vnode) { options.vnode(p); } | |
return p; | |
} | |
function cloneElement(vnode, props) { | |
return h(vnode.nodeName, extend(clone(vnode.attributes), props), arguments.length > 2 ? toArray(arguments, 2) : vnode.children); | |
} | |
function createLinkedState(component, key, eventPath) { | |
var path = key.split('.'), p0 = path[0]; | |
return function(e) { | |
var _component$setState; | |
var v, i, t = e && e.currentTarget || this, s = component.state, obj = s; | |
if (isString(eventPath)) { v = delve(e, eventPath); } else { v = t.nodeName ? (t.nodeName + t.type).match(/^input(check|rad)/i) ? t.checked : t.value : e; } | |
if (path.length > 1) { | |
for (i = 0; i < path.length - 1; i++) { obj = obj[path[i]] || (obj[path[i]] = {}); } | |
obj[path[i]] = v; | |
v = s[p0]; | |
} | |
component.setState((_component$setState = {}, _component$setState[p0] = v, _component$setState)); | |
}; | |
} | |
function enqueueRender(component) { | |
if (1 === items.push(component)) { (options.debounceRendering || defer)(rerender); } | |
} | |
function rerender() { | |
if (items.length) { | |
var p, currentItems = items; | |
items = itemsOffline; | |
itemsOffline = currentItems; | |
while (p = currentItems.pop()) { if (p._dirty) { renderComponent(p); } } | |
} | |
} | |
function isFunctionalComponent(vnode) { | |
var nodeName = vnode && vnode.nodeName; | |
return nodeName && isFunction(nodeName) && !(nodeName.prototype && nodeName.prototype.render); | |
} | |
function buildFunctionalComponent(vnode, context) { | |
return vnode.nodeName(getNodeProps(vnode), context || EMPTY); | |
} | |
function ensureNodeData(node, data) { | |
return node[ATTR_KEY] || (node[ATTR_KEY] = data || {}); | |
} | |
function getNodeType(node) { | |
if (node instanceof Text) { return 3; } | |
if (node instanceof Element) { return 1; } else { return 0; } | |
} | |
function removeNode(node) { | |
var p = node.parentNode; | |
if (p) { p.removeChild(node); } | |
} | |
function setAccessor(node, name, value, old, isSvg) { | |
ensureNodeData(node)[name] = value; | |
if ('key' !== name && 'children' !== name && 'innerHTML' !== name) { if ('class' === name && !isSvg) { node.className = value || ''; } else if ('style' === name) { | |
if (!value || isString(value) || isString(old)) { node.style.cssText = value || ''; } | |
if (value && 'object' == typeof value) { | |
if (!isString(old)) { for (var i in old) { if (!(i in value)) { node.style[i] = ''; } } } | |
for (var i in value) { node.style[i] = 'number' == typeof value[i] && !NON_DIMENSION_PROPS[i] ? value[i] + 'px' : value[i]; } | |
} | |
} else if ('dangerouslySetInnerHTML' === name) { | |
if (value) { node.innerHTML = value.__html; } | |
} else if ('o' == name[0] && 'n' == name[1]) { | |
var l = node._listeners || (node._listeners = {}); | |
name = toLowerCase(name.substring(2)); | |
if (value) { | |
if (!l[name]) { node.addEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]); } | |
} else if (l[name]) { node.removeEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]); } | |
l[name] = value; | |
} else if ('list' !== name && 'type' !== name && !isSvg && name in node) { | |
setProperty(node, name, empty(value) ? '' : value); | |
if (falsey(value)) { node.removeAttribute(name); } | |
} else { | |
var ns = isSvg && name.match(/^xlink\:?(.+)/); | |
if (falsey(value)) { if (ns) { node.removeAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1])); } else { node.removeAttribute(name); } } else if ('object' != typeof value && !isFunction(value)) { if (ns) { node.setAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1]), value); } else { node.setAttribute(name, value); } } | |
} } | |
} | |
function setProperty(node, name, value) { | |
try { | |
node[name] = value; | |
} catch (e) {} | |
} | |
function eventProxy(e) { | |
return this._listeners[e.type](options.event && options.event(e) || e); | |
} | |
function getRawNodeAttributes(node) { | |
var attrs = {}; | |
for (var i = node.attributes.length; i--; ) { attrs[node.attributes[i].name] = node.attributes[i].value; } | |
return attrs; | |
} | |
function isSameNodeType(node, vnode) { | |
if (isString(vnode)) { return 3 === getNodeType(node); } | |
if (isString(vnode.nodeName)) { return isNamedNode(node, vnode.nodeName); } | |
if (isFunction(vnode.nodeName)) { return node._componentConstructor === vnode.nodeName || isFunctionalComponent(vnode); } else { } | |
} | |
function isNamedNode(node, nodeName) { | |
return node.normalizedNodeName === nodeName || toLowerCase(node.nodeName) === toLowerCase(nodeName); | |
} | |
function getNodeProps(vnode) { | |
var defaultProps = vnode.nodeName.defaultProps, props = clone(defaultProps || vnode.attributes); | |
if (defaultProps) { extend(props, vnode.attributes); } | |
if (vnode.children) { props.children = vnode.children; } | |
return props; | |
} | |
function collectNode(node) { | |
removeNode(node); | |
if (1 === getNodeType(node)) { | |
cleanNode(node); | |
var name = toLowerCase(node.nodeName), list = nodes[name]; | |
if (list) { list.push(node); } else { nodes[name] = [ node ]; } | |
} | |
} | |
function createNode(nodeName, isSvg) { | |
var name = toLowerCase(nodeName), node = nodes[name] && nodes[name].pop() || (isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName)); | |
ensureNodeData(node); | |
node.normalizedNodeName = name; | |
return node; | |
} | |
function cleanNode(node) { | |
ensureNodeData(node, getRawNodeAttributes(node)); | |
node._component = node._componentConstructor = null; | |
} | |
function flushMounts() { | |
var c; | |
while (c = mounts.pop()) { if (c.componentDidMount) { c.componentDidMount(); } } | |
} | |
function diff(dom, vnode, context, mountAll, parent, rootComponent) { | |
diffLevel++; | |
var ret = idiff(dom, vnode, context, mountAll, rootComponent); | |
if (parent && ret.parentNode !== parent) { parent.appendChild(ret); } | |
if (!--diffLevel) { flushMounts(); } | |
return ret; | |
} | |
function idiff(dom, vnode, context, mountAll, rootComponent) { | |
var originalAttributes = vnode && vnode.attributes; | |
while (isFunctionalComponent(vnode)) { vnode = buildFunctionalComponent(vnode, context); } | |
if (empty(vnode)) { | |
vnode = ''; | |
if (rootComponent) { | |
if (dom) { | |
if (8 === dom.nodeType) { return dom; } | |
recollectNodeTree(dom); | |
} | |
return document.createComment(vnode); | |
} | |
} | |
if (isString(vnode)) { | |
if (dom) { | |
if (3 === getNodeType(dom) && dom.parentNode) { | |
dom.nodeValue = vnode; | |
return dom; | |
} | |
recollectNodeTree(dom); | |
} | |
return document.createTextNode(vnode); | |
} | |
var out = dom, nodeName = vnode.nodeName, prevSvgMode = isSvgMode; | |
if (isFunction(nodeName)) { return buildComponentFromVNode(dom, vnode, context, mountAll); } | |
if (!isString(nodeName)) { nodeName = String(nodeName); } | |
isSvgMode = 'svg' === nodeName ? !0 : 'foreignObject' === nodeName ? !1 : isSvgMode; | |
if (!dom) { out = createNode(nodeName, isSvgMode); } else if (!isNamedNode(dom, nodeName)) { | |
out = createNode(nodeName, isSvgMode); | |
while (dom.firstChild) { out.appendChild(dom.firstChild); } | |
recollectNodeTree(dom); | |
} | |
if (vnode.children && 1 === vnode.children.length && 'string' == typeof vnode.children[0] && 1 === out.childNodes.length && out.firstChild instanceof Text) { out.firstChild.nodeValue = vnode.children[0]; } else if (vnode.children || out.firstChild) { innerDiffNode(out, vnode.children, context, mountAll); } | |
diffAttributes(out, vnode.attributes); | |
if (originalAttributes && originalAttributes.ref) { (out[ATTR_KEY].ref = originalAttributes.ref)(out); } | |
isSvgMode = prevSvgMode; | |
return out; | |
} | |
function innerDiffNode(dom, vchildren, context, mountAll) { | |
var j, c, vchild, child, originalChildren = dom.childNodes, children = [], keyed = {}, keyedLen = 0, min = 0, len = originalChildren.length, childrenLen = 0, vlen = vchildren && vchildren.length; | |
if (len) { for (var i = 0; i < len; i++) { | |
var _child = originalChildren[i], key = vlen ? (c = _child._component) ? c.__key : (c = _child[ATTR_KEY]) ? c.key : null : null; | |
if (key || 0 === key) { | |
keyedLen++; | |
keyed[key] = _child; | |
} else { children[childrenLen++] = _child; } | |
} } | |
if (vlen) { for (var i = 0; i < vlen; i++) { | |
vchild = vchildren[i]; | |
child = null; | |
var key = vchild.key; | |
if (!empty(key)) { | |
if (keyedLen && key in keyed) { | |
child = keyed[key]; | |
keyed[key] = void 0; | |
keyedLen--; | |
} | |
} else if (!child && min < childrenLen) { | |
for (j = min; j < childrenLen; j++) { | |
c = children[j]; | |
if (c && isSameNodeType(c, vchild)) { | |
child = c; | |
children[j] = void 0; | |
if (j === childrenLen - 1) { childrenLen--; } | |
if (j === min) { min++; } | |
break; | |
} | |
} | |
if (!child && min < childrenLen && isFunction(vchild.nodeName) && mountAll) { | |
child = children[min]; | |
children[min++] = void 0; | |
} | |
} | |
child = idiff(child, vchild, context, mountAll); | |
if (child !== originalChildren[i]) { dom.insertBefore(child, originalChildren[i] || null); } | |
} } | |
if (keyedLen) { for (var i in keyed) { if (keyed[i]) { children[min = childrenLen++] = keyed[i]; } } } | |
if (min < childrenLen) { removeOrphanedChildren(children); } | |
} | |
function removeOrphanedChildren(children, unmountOnly) { | |
for (var i = children.length; i--; ) { | |
var child = children[i]; | |
if (child) { recollectNodeTree(child, unmountOnly); } | |
} | |
} | |
function recollectNodeTree(node, unmountOnly) { | |
var component = node._component; | |
if (component) { unmountComponent(component, !unmountOnly); } else { | |
if (node[ATTR_KEY] && node[ATTR_KEY].ref) { node[ATTR_KEY].ref(null); } | |
if (!unmountOnly) { collectNode(node); } | |
if (node.childNodes && node.childNodes.length) { removeOrphanedChildren(node.childNodes, unmountOnly); } | |
} | |
} | |
function diffAttributes(dom, attrs) { | |
var old = dom[ATTR_KEY] || getRawNodeAttributes(dom); | |
for (var _name in old) { if (!(attrs && _name in attrs)) { setAccessor(dom, _name, null, old[_name], isSvgMode); } } | |
if (attrs) { for (var _name2 in attrs) { if (!(_name2 in old) || attrs[_name2] != old[_name2] || ('value' === _name2 || 'checked' === _name2) && attrs[_name2] != dom[_name2]) { setAccessor(dom, _name2, attrs[_name2], old[_name2], isSvgMode); } } } | |
} | |
function collectComponent(component) { | |
var name = component.constructor.name, list = components[name]; | |
if (list) { list.push(component); } else { components[name] = [ component ]; } | |
} | |
function createComponent(Ctor, props, context) { | |
var inst = new Ctor(props, context), list = components[Ctor.name]; | |
inst.props = props; | |
inst.context = context; | |
if (list) { for (var i = list.length; i--; ) { if (list[i].constructor === Ctor) { | |
inst.nextBase = list[i].nextBase; | |
list.splice(i, 1); | |
break; | |
} } } | |
return inst; | |
} | |
function triggerComponentRender(component) { | |
if (!component._dirty) { | |
component._dirty = !0; | |
enqueueRender(component); | |
} | |
} | |
function setComponentProps(component, props, opts, context, mountAll) { | |
var b = component.base; | |
if (!component._disableRendering) { | |
component._disableRendering = !0; | |
if (component.__ref = props.ref) { delete props.ref; } | |
if (component.__key = props.key) { delete props.key; } | |
if (empty(b) || mountAll) { | |
if (component.componentWillMount) { component.componentWillMount(); } | |
} else if (component.componentWillReceiveProps) { component.componentWillReceiveProps(props, context); } | |
if (context && context !== component.context) { | |
if (!component.prevContext) { component.prevContext = component.context; } | |
component.context = context; | |
} | |
if (!component.prevProps) { component.prevProps = component.props; } | |
component.props = props; | |
component._disableRendering = !1; | |
if (0 !== opts) { if (1 === opts || options.syncComponentUpdates !== !1 || !b) { renderComponent(component, 1, mountAll); } else { triggerComponentRender(component); } } | |
if (component.__ref) { component.__ref(component); } | |
} | |
} | |
function renderComponent(component, opts, mountAll) { | |
if (!component._disableRendering) { | |
var skip, rendered, props = component.props, state = component.state, context = component.context, previousProps = component.prevProps || props, previousState = component.prevState || state, previousContext = component.prevContext || context, isUpdate = component.base, initialBase = isUpdate || component.nextBase, initialChildComponent = component._component; | |
if (isUpdate) { | |
component.props = previousProps; | |
component.state = previousState; | |
component.context = previousContext; | |
if (2 !== opts && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === !1) { skip = !0; } else if (component.componentWillUpdate) { component.componentWillUpdate(props, state, context); } | |
component.props = props; | |
component.state = state; | |
component.context = context; | |
} | |
component.prevProps = component.prevState = component.prevContext = component.nextBase = null; | |
component._dirty = !1; | |
if (!skip) { | |
if (component.render) { rendered = component.render(props, state, context); } | |
if (component.getChildContext) { context = extend(clone(context), component.getChildContext()); } | |
while (isFunctionalComponent(rendered)) { rendered = buildFunctionalComponent(rendered, context); } | |
var toUnmount, base, childComponent = rendered && rendered.nodeName; | |
if (isFunction(childComponent) && childComponent.prototype.render) { | |
var inst = initialChildComponent, childProps = getNodeProps(rendered); | |
if (inst && inst.constructor === childComponent) { setComponentProps(inst, childProps, 1, context); } else { | |
toUnmount = inst; | |
inst = createComponent(childComponent, childProps, context); | |
inst.nextBase = inst.nextBase || mountAll && initialBase; | |
inst._parentComponent = component; | |
component._component = inst; | |
setComponentProps(inst, childProps, 0, context); | |
renderComponent(inst, 1); | |
} | |
base = inst.base; | |
} else { | |
var cbase = initialBase; | |
toUnmount = initialChildComponent; | |
if (toUnmount) { cbase = component._component = null; } | |
if (initialBase || 1 === opts) { | |
if (cbase) { cbase._component = null; } | |
base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, !0); | |
} | |
} | |
if (initialBase && base !== initialBase) { | |
var baseParent = initialBase.parentNode; | |
if (baseParent && base !== baseParent) { baseParent.replaceChild(base, initialBase); } | |
if (!toUnmount && component._parentComponent) { | |
initialBase._component = null; | |
recollectNodeTree(initialBase); | |
} | |
} | |
if (toUnmount) { unmountComponent(toUnmount, base !== initialBase); } | |
component.base = base; | |
if (base) { | |
var componentRef = component, t = component; | |
while (t = t._parentComponent) { componentRef = t; } | |
base._component = componentRef; | |
base._componentConstructor = componentRef.constructor; | |
} | |
} | |
if (!isUpdate || mountAll) { | |
mounts.unshift(component); | |
if (!diffLevel) { flushMounts(); } | |
} else if (!skip && component.componentDidUpdate) { component.componentDidUpdate(previousProps, previousState, previousContext); } | |
var fn, cb = component._renderCallbacks; | |
if (cb) { while (fn = cb.pop()) { fn.call(component); } } | |
return rendered; | |
} | |
} | |
function buildComponentFromVNode(dom, vnode, context, mountAll) { | |
var c = dom && dom._component, oldDom = dom, isDirectOwner = c && dom._componentConstructor === vnode.nodeName, isOwner = isDirectOwner, props = getNodeProps(vnode); | |
while (c && !isOwner && (c = c._parentComponent)) { isOwner = c.constructor === vnode.nodeName; } | |
if (isOwner && (!mountAll || c._component)) { | |
setComponentProps(c, props, 3, context, mountAll); | |
dom = c.base; | |
} else { | |
if (c && !isDirectOwner) { | |
unmountComponent(c, !0); | |
dom = oldDom = null; | |
} | |
c = createComponent(vnode.nodeName, props, context); | |
if (dom && !c.nextBase) { c.nextBase = dom; } | |
setComponentProps(c, props, 1, context, mountAll); | |
dom = c.base; | |
if (oldDom && dom !== oldDom) { | |
oldDom._component = null; | |
recollectNodeTree(oldDom); | |
} | |
} | |
return dom; | |
} | |
function unmountComponent(component, remove) { | |
var base = component.base; | |
component._disableRendering = !0; | |
if (component.componentWillUnmount) { component.componentWillUnmount(); } | |
component.base = null; | |
var inner = component._component; | |
if (inner) { unmountComponent(inner, remove); } else if (base) { | |
if (base[ATTR_KEY] && base[ATTR_KEY].ref) { base[ATTR_KEY].ref(null); } | |
component.nextBase = base; | |
if (remove) { | |
removeNode(base); | |
collectComponent(component); | |
} | |
removeOrphanedChildren(base.childNodes, !remove); | |
} | |
if (component.__ref) { component.__ref(null); } | |
if (component.componentDidUnmount) { component.componentDidUnmount(); } | |
} | |
function Component(props, context) { | |
this._dirty = !0; | |
this._disableRendering = !1; | |
this.prevState = this.prevProps = this.prevContext = this.base = this.nextBase = this._parentComponent = this._component = this.__ref = this.__key = this._linkedStates = this._renderCallbacks = null; | |
this.context = context; | |
this.props = props; | |
this.state = this.getInitialState && this.getInitialState() || {}; | |
} | |
function render(vnode, parent, merge) { | |
return diff(merge, vnode, {}, !1, parent); | |
} | |
var options = {}; | |
var lcCache = {}; | |
var toLowerCase = function(s) { | |
return lcCache[s] || (lcCache[s] = s.toLowerCase()); | |
}; | |
var resolved = 'undefined' != typeof Promise && Promise.resolve(); | |
var defer = resolved ? function(f) { | |
resolved.then(f); | |
} : setTimeout; | |
var SHARED_TEMP_ARRAY = []; | |
var EMPTY = {}; | |
var ATTR_KEY = 'undefined' != typeof Symbol ? Symbol.for('preactattr') : '__preactattr_'; | |
var NON_DIMENSION_PROPS = { | |
boxFlex: 1, | |
boxFlexGroup: 1, | |
columnCount: 1, | |
fillOpacity: 1, | |
flex: 1, | |
flexGrow: 1, | |
flexPositive: 1, | |
flexShrink: 1, | |
flexNegative: 1, | |
fontWeight: 1, | |
lineClamp: 1, | |
lineHeight: 1, | |
opacity: 1, | |
order: 1, | |
orphans: 1, | |
strokeOpacity: 1, | |
widows: 1, | |
zIndex: 1, | |
zoom: 1 | |
}; | |
var NON_BUBBLING_EVENTS = { | |
blur: 1, | |
error: 1, | |
focus: 1, | |
load: 1, | |
resize: 1, | |
scroll: 1 | |
}; | |
var items = []; | |
var itemsOffline = []; | |
var nodes = {}; | |
var mounts = []; | |
var diffLevel = 0; | |
var isSvgMode = !1; | |
var components = {}; | |
extend(Component.prototype, { | |
linkState: function(key, eventPath) { | |
var c = this._linkedStates || (this._linkedStates = {}), cacheKey = key + '|' + eventPath; | |
return c[cacheKey] || (c[cacheKey] = createLinkedState(this, key, eventPath)); | |
}, | |
setState: function(state, callback) { | |
var s = this.state; | |
if (!this.prevState) { this.prevState = clone(s); } | |
extend(s, isFunction(state) ? state(s, this.props) : state); | |
if (callback) { (this._renderCallbacks = this._renderCallbacks || []).push(callback); } | |
triggerComponentRender(this); | |
}, | |
forceUpdate: function() { | |
renderComponent(this, 2); | |
}, | |
render: function() { | |
return null; | |
} | |
}); | |
exports.h = h; | |
exports.cloneElement = cloneElement; | |
exports.Component = Component; | |
exports.render = render; | |
exports.rerender = rerender; | |
exports.options = options; | |
}); | |
}); | |
var td = ["abbr","align","axis","bgcolor","char","charoff","colspan","headers","height","nowrap","rowspan","scope","valign","width"]; | |
var th = ["abbr","align","axis","bgcolor","char","charoff","colspan","headers","height","nowrap","rowspan","scope","valign","width"]; | |
var form = ["accept","accept-charset","action","autocomplete","enctype","method","name","novalidate","target"]; | |
var input = ["accept","align","alt","autocomplete","autofocus","checked","dirname","disabled","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","ismap","list","max","maxlength","min","minlength","multiple","name","pattern","placeholder","readonly","required","size","src","step","type","usemap","value","width"]; | |
var a = ["charset","coords","download","href","hreflang","name","ping","rel","rev","shape","target","type"]; | |
var area = ["alt","coords","download","href","hreflang","nohref","ping","rel","shape","target","type"]; | |
var button = ["autofocus","disabled","form","formaction","formenctype","formmethod","formnovalidate","formtarget","menu","name","type","value"]; | |
var label = ["for","form"]; | |
var legend = ["align"]; | |
var textarea = ["autocomplete","autofocus","cols","dirname","disabled","form","inputmode","maxlength","minlength","name","placeholder","readonly","required","rows","wrap"]; | |
var caption = ["align"]; | |
var applet = ["align","alt","archive","code","codebase","height","hspace","name","object","vspace","width"]; | |
var iframe = ["align","allowfullscreen","frameborder","height","longdesc","marginheight","marginwidth","name","sandbox","scrolling","src","srcdoc","width"]; | |
var img = ["align","alt","border","crossorigin","height","hspace","ismap","longdesc","name","sizes","src","srcset","usemap","vspace","width"]; | |
var object$1 = ["align","archive","border","classid","codebase","codetype","data","declare","form","height","hspace","name","standby","type","typemustmatch","usemap","vspace","width"]; | |
var table = ["align","bgcolor","border","cellpadding","cellspacing","frame","rules","summary","width"]; | |
var hr = ["align","noshade","size","width"]; | |
var div = ["align"]; | |
var h1 = ["align"]; | |
var h2 = ["align"]; | |
var h3 = ["align"]; | |
var h4 = ["align"]; | |
var h5 = ["align"]; | |
var h6 = ["align"]; | |
var p = ["align"]; | |
var col = ["align","char","charoff","span","valign","width"]; | |
var colgroup = ["align","char","charoff","span","valign","width"]; | |
var tbody = ["align","char","charoff","valign"]; | |
var tfoot = ["align","char","charoff","valign"]; | |
var thead = ["align","char","charoff","valign"]; | |
var tr = ["align","bgcolor","char","charoff","valign"]; | |
var body = ["alink","background","bgcolor","link","text","vlink"]; | |
var link = ["charset","crossorigin","href","hreflang","media","rel","rev","sizes","target","type"]; | |
var script = ["async","charset","crossorigin","defer","language","nonce","src","type"]; | |
var blockquote = ["cite"]; | |
var q = ["cite"]; | |
var del = ["cite","datetime"]; | |
var ins = ["cite","datetime"]; | |
var br = ["clear"]; | |
var basefont = ["color","face","size"]; | |
var font = ["color","face","size"]; | |
var frameset = ["cols","rows"]; | |
var dir = ["compact"]; | |
var dl = ["compact"]; | |
var menu = ["compact","label","type"]; | |
var ol = ["compact","reversed","start","type"]; | |
var ul = ["compact","type"]; | |
var meta = ["charset","content","http-equiv","name","scheme"]; | |
var optgroup = ["disabled","label"]; | |
var option = ["disabled","label","selected","value"]; | |
var select = ["autocomplete","autofocus","disabled","form","multiple","name","required","size"]; | |
var frame = ["frameborder","longdesc","marginheight","marginwidth","name","noresize","scrolling","src"]; | |
var base = ["href","target"]; | |
var style = ["media","nonce","scoped","type"]; | |
var map = ["name"]; | |
var param = ["name","type","value","valuetype"]; | |
var head = ["profile"]; | |
var isindex = ["prompt"]; | |
var li = ["type","value"]; | |
var html = ["manifest","version"]; | |
var pre = ["width"]; | |
var keygen = ["autofocus","challenge","disabled","form","keytype","name"]; | |
var audio = ["autoplay","controls","crossorigin","loop","mediagroup","muted","preload","src"]; | |
var video = ["autoplay","controls","crossorigin","height","loop","mediagroup","muted","poster","preload","src","width"]; | |
var time = ["datetime"]; | |
var track = ["default","kind","label","src","srclang"]; | |
var fieldset = ["disabled","form","name"]; | |
var output = ["for","form","name"]; | |
var canvas = ["height","width"]; | |
var embed = ["height","src","type","width"]; | |
var meter = ["high","low","max","min","optimum","value"]; | |
var progress = ["max","value"]; | |
var source = ["media","sizes","src","srcset","type"]; | |
var data = ["value"]; | |
var menuitem = ["checked","default","disabled","icon","label","radiogroup","type"]; | |
var details = ["open"]; | |
var dialog = ["open"]; | |
var index$56 = { | |
td: td, | |
th: th, | |
form: form, | |
input: input, | |
a: a, | |
area: area, | |
button: button, | |
label: label, | |
legend: legend, | |
textarea: textarea, | |
caption: caption, | |
applet: applet, | |
iframe: iframe, | |
img: img, | |
object: object$1, | |
table: table, | |
hr: hr, | |
div: div, | |
h1: h1, | |
h2: h2, | |
h3: h3, | |
h4: h4, | |
h5: h5, | |
h6: h6, | |
p: p, | |
col: col, | |
colgroup: colgroup, | |
tbody: tbody, | |
tfoot: tfoot, | |
thead: thead, | |
tr: tr, | |
body: body, | |
link: link, | |
script: script, | |
blockquote: blockquote, | |
q: q, | |
del: del, | |
ins: ins, | |
br: br, | |
basefont: basefont, | |
font: font, | |
frameset: frameset, | |
dir: dir, | |
dl: dl, | |
menu: menu, | |
ol: ol, | |
ul: ul, | |
meta: meta, | |
optgroup: optgroup, | |
option: option, | |
select: select, | |
frame: frame, | |
base: base, | |
style: style, | |
map: map, | |
param: param, | |
head: head, | |
isindex: isindex, | |
li: li, | |
html: html, | |
pre: pre, | |
keygen: keygen, | |
audio: audio, | |
video: video, | |
time: time, | |
track: track, | |
fieldset: fieldset, | |
output: output, | |
canvas: canvas, | |
embed: embed, | |
meter: meter, | |
progress: progress, | |
source: source, | |
data: data, | |
menuitem: menuitem, | |
details: details, | |
dialog: dialog, | |
"*": ["accesskey","class","contenteditable","contextmenu","dir","draggable","dropzone","hidden","id","itemid","itemprop","itemref","itemscope","itemtype","lang","spellcheck","style","tabindex","title","translate"] | |
}; | |
var index$57 = Object.freeze({ | |
td: td, | |
th: th, | |
form: form, | |
input: input, | |
a: a, | |
area: area, | |
button: button, | |
label: label, | |
legend: legend, | |
textarea: textarea, | |
caption: caption, | |
applet: applet, | |
iframe: iframe, | |
img: img, | |
object: object$1, | |
table: table, | |
hr: hr, | |
div: div, | |
h1: h1, | |
h2: h2, | |
h3: h3, | |
h4: h4, | |
h5: h5, | |
h6: h6, | |
p: p, | |
col: col, | |
colgroup: colgroup, | |
tbody: tbody, | |
tfoot: tfoot, | |
thead: thead, | |
tr: tr, | |
body: body, | |
link: link, | |
script: script, | |
blockquote: blockquote, | |
q: q, | |
del: del, | |
ins: ins, | |
br: br, | |
basefont: basefont, | |
font: font, | |
frameset: frameset, | |
dir: dir, | |
dl: dl, | |
menu: menu, | |
ol: ol, | |
ul: ul, | |
meta: meta, | |
optgroup: optgroup, | |
option: option, | |
select: select, | |
frame: frame, | |
base: base, | |
style: style, | |
map: map, | |
param: param, | |
head: head, | |
isindex: isindex, | |
li: li, | |
html: html, | |
pre: pre, | |
keygen: keygen, | |
audio: audio, | |
video: video, | |
time: time, | |
track: track, | |
fieldset: fieldset, | |
output: output, | |
canvas: canvas, | |
embed: embed, | |
meter: meter, | |
progress: progress, | |
source: source, | |
data: data, | |
menuitem: menuitem, | |
details: details, | |
dialog: dialog, | |
default: index$56 | |
}); | |
var require$$0$16 = ( index$57 && index$57['default'] ) || index$57; | |
/* eslint-env commonjs */ | |
/* | |
* Expose. | |
*/ | |
var index$54 = require$$0$16; | |
var index$60 = [ | |
"a", | |
"abbr", | |
"acronym", | |
"address", | |
"applet", | |
"area", | |
"article", | |
"aside", | |
"audio", | |
"b", | |
"base", | |
"basefont", | |
"bdi", | |
"bdo", | |
"bgsound", | |
"big", | |
"blink", | |
"blockquote", | |
"body", | |
"br", | |
"button", | |
"canvas", | |
"caption", | |
"center", | |
"cite", | |
"code", | |
"col", | |
"colgroup", | |
"command", | |
"content", | |
"data", | |
"datalist", | |
"dd", | |
"del", | |
"details", | |
"dfn", | |
"dialog", | |
"dir", | |
"div", | |
"dl", | |
"dt", | |
"element", | |
"em", | |
"embed", | |
"fieldset", | |
"figcaption", | |
"figure", | |
"font", | |
"footer", | |
"form", | |
"frame", | |
"frameset", | |
"h1", | |
"h2", | |
"h3", | |
"h4", | |
"h5", | |
"h6", | |
"head", | |
"header", | |
"hgroup", | |
"hr", | |
"html", | |
"i", | |
"iframe", | |
"image", | |
"img", | |
"input", | |
"ins", | |
"isindex", | |
"kbd", | |
"keygen", | |
"label", | |
"legend", | |
"li", | |
"link", | |
"listing", | |
"main", | |
"map", | |
"mark", | |
"marquee", | |
"math", | |
"menu", | |
"menuitem", | |
"meta", | |
"meter", | |
"multicol", | |
"nav", | |
"nextid", | |
"nobr", | |
"noembed", | |
"noframes", | |
"noscript", | |
"object", | |
"ol", | |
"optgroup", | |
"option", | |
"output", | |
"p", | |
"param", | |
"picture", | |
"plaintext", | |
"pre", | |
"progress", | |
"q", | |
"rb", | |
"rbc", | |
"rp", | |
"rt", | |
"rtc", | |
"ruby", | |
"s", | |
"samp", | |
"script", | |
"section", | |
"select", | |
"shadow", | |
"small", | |
"source", | |
"spacer", | |
"span", | |
"strike", | |
"strong", | |
"style", | |
"sub", | |
"summary", | |
"sup", | |
"svg", | |
"table", | |
"tbody", | |
"td", | |
"template", | |
"textarea", | |
"tfoot", | |
"th", | |
"thead", | |
"time", | |
"title", | |
"tr", | |
"track", | |
"tt", | |
"u", | |
"ul", | |
"var", | |
"video", | |
"wbr", | |
"xmp" | |
] | |
; | |
var index$61 = Object.freeze({ | |
default: index$60 | |
}); | |
var require$$0$17 = ( index$61 && index$61['default'] ) || index$61; | |
/* eslint-env commonjs */ | |
/* | |
* Expose. | |
*/ | |
var index$58 = require$$0$17; | |
var index$62 = function flatten(list, depth) { | |
depth = (typeof depth == 'number') ? depth : Infinity; | |
if (!depth) { | |
if (Array.isArray(list)) { | |
return list.map(function(i) { return i; }); | |
} | |
return list; | |
} | |
return _flatten(list, 1); | |
function _flatten(list, d) { | |
return list.reduce(function (acc, item) { | |
if (Array.isArray(item) && d < depth) { | |
return acc.concat(_flatten(item, d + 1)); | |
} | |
else { | |
return acc.concat(item); | |
} | |
}, []); | |
} | |
}; | |
var index$52 = createCommonjsModule(function (module, exports) { | |
/** | |
* Module Dependencies | |
*/ | |
var Attributes = index$54 | |
var assign = index$6 | |
var Tags = index$58 | |
var flatten = index$62 | |
var sliced = index$8 | |
var slice = index$8 | |
var h = preact.h; | |
/** | |
* Utils | |
*/ | |
var isObject = function (v) { return Object.prototype.toString.call(v) === '[object Object]'; } | |
var isClass = function (v) { return /class(name)?/i.test(v); } | |
var has = function (o, v) { return o.hasOwnProperty(v); } | |
var isArray = function (v) { return Array.isArray(v); } | |
var truthy = function (v) { return !!v; } | |
/** | |
* Attach events | |
* | |
* Pulled from: https://facebook.github.io/react/docs/events.html | |
*/ | |
var Events = [ | |
'onCopy', 'onCut', 'onPaste', | |
'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate', | |
'onKeyDown', 'onKeyPress', 'onKeyUp', | |
'onFocus', 'onBlur', | |
'onChange', 'onInput', 'onSubmit', | |
'onClick', 'onContextMenu', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', | |
'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', | |
'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', | |
'onSelect', | |
'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', | |
'onScroll', | |
'onWheel', | |
'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', | |
'onEnded', 'onError', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', | |
'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', | |
'onTimeUpdate', 'onVolumeChange', 'onWaiting', | |
'onLoad', | |
'onAnimationStart', 'onAnimationEnd', 'onAnimationIteration', | |
'onTransitionEnd' | |
] | |
/** | |
* Create functions from all the tags | |
*/ | |
Tags.forEach(function (name) { exports[name] = Component(name) }) | |
/** | |
* Create a custom component | |
*/ | |
exports.component = Component | |
/** | |
* Create a component | |
*/ | |
function Component (name) { | |
var attributes = Attributes['*'].concat(Events).concat(Attributes[name]) | |
function Tag () { | |
var attrs = {} | |
function tag (mixed) { | |
if (!arguments.length) { | |
return h(name, attrs) | |
} else if (mixed.nodeName || arguments.length > 1) { | |
return h(name, attrs, flatten(slice(arguments))) | |
} else if (isArray(mixed)) { | |
return h(name, attrs, flatten(mixed)) | |
} else if (!isObject(mixed)) { | |
return h(name, attrs, mixed) | |
} else if (has(mixed, 'toString')) { | |
return h(name, attrs, String(mixed)) | |
} | |
// attributes | |
attrs = assign(attrs, mixed) | |
return tag | |
} | |
// attach instance functions | |
attributes.forEach(function (attr) { tag[attr] = IAttr(tag, attrs, attr) }) | |
tag.toJSON = function () { return h(name, attrs); } | |
// create an instance of the tag | |
return tag.apply(null, arguments) | |
} | |
// attach static functions | |
attributes.forEach(function (attr) { Tag[attr] = Attr(Tag, attr) }) | |
Tag.toJSON = function () { return h(name); } | |
return Tag | |
} | |
/** | |
* Attribute builder function for all tags | |
*/ | |
function Attr (fn, attr) { | |
return function (value) { | |
var attrs = {} | |
attrs[attr] = isClass(attr) | |
? sliced(arguments).filter(truthy).join(' ') | |
: value | |
return fn(attrs) | |
} | |
} | |
/** | |
* Attribute builder for all tag instances | |
*/ | |
function IAttr (fn, attrs, attr) { | |
return function (value) { | |
attrs[attr] = isClass(attr) | |
? sliced(arguments).filter(truthy).join(' ') | |
: value | |
return fn | |
} | |
} | |
}); | |
var index = createCommonjsModule(function (module) { | |
'use strict' | |
/** | |
* Module Dependencies | |
*/ | |
var Socrates = index$2 | |
var Stylesheet = index$42 | |
var Effects = alley | |
var preact$$1 = preact | |
var rsplit = /\.?([^\s]+)/g | |
var sun = index$52 | |
/** | |
* Defer with fallback | |
*/ | |
var resolved = typeof Promise !== 'undefined' && Promise.resolve() | |
var defer = resolved ? function (f) { resolved.then(f) } : setTimeout | |
/** | |
* Initialize the vcom object | |
*/ | |
var vcom = module.exports = {} | |
/** | |
* DOM | |
*/ | |
vcom.HTML = sun | |
/** | |
* Attach CSS | |
*/ | |
vcom.CSS = CSS | |
/** | |
* Store | |
*/ | |
vcom.Store = Socrates | |
/** | |
* Effects | |
*/ | |
vcom.Effects = Effects | |
/** | |
* Stylesheet | |
*/ | |
vcom.Stylesheet = Stylesheet | |
/** | |
* Render | |
*/ | |
vcom.render = Render | |
/** | |
* Render | |
*/ | |
function Render (renderable, parent, ref) { | |
if ( ref === void 0 ) ref = {}; | |
var effects = ref.effects; | |
var store = ref.store; | |
var css = ref.css; | |
var styles = typeof css === 'object' ? function (key) { return css[key]; } : css | |
var transform = Transform({ css: styles, effects: effects }) | |
var root = null | |
function render () { | |
var state = typeof store === 'function' ? store() : store | |
var vdom = typeof renderable === 'function' | |
? transform(renderable(state)) | |
: transform(renderable) | |
root = preact$$1.render(vdom, parent, root) | |
return root | |
} | |
// subscribe to updates | |
if (store && typeof store === 'function') { | |
store.subscribe(function () { return defer(render); }) | |
} | |
return render() | |
} | |
/** | |
* CSS transform | |
*/ | |
function CSS () { | |
var sheet = Stylesheet.apply(null, arguments) | |
return function css (render) { | |
if (typeof render === 'function') { | |
return Stylize(render, sheet) | |
} else { | |
sheet = sheet.apply(null, arguments) | |
return css | |
} | |
} | |
} | |
/** | |
* Stylize the render | |
*/ | |
function Stylize (Render, css) { | |
var styles = Styles(css) | |
return function render () { | |
var vnodes = Render.apply(Render, arguments) | |
if (!vnodes) { return vnodes } | |
return walk(vnodes, function (node) { return styles(node); }) | |
} | |
} | |
/** | |
* Transform vnodes | |
*/ | |
function Transform (ref) { | |
var css = ref.css; | |
var effects = ref.effects; | |
var actions = Actions(effects) | |
var styles = Styles(css) | |
return function transform (vnode) { | |
return walk(vnode, function (node) { | |
if (css) { styles(node) } | |
if (effects) { actions(node) } | |
return node | |
}) | |
} | |
} | |
/** | |
* Render the classnames | |
*/ | |
function Styles (css) { | |
return function styles (node) { | |
var attrs = node.attributes | |
if (!attrs || !attrs.class) { return node } | |
attrs.class = selectors(attrs.class) | |
.map(function (cls) { return css[cls] || cls; }) | |
.join(' ') | |
return node | |
} | |
} | |
/** | |
* Actions | |
*/ | |
function Actions (effects) { | |
return function actions (node) { | |
var attrs = node.attributes | |
if (!attrs) { return node } | |
var loop = function ( attr ) { | |
if (typeof attrs[attr] !== 'function') { return } | |
var fn = attrs[attr] | |
attrs[attr] = function (e) { return fn(e, effects.send); } | |
}; | |
for (var attr in attrs) loop( attr ); | |
return node | |
} | |
} | |
/** | |
* Walk the vnode tree | |
*/ | |
function walk (vnode, fn) { | |
if (!vnode) { return vnode } | |
fn(vnode) | |
if (!vnode.children) { return vnode } | |
vnode.children.map(function (child) { return walk(child, fn); }) | |
return vnode | |
} | |
/** | |
* Split into separate selectors | |
*/ | |
function selectors (selectors) { | |
var arr = [] | |
selectors.replace(rsplit, function (m, s) { return arr.push(s); }) | |
return arr.filter(function (selector) { return !!selector; }) | |
} | |
}); | |
return index; | |
}))); | |
//# sourceMappingURL=vcom.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment