From bde0aa46ea7583a8a284f3f5a4f9e513e0b8e796 Mon Sep 17 00:00:00 2001
From: Nina Breznik
Date: Wed, 19 Jan 2022 17:29:29 +0100
Subject: [PATCH] Bundle
---
bundles/bundle.js | 2 +-
docs/bundles/bundle.js | 32827 ++++++++++++++++++++-------------------
2 files changed, 16527 insertions(+), 16302 deletions(-)
diff --git a/bundles/bundle.js b/bundles/bundle.js
index 85b972d..5023da2 100644
--- a/bundles/bundle.js
+++ b/bundles/bundle.js
@@ -16948,7 +16948,7 @@ module.exports = {
};
},{"./default":149,"./home":150,"./list":152}],152:[function(require,module,exports){
var _templateObject = _taggedTemplateLiteral(['\n \n '], ['\n \n ']),
- _templateObject2 = _taggedTemplateLiteral(['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n '], ['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n ']),
+ _templateObject2 = _taggedTemplateLiteral(['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n '], ['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n ']),
_templateObject3 = _taggedTemplateLiteral(['\n \n TAGS: ', '\n
\n '], ['\n \n TAGS: ', '\n
\n ']);
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
diff --git a/docs/bundles/bundle.js b/docs/bundles/bundle.js
index b4555c4..ac7d9b4 100644
--- a/docs/bundles/bundle.js
+++ b/docs/bundles/bundle.js
@@ -1,16822 +1,17047 @@
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i
- * @license MIT
- */
-
-function compare(a, b) {
- if (a === b) {
+ (function (global){(function (){
+ 'use strict';
+
+ var objectAssign = require('object-assign');
+
+ // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
+ // original notice:
+
+ /*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+ function compare(a, b) {
+ if (a === b) {
+ return 0;
+ }
+
+ var x = a.length;
+ var y = b.length;
+
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
+ if (a[i] !== b[i]) {
+ x = a[i];
+ y = b[i];
+ break;
+ }
+ }
+
+ if (x < y) {
+ return -1;
+ }
+ if (y < x) {
+ return 1;
+ }
return 0;
}
-
- var x = a.length;
- var y = b.length;
-
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i];
- y = b[i];
- break;
+ function isBuffer(b) {
+ if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
+ return global.Buffer.isBuffer(b);
}
+ return !!(b != null && b._isBuffer);
}
-
- if (x < y) {
- return -1;
- }
- if (y < x) {
- return 1;
- }
- return 0;
-}
-function isBuffer(b) {
- if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
- return global.Buffer.isBuffer(b);
- }
- return !!(b != null && b._isBuffer);
-}
-
-// based on node assert, original notice:
-
-// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
-//
-// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
-//
-// Originally from narwhal.js (http://narwhaljs.org)
-// Copyright (c) 2009 Thomas Robinson <280north.com>
-//
-// 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 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.
-
-var util = require('util/');
-var hasOwn = Object.prototype.hasOwnProperty;
-var pSlice = Array.prototype.slice;
-var functionsHaveNames = function () {
- return function foo() {}.name === 'foo';
-}();
-function pToString(obj) {
- return Object.prototype.toString.call(obj);
-}
-function isView(arrbuf) {
- if (isBuffer(arrbuf)) {
- return false;
- }
- if (typeof global.ArrayBuffer !== 'function') {
- return false;
- }
- if (typeof ArrayBuffer.isView === 'function') {
- return ArrayBuffer.isView(arrbuf);
+
+ // based on node assert, original notice:
+ // NB: The URL to the CommonJS spec is kept just for tradition.
+ // node-assert has evolved a lot since then, both in API and behavior.
+
+ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
+ //
+ // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
+ //
+ // Originally from narwhal.js (http://narwhaljs.org)
+ // Copyright (c) 2009 Thomas Robinson <280north.com>
+ //
+ // 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 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.
+
+ var util = require('util/');
+ var hasOwn = Object.prototype.hasOwnProperty;
+ var pSlice = Array.prototype.slice;
+ var functionsHaveNames = function () {
+ return function foo() {}.name === 'foo';
+ }();
+ function pToString(obj) {
+ return Object.prototype.toString.call(obj);
}
- if (!arrbuf) {
+ function isView(arrbuf) {
+ if (isBuffer(arrbuf)) {
+ return false;
+ }
+ if (typeof global.ArrayBuffer !== 'function') {
+ return false;
+ }
+ if (typeof ArrayBuffer.isView === 'function') {
+ return ArrayBuffer.isView(arrbuf);
+ }
+ if (!arrbuf) {
+ return false;
+ }
+ if (arrbuf instanceof DataView) {
+ return true;
+ }
+ if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
+ return true;
+ }
return false;
}
- if (arrbuf instanceof DataView) {
- return true;
+ // 1. The assert module provides functions that throw
+ // AssertionError's when particular conditions are not met. The
+ // assert module must conform to the following interface.
+
+ var assert = module.exports = ok;
+
+ // 2. The AssertionError is defined in assert.
+ // new assert.AssertionError({ message: message,
+ // actual: actual,
+ // expected: expected })
+
+ var regex = /\s*function\s+([^\(\s]*)\s*/;
+ // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
+ function getName(func) {
+ if (!util.isFunction(func)) {
+ return;
+ }
+ if (functionsHaveNames) {
+ return func.name;
+ }
+ var str = func.toString();
+ var match = str.match(regex);
+ return match && match[1];
+ }
+ assert.AssertionError = function AssertionError(options) {
+ this.name = 'AssertionError';
+ this.actual = options.actual;
+ this.expected = options.expected;
+ this.operator = options.operator;
+ if (options.message) {
+ this.message = options.message;
+ this.generatedMessage = false;
+ } else {
+ this.message = getMessage(this);
+ this.generatedMessage = true;
+ }
+ var stackStartFunction = options.stackStartFunction || fail;
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, stackStartFunction);
+ } else {
+ // non v8 browsers so we can have a stacktrace
+ var err = new Error();
+ if (err.stack) {
+ var out = err.stack;
+
+ // try to strip useless frames
+ var fn_name = getName(stackStartFunction);
+ var idx = out.indexOf('\n' + fn_name);
+ if (idx >= 0) {
+ // once we have located the function frame
+ // we need to strip out everything before it (and its line)
+ var next_line = out.indexOf('\n', idx + 1);
+ out = out.substring(next_line + 1);
+ }
+
+ this.stack = out;
+ }
+ }
+ };
+
+ // assert.AssertionError instanceof Error
+ util.inherits(assert.AssertionError, Error);
+
+ function truncate(s, n) {
+ if (typeof s === 'string') {
+ return s.length < n ? s : s.slice(0, n);
+ } else {
+ return s;
+ }
+ }
+ function inspect(something) {
+ if (functionsHaveNames || !util.isFunction(something)) {
+ return util.inspect(something);
+ }
+ var rawname = getName(something);
+ var name = rawname ? ': ' + rawname : '';
+ return '[Function' + name + ']';
+ }
+ function getMessage(self) {
+ return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + truncate(inspect(self.expected), 128);
+ }
+
+ // At present only the three keys mentioned above are used and
+ // understood by the spec. Implementations or sub modules can pass
+ // other keys to the AssertionError's constructor - they will be
+ // ignored.
+
+ // 3. All of the following functions must throw an AssertionError
+ // when a corresponding condition is not met, with a message that
+ // may be undefined if not provided. All assertion methods provide
+ // both the actual and expected values to the assertion error for
+ // display purposes.
+
+ function fail(actual, expected, message, operator, stackStartFunction) {
+ throw new assert.AssertionError({
+ message: message,
+ actual: actual,
+ expected: expected,
+ operator: operator,
+ stackStartFunction: stackStartFunction
+ });
}
- if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
+
+ // EXTENSION! allows for well behaved errors defined elsewhere.
+ assert.fail = fail;
+
+ // 4. Pure assertion tests whether a value is truthy, as determined
+ // by !!guard.
+ // assert.ok(guard, message_opt);
+ // This statement is equivalent to assert.equal(true, !!guard,
+ // message_opt);. To test strictly for the value true, use
+ // assert.strictEqual(true, guard, message_opt);.
+
+ function ok(value, message) {
+ if (!value) fail(value, true, message, '==', assert.ok);
+ }
+ assert.ok = ok;
+
+ // 5. The equality assertion tests shallow, coercive equality with
+ // ==.
+ // assert.equal(actual, expected, message_opt);
+
+ assert.equal = function equal(actual, expected, message) {
+ if (actual != expected) fail(actual, expected, message, '==', assert.equal);
+ };
+
+ // 6. The non-equality assertion tests for whether two objects are not equal
+ // with != assert.notEqual(actual, expected, message_opt);
+
+ assert.notEqual = function notEqual(actual, expected, message) {
+ if (actual == expected) {
+ fail(actual, expected, message, '!=', assert.notEqual);
+ }
+ };
+
+ // 7. The equivalence assertion tests a deep equality relation.
+ // assert.deepEqual(actual, expected, message_opt);
+
+ assert.deepEqual = function deepEqual(actual, expected, message) {
+ if (!_deepEqual(actual, expected, false)) {
+ fail(actual, expected, message, 'deepEqual', assert.deepEqual);
+ }
+ };
+
+ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
+ if (!_deepEqual(actual, expected, true)) {
+ fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
+ }
+ };
+
+ function _deepEqual(actual, expected, strict, memos) {
+ // 7.1. All identical values are equivalent, as determined by ===.
+ if (actual === expected) {
+ return true;
+ } else if (isBuffer(actual) && isBuffer(expected)) {
+ return compare(actual, expected) === 0;
+
+ // 7.2. If the expected value is a Date object, the actual value is
+ // equivalent if it is also a Date object that refers to the same time.
+ } else if (util.isDate(actual) && util.isDate(expected)) {
+ return actual.getTime() === expected.getTime();
+
+ // 7.3 If the expected value is a RegExp object, the actual value is
+ // equivalent if it is also a RegExp object with the same source and
+ // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
+ } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
+ return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
+
+ // 7.4. Other pairs that do not both pass typeof value == 'object',
+ // equivalence is determined by ==.
+ } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) {
+ return strict ? actual === expected : actual == expected;
+
+ // If both values are instances of typed arrays, wrap their underlying
+ // ArrayBuffers in a Buffer each to increase performance
+ // This optimization requires the arrays to have the same type as checked by
+ // Object.prototype.toString (aka pToString). Never perform binary
+ // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
+ // bit patterns are not identical.
+ } else if (isView(actual) && isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || actual instanceof Float64Array)) {
+ return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0;
+
+ // 7.5 For all other Object pairs, including Array objects, equivalence is
+ // determined by having the same number of owned properties (as verified
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
+ // (although not necessarily the same order), equivalent values for every
+ // corresponding key, and an identical 'prototype' property. Note: this
+ // accounts for both named and indexed properties on Arrays.
+ } else if (isBuffer(actual) !== isBuffer(expected)) {
+ return false;
+ } else {
+ memos = memos || { actual: [], expected: [] };
+
+ var actualIndex = memos.actual.indexOf(actual);
+ if (actualIndex !== -1) {
+ if (actualIndex === memos.expected.indexOf(expected)) {
+ return true;
+ }
+ }
+
+ memos.actual.push(actual);
+ memos.expected.push(expected);
+
+ return objEquiv(actual, expected, strict, memos);
+ }
+ }
+
+ function isArguments(object) {
+ return Object.prototype.toString.call(object) == '[object Arguments]';
+ }
+
+ function objEquiv(a, b, strict, actualVisitedObjects) {
+ if (a === null || a === undefined || b === null || b === undefined) return false;
+ // if one is a primitive, the other must be same
+ if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b;
+ if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
+ var aIsArgs = isArguments(a);
+ var bIsArgs = isArguments(b);
+ if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false;
+ if (aIsArgs) {
+ a = pSlice.call(a);
+ b = pSlice.call(b);
+ return _deepEqual(a, b, strict);
+ }
+ var ka = objectKeys(a);
+ var kb = objectKeys(b);
+ var key, i;
+ // having the same number of owned properties (keys incorporates
+ // hasOwnProperty)
+ if (ka.length !== kb.length) return false;
+ //the same set of keys (although not necessarily the same order),
+ ka.sort();
+ kb.sort();
+ //~~~cheap key test
+ for (i = ka.length - 1; i >= 0; i--) {
+ if (ka[i] !== kb[i]) return false;
+ }
+ //equivalent values for every corresponding key, and
+ //~~~possibly expensive deep test
+ for (i = ka.length - 1; i >= 0; i--) {
+ key = ka[i];
+ if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false;
+ }
return true;
}
- return false;
-}
-// 1. The assert module provides functions that throw
-// AssertionError's when particular conditions are not met. The
-// assert module must conform to the following interface.
-
-var assert = module.exports = ok;
-
-// 2. The AssertionError is defined in assert.
-// new assert.AssertionError({ message: message,
-// actual: actual,
-// expected: expected })
-
-var regex = /\s*function\s+([^\(\s]*)\s*/;
-// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
-function getName(func) {
- if (!util.isFunction(func)) {
- return;
- }
- if (functionsHaveNames) {
- return func.name;
- }
- var str = func.toString();
- var match = str.match(regex);
- return match && match[1];
-}
-assert.AssertionError = function AssertionError(options) {
- this.name = 'AssertionError';
- this.actual = options.actual;
- this.expected = options.expected;
- this.operator = options.operator;
- if (options.message) {
- this.message = options.message;
- this.generatedMessage = false;
- } else {
- this.message = getMessage(this);
- this.generatedMessage = true;
+
+ // 8. The non-equivalence assertion tests for any deep inequality.
+ // assert.notDeepEqual(actual, expected, message_opt);
+
+ assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
+ if (_deepEqual(actual, expected, false)) {
+ fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
+ }
+ };
+
+ assert.notDeepStrictEqual = notDeepStrictEqual;
+ function notDeepStrictEqual(actual, expected, message) {
+ if (_deepEqual(actual, expected, true)) {
+ fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
+ }
}
- var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- } else {
- // non v8 browsers so we can have a stacktrace
- var err = new Error();
- if (err.stack) {
- var out = err.stack;
-
- // try to strip useless frames
- var fn_name = getName(stackStartFunction);
- var idx = out.indexOf('\n' + fn_name);
- if (idx >= 0) {
- // once we have located the function frame
- // we need to strip out everything before it (and its line)
- var next_line = out.indexOf('\n', idx + 1);
- out = out.substring(next_line + 1);
- }
-
- this.stack = out;
- }
- }
-};
-
-// assert.AssertionError instanceof Error
-util.inherits(assert.AssertionError, Error);
-
-function truncate(s, n) {
- if (typeof s === 'string') {
- return s.length < n ? s : s.slice(0, n);
- } else {
- return s;
- }
-}
-function inspect(something) {
- if (functionsHaveNames || !util.isFunction(something)) {
- return util.inspect(something);
- }
- var rawname = getName(something);
- var name = rawname ? ': ' + rawname : '';
- return '[Function' + name + ']';
-}
-function getMessage(self) {
- return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + truncate(inspect(self.expected), 128);
-}
-
-// At present only the three keys mentioned above are used and
-// understood by the spec. Implementations or sub modules can pass
-// other keys to the AssertionError's constructor - they will be
-// ignored.
-
-// 3. All of the following functions must throw an AssertionError
-// when a corresponding condition is not met, with a message that
-// may be undefined if not provided. All assertion methods provide
-// both the actual and expected values to the assertion error for
-// display purposes.
-
-function fail(actual, expected, message, operator, stackStartFunction) {
- throw new assert.AssertionError({
- message: message,
- actual: actual,
- expected: expected,
- operator: operator,
- stackStartFunction: stackStartFunction
- });
-}
-
-// EXTENSION! allows for well behaved errors defined elsewhere.
-assert.fail = fail;
-
-// 4. Pure assertion tests whether a value is truthy, as determined
-// by !!guard.
-// assert.ok(guard, message_opt);
-// This statement is equivalent to assert.equal(true, !!guard,
-// message_opt);. To test strictly for the value true, use
-// assert.strictEqual(true, guard, message_opt);.
-
-function ok(value, message) {
- if (!value) fail(value, true, message, '==', assert.ok);
-}
-assert.ok = ok;
-
-// 5. The equality assertion tests shallow, coercive equality with
-// ==.
-// assert.equal(actual, expected, message_opt);
-
-assert.equal = function equal(actual, expected, message) {
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
-};
-
-// 6. The non-equality assertion tests for whether two objects are not equal
-// with != assert.notEqual(actual, expected, message_opt);
-
-assert.notEqual = function notEqual(actual, expected, message) {
- if (actual == expected) {
- fail(actual, expected, message, '!=', assert.notEqual);
- }
-};
-
-// 7. The equivalence assertion tests a deep equality relation.
-// assert.deepEqual(actual, expected, message_opt);
-
-assert.deepEqual = function deepEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
- }
-};
-
-assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
- }
-};
-
-function _deepEqual(actual, expected, strict, memos) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
- } else if (isBuffer(actual) && isBuffer(expected)) {
- return compare(actual, expected) === 0;
-
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (util.isDate(actual) && util.isDate(expected)) {
- return actual.getTime() === expected.getTime();
-
- // 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source and
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
- return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
-
- // 7.4. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) {
- return strict ? actual === expected : actual == expected;
-
- // If both values are instances of typed arrays, wrap their underlying
- // ArrayBuffers in a Buffer each to increase performance
- // This optimization requires the arrays to have the same type as checked by
- // Object.prototype.toString (aka pToString). Never perform binary
- // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
- // bit patterns are not identical.
- } else if (isView(actual) && isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || actual instanceof Float64Array)) {
- return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0;
-
- // 7.5 For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else if (isBuffer(actual) !== isBuffer(expected)) {
- return false;
- } else {
- memos = memos || { actual: [], expected: [] };
-
- var actualIndex = memos.actual.indexOf(actual);
- if (actualIndex !== -1) {
- if (actualIndex === memos.expected.indexOf(expected)) {
+
+ // 9. The strict equality assertion tests strict equality, as determined by ===.
+ // assert.strictEqual(actual, expected, message_opt);
+
+ assert.strictEqual = function strictEqual(actual, expected, message) {
+ if (actual !== expected) {
+ fail(actual, expected, message, '===', assert.strictEqual);
+ }
+ };
+
+ // 10. The strict non-equality assertion tests for strict inequality, as
+ // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
+
+ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
+ if (actual === expected) {
+ fail(actual, expected, message, '!==', assert.notStrictEqual);
+ }
+ };
+
+ function expectedException(actual, expected) {
+ if (!actual || !expected) {
+ return false;
+ }
+
+ if (Object.prototype.toString.call(expected) == '[object RegExp]') {
+ return expected.test(actual);
+ }
+
+ try {
+ if (actual instanceof expected) {
return true;
}
+ } catch (e) {
+ // Ignore. The instanceof check doesn't work for arrow functions.
}
-
- memos.actual.push(actual);
- memos.expected.push(expected);
-
- return objEquiv(actual, expected, strict, memos);
- }
-}
-
-function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
-}
-
-function objEquiv(a, b, strict, actualVisitedObjects) {
- if (a === null || a === undefined || b === null || b === undefined) return false;
- // if one is a primitive, the other must be same
- if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b;
- if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
- var aIsArgs = isArguments(a);
- var bIsArgs = isArguments(b);
- if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false;
- if (aIsArgs) {
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b, strict);
- }
- var ka = objectKeys(a);
- var kb = objectKeys(b);
- var key, i;
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length !== kb.length) return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] !== kb[i]) return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false;
- }
- return true;
-}
-
-// 8. The non-equivalence assertion tests for any deep inequality.
-// assert.notDeepEqual(actual, expected, message_opt);
-
-assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
- }
-};
-
-assert.notDeepStrictEqual = notDeepStrictEqual;
-function notDeepStrictEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
- }
-}
-
-// 9. The strict equality assertion tests strict equality, as determined by ===.
-// assert.strictEqual(actual, expected, message_opt);
-
-assert.strictEqual = function strictEqual(actual, expected, message) {
- if (actual !== expected) {
- fail(actual, expected, message, '===', assert.strictEqual);
- }
-};
-
-// 10. The strict non-equality assertion tests for strict inequality, as
-// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
-
-assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
- if (actual === expected) {
- fail(actual, expected, message, '!==', assert.notStrictEqual);
- }
-};
-
-function expectedException(actual, expected) {
- if (!actual || !expected) {
- return false;
- }
-
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
- return expected.test(actual);
- }
-
- try {
- if (actual instanceof expected) {
- return true;
+
+ if (Error.isPrototypeOf(expected)) {
+ return false;
}
- } catch (e) {
- // Ignore. The instanceof check doesn't work for arrow functions.
- }
-
- if (Error.isPrototypeOf(expected)) {
- return false;
+
+ return expected.call({}, actual) === true;
}
-
- return expected.call({}, actual) === true;
-}
-
-function _tryBlock(block) {
- var error;
- try {
- block();
- } catch (e) {
- error = e;
- }
- return error;
-}
-
-function _throws(shouldThrow, block, expected, message) {
- var actual;
-
- if (typeof block !== 'function') {
- throw new TypeError('"block" argument must be a function');
- }
-
- if (typeof expected === 'string') {
- message = expected;
- expected = null;
- }
-
- actual = _tryBlock(block);
-
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.');
-
- if (shouldThrow && !actual) {
- fail(actual, expected, 'Missing expected exception' + message);
- }
-
- var userProvidedMessage = typeof message === 'string';
- var isUnwantedException = !shouldThrow && util.isError(actual);
- var isUnexpectedException = !shouldThrow && actual && !expected;
-
- if (isUnwantedException && userProvidedMessage && expectedException(actual, expected) || isUnexpectedException) {
- fail(actual, expected, 'Got unwanted exception' + message);
- }
-
- if (shouldThrow && actual && expected && !expectedException(actual, expected) || !shouldThrow && actual) {
- throw actual;
- }
-}
-
-// 11. Expected to throw an error:
-// assert.throws(block, Error_opt, message_opt);
-
-assert.throws = function (block, /*optional*/error, /*optional*/message) {
- _throws(true, block, error, message);
-};
-
-// EXTENSION! This is annoying to write outside this module.
-assert.doesNotThrow = function (block, /*optional*/error, /*optional*/message) {
- _throws(false, block, error, message);
-};
-
-assert.ifError = function (err) {
- if (err) throw err;
-};
-
-var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- if (hasOwn.call(obj, key)) keys.push(key);
- }
- return keys;
-};
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"util/":4}],2:[function(require,module,exports){
-if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
+
+ function _tryBlock(block) {
+ var error;
+ try {
+ block();
+ } catch (e) {
+ error = e;
+ }
+ return error;
+ }
+
+ function _throws(shouldThrow, block, expected, message) {
+ var actual;
+
+ if (typeof block !== 'function') {
+ throw new TypeError('"block" argument must be a function');
+ }
+
+ if (typeof expected === 'string') {
+ message = expected;
+ expected = null;
+ }
+
+ actual = _tryBlock(block);
+
+ message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.');
+
+ if (shouldThrow && !actual) {
+ fail(actual, expected, 'Missing expected exception' + message);
+ }
+
+ var userProvidedMessage = typeof message === 'string';
+ var isUnwantedException = !shouldThrow && util.isError(actual);
+ var isUnexpectedException = !shouldThrow && actual && !expected;
+
+ if (isUnwantedException && userProvidedMessage && expectedException(actual, expected) || isUnexpectedException) {
+ fail(actual, expected, 'Got unwanted exception' + message);
+ }
+
+ if (shouldThrow && actual && expected && !expectedException(actual, expected) || !shouldThrow && actual) {
+ throw actual;
+ }
+ }
+
+ // 11. Expected to throw an error:
+ // assert.throws(block, Error_opt, message_opt);
+
+ assert.throws = function (block, /*optional*/error, /*optional*/message) {
+ _throws(true, block, error, message);
};
-} else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
+
+ // EXTENSION! This is annoying to write outside this module.
+ assert.doesNotThrow = function (block, /*optional*/error, /*optional*/message) {
+ _throws(false, block, error, message);
};
-}
-},{}],3:[function(require,module,exports){
-module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
-};
-},{}],4:[function(require,module,exports){
-(function (process,global){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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.
-
-var formatRegExp = /%[sdj%]/g;
-exports.format = function (f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
-
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function (x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s':
- return String(args[i++]);
- case '%d':
- return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
+
+ assert.ifError = function (err) {
+ if (err) throw err;
+ };
+
+ // Expose a strict only variant of assert
+ function strict(value, message) {
+ if (!value) fail(value, true, message, '==', strict);
+ }
+ assert.strict = objectAssign(strict, assert, {
+ equal: assert.strictEqual,
+ deepEqual: assert.deepStrictEqual,
+ notEqual: assert.notStrictEqual,
+ notDeepEqual: assert.notDeepStrictEqual
});
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
-};
-
-// Mark that a method should not be used.
-// Returns a modified function which warns once by default.
-// If --no-deprecation is set, then it is a no-op.
-exports.deprecate = function (fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function () {
- return exports.deprecate(fn, msg).apply(this, arguments);
+ assert.strict.strict = assert.strict;
+
+ var objectKeys = Object.keys || function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ if (hasOwn.call(obj, key)) keys.push(key);
+ }
+ return keys;
+ };
+ }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{"object-assign":93,"util/":4}],2:[function(require,module,exports){
+ if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+ } else {
+ // old school shim for old browsers
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
};
}
-
- if (process.noDeprecation === true) {
- return fn;
- }
-
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
+ },{}],3:[function(require,module,exports){
+ module.exports = function isBuffer(arg) {
+ return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
+ };
+ },{}],4:[function(require,module,exports){
+ (function (process,global){(function (){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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.
+
+ var formatRegExp = /%[sdj%]/g;
+ exports.format = function (f) {
+ if (!isString(f)) {
+ var objects = [];
+ for (var i = 0; i < arguments.length; i++) {
+ objects.push(inspect(arguments[i]));
+ }
+ return objects.join(' ');
+ }
+
+ var i = 1;
+ var args = arguments;
+ var len = args.length;
+ var str = String(f).replace(formatRegExp, function (x) {
+ if (x === '%%') return '%';
+ if (i >= len) return x;
+ switch (x) {
+ case '%s':
+ return String(args[i++]);
+ case '%d':
+ return Number(args[i++]);
+ case '%j':
+ try {
+ return JSON.stringify(args[i++]);
+ } catch (_) {
+ return '[Circular]';
+ }
+ default:
+ return x;
+ }
+ });
+ for (var x = args[i]; i < len; x = args[++i]) {
+ if (isNull(x) || !isObject(x)) {
+ str += ' ' + x;
} else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
-
- return deprecated;
-};
-
-var debugs = {};
-var debugEnviron;
-exports.debuglog = function (set) {
- if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function () {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
+ str += ' ' + inspect(x);
+ }
+ }
+ return str;
+ };
+
+ // Mark that a method should not be used.
+ // Returns a modified function which warns once by default.
+ // If --no-deprecation is set, then it is a no-op.
+ exports.deprecate = function (fn, msg) {
+ // Allow for deprecating things in the process of starting up.
+ if (isUndefined(global.process)) {
+ return function () {
+ return exports.deprecate(fn, msg).apply(this, arguments);
};
- } else {
- debugs[set] = function () {};
- }
- }
- return debugs[set];
-};
-
-/**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
-/* legacy: obj, showHidden, depth, colors*/
-function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
+ }
+
+ if (process.noDeprecation === true) {
+ return fn;
+ }
+
+ var warned = false;
+ function deprecated() {
+ if (!warned) {
+ if (process.throwDeprecation) {
+ throw new Error(msg);
+ } else if (process.traceDeprecation) {
+ console.trace(msg);
+ } else {
+ console.error(msg);
+ }
+ warned = true;
+ }
+ return fn.apply(this, arguments);
+ }
+
+ return deprecated;
};
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
+
+ var debugs = {};
+ var debugEnviron;
+ exports.debuglog = function (set) {
+ if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || '';
+ set = set.toUpperCase();
+ if (!debugs[set]) {
+ if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
+ var pid = process.pid;
+ debugs[set] = function () {
+ var msg = exports.format.apply(exports, arguments);
+ console.error('%s %d: %s', set, pid, msg);
+ };
+ } else {
+ debugs[set] = function () {};
+ }
+ }
+ return debugs[set];
+ };
+
+ /**
+ * Echos the value of a value. Trys to print the value out
+ * in the best way possible given the different types.
+ *
+ * @param {Object} obj The object to print out.
+ * @param {Object} opts Optional options object that alters the output.
+ */
+ /* legacy: obj, showHidden, depth, colors*/
+ function inspect(obj, opts) {
+ // default options
+ var ctx = {
+ seen: [],
+ stylize: stylizeNoColor
+ };
// legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
-}
-exports.inspect = inspect;
-
-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
-inspect.colors = {
- 'bold': [1, 22],
- 'italic': [3, 23],
- 'underline': [4, 24],
- 'inverse': [7, 27],
- 'white': [37, 39],
- 'grey': [90, 39],
- 'black': [30, 39],
- 'blue': [34, 39],
- 'cyan': [36, 39],
- 'green': [32, 39],
- 'magenta': [35, 39],
- 'red': [31, 39],
- 'yellow': [33, 39]
-};
-
-// Don't use 'blue' not visible on cmd.exe
-inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
-};
-
-function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
-
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
+ if (arguments.length >= 3) ctx.depth = arguments[2];
+ if (arguments.length >= 4) ctx.colors = arguments[3];
+ if (isBoolean(opts)) {
+ // legacy...
+ ctx.showHidden = opts;
+ } else if (opts) {
+ // got an "options" object
+ exports._extend(ctx, opts);
+ }
+ // set default options
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
+ if (isUndefined(ctx.colors)) ctx.colors = false;
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
+ return formatValue(ctx, obj, ctx.depth);
+ }
+ exports.inspect = inspect;
+
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
+ inspect.colors = {
+ 'bold': [1, 22],
+ 'italic': [3, 23],
+ 'underline': [4, 24],
+ 'inverse': [7, 27],
+ 'white': [37, 39],
+ 'grey': [90, 39],
+ 'black': [30, 39],
+ 'blue': [34, 39],
+ 'cyan': [36, 39],
+ 'green': [32, 39],
+ 'magenta': [35, 39],
+ 'red': [31, 39],
+ 'yellow': [33, 39]
+ };
+
+ // Don't use 'blue' not visible on cmd.exe
+ inspect.styles = {
+ 'special': 'cyan',
+ 'number': 'yellow',
+ 'boolean': 'yellow',
+ 'undefined': 'grey',
+ 'null': 'bold',
+ 'string': 'green',
+ 'date': 'magenta',
+ // "name": intentionally not styling
+ 'regexp': 'red'
+ };
+
+ function stylizeWithColor(str, styleType) {
+ var style = inspect.styles[styleType];
+
+ if (style) {
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm';
+ } else {
+ return str;
+ }
+ }
+
+ function stylizeNoColor(str, styleType) {
return str;
}
-}
-
-function stylizeNoColor(str, styleType) {
- return str;
-}
-
-function arrayToHash(array) {
- var hash = {};
-
- array.forEach(function (val, idx) {
- hash[val] = true;
- });
-
- return hash;
-}
-
-function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect && value && isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
+
+ function arrayToHash(array) {
+ var hash = {};
+
+ array.forEach(function (val, idx) {
+ hash[val] = true;
+ });
+
+ return hash;
+ }
+
+ function formatValue(ctx, value, recurseTimes) {
+ // Provide a hook for user-specified inspect functions.
+ // Check that value is an object with an inspect function on it
+ if (ctx.customInspect && value && isFunction(value.inspect) &&
+ // Filter out the util module, it's inspect function is special
+ value.inspect !== exports.inspect &&
+ // Also filter out any prototype objects using the circular check.
+ !(value.constructor && value.constructor.prototype === value)) {
+ var ret = value.inspect(recurseTimes, ctx);
+ if (!isString(ret)) {
+ ret = formatValue(ctx, ret, recurseTimes);
+ }
+ return ret;
+ }
+
+ // Primitive types cannot have properties
+ var primitive = formatPrimitive(ctx, value);
+ if (primitive) {
+ return primitive;
+ }
+
+ // Look up the keys of the object.
+ var keys = Object.keys(value);
+ var visibleKeys = arrayToHash(keys);
+
+ if (ctx.showHidden) {
+ keys = Object.getOwnPropertyNames(value);
+ }
+
+ // IE doesn't make error fields non-enumerable
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
+ if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
+ return formatError(value);
}
- return ret;
- }
-
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
-
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
-
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
-
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
-
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
+
+ // Some type of object without properties can be shortcutted.
+ if (keys.length === 0) {
+ if (isFunction(value)) {
+ var name = value.name ? ': ' + value.name : '';
+ return ctx.stylize('[Function' + name + ']', 'special');
+ }
+ if (isRegExp(value)) {
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+ }
+ if (isDate(value)) {
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
+ }
+ if (isError(value)) {
+ return formatError(value);
+ }
+ }
+
+ var base = '',
+ array = false,
+ braces = ['{', '}'];
+
+ // Make Array say that they are Array
+ if (isArray(value)) {
+ array = true;
+ braces = ['[', ']'];
+ }
+
+ // Make functions say that they are functions
if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
+ var n = value.name ? ': ' + value.name : '';
+ base = ' [Function' + n + ']';
}
+
+ // Make RegExps say that they are RegExps
if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+ base = ' ' + RegExp.prototype.toString.call(value);
}
+
+ // Make dates with properties first say the date
if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
+ base = ' ' + Date.prototype.toUTCString.call(value);
}
+
+ // Make error with message first say the error
if (isError(value)) {
- return formatError(value);
+ base = ' ' + formatError(value);
}
- }
-
- var base = '',
- array = false,
- braces = ['{', '}'];
-
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
-
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
-
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
-
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
-
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
-
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
-
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+
+ if (keys.length === 0 && (!array || value.length == 0)) {
+ return braces[0] + base + braces[1];
+ }
+
+ if (recurseTimes < 0) {
+ if (isRegExp(value)) {
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+ } else {
+ return ctx.stylize('[Object]', 'special');
+ }
+ }
+
+ ctx.seen.push(value);
+
+ var output;
+ if (array) {
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
- return ctx.stylize('[Object]', 'special');
+ output = keys.map(function (key) {
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
+ });
}
- }
-
- ctx.seen.push(value);
-
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function (key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
+
+ ctx.seen.pop();
+
+ return reduceToSingleString(output, base, braces);
+ }
+
+ function formatPrimitive(ctx, value) {
+ if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
+ if (isString(value)) {
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
+ return ctx.stylize(simple, 'string');
+ }
+ if (isNumber(value)) return ctx.stylize('' + value, 'number');
+ if (isBoolean(value)) return ctx.stylize('' + value, 'boolean');
+ // For some reason typeof null is "object", so special case here.
+ if (isNull(value)) return ctx.stylize('null', 'null');
+ }
+
+ function formatError(value) {
+ return '[' + Error.prototype.toString.call(value) + ']';
+ }
+
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
+ var output = [];
+ for (var i = 0, l = value.length; i < l; ++i) {
+ if (hasOwnProperty(value, String(i))) {
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
+ } else {
+ output.push('');
+ }
+ }
+ keys.forEach(function (key) {
+ if (!key.match(/^\d+$/)) {
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
+ }
});
- }
-
- ctx.seen.pop();
-
- return reduceToSingleString(output, base, braces);
-}
-
-function formatPrimitive(ctx, value) {
- if (isUndefined(value)) return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value)) return ctx.stylize('' + value, 'number');
- if (isBoolean(value)) return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value)) return ctx.stylize('null', 'null');
-}
-
-function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
-}
-
-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
+ return output;
+ }
+
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
+ var name, str, desc;
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
+ if (desc.get) {
+ if (desc.set) {
+ str = ctx.stylize('[Getter/Setter]', 'special');
+ } else {
+ str = ctx.stylize('[Getter]', 'special');
+ }
} else {
- output.push('');
+ if (desc.set) {
+ str = ctx.stylize('[Setter]', 'special');
+ }
}
- }
- keys.forEach(function (key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
+ if (!hasOwnProperty(visibleKeys, key)) {
+ name = '[' + key + ']';
}
- });
- return output;
-}
-
-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
+ if (!str) {
+ if (ctx.seen.indexOf(desc.value) < 0) {
+ if (isNull(recurseTimes)) {
+ str = formatValue(ctx, desc.value, null);
+ } else {
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
+ }
+ if (str.indexOf('\n') > -1) {
+ if (array) {
+ str = str.split('\n').map(function (line) {
+ return ' ' + line;
+ }).join('\n').substr(2);
+ } else {
+ str = '\n' + str.split('\n').map(function (line) {
+ return ' ' + line;
+ }).join('\n');
+ }
+ }
+ } else {
+ str = ctx.stylize('[Circular]', 'special');
+ }
}
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
+ if (isUndefined(name)) {
+ if (array && key.match(/^\d+$/)) {
+ return str;
+ }
+ name = JSON.stringify('' + key);
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
+ name = name.substr(1, name.length - 2);
+ name = ctx.stylize(name, 'name');
+ } else {
+ name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
+ name = ctx.stylize(name, 'string');
+ }
}
+
+ return name + ': ' + str;
+ }
+
+ function reduceToSingleString(output, base, braces) {
+ var numLinesEst = 0;
+ var length = output.reduce(function (prev, cur) {
+ numLinesEst++;
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
+ }, 0);
+
+ if (length > 60) {
+ return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
+ }
+
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
+ }
+
+ // NOTE: These type checking functions intentionally don't use `instanceof`
+ // because it is fragile and can be easily faked with `Object.create()`.
+ function isArray(ar) {
+ return Array.isArray(ar);
+ }
+ exports.isArray = isArray;
+
+ function isBoolean(arg) {
+ return typeof arg === 'boolean';
+ }
+ exports.isBoolean = isBoolean;
+
+ function isNull(arg) {
+ return arg === null;
+ }
+ exports.isNull = isNull;
+
+ function isNullOrUndefined(arg) {
+ return arg == null;
}
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
+ exports.isNullOrUndefined = isNullOrUndefined;
+
+ function isNumber(arg) {
+ return typeof arg === 'number';
}
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
+ exports.isNumber = isNumber;
+
+ function isString(arg) {
+ return typeof arg === 'string';
+ }
+ exports.isString = isString;
+
+ function isSymbol(arg) {
+ return typeof arg === 'symbol';
+ }
+ exports.isSymbol = isSymbol;
+
+ function isUndefined(arg) {
+ return arg === void 0;
+ }
+ exports.isUndefined = isUndefined;
+
+ function isRegExp(re) {
+ return isObject(re) && objectToString(re) === '[object RegExp]';
+ }
+ exports.isRegExp = isRegExp;
+
+ function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+ }
+ exports.isObject = isObject;
+
+ function isDate(d) {
+ return isObject(d) && objectToString(d) === '[object Date]';
+ }
+ exports.isDate = isDate;
+
+ function isError(e) {
+ return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
+ }
+ exports.isError = isError;
+
+ function isFunction(arg) {
+ return typeof arg === 'function';
+ }
+ exports.isFunction = isFunction;
+
+ function isPrimitive(arg) {
+ return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol
+ typeof arg === 'undefined';
+ }
+ exports.isPrimitive = isPrimitive;
+
+ exports.isBuffer = require('./support/isBuffer');
+
+ function objectToString(o) {
+ return Object.prototype.toString.call(o);
+ }
+
+ function pad(n) {
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
+ }
+
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+
+ // 26 Feb 16:19:34
+ function timestamp() {
+ var d = new Date();
+ var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
+ }
+
+ // log is just a thin wrapper to console.log that prepends a timestamp
+ exports.log = function () {
+ console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
+ };
+
+ /**
+ * Inherit the prototype methods from one constructor into another.
+ *
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
+ * during bootstrapping this function needs to be rewritten using some native
+ * functions as prototype setup using normal JavaScript does not work as
+ * expected during bootstrapping (see mirror.js in r114903).
+ *
+ * @param {function} ctor Constructor function which needs to inherit the
+ * prototype.
+ * @param {function} superCtor Constructor function to inherit prototype from.
+ */
+ exports.inherits = require('inherits');
+
+ exports._extend = function (origin, add) {
+ // Don't do anything if add isn't an object
+ if (!add || !isObject(add)) return origin;
+
+ var keys = Object.keys(add);
+ var i = keys.length;
+ while (i--) {
+ origin[keys[i]] = add[keys[i]];
+ }
+ return origin;
+ };
+
+ function hasOwnProperty(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+ }
+ }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{"./support/isBuffer":3,"_process":105,"inherits":2}],5:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = balanced;
+ function balanced(a, b, str) {
+ if (a instanceof RegExp) a = maybeMatch(a, str);
+ if (b instanceof RegExp) b = maybeMatch(b, str);
+
+ var r = range(a, b, str);
+
+ return r && {
+ start: r[0],
+ end: r[1],
+ pre: str.slice(0, r[0]),
+ body: str.slice(r[0] + a.length, r[1]),
+ post: str.slice(r[1] + b.length)
+ };
+ }
+
+ function maybeMatch(reg, str) {
+ var m = str.match(reg);
+ return m ? m[0] : null;
+ }
+
+ balanced.range = range;
+ function range(a, b, str) {
+ var begs, beg, left, right, result;
+ var ai = str.indexOf(a);
+ var bi = str.indexOf(b, ai + 1);
+ var i = ai;
+
+ if (ai >= 0 && bi > 0) {
+ if (a === b) {
+ return [ai, bi];
}
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function (line) {
- return ' ' + line;
- }).join('\n').substr(2);
+ begs = [];
+ left = str.length;
+
+ while (i >= 0 && !result) {
+ if (i == ai) {
+ begs.push(i);
+ ai = str.indexOf(a, i + 1);
+ } else if (begs.length == 1) {
+ result = [begs.pop(), bi];
} else {
- str = '\n' + str.split('\n').map(function (line) {
- return ' ' + line;
- }).join('\n');
+ beg = begs.pop();
+ if (beg < left) {
+ left = beg;
+ right = bi;
+ }
+
+ bi = str.indexOf(b, i + 1);
}
+
+ i = ai < bi && ai >= 0 ? ai : bi;
+ }
+
+ if (begs.length) {
+ result = [left, right];
}
- } else {
- str = ctx.stylize('[Circular]', 'special');
}
+
+ return result;
}
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
-
- return name + ': ' + str;
-}
-
-function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function (prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
-
- if (length > 60) {
- return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
- }
-
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
-}
-
-// NOTE: These type checking functions intentionally don't use `instanceof`
-// because it is fragile and can be easily faked with `Object.create()`.
-function isArray(ar) {
- return Array.isArray(ar);
-}
-exports.isArray = isArray;
-
-function isBoolean(arg) {
- return typeof arg === 'boolean';
-}
-exports.isBoolean = isBoolean;
-
-function isNull(arg) {
- return arg === null;
-}
-exports.isNull = isNull;
-
-function isNullOrUndefined(arg) {
- return arg == null;
-}
-exports.isNullOrUndefined = isNullOrUndefined;
-
-function isNumber(arg) {
- return typeof arg === 'number';
-}
-exports.isNumber = isNumber;
-
-function isString(arg) {
- return typeof arg === 'string';
-}
-exports.isString = isString;
-
-function isSymbol(arg) {
- return typeof arg === 'symbol';
-}
-exports.isSymbol = isSymbol;
-
-function isUndefined(arg) {
- return arg === void 0;
-}
-exports.isUndefined = isUndefined;
-
-function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
-}
-exports.isRegExp = isRegExp;
-
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
-exports.isObject = isObject;
-
-function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
-}
-exports.isDate = isDate;
-
-function isError(e) {
- return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
-}
-exports.isError = isError;
-
-function isFunction(arg) {
- return typeof arg === 'function';
-}
-exports.isFunction = isFunction;
-
-function isPrimitive(arg) {
- return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
-}
-exports.isPrimitive = isPrimitive;
-
-exports.isBuffer = require('./support/isBuffer');
-
-function objectToString(o) {
- return Object.prototype.toString.call(o);
-}
-
-function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
-}
-
-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
-
-// 26 Feb 16:19:34
-function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
-}
-
-// log is just a thin wrapper to console.log that prepends a timestamp
-exports.log = function () {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
-};
-
-/**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
-exports.inherits = require('inherits');
-
-exports._extend = function (origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
-
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
-};
-
-function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./support/isBuffer":3,"_process":101,"inherits":2}],5:[function(require,module,exports){
-'use strict';
-
-module.exports = balanced;
-function balanced(a, b, str) {
- if (a instanceof RegExp) a = maybeMatch(a, str);
- if (b instanceof RegExp) b = maybeMatch(b, str);
-
- var r = range(a, b, str);
-
- return r && {
- start: r[0],
- end: r[1],
- pre: str.slice(0, r[0]),
- body: str.slice(r[0] + a.length, r[1]),
- post: str.slice(r[1] + b.length)
+ },{}],6:[function(require,module,exports){
+ var document = require('global/document');
+ var hyperx = require('hyperx');
+ var onload = require('on-load');
+
+ var SVGNS = 'http://www.w3.org/2000/svg';
+ var XLINKNS = 'http://www.w3.org/1999/xlink';
+
+ var BOOL_PROPS = {
+ autofocus: 1,
+ checked: 1,
+ defaultchecked: 1,
+ disabled: 1,
+ formnovalidate: 1,
+ indeterminate: 1,
+ readonly: 1,
+ required: 1,
+ selected: 1,
+ willvalidate: 1
};
-}
-
-function maybeMatch(reg, str) {
- var m = str.match(reg);
- return m ? m[0] : null;
-}
-
-balanced.range = range;
-function range(a, b, str) {
- var begs, beg, left, right, result;
- var ai = str.indexOf(a);
- var bi = str.indexOf(b, ai + 1);
- var i = ai;
-
- if (ai >= 0 && bi > 0) {
- begs = [];
- left = str.length;
-
- while (i >= 0 && !result) {
- if (i == ai) {
- begs.push(i);
- ai = str.indexOf(a, i + 1);
- } else if (begs.length == 1) {
- result = [begs.pop(), bi];
- } else {
- beg = begs.pop();
- if (beg < left) {
- left = beg;
- right = bi;
+ var COMMENT_TAG = '!--';
+ var SVG_TAGS = ['svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'];
+
+ function belCreateElement(tag, props, children) {
+ var el;
+
+ // If an svg tag, it needs a namespace
+ if (SVG_TAGS.indexOf(tag) !== -1) {
+ props.namespace = SVGNS;
+ }
+
+ // If we are using a namespace
+ var ns = false;
+ if (props.namespace) {
+ ns = props.namespace;
+ delete props.namespace;
+ }
+
+ // Create the element
+ if (ns) {
+ el = document.createElementNS(ns, tag);
+ } else if (tag === COMMENT_TAG) {
+ return document.createComment(props.comment);
+ } else {
+ el = document.createElement(tag);
+ }
+
+ // If adding onload events
+ if (props.onload || props.onunload) {
+ var load = props.onload || function () {};
+ var unload = props.onunload || function () {};
+ onload(el, function belOnload() {
+ load(el);
+ }, function belOnunload() {
+ unload(el);
+ },
+ // We have to use non-standard `caller` to find who invokes `belCreateElement`
+ belCreateElement.caller.caller.caller);
+ delete props.onload;
+ delete props.onunload;
+ }
+
+ // Create the properties
+ for (var p in props) {
+ if (props.hasOwnProperty(p)) {
+ var key = p.toLowerCase();
+ var val = props[p];
+ // Normalize className
+ if (key === 'classname') {
+ key = 'class';
+ p = 'class';
}
-
- bi = str.indexOf(b, i + 1);
- }
-
- i = ai < bi && ai >= 0 ? ai : bi;
- }
-
- if (begs.length) {
- result = [left, right];
- }
- }
-
- return result;
-}
-},{}],6:[function(require,module,exports){
-var document = require('global/document');
-var hyperx = require('hyperx');
-var onload = require('on-load');
-
-var SVGNS = 'http://www.w3.org/2000/svg';
-var XLINKNS = 'http://www.w3.org/1999/xlink';
-
-var BOOL_PROPS = {
- autofocus: 1,
- checked: 1,
- defaultchecked: 1,
- disabled: 1,
- formnovalidate: 1,
- indeterminate: 1,
- readonly: 1,
- required: 1,
- selected: 1,
- willvalidate: 1
-};
-var COMMENT_TAG = '!--';
-var SVG_TAGS = ['svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'];
-
-function belCreateElement(tag, props, children) {
- var el;
-
- // If an svg tag, it needs a namespace
- if (SVG_TAGS.indexOf(tag) !== -1) {
- props.namespace = SVGNS;
- }
-
- // If we are using a namespace
- var ns = false;
- if (props.namespace) {
- ns = props.namespace;
- delete props.namespace;
- }
-
- // Create the element
- if (ns) {
- el = document.createElementNS(ns, tag);
- } else if (tag === COMMENT_TAG) {
- return document.createComment(props.comment);
- } else {
- el = document.createElement(tag);
- }
-
- // If adding onload events
- if (props.onload || props.onunload) {
- var load = props.onload || function () {};
- var unload = props.onunload || function () {};
- onload(el, function belOnload() {
- load(el);
- }, function belOnunload() {
- unload(el);
- },
- // We have to use non-standard `caller` to find who invokes `belCreateElement`
- belCreateElement.caller.caller.caller);
- delete props.onload;
- delete props.onunload;
- }
-
- // Create the properties
- for (var p in props) {
- if (props.hasOwnProperty(p)) {
- var key = p.toLowerCase();
- var val = props[p];
- // Normalize className
- if (key === 'classname') {
- key = 'class';
- p = 'class';
- }
- // The for attribute gets transformed to htmlFor, but we just set as for
- if (p === 'htmlFor') {
- p = 'for';
- }
- // If a property is boolean, set itself to the key
- if (BOOL_PROPS[key]) {
- if (val === 'true') val = key;else if (val === 'false') continue;
- }
- // If a property prefers being set directly vs setAttribute
- if (key.slice(0, 2) === 'on') {
- el[p] = val;
- } else {
- if (ns) {
- if (p === 'xlink:href') {
- el.setAttributeNS(XLINKNS, p, val);
- } else if (/^xmlns($|:)/i.test(p)) {
- // skip xmlns definitions
+ // The for attribute gets transformed to htmlFor, but we just set as for
+ if (p === 'htmlFor') {
+ p = 'for';
+ }
+ // If a property is boolean, set itself to the key
+ if (BOOL_PROPS[key]) {
+ if (val === 'true') val = key;else if (val === 'false') continue;
+ }
+ // If a property prefers being set directly vs setAttribute
+ if (key.slice(0, 2) === 'on') {
+ el[p] = val;
+ } else {
+ if (ns) {
+ if (p === 'xlink:href') {
+ el.setAttributeNS(XLINKNS, p, val);
+ } else if (/^xmlns($|:)/i.test(p)) {
+ // skip xmlns definitions
+ } else {
+ el.setAttributeNS(null, p, val);
+ }
} else {
- el.setAttributeNS(null, p, val);
+ el.setAttribute(p, val);
}
- } else {
- el.setAttribute(p, val);
}
}
}
- }
-
- function appendChild(childs) {
- if (!Array.isArray(childs)) return;
- for (var i = 0; i < childs.length; i++) {
- var node = childs[i];
- if (Array.isArray(node)) {
- appendChild(node);
- continue;
- }
-
- if (typeof node === 'number' || typeof node === 'boolean' || typeof node === 'function' || node instanceof Date || node instanceof RegExp) {
- node = node.toString();
- }
-
- if (typeof node === 'string') {
- if (el.lastChild && el.lastChild.nodeName === '#text') {
- el.lastChild.nodeValue += node;
+
+ function appendChild(childs) {
+ if (!Array.isArray(childs)) return;
+ for (var i = 0; i < childs.length; i++) {
+ var node = childs[i];
+ if (Array.isArray(node)) {
+ appendChild(node);
continue;
}
- node = document.createTextNode(node);
+
+ if (typeof node === 'number' || typeof node === 'boolean' || typeof node === 'function' || node instanceof Date || node instanceof RegExp) {
+ node = node.toString();
+ }
+
+ if (typeof node === 'string') {
+ if (el.lastChild && el.lastChild.nodeName === '#text') {
+ el.lastChild.nodeValue += node;
+ continue;
+ }
+ node = document.createTextNode(node);
+ }
+
+ if (node && node.nodeType) {
+ el.appendChild(node);
+ }
}
-
- if (node && node.nodeType) {
- el.appendChild(node);
+ }
+ appendChild(children);
+
+ return el;
+ }
+
+ module.exports = hyperx(belCreateElement, { comments: true });
+ module.exports.default = module.exports;
+ module.exports.createElement = belCreateElement;
+ },{"global/document":20,"hyperx":25,"on-load":98}],7:[function(require,module,exports){
+ var concatMap = require('concat-map');
+ var balanced = require('balanced-match');
+
+ module.exports = expandTop;
+
+ var escSlash = '\0SLASH' + Math.random() + '\0';
+ var escOpen = '\0OPEN' + Math.random() + '\0';
+ var escClose = '\0CLOSE' + Math.random() + '\0';
+ var escComma = '\0COMMA' + Math.random() + '\0';
+ var escPeriod = '\0PERIOD' + Math.random() + '\0';
+
+ function numeric(str) {
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
+ }
+
+ function escapeBraces(str) {
+ return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
+ }
+
+ function unescapeBraces(str) {
+ return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
+ }
+
+ // Basically just str.split(","), but handling cases
+ // where we have nested braced sections, which should be
+ // treated as individual members, like {a,{b,c},d}
+ function parseCommaParts(str) {
+ if (!str) return [''];
+
+ var parts = [];
+ var m = balanced('{', '}', str);
+
+ if (!m) return str.split(',');
+
+ var pre = m.pre;
+ var body = m.body;
+ var post = m.post;
+ var p = pre.split(',');
+
+ p[p.length - 1] += '{' + body + '}';
+ var postParts = parseCommaParts(post);
+ if (post.length) {
+ p[p.length - 1] += postParts.shift();
+ p.push.apply(p, postParts);
+ }
+
+ parts.push.apply(parts, p);
+
+ return parts;
+ }
+
+ function expandTop(str) {
+ if (!str) return [];
+
+ // I don't know why Bash 4.3 does this, but it does.
+ // Anything starting with {} will have the first two bytes preserved
+ // but *only* at the top level, so {},a}b will not expand to anything,
+ // but a{},b}c will be expanded to [a}c,abc].
+ // One could argue that this is a bug in Bash, but since the goal of
+ // this module is to match Bash's rules, we escape a leading {}
+ if (str.substr(0, 2) === '{}') {
+ str = '\\{\\}' + str.substr(2);
+ }
+
+ return expand(escapeBraces(str), true).map(unescapeBraces);
+ }
+
+ function identity(e) {
+ return e;
+ }
+
+ function embrace(str) {
+ return '{' + str + '}';
+ }
+ function isPadded(el) {
+ return (/^-?0\d/.test(el)
+ );
+ }
+
+ function lte(i, y) {
+ return i <= y;
+ }
+ function gte(i, y) {
+ return i >= y;
+ }
+
+ function expand(str, isTop) {
+ var expansions = [];
+
+ var m = balanced('{', '}', str);
+ if (!m || /\$$/.test(m.pre)) return [str];
+
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
+ var isSequence = isNumericSequence || isAlphaSequence;
+ var isOptions = m.body.indexOf(',') >= 0;
+ if (!isSequence && !isOptions) {
+ // {a},b}
+ if (m.post.match(/,.*\}/)) {
+ str = m.pre + '{' + m.body + escClose + m.post;
+ return expand(str);
}
+ return [str];
}
- }
- appendChild(children);
-
- return el;
-}
-
-module.exports = hyperx(belCreateElement, { comments: true });
-module.exports.default = module.exports;
-module.exports.createElement = belCreateElement;
-},{"global/document":20,"hyperx":24,"on-load":94}],7:[function(require,module,exports){
-var concatMap = require('concat-map');
-var balanced = require('balanced-match');
-
-module.exports = expandTop;
-
-var escSlash = '\0SLASH' + Math.random() + '\0';
-var escOpen = '\0OPEN' + Math.random() + '\0';
-var escClose = '\0CLOSE' + Math.random() + '\0';
-var escComma = '\0COMMA' + Math.random() + '\0';
-var escPeriod = '\0PERIOD' + Math.random() + '\0';
-
-function numeric(str) {
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
-}
-
-function escapeBraces(str) {
- return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
-}
-
-function unescapeBraces(str) {
- return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
-}
-
-// Basically just str.split(","), but handling cases
-// where we have nested braced sections, which should be
-// treated as individual members, like {a,{b,c},d}
-function parseCommaParts(str) {
- if (!str) return [''];
-
- var parts = [];
- var m = balanced('{', '}', str);
-
- if (!m) return str.split(',');
-
- var pre = m.pre;
- var body = m.body;
- var post = m.post;
- var p = pre.split(',');
-
- p[p.length - 1] += '{' + body + '}';
- var postParts = parseCommaParts(post);
- if (post.length) {
- p[p.length - 1] += postParts.shift();
- p.push.apply(p, postParts);
- }
-
- parts.push.apply(parts, p);
-
- return parts;
-}
-
-function expandTop(str) {
- if (!str) return [];
-
- // I don't know why Bash 4.3 does this, but it does.
- // Anything starting with {} will have the first two bytes preserved
- // but *only* at the top level, so {},a}b will not expand to anything,
- // but a{},b}c will be expanded to [a}c,abc].
- // One could argue that this is a bug in Bash, but since the goal of
- // this module is to match Bash's rules, we escape a leading {}
- if (str.substr(0, 2) === '{}') {
- str = '\\{\\}' + str.substr(2);
- }
-
- return expand(escapeBraces(str), true).map(unescapeBraces);
-}
-
-function identity(e) {
- return e;
-}
-
-function embrace(str) {
- return '{' + str + '}';
-}
-function isPadded(el) {
- return (/^-?0\d/.test(el)
- );
-}
-
-function lte(i, y) {
- return i <= y;
-}
-function gte(i, y) {
- return i >= y;
-}
-
-function expand(str, isTop) {
- var expansions = [];
-
- var m = balanced('{', '}', str);
- if (!m || /\$$/.test(m.pre)) return [str];
-
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
- var isSequence = isNumericSequence || isAlphaSequence;
- var isOptions = m.body.indexOf(',') >= 0;
- if (!isSequence && !isOptions) {
- // {a},b}
- if (m.post.match(/,.*\}/)) {
- str = m.pre + '{' + m.body + escClose + m.post;
- return expand(str);
- }
- return [str];
- }
-
- var n;
- if (isSequence) {
- n = m.body.split(/\.\./);
- } else {
- n = parseCommaParts(m.body);
- if (n.length === 1) {
- // x{{a,b}}y ==> x{a}y x{b}y
- n = expand(n[0], false).map(embrace);
+
+ var n;
+ if (isSequence) {
+ n = m.body.split(/\.\./);
+ } else {
+ n = parseCommaParts(m.body);
if (n.length === 1) {
- var post = m.post.length ? expand(m.post, false) : [''];
- return post.map(function (p) {
- return m.pre + n[0] + p;
- });
+ // x{{a,b}}y ==> x{a}y x{b}y
+ n = expand(n[0], false).map(embrace);
+ if (n.length === 1) {
+ var post = m.post.length ? expand(m.post, false) : [''];
+ return post.map(function (p) {
+ return m.pre + n[0] + p;
+ });
+ }
}
}
- }
-
- // at this point, n is the parts, and we know it's not a comma set
- // with a single entry.
-
- // no need to expand pre, since it is guaranteed to be free of brace-sets
- var pre = m.pre;
- var post = m.post.length ? expand(m.post, false) : [''];
-
- var N;
-
- if (isSequence) {
- var x = numeric(n[0]);
- var y = numeric(n[1]);
- var width = Math.max(n[0].length, n[1].length);
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
- var test = lte;
- var reverse = y < x;
- if (reverse) {
- incr *= -1;
- test = gte;
- }
- var pad = n.some(isPadded);
-
- N = [];
-
- for (var i = x; test(i, y); i += incr) {
- var c;
- if (isAlphaSequence) {
- c = String.fromCharCode(i);
- if (c === '\\') c = '';
- } else {
- c = String(i);
- if (pad) {
- var need = width - c.length;
- if (need > 0) {
- var z = new Array(need + 1).join('0');
- if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
+
+ // at this point, n is the parts, and we know it's not a comma set
+ // with a single entry.
+
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
+ var pre = m.pre;
+ var post = m.post.length ? expand(m.post, false) : [''];
+
+ var N;
+
+ if (isSequence) {
+ var x = numeric(n[0]);
+ var y = numeric(n[1]);
+ var width = Math.max(n[0].length, n[1].length);
+ var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
+ var test = lte;
+ var reverse = y < x;
+ if (reverse) {
+ incr *= -1;
+ test = gte;
+ }
+ var pad = n.some(isPadded);
+
+ N = [];
+
+ for (var i = x; test(i, y); i += incr) {
+ var c;
+ if (isAlphaSequence) {
+ c = String.fromCharCode(i);
+ if (c === '\\') c = '';
+ } else {
+ c = String(i);
+ if (pad) {
+ var need = width - c.length;
+ if (need > 0) {
+ var z = new Array(need + 1).join('0');
+ if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
+ }
}
}
+ N.push(c);
}
- N.push(c);
- }
- } else {
- N = concatMap(n, function (el) {
- return expand(el, false);
- });
+ } else {
+ N = concatMap(n, function (el) {
+ return expand(el, false);
+ });
+ }
+
+ for (var j = 0; j < N.length; j++) {
+ for (var k = 0; k < post.length; k++) {
+ var expansion = pre + N[j] + post[k];
+ if (!isTop || isSequence || expansion) expansions.push(expansion);
+ }
+ }
+
+ return expansions;
}
-
- for (var j = 0; j < N.length; j++) {
- for (var k = 0; k < post.length; k++) {
- var expansion = pre + N[j] + post[k];
- if (!isTop || isSequence || expansion) expansions.push(expansion);
- }
- }
-
- return expansions;
-}
-},{"balanced-match":5,"concat-map":10}],8:[function(require,module,exports){
-
-},{}],9:[function(require,module,exports){
-arguments[4][8][0].apply(exports,arguments)
-},{"dup":8}],10:[function(require,module,exports){
-module.exports = function (xs, fn) {
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- var x = fn(xs[i], i);
- if (isArray(x)) res.push.apply(res, x);else res.push(x);
+ },{"balanced-match":5,"concat-map":10}],8:[function(require,module,exports){
+
+ },{}],9:[function(require,module,exports){
+ arguments[4][8][0].apply(exports,arguments)
+ },{"dup":8}],10:[function(require,module,exports){
+ module.exports = function (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ var x = fn(xs[i], i);
+ if (isArray(x)) res.push.apply(res, x);else res.push(x);
+ }
+ return res;
+ };
+
+ var isArray = Array.isArray || function (xs) {
+ return Object.prototype.toString.call(xs) === '[object Array]';
+ };
+ },{}],11:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral([''], ['']);
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var path = require('path');
+ var html = require('bel');
+
+ module.exports = main;
+
+ function main() {
+ var sprite = "";
+
+ var parentEl = html(_templateObject);
+ parentEl.innerHTML = sprite;
+ var el = parentEl.childNodes[0];
+
+ return el;
+ }
+ },{"bel":6,"path":102}],12:[function(require,module,exports){
+ /*!
+ * depd
+ * Copyright(c) 2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+ 'use strict';
+
+ /**
+ * Module exports.
+ * @public
+ */
+
+ module.exports = depd;
+
+ /**
+ * Create deprecate for namespace in caller.
+ */
+
+ function depd(namespace) {
+ if (!namespace) {
+ throw new TypeError('argument namespace is required');
+ }
+
+ function deprecate(message) {
+ // no-op in browser
+ }
+
+ deprecate._file = undefined;
+ deprecate._ignored = true;
+ deprecate._namespace = namespace;
+ deprecate._traced = false;
+ deprecate._warned = Object.create(null);
+
+ deprecate.function = wrapfunction;
+ deprecate.property = wrapproperty;
+
+ return deprecate;
+ }
+
+ /**
+ * Return a wrapped function in a deprecation message.
+ *
+ * This is a no-op version of the wrapper, which does nothing but call
+ * validation.
+ */
+
+ function wrapfunction(fn, message) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('argument fn must be a function');
}
- return res;
-};
-
-var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
-};
-},{}],11:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral([''], ['']);
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var path = require('path');
-var html = require('bel');
-
-module.exports = main;
-
-function main() {
- var sprite = "";
-
- var parentEl = html(_templateObject);
- parentEl.innerHTML = sprite;
- var el = parentEl.childNodes[0];
-
- return el;
-}
-},{"bel":6,"path":98}],12:[function(require,module,exports){
-/*!
- * depd
- * Copyright(c) 2015 Douglas Christopher Wilson
- * MIT Licensed
- */
-
-'use strict';
-
-/**
- * Module exports.
- * @public
- */
-
-module.exports = depd;
-
-/**
- * Create deprecate for namespace in caller.
- */
-
-function depd(namespace) {
- if (!namespace) {
- throw new TypeError('argument namespace is required');
- }
-
- function deprecate(message) {
- // no-op in browser
- }
-
- deprecate._file = undefined;
- deprecate._ignored = true;
- deprecate._namespace = namespace;
- deprecate._traced = false;
- deprecate._warned = Object.create(null);
-
- deprecate.function = wrapfunction;
- deprecate.property = wrapproperty;
-
- return deprecate;
-}
-
-/**
- * Return a wrapped function in a deprecation message.
- *
- * This is a no-op version of the wrapper, which does nothing but call
- * validation.
- */
-
-function wrapfunction(fn, message) {
- if (typeof fn !== 'function') {
- throw new TypeError('argument fn must be a function');
- }
-
- return fn;
-}
-
-/**
- * Wrap property in a deprecation message.
- *
- * This is a no-op version of the wrapper, which does nothing but call
- * validation.
- */
-
-function wrapproperty(obj, prop, message) {
- if (!obj || typeof obj !== 'object' && typeof obj !== 'function') {
- throw new TypeError('argument obj must be object');
- }
-
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
-
- if (!descriptor) {
- throw new TypeError('must call property on owner object');
- }
-
- if (!descriptor.configurable) {
- throw new TypeError('property must be configurable');
- }
-}
-},{}],13:[function(require,module,exports){
-'use strict';
-
-var assert = require('assert');
-
-module.exports = ready;
-
-function ready(callback) {
- assert.notEqual(typeof document, 'undefined', 'document-ready only runs in the browser');
- var state = document.readyState;
- if (state === 'complete' || state === 'interactive') {
- return setTimeout(callback, 0);
- }
-
- document.addEventListener('DOMContentLoaded', function onLoad() {
- callback();
- });
-}
-},{"assert":1}],14:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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.
-
-var objectCreate = Object.create || objectCreatePolyfill;
-var objectKeys = Object.keys || objectKeysPolyfill;
-var bind = Function.prototype.bind || functionBindPolyfill;
-
-function EventEmitter() {
- if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
- this._events = objectCreate(null);
- this._eventsCount = 0;
- }
-
- this._maxListeners = this._maxListeners || undefined;
-}
-module.exports = EventEmitter;
-
-// Backwards-compat with node 0.10.x
-EventEmitter.EventEmitter = EventEmitter;
-
-EventEmitter.prototype._events = undefined;
-EventEmitter.prototype._maxListeners = undefined;
-
-// By default EventEmitters will print a warning if more than 10 listeners are
-// added to it. This is a useful default which helps finding memory leaks.
-var defaultMaxListeners = 10;
-
-var hasDefineProperty;
-try {
- var o = {};
- if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
- hasDefineProperty = o.x === 0;
-} catch (err) {
- hasDefineProperty = false;
-}
-if (hasDefineProperty) {
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
- enumerable: true,
- get: function () {
- return defaultMaxListeners;
- },
- set: function (arg) {
- // check whether the input is a positive number (whose value is zero or
- // greater and not a NaN).
- if (typeof arg !== 'number' || arg < 0 || arg !== arg) throw new TypeError('"defaultMaxListeners" must be a positive number');
- defaultMaxListeners = arg;
+
+ return fn;
+ }
+
+ /**
+ * Wrap property in a deprecation message.
+ *
+ * This is a no-op version of the wrapper, which does nothing but call
+ * validation.
+ */
+
+ function wrapproperty(obj, prop, message) {
+ if (!obj || typeof obj !== 'object' && typeof obj !== 'function') {
+ throw new TypeError('argument obj must be object');
}
- });
-} else {
- EventEmitter.defaultMaxListeners = defaultMaxListeners;
-}
-
-// Obviously not all Emitters should be limited to 10. This function allows
-// that to be increased. Set to zero for unlimited.
-EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
- if (typeof n !== 'number' || n < 0 || isNaN(n)) throw new TypeError('"n" argument must be a positive number');
- this._maxListeners = n;
- return this;
-};
-
-function $getMaxListeners(that) {
- if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
- return that._maxListeners;
-}
-
-EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
- return $getMaxListeners(this);
-};
-
-// These standalone emit* functions are used to optimize calling of event
-// handlers for fast cases because emit() itself often has a variable number of
-// arguments and can be deoptimized because of that. These functions always have
-// the same number of arguments and thus do not get deoptimized, so the code
-// inside them can execute faster.
-function emitNone(handler, isFn, self) {
- if (isFn) handler.call(self);else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i) {
- listeners[i].call(self);
+
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
+
+ if (!descriptor) {
+ throw new TypeError('must call property on owner object');
+ }
+
+ if (!descriptor.configurable) {
+ throw new TypeError('property must be configurable');
}
}
-}
-function emitOne(handler, isFn, self, arg1) {
- if (isFn) handler.call(self, arg1);else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i) {
- listeners[i].call(self, arg1);
+ },{}],13:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = ready;
+
+ function ready(callback) {
+ if (typeof document === 'undefined') {
+ throw new Error('document-ready only runs in the browser');
+ }
+ var state = document.readyState;
+ if (state === 'complete' || state === 'interactive') {
+ return setTimeout(callback, 0);
+ }
+
+ document.addEventListener('DOMContentLoaded', function onLoad() {
+ callback();
+ });
+ }
+ },{}],14:[function(require,module,exports){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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.
+
+ var objectCreate = Object.create || objectCreatePolyfill;
+ var objectKeys = Object.keys || objectKeysPolyfill;
+ var bind = Function.prototype.bind || functionBindPolyfill;
+
+ function EventEmitter() {
+ if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
+ this._events = objectCreate(null);
+ this._eventsCount = 0;
}
+
+ this._maxListeners = this._maxListeners || undefined;
+ }
+ module.exports = EventEmitter;
+
+ // Backwards-compat with node 0.10.x
+ EventEmitter.EventEmitter = EventEmitter;
+
+ EventEmitter.prototype._events = undefined;
+ EventEmitter.prototype._maxListeners = undefined;
+
+ // By default EventEmitters will print a warning if more than 10 listeners are
+ // added to it. This is a useful default which helps finding memory leaks.
+ var defaultMaxListeners = 10;
+
+ var hasDefineProperty;
+ try {
+ var o = {};
+ if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
+ hasDefineProperty = o.x === 0;
+ } catch (err) {
+ hasDefineProperty = false;
}
-}
-function emitTwo(handler, isFn, self, arg1, arg2) {
- if (isFn) handler.call(self, arg1, arg2);else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i) {
- listeners[i].call(self, arg1, arg2);
+ if (hasDefineProperty) {
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
+ enumerable: true,
+ get: function () {
+ return defaultMaxListeners;
+ },
+ set: function (arg) {
+ // check whether the input is a positive number (whose value is zero or
+ // greater and not a NaN).
+ if (typeof arg !== 'number' || arg < 0 || arg !== arg) throw new TypeError('"defaultMaxListeners" must be a positive number');
+ defaultMaxListeners = arg;
+ }
+ });
+ } else {
+ EventEmitter.defaultMaxListeners = defaultMaxListeners;
+ }
+
+ // Obviously not all Emitters should be limited to 10. This function allows
+ // that to be increased. Set to zero for unlimited.
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
+ if (typeof n !== 'number' || n < 0 || isNaN(n)) throw new TypeError('"n" argument must be a positive number');
+ this._maxListeners = n;
+ return this;
+ };
+
+ function $getMaxListeners(that) {
+ if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
+ return that._maxListeners;
+ }
+
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
+ return $getMaxListeners(this);
+ };
+
+ // These standalone emit* functions are used to optimize calling of event
+ // handlers for fast cases because emit() itself often has a variable number of
+ // arguments and can be deoptimized because of that. These functions always have
+ // the same number of arguments and thus do not get deoptimized, so the code
+ // inside them can execute faster.
+ function emitNone(handler, isFn, self) {
+ if (isFn) handler.call(self);else {
+ var len = handler.length;
+ var listeners = arrayClone(handler, len);
+ for (var i = 0; i < len; ++i) {
+ listeners[i].call(self);
+ }
}
}
-}
-function emitThree(handler, isFn, self, arg1, arg2, arg3) {
- if (isFn) handler.call(self, arg1, arg2, arg3);else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i) {
- listeners[i].call(self, arg1, arg2, arg3);
+ function emitOne(handler, isFn, self, arg1) {
+ if (isFn) handler.call(self, arg1);else {
+ var len = handler.length;
+ var listeners = arrayClone(handler, len);
+ for (var i = 0; i < len; ++i) {
+ listeners[i].call(self, arg1);
+ }
}
}
-}
-
-function emitMany(handler, isFn, self, args) {
- if (isFn) handler.apply(self, args);else {
- var len = handler.length;
- var listeners = arrayClone(handler, len);
- for (var i = 0; i < len; ++i) {
- listeners[i].apply(self, args);
- }
- }
-}
-
-EventEmitter.prototype.emit = function emit(type) {
- var er, handler, len, args, i, events;
- var doError = type === 'error';
-
- events = this._events;
- if (events) doError = doError && events.error == null;else if (!doError) return false;
-
- // If there is no 'error' event listener then throw.
- if (doError) {
- if (arguments.length > 1) er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- } else {
- // At least give some kind of context to the user
- var err = new Error('Unhandled "error" event. (' + er + ')');
- err.context = er;
- throw err;
+ function emitTwo(handler, isFn, self, arg1, arg2) {
+ if (isFn) handler.call(self, arg1, arg2);else {
+ var len = handler.length;
+ var listeners = arrayClone(handler, len);
+ for (var i = 0; i < len; ++i) {
+ listeners[i].call(self, arg1, arg2);
+ }
}
- return false;
}
-
- handler = events[type];
-
- if (!handler) return false;
-
- var isFn = typeof handler === 'function';
- len = arguments.length;
- switch (len) {
- // fast cases
- case 1:
- emitNone(handler, isFn, this);
- break;
- case 2:
- emitOne(handler, isFn, this, arguments[1]);
- break;
- case 3:
- emitTwo(handler, isFn, this, arguments[1], arguments[2]);
- break;
- case 4:
- emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
- break;
- // slower
- default:
- args = new Array(len - 1);
- for (i = 1; i < len; i++) {
- args[i - 1] = arguments[i];
- }emitMany(handler, isFn, this, args);
- }
-
- return true;
-};
-
-function _addListener(target, type, listener, prepend) {
- var m;
- var events;
- var existing;
-
- if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
-
- events = target._events;
- if (!events) {
- events = target._events = objectCreate(null);
- target._eventsCount = 0;
- } else {
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (events.newListener) {
- target.emit('newListener', type, listener.listener ? listener.listener : listener);
-
- // Re-assign `events` because a newListener handler could have caused the
- // this._events to be assigned to a new object
- events = target._events;
- }
- existing = events[type];
- }
-
- if (!existing) {
- // Optimize the case of one listener. Don't need the extra array object.
- existing = events[type] = listener;
- ++target._eventsCount;
- } else {
- if (typeof existing === 'function') {
- // Adding the second element, need to change to array.
- existing = events[type] = prepend ? [listener, existing] : [existing, listener];
- } else {
- // If we've already got an array, just append.
- if (prepend) {
- existing.unshift(listener);
- } else {
- existing.push(listener);
- }
- }
-
- // Check for listener leak
- if (!existing.warned) {
- m = $getMaxListeners(target);
- if (m && m > 0 && existing.length > m) {
- existing.warned = true;
- var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' "' + String(type) + '" listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit.');
- w.name = 'MaxListenersExceededWarning';
- w.emitter = target;
- w.type = type;
- w.count = existing.length;
- if (typeof console === 'object' && console.warn) {
- console.warn('%s: %s', w.name, w.message);
- }
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
+ if (isFn) handler.call(self, arg1, arg2, arg3);else {
+ var len = handler.length;
+ var listeners = arrayClone(handler, len);
+ for (var i = 0; i < len; ++i) {
+ listeners[i].call(self, arg1, arg2, arg3);
}
}
}
-
- return target;
-}
-
-EventEmitter.prototype.addListener = function addListener(type, listener) {
- return _addListener(this, type, listener, false);
-};
-
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-
-EventEmitter.prototype.prependListener = function prependListener(type, listener) {
- return _addListener(this, type, listener, true);
-};
-
-function onceWrapper() {
- if (!this.fired) {
- this.target.removeListener(this.type, this.wrapFn);
- this.fired = true;
- switch (arguments.length) {
- case 0:
- return this.listener.call(this.target);
+
+ function emitMany(handler, isFn, self, args) {
+ if (isFn) handler.apply(self, args);else {
+ var len = handler.length;
+ var listeners = arrayClone(handler, len);
+ for (var i = 0; i < len; ++i) {
+ listeners[i].apply(self, args);
+ }
+ }
+ }
+
+ EventEmitter.prototype.emit = function emit(type) {
+ var er, handler, len, args, i, events;
+ var doError = type === 'error';
+
+ events = this._events;
+ if (events) doError = doError && events.error == null;else if (!doError) return false;
+
+ // If there is no 'error' event listener then throw.
+ if (doError) {
+ if (arguments.length > 1) er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ // At least give some kind of context to the user
+ var err = new Error('Unhandled "error" event. (' + er + ')');
+ err.context = er;
+ throw err;
+ }
+ return false;
+ }
+
+ handler = events[type];
+
+ if (!handler) return false;
+
+ var isFn = typeof handler === 'function';
+ len = arguments.length;
+ switch (len) {
+ // fast cases
case 1:
- return this.listener.call(this.target, arguments[0]);
+ emitNone(handler, isFn, this);
+ break;
case 2:
- return this.listener.call(this.target, arguments[0], arguments[1]);
+ emitOne(handler, isFn, this, arguments[1]);
+ break;
case 3:
- return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]);
- default:
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; ++i) {
- args[i] = arguments[i];
- }this.listener.apply(this.target, args);
- }
- }
-}
-
-function _onceWrap(target, type, listener) {
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
- var wrapped = bind.call(onceWrapper, state);
- wrapped.listener = listener;
- state.wrapFn = wrapped;
- return wrapped;
-}
-
-EventEmitter.prototype.once = function once(type, listener) {
- if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
- this.on(type, _onceWrap(this, type, listener));
- return this;
-};
-
-EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
- if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
- this.prependListener(type, _onceWrap(this, type, listener));
- return this;
-};
-
-// Emits a 'removeListener' event if and only if the listener was removed.
-EventEmitter.prototype.removeListener = function removeListener(type, listener) {
- var list, events, position, i, originalListener;
-
- if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
-
- events = this._events;
- if (!events) return this;
-
- list = events[type];
- if (!list) return this;
-
- if (list === listener || list.listener === listener) {
- if (--this._eventsCount === 0) this._events = objectCreate(null);else {
- delete events[type];
- if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
- }
- } else if (typeof list !== 'function') {
- position = -1;
-
- for (i = list.length - 1; i >= 0; i--) {
- if (list[i] === listener || list[i].listener === listener) {
- originalListener = list[i].listener;
- position = i;
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
break;
- }
- }
-
- if (position < 0) return this;
-
- if (position === 0) list.shift();else spliceOne(list, position);
-
- if (list.length === 1) events[type] = list[0];
-
- if (events.removeListener) this.emit('removeListener', type, originalListener || listener);
- }
-
- return this;
-};
-
-EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
- var listeners, events, i;
-
- events = this._events;
- if (!events) return this;
-
- // not listening for removeListener, no need to emit
- if (!events.removeListener) {
- if (arguments.length === 0) {
- this._events = objectCreate(null);
- this._eventsCount = 0;
- } else if (events[type]) {
- if (--this._eventsCount === 0) this._events = objectCreate(null);else delete events[type];
+ case 4:
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
+ break;
+ // slower
+ default:
+ args = new Array(len - 1);
+ for (i = 1; i < len; i++) {
+ args[i - 1] = arguments[i];
+ }emitMany(handler, isFn, this, args);
}
- return this;
- }
-
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- var keys = objectKeys(events);
- var key;
- for (i = 0; i < keys.length; ++i) {
- key = keys[i];
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = objectCreate(null);
- this._eventsCount = 0;
- return this;
- }
-
- listeners = events[type];
-
- if (typeof listeners === 'function') {
- this.removeListener(type, listeners);
- } else if (listeners) {
- // LIFO order
- for (i = listeners.length - 1; i >= 0; i--) {
- this.removeListener(type, listeners[i]);
- }
- }
-
- return this;
-};
-
-function _listeners(target, type, unwrap) {
- var events = target._events;
-
- if (!events) return [];
-
- var evlistener = events[type];
- if (!evlistener) return [];
-
- if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
-
- return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
-}
-
-EventEmitter.prototype.listeners = function listeners(type) {
- return _listeners(this, type, true);
-};
-
-EventEmitter.prototype.rawListeners = function rawListeners(type) {
- return _listeners(this, type, false);
-};
-
-EventEmitter.listenerCount = function (emitter, type) {
- if (typeof emitter.listenerCount === 'function') {
- return emitter.listenerCount(type);
- } else {
- return listenerCount.call(emitter, type);
- }
-};
-
-EventEmitter.prototype.listenerCount = listenerCount;
-function listenerCount(type) {
- var events = this._events;
-
- if (events) {
- var evlistener = events[type];
-
- if (typeof evlistener === 'function') {
- return 1;
- } else if (evlistener) {
- return evlistener.length;
- }
- }
-
- return 0;
-}
-
-EventEmitter.prototype.eventNames = function eventNames() {
- return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
-};
-
-// About 1.5x faster than the two-arg version of Array#splice().
-function spliceOne(list, index) {
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
- list[i] = list[k];
- }list.pop();
-}
-
-function arrayClone(arr, n) {
- var copy = new Array(n);
- for (var i = 0; i < n; ++i) {
- copy[i] = arr[i];
- }return copy;
-}
-
-function unwrapListeners(arr) {
- var ret = new Array(arr.length);
- for (var i = 0; i < ret.length; ++i) {
- ret[i] = arr[i].listener || arr[i];
- }
- return ret;
-}
-
-function objectCreatePolyfill(proto) {
- var F = function () {};
- F.prototype = proto;
- return new F();
-}
-function objectKeysPolyfill(obj) {
- var keys = [];
- for (var k in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, k)) {
- keys.push(k);
- }
- }return k;
-}
-function functionBindPolyfill(context) {
- var fn = this;
- return function () {
- return fn.apply(context, arguments);
+
+ return true;
};
-}
-},{}],15:[function(require,module,exports){
-(function (process){
-module.exports = realpath;
-realpath.realpath = realpath;
-realpath.sync = realpathSync;
-realpath.realpathSync = realpathSync;
-realpath.monkeypatch = monkeypatch;
-realpath.unmonkeypatch = unmonkeypatch;
-
-var fs = require('fs');
-var origRealpath = fs.realpath;
-var origRealpathSync = fs.realpathSync;
-
-var version = process.version;
-var ok = /^v[0-5]\./.test(version);
-var old = require('./old.js');
-
-function newError(er) {
- return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
-}
-
-function realpath(p, cache, cb) {
- if (ok) {
- return origRealpath(p, cache, cb);
- }
-
- if (typeof cache === 'function') {
- cb = cache;
- cache = null;
- }
- origRealpath(p, cache, function (er, result) {
- if (newError(er)) {
- old.realpath(p, cache, cb);
+
+ function _addListener(target, type, listener, prepend) {
+ var m;
+ var events;
+ var existing;
+
+ if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
+
+ events = target._events;
+ if (!events) {
+ events = target._events = objectCreate(null);
+ target._eventsCount = 0;
} else {
- cb(er, result);
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (events.newListener) {
+ target.emit('newListener', type, listener.listener ? listener.listener : listener);
+
+ // Re-assign `events` because a newListener handler could have caused the
+ // this._events to be assigned to a new object
+ events = target._events;
+ }
+ existing = events[type];
}
- });
-}
-
-function realpathSync(p, cache) {
- if (ok) {
- return origRealpathSync(p, cache);
- }
-
- try {
- return origRealpathSync(p, cache);
- } catch (er) {
- if (newError(er)) {
- return old.realpathSync(p, cache);
+
+ if (!existing) {
+ // Optimize the case of one listener. Don't need the extra array object.
+ existing = events[type] = listener;
+ ++target._eventsCount;
} else {
- throw er;
- }
- }
-}
-
-function monkeypatch() {
- fs.realpath = realpath;
- fs.realpathSync = realpathSync;
-}
-
-function unmonkeypatch() {
- fs.realpath = origRealpath;
- fs.realpathSync = origRealpathSync;
-}
-}).call(this,require('_process'))
-},{"./old.js":16,"_process":101,"fs":9}],16:[function(require,module,exports){
-(function (process){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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.
-
-var pathModule = require('path');
-var isWindows = process.platform === 'win32';
-var fs = require('fs');
-
-// JavaScript implementation of realpath, ported from node pre-v6
-
-var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
-
-function rethrow() {
- // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
- // is fairly slow to generate.
- var callback;
- if (DEBUG) {
- var backtrace = new Error();
- callback = debugCallback;
- } else callback = missingCallback;
-
- return callback;
-
- function debugCallback(err) {
- if (err) {
- backtrace.message = err.message;
- err = backtrace;
- missingCallback(err);
- }
- }
-
- function missingCallback(err) {
- if (err) {
- if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
- else if (!process.noDeprecation) {
- var msg = 'fs: missing callback ' + (err.stack || err.message);
- if (process.traceDeprecation) console.trace(msg);else console.error(msg);
+ if (typeof existing === 'function') {
+ // Adding the second element, need to change to array.
+ existing = events[type] = prepend ? [listener, existing] : [existing, listener];
+ } else {
+ // If we've already got an array, just append.
+ if (prepend) {
+ existing.unshift(listener);
+ } else {
+ existing.push(listener);
}
- }
- }
-}
-
-function maybeCallback(cb) {
- return typeof cb === 'function' ? cb : rethrow();
-}
-
-var normalize = pathModule.normalize;
-
-// Regexp that finds the next partion of a (partial) path
-// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
-if (isWindows) {
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
-} else {
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
-}
-
-// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
-if (isWindows) {
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
-} else {
- var splitRootRe = /^[\/]*/;
-}
-
-exports.realpathSync = function realpathSync(p, cache) {
- // make p is absolute
- p = pathModule.resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return cache[p];
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstatSync(base);
- knownHard[base] = true;
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- // NB: p.length changes.
- while (pos < p.length) {
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || cache && cache[base] === base) {
- continue;
- }
-
- var resolvedLink;
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // some known symbolic link. no need to stat again.
- resolvedLink = cache[base];
- } else {
- var stat = fs.lstatSync(base);
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- continue;
}
-
- // read the link if it wasn't read before
- // dev/ino always return 0 on windows, so skip the check.
- var linkTarget = null;
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- linkTarget = seenLinks[id];
+
+ // Check for listener leak
+ if (!existing.warned) {
+ m = $getMaxListeners(target);
+ if (m && m > 0 && existing.length > m) {
+ existing.warned = true;
+ var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' "' + String(type) + '" listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit.');
+ w.name = 'MaxListenersExceededWarning';
+ w.emitter = target;
+ w.type = type;
+ w.count = existing.length;
+ if (typeof console === 'object' && console.warn) {
+ console.warn('%s: %s', w.name, w.message);
+ }
}
}
- if (linkTarget === null) {
- fs.statSync(base);
- linkTarget = fs.readlinkSync(base);
- }
- resolvedLink = pathModule.resolve(previous, linkTarget);
- // track this, if given a cache.
- if (cache) cache[base] = resolvedLink;
- if (!isWindows) seenLinks[id] = linkTarget;
}
-
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
- }
-
- if (cache) cache[original] = p;
-
- return p;
-};
-
-exports.realpath = function realpath(p, cache, cb) {
- if (typeof cb !== 'function') {
- cb = maybeCallback(cache);
- cache = null;
- }
-
- // make p is absolute
- p = pathModule.resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return process.nextTick(cb.bind(null, null, cache[p]));
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstat(base, function (err) {
- if (err) return cb(err);
- knownHard[base] = true;
- LOOP();
- });
- } else {
- process.nextTick(LOOP);
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- function LOOP() {
- // stop if scanned past end of path
- if (pos >= p.length) {
- if (cache) cache[original] = p;
- return cb(null, p);
- }
-
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || cache && cache[base] === base) {
- return process.nextTick(LOOP);
- }
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // known symbolic link. no need to stat again.
- return gotResolvedLink(cache[base]);
- }
-
- return fs.lstat(base, gotStat);
- }
-
- function gotStat(err, stat) {
- if (err) return cb(err);
-
- // if not a symlink, skip to the next path part
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- return process.nextTick(LOOP);
- }
-
- // stat & read the link if not read before
- // call gotTarget as soon as the link target is known
- // dev/ino always return 0 on windows, so skip the check.
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- return gotTarget(null, seenLinks[id], base);
- }
- }
- fs.stat(base, function (err) {
- if (err) return cb(err);
-
- fs.readlink(base, function (err, target) {
- if (!isWindows) seenLinks[id] = target;
- gotTarget(err, target);
- });
- });
- }
-
- function gotTarget(err, target, base) {
- if (err) return cb(err);
-
- var resolvedLink = pathModule.resolve(previous, target);
- if (cache) cache[base] = resolvedLink;
- gotResolvedLink(resolvedLink);
- }
-
- function gotResolvedLink(resolvedLink) {
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
+
+ return target;
}
-};
-}).call(this,require('_process'))
-},{"_process":101,"fs":9,"path":98}],17:[function(require,module,exports){
-(function (process){
-exports.alphasort = alphasort;
-exports.alphasorti = alphasorti;
-exports.setopts = setopts;
-exports.ownProp = ownProp;
-exports.makeAbs = makeAbs;
-exports.finish = finish;
-exports.mark = mark;
-exports.isIgnored = isIgnored;
-exports.childrenIgnored = childrenIgnored;
-
-function ownProp(obj, field) {
- return Object.prototype.hasOwnProperty.call(obj, field);
-}
-
-var path = require("path");
-var minimatch = require("minimatch");
-var isAbsolute = require("path-is-absolute");
-var Minimatch = minimatch.Minimatch;
-
-function alphasorti(a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase());
-}
-
-function alphasort(a, b) {
- return a.localeCompare(b);
-}
-
-function setupIgnores(self, options) {
- self.ignore = options.ignore || [];
-
- if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
-
- if (self.ignore.length) {
- self.ignore = self.ignore.map(ignoreMap);
- }
-}
-
-// ignore patterns are always in dot:true mode.
-function ignoreMap(pattern) {
- var gmatcher = null;
- if (pattern.slice(-3) === '/**') {
- var gpattern = pattern.replace(/(\/\*\*)+$/, '');
- gmatcher = new Minimatch(gpattern, { dot: true });
- }
-
- return {
- matcher: new Minimatch(pattern, { dot: true }),
- gmatcher: gmatcher
+
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
+ return _addListener(this, type, listener, false);
+ };
+
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+ EventEmitter.prototype.prependListener = function prependListener(type, listener) {
+ return _addListener(this, type, listener, true);
};
-}
-
-function setopts(self, pattern, options) {
- if (!options) options = {};
-
- // base-matching: just use globstar for that.
- if (options.matchBase && -1 === pattern.indexOf("/")) {
- if (options.noglobstar) {
- throw new Error("base matching requires globstar");
- }
- pattern = "**/" + pattern;
- }
-
- self.silent = !!options.silent;
- self.pattern = pattern;
- self.strict = options.strict !== false;
- self.realpath = !!options.realpath;
- self.realpathCache = options.realpathCache || Object.create(null);
- self.follow = !!options.follow;
- self.dot = !!options.dot;
- self.mark = !!options.mark;
- self.nodir = !!options.nodir;
- if (self.nodir) self.mark = true;
- self.sync = !!options.sync;
- self.nounique = !!options.nounique;
- self.nonull = !!options.nonull;
- self.nosort = !!options.nosort;
- self.nocase = !!options.nocase;
- self.stat = !!options.stat;
- self.noprocess = !!options.noprocess;
- self.absolute = !!options.absolute;
-
- self.maxLength = options.maxLength || Infinity;
- self.cache = options.cache || Object.create(null);
- self.statCache = options.statCache || Object.create(null);
- self.symlinks = options.symlinks || Object.create(null);
-
- setupIgnores(self, options);
-
- self.changedCwd = false;
- var cwd = process.cwd();
- if (!ownProp(options, "cwd")) self.cwd = cwd;else {
- self.cwd = path.resolve(options.cwd);
- self.changedCwd = self.cwd !== cwd;
- }
-
- self.root = options.root || path.resolve(self.cwd, "/");
- self.root = path.resolve(self.root);
- if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/");
-
- // TODO: is an absolute `cwd` supposed to be resolved against `root`?
- // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
- self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
- if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
- self.nomount = !!options.nomount;
-
- // disable comments and negation in Minimatch.
- // Note that they are not supported in Glob itself anyway.
- options.nonegate = true;
- options.nocomment = true;
-
- self.minimatch = new Minimatch(pattern, options);
- self.options = self.minimatch.options;
-}
-
-function finish(self) {
- var nou = self.nounique;
- var all = nou ? [] : Object.create(null);
-
- for (var i = 0, l = self.matches.length; i < l; i++) {
- var matches = self.matches[i];
- if (!matches || Object.keys(matches).length === 0) {
- if (self.nonull) {
- // do like the shell, and spit out the literal glob
- var literal = self.minimatch.globSet[i];
- if (nou) all.push(literal);else all[literal] = true;
+
+ function onceWrapper() {
+ if (!this.fired) {
+ this.target.removeListener(this.type, this.wrapFn);
+ this.fired = true;
+ switch (arguments.length) {
+ case 0:
+ return this.listener.call(this.target);
+ case 1:
+ return this.listener.call(this.target, arguments[0]);
+ case 2:
+ return this.listener.call(this.target, arguments[0], arguments[1]);
+ case 3:
+ return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]);
+ default:
+ var args = new Array(arguments.length);
+ for (var i = 0; i < args.length; ++i) {
+ args[i] = arguments[i];
+ }this.listener.apply(this.target, args);
}
- } else {
- // had matches
- var m = Object.keys(matches);
- if (nou) all.push.apply(all, m);else m.forEach(function (m) {
- all[m] = true;
- });
- }
- }
-
- if (!nou) all = Object.keys(all);
-
- if (!self.nosort) all = all.sort(self.nocase ? alphasorti : alphasort);
-
- // at *some* point we statted all of these
- if (self.mark) {
- for (var i = 0; i < all.length; i++) {
- all[i] = self._mark(all[i]);
- }
- if (self.nodir) {
- all = all.filter(function (e) {
- var notDir = !/\/$/.test(e);
- var c = self.cache[e] || self.cache[makeAbs(self, e)];
- if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
- return notDir;
- });
}
}
-
- if (self.ignore.length) all = all.filter(function (m) {
- return !isIgnored(self, m);
- });
-
- self.found = all;
-}
-
-function mark(self, p) {
- var abs = makeAbs(self, p);
- var c = self.cache[abs];
- var m = p;
- if (c) {
- var isDir = c === 'DIR' || Array.isArray(c);
- var slash = p.slice(-1) === '/';
-
- if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
-
- if (m !== p) {
- var mabs = makeAbs(self, m);
- self.statCache[mabs] = self.statCache[abs];
- self.cache[mabs] = self.cache[abs];
- }
- }
-
- return m;
-}
-
-// lotta situps...
-function makeAbs(self, f) {
- var abs = f;
- if (f.charAt(0) === '/') {
- abs = path.join(self.root, f);
- } else if (isAbsolute(f) || f === '') {
- abs = f;
- } else if (self.changedCwd) {
- abs = path.resolve(self.cwd, f);
- } else {
- abs = path.resolve(f);
- }
-
- if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
-
- return abs;
-}
-
-// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
-// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
-function isIgnored(self, path) {
- if (!self.ignore.length) return false;
-
- return self.ignore.some(function (item) {
- return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path));
- });
-}
-
-function childrenIgnored(self, path) {
- if (!self.ignore.length) return false;
-
- return self.ignore.some(function (item) {
- return !!(item.gmatcher && item.gmatcher.match(path));
- });
-}
-}).call(this,require('_process'))
-},{"_process":101,"minimatch":72,"path":98,"path-is-absolute":99}],18:[function(require,module,exports){
-(function (process){
-// Approach:
-//
-// 1. Get the minimatch set
-// 2. For each pattern in the set, PROCESS(pattern, false)
-// 3. Store matches per-set, then uniq them
-//
-// PROCESS(pattern, inGlobStar)
-// Get the first [n] items from pattern that are all strings
-// Join these together. This is PREFIX.
-// If there is no more remaining, then stat(PREFIX) and
-// add to matches if it succeeds. END.
-//
-// If inGlobStar and PREFIX is symlink and points to dir
-// set ENTRIES = []
-// else readdir(PREFIX) as ENTRIES
-// If fail, END
-//
-// with ENTRIES
-// If pattern[n] is GLOBSTAR
-// // handle the case where the globstar match is empty
-// // by pruning it out, and testing the resulting pattern
-// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
-// // handle other cases.
-// for ENTRY in ENTRIES (not dotfiles)
-// // attach globstar + tail onto the entry
-// // Mark that this entry is a globstar match
-// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
-//
-// else // not globstar
-// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
-// Test ENTRY against pattern[n]
-// If fails, continue
-// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
-//
-// Caveat:
-// Cache all stats and readdirs results to minimize syscall. Since all
-// we ever care about is existence and directory-ness, we can just keep
-// `true` for files, and [children,...] for directories, or `false` for
-// things that don't exist.
-
-module.exports = glob;
-
-var fs = require('fs');
-var rp = require('fs.realpath');
-var minimatch = require('minimatch');
-var Minimatch = minimatch.Minimatch;
-var inherits = require('inherits');
-var EE = require('events').EventEmitter;
-var path = require('path');
-var assert = require('assert');
-var isAbsolute = require('path-is-absolute');
-var globSync = require('./sync.js');
-var common = require('./common.js');
-var alphasort = common.alphasort;
-var alphasorti = common.alphasorti;
-var setopts = common.setopts;
-var ownProp = common.ownProp;
-var inflight = require('inflight');
-var util = require('util');
-var childrenIgnored = common.childrenIgnored;
-var isIgnored = common.isIgnored;
-
-var once = require('once');
-
-function glob(pattern, options, cb) {
- if (typeof options === 'function') cb = options, options = {};
- if (!options) options = {};
-
- if (options.sync) {
- if (cb) throw new TypeError('callback provided to sync glob');
- return globSync(pattern, options);
- }
-
- return new Glob(pattern, options, cb);
-}
-
-glob.sync = globSync;
-var GlobSync = glob.GlobSync = globSync.GlobSync;
-
-// old api surface
-glob.glob = glob;
-
-function extend(origin, add) {
- if (add === null || typeof add !== 'object') {
- return origin;
- }
-
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
-}
-
-glob.hasMagic = function (pattern, options_) {
- var options = extend({}, options_);
- options.noprocess = true;
-
- var g = new Glob(pattern, options);
- var set = g.minimatch.set;
-
- if (!pattern) return false;
-
- if (set.length > 1) return true;
-
- for (var j = 0; j < set[0].length; j++) {
- if (typeof set[0][j] !== 'string') return true;
- }
-
- return false;
-};
-
-glob.Glob = Glob;
-inherits(Glob, EE);
-function Glob(pattern, options, cb) {
- if (typeof options === 'function') {
- cb = options;
- options = null;
- }
-
- if (options && options.sync) {
- if (cb) throw new TypeError('callback provided to sync glob');
- return new GlobSync(pattern, options);
- }
-
- if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
-
- setopts(this, pattern, options);
- this._didRealPath = false;
-
- // process each pattern in the minimatch set
- var n = this.minimatch.set.length;
-
- // The matches are stored as {: true,...} so that
- // duplicates are automagically pruned.
- // Later, we do an Object.keys() on these.
- // Keep them as a list so we can fill in when nonull is set.
- this.matches = new Array(n);
-
- if (typeof cb === 'function') {
- cb = once(cb);
- this.on('error', cb);
- this.on('end', function (matches) {
- cb(null, matches);
- });
+
+ function _onceWrap(target, type, listener) {
+ var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
+ var wrapped = bind.call(onceWrapper, state);
+ wrapped.listener = listener;
+ state.wrapFn = wrapped;
+ return wrapped;
}
-
- var self = this;
- this._processing = 0;
-
- this._emitQueue = [];
- this._processQueue = [];
- this.paused = false;
-
- if (this.noprocess) return this;
-
- if (n === 0) return done();
-
- var sync = true;
- for (var i = 0; i < n; i++) {
- this._process(this.minimatch.set[i], i, false, done);
- }
- sync = false;
-
- function done() {
- --self._processing;
- if (self._processing <= 0) {
- if (sync) {
- process.nextTick(function () {
- self._finish();
- });
- } else {
- self._finish();
- }
- }
- }
-}
-
-Glob.prototype._finish = function () {
- assert(this instanceof Glob);
- if (this.aborted) return;
-
- if (this.realpath && !this._didRealpath) return this._realpath();
-
- common.finish(this);
- this.emit('end', this.found);
-};
-
-Glob.prototype._realpath = function () {
- if (this._didRealpath) return;
-
- this._didRealpath = true;
-
- var n = this.matches.length;
- if (n === 0) return this._finish();
-
- var self = this;
- for (var i = 0; i < this.matches.length; i++) {
- this._realpathSet(i, next);
- }function next() {
- if (--n === 0) self._finish();
- }
-};
-
-Glob.prototype._realpathSet = function (index, cb) {
- var matchset = this.matches[index];
- if (!matchset) return cb();
-
- var found = Object.keys(matchset);
- var self = this;
- var n = found.length;
-
- if (n === 0) return cb();
-
- var set = this.matches[index] = Object.create(null);
- found.forEach(function (p, i) {
- // If there's a problem with the stat, then it means that
- // one or more of the links in the realpath couldn't be
- // resolved. just return the abs value in that case.
- p = self._makeAbs(p);
- rp.realpath(p, self.realpathCache, function (er, real) {
- if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
-
- if (--n === 0) {
- self.matches[index] = set;
- cb();
+
+ EventEmitter.prototype.once = function once(type, listener) {
+ if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
+ this.on(type, _onceWrap(this, type, listener));
+ return this;
+ };
+
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
+ if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
+ this.prependListener(type, _onceWrap(this, type, listener));
+ return this;
+ };
+
+ // Emits a 'removeListener' event if and only if the listener was removed.
+ EventEmitter.prototype.removeListener = function removeListener(type, listener) {
+ var list, events, position, i, originalListener;
+
+ if (typeof listener !== 'function') throw new TypeError('"listener" argument must be a function');
+
+ events = this._events;
+ if (!events) return this;
+
+ list = events[type];
+ if (!list) return this;
+
+ if (list === listener || list.listener === listener) {
+ if (--this._eventsCount === 0) this._events = objectCreate(null);else {
+ delete events[type];
+ if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
}
- });
- });
-};
-
-Glob.prototype._mark = function (p) {
- return common.mark(this, p);
-};
-
-Glob.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f);
-};
-
-Glob.prototype.abort = function () {
- this.aborted = true;
- this.emit('abort');
-};
-
-Glob.prototype.pause = function () {
- if (!this.paused) {
- this.paused = true;
- this.emit('pause');
- }
-};
-
-Glob.prototype.resume = function () {
- if (this.paused) {
- this.emit('resume');
- this.paused = false;
- if (this._emitQueue.length) {
- var eq = this._emitQueue.slice(0);
- this._emitQueue.length = 0;
- for (var i = 0; i < eq.length; i++) {
- var e = eq[i];
- this._emitMatch(e[0], e[1]);
- }
- }
- if (this._processQueue.length) {
- var pq = this._processQueue.slice(0);
- this._processQueue.length = 0;
- for (var i = 0; i < pq.length; i++) {
- var p = pq[i];
- this._processing--;
- this._process(p[0], p[1], p[2], p[3]);
- }
- }
- }
-};
-
-Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
- assert(this instanceof Glob);
- assert(typeof cb === 'function');
-
- if (this.aborted) return;
-
- this._processing++;
- if (this.paused) {
- this._processQueue.push([pattern, index, inGlobStar, cb]);
- return;
- }
-
- //console.error('PROCESS %d', this._processing, pattern)
-
- // Get the first [n] parts of pattern that are all strings.
- var n = 0;
- while (typeof pattern[n] === 'string') {
- n++;
- }
- // now n is the index of the first one that is *not* a string.
-
- // see if there's anything else
- var prefix;
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index, cb);
- return;
-
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null;
- break;
-
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/');
- break;
- }
-
- var remain = pattern.slice(n);
-
- // get the list of entries.
- var read;
- if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
- if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
- read = prefix;
- } else read = prefix;
-
- var abs = this._makeAbs(read);
-
- //if ignored, skip _processing
- if (childrenIgnored(this, read)) return cb();
-
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
- if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
-};
-
-Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this;
- this._readdir(abs, inGlobStar, function (er, entries) {
- return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
- });
-};
-
-Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
-
- // if the abs isn't a dir, then nothing can match!
- if (!entries) return cb();
-
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0];
- var negate = !!this.minimatch.negate;
- var rawGlob = pn._glob;
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
-
- var matchedEntries = [];
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e.charAt(0) !== '.' || dotOk) {
- var m;
- if (negate && !prefix) {
- m = !e.match(pn);
- } else {
- m = e.match(pn);
+ } else if (typeof list !== 'function') {
+ position = -1;
+
+ for (i = list.length - 1; i >= 0; i--) {
+ if (list[i] === listener || list[i].listener === listener) {
+ originalListener = list[i].listener;
+ position = i;
+ break;
+ }
+ }
+
+ if (position < 0) return this;
+
+ if (position === 0) list.shift();else spliceOne(list, position);
+
+ if (list.length === 1) events[type] = list[0];
+
+ if (events.removeListener) this.emit('removeListener', type, originalListener || listener);
+ }
+
+ return this;
+ };
+
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
+ var listeners, events, i;
+
+ events = this._events;
+ if (!events) return this;
+
+ // not listening for removeListener, no need to emit
+ if (!events.removeListener) {
+ if (arguments.length === 0) {
+ this._events = objectCreate(null);
+ this._eventsCount = 0;
+ } else if (events[type]) {
+ if (--this._eventsCount === 0) this._events = objectCreate(null);else delete events[type];
}
- if (m) matchedEntries.push(e);
+ return this;
}
- }
-
- //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
-
- var len = matchedEntries.length;
- // If there are no matched entries, then nothing matches.
- if (len === 0) return cb();
-
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
-
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index]) this.matches[index] = Object.create(null);
-
- for (var i = 0; i < len; i++) {
- var e = matchedEntries[i];
- if (prefix) {
- if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
+
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ var keys = objectKeys(events);
+ var key;
+ for (i = 0; i < keys.length; ++i) {
+ key = keys[i];
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
}
-
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path.join(this.root, e);
+ this.removeAllListeners('removeListener');
+ this._events = objectCreate(null);
+ this._eventsCount = 0;
+ return this;
+ }
+
+ listeners = events[type];
+
+ if (typeof listeners === 'function') {
+ this.removeListener(type, listeners);
+ } else if (listeners) {
+ // LIFO order
+ for (i = listeners.length - 1; i >= 0; i--) {
+ this.removeListener(type, listeners[i]);
}
- this._emitMatch(index, e);
}
- // This was the last one, and no stats were needed
- return cb();
- }
-
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift();
- for (var i = 0; i < len; i++) {
- var e = matchedEntries[i];
- var newPattern;
- if (prefix) {
- if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
- }
- this._process([e].concat(remain), index, inGlobStar, cb);
- }
- cb();
-};
-
-Glob.prototype._emitMatch = function (index, e) {
- if (this.aborted) return;
-
- if (isIgnored(this, e)) return;
-
- if (this.paused) {
- this._emitQueue.push([index, e]);
- return;
- }
-
- var abs = isAbsolute(e) ? e : this._makeAbs(e);
-
- if (this.mark) e = this._mark(e);
-
- if (this.absolute) e = abs;
-
- if (this.matches[index][e]) return;
-
- if (this.nodir) {
- var c = this.cache[abs];
- if (c === 'DIR' || Array.isArray(c)) return;
- }
-
- this.matches[index][e] = true;
-
- var st = this.statCache[abs];
- if (st) this.emit('stat', e, st);
-
- this.emit('match', e);
-};
-
-Glob.prototype._readdirInGlobStar = function (abs, cb) {
- if (this.aborted) return;
-
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow) return this._readdir(abs, false, cb);
-
- var lstatkey = 'lstat\0' + abs;
- var self = this;
- var lstatcb = inflight(lstatkey, lstatcb_);
-
- if (lstatcb) fs.lstat(abs, lstatcb);
-
- function lstatcb_(er, lstat) {
- if (er && er.code === 'ENOENT') return cb();
-
- var isSym = lstat && lstat.isSymbolicLink();
- self.symlinks[abs] = isSym;
-
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && lstat && !lstat.isDirectory()) {
- self.cache[abs] = 'FILE';
- cb();
- } else self._readdir(abs, false, cb);
- }
-};
-
-Glob.prototype._readdir = function (abs, inGlobStar, cb) {
- if (this.aborted) return;
-
- cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb);
- if (!cb) return;
-
- //console.error('RD %j %j', +inGlobStar, abs)
- if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
-
- if (ownProp(this.cache, abs)) {
- var c = this.cache[abs];
- if (!c || c === 'FILE') return cb();
-
- if (Array.isArray(c)) return cb(null, c);
- }
-
- var self = this;
- fs.readdir(abs, readdirCb(this, abs, cb));
-};
-
-function readdirCb(self, abs, cb) {
- return function (er, entries) {
- if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
+
+ return this;
};
-}
-
-Glob.prototype._readdirEntries = function (abs, entries, cb) {
- if (this.aborted) return;
-
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (abs === '/') e = abs + e;else e = abs + '/' + e;
- this.cache[e] = true;
- }
- }
-
- this.cache[abs] = entries;
- return cb(null, entries);
-};
-
-Glob.prototype._readdirError = function (f, er, cb) {
- if (this.aborted) return;
-
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR':
- // totally normal. means it *does* exist.
- var abs = this._makeAbs(f);
- this.cache[abs] = 'FILE';
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
- error.path = this.cwd;
- error.code = er.code;
- this.emit('error', error);
- this.abort();
- }
- break;
-
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false;
- break;
-
- default:
- // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false;
- if (this.strict) {
- this.emit('error', er);
- // If the error is handled, then we abort
- // if not, we threw out of here
- this.abort();
- }
- if (!this.silent) console.error('glob error', er);
- break;
- }
-
- return cb();
-};
-
-Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this;
- this._readdir(abs, inGlobStar, function (er, entries) {
- self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
- });
-};
-
-Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
- //console.error('pgs2', prefix, remain[0], entries)
-
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries) return cb();
-
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1);
- var gspref = prefix ? [prefix] : [];
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
-
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false, cb);
-
- var isSym = this.symlinks[abs];
- var len = entries.length;
-
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar) return cb();
-
- for (var i = 0; i < len; i++) {
- var e = entries[i];
- if (e.charAt(0) === '.' && !this.dot) continue;
-
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
- this._process(instead, index, true, cb);
-
- var below = gspref.concat(entries[i], remain);
- this._process(below, index, true, cb);
- }
-
- cb();
-};
-
-Glob.prototype._processSimple = function (prefix, index, cb) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var self = this;
- this._stat(prefix, function (er, exists) {
- self._processSimple2(prefix, index, er, exists, cb);
- });
-};
-Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
-
- //console.error('ps2', prefix, exists)
-
- if (!this.matches[index]) this.matches[index] = Object.create(null);
-
- // If it doesn't exist, then just mark the lack of results
- if (!exists) return cb();
-
- if (prefix && isAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix);
- if (prefix.charAt(0) === '/') {
- prefix = path.join(this.root, prefix);
- } else {
- prefix = path.resolve(this.root, prefix);
- if (trail) prefix += '/';
- }
- }
-
- if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/');
-
- // Mark this as a match
- this._emitMatch(index, prefix);
- cb();
-};
-
-// Returns either 'DIR', 'FILE', or false
-Glob.prototype._stat = function (f, cb) {
- var abs = this._makeAbs(f);
- var needDir = f.slice(-1) === '/';
-
- if (f.length > this.maxLength) return cb();
-
- if (!this.stat && ownProp(this.cache, abs)) {
- var c = this.cache[abs];
-
- if (Array.isArray(c)) c = 'DIR';
-
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR') return cb(null, c);
-
- if (needDir && c === 'FILE') return cb();
-
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
-
- var exists;
- var stat = this.statCache[abs];
- if (stat !== undefined) {
- if (stat === false) return cb(null, stat);else {
- var type = stat.isDirectory() ? 'DIR' : 'FILE';
- if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
- }
- }
-
- var self = this;
- var statcb = inflight('stat\0' + abs, lstatcb_);
- if (statcb) fs.lstat(abs, statcb);
-
- function lstatcb_(er, lstat) {
- if (lstat && lstat.isSymbolicLink()) {
- // If it's a symlink, then treat it as the target, unless
- // the target does not exist, then treat it as a file.
- return fs.stat(abs, function (er, stat) {
- if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
- });
+
+ function _listeners(target, type, unwrap) {
+ var events = target._events;
+
+ if (!events) return [];
+
+ var evlistener = events[type];
+ if (!evlistener) return [];
+
+ if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
+
+ return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
+ }
+
+ EventEmitter.prototype.listeners = function listeners(type) {
+ return _listeners(this, type, true);
+ };
+
+ EventEmitter.prototype.rawListeners = function rawListeners(type) {
+ return _listeners(this, type, false);
+ };
+
+ EventEmitter.listenerCount = function (emitter, type) {
+ if (typeof emitter.listenerCount === 'function') {
+ return emitter.listenerCount(type);
} else {
- self._stat2(f, abs, er, lstat, cb);
+ return listenerCount.call(emitter, type);
+ }
+ };
+
+ EventEmitter.prototype.listenerCount = listenerCount;
+ function listenerCount(type) {
+ var events = this._events;
+
+ if (events) {
+ var evlistener = events[type];
+
+ if (typeof evlistener === 'function') {
+ return 1;
+ } else if (evlistener) {
+ return evlistener.length;
+ }
}
+
+ return 0;
}
-};
-
-Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
- this.statCache[abs] = false;
- return cb();
+
+ EventEmitter.prototype.eventNames = function eventNames() {
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
+ };
+
+ // About 1.5x faster than the two-arg version of Array#splice().
+ function spliceOne(list, index) {
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
+ list[i] = list[k];
+ }list.pop();
+ }
+
+ function arrayClone(arr, n) {
+ var copy = new Array(n);
+ for (var i = 0; i < n; ++i) {
+ copy[i] = arr[i];
+ }return copy;
+ }
+
+ function unwrapListeners(arr) {
+ var ret = new Array(arr.length);
+ for (var i = 0; i < ret.length; ++i) {
+ ret[i] = arr[i].listener || arr[i];
+ }
+ return ret;
}
-
- var needDir = f.slice(-1) === '/';
- this.statCache[abs] = stat;
-
- if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
-
- var c = true;
- if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
- this.cache[abs] = this.cache[abs] || c;
-
- if (needDir && c === 'FILE') return cb();
-
- return cb(null, c, stat);
-};
-}).call(this,require('_process'))
-},{"./common.js":17,"./sync.js":19,"_process":101,"assert":1,"events":14,"fs":9,"fs.realpath":15,"inflight":37,"inherits":38,"minimatch":72,"once":95,"path":98,"path-is-absolute":99,"util":121}],19:[function(require,module,exports){
-(function (process){
-module.exports = globSync;
-globSync.GlobSync = GlobSync;
-
-var fs = require('fs');
-var rp = require('fs.realpath');
-var minimatch = require('minimatch');
-var Minimatch = minimatch.Minimatch;
-var Glob = require('./glob.js').Glob;
-var util = require('util');
-var path = require('path');
-var assert = require('assert');
-var isAbsolute = require('path-is-absolute');
-var common = require('./common.js');
-var alphasort = common.alphasort;
-var alphasorti = common.alphasorti;
-var setopts = common.setopts;
-var ownProp = common.ownProp;
-var childrenIgnored = common.childrenIgnored;
-var isIgnored = common.isIgnored;
-
-function globSync(pattern, options) {
- if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
-
- return new GlobSync(pattern, options).found;
-}
-
-function GlobSync(pattern, options) {
- if (!pattern) throw new Error('must provide pattern');
-
- if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
-
- if (!(this instanceof GlobSync)) return new GlobSync(pattern, options);
-
- setopts(this, pattern, options);
-
- if (this.noprocess) return this;
-
- var n = this.minimatch.set.length;
- this.matches = new Array(n);
- for (var i = 0; i < n; i++) {
- this._process(this.minimatch.set[i], i, false);
- }
- this._finish();
-}
-
-GlobSync.prototype._finish = function () {
- assert(this instanceof GlobSync);
- if (this.realpath) {
- var self = this;
- this.matches.forEach(function (matchset, index) {
- var set = self.matches[index] = Object.create(null);
- for (var p in matchset) {
- try {
- p = self._makeAbs(p);
- var real = rp.realpathSync(p, self.realpathCache);
- set[real] = true;
- } catch (er) {
- if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
- }
+
+ function objectCreatePolyfill(proto) {
+ var F = function () {};
+ F.prototype = proto;
+ return new F();
+ }
+ function objectKeysPolyfill(obj) {
+ var keys = [];
+ for (var k in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, k)) {
+ keys.push(k);
+ }
+ }return k;
+ }
+ function functionBindPolyfill(context) {
+ var fn = this;
+ return function () {
+ return fn.apply(context, arguments);
+ };
+ }
+ },{}],15:[function(require,module,exports){
+ (function (process){(function (){
+ module.exports = realpath;
+ realpath.realpath = realpath;
+ realpath.sync = realpathSync;
+ realpath.realpathSync = realpathSync;
+ realpath.monkeypatch = monkeypatch;
+ realpath.unmonkeypatch = unmonkeypatch;
+
+ var fs = require('fs');
+ var origRealpath = fs.realpath;
+ var origRealpathSync = fs.realpathSync;
+
+ var version = process.version;
+ var ok = /^v[0-5]\./.test(version);
+ var old = require('./old.js');
+
+ function newError(er) {
+ return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
+ }
+
+ function realpath(p, cache, cb) {
+ if (ok) {
+ return origRealpath(p, cache, cb);
+ }
+
+ if (typeof cache === 'function') {
+ cb = cache;
+ cache = null;
+ }
+ origRealpath(p, cache, function (er, result) {
+ if (newError(er)) {
+ old.realpath(p, cache, cb);
+ } else {
+ cb(er, result);
}
});
}
- common.finish(this);
-};
-
-GlobSync.prototype._process = function (pattern, index, inGlobStar) {
- assert(this instanceof GlobSync);
-
- // Get the first [n] parts of pattern that are all strings.
- var n = 0;
- while (typeof pattern[n] === 'string') {
- n++;
- }
- // now n is the index of the first one that is *not* a string.
-
- // See if there's anything else
- var prefix;
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index);
- return;
-
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null;
- break;
-
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/');
- break;
- }
-
- var remain = pattern.slice(n);
-
- // get the list of entries.
- var read;
- if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
- if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
- read = prefix;
- } else read = prefix;
-
- var abs = this._makeAbs(read);
-
- //if ignored, skip processing
- if (childrenIgnored(this, read)) return;
-
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
- if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
-};
-
-GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
- var entries = this._readdir(abs, inGlobStar);
-
- // if the abs isn't a dir, then nothing can match!
- if (!entries) return;
-
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0];
- var negate = !!this.minimatch.negate;
- var rawGlob = pn._glob;
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
-
- var matchedEntries = [];
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e.charAt(0) !== '.' || dotOk) {
- var m;
- if (negate && !prefix) {
- m = !e.match(pn);
+
+ function realpathSync(p, cache) {
+ if (ok) {
+ return origRealpathSync(p, cache);
+ }
+
+ try {
+ return origRealpathSync(p, cache);
+ } catch (er) {
+ if (newError(er)) {
+ return old.realpathSync(p, cache);
} else {
- m = e.match(pn);
+ throw er;
}
- if (m) matchedEntries.push(e);
}
}
-
- var len = matchedEntries.length;
- // If there are no matched entries, then nothing matches.
- if (len === 0) return;
-
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
-
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index]) this.matches[index] = Object.create(null);
-
- for (var i = 0; i < len; i++) {
- var e = matchedEntries[i];
- if (prefix) {
- if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
- }
-
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path.join(this.root, e);
- }
- this._emitMatch(index, e);
- }
- // This was the last one, and no stats were needed
- return;
- }
-
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift();
- for (var i = 0; i < len; i++) {
- var e = matchedEntries[i];
- var newPattern;
- if (prefix) newPattern = [prefix, e];else newPattern = [e];
- this._process(newPattern.concat(remain), index, inGlobStar);
- }
-};
-
-GlobSync.prototype._emitMatch = function (index, e) {
- if (isIgnored(this, e)) return;
-
- var abs = this._makeAbs(e);
-
- if (this.mark) e = this._mark(e);
-
- if (this.absolute) {
- e = abs;
- }
-
- if (this.matches[index][e]) return;
-
- if (this.nodir) {
- var c = this.cache[abs];
- if (c === 'DIR' || Array.isArray(c)) return;
- }
-
- this.matches[index][e] = true;
-
- if (this.stat) this._stat(e);
-};
-
-GlobSync.prototype._readdirInGlobStar = function (abs) {
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow) return this._readdir(abs, false);
-
- var entries;
- var lstat;
- var stat;
- try {
- lstat = fs.lstatSync(abs);
- } catch (er) {
- if (er.code === 'ENOENT') {
- // lstat failed, doesn't exist
- return null;
- }
+
+ function monkeypatch() {
+ fs.realpath = realpath;
+ fs.realpathSync = realpathSync;
}
-
- var isSym = lstat && lstat.isSymbolicLink();
- this.symlinks[abs] = isSym;
-
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
-
- return entries;
-};
-
-GlobSync.prototype._readdir = function (abs, inGlobStar) {
- var entries;
-
- if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs);
-
- if (ownProp(this.cache, abs)) {
- var c = this.cache[abs];
- if (!c || c === 'FILE') return null;
-
- if (Array.isArray(c)) return c;
- }
-
- try {
- return this._readdirEntries(abs, fs.readdirSync(abs));
- } catch (er) {
- this._readdirError(abs, er);
- return null;
+
+ function unmonkeypatch() {
+ fs.realpath = origRealpath;
+ fs.realpathSync = origRealpathSync;
}
-};
-
-GlobSync.prototype._readdirEntries = function (abs, entries) {
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (abs === '/') e = abs + e;else e = abs + '/' + e;
- this.cache[e] = true;
- }
- }
-
- this.cache[abs] = entries;
-
- // mark and cache dir-ness
- return entries;
-};
-
-GlobSync.prototype._readdirError = function (f, er) {
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR':
- // totally normal. means it *does* exist.
- var abs = this._makeAbs(f);
- this.cache[abs] = 'FILE';
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
- error.path = this.cwd;
- error.code = er.code;
- throw error;
- }
- break;
-
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false;
- break;
-
- default:
- // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false;
- if (this.strict) throw er;
- if (!this.silent) console.error('glob error', er);
- break;
- }
-};
-
-GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
-
- var entries = this._readdir(abs, inGlobStar);
-
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries) return;
-
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1);
- var gspref = prefix ? [prefix] : [];
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
-
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false);
-
- var len = entries.length;
- var isSym = this.symlinks[abs];
-
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar) return;
-
- for (var i = 0; i < len; i++) {
- var e = entries[i];
- if (e.charAt(0) === '.' && !this.dot) continue;
-
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
- this._process(instead, index, true);
-
- var below = gspref.concat(entries[i], remain);
- this._process(below, index, true);
- }
-};
-
-GlobSync.prototype._processSimple = function (prefix, index) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var exists = this._stat(prefix);
-
- if (!this.matches[index]) this.matches[index] = Object.create(null);
-
- // If it doesn't exist, then just mark the lack of results
- if (!exists) return;
-
- if (prefix && isAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix);
- if (prefix.charAt(0) === '/') {
- prefix = path.join(this.root, prefix);
- } else {
- prefix = path.resolve(this.root, prefix);
- if (trail) prefix += '/';
- }
- }
-
- if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/');
-
- // Mark this as a match
- this._emitMatch(index, prefix);
-};
-
-// Returns either 'DIR', 'FILE', or false
-GlobSync.prototype._stat = function (f) {
- var abs = this._makeAbs(f);
- var needDir = f.slice(-1) === '/';
-
- if (f.length > this.maxLength) return false;
-
- if (!this.stat && ownProp(this.cache, abs)) {
- var c = this.cache[abs];
-
- if (Array.isArray(c)) c = 'DIR';
-
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR') return c;
-
- if (needDir && c === 'FILE') return false;
-
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
-
- var exists;
- var stat = this.statCache[abs];
- if (!stat) {
- var lstat;
- try {
- lstat = fs.lstatSync(abs);
- } catch (er) {
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
- this.statCache[abs] = false;
- return false;
+ }).call(this)}).call(this,require('_process'))
+ },{"./old.js":16,"_process":105,"fs":9}],16:[function(require,module,exports){
+ (function (process){(function (){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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.
+
+ var pathModule = require('path');
+ var isWindows = process.platform === 'win32';
+ var fs = require('fs');
+
+ // JavaScript implementation of realpath, ported from node pre-v6
+
+ var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
+
+ function rethrow() {
+ // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
+ // is fairly slow to generate.
+ var callback;
+ if (DEBUG) {
+ var backtrace = new Error();
+ callback = debugCallback;
+ } else callback = missingCallback;
+
+ return callback;
+
+ function debugCallback(err) {
+ if (err) {
+ backtrace.message = err.message;
+ err = backtrace;
+ missingCallback(err);
}
}
-
- if (lstat && lstat.isSymbolicLink()) {
- try {
- stat = fs.statSync(abs);
- } catch (er) {
- stat = lstat;
+
+ function missingCallback(err) {
+ if (err) {
+ if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
+ else if (!process.noDeprecation) {
+ var msg = 'fs: missing callback ' + (err.stack || err.message);
+ if (process.traceDeprecation) console.trace(msg);else console.error(msg);
+ }
}
- } else {
- stat = lstat;
- }
- }
-
- this.statCache[abs] = stat;
-
- var c = true;
- if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
-
- this.cache[abs] = this.cache[abs] || c;
-
- if (needDir && c === 'FILE') return false;
-
- return c;
-};
-
-GlobSync.prototype._mark = function (p) {
- return common.mark(this, p);
-};
-
-GlobSync.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f);
-};
-}).call(this,require('_process'))
-},{"./common.js":17,"./glob.js":18,"_process":101,"assert":1,"fs":9,"fs.realpath":15,"minimatch":72,"path":98,"path-is-absolute":99,"util":121}],20:[function(require,module,exports){
-(function (global){
-var topLevel = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : {};
-var minDoc = require('min-document');
-
-var doccy;
-
-if (typeof document !== 'undefined') {
- doccy = document;
-} else {
- doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
-
- if (!doccy) {
- doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
- }
-}
-
-module.exports = doccy;
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"min-document":8}],21:[function(require,module,exports){
-(function (global){
-var win;
-
-if (typeof window !== "undefined") {
- win = window;
-} else if (typeof global !== "undefined") {
- win = global;
-} else if (typeof self !== "undefined") {
- win = self;
-} else {
- win = {};
-}
-
-module.exports = win;
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],22:[function(require,module,exports){
-/*!
- * http-errors
- * Copyright(c) 2014 Jonathan Ong
- * Copyright(c) 2016 Douglas Christopher Wilson
- * MIT Licensed
- */
-
-'use strict';
-
-/**
- * Module dependencies.
- * @private
- */
-
-var deprecate = require('depd')('http-errors');
-var setPrototypeOf = require('setprototypeof');
-var statuses = require('statuses');
-var inherits = require('inherits');
-
-/**
- * Module exports.
- * @public
- */
-
-module.exports = createError;
-module.exports.HttpError = createHttpErrorConstructor();
-
-// Populate exports for all constructors
-populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError);
-
-/**
- * Get the code class of a status code.
- * @private
- */
-
-function codeClass(status) {
- return Number(String(status).charAt(0) + '00');
-}
-
-/**
- * Create a new HTTP Error.
- *
- * @returns {Error}
- * @public
- */
-
-function createError() {
- // so much arity going on ~_~
- var err;
- var msg;
- var status = 500;
- var props = {};
- for (var i = 0; i < arguments.length; i++) {
- var arg = arguments[i];
- if (arg instanceof Error) {
- err = arg;
- status = err.status || err.statusCode || status;
- continue;
- }
- switch (typeof arg) {
- case 'string':
- msg = arg;
- break;
- case 'number':
- status = arg;
- if (i !== 0) {
- deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)');
- }
- break;
- case 'object':
- props = arg;
- break;
}
}
-
- if (typeof status === 'number' && (status < 400 || status >= 600)) {
- deprecate('non-error status code; use only 4xx or 5xx status codes');
- }
-
- if (typeof status !== 'number' || !statuses[status] && (status < 400 || status >= 600)) {
- status = 500;
- }
-
- // constructor
- var HttpError = createError[status] || createError[codeClass(status)];
-
- if (!err) {
- // create error
- err = HttpError ? new HttpError(msg) : new Error(msg || statuses[status]);
- Error.captureStackTrace(err, createError);
- }
-
- if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
- // add properties to generic error
- err.expose = status < 500;
- err.status = err.statusCode = status;
- }
-
- for (var key in props) {
- if (key !== 'status' && key !== 'statusCode') {
- err[key] = props[key];
- }
- }
-
- return err;
-}
-
-/**
- * Create HTTP error abstract base class.
- * @private
- */
-
-function createHttpErrorConstructor() {
- function HttpError() {
- throw new TypeError('cannot construct abstract class');
- }
-
- inherits(HttpError, Error);
-
- return HttpError;
-}
-
-/**
- * Create a constructor for a client error.
- * @private
- */
-
-function createClientErrorConstructor(HttpError, name, code) {
- var className = name.match(/Error$/) ? name : name + 'Error';
-
- function ClientError(message) {
- // create the error object
- var msg = message != null ? message : statuses[code];
- var err = new Error(msg);
-
- // capture a stack trace to the construction point
- Error.captureStackTrace(err, ClientError);
-
- // adjust the [[Prototype]]
- setPrototypeOf(err, ClientError.prototype);
-
- // redefine the error message
- Object.defineProperty(err, 'message', {
- enumerable: true,
- configurable: true,
- value: msg,
- writable: true
- });
-
- // redefine the error name
- Object.defineProperty(err, 'name', {
- enumerable: false,
- configurable: true,
- value: className,
- writable: true
- });
-
- return err;
+
+ function maybeCallback(cb) {
+ return typeof cb === 'function' ? cb : rethrow();
}
-
- inherits(ClientError, HttpError);
-
- ClientError.prototype.status = code;
- ClientError.prototype.statusCode = code;
- ClientError.prototype.expose = true;
-
- return ClientError;
-}
-
-/**
- * Create a constructor for a server error.
- * @private
- */
-
-function createServerErrorConstructor(HttpError, name, code) {
- var className = name.match(/Error$/) ? name : name + 'Error';
-
- function ServerError(message) {
- // create the error object
- var msg = message != null ? message : statuses[code];
- var err = new Error(msg);
-
- // capture a stack trace to the construction point
- Error.captureStackTrace(err, ServerError);
-
- // adjust the [[Prototype]]
- setPrototypeOf(err, ServerError.prototype);
-
- // redefine the error message
- Object.defineProperty(err, 'message', {
- enumerable: true,
- configurable: true,
- value: msg,
- writable: true
- });
-
- // redefine the error name
- Object.defineProperty(err, 'name', {
- enumerable: false,
- configurable: true,
- value: className,
- writable: true
- });
-
- return err;
+
+ var normalize = pathModule.normalize;
+
+ // Regexp that finds the next partion of a (partial) path
+ // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
+ if (isWindows) {
+ var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
+ } else {
+ var nextPartRe = /(.*?)(?:[\/]+|$)/g;
}
-
- inherits(ServerError, HttpError);
-
- ServerError.prototype.status = code;
- ServerError.prototype.statusCode = code;
- ServerError.prototype.expose = false;
-
- return ServerError;
-}
-
-/**
- * Populate the exports object with constructors for every error class.
- * @private
- */
-
-function populateConstructorExports(exports, codes, HttpError) {
- codes.forEach(function forEachCode(code) {
- var CodeError;
- var name = toIdentifier(statuses[code]);
-
- switch (codeClass(code)) {
- case 400:
- CodeError = createClientErrorConstructor(HttpError, name, code);
- break;
- case 500:
- CodeError = createServerErrorConstructor(HttpError, name, code);
- break;
+
+ // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
+ if (isWindows) {
+ var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
+ } else {
+ var splitRootRe = /^[\/]*/;
+ }
+
+ exports.realpathSync = function realpathSync(p, cache) {
+ // make p is absolute
+ p = pathModule.resolve(p);
+
+ if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
+ return cache[p];
+ }
+
+ var original = p,
+ seenLinks = {},
+ knownHard = {};
+
+ // current character position in p
+ var pos;
+ // the partial path so far, including a trailing slash if any
+ var current;
+ // the partial path without a trailing slash (except when pointing at a root)
+ var base;
+ // the partial path scanned in the previous round, with slash
+ var previous;
+
+ start();
+
+ function start() {
+ // Skip over roots
+ var m = splitRootRe.exec(p);
+ pos = m[0].length;
+ current = m[0];
+ base = m[0];
+ previous = '';
+
+ // On windows, check that the root exists. On unix there is no need.
+ if (isWindows && !knownHard[base]) {
+ fs.lstatSync(base);
+ knownHard[base] = true;
+ }
}
-
- if (CodeError) {
- // export the constructor
- exports[code] = CodeError;
- exports[name] = CodeError;
- }
- });
-
- // backwards-compatibility
- exports["I'mateapot"] = deprecate.function(exports.ImATeapot, '"I\'mateapot"; use "ImATeapot" instead');
-}
-
-/**
- * Convert a string of words to a JavaScript identifier.
- * @private
- */
-
-function toIdentifier(str) {
- return str.split(' ').map(function (token) {
- return token.slice(0, 1).toUpperCase() + token.slice(1);
- }).join('').replace(/[^ _0-9a-z]/gi, '');
-}
-},{"depd":12,"inherits":38,"setprototypeof":110,"statuses":117}],23:[function(require,module,exports){
-module.exports = attributeToProperty;
-
-var transform = {
- 'class': 'className',
- 'for': 'htmlFor',
- 'http-equiv': 'httpEquiv'
-};
-
-function attributeToProperty(h) {
- return function (tagName, attrs, children) {
- for (var attr in attrs) {
- if (attr in transform) {
- attrs[transform[attr]] = attrs[attr];
- delete attrs[attr];
- }
- }
- return h(tagName, attrs, children);
- };
-}
-},{}],24:[function(require,module,exports){
-var attrToProp = require('hyperscript-attribute-to-property');
-
-var VAR = 0,
- TEXT = 1,
- OPEN = 2,
- CLOSE = 3,
- ATTR = 4;
-var ATTR_KEY = 5,
- ATTR_KEY_W = 6;
-var ATTR_VALUE_W = 7,
- ATTR_VALUE = 8;
-var ATTR_VALUE_SQ = 9,
- ATTR_VALUE_DQ = 10;
-var ATTR_EQ = 11,
- ATTR_BREAK = 12;
-var COMMENT = 13;
-
-module.exports = function (h, opts) {
- if (!opts) opts = {};
- var concat = opts.concat || function (a, b) {
- return String(a) + String(b);
- };
- if (opts.attrToProp !== false) {
- h = attrToProp(h);
- }
-
- return function (strings) {
- var state = TEXT,
- reg = '';
- var arglen = arguments.length;
- var parts = [];
-
- for (var i = 0; i < strings.length; i++) {
- if (i < arglen - 1) {
- var arg = arguments[i + 1];
- var p = parse(strings[i]);
- var xstate = state;
- if (xstate === ATTR_VALUE_DQ) xstate = ATTR_VALUE;
- if (xstate === ATTR_VALUE_SQ) xstate = ATTR_VALUE;
- if (xstate === ATTR_VALUE_W) xstate = ATTR_VALUE;
- if (xstate === ATTR) xstate = ATTR_KEY;
- if (xstate === OPEN) {
- if (reg === '/') {
- p.push([OPEN, '/', arg]);
- reg = '';
- } else {
- p.push([OPEN, arg]);
- }
- } else {
- p.push([VAR, xstate, arg]);
- }
- parts.push.apply(parts, p);
- } else parts.push.apply(parts, parse(strings[i]));
- }
-
- var tree = [null, {}, []];
- var stack = [[tree, -1]];
- for (var i = 0; i < parts.length; i++) {
- var cur = stack[stack.length - 1][0];
- var p = parts[i],
- s = p[0];
- if (s === OPEN && /^\//.test(p[1])) {
- var ix = stack[stack.length - 1][1];
- if (stack.length > 1) {
- stack.pop();
- stack[stack.length - 1][0][2][ix] = h(cur[0], cur[1], cur[2].length ? cur[2] : undefined);
- }
- } else if (s === OPEN) {
- var c = [p[1], {}, []];
- cur[2].push(c);
- stack.push([c, cur[2].length - 1]);
- } else if (s === ATTR_KEY || s === VAR && p[1] === ATTR_KEY) {
- var key = '';
- var copyKey;
- for (; i < parts.length; i++) {
- if (parts[i][0] === ATTR_KEY) {
- key = concat(key, parts[i][1]);
- } else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) {
- if (typeof parts[i][2] === 'object' && !key) {
- for (copyKey in parts[i][2]) {
- if (parts[i][2].hasOwnProperty(copyKey) && !cur[1][copyKey]) {
- cur[1][copyKey] = parts[i][2][copyKey];
- }
- }
- } else {
- key = concat(key, parts[i][2]);
- }
- } else break;
+
+ // walk down the path, swapping out linked pathparts for their real
+ // values
+ // NB: p.length changes.
+ while (pos < p.length) {
+ // find the next part
+ nextPartRe.lastIndex = pos;
+ var result = nextPartRe.exec(p);
+ previous = current;
+ current += result[0];
+ base = previous + result[1];
+ pos = nextPartRe.lastIndex;
+
+ // continue if not a symlink
+ if (knownHard[base] || cache && cache[base] === base) {
+ continue;
+ }
+
+ var resolvedLink;
+ if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
+ // some known symbolic link. no need to stat again.
+ resolvedLink = cache[base];
+ } else {
+ var stat = fs.lstatSync(base);
+ if (!stat.isSymbolicLink()) {
+ knownHard[base] = true;
+ if (cache) cache[base] = base;
+ continue;
}
- if (parts[i][0] === ATTR_EQ) i++;
- var j = i;
- for (; i < parts.length; i++) {
- if (parts[i][0] === ATTR_VALUE || parts[i][0] === ATTR_KEY) {
- if (!cur[1][key]) cur[1][key] = strfn(parts[i][1]);else parts[i][1] === "" || (cur[1][key] = concat(cur[1][key], parts[i][1]));
- } else if (parts[i][0] === VAR && (parts[i][1] === ATTR_VALUE || parts[i][1] === ATTR_KEY)) {
- if (!cur[1][key]) cur[1][key] = strfn(parts[i][2]);else parts[i][2] === "" || (cur[1][key] = concat(cur[1][key], parts[i][2]));
- } else {
- if (key.length && !cur[1][key] && i === j && (parts[i][0] === CLOSE || parts[i][0] === ATTR_BREAK)) {
- // https://html.spec.whatwg.org/multipage/infrastructure.html#boolean-attributes
- // empty string is falsy, not well behaved value in browser
- cur[1][key] = key.toLowerCase();
- }
- if (parts[i][0] === CLOSE) {
- i--;
- }
- break;
+
+ // read the link if it wasn't read before
+ // dev/ino always return 0 on windows, so skip the check.
+ var linkTarget = null;
+ if (!isWindows) {
+ var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
+ if (seenLinks.hasOwnProperty(id)) {
+ linkTarget = seenLinks[id];
}
}
- } else if (s === ATTR_KEY) {
- cur[1][p[1]] = true;
- } else if (s === VAR && p[1] === ATTR_KEY) {
- cur[1][p[2]] = true;
- } else if (s === CLOSE) {
- if (selfClosing(cur[0]) && stack.length) {
- var ix = stack[stack.length - 1][1];
- stack.pop();
- stack[stack.length - 1][0][2][ix] = h(cur[0], cur[1], cur[2].length ? cur[2] : undefined);
- }
- } else if (s === VAR && p[1] === TEXT) {
- if (p[2] === undefined || p[2] === null) p[2] = '';else if (!p[2]) p[2] = concat('', p[2]);
- if (Array.isArray(p[2][0])) {
- cur[2].push.apply(cur[2], p[2]);
- } else {
- cur[2].push(p[2]);
+ if (linkTarget === null) {
+ fs.statSync(base);
+ linkTarget = fs.readlinkSync(base);
}
- } else if (s === TEXT) {
- cur[2].push(p[1]);
- } else if (s === ATTR_EQ || s === ATTR_BREAK) {
- // no-op
+ resolvedLink = pathModule.resolve(previous, linkTarget);
+ // track this, if given a cache.
+ if (cache) cache[base] = resolvedLink;
+ if (!isWindows) seenLinks[id] = linkTarget;
+ }
+
+ // resolve the link, then start over
+ p = pathModule.resolve(resolvedLink, p.slice(pos));
+ start();
+ }
+
+ if (cache) cache[original] = p;
+
+ return p;
+ };
+
+ exports.realpath = function realpath(p, cache, cb) {
+ if (typeof cb !== 'function') {
+ cb = maybeCallback(cache);
+ cache = null;
+ }
+
+ // make p is absolute
+ p = pathModule.resolve(p);
+
+ if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
+ return process.nextTick(cb.bind(null, null, cache[p]));
+ }
+
+ var original = p,
+ seenLinks = {},
+ knownHard = {};
+
+ // current character position in p
+ var pos;
+ // the partial path so far, including a trailing slash if any
+ var current;
+ // the partial path without a trailing slash (except when pointing at a root)
+ var base;
+ // the partial path scanned in the previous round, with slash
+ var previous;
+
+ start();
+
+ function start() {
+ // Skip over roots
+ var m = splitRootRe.exec(p);
+ pos = m[0].length;
+ current = m[0];
+ base = m[0];
+ previous = '';
+
+ // On windows, check that the root exists. On unix there is no need.
+ if (isWindows && !knownHard[base]) {
+ fs.lstat(base, function (err) {
+ if (err) return cb(err);
+ knownHard[base] = true;
+ LOOP();
+ });
} else {
- throw new Error('unhandled: ' + s);
+ process.nextTick(LOOP);
}
}
-
- if (tree[2].length > 1 && /^\s*$/.test(tree[2][0])) {
- tree[2].shift();
- }
-
- if (tree[2].length > 2 || tree[2].length === 2 && /\S/.test(tree[2][1])) {
- throw new Error('multiple root elements must be wrapped in an enclosing tag');
- }
- if (Array.isArray(tree[2][0]) && typeof tree[2][0][0] === 'string' && Array.isArray(tree[2][0][2])) {
- tree[2][0] = h(tree[2][0][0], tree[2][0][1], tree[2][0][2]);
- }
- return tree[2][0];
-
- function parse(str) {
- var res = [];
- if (state === ATTR_VALUE_W) state = ATTR;
- for (var i = 0; i < str.length; i++) {
- var c = str.charAt(i);
- if (state === TEXT && c === '<') {
- if (reg.length) res.push([TEXT, reg]);
- reg = '';
- state = OPEN;
- } else if (c === '>' && !quot(state) && state !== COMMENT) {
- if (state === OPEN && reg.length) {
- res.push([OPEN, reg]);
- } else if (state === ATTR_KEY) {
- res.push([ATTR_KEY, reg]);
- } else if (state === ATTR_VALUE && reg.length) {
- res.push([ATTR_VALUE, reg]);
- }
- res.push([CLOSE]);
- reg = '';
- state = TEXT;
- } else if (state === COMMENT && /-$/.test(reg) && c === '-') {
- if (opts.comments) {
- res.push([ATTR_VALUE, reg.substr(0, reg.length - 1)], [CLOSE]);
- }
- reg = '';
- state = TEXT;
- } else if (state === OPEN && /^!--$/.test(reg)) {
- if (opts.comments) {
- res.push([OPEN, reg], [ATTR_KEY, 'comment'], [ATTR_EQ]);
- }
- reg = c;
- state = COMMENT;
- } else if (state === TEXT || state === COMMENT) {
- reg += c;
- } else if (state === OPEN && c === '/' && reg.length) {
- // no-op, self closing tag without a space
- } else if (state === OPEN && /\s/.test(c)) {
- if (reg.length) {
- res.push([OPEN, reg]);
- }
- reg = '';
- state = ATTR;
- } else if (state === OPEN) {
- reg += c;
- } else if (state === ATTR && /[^\s"'=/]/.test(c)) {
- state = ATTR_KEY;
- reg = c;
- } else if (state === ATTR && /\s/.test(c)) {
- if (reg.length) res.push([ATTR_KEY, reg]);
- res.push([ATTR_BREAK]);
- } else if (state === ATTR_KEY && /\s/.test(c)) {
- res.push([ATTR_KEY, reg]);
- reg = '';
- state = ATTR_KEY_W;
- } else if (state === ATTR_KEY && c === '=') {
- res.push([ATTR_KEY, reg], [ATTR_EQ]);
- reg = '';
- state = ATTR_VALUE_W;
- } else if (state === ATTR_KEY) {
- reg += c;
- } else if ((state === ATTR_KEY_W || state === ATTR) && c === '=') {
- res.push([ATTR_EQ]);
- state = ATTR_VALUE_W;
- } else if ((state === ATTR_KEY_W || state === ATTR) && !/\s/.test(c)) {
- res.push([ATTR_BREAK]);
- if (/[\w-]/.test(c)) {
- reg += c;
- state = ATTR_KEY;
- } else state = ATTR;
- } else if (state === ATTR_VALUE_W && c === '"') {
- state = ATTR_VALUE_DQ;
- } else if (state === ATTR_VALUE_W && c === "'") {
- state = ATTR_VALUE_SQ;
- } else if (state === ATTR_VALUE_DQ && c === '"') {
- res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
- reg = '';
- state = ATTR;
- } else if (state === ATTR_VALUE_SQ && c === "'") {
- res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
- reg = '';
- state = ATTR;
- } else if (state === ATTR_VALUE_W && !/\s/.test(c)) {
- state = ATTR_VALUE;
- i--;
- } else if (state === ATTR_VALUE && /\s/.test(c)) {
- res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
- reg = '';
- state = ATTR;
- } else if (state === ATTR_VALUE || state === ATTR_VALUE_SQ || state === ATTR_VALUE_DQ) {
- reg += c;
- }
+
+ // walk down the path, swapping out linked pathparts for their real
+ // values
+ function LOOP() {
+ // stop if scanned past end of path
+ if (pos >= p.length) {
+ if (cache) cache[original] = p;
+ return cb(null, p);
}
- if (state === TEXT && reg.length) {
- res.push([TEXT, reg]);
- reg = '';
- } else if (state === ATTR_VALUE && reg.length) {
- res.push([ATTR_VALUE, reg]);
- reg = '';
- } else if (state === ATTR_VALUE_DQ && reg.length) {
- res.push([ATTR_VALUE, reg]);
- reg = '';
- } else if (state === ATTR_VALUE_SQ && reg.length) {
- res.push([ATTR_VALUE, reg]);
- reg = '';
- } else if (state === ATTR_KEY) {
- res.push([ATTR_KEY, reg]);
- reg = '';
+
+ // find the next part
+ nextPartRe.lastIndex = pos;
+ var result = nextPartRe.exec(p);
+ previous = current;
+ current += result[0];
+ base = previous + result[1];
+ pos = nextPartRe.lastIndex;
+
+ // continue if not a symlink
+ if (knownHard[base] || cache && cache[base] === base) {
+ return process.nextTick(LOOP);
}
- return res;
+
+ if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
+ // known symbolic link. no need to stat again.
+ return gotResolvedLink(cache[base]);
+ }
+
+ return fs.lstat(base, gotStat);
}
- };
-
- function strfn(x) {
- if (typeof x === 'function') return x;else if (typeof x === 'string') return x;else if (x && typeof x === 'object') return x;else return concat('', x);
- }
-};
-
-function quot(state) {
- return state === ATTR_VALUE_SQ || state === ATTR_VALUE_DQ;
-}
-
-var hasOwn = Object.prototype.hasOwnProperty;
-function has(obj, key) {
- return hasOwn.call(obj, key);
-}
-
-var closeRE = RegExp('^(' + ['area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', '!--',
-// SVG TAGS
-'animate', 'animateTransform', 'circle', 'cursor', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'font-face-format', 'font-face-name', 'font-face-uri', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'missing-glyph', 'mpath', 'path', 'polygon', 'polyline', 'rect', 'set', 'stop', 'tref', 'use', 'view', 'vkern'].join('|') + ')(?:[\.#][a-zA-Z0-9\u007F-\uFFFF_:-]+)*$');
-function selfClosing(tag) {
- return closeRE.test(tag);
-}
-},{"hyperscript-attribute-to-property":23}],25:[function(require,module,exports){
-var xtend = require('xtend');
-var fs = require('fs');
-var lib = require('./lib');
-
-module.exports = {
- readFile: readFile,
- readFileSync: readFileSync,
- readFiles: readFiles,
- readFilesSync: readFilesSync,
- readPage: readPage,
- readPageSync: readPageSync,
- readSite: readSite,
- readSiteSync: readSiteSync
-};
-
-function readFile(pathFile, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readFile(pathFile, opts, callback);
-}
-
-function readFileSync(pathFile, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readFileSync(pathFile, opts);
-}
-
-function readFiles(files, pathSite, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readFiles(files, pathSite, opts, callback);
-}
-
-function readFilesSync(pathFile, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readFilesSync(pathFile, opts);
-}
-
-function readPage(pathPage, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readPage(pathPage, opts, callback);
-}
-
-function readPageSync(pathPage, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readPageSync(pathPage, opts);
-}
-
-function readSite(pathSite, opts, callback) {
- opts = xtend({ fs: fs }, opts);
- return lib.readSite(pathSite, opts, callback);
-}
-
-function readSiteSync(pathSite, opts, callback) {
- opts = xtend(opts, { fs: fs });
- return lib.readSiteSync(pathSite, opts);
-}
-},{"./lib":27,"fs":9,"xtend":127}],26:[function(require,module,exports){
-module.exports = {
- reservedKeys: ['files', 'pages', 'url', 'name', 'path'],
- ignore: /(^[.#]|(?:__|~)$)/,
- encoding: 'utf8',
- file: 'index.txt',
- filetypes: {
- asset: ['.css', '.js'],
- archive: ['.zip'],
- audio: ['.mp3', '.wav', '.aiff'],
- document: ['.pdf'],
- image: ['.gif', '.jpg', '.jpeg', '.png', '.svg'],
- video: ['.mp4', '.mov'],
- font: ['.ttf', '.otf', '.woff', '.woff2']
- }
-};
-},{}],27:[function(require,module,exports){
-module.exports = {
- readPage: require('./readPage'),
- readPageSync: require('./readPageSync'),
- readFile: require('./readFile'),
- readFiles: require('./readFiles'),
- readSite: require('./readSite'),
- readSiteSync: require('./readSiteSync')
-};
-},{"./readFile":28,"./readFiles":30,"./readPage":32,"./readPageSync":33,"./readSite":34,"./readSiteSync":35}],28:[function(require,module,exports){
-var assert = require('assert');
-
-var utilFile = require('../utils/file');
-var readPage = require('./readPage');
-
-module.exports = readFile;
-
-async function readFile(pathFile, opts) {
- assert.equal(typeof pathFile, 'string', 'arg1: pathFile must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- if (!utilFile.isFile(pathFile)) {
- return readPage(pathFile, opts);
- } else {
- return false;
- }
-}
-},{"../utils/file":36,"./readPage":32,"assert":1}],29:[function(require,module,exports){
-var assert = require('assert');
-
-var readPageSync = require('./readPageSync');
-var utilFile = require('../utils/file');
-
-module.exports = readFileSync;
-
-function readFileSync(pathFile, opts) {
- assert.equal(typeof pathFile, 'string', 'arg1: pathFile must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- if (!utilFile.isFile(pathFile)) {
- return readPageSync(pathFile, opts);
- } else {
- return false;
- }
-}
-},{"../utils/file":36,"./readPageSync":33,"assert":1}],30:[function(require,module,exports){
-var assert = require('assert');
-
-var defaults = require('./defaults');
-var readFile = require('./readFile');
-
-module.exports = readFiles;
-
-async function readFiles(files, pathSite, opts) {
- assert.equal(typeof files, 'object', 'arg1: files must be type object');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- var output = {};
-
- // read the index
- if (files.indexOf(pathSite) < 0) {
- files.push(pathSite);
- }
-
- await Promise.all(files.map(read));
- return output;
-
- async function read(pathFile) {
- var content = await readFile(pathFile, opts);
- if (content && !content.name.match(defaults.ignore)) {
- output[content.url] = content;
- }
- return content;
- }
-}
-},{"./defaults":26,"./readFile":28,"assert":1}],31:[function(require,module,exports){
-var assert = require('assert');
-
-var readFileSync = require('./readFileSync');
-var defaults = require('./defaults');
-
-module.exports = readFilesSync;
-
-function readFilesSync(files, pathSite, opts) {
- assert.equal(typeof files, 'object', 'arg1: files must be type object');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- var output = {};
-
- // read the index
- if (files.indexOf(pathSite) < 0) {
- files.push(pathSite);
- }
-
- files.forEach(function (pathFile) {
- if (typeof opts.onFile === 'function') opts.onFile(pathFile);
- var content = readFileSync(pathFile, opts);
- if (content && !content.name.match(defaults.ignore)) {
- output[content.url] = content;
+
+ function gotStat(err, stat) {
+ if (err) return cb(err);
+
+ // if not a symlink, skip to the next path part
+ if (!stat.isSymbolicLink()) {
+ knownHard[base] = true;
+ if (cache) cache[base] = base;
+ return process.nextTick(LOOP);
+ }
+
+ // stat & read the link if not read before
+ // call gotTarget as soon as the link target is known
+ // dev/ino always return 0 on windows, so skip the check.
+ if (!isWindows) {
+ var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
+ if (seenLinks.hasOwnProperty(id)) {
+ return gotTarget(null, seenLinks[id], base);
+ }
+ }
+ fs.stat(base, function (err) {
+ if (err) return cb(err);
+
+ fs.readlink(base, function (err, target) {
+ if (!isWindows) seenLinks[id] = target;
+ gotTarget(err, target);
+ });
+ });
}
- });
-
- return output;
-}
-},{"./defaults":26,"./readFileSync":29,"assert":1}],32:[function(require,module,exports){
-var slash = require('normalize-path');
-var assert = require('assert');
-var smarkt = require('smarkt');
-var xtend = require('xtend');
-var path = require('path');
-var pify = require('pify');
-
-var utilFile = require('../utils/file');
-var defaults = require('./defaults');
-
-module.exports = readPage;
-
-async function readPage(pathPage, opts) {
- assert.equal(typeof pathPage, 'string', 'arg1: pathPage must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- var fs = opts.fs.url ? opts.fs : pify(opts.fs); // web api or node
- var parse = typeof opts.parse === 'function' ? opts.parse : smarkt.parse;
- var fileIndex = opts.file || defaults.file;
- var fileExtname = path.extname(fileIndex);
- var filetypes = opts.filetypes || defaults.filetypes;
- var pathRoot = opts.pathRoot || '';
- var pathUrl = utilFile.formatUrl(pathPage, pathRoot, opts.parent);
- var encoding = opts.encoding || defaults.encoding;
- var content = await getContent();
- var childrenInput = await getChildren();
- var children = childrenInput.filter(function (file) {
- return utilFile.filterFile(file, fileIndex);
- }).reduce(utilFile.sortChildren, { files: [], pages: [] });
- var files = await getFiles(children.files);
- var pages = getPages(children.pages);
-
- return xtend(content, {
- name: path.basename(pathPage),
- path: utilFile.formatUrl(pathPage, pathRoot),
- url: pathUrl,
- files: files,
- pages: pages
- });
-
- async function getChildren() {
- try {
- return await fs.readdir(pathPage);
- } catch (err) {
- return [];
+
+ function gotTarget(err, target, base) {
+ if (err) return cb(err);
+
+ var resolvedLink = pathModule.resolve(previous, target);
+ if (cache) cache[base] = resolvedLink;
+ gotResolvedLink(resolvedLink);
}
- }
-
- async function getContent() {
- try {
- var content;
- content = await fs.readFile(slash(path.join(pathPage, fileIndex)), encoding);
- content = parse(content);
- return content;
- } catch (err) {
- return '';
+
+ function gotResolvedLink(resolvedLink) {
+ // resolve the link, then start over
+ p = pathModule.resolve(resolvedLink, p.slice(pos));
+ start();
}
+ };
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105,"fs":9,"path":102}],17:[function(require,module,exports){
+ (function (process){(function (){
+ exports.setopts = setopts;
+ exports.ownProp = ownProp;
+ exports.makeAbs = makeAbs;
+ exports.finish = finish;
+ exports.mark = mark;
+ exports.isIgnored = isIgnored;
+ exports.childrenIgnored = childrenIgnored;
+
+ function ownProp(obj, field) {
+ return Object.prototype.hasOwnProperty.call(obj, field);
+ }
+
+ var fs = require("fs");
+ var path = require("path");
+ var minimatch = require("minimatch");
+ var isAbsolute = require("path-is-absolute");
+ var Minimatch = minimatch.Minimatch;
+
+ function alphasort(a, b) {
+ return a.localeCompare(b, 'en');
+ }
+
+ function setupIgnores(self, options) {
+ self.ignore = options.ignore || [];
+
+ if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
+
+ if (self.ignore.length) {
+ self.ignore = self.ignore.map(ignoreMap);
+ }
+ }
+
+ // ignore patterns are always in dot:true mode.
+ function ignoreMap(pattern) {
+ var gmatcher = null;
+ if (pattern.slice(-3) === '/**') {
+ var gpattern = pattern.replace(/(\/\*\*)+$/, '');
+ gmatcher = new Minimatch(gpattern, { dot: true });
+ }
+
+ return {
+ matcher: new Minimatch(pattern, { dot: true }),
+ gmatcher: gmatcher
+ };
}
-
- async function getFiles(files) {
- var result = {};
- await Promise.all(files.map(read));
- return result;
-
- async function read(pathFile) {
- var fileParsed = utilFile.getFileMeta({
- pathFile: pathFile,
- pathRoot: pathRoot,
- filetypes: filetypes,
- pathParent: pathPage,
- pathSource: opts.source,
- pathSiteParent: opts.parent
- });
-
- try {
- var fileMeta = pathFile + fileExtname;
- var pathMeta = path.join(pathPage, fileMeta);
- var text = await fs.readFile(pathMeta, encoding);
- // set
- result[fileParsed.filename] = xtend(parse(text), fileParsed);
- files.splice(files.indexOf(fileMeta), 1);
- // cleanup
- delete result[fileMeta];
- return text;
- } catch (err) {
- if (fileParsed.filename) {
- result[fileParsed.filename] = fileParsed;
+
+ function setopts(self, pattern, options) {
+ if (!options) options = {};
+
+ // base-matching: just use globstar for that.
+ if (options.matchBase && -1 === pattern.indexOf("/")) {
+ if (options.noglobstar) {
+ throw new Error("base matching requires globstar");
+ }
+ pattern = "**/" + pattern;
+ }
+
+ self.silent = !!options.silent;
+ self.pattern = pattern;
+ self.strict = options.strict !== false;
+ self.realpath = !!options.realpath;
+ self.realpathCache = options.realpathCache || Object.create(null);
+ self.follow = !!options.follow;
+ self.dot = !!options.dot;
+ self.mark = !!options.mark;
+ self.nodir = !!options.nodir;
+ if (self.nodir) self.mark = true;
+ self.sync = !!options.sync;
+ self.nounique = !!options.nounique;
+ self.nonull = !!options.nonull;
+ self.nosort = !!options.nosort;
+ self.nocase = !!options.nocase;
+ self.stat = !!options.stat;
+ self.noprocess = !!options.noprocess;
+ self.absolute = !!options.absolute;
+ self.fs = options.fs || fs;
+
+ self.maxLength = options.maxLength || Infinity;
+ self.cache = options.cache || Object.create(null);
+ self.statCache = options.statCache || Object.create(null);
+ self.symlinks = options.symlinks || Object.create(null);
+
+ setupIgnores(self, options);
+
+ self.changedCwd = false;
+ var cwd = process.cwd();
+ if (!ownProp(options, "cwd")) self.cwd = cwd;else {
+ self.cwd = path.resolve(options.cwd);
+ self.changedCwd = self.cwd !== cwd;
+ }
+
+ self.root = options.root || path.resolve(self.cwd, "/");
+ self.root = path.resolve(self.root);
+ if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/");
+
+ // TODO: is an absolute `cwd` supposed to be resolved against `root`?
+ // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
+ self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
+ if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
+ self.nomount = !!options.nomount;
+
+ // disable comments and negation in Minimatch.
+ // Note that they are not supported in Glob itself anyway.
+ options.nonegate = true;
+ options.nocomment = true;
+
+ self.minimatch = new Minimatch(pattern, options);
+ self.options = self.minimatch.options;
+ }
+
+ function finish(self) {
+ var nou = self.nounique;
+ var all = nou ? [] : Object.create(null);
+
+ for (var i = 0, l = self.matches.length; i < l; i++) {
+ var matches = self.matches[i];
+ if (!matches || Object.keys(matches).length === 0) {
+ if (self.nonull) {
+ // do like the shell, and spit out the literal glob
+ var literal = self.minimatch.globSet[i];
+ if (nou) all.push(literal);else all[literal] = true;
}
- return Promise.resolve();
+ } else {
+ // had matches
+ var m = Object.keys(matches);
+ if (nou) all.push.apply(all, m);else m.forEach(function (m) {
+ all[m] = true;
+ });
}
}
- }
-
- function getPages(pages) {
- return pages.reduce(function (result, pathSubpage) {
- var fileParsed = utilFile.getFileMeta({
- pathRoot: pathRoot,
- pathFile: pathSubpage,
- filetypes: filetypes,
- pathParent: pathPage,
- pathSiteParent: opts.parent
- });
-
- if (fileParsed.name) result[fileParsed.name] = fileParsed;
- return result;
- }, {});
- }
-}
-},{"../utils/file":36,"./defaults":26,"assert":1,"normalize-path":90,"path":98,"pify":100,"smarkt":112,"xtend":127}],33:[function(require,module,exports){
-var slash = require('normalize-path');
-var assert = require('assert');
-var smarkt = require('smarkt');
-var xtend = require('xtend');
-var path = require('path');
-
-var utilFile = require('../utils/file');
-var defaults = require('./defaults');
-
-module.exports = readPageSync;
-
-function readPageSync(pathPage, opts) {
- assert.equal(typeof pathPage, 'string', 'arg1: pathPage must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- var fs = opts.fs;
- var parse = typeof opts.parse === 'function' ? opts.parse : smarkt.parse;
- var fileIndex = opts.file || defaults.file;
- var fileExtname = path.extname(fileIndex);
- var filetypes = opts.filetypes || defaults.filetypes;
- var pathRoot = opts.pathRoot || '';
- var pathUrl = utilFile.formatUrl(pathPage, pathRoot, opts.parent);
- var encoding = opts.encoding || defaults.encoding;
- var content = getContent();
- var children = getChildren().filter(function (file) {
- return utilFile.filterFile(file, fileIndex);
- }).reduce(utilFile.sortChildren, { files: [], pages: [] });
- var files = getFiles(children.files);
- var pages = getPages(children.pages);
-
- return xtend(content, {
- name: path.basename(pathPage),
- path: utilFile.formatUrl(pathPage, pathRoot),
- url: pathUrl,
- files: files,
- pages: pages
- });
-
- function getChildren() {
- try {
- return fs.readdirSync(pathPage);
- } catch (err) {
- return [];
+
+ if (!nou) all = Object.keys(all);
+
+ if (!self.nosort) all = all.sort(alphasort);
+
+ // at *some* point we statted all of these
+ if (self.mark) {
+ for (var i = 0; i < all.length; i++) {
+ all[i] = self._mark(all[i]);
+ }
+ if (self.nodir) {
+ all = all.filter(function (e) {
+ var notDir = !/\/$/.test(e);
+ var c = self.cache[e] || self.cache[makeAbs(self, e)];
+ if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
+ return notDir;
+ });
+ }
}
- }
-
- function getContent() {
- try {
- var content;
- content = fs.readFileSync(slash(path.join(pathPage, fileIndex)), encoding);
- content = parse(content);
- return content;
- } catch (err) {
- return '';
+
+ if (self.ignore.length) all = all.filter(function (m) {
+ return !isIgnored(self, m);
+ });
+
+ self.found = all;
+ }
+
+ function mark(self, p) {
+ var abs = makeAbs(self, p);
+ var c = self.cache[abs];
+ var m = p;
+ if (c) {
+ var isDir = c === 'DIR' || Array.isArray(c);
+ var slash = p.slice(-1) === '/';
+
+ if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
+
+ if (m !== p) {
+ var mabs = makeAbs(self, m);
+ self.statCache[mabs] = self.statCache[abs];
+ self.cache[mabs] = self.cache[abs];
+ }
}
+
+ return m;
+ }
+
+ // lotta situps...
+ function makeAbs(self, f) {
+ var abs = f;
+ if (f.charAt(0) === '/') {
+ abs = path.join(self.root, f);
+ } else if (isAbsolute(f) || f === '') {
+ abs = f;
+ } else if (self.changedCwd) {
+ abs = path.resolve(self.cwd, f);
+ } else {
+ abs = path.resolve(f);
+ }
+
+ if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
+
+ return abs;
+ }
+
+ // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
+ // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
+ function isIgnored(self, path) {
+ if (!self.ignore.length) return false;
+
+ return self.ignore.some(function (item) {
+ return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path));
+ });
}
-
- function getFiles(files) {
- return files.reduce(function (result, pathFile) {
- var fileParsed = utilFile.getFileMeta({
- pathFile: pathFile,
- pathRoot: pathRoot,
- filetypes: filetypes,
- pathParent: pathPage,
- pathSiteParent: opts.parent
- });
-
- try {
- var fileMeta = pathFile + fileExtname;
- var text = fs.readFileSync(slash(path.join(pathPage, fileMeta)), encoding);
- // set
- result[fileParsed.filename] = xtend(parse(text), fileParsed);
- files.splice(files.indexOf(fileMeta), 1);
- // cleanup
- delete result[fileMeta];
- } catch (err) {
- if (fileParsed.filename) {
- result[fileParsed.filename] = fileParsed;
- }
- }
-
- return result;
- }, {});
+
+ function childrenIgnored(self, path) {
+ if (!self.ignore.length) return false;
+
+ return self.ignore.some(function (item) {
+ return !!(item.gmatcher && item.gmatcher.match(path));
+ });
}
-
- function getPages(pages) {
- return pages.reduce(function (result, pathSubpage) {
- var fileParsed = utilFile.getFileMeta({
- pathRoot: pathRoot,
- pathFile: pathSubpage,
- filetypes: filetypes,
- pathParent: pathPage,
- pathSource: opts.source,
- pathSiteParent: opts.parent
- });
-
- if (fileParsed.name) result[fileParsed.name] = fileParsed;
- return result;
- }, {});
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105,"fs":9,"minimatch":74,"path":102,"path-is-absolute":103}],18:[function(require,module,exports){
+ (function (process){(function (){
+ // Approach:
+ //
+ // 1. Get the minimatch set
+ // 2. For each pattern in the set, PROCESS(pattern, false)
+ // 3. Store matches per-set, then uniq them
+ //
+ // PROCESS(pattern, inGlobStar)
+ // Get the first [n] items from pattern that are all strings
+ // Join these together. This is PREFIX.
+ // If there is no more remaining, then stat(PREFIX) and
+ // add to matches if it succeeds. END.
+ //
+ // If inGlobStar and PREFIX is symlink and points to dir
+ // set ENTRIES = []
+ // else readdir(PREFIX) as ENTRIES
+ // If fail, END
+ //
+ // with ENTRIES
+ // If pattern[n] is GLOBSTAR
+ // // handle the case where the globstar match is empty
+ // // by pruning it out, and testing the resulting pattern
+ // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
+ // // handle other cases.
+ // for ENTRY in ENTRIES (not dotfiles)
+ // // attach globstar + tail onto the entry
+ // // Mark that this entry is a globstar match
+ // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
+ //
+ // else // not globstar
+ // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
+ // Test ENTRY against pattern[n]
+ // If fails, continue
+ // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
+ //
+ // Caveat:
+ // Cache all stats and readdirs results to minimize syscall. Since all
+ // we ever care about is existence and directory-ness, we can just keep
+ // `true` for files, and [children,...] for directories, or `false` for
+ // things that don't exist.
+
+ module.exports = glob;
+
+ var rp = require('fs.realpath');
+ var minimatch = require('minimatch');
+ var Minimatch = minimatch.Minimatch;
+ var inherits = require('inherits');
+ var EE = require('events').EventEmitter;
+ var path = require('path');
+ var assert = require('assert');
+ var isAbsolute = require('path-is-absolute');
+ var globSync = require('./sync.js');
+ var common = require('./common.js');
+ var setopts = common.setopts;
+ var ownProp = common.ownProp;
+ var inflight = require('inflight');
+ var util = require('util');
+ var childrenIgnored = common.childrenIgnored;
+ var isIgnored = common.isIgnored;
+
+ var once = require('once');
+
+ function glob(pattern, options, cb) {
+ if (typeof options === 'function') cb = options, options = {};
+ if (!options) options = {};
+
+ if (options.sync) {
+ if (cb) throw new TypeError('callback provided to sync glob');
+ return globSync(pattern, options);
+ }
+
+ return new Glob(pattern, options, cb);
+ }
+
+ glob.sync = globSync;
+ var GlobSync = glob.GlobSync = globSync.GlobSync;
+
+ // old api surface
+ glob.glob = glob;
+
+ function extend(origin, add) {
+ if (add === null || typeof add !== 'object') {
+ return origin;
+ }
+
+ var keys = Object.keys(add);
+ var i = keys.length;
+ while (i--) {
+ origin[keys[i]] = add[keys[i]];
+ }
+ return origin;
}
-}
-},{"../utils/file":36,"./defaults":26,"assert":1,"normalize-path":90,"path":98,"smarkt":112,"xtend":127}],34:[function(require,module,exports){
-var slash = require('normalize-path');
-var assert = require('assert');
-var path = require('path');
-var pify = require('pify');
-var glob = pify(require('glob'));
-
-var readFiles = require('./readFiles');
-
-module.exports = readSite;
-
-async function readSite(pathSite, opts) {
- assert.equal(typeof pathSite, 'string', 'arg1: pathSite must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- // parent
- if (opts.parent === true) opts.parent = pathSite;
-
- // loop through the files
- var files = await glob(slash(path.join(pathSite, '/**/*')));
- return readFiles(files, pathSite, opts);
-}
-},{"./readFiles":30,"assert":1,"glob":18,"normalize-path":90,"path":98,"pify":100}],35:[function(require,module,exports){
-var slash = require('normalize-path');
-var assert = require('assert');
-var path = require('path');
-var glob = require('glob');
-
-var readFilesSync = require('./readFilesSync');
-
-module.exports = readSiteSync;
-
-function readSiteSync(pathSite, opts) {
- assert.equal(typeof pathSite, 'string', 'arg1: pathSite must be type string');
- assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
- assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
-
- // parent
- if (opts.parent === true) opts.parent = pathSite;
-
- // loop through the files
- var files = glob.sync(slash(path.join(pathSite, '/**/*')));
- return readFilesSync(files, pathSite, opts);
-}
-},{"./readFilesSync":31,"assert":1,"glob":18,"normalize-path":90,"path":98}],36:[function(require,module,exports){
-var objectKeys = require('object-keys');
-var assert = require('assert');
-var slash = require('normalize-path');
-var path = require('path');
-
-module.exports = {
- formatUrl: formatUrl,
- filterFile: filterFile,
- getFileType: getFileType,
- getFileMeta: getFileMeta,
- sortChildren: sortChildren,
- isFile: isFile
-};
-
-function sortChildren(result, active) {
- var ext = path.extname(active);
- result = result || {};
- result.files = result.files || [];
- result.pages = result.pages || [];
-
- if (ext) result.files.push(active);else result.pages.push(active);
-
- return result;
-}
-
-function filterFile(file, index) {
- if (file === '.DS_Store') return false;
- if (/(^[.#]|(?:__|~)$)/.test(file)) return false;
- if (file.indexOf(index) >= 0) return false;
- if (file.indexOf('src') >= 0) return false;
- return true;
-}
-
-function getFileType(extension, filetypes) {
- return objectKeys(filetypes).reduce(function (result, value, i, source) {
- if (result) return result;
-
- if (filetypes[value] && filetypes[value].indexOf(extension) >= 0) {
- return value;
- }
-
- if (i >= source.length) return 'unknown';
- }, '');
-}
-
-function isFile(pathFile) {
- assert.equal(typeof pathFile, 'string', 'enoki: arg1 pathFile must be type string');
- return path.extname(pathFile) !== '';
-}
-
-function getFileMeta(opts) {
- assert.equal(typeof opts, 'object', 'enoki: arg1 opts must be type object');
- assert.equal(typeof opts.pathFile, 'string', 'enoki: arg1 opts.pathFile must be type string');
- assert.equal(typeof opts.pathParent, 'string', 'enoki: arg1 opts.pathParent must be type string');
- assert.equal(typeof opts.pathRoot, 'string', 'enoki: arg1 opts.pathRoot must be type string');
- assert.equal(typeof opts.filetypes, 'object', 'enoki: arg1 opts.filetypes must be type string');
-
- var output = {};
- var ext = path.extname(opts.pathFile);
- output.name = path.basename(opts.pathFile, ext);
- output.path = formatUrl(path.join('/', opts.pathParent, '/', opts.pathFile), opts.pathRoot);
- output.url = formatUrl(path.join('/', opts.pathParent, '/', opts.pathFile), opts.pathRoot, opts.pathSiteParent);
- output.source = opts.pathSource ? opts.pathSource + output.path : output.path;
-
- if (ext) {
- output.extension = ext.toLowerCase();
- output.filename = path.basename(opts.pathFile);
- output.type = getFileType(output.extension, opts.filetypes);
- }
-
- return output;
-}
-
-function formatUrl(pathFile, pathRoot, pathSiteParent) {
- pathFile = pathFile.replace(pathRoot, '');
- if (pathSiteParent) pathFile = pathFile.replace(pathSiteParent, '');
- pathFile = slash(path.join('/', pathFile));
- return pathFile || '/';
-}
-},{"assert":1,"normalize-path":90,"object-keys":91,"path":98}],37:[function(require,module,exports){
-(function (process){
-var wrappy = require('wrappy');
-var reqs = Object.create(null);
-var once = require('once');
-
-module.exports = wrappy(inflight);
-
-function inflight(key, cb) {
- if (reqs[key]) {
- reqs[key].push(cb);
- return null;
- } else {
- reqs[key] = [cb];
- return makeres(key);
- }
-}
-
-function makeres(key) {
- return once(function RES() {
- var cbs = reqs[key];
- var len = cbs.length;
- var args = slice(arguments);
-
- // XXX It's somewhat ambiguous whether a new callback added in this
- // pass should be queued for later execution if something in the
- // list of callbacks throws, or if it should just be discarded.
- // However, it's such an edge case that it hardly matters, and either
- // choice is likely as surprising as the other.
- // As it happens, we do go ahead and schedule it for later execution.
- try {
- for (var i = 0; i < len; i++) {
- cbs[i].apply(null, args);
- }
- } finally {
- if (cbs.length > len) {
- // added more in the interim.
- // de-zalgo, just in case, but don't call again.
- cbs.splice(0, len);
- process.nextTick(function () {
- RES.apply(null, args);
- });
- } else {
- delete reqs[key];
- }
+
+ glob.hasMagic = function (pattern, options_) {
+ var options = extend({}, options_);
+ options.noprocess = true;
+
+ var g = new Glob(pattern, options);
+ var set = g.minimatch.set;
+
+ if (!pattern) return false;
+
+ if (set.length > 1) return true;
+
+ for (var j = 0; j < set[0].length; j++) {
+ if (typeof set[0][j] !== 'string') return true;
+ }
+
+ return false;
+ };
+
+ glob.Glob = Glob;
+ inherits(Glob, EE);
+ function Glob(pattern, options, cb) {
+ if (typeof options === 'function') {
+ cb = options;
+ options = null;
+ }
+
+ if (options && options.sync) {
+ if (cb) throw new TypeError('callback provided to sync glob');
+ return new GlobSync(pattern, options);
+ }
+
+ if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
+
+ setopts(this, pattern, options);
+ this._didRealPath = false;
+
+ // process each pattern in the minimatch set
+ var n = this.minimatch.set.length;
+
+ // The matches are stored as {: true,...} so that
+ // duplicates are automagically pruned.
+ // Later, we do an Object.keys() on these.
+ // Keep them as a list so we can fill in when nonull is set.
+ this.matches = new Array(n);
+
+ if (typeof cb === 'function') {
+ cb = once(cb);
+ this.on('error', cb);
+ this.on('end', function (matches) {
+ cb(null, matches);
+ });
}
- });
-}
-
-function slice(args) {
- var length = args.length;
- var array = [];
-
- for (var i = 0; i < length; i++) {
- array[i] = args[i];
- }return array;
-}
-}).call(this,require('_process'))
-},{"_process":101,"once":95,"wrappy":124}],38:[function(require,module,exports){
-arguments[4][2][0].apply(exports,arguments)
-},{"dup":2}],39:[function(require,module,exports){
-var containers = []; // will store container HTMLElement references
-var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}
-
-var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';
-
-function insertCss(css, options) {
- options = options || {};
-
- if (css === undefined) {
- throw new Error(usage);
- }
-
- var position = options.prepend === true ? 'prepend' : 'append';
- var container = options.container !== undefined ? options.container : document.querySelector('head');
- var containerId = containers.indexOf(container);
-
- // first time we see this container, create the necessary entries
- if (containerId === -1) {
- containerId = containers.push(container) - 1;
- styleElements[containerId] = {};
- }
-
- // try to get the correponding container + position styleElement, create it otherwise
- var styleElement;
-
- if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {
- styleElement = styleElements[containerId][position];
- } else {
- styleElement = styleElements[containerId][position] = createStyleElement();
-
- if (position === 'prepend') {
- container.insertBefore(styleElement, container.childNodes[0]);
+
+ var self = this;
+ this._processing = 0;
+
+ this._emitQueue = [];
+ this._processQueue = [];
+ this.paused = false;
+
+ if (this.noprocess) return this;
+
+ if (n === 0) return done();
+
+ var sync = true;
+ for (var i = 0; i < n; i++) {
+ this._process(this.minimatch.set[i], i, false, done);
+ }
+ sync = false;
+
+ function done() {
+ --self._processing;
+ if (self._processing <= 0) {
+ if (sync) {
+ process.nextTick(function () {
+ self._finish();
+ });
} else {
- container.appendChild(styleElement);
+ self._finish();
}
+ }
}
-
- // strip potential UTF-8 BOM if css was read from a file
- if (css.charCodeAt(0) === 0xFEFF) {
- css = css.substr(1, css.length);
- }
-
- // actually add the stylesheet
- if (styleElement.styleSheet) {
- styleElement.styleSheet.cssText += css;
- } else {
- styleElement.textContent += css;
- }
-
- return styleElement;
-};
-
-function createStyleElement() {
- var styleElement = document.createElement('style');
- styleElement.setAttribute('type', 'text/css');
- return styleElement;
-}
-
-module.exports = insertCss;
-module.exports.insertCss = insertCss;
-},{}],40:[function(require,module,exports){
-module.exports = isFunction;
-
-var toString = Object.prototype.toString;
-
-function isFunction(fn) {
- if (!fn) {
- return false;
}
- var string = toString.call(fn);
- return string === '[object Function]' || typeof fn === 'function' && string !== '[object RegExp]' || typeof window !== 'undefined' && (
- // IE8 and below
- fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt);
-};
-},{}],41:[function(require,module,exports){
-'use strict';
-
-var yaml = require('./lib/js-yaml.js');
-
-module.exports = yaml;
-},{"./lib/js-yaml.js":42}],42:[function(require,module,exports){
-'use strict';
-
-var loader = require('./js-yaml/loader');
-var dumper = require('./js-yaml/dumper');
-
-function deprecated(name) {
- return function () {
- throw new Error('Function ' + name + ' is deprecated and cannot be used.');
+
+ Glob.prototype._finish = function () {
+ assert(this instanceof Glob);
+ if (this.aborted) return;
+
+ if (this.realpath && !this._didRealpath) return this._realpath();
+
+ common.finish(this);
+ this.emit('end', this.found);
};
-}
-
-module.exports.Type = require('./js-yaml/type');
-module.exports.Schema = require('./js-yaml/schema');
-module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
-module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
-module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
-module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
-module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
-module.exports.load = loader.load;
-module.exports.loadAll = loader.loadAll;
-module.exports.safeLoad = loader.safeLoad;
-module.exports.safeLoadAll = loader.safeLoadAll;
-module.exports.dump = dumper.dump;
-module.exports.safeDump = dumper.safeDump;
-module.exports.YAMLException = require('./js-yaml/exception');
-
-// Deprecated schema names from JS-YAML 2.0.x
-module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
-module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
-module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
-
-// Deprecated functions from JS-YAML 1.x.x
-module.exports.scan = deprecated('scan');
-module.exports.parse = deprecated('parse');
-module.exports.compose = deprecated('compose');
-module.exports.addConstructor = deprecated('addConstructor');
-},{"./js-yaml/dumper":44,"./js-yaml/exception":45,"./js-yaml/loader":46,"./js-yaml/schema":48,"./js-yaml/schema/core":49,"./js-yaml/schema/default_full":50,"./js-yaml/schema/default_safe":51,"./js-yaml/schema/failsafe":52,"./js-yaml/schema/json":53,"./js-yaml/type":54}],43:[function(require,module,exports){
-'use strict';
-
-function isNothing(subject) {
- return typeof subject === 'undefined' || subject === null;
-}
-
-function isObject(subject) {
- return typeof subject === 'object' && subject !== null;
-}
-
-function toArray(sequence) {
- if (Array.isArray(sequence)) return sequence;else if (isNothing(sequence)) return [];
-
- return [sequence];
-}
-
-function extend(target, source) {
- var index, length, key, sourceKeys;
-
- if (source) {
- sourceKeys = Object.keys(source);
-
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
- key = sourceKeys[index];
- target[key] = source[key];
- }
- }
-
- return target;
-}
-
-function repeat(string, count) {
- var result = '',
- cycle;
-
- for (cycle = 0; cycle < count; cycle += 1) {
- result += string;
- }
-
- return result;
-}
-
-function isNegativeZero(number) {
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
-}
-
-module.exports.isNothing = isNothing;
-module.exports.isObject = isObject;
-module.exports.toArray = toArray;
-module.exports.repeat = repeat;
-module.exports.isNegativeZero = isNegativeZero;
-module.exports.extend = extend;
-},{}],44:[function(require,module,exports){
-'use strict';
-
-/*eslint-disable no-use-before-define*/
-
-var common = require('./common');
-var YAMLException = require('./exception');
-var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
-var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
-
-var _toString = Object.prototype.toString;
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-
-var CHAR_TAB = 0x09; /* Tab */
-var CHAR_LINE_FEED = 0x0A; /* LF */
-var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
-var CHAR_SPACE = 0x20; /* Space */
-var CHAR_EXCLAMATION = 0x21; /* ! */
-var CHAR_DOUBLE_QUOTE = 0x22; /* " */
-var CHAR_SHARP = 0x23; /* # */
-var CHAR_PERCENT = 0x25; /* % */
-var CHAR_AMPERSAND = 0x26; /* & */
-var CHAR_SINGLE_QUOTE = 0x27; /* ' */
-var CHAR_ASTERISK = 0x2A; /* * */
-var CHAR_COMMA = 0x2C; /* , */
-var CHAR_MINUS = 0x2D; /* - */
-var CHAR_COLON = 0x3A; /* : */
-var CHAR_EQUALS = 0x3D; /* = */
-var CHAR_GREATER_THAN = 0x3E; /* > */
-var CHAR_QUESTION = 0x3F; /* ? */
-var CHAR_COMMERCIAL_AT = 0x40; /* @ */
-var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
-var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
-var CHAR_GRAVE_ACCENT = 0x60; /* ` */
-var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
-var CHAR_VERTICAL_LINE = 0x7C; /* | */
-var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
-
-var ESCAPE_SEQUENCES = {};
-
-ESCAPE_SEQUENCES[0x00] = '\\0';
-ESCAPE_SEQUENCES[0x07] = '\\a';
-ESCAPE_SEQUENCES[0x08] = '\\b';
-ESCAPE_SEQUENCES[0x09] = '\\t';
-ESCAPE_SEQUENCES[0x0A] = '\\n';
-ESCAPE_SEQUENCES[0x0B] = '\\v';
-ESCAPE_SEQUENCES[0x0C] = '\\f';
-ESCAPE_SEQUENCES[0x0D] = '\\r';
-ESCAPE_SEQUENCES[0x1B] = '\\e';
-ESCAPE_SEQUENCES[0x22] = '\\"';
-ESCAPE_SEQUENCES[0x5C] = '\\\\';
-ESCAPE_SEQUENCES[0x85] = '\\N';
-ESCAPE_SEQUENCES[0xA0] = '\\_';
-ESCAPE_SEQUENCES[0x2028] = '\\L';
-ESCAPE_SEQUENCES[0x2029] = '\\P';
-
-var DEPRECATED_BOOLEANS_SYNTAX = ['y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'];
-
-function compileStyleMap(schema, map) {
- var result, keys, index, length, tag, style, type;
-
- if (map === null) return {};
-
- result = {};
- keys = Object.keys(map);
-
- for (index = 0, length = keys.length; index < length; index += 1) {
- tag = keys[index];
- style = String(map[tag]);
-
- if (tag.slice(0, 2) === '!!') {
- tag = 'tag:yaml.org,2002:' + tag.slice(2);
- }
- type = schema.compiledTypeMap['fallback'][tag];
-
- if (type && _hasOwnProperty.call(type.styleAliases, style)) {
- style = type.styleAliases[style];
- }
-
- result[tag] = style;
- }
-
- return result;
-}
-
-function encodeHex(character) {
- var string, handle, length;
-
- string = character.toString(16).toUpperCase();
-
- if (character <= 0xFF) {
- handle = 'x';
- length = 2;
- } else if (character <= 0xFFFF) {
- handle = 'u';
- length = 4;
- } else if (character <= 0xFFFFFFFF) {
- handle = 'U';
- length = 8;
- } else {
- throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
- }
-
- return '\\' + handle + common.repeat('0', length - string.length) + string;
-}
-
-function State(options) {
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.indent = Math.max(1, options['indent'] || 2);
- this.noArrayIndent = options['noArrayIndent'] || false;
- this.skipInvalid = options['skipInvalid'] || false;
- this.flowLevel = common.isNothing(options['flowLevel']) ? -1 : options['flowLevel'];
- this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
- this.sortKeys = options['sortKeys'] || false;
- this.lineWidth = options['lineWidth'] || 80;
- this.noRefs = options['noRefs'] || false;
- this.noCompatMode = options['noCompatMode'] || false;
- this.condenseFlow = options['condenseFlow'] || false;
-
- this.implicitTypes = this.schema.compiledImplicit;
- this.explicitTypes = this.schema.compiledExplicit;
-
- this.tag = null;
- this.result = '';
-
- this.duplicates = [];
- this.usedDuplicates = null;
-}
-
-// Indents every line in a string. Empty lines (\n only) are not indented.
-function indentString(string, spaces) {
- var ind = common.repeat(' ', spaces),
- position = 0,
- next = -1,
- result = '',
- line,
- length = string.length;
-
- while (position < length) {
- next = string.indexOf('\n', position);
- if (next === -1) {
- line = string.slice(position);
- position = length;
- } else {
- line = string.slice(position, next + 1);
- position = next + 1;
- }
-
- if (line.length && line !== '\n') result += ind;
-
- result += line;
- }
-
- return result;
-}
-
-function generateNextLine(state, level) {
- return '\n' + common.repeat(' ', state.indent * level);
-}
-
-function testImplicitResolving(state, str) {
- var index, length, type;
-
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
- type = state.implicitTypes[index];
-
- if (type.resolve(str)) {
- return true;
- }
- }
-
- return false;
-}
-
-// [33] s-white ::= s-space | s-tab
-function isWhitespace(c) {
- return c === CHAR_SPACE || c === CHAR_TAB;
-}
-
-// Returns true if the character can be printed without escaping.
-// From YAML 1.2: "any allowed characters known to be non-printable
-// should also be escaped. [However,] This isn’t mandatory"
-// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
-function isPrintable(c) {
- return 0x00020 <= c && c <= 0x00007E || 0x000A1 <= c && c <= 0x00D7FF && c !== 0x2028 && c !== 0x2029 || 0x0E000 <= c && c <= 0x00FFFD && c !== 0xFEFF /* BOM */ || 0x10000 <= c && c <= 0x10FFFF;
-}
-
-// [34] ns-char ::= nb-char - s-white
-// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
-// [26] b-char ::= b-line-feed | b-carriage-return
-// [24] b-line-feed ::= #xA /* LF */
-// [25] b-carriage-return ::= #xD /* CR */
-// [3] c-byte-order-mark ::= #xFEFF
-function isNsChar(c) {
- return isPrintable(c) && !isWhitespace(c)
- // byte-order-mark
- && c !== 0xFEFF
- // b-char
- && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
-}
-
-// Simplified test for values allowed after the first character in plain style.
-function isPlainSafe(c, prev) {
- // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
- // where nb-char ::= c-printable - b-char - c-byte-order-mark.
- return isPrintable(c) && c !== 0xFEFF
- // - c-flow-indicator
- && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET
- // - ":" - "#"
- // /* An ns-char preceding */ "#"
- && c !== CHAR_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
-}
-
-// Simplified test for values allowed as the first character in plain style.
-function isPlainSafeFirst(c) {
- // Uses a subset of ns-char - c-indicator
- // where ns-char = nb-char - s-white.
- return isPrintable(c) && c !== 0xFEFF && !isWhitespace(c) // - s-white
- // - (c-indicator ::=
- // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
- && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET
- // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
- && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE
- // | “%” | “@” | “`”)
- && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
-}
-
-// Determines whether block indentation indicator is required.
-function needIndentIndicator(string) {
- var leadingSpaceRe = /^\n* /;
- return leadingSpaceRe.test(string);
-}
-
-var STYLE_PLAIN = 1,
- STYLE_SINGLE = 2,
- STYLE_LITERAL = 3,
- STYLE_FOLDED = 4,
- STYLE_DOUBLE = 5;
-
-// Determines which scalar styles are possible and returns the preferred style.
-// lineWidth = -1 => no limit.
-// Pre-conditions: str.length > 0.
-// Post-conditions:
-// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
-// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
-// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
-function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
- var i;
- var char, prev_char;
- var hasLineBreak = false;
- var hasFoldableLine = false; // only checked if shouldTrackWidth
- var shouldTrackWidth = lineWidth !== -1;
- var previousLineBreak = -1; // count the first line correctly
- var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
-
- if (singleLineOnly) {
- // Case: no block styles.
- // Check for disallowed characters to rule out plain and single.
- for (i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- if (!isPrintable(char)) {
- return STYLE_DOUBLE;
- }
- prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
- plain = plain && isPlainSafe(char, prev_char);
+
+ Glob.prototype._realpath = function () {
+ if (this._didRealpath) return;
+
+ this._didRealpath = true;
+
+ var n = this.matches.length;
+ if (n === 0) return this._finish();
+
+ var self = this;
+ for (var i = 0; i < this.matches.length; i++) {
+ this._realpathSet(i, next);
+ }function next() {
+ if (--n === 0) self._finish();
}
- } else {
- // Case: block styles permitted.
- for (i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- if (char === CHAR_LINE_FEED) {
- hasLineBreak = true;
- // Check if any line can be folded.
- if (shouldTrackWidth) {
- hasFoldableLine = hasFoldableLine ||
- // Foldable line = too long, and not more-indented.
- i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
- previousLineBreak = i;
+ };
+
+ Glob.prototype._realpathSet = function (index, cb) {
+ var matchset = this.matches[index];
+ if (!matchset) return cb();
+
+ var found = Object.keys(matchset);
+ var self = this;
+ var n = found.length;
+
+ if (n === 0) return cb();
+
+ var set = this.matches[index] = Object.create(null);
+ found.forEach(function (p, i) {
+ // If there's a problem with the stat, then it means that
+ // one or more of the links in the realpath couldn't be
+ // resolved. just return the abs value in that case.
+ p = self._makeAbs(p);
+ rp.realpath(p, self.realpathCache, function (er, real) {
+ if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
+
+ if (--n === 0) {
+ self.matches[index] = set;
+ cb();
}
- } else if (!isPrintable(char)) {
- return STYLE_DOUBLE;
- }
- prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
- plain = plain && isPlainSafe(char, prev_char);
- }
- // in case the end is missing a \n
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
- }
- // Although every style can represent \n without escaping, prefer block styles
- // for multiline, since they're more readable and they don't add empty lines.
- // Also prefer folding a super-long line.
- if (!hasLineBreak && !hasFoldableLine) {
- // Strings interpretable as another type have to be quoted;
- // e.g. the string 'true' vs. the boolean true.
- return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
- }
- // Edge case: block indentation indicator can only have one digit.
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
- return STYLE_DOUBLE;
- }
- // At this point we know block styles are valid.
- // Prefer literal style unless we want to fold.
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
-}
-
-// Note: line breaking/folding is implemented for only the folded style.
-// NB. We drop the last trailing newline (if any) of a returned block scalar
-// since the dumper adds its own newline. This always works:
-// • No ending newline => unaffected; already using strip "-" chomping.
-// • Ending newline => removed then restored.
-// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
-function writeScalar(state, string, level, iskey) {
- state.dump = function () {
- if (string.length === 0) {
- return "''";
- }
- if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
- return "'" + string + "'";
- }
-
- var indent = state.indent * Math.max(1, level); // no 0-indent scalars
- // As indentation gets deeper, let the width decrease monotonically
- // to the lower bound min(state.lineWidth, 40).
- // Note that this implies
- // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
- // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
- // This behaves better than a constant minimum width which disallows narrower options,
- // or an indent threshold which causes the width to suddenly increase.
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
-
- // Without knowing if keys are implicit/explicit, assume implicit for safety.
- var singleLineOnly = iskey
- // No block styles in flow mode.
- || state.flowLevel > -1 && level >= state.flowLevel;
- function testAmbiguity(string) {
- return testImplicitResolving(state, string);
- }
-
- switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
- case STYLE_PLAIN:
- return string;
- case STYLE_SINGLE:
- return "'" + string.replace(/'/g, "''") + "'";
- case STYLE_LITERAL:
- return '|' + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
- case STYLE_FOLDED:
- return '>' + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
- case STYLE_DOUBLE:
- return '"' + escapeString(string, lineWidth) + '"';
- default:
- throw new YAMLException('impossible error: invalid scalar style');
+ });
+ });
+ };
+
+ Glob.prototype._mark = function (p) {
+ return common.mark(this, p);
+ };
+
+ Glob.prototype._makeAbs = function (f) {
+ return common.makeAbs(this, f);
+ };
+
+ Glob.prototype.abort = function () {
+ this.aborted = true;
+ this.emit('abort');
+ };
+
+ Glob.prototype.pause = function () {
+ if (!this.paused) {
+ this.paused = true;
+ this.emit('pause');
}
- }();
-}
-
-// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
-function blockHeader(string, indentPerLevel) {
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
-
- // note the special case: the string '\n' counts as a "trailing" empty line.
- var clip = string[string.length - 1] === '\n';
- var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
- var chomp = keep ? '+' : clip ? '' : '-';
-
- return indentIndicator + chomp + '\n';
-}
-
-// (See the note for writeScalar.)
-function dropEndingNewline(string) {
- return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
-}
-
-// Note: a long line without a suitable break point will exceed the width limit.
-// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
-function foldString(string, width) {
- // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
- // unless they're before or after a more-indented line, or at the very
- // beginning or end, in which case $k$ maps to $k$.
- // Therefore, parse each chunk as newline(s) followed by a content line.
- var lineRe = /(\n+)([^\n]*)/g;
-
- // first line (possibly an empty line)
- var result = function () {
- var nextLF = string.indexOf('\n');
- nextLF = nextLF !== -1 ? nextLF : string.length;
- lineRe.lastIndex = nextLF;
- return foldLine(string.slice(0, nextLF), width);
- }();
- // If we haven't reached the first content line yet, don't add an extra \n.
- var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
- var moreIndented;
-
- // rest of the lines
- var match;
- while (match = lineRe.exec(string)) {
- var prefix = match[1],
- line = match[2];
- moreIndented = line[0] === ' ';
- result += prefix + (!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') + foldLine(line, width);
- prevMoreIndented = moreIndented;
- }
-
- return result;
-}
-
-// Greedy line breaking.
-// Picks the longest line under the limit each time,
-// otherwise settles for the shortest line over the limit.
-// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
-function foldLine(line, width) {
- if (line === '' || line[0] === ' ') return line;
-
- // Since a more-indented line adds a \n, breaks can't be followed by a space.
- var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
- var match;
- // start is an inclusive index. end, curr, and next are exclusive.
- var start = 0,
- end,
- curr = 0,
- next = 0;
- var result = '';
-
- // Invariants: 0 <= start <= length-1.
- // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
- // Inside the loop:
- // A match implies length >= 2, so curr and next are <= length-2.
- while (match = breakRe.exec(line)) {
- next = match.index;
- // maintain invariant: curr - start <= width
- if (next - start > width) {
- end = curr > start ? curr : next; // derive end <= length-2
- result += '\n' + line.slice(start, end);
- // skip the space that was output as \n
- start = end + 1; // derive start <= length-1
- }
- curr = next;
- }
-
- // By the invariants, start <= length-1, so there is something left over.
- // It is either the whole string or a part starting from non-whitespace.
- result += '\n';
- // Insert a break if the remainder is too long and there is a break available.
- if (line.length - start > width && curr > start) {
- result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
- } else {
- result += line.slice(start);
- }
-
- return result.slice(1); // drop extra \n joiner
-}
-
-// Escapes a double-quoted string.
-function escapeString(string) {
- var result = '';
- var char, nextChar;
- var escapeSeq;
-
- for (var i = 0; i < string.length; i++) {
- char = string.charCodeAt(i);
- // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
- if (char >= 0xD800 && char <= 0xDBFF /* high surrogate */) {
- nextChar = string.charCodeAt(i + 1);
- if (nextChar >= 0xDC00 && nextChar <= 0xDFFF /* low surrogate */) {
- // Combine the surrogate pair and store it escaped.
- result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
- // Advance index one extra since we already used that char here.
- i++;continue;
- }
- }
- escapeSeq = ESCAPE_SEQUENCES[char];
- result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
- }
-
- return result;
-}
-
-function writeFlowSequence(state, level, object) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level, object[index], false, false)) {
- if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
- _result += state.dump;
- }
- }
-
- state.tag = _tag;
- state.dump = '[' + _result + ']';
-}
-
-function writeBlockSequence(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- index,
- length;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- // Write only valid elements.
- if (writeNode(state, level + 1, object[index], true, true)) {
- if (!compact || index !== 0) {
- _result += generateNextLine(state, level);
+ };
+
+ Glob.prototype.resume = function () {
+ if (this.paused) {
+ this.emit('resume');
+ this.paused = false;
+ if (this._emitQueue.length) {
+ var eq = this._emitQueue.slice(0);
+ this._emitQueue.length = 0;
+ for (var i = 0; i < eq.length; i++) {
+ var e = eq[i];
+ this._emitMatch(e[0], e[1]);
+ }
}
-
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- _result += '-';
- } else {
- _result += '- ';
- }
-
- _result += state.dump;
- }
- }
-
- state.tag = _tag;
- state.dump = _result || '[]'; // Empty sequence if no valid values.
-}
-
-function writeFlowMapping(state, level, object) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- pairBuffer;
-
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
-
- pairBuffer = '';
- if (index !== 0) pairBuffer += ', ';
-
- if (state.condenseFlow) pairBuffer += '"';
-
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
-
- if (!writeNode(state, level, objectKey, false, false)) {
- continue; // Skip this pair because of invalid key;
- }
-
- if (state.dump.length > 1024) pairBuffer += '? ';
-
- pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
-
- if (!writeNode(state, level, objectValue, false, false)) {
- continue; // Skip this pair because of invalid value.
- }
-
- pairBuffer += state.dump;
-
- // Both key and value are valid.
- _result += pairBuffer;
- }
-
- state.tag = _tag;
- state.dump = '{' + _result + '}';
-}
-
-function writeBlockMapping(state, level, object, compact) {
- var _result = '',
- _tag = state.tag,
- objectKeyList = Object.keys(object),
- index,
- length,
- objectKey,
- objectValue,
- explicitPair,
- pairBuffer;
-
- // Allow sorting keys so that the output file is deterministic
- if (state.sortKeys === true) {
- // Default sorting
- objectKeyList.sort();
- } else if (typeof state.sortKeys === 'function') {
- // Custom sort function
- objectKeyList.sort(state.sortKeys);
- } else if (state.sortKeys) {
- // Something is wrong
- throw new YAMLException('sortKeys must be a boolean or a function');
- }
-
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- pairBuffer = '';
-
- if (!compact || index !== 0) {
- pairBuffer += generateNextLine(state, level);
- }
-
- objectKey = objectKeyList[index];
- objectValue = object[objectKey];
-
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
- continue; // Skip this pair because of invalid key.
- }
-
- explicitPair = state.tag !== null && state.tag !== '?' || state.dump && state.dump.length > 1024;
-
- if (explicitPair) {
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += '?';
- } else {
- pairBuffer += '? ';
+ if (this._processQueue.length) {
+ var pq = this._processQueue.slice(0);
+ this._processQueue.length = 0;
+ for (var i = 0; i < pq.length; i++) {
+ var p = pq[i];
+ this._processing--;
+ this._process(p[0], p[1], p[2], p[3]);
+ }
}
}
-
- pairBuffer += state.dump;
-
- if (explicitPair) {
- pairBuffer += generateNextLine(state, level);
+ };
+
+ Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
+ assert(this instanceof Glob);
+ assert(typeof cb === 'function');
+
+ if (this.aborted) return;
+
+ this._processing++;
+ if (this.paused) {
+ this._processQueue.push([pattern, index, inGlobStar, cb]);
+ return;
}
-
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
- continue; // Skip this pair because of invalid value.
+
+ //console.error('PROCESS %d', this._processing, pattern)
+
+ // Get the first [n] parts of pattern that are all strings.
+ var n = 0;
+ while (typeof pattern[n] === 'string') {
+ n++;
+ }
+ // now n is the index of the first one that is *not* a string.
+
+ // see if there's anything else
+ var prefix;
+ switch (n) {
+ // if not, then this is rather simple
+ case pattern.length:
+ this._processSimple(pattern.join('/'), index, cb);
+ return;
+
+ case 0:
+ // pattern *starts* with some non-trivial item.
+ // going to readdir(cwd), but not include the prefix in matches.
+ prefix = null;
+ break;
+
+ default:
+ // pattern has some string bits in the front.
+ // whatever it starts with, whether that's 'absolute' like /foo/bar,
+ // or 'relative' like '../baz'
+ prefix = pattern.slice(0, n).join('/');
+ break;
}
-
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
- pairBuffer += ':';
- } else {
- pairBuffer += ': ';
- }
-
- pairBuffer += state.dump;
-
- // Both key and value are valid.
- _result += pairBuffer;
- }
-
- state.tag = _tag;
- state.dump = _result || '{}'; // Empty mapping if no valid pairs.
-}
-
-function detectType(state, object, explicit) {
- var _result, typeList, index, length, type, style;
-
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
-
- for (index = 0, length = typeList.length; index < length; index += 1) {
- type = typeList[index];
-
- if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === 'object' && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
-
- state.tag = explicit ? type.tag : '?';
-
- if (type.represent) {
- style = state.styleMap[type.tag] || type.defaultStyle;
-
- if (_toString.call(type.represent) === '[object Function]') {
- _result = type.represent(object, style);
- } else if (_hasOwnProperty.call(type.represent, style)) {
- _result = type.represent[style](object, style);
+
+ var remain = pattern.slice(n);
+
+ // get the list of entries.
+ var read;
+ if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
+ if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
+ read = prefix;
+ } else read = prefix;
+
+ var abs = this._makeAbs(read);
+
+ //if ignored, skip _processing
+ if (childrenIgnored(this, read)) return cb();
+
+ var isGlobStar = remain[0] === minimatch.GLOBSTAR;
+ if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
+ };
+
+ Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
+ var self = this;
+ this._readdir(abs, inGlobStar, function (er, entries) {
+ return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
+ });
+ };
+
+ Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
+
+ // if the abs isn't a dir, then nothing can match!
+ if (!entries) return cb();
+
+ // It will only match dot entries if it starts with a dot, or if
+ // dot is set. Stuff like @(.foo|.bar) isn't allowed.
+ var pn = remain[0];
+ var negate = !!this.minimatch.negate;
+ var rawGlob = pn._glob;
+ var dotOk = this.dot || rawGlob.charAt(0) === '.';
+
+ var matchedEntries = [];
+ for (var i = 0; i < entries.length; i++) {
+ var e = entries[i];
+ if (e.charAt(0) !== '.' || dotOk) {
+ var m;
+ if (negate && !prefix) {
+ m = !e.match(pn);
} else {
- throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
+ m = e.match(pn);
}
-
- state.dump = _result;
+ if (m) matchedEntries.push(e);
}
-
- return true;
}
- }
-
- return false;
-}
-
-// Serializes `object` and writes it to global `result`.
-// Returns true on success, or false on invalid object.
-//
-function writeNode(state, level, object, block, compact, iskey) {
- state.tag = null;
- state.dump = object;
-
- if (!detectType(state, object, false)) {
- detectType(state, object, true);
- }
-
- var type = _toString.call(state.dump);
-
- if (block) {
- block = state.flowLevel < 0 || state.flowLevel > level;
- }
-
- var objectOrArray = type === '[object Object]' || type === '[object Array]',
- duplicateIndex,
- duplicate;
-
- if (objectOrArray) {
- duplicateIndex = state.duplicates.indexOf(object);
- duplicate = duplicateIndex !== -1;
- }
-
- if (state.tag !== null && state.tag !== '?' || duplicate || state.indent !== 2 && level > 0) {
- compact = false;
- }
-
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
- state.dump = '*ref_' + duplicateIndex;
- } else {
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
- state.usedDuplicates[duplicateIndex] = true;
- }
- if (type === '[object Object]') {
- if (block && Object.keys(state.dump).length !== 0) {
- writeBlockMapping(state, level, state.dump, compact);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + state.dump;
- }
- } else {
- writeFlowMapping(state, level, state.dump);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
- }
- }
- } else if (type === '[object Array]') {
- var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
- if (block && state.dump.length !== 0) {
- writeBlockSequence(state, arrayLevel, state.dump, compact);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + state.dump;
+
+ //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
+
+ var len = matchedEntries.length;
+ // If there are no matched entries, then nothing matches.
+ if (len === 0) return cb();
+
+ // if this is the last remaining pattern bit, then no need for
+ // an additional stat *unless* the user has specified mark or
+ // stat explicitly. We know they exist, since readdir returned
+ // them.
+
+ if (remain.length === 1 && !this.mark && !this.stat) {
+ if (!this.matches[index]) this.matches[index] = Object.create(null);
+
+ for (var i = 0; i < len; i++) {
+ var e = matchedEntries[i];
+ if (prefix) {
+ if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
}
- } else {
- writeFlowSequence(state, arrayLevel, state.dump);
- if (duplicate) {
- state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
+
+ if (e.charAt(0) === '/' && !this.nomount) {
+ e = path.join(this.root, e);
}
+ this._emitMatch(index, e);
}
- } else if (type === '[object String]') {
- if (state.tag !== '?') {
- writeScalar(state, state.dump, level, iskey);
- }
- } else {
- if (state.skipInvalid) return false;
- throw new YAMLException('unacceptable kind of an object to dump ' + type);
- }
-
- if (state.tag !== null && state.tag !== '?') {
- state.dump = '!<' + state.tag + '> ' + state.dump;
- }
- }
-
- return true;
-}
-
-function getDuplicateReferences(object, state) {
- var objects = [],
- duplicatesIndexes = [],
- index,
- length;
-
- inspectNode(object, objects, duplicatesIndexes);
-
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
- state.duplicates.push(objects[duplicatesIndexes[index]]);
- }
- state.usedDuplicates = new Array(length);
-}
-
-function inspectNode(object, objects, duplicatesIndexes) {
- var objectKeyList, index, length;
-
- if (object !== null && typeof object === 'object') {
- index = objects.indexOf(object);
- if (index !== -1) {
- if (duplicatesIndexes.indexOf(index) === -1) {
- duplicatesIndexes.push(index);
- }
- } else {
- objects.push(object);
-
- if (Array.isArray(object)) {
- for (index = 0, length = object.length; index < length; index += 1) {
- inspectNode(object[index], objects, duplicatesIndexes);
- }
- } else {
- objectKeyList = Object.keys(object);
-
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
- }
+ // This was the last one, and no stats were needed
+ return cb();
+ }
+
+ // now test all matched entries as stand-ins for that part
+ // of the pattern.
+ remain.shift();
+ for (var i = 0; i < len; i++) {
+ var e = matchedEntries[i];
+ var newPattern;
+ if (prefix) {
+ if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
}
+ this._process([e].concat(remain), index, inGlobStar, cb);
}
- }
-}
-
-function dump(input, options) {
- options = options || {};
-
- var state = new State(options);
-
- if (!state.noRefs) getDuplicateReferences(input, state);
-
- if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
-
- return '';
-}
-
-function safeDump(input, options) {
- return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-module.exports.dump = dump;
-module.exports.safeDump = safeDump;
-},{"./common":43,"./exception":45,"./schema/default_full":50,"./schema/default_safe":51}],45:[function(require,module,exports){
-// YAML error class. http://stackoverflow.com/questions/8458984
-//
-'use strict';
-
-function YAMLException(reason, mark) {
- // Super constructor
- Error.call(this);
-
- this.name = 'YAMLException';
- this.reason = reason;
- this.mark = mark;
- this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
-
- // Include stack trace in error object
- if (Error.captureStackTrace) {
- // Chrome and NodeJS
- Error.captureStackTrace(this, this.constructor);
- } else {
- // FF, IE 10+ and Safari 6+. Fallback for others
- this.stack = new Error().stack || '';
- }
-}
-
-// Inherit from Error
-YAMLException.prototype = Object.create(Error.prototype);
-YAMLException.prototype.constructor = YAMLException;
-
-YAMLException.prototype.toString = function toString(compact) {
- var result = this.name + ': ';
-
- result += this.reason || '(unknown reason)';
-
- if (!compact && this.mark) {
- result += ' ' + this.mark.toString();
- }
-
- return result;
-};
-
-module.exports = YAMLException;
-},{}],46:[function(require,module,exports){
-'use strict';
-
-/*eslint-disable max-len,no-use-before-define*/
-
-var common = require('./common');
-var YAMLException = require('./exception');
-var Mark = require('./mark');
-var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
-var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-
-var CONTEXT_FLOW_IN = 1;
-var CONTEXT_FLOW_OUT = 2;
-var CONTEXT_BLOCK_IN = 3;
-var CONTEXT_BLOCK_OUT = 4;
-
-var CHOMPING_CLIP = 1;
-var CHOMPING_STRIP = 2;
-var CHOMPING_KEEP = 3;
-
-var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
-var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
-var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
-var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
-var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
-
-function _class(obj) {
- return Object.prototype.toString.call(obj);
-}
-
-function is_EOL(c) {
- return c === 0x0A /* LF */ || c === 0x0D /* CR */;
-}
-
-function is_WHITE_SPACE(c) {
- return c === 0x09 /* Tab */ || c === 0x20 /* Space */;
-}
-
-function is_WS_OR_EOL(c) {
- return c === 0x09 /* Tab */ || c === 0x20 /* Space */ || c === 0x0A /* LF */ || c === 0x0D /* CR */;
-}
-
-function is_FLOW_INDICATOR(c) {
- return c === 0x2C /* , */ || c === 0x5B /* [ */ || c === 0x5D /* ] */ || c === 0x7B /* { */ || c === 0x7D /* } */;
-}
-
-function fromHexCode(c) {
- var lc;
-
- if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) {
- return c - 0x30;
- }
-
- /*eslint-disable no-bitwise*/
- lc = c | 0x20;
-
- if (0x61 /* a */ <= lc && lc <= 0x66 /* f */) {
- return lc - 0x61 + 10;
- }
-
- return -1;
-}
-
-function escapedHexLen(c) {
- if (c === 0x78 /* x */) {
- return 2;
- }
- if (c === 0x75 /* u */) {
- return 4;
- }
- if (c === 0x55 /* U */) {
- return 8;
- }
- return 0;
-}
-
-function fromDecimalCode(c) {
- if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) {
- return c - 0x30;
- }
-
- return -1;
-}
-
-function simpleEscapeSequence(c) {
- /* eslint-disable indent */
- return c === 0x30 /* 0 */ ? '\x00' : c === 0x61 /* a */ ? '\x07' : c === 0x62 /* b */ ? '\x08' : c === 0x74 /* t */ ? '\x09' : c === 0x09 /* Tab */ ? '\x09' : c === 0x6E /* n */ ? '\x0A' : c === 0x76 /* v */ ? '\x0B' : c === 0x66 /* f */ ? '\x0C' : c === 0x72 /* r */ ? '\x0D' : c === 0x65 /* e */ ? '\x1B' : c === 0x20 /* Space */ ? ' ' : c === 0x22 /* " */ ? '\x22' : c === 0x2F /* / */ ? '/' : c === 0x5C /* \ */ ? '\x5C' : c === 0x4E /* N */ ? '\x85' : c === 0x5F /* _ */ ? '\xA0' : c === 0x4C /* L */ ? '\u2028' : c === 0x50 /* P */ ? '\u2029' : '';
-}
-
-function charFromCodepoint(c) {
- if (c <= 0xFFFF) {
- return String.fromCharCode(c);
- }
- // Encode UTF-16 surrogate pair
- // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
- return String.fromCharCode((c - 0x010000 >> 10) + 0xD800, (c - 0x010000 & 0x03FF) + 0xDC00);
-}
-
-var simpleEscapeCheck = new Array(256); // integer, for fast access
-var simpleEscapeMap = new Array(256);
-for (var i = 0; i < 256; i++) {
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
- simpleEscapeMap[i] = simpleEscapeSequence(i);
-}
-
-function State(input, options) {
- this.input = input;
-
- this.filename = options['filename'] || null;
- this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
- this.onWarning = options['onWarning'] || null;
- this.legacy = options['legacy'] || false;
- this.json = options['json'] || false;
- this.listener = options['listener'] || null;
-
- this.implicitTypes = this.schema.compiledImplicit;
- this.typeMap = this.schema.compiledTypeMap;
-
- this.length = input.length;
- this.position = 0;
- this.line = 0;
- this.lineStart = 0;
- this.lineIndent = 0;
-
- this.documents = [];
-
- /*
- this.version;
- this.checkLineBreaks;
- this.tagMap;
- this.anchorMap;
- this.tag;
- this.anchor;
- this.kind;
- this.result;*/
-}
-
-function generateError(state, message) {
- return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart));
-}
-
-function throwError(state, message) {
- throw generateError(state, message);
-}
-
-function throwWarning(state, message) {
- if (state.onWarning) {
- state.onWarning.call(null, generateError(state, message));
- }
-}
-
-var directiveHandlers = {
-
- YAML: function handleYamlDirective(state, name, args) {
-
- var match, major, minor;
-
- if (state.version !== null) {
- throwError(state, 'duplication of %YAML directive');
- }
-
- if (args.length !== 1) {
- throwError(state, 'YAML directive accepts exactly one argument');
- }
-
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
-
- if (match === null) {
- throwError(state, 'ill-formed argument of the YAML directive');
- }
-
- major = parseInt(match[1], 10);
- minor = parseInt(match[2], 10);
-
- if (major !== 1) {
- throwError(state, 'unacceptable YAML version of the document');
- }
-
- state.version = args[0];
- state.checkLineBreaks = minor < 2;
-
- if (minor !== 1 && minor !== 2) {
- throwWarning(state, 'unsupported YAML version of the document');
+ cb();
+ };
+
+ Glob.prototype._emitMatch = function (index, e) {
+ if (this.aborted) return;
+
+ if (isIgnored(this, e)) return;
+
+ if (this.paused) {
+ this._emitQueue.push([index, e]);
+ return;
}
- },
-
- TAG: function handleTagDirective(state, name, args) {
-
- var handle, prefix;
-
- if (args.length !== 2) {
- throwError(state, 'TAG directive accepts exactly two arguments');
- }
-
- handle = args[0];
- prefix = args[1];
-
- if (!PATTERN_TAG_HANDLE.test(handle)) {
- throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
- }
-
- if (_hasOwnProperty.call(state.tagMap, handle)) {
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
- }
-
- if (!PATTERN_TAG_URI.test(prefix)) {
- throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
- }
-
- state.tagMap[handle] = prefix;
- }
-};
-
-function captureSegment(state, start, end, checkJson) {
- var _position, _length, _character, _result;
-
- if (start < end) {
- _result = state.input.slice(start, end);
-
- if (checkJson) {
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
- _character = _result.charCodeAt(_position);
- if (!(_character === 0x09 || 0x20 <= _character && _character <= 0x10FFFF)) {
- throwError(state, 'expected valid JSON character');
- }
- }
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
- throwError(state, 'the stream contains non-printable characters');
- }
-
- state.result += _result;
- }
-}
-
-function mergeMappings(state, destination, source, overridableKeys) {
- var sourceKeys, key, index, quantity;
-
- if (!common.isObject(source)) {
- throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
- }
-
- sourceKeys = Object.keys(source);
-
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
- key = sourceKeys[index];
-
- if (!_hasOwnProperty.call(destination, key)) {
- destination[key] = source[key];
- overridableKeys[key] = true;
- }
- }
-}
-
-function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
- var index, quantity;
-
- // The output is a plain object here, so keys can only be strings.
- // We need to convert keyNode to a string, but doing so can hang the process
- // (deeply nested arrays that explode exponentially using aliases).
- if (Array.isArray(keyNode)) {
- keyNode = Array.prototype.slice.call(keyNode);
-
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
- if (Array.isArray(keyNode[index])) {
- throwError(state, 'nested arrays are not supported inside keys');
- }
-
- if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
- keyNode[index] = '[object Object]';
- }
- }
- }
-
- // Avoid code execution in load() via toString property
- // (still use its own toString for arrays, timestamps,
- // and whatever user schema extensions happen to have @@toStringTag)
- if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
- keyNode = '[object Object]';
- }
-
- keyNode = String(keyNode);
-
- if (_result === null) {
- _result = {};
- }
-
- if (keyTag === 'tag:yaml.org,2002:merge') {
- if (Array.isArray(valueNode)) {
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
- mergeMappings(state, _result, valueNode[index], overridableKeys);
+
+ var abs = isAbsolute(e) ? e : this._makeAbs(e);
+
+ if (this.mark) e = this._mark(e);
+
+ if (this.absolute) e = abs;
+
+ if (this.matches[index][e]) return;
+
+ if (this.nodir) {
+ var c = this.cache[abs];
+ if (c === 'DIR' || Array.isArray(c)) return;
+ }
+
+ this.matches[index][e] = true;
+
+ var st = this.statCache[abs];
+ if (st) this.emit('stat', e, st);
+
+ this.emit('match', e);
+ };
+
+ Glob.prototype._readdirInGlobStar = function (abs, cb) {
+ if (this.aborted) return;
+
+ // follow all symlinked directories forever
+ // just proceed as if this is a non-globstar situation
+ if (this.follow) return this._readdir(abs, false, cb);
+
+ var lstatkey = 'lstat\0' + abs;
+ var self = this;
+ var lstatcb = inflight(lstatkey, lstatcb_);
+
+ if (lstatcb) self.fs.lstat(abs, lstatcb);
+
+ function lstatcb_(er, lstat) {
+ if (er && er.code === 'ENOENT') return cb();
+
+ var isSym = lstat && lstat.isSymbolicLink();
+ self.symlinks[abs] = isSym;
+
+ // If it's not a symlink or a dir, then it's definitely a regular file.
+ // don't bother doing a readdir in that case.
+ if (!isSym && lstat && !lstat.isDirectory()) {
+ self.cache[abs] = 'FILE';
+ cb();
+ } else self._readdir(abs, false, cb);
+ }
+ };
+
+ Glob.prototype._readdir = function (abs, inGlobStar, cb) {
+ if (this.aborted) return;
+
+ cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb);
+ if (!cb) return;
+
+ //console.error('RD %j %j', +inGlobStar, abs)
+ if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
+
+ if (ownProp(this.cache, abs)) {
+ var c = this.cache[abs];
+ if (!c || c === 'FILE') return cb();
+
+ if (Array.isArray(c)) return cb(null, c);
+ }
+
+ var self = this;
+ self.fs.readdir(abs, readdirCb(this, abs, cb));
+ };
+
+ function readdirCb(self, abs, cb) {
+ return function (er, entries) {
+ if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
+ };
+ }
+
+ Glob.prototype._readdirEntries = function (abs, entries, cb) {
+ if (this.aborted) return;
+
+ // if we haven't asked to stat everything, then just
+ // assume that everything in there exists, so we can avoid
+ // having to stat it a second time.
+ if (!this.mark && !this.stat) {
+ for (var i = 0; i < entries.length; i++) {
+ var e = entries[i];
+ if (abs === '/') e = abs + e;else e = abs + '/' + e;
+ this.cache[e] = true;
}
- } else {
- mergeMappings(state, _result, valueNode, overridableKeys);
}
- } else {
- if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
- state.line = startLine || state.line;
- state.position = startPos || state.position;
- throwError(state, 'duplicated mapping key');
- }
- _result[keyNode] = valueNode;
- delete overridableKeys[keyNode];
- }
-
- return _result;
-}
-
-function readLineBreak(state) {
- var ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x0A /* LF */) {
- state.position++;
- } else if (ch === 0x0D /* CR */) {
- state.position++;
- if (state.input.charCodeAt(state.position) === 0x0A /* LF */) {
+
+ this.cache[abs] = entries;
+ return cb(null, entries);
+ };
+
+ Glob.prototype._readdirError = function (f, er, cb) {
+ if (this.aborted) return;
+
+ // handle errors, and cache the information
+ switch (er.code) {
+ case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
+ case 'ENOTDIR':
+ // totally normal. means it *does* exist.
+ var abs = this._makeAbs(f);
+ this.cache[abs] = 'FILE';
+ if (abs === this.cwdAbs) {
+ var error = new Error(er.code + ' invalid cwd ' + this.cwd);
+ error.path = this.cwd;
+ error.code = er.code;
+ this.emit('error', error);
+ this.abort();
+ }
+ break;
+
+ case 'ENOENT': // not terribly unusual
+ case 'ELOOP':
+ case 'ENAMETOOLONG':
+ case 'UNKNOWN':
+ this.cache[this._makeAbs(f)] = false;
+ break;
+
+ default:
+ // some unusual error. Treat as failure.
+ this.cache[this._makeAbs(f)] = false;
+ if (this.strict) {
+ this.emit('error', er);
+ // If the error is handled, then we abort
+ // if not, we threw out of here
+ this.abort();
+ }
+ if (!this.silent) console.error('glob error', er);
+ break;
+ }
+
+ return cb();
+ };
+
+ Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
+ var self = this;
+ this._readdir(abs, inGlobStar, function (er, entries) {
+ self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
+ });
+ };
+
+ Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
+ //console.error('pgs2', prefix, remain[0], entries)
+
+ // no entries means not a dir, so it can never have matches
+ // foo.txt/** doesn't match foo.txt
+ if (!entries) return cb();
+
+ // test without the globstar, and with every child both below
+ // and replacing the globstar.
+ var remainWithoutGlobStar = remain.slice(1);
+ var gspref = prefix ? [prefix] : [];
+ var noGlobStar = gspref.concat(remainWithoutGlobStar);
+
+ // the noGlobStar pattern exits the inGlobStar state
+ this._process(noGlobStar, index, false, cb);
+
+ var isSym = this.symlinks[abs];
+ var len = entries.length;
+
+ // If it's a symlink, and we're in a globstar, then stop
+ if (isSym && inGlobStar) return cb();
+
+ for (var i = 0; i < len; i++) {
+ var e = entries[i];
+ if (e.charAt(0) === '.' && !this.dot) continue;
+
+ // these two cases enter the inGlobStar state
+ var instead = gspref.concat(entries[i], remainWithoutGlobStar);
+ this._process(instead, index, true, cb);
+
+ var below = gspref.concat(entries[i], remain);
+ this._process(below, index, true, cb);
+ }
+
+ cb();
+ };
+
+ Glob.prototype._processSimple = function (prefix, index, cb) {
+ // XXX review this. Shouldn't it be doing the mounting etc
+ // before doing stat? kinda weird?
+ var self = this;
+ this._stat(prefix, function (er, exists) {
+ self._processSimple2(prefix, index, er, exists, cb);
+ });
+ };
+ Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
+
+ //console.error('ps2', prefix, exists)
+
+ if (!this.matches[index]) this.matches[index] = Object.create(null);
+
+ // If it doesn't exist, then just mark the lack of results
+ if (!exists) return cb();
+
+ if (prefix && isAbsolute(prefix) && !this.nomount) {
+ var trail = /[\/\\]$/.test(prefix);
+ if (prefix.charAt(0) === '/') {
+ prefix = path.join(this.root, prefix);
+ } else {
+ prefix = path.resolve(this.root, prefix);
+ if (trail) prefix += '/';
+ }
+ }
+
+ if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/');
+
+ // Mark this as a match
+ this._emitMatch(index, prefix);
+ cb();
+ };
+
+ // Returns either 'DIR', 'FILE', or false
+ Glob.prototype._stat = function (f, cb) {
+ var abs = this._makeAbs(f);
+ var needDir = f.slice(-1) === '/';
+
+ if (f.length > this.maxLength) return cb();
+
+ if (!this.stat && ownProp(this.cache, abs)) {
+ var c = this.cache[abs];
+
+ if (Array.isArray(c)) c = 'DIR';
+
+ // It exists, but maybe not how we need it
+ if (!needDir || c === 'DIR') return cb(null, c);
+
+ if (needDir && c === 'FILE') return cb();
+
+ // otherwise we have to stat, because maybe c=true
+ // if we know it exists, but not what it is.
+ }
+
+ var exists;
+ var stat = this.statCache[abs];
+ if (stat !== undefined) {
+ if (stat === false) return cb(null, stat);else {
+ var type = stat.isDirectory() ? 'DIR' : 'FILE';
+ if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
+ }
+ }
+
+ var self = this;
+ var statcb = inflight('stat\0' + abs, lstatcb_);
+ if (statcb) self.fs.lstat(abs, statcb);
+
+ function lstatcb_(er, lstat) {
+ if (lstat && lstat.isSymbolicLink()) {
+ // If it's a symlink, then treat it as the target, unless
+ // the target does not exist, then treat it as a file.
+ return self.fs.stat(abs, function (er, stat) {
+ if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
+ });
+ } else {
+ self._stat2(f, abs, er, lstat, cb);
+ }
+ }
+ };
+
+ Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
+ if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
+ this.statCache[abs] = false;
+ return cb();
+ }
+
+ var needDir = f.slice(-1) === '/';
+ this.statCache[abs] = stat;
+
+ if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
+
+ var c = true;
+ if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
+ this.cache[abs] = this.cache[abs] || c;
+
+ if (needDir && c === 'FILE') return cb();
+
+ return cb(null, c, stat);
+ };
+ }).call(this)}).call(this,require('_process'))
+ },{"./common.js":17,"./sync.js":19,"_process":105,"assert":1,"events":14,"fs.realpath":15,"inflight":39,"inherits":40,"minimatch":74,"once":99,"path":102,"path-is-absolute":103,"util":126}],19:[function(require,module,exports){
+ (function (process){(function (){
+ module.exports = globSync;
+ globSync.GlobSync = GlobSync;
+
+ var rp = require('fs.realpath');
+ var minimatch = require('minimatch');
+ var Minimatch = minimatch.Minimatch;
+ var Glob = require('./glob.js').Glob;
+ var util = require('util');
+ var path = require('path');
+ var assert = require('assert');
+ var isAbsolute = require('path-is-absolute');
+ var common = require('./common.js');
+ var setopts = common.setopts;
+ var ownProp = common.ownProp;
+ var childrenIgnored = common.childrenIgnored;
+ var isIgnored = common.isIgnored;
+
+ function globSync(pattern, options) {
+ if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
+
+ return new GlobSync(pattern, options).found;
+ }
+
+ function GlobSync(pattern, options) {
+ if (!pattern) throw new Error('must provide pattern');
+
+ if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
+
+ if (!(this instanceof GlobSync)) return new GlobSync(pattern, options);
+
+ setopts(this, pattern, options);
+
+ if (this.noprocess) return this;
+
+ var n = this.minimatch.set.length;
+ this.matches = new Array(n);
+ for (var i = 0; i < n; i++) {
+ this._process(this.minimatch.set[i], i, false);
+ }
+ this._finish();
+ }
+
+ GlobSync.prototype._finish = function () {
+ assert(this instanceof GlobSync);
+ if (this.realpath) {
+ var self = this;
+ this.matches.forEach(function (matchset, index) {
+ var set = self.matches[index] = Object.create(null);
+ for (var p in matchset) {
+ try {
+ p = self._makeAbs(p);
+ var real = rp.realpathSync(p, self.realpathCache);
+ set[real] = true;
+ } catch (er) {
+ if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
+ }
+ }
+ });
+ }
+ common.finish(this);
+ };
+
+ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
+ assert(this instanceof GlobSync);
+
+ // Get the first [n] parts of pattern that are all strings.
+ var n = 0;
+ while (typeof pattern[n] === 'string') {
+ n++;
+ }
+ // now n is the index of the first one that is *not* a string.
+
+ // See if there's anything else
+ var prefix;
+ switch (n) {
+ // if not, then this is rather simple
+ case pattern.length:
+ this._processSimple(pattern.join('/'), index);
+ return;
+
+ case 0:
+ // pattern *starts* with some non-trivial item.
+ // going to readdir(cwd), but not include the prefix in matches.
+ prefix = null;
+ break;
+
+ default:
+ // pattern has some string bits in the front.
+ // whatever it starts with, whether that's 'absolute' like /foo/bar,
+ // or 'relative' like '../baz'
+ prefix = pattern.slice(0, n).join('/');
+ break;
+ }
+
+ var remain = pattern.slice(n);
+
+ // get the list of entries.
+ var read;
+ if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
+ if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
+ read = prefix;
+ } else read = prefix;
+
+ var abs = this._makeAbs(read);
+
+ //if ignored, skip processing
+ if (childrenIgnored(this, read)) return;
+
+ var isGlobStar = remain[0] === minimatch.GLOBSTAR;
+ if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
+ };
+
+ GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
+ var entries = this._readdir(abs, inGlobStar);
+
+ // if the abs isn't a dir, then nothing can match!
+ if (!entries) return;
+
+ // It will only match dot entries if it starts with a dot, or if
+ // dot is set. Stuff like @(.foo|.bar) isn't allowed.
+ var pn = remain[0];
+ var negate = !!this.minimatch.negate;
+ var rawGlob = pn._glob;
+ var dotOk = this.dot || rawGlob.charAt(0) === '.';
+
+ var matchedEntries = [];
+ for (var i = 0; i < entries.length; i++) {
+ var e = entries[i];
+ if (e.charAt(0) !== '.' || dotOk) {
+ var m;
+ if (negate && !prefix) {
+ m = !e.match(pn);
+ } else {
+ m = e.match(pn);
+ }
+ if (m) matchedEntries.push(e);
+ }
+ }
+
+ var len = matchedEntries.length;
+ // If there are no matched entries, then nothing matches.
+ if (len === 0) return;
+
+ // if this is the last remaining pattern bit, then no need for
+ // an additional stat *unless* the user has specified mark or
+ // stat explicitly. We know they exist, since readdir returned
+ // them.
+
+ if (remain.length === 1 && !this.mark && !this.stat) {
+ if (!this.matches[index]) this.matches[index] = Object.create(null);
+
+ for (var i = 0; i < len; i++) {
+ var e = matchedEntries[i];
+ if (prefix) {
+ if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
+ }
+
+ if (e.charAt(0) === '/' && !this.nomount) {
+ e = path.join(this.root, e);
+ }
+ this._emitMatch(index, e);
+ }
+ // This was the last one, and no stats were needed
+ return;
+ }
+
+ // now test all matched entries as stand-ins for that part
+ // of the pattern.
+ remain.shift();
+ for (var i = 0; i < len; i++) {
+ var e = matchedEntries[i];
+ var newPattern;
+ if (prefix) newPattern = [prefix, e];else newPattern = [e];
+ this._process(newPattern.concat(remain), index, inGlobStar);
+ }
+ };
+
+ GlobSync.prototype._emitMatch = function (index, e) {
+ if (isIgnored(this, e)) return;
+
+ var abs = this._makeAbs(e);
+
+ if (this.mark) e = this._mark(e);
+
+ if (this.absolute) {
+ e = abs;
+ }
+
+ if (this.matches[index][e]) return;
+
+ if (this.nodir) {
+ var c = this.cache[abs];
+ if (c === 'DIR' || Array.isArray(c)) return;
+ }
+
+ this.matches[index][e] = true;
+
+ if (this.stat) this._stat(e);
+ };
+
+ GlobSync.prototype._readdirInGlobStar = function (abs) {
+ // follow all symlinked directories forever
+ // just proceed as if this is a non-globstar situation
+ if (this.follow) return this._readdir(abs, false);
+
+ var entries;
+ var lstat;
+ var stat;
+ try {
+ lstat = this.fs.lstatSync(abs);
+ } catch (er) {
+ if (er.code === 'ENOENT') {
+ // lstat failed, doesn't exist
+ return null;
+ }
+ }
+
+ var isSym = lstat && lstat.isSymbolicLink();
+ this.symlinks[abs] = isSym;
+
+ // If it's not a symlink or a dir, then it's definitely a regular file.
+ // don't bother doing a readdir in that case.
+ if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
+
+ return entries;
+ };
+
+ GlobSync.prototype._readdir = function (abs, inGlobStar) {
+ var entries;
+
+ if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs);
+
+ if (ownProp(this.cache, abs)) {
+ var c = this.cache[abs];
+ if (!c || c === 'FILE') return null;
+
+ if (Array.isArray(c)) return c;
+ }
+
+ try {
+ return this._readdirEntries(abs, this.fs.readdirSync(abs));
+ } catch (er) {
+ this._readdirError(abs, er);
+ return null;
+ }
+ };
+
+ GlobSync.prototype._readdirEntries = function (abs, entries) {
+ // if we haven't asked to stat everything, then just
+ // assume that everything in there exists, so we can avoid
+ // having to stat it a second time.
+ if (!this.mark && !this.stat) {
+ for (var i = 0; i < entries.length; i++) {
+ var e = entries[i];
+ if (abs === '/') e = abs + e;else e = abs + '/' + e;
+ this.cache[e] = true;
+ }
+ }
+
+ this.cache[abs] = entries;
+
+ // mark and cache dir-ness
+ return entries;
+ };
+
+ GlobSync.prototype._readdirError = function (f, er) {
+ // handle errors, and cache the information
+ switch (er.code) {
+ case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
+ case 'ENOTDIR':
+ // totally normal. means it *does* exist.
+ var abs = this._makeAbs(f);
+ this.cache[abs] = 'FILE';
+ if (abs === this.cwdAbs) {
+ var error = new Error(er.code + ' invalid cwd ' + this.cwd);
+ error.path = this.cwd;
+ error.code = er.code;
+ throw error;
+ }
+ break;
+
+ case 'ENOENT': // not terribly unusual
+ case 'ELOOP':
+ case 'ENAMETOOLONG':
+ case 'UNKNOWN':
+ this.cache[this._makeAbs(f)] = false;
+ break;
+
+ default:
+ // some unusual error. Treat as failure.
+ this.cache[this._makeAbs(f)] = false;
+ if (this.strict) throw er;
+ if (!this.silent) console.error('glob error', er);
+ break;
+ }
+ };
+
+ GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
+
+ var entries = this._readdir(abs, inGlobStar);
+
+ // no entries means not a dir, so it can never have matches
+ // foo.txt/** doesn't match foo.txt
+ if (!entries) return;
+
+ // test without the globstar, and with every child both below
+ // and replacing the globstar.
+ var remainWithoutGlobStar = remain.slice(1);
+ var gspref = prefix ? [prefix] : [];
+ var noGlobStar = gspref.concat(remainWithoutGlobStar);
+
+ // the noGlobStar pattern exits the inGlobStar state
+ this._process(noGlobStar, index, false);
+
+ var len = entries.length;
+ var isSym = this.symlinks[abs];
+
+ // If it's a symlink, and we're in a globstar, then stop
+ if (isSym && inGlobStar) return;
+
+ for (var i = 0; i < len; i++) {
+ var e = entries[i];
+ if (e.charAt(0) === '.' && !this.dot) continue;
+
+ // these two cases enter the inGlobStar state
+ var instead = gspref.concat(entries[i], remainWithoutGlobStar);
+ this._process(instead, index, true);
+
+ var below = gspref.concat(entries[i], remain);
+ this._process(below, index, true);
+ }
+ };
+
+ GlobSync.prototype._processSimple = function (prefix, index) {
+ // XXX review this. Shouldn't it be doing the mounting etc
+ // before doing stat? kinda weird?
+ var exists = this._stat(prefix);
+
+ if (!this.matches[index]) this.matches[index] = Object.create(null);
+
+ // If it doesn't exist, then just mark the lack of results
+ if (!exists) return;
+
+ if (prefix && isAbsolute(prefix) && !this.nomount) {
+ var trail = /[\/\\]$/.test(prefix);
+ if (prefix.charAt(0) === '/') {
+ prefix = path.join(this.root, prefix);
+ } else {
+ prefix = path.resolve(this.root, prefix);
+ if (trail) prefix += '/';
+ }
+ }
+
+ if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/');
+
+ // Mark this as a match
+ this._emitMatch(index, prefix);
+ };
+
+ // Returns either 'DIR', 'FILE', or false
+ GlobSync.prototype._stat = function (f) {
+ var abs = this._makeAbs(f);
+ var needDir = f.slice(-1) === '/';
+
+ if (f.length > this.maxLength) return false;
+
+ if (!this.stat && ownProp(this.cache, abs)) {
+ var c = this.cache[abs];
+
+ if (Array.isArray(c)) c = 'DIR';
+
+ // It exists, but maybe not how we need it
+ if (!needDir || c === 'DIR') return c;
+
+ if (needDir && c === 'FILE') return false;
+
+ // otherwise we have to stat, because maybe c=true
+ // if we know it exists, but not what it is.
+ }
+
+ var exists;
+ var stat = this.statCache[abs];
+ if (!stat) {
+ var lstat;
+ try {
+ lstat = this.fs.lstatSync(abs);
+ } catch (er) {
+ if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
+ this.statCache[abs] = false;
+ return false;
+ }
+ }
+
+ if (lstat && lstat.isSymbolicLink()) {
+ try {
+ stat = this.fs.statSync(abs);
+ } catch (er) {
+ stat = lstat;
+ }
+ } else {
+ stat = lstat;
+ }
+ }
+
+ this.statCache[abs] = stat;
+
+ var c = true;
+ if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
+
+ this.cache[abs] = this.cache[abs] || c;
+
+ if (needDir && c === 'FILE') return false;
+
+ return c;
+ };
+
+ GlobSync.prototype._mark = function (p) {
+ return common.mark(this, p);
+ };
+
+ GlobSync.prototype._makeAbs = function (f) {
+ return common.makeAbs(this, f);
+ };
+ }).call(this)}).call(this,require('_process'))
+ },{"./common.js":17,"./glob.js":18,"_process":105,"assert":1,"fs.realpath":15,"minimatch":74,"path":102,"path-is-absolute":103,"util":126}],20:[function(require,module,exports){
+ (function (global){(function (){
+ var topLevel = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : {};
+ var minDoc = require('min-document');
+
+ var doccy;
+
+ if (typeof document !== 'undefined') {
+ doccy = document;
+ } else {
+ doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
+
+ if (!doccy) {
+ doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
+ }
+ }
+
+ module.exports = doccy;
+ }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{"min-document":8}],21:[function(require,module,exports){
+ (function (global){(function (){
+ var win;
+
+ if (typeof window !== "undefined") {
+ win = window;
+ } else if (typeof global !== "undefined") {
+ win = global;
+ } else if (typeof self !== "undefined") {
+ win = self;
+ } else {
+ win = {};
+ }
+
+ module.exports = win;
+ }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{}],22:[function(require,module,exports){
+ /*!
+ * http-errors
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2016 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+ 'use strict';
+
+ /**
+ * Module dependencies.
+ * @private
+ */
+
+ var deprecate = require('depd')('http-errors');
+ var setPrototypeOf = require('setprototypeof');
+ var statuses = require('statuses');
+ var inherits = require('inherits');
+
+ /**
+ * Module exports.
+ * @public
+ */
+
+ module.exports = createError;
+ module.exports.HttpError = createHttpErrorConstructor();
+
+ // Populate exports for all constructors
+ populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError);
+
+ /**
+ * Get the code class of a status code.
+ * @private
+ */
+
+ function codeClass(status) {
+ return Number(String(status).charAt(0) + '00');
+ }
+
+ /**
+ * Create a new HTTP Error.
+ *
+ * @returns {Error}
+ * @public
+ */
+
+ function createError() {
+ // so much arity going on ~_~
+ var err;
+ var msg;
+ var status = 500;
+ var props = {};
+ for (var i = 0; i < arguments.length; i++) {
+ var arg = arguments[i];
+ if (arg instanceof Error) {
+ err = arg;
+ status = err.status || err.statusCode || status;
+ continue;
+ }
+ switch (typeof arg) {
+ case 'string':
+ msg = arg;
+ break;
+ case 'number':
+ status = arg;
+ if (i !== 0) {
+ deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)');
+ }
+ break;
+ case 'object':
+ props = arg;
+ break;
+ }
+ }
+
+ if (typeof status === 'number' && (status < 400 || status >= 600)) {
+ deprecate('non-error status code; use only 4xx or 5xx status codes');
+ }
+
+ if (typeof status !== 'number' || !statuses[status] && (status < 400 || status >= 600)) {
+ status = 500;
+ }
+
+ // constructor
+ var HttpError = createError[status] || createError[codeClass(status)];
+
+ if (!err) {
+ // create error
+ err = HttpError ? new HttpError(msg) : new Error(msg || statuses[status]);
+ Error.captureStackTrace(err, createError);
+ }
+
+ if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
+ // add properties to generic error
+ err.expose = status < 500;
+ err.status = err.statusCode = status;
+ }
+
+ for (var key in props) {
+ if (key !== 'status' && key !== 'statusCode') {
+ err[key] = props[key];
+ }
+ }
+
+ return err;
+ }
+
+ /**
+ * Create HTTP error abstract base class.
+ * @private
+ */
+
+ function createHttpErrorConstructor() {
+ function HttpError() {
+ throw new TypeError('cannot construct abstract class');
+ }
+
+ inherits(HttpError, Error);
+
+ return HttpError;
+ }
+
+ /**
+ * Create a constructor for a client error.
+ * @private
+ */
+
+ function createClientErrorConstructor(HttpError, name, code) {
+ var className = name.match(/Error$/) ? name : name + 'Error';
+
+ function ClientError(message) {
+ // create the error object
+ var msg = message != null ? message : statuses[code];
+ var err = new Error(msg);
+
+ // capture a stack trace to the construction point
+ Error.captureStackTrace(err, ClientError);
+
+ // adjust the [[Prototype]]
+ setPrototypeOf(err, ClientError.prototype);
+
+ // redefine the error message
+ Object.defineProperty(err, 'message', {
+ enumerable: true,
+ configurable: true,
+ value: msg,
+ writable: true
+ });
+
+ // redefine the error name
+ Object.defineProperty(err, 'name', {
+ enumerable: false,
+ configurable: true,
+ value: className,
+ writable: true
+ });
+
+ return err;
+ }
+
+ inherits(ClientError, HttpError);
+
+ ClientError.prototype.status = code;
+ ClientError.prototype.statusCode = code;
+ ClientError.prototype.expose = true;
+
+ return ClientError;
+ }
+
+ /**
+ * Create a constructor for a server error.
+ * @private
+ */
+
+ function createServerErrorConstructor(HttpError, name, code) {
+ var className = name.match(/Error$/) ? name : name + 'Error';
+
+ function ServerError(message) {
+ // create the error object
+ var msg = message != null ? message : statuses[code];
+ var err = new Error(msg);
+
+ // capture a stack trace to the construction point
+ Error.captureStackTrace(err, ServerError);
+
+ // adjust the [[Prototype]]
+ setPrototypeOf(err, ServerError.prototype);
+
+ // redefine the error message
+ Object.defineProperty(err, 'message', {
+ enumerable: true,
+ configurable: true,
+ value: msg,
+ writable: true
+ });
+
+ // redefine the error name
+ Object.defineProperty(err, 'name', {
+ enumerable: false,
+ configurable: true,
+ value: className,
+ writable: true
+ });
+
+ return err;
+ }
+
+ inherits(ServerError, HttpError);
+
+ ServerError.prototype.status = code;
+ ServerError.prototype.statusCode = code;
+ ServerError.prototype.expose = false;
+
+ return ServerError;
+ }
+
+ /**
+ * Populate the exports object with constructors for every error class.
+ * @private
+ */
+
+ function populateConstructorExports(exports, codes, HttpError) {
+ codes.forEach(function forEachCode(code) {
+ var CodeError;
+ var name = toIdentifier(statuses[code]);
+
+ switch (codeClass(code)) {
+ case 400:
+ CodeError = createClientErrorConstructor(HttpError, name, code);
+ break;
+ case 500:
+ CodeError = createServerErrorConstructor(HttpError, name, code);
+ break;
+ }
+
+ if (CodeError) {
+ // export the constructor
+ exports[code] = CodeError;
+ exports[name] = CodeError;
+ }
+ });
+
+ // backwards-compatibility
+ exports["I'mateapot"] = deprecate.function(exports.ImATeapot, '"I\'mateapot"; use "ImATeapot" instead');
+ }
+
+ /**
+ * Convert a string of words to a JavaScript identifier.
+ * @private
+ */
+
+ function toIdentifier(str) {
+ return str.split(' ').map(function (token) {
+ return token.slice(0, 1).toUpperCase() + token.slice(1);
+ }).join('').replace(/[^ _0-9a-z]/gi, '');
+ }
+ },{"depd":12,"inherits":23,"setprototypeof":114,"statuses":121}],23:[function(require,module,exports){
+ arguments[4][2][0].apply(exports,arguments)
+ },{"dup":2}],24:[function(require,module,exports){
+ module.exports = attributeToProperty;
+
+ var transform = {
+ 'class': 'className',
+ 'for': 'htmlFor',
+ 'http-equiv': 'httpEquiv'
+ };
+
+ function attributeToProperty(h) {
+ return function (tagName, attrs, children) {
+ for (var attr in attrs) {
+ if (attr in transform) {
+ attrs[transform[attr]] = attrs[attr];
+ delete attrs[attr];
+ }
+ }
+ return h(tagName, attrs, children);
+ };
+ }
+ },{}],25:[function(require,module,exports){
+ var attrToProp = require('hyperscript-attribute-to-property');
+
+ var VAR = 0,
+ TEXT = 1,
+ OPEN = 2,
+ CLOSE = 3,
+ ATTR = 4;
+ var ATTR_KEY = 5,
+ ATTR_KEY_W = 6;
+ var ATTR_VALUE_W = 7,
+ ATTR_VALUE = 8;
+ var ATTR_VALUE_SQ = 9,
+ ATTR_VALUE_DQ = 10;
+ var ATTR_EQ = 11,
+ ATTR_BREAK = 12;
+ var COMMENT = 13;
+
+ module.exports = function (h, opts) {
+ if (!opts) opts = {};
+ var concat = opts.concat || function (a, b) {
+ return String(a) + String(b);
+ };
+ if (opts.attrToProp !== false) {
+ h = attrToProp(h);
+ }
+
+ return function (strings) {
+ var state = TEXT,
+ reg = '';
+ var arglen = arguments.length;
+ var parts = [];
+
+ for (var i = 0; i < strings.length; i++) {
+ if (i < arglen - 1) {
+ var arg = arguments[i + 1];
+ var p = parse(strings[i]);
+ var xstate = state;
+ if (xstate === ATTR_VALUE_DQ) xstate = ATTR_VALUE;
+ if (xstate === ATTR_VALUE_SQ) xstate = ATTR_VALUE;
+ if (xstate === ATTR_VALUE_W) xstate = ATTR_VALUE;
+ if (xstate === ATTR) xstate = ATTR_KEY;
+ if (xstate === OPEN) {
+ if (reg === '/') {
+ p.push([OPEN, '/', arg]);
+ reg = '';
+ } else {
+ p.push([OPEN, arg]);
+ }
+ } else if (xstate === COMMENT && opts.comments) {
+ reg += String(arg);
+ } else if (xstate !== COMMENT) {
+ p.push([VAR, xstate, arg]);
+ }
+ parts.push.apply(parts, p);
+ } else parts.push.apply(parts, parse(strings[i]));
+ }
+
+ var tree = [null, {}, []];
+ var stack = [[tree, -1]];
+ for (var i = 0; i < parts.length; i++) {
+ var cur = stack[stack.length - 1][0];
+ var p = parts[i],
+ s = p[0];
+ if (s === OPEN && /^\//.test(p[1])) {
+ var ix = stack[stack.length - 1][1];
+ if (stack.length > 1) {
+ stack.pop();
+ stack[stack.length - 1][0][2][ix] = h(cur[0], cur[1], cur[2].length ? cur[2] : undefined);
+ }
+ } else if (s === OPEN) {
+ var c = [p[1], {}, []];
+ cur[2].push(c);
+ stack.push([c, cur[2].length - 1]);
+ } else if (s === ATTR_KEY || s === VAR && p[1] === ATTR_KEY) {
+ var key = '';
+ var copyKey;
+ for (; i < parts.length; i++) {
+ if (parts[i][0] === ATTR_KEY) {
+ key = concat(key, parts[i][1]);
+ } else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) {
+ if (typeof parts[i][2] === 'object' && !key) {
+ for (copyKey in parts[i][2]) {
+ if (parts[i][2].hasOwnProperty(copyKey) && !cur[1][copyKey]) {
+ cur[1][copyKey] = parts[i][2][copyKey];
+ }
+ }
+ } else {
+ key = concat(key, parts[i][2]);
+ }
+ } else break;
+ }
+ if (parts[i][0] === ATTR_EQ) i++;
+ var j = i;
+ for (; i < parts.length; i++) {
+ if (parts[i][0] === ATTR_VALUE || parts[i][0] === ATTR_KEY) {
+ if (!cur[1][key]) cur[1][key] = strfn(parts[i][1]);else parts[i][1] === "" || (cur[1][key] = concat(cur[1][key], parts[i][1]));
+ } else if (parts[i][0] === VAR && (parts[i][1] === ATTR_VALUE || parts[i][1] === ATTR_KEY)) {
+ if (!cur[1][key]) cur[1][key] = strfn(parts[i][2]);else parts[i][2] === "" || (cur[1][key] = concat(cur[1][key], parts[i][2]));
+ } else {
+ if (key.length && !cur[1][key] && i === j && (parts[i][0] === CLOSE || parts[i][0] === ATTR_BREAK)) {
+ // https://html.spec.whatwg.org/multipage/infrastructure.html#boolean-attributes
+ // empty string is falsy, not well behaved value in browser
+ cur[1][key] = key.toLowerCase();
+ }
+ if (parts[i][0] === CLOSE) {
+ i--;
+ }
+ break;
+ }
+ }
+ } else if (s === ATTR_KEY) {
+ cur[1][p[1]] = true;
+ } else if (s === VAR && p[1] === ATTR_KEY) {
+ cur[1][p[2]] = true;
+ } else if (s === CLOSE) {
+ if (selfClosing(cur[0]) && stack.length) {
+ var ix = stack[stack.length - 1][1];
+ stack.pop();
+ stack[stack.length - 1][0][2][ix] = h(cur[0], cur[1], cur[2].length ? cur[2] : undefined);
+ }
+ } else if (s === VAR && p[1] === TEXT) {
+ if (p[2] === undefined || p[2] === null) p[2] = '';else if (!p[2]) p[2] = concat('', p[2]);
+ if (Array.isArray(p[2][0])) {
+ cur[2].push.apply(cur[2], p[2]);
+ } else {
+ cur[2].push(p[2]);
+ }
+ } else if (s === TEXT) {
+ cur[2].push(p[1]);
+ } else if (s === ATTR_EQ || s === ATTR_BREAK) {
+ // no-op
+ } else {
+ throw new Error('unhandled: ' + s);
+ }
+ }
+
+ if (tree[2].length > 1 && /^\s*$/.test(tree[2][0])) {
+ tree[2].shift();
+ }
+
+ if (tree[2].length > 2 || tree[2].length === 2 && /\S/.test(tree[2][1])) {
+ if (opts.createFragment) return opts.createFragment(tree[2]);
+ throw new Error('multiple root elements must be wrapped in an enclosing tag');
+ }
+ if (Array.isArray(tree[2][0]) && typeof tree[2][0][0] === 'string' && Array.isArray(tree[2][0][2])) {
+ tree[2][0] = h(tree[2][0][0], tree[2][0][1], tree[2][0][2]);
+ }
+ return tree[2][0];
+
+ function parse(str) {
+ var res = [];
+ if (state === ATTR_VALUE_W) state = ATTR;
+ for (var i = 0; i < str.length; i++) {
+ var c = str.charAt(i);
+ if (state === TEXT && c === '<') {
+ if (reg.length) res.push([TEXT, reg]);
+ reg = '';
+ state = OPEN;
+ } else if (c === '>' && !quot(state) && state !== COMMENT) {
+ if (state === OPEN && reg.length) {
+ res.push([OPEN, reg]);
+ } else if (state === ATTR_KEY) {
+ res.push([ATTR_KEY, reg]);
+ } else if (state === ATTR_VALUE && reg.length) {
+ res.push([ATTR_VALUE, reg]);
+ }
+ res.push([CLOSE]);
+ reg = '';
+ state = TEXT;
+ } else if (state === COMMENT && /-$/.test(reg) && c === '-') {
+ if (opts.comments) {
+ res.push([ATTR_VALUE, reg.substr(0, reg.length - 1)]);
+ }
+ reg = '';
+ state = TEXT;
+ } else if (state === OPEN && /^!--$/.test(reg)) {
+ if (opts.comments) {
+ res.push([OPEN, reg], [ATTR_KEY, 'comment'], [ATTR_EQ]);
+ }
+ reg = c;
+ state = COMMENT;
+ } else if (state === TEXT || state === COMMENT) {
+ reg += c;
+ } else if (state === OPEN && c === '/' && reg.length) {
+ // no-op, self closing tag without a space
+ } else if (state === OPEN && /\s/.test(c)) {
+ if (reg.length) {
+ res.push([OPEN, reg]);
+ }
+ reg = '';
+ state = ATTR;
+ } else if (state === OPEN) {
+ reg += c;
+ } else if (state === ATTR && /[^\s"'=/]/.test(c)) {
+ state = ATTR_KEY;
+ reg = c;
+ } else if (state === ATTR && /\s/.test(c)) {
+ if (reg.length) res.push([ATTR_KEY, reg]);
+ res.push([ATTR_BREAK]);
+ } else if (state === ATTR_KEY && /\s/.test(c)) {
+ res.push([ATTR_KEY, reg]);
+ reg = '';
+ state = ATTR_KEY_W;
+ } else if (state === ATTR_KEY && c === '=') {
+ res.push([ATTR_KEY, reg], [ATTR_EQ]);
+ reg = '';
+ state = ATTR_VALUE_W;
+ } else if (state === ATTR_KEY) {
+ reg += c;
+ } else if ((state === ATTR_KEY_W || state === ATTR) && c === '=') {
+ res.push([ATTR_EQ]);
+ state = ATTR_VALUE_W;
+ } else if ((state === ATTR_KEY_W || state === ATTR) && !/\s/.test(c)) {
+ res.push([ATTR_BREAK]);
+ if (/[\w-]/.test(c)) {
+ reg += c;
+ state = ATTR_KEY;
+ } else state = ATTR;
+ } else if (state === ATTR_VALUE_W && c === '"') {
+ state = ATTR_VALUE_DQ;
+ } else if (state === ATTR_VALUE_W && c === "'") {
+ state = ATTR_VALUE_SQ;
+ } else if (state === ATTR_VALUE_DQ && c === '"') {
+ res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
+ reg = '';
+ state = ATTR;
+ } else if (state === ATTR_VALUE_SQ && c === "'") {
+ res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
+ reg = '';
+ state = ATTR;
+ } else if (state === ATTR_VALUE_W && !/\s/.test(c)) {
+ state = ATTR_VALUE;
+ i--;
+ } else if (state === ATTR_VALUE && /\s/.test(c)) {
+ res.push([ATTR_VALUE, reg], [ATTR_BREAK]);
+ reg = '';
+ state = ATTR;
+ } else if (state === ATTR_VALUE || state === ATTR_VALUE_SQ || state === ATTR_VALUE_DQ) {
+ reg += c;
+ }
+ }
+ if (state === TEXT && reg.length) {
+ res.push([TEXT, reg]);
+ reg = '';
+ } else if (state === ATTR_VALUE && reg.length) {
+ res.push([ATTR_VALUE, reg]);
+ reg = '';
+ } else if (state === ATTR_VALUE_DQ && reg.length) {
+ res.push([ATTR_VALUE, reg]);
+ reg = '';
+ } else if (state === ATTR_VALUE_SQ && reg.length) {
+ res.push([ATTR_VALUE, reg]);
+ reg = '';
+ } else if (state === ATTR_KEY) {
+ res.push([ATTR_KEY, reg]);
+ reg = '';
+ }
+ return res;
+ }
+ };
+
+ function strfn(x) {
+ if (typeof x === 'function') return x;else if (typeof x === 'string') return x;else if (x && typeof x === 'object') return x;else if (x === null || x === undefined) return x;else return concat('', x);
+ }
+ };
+
+ function quot(state) {
+ return state === ATTR_VALUE_SQ || state === ATTR_VALUE_DQ;
+ }
+
+ var closeRE = RegExp('^(' + ['area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', '!--',
+ // SVG TAGS
+ 'animate', 'animateTransform', 'circle', 'cursor', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'font-face-format', 'font-face-name', 'font-face-uri', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'missing-glyph', 'mpath', 'path', 'polygon', 'polyline', 'rect', 'set', 'stop', 'tref', 'use', 'view', 'vkern'].join('|') + ')(?:[\.#][a-zA-Z0-9\u007F-\uFFFF_:-]+)*$');
+ function selfClosing(tag) {
+ return closeRE.test(tag);
+ }
+ },{"hyperscript-attribute-to-property":24}],26:[function(require,module,exports){
+ var xtend = require('xtend');
+ var fs = require('fs');
+ var lib = require('./lib');
+
+ module.exports = {
+ readFile: readFile,
+ readFileSync: readFileSync,
+ readFiles: readFiles,
+ readFilesSync: readFilesSync,
+ readPage: readPage,
+ readPageSync: readPageSync,
+ readSite: readSite,
+ readSiteSync: readSiteSync
+ };
+
+ function readFile(pathFile, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readFile(pathFile, opts, callback);
+ }
+
+ function readFileSync(pathFile, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readFileSync(pathFile, opts);
+ }
+
+ function readFiles(files, pathSite, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readFiles(files, pathSite, opts, callback);
+ }
+
+ function readFilesSync(pathFile, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readFilesSync(pathFile, opts);
+ }
+
+ function readPage(pathPage, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readPage(pathPage, opts, callback);
+ }
+
+ function readPageSync(pathPage, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readPageSync(pathPage, opts);
+ }
+
+ function readSite(pathSite, opts, callback) {
+ opts = xtend({ fs: fs }, opts);
+ return lib.readSite(pathSite, opts, callback);
+ }
+
+ function readSiteSync(pathSite, opts, callback) {
+ opts = xtend(opts, { fs: fs });
+ return lib.readSiteSync(pathSite, opts);
+ }
+ },{"./lib":28,"fs":9,"xtend":131}],27:[function(require,module,exports){
+ module.exports = {
+ reservedKeys: ['files', 'pages', 'url', 'name', 'path'],
+ ignore: /(^[.#]|(?:__|~)$)/,
+ encoding: 'utf8',
+ file: 'index.txt',
+ filetypes: {
+ asset: ['.css', '.js'],
+ archive: ['.zip'],
+ audio: ['.mp3', '.wav', '.aiff'],
+ document: ['.pdf'],
+ image: ['.gif', '.jpg', '.jpeg', '.png', '.svg'],
+ video: ['.mp4', '.mov'],
+ font: ['.ttf', '.otf', '.woff', '.woff2']
+ }
+ };
+ },{}],28:[function(require,module,exports){
+ module.exports = {
+ readPage: require('./readPage'),
+ readPageSync: require('./readPageSync'),
+ readFile: require('./readFile'),
+ readFiles: require('./readFiles'),
+ readSite: require('./readSite'),
+ readSiteSync: require('./readSiteSync')
+ };
+ },{"./readFile":29,"./readFiles":31,"./readPage":33,"./readPageSync":34,"./readSite":35,"./readSiteSync":36}],29:[function(require,module,exports){
+ var assert = require('assert');
+
+ var utilFile = require('../utils/file');
+ var readPage = require('./readPage');
+
+ module.exports = readFile;
+
+ async function readFile(pathFile, opts) {
+ assert.equal(typeof pathFile, 'string', 'arg1: pathFile must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ if (!utilFile.isFile(pathFile)) {
+ return readPage(pathFile, opts);
+ } else {
+ return false;
+ }
+ }
+ },{"../utils/file":38,"./readPage":33,"assert":1}],30:[function(require,module,exports){
+ var assert = require('assert');
+
+ var readPageSync = require('./readPageSync');
+ var utilFile = require('../utils/file');
+
+ module.exports = readFileSync;
+
+ function readFileSync(pathFile, opts) {
+ assert.equal(typeof pathFile, 'string', 'arg1: pathFile must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ if (!utilFile.isFile(pathFile)) {
+ return readPageSync(pathFile, opts);
+ } else {
+ return false;
+ }
+ }
+ },{"../utils/file":38,"./readPageSync":34,"assert":1}],31:[function(require,module,exports){
+ var assert = require('assert');
+
+ var defaults = require('./defaults');
+ var readFile = require('./readFile');
+
+ module.exports = readFiles;
+
+ async function readFiles(files, pathSite, opts) {
+ assert.equal(typeof files, 'object', 'arg1: files must be type object');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ var output = {};
+
+ // read the index
+ if (files.indexOf(pathSite) < 0) {
+ files.push(pathSite);
+ }
+
+ await Promise.all(files.map(read));
+ return output;
+
+ async function read(pathFile) {
+ var content = await readFile(pathFile, opts);
+ if (content && !content.name.match(defaults.ignore)) {
+ output[content.url] = content;
+ }
+ return content;
+ }
+ }
+ },{"./defaults":27,"./readFile":29,"assert":1}],32:[function(require,module,exports){
+ var assert = require('assert');
+
+ var readFileSync = require('./readFileSync');
+ var defaults = require('./defaults');
+
+ module.exports = readFilesSync;
+
+ function readFilesSync(files, pathSite, opts) {
+ assert.equal(typeof files, 'object', 'arg1: files must be type object');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ var output = {};
+
+ // read the index
+ if (files.indexOf(pathSite) < 0) {
+ files.push(pathSite);
+ }
+
+ files.forEach(function (pathFile) {
+ if (typeof opts.onFile === 'function') opts.onFile(pathFile);
+ var content = readFileSync(pathFile, opts);
+ if (content && !content.name.match(defaults.ignore)) {
+ output[content.url] = content;
+ }
+ });
+
+ return output;
+ }
+ },{"./defaults":27,"./readFileSync":30,"assert":1}],33:[function(require,module,exports){
+ var slash = require('normalize-path');
+ var assert = require('assert');
+ var smarkt = require('smarkt');
+ var xtend = require('xtend');
+ var path = require('path');
+ var pify = require('pify');
+
+ var utilFile = require('../utils/file');
+ var defaults = require('./defaults');
+
+ module.exports = readPage;
+
+ async function readPage(pathPage, opts) {
+ assert.equal(typeof pathPage, 'string', 'arg1: pathPage must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ var fs = opts.fs.url ? opts.fs : pify(opts.fs); // web api or node
+ var parse = typeof opts.parse === 'function' ? opts.parse : smarkt.parse;
+ var fileIndex = opts.file || defaults.file;
+ var fileExtname = path.extname(fileIndex);
+ var filetypes = opts.filetypes || defaults.filetypes;
+ var pathRoot = opts.pathRoot || '';
+ var pathUrl = utilFile.formatUrl(pathPage, pathRoot, opts.parent);
+ var encoding = opts.encoding || defaults.encoding;
+ var content = await getContent();
+ var childrenInput = await getChildren();
+ var children = childrenInput.filter(function (file) {
+ return utilFile.filterFile(file, fileIndex);
+ }).reduce(utilFile.sortChildren, { files: [], pages: [] });
+ var files = await getFiles(children.files);
+ var pages = getPages(children.pages);
+
+ return xtend(content, {
+ name: path.basename(pathPage),
+ path: utilFile.formatUrl(pathPage, pathRoot),
+ url: pathUrl,
+ files: files,
+ pages: pages
+ });
+
+ async function getChildren() {
+ try {
+ return await fs.readdir(pathPage);
+ } catch (err) {
+ return [];
+ }
+ }
+
+ async function getContent() {
+ try {
+ var content;
+ content = await fs.readFile(slash(path.join(pathPage, fileIndex)), encoding);
+ content = parse(content);
+ return content;
+ } catch (err) {
+ return '';
+ }
+ }
+
+ async function getFiles(files) {
+ var result = {};
+ await Promise.all(files.map(read));
+ return result;
+
+ async function read(pathFile) {
+ var fileParsed = utilFile.getFileMeta({
+ pathFile: pathFile,
+ pathRoot: pathRoot,
+ filetypes: filetypes,
+ pathParent: pathPage,
+ pathSource: opts.source,
+ pathSiteParent: opts.parent
+ });
+
+ try {
+ var fileMeta = pathFile + fileExtname;
+ var pathMeta = path.join(pathPage, fileMeta);
+ var text = await fs.readFile(pathMeta, encoding);
+ // set
+ result[fileParsed.filename] = xtend(parse(text), fileParsed);
+ files.splice(files.indexOf(fileMeta), 1);
+ // cleanup
+ delete result[fileMeta];
+ return text;
+ } catch (err) {
+ if (fileParsed.filename) {
+ result[fileParsed.filename] = fileParsed;
+ }
+ return Promise.resolve();
+ }
+ }
+ }
+
+ function getPages(pages) {
+ return pages.reduce(function (result, pathSubpage) {
+ var fileParsed = utilFile.getFileMeta({
+ pathRoot: pathRoot,
+ pathFile: pathSubpage,
+ filetypes: filetypes,
+ pathParent: pathPage,
+ pathSiteParent: opts.parent
+ });
+
+ if (fileParsed.name) result[fileParsed.name] = fileParsed;
+ return result;
+ }, {});
+ }
+ }
+ },{"../utils/file":38,"./defaults":27,"assert":1,"normalize-path":37,"path":102,"pify":104,"smarkt":116,"xtend":131}],34:[function(require,module,exports){
+ var slash = require('normalize-path');
+ var assert = require('assert');
+ var smarkt = require('smarkt');
+ var xtend = require('xtend');
+ var path = require('path');
+
+ var utilFile = require('../utils/file');
+ var defaults = require('./defaults');
+
+ module.exports = readPageSync;
+
+ function readPageSync(pathPage, opts) {
+ assert.equal(typeof pathPage, 'string', 'arg1: pathPage must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ var fs = opts.fs;
+ var parse = typeof opts.parse === 'function' ? opts.parse : smarkt.parse;
+ var fileIndex = opts.file || defaults.file;
+ var fileExtname = path.extname(fileIndex);
+ var filetypes = opts.filetypes || defaults.filetypes;
+ var pathRoot = opts.pathRoot || '';
+ var pathUrl = utilFile.formatUrl(pathPage, pathRoot, opts.parent);
+ var encoding = opts.encoding || defaults.encoding;
+ var content = getContent();
+ var children = getChildren().filter(function (file) {
+ return utilFile.filterFile(file, fileIndex);
+ }).reduce(utilFile.sortChildren, { files: [], pages: [] });
+ var files = getFiles(children.files);
+ var pages = getPages(children.pages);
+
+ return xtend(content, {
+ name: path.basename(pathPage),
+ path: utilFile.formatUrl(pathPage, pathRoot),
+ url: pathUrl,
+ files: files,
+ pages: pages
+ });
+
+ function getChildren() {
+ try {
+ return fs.readdirSync(pathPage);
+ } catch (err) {
+ return [];
+ }
+ }
+
+ function getContent() {
+ try {
+ var content;
+ content = fs.readFileSync(slash(path.join(pathPage, fileIndex)), encoding);
+ content = parse(content);
+ return content;
+ } catch (err) {
+ return '';
+ }
+ }
+
+ function getFiles(files) {
+ return files.reduce(function (result, pathFile) {
+ var fileParsed = utilFile.getFileMeta({
+ pathFile: pathFile,
+ pathRoot: pathRoot,
+ filetypes: filetypes,
+ pathParent: pathPage,
+ pathSiteParent: opts.parent
+ });
+
+ try {
+ var fileMeta = pathFile + fileExtname;
+ var text = fs.readFileSync(slash(path.join(pathPage, fileMeta)), encoding);
+ // set
+ result[fileParsed.filename] = xtend(parse(text), fileParsed);
+ files.splice(files.indexOf(fileMeta), 1);
+ // cleanup
+ delete result[fileMeta];
+ } catch (err) {
+ if (fileParsed.filename) {
+ result[fileParsed.filename] = fileParsed;
+ }
+ }
+
+ return result;
+ }, {});
+ }
+
+ function getPages(pages) {
+ return pages.reduce(function (result, pathSubpage) {
+ var fileParsed = utilFile.getFileMeta({
+ pathRoot: pathRoot,
+ pathFile: pathSubpage,
+ filetypes: filetypes,
+ pathParent: pathPage,
+ pathSource: opts.source,
+ pathSiteParent: opts.parent
+ });
+
+ if (fileParsed.name) result[fileParsed.name] = fileParsed;
+ return result;
+ }, {});
+ }
+ }
+ },{"../utils/file":38,"./defaults":27,"assert":1,"normalize-path":37,"path":102,"smarkt":116,"xtend":131}],35:[function(require,module,exports){
+ var slash = require('normalize-path');
+ var assert = require('assert');
+ var path = require('path');
+ var pify = require('pify');
+ var glob = pify(require('glob'));
+
+ var readFiles = require('./readFiles');
+
+ module.exports = readSite;
+
+ async function readSite(pathSite, opts) {
+ assert.equal(typeof pathSite, 'string', 'arg1: pathSite must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ // parent
+ if (opts.parent === true) opts.parent = pathSite;
+
+ // loop through the files
+ var files = await glob(slash(path.join(pathSite, '/**/*')));
+ return readFiles(files, pathSite, opts);
+ }
+ },{"./readFiles":31,"assert":1,"glob":18,"normalize-path":37,"path":102,"pify":104}],36:[function(require,module,exports){
+ var slash = require('normalize-path');
+ var assert = require('assert');
+ var path = require('path');
+ var glob = require('glob');
+
+ var readFilesSync = require('./readFilesSync');
+
+ module.exports = readSiteSync;
+
+ function readSiteSync(pathSite, opts) {
+ assert.equal(typeof pathSite, 'string', 'arg1: pathSite must be type string');
+ assert.equal(typeof opts, 'object', 'arg2: opts must be type object');
+ assert.equal(typeof opts.fs, 'object', 'arg2: opts.fs must be type object');
+
+ // parent
+ if (opts.parent === true) opts.parent = pathSite;
+
+ // loop through the files
+ var files = glob.sync(slash(path.join(pathSite, '/**/*')));
+ return readFilesSync(files, pathSite, opts);
+ }
+ },{"./readFilesSync":32,"assert":1,"glob":18,"normalize-path":37,"path":102}],37:[function(require,module,exports){
+ /*!
+ * normalize-path
+ *
+ * Copyright (c) 2014-2017, Jon Schlinkert.
+ * Released under the MIT License.
+ */
+
+ var removeTrailingSeparator = require('remove-trailing-separator');
+
+ module.exports = function normalizePath(str, stripTrailing) {
+ if (typeof str !== 'string') {
+ throw new TypeError('expected a string');
+ }
+ str = str.replace(/[\\\/]+/g, '/');
+ if (stripTrailing !== false) {
+ str = removeTrailingSeparator(str);
+ }
+ return str;
+ };
+ },{"remove-trailing-separator":111}],38:[function(require,module,exports){
+ var objectKeys = require('object-keys');
+ var assert = require('assert');
+ var slash = require('normalize-path');
+ var path = require('path');
+
+ module.exports = {
+ formatUrl: formatUrl,
+ filterFile: filterFile,
+ getFileType: getFileType,
+ getFileMeta: getFileMeta,
+ sortChildren: sortChildren,
+ isFile: isFile
+ };
+
+ function sortChildren(result, active) {
+ var ext = path.extname(active);
+ result = result || {};
+ result.files = result.files || [];
+ result.pages = result.pages || [];
+
+ if (ext) result.files.push(active);else result.pages.push(active);
+
+ return result;
+ }
+
+ function filterFile(file, index) {
+ if (file === '.DS_Store') return false;
+ if (/(^[.#]|(?:__|~)$)/.test(file)) return false;
+ if (file.indexOf(index) >= 0) return false;
+ if (file.indexOf('src') >= 0) return false;
+ return true;
+ }
+
+ function getFileType(extension, filetypes) {
+ return objectKeys(filetypes).reduce(function (result, value, i, source) {
+ if (result) return result;
+
+ if (filetypes[value] && filetypes[value].indexOf(extension) >= 0) {
+ return value;
+ }
+
+ if (i >= source.length) return 'unknown';
+ }, '');
+ }
+
+ function isFile(pathFile) {
+ assert.equal(typeof pathFile, 'string', 'enoki: arg1 pathFile must be type string');
+ return path.extname(pathFile) !== '';
+ }
+
+ function getFileMeta(opts) {
+ assert.equal(typeof opts, 'object', 'enoki: arg1 opts must be type object');
+ assert.equal(typeof opts.pathFile, 'string', 'enoki: arg1 opts.pathFile must be type string');
+ assert.equal(typeof opts.pathParent, 'string', 'enoki: arg1 opts.pathParent must be type string');
+ assert.equal(typeof opts.pathRoot, 'string', 'enoki: arg1 opts.pathRoot must be type string');
+ assert.equal(typeof opts.filetypes, 'object', 'enoki: arg1 opts.filetypes must be type string');
+
+ var output = {};
+ var ext = path.extname(opts.pathFile);
+ output.name = path.basename(opts.pathFile, ext);
+ output.path = formatUrl(path.join('/', opts.pathParent, '/', opts.pathFile), opts.pathRoot);
+ output.url = formatUrl(path.join('/', opts.pathParent, '/', opts.pathFile), opts.pathRoot, opts.pathSiteParent);
+ output.source = opts.pathSource ? opts.pathSource + output.path : output.path;
+
+ if (ext) {
+ output.extension = ext.toLowerCase();
+ output.filename = path.basename(opts.pathFile);
+ output.type = getFileType(output.extension, opts.filetypes);
+ }
+
+ return output;
+ }
+
+ function formatUrl(pathFile, pathRoot, pathSiteParent) {
+ pathFile = pathFile.replace(pathRoot, '');
+ if (pathSiteParent) pathFile = pathFile.replace(pathSiteParent, '');
+ pathFile = slash(path.join('/', pathFile));
+ return pathFile || '/';
+ }
+ },{"assert":1,"normalize-path":37,"object-keys":95,"path":102}],39:[function(require,module,exports){
+ (function (process){(function (){
+ var wrappy = require('wrappy');
+ var reqs = Object.create(null);
+ var once = require('once');
+
+ module.exports = wrappy(inflight);
+
+ function inflight(key, cb) {
+ if (reqs[key]) {
+ reqs[key].push(cb);
+ return null;
+ } else {
+ reqs[key] = [cb];
+ return makeres(key);
+ }
+ }
+
+ function makeres(key) {
+ return once(function RES() {
+ var cbs = reqs[key];
+ var len = cbs.length;
+ var args = slice(arguments);
+
+ // XXX It's somewhat ambiguous whether a new callback added in this
+ // pass should be queued for later execution if something in the
+ // list of callbacks throws, or if it should just be discarded.
+ // However, it's such an edge case that it hardly matters, and either
+ // choice is likely as surprising as the other.
+ // As it happens, we do go ahead and schedule it for later execution.
+ try {
+ for (var i = 0; i < len; i++) {
+ cbs[i].apply(null, args);
+ }
+ } finally {
+ if (cbs.length > len) {
+ // added more in the interim.
+ // de-zalgo, just in case, but don't call again.
+ cbs.splice(0, len);
+ process.nextTick(function () {
+ RES.apply(null, args);
+ });
+ } else {
+ delete reqs[key];
+ }
+ }
+ });
+ }
+
+ function slice(args) {
+ var length = args.length;
+ var array = [];
+
+ for (var i = 0; i < length; i++) {
+ array[i] = args[i];
+ }return array;
+ }
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105,"once":99,"wrappy":129}],40:[function(require,module,exports){
+ if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ module.exports = function inherits(ctor, superCtor) {
+ if (superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ }
+ };
+ } else {
+ // old school shim for old browsers
+ module.exports = function inherits(ctor, superCtor) {
+ if (superCtor) {
+ ctor.super_ = superCtor;
+ var TempCtor = function () {};
+ TempCtor.prototype = superCtor.prototype;
+ ctor.prototype = new TempCtor();
+ ctor.prototype.constructor = ctor;
+ }
+ };
+ }
+ },{}],41:[function(require,module,exports){
+ var containers = []; // will store container HTMLElement references
+ var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}
+
+ var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';
+
+ function insertCss(css, options) {
+ options = options || {};
+
+ if (css === undefined) {
+ throw new Error(usage);
+ }
+
+ var position = options.prepend === true ? 'prepend' : 'append';
+ var container = options.container !== undefined ? options.container : document.querySelector('head');
+ var containerId = containers.indexOf(container);
+
+ // first time we see this container, create the necessary entries
+ if (containerId === -1) {
+ containerId = containers.push(container) - 1;
+ styleElements[containerId] = {};
+ }
+
+ // try to get the correponding container + position styleElement, create it otherwise
+ var styleElement;
+
+ if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {
+ styleElement = styleElements[containerId][position];
+ } else {
+ styleElement = styleElements[containerId][position] = createStyleElement();
+
+ if (position === 'prepend') {
+ container.insertBefore(styleElement, container.childNodes[0]);
+ } else {
+ container.appendChild(styleElement);
+ }
+ }
+
+ // strip potential UTF-8 BOM if css was read from a file
+ if (css.charCodeAt(0) === 0xFEFF) {
+ css = css.substr(1, css.length);
+ }
+
+ // actually add the stylesheet
+ if (styleElement.styleSheet) {
+ styleElement.styleSheet.cssText += css;
+ } else {
+ styleElement.textContent += css;
+ }
+
+ return styleElement;
+ };
+
+ function createStyleElement() {
+ var styleElement = document.createElement('style');
+ styleElement.setAttribute('type', 'text/css');
+ return styleElement;
+ }
+
+ module.exports = insertCss;
+ module.exports.insertCss = insertCss;
+ },{}],42:[function(require,module,exports){
+ module.exports = isFunction;
+
+ var toString = Object.prototype.toString;
+
+ function isFunction(fn) {
+ if (!fn) {
+ return false;
+ }
+ var string = toString.call(fn);
+ return string === '[object Function]' || typeof fn === 'function' && string !== '[object RegExp]' || typeof window !== 'undefined' && (
+ // IE8 and below
+ fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt);
+ };
+ },{}],43:[function(require,module,exports){
+ 'use strict';
+
+ var yaml = require('./lib/js-yaml.js');
+
+ module.exports = yaml;
+ },{"./lib/js-yaml.js":44}],44:[function(require,module,exports){
+ 'use strict';
+
+ var loader = require('./js-yaml/loader');
+ var dumper = require('./js-yaml/dumper');
+
+ function deprecated(name) {
+ return function () {
+ throw new Error('Function ' + name + ' is deprecated and cannot be used.');
+ };
+ }
+
+ module.exports.Type = require('./js-yaml/type');
+ module.exports.Schema = require('./js-yaml/schema');
+ module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
+ module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
+ module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
+ module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
+ module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
+ module.exports.load = loader.load;
+ module.exports.loadAll = loader.loadAll;
+ module.exports.safeLoad = loader.safeLoad;
+ module.exports.safeLoadAll = loader.safeLoadAll;
+ module.exports.dump = dumper.dump;
+ module.exports.safeDump = dumper.safeDump;
+ module.exports.YAMLException = require('./js-yaml/exception');
+
+ // Deprecated schema names from JS-YAML 2.0.x
+ module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
+ module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
+ module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
+
+ // Deprecated functions from JS-YAML 1.x.x
+ module.exports.scan = deprecated('scan');
+ module.exports.parse = deprecated('parse');
+ module.exports.compose = deprecated('compose');
+ module.exports.addConstructor = deprecated('addConstructor');
+ },{"./js-yaml/dumper":46,"./js-yaml/exception":47,"./js-yaml/loader":48,"./js-yaml/schema":50,"./js-yaml/schema/core":51,"./js-yaml/schema/default_full":52,"./js-yaml/schema/default_safe":53,"./js-yaml/schema/failsafe":54,"./js-yaml/schema/json":55,"./js-yaml/type":56}],45:[function(require,module,exports){
+ 'use strict';
+
+ function isNothing(subject) {
+ return typeof subject === 'undefined' || subject === null;
+ }
+
+ function isObject(subject) {
+ return typeof subject === 'object' && subject !== null;
+ }
+
+ function toArray(sequence) {
+ if (Array.isArray(sequence)) return sequence;else if (isNothing(sequence)) return [];
+
+ return [sequence];
+ }
+
+ function extend(target, source) {
+ var index, length, key, sourceKeys;
+
+ if (source) {
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
+ key = sourceKeys[index];
+ target[key] = source[key];
+ }
+ }
+
+ return target;
+ }
+
+ function repeat(string, count) {
+ var result = '',
+ cycle;
+
+ for (cycle = 0; cycle < count; cycle += 1) {
+ result += string;
+ }
+
+ return result;
+ }
+
+ function isNegativeZero(number) {
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
+ }
+
+ module.exports.isNothing = isNothing;
+ module.exports.isObject = isObject;
+ module.exports.toArray = toArray;
+ module.exports.repeat = repeat;
+ module.exports.isNegativeZero = isNegativeZero;
+ module.exports.extend = extend;
+ },{}],46:[function(require,module,exports){
+ 'use strict';
+
+ /*eslint-disable no-use-before-define*/
+
+ var common = require('./common');
+ var YAMLException = require('./exception');
+ var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
+ var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
+
+ var _toString = Object.prototype.toString;
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ var CHAR_TAB = 0x09; /* Tab */
+ var CHAR_LINE_FEED = 0x0A; /* LF */
+ var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
+ var CHAR_SPACE = 0x20; /* Space */
+ var CHAR_EXCLAMATION = 0x21; /* ! */
+ var CHAR_DOUBLE_QUOTE = 0x22; /* " */
+ var CHAR_SHARP = 0x23; /* # */
+ var CHAR_PERCENT = 0x25; /* % */
+ var CHAR_AMPERSAND = 0x26; /* & */
+ var CHAR_SINGLE_QUOTE = 0x27; /* ' */
+ var CHAR_ASTERISK = 0x2A; /* * */
+ var CHAR_COMMA = 0x2C; /* , */
+ var CHAR_MINUS = 0x2D; /* - */
+ var CHAR_COLON = 0x3A; /* : */
+ var CHAR_EQUALS = 0x3D; /* = */
+ var CHAR_GREATER_THAN = 0x3E; /* > */
+ var CHAR_QUESTION = 0x3F; /* ? */
+ var CHAR_COMMERCIAL_AT = 0x40; /* @ */
+ var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
+ var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
+ var CHAR_GRAVE_ACCENT = 0x60; /* ` */
+ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
+ var CHAR_VERTICAL_LINE = 0x7C; /* | */
+ var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
+
+ var ESCAPE_SEQUENCES = {};
+
+ ESCAPE_SEQUENCES[0x00] = '\\0';
+ ESCAPE_SEQUENCES[0x07] = '\\a';
+ ESCAPE_SEQUENCES[0x08] = '\\b';
+ ESCAPE_SEQUENCES[0x09] = '\\t';
+ ESCAPE_SEQUENCES[0x0A] = '\\n';
+ ESCAPE_SEQUENCES[0x0B] = '\\v';
+ ESCAPE_SEQUENCES[0x0C] = '\\f';
+ ESCAPE_SEQUENCES[0x0D] = '\\r';
+ ESCAPE_SEQUENCES[0x1B] = '\\e';
+ ESCAPE_SEQUENCES[0x22] = '\\"';
+ ESCAPE_SEQUENCES[0x5C] = '\\\\';
+ ESCAPE_SEQUENCES[0x85] = '\\N';
+ ESCAPE_SEQUENCES[0xA0] = '\\_';
+ ESCAPE_SEQUENCES[0x2028] = '\\L';
+ ESCAPE_SEQUENCES[0x2029] = '\\P';
+
+ var DEPRECATED_BOOLEANS_SYNTAX = ['y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'];
+
+ function compileStyleMap(schema, map) {
+ var result, keys, index, length, tag, style, type;
+
+ if (map === null) return {};
+
+ result = {};
+ keys = Object.keys(map);
+
+ for (index = 0, length = keys.length; index < length; index += 1) {
+ tag = keys[index];
+ style = String(map[tag]);
+
+ if (tag.slice(0, 2) === '!!') {
+ tag = 'tag:yaml.org,2002:' + tag.slice(2);
+ }
+ type = schema.compiledTypeMap['fallback'][tag];
+
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
+ style = type.styleAliases[style];
+ }
+
+ result[tag] = style;
+ }
+
+ return result;
+ }
+
+ function encodeHex(character) {
+ var string, handle, length;
+
+ string = character.toString(16).toUpperCase();
+
+ if (character <= 0xFF) {
+ handle = 'x';
+ length = 2;
+ } else if (character <= 0xFFFF) {
+ handle = 'u';
+ length = 4;
+ } else if (character <= 0xFFFFFFFF) {
+ handle = 'U';
+ length = 8;
+ } else {
+ throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
+ }
+
+ return '\\' + handle + common.repeat('0', length - string.length) + string;
+ }
+
+ function State(options) {
+ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
+ this.indent = Math.max(1, options['indent'] || 2);
+ this.noArrayIndent = options['noArrayIndent'] || false;
+ this.skipInvalid = options['skipInvalid'] || false;
+ this.flowLevel = common.isNothing(options['flowLevel']) ? -1 : options['flowLevel'];
+ this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
+ this.sortKeys = options['sortKeys'] || false;
+ this.lineWidth = options['lineWidth'] || 80;
+ this.noRefs = options['noRefs'] || false;
+ this.noCompatMode = options['noCompatMode'] || false;
+ this.condenseFlow = options['condenseFlow'] || false;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.explicitTypes = this.schema.compiledExplicit;
+
+ this.tag = null;
+ this.result = '';
+
+ this.duplicates = [];
+ this.usedDuplicates = null;
+ }
+
+ // Indents every line in a string. Empty lines (\n only) are not indented.
+ function indentString(string, spaces) {
+ var ind = common.repeat(' ', spaces),
+ position = 0,
+ next = -1,
+ result = '',
+ line,
+ length = string.length;
+
+ while (position < length) {
+ next = string.indexOf('\n', position);
+ if (next === -1) {
+ line = string.slice(position);
+ position = length;
+ } else {
+ line = string.slice(position, next + 1);
+ position = next + 1;
+ }
+
+ if (line.length && line !== '\n') result += ind;
+
+ result += line;
+ }
+
+ return result;
+ }
+
+ function generateNextLine(state, level) {
+ return '\n' + common.repeat(' ', state.indent * level);
+ }
+
+ function testImplicitResolving(state, str) {
+ var index, length, type;
+
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
+ type = state.implicitTypes[index];
+
+ if (type.resolve(str)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // [33] s-white ::= s-space | s-tab
+ function isWhitespace(c) {
+ return c === CHAR_SPACE || c === CHAR_TAB;
+ }
+
+ // Returns true if the character can be printed without escaping.
+ // From YAML 1.2: "any allowed characters known to be non-printable
+ // should also be escaped. [However,] This isn’t mandatory"
+ // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
+ function isPrintable(c) {
+ return 0x00020 <= c && c <= 0x00007E || 0x000A1 <= c && c <= 0x00D7FF && c !== 0x2028 && c !== 0x2029 || 0x0E000 <= c && c <= 0x00FFFD && c !== 0xFEFF /* BOM */ || 0x10000 <= c && c <= 0x10FFFF;
+ }
+
+ // [34] ns-char ::= nb-char - s-white
+ // [27] nb-char ::= c-printable - b-char - c-byte-order-mark
+ // [26] b-char ::= b-line-feed | b-carriage-return
+ // [24] b-line-feed ::= #xA /* LF */
+ // [25] b-carriage-return ::= #xD /* CR */
+ // [3] c-byte-order-mark ::= #xFEFF
+ function isNsChar(c) {
+ return isPrintable(c) && !isWhitespace(c)
+ // byte-order-mark
+ && c !== 0xFEFF
+ // b-char
+ && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
+ }
+
+ // Simplified test for values allowed after the first character in plain style.
+ function isPlainSafe(c, prev) {
+ // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
+ // where nb-char ::= c-printable - b-char - c-byte-order-mark.
+ return isPrintable(c) && c !== 0xFEFF
+ // - c-flow-indicator
+ && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET
+ // - ":" - "#"
+ // /* An ns-char preceding */ "#"
+ && c !== CHAR_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
+ }
+
+ // Simplified test for values allowed as the first character in plain style.
+ function isPlainSafeFirst(c) {
+ // Uses a subset of ns-char - c-indicator
+ // where ns-char = nb-char - s-white.
+ return isPrintable(c) && c !== 0xFEFF && !isWhitespace(c) // - s-white
+ // - (c-indicator ::=
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
+ && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET
+ // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
+ && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE
+ // | “%” | “@” | “`”)
+ && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
+ }
+
+ // Determines whether block indentation indicator is required.
+ function needIndentIndicator(string) {
+ var leadingSpaceRe = /^\n* /;
+ return leadingSpaceRe.test(string);
+ }
+
+ var STYLE_PLAIN = 1,
+ STYLE_SINGLE = 2,
+ STYLE_LITERAL = 3,
+ STYLE_FOLDED = 4,
+ STYLE_DOUBLE = 5;
+
+ // Determines which scalar styles are possible and returns the preferred style.
+ // lineWidth = -1 => no limit.
+ // Pre-conditions: str.length > 0.
+ // Post-conditions:
+ // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
+ // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
+ // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
+ var i;
+ var char, prev_char;
+ var hasLineBreak = false;
+ var hasFoldableLine = false; // only checked if shouldTrackWidth
+ var shouldTrackWidth = lineWidth !== -1;
+ var previousLineBreak = -1; // count the first line correctly
+ var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
+
+ if (singleLineOnly) {
+ // Case: no block styles.
+ // Check for disallowed characters to rule out plain and single.
+ for (i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
+ plain = plain && isPlainSafe(char, prev_char);
+ }
+ } else {
+ // Case: block styles permitted.
+ for (i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ if (char === CHAR_LINE_FEED) {
+ hasLineBreak = true;
+ // Check if any line can be folded.
+ if (shouldTrackWidth) {
+ hasFoldableLine = hasFoldableLine ||
+ // Foldable line = too long, and not more-indented.
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
+ previousLineBreak = i;
+ }
+ } else if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
+ plain = plain && isPlainSafe(char, prev_char);
+ }
+ // in case the end is missing a \n
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ';
+ }
+ // Although every style can represent \n without escaping, prefer block styles
+ // for multiline, since they're more readable and they don't add empty lines.
+ // Also prefer folding a super-long line.
+ if (!hasLineBreak && !hasFoldableLine) {
+ // Strings interpretable as another type have to be quoted;
+ // e.g. the string 'true' vs. the boolean true.
+ return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
+ }
+ // Edge case: block indentation indicator can only have one digit.
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
+ return STYLE_DOUBLE;
+ }
+ // At this point we know block styles are valid.
+ // Prefer literal style unless we want to fold.
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
+ }
+
+ // Note: line breaking/folding is implemented for only the folded style.
+ // NB. We drop the last trailing newline (if any) of a returned block scalar
+ // since the dumper adds its own newline. This always works:
+ // • No ending newline => unaffected; already using strip "-" chomping.
+ // • Ending newline => removed then restored.
+ // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
+ function writeScalar(state, string, level, iskey) {
+ state.dump = function () {
+ if (string.length === 0) {
+ return "''";
+ }
+ if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
+ return "'" + string + "'";
+ }
+
+ var indent = state.indent * Math.max(1, level); // no 0-indent scalars
+ // As indentation gets deeper, let the width decrease monotonically
+ // to the lower bound min(state.lineWidth, 40).
+ // Note that this implies
+ // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
+ // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
+ // This behaves better than a constant minimum width which disallows narrower options,
+ // or an indent threshold which causes the width to suddenly increase.
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
+
+ // Without knowing if keys are implicit/explicit, assume implicit for safety.
+ var singleLineOnly = iskey
+ // No block styles in flow mode.
+ || state.flowLevel > -1 && level >= state.flowLevel;
+ function testAmbiguity(string) {
+ return testImplicitResolving(state, string);
+ }
+
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
+ case STYLE_PLAIN:
+ return string;
+ case STYLE_SINGLE:
+ return "'" + string.replace(/'/g, "''") + "'";
+ case STYLE_LITERAL:
+ return '|' + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
+ case STYLE_FOLDED:
+ return '>' + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
+ case STYLE_DOUBLE:
+ return '"' + escapeString(string, lineWidth) + '"';
+ default:
+ throw new YAMLException('impossible error: invalid scalar style');
+ }
+ }();
+ }
+
+ // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
+ function blockHeader(string, indentPerLevel) {
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
+
+ // note the special case: the string '\n' counts as a "trailing" empty line.
+ var clip = string[string.length - 1] === '\n';
+ var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
+ var chomp = keep ? '+' : clip ? '' : '-';
+
+ return indentIndicator + chomp + '\n';
+ }
+
+ // (See the note for writeScalar.)
+ function dropEndingNewline(string) {
+ return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
+ }
+
+ // Note: a long line without a suitable break point will exceed the width limit.
+ // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
+ function foldString(string, width) {
+ // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
+ // unless they're before or after a more-indented line, or at the very
+ // beginning or end, in which case $k$ maps to $k$.
+ // Therefore, parse each chunk as newline(s) followed by a content line.
+ var lineRe = /(\n+)([^\n]*)/g;
+
+ // first line (possibly an empty line)
+ var result = function () {
+ var nextLF = string.indexOf('\n');
+ nextLF = nextLF !== -1 ? nextLF : string.length;
+ lineRe.lastIndex = nextLF;
+ return foldLine(string.slice(0, nextLF), width);
+ }();
+ // If we haven't reached the first content line yet, don't add an extra \n.
+ var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
+ var moreIndented;
+
+ // rest of the lines
+ var match;
+ while (match = lineRe.exec(string)) {
+ var prefix = match[1],
+ line = match[2];
+ moreIndented = line[0] === ' ';
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') + foldLine(line, width);
+ prevMoreIndented = moreIndented;
+ }
+
+ return result;
+ }
+
+ // Greedy line breaking.
+ // Picks the longest line under the limit each time,
+ // otherwise settles for the shortest line over the limit.
+ // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
+ function foldLine(line, width) {
+ if (line === '' || line[0] === ' ') return line;
+
+ // Since a more-indented line adds a \n, breaks can't be followed by a space.
+ var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
+ var match;
+ // start is an inclusive index. end, curr, and next are exclusive.
+ var start = 0,
+ end,
+ curr = 0,
+ next = 0;
+ var result = '';
+
+ // Invariants: 0 <= start <= length-1.
+ // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
+ // Inside the loop:
+ // A match implies length >= 2, so curr and next are <= length-2.
+ while (match = breakRe.exec(line)) {
+ next = match.index;
+ // maintain invariant: curr - start <= width
+ if (next - start > width) {
+ end = curr > start ? curr : next; // derive end <= length-2
+ result += '\n' + line.slice(start, end);
+ // skip the space that was output as \n
+ start = end + 1; // derive start <= length-1
+ }
+ curr = next;
+ }
+
+ // By the invariants, start <= length-1, so there is something left over.
+ // It is either the whole string or a part starting from non-whitespace.
+ result += '\n';
+ // Insert a break if the remainder is too long and there is a break available.
+ if (line.length - start > width && curr > start) {
+ result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
+ } else {
+ result += line.slice(start);
+ }
+
+ return result.slice(1); // drop extra \n joiner
+ }
+
+ // Escapes a double-quoted string.
+ function escapeString(string) {
+ var result = '';
+ var char, nextChar;
+ var escapeSeq;
+
+ for (var i = 0; i < string.length; i++) {
+ char = string.charCodeAt(i);
+ // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
+ if (char >= 0xD800 && char <= 0xDBFF /* high surrogate */) {
+ nextChar = string.charCodeAt(i + 1);
+ if (nextChar >= 0xDC00 && nextChar <= 0xDFFF /* low surrogate */) {
+ // Combine the surrogate pair and store it escaped.
+ result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
+ // Advance index one extra since we already used that char here.
+ i++;continue;
+ }
+ }
+ escapeSeq = ESCAPE_SEQUENCES[char];
+ result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
+ }
+
+ return result;
+ }
+
+ function writeFlowSequence(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ // Write only valid elements.
+ if (writeNode(state, level, object[index], false, false)) {
+ if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = '[' + _result + ']';
+ }
+
+ function writeBlockSequence(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ // Write only valid elements.
+ if (writeNode(state, level + 1, object[index], true, true)) {
+ if (!compact || index !== 0) {
+ _result += generateNextLine(state, level);
+ }
+
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ _result += '-';
+ } else {
+ _result += '- ';
+ }
+
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '[]'; // Empty sequence if no valid values.
+ }
+
+ function writeFlowMapping(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ pairBuffer;
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+
+ pairBuffer = '';
+ if (index !== 0) pairBuffer += ', ';
+
+ if (state.condenseFlow) pairBuffer += '"';
+
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
+
+ if (!writeNode(state, level, objectKey, false, false)) {
+ continue; // Skip this pair because of invalid key;
+ }
+
+ if (state.dump.length > 1024) pairBuffer += '? ';
+
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
+
+ if (!writeNode(state, level, objectValue, false, false)) {
+ continue; // Skip this pair because of invalid value.
+ }
+
+ pairBuffer += state.dump;
+
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
+
+ state.tag = _tag;
+ state.dump = '{' + _result + '}';
+ }
+
+ function writeBlockMapping(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ explicitPair,
+ pairBuffer;
+
+ // Allow sorting keys so that the output file is deterministic
+ if (state.sortKeys === true) {
+ // Default sorting
+ objectKeyList.sort();
+ } else if (typeof state.sortKeys === 'function') {
+ // Custom sort function
+ objectKeyList.sort(state.sortKeys);
+ } else if (state.sortKeys) {
+ // Something is wrong
+ throw new YAMLException('sortKeys must be a boolean or a function');
+ }
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ pairBuffer = '';
+
+ if (!compact || index !== 0) {
+ pairBuffer += generateNextLine(state, level);
+ }
+
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
+
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
+ continue; // Skip this pair because of invalid key.
+ }
+
+ explicitPair = state.tag !== null && state.tag !== '?' || state.dump && state.dump.length > 1024;
+
+ if (explicitPair) {
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += '?';
+ } else {
+ pairBuffer += '? ';
+ }
+ }
+
+ pairBuffer += state.dump;
+
+ if (explicitPair) {
+ pairBuffer += generateNextLine(state, level);
+ }
+
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
+ continue; // Skip this pair because of invalid value.
+ }
+
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += ':';
+ } else {
+ pairBuffer += ': ';
+ }
+
+ pairBuffer += state.dump;
+
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '{}'; // Empty mapping if no valid pairs.
+ }
+
+ function detectType(state, object, explicit) {
+ var _result, typeList, index, length, type, style;
+
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
+
+ for (index = 0, length = typeList.length; index < length; index += 1) {
+ type = typeList[index];
+
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === 'object' && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
+
+ state.tag = explicit ? type.tag : '?';
+
+ if (type.represent) {
+ style = state.styleMap[type.tag] || type.defaultStyle;
+
+ if (_toString.call(type.represent) === '[object Function]') {
+ _result = type.represent(object, style);
+ } else if (_hasOwnProperty.call(type.represent, style)) {
+ _result = type.represent[style](object, style);
+ } else {
+ throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
+ }
+
+ state.dump = _result;
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // Serializes `object` and writes it to global `result`.
+ // Returns true on success, or false on invalid object.
+ //
+ function writeNode(state, level, object, block, compact, iskey) {
+ state.tag = null;
+ state.dump = object;
+
+ if (!detectType(state, object, false)) {
+ detectType(state, object, true);
+ }
+
+ var type = _toString.call(state.dump);
+
+ if (block) {
+ block = state.flowLevel < 0 || state.flowLevel > level;
+ }
+
+ var objectOrArray = type === '[object Object]' || type === '[object Array]',
+ duplicateIndex,
+ duplicate;
+
+ if (objectOrArray) {
+ duplicateIndex = state.duplicates.indexOf(object);
+ duplicate = duplicateIndex !== -1;
+ }
+
+ if (state.tag !== null && state.tag !== '?' || duplicate || state.indent !== 2 && level > 0) {
+ compact = false;
+ }
+
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
+ state.dump = '*ref_' + duplicateIndex;
+ } else {
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
+ state.usedDuplicates[duplicateIndex] = true;
+ }
+ if (type === '[object Object]') {
+ if (block && Object.keys(state.dump).length !== 0) {
+ writeBlockMapping(state, level, state.dump, compact);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
+ }
+ } else {
+ writeFlowMapping(state, level, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
+ }
+ }
+ } else if (type === '[object Array]') {
+ var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
+ if (block && state.dump.length !== 0) {
+ writeBlockSequence(state, arrayLevel, state.dump, compact);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
+ }
+ } else {
+ writeFlowSequence(state, arrayLevel, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
+ }
+ }
+ } else if (type === '[object String]') {
+ if (state.tag !== '?') {
+ writeScalar(state, state.dump, level, iskey);
+ }
+ } else {
+ if (state.skipInvalid) return false;
+ throw new YAMLException('unacceptable kind of an object to dump ' + type);
+ }
+
+ if (state.tag !== null && state.tag !== '?') {
+ state.dump = '!<' + state.tag + '> ' + state.dump;
+ }
+ }
+
+ return true;
+ }
+
+ function getDuplicateReferences(object, state) {
+ var objects = [],
+ duplicatesIndexes = [],
+ index,
+ length;
+
+ inspectNode(object, objects, duplicatesIndexes);
+
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
+ }
+ state.usedDuplicates = new Array(length);
+ }
+
+ function inspectNode(object, objects, duplicatesIndexes) {
+ var objectKeyList, index, length;
+
+ if (object !== null && typeof object === 'object') {
+ index = objects.indexOf(object);
+ if (index !== -1) {
+ if (duplicatesIndexes.indexOf(index) === -1) {
+ duplicatesIndexes.push(index);
+ }
+ } else {
+ objects.push(object);
+
+ if (Array.isArray(object)) {
+ for (index = 0, length = object.length; index < length; index += 1) {
+ inspectNode(object[index], objects, duplicatesIndexes);
+ }
+ } else {
+ objectKeyList = Object.keys(object);
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
+ }
+ }
+ }
+ }
+ }
+
+ function dump(input, options) {
+ options = options || {};
+
+ var state = new State(options);
+
+ if (!state.noRefs) getDuplicateReferences(input, state);
+
+ if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
+
+ return '';
+ }
+
+ function safeDump(input, options) {
+ return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+ }
+
+ module.exports.dump = dump;
+ module.exports.safeDump = safeDump;
+ },{"./common":45,"./exception":47,"./schema/default_full":52,"./schema/default_safe":53}],47:[function(require,module,exports){
+ // YAML error class. http://stackoverflow.com/questions/8458984
+ //
+ 'use strict';
+
+ function YAMLException(reason, mark) {
+ // Super constructor
+ Error.call(this);
+
+ this.name = 'YAMLException';
+ this.reason = reason;
+ this.mark = mark;
+ this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
+
+ // Include stack trace in error object
+ if (Error.captureStackTrace) {
+ // Chrome and NodeJS
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ // FF, IE 10+ and Safari 6+. Fallback for others
+ this.stack = new Error().stack || '';
+ }
+ }
+
+ // Inherit from Error
+ YAMLException.prototype = Object.create(Error.prototype);
+ YAMLException.prototype.constructor = YAMLException;
+
+ YAMLException.prototype.toString = function toString(compact) {
+ var result = this.name + ': ';
+
+ result += this.reason || '(unknown reason)';
+
+ if (!compact && this.mark) {
+ result += ' ' + this.mark.toString();
+ }
+
+ return result;
+ };
+
+ module.exports = YAMLException;
+ },{}],48:[function(require,module,exports){
+ 'use strict';
+
+ /*eslint-disable max-len,no-use-before-define*/
+
+ var common = require('./common');
+ var YAMLException = require('./exception');
+ var Mark = require('./mark');
+ var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
+ var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
+
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ var CONTEXT_FLOW_IN = 1;
+ var CONTEXT_FLOW_OUT = 2;
+ var CONTEXT_BLOCK_IN = 3;
+ var CONTEXT_BLOCK_OUT = 4;
+
+ var CHOMPING_CLIP = 1;
+ var CHOMPING_STRIP = 2;
+ var CHOMPING_KEEP = 3;
+
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
+
+ function _class(obj) {
+ return Object.prototype.toString.call(obj);
+ }
+
+ function is_EOL(c) {
+ return c === 0x0A /* LF */ || c === 0x0D /* CR */;
+ }
+
+ function is_WHITE_SPACE(c) {
+ return c === 0x09 /* Tab */ || c === 0x20 /* Space */;
+ }
+
+ function is_WS_OR_EOL(c) {
+ return c === 0x09 /* Tab */ || c === 0x20 /* Space */ || c === 0x0A /* LF */ || c === 0x0D /* CR */;
+ }
+
+ function is_FLOW_INDICATOR(c) {
+ return c === 0x2C /* , */ || c === 0x5B /* [ */ || c === 0x5D /* ] */ || c === 0x7B /* { */ || c === 0x7D /* } */;
+ }
+
+ function fromHexCode(c) {
+ var lc;
+
+ if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) {
+ return c - 0x30;
+ }
+
+ /*eslint-disable no-bitwise*/
+ lc = c | 0x20;
+
+ if (0x61 /* a */ <= lc && lc <= 0x66 /* f */) {
+ return lc - 0x61 + 10;
+ }
+
+ return -1;
+ }
+
+ function escapedHexLen(c) {
+ if (c === 0x78 /* x */) {
+ return 2;
+ }
+ if (c === 0x75 /* u */) {
+ return 4;
+ }
+ if (c === 0x55 /* U */) {
+ return 8;
+ }
+ return 0;
+ }
+
+ function fromDecimalCode(c) {
+ if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) {
+ return c - 0x30;
+ }
+
+ return -1;
+ }
+
+ function simpleEscapeSequence(c) {
+ /* eslint-disable indent */
+ return c === 0x30 /* 0 */ ? '\x00' : c === 0x61 /* a */ ? '\x07' : c === 0x62 /* b */ ? '\x08' : c === 0x74 /* t */ ? '\x09' : c === 0x09 /* Tab */ ? '\x09' : c === 0x6E /* n */ ? '\x0A' : c === 0x76 /* v */ ? '\x0B' : c === 0x66 /* f */ ? '\x0C' : c === 0x72 /* r */ ? '\x0D' : c === 0x65 /* e */ ? '\x1B' : c === 0x20 /* Space */ ? ' ' : c === 0x22 /* " */ ? '\x22' : c === 0x2F /* / */ ? '/' : c === 0x5C /* \ */ ? '\x5C' : c === 0x4E /* N */ ? '\x85' : c === 0x5F /* _ */ ? '\xA0' : c === 0x4C /* L */ ? '\u2028' : c === 0x50 /* P */ ? '\u2029' : '';
+ }
+
+ function charFromCodepoint(c) {
+ if (c <= 0xFFFF) {
+ return String.fromCharCode(c);
+ }
+ // Encode UTF-16 surrogate pair
+ // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
+ return String.fromCharCode((c - 0x010000 >> 10) + 0xD800, (c - 0x010000 & 0x03FF) + 0xDC00);
+ }
+
+ var simpleEscapeCheck = new Array(256); // integer, for fast access
+ var simpleEscapeMap = new Array(256);
+ for (var i = 0; i < 256; i++) {
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
+ }
+
+ function State(input, options) {
+ this.input = input;
+
+ this.filename = options['filename'] || null;
+ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
+ this.onWarning = options['onWarning'] || null;
+ this.legacy = options['legacy'] || false;
+ this.json = options['json'] || false;
+ this.listener = options['listener'] || null;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.typeMap = this.schema.compiledTypeMap;
+
+ this.length = input.length;
+ this.position = 0;
+ this.line = 0;
+ this.lineStart = 0;
+ this.lineIndent = 0;
+
+ this.documents = [];
+
+ /*
+ this.version;
+ this.checkLineBreaks;
+ this.tagMap;
+ this.anchorMap;
+ this.tag;
+ this.anchor;
+ this.kind;
+ this.result;*/
+ }
+
+ function generateError(state, message) {
+ return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart));
+ }
+
+ function throwError(state, message) {
+ throw generateError(state, message);
+ }
+
+ function throwWarning(state, message) {
+ if (state.onWarning) {
+ state.onWarning.call(null, generateError(state, message));
+ }
+ }
+
+ var directiveHandlers = {
+
+ YAML: function handleYamlDirective(state, name, args) {
+
+ var match, major, minor;
+
+ if (state.version !== null) {
+ throwError(state, 'duplication of %YAML directive');
+ }
+
+ if (args.length !== 1) {
+ throwError(state, 'YAML directive accepts exactly one argument');
+ }
+
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
+
+ if (match === null) {
+ throwError(state, 'ill-formed argument of the YAML directive');
+ }
+
+ major = parseInt(match[1], 10);
+ minor = parseInt(match[2], 10);
+
+ if (major !== 1) {
+ throwError(state, 'unacceptable YAML version of the document');
+ }
+
+ state.version = args[0];
+ state.checkLineBreaks = minor < 2;
+
+ if (minor !== 1 && minor !== 2) {
+ throwWarning(state, 'unsupported YAML version of the document');
+ }
+ },
+
+ TAG: function handleTagDirective(state, name, args) {
+
+ var handle, prefix;
+
+ if (args.length !== 2) {
+ throwError(state, 'TAG directive accepts exactly two arguments');
+ }
+
+ handle = args[0];
+ prefix = args[1];
+
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
+ throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
+ }
+
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
+ }
+
+ if (!PATTERN_TAG_URI.test(prefix)) {
+ throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
+ }
+
+ state.tagMap[handle] = prefix;
+ }
+ };
+
+ function captureSegment(state, start, end, checkJson) {
+ var _position, _length, _character, _result;
+
+ if (start < end) {
+ _result = state.input.slice(start, end);
+
+ if (checkJson) {
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
+ _character = _result.charCodeAt(_position);
+ if (!(_character === 0x09 || 0x20 <= _character && _character <= 0x10FFFF)) {
+ throwError(state, 'expected valid JSON character');
+ }
+ }
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
+ throwError(state, 'the stream contains non-printable characters');
+ }
+
+ state.result += _result;
+ }
+ }
+
+ function mergeMappings(state, destination, source, overridableKeys) {
+ var sourceKeys, key, index, quantity;
+
+ if (!common.isObject(source)) {
+ throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
+ }
+
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
+ key = sourceKeys[index];
+
+ if (!_hasOwnProperty.call(destination, key)) {
+ destination[key] = source[key];
+ overridableKeys[key] = true;
+ }
+ }
+ }
+
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
+ var index, quantity;
+
+ // The output is a plain object here, so keys can only be strings.
+ // We need to convert keyNode to a string, but doing so can hang the process
+ // (deeply nested arrays that explode exponentially using aliases).
+ if (Array.isArray(keyNode)) {
+ keyNode = Array.prototype.slice.call(keyNode);
+
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
+ if (Array.isArray(keyNode[index])) {
+ throwError(state, 'nested arrays are not supported inside keys');
+ }
+
+ if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
+ keyNode[index] = '[object Object]';
+ }
+ }
+ }
+
+ // Avoid code execution in load() via toString property
+ // (still use its own toString for arrays, timestamps,
+ // and whatever user schema extensions happen to have @@toStringTag)
+ if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
+ keyNode = '[object Object]';
+ }
+
+ keyNode = String(keyNode);
+
+ if (_result === null) {
+ _result = {};
+ }
+
+ if (keyTag === 'tag:yaml.org,2002:merge') {
+ if (Array.isArray(valueNode)) {
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
+ }
+ } else {
+ mergeMappings(state, _result, valueNode, overridableKeys);
+ }
+ } else {
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
+ state.line = startLine || state.line;
+ state.position = startPos || state.position;
+ throwError(state, 'duplicated mapping key');
+ }
+ _result[keyNode] = valueNode;
+ delete overridableKeys[keyNode];
+ }
+
+ return _result;
+ }
+
+ function readLineBreak(state) {
+ var ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x0A /* LF */) {
+ state.position++;
+ } else if (ch === 0x0D /* CR */) {
+ state.position++;
+ if (state.input.charCodeAt(state.position) === 0x0A /* LF */) {
+ state.position++;
+ }
+ } else {
+ throwError(state, 'a line break is expected');
+ }
+
+ state.line += 1;
+ state.lineStart = state.position;
+ }
+
+ function skipSeparationSpace(state, allowComments, checkIndent) {
+ var lineBreaks = 0,
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (allowComments && ch === 0x23 /* # */) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (ch !== 0x0A /* LF */ && ch !== 0x0D /* CR */ && ch !== 0);
+ }
+
+ if (is_EOL(ch)) {
+ readLineBreak(state);
+
+ ch = state.input.charCodeAt(state.position);
+ lineBreaks++;
+ state.lineIndent = 0;
+
+ while (ch === 0x20 /* Space */) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
+ throwWarning(state, 'deficient indentation');
+ }
+
+ return lineBreaks;
+ }
+
+ function testDocumentSeparator(state) {
+ var _position = state.position,
+ ch;
+
+ ch = state.input.charCodeAt(_position);
+
+ // Condition state.position === state.lineStart is tested
+ // in parent on each call, for efficiency. No needs to test here again.
+ if ((ch === 0x2D /* - */ || ch === 0x2E /* . */) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
+
+ _position += 3;
+
+ ch = state.input.charCodeAt(_position);
+
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function writeFoldedLines(state, count) {
+ if (count === 1) {
+ state.result += ' ';
+ } else if (count > 1) {
+ state.result += common.repeat('\n', count - 1);
+ }
+ }
+
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
+ var preceding,
+ following,
+ captureStart,
+ captureEnd,
+ hasPendingContent,
+ _line,
+ _lineStart,
+ _lineIndent,
+ _kind = state.kind,
+ _result = state.result,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 0x23 /* # */ || ch === 0x26 /* & */ || ch === 0x2A /* * */ || ch === 0x21 /* ! */ || ch === 0x7C /* | */ || ch === 0x3E /* > */ || ch === 0x27 /* ' */ || ch === 0x22 /* " */ || ch === 0x25 /* % */ || ch === 0x40 /* @ */ || ch === 0x60 /* ` */) {
+ return false;
+ }
+
+ if (ch === 0x3F /* ? */ || ch === 0x2D /* - */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ return false;
+ }
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+
+ while (ch !== 0) {
+ if (ch === 0x3A /* : */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ break;
+ }
+ } else if (ch === 0x23 /* # */) {
+ preceding = state.input.charCodeAt(state.position - 1);
+
+ if (is_WS_OR_EOL(preceding)) {
+ break;
+ }
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
+ break;
+ } else if (is_EOL(ch)) {
+ _line = state.line;
+ _lineStart = state.lineStart;
+ _lineIndent = state.lineIndent;
+ skipSeparationSpace(state, false, -1);
+
+ if (state.lineIndent >= nodeIndent) {
+ hasPendingContent = true;
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ } else {
+ state.position = captureEnd;
+ state.line = _line;
+ state.lineStart = _lineStart;
+ state.lineIndent = _lineIndent;
+ break;
+ }
+ }
+
+ if (hasPendingContent) {
+ captureSegment(state, captureStart, captureEnd, false);
+ writeFoldedLines(state, state.line - _line);
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+ }
+
+ if (!is_WHITE_SPACE(ch)) {
+ captureEnd = state.position + 1;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, captureEnd, false);
+
+ if (state.result) {
+ return true;
+ }
+
+ state.kind = _kind;
+ state.result = _result;
+ return false;
+ }
+
+ function readSingleQuotedScalar(state, nodeIndent) {
+ var ch, captureStart, captureEnd;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x27 /* ' */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x27 /* ' */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x27 /* ' */) {
+ captureStart = state.position;
+ state.position++;
+ captureEnd = state.position;
+ } else {
+ return true;
+ }
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a single quoted scalar');
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a single quoted scalar');
+ }
+
+ function readDoubleQuotedScalar(state, nodeIndent) {
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x22 /* " */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x22 /* " */) {
+ captureSegment(state, captureStart, state.position, true);
state.position++;
+ return true;
+ } else if (ch === 0x5C /* \ */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (is_EOL(ch)) {
+ skipSeparationSpace(state, false, nodeIndent);
+
+ // TODO: rework to inline fn with no type cast?
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
+ state.result += simpleEscapeMap[ch];
+ state.position++;
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
+ hexLength = tmp;
+ hexResult = 0;
+
+ for (; hexLength > 0; hexLength--) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if ((tmp = fromHexCode(ch)) >= 0) {
+ hexResult = (hexResult << 4) + tmp;
+ } else {
+ throwError(state, 'expected hexadecimal character');
+ }
+ }
+
+ state.result += charFromCodepoint(hexResult);
+
+ state.position++;
+ } else {
+ throwError(state, 'unknown escape sequence');
+ }
+
+ captureStart = captureEnd = state.position;
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a double quoted scalar');
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a double quoted scalar');
+ }
+
+ function readFlowCollection(state, nodeIndent) {
+ var readNext = true,
+ _line,
+ _tag = state.tag,
+ _result,
+ _anchor = state.anchor,
+ following,
+ terminator,
+ isPair,
+ isExplicitPair,
+ isMapping,
+ overridableKeys = {},
+ keyNode,
+ keyTag,
+ valueNode,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x5B /* [ */) {
+ terminator = 0x5D; /* ] */
+ isMapping = false;
+ _result = [];
+ } else if (ch === 0x7B /* { */) {
+ terminator = 0x7D; /* } */
+ isMapping = true;
+ _result = {};
+ } else {
+ return false;
+ }
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ while (ch !== 0) {
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === terminator) {
+ state.position++;
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = isMapping ? 'mapping' : 'sequence';
+ state.result = _result;
+ return true;
+ } else if (!readNext) {
+ throwError(state, 'missed comma between flow collection entries');
+ }
+
+ keyTag = keyNode = valueNode = null;
+ isPair = isExplicitPair = false;
+
+ if (ch === 0x3F /* ? */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following)) {
+ isPair = isExplicitPair = true;
+ state.position++;
+ skipSeparationSpace(state, true, nodeIndent);
+ }
+ }
+
+ _line = state.line;
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ keyTag = state.tag;
+ keyNode = state.result;
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((isExplicitPair || state.line === _line) && ch === 0x3A /* : */) {
+ isPair = true;
+ ch = state.input.charCodeAt(++state.position);
+ skipSeparationSpace(state, true, nodeIndent);
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ valueNode = state.result;
+ }
+
+ if (isMapping) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
+ } else if (isPair) {
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
+ } else {
+ _result.push(keyNode);
+ }
+
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x2C /* , */) {
+ readNext = true;
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ readNext = false;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a flow collection');
+ }
+
+ function readBlockScalar(state, nodeIndent) {
+ var captureStart,
+ folding,
+ chomping = CHOMPING_CLIP,
+ didReadContent = false,
+ detectedIndent = false,
+ textIndent = nodeIndent,
+ emptyLines = 0,
+ atMoreIndented = false,
+ tmp,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x7C /* | */) {
+ folding = false;
+ } else if (ch === 0x3E /* > */) {
+ folding = true;
+ } else {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+
+ while (ch !== 0) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x2B /* + */ || ch === 0x2D /* - */) {
+ if (CHOMPING_CLIP === chomping) {
+ chomping = ch === 0x2B /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP;
+ } else {
+ throwError(state, 'repeat of a chomping mode identifier');
+ }
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
+ if (tmp === 0) {
+ throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
+ } else if (!detectedIndent) {
+ textIndent = nodeIndent + tmp - 1;
+ detectedIndent = true;
+ } else {
+ throwError(state, 'repeat of an indentation width identifier');
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (is_WHITE_SPACE(ch)) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (is_WHITE_SPACE(ch));
+
+ if (ch === 0x23 /* # */) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (!is_EOL(ch) && ch !== 0);
+ }
+ }
+
+ while (ch !== 0) {
+ readLineBreak(state);
+ state.lineIndent = 0;
+
+ ch = state.input.charCodeAt(state.position);
+
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 0x20 /* Space */) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (!detectedIndent && state.lineIndent > textIndent) {
+ textIndent = state.lineIndent;
+ }
+
+ if (is_EOL(ch)) {
+ emptyLines++;
+ continue;
+ }
+
+ // End of the scalar.
+ if (state.lineIndent < textIndent) {
+
+ // Perform the chomping.
+ if (chomping === CHOMPING_KEEP) {
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ } else if (chomping === CHOMPING_CLIP) {
+ if (didReadContent) {
+ // i.e. only if the scalar is not empty.
+ state.result += '\n';
+ }
+ }
+
+ // Break this `while` cycle and go to the funciton's epilogue.
+ break;
+ }
+
+ // Folded style: use fancy rules to handle line breaks.
+ if (folding) {
+
+ // Lines starting with white space characters (more-indented lines) are not folded.
+ if (is_WHITE_SPACE(ch)) {
+ atMoreIndented = true;
+ // except for the first content line (cf. Example 8.1)
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+
+ // End of more-indented block.
+ } else if (atMoreIndented) {
+ atMoreIndented = false;
+ state.result += common.repeat('\n', emptyLines + 1);
+
+ // Just one line break - perceive as the same line.
+ } else if (emptyLines === 0) {
+ if (didReadContent) {
+ // i.e. only if we have already read some scalar content.
+ state.result += ' ';
+ }
+
+ // Several line breaks - perceive as different lines.
+ } else {
+ state.result += common.repeat('\n', emptyLines);
+ }
+
+ // Literal style: just add exact number of line breaks between content lines.
+ } else {
+ // Keep all line breaks except the header line break.
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ }
+
+ didReadContent = true;
+ detectedIndent = true;
+ emptyLines = 0;
+ captureStart = state.position;
+
+ while (!is_EOL(ch) && ch !== 0) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, state.position, false);
+ }
+
+ return true;
+ }
+
+ function readBlockSequence(state, nodeIndent) {
+ var _line,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = [],
+ following,
+ detected = false,
+ ch;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+
+ if (ch !== 0x2D /* - */) {
+ break;
+ }
+
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (!is_WS_OR_EOL(following)) {
+ break;
+ }
+
+ detected = true;
+ state.position++;
+
+ if (skipSeparationSpace(state, true, -1)) {
+ if (state.lineIndent <= nodeIndent) {
+ _result.push(null);
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ }
+ }
+
+ _line = state.line;
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
+ _result.push(state.result);
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
+ throwError(state, 'bad indentation of a sequence entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'sequence';
+ state.result = _result;
+ return true;
+ }
+ return false;
+ }
+
+ function readBlockMapping(state, nodeIndent, flowIndent) {
+ var following,
+ allowCompact,
+ _line,
+ _pos,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = {},
+ overridableKeys = {},
+ keyTag = null,
+ keyNode = null,
+ valueNode = null,
+ atExplicitKey = false,
+ detected = false,
+ ch;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ following = state.input.charCodeAt(state.position + 1);
+ _line = state.line; // Save the current line.
+ _pos = state.position;
+
+ //
+ // Explicit notation case. There are two separate blocks:
+ // first for the key (denoted by "?") and second for the value (denoted by ":")
+ //
+ if ((ch === 0x3F /* ? */ || ch === 0x3A /* : */) && is_WS_OR_EOL(following)) {
+
+ if (ch === 0x3F /* ? */) {
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ detected = true;
+ atExplicitKey = true;
+ allowCompact = true;
+ } else if (atExplicitKey) {
+ // i.e. 0x3A/* : */ === character after the explicit key.
+ atExplicitKey = false;
+ allowCompact = true;
+ } else {
+ throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
+ }
+
+ state.position += 1;
+ ch = following;
+
+ //
+ // Implicit notation case. Flow-style node as the key first, then ":", and the value.
+ //
+ } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
+
+ if (state.line === _line) {
+ ch = state.input.charCodeAt(state.position);
+
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (ch === 0x3A /* : */) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (!is_WS_OR_EOL(ch)) {
+ throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
+ }
+
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ detected = true;
+ atExplicitKey = false;
+ allowCompact = false;
+ keyTag = state.tag;
+ keyNode = state.result;
+ } else if (detected) {
+ throwError(state, 'can not read an implicit mapping pair; a colon is missed');
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
+ }
+ } else if (detected) {
+ throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
+ }
+ } else {
+ break; // Reading is done. Go to the epilogue.
+ }
+
+ //
+ // Common reading code for both explicit and implicit notations.
+ //
+ if (state.line === _line || state.lineIndent > nodeIndent) {
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
+ if (atExplicitKey) {
+ keyNode = state.result;
+ } else {
+ valueNode = state.result;
+ }
+ }
+
+ if (!atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ skipSeparationSpace(state, true, -1);
+ ch = state.input.charCodeAt(state.position);
+ }
+
+ if (state.lineIndent > nodeIndent && ch !== 0) {
+ throwError(state, 'bad indentation of a mapping entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ //
+ // Epilogue.
+ //
+
+ // Special case: last mapping's node contains only the key in explicit notation.
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
+ }
+
+ // Expose the resulting mapping.
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'mapping';
+ state.result = _result;
+ }
+
+ return detected;
+ }
+
+ function readTagProperty(state) {
+ var _position,
+ isVerbatim = false,
+ isNamed = false,
+ tagHandle,
+ tagName,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x21 /* ! */) return false;
+
+ if (state.tag !== null) {
+ throwError(state, 'duplication of a tag property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x3C /* < */) {
+ isVerbatim = true;
+ ch = state.input.charCodeAt(++state.position);
+ } else if (ch === 0x21 /* ! */) {
+ isNamed = true;
+ tagHandle = '!!';
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ tagHandle = '!';
+ }
+
+ _position = state.position;
+
+ if (isVerbatim) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (ch !== 0 && ch !== 0x3E /* > */);
+
+ if (state.position < state.length) {
+ tagName = state.input.slice(_position, state.position);
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ throwError(state, 'unexpected end of the stream within a verbatim tag');
+ }
+ } else {
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+
+ if (ch === 0x21 /* ! */) {
+ if (!isNamed) {
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
+
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
+ throwError(state, 'named tag handle cannot contain such characters');
+ }
+
+ isNamed = true;
+ _position = state.position + 1;
+ } else {
+ throwError(state, 'tag suffix cannot contain exclamation marks');
+ }
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ tagName = state.input.slice(_position, state.position);
+
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
+ throwError(state, 'tag suffix cannot contain flow indicator characters');
+ }
+ }
+
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
+ throwError(state, 'tag name cannot contain such characters: ' + tagName);
+ }
+
+ if (isVerbatim) {
+ state.tag = tagName;
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
+ state.tag = state.tagMap[tagHandle] + tagName;
+ } else if (tagHandle === '!') {
+ state.tag = '!' + tagName;
+ } else if (tagHandle === '!!') {
+ state.tag = 'tag:yaml.org,2002:' + tagName;
+ } else {
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
+ }
+
+ return true;
+ }
+
+ function readAnchorProperty(state) {
+ var _position, ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x26 /* & */) return false;
+
+ if (state.anchor !== null) {
+ throwError(state, 'duplication of an anchor property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an anchor node must contain at least one character');
+ }
+
+ state.anchor = state.input.slice(_position, state.position);
+ return true;
+ }
+
+ function readAlias(state) {
+ var _position, alias, ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x2A /* * */) return false;
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an alias node must contain at least one character');
+ }
+
+ alias = state.input.slice(_position, state.position);
+
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
+ throwError(state, 'unidentified alias "' + alias + '"');
+ }
+
+ state.result = state.anchorMap[alias];
+ skipSeparationSpace(state, true, -1);
+ return true;
+ }
+
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
+ var allowBlockStyles,
+ allowBlockScalars,
+ allowBlockCollections,
+ indentStatus = 1,
+ // 1: this>parent, 0: this=parent, -1: this parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
+ }
+ }
+ }
+
+ if (indentStatus === 1) {
+ while (readTagProperty(state) || readAnchorProperty(state)) {
+ if (skipSeparationSpace(state, true, -1)) {
+ atNewLine = true;
+ allowBlockCollections = allowBlockStyles;
+
+ if (state.lineIndent > parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
+ }
+ } else {
+ allowBlockCollections = false;
+ }
+ }
+ }
+
+ if (allowBlockCollections) {
+ allowBlockCollections = atNewLine || allowCompact;
+ }
+
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
+ flowIndent = parentIndent;
+ } else {
+ flowIndent = parentIndent + 1;
+ }
+
+ blockIndent = state.position - state.lineStart;
+
+ if (indentStatus === 1) {
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
+ hasContent = true;
+ } else {
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
+ hasContent = true;
+ } else if (readAlias(state)) {
+ hasContent = true;
+
+ if (state.tag !== null || state.anchor !== null) {
+ throwError(state, 'alias node should not have any properties');
+ }
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
+ hasContent = true;
+
+ if (state.tag === null) {
+ state.tag = '?';
+ }
+ }
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ }
+ } else if (indentStatus === 0) {
+ // Special case: block sequences are allowed to have same indentation level as the parent.
+ // http://www.yaml.org/spec/1.2/spec.html#id2799784
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
+ }
+ }
+
+ if (state.tag !== null && state.tag !== '!') {
+ if (state.tag === '?') {
+ // Implicit resolving is not allowed for non-scalar types, and '?'
+ // non-specific tag is only automatically assigned to plain scalars.
+ //
+ // We only need to check kind conformity in case user explicitly assigns '?'
+ // tag, for example like this: "!> [0]"
+ //
+ if (state.result !== null && state.kind !== 'scalar') {
+ throwError(state, 'unacceptable node kind for !> tag; it should be "scalar", not "' + state.kind + '"');
+ }
+
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
+ type = state.implicitTypes[typeIndex];
+
+ if (type.resolve(state.result)) {
+ // `state.result` updated in resolver if matched
+ state.result = type.construct(state.result);
+ state.tag = type.tag;
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ break;
+ }
+ }
+ } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
+ type = state.typeMap[state.kind || 'fallback'][state.tag];
+
+ if (state.result !== null && type.kind !== state.kind) {
+ throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
+ }
+
+ if (!type.resolve(state.result)) {
+ // `state.result` updated in resolver if matched
+ throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
+ } else {
+ state.result = type.construct(state.result);
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ }
+ } else {
+ throwError(state, 'unknown tag !<' + state.tag + '>');
+ }
+ }
+
+ if (state.listener !== null) {
+ state.listener('close', state);
+ }
+ return state.tag !== null || state.anchor !== null || hasContent;
+ }
+
+ function readDocument(state) {
+ var documentStart = state.position,
+ _position,
+ directiveName,
+ directiveArgs,
+ hasDirectives = false,
+ ch;
+
+ state.version = null;
+ state.checkLineBreaks = state.legacy;
+ state.tagMap = {};
+ state.anchorMap = {};
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (state.lineIndent > 0 || ch !== 0x25 /* % */) {
+ break;
+ }
+
+ hasDirectives = true;
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveName = state.input.slice(_position, state.position);
+ directiveArgs = [];
+
+ if (directiveName.length < 1) {
+ throwError(state, 'directive name must not be less than one character in length');
+ }
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (ch === 0x23 /* # */) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (ch !== 0 && !is_EOL(ch));
+ break;
+ }
+
+ if (is_EOL(ch)) break;
+
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveArgs.push(state.input.slice(_position, state.position));
+ }
+
+ if (ch !== 0) readLineBreak(state);
+
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
+ } else {
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
+ }
+ }
+
+ skipSeparationSpace(state, true, -1);
+
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 0x2D /* - */ && state.input.charCodeAt(state.position + 1) === 0x2D /* - */ && state.input.charCodeAt(state.position + 2) === 0x2D /* - */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+ } else if (hasDirectives) {
+ throwError(state, 'directives end mark is expected');
+ }
+
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
+ skipSeparationSpace(state, true, -1);
+
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
+ throwWarning(state, 'non-ASCII line breaks are interpreted as content');
+ }
+
+ state.documents.push(state.result);
+
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
+
+ if (state.input.charCodeAt(state.position) === 0x2E /* . */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+ }
+ return;
+ }
+
+ if (state.position < state.length - 1) {
+ throwError(state, 'end of the stream or a document separator is expected');
+ } else {
+ return;
+ }
+ }
+
+ function loadDocuments(input, options) {
+ input = String(input);
+ options = options || {};
+
+ if (input.length !== 0) {
+
+ // Add tailing `\n` if not exists
+ if (input.charCodeAt(input.length - 1) !== 0x0A /* LF */ && input.charCodeAt(input.length - 1) !== 0x0D /* CR */) {
+ input += '\n';
+ }
+
+ // Strip BOM
+ if (input.charCodeAt(0) === 0xFEFF) {
+ input = input.slice(1);
+ }
+ }
+
+ var state = new State(input, options);
+
+ var nullpos = input.indexOf('\0');
+
+ if (nullpos !== -1) {
+ state.position = nullpos;
+ throwError(state, 'null byte is not allowed in input');
+ }
+
+ // Use 0 as string terminator. That significantly simplifies bounds check.
+ state.input += '\0';
+
+ while (state.input.charCodeAt(state.position) === 0x20 /* Space */) {
+ state.lineIndent += 1;
+ state.position += 1;
+ }
+
+ while (state.position < state.length - 1) {
+ readDocument(state);
+ }
+
+ return state.documents;
+ }
+
+ function loadAll(input, iterator, options) {
+ if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
+ options = iterator;
+ iterator = null;
+ }
+
+ var documents = loadDocuments(input, options);
+
+ if (typeof iterator !== 'function') {
+ return documents;
+ }
+
+ for (var index = 0, length = documents.length; index < length; index += 1) {
+ iterator(documents[index]);
+ }
+ }
+
+ function load(input, options) {
+ var documents = loadDocuments(input, options);
+
+ if (documents.length === 0) {
+ /*eslint-disable no-undefined*/
+ return undefined;
+ } else if (documents.length === 1) {
+ return documents[0];
+ }
+ throw new YAMLException('expected a single document in the stream, but found more');
+ }
+
+ function safeLoadAll(input, iterator, options) {
+ if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
+ options = iterator;
+ iterator = null;
+ }
+
+ return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+ }
+
+ function safeLoad(input, options) {
+ return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
+ }
+
+ module.exports.loadAll = loadAll;
+ module.exports.load = load;
+ module.exports.safeLoadAll = safeLoadAll;
+ module.exports.safeLoad = safeLoad;
+ },{"./common":45,"./exception":47,"./mark":49,"./schema/default_full":52,"./schema/default_safe":53}],49:[function(require,module,exports){
+ 'use strict';
+
+ var common = require('./common');
+
+ function Mark(name, buffer, position, line, column) {
+ this.name = name;
+ this.buffer = buffer;
+ this.position = position;
+ this.line = line;
+ this.column = column;
+ }
+
+ Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
+ var head, start, tail, end, snippet;
+
+ if (!this.buffer) return null;
+
+ indent = indent || 4;
+ maxLength = maxLength || 75;
+
+ head = '';
+ start = this.position;
+
+ while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
+ start -= 1;
+ if (this.position - start > maxLength / 2 - 1) {
+ head = ' ... ';
+ start += 5;
+ break;
+ }
+ }
+
+ tail = '';
+ end = this.position;
+
+ while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
+ end += 1;
+ if (end - this.position > maxLength / 2 - 1) {
+ tail = ' ... ';
+ end -= 5;
+ break;
+ }
+ }
+
+ snippet = this.buffer.slice(start, end);
+
+ return common.repeat(' ', indent) + head + snippet + tail + '\n' + common.repeat(' ', indent + this.position - start + head.length) + '^';
+ };
+
+ Mark.prototype.toString = function toString(compact) {
+ var snippet,
+ where = '';
+
+ if (this.name) {
+ where += 'in "' + this.name + '" ';
+ }
+
+ where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
+
+ if (!compact) {
+ snippet = this.getSnippet();
+
+ if (snippet) {
+ where += ':\n' + snippet;
+ }
+ }
+
+ return where;
+ };
+
+ module.exports = Mark;
+ },{"./common":45}],50:[function(require,module,exports){
+ 'use strict';
+
+ /*eslint-disable max-len*/
+
+ var common = require('./common');
+ var YAMLException = require('./exception');
+ var Type = require('./type');
+
+ function compileList(schema, name, result) {
+ var exclude = [];
+
+ schema.include.forEach(function (includedSchema) {
+ result = compileList(includedSchema, name, result);
+ });
+
+ schema[name].forEach(function (currentType) {
+ result.forEach(function (previousType, previousIndex) {
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
+ exclude.push(previousIndex);
+ }
+ });
+
+ result.push(currentType);
+ });
+
+ return result.filter(function (type, index) {
+ return exclude.indexOf(index) === -1;
+ });
+ }
+
+ function compileMap() /* lists... */{
+ var result = {
+ scalar: {},
+ sequence: {},
+ mapping: {},
+ fallback: {}
+ },
+ index,
+ length;
+
+ function collectType(type) {
+ result[type.kind][type.tag] = result['fallback'][type.tag] = type;
+ }
+
+ for (index = 0, length = arguments.length; index < length; index += 1) {
+ arguments[index].forEach(collectType);
+ }
+ return result;
+ }
+
+ function Schema(definition) {
+ this.include = definition.include || [];
+ this.implicit = definition.implicit || [];
+ this.explicit = definition.explicit || [];
+
+ this.implicit.forEach(function (type) {
+ if (type.loadKind && type.loadKind !== 'scalar') {
+ throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
+ }
+ });
+
+ this.compiledImplicit = compileList(this, 'implicit', []);
+ this.compiledExplicit = compileList(this, 'explicit', []);
+ this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
+ }
+
+ Schema.DEFAULT = null;
+
+ Schema.create = function createSchema() {
+ var schemas, types;
+
+ switch (arguments.length) {
+ case 1:
+ schemas = Schema.DEFAULT;
+ types = arguments[0];
+ break;
+
+ case 2:
+ schemas = arguments[0];
+ types = arguments[1];
+ break;
+
+ default:
+ throw new YAMLException('Wrong number of arguments for Schema.create function');
+ }
+
+ schemas = common.toArray(schemas);
+ types = common.toArray(types);
+
+ if (!schemas.every(function (schema) {
+ return schema instanceof Schema;
+ })) {
+ throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
+ }
+
+ if (!types.every(function (type) {
+ return type instanceof Type;
+ })) {
+ throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
+ }
+
+ return new Schema({
+ include: schemas,
+ explicit: types
+ });
+ };
+
+ module.exports = Schema;
+ },{"./common":45,"./exception":47,"./type":56}],51:[function(require,module,exports){
+ // Standard YAML's Core schema.
+ // http://www.yaml.org/spec/1.2/spec.html#id2804923
+ //
+ // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
+ // So, Core schema has no distinctions from JSON schema is JS-YAML.
+
+
+ 'use strict';
+
+ var Schema = require('../schema');
+
+ module.exports = new Schema({
+ include: [require('./json')]
+ });
+ },{"../schema":50,"./json":55}],52:[function(require,module,exports){
+ // JS-YAML's default schema for `load` function.
+ // It is not described in the YAML specification.
+ //
+ // This schema is based on JS-YAML's default safe schema and includes
+ // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
+ //
+ // Also this schema is used as default base schema at `Schema.create` function.
+
+
+ 'use strict';
+
+ var Schema = require('../schema');
+
+ module.exports = Schema.DEFAULT = new Schema({
+ include: [require('./default_safe')],
+ explicit: [require('../type/js/undefined'), require('../type/js/regexp'), require('../type/js/function')]
+ });
+ },{"../schema":50,"../type/js/function":61,"../type/js/regexp":62,"../type/js/undefined":63,"./default_safe":53}],53:[function(require,module,exports){
+ // JS-YAML's default schema for `safeLoad` function.
+ // It is not described in the YAML specification.
+ //
+ // This schema is based on standard YAML's Core schema and includes most of
+ // extra types described at YAML tag repository. (http://yaml.org/type/)
+
+
+ 'use strict';
+
+ var Schema = require('../schema');
+
+ module.exports = new Schema({
+ include: [require('./core')],
+ implicit: [require('../type/timestamp'), require('../type/merge')],
+ explicit: [require('../type/binary'), require('../type/omap'), require('../type/pairs'), require('../type/set')]
+ });
+ },{"../schema":50,"../type/binary":57,"../type/merge":65,"../type/omap":67,"../type/pairs":68,"../type/set":70,"../type/timestamp":72,"./core":51}],54:[function(require,module,exports){
+ // Standard YAML's Failsafe schema.
+ // http://www.yaml.org/spec/1.2/spec.html#id2802346
+
+
+ 'use strict';
+
+ var Schema = require('../schema');
+
+ module.exports = new Schema({
+ explicit: [require('../type/str'), require('../type/seq'), require('../type/map')]
+ });
+ },{"../schema":50,"../type/map":64,"../type/seq":69,"../type/str":71}],55:[function(require,module,exports){
+ // Standard YAML's JSON schema.
+ // http://www.yaml.org/spec/1.2/spec.html#id2803231
+ //
+ // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
+ // So, this schema is not such strict as defined in the YAML specification.
+ // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
+
+
+ 'use strict';
+
+ var Schema = require('../schema');
+
+ module.exports = new Schema({
+ include: [require('./failsafe')],
+ implicit: [require('../type/null'), require('../type/bool'), require('../type/int'), require('../type/float')]
+ });
+ },{"../schema":50,"../type/bool":58,"../type/float":59,"../type/int":60,"../type/null":66,"./failsafe":54}],56:[function(require,module,exports){
+ 'use strict';
+
+ var YAMLException = require('./exception');
+
+ var TYPE_CONSTRUCTOR_OPTIONS = ['kind', 'resolve', 'construct', 'instanceOf', 'predicate', 'represent', 'defaultStyle', 'styleAliases'];
+
+ var YAML_NODE_KINDS = ['scalar', 'sequence', 'mapping'];
+
+ function compileStyleAliases(map) {
+ var result = {};
+
+ if (map !== null) {
+ Object.keys(map).forEach(function (style) {
+ map[style].forEach(function (alias) {
+ result[String(alias)] = style;
+ });
+ });
+ }
+
+ return result;
+ }
+
+ function Type(tag, options) {
+ options = options || {};
+
+ Object.keys(options).forEach(function (name) {
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
+ throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
+ }
+ });
+
+ // TODO: Add tag format check.
+ this.tag = tag;
+ this.kind = options['kind'] || null;
+ this.resolve = options['resolve'] || function () {
+ return true;
+ };
+ this.construct = options['construct'] || function (data) {
+ return data;
+ };
+ this.instanceOf = options['instanceOf'] || null;
+ this.predicate = options['predicate'] || null;
+ this.represent = options['represent'] || null;
+ this.defaultStyle = options['defaultStyle'] || null;
+ this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
+
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
+ throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
+ }
+ }
+
+ module.exports = Type;
+ },{"./exception":47}],57:[function(require,module,exports){
+ 'use strict';
+
+ /*eslint-disable no-bitwise*/
+
+ var NodeBuffer;
+
+ try {
+ // A trick for browserified version, to not include `Buffer` shim
+ var _require = require;
+ NodeBuffer = _require('buffer').Buffer;
+ } catch (__) {}
+
+ var Type = require('../type');
+
+ // [ 64, 65, 66 ] -> [ padding, CR, LF ]
+ var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
+
+ function resolveYamlBinary(data) {
+ if (data === null) return false;
+
+ var code,
+ idx,
+ bitlen = 0,
+ max = data.length,
+ map = BASE64_MAP;
+
+ // Convert one by one.
+ for (idx = 0; idx < max; idx++) {
+ code = map.indexOf(data.charAt(idx));
+
+ // Skip CR/LF
+ if (code > 64) continue;
+
+ // Fail on illegal characters
+ if (code < 0) return false;
+
+ bitlen += 6;
+ }
+
+ // If there are any bits left, source was corrupted
+ return bitlen % 8 === 0;
+ }
+
+ function constructYamlBinary(data) {
+ var idx,
+ tailbits,
+ input = data.replace(/[\r\n=]/g, ''),
+ // remove CR/LF & padding to simplify scan
+ max = input.length,
+ map = BASE64_MAP,
+ bits = 0,
+ result = [];
+
+ // Collect by 6*4 bits (3 bytes)
+
+ for (idx = 0; idx < max; idx++) {
+ if (idx % 4 === 0 && idx) {
+ result.push(bits >> 16 & 0xFF);
+ result.push(bits >> 8 & 0xFF);
+ result.push(bits & 0xFF);
+ }
+
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
+ }
+
+ // Dump tail
+
+ tailbits = max % 4 * 6;
+
+ if (tailbits === 0) {
+ result.push(bits >> 16 & 0xFF);
+ result.push(bits >> 8 & 0xFF);
+ result.push(bits & 0xFF);
+ } else if (tailbits === 18) {
+ result.push(bits >> 10 & 0xFF);
+ result.push(bits >> 2 & 0xFF);
+ } else if (tailbits === 12) {
+ result.push(bits >> 4 & 0xFF);
+ }
+
+ // Wrap into Buffer for NodeJS and leave Array for browser
+ if (NodeBuffer) {
+ // Support node 6.+ Buffer API when available
+ return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
+ }
+
+ return result;
+ }
+
+ function representYamlBinary(object /*, style*/) {
+ var result = '',
+ bits = 0,
+ idx,
+ tail,
+ max = object.length,
+ map = BASE64_MAP;
+
+ // Convert every three bytes to 4 ASCII characters.
+
+ for (idx = 0; idx < max; idx++) {
+ if (idx % 3 === 0 && idx) {
+ result += map[bits >> 18 & 0x3F];
+ result += map[bits >> 12 & 0x3F];
+ result += map[bits >> 6 & 0x3F];
+ result += map[bits & 0x3F];
+ }
+
+ bits = (bits << 8) + object[idx];
+ }
+
+ // Dump tail
+
+ tail = max % 3;
+
+ if (tail === 0) {
+ result += map[bits >> 18 & 0x3F];
+ result += map[bits >> 12 & 0x3F];
+ result += map[bits >> 6 & 0x3F];
+ result += map[bits & 0x3F];
+ } else if (tail === 2) {
+ result += map[bits >> 10 & 0x3F];
+ result += map[bits >> 4 & 0x3F];
+ result += map[bits << 2 & 0x3F];
+ result += map[64];
+ } else if (tail === 1) {
+ result += map[bits >> 2 & 0x3F];
+ result += map[bits << 4 & 0x3F];
+ result += map[64];
+ result += map[64];
+ }
+
+ return result;
+ }
+
+ function isBinary(object) {
+ return NodeBuffer && NodeBuffer.isBuffer(object);
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:binary', {
+ kind: 'scalar',
+ resolve: resolveYamlBinary,
+ construct: constructYamlBinary,
+ predicate: isBinary,
+ represent: representYamlBinary
+ });
+ },{"../type":56}],58:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ function resolveYamlBoolean(data) {
+ if (data === null) return false;
+
+ var max = data.length;
+
+ return max === 4 && (data === 'true' || data === 'True' || data === 'TRUE') || max === 5 && (data === 'false' || data === 'False' || data === 'FALSE');
+ }
+
+ function constructYamlBoolean(data) {
+ return data === 'true' || data === 'True' || data === 'TRUE';
+ }
+
+ function isBoolean(object) {
+ return Object.prototype.toString.call(object) === '[object Boolean]';
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:bool', {
+ kind: 'scalar',
+ resolve: resolveYamlBoolean,
+ construct: constructYamlBoolean,
+ predicate: isBoolean,
+ represent: {
+ lowercase: function (object) {
+ return object ? 'true' : 'false';
+ },
+ uppercase: function (object) {
+ return object ? 'TRUE' : 'FALSE';
+ },
+ camelcase: function (object) {
+ return object ? 'True' : 'False';
+ }
+ },
+ defaultStyle: 'lowercase'
+ });
+ },{"../type":56}],59:[function(require,module,exports){
+ 'use strict';
+
+ var common = require('../common');
+ var Type = require('../type');
+
+ var YAML_FLOAT_PATTERN = new RegExp(
+ // 2.5e4, 2.5 and integers
+ '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
+ // .2e4, .2
+ // special case, seems not from spec
+ '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
+ // 20:59
+ '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
+ // .inf
+ '|[-+]?\\.(?:inf|Inf|INF)' +
+ // .nan
+ '|\\.(?:nan|NaN|NAN))$');
+
+ function resolveYamlFloat(data) {
+ if (data === null) return false;
+
+ if (!YAML_FLOAT_PATTERN.test(data) ||
+ // Quick hack to not allow integers end with `_`
+ // Probably should update regexp & check speed
+ data[data.length - 1] === '_') {
+ return false;
+ }
+
+ return true;
+ }
+
+ function constructYamlFloat(data) {
+ var value, sign, base, digits;
+
+ value = data.replace(/_/g, '').toLowerCase();
+ sign = value[0] === '-' ? -1 : 1;
+ digits = [];
+
+ if ('+-'.indexOf(value[0]) >= 0) {
+ value = value.slice(1);
+ }
+
+ if (value === '.inf') {
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
+ } else if (value === '.nan') {
+ return NaN;
+ } else if (value.indexOf(':') >= 0) {
+ value.split(':').forEach(function (v) {
+ digits.unshift(parseFloat(v, 10));
+ });
+
+ value = 0.0;
+ base = 1;
+
+ digits.forEach(function (d) {
+ value += d * base;
+ base *= 60;
+ });
+
+ return sign * value;
+ }
+ return sign * parseFloat(value, 10);
+ }
+
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
+
+ function representYamlFloat(object, style) {
+ var res;
+
+ if (isNaN(object)) {
+ switch (style) {
+ case 'lowercase':
+ return '.nan';
+ case 'uppercase':
+ return '.NAN';
+ case 'camelcase':
+ return '.NaN';
+ }
+ } else if (Number.POSITIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase':
+ return '.inf';
+ case 'uppercase':
+ return '.INF';
+ case 'camelcase':
+ return '.Inf';
+ }
+ } else if (Number.NEGATIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase':
+ return '-.inf';
+ case 'uppercase':
+ return '-.INF';
+ case 'camelcase':
+ return '-.Inf';
+ }
+ } else if (common.isNegativeZero(object)) {
+ return '-0.0';
+ }
+
+ res = object.toString(10);
+
+ // JS stringifier can build scientific format without dots: 5e-100,
+ // while YAML requres dot: 5.e-100. Fix it with simple hack
+
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
+ }
+
+ function isFloat(object) {
+ return Object.prototype.toString.call(object) === '[object Number]' && (object % 1 !== 0 || common.isNegativeZero(object));
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:float', {
+ kind: 'scalar',
+ resolve: resolveYamlFloat,
+ construct: constructYamlFloat,
+ predicate: isFloat,
+ represent: representYamlFloat,
+ defaultStyle: 'lowercase'
+ });
+ },{"../common":45,"../type":56}],60:[function(require,module,exports){
+ 'use strict';
+
+ var common = require('../common');
+ var Type = require('../type');
+
+ function isHexCode(c) {
+ return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */ || 0x41 /* A */ <= c && c <= 0x46 /* F */ || 0x61 /* a */ <= c && c <= 0x66 /* f */;
+ }
+
+ function isOctCode(c) {
+ return 0x30 /* 0 */ <= c && c <= 0x37 /* 7 */;
+ }
+
+ function isDecCode(c) {
+ return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */;
+ }
+
+ function resolveYamlInteger(data) {
+ if (data === null) return false;
+
+ var max = data.length,
+ index = 0,
+ hasDigits = false,
+ ch;
+
+ if (!max) return false;
+
+ ch = data[index];
+
+ // sign
+ if (ch === '-' || ch === '+') {
+ ch = data[++index];
+ }
+
+ if (ch === '0') {
+ // 0
+ if (index + 1 === max) return true;
+ ch = data[++index];
+
+ // base 2, base 8, base 16
+
+ if (ch === 'b') {
+ // base 2
+ index++;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (ch !== '0' && ch !== '1') return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+
+ if (ch === 'x') {
+ // base 16
+ index++;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isHexCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+
+ // base 8
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isOctCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+
+ // base 10 (except 0) or base 60
+
+ // value should not start with `_`;
+ if (ch === '_') return false;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (ch === ':') break;
+ if (!isDecCode(data.charCodeAt(index))) {
+ return false;
+ }
+ hasDigits = true;
+ }
+
+ // Should have digits and should not end with `_`
+ if (!hasDigits || ch === '_') return false;
+
+ // if !base60 - done;
+ if (ch !== ':') return true;
+
+ // base60 almost not used, no needs to optimize
+ return (/^(:[0-5]?[0-9])+$/.test(data.slice(index))
+ );
+ }
+
+ function constructYamlInteger(data) {
+ var value = data,
+ sign = 1,
+ ch,
+ base,
+ digits = [];
+
+ if (value.indexOf('_') !== -1) {
+ value = value.replace(/_/g, '');
+ }
+
+ ch = value[0];
+
+ if (ch === '-' || ch === '+') {
+ if (ch === '-') sign = -1;
+ value = value.slice(1);
+ ch = value[0];
+ }
+
+ if (value === '0') return 0;
+
+ if (ch === '0') {
+ if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
+ if (value[1] === 'x') return sign * parseInt(value, 16);
+ return sign * parseInt(value, 8);
+ }
+
+ if (value.indexOf(':') !== -1) {
+ value.split(':').forEach(function (v) {
+ digits.unshift(parseInt(v, 10));
+ });
+
+ value = 0;
+ base = 1;
+
+ digits.forEach(function (d) {
+ value += d * base;
+ base *= 60;
+ });
+
+ return sign * value;
+ }
+
+ return sign * parseInt(value, 10);
+ }
+
+ function isInteger(object) {
+ return Object.prototype.toString.call(object) === '[object Number]' && object % 1 === 0 && !common.isNegativeZero(object);
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:int', {
+ kind: 'scalar',
+ resolve: resolveYamlInteger,
+ construct: constructYamlInteger,
+ predicate: isInteger,
+ represent: {
+ binary: function (obj) {
+ return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1);
+ },
+ octal: function (obj) {
+ return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1);
+ },
+ decimal: function (obj) {
+ return obj.toString(10);
+ },
+ /* eslint-disable max-len */
+ hexadecimal: function (obj) {
+ return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1);
+ }
+ },
+ defaultStyle: 'decimal',
+ styleAliases: {
+ binary: [2, 'bin'],
+ octal: [8, 'oct'],
+ decimal: [10, 'dec'],
+ hexadecimal: [16, 'hex']
+ }
+ });
+ },{"../common":45,"../type":56}],61:[function(require,module,exports){
+ 'use strict';
+
+ var esprima;
+
+ // Browserified version does not have esprima
+ //
+ // 1. For node.js just require module as deps
+ // 2. For browser try to require mudule via external AMD system.
+ // If not found - try to fallback to window.esprima. If not
+ // found too - then fail to parse.
+ //
+ try {
+ // workaround to exclude package from browserify list.
+ var _require = require;
+ esprima = _require('esprima');
+ } catch (_) {
+ /* eslint-disable no-redeclare */
+ /* global window */
+ if (typeof window !== 'undefined') esprima = window.esprima;
+ }
+
+ var Type = require('../../type');
+
+ function resolveJavascriptFunction(data) {
+ if (data === null) return false;
+
+ try {
+ var source = '(' + data + ')',
+ ast = esprima.parse(source, { range: true });
+
+ if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
+ return false;
+ }
+
+ return true;
+ } catch (err) {
+ return false;
+ }
+ }
+
+ function constructJavascriptFunction(data) {
+ /*jslint evil:true*/
+
+ var source = '(' + data + ')',
+ ast = esprima.parse(source, { range: true }),
+ params = [],
+ body;
+
+ if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
+ throw new Error('Failed to resolve function');
+ }
+
+ ast.body[0].expression.params.forEach(function (param) {
+ params.push(param.name);
+ });
+
+ body = ast.body[0].expression.body.range;
+
+ // Esprima's ranges include the first '{' and the last '}' characters on
+ // function expressions. So cut them out.
+ if (ast.body[0].expression.body.type === 'BlockStatement') {
+ /*eslint-disable no-new-func*/
+ return new Function(params, source.slice(body[0] + 1, body[1] - 1));
+ }
+ // ES6 arrow functions can omit the BlockStatement. In that case, just return
+ // the body.
+ /*eslint-disable no-new-func*/
+ return new Function(params, 'return ' + source.slice(body[0], body[1]));
+ }
+
+ function representJavascriptFunction(object /*, style*/) {
+ return object.toString();
+ }
+
+ function isFunction(object) {
+ return Object.prototype.toString.call(object) === '[object Function]';
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:js/function', {
+ kind: 'scalar',
+ resolve: resolveJavascriptFunction,
+ construct: constructJavascriptFunction,
+ predicate: isFunction,
+ represent: representJavascriptFunction
+ });
+ },{"../../type":56}],62:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../../type');
+
+ function resolveJavascriptRegExp(data) {
+ if (data === null) return false;
+ if (data.length === 0) return false;
+
+ var regexp = data,
+ tail = /\/([gim]*)$/.exec(data),
+ modifiers = '';
+
+ // if regexp starts with '/' it can have modifiers and must be properly closed
+ // `/foo/gim` - modifiers tail can be maximum 3 chars
+ if (regexp[0] === '/') {
+ if (tail) modifiers = tail[1];
+
+ if (modifiers.length > 3) return false;
+ // if expression starts with /, is should be properly terminated
+ if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
+ }
+
+ return true;
+ }
+
+ function constructJavascriptRegExp(data) {
+ var regexp = data,
+ tail = /\/([gim]*)$/.exec(data),
+ modifiers = '';
+
+ // `/foo/gim` - tail can be maximum 4 chars
+ if (regexp[0] === '/') {
+ if (tail) modifiers = tail[1];
+ regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
+ }
+
+ return new RegExp(regexp, modifiers);
+ }
+
+ function representJavascriptRegExp(object /*, style*/) {
+ var result = '/' + object.source + '/';
+
+ if (object.global) result += 'g';
+ if (object.multiline) result += 'm';
+ if (object.ignoreCase) result += 'i';
+
+ return result;
+ }
+
+ function isRegExp(object) {
+ return Object.prototype.toString.call(object) === '[object RegExp]';
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:js/regexp', {
+ kind: 'scalar',
+ resolve: resolveJavascriptRegExp,
+ construct: constructJavascriptRegExp,
+ predicate: isRegExp,
+ represent: representJavascriptRegExp
+ });
+ },{"../../type":56}],63:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../../type');
+
+ function resolveJavascriptUndefined() {
+ return true;
+ }
+
+ function constructJavascriptUndefined() {
+ /*eslint-disable no-undefined*/
+ return undefined;
+ }
+
+ function representJavascriptUndefined() {
+ return '';
+ }
+
+ function isUndefined(object) {
+ return typeof object === 'undefined';
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:js/undefined', {
+ kind: 'scalar',
+ resolve: resolveJavascriptUndefined,
+ construct: constructJavascriptUndefined,
+ predicate: isUndefined,
+ represent: representJavascriptUndefined
+ });
+ },{"../../type":56}],64:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ module.exports = new Type('tag:yaml.org,2002:map', {
+ kind: 'mapping',
+ construct: function (data) {
+ return data !== null ? data : {};
+ }
+ });
+ },{"../type":56}],65:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ function resolveYamlMerge(data) {
+ return data === '<<' || data === null;
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:merge', {
+ kind: 'scalar',
+ resolve: resolveYamlMerge
+ });
+ },{"../type":56}],66:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ function resolveYamlNull(data) {
+ if (data === null) return true;
+
+ var max = data.length;
+
+ return max === 1 && data === '~' || max === 4 && (data === 'null' || data === 'Null' || data === 'NULL');
+ }
+
+ function constructYamlNull() {
+ return null;
+ }
+
+ function isNull(object) {
+ return object === null;
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:null', {
+ kind: 'scalar',
+ resolve: resolveYamlNull,
+ construct: constructYamlNull,
+ predicate: isNull,
+ represent: {
+ canonical: function () {
+ return '~';
+ },
+ lowercase: function () {
+ return 'null';
+ },
+ uppercase: function () {
+ return 'NULL';
+ },
+ camelcase: function () {
+ return 'Null';
+ }
+ },
+ defaultStyle: 'lowercase'
+ });
+ },{"../type":56}],67:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
+ var _toString = Object.prototype.toString;
+
+ function resolveYamlOmap(data) {
+ if (data === null) return true;
+
+ var objectKeys = [],
+ index,
+ length,
+ pair,
+ pairKey,
+ pairHasKey,
+ object = data;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+ pairHasKey = false;
+
+ if (_toString.call(pair) !== '[object Object]') return false;
+
+ for (pairKey in pair) {
+ if (_hasOwnProperty.call(pair, pairKey)) {
+ if (!pairHasKey) pairHasKey = true;else return false;
+ }
+ }
+
+ if (!pairHasKey) return false;
+
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);else return false;
+ }
+
+ return true;
+ }
+
+ function constructYamlOmap(data) {
+ return data !== null ? data : [];
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:omap', {
+ kind: 'sequence',
+ resolve: resolveYamlOmap,
+ construct: constructYamlOmap
+ });
+ },{"../type":56}],68:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ var _toString = Object.prototype.toString;
+
+ function resolveYamlPairs(data) {
+ if (data === null) return true;
+
+ var index,
+ length,
+ pair,
+ keys,
+ result,
+ object = data;
+
+ result = new Array(object.length);
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+
+ if (_toString.call(pair) !== '[object Object]') return false;
+
+ keys = Object.keys(pair);
+
+ if (keys.length !== 1) return false;
+
+ result[index] = [keys[0], pair[keys[0]]];
+ }
+
+ return true;
+ }
+
+ function constructYamlPairs(data) {
+ if (data === null) return [];
+
+ var index,
+ length,
+ pair,
+ keys,
+ result,
+ object = data;
+
+ result = new Array(object.length);
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+
+ keys = Object.keys(pair);
+
+ result[index] = [keys[0], pair[keys[0]]];
+ }
+
+ return result;
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:pairs', {
+ kind: 'sequence',
+ resolve: resolveYamlPairs,
+ construct: constructYamlPairs
+ });
+ },{"../type":56}],69:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ module.exports = new Type('tag:yaml.org,2002:seq', {
+ kind: 'sequence',
+ construct: function (data) {
+ return data !== null ? data : [];
+ }
+ });
+ },{"../type":56}],70:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ function resolveYamlSet(data) {
+ if (data === null) return true;
+
+ var key,
+ object = data;
+
+ for (key in object) {
+ if (_hasOwnProperty.call(object, key)) {
+ if (object[key] !== null) return false;
+ }
+ }
+
+ return true;
+ }
+
+ function constructYamlSet(data) {
+ return data !== null ? data : {};
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:set', {
+ kind: 'mapping',
+ resolve: resolveYamlSet,
+ construct: constructYamlSet
+ });
+ },{"../type":56}],71:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ module.exports = new Type('tag:yaml.org,2002:str', {
+ kind: 'scalar',
+ construct: function (data) {
+ return data !== null ? data : '';
+ }
+ });
+ },{"../type":56}],72:[function(require,module,exports){
+ 'use strict';
+
+ var Type = require('../type');
+
+ var YAML_DATE_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9])' + // [2] month
+ '-([0-9][0-9])$'); // [3] day
+
+ var YAML_TIMESTAMP_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9]?)' + // [2] month
+ '-([0-9][0-9]?)' + // [3] day
+ '(?:[Tt]|[ \\t]+)' + // ...
+ '([0-9][0-9]?)' + // [4] hour
+ ':([0-9][0-9])' + // [5] minute
+ ':([0-9][0-9])' + // [6] second
+ '(?:\\.([0-9]*))?' + // [7] fraction
+ '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
+ '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
+
+ function resolveYamlTimestamp(data) {
+ if (data === null) return false;
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
+ return false;
+ }
+
+ function constructYamlTimestamp(data) {
+ var match,
+ year,
+ month,
+ day,
+ hour,
+ minute,
+ second,
+ fraction = 0,
+ delta = null,
+ tz_hour,
+ tz_minute,
+ date;
+
+ match = YAML_DATE_REGEXP.exec(data);
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
+
+ if (match === null) throw new Error('Date resolve error');
+
+ // match: [1] year [2] month [3] day
+
+ year = +match[1];
+ month = +match[2] - 1; // JS month starts with 0
+ day = +match[3];
+
+ if (!match[4]) {
+ // no hour
+ return new Date(Date.UTC(year, month, day));
+ }
+
+ // match: [4] hour [5] minute [6] second [7] fraction
+
+ hour = +match[4];
+ minute = +match[5];
+ second = +match[6];
+
+ if (match[7]) {
+ fraction = match[7].slice(0, 3);
+ while (fraction.length < 3) {
+ // milli-seconds
+ fraction += '0';
+ }
+ fraction = +fraction;
+ }
+
+ // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
+
+ if (match[9]) {
+ tz_hour = +match[10];
+ tz_minute = +(match[11] || 0);
+ delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
+ if (match[9] === '-') delta = -delta;
+ }
+
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
+
+ if (delta) date.setTime(date.getTime() - delta);
+
+ return date;
+ }
+
+ function representYamlTimestamp(object /*, style*/) {
+ return object.toISOString();
+ }
+
+ module.exports = new Type('tag:yaml.org,2002:timestamp', {
+ kind: 'scalar',
+ resolve: resolveYamlTimestamp,
+ construct: constructYamlTimestamp,
+ instanceOf: Date,
+ represent: representYamlTimestamp
+ });
+ },{"../type":56}],73:[function(require,module,exports){
+ (function (global){(function (){
+ /**
+ * marked - a markdown parser
+ * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
+ * https://github.com/markedjs/marked
+ */
+
+ ;(function (root) {
+ 'use strict';
+
+ /**
+ * Block-Level Grammar
+ */
+
+ var block = {
+ newline: /^\n+/,
+ code: /^( {4}[^\n]+\n*)+/,
+ fences: noop,
+ hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
+ heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
+ nptable: noop,
+ blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
+ list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
+ html: '^ {0,3}(?:' // optional indentation
+ + '<(script|pre|style)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)' // (1)
+ + '|comment[^\\n]*(\\n+|$)' // (2)
+ + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
+ + '|\\n*' // (4)
+ + '|\\n*' // (5)
+ + '|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
+ + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
+ + '|(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
+ + ')',
+ def: /^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
+ table: noop,
+ lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
+ paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
+ text: /^[^\n]+/
+ };
+
+ block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
+ block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
+ block.def = edit(block.def).replace('label', block._label).replace('title', block._title).getRegex();
+
+ block.bullet = /(?:[*+-]|\d+\.)/;
+ block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
+ block.item = edit(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
+
+ block.list = edit(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
+
+ block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
+ block._comment = //;
+ block.html = edit(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
+
+ block.paragraph = edit(block.paragraph).replace('hr', block.hr).replace('heading', block.heading).replace('lheading', block.lheading).replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
+ .getRegex();
+
+ block.blockquote = edit(block.blockquote).replace('paragraph', block.paragraph).getRegex();
+
+ /**
+ * Normal Block Grammar
+ */
+
+ block.normal = merge({}, block);
+
+ /**
+ * GFM Block Grammar
+ */
+
+ block.gfm = merge({}, block.normal, {
+ fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
+ paragraph: /^/,
+ heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
+ });
+
+ block.gfm.paragraph = edit(block.paragraph).replace('(?!', '(?!' + block.gfm.fences.source.replace('\\1', '\\2') + '|' + block.list.source.replace('\\1', '\\3') + '|').getRegex();
+
+ /**
+ * GFM + Tables Block Grammar
+ */
+
+ block.tables = merge({}, block.gfm, {
+ nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
+ table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
+ });
+
+ /**
+ * Pedantic grammar
+ */
+
+ block.pedantic = merge({}, block.normal, {
+ html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)' // closed tag
+ + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
+ def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
+ });
+
+ /**
+ * Block Lexer
+ */
+
+ function Lexer(options) {
+ this.tokens = [];
+ this.tokens.links = Object.create(null);
+ this.options = options || marked.defaults;
+ this.rules = block.normal;
+
+ if (this.options.pedantic) {
+ this.rules = block.pedantic;
+ } else if (this.options.gfm) {
+ if (this.options.tables) {
+ this.rules = block.tables;
+ } else {
+ this.rules = block.gfm;
+ }
+ }
+ }
+
+ /**
+ * Expose Block Rules
+ */
+
+ Lexer.rules = block;
+
+ /**
+ * Static Lex Method
+ */
+
+ Lexer.lex = function (src, options) {
+ var lexer = new Lexer(options);
+ return lexer.lex(src);
+ };
+
+ /**
+ * Preprocessing
+ */
+
+ Lexer.prototype.lex = function (src) {
+ src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ').replace(/\u00a0/g, ' ').replace(/\u2424/g, '\n');
+
+ return this.token(src, true);
+ };
+
+ /**
+ * Lexing
+ */
+
+ Lexer.prototype.token = function (src, top) {
+ src = src.replace(/^ +$/gm, '');
+ var next, loose, cap, bull, b, item, listStart, listItems, t, space, i, tag, l, isordered, istask, ischecked;
+
+ while (src) {
+ // newline
+ if (cap = this.rules.newline.exec(src)) {
+ src = src.substring(cap[0].length);
+ if (cap[0].length > 1) {
+ this.tokens.push({
+ type: 'space'
+ });
+ }
+ }
+
+ // code
+ if (cap = this.rules.code.exec(src)) {
+ src = src.substring(cap[0].length);
+ cap = cap[0].replace(/^ {4}/gm, '');
+ this.tokens.push({
+ type: 'code',
+ text: !this.options.pedantic ? rtrim(cap, '\n') : cap
+ });
+ continue;
+ }
+
+ // fences (gfm)
+ if (cap = this.rules.fences.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'code',
+ lang: cap[2],
+ text: cap[3] || ''
+ });
+ continue;
+ }
+
+ // heading
+ if (cap = this.rules.heading.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'heading',
+ depth: cap[1].length,
+ text: cap[2]
+ });
+ continue;
+ }
+
+ // table no leading pipe (gfm)
+ if (top && (cap = this.rules.nptable.exec(src))) {
+ item = {
+ type: 'table',
+ header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
+ align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
+ cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
+ };
+
+ if (item.header.length === item.align.length) {
+ src = src.substring(cap[0].length);
+
+ for (i = 0; i < item.align.length; i++) {
+ if (/^ *-+: *$/.test(item.align[i])) {
+ item.align[i] = 'right';
+ } else if (/^ *:-+: *$/.test(item.align[i])) {
+ item.align[i] = 'center';
+ } else if (/^ *:-+ *$/.test(item.align[i])) {
+ item.align[i] = 'left';
+ } else {
+ item.align[i] = null;
+ }
+ }
+
+ for (i = 0; i < item.cells.length; i++) {
+ item.cells[i] = splitCells(item.cells[i], item.header.length);
+ }
+
+ this.tokens.push(item);
+
+ continue;
+ }
+ }
+
+ // hr
+ if (cap = this.rules.hr.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'hr'
+ });
+ continue;
+ }
+
+ // blockquote
+ if (cap = this.rules.blockquote.exec(src)) {
+ src = src.substring(cap[0].length);
+
+ this.tokens.push({
+ type: 'blockquote_start'
+ });
+
+ cap = cap[0].replace(/^ *> ?/gm, '');
+
+ // Pass `top` to keep the current
+ // "toplevel" state. This is exactly
+ // how markdown.pl works.
+ this.token(cap, top);
+
+ this.tokens.push({
+ type: 'blockquote_end'
+ });
+
+ continue;
+ }
+
+ // list
+ if (cap = this.rules.list.exec(src)) {
+ src = src.substring(cap[0].length);
+ bull = cap[2];
+ isordered = bull.length > 1;
+
+ listStart = {
+ type: 'list_start',
+ ordered: isordered,
+ start: isordered ? +bull : '',
+ loose: false
+ };
+
+ this.tokens.push(listStart);
+
+ // Get each top-level item.
+ cap = cap[0].match(this.rules.item);
+
+ listItems = [];
+ next = false;
+ l = cap.length;
+ i = 0;
+
+ for (; i < l; i++) {
+ item = cap[i];
+
+ // Remove the list item's bullet
+ // so it is seen as the next token.
+ space = item.length;
+ item = item.replace(/^ *([*+-]|\d+\.) +/, '');
+
+ // Outdent whatever the
+ // list item contains. Hacky.
+ if (~item.indexOf('\n ')) {
+ space -= item.length;
+ item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
+ }
+
+ // Determine whether the next list item belongs here.
+ // Backpedal if it does not belong in this list.
+ if (this.options.smartLists && i !== l - 1) {
+ b = block.bullet.exec(cap[i + 1])[0];
+ if (bull !== b && !(bull.length > 1 && b.length > 1)) {
+ src = cap.slice(i + 1).join('\n') + src;
+ i = l - 1;
+ }
+ }
+
+ // Determine whether item is loose or not.
+ // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
+ // for discount behavior.
+ loose = next || /\n\n(?!\s*$)/.test(item);
+ if (i !== l - 1) {
+ next = item.charAt(item.length - 1) === '\n';
+ if (!loose) loose = next;
+ }
+
+ if (loose) {
+ listStart.loose = true;
+ }
+
+ // Check for task list items
+ istask = /^\[[ xX]\] /.test(item);
+ ischecked = undefined;
+ if (istask) {
+ ischecked = item[1] !== ' ';
+ item = item.replace(/^\[[ xX]\] +/, '');
+ }
+
+ t = {
+ type: 'list_item_start',
+ task: istask,
+ checked: ischecked,
+ loose: loose
+ };
+
+ listItems.push(t);
+ this.tokens.push(t);
+
+ // Recurse.
+ this.token(item, false);
+
+ this.tokens.push({
+ type: 'list_item_end'
+ });
+ }
+
+ if (listStart.loose) {
+ l = listItems.length;
+ i = 0;
+ for (; i < l; i++) {
+ listItems[i].loose = true;
+ }
+ }
+
+ this.tokens.push({
+ type: 'list_end'
+ });
+
+ continue;
+ }
+
+ // html
+ if (cap = this.rules.html.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: this.options.sanitize ? 'paragraph' : 'html',
+ pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
+ text: cap[0]
+ });
+ continue;
+ }
+
+ // def
+ if (top && (cap = this.rules.def.exec(src))) {
+ src = src.substring(cap[0].length);
+ if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
+ tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
+ if (!this.tokens.links[tag]) {
+ this.tokens.links[tag] = {
+ href: cap[2],
+ title: cap[3]
+ };
+ }
+ continue;
+ }
+
+ // table (gfm)
+ if (top && (cap = this.rules.table.exec(src))) {
+ item = {
+ type: 'table',
+ header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
+ align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
+ cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
+ };
+
+ if (item.header.length === item.align.length) {
+ src = src.substring(cap[0].length);
+
+ for (i = 0; i < item.align.length; i++) {
+ if (/^ *-+: *$/.test(item.align[i])) {
+ item.align[i] = 'right';
+ } else if (/^ *:-+: *$/.test(item.align[i])) {
+ item.align[i] = 'center';
+ } else if (/^ *:-+ *$/.test(item.align[i])) {
+ item.align[i] = 'left';
+ } else {
+ item.align[i] = null;
+ }
+ }
+
+ for (i = 0; i < item.cells.length; i++) {
+ item.cells[i] = splitCells(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
+ }
+
+ this.tokens.push(item);
+
+ continue;
+ }
+ }
+
+ // lheading
+ if (cap = this.rules.lheading.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'heading',
+ depth: cap[2] === '=' ? 1 : 2,
+ text: cap[1]
+ });
+ continue;
+ }
+
+ // top-level paragraph
+ if (top && (cap = this.rules.paragraph.exec(src))) {
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'paragraph',
+ text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
+ });
+ continue;
+ }
+
+ // text
+ if (cap = this.rules.text.exec(src)) {
+ // Top-level should never reach here.
+ src = src.substring(cap[0].length);
+ this.tokens.push({
+ type: 'text',
+ text: cap[0]
+ });
+ continue;
+ }
+
+ if (src) {
+ throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ }
+ }
+
+ return this.tokens;
+ };
+
+ /**
+ * Inline-Level Grammar
+ */
+
+ var inline = {
+ escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
+ autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
+ url: noop,
+ tag: '^comment' + '|^[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
+ + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
+ + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g.
+ + '|^' // declaration, e.g.
+ + '|^', // CDATA section
+ link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
+ reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
+ nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
+ strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
+ em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\s.])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\s.])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
+ code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
+ br: /^( {2,}|\\)\n(?!\s*$)/,
+ del: noop,
+ text: /^(`+|[^`])[\s\S]*?(?=[\\?@\[\]\\^_`{|}~])/g;
+
+ inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
+ inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
+ inline.autolink = edit(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
+
+ inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
+
+ inline.tag = edit(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
+
+ inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
+ inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/;
+ inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
+
+ inline.link = edit(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
+
+ inline.reflink = edit(inline.reflink).replace('label', inline._label).getRegex();
+
+ /**
+ * Normal Inline Grammar
+ */
+
+ inline.normal = merge({}, inline);
+
+ /**
+ * Pedantic Inline Grammar
+ */
+
+ inline.pedantic = merge({}, inline.normal, {
+ strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
+ em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
+ });
+
+ /**
+ * GFM Inline Grammar
+ */
+
+ inline.gfm = merge({}, inline.normal, {
+ escape: edit(inline.escape).replace('])', '~|])').getRegex(),
+ _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
+ url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
+ _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
+ del: /^~+(?=\S)([\s\S]*?\S)~+/,
+ text: edit(inline.text).replace(']|', '~]|').replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$').getRegex()
+ });
+
+ inline.gfm.url = edit(inline.gfm.url).replace('email', inline.gfm._extended_email).getRegex();
+ /**
+ * GFM + Line Breaks Inline Grammar
+ */
+
+ inline.breaks = merge({}, inline.gfm, {
+ br: edit(inline.br).replace('{2,}', '*').getRegex(),
+ text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
+ });
+
+ /**
+ * Inline Lexer & Compiler
+ */
+
+ function InlineLexer(links, options) {
+ this.options = options || marked.defaults;
+ this.links = links;
+ this.rules = inline.normal;
+ this.renderer = this.options.renderer || new Renderer();
+ this.renderer.options = this.options;
+
+ if (!this.links) {
+ throw new Error('Tokens array requires a `links` property.');
+ }
+
+ if (this.options.pedantic) {
+ this.rules = inline.pedantic;
+ } else if (this.options.gfm) {
+ if (this.options.breaks) {
+ this.rules = inline.breaks;
+ } else {
+ this.rules = inline.gfm;
+ }
+ }
+ }
+
+ /**
+ * Expose Inline Rules
+ */
+
+ InlineLexer.rules = inline;
+
+ /**
+ * Static Lexing/Compiling Method
+ */
+
+ InlineLexer.output = function (src, links, options) {
+ var inline = new InlineLexer(links, options);
+ return inline.output(src);
+ };
+
+ /**
+ * Lexing/Compiling
+ */
+
+ InlineLexer.prototype.output = function (src) {
+ var out = '',
+ link,
+ text,
+ href,
+ title,
+ cap,
+ prevCapZero;
+
+ while (src) {
+ // escape
+ if (cap = this.rules.escape.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += cap[1];
+ continue;
+ }
+
+ // autolink
+ if (cap = this.rules.autolink.exec(src)) {
+ src = src.substring(cap[0].length);
+ if (cap[2] === '@') {
+ text = escape(this.mangle(cap[1]));
+ href = 'mailto:' + text;
+ } else {
+ text = escape(cap[1]);
+ href = text;
+ }
+ out += this.renderer.link(href, null, text);
+ continue;
+ }
+
+ // url (gfm)
+ if (!this.inLink && (cap = this.rules.url.exec(src))) {
+ if (cap[2] === '@') {
+ text = escape(cap[0]);
+ href = 'mailto:' + text;
+ } else {
+ // do extended autolink path validation
+ do {
+ prevCapZero = cap[0];
+ cap[0] = this.rules._backpedal.exec(cap[0])[0];
+ } while (prevCapZero !== cap[0]);
+ text = escape(cap[0]);
+ if (cap[1] === 'www.') {
+ href = 'http://' + text;
+ } else {
+ href = text;
+ }
+ }
+ src = src.substring(cap[0].length);
+ out += this.renderer.link(href, null, text);
+ continue;
+ }
+
+ // tag
+ if (cap = this.rules.tag.exec(src)) {
+ if (!this.inLink && /^/i.test(cap[0])) {
+ this.inLink = false;
+ }
+ if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
+ this.inRawBlock = true;
+ } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
+ this.inRawBlock = false;
+ }
+
+ src = src.substring(cap[0].length);
+ out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
+ continue;
+ }
+
+ // link
+ if (cap = this.rules.link.exec(src)) {
+ src = src.substring(cap[0].length);
+ this.inLink = true;
+ href = cap[2];
+ if (this.options.pedantic) {
+ link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
+
+ if (link) {
+ href = link[1];
+ title = link[3];
+ } else {
+ title = '';
+ }
+ } else {
+ title = cap[3] ? cap[3].slice(1, -1) : '';
+ }
+ href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
+ out += this.outputLink(cap, {
+ href: InlineLexer.escapes(href),
+ title: InlineLexer.escapes(title)
+ });
+ this.inLink = false;
+ continue;
+ }
+
+ // reflink, nolink
+ if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
+ src = src.substring(cap[0].length);
+ link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
+ link = this.links[link.toLowerCase()];
+ if (!link || !link.href) {
+ out += cap[0].charAt(0);
+ src = cap[0].substring(1) + src;
+ continue;
+ }
+ this.inLink = true;
+ out += this.outputLink(cap, link);
+ this.inLink = false;
+ continue;
+ }
+
+ // strong
+ if (cap = this.rules.strong.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
+ continue;
+ }
+
+ // em
+ if (cap = this.rules.em.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
+ continue;
+ }
+
+ // code
+ if (cap = this.rules.code.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.codespan(escape(cap[2].trim(), true));
+ continue;
+ }
+
+ // br
+ if (cap = this.rules.br.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.br();
+ continue;
+ }
+
+ // del (gfm)
+ if (cap = this.rules.del.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += this.renderer.del(this.output(cap[1]));
+ continue;
+ }
+
+ // text
+ if (cap = this.rules.text.exec(src)) {
+ src = src.substring(cap[0].length);
+ if (this.inRawBlock) {
+ out += this.renderer.text(cap[0]);
+ } else {
+ out += this.renderer.text(escape(this.smartypants(cap[0])));
+ }
+ continue;
+ }
+
+ if (src) {
+ throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ }
+ }
+
+ return out;
+ };
+
+ InlineLexer.escapes = function (text) {
+ return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
+ };
+
+ /**
+ * Compile Link
+ */
+
+ InlineLexer.prototype.outputLink = function (cap, link) {
+ var href = link.href,
+ title = link.title ? escape(link.title) : null;
+
+ return cap[0].charAt(0) !== '!' ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]));
+ };
+
+ /**
+ * Smartypants Transformations
+ */
+
+ InlineLexer.prototype.smartypants = function (text) {
+ if (!this.options.smartypants) return text;
+ return text
+ // em-dashes
+ .replace(/---/g, '\u2014')
+ // en-dashes
+ .replace(/--/g, '\u2013')
+ // opening singles
+ .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
+ // closing singles & apostrophes
+ .replace(/'/g, '\u2019')
+ // opening doubles
+ .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
+ // closing doubles
+ .replace(/"/g, '\u201d')
+ // ellipses
+ .replace(/\.{3}/g, '\u2026');
+ };
+
+ /**
+ * Mangle Links
+ */
+
+ InlineLexer.prototype.mangle = function (text) {
+ if (!this.options.mangle) return text;
+ var out = '',
+ l = text.length,
+ i = 0,
+ ch;
+
+ for (; i < l; i++) {
+ ch = text.charCodeAt(i);
+ if (Math.random() > 0.5) {
+ ch = 'x' + ch.toString(16);
+ }
+ out += '' + ch + ';';
+ }
+
+ return out;
+ };
+
+ /**
+ * Renderer
+ */
+
+ function Renderer(options) {
+ this.options = options || marked.defaults;
+ }
+
+ Renderer.prototype.code = function (code, lang, escaped) {
+ if (this.options.highlight) {
+ var out = this.options.highlight(code, lang);
+ if (out != null && out !== code) {
+ escaped = true;
+ code = out;
+ }
+ }
+
+ if (!lang) {
+ return '' + (escaped ? code : escape(code, true)) + '
';
+ }
+
+ return '' + (escaped ? code : escape(code, true)) + '
\n';
+ };
+
+ Renderer.prototype.blockquote = function (quote) {
+ return '\n' + quote + '
\n';
+ };
+
+ Renderer.prototype.html = function (html) {
+ return html;
+ };
+
+ Renderer.prototype.heading = function (text, level, raw) {
+ if (this.options.headerIds) {
+ return '\n';
+ }
+ // ignore IDs
+ return '' + text + '\n';
+ };
+
+ Renderer.prototype.hr = function () {
+ return this.options.xhtml ? '
\n' : '
\n';
+ };
+
+ Renderer.prototype.list = function (body, ordered, start) {
+ var type = ordered ? 'ol' : 'ul',
+ startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
+ return '<' + type + startatt + '>\n' + body + '' + type + '>\n';
+ };
+
+ Renderer.prototype.listitem = function (text) {
+ return '' + text + '\n';
+ };
+
+ Renderer.prototype.checkbox = function (checked) {
+ return ' ';
+ };
+
+ Renderer.prototype.paragraph = function (text) {
+ return '' + text + '
\n';
+ };
+
+ Renderer.prototype.table = function (header, body) {
+ if (body) body = '' + body + '';
+
+ return '\n' + '\n' + header + '\n' + body + '
\n';
+ };
+
+ Renderer.prototype.tablerow = function (content) {
+ return '\n' + content + '
\n';
+ };
+
+ Renderer.prototype.tablecell = function (content, flags) {
+ var type = flags.header ? 'th' : 'td';
+ var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
+ return tag + content + '' + type + '>\n';
+ };
+
+ // span level renderer
+ Renderer.prototype.strong = function (text) {
+ return '' + text + '';
+ };
+
+ Renderer.prototype.em = function (text) {
+ return '' + text + '';
+ };
+
+ Renderer.prototype.codespan = function (text) {
+ return '' + text + '
';
+ };
+
+ Renderer.prototype.br = function () {
+ return this.options.xhtml ? '
' : '
';
+ };
+
+ Renderer.prototype.del = function (text) {
+ return '' + text + '';
+ };
+
+ Renderer.prototype.link = function (href, title, text) {
+ href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ if (href === null) {
+ return text;
+ }
+ var out = '' + text + '';
+ return out;
+ };
+
+ Renderer.prototype.image = function (href, title, text) {
+ href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ if (href === null) {
+ return text;
+ }
+
+ var out = '' : '>';
+ return out;
+ };
+
+ Renderer.prototype.text = function (text) {
+ return text;
+ };
+
+ /**
+ * TextRenderer
+ * returns only the textual part of the token
+ */
+
+ function TextRenderer() {}
+
+ // no need for block level renderers
+
+ TextRenderer.prototype.strong = TextRenderer.prototype.em = TextRenderer.prototype.codespan = TextRenderer.prototype.del = TextRenderer.prototype.text = function (text) {
+ return text;
+ };
+
+ TextRenderer.prototype.link = TextRenderer.prototype.image = function (href, title, text) {
+ return '' + text;
+ };
+
+ TextRenderer.prototype.br = function () {
+ return '';
+ };
+
+ /**
+ * Parsing & Compiling
+ */
+
+ function Parser(options) {
+ this.tokens = [];
+ this.token = null;
+ this.options = options || marked.defaults;
+ this.options.renderer = this.options.renderer || new Renderer();
+ this.renderer = this.options.renderer;
+ this.renderer.options = this.options;
+ }
+
+ /**
+ * Static Parse Method
+ */
+
+ Parser.parse = function (src, options) {
+ var parser = new Parser(options);
+ return parser.parse(src);
+ };
+
+ /**
+ * Parse Loop
+ */
+
+ Parser.prototype.parse = function (src) {
+ this.inline = new InlineLexer(src.links, this.options);
+ // use an InlineLexer with a TextRenderer to extract pure text
+ this.inlineText = new InlineLexer(src.links, merge({}, this.options, { renderer: new TextRenderer() }));
+ this.tokens = src.reverse();
+
+ var out = '';
+ while (this.next()) {
+ out += this.tok();
+ }
+
+ return out;
+ };
+
+ /**
+ * Next Token
+ */
+
+ Parser.prototype.next = function () {
+ return this.token = this.tokens.pop();
+ };
+
+ /**
+ * Preview Next Token
+ */
+
+ Parser.prototype.peek = function () {
+ return this.tokens[this.tokens.length - 1] || 0;
+ };
+
+ /**
+ * Parse Text Tokens
+ */
+
+ Parser.prototype.parseText = function () {
+ var body = this.token.text;
+
+ while (this.peek().type === 'text') {
+ body += '\n' + this.next().text;
+ }
+
+ return this.inline.output(body);
+ };
+
+ /**
+ * Parse Current Token
+ */
+
+ Parser.prototype.tok = function () {
+ switch (this.token.type) {
+ case 'space':
+ {
+ return '';
+ }
+ case 'hr':
+ {
+ return this.renderer.hr();
+ }
+ case 'heading':
+ {
+ return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, unescape(this.inlineText.output(this.token.text)));
+ }
+ case 'code':
+ {
+ return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
+ }
+ case 'table':
+ {
+ var header = '',
+ body = '',
+ i,
+ row,
+ cell,
+ j;
+
+ // header
+ cell = '';
+ for (i = 0; i < this.token.header.length; i++) {
+ cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), { header: true, align: this.token.align[i] });
+ }
+ header += this.renderer.tablerow(cell);
+
+ for (i = 0; i < this.token.cells.length; i++) {
+ row = this.token.cells[i];
+
+ cell = '';
+ for (j = 0; j < row.length; j++) {
+ cell += this.renderer.tablecell(this.inline.output(row[j]), { header: false, align: this.token.align[j] });
+ }
+
+ body += this.renderer.tablerow(cell);
+ }
+ return this.renderer.table(header, body);
+ }
+ case 'blockquote_start':
+ {
+ body = '';
+
+ while (this.next().type !== 'blockquote_end') {
+ body += this.tok();
+ }
+
+ return this.renderer.blockquote(body);
+ }
+ case 'list_start':
+ {
+ body = '';
+ var ordered = this.token.ordered,
+ start = this.token.start;
+
+ while (this.next().type !== 'list_end') {
+ body += this.tok();
+ }
+
+ return this.renderer.list(body, ordered, start);
+ }
+ case 'list_item_start':
+ {
+ body = '';
+ var loose = this.token.loose;
+
+ if (this.token.task) {
+ body += this.renderer.checkbox(this.token.checked);
+ }
+
+ while (this.next().type !== 'list_item_end') {
+ body += !loose && this.token.type === 'text' ? this.parseText() : this.tok();
+ }
+
+ return this.renderer.listitem(body);
+ }
+ case 'html':
+ {
+ // TODO parse inline content if parameter markdown=1
+ return this.renderer.html(this.token.text);
+ }
+ case 'paragraph':
+ {
+ return this.renderer.paragraph(this.inline.output(this.token.text));
+ }
+ case 'text':
+ {
+ return this.renderer.paragraph(this.parseText());
+ }
+ }
+ };
+
+ /**
+ * Helpers
+ */
+
+ function escape(html, encode) {
+ if (encode) {
+ if (escape.escapeTest.test(html)) {
+ return html.replace(escape.escapeReplace, function (ch) {
+ return escape.replacements[ch];
+ });
+ }
+ } else {
+ if (escape.escapeTestNoEncode.test(html)) {
+ return html.replace(escape.escapeReplaceNoEncode, function (ch) {
+ return escape.replacements[ch];
+ });
+ }
+ }
+
+ return html;
+ }
+
+ escape.escapeTest = /[&<>"']/;
+ escape.escapeReplace = /[&<>"']/g;
+ escape.replacements = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": '''
+ };
+
+ escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
+ escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
+
+ function unescape(html) {
+ // explicitly match decimal, hex, and named HTML entities
+ return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
+ n = n.toLowerCase();
+ if (n === 'colon') return ':';
+ if (n.charAt(0) === '#') {
+ return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
+ }
+ return '';
+ });
+ }
+
+ function edit(regex, opt) {
+ regex = regex.source || regex;
+ opt = opt || '';
+ return {
+ replace: function (name, val) {
+ val = val.source || val;
+ val = val.replace(/(^|[^\[])\^/g, '$1');
+ regex = regex.replace(name, val);
+ return this;
+ },
+ getRegex: function () {
+ return new RegExp(regex, opt);
+ }
+ };
+ }
+
+ function cleanUrl(sanitize, base, href) {
+ if (sanitize) {
+ try {
+ var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, '').toLowerCase();
+ } catch (e) {
+ return null;
+ }
+ if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
+ return null;
+ }
+ }
+ if (base && !originIndependentUrl.test(href)) {
+ href = resolveUrl(base, href);
+ }
+ try {
+ href = encodeURI(href).replace(/%25/g, '%');
+ } catch (e) {
+ return null;
+ }
+ return href;
+ }
+
+ function resolveUrl(base, href) {
+ if (!baseUrls[' ' + base]) {
+ // we can ignore everything in base after the last slash of its path component,
+ // but we might need to add _that_
+ // https://tools.ietf.org/html/rfc3986#section-3
+ if (/^[^:]+:\/*[^/]*$/.test(base)) {
+ baseUrls[' ' + base] = base + '/';
+ } else {
+ baseUrls[' ' + base] = rtrim(base, '/', true);
+ }
+ }
+ base = baseUrls[' ' + base];
+
+ if (href.slice(0, 2) === '//') {
+ return base.replace(/:[\s\S]*/, ':') + href;
+ } else if (href.charAt(0) === '/') {
+ return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
+ } else {
+ return base + href;
+ }
+ }
+ var baseUrls = {};
+ var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
+
+ function noop() {}
+ noop.exec = noop;
+
+ function merge(obj) {
+ var i = 1,
+ target,
+ key;
+
+ for (; i < arguments.length; i++) {
+ target = arguments[i];
+ for (key in target) {
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
+ obj[key] = target[key];
+ }
+ }
+ }
+
+ return obj;
+ }
+
+ function splitCells(tableRow, count) {
+ // ensure that every cell-delimiting pipe has a space
+ // before it to distinguish it from an escaped pipe
+ var row = tableRow.replace(/\|/g, function (match, offset, str) {
+ var escaped = false,
+ curr = offset;
+ while (--curr >= 0 && str[curr] === '\\') {
+ escaped = !escaped;
+ }if (escaped) {
+ // odd number of slashes means | is escaped
+ // so we leave it alone
+ return '|';
+ } else {
+ // add space before unescaped |
+ return ' |';
+ }
+ }),
+ cells = row.split(/ \|/),
+ i = 0;
+
+ if (cells.length > count) {
+ cells.splice(count);
+ } else {
+ while (cells.length < count) {
+ cells.push('');
+ }
+ }
+
+ for (; i < cells.length; i++) {
+ // leading or trailing whitespace is ignored per the gfm spec
+ cells[i] = cells[i].trim().replace(/\\\|/g, '|');
+ }
+ return cells;
+ }
+
+ // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
+ // /c*$/ is vulnerable to REDOS.
+ // invert: Remove suffix of non-c chars instead. Default falsey.
+ function rtrim(str, c, invert) {
+ if (str.length === 0) {
+ return '';
+ }
+
+ // Length of suffix matching the invert condition.
+ var suffLen = 0;
+
+ // Step left until we fail to match the invert condition.
+ while (suffLen < str.length) {
+ var currChar = str.charAt(str.length - suffLen - 1);
+ if (currChar === c && !invert) {
+ suffLen++;
+ } else if (currChar !== c && invert) {
+ suffLen++;
+ } else {
+ break;
+ }
+ }
+
+ return str.substr(0, str.length - suffLen);
+ }
+
+ /**
+ * Marked
+ */
+
+ function marked(src, opt, callback) {
+ // throw error in case of non string input
+ if (typeof src === 'undefined' || src === null) {
+ throw new Error('marked(): input parameter is undefined or null');
+ }
+ if (typeof src !== 'string') {
+ throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
+ }
+
+ if (callback || typeof opt === 'function') {
+ if (!callback) {
+ callback = opt;
+ opt = null;
+ }
+
+ opt = merge({}, marked.defaults, opt || {});
+
+ var highlight = opt.highlight,
+ tokens,
+ pending,
+ i = 0;
+
+ try {
+ tokens = Lexer.lex(src, opt);
+ } catch (e) {
+ return callback(e);
+ }
+
+ pending = tokens.length;
+
+ var done = function (err) {
+ if (err) {
+ opt.highlight = highlight;
+ return callback(err);
+ }
+
+ var out;
+
+ try {
+ out = Parser.parse(tokens, opt);
+ } catch (e) {
+ err = e;
+ }
+
+ opt.highlight = highlight;
+
+ return err ? callback(err) : callback(null, out);
+ };
+
+ if (!highlight || highlight.length < 3) {
+ return done();
+ }
+
+ delete opt.highlight;
+
+ if (!pending) return done();
+
+ for (; i < tokens.length; i++) {
+ (function (token) {
+ if (token.type !== 'code') {
+ return --pending || done();
+ }
+ return highlight(token.text, token.lang, function (err, code) {
+ if (err) return done(err);
+ if (code == null || code === token.text) {
+ return --pending || done();
+ }
+ token.text = code;
+ token.escaped = true;
+ --pending || done();
+ });
+ })(tokens[i]);
+ }
+
+ return;
+ }
+ try {
+ if (opt) opt = merge({}, marked.defaults, opt);
+ return Parser.parse(Lexer.lex(src, opt), opt);
+ } catch (e) {
+ e.message += '\nPlease report this to https://github.com/markedjs/marked.';
+ if ((opt || marked.defaults).silent) {
+ return 'An error occurred:
' + escape(e.message + '', true) + '
';
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Options
+ */
+
+ marked.options = marked.setOptions = function (opt) {
+ merge(marked.defaults, opt);
+ return marked;
+ };
+
+ marked.getDefaults = function () {
+ return {
+ baseUrl: null,
+ breaks: false,
+ gfm: true,
+ headerIds: true,
+ headerPrefix: '',
+ highlight: null,
+ langPrefix: 'language-',
+ mangle: true,
+ pedantic: false,
+ renderer: new Renderer(),
+ sanitize: false,
+ sanitizer: null,
+ silent: false,
+ smartLists: false,
+ smartypants: false,
+ tables: true,
+ xhtml: false
+ };
+ };
+
+ marked.defaults = marked.getDefaults();
+
+ /**
+ * Expose
+ */
+
+ marked.Parser = Parser;
+ marked.parser = Parser.parse;
+
+ marked.Renderer = Renderer;
+ marked.TextRenderer = TextRenderer;
+
+ marked.Lexer = Lexer;
+ marked.lexer = Lexer.lex;
+
+ marked.InlineLexer = InlineLexer;
+ marked.inlineLexer = InlineLexer.output;
+
+ marked.parse = marked;
+
+ if (typeof module !== 'undefined' && typeof exports === 'object') {
+ module.exports = marked;
+ } else if (typeof define === 'function' && define.amd) {
+ define(function () {
+ return marked;
+ });
+ } else {
+ root.marked = marked;
+ }
+ })(this || (typeof window !== 'undefined' ? window : global));
+ }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{}],74:[function(require,module,exports){
+ module.exports = minimatch;
+ minimatch.Minimatch = Minimatch;
+
+ var path = { sep: '/' };
+ try {
+ path = require('path');
+ } catch (er) {}
+
+ var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
+ var expand = require('brace-expansion');
+
+ var plTypes = {
+ '!': { open: '(?:(?!(?:', close: '))[^/]*?)' },
+ '?': { open: '(?:', close: ')?' },
+ '+': { open: '(?:', close: ')+' },
+ '*': { open: '(?:', close: ')*' },
+ '@': { open: '(?:', close: ')' }
+
+ // any single thing other than /
+ // don't need to escape / when using new RegExp()
+ };var qmark = '[^/]';
+
+ // * => any number of characters
+ var star = qmark + '*?';
+
+ // ** when dots are allowed. Anything goes, except .. and .
+ // not (^ or / followed by one or two dots followed by $ or /),
+ // followed by anything, any number of times.
+ var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
+
+ // not a ^ or / followed by a dot,
+ // followed by anything, any number of times.
+ var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
+
+ // characters that need to be escaped in RegExp.
+ var reSpecials = charSet('().*{}+?[]^$\\!');
+
+ // "abc" -> { a:true, b:true, c:true }
+ function charSet(s) {
+ return s.split('').reduce(function (set, c) {
+ set[c] = true;
+ return set;
+ }, {});
+ }
+
+ // normalizes slashes.
+ var slashSplit = /\/+/;
+
+ minimatch.filter = filter;
+ function filter(pattern, options) {
+ options = options || {};
+ return function (p, i, list) {
+ return minimatch(p, pattern, options);
+ };
+ }
+
+ function ext(a, b) {
+ a = a || {};
+ b = b || {};
+ var t = {};
+ Object.keys(b).forEach(function (k) {
+ t[k] = b[k];
+ });
+ Object.keys(a).forEach(function (k) {
+ t[k] = a[k];
+ });
+ return t;
+ }
+
+ minimatch.defaults = function (def) {
+ if (!def || !Object.keys(def).length) return minimatch;
+
+ var orig = minimatch;
+
+ var m = function minimatch(p, pattern, options) {
+ return orig.minimatch(p, pattern, ext(def, options));
+ };
+
+ m.Minimatch = function Minimatch(pattern, options) {
+ return new orig.Minimatch(pattern, ext(def, options));
+ };
+
+ return m;
+ };
+
+ Minimatch.defaults = function (def) {
+ if (!def || !Object.keys(def).length) return Minimatch;
+ return minimatch.defaults(def).Minimatch;
+ };
+
+ function minimatch(p, pattern, options) {
+ if (typeof pattern !== 'string') {
+ throw new TypeError('glob pattern string required');
+ }
+
+ if (!options) options = {};
+
+ // shortcut: comments match nothing.
+ if (!options.nocomment && pattern.charAt(0) === '#') {
+ return false;
+ }
+
+ // "" only matches ""
+ if (pattern.trim() === '') return p === '';
+
+ return new Minimatch(pattern, options).match(p);
+ }
+
+ function Minimatch(pattern, options) {
+ if (!(this instanceof Minimatch)) {
+ return new Minimatch(pattern, options);
+ }
+
+ if (typeof pattern !== 'string') {
+ throw new TypeError('glob pattern string required');
+ }
+
+ if (!options) options = {};
+ pattern = pattern.trim();
+
+ // windows support: need to use /, not \
+ if (path.sep !== '/') {
+ pattern = pattern.split(path.sep).join('/');
+ }
+
+ this.options = options;
+ this.set = [];
+ this.pattern = pattern;
+ this.regexp = null;
+ this.negate = false;
+ this.comment = false;
+ this.empty = false;
+
+ // make the set of regexps etc.
+ this.make();
+ }
+
+ Minimatch.prototype.debug = function () {};
+
+ Minimatch.prototype.make = make;
+ function make() {
+ // don't do it more than once.
+ if (this._made) return;
+
+ var pattern = this.pattern;
+ var options = this.options;
+
+ // empty patterns and comments match nothing.
+ if (!options.nocomment && pattern.charAt(0) === '#') {
+ this.comment = true;
+ return;
+ }
+ if (!pattern) {
+ this.empty = true;
+ return;
+ }
+
+ // step 1: figure out negation, etc.
+ this.parseNegate();
+
+ // step 2: expand braces
+ var set = this.globSet = this.braceExpand();
+
+ if (options.debug) this.debug = console.error;
+
+ this.debug(this.pattern, set);
+
+ // step 3: now we have a set, so turn each one into a series of path-portion
+ // matching patterns.
+ // These will be regexps, except in the case of "**", which is
+ // set to the GLOBSTAR object for globstar behavior,
+ // and will not contain any / characters
+ set = this.globParts = set.map(function (s) {
+ return s.split(slashSplit);
+ });
+
+ this.debug(this.pattern, set);
+
+ // glob --> regexps
+ set = set.map(function (s, si, set) {
+ return s.map(this.parse, this);
+ }, this);
+
+ this.debug(this.pattern, set);
+
+ // filter out everything that didn't compile properly.
+ set = set.filter(function (s) {
+ return s.indexOf(false) === -1;
+ });
+
+ this.debug(this.pattern, set);
+
+ this.set = set;
+ }
+
+ Minimatch.prototype.parseNegate = parseNegate;
+ function parseNegate() {
+ var pattern = this.pattern;
+ var negate = false;
+ var options = this.options;
+ var negateOffset = 0;
+
+ if (options.nonegate) return;
+
+ for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
+ negate = !negate;
+ negateOffset++;
+ }
+
+ if (negateOffset) this.pattern = pattern.substr(negateOffset);
+ this.negate = negate;
+ }
+
+ // Brace expansion:
+ // a{b,c}d -> abd acd
+ // a{b,}c -> abc ac
+ // a{0..3}d -> a0d a1d a2d a3d
+ // a{b,c{d,e}f}g -> abg acdfg acefg
+ // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
+ //
+ // Invalid sets are not expanded.
+ // a{2..}b -> a{2..}b
+ // a{b}c -> a{b}c
+ minimatch.braceExpand = function (pattern, options) {
+ return braceExpand(pattern, options);
+ };
+
+ Minimatch.prototype.braceExpand = braceExpand;
+
+ function braceExpand(pattern, options) {
+ if (!options) {
+ if (this instanceof Minimatch) {
+ options = this.options;
+ } else {
+ options = {};
+ }
+ }
+
+ pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
+
+ if (typeof pattern === 'undefined') {
+ throw new TypeError('undefined pattern');
+ }
+
+ if (options.nobrace || !pattern.match(/\{.*\}/)) {
+ // shortcut. no need to expand.
+ return [pattern];
+ }
+
+ return expand(pattern);
+ }
+
+ // parse a component of the expanded set.
+ // At this point, no pattern may contain "/" in it
+ // so we're going to return a 2d array, where each entry is the full
+ // pattern, split on '/', and then turned into a regular expression.
+ // A regexp is made at the end which joins each array with an
+ // escaped /, and another full one which joins each regexp with |.
+ //
+ // Following the lead of Bash 4.1, note that "**" only has special meaning
+ // when it is the *only* thing in a path portion. Otherwise, any series
+ // of * is equivalent to a single *. Globstar behavior is enabled by
+ // default, and can be disabled by setting options.noglobstar.
+ Minimatch.prototype.parse = parse;
+ var SUBPARSE = {};
+ function parse(pattern, isSub) {
+ if (pattern.length > 1024 * 64) {
+ throw new TypeError('pattern is too long');
+ }
+
+ var options = this.options;
+
+ // shortcuts
+ if (!options.noglobstar && pattern === '**') return GLOBSTAR;
+ if (pattern === '') return '';
+
+ var re = '';
+ var hasMagic = !!options.nocase;
+ var escaping = false;
+ // ? => one single character
+ var patternListStack = [];
+ var negativeLists = [];
+ var stateChar;
+ var inClass = false;
+ var reClassStart = -1;
+ var classStart = -1;
+ // . and .. never match anything that doesn't start with .,
+ // even when options.dot is set.
+ var patternStart = pattern.charAt(0) === '.' ? '' // anything
+ // not (start or / followed by . or .. followed by / or end)
+ : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
+ var self = this;
+
+ function clearStateChar() {
+ if (stateChar) {
+ // we had some state-tracking character
+ // that wasn't consumed by this pass.
+ switch (stateChar) {
+ case '*':
+ re += star;
+ hasMagic = true;
+ break;
+ case '?':
+ re += qmark;
+ hasMagic = true;
+ break;
+ default:
+ re += '\\' + stateChar;
+ break;
+ }
+ self.debug('clearStateChar %j %j', stateChar, re);
+ stateChar = false;
+ }
+ }
+
+ for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
+ this.debug('%s\t%s %s %j', pattern, i, re, c);
+
+ // skip over any that are escaped.
+ if (escaping && reSpecials[c]) {
+ re += '\\' + c;
+ escaping = false;
+ continue;
+ }
+
+ switch (c) {
+ case '/':
+ // completely not allowed, even escaped.
+ // Should already be path-split by now.
+ return false;
+
+ case '\\':
+ clearStateChar();
+ escaping = true;
+ continue;
+
+ // the various stateChar values
+ // for the "extglob" stuff.
+ case '?':
+ case '*':
+ case '+':
+ case '@':
+ case '!':
+ this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
+
+ // all of those are literals inside a class, except that
+ // the glob [!a] means [^a] in regexp
+ if (inClass) {
+ this.debug(' in class');
+ if (c === '!' && i === classStart + 1) c = '^';
+ re += c;
+ continue;
+ }
+
+ // if we already have a stateChar, then it means
+ // that there was something like ** or +? in there.
+ // Handle the stateChar, then proceed with this one.
+ self.debug('call clearStateChar %j', stateChar);
+ clearStateChar();
+ stateChar = c;
+ // if extglob is disabled, then +(asdf|foo) isn't a thing.
+ // just clear the statechar *now*, rather than even diving into
+ // the patternList stuff.
+ if (options.noext) clearStateChar();
+ continue;
+
+ case '(':
+ if (inClass) {
+ re += '(';
+ continue;
+ }
+
+ if (!stateChar) {
+ re += '\\(';
+ continue;
+ }
+
+ patternListStack.push({
+ type: stateChar,
+ start: i - 1,
+ reStart: re.length,
+ open: plTypes[stateChar].open,
+ close: plTypes[stateChar].close
+ });
+ // negation is (?:(?!js)[^/]*)
+ re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
+ this.debug('plType %j %j', stateChar, re);
+ stateChar = false;
+ continue;
+
+ case ')':
+ if (inClass || !patternListStack.length) {
+ re += '\\)';
+ continue;
+ }
+
+ clearStateChar();
+ hasMagic = true;
+ var pl = patternListStack.pop();
+ // negation is (?:(?!js)[^/]*)
+ // The others are (?:)
+ re += pl.close;
+ if (pl.type === '!') {
+ negativeLists.push(pl);
+ }
+ pl.reEnd = re.length;
+ continue;
+
+ case '|':
+ if (inClass || !patternListStack.length || escaping) {
+ re += '\\|';
+ escaping = false;
+ continue;
+ }
+
+ clearStateChar();
+ re += '|';
+ continue;
+
+ // these are mostly the same in regexp and glob
+ case '[':
+ // swallow any state-tracking char before the [
+ clearStateChar();
+
+ if (inClass) {
+ re += '\\' + c;
+ continue;
+ }
+
+ inClass = true;
+ classStart = i;
+ reClassStart = re.length;
+ re += c;
+ continue;
+
+ case ']':
+ // a right bracket shall lose its special
+ // meaning and represent itself in
+ // a bracket expression if it occurs
+ // first in the list. -- POSIX.2 2.8.3.2
+ if (i === classStart + 1 || !inClass) {
+ re += '\\' + c;
+ escaping = false;
+ continue;
+ }
+
+ // handle the case where we left a class open.
+ // "[z-a]" is valid, equivalent to "\[z-a\]"
+ if (inClass) {
+ // split where the last [ was, make sure we don't have
+ // an invalid re. if so, re-walk the contents of the
+ // would-be class to re-translate any characters that
+ // were passed through as-is
+ // TODO: It would probably be faster to determine this
+ // without a try/catch and a new RegExp, but it's tricky
+ // to do safely. For now, this is safe and works.
+ var cs = pattern.substring(classStart + 1, i);
+ try {
+ RegExp('[' + cs + ']');
+ } catch (er) {
+ // not a valid class!
+ var sp = this.parse(cs, SUBPARSE);
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
+ hasMagic = hasMagic || sp[1];
+ inClass = false;
+ continue;
+ }
+ }
+
+ // finish up the class.
+ hasMagic = true;
+ inClass = false;
+ re += c;
+ continue;
+
+ default:
+ // swallow any state char that wasn't consumed
+ clearStateChar();
+
+ if (escaping) {
+ // no need
+ escaping = false;
+ } else if (reSpecials[c] && !(c === '^' && inClass)) {
+ re += '\\';
+ }
+
+ re += c;
+
+ } // switch
+ } // for
+
+ // handle the case where we left a class open.
+ // "[abc" is valid, equivalent to "\[abc"
+ if (inClass) {
+ // split where the last [ was, and escape it
+ // this is a huge pita. We now have to re-walk
+ // the contents of the would-be class to re-translate
+ // any characters that were passed through as-is
+ cs = pattern.substr(classStart + 1);
+ sp = this.parse(cs, SUBPARSE);
+ re = re.substr(0, reClassStart) + '\\[' + sp[0];
+ hasMagic = hasMagic || sp[1];
+ }
+
+ // handle the case where we had a +( thing at the *end*
+ // of the pattern.
+ // each pattern list stack adds 3 chars, and we need to go through
+ // and escape any | chars that were passed through as-is for the regexp.
+ // Go through and escape them, taking care not to double-escape any
+ // | chars that were already escaped.
+ for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
+ var tail = re.slice(pl.reStart + pl.open.length);
+ this.debug('setting tail', re, pl);
+ // maybe some even number of \, then maybe 1 \, followed by a |
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
+ if (!$2) {
+ // the | isn't already escaped, so escape it.
+ $2 = '\\';
+ }
+
+ // need to escape all those slashes *again*, without escaping the
+ // one that we need for escaping the | character. As it works out,
+ // escaping an even number of slashes can be done by simply repeating
+ // it exactly after itself. That's why this trick works.
+ //
+ // I am sorry that you have to see this.
+ return $1 + $1 + $2 + '|';
+ });
+
+ this.debug('tail=%j\n %s', tail, tail, pl, re);
+ var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
+
+ hasMagic = true;
+ re = re.slice(0, pl.reStart) + t + '\\(' + tail;
+ }
+
+ // handle trailing things that only matter at the very end.
+ clearStateChar();
+ if (escaping) {
+ // trailing \\
+ re += '\\\\';
+ }
+
+ // only need to apply the nodot start if the re starts with
+ // something that could conceivably capture a dot
+ var addPatternStart = false;
+ switch (re.charAt(0)) {
+ case '.':
+ case '[':
+ case '(':
+ addPatternStart = true;
+ }
+
+ // Hack to work around lack of negative lookbehind in JS
+ // A pattern like: *.!(x).!(y|z) needs to ensure that a name
+ // like 'a.xyz.yz' doesn't match. So, the first negative
+ // lookahead, has to look ALL the way ahead, to the end of
+ // the pattern.
+ for (var n = negativeLists.length - 1; n > -1; n--) {
+ var nl = negativeLists[n];
+
+ var nlBefore = re.slice(0, nl.reStart);
+ var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
+ var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
+ var nlAfter = re.slice(nl.reEnd);
+
+ nlLast += nlAfter;
+
+ // Handle nested stuff like *(*.js|!(*.json)), where open parens
+ // mean that we should *not* include the ) in the bit that is considered
+ // "after" the negated section.
+ var openParensBefore = nlBefore.split('(').length - 1;
+ var cleanAfter = nlAfter;
+ for (i = 0; i < openParensBefore; i++) {
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
+ }
+ nlAfter = cleanAfter;
+
+ var dollar = '';
+ if (nlAfter === '' && isSub !== SUBPARSE) {
+ dollar = '$';
+ }
+ var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
+ re = newRe;
+ }
+
+ // if the re is not "" at this point, then we need to make sure
+ // it doesn't match against an empty path part.
+ // Otherwise a/* will match a/, which it should not.
+ if (re !== '' && hasMagic) {
+ re = '(?=.)' + re;
+ }
+
+ if (addPatternStart) {
+ re = patternStart + re;
+ }
+
+ // parsing just a piece of a larger pattern.
+ if (isSub === SUBPARSE) {
+ return [re, hasMagic];
+ }
+
+ // skip the regexp for non-magical patterns
+ // unescape anything in it, though, so that it'll be
+ // an exact match against a file etc.
+ if (!hasMagic) {
+ return globUnescape(pattern);
+ }
+
+ var flags = options.nocase ? 'i' : '';
+ try {
+ var regExp = new RegExp('^' + re + '$', flags);
+ } catch (er) {
+ // If it was an invalid regular expression, then it can't match
+ // anything. This trick looks for a character after the end of
+ // the string, which is of course impossible, except in multi-line
+ // mode, but it's not a /m regex.
+ return new RegExp('$.');
+ }
+
+ regExp._glob = pattern;
+ regExp._src = re;
+
+ return regExp;
+ }
+
+ minimatch.makeRe = function (pattern, options) {
+ return new Minimatch(pattern, options || {}).makeRe();
+ };
+
+ Minimatch.prototype.makeRe = makeRe;
+ function makeRe() {
+ if (this.regexp || this.regexp === false) return this.regexp;
+
+ // at this point, this.set is a 2d array of partial
+ // pattern strings, or "**".
+ //
+ // It's better to use .match(). This function shouldn't
+ // be used, really, but it's pretty convenient sometimes,
+ // when you just want to work with a regex.
+ var set = this.set;
+
+ if (!set.length) {
+ this.regexp = false;
+ return this.regexp;
+ }
+ var options = this.options;
+
+ var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
+ var flags = options.nocase ? 'i' : '';
+
+ var re = set.map(function (pattern) {
+ return pattern.map(function (p) {
+ return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
+ }).join('\\\/');
+ }).join('|');
+
+ // must match entire pattern
+ // ending in a * or ** will make it less strict.
+ re = '^(?:' + re + ')$';
+
+ // can match anything, as long as it's not this.
+ if (this.negate) re = '^(?!' + re + ').*$';
+
+ try {
+ this.regexp = new RegExp(re, flags);
+ } catch (ex) {
+ this.regexp = false;
+ }
+ return this.regexp;
+ }
+
+ minimatch.match = function (list, pattern, options) {
+ options = options || {};
+ var mm = new Minimatch(pattern, options);
+ list = list.filter(function (f) {
+ return mm.match(f);
+ });
+ if (mm.options.nonull && !list.length) {
+ list.push(pattern);
+ }
+ return list;
+ };
+
+ Minimatch.prototype.match = match;
+ function match(f, partial) {
+ this.debug('match', f, this.pattern);
+ // short-circuit in the case of busted things.
+ // comments, etc.
+ if (this.comment) return false;
+ if (this.empty) return f === '';
+
+ if (f === '/' && partial) return true;
+
+ var options = this.options;
+
+ // windows: need to use /, not \
+ if (path.sep !== '/') {
+ f = f.split(path.sep).join('/');
+ }
+
+ // treat the test path as a set of pathparts.
+ f = f.split(slashSplit);
+ this.debug(this.pattern, 'split', f);
+
+ // just ONE of the pattern sets in this.set needs to match
+ // in order for it to be valid. If negating, then just one
+ // match means that we have failed.
+ // Either way, return on the first hit.
+
+ var set = this.set;
+ this.debug(this.pattern, 'set', set);
+
+ // Find the basename of the path by looking for the last non-empty segment
+ var filename;
+ var i;
+ for (i = f.length - 1; i >= 0; i--) {
+ filename = f[i];
+ if (filename) break;
+ }
+
+ for (i = 0; i < set.length; i++) {
+ var pattern = set[i];
+ var file = f;
+ if (options.matchBase && pattern.length === 1) {
+ file = [filename];
+ }
+ var hit = this.matchOne(file, pattern, partial);
+ if (hit) {
+ if (options.flipNegate) return true;
+ return !this.negate;
+ }
+ }
+
+ // didn't get any hits. this is success if it's a negative
+ // pattern, failure otherwise.
+ if (options.flipNegate) return false;
+ return this.negate;
+ }
+
+ // set partial to true to test if, for example,
+ // "/a/b" matches the start of "/*/b/*/d"
+ // Partial means, if you run out of file before you run
+ // out of pattern, then that's fine, as long as all
+ // the parts match.
+ Minimatch.prototype.matchOne = function (file, pattern, partial) {
+ var options = this.options;
+
+ this.debug('matchOne', { 'this': this, file: file, pattern: pattern });
+
+ this.debug('matchOne', file.length, pattern.length);
+
+ for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
+ this.debug('matchOne loop');
+ var p = pattern[pi];
+ var f = file[fi];
+
+ this.debug(pattern, p, f);
+
+ // should be impossible.
+ // some invalid regexp stuff in the set.
+ if (p === false) return false;
+
+ if (p === GLOBSTAR) {
+ this.debug('GLOBSTAR', [pattern, p, f]);
+
+ // "**"
+ // a/**/b/**/c would match the following:
+ // a/b/x/y/z/c
+ // a/x/y/z/b/c
+ // a/b/x/b/x/c
+ // a/b/c
+ // To do this, take the rest of the pattern after
+ // the **, and see if it would match the file remainder.
+ // If so, return success.
+ // If not, the ** "swallows" a segment, and try again.
+ // This is recursively awful.
+ //
+ // a/**/b/**/c matching a/b/x/y/z/c
+ // - a matches a
+ // - doublestar
+ // - matchOne(b/x/y/z/c, b/**/c)
+ // - b matches b
+ // - doublestar
+ // - matchOne(x/y/z/c, c) -> no
+ // - matchOne(y/z/c, c) -> no
+ // - matchOne(z/c, c) -> no
+ // - matchOne(c, c) yes, hit
+ var fr = fi;
+ var pr = pi + 1;
+ if (pr === pl) {
+ this.debug('** at the end');
+ // a ** at the end will just swallow the rest.
+ // We have found a match.
+ // however, it will not swallow /.x, unless
+ // options.dot is set.
+ // . and .. are *never* matched by **, for explosively
+ // exponential reasons.
+ for (; fi < fl; fi++) {
+ if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
+ }
+ return true;
+ }
+
+ // ok, let's see if we can swallow whatever we can.
+ while (fr < fl) {
+ var swallowee = file[fr];
+
+ this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
+
+ // XXX remove this slice. Just pass the start index.
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
+ this.debug('globstar found match!', fr, fl, swallowee);
+ // found a match.
+ return true;
+ } else {
+ // can't swallow "." or ".." ever.
+ // can only swallow ".foo" when explicitly asked.
+ if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
+ this.debug('dot detected!', file, fr, pattern, pr);
+ break;
+ }
+
+ // ** swallows a segment, and continue.
+ this.debug('globstar swallow a segment, and continue');
+ fr++;
+ }
+ }
+
+ // no match was found.
+ // However, in partial mode, we can't say this is necessarily over.
+ // If there's more *pattern* left, then
+ if (partial) {
+ // ran out of file
+ this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
+ if (fr === fl) return true;
+ }
+ return false;
+ }
+
+ // something other than **
+ // non-magic patterns just have to match exactly
+ // patterns with magic have been turned into regexps.
+ var hit;
+ if (typeof p === 'string') {
+ if (options.nocase) {
+ hit = f.toLowerCase() === p.toLowerCase();
+ } else {
+ hit = f === p;
}
+ this.debug('string match', p, f, hit);
+ } else {
+ hit = f.match(p);
+ this.debug('pattern match', p, f, hit);
+ }
+
+ if (!hit) return false;
+ }
+
+ // Note: ending in / means that we'll get a final ""
+ // at the end of the pattern. This can only match a
+ // corresponding "" at the end of the file.
+ // If the file ends in /, then it can only match a
+ // a pattern that ends in /, unless the pattern just
+ // doesn't have any more for it. But, a/b/ should *not*
+ // match "a/b/*", even though "" matches against the
+ // [^/]*? pattern, except in partial mode, where it might
+ // simply not be reached yet.
+ // However, a/b/ should still satisfy a/*
+
+ // now either we fell off the end of the pattern, or we're done.
+ if (fi === fl && pi === pl) {
+ // ran out of pattern and filename at the same time.
+ // an exact hit!
+ return true;
+ } else if (fi === fl) {
+ // ran out of file, but still had pattern left.
+ // this is ok if we're doing the match as part of
+ // a glob fs traversal.
+ return partial;
+ } else if (pi === pl) {
+ // ran out of pattern, still have file left.
+ // this is only acceptable if we're on the very last
+ // empty segment of a file with a trailing slash.
+ // a/* should match a/b/
+ var emptyFileEnd = fi === fl - 1 && file[fi] === '';
+ return emptyFileEnd;
+ }
+
+ // should be unreachable.
+ throw new Error('wtf?');
+ };
+
+ // replace stuff like \* with *
+ function globUnescape(s) {
+ return s.replace(/\\(.)/g, '$1');
+ }
+
+ function regExpEscape(s) {
+ return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
+ }
+ },{"brace-expansion":7,"path":102}],75:[function(require,module,exports){
+ assert.notEqual = notEqual;
+ assert.notOk = notOk;
+ assert.equal = equal;
+ assert.ok = assert;
+
+ module.exports = assert;
+
+ function equal(a, b, m) {
+ assert(a == b, m); // eslint-disable-line eqeqeq
+ }
+
+ function notEqual(a, b, m) {
+ assert(a != b, m); // eslint-disable-line eqeqeq
+ }
+
+ function notOk(t, m) {
+ assert(!t, m);
+ }
+
+ function assert(t, m) {
+ if (!t) throw new Error(m || 'AssertionError');
+ }
+ },{}],76:[function(require,module,exports){
+ var splice = require('remove-array-items');
+ var nanotiming = require('nanotiming');
+ var assert = require('assert');
+
+ module.exports = Nanobus;
+
+ function Nanobus(name) {
+ if (!(this instanceof Nanobus)) return new Nanobus(name);
+
+ this._name = name || 'nanobus';
+ this._starListeners = [];
+ this._listeners = {};
+ }
+
+ Nanobus.prototype.emit = function (eventName) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.emit: eventName should be type string or symbol');
+
+ var data = [];
+ for (var i = 1, len = arguments.length; i < len; i++) {
+ data.push(arguments[i]);
+ }
+
+ var emitTiming = nanotiming(this._name + "('" + eventName.toString() + "')");
+ var listeners = this._listeners[eventName];
+ if (listeners && listeners.length > 0) {
+ this._emit(this._listeners[eventName], data);
+ }
+
+ if (this._starListeners.length > 0) {
+ this._emit(this._starListeners, eventName, data, emitTiming.uuid);
+ }
+ emitTiming();
+
+ return this;
+ };
+
+ Nanobus.prototype.on = Nanobus.prototype.addListener = function (eventName, listener) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.on: eventName should be type string or symbol');
+ assert.equal(typeof listener, 'function', 'nanobus.on: listener should be type function');
+
+ if (eventName === '*') {
+ this._starListeners.push(listener);
+ } else {
+ if (!this._listeners[eventName]) this._listeners[eventName] = [];
+ this._listeners[eventName].push(listener);
+ }
+ return this;
+ };
+
+ Nanobus.prototype.prependListener = function (eventName, listener) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.prependListener: eventName should be type string or symbol');
+ assert.equal(typeof listener, 'function', 'nanobus.prependListener: listener should be type function');
+
+ if (eventName === '*') {
+ this._starListeners.unshift(listener);
} else {
- throwError(state, 'a line break is expected');
- }
-
- state.line += 1;
- state.lineStart = state.position;
-}
-
-function skipSeparationSpace(state, allowComments, checkIndent) {
- var lineBreaks = 0,
- ch = state.input.charCodeAt(state.position);
-
- while (ch !== 0) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
+ if (!this._listeners[eventName]) this._listeners[eventName] = [];
+ this._listeners[eventName].unshift(listener);
}
-
- if (allowComments && ch === 0x23 /* # */) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (ch !== 0x0A /* LF */ && ch !== 0x0D /* CR */ && ch !== 0);
+ return this;
+ };
+
+ Nanobus.prototype.once = function (eventName, listener) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.once: eventName should be type string or symbol');
+ assert.equal(typeof listener, 'function', 'nanobus.once: listener should be type function');
+
+ var self = this;
+ this.on(eventName, once);
+ function once() {
+ listener.apply(self, arguments);
+ self.removeListener(eventName, once);
+ }
+ return this;
+ };
+
+ Nanobus.prototype.prependOnceListener = function (eventName, listener) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.prependOnceListener: eventName should be type string or symbol');
+ assert.equal(typeof listener, 'function', 'nanobus.prependOnceListener: listener should be type function');
+
+ var self = this;
+ this.prependListener(eventName, once);
+ function once() {
+ listener.apply(self, arguments);
+ self.removeListener(eventName, once);
+ }
+ return this;
+ };
+
+ Nanobus.prototype.removeListener = function (eventName, listener) {
+ assert.ok(typeof eventName === 'string' || typeof eventName === 'symbol', 'nanobus.removeListener: eventName should be type string or symbol');
+ assert.equal(typeof listener, 'function', 'nanobus.removeListener: listener should be type function');
+
+ if (eventName === '*') {
+ this._starListeners = this._starListeners.slice();
+ return remove(this._starListeners, listener);
+ } else {
+ if (typeof this._listeners[eventName] !== 'undefined') {
+ this._listeners[eventName] = this._listeners[eventName].slice();
}
-
- if (is_EOL(ch)) {
- readLineBreak(state);
-
- ch = state.input.charCodeAt(state.position);
- lineBreaks++;
- state.lineIndent = 0;
-
- while (ch === 0x20 /* Space */) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
+
+ return remove(this._listeners[eventName], listener);
+ }
+
+ function remove(arr, listener) {
+ if (!arr) return;
+ var index = arr.indexOf(listener);
+ if (index !== -1) {
+ splice(arr, index, 1);
+ return true;
}
- } else {
- break;
- }
- }
-
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
- throwWarning(state, 'deficient indentation');
- }
-
- return lineBreaks;
-}
-
-function testDocumentSeparator(state) {
- var _position = state.position,
- ch;
-
- ch = state.input.charCodeAt(_position);
-
- // Condition state.position === state.lineStart is tested
- // in parent on each call, for efficiency. No needs to test here again.
- if ((ch === 0x2D /* - */ || ch === 0x2E /* . */) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
-
- _position += 3;
-
- ch = state.input.charCodeAt(_position);
-
- if (ch === 0 || is_WS_OR_EOL(ch)) {
- return true;
}
- }
-
- return false;
-}
-
-function writeFoldedLines(state, count) {
- if (count === 1) {
- state.result += ' ';
- } else if (count > 1) {
- state.result += common.repeat('\n', count - 1);
- }
-}
-
-function readPlainScalar(state, nodeIndent, withinFlowCollection) {
- var preceding,
- following,
- captureStart,
- captureEnd,
- hasPendingContent,
- _line,
- _lineStart,
- _lineIndent,
- _kind = state.kind,
- _result = state.result,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 0x23 /* # */ || ch === 0x26 /* & */ || ch === 0x2A /* * */ || ch === 0x21 /* ! */ || ch === 0x7C /* | */ || ch === 0x3E /* > */ || ch === 0x27 /* ' */ || ch === 0x22 /* " */ || ch === 0x25 /* % */ || ch === 0x40 /* @ */ || ch === 0x60 /* ` */) {
- return false;
+ };
+
+ Nanobus.prototype.removeAllListeners = function (eventName) {
+ if (eventName) {
+ if (eventName === '*') {
+ this._starListeners = [];
+ } else {
+ this._listeners[eventName] = [];
+ }
+ } else {
+ this._starListeners = [];
+ this._listeners = {};
}
-
- if (ch === 0x3F /* ? */ || ch === 0x2D /* - */) {
- following = state.input.charCodeAt(state.position + 1);
-
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
- return false;
+ return this;
+ };
+
+ Nanobus.prototype.listeners = function (eventName) {
+ var listeners = eventName !== '*' ? this._listeners[eventName] : this._starListeners;
+
+ var ret = [];
+ if (listeners) {
+ var ilength = listeners.length;
+ for (var i = 0; i < ilength; i++) {
+ ret.push(listeners[i]);
}
}
-
- state.kind = 'scalar';
- state.result = '';
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
-
- while (ch !== 0) {
- if (ch === 0x3A /* : */) {
- following = state.input.charCodeAt(state.position + 1);
-
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
- break;
- }
- } else if (ch === 0x23 /* # */) {
- preceding = state.input.charCodeAt(state.position - 1);
-
- if (is_WS_OR_EOL(preceding)) {
- break;
- }
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
- break;
- } else if (is_EOL(ch)) {
- _line = state.line;
- _lineStart = state.lineStart;
- _lineIndent = state.lineIndent;
- skipSeparationSpace(state, false, -1);
-
- if (state.lineIndent >= nodeIndent) {
- hasPendingContent = true;
- ch = state.input.charCodeAt(state.position);
- continue;
+ return ret;
+ };
+
+ Nanobus.prototype._emit = function (arr, eventName, data, uuid) {
+ if (typeof arr === 'undefined') return;
+ if (arr.length === 0) return;
+ if (data === undefined) {
+ data = eventName;
+ eventName = null;
+ }
+
+ if (eventName) {
+ if (uuid !== undefined) {
+ data = [eventName].concat(data, uuid);
} else {
- state.position = captureEnd;
- state.line = _line;
- state.lineStart = _lineStart;
- state.lineIndent = _lineIndent;
- break;
+ data = [eventName].concat(data);
}
}
-
- if (hasPendingContent) {
- captureSegment(state, captureStart, captureEnd, false);
- writeFoldedLines(state, state.line - _line);
- captureStart = captureEnd = state.position;
- hasPendingContent = false;
+
+ var length = arr.length;
+ for (var i = 0; i < length; i++) {
+ var listener = arr[i];
+ listener.apply(listener, data);
}
-
- if (!is_WHITE_SPACE(ch)) {
- captureEnd = state.position + 1;
- }
-
- ch = state.input.charCodeAt(++state.position);
- }
-
- captureSegment(state, captureStart, captureEnd, false);
-
- if (state.result) {
- return true;
+ };
+ },{"assert":75,"nanotiming":92,"remove-array-items":110}],77:[function(require,module,exports){
+ var assert = require('assert');
+
+ var safeExternalLink = /(noopener|noreferrer) (noopener|noreferrer)/;
+ var protocolLink = /^[\w-_]+:/;
+
+ module.exports = href;
+
+ function href(cb, root) {
+ assert.notEqual(typeof window, 'undefined', 'nanohref: expected window to exist');
+
+ root = root || window.document;
+
+ assert.equal(typeof cb, 'function', 'nanohref: cb should be type function');
+ assert.equal(typeof root, 'object', 'nanohref: root should be type object');
+
+ window.addEventListener('click', function (e) {
+ if (e.button && e.button !== 0 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.defaultPrevented) return;
+
+ var anchor = function traverse(node) {
+ if (!node || node === root) return;
+ if (node.localName !== 'a' || node.href === undefined) {
+ return traverse(node.parentNode);
+ }
+ return node;
+ }(e.target);
+
+ if (!anchor) return;
+
+ if (window.location.protocol !== anchor.protocol || window.location.hostname !== anchor.hostname || window.location.port !== anchor.port || anchor.hasAttribute('data-nanohref-ignore') || anchor.hasAttribute('download') || anchor.getAttribute('target') === '_blank' && safeExternalLink.test(anchor.getAttribute('rel')) || protocolLink.test(anchor.getAttribute('href'))) return;
+
+ e.preventDefault();
+ cb(anchor);
+ });
}
-
- state.kind = _kind;
- state.result = _result;
- return false;
-}
-
-function readSingleQuotedScalar(state, nodeIndent) {
- var ch, captureStart, captureEnd;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch !== 0x27 /* ' */) {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
-
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- if (ch === 0x27 /* ' */) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
-
- if (ch === 0x27 /* ' */) {
- captureStart = state.position;
- state.position++;
- captureEnd = state.position;
- } else {
- return true;
+ },{"assert":75}],78:[function(require,module,exports){
+ 'use strict';
+
+ var trailingNewlineRegex = /\n[\s]+$/;
+ var leadingNewlineRegex = /^\n[\s]+/;
+ var trailingSpaceRegex = /[\s]+$/;
+ var leadingSpaceRegex = /^[\s]+/;
+ var multiSpaceRegex = /[\n\s]+/g;
+
+ var TEXT_TAGS = ['a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'data', 'dfn', 'em', 'i', 'kbd', 'mark', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'amp', 'small', 'span', 'strong', 'sub', 'sup', 'time', 'u', 'var', 'wbr'];
+
+ var VERBATIM_TAGS = ['code', 'pre', 'textarea'];
+
+ module.exports = function appendChild(el, childs) {
+ if (!Array.isArray(childs)) return;
+
+ var nodeName = el.nodeName.toLowerCase();
+
+ var hadText = false;
+ var value, leader;
+
+ for (var i = 0, len = childs.length; i < len; i++) {
+ var node = childs[i];
+ if (Array.isArray(node)) {
+ appendChild(el, node);
+ continue;
+ }
+
+ if (typeof node === 'number' || typeof node === 'boolean' || typeof node === 'function' || node instanceof Date || node instanceof RegExp) {
+ node = node.toString();
+ }
+
+ var lastChild = el.childNodes[el.childNodes.length - 1];
+
+ // Iterate over text nodes
+ if (typeof node === 'string') {
+ hadText = true;
+
+ // If we already had text, append to the existing text
+ if (lastChild && lastChild.nodeName === '#text') {
+ lastChild.nodeValue += node;
+
+ // We didn't have a text node yet, create one
+ } else {
+ node = el.ownerDocument.createTextNode(node);
+ el.appendChild(node);
+ lastChild = node;
}
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a single quoted scalar');
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a single quoted scalar');
-}
-
-function readDoubleQuotedScalar(state, nodeIndent) {
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch !== 0x22 /* " */) {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
- state.position++;
- captureStart = captureEnd = state.position;
-
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- if (ch === 0x22 /* " */) {
- captureSegment(state, captureStart, state.position, true);
- state.position++;
- return true;
- } else if (ch === 0x5C /* \ */) {
- captureSegment(state, captureStart, state.position, true);
- ch = state.input.charCodeAt(++state.position);
-
- if (is_EOL(ch)) {
- skipSeparationSpace(state, false, nodeIndent);
-
- // TODO: rework to inline fn with no type cast?
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
- state.result += simpleEscapeMap[ch];
- state.position++;
- } else if ((tmp = escapedHexLen(ch)) > 0) {
- hexLength = tmp;
- hexResult = 0;
-
- for (; hexLength > 0; hexLength--) {
- ch = state.input.charCodeAt(++state.position);
-
- if ((tmp = fromHexCode(ch)) >= 0) {
- hexResult = (hexResult << 4) + tmp;
+
+ // If this is the last of the child nodes, make sure we close it out
+ // right
+ if (i === len - 1) {
+ hadText = false;
+ // Trim the child text nodes if the current node isn't a
+ // node where whitespace matters.
+ if (TEXT_TAGS.indexOf(nodeName) === -1 && VERBATIM_TAGS.indexOf(nodeName) === -1) {
+ value = lastChild.nodeValue.replace(leadingNewlineRegex, '').replace(trailingSpaceRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
+ if (value === '') {
+ el.removeChild(lastChild);
} else {
- throwError(state, 'expected hexadecimal character');
+ lastChild.nodeValue = value;
}
+ } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
+ // The very first node in the list should not have leading
+ // whitespace. Sibling text nodes should have whitespace if there
+ // was any.
+ leader = i === 0 ? '' : ' ';
+ value = lastChild.nodeValue.replace(leadingNewlineRegex, leader).replace(leadingSpaceRegex, ' ').replace(trailingSpaceRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
+ lastChild.nodeValue = value;
}
-
- state.result += charFromCodepoint(hexResult);
-
- state.position++;
- } else {
- throwError(state, 'unknown escape sequence');
}
-
- captureStart = captureEnd = state.position;
- } else if (is_EOL(ch)) {
- captureSegment(state, captureStart, captureEnd, true);
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
- captureStart = captureEnd = state.position;
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
- throwError(state, 'unexpected end of the document within a double quoted scalar');
- } else {
- state.position++;
- captureEnd = state.position;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a double quoted scalar');
-}
-
-function readFlowCollection(state, nodeIndent) {
- var readNext = true,
- _line,
- _tag = state.tag,
- _result,
- _anchor = state.anchor,
- following,
- terminator,
- isPair,
- isExplicitPair,
- isMapping,
- overridableKeys = {},
- keyNode,
- keyTag,
- valueNode,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x5B /* [ */) {
- terminator = 0x5D; /* ] */
- isMapping = false;
- _result = [];
- } else if (ch === 0x7B /* { */) {
- terminator = 0x7D; /* } */
- isMapping = true;
- _result = {};
- } else {
- return false;
- }
-
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(++state.position);
-
- while (ch !== 0) {
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === terminator) {
- state.position++;
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = isMapping ? 'mapping' : 'sequence';
- state.result = _result;
- return true;
- } else if (!readNext) {
- throwError(state, 'missed comma between flow collection entries');
- }
-
- keyTag = keyNode = valueNode = null;
- isPair = isExplicitPair = false;
-
- if (ch === 0x3F /* ? */) {
- following = state.input.charCodeAt(state.position + 1);
-
- if (is_WS_OR_EOL(following)) {
- isPair = isExplicitPair = true;
- state.position++;
- skipSeparationSpace(state, true, nodeIndent);
+
+ // Iterate over DOM nodes
+ } else if (node && node.nodeType) {
+ // If the last node was a text node, make sure it is properly closed out
+ if (hadText) {
+ hadText = false;
+
+ // Trim the child text nodes if the current node isn't a
+ // text node or a code node
+ if (TEXT_TAGS.indexOf(nodeName) === -1 && VERBATIM_TAGS.indexOf(nodeName) === -1) {
+ value = lastChild.nodeValue.replace(leadingNewlineRegex, '').replace(trailingNewlineRegex, ' ').replace(multiSpaceRegex, ' ');
+
+ // Remove empty text nodes, append otherwise
+ if (value === '') {
+ el.removeChild(lastChild);
+ } else {
+ lastChild.nodeValue = value;
+ }
+ // Trim the child nodes but preserve the appropriate whitespace
+ } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
+ value = lastChild.nodeValue.replace(leadingSpaceRegex, ' ').replace(leadingNewlineRegex, '').replace(trailingNewlineRegex, ' ').replace(multiSpaceRegex, ' ');
+ lastChild.nodeValue = value;
+ }
}
+
+ // Store the last nodename
+ var _nodeName = node.nodeName;
+ if (_nodeName) nodeName = _nodeName.toLowerCase();
+
+ // Append the node to the DOM
+ el.appendChild(node);
}
-
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- keyTag = state.tag;
- keyNode = state.result;
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if ((isExplicitPair || state.line === _line) && ch === 0x3A /* : */) {
- isPair = true;
- ch = state.input.charCodeAt(++state.position);
- skipSeparationSpace(state, true, nodeIndent);
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
- valueNode = state.result;
- }
-
- if (isMapping) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
- } else if (isPair) {
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
- } else {
- _result.push(keyNode);
}
-
- skipSeparationSpace(state, true, nodeIndent);
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x2C /* , */) {
- readNext = true;
- ch = state.input.charCodeAt(++state.position);
- } else {
- readNext = false;
- }
- }
-
- throwError(state, 'unexpected end of the stream within a flow collection');
-}
-
-function readBlockScalar(state, nodeIndent) {
- var captureStart,
- folding,
- chomping = CHOMPING_CLIP,
- didReadContent = false,
- detectedIndent = false,
- textIndent = nodeIndent,
- emptyLines = 0,
- atMoreIndented = false,
- tmp,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch === 0x7C /* | */) {
- folding = false;
- } else if (ch === 0x3E /* > */) {
- folding = true;
- } else {
- return false;
- }
-
- state.kind = 'scalar';
- state.result = '';
-
- while (ch !== 0) {
- ch = state.input.charCodeAt(++state.position);
-
- if (ch === 0x2B /* + */ || ch === 0x2D /* - */) {
- if (CHOMPING_CLIP === chomping) {
- chomping = ch === 0x2B /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP;
+ };
+ },{}],79:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = ['async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defaultchecked', 'defer', 'disabled', 'formnovalidate', 'hidden', 'ismap', 'loop', 'multiple', 'muted', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected'];
+ },{}],80:[function(require,module,exports){
+ module.exports = require('./dom')(document);
+ },{"./dom":82}],81:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = ['indeterminate'];
+ },{}],82:[function(require,module,exports){
+ 'use strict';
+
+ var hyperx = require('hyperx');
+ var appendChild = require('./append-child');
+ var SVG_TAGS = require('./svg-tags');
+ var BOOL_PROPS = require('./bool-props');
+ // Props that need to be set directly rather than with el.setAttribute()
+ var DIRECT_PROPS = require('./direct-props');
+
+ var SVGNS = 'http://www.w3.org/2000/svg';
+ var XLINKNS = 'http://www.w3.org/1999/xlink';
+
+ var COMMENT_TAG = '!--';
+
+ module.exports = function (document) {
+ function nanoHtmlCreateElement(tag, props, children) {
+ var el;
+
+ // If an svg tag, it needs a namespace
+ if (SVG_TAGS.indexOf(tag) !== -1) {
+ props.namespace = SVGNS;
+ }
+
+ // If we are using a namespace
+ var ns = false;
+ if (props.namespace) {
+ ns = props.namespace;
+ delete props.namespace;
+ }
+
+ // If we are extending a builtin element
+ var isCustomElement = false;
+ if (props.is) {
+ isCustomElement = props.is;
+ delete props.is;
+ }
+
+ // Create the element
+ if (ns) {
+ if (isCustomElement) {
+ el = document.createElementNS(ns, tag, { is: isCustomElement });
} else {
- throwError(state, 'repeat of a chomping mode identifier');
+ el = document.createElementNS(ns, tag);
}
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
- if (tmp === 0) {
- throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
- } else if (!detectedIndent) {
- textIndent = nodeIndent + tmp - 1;
- detectedIndent = true;
+ } else if (tag === COMMENT_TAG) {
+ return document.createComment(props.comment);
+ } else if (isCustomElement) {
+ el = document.createElement(tag, { is: isCustomElement });
} else {
- throwError(state, 'repeat of an indentation width identifier');
- }
- } else {
- break;
- }
- }
-
- if (is_WHITE_SPACE(ch)) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (is_WHITE_SPACE(ch));
-
- if (ch === 0x23 /* # */) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (!is_EOL(ch) && ch !== 0);
+ el = document.createElement(tag);
}
- }
-
- while (ch !== 0) {
- readLineBreak(state);
- state.lineIndent = 0;
-
- ch = state.input.charCodeAt(state.position);
-
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 0x20 /* Space */) {
- state.lineIndent++;
- ch = state.input.charCodeAt(++state.position);
- }
-
- if (!detectedIndent && state.lineIndent > textIndent) {
- textIndent = state.lineIndent;
- }
-
- if (is_EOL(ch)) {
- emptyLines++;
- continue;
- }
-
- // End of the scalar.
- if (state.lineIndent < textIndent) {
-
- // Perform the chomping.
- if (chomping === CHOMPING_KEEP) {
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
- } else if (chomping === CHOMPING_CLIP) {
- if (didReadContent) {
- // i.e. only if the scalar is not empty.
- state.result += '\n';
+
+ // Create the properties
+ for (var p in props) {
+ if (props.hasOwnProperty(p)) {
+ var key = p.toLowerCase();
+ var val = props[p];
+ // Normalize className
+ if (key === 'classname') {
+ key = 'class';
+ p = 'class';
+ }
+ // The for attribute gets transformed to htmlFor, but we just set as for
+ if (p === 'htmlFor') {
+ p = 'for';
+ }
+ // If a property is boolean, set itself to the key
+ if (BOOL_PROPS.indexOf(key) !== -1) {
+ if (String(val) === 'true') val = key;else if (String(val) === 'false') continue;
+ }
+ // If a property prefers being set directly vs setAttribute
+ if (key.slice(0, 2) === 'on' || DIRECT_PROPS.indexOf(key) !== -1) {
+ el[p] = val;
+ } else {
+ if (ns) {
+ if (p === 'xlink:href') {
+ el.setAttributeNS(XLINKNS, p, val);
+ } else if (/^xmlns($|:)/i.test(p)) {
+ // skip xmlns definitions
+ } else {
+ el.setAttributeNS(null, p, val);
+ }
+ } else {
+ el.setAttribute(p, val);
+ }
+ }
}
}
-
- // Break this `while` cycle and go to the funciton's epilogue.
- break;
- }
-
- // Folded style: use fancy rules to handle line breaks.
- if (folding) {
-
- // Lines starting with white space characters (more-indented lines) are not folded.
- if (is_WHITE_SPACE(ch)) {
- atMoreIndented = true;
- // except for the first content line (cf. Example 8.1)
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
-
- // End of more-indented block.
- } else if (atMoreIndented) {
- atMoreIndented = false;
- state.result += common.repeat('\n', emptyLines + 1);
-
- // Just one line break - perceive as the same line.
- } else if (emptyLines === 0) {
- if (didReadContent) {
- // i.e. only if we have already read some scalar content.
- state.result += ' ';
+
+ appendChild(el, children);
+ return el;
+ }
+
+ function createFragment(nodes) {
+ var fragment = document.createDocumentFragment();
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i] == null) continue;
+ if (Array.isArray(nodes[i])) {
+ fragment.appendChild(createFragment(nodes[i]));
+ } else {
+ if (typeof nodes[i] === 'string') nodes[i] = document.createTextNode(nodes[i]);
+ fragment.appendChild(nodes[i]);
}
-
- // Several line breaks - perceive as different lines.
- } else {
- state.result += common.repeat('\n', emptyLines);
}
-
- // Literal style: just add exact number of line breaks between content lines.
- } else {
- // Keep all line breaks except the header line break.
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
- }
-
- didReadContent = true;
- detectedIndent = true;
- emptyLines = 0;
- captureStart = state.position;
-
- while (!is_EOL(ch) && ch !== 0) {
- ch = state.input.charCodeAt(++state.position);
+ return fragment;
}
-
- captureSegment(state, captureStart, state.position, false);
- }
-
- return true;
-}
-
-function readBlockSequence(state, nodeIndent) {
- var _line,
- _tag = state.tag,
- _anchor = state.anchor,
- _result = [],
- following,
- detected = false,
- ch;
-
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(state.position);
-
- while (ch !== 0) {
-
- if (ch !== 0x2D /* - */) {
- break;
- }
-
- following = state.input.charCodeAt(state.position + 1);
-
- if (!is_WS_OR_EOL(following)) {
- break;
+
+ var exports = hyperx(nanoHtmlCreateElement, {
+ comments: true,
+ createFragment: createFragment
+ });
+ exports.default = exports;
+ exports.createComment = nanoHtmlCreateElement;
+ return exports;
+ };
+ },{"./append-child":78,"./bool-props":79,"./direct-props":81,"./svg-tags":83,"hyperx":25}],83:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = ['svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'];
+ },{}],84:[function(require,module,exports){
+ module.exports = LRU;
+
+ function LRU(opts) {
+ if (!(this instanceof LRU)) return new LRU(opts);
+ if (typeof opts === 'number') opts = { max: opts };
+ if (!opts) opts = {};
+ this.cache = {};
+ this.head = this.tail = null;
+ this.length = 0;
+ this.max = opts.max || 1000;
+ this.maxAge = opts.maxAge || 0;
+ }
+
+ Object.defineProperty(LRU.prototype, 'keys', {
+ get: function () {
+ return Object.keys(this.cache);
}
-
- detected = true;
- state.position++;
-
- if (skipSeparationSpace(state, true, -1)) {
- if (state.lineIndent <= nodeIndent) {
- _result.push(null);
- ch = state.input.charCodeAt(state.position);
- continue;
+ });
+
+ LRU.prototype.clear = function () {
+ this.cache = {};
+ this.head = this.tail = null;
+ this.length = 0;
+ };
+
+ LRU.prototype.remove = function (key) {
+ if (typeof key !== 'string') key = '' + key;
+ if (!this.cache.hasOwnProperty(key)) return;
+
+ var element = this.cache[key];
+ delete this.cache[key];
+ this._unlink(key, element.prev, element.next);
+ return element.value;
+ };
+
+ LRU.prototype._unlink = function (key, prev, next) {
+ this.length--;
+
+ if (this.length === 0) {
+ this.head = this.tail = null;
+ } else {
+ if (this.head === key) {
+ this.head = prev;
+ this.cache[this.head].next = null;
+ } else if (this.tail === key) {
+ this.tail = next;
+ this.cache[this.tail].prev = null;
+ } else {
+ this.cache[prev].next = next;
+ this.cache[next].prev = prev;
}
}
-
- _line = state.line;
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
- _result.push(state.result);
- skipSeparationSpace(state, true, -1);
-
- ch = state.input.charCodeAt(state.position);
-
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
- throwError(state, 'bad indentation of a sequence entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
+ };
+
+ LRU.prototype.peek = function (key) {
+ if (!this.cache.hasOwnProperty(key)) return;
+
+ var element = this.cache[key];
+
+ if (!this._checkAge(key, element)) return;
+ return element.value;
+ };
+
+ LRU.prototype.set = function (key, value) {
+ if (typeof key !== 'string') key = '' + key;
+
+ var element;
+
+ if (this.cache.hasOwnProperty(key)) {
+ element = this.cache[key];
+ element.value = value;
+ if (this.maxAge) element.modified = Date.now();
+
+ // If it's already the head, there's nothing more to do:
+ if (key === this.head) return value;
+ this._unlink(key, element.prev, element.next);
+ } else {
+ element = { value: value, modified: 0, next: null, prev: null };
+ if (this.maxAge) element.modified = Date.now();
+ this.cache[key] = element;
+
+ // Eviction is only possible if the key didn't already exist:
+ if (this.length === this.max) this.evict();
+ }
+
+ this.length++;
+ element.next = null;
+ element.prev = this.head;
+
+ if (this.head) this.cache[this.head].next = key;
+ this.head = key;
+
+ if (!this.tail) this.tail = key;
+ return value;
+ };
+
+ LRU.prototype._checkAge = function (key, element) {
+ if (this.maxAge && Date.now() - element.modified > this.maxAge) {
+ this.remove(key);
+ return false;
}
- }
-
- if (detected) {
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = 'sequence';
- state.result = _result;
return true;
- }
- return false;
-}
-
-function readBlockMapping(state, nodeIndent, flowIndent) {
- var following,
- allowCompact,
- _line,
- _pos,
- _tag = state.tag,
- _anchor = state.anchor,
- _result = {},
- overridableKeys = {},
- keyTag = null,
- keyNode = null,
- valueNode = null,
- atExplicitKey = false,
- detected = false,
- ch;
-
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = _result;
- }
-
- ch = state.input.charCodeAt(state.position);
-
- while (ch !== 0) {
- following = state.input.charCodeAt(state.position + 1);
- _line = state.line; // Save the current line.
- _pos = state.position;
-
- //
- // Explicit notation case. There are two separate blocks:
- // first for the key (denoted by "?") and second for the value (denoted by ":")
- //
- if ((ch === 0x3F /* ? */ || ch === 0x3A /* : */) && is_WS_OR_EOL(following)) {
-
- if (ch === 0x3F /* ? */) {
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
-
- detected = true;
- atExplicitKey = true;
- allowCompact = true;
- } else if (atExplicitKey) {
- // i.e. 0x3A/* : */ === character after the explicit key.
- atExplicitKey = false;
- allowCompact = true;
+ };
+
+ LRU.prototype.get = function (key) {
+ if (typeof key !== 'string') key = '' + key;
+ if (!this.cache.hasOwnProperty(key)) return;
+
+ var element = this.cache[key];
+
+ if (!this._checkAge(key, element)) return;
+
+ if (this.head !== key) {
+ if (key === this.tail) {
+ this.tail = element.next;
+ this.cache[this.tail].prev = null;
} else {
- throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
+ // Set prev.next -> element.next:
+ this.cache[element.prev].next = element.next;
}
-
- state.position += 1;
- ch = following;
-
- //
- // Implicit notation case. Flow-style node as the key first, then ":", and the value.
- //
- } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
-
- if (state.line === _line) {
- ch = state.input.charCodeAt(state.position);
-
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
+
+ // Set element.next.prev -> element.prev:
+ this.cache[element.next].prev = element.prev;
+
+ // Element is the new head
+ this.cache[this.head].next = key;
+ element.prev = this.head;
+ element.next = null;
+ this.head = key;
+ }
+
+ return element.value;
+ };
+
+ LRU.prototype.evict = function () {
+ if (!this.tail) return;
+ this.remove(this.tail);
+ };
+ },{}],85:[function(require,module,exports){
+ var assert = require('nanoassert');
+ var morph = require('./lib/morph');
+
+ var TEXT_NODE = 3;
+ // var DEBUG = false
+
+ module.exports = nanomorph;
+
+ // Morph one tree into another tree
+ //
+ // no parent
+ // -> same: diff and walk children
+ // -> not same: replace and return
+ // old node doesn't exist
+ // -> insert new node
+ // new node doesn't exist
+ // -> delete old node
+ // nodes are not the same
+ // -> diff nodes and apply patch to old node
+ // nodes are the same
+ // -> walk all child nodes and append to old node
+ function nanomorph(oldTree, newTree, options) {
+ // if (DEBUG) {
+ // console.log(
+ // 'nanomorph\nold\n %s\nnew\n %s',
+ // oldTree && oldTree.outerHTML,
+ // newTree && newTree.outerHTML
+ // )
+ // }
+ assert.equal(typeof oldTree, 'object', 'nanomorph: oldTree should be an object');
+ assert.equal(typeof newTree, 'object', 'nanomorph: newTree should be an object');
+
+ if (options && options.childrenOnly) {
+ updateChildren(newTree, oldTree);
+ return oldTree;
+ }
+
+ assert.notEqual(newTree.nodeType, 11, 'nanomorph: newTree should have one root node (which is not a DocumentFragment)');
+
+ return walk(newTree, oldTree);
+ }
+
+ // Walk and morph a dom tree
+ function walk(newNode, oldNode) {
+ // if (DEBUG) {
+ // console.log(
+ // 'walk\nold\n %s\nnew\n %s',
+ // oldNode && oldNode.outerHTML,
+ // newNode && newNode.outerHTML
+ // )
+ // }
+ if (!oldNode) {
+ return newNode;
+ } else if (!newNode) {
+ return null;
+ } else if (newNode.isSameNode && newNode.isSameNode(oldNode)) {
+ return oldNode;
+ } else if (newNode.tagName !== oldNode.tagName || getComponentId(newNode) !== getComponentId(oldNode)) {
+ return newNode;
+ } else {
+ morph(newNode, oldNode);
+ updateChildren(newNode, oldNode);
+ return oldNode;
+ }
+ }
+
+ function getComponentId(node) {
+ return node.dataset ? node.dataset.nanomorphComponentId : undefined;
+ }
+
+ // Update the children of elements
+ // (obj, obj) -> null
+ function updateChildren(newNode, oldNode) {
+ // if (DEBUG) {
+ // console.log(
+ // 'updateChildren\nold\n %s\nnew\n %s',
+ // oldNode && oldNode.outerHTML,
+ // newNode && newNode.outerHTML
+ // )
+ // }
+ var oldChild, newChild, morphed, oldMatch;
+
+ // The offset is only ever increased, and used for [i - offset] in the loop
+ var offset = 0;
+
+ for (var i = 0;; i++) {
+ oldChild = oldNode.childNodes[i];
+ newChild = newNode.childNodes[i - offset];
+ // if (DEBUG) {
+ // console.log(
+ // '===\n- old\n %s\n- new\n %s',
+ // oldChild && oldChild.outerHTML,
+ // newChild && newChild.outerHTML
+ // )
+ // }
+ // Both nodes are empty, do nothing
+ if (!oldChild && !newChild) {
+ break;
+
+ // There is no new child, remove old
+ } else if (!newChild) {
+ oldNode.removeChild(oldChild);
+ i--;
+
+ // There is no old child, add new
+ } else if (!oldChild) {
+ oldNode.appendChild(newChild);
+ offset++;
+
+ // Both nodes are the same, morph
+ } else if (same(newChild, oldChild)) {
+ morphed = walk(newChild, oldChild);
+ if (morphed !== oldChild) {
+ oldNode.replaceChild(morphed, oldChild);
+ offset++;
}
-
- if (ch === 0x3A /* : */) {
- ch = state.input.charCodeAt(++state.position);
-
- if (!is_WS_OR_EOL(ch)) {
- throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
- }
-
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- keyTag = keyNode = valueNode = null;
- }
-
- detected = true;
- atExplicitKey = false;
- allowCompact = false;
- keyTag = state.tag;
- keyNode = state.result;
- } else if (detected) {
- throwError(state, 'can not read an implicit mapping pair; a colon is missed');
+
+ // Both nodes do not share an ID or a placeholder, try reorder
+ } else {
+ oldMatch = null;
+
+ // Try and find a similar node somewhere in the tree
+ for (var j = i; j < oldNode.childNodes.length; j++) {
+ if (same(oldNode.childNodes[j], newChild)) {
+ oldMatch = oldNode.childNodes[j];
+ break;
+ }
+ }
+
+ // If there was a node with the same ID or placeholder in the old list
+ if (oldMatch) {
+ morphed = walk(newChild, oldMatch);
+ if (morphed !== oldMatch) offset++;
+ oldNode.insertBefore(morphed, oldChild);
+
+ // It's safe to morph two nodes in-place if neither has an ID
+ } else if (!newChild.id && !oldChild.id) {
+ morphed = walk(newChild, oldChild);
+ if (morphed !== oldChild) {
+ oldNode.replaceChild(morphed, oldChild);
+ offset++;
+ }
+
+ // Insert the node at the index if we couldn't morph or find a matching node
} else {
- state.tag = _tag;
- state.anchor = _anchor;
- return true; // Keep the result of `composeNode`.
+ oldNode.insertBefore(newChild, oldChild);
+ offset++;
}
- } else if (detected) {
- throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
- } else {
- state.tag = _tag;
- state.anchor = _anchor;
- return true; // Keep the result of `composeNode`.
}
- } else {
- break; // Reading is done. Go to the epilogue.
+ }
+ }
+
+ function same(a, b) {
+ if (a.id) return a.id === b.id;
+ if (a.isSameNode) return a.isSameNode(b);
+ if (a.tagName !== b.tagName) return false;
+ if (a.type === TEXT_NODE) return a.nodeValue === b.nodeValue;
+ return false;
+ }
+ },{"./lib/morph":87,"nanoassert":75}],86:[function(require,module,exports){
+ module.exports = [
+ // attribute events (can be set with attributes)
+ 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onmouseenter', 'onmouseleave', 'ontouchcancel', 'ontouchend', 'ontouchmove', 'ontouchstart', 'ondragstart', 'ondrag', 'ondragenter', 'ondragleave', 'ondragover', 'ondrop', 'ondragend', 'onkeydown', 'onkeypress', 'onkeyup', 'onunload', 'onabort', 'onerror', 'onresize', 'onscroll', 'onselect', 'onchange', 'onsubmit', 'onreset', 'onfocus', 'onblur', 'oninput', 'onanimationend', 'onanimationiteration', 'onanimationstart',
+ // other common events
+ 'oncontextmenu', 'onfocusin', 'onfocusout'];
+ },{}],87:[function(require,module,exports){
+ var events = require('./events');
+ var eventsLength = events.length;
+
+ var ELEMENT_NODE = 1;
+ var TEXT_NODE = 3;
+ var COMMENT_NODE = 8;
+
+ module.exports = morph;
+
+ // diff elements and apply the resulting patch to the old node
+ // (obj, obj) -> null
+ function morph(newNode, oldNode) {
+ var nodeType = newNode.nodeType;
+ var nodeName = newNode.nodeName;
+
+ if (nodeType === ELEMENT_NODE) {
+ copyAttrs(newNode, oldNode);
+ }
+
+ if (nodeType === TEXT_NODE || nodeType === COMMENT_NODE) {
+ if (oldNode.nodeValue !== newNode.nodeValue) {
+ oldNode.nodeValue = newNode.nodeValue;
+ }
+ }
+
+ // Some DOM nodes are weird
+ // https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js
+ if (nodeName === 'INPUT') updateInput(newNode, oldNode);else if (nodeName === 'OPTION') updateOption(newNode, oldNode);else if (nodeName === 'TEXTAREA') updateTextarea(newNode, oldNode);
+
+ copyEvents(newNode, oldNode);
+ }
+
+ function copyAttrs(newNode, oldNode) {
+ var oldAttrs = oldNode.attributes;
+ var newAttrs = newNode.attributes;
+ var attrNamespaceURI = null;
+ var attrValue = null;
+ var fromValue = null;
+ var attrName = null;
+ var attr = null;
+
+ for (var i = newAttrs.length - 1; i >= 0; --i) {
+ attr = newAttrs[i];
+ attrName = attr.name;
+ attrNamespaceURI = attr.namespaceURI;
+ attrValue = attr.value;
+ if (attrNamespaceURI) {
+ attrName = attr.localName || attrName;
+ fromValue = oldNode.getAttributeNS(attrNamespaceURI, attrName);
+ if (fromValue !== attrValue) {
+ oldNode.setAttributeNS(attrNamespaceURI, attrName, attrValue);
+ }
+ } else {
+ if (!oldNode.hasAttribute(attrName)) {
+ oldNode.setAttribute(attrName, attrValue);
+ } else {
+ fromValue = oldNode.getAttribute(attrName);
+ if (fromValue !== attrValue) {
+ // apparently values are always cast to strings, ah well
+ if (attrValue === 'null' || attrValue === 'undefined') {
+ oldNode.removeAttribute(attrName);
+ } else {
+ oldNode.setAttribute(attrName, attrValue);
+ }
+ }
+ }
}
-
- //
- // Common reading code for both explicit and implicit notations.
- //
- if (state.line === _line || state.lineIndent > nodeIndent) {
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
- if (atExplicitKey) {
- keyNode = state.result;
+ }
+
+ // Remove any extra attributes found on the original DOM element that
+ // weren't found on the target element.
+ for (var j = oldAttrs.length - 1; j >= 0; --j) {
+ attr = oldAttrs[j];
+ if (attr.specified !== false) {
+ attrName = attr.name;
+ attrNamespaceURI = attr.namespaceURI;
+
+ if (attrNamespaceURI) {
+ attrName = attr.localName || attrName;
+ if (!newNode.hasAttributeNS(attrNamespaceURI, attrName)) {
+ oldNode.removeAttributeNS(attrNamespaceURI, attrName);
+ }
} else {
- valueNode = state.result;
+ if (!newNode.hasAttributeNS(null, attrName)) {
+ oldNode.removeAttribute(attrName);
+ }
}
}
-
- if (!atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
- keyTag = keyNode = valueNode = null;
+ }
+ }
+
+ function copyEvents(newNode, oldNode) {
+ for (var i = 0; i < eventsLength; i++) {
+ var ev = events[i];
+ if (newNode[ev]) {
+ // if new element has a whitelisted attribute
+ oldNode[ev] = newNode[ev]; // update existing element
+ } else if (oldNode[ev]) {
+ // if existing element has it and new one doesnt
+ oldNode[ev] = undefined; // remove it from existing element
}
-
- skipSeparationSpace(state, true, -1);
- ch = state.input.charCodeAt(state.position);
}
-
- if (state.lineIndent > nodeIndent && ch !== 0) {
- throwError(state, 'bad indentation of a mapping entry');
- } else if (state.lineIndent < nodeIndent) {
- break;
+ }
+
+ function updateOption(newNode, oldNode) {
+ updateAttribute(newNode, oldNode, 'selected');
+ }
+
+ // The "value" attribute is special for the element since it sets the
+ // initial value. Changing the "value" attribute without changing the "value"
+ // property will have no effect since it is only used to the set the initial
+ // value. Similar for the "checked" attribute, and "disabled".
+ function updateInput(newNode, oldNode) {
+ var newValue = newNode.value;
+ var oldValue = oldNode.value;
+
+ updateAttribute(newNode, oldNode, 'checked');
+ updateAttribute(newNode, oldNode, 'disabled');
+
+ // The "indeterminate" property can not be set using an HTML attribute.
+ // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
+ if (newNode.indeterminate !== oldNode.indeterminate) {
+ oldNode.indeterminate = newNode.indeterminate;
+ }
+
+ // Persist file value since file inputs can't be changed programatically
+ if (oldNode.type === 'file') return;
+
+ if (newValue !== oldValue) {
+ oldNode.setAttribute('value', newValue);
+ oldNode.value = newValue;
+ }
+
+ if (newValue === 'null') {
+ oldNode.value = '';
+ oldNode.removeAttribute('value');
+ }
+
+ if (!newNode.hasAttributeNS(null, 'value')) {
+ oldNode.removeAttribute('value');
+ } else if (oldNode.type === 'range') {
+ // this is so elements like slider move their UI thingy
+ oldNode.value = newValue;
+ }
+ }
+
+ function updateTextarea(newNode, oldNode) {
+ var newValue = newNode.value;
+ if (newValue !== oldNode.value) {
+ oldNode.value = newValue;
+ }
+
+ if (oldNode.firstChild && oldNode.firstChild.nodeValue !== newValue) {
+ // Needed for IE. Apparently IE sets the placeholder as the
+ // node value and vise versa. This ignores an empty update.
+ if (newValue === '' && oldNode.firstChild.nodeValue === oldNode.placeholder) {
+ return;
+ }
+
+ oldNode.firstChild.nodeValue = newValue;
}
}
-
- //
- // Epilogue.
- //
-
- // Special case: last mapping's node contains only the key in explicit notation.
- if (atExplicitKey) {
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
- }
-
- // Expose the resulting mapping.
- if (detected) {
- state.tag = _tag;
- state.anchor = _anchor;
- state.kind = 'mapping';
- state.result = _result;
+
+ function updateAttribute(newNode, oldNode, name) {
+ if (newNode[name] !== oldNode[name]) {
+ oldNode[name] = newNode[name];
+ if (newNode[name]) {
+ oldNode.setAttribute(name, '');
+ } else {
+ oldNode.removeAttribute(name);
+ }
+ }
}
-
- return detected;
-}
-
-function readTagProperty(state) {
- var _position,
- isVerbatim = false,
- isNamed = false,
- tagHandle,
- tagName,
- ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch !== 0x21 /* ! */) return false;
-
- if (state.tag !== null) {
- throwError(state, 'duplication of a tag property');
- }
-
- ch = state.input.charCodeAt(++state.position);
-
- if (ch === 0x3C /* < */) {
- isVerbatim = true;
- ch = state.input.charCodeAt(++state.position);
- } else if (ch === 0x21 /* ! */) {
- isNamed = true;
- tagHandle = '!!';
- ch = state.input.charCodeAt(++state.position);
- } else {
- tagHandle = '!';
+ },{"./events":86}],88:[function(require,module,exports){
+ var reg = /([^?=&]+)(=([^&]*))?/g;
+ var assert = require('assert');
+
+ module.exports = qs;
+
+ function qs(url) {
+ assert.equal(typeof url, 'string', 'nanoquery: url should be type string');
+
+ var obj = {};
+ url.replace(/^.*\?/, '').replace(reg, function (a0, a1, a2, a3) {
+ var value = decodeURIComponent(a3);
+ var key = decodeURIComponent(a1);
+ if (obj.hasOwnProperty(key)) {
+ if (Array.isArray(obj[key])) obj[key].push(value);else obj[key] = [obj[key], value];
+ } else {
+ obj[key] = value;
+ }
+ });
+
+ return obj;
}
-
- _position = state.position;
-
- if (isVerbatim) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (ch !== 0 && ch !== 0x3E /* > */);
-
- if (state.position < state.length) {
- tagName = state.input.slice(_position, state.position);
- ch = state.input.charCodeAt(++state.position);
+ },{"assert":75}],89:[function(require,module,exports){
+ 'use strict';
+
+ var assert = require('assert');
+
+ module.exports = nanoraf;
+
+ // Only call RAF when needed
+ // (fn, fn?) -> fn
+ function nanoraf(render, raf) {
+ assert.equal(typeof render, 'function', 'nanoraf: render should be a function');
+ assert.ok(typeof raf === 'function' || typeof raf === 'undefined', 'nanoraf: raf should be a function or undefined');
+
+ if (!raf) raf = window.requestAnimationFrame;
+ var redrawScheduled = false;
+ var args = null;
+
+ return function frame() {
+ if (args === null && !redrawScheduled) {
+ redrawScheduled = true;
+
+ raf(function redraw() {
+ redrawScheduled = false;
+
+ var length = args.length;
+ var _args = new Array(length);
+ for (var i = 0; i < length; i++) {
+ _args[i] = args[i];
+ }render.apply(render, _args);
+ args = null;
+ });
+ }
+
+ args = arguments;
+ };
+ }
+ },{"assert":75}],90:[function(require,module,exports){
+ var assert = require('assert');
+ var wayfarer = require('wayfarer');
+
+ // electron support
+ var isLocalFile = /file:\/\//.test(typeof window === 'object' && window.location && window.location.origin);
+
+ /* eslint-disable no-useless-escape */
+ var electron = '^(file:\/\/|\/)(.*\.html?\/?)?';
+ var protocol = '^(http(s)?(:\/\/))?(www\.)?';
+ var domain = '[a-zA-Z0-9-_\.]+(:[0-9]{1,5})?(\/{1})?';
+ var qs = '[\?].*$';
+ /* eslint-enable no-useless-escape */
+
+ var stripElectron = new RegExp(electron);
+ var prefix = new RegExp(protocol + domain);
+ var normalize = new RegExp('#');
+ var suffix = new RegExp(qs);
+
+ module.exports = Nanorouter;
+
+ function Nanorouter(opts) {
+ if (!(this instanceof Nanorouter)) return new Nanorouter(opts);
+ opts = opts || {};
+ this.router = wayfarer(opts.default || '/404');
+ }
+
+ Nanorouter.prototype.on = function (routename, listener) {
+ assert.equal(typeof routename, 'string');
+ routename = routename.replace(/^[#/]/, '');
+ this.router.on(routename, listener);
+ };
+
+ Nanorouter.prototype.emit = function (routename) {
+ assert.equal(typeof routename, 'string');
+ routename = pathname(routename, isLocalFile);
+ return this.router.emit(routename);
+ };
+
+ Nanorouter.prototype.match = function (routename) {
+ assert.equal(typeof routename, 'string');
+ routename = pathname(routename, isLocalFile);
+ return this.router.match(routename);
+ };
+
+ // replace everything in a route but the pathname and hash
+ function pathname(routename, isElectron) {
+ if (isElectron) routename = routename.replace(stripElectron, '');else routename = routename.replace(prefix, '');
+ return decodeURI(routename.replace(suffix, '').replace(normalize, '/'));
+ }
+ },{"assert":75,"wayfarer":127}],91:[function(require,module,exports){
+ var assert = require('assert');
+
+ var hasWindow = typeof window !== 'undefined';
+
+ function createScheduler() {
+ var scheduler;
+ if (hasWindow) {
+ if (!window._nanoScheduler) window._nanoScheduler = new NanoScheduler(true);
+ scheduler = window._nanoScheduler;
} else {
- throwError(state, 'unexpected end of the stream within a verbatim tag');
- }
- } else {
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
-
- if (ch === 0x21 /* ! */) {
- if (!isNamed) {
- tagHandle = state.input.slice(_position - 1, state.position + 1);
-
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
- throwError(state, 'named tag handle cannot contain such characters');
- }
-
- isNamed = true;
- _position = state.position + 1;
- } else {
- throwError(state, 'tag suffix cannot contain exclamation marks');
- }
+ scheduler = new NanoScheduler();
+ }
+ return scheduler;
+ }
+
+ function NanoScheduler(hasWindow) {
+ this.hasWindow = hasWindow;
+ this.hasIdle = this.hasWindow && window.requestIdleCallback;
+ this.method = this.hasIdle ? window.requestIdleCallback.bind(window) : this.setTimeout;
+ this.scheduled = false;
+ this.queue = [];
+ }
+
+ NanoScheduler.prototype.push = function (cb) {
+ assert.equal(typeof cb, 'function', 'nanoscheduler.push: cb should be type function');
+
+ this.queue.push(cb);
+ this.schedule();
+ };
+
+ NanoScheduler.prototype.schedule = function () {
+ if (this.scheduled) return;
+
+ this.scheduled = true;
+ var self = this;
+ this.method(function (idleDeadline) {
+ var cb;
+ while (self.queue.length && idleDeadline.timeRemaining() > 0) {
+ cb = self.queue.shift();
+ cb(idleDeadline);
+ }
+ self.scheduled = false;
+ if (self.queue.length) self.schedule();
+ });
+ };
+
+ NanoScheduler.prototype.setTimeout = function (cb) {
+ setTimeout(cb, 0, {
+ timeRemaining: function () {
+ return 1;
+ }
+ });
+ };
+
+ module.exports = createScheduler;
+ },{"assert":75}],92:[function(require,module,exports){
+ var scheduler = require('nanoscheduler')();
+ var assert = require('assert');
+
+ var perf;
+ nanotiming.disabled = true;
+ try {
+ perf = window.performance;
+ nanotiming.disabled = window.localStorage.DISABLE_NANOTIMING === 'true' || !perf.mark;
+ } catch (e) {}
+
+ module.exports = nanotiming;
+
+ function nanotiming(name) {
+ assert.equal(typeof name, 'string', 'nanotiming: name should be type string');
+
+ if (nanotiming.disabled) return noop;
+
+ var uuid = (perf.now() * 10000).toFixed() % Number.MAX_SAFE_INTEGER;
+ var startName = 'start-' + uuid + '-' + name;
+ perf.mark(startName);
+
+ function end(cb) {
+ var endName = 'end-' + uuid + '-' + name;
+ perf.mark(endName);
+
+ scheduler.push(function () {
+ var err = null;
+ try {
+ var measureName = name + ' [' + uuid + ']';
+ perf.measure(measureName, startName, endName);
+ perf.clearMarks(startName);
+ perf.clearMarks(endName);
+ } catch (e) {
+ err = e;
}
-
- ch = state.input.charCodeAt(++state.position);
+ if (cb) cb(err, name);
+ });
}
-
- tagName = state.input.slice(_position, state.position);
-
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
- throwError(state, 'tag suffix cannot contain flow indicator characters');
- }
- }
-
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
- throwError(state, 'tag name cannot contain such characters: ' + tagName);
- }
-
- if (isVerbatim) {
- state.tag = tagName;
- } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
- state.tag = state.tagMap[tagHandle] + tagName;
- } else if (tagHandle === '!') {
- state.tag = '!' + tagName;
- } else if (tagHandle === '!!') {
- state.tag = 'tag:yaml.org,2002:' + tagName;
- } else {
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
- }
-
- return true;
-}
-
-function readAnchorProperty(state) {
- var _position, ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch !== 0x26 /* & */) return false;
-
- if (state.anchor !== null) {
- throwError(state, 'duplication of an anchor property');
- }
-
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
+
+ end.uuid = uuid;
+ return end;
}
-
- if (state.position === _position) {
- throwError(state, 'name of an anchor node must contain at least one character');
- }
-
- state.anchor = state.input.slice(_position, state.position);
- return true;
-}
-
-function readAlias(state) {
- var _position, alias, ch;
-
- ch = state.input.charCodeAt(state.position);
-
- if (ch !== 0x2A /* * */) return false;
-
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
- ch = state.input.charCodeAt(++state.position);
+
+ function noop(cb) {
+ if (cb) {
+ scheduler.push(function () {
+ cb(new Error('nanotiming: performance API unavailable'));
+ });
+ }
}
-
- if (state.position === _position) {
- throwError(state, 'name of an alias node must contain at least one character');
- }
-
- alias = state.input.slice(_position, state.position);
-
- if (!_hasOwnProperty.call(state.anchorMap, alias)) {
- throwError(state, 'unidentified alias "' + alias + '"');
- }
-
- state.result = state.anchorMap[alias];
- skipSeparationSpace(state, true, -1);
- return true;
-}
-
-function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
- var allowBlockStyles,
- allowBlockScalars,
- allowBlockCollections,
- indentStatus = 1,
- // 1: this>parent, 0: this=parent, -1: this parentIndent) {
- indentStatus = 1;
- } else if (state.lineIndent === parentIndent) {
- indentStatus = 0;
- } else if (state.lineIndent < parentIndent) {
- indentStatus = -1;
- }
- }
- }
-
- if (indentStatus === 1) {
- while (readTagProperty(state) || readAnchorProperty(state)) {
- if (skipSeparationSpace(state, true, -1)) {
- atNewLine = true;
- allowBlockCollections = allowBlockStyles;
-
- if (state.lineIndent > parentIndent) {
- indentStatus = 1;
- } else if (state.lineIndent === parentIndent) {
- indentStatus = 0;
- } else if (state.lineIndent < parentIndent) {
- indentStatus = -1;
- }
- } else {
- allowBlockCollections = false;
+ },{"assert":75,"nanoscheduler":91}],93:[function(require,module,exports){
+ /*
+ object-assign
+ (c) Sindre Sorhus
+ @license MIT
+ */
+
+ 'use strict';
+ /* eslint-disable no-unused-vars */
+
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
+ 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 no-new-wrappers
+ 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 (err) {
+ // We don't expect any of the above to throw, but better to be safe.
+ return false;
}
}
-
- if (allowBlockCollections) {
- allowBlockCollections = atNewLine || allowCompact;
- }
-
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
- flowIndent = parentIndent;
- } else {
- flowIndent = parentIndent + 1;
- }
-
- blockIndent = state.position - state.lineStart;
-
- if (indentStatus === 1) {
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
- hasContent = true;
- } else {
- if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
- hasContent = true;
- } else if (readAlias(state)) {
- hasContent = true;
-
- if (state.tag !== null || state.anchor !== null) {
- throwError(state, 'alias node should not have any properties');
- }
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
- hasContent = true;
-
- if (state.tag === null) {
- state.tag = '?';
- }
+
+ module.exports = shouldUseNative() ? Object.assign : function (target, source) {
+ var from;
+ var to = toObject(target);
+ var symbols;
+
+ for (var s = 1; s < arguments.length; s++) {
+ from = Object(arguments[s]);
+
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ to[key] = from[key];
}
-
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
+ }
+
+ if (getOwnPropertySymbols) {
+ symbols = getOwnPropertySymbols(from);
+ for (var i = 0; i < symbols.length; i++) {
+ if (propIsEnumerable.call(from, symbols[i])) {
+ to[symbols[i]] = from[symbols[i]];
+ }
}
}
- } else if (indentStatus === 0) {
- // Special case: block sequences are allowed to have same indentation level as the parent.
- // http://www.yaml.org/spec/1.2/spec.html#id2799784
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
}
- }
-
- if (state.tag !== null && state.tag !== '!') {
- if (state.tag === '?') {
- // Implicit resolving is not allowed for non-scalar types, and '?'
- // non-specific tag is only automatically assigned to plain scalars.
- //
- // We only need to check kind conformity in case user explicitly assigns '?'
- // tag, for example like this: "!> [0]"
- //
- if (state.result !== null && state.kind !== 'scalar') {
- throwError(state, 'unacceptable node kind for !> tag; it should be "scalar", not "' + state.kind + '"');
- }
-
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
- type = state.implicitTypes[typeIndex];
-
- if (type.resolve(state.result)) {
- // `state.result` updated in resolver if matched
- state.result = type.construct(state.result);
- state.tag = type.tag;
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
+
+ return to;
+ };
+ },{}],94:[function(require,module,exports){
+ 'use strict';
+
+ var keysShim;
+ if (!Object.keys) {
+ // modified from https://github.com/es-shims/es5-shim
+ var has = Object.prototype.hasOwnProperty;
+ var toStr = Object.prototype.toString;
+ var isArgs = require('./isArguments'); // eslint-disable-line global-require
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
+ var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
+ var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
+ var dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'];
+ var equalsConstructorPrototype = function (o) {
+ var ctor = o.constructor;
+ return ctor && ctor.prototype === o;
+ };
+ var excludedKeys = {
+ $applicationCache: true,
+ $console: true,
+ $external: true,
+ $frame: true,
+ $frameElement: true,
+ $frames: true,
+ $innerHeight: true,
+ $innerWidth: true,
+ $onmozfullscreenchange: true,
+ $onmozfullscreenerror: true,
+ $outerHeight: true,
+ $outerWidth: true,
+ $pageXOffset: true,
+ $pageYOffset: true,
+ $parent: true,
+ $scrollLeft: true,
+ $scrollTop: true,
+ $scrollX: true,
+ $scrollY: true,
+ $self: true,
+ $webkitIndexedDB: true,
+ $webkitStorageInfo: true,
+ $window: true
+ };
+ var hasAutomationEqualityBug = function () {
+ /* global window */
+ if (typeof window === 'undefined') {
+ return false;
+ }
+ for (var k in window) {
+ try {
+ if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
+ try {
+ equalsConstructorPrototype(window[k]);
+ } catch (e) {
+ return true;
+ }
}
- break;
+ } catch (e) {
+ return true;
}
}
- } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
- type = state.typeMap[state.kind || 'fallback'][state.tag];
-
- if (state.result !== null && type.kind !== state.kind) {
- throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
+ return false;
+ }();
+ var equalsConstructorPrototypeIfNotBuggy = function (o) {
+ /* global window */
+ if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
+ return equalsConstructorPrototype(o);
}
-
- if (!type.resolve(state.result)) {
- // `state.result` updated in resolver if matched
- throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
- } else {
- state.result = type.construct(state.result);
- if (state.anchor !== null) {
- state.anchorMap[state.anchor] = state.result;
- }
+ try {
+ return equalsConstructorPrototype(o);
+ } catch (e) {
+ return false;
}
- } else {
- throwError(state, 'unknown tag !<' + state.tag + '>');
- }
- }
-
- if (state.listener !== null) {
- state.listener('close', state);
- }
- return state.tag !== null || state.anchor !== null || hasContent;
-}
-
-function readDocument(state) {
- var documentStart = state.position,
- _position,
- directiveName,
- directiveArgs,
- hasDirectives = false,
- ch;
-
- state.version = null;
- state.checkLineBreaks = state.legacy;
- state.tagMap = {};
- state.anchorMap = {};
-
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
- skipSeparationSpace(state, true, -1);
-
- ch = state.input.charCodeAt(state.position);
-
- if (state.lineIndent > 0 || ch !== 0x25 /* % */) {
- break;
+ };
+
+ keysShim = function keys(object) {
+ var isObject = object !== null && typeof object === 'object';
+ var isFunction = toStr.call(object) === '[object Function]';
+ var isArguments = isArgs(object);
+ var isString = isObject && toStr.call(object) === '[object String]';
+ var theKeys = [];
+
+ if (!isObject && !isFunction && !isArguments) {
+ throw new TypeError('Object.keys called on a non-object');
}
-
- hasDirectives = true;
- ch = state.input.charCodeAt(++state.position);
- _position = state.position;
-
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
- }
-
- directiveName = state.input.slice(_position, state.position);
- directiveArgs = [];
-
- if (directiveName.length < 1) {
- throwError(state, 'directive name must not be less than one character in length');
- }
-
- while (ch !== 0) {
- while (is_WHITE_SPACE(ch)) {
- ch = state.input.charCodeAt(++state.position);
+
+ var skipProto = hasProtoEnumBug && isFunction;
+ if (isString && object.length > 0 && !has.call(object, 0)) {
+ for (var i = 0; i < object.length; ++i) {
+ theKeys.push(String(i));
+ }
}
-
- if (ch === 0x23 /* # */) {
- do {
- ch = state.input.charCodeAt(++state.position);
- } while (ch !== 0 && !is_EOL(ch));
- break;
+
+ if (isArguments && object.length > 0) {
+ for (var j = 0; j < object.length; ++j) {
+ theKeys.push(String(j));
+ }
+ } else {
+ for (var name in object) {
+ if (!(skipProto && name === 'prototype') && has.call(object, name)) {
+ theKeys.push(String(name));
+ }
}
-
- if (is_EOL(ch)) break;
-
- _position = state.position;
-
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
- ch = state.input.charCodeAt(++state.position);
}
-
- directiveArgs.push(state.input.slice(_position, state.position));
- }
-
- if (ch !== 0) readLineBreak(state);
-
- if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
- } else {
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
- }
- }
-
- skipSeparationSpace(state, true, -1);
-
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 0x2D /* - */ && state.input.charCodeAt(state.position + 1) === 0x2D /* - */ && state.input.charCodeAt(state.position + 2) === 0x2D /* - */) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
- } else if (hasDirectives) {
- throwError(state, 'directives end mark is expected');
- }
-
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
- skipSeparationSpace(state, true, -1);
-
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
- throwWarning(state, 'non-ASCII line breaks are interpreted as content');
- }
-
- state.documents.push(state.result);
-
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
-
- if (state.input.charCodeAt(state.position) === 0x2E /* . */) {
- state.position += 3;
- skipSeparationSpace(state, true, -1);
+
+ if (hasDontEnumBug) {
+ var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
+
+ for (var k = 0; k < dontEnums.length; ++k) {
+ if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
+ theKeys.push(dontEnums[k]);
+ }
+ }
}
- return;
+ return theKeys;
+ };
}
-
- if (state.position < state.length - 1) {
- throwError(state, 'end of the stream or a document separator is expected');
- } else {
- return;
- }
-}
-
-function loadDocuments(input, options) {
- input = String(input);
- options = options || {};
-
- if (input.length !== 0) {
-
- // Add tailing `\n` if not exists
- if (input.charCodeAt(input.length - 1) !== 0x0A /* LF */ && input.charCodeAt(input.length - 1) !== 0x0D /* CR */) {
- input += '\n';
- }
-
- // Strip BOM
- if (input.charCodeAt(0) === 0xFEFF) {
- input = input.slice(1);
- }
- }
-
- var state = new State(input, options);
-
- var nullpos = input.indexOf('\0');
-
- if (nullpos !== -1) {
- state.position = nullpos;
- throwError(state, 'null byte is not allowed in input');
- }
-
- // Use 0 as string terminator. That significantly simplifies bounds check.
- state.input += '\0';
-
- while (state.input.charCodeAt(state.position) === 0x20 /* Space */) {
- state.lineIndent += 1;
- state.position += 1;
- }
-
- while (state.position < state.length - 1) {
- readDocument(state);
- }
-
- return state.documents;
-}
-
-function loadAll(input, iterator, options) {
- if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
- options = iterator;
- iterator = null;
- }
-
- var documents = loadDocuments(input, options);
-
- if (typeof iterator !== 'function') {
- return documents;
- }
-
- for (var index = 0, length = documents.length; index < length; index += 1) {
- iterator(documents[index]);
- }
-}
-
-function load(input, options) {
- var documents = loadDocuments(input, options);
-
- if (documents.length === 0) {
- /*eslint-disable no-undefined*/
- return undefined;
- } else if (documents.length === 1) {
- return documents[0];
- }
- throw new YAMLException('expected a single document in the stream, but found more');
-}
-
-function safeLoadAll(input, iterator, options) {
- if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
- options = iterator;
- iterator = null;
- }
-
- return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-function safeLoad(input, options) {
- return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
-}
-
-module.exports.loadAll = loadAll;
-module.exports.load = load;
-module.exports.safeLoadAll = safeLoadAll;
-module.exports.safeLoad = safeLoad;
-},{"./common":43,"./exception":45,"./mark":47,"./schema/default_full":50,"./schema/default_safe":51}],47:[function(require,module,exports){
-'use strict';
-
-var common = require('./common');
-
-function Mark(name, buffer, position, line, column) {
- this.name = name;
- this.buffer = buffer;
- this.position = position;
- this.line = line;
- this.column = column;
-}
-
-Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
- var head, start, tail, end, snippet;
-
- if (!this.buffer) return null;
-
- indent = indent || 4;
- maxLength = maxLength || 75;
-
- head = '';
- start = this.position;
-
- while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
- start -= 1;
- if (this.position - start > maxLength / 2 - 1) {
- head = ' ... ';
- start += 5;
- break;
- }
- }
-
- tail = '';
- end = this.position;
-
- while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
- end += 1;
- if (end - this.position > maxLength / 2 - 1) {
- tail = ' ... ';
- end -= 5;
- break;
- }
- }
-
- snippet = this.buffer.slice(start, end);
-
- return common.repeat(' ', indent) + head + snippet + tail + '\n' + common.repeat(' ', indent + this.position - start + head.length) + '^';
-};
-
-Mark.prototype.toString = function toString(compact) {
- var snippet,
- where = '';
-
- if (this.name) {
- where += 'in "' + this.name + '" ';
- }
-
- where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
-
- if (!compact) {
- snippet = this.getSnippet();
-
- if (snippet) {
- where += ':\n' + snippet;
- }
- }
-
- return where;
-};
-
-module.exports = Mark;
-},{"./common":43}],48:[function(require,module,exports){
-'use strict';
-
-/*eslint-disable max-len*/
-
-var common = require('./common');
-var YAMLException = require('./exception');
-var Type = require('./type');
-
-function compileList(schema, name, result) {
- var exclude = [];
-
- schema.include.forEach(function (includedSchema) {
- result = compileList(includedSchema, name, result);
- });
-
- schema[name].forEach(function (currentType) {
- result.forEach(function (previousType, previousIndex) {
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
- exclude.push(previousIndex);
+ module.exports = keysShim;
+ },{"./isArguments":96}],95:[function(require,module,exports){
+ 'use strict';
+
+ var slice = Array.prototype.slice;
+ var isArgs = require('./isArguments');
+
+ var origKeys = Object.keys;
+ var keysShim = origKeys ? function keys(o) {
+ return origKeys(o);
+ } : require('./implementation');
+
+ var originalKeys = Object.keys;
+
+ keysShim.shim = function shimObjectKeys() {
+ if (Object.keys) {
+ var keysWorksWithArguments = function () {
+ // Safari 5.0 bug
+ var args = Object.keys(arguments);
+ return args && args.length === arguments.length;
+ }(1, 2);
+ if (!keysWorksWithArguments) {
+ Object.keys = function keys(object) {
+ // eslint-disable-line func-name-matching
+ if (isArgs(object)) {
+ return originalKeys(slice.call(object));
+ }
+ return originalKeys(object);
+ };
}
- });
-
- result.push(currentType);
- });
-
- return result.filter(function (type, index) {
- return exclude.indexOf(index) === -1;
- });
-}
-
-function compileMap() /* lists... */{
- var result = {
- scalar: {},
- sequence: {},
- mapping: {},
- fallback: {}
- },
- index,
- length;
-
- function collectType(type) {
- result[type.kind][type.tag] = result['fallback'][type.tag] = type;
- }
-
- for (index = 0, length = arguments.length; index < length; index += 1) {
- arguments[index].forEach(collectType);
- }
- return result;
-}
-
-function Schema(definition) {
- this.include = definition.include || [];
- this.implicit = definition.implicit || [];
- this.explicit = definition.explicit || [];
-
- this.implicit.forEach(function (type) {
- if (type.loadKind && type.loadKind !== 'scalar') {
- throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
- }
- });
-
- this.compiledImplicit = compileList(this, 'implicit', []);
- this.compiledExplicit = compileList(this, 'explicit', []);
- this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
-}
-
-Schema.DEFAULT = null;
-
-Schema.create = function createSchema() {
- var schemas, types;
-
- switch (arguments.length) {
- case 1:
- schemas = Schema.DEFAULT;
- types = arguments[0];
- break;
-
- case 2:
- schemas = arguments[0];
- types = arguments[1];
- break;
-
- default:
- throw new YAMLException('Wrong number of arguments for Schema.create function');
- }
-
- schemas = common.toArray(schemas);
- types = common.toArray(types);
-
- if (!schemas.every(function (schema) {
- return schema instanceof Schema;
- })) {
- throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
- }
-
- if (!types.every(function (type) {
- return type instanceof Type;
- })) {
- throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
- }
-
- return new Schema({
- include: schemas,
- explicit: types
- });
-};
-
-module.exports = Schema;
-},{"./common":43,"./exception":45,"./type":54}],49:[function(require,module,exports){
-// Standard YAML's Core schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2804923
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, Core schema has no distinctions from JSON schema is JS-YAML.
-
-
-'use strict';
-
-var Schema = require('../schema');
-
-module.exports = new Schema({
- include: [require('./json')]
-});
-},{"../schema":48,"./json":53}],50:[function(require,module,exports){
-// JS-YAML's default schema for `load` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on JS-YAML's default safe schema and includes
-// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
-//
-// Also this schema is used as default base schema at `Schema.create` function.
-
-
-'use strict';
-
-var Schema = require('../schema');
-
-module.exports = Schema.DEFAULT = new Schema({
- include: [require('./default_safe')],
- explicit: [require('../type/js/undefined'), require('../type/js/regexp'), require('../type/js/function')]
-});
-},{"../schema":48,"../type/js/function":59,"../type/js/regexp":60,"../type/js/undefined":61,"./default_safe":51}],51:[function(require,module,exports){
-// JS-YAML's default schema for `safeLoad` function.
-// It is not described in the YAML specification.
-//
-// This schema is based on standard YAML's Core schema and includes most of
-// extra types described at YAML tag repository. (http://yaml.org/type/)
-
-
-'use strict';
-
-var Schema = require('../schema');
-
-module.exports = new Schema({
- include: [require('./core')],
- implicit: [require('../type/timestamp'), require('../type/merge')],
- explicit: [require('../type/binary'), require('../type/omap'), require('../type/pairs'), require('../type/set')]
-});
-},{"../schema":48,"../type/binary":55,"../type/merge":63,"../type/omap":65,"../type/pairs":66,"../type/set":68,"../type/timestamp":70,"./core":49}],52:[function(require,module,exports){
-// Standard YAML's Failsafe schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2802346
-
-
-'use strict';
-
-var Schema = require('../schema');
-
-module.exports = new Schema({
- explicit: [require('../type/str'), require('../type/seq'), require('../type/map')]
-});
-},{"../schema":48,"../type/map":62,"../type/seq":67,"../type/str":69}],53:[function(require,module,exports){
-// Standard YAML's JSON schema.
-// http://www.yaml.org/spec/1.2/spec.html#id2803231
-//
-// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
-// So, this schema is not such strict as defined in the YAML specification.
-// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
-
-
-'use strict';
-
-var Schema = require('../schema');
-
-module.exports = new Schema({
- include: [require('./failsafe')],
- implicit: [require('../type/null'), require('../type/bool'), require('../type/int'), require('../type/float')]
-});
-},{"../schema":48,"../type/bool":56,"../type/float":57,"../type/int":58,"../type/null":64,"./failsafe":52}],54:[function(require,module,exports){
-'use strict';
-
-var YAMLException = require('./exception');
-
-var TYPE_CONSTRUCTOR_OPTIONS = ['kind', 'resolve', 'construct', 'instanceOf', 'predicate', 'represent', 'defaultStyle', 'styleAliases'];
-
-var YAML_NODE_KINDS = ['scalar', 'sequence', 'mapping'];
-
-function compileStyleAliases(map) {
- var result = {};
-
- if (map !== null) {
- Object.keys(map).forEach(function (style) {
- map[style].forEach(function (alias) {
- result[String(alias)] = style;
- });
- });
- }
-
- return result;
-}
-
-function Type(tag, options) {
- options = options || {};
-
- Object.keys(options).forEach(function (name) {
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
- throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
+ } else {
+ Object.keys = keysShim;
}
- });
-
- // TODO: Add tag format check.
- this.tag = tag;
- this.kind = options['kind'] || null;
- this.resolve = options['resolve'] || function () {
- return true;
+ return Object.keys || keysShim;
};
- this.construct = options['construct'] || function (data) {
- return data;
+
+ module.exports = keysShim;
+ },{"./implementation":94,"./isArguments":96}],96:[function(require,module,exports){
+ 'use strict';
+
+ var toStr = Object.prototype.toString;
+
+ module.exports = function isArguments(value) {
+ var str = toStr.call(value);
+ var isArgs = str === '[object Arguments]';
+ if (!isArgs) {
+ isArgs = str !== '[object Array]' && value !== null && typeof value === 'object' && typeof value.length === 'number' && value.length >= 0 && toStr.call(value.callee) === '[object Function]';
+ }
+ return isArgs;
};
- this.instanceOf = options['instanceOf'] || null;
- this.predicate = options['predicate'] || null;
- this.represent = options['represent'] || null;
- this.defaultStyle = options['defaultStyle'] || null;
- this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
-
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
- throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
- }
-}
-
-module.exports = Type;
-},{"./exception":45}],55:[function(require,module,exports){
-'use strict';
-
-/*eslint-disable no-bitwise*/
-
-var NodeBuffer;
-
-try {
- // A trick for browserified version, to not include `Buffer` shim
- var _require = require;
- NodeBuffer = _require('buffer').Buffer;
-} catch (__) {}
-
-var Type = require('../type');
-
-// [ 64, 65, 66 ] -> [ padding, CR, LF ]
-var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
-
-function resolveYamlBinary(data) {
- if (data === null) return false;
-
- var code,
- idx,
- bitlen = 0,
- max = data.length,
- map = BASE64_MAP;
-
- // Convert one by one.
- for (idx = 0; idx < max; idx++) {
- code = map.indexOf(data.charAt(idx));
-
- // Skip CR/LF
- if (code > 64) continue;
-
- // Fail on illegal characters
- if (code < 0) return false;
-
- bitlen += 6;
- }
-
- // If there are any bits left, source was corrupted
- return bitlen % 8 === 0;
-}
-
-function constructYamlBinary(data) {
- var idx,
- tailbits,
- input = data.replace(/[\r\n=]/g, ''),
- // remove CR/LF & padding to simplify scan
- max = input.length,
- map = BASE64_MAP,
- bits = 0,
- result = [];
-
- // Collect by 6*4 bits (3 bytes)
-
- for (idx = 0; idx < max; idx++) {
- if (idx % 4 === 0 && idx) {
- result.push(bits >> 16 & 0xFF);
- result.push(bits >> 8 & 0xFF);
- result.push(bits & 0xFF);
- }
-
- bits = bits << 6 | map.indexOf(input.charAt(idx));
- }
-
- // Dump tail
-
- tailbits = max % 4 * 6;
-
- if (tailbits === 0) {
- result.push(bits >> 16 & 0xFF);
- result.push(bits >> 8 & 0xFF);
- result.push(bits & 0xFF);
- } else if (tailbits === 18) {
- result.push(bits >> 10 & 0xFF);
- result.push(bits >> 2 & 0xFF);
- } else if (tailbits === 12) {
- result.push(bits >> 4 & 0xFF);
- }
-
- // Wrap into Buffer for NodeJS and leave Array for browser
- if (NodeBuffer) {
- // Support node 6.+ Buffer API when available
- return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
- }
-
- return result;
-}
-
-function representYamlBinary(object /*, style*/) {
- var result = '',
- bits = 0,
- idx,
- tail,
- max = object.length,
- map = BASE64_MAP;
-
- // Convert every three bytes to 4 ASCII characters.
-
- for (idx = 0; idx < max; idx++) {
- if (idx % 3 === 0 && idx) {
- result += map[bits >> 18 & 0x3F];
- result += map[bits >> 12 & 0x3F];
- result += map[bits >> 6 & 0x3F];
- result += map[bits & 0x3F];
- }
-
- bits = (bits << 8) + object[idx];
- }
-
- // Dump tail
-
- tail = max % 3;
-
- if (tail === 0) {
- result += map[bits >> 18 & 0x3F];
- result += map[bits >> 12 & 0x3F];
- result += map[bits >> 6 & 0x3F];
- result += map[bits & 0x3F];
- } else if (tail === 2) {
- result += map[bits >> 10 & 0x3F];
- result += map[bits >> 4 & 0x3F];
- result += map[bits << 2 & 0x3F];
- result += map[64];
- } else if (tail === 1) {
- result += map[bits >> 2 & 0x3F];
- result += map[bits << 4 & 0x3F];
- result += map[64];
- result += map[64];
- }
-
- return result;
-}
-
-function isBinary(object) {
- return NodeBuffer && NodeBuffer.isBuffer(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:binary', {
- kind: 'scalar',
- resolve: resolveYamlBinary,
- construct: constructYamlBinary,
- predicate: isBinary,
- represent: representYamlBinary
-});
-},{"../type":54}],56:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-function resolveYamlBoolean(data) {
- if (data === null) return false;
-
- var max = data.length;
-
- return max === 4 && (data === 'true' || data === 'True' || data === 'TRUE') || max === 5 && (data === 'false' || data === 'False' || data === 'FALSE');
-}
-
-function constructYamlBoolean(data) {
- return data === 'true' || data === 'True' || data === 'TRUE';
-}
-
-function isBoolean(object) {
- return Object.prototype.toString.call(object) === '[object Boolean]';
-}
-
-module.exports = new Type('tag:yaml.org,2002:bool', {
- kind: 'scalar',
- resolve: resolveYamlBoolean,
- construct: constructYamlBoolean,
- predicate: isBoolean,
- represent: {
- lowercase: function (object) {
- return object ? 'true' : 'false';
- },
- uppercase: function (object) {
- return object ? 'TRUE' : 'FALSE';
- },
- camelcase: function (object) {
- return object ? 'True' : 'False';
- }
- },
- defaultStyle: 'lowercase'
-});
-},{"../type":54}],57:[function(require,module,exports){
-'use strict';
-
-var common = require('../common');
-var Type = require('../type');
-
-var YAML_FLOAT_PATTERN = new RegExp(
-// 2.5e4, 2.5 and integers
-'^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
-// .2e4, .2
-// special case, seems not from spec
-'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
-// 20:59
-'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
-// .inf
-'|[-+]?\\.(?:inf|Inf|INF)' +
-// .nan
-'|\\.(?:nan|NaN|NAN))$');
-
-function resolveYamlFloat(data) {
- if (data === null) return false;
-
- if (!YAML_FLOAT_PATTERN.test(data) ||
- // Quick hack to not allow integers end with `_`
- // Probably should update regexp & check speed
- data[data.length - 1] === '_') {
- return false;
- }
-
- return true;
-}
-
-function constructYamlFloat(data) {
- var value, sign, base, digits;
-
- value = data.replace(/_/g, '').toLowerCase();
- sign = value[0] === '-' ? -1 : 1;
- digits = [];
-
- if ('+-'.indexOf(value[0]) >= 0) {
- value = value.slice(1);
- }
-
- if (value === '.inf') {
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
- } else if (value === '.nan') {
- return NaN;
- } else if (value.indexOf(':') >= 0) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseFloat(v, 10));
- });
-
- value = 0.0;
- base = 1;
-
- digits.forEach(function (d) {
- value += d * base;
- base *= 60;
+ },{}],97:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = function (object) {
+ return Object.keys(object).map(function (i) {
+ return object[i];
});
-
- return sign * value;
- }
- return sign * parseFloat(value, 10);
-}
-
-var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
-
-function representYamlFloat(object, style) {
- var res;
-
- if (isNaN(object)) {
- switch (style) {
- case 'lowercase':
- return '.nan';
- case 'uppercase':
- return '.NAN';
- case 'camelcase':
- return '.NaN';
- }
- } else if (Number.POSITIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase':
- return '.inf';
- case 'uppercase':
- return '.INF';
- case 'camelcase':
- return '.Inf';
- }
- } else if (Number.NEGATIVE_INFINITY === object) {
- switch (style) {
- case 'lowercase':
- return '-.inf';
- case 'uppercase':
- return '-.INF';
- case 'camelcase':
- return '-.Inf';
- }
- } else if (common.isNegativeZero(object)) {
- return '-0.0';
- }
-
- res = object.toString(10);
-
- // JS stringifier can build scientific format without dots: 5e-100,
- // while YAML requres dot: 5.e-100. Fix it with simple hack
-
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
-}
-
-function isFloat(object) {
- return Object.prototype.toString.call(object) === '[object Number]' && (object % 1 !== 0 || common.isNegativeZero(object));
-}
-
-module.exports = new Type('tag:yaml.org,2002:float', {
- kind: 'scalar',
- resolve: resolveYamlFloat,
- construct: constructYamlFloat,
- predicate: isFloat,
- represent: representYamlFloat,
- defaultStyle: 'lowercase'
-});
-},{"../common":43,"../type":54}],58:[function(require,module,exports){
-'use strict';
-
-var common = require('../common');
-var Type = require('../type');
-
-function isHexCode(c) {
- return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */ || 0x41 /* A */ <= c && c <= 0x46 /* F */ || 0x61 /* a */ <= c && c <= 0x66 /* f */;
-}
-
-function isOctCode(c) {
- return 0x30 /* 0 */ <= c && c <= 0x37 /* 7 */;
-}
-
-function isDecCode(c) {
- return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */;
-}
-
-function resolveYamlInteger(data) {
- if (data === null) return false;
-
- var max = data.length,
- index = 0,
- hasDigits = false,
- ch;
-
- if (!max) return false;
-
- ch = data[index];
-
- // sign
- if (ch === '-' || ch === '+') {
- ch = data[++index];
- }
-
- if (ch === '0') {
- // 0
- if (index + 1 === max) return true;
- ch = data[++index];
-
- // base 2, base 8, base 16
-
- if (ch === 'b') {
- // base 2
- index++;
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (ch !== '0' && ch !== '1') return false;
- hasDigits = true;
- }
- return hasDigits && ch !== '_';
- }
-
- if (ch === 'x') {
- // base 16
- index++;
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (!isHexCode(data.charCodeAt(index))) return false;
- hasDigits = true;
+ };
+ },{}],98:[function(require,module,exports){
+ /* global MutationObserver */
+ var document = require('global/document');
+ var window = require('global/window');
+ var assert = require('assert');
+ var watch = Object.create(null);
+ var KEY_ID = 'onloadid' + (new Date() % 9e6).toString(36);
+ var KEY_ATTR = 'data-' + KEY_ID;
+ var INDEX = 0;
+
+ if (window && window.MutationObserver) {
+ var observer = new MutationObserver(function (mutations) {
+ if (Object.keys(watch).length < 1) return;
+ for (var i = 0; i < mutations.length; i++) {
+ if (mutations[i].attributeName === KEY_ATTR) {
+ eachAttr(mutations[i], turnon, turnoff);
+ continue;
+ }
+ eachMutation(mutations[i].removedNodes, turnoff);
+ eachMutation(mutations[i].addedNodes, turnon);
}
- return hasDigits && ch !== '_';
- }
-
- // base 8
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (!isOctCode(data.charCodeAt(index))) return false;
- hasDigits = true;
- }
- return hasDigits && ch !== '_';
- }
-
- // base 10 (except 0) or base 60
-
- // value should not start with `_`;
- if (ch === '_') return false;
-
- for (; index < max; index++) {
- ch = data[index];
- if (ch === '_') continue;
- if (ch === ':') break;
- if (!isDecCode(data.charCodeAt(index))) {
- return false;
+ });
+ if (document.body) {
+ beginObserve(observer);
+ } else {
+ document.addEventListener('DOMContentLoaded', function (event) {
+ beginObserve(observer);
+ });
}
- hasDigits = true;
- }
-
- // Should have digits and should not end with `_`
- if (!hasDigits || ch === '_') return false;
-
- // if !base60 - done;
- if (ch !== ':') return true;
-
- // base60 almost not used, no needs to optimize
- return (/^(:[0-5]?[0-9])+$/.test(data.slice(index))
- );
-}
-
-function constructYamlInteger(data) {
- var value = data,
- sign = 1,
- ch,
- base,
- digits = [];
-
- if (value.indexOf('_') !== -1) {
- value = value.replace(/_/g, '');
- }
-
- ch = value[0];
-
- if (ch === '-' || ch === '+') {
- if (ch === '-') sign = -1;
- value = value.slice(1);
- ch = value[0];
}
-
- if (value === '0') return 0;
-
- if (ch === '0') {
- if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
- if (value[1] === 'x') return sign * parseInt(value, 16);
- return sign * parseInt(value, 8);
- }
-
- if (value.indexOf(':') !== -1) {
- value.split(':').forEach(function (v) {
- digits.unshift(parseInt(v, 10));
+
+ function beginObserve(observer) {
+ observer.observe(document.documentElement, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeOldValue: true,
+ attributeFilter: [KEY_ATTR]
});
-
- value = 0;
- base = 1;
-
- digits.forEach(function (d) {
- value += d * base;
- base *= 60;
- });
-
- return sign * value;
- }
-
- return sign * parseInt(value, 10);
-}
-
-function isInteger(object) {
- return Object.prototype.toString.call(object) === '[object Number]' && object % 1 === 0 && !common.isNegativeZero(object);
-}
-
-module.exports = new Type('tag:yaml.org,2002:int', {
- kind: 'scalar',
- resolve: resolveYamlInteger,
- construct: constructYamlInteger,
- predicate: isInteger,
- represent: {
- binary: function (obj) {
- return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1);
- },
- octal: function (obj) {
- return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1);
- },
- decimal: function (obj) {
- return obj.toString(10);
- },
- /* eslint-disable max-len */
- hexadecimal: function (obj) {
- return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1);
+ }
+
+ module.exports = function onload(el, on, off, caller) {
+ assert(document.body, 'on-load: will not work prior to DOMContentLoaded');
+ on = on || function () {};
+ off = off || function () {};
+ el.setAttribute(KEY_ATTR, 'o' + INDEX);
+ watch['o' + INDEX] = [on, off, 0, caller || onload.caller];
+ INDEX += 1;
+ return el;
+ };
+
+ module.exports.KEY_ATTR = KEY_ATTR;
+ module.exports.KEY_ID = KEY_ID;
+
+ function turnon(index, el) {
+ if (watch[index][0] && watch[index][2] === 0) {
+ watch[index][0](el);
+ watch[index][2] = 1;
+ }
+ }
+
+ function turnoff(index, el) {
+ if (watch[index][1] && watch[index][2] === 1) {
+ watch[index][1](el);
+ watch[index][2] = 0;
+ }
+ }
+
+ function eachAttr(mutation, on, off) {
+ var newValue = mutation.target.getAttribute(KEY_ATTR);
+ if (sameOrigin(mutation.oldValue, newValue)) {
+ watch[newValue] = watch[mutation.oldValue];
+ return;
}
- },
- defaultStyle: 'decimal',
- styleAliases: {
- binary: [2, 'bin'],
- octal: [8, 'oct'],
- decimal: [10, 'dec'],
- hexadecimal: [16, 'hex']
- }
-});
-},{"../common":43,"../type":54}],59:[function(require,module,exports){
-'use strict';
-
-var esprima;
-
-// Browserified version does not have esprima
-//
-// 1. For node.js just require module as deps
-// 2. For browser try to require mudule via external AMD system.
-// If not found - try to fallback to window.esprima. If not
-// found too - then fail to parse.
-//
-try {
- // workaround to exclude package from browserify list.
- var _require = require;
- esprima = _require('esprima');
-} catch (_) {
- /* eslint-disable no-redeclare */
- /* global window */
- if (typeof window !== 'undefined') esprima = window.esprima;
-}
-
-var Type = require('../../type');
-
-function resolveJavascriptFunction(data) {
- if (data === null) return false;
-
- try {
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true });
-
- if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
- return false;
+ if (watch[mutation.oldValue]) {
+ off(mutation.oldValue, mutation.target);
+ }
+ if (watch[newValue]) {
+ on(newValue, mutation.target);
}
-
- return true;
- } catch (err) {
- return false;
}
-}
-
-function constructJavascriptFunction(data) {
- /*jslint evil:true*/
-
- var source = '(' + data + ')',
- ast = esprima.parse(source, { range: true }),
- params = [],
- body;
-
- if (ast.type !== 'Program' || ast.body.length !== 1 || ast.body[0].type !== 'ExpressionStatement' || ast.body[0].expression.type !== 'ArrowFunctionExpression' && ast.body[0].expression.type !== 'FunctionExpression') {
- throw new Error('Failed to resolve function');
- }
-
- ast.body[0].expression.params.forEach(function (param) {
- params.push(param.name);
- });
-
- body = ast.body[0].expression.body.range;
-
- // Esprima's ranges include the first '{' and the last '}' characters on
- // function expressions. So cut them out.
- if (ast.body[0].expression.body.type === 'BlockStatement') {
- /*eslint-disable no-new-func*/
- return new Function(params, source.slice(body[0] + 1, body[1] - 1));
- }
- // ES6 arrow functions can omit the BlockStatement. In that case, just return
- // the body.
- /*eslint-disable no-new-func*/
- return new Function(params, 'return ' + source.slice(body[0], body[1]));
-}
-
-function representJavascriptFunction(object /*, style*/) {
- return object.toString();
-}
-
-function isFunction(object) {
- return Object.prototype.toString.call(object) === '[object Function]';
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/function', {
- kind: 'scalar',
- resolve: resolveJavascriptFunction,
- construct: constructJavascriptFunction,
- predicate: isFunction,
- represent: representJavascriptFunction
-});
-},{"../../type":54}],60:[function(require,module,exports){
-'use strict';
-
-var Type = require('../../type');
-
-function resolveJavascriptRegExp(data) {
- if (data === null) return false;
- if (data.length === 0) return false;
-
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
-
- // if regexp starts with '/' it can have modifiers and must be properly closed
- // `/foo/gim` - modifiers tail can be maximum 3 chars
- if (regexp[0] === '/') {
- if (tail) modifiers = tail[1];
-
- if (modifiers.length > 3) return false;
- // if expression starts with /, is should be properly terminated
- if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
- }
-
- return true;
-}
-
-function constructJavascriptRegExp(data) {
- var regexp = data,
- tail = /\/([gim]*)$/.exec(data),
- modifiers = '';
-
- // `/foo/gim` - tail can be maximum 4 chars
- if (regexp[0] === '/') {
- if (tail) modifiers = tail[1];
- regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
- }
-
- return new RegExp(regexp, modifiers);
-}
-
-function representJavascriptRegExp(object /*, style*/) {
- var result = '/' + object.source + '/';
-
- if (object.global) result += 'g';
- if (object.multiline) result += 'm';
- if (object.ignoreCase) result += 'i';
-
- return result;
-}
-
-function isRegExp(object) {
- return Object.prototype.toString.call(object) === '[object RegExp]';
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/regexp', {
- kind: 'scalar',
- resolve: resolveJavascriptRegExp,
- construct: constructJavascriptRegExp,
- predicate: isRegExp,
- represent: representJavascriptRegExp
-});
-},{"../../type":54}],61:[function(require,module,exports){
-'use strict';
-
-var Type = require('../../type');
-
-function resolveJavascriptUndefined() {
- return true;
-}
-
-function constructJavascriptUndefined() {
- /*eslint-disable no-undefined*/
- return undefined;
-}
-
-function representJavascriptUndefined() {
- return '';
-}
-
-function isUndefined(object) {
- return typeof object === 'undefined';
-}
-
-module.exports = new Type('tag:yaml.org,2002:js/undefined', {
- kind: 'scalar',
- resolve: resolveJavascriptUndefined,
- construct: constructJavascriptUndefined,
- predicate: isUndefined,
- represent: representJavascriptUndefined
-});
-},{"../../type":54}],62:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-module.exports = new Type('tag:yaml.org,2002:map', {
- kind: 'mapping',
- construct: function (data) {
- return data !== null ? data : {};
+
+ function sameOrigin(oldValue, newValue) {
+ if (!oldValue || !newValue) return false;
+ return watch[oldValue][3] === watch[newValue][3];
+ }
+
+ function eachMutation(nodes, fn) {
+ var keys = Object.keys(watch);
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i] && nodes[i].getAttribute && nodes[i].getAttribute(KEY_ATTR)) {
+ var onloadid = nodes[i].getAttribute(KEY_ATTR);
+ keys.forEach(function (k) {
+ if (onloadid === k) {
+ fn(k, nodes[i]);
+ }
+ });
+ }
+ if (nodes[i].childNodes.length > 0) {
+ eachMutation(nodes[i].childNodes, fn);
+ }
+ }
}
-});
-},{"../type":54}],63:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-function resolveYamlMerge(data) {
- return data === '<<' || data === null;
-}
-
-module.exports = new Type('tag:yaml.org,2002:merge', {
- kind: 'scalar',
- resolve: resolveYamlMerge
-});
-},{"../type":54}],64:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-function resolveYamlNull(data) {
- if (data === null) return true;
-
- var max = data.length;
-
- return max === 1 && data === '~' || max === 4 && (data === 'null' || data === 'Null' || data === 'NULL');
-}
-
-function constructYamlNull() {
- return null;
-}
-
-function isNull(object) {
- return object === null;
-}
-
-module.exports = new Type('tag:yaml.org,2002:null', {
- kind: 'scalar',
- resolve: resolveYamlNull,
- construct: constructYamlNull,
- predicate: isNull,
- represent: {
- canonical: function () {
- return '~';
- },
- lowercase: function () {
- return 'null';
- },
- uppercase: function () {
- return 'NULL';
- },
- camelcase: function () {
- return 'Null';
+ },{"assert":75,"global/document":20,"global/window":21}],99:[function(require,module,exports){
+ var wrappy = require('wrappy');
+ module.exports = wrappy(once);
+ module.exports.strict = wrappy(onceStrict);
+
+ once.proto = once(function () {
+ Object.defineProperty(Function.prototype, 'once', {
+ value: function () {
+ return once(this);
+ },
+ configurable: true
+ });
+
+ Object.defineProperty(Function.prototype, 'onceStrict', {
+ value: function () {
+ return onceStrict(this);
+ },
+ configurable: true
+ });
+ });
+
+ function once(fn) {
+ var f = function () {
+ if (f.called) return f.value;
+ f.called = true;
+ return f.value = fn.apply(this, arguments);
+ };
+ f.called = false;
+ return f;
+ }
+
+ function onceStrict(fn) {
+ var f = function () {
+ if (f.called) throw new Error(f.onceError);
+ f.called = true;
+ return f.value = fn.apply(this, arguments);
+ };
+ var name = fn.name || 'Function wrapped with `once`';
+ f.onceError = name + " shouldn't be called more than once";
+ f.called = false;
+ return f;
+ }
+ },{"wrappy":129}],100:[function(require,module,exports){
+ var isNode = typeof window === 'undefined';
+ var parse = isNode ? require('url').parse : browserParse;
+
+ var SCHEME_REGEX = /[a-z]+:\/\//i;
+ // 1 2 3 4
+ var VERSION_REGEX = /^(dat:\/\/)?([^/]+)(\+[^/]+)(.*)$/i;
+
+ module.exports = function parseDatURL(str, parseQS) {
+ // prepend the scheme if it's missing
+ if (!SCHEME_REGEX.test(str)) {
+ str = 'dat://' + str;
+ }
+
+ var parsed,
+ version = null,
+ match = VERSION_REGEX.exec(str);
+ if (match) {
+ // run typical parse with version segment removed
+ parsed = parse((match[1] || '') + (match[2] || '') + (match[4] || ''), parseQS);
+ version = match[3].slice(1);
+ } else {
+ parsed = parse(str, parseQS);
}
- },
- defaultStyle: 'lowercase'
-});
-},{"../type":54}],65:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-var _toString = Object.prototype.toString;
-
-function resolveYamlOmap(data) {
- if (data === null) return true;
-
- var objectKeys = [],
- index,
- length,
- pair,
- pairKey,
- pairHasKey,
- object = data;
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
- pairHasKey = false;
-
- if (_toString.call(pair) !== '[object Object]') return false;
-
- for (pairKey in pair) {
- if (_hasOwnProperty.call(pair, pairKey)) {
- if (!pairHasKey) pairHasKey = true;else return false;
- }
- }
-
- if (!pairHasKey) return false;
-
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);else return false;
- }
-
- return true;
-}
-
-function constructYamlOmap(data) {
- return data !== null ? data : [];
-}
-
-module.exports = new Type('tag:yaml.org,2002:omap', {
- kind: 'sequence',
- resolve: resolveYamlOmap,
- construct: constructYamlOmap
-});
-},{"../type":54}],66:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-var _toString = Object.prototype.toString;
-
-function resolveYamlPairs(data) {
- if (data === null) return true;
-
- var index,
- length,
- pair,
- keys,
- result,
- object = data;
-
- result = new Array(object.length);
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
-
- if (_toString.call(pair) !== '[object Object]') return false;
-
- keys = Object.keys(pair);
-
- if (keys.length !== 1) return false;
-
- result[index] = [keys[0], pair[keys[0]]];
- }
-
- return true;
-}
-
-function constructYamlPairs(data) {
- if (data === null) return [];
-
- var index,
- length,
- pair,
- keys,
- result,
- object = data;
-
- result = new Array(object.length);
-
- for (index = 0, length = object.length; index < length; index += 1) {
- pair = object[index];
-
- keys = Object.keys(pair);
-
- result[index] = [keys[0], pair[keys[0]]];
- }
-
- return result;
-}
-
-module.exports = new Type('tag:yaml.org,2002:pairs', {
- kind: 'sequence',
- resolve: resolveYamlPairs,
- construct: constructYamlPairs
-});
-},{"../type":54}],67:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-module.exports = new Type('tag:yaml.org,2002:seq', {
- kind: 'sequence',
- construct: function (data) {
- return data !== null ? data : [];
+ if (isNode) parsed.href = str; // overwrite href to include actual original
+ else parsed.path = parsed.pathname; // to match node
+ if (!parsed.query && parsed.searchParams) {
+ parsed.query = Object.fromEntries(parsed.searchParams); // to match node
+ }
+ parsed.version = version; // add version segment
+ return parsed;
+ };
+
+ function browserParse(str) {
+ return new URL(str);
}
-});
-},{"../type":54}],68:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-var _hasOwnProperty = Object.prototype.hasOwnProperty;
-
-function resolveYamlSet(data) {
- if (data === null) return true;
-
- var key,
- object = data;
-
- for (key in object) {
- if (_hasOwnProperty.call(object, key)) {
- if (object[key] !== null) return false;
- }
- }
-
- return true;
-}
-
-function constructYamlSet(data) {
- return data !== null ? data : {};
-}
-
-module.exports = new Type('tag:yaml.org,2002:set', {
- kind: 'mapping',
- resolve: resolveYamlSet,
- construct: constructYamlSet
-});
-},{"../type":54}],69:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-module.exports = new Type('tag:yaml.org,2002:str', {
- kind: 'scalar',
- construct: function (data) {
- return data !== null ? data : '';
- }
-});
-},{"../type":54}],70:[function(require,module,exports){
-'use strict';
-
-var Type = require('../type');
-
-var YAML_DATE_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
-'-([0-9][0-9])' + // [2] month
-'-([0-9][0-9])$'); // [3] day
-
-var YAML_TIMESTAMP_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + // [1] year
-'-([0-9][0-9]?)' + // [2] month
-'-([0-9][0-9]?)' + // [3] day
-'(?:[Tt]|[ \\t]+)' + // ...
-'([0-9][0-9]?)' + // [4] hour
-':([0-9][0-9])' + // [5] minute
-':([0-9][0-9])' + // [6] second
-'(?:\\.([0-9]*))?' + // [7] fraction
-'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
-'(?::([0-9][0-9]))?))?$'); // [11] tz_minute
-
-function resolveYamlTimestamp(data) {
- if (data === null) return false;
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
- return false;
-}
-
-function constructYamlTimestamp(data) {
- var match,
- year,
- month,
- day,
- hour,
- minute,
- second,
- fraction = 0,
- delta = null,
- tz_hour,
- tz_minute,
- date;
-
- match = YAML_DATE_REGEXP.exec(data);
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
-
- if (match === null) throw new Error('Date resolve error');
-
- // match: [1] year [2] month [3] day
-
- year = +match[1];
- month = +match[2] - 1; // JS month starts with 0
- day = +match[3];
-
- if (!match[4]) {
- // no hour
- return new Date(Date.UTC(year, month, day));
- }
-
- // match: [4] hour [5] minute [6] second [7] fraction
-
- hour = +match[4];
- minute = +match[5];
- second = +match[6];
-
- if (match[7]) {
- fraction = match[7].slice(0, 3);
- while (fraction.length < 3) {
- // milli-seconds
- fraction += '0';
- }
- fraction = +fraction;
- }
-
- // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
-
- if (match[9]) {
- tz_hour = +match[10];
- tz_minute = +(match[11] || 0);
- delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
- if (match[9] === '-') delta = -delta;
- }
-
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
-
- if (delta) date.setTime(date.getTime() - delta);
-
- return date;
-}
-
-function representYamlTimestamp(object /*, style*/) {
- return object.toISOString();
-}
-
-module.exports = new Type('tag:yaml.org,2002:timestamp', {
- kind: 'scalar',
- resolve: resolveYamlTimestamp,
- construct: constructYamlTimestamp,
- instanceOf: Date,
- represent: representYamlTimestamp
-});
-},{"../type":54}],71:[function(require,module,exports){
-(function (global){
-/**
- * marked - a markdown parser
- * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
- * https://github.com/markedjs/marked
- */
-
-;(function (root) {
- 'use strict';
-
- /**
- * Block-Level Grammar
- */
-
- var block = {
- newline: /^\n+/,
- code: /^( {4}[^\n]+\n*)+/,
- fences: noop,
- hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
- heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
- nptable: noop,
- blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
- list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
- html: '^ {0,3}(?:' // optional indentation
- + '<(script|pre|style)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)' // (1)
- + '|comment[^\\n]*(\\n+|$)' // (2)
- + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
- + '|\\n*' // (4)
- + '|\\n*' // (5)
- + '|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
- + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
- + '|(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
- + ')',
- def: /^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
- table: noop,
- lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
- paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
- text: /^[^\n]+/
+ },{"url":122}],101:[function(require,module,exports){
+ var trim = function (string) {
+ return string.replace(/^\s+|\s+$/g, '');
+ },
+ isArray = function (arg) {
+ return Object.prototype.toString.call(arg) === '[object Array]';
};
-
- block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
- block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
- block.def = edit(block.def).replace('label', block._label).replace('title', block._title).getRegex();
-
- block.bullet = /(?:[*+-]|\d+\.)/;
- block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
- block.item = edit(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
-
- block.list = edit(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
-
- block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
- block._comment = //;
- block.html = edit(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
-
- block.paragraph = edit(block.paragraph).replace('hr', block.hr).replace('heading', block.heading).replace('lheading', block.lheading).replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
- .getRegex();
-
- block.blockquote = edit(block.blockquote).replace('paragraph', block.paragraph).getRegex();
-
- /**
- * Normal Block Grammar
- */
-
- block.normal = merge({}, block);
-
- /**
- * GFM Block Grammar
- */
-
- block.gfm = merge({}, block.normal, {
- fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
- paragraph: /^/,
- heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
- });
-
- block.gfm.paragraph = edit(block.paragraph).replace('(?!', '(?!' + block.gfm.fences.source.replace('\\1', '\\2') + '|' + block.list.source.replace('\\1', '\\3') + '|').getRegex();
-
- /**
- * GFM + Tables Block Grammar
- */
-
- block.tables = merge({}, block.gfm, {
- nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
- table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
- });
-
- /**
- * Pedantic grammar
- */
-
- block.pedantic = merge({}, block.normal, {
- html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)' // closed tag
- + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', block._comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
- def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
- });
-
- /**
- * Block Lexer
- */
-
- function Lexer(options) {
- this.tokens = [];
- this.tokens.links = Object.create(null);
- this.options = options || marked.defaults;
- this.rules = block.normal;
-
- if (this.options.pedantic) {
- this.rules = block.pedantic;
- } else if (this.options.gfm) {
- if (this.options.tables) {
- this.rules = block.tables;
+
+ module.exports = function (headers) {
+ if (!headers) return {};
+
+ var result = {};
+
+ var headersArr = trim(headers).split('\n');
+
+ for (var i = 0; i < headersArr.length; i++) {
+ var row = headersArr[i];
+ var index = row.indexOf(':'),
+ key = trim(row.slice(0, index)).toLowerCase(),
+ value = trim(row.slice(index + 1));
+
+ if (typeof result[key] === 'undefined') {
+ result[key] = value;
+ } else if (isArray(result[key])) {
+ result[key].push(value);
} else {
- this.rules = block.gfm;
+ result[key] = [result[key], value];
}
}
- }
-
- /**
- * Expose Block Rules
- */
-
- Lexer.rules = block;
-
- /**
- * Static Lex Method
- */
-
- Lexer.lex = function (src, options) {
- var lexer = new Lexer(options);
- return lexer.lex(src);
- };
-
- /**
- * Preprocessing
- */
-
- Lexer.prototype.lex = function (src) {
- src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ').replace(/\u00a0/g, ' ').replace(/\u2424/g, '\n');
-
- return this.token(src, true);
+
+ return result;
};
-
- /**
- * Lexing
- */
-
- Lexer.prototype.token = function (src, top) {
- src = src.replace(/^ +$/gm, '');
- var next, loose, cap, bull, b, item, listStart, listItems, t, space, i, tag, l, isordered, istask, ischecked;
-
- while (src) {
- // newline
- if (cap = this.rules.newline.exec(src)) {
- src = src.substring(cap[0].length);
- if (cap[0].length > 1) {
- this.tokens.push({
- type: 'space'
- });
- }
+ },{}],102:[function(require,module,exports){
+ (function (process){(function (){
+ // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
+ // backported and transplited with Babel, with backwards-compat fixes
+
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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.
+
+ // resolves . and .. elements in a path array with directory names there
+ // must be no slashes, empty elements, or device names (c:\) in the array
+ // (so also no leading and trailing slashes - it does not distinguish
+ // relative and absolute paths)
+ function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
}
-
- // code
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- cap = cap[0].replace(/^ {4}/gm, '');
- this.tokens.push({
- type: 'code',
- text: !this.options.pedantic ? rtrim(cap, '\n') : cap
- });
- continue;
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
}
-
- // fences (gfm)
- if (cap = this.rules.fences.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'code',
- lang: cap[2],
- text: cap[3] || ''
- });
+ }
+
+ return parts;
+ }
+
+ // path.resolve([from ...], to)
+ // posix version
+ exports.resolve = function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = i >= 0 ? arguments[i] : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
continue;
}
-
- // heading
- if (cap = this.rules.heading.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'heading',
- depth: cap[1].length,
- text: cap[2]
- });
- continue;
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+
+ // Normalize the path
+ resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return (resolvedAbsolute ? '/' : '') + resolvedPath || '.';
+ };
+
+ // path.normalize(path)
+ // posix version
+ exports.normalize = function (path) {
+ var isAbsolute = exports.isAbsolute(path),
+ trailingSlash = substr(path, -1) === '/';
+
+ // Normalize the path
+ path = normalizeArray(filter(path.split('/'), function (p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+ };
+
+ // posix version
+ exports.isAbsolute = function (path) {
+ return path.charAt(0) === '/';
+ };
+
+ // posix version
+ exports.join = function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(filter(paths, function (p, index) {
+ if (typeof p !== 'string') {
+ throw new TypeError('Arguments to path.join must be strings');
}
-
- // table no leading pipe (gfm)
- if (top && (cap = this.rules.nptable.exec(src))) {
- item = {
- type: 'table',
- header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
- cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
- };
-
- if (item.header.length === item.align.length) {
- src = src.substring(cap[0].length);
-
- for (i = 0; i < item.align.length; i++) {
- if (/^ *-+: *$/.test(item.align[i])) {
- item.align[i] = 'right';
- } else if (/^ *:-+: *$/.test(item.align[i])) {
- item.align[i] = 'center';
- } else if (/^ *:-+ *$/.test(item.align[i])) {
- item.align[i] = 'left';
- } else {
- item.align[i] = null;
- }
- }
-
- for (i = 0; i < item.cells.length; i++) {
- item.cells[i] = splitCells(item.cells[i], item.header.length);
- }
-
- this.tokens.push(item);
-
- continue;
- }
+ return p;
+ }).join('/'));
+ };
+
+ // path.relative(from, to)
+ // posix version
+ exports.relative = function (from, to) {
+ from = exports.resolve(from).substr(1);
+ to = exports.resolve(to).substr(1);
+
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
}
-
- // hr
- if (cap = this.rules.hr.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'hr'
- });
- continue;
+
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
}
-
- // blockquote
- if (cap = this.rules.blockquote.exec(src)) {
- src = src.substring(cap[0].length);
-
- this.tokens.push({
- type: 'blockquote_start'
- });
-
- cap = cap[0].replace(/^ *> ?/gm, '');
-
- // Pass `top` to keep the current
- // "toplevel" state. This is exactly
- // how markdown.pl works.
- this.token(cap, top);
-
- this.tokens.push({
- type: 'blockquote_end'
- });
-
- continue;
+
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
}
-
- // list
- if (cap = this.rules.list.exec(src)) {
- src = src.substring(cap[0].length);
- bull = cap[2];
- isordered = bull.length > 1;
-
- listStart = {
- type: 'list_start',
- ordered: isordered,
- start: isordered ? +bull : '',
- loose: false
- };
-
- this.tokens.push(listStart);
-
- // Get each top-level item.
- cap = cap[0].match(this.rules.item);
-
- listItems = [];
- next = false;
- l = cap.length;
- i = 0;
-
- for (; i < l; i++) {
- item = cap[i];
-
- // Remove the list item's bullet
- // so it is seen as the next token.
- space = item.length;
- item = item.replace(/^ *([*+-]|\d+\.) +/, '');
-
- // Outdent whatever the
- // list item contains. Hacky.
- if (~item.indexOf('\n ')) {
- space -= item.length;
- item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
- }
-
- // Determine whether the next list item belongs here.
- // Backpedal if it does not belong in this list.
- if (this.options.smartLists && i !== l - 1) {
- b = block.bullet.exec(cap[i + 1])[0];
- if (bull !== b && !(bull.length > 1 && b.length > 1)) {
- src = cap.slice(i + 1).join('\n') + src;
- i = l - 1;
- }
- }
-
- // Determine whether item is loose or not.
- // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
- // for discount behavior.
- loose = next || /\n\n(?!\s*$)/.test(item);
- if (i !== l - 1) {
- next = item.charAt(item.length - 1) === '\n';
- if (!loose) loose = next;
- }
-
- if (loose) {
- listStart.loose = true;
- }
-
- // Check for task list items
- istask = /^\[[ xX]\] /.test(item);
- ischecked = undefined;
- if (istask) {
- ischecked = item[1] !== ' ';
- item = item.replace(/^\[[ xX]\] +/, '');
- }
-
- t = {
- type: 'list_item_start',
- task: istask,
- checked: ischecked,
- loose: loose
- };
-
- listItems.push(t);
- this.tokens.push(t);
-
- // Recurse.
- this.token(item, false);
-
- this.tokens.push({
- type: 'list_item_end'
- });
- }
-
- if (listStart.loose) {
- l = listItems.length;
- i = 0;
- for (; i < l; i++) {
- listItems[i].loose = true;
+ }
+
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+
+ return outputParts.join('/');
+ };
+
+ exports.sep = '/';
+ exports.delimiter = ':';
+
+ exports.dirname = function (path) {
+ if (typeof path !== 'string') path = path + '';
+ if (path.length === 0) return '.';
+ var code = path.charCodeAt(0);
+ var hasRoot = code === 47 /*/*/;
+ var end = -1;
+ var matchedSlash = true;
+ for (var i = path.length - 1; i >= 1; --i) {
+ code = path.charCodeAt(i);
+ if (code === 47 /*/*/) {
+ if (!matchedSlash) {
+ end = i;
+ break;
}
- }
-
- this.tokens.push({
- type: 'list_end'
- });
-
- continue;
- }
-
- // html
- if (cap = this.rules.html.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: this.options.sanitize ? 'paragraph' : 'html',
- pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
- text: cap[0]
- });
- continue;
- }
-
- // def
- if (top && (cap = this.rules.def.exec(src))) {
- src = src.substring(cap[0].length);
- if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
- tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
- if (!this.tokens.links[tag]) {
- this.tokens.links[tag] = {
- href: cap[2],
- title: cap[3]
- };
- }
- continue;
+ } else {
+ // We saw the first non-path separator
+ matchedSlash = false;
}
-
- // table (gfm)
- if (top && (cap = this.rules.table.exec(src))) {
- item = {
- type: 'table',
- header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
- cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
- };
-
- if (item.header.length === item.align.length) {
- src = src.substring(cap[0].length);
-
- for (i = 0; i < item.align.length; i++) {
- if (/^ *-+: *$/.test(item.align[i])) {
- item.align[i] = 'right';
- } else if (/^ *:-+: *$/.test(item.align[i])) {
- item.align[i] = 'center';
- } else if (/^ *:-+ *$/.test(item.align[i])) {
- item.align[i] = 'left';
- } else {
- item.align[i] = null;
- }
+ }
+
+ if (end === -1) return hasRoot ? '/' : '.';
+ if (hasRoot && end === 1) {
+ // return '//';
+ // Backwards-compat fix:
+ return '/';
+ }
+ return path.slice(0, end);
+ };
+
+ function basename(path) {
+ if (typeof path !== 'string') path = path + '';
+
+ var start = 0;
+ var end = -1;
+ var matchedSlash = true;
+ var i;
+
+ for (i = path.length - 1; i >= 0; --i) {
+ if (path.charCodeAt(i) === 47 /*/*/) {
+ // If we reached a path separator that was not part of a set of path
+ // separators at the end of the string, stop now
+ if (!matchedSlash) {
+ start = i + 1;
+ break;
}
-
- for (i = 0; i < item.cells.length; i++) {
- item.cells[i] = splitCells(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
+ } else if (end === -1) {
+ // We saw the first non-path separator, mark this as the end of our
+ // path component
+ matchedSlash = false;
+ end = i + 1;
+ }
+ }
+
+ if (end === -1) return '';
+ return path.slice(start, end);
+ }
+
+ // Uses a mixed approach for backwards-compatibility, as ext behavior changed
+ // in new Node.js versions, so only basename() above is backported here
+ exports.basename = function (path, ext) {
+ var f = basename(path);
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+ };
+
+ exports.extname = function (path) {
+ if (typeof path !== 'string') path = path + '';
+ var startDot = -1;
+ var startPart = 0;
+ var end = -1;
+ var matchedSlash = true;
+ // Track the state of characters (if any) we see before our first dot and
+ // after any path separator we find
+ var preDotState = 0;
+ for (var i = path.length - 1; i >= 0; --i) {
+ var code = path.charCodeAt(i);
+ if (code === 47 /*/*/) {
+ // If we reached a path separator that was not part of a set of path
+ // separators at the end of the string, stop now
+ if (!matchedSlash) {
+ startPart = i + 1;
+ break;
}
-
- this.tokens.push(item);
-
continue;
}
+ if (end === -1) {
+ // We saw the first non-path separator, mark this as the end of our
+ // extension
+ matchedSlash = false;
+ end = i + 1;
}
-
- // lheading
- if (cap = this.rules.lheading.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'heading',
- depth: cap[2] === '=' ? 1 : 2,
- text: cap[1]
- });
- continue;
- }
-
- // top-level paragraph
- if (top && (cap = this.rules.paragraph.exec(src))) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'paragraph',
- text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
- });
- continue;
- }
-
- // text
- if (cap = this.rules.text.exec(src)) {
- // Top-level should never reach here.
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'text',
- text: cap[0]
- });
- continue;
- }
-
- if (src) {
- throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ if (code === 46 /*.*/) {
+ // If this is our first dot, mark it as the start of our extension
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
+ } else if (startDot !== -1) {
+ // We saw a non-dot and non-path separator before our dot, so we should
+ // have a good chance at having a non-empty extension
+ preDotState = -1;
}
}
-
- return this.tokens;
- };
-
- /**
- * Inline-Level Grammar
- */
-
- var inline = {
- escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
- autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
- url: noop,
- tag: '^comment' + '|^[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
- + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
- + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g.
- + '|^' // declaration, e.g.
- + '|^', // CDATA section
- link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
- reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
- nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
- strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
- em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
- code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
- br: /^( {2,}|\\)\n(?!\s*$)/,
- del: noop,
- text: /^(`+|[^`])[\s\S]*?(?=[\\?@\[\]\\^_`{|}~])/g;
-
- inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
- inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
- inline.autolink = edit(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
-
- inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
-
- inline.tag = edit(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
-
- inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
- inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/;
- inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
-
- inline.link = edit(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
-
- inline.reflink = edit(inline.reflink).replace('label', inline._label).getRegex();
-
- /**
- * Normal Inline Grammar
- */
-
- inline.normal = merge({}, inline);
-
- /**
- * Pedantic Inline Grammar
- */
-
- inline.pedantic = merge({}, inline.normal, {
- strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
- em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
- });
-
- /**
- * GFM Inline Grammar
- */
-
- inline.gfm = merge({}, inline.normal, {
- escape: edit(inline.escape).replace('])', '~|])').getRegex(),
- _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
- url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
- _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
- del: /^~+(?=\S)([\s\S]*?\S)~+/,
- text: edit(inline.text).replace(']|', '~]|').replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$').getRegex()
- });
-
- inline.gfm.url = edit(inline.gfm.url).replace('email', inline.gfm._extended_email).getRegex();
- /**
- * GFM + Line Breaks Inline Grammar
- */
-
- inline.breaks = merge({}, inline.gfm, {
- br: edit(inline.br).replace('{2,}', '*').getRegex(),
- text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
- });
-
- /**
- * Inline Lexer & Compiler
- */
-
- function InlineLexer(links, options) {
- this.options = options || marked.defaults;
- this.links = links;
- this.rules = inline.normal;
- this.renderer = this.options.renderer || new Renderer();
- this.renderer.options = this.options;
-
- if (!this.links) {
- throw new Error('Tokens array requires a `links` property.');
- }
-
- if (this.options.pedantic) {
- this.rules = inline.pedantic;
- } else if (this.options.gfm) {
- if (this.options.breaks) {
- this.rules = inline.breaks;
- } else {
- this.rules = inline.gfm;
- }
+
+ function filter(xs, f) {
+ if (xs.filter) return xs.filter(f);
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ if (f(xs[i], i, xs)) res.push(xs[i]);
}
+ return res;
}
-
- /**
- * Expose Inline Rules
- */
-
- InlineLexer.rules = inline;
-
- /**
- * Static Lexing/Compiling Method
- */
-
- InlineLexer.output = function (src, links, options) {
- var inline = new InlineLexer(links, options);
- return inline.output(src);
+
+ // String.prototype.substr - negative index don't work in IE8
+ var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) {
+ return str.substr(start, len);
+ } : function (str, start, len) {
+ if (start < 0) start = str.length + start;
+ return str.substr(start, len);
};
-
- /**
- * Lexing/Compiling
- */
-
- InlineLexer.prototype.output = function (src) {
- var out = '',
- link,
- text,
- href,
- title,
- cap,
- prevCapZero;
-
- while (src) {
- // escape
- if (cap = this.rules.escape.exec(src)) {
- src = src.substring(cap[0].length);
- out += cap[1];
- continue;
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105}],103:[function(require,module,exports){
+ (function (process){(function (){
+ 'use strict';
+
+ function posix(path) {
+ return path.charAt(0) === '/';
+ }
+
+ function win32(path) {
+ // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
+ var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
+ var result = splitDeviceRe.exec(path);
+ var device = result[1] || '';
+ var isUnc = Boolean(device && device.charAt(1) !== ':');
+
+ // UNC paths are always absolute
+ return Boolean(result[2] || isUnc);
+ }
+
+ module.exports = process.platform === 'win32' ? win32 : posix;
+ module.exports.posix = posix;
+ module.exports.win32 = win32;
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105}],104:[function(require,module,exports){
+ 'use strict';
+
+ var processFn = function (fn, opts) {
+ return function () {
+ var _this = this;
+
+ var P = opts.promiseModule;
+ var args = new Array(arguments.length);
+
+ for (var i = 0; i < arguments.length; i++) {
+ args[i] = arguments[i];
}
-
- // autolink
- if (cap = this.rules.autolink.exec(src)) {
- src = src.substring(cap[0].length);
- if (cap[2] === '@') {
- text = escape(this.mangle(cap[1]));
- href = 'mailto:' + text;
+
+ return new P(function (resolve, reject) {
+ if (opts.errorFirst) {
+ args.push(function (err, result) {
+ if (opts.multiArgs) {
+ var results = new Array(arguments.length - 1);
+
+ for (var _i = 1; _i < arguments.length; _i++) {
+ results[_i - 1] = arguments[_i];
+ }
+
+ if (err) {
+ results.unshift(err);
+ reject(results);
+ } else {
+ resolve(results);
+ }
+ } else if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ });
} else {
- text = escape(cap[1]);
- href = text;
+ args.push(function (result) {
+ if (opts.multiArgs) {
+ var results = new Array(arguments.length - 1);
+
+ for (var _i2 = 0; _i2 < arguments.length; _i2++) {
+ results[_i2] = arguments[_i2];
+ }
+
+ resolve(results);
+ } else {
+ resolve(result);
+ }
+ });
}
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // url (gfm)
- if (!this.inLink && (cap = this.rules.url.exec(src))) {
- if (cap[2] === '@') {
- text = escape(cap[0]);
- href = 'mailto:' + text;
- } else {
- // do extended autolink path validation
- do {
- prevCapZero = cap[0];
- cap[0] = this.rules._backpedal.exec(cap[0])[0];
- } while (prevCapZero !== cap[0]);
- text = escape(cap[0]);
- if (cap[1] === 'www.') {
- href = 'http://' + text;
+
+ fn.apply(_this, args);
+ });
+ };
+ };
+
+ module.exports = function (obj, opts) {
+ opts = Object.assign({
+ exclude: [/.+(Sync|Stream)$/],
+ errorFirst: true,
+ promiseModule: Promise
+ }, opts);
+
+ var filter = function (key) {
+ var match = function (pattern) {
+ return typeof pattern === 'string' ? key === pattern : pattern.test(key);
+ };
+ return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
+ };
+
+ var ret = void 0;
+ if (typeof obj === 'function') {
+ ret = function () {
+ if (opts.excludeMain) {
+ return obj.apply(this, arguments);
+ }
+
+ return processFn(obj, opts).apply(this, arguments);
+ };
+ } else {
+ ret = Object.create(Object.getPrototypeOf(obj));
+ }
+
+ for (var key in obj) {
+ // eslint-disable-line guard-for-in
+ var x = obj[key];
+ ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
+ }
+
+ return ret;
+ };
+ },{}],105:[function(require,module,exports){
+ // shim for using process in browser
+ var process = module.exports = {};
+
+ // cached from whatever global is present so that test runners that stub it
+ // don't break things. But we need to wrap it in a try catch in case it is
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
+ // function because try/catches deoptimize in certain engines.
+
+ var cachedSetTimeout;
+ var cachedClearTimeout;
+
+ function defaultSetTimout() {
+ throw new Error('setTimeout has not been defined');
+ }
+ function defaultClearTimeout() {
+ throw new Error('clearTimeout has not been defined');
+ }
+ (function () {
+ try {
+ if (typeof setTimeout === 'function') {
+ cachedSetTimeout = setTimeout;
} else {
- href = text;
+ cachedSetTimeout = defaultSetTimout;
}
- }
- src = src.substring(cap[0].length);
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // tag
- if (cap = this.rules.tag.exec(src)) {
- if (!this.inLink && /^/i.test(cap[0])) {
- this.inLink = false;
- }
- if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = true;
- } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = false;
- }
-
- src = src.substring(cap[0].length);
- out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
- continue;
+ } catch (e) {
+ cachedSetTimeout = defaultSetTimout;
}
-
- // link
- if (cap = this.rules.link.exec(src)) {
- src = src.substring(cap[0].length);
- this.inLink = true;
- href = cap[2];
- if (this.options.pedantic) {
- link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
-
- if (link) {
- href = link[1];
- title = link[3];
+ try {
+ if (typeof clearTimeout === 'function') {
+ cachedClearTimeout = clearTimeout;
} else {
- title = '';
+ cachedClearTimeout = defaultClearTimeout;
}
- } else {
- title = cap[3] ? cap[3].slice(1, -1) : '';
- }
- href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
- out += this.outputLink(cap, {
- href: InlineLexer.escapes(href),
- title: InlineLexer.escapes(title)
- });
- this.inLink = false;
- continue;
+ } catch (e) {
+ cachedClearTimeout = defaultClearTimeout;
}
-
- // reflink, nolink
- if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
- src = src.substring(cap[0].length);
- link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
- link = this.links[link.toLowerCase()];
- if (!link || !link.href) {
- out += cap[0].charAt(0);
- src = cap[0].substring(1) + src;
- continue;
- }
- this.inLink = true;
- out += this.outputLink(cap, link);
- this.inLink = false;
- continue;
+ })();
+ function runTimeout(fun) {
+ if (cachedSetTimeout === setTimeout) {
+ //normal enviroments in sane situations
+ return setTimeout(fun, 0);
}
-
- // strong
- if (cap = this.rules.strong.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
+ // if setTimeout wasn't available but was latter defined
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
+ cachedSetTimeout = setTimeout;
+ return setTimeout(fun, 0);
}
-
- // em
- if (cap = this.rules.em.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedSetTimeout(fun, 0);
+ } catch (e) {
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedSetTimeout.call(null, fun, 0);
+ } catch (e) {
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
+ return cachedSetTimeout.call(this, fun, 0);
+ }
}
-
- // code
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.codespan(escape(cap[2].trim(), true));
- continue;
+ }
+ function runClearTimeout(marker) {
+ if (cachedClearTimeout === clearTimeout) {
+ //normal enviroments in sane situations
+ return clearTimeout(marker);
}
-
- // br
- if (cap = this.rules.br.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.br();
- continue;
+ // if clearTimeout wasn't available but was latter defined
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
+ cachedClearTimeout = clearTimeout;
+ return clearTimeout(marker);
}
-
- // del (gfm)
- if (cap = this.rules.del.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.del(this.output(cap[1]));
- continue;
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedClearTimeout(marker);
+ } catch (e) {
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedClearTimeout.call(null, marker);
+ } catch (e) {
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
+ return cachedClearTimeout.call(this, marker);
+ }
}
-
- // text
- if (cap = this.rules.text.exec(src)) {
- src = src.substring(cap[0].length);
- if (this.inRawBlock) {
- out += this.renderer.text(cap[0]);
- } else {
- out += this.renderer.text(escape(this.smartypants(cap[0])));
- }
- continue;
+ }
+ var queue = [];
+ var draining = false;
+ var currentQueue;
+ var queueIndex = -1;
+
+ function cleanUpNextTick() {
+ if (!draining || !currentQueue) {
+ return;
}
-
- if (src) {
- throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ draining = false;
+ if (currentQueue.length) {
+ queue = currentQueue.concat(queue);
+ } else {
+ queueIndex = -1;
}
- }
-
- return out;
- };
-
- InlineLexer.escapes = function (text) {
- return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
- };
-
- /**
- * Compile Link
- */
-
- InlineLexer.prototype.outputLink = function (cap, link) {
- var href = link.href,
- title = link.title ? escape(link.title) : null;
-
- return cap[0].charAt(0) !== '!' ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]));
- };
-
- /**
- * Smartypants Transformations
- */
-
- InlineLexer.prototype.smartypants = function (text) {
- if (!this.options.smartypants) return text;
- return text
- // em-dashes
- .replace(/---/g, '\u2014')
- // en-dashes
- .replace(/--/g, '\u2013')
- // opening singles
- .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
- // closing singles & apostrophes
- .replace(/'/g, '\u2019')
- // opening doubles
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
- // closing doubles
- .replace(/"/g, '\u201d')
- // ellipses
- .replace(/\.{3}/g, '\u2026');
- };
-
- /**
- * Mangle Links
- */
-
- InlineLexer.prototype.mangle = function (text) {
- if (!this.options.mangle) return text;
- var out = '',
- l = text.length,
- i = 0,
- ch;
-
- for (; i < l; i++) {
- ch = text.charCodeAt(i);
- if (Math.random() > 0.5) {
- ch = 'x' + ch.toString(16);
+ if (queue.length) {
+ drainQueue();
}
- out += '' + ch + ';';
- }
-
- return out;
- };
-
- /**
- * Renderer
- */
-
- function Renderer(options) {
- this.options = options || marked.defaults;
}
-
- Renderer.prototype.code = function (code, lang, escaped) {
- if (this.options.highlight) {
- var out = this.options.highlight(code, lang);
- if (out != null && out !== code) {
- escaped = true;
- code = out;
+
+ function drainQueue() {
+ if (draining) {
+ return;
+ }
+ var timeout = runTimeout(cleanUpNextTick);
+ draining = true;
+
+ var len = queue.length;
+ while (len) {
+ currentQueue = queue;
+ queue = [];
+ while (++queueIndex < len) {
+ if (currentQueue) {
+ currentQueue[queueIndex].run();
+ }
+ }
+ queueIndex = -1;
+ len = queue.length;
+ }
+ currentQueue = null;
+ draining = false;
+ runClearTimeout(timeout);
+ }
+
+ process.nextTick = function (fun) {
+ var args = new Array(arguments.length - 1);
+ if (arguments.length > 1) {
+ for (var i = 1; i < arguments.length; i++) {
+ args[i - 1] = arguments[i];
+ }
+ }
+ queue.push(new Item(fun, args));
+ if (queue.length === 1 && !draining) {
+ runTimeout(drainQueue);
}
- }
-
- if (!lang) {
- return '' + (escaped ? code : escape(code, true)) + '
';
- }
-
- return '' + (escaped ? code : escape(code, true)) + '
\n';
- };
-
- Renderer.prototype.blockquote = function (quote) {
- return '\n' + quote + '
\n';
- };
-
- Renderer.prototype.html = function (html) {
- return html;
- };
-
- Renderer.prototype.heading = function (text, level, raw) {
- if (this.options.headerIds) {
- return '\n';
- }
- // ignore IDs
- return '' + text + '\n';
- };
-
- Renderer.prototype.hr = function () {
- return this.options.xhtml ? '
\n' : '
\n';
- };
-
- Renderer.prototype.list = function (body, ordered, start) {
- var type = ordered ? 'ol' : 'ul',
- startatt = ordered && start !== 1 ? ' start="' + start + '"' : '';
- return '<' + type + startatt + '>\n' + body + '' + type + '>\n';
- };
-
- Renderer.prototype.listitem = function (text) {
- return '' + text + '\n';
- };
-
- Renderer.prototype.checkbox = function (checked) {
- return ' ';
- };
-
- Renderer.prototype.paragraph = function (text) {
- return '' + text + '
\n';
- };
-
- Renderer.prototype.table = function (header, body) {
- if (body) body = '' + body + '';
-
- return '\n' + '\n' + header + '\n' + body + '
\n';
- };
-
- Renderer.prototype.tablerow = function (content) {
- return '\n' + content + '
\n';
};
-
- Renderer.prototype.tablecell = function (content, flags) {
- var type = flags.header ? 'th' : 'td';
- var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
- return tag + content + '' + type + '>\n';
+
+ // v8 likes predictible objects
+ function Item(fun, array) {
+ this.fun = fun;
+ this.array = array;
+ }
+ Item.prototype.run = function () {
+ this.fun.apply(null, this.array);
};
-
- // span level renderer
- Renderer.prototype.strong = function (text) {
- return '' + text + '';
+ process.title = 'browser';
+ process.browser = true;
+ process.env = {};
+ process.argv = [];
+ process.version = ''; // empty string to avoid regexp issues
+ process.versions = {};
+
+ function noop() {}
+
+ process.on = noop;
+ process.addListener = noop;
+ process.once = noop;
+ process.off = noop;
+ process.removeListener = noop;
+ process.removeAllListeners = noop;
+ process.emit = noop;
+ process.prependListener = noop;
+ process.prependOnceListener = noop;
+
+ process.listeners = function (name) {
+ return [];
};
-
- Renderer.prototype.em = function (text) {
- return '' + text + '';
+
+ process.binding = function (name) {
+ throw new Error('process.binding is not supported');
};
-
- Renderer.prototype.codespan = function (text) {
- return '' + text + '
';
+
+ process.cwd = function () {
+ return '/';
};
-
- Renderer.prototype.br = function () {
- return this.options.xhtml ? '
' : '
';
+ process.chdir = function (dir) {
+ throw new Error('process.chdir is not supported');
};
-
- Renderer.prototype.del = function (text) {
- return '' + text + '';
+ process.umask = function () {
+ return 0;
};
-
- Renderer.prototype.link = function (href, title, text) {
- if (this.options.sanitize) {
- try {
- var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, '').toLowerCase();
- } catch (e) {
- return text;
- }
- if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
- return text;
+ },{}],106:[function(require,module,exports){
+ (function (global){(function (){
+ /*! https://mths.be/punycode v1.4.1 by @mathias */
+ ;(function (root) {
+
+ /** Detect free variables */
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+ var freeModule = typeof module == 'object' && module && !module.nodeType && module;
+ var freeGlobal = typeof global == 'object' && global;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
+ root = freeGlobal;
+ }
+
+ /**
+ * The `punycode` object.
+ * @name punycode
+ * @type Object
+ */
+ var punycode,
+
+
+ /** Highest positive signed 32-bit float value */
+ maxInt = 2147483647,
+ // aka. 0x7FFFFFFF or 2^31-1
+
+ /** Bootstring parameters */
+ base = 36,
+ tMin = 1,
+ tMax = 26,
+ skew = 38,
+ damp = 700,
+ initialBias = 72,
+ initialN = 128,
+ // 0x80
+ delimiter = '-',
+ // '\x2D'
+
+ /** Regular expressions */
+ regexPunycode = /^xn--/,
+ regexNonASCII = /[^\x20-\x7E]/,
+ // unprintable ASCII chars + non-ASCII chars
+ regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
+ // RFC 3490 separators
+
+ /** Error messages */
+ errors = {
+ 'overflow': 'Overflow: input needs wider integers to process',
+ 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
+ 'invalid-input': 'Invalid input'
+ },
+
+
+ /** Convenience shortcuts */
+ baseMinusTMin = base - tMin,
+ floor = Math.floor,
+ stringFromCharCode = String.fromCharCode,
+
+
+ /** Temporary variable */
+ key;
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * A generic error utility function.
+ * @private
+ * @param {String} type The error type.
+ * @returns {Error} Throws a `RangeError` with the applicable error message.
+ */
+ function error(type) {
+ throw new RangeError(errors[type]);
+ }
+
+ /**
+ * A generic `Array#map` utility function.
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} callback The function that gets called for every array
+ * item.
+ * @returns {Array} A new array of values returned by the callback function.
+ */
+ function map(array, fn) {
+ var length = array.length;
+ var result = [];
+ while (length--) {
+ result[length] = fn(array[length]);
}
+ return result;
}
- if (this.options.baseUrl && !originIndependentUrl.test(href)) {
- href = resolveUrl(this.options.baseUrl, href);
+
+ /**
+ * A simple `Array#map`-like wrapper to work with domain name strings or email
+ * addresses.
+ * @private
+ * @param {String} domain The domain name or email address.
+ * @param {Function} callback The function that gets called for every
+ * character.
+ * @returns {Array} A new string of characters returned by the callback
+ * function.
+ */
+ function mapDomain(string, fn) {
+ var parts = string.split('@');
+ var result = '';
+ if (parts.length > 1) {
+ // In email addresses, only the domain name should be punycoded. Leave
+ // the local part (i.e. everything up to `@`) intact.
+ result = parts[0] + '@';
+ string = parts[1];
+ }
+ // Avoid `split(regex)` for IE8 compatibility. See #17.
+ string = string.replace(regexSeparators, '\x2E');
+ var labels = string.split('.');
+ var encoded = map(labels, fn).join('.');
+ return result + encoded;
}
- try {
- href = encodeURI(href).replace(/%25/g, '%');
- } catch (e) {
- return text;
+
+ /**
+ * Creates an array containing the numeric code points of each Unicode
+ * character in the string. While JavaScript uses UCS-2 internally,
+ * this function will convert a pair of surrogate halves (each of which
+ * UCS-2 exposes as separate characters) into a single code point,
+ * matching UTF-16.
+ * @see `punycode.ucs2.encode`
+ * @see
+ * @memberOf punycode.ucs2
+ * @name decode
+ * @param {String} string The Unicode input string (UCS-2).
+ * @returns {Array} The new array of code points.
+ */
+ function ucs2decode(string) {
+ var output = [],
+ counter = 0,
+ length = string.length,
+ value,
+ extra;
+ while (counter < length) {
+ value = string.charCodeAt(counter++);
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
+ // high surrogate, and there is a next character
+ extra = string.charCodeAt(counter++);
+ if ((extra & 0xFC00) == 0xDC00) {
+ // low surrogate
+ output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
+ } else {
+ // unmatched surrogate; only append this code unit, in case the next
+ // code unit is the high surrogate of a surrogate pair
+ output.push(value);
+ counter--;
+ }
+ } else {
+ output.push(value);
+ }
+ }
+ return output;
}
- var out = ' 0xFFFF) {
+ value -= 0x10000;
+ output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
+ value = 0xDC00 | value & 0x3FF;
+ }
+ output += stringFromCharCode(value);
+ return output;
+ }).join('');
}
- out += '>' + text + '';
- return out;
- };
-
- Renderer.prototype.image = function (href, title, text) {
- if (this.options.baseUrl && !originIndependentUrl.test(href)) {
- href = resolveUrl(this.options.baseUrl, href);
+
+ /**
+ * Converts a basic code point into a digit/integer.
+ * @see `digitToBasic()`
+ * @private
+ * @param {Number} codePoint The basic numeric code point value.
+ * @returns {Number} The numeric value of a basic code point (for use in
+ * representing integers) in the range `0` to `base - 1`, or `base` if
+ * the code point does not represent a value.
+ */
+ function basicToDigit(codePoint) {
+ if (codePoint - 48 < 10) {
+ return codePoint - 22;
+ }
+ if (codePoint - 65 < 26) {
+ return codePoint - 65;
+ }
+ if (codePoint - 97 < 26) {
+ return codePoint - 97;
+ }
+ return base;
}
- var out = '> 1;
+ delta += floor(delta / numPoints);
+ for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
+ delta = floor(delta / baseMinusTMin);
+ }
+ return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
}
- out += this.options.xhtml ? '/>' : '>';
- return out;
- };
-
- Renderer.prototype.text = function (text) {
- return text;
- };
-
- /**
- * TextRenderer
- * returns only the textual part of the token
- */
-
- function TextRenderer() {}
-
- // no need for block level renderers
-
- TextRenderer.prototype.strong = TextRenderer.prototype.em = TextRenderer.prototype.codespan = TextRenderer.prototype.del = TextRenderer.prototype.text = function (text) {
- return text;
- };
-
- TextRenderer.prototype.link = TextRenderer.prototype.image = function (href, title, text) {
- return '' + text;
- };
-
- TextRenderer.prototype.br = function () {
- return '';
- };
-
- /**
- * Parsing & Compiling
- */
-
- function Parser(options) {
- this.tokens = [];
- this.token = null;
- this.options = options || marked.defaults;
- this.options.renderer = this.options.renderer || new Renderer();
- this.renderer = this.options.renderer;
- this.renderer.options = this.options;
- }
-
- /**
- * Static Parse Method
- */
-
- Parser.parse = function (src, options) {
- var parser = new Parser(options);
- return parser.parse(src);
- };
-
- /**
- * Parse Loop
- */
-
- Parser.prototype.parse = function (src) {
- this.inline = new InlineLexer(src.links, this.options);
- // use an InlineLexer with a TextRenderer to extract pure text
- this.inlineText = new InlineLexer(src.links, merge({}, this.options, { renderer: new TextRenderer() }));
- this.tokens = src.reverse();
-
- var out = '';
- while (this.next()) {
- out += this.tok();
- }
-
- return out;
- };
-
- /**
- * Next Token
- */
-
- Parser.prototype.next = function () {
- return this.token = this.tokens.pop();
- };
-
- /**
- * Preview Next Token
- */
-
- Parser.prototype.peek = function () {
- return this.tokens[this.tokens.length - 1] || 0;
- };
-
- /**
- * Parse Text Tokens
- */
-
- Parser.prototype.parseText = function () {
- var body = this.token.text;
-
- while (this.peek().type === 'text') {
- body += '\n' + this.next().text;
- }
-
- return this.inline.output(body);
- };
-
- /**
- * Parse Current Token
- */
-
- Parser.prototype.tok = function () {
- switch (this.token.type) {
- case 'space':
- {
- return '';
- }
- case 'hr':
- {
- return this.renderer.hr();
- }
- case 'heading':
- {
- return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, unescape(this.inlineText.output(this.token.text)));
- }
- case 'code':
- {
- return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
+
+ /**
+ * Converts a Punycode string of ASCII-only symbols to a string of Unicode
+ * symbols.
+ * @memberOf punycode
+ * @param {String} input The Punycode string of ASCII-only symbols.
+ * @returns {String} The resulting string of Unicode symbols.
+ */
+ function decode(input) {
+ // Don't use UCS-2
+ var output = [],
+ inputLength = input.length,
+ out,
+ i = 0,
+ n = initialN,
+ bias = initialBias,
+ basic,
+ j,
+ index,
+ oldi,
+ w,
+ k,
+ digit,
+ t,
+
+ /** Cached calculation results */
+ baseMinusT;
+
+ // Handle the basic code points: let `basic` be the number of input code
+ // points before the last delimiter, or `0` if there is none, then copy
+ // the first basic code points to the output.
+
+ basic = input.lastIndexOf(delimiter);
+ if (basic < 0) {
+ basic = 0;
+ }
+
+ for (j = 0; j < basic; ++j) {
+ // if it's not a basic code point
+ if (input.charCodeAt(j) >= 0x80) {
+ error('not-basic');
}
- case 'table':
- {
- var header = '',
- body = '',
- i,
- row,
- cell,
- j;
-
- // header
- cell = '';
- for (i = 0; i < this.token.header.length; i++) {
- cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), { header: true, align: this.token.align[i] });
+ output.push(input.charCodeAt(j));
+ }
+
+ // Main decoding loop: start just after the last delimiter if any basic code
+ // points were copied; start at the beginning otherwise.
+
+ for (index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
+
+ // `index` is the index of the next character to be consumed.
+ // Decode a generalized variable-length integer into `delta`,
+ // which gets added to `i`. The overflow checking is easier
+ // if we increase `i` as we go, then subtract off its starting
+ // value at the end to obtain `delta`.
+ for (oldi = i, w = 1, k = base;; /* no condition */k += base) {
+
+ if (index >= inputLength) {
+ error('invalid-input');
}
- header += this.renderer.tablerow(cell);
-
- for (i = 0; i < this.token.cells.length; i++) {
- row = this.token.cells[i];
-
- cell = '';
- for (j = 0; j < row.length; j++) {
- cell += this.renderer.tablecell(this.inline.output(row[j]), { header: false, align: this.token.align[j] });
- }
-
- body += this.renderer.tablerow(cell);
+
+ digit = basicToDigit(input.charCodeAt(index++));
+
+ if (digit >= base || digit > floor((maxInt - i) / w)) {
+ error('overflow');
}
- return this.renderer.table(header, body);
- }
- case 'blockquote_start':
- {
- body = '';
-
- while (this.next().type !== 'blockquote_end') {
- body += this.tok();
+
+ i += digit * w;
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+
+ if (digit < t) {
+ break;
}
-
- return this.renderer.blockquote(body);
- }
- case 'list_start':
- {
- body = '';
- var ordered = this.token.ordered,
- start = this.token.start;
-
- while (this.next().type !== 'list_end') {
- body += this.tok();
+
+ baseMinusT = base - t;
+ if (w > floor(maxInt / baseMinusT)) {
+ error('overflow');
}
-
- return this.renderer.list(body, ordered, start);
+
+ w *= baseMinusT;
}
- case 'list_item_start':
- {
- body = '';
- var loose = this.token.loose;
-
- if (this.token.task) {
- body += this.renderer.checkbox(this.token.checked);
- }
-
- while (this.next().type !== 'list_item_end') {
- body += !loose && this.token.type === 'text' ? this.parseText() : this.tok();
- }
-
- return this.renderer.listitem(body);
+
+ out = output.length + 1;
+ bias = adapt(i - oldi, out, oldi == 0);
+
+ // `i` was supposed to wrap around from `out` to `0`,
+ // incrementing `n` each time, so we'll fix that now:
+ if (floor(i / out) > maxInt - n) {
+ error('overflow');
}
- case 'html':
- {
- // TODO parse inline content if parameter markdown=1
- return this.renderer.html(this.token.text);
+
+ n += floor(i / out);
+ i %= out;
+
+ // Insert `n` at position `i` of the output
+ output.splice(i++, 0, n);
+ }
+
+ return ucs2encode(output);
+ }
+
+ /**
+ * Converts a string of Unicode symbols (e.g. a domain name label) to a
+ * Punycode string of ASCII-only symbols.
+ * @memberOf punycode
+ * @param {String} input The string of Unicode symbols.
+ * @returns {String} The resulting Punycode string of ASCII-only symbols.
+ */
+ function encode(input) {
+ var n,
+ delta,
+ handledCPCount,
+ basicLength,
+ bias,
+ j,
+ m,
+ q,
+ k,
+ t,
+ currentValue,
+ output = [],
+
+ /** `inputLength` will hold the number of code points in `input`. */
+ inputLength,
+
+ /** Cached calculation results */
+ handledCPCountPlusOne,
+ baseMinusT,
+ qMinusT;
+
+ // Convert the input in UCS-2 to Unicode
+ input = ucs2decode(input);
+
+ // Cache the length
+ inputLength = input.length;
+
+ // Initialize the state
+ n = initialN;
+ delta = 0;
+ bias = initialBias;
+
+ // Handle the basic code points
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue < 0x80) {
+ output.push(stringFromCharCode(currentValue));
}
- case 'paragraph':
- {
- return this.renderer.paragraph(this.inline.output(this.token.text));
+ }
+
+ handledCPCount = basicLength = output.length;
+
+ // `handledCPCount` is the number of code points that have been handled;
+ // `basicLength` is the number of basic code points.
+
+ // Finish the basic string - if it is not empty - with a delimiter
+ if (basicLength) {
+ output.push(delimiter);
+ }
+
+ // Main encoding loop:
+ while (handledCPCount < inputLength) {
+
+ // All non-basic code points < n have been handled already. Find the next
+ // larger one:
+ for (m = maxInt, j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+ if (currentValue >= n && currentValue < m) {
+ m = currentValue;
+ }
}
- case 'text':
- {
- return this.renderer.paragraph(this.parseText());
+
+ // Increase `delta` enough to advance the decoder's state to ,
+ // but guard against overflow
+ handledCPCountPlusOne = handledCPCount + 1;
+ if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
+ error('overflow');
}
- }
- };
-
- /**
- * Helpers
- */
-
- function escape(html, encode) {
- if (encode) {
- if (escape.escapeTest.test(html)) {
- return html.replace(escape.escapeReplace, function (ch) {
- return escape.replacements[ch];
- });
- }
- } else {
- if (escape.escapeTestNoEncode.test(html)) {
- return html.replace(escape.escapeReplaceNoEncode, function (ch) {
- return escape.replacements[ch];
- });
+
+ delta += (m - n) * handledCPCountPlusOne;
+ n = m;
+
+ for (j = 0; j < inputLength; ++j) {
+ currentValue = input[j];
+
+ if (currentValue < n && ++delta > maxInt) {
+ error('overflow');
+ }
+
+ if (currentValue == n) {
+ // Represent delta as a generalized variable-length integer
+ for (q = delta, k = base;; /* no condition */k += base) {
+ t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
+ if (q < t) {
+ break;
+ }
+ qMinusT = q - t;
+ baseMinusT = base - t;
+ output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
+ q = floor(qMinusT / baseMinusT);
+ }
+
+ output.push(stringFromCharCode(digitToBasic(q, 0)));
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
+ delta = 0;
+ ++handledCPCount;
+ }
+ }
+
+ ++delta;
+ ++n;
}
+ return output.join('');
}
-
- return html;
- }
-
- escape.escapeTest = /[&<>"']/;
- escape.escapeReplace = /[&<>"']/g;
- escape.replacements = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": '''
- };
-
- escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
- escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
-
- function unescape(html) {
- // explicitly match decimal, hex, and named HTML entities
- return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function (_, n) {
- n = n.toLowerCase();
- if (n === 'colon') return ':';
- if (n.charAt(0) === '#') {
- return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
- }
- return '';
- });
- }
-
- function edit(regex, opt) {
- regex = regex.source || regex;
- opt = opt || '';
- return {
- replace: function (name, val) {
- val = val.source || val;
- val = val.replace(/(^|[^\[])\^/g, '$1');
- regex = regex.replace(name, val);
- return this;
+
+ /**
+ * Converts a Punycode string representing a domain name or an email address
+ * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
+ * it doesn't matter if you call it on a string that has already been
+ * converted to Unicode.
+ * @memberOf punycode
+ * @param {String} input The Punycoded domain name or email address to
+ * convert to Unicode.
+ * @returns {String} The Unicode representation of the given Punycode
+ * string.
+ */
+ function toUnicode(input) {
+ return mapDomain(input, function (string) {
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
+ });
+ }
+
+ /**
+ * Converts a Unicode string representing a domain name or an email address to
+ * Punycode. Only the non-ASCII parts of the domain name will be converted,
+ * i.e. it doesn't matter if you call it with a domain that's already in
+ * ASCII.
+ * @memberOf punycode
+ * @param {String} input The domain name or email address to convert, as a
+ * Unicode string.
+ * @returns {String} The Punycode representation of the given domain name or
+ * email address.
+ */
+ function toASCII(input) {
+ return mapDomain(input, function (string) {
+ return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
+ });
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /** Define the public API */
+ punycode = {
+ /**
+ * A string representing the current Punycode.js version number.
+ * @memberOf punycode
+ * @type String
+ */
+ 'version': '1.4.1',
+ /**
+ * An object of methods to convert from JavaScript's internal character
+ * representation (UCS-2) to Unicode code points, and back.
+ * @see
+ * @memberOf punycode
+ * @type Object
+ */
+ 'ucs2': {
+ 'decode': ucs2decode,
+ 'encode': ucs2encode
},
- getRegex: function () {
- return new RegExp(regex, opt);
- }
+ 'decode': decode,
+ 'encode': encode,
+ 'toASCII': toASCII,
+ 'toUnicode': toUnicode
};
- }
-
- function resolveUrl(base, href) {
- if (!baseUrls[' ' + base]) {
- // we can ignore everything in base after the last slash of its path component,
- // but we might need to add _that_
- // https://tools.ietf.org/html/rfc3986#section-3
- if (/^[^:]+:\/*[^/]*$/.test(base)) {
- baseUrls[' ' + base] = base + '/';
+
+ /** Expose `punycode` */
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
+ // like the following:
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
+ define('punycode', function () {
+ return punycode;
+ });
+ } else if (freeExports && freeModule) {
+ if (module.exports == freeExports) {
+ // in Node.js, io.js, or RingoJS v0.8.0+
+ freeModule.exports = punycode;
} else {
- baseUrls[' ' + base] = rtrim(base, '/', true);
- }
- }
- base = baseUrls[' ' + base];
-
- if (href.slice(0, 2) === '//') {
- return base.replace(/:[\s\S]*/, ':') + href;
- } else if (href.charAt(0) === '/') {
- return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
- } else {
- return base + href;
- }
- }
- var baseUrls = {};
- var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
-
- function noop() {}
- noop.exec = noop;
-
- function merge(obj) {
- var i = 1,
- target,
- key;
-
- for (; i < arguments.length; i++) {
- target = arguments[i];
- for (key in target) {
- if (Object.prototype.hasOwnProperty.call(target, key)) {
- obj[key] = target[key];
+ // in Narwhal or RingoJS v0.7.0-
+ for (key in punycode) {
+ punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
}
}
- }
-
- return obj;
- }
-
- function splitCells(tableRow, count) {
- // ensure that every cell-delimiting pipe has a space
- // before it to distinguish it from an escaped pipe
- var row = tableRow.replace(/\|/g, function (match, offset, str) {
- var escaped = false,
- curr = offset;
- while (--curr >= 0 && str[curr] === '\\') {
- escaped = !escaped;
- }if (escaped) {
- // odd number of slashes means | is escaped
- // so we leave it alone
- return '|';
- } else {
- // add space before unescaped |
- return ' |';
- }
- }),
- cells = row.split(/ \|/),
- i = 0;
-
- if (cells.length > count) {
- cells.splice(count);
} else {
- while (cells.length < count) {
- cells.push('');
- }
- }
-
- for (; i < cells.length; i++) {
- // leading or trailing whitespace is ignored per the gfm spec
- cells[i] = cells[i].trim().replace(/\\\|/g, '|');
- }
- return cells;
- }
-
- // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
- // /c*$/ is vulnerable to REDOS.
- // invert: Remove suffix of non-c chars instead. Default falsey.
- function rtrim(str, c, invert) {
- if (str.length === 0) {
- return '';
+ // in Rhino or a web browser
+ root.punycode = punycode;
}
-
- // Length of suffix matching the invert condition.
- var suffLen = 0;
-
- // Step left until we fail to match the invert condition.
- while (suffLen < str.length) {
- var currChar = str.charAt(str.length - suffLen - 1);
- if (currChar === c && !invert) {
- suffLen++;
- } else if (currChar !== c && invert) {
- suffLen++;
+ })(this);
+ }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+ },{}],107:[function(require,module,exports){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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';
+
+ // If obj.hasOwnProperty has been overridden, then calling
+ // obj.hasOwnProperty(prop) will break.
+ // See: https://github.com/joyent/node/issues/1707
+
+ function hasOwnProperty(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+ }
+
+ module.exports = function (qs, sep, eq, options) {
+ sep = sep || '&';
+ eq = eq || '=';
+ var obj = {};
+
+ if (typeof qs !== 'string' || qs.length === 0) {
+ return obj;
+ }
+
+ var regexp = /\+/g;
+ qs = qs.split(sep);
+
+ var maxKeys = 1000;
+ if (options && typeof options.maxKeys === 'number') {
+ maxKeys = options.maxKeys;
+ }
+
+ var len = qs.length;
+ // maxKeys <= 0 means that we should not limit keys count
+ if (maxKeys > 0 && len > maxKeys) {
+ len = maxKeys;
+ }
+
+ for (var i = 0; i < len; ++i) {
+ var x = qs[i].replace(regexp, '%20'),
+ idx = x.indexOf(eq),
+ kstr,
+ vstr,
+ k,
+ v;
+
+ if (idx >= 0) {
+ kstr = x.substr(0, idx);
+ vstr = x.substr(idx + 1);
} else {
- break;
- }
- }
-
- return str.substr(0, str.length - suffLen);
- }
-
- /**
- * Marked
- */
-
- function marked(src, opt, callback) {
- // throw error in case of non string input
- if (typeof src === 'undefined' || src === null) {
- throw new Error('marked(): input parameter is undefined or null');
- }
- if (typeof src !== 'string') {
- throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
- }
-
- if (callback || typeof opt === 'function') {
- if (!callback) {
- callback = opt;
- opt = null;
- }
-
- opt = merge({}, marked.defaults, opt || {});
-
- var highlight = opt.highlight,
- tokens,
- pending,
- i = 0;
-
- try {
- tokens = Lexer.lex(src, opt);
- } catch (e) {
- return callback(e);
- }
-
- pending = tokens.length;
-
- var done = function (err) {
- if (err) {
- opt.highlight = highlight;
- return callback(err);
- }
-
- var out;
-
- try {
- out = Parser.parse(tokens, opt);
- } catch (e) {
- err = e;
- }
-
- opt.highlight = highlight;
-
- return err ? callback(err) : callback(null, out);
- };
-
- if (!highlight || highlight.length < 3) {
- return done();
- }
-
- delete opt.highlight;
-
- if (!pending) return done();
-
- for (; i < tokens.length; i++) {
- (function (token) {
- if (token.type !== 'code') {
- return --pending || done();
- }
- return highlight(token.text, token.lang, function (err, code) {
- if (err) return done(err);
- if (code == null || code === token.text) {
- return --pending || done();
- }
- token.text = code;
- token.escaped = true;
- --pending || done();
- });
- })(tokens[i]);
+ kstr = x;
+ vstr = '';
}
-
- return;
- }
- try {
- if (opt) opt = merge({}, marked.defaults, opt);
- return Parser.parse(Lexer.lex(src, opt), opt);
- } catch (e) {
- e.message += '\nPlease report this to https://github.com/markedjs/marked.';
- if ((opt || marked.defaults).silent) {
- return 'An error occurred:
' + escape(e.message + '', true) + '
';
+
+ k = decodeURIComponent(kstr);
+ v = decodeURIComponent(vstr);
+
+ if (!hasOwnProperty(obj, k)) {
+ obj[k] = v;
+ } else if (isArray(obj[k])) {
+ obj[k].push(v);
+ } else {
+ obj[k] = [obj[k], v];
}
- throw e;
}
- }
-
- /**
- * Options
- */
-
- marked.options = marked.setOptions = function (opt) {
- merge(marked.defaults, opt);
- return marked;
+
+ return obj;
};
-
- marked.getDefaults = function () {
- return {
- baseUrl: null,
- breaks: false,
- gfm: true,
- headerIds: true,
- headerPrefix: '',
- highlight: null,
- langPrefix: 'language-',
- mangle: true,
- pedantic: false,
- renderer: new Renderer(),
- sanitize: false,
- sanitizer: null,
- silent: false,
- smartLists: false,
- smartypants: false,
- tables: true,
- xhtml: false
- };
+
+ var isArray = Array.isArray || function (xs) {
+ return Object.prototype.toString.call(xs) === '[object Array]';
};
-
- marked.defaults = marked.getDefaults();
-
- /**
- * Expose
- */
-
- marked.Parser = Parser;
- marked.parser = Parser.parse;
-
- marked.Renderer = Renderer;
- marked.TextRenderer = TextRenderer;
-
- marked.Lexer = Lexer;
- marked.lexer = Lexer.lex;
-
- marked.InlineLexer = InlineLexer;
- marked.inlineLexer = InlineLexer.output;
-
- marked.parse = marked;
-
- if (typeof module !== 'undefined' && typeof exports === 'object') {
- module.exports = marked;
- } else if (typeof define === 'function' && define.amd) {
- define(function () {
- return marked;
- });
- } else {
- root.marked = marked;
- }
-})(this || (typeof window !== 'undefined' ? window : global));
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],72:[function(require,module,exports){
-module.exports = minimatch;
-minimatch.Minimatch = Minimatch;
-
-var path = { sep: '/' };
-try {
- path = require('path');
-} catch (er) {}
-
-var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
-var expand = require('brace-expansion');
-
-var plTypes = {
- '!': { open: '(?:(?!(?:', close: '))[^/]*?)' },
- '?': { open: '(?:', close: ')?' },
- '+': { open: '(?:', close: ')+' },
- '*': { open: '(?:', close: ')*' },
- '@': { open: '(?:', close: ')' }
-
- // any single thing other than /
- // don't need to escape / when using new RegExp()
-};var qmark = '[^/]';
-
-// * => any number of characters
-var star = qmark + '*?';
-
-// ** when dots are allowed. Anything goes, except .. and .
-// not (^ or / followed by one or two dots followed by $ or /),
-// followed by anything, any number of times.
-var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
-
-// not a ^ or / followed by a dot,
-// followed by anything, any number of times.
-var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
-
-// characters that need to be escaped in RegExp.
-var reSpecials = charSet('().*{}+?[]^$\\!');
-
-// "abc" -> { a:true, b:true, c:true }
-function charSet(s) {
- return s.split('').reduce(function (set, c) {
- set[c] = true;
- return set;
- }, {});
-}
-
-// normalizes slashes.
-var slashSplit = /\/+/;
-
-minimatch.filter = filter;
-function filter(pattern, options) {
- options = options || {};
- return function (p, i, list) {
- return minimatch(p, pattern, options);
+ },{}],108:[function(require,module,exports){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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';
+
+ var stringifyPrimitive = function (v) {
+ switch (typeof v) {
+ case 'string':
+ return v;
+
+ case 'boolean':
+ return v ? 'true' : 'false';
+
+ case 'number':
+ return isFinite(v) ? v : '';
+
+ default:
+ return '';
+ }
};
-}
-
-function ext(a, b) {
- a = a || {};
- b = b || {};
- var t = {};
- Object.keys(b).forEach(function (k) {
- t[k] = b[k];
- });
- Object.keys(a).forEach(function (k) {
- t[k] = a[k];
- });
- return t;
-}
-
-minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return minimatch;
-
- var orig = minimatch;
-
- var m = function minimatch(p, pattern, options) {
- return orig.minimatch(p, pattern, ext(def, options));
+
+ module.exports = function (obj, sep, eq, name) {
+ sep = sep || '&';
+ eq = eq || '=';
+ if (obj === null) {
+ obj = undefined;
+ }
+
+ if (typeof obj === 'object') {
+ return map(objectKeys(obj), function (k) {
+ var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
+ if (isArray(obj[k])) {
+ return map(obj[k], function (v) {
+ return ks + encodeURIComponent(stringifyPrimitive(v));
+ }).join(sep);
+ } else {
+ return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
+ }
+ }).join(sep);
+ }
+
+ if (!name) return '';
+ return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
};
-
- m.Minimatch = function Minimatch(pattern, options) {
- return new orig.Minimatch(pattern, ext(def, options));
+
+ var isArray = Array.isArray || function (xs) {
+ return Object.prototype.toString.call(xs) === '[object Array]';
};
-
- return m;
-};
-
-Minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return Minimatch;
- return minimatch.defaults(def).Minimatch;
-};
-
-function minimatch(p, pattern, options) {
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required');
- }
-
- if (!options) options = {};
-
- // shortcut: comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- return false;
+
+ function map(xs, f) {
+ if (xs.map) return xs.map(f);
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ res.push(f(xs[i], i));
+ }
+ return res;
}
-
- // "" only matches ""
- if (pattern.trim() === '') return p === '';
-
- return new Minimatch(pattern, options).match(p);
-}
-
-function Minimatch(pattern, options) {
- if (!(this instanceof Minimatch)) {
- return new Minimatch(pattern, options);
- }
-
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required');
- }
-
- if (!options) options = {};
- pattern = pattern.trim();
-
- // windows support: need to use /, not \
- if (path.sep !== '/') {
- pattern = pattern.split(path.sep).join('/');
- }
-
- this.options = options;
- this.set = [];
- this.pattern = pattern;
- this.regexp = null;
- this.negate = false;
- this.comment = false;
- this.empty = false;
-
- // make the set of regexps etc.
- this.make();
-}
-
-Minimatch.prototype.debug = function () {};
-
-Minimatch.prototype.make = make;
-function make() {
- // don't do it more than once.
- if (this._made) return;
-
- var pattern = this.pattern;
- var options = this.options;
-
- // empty patterns and comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- this.comment = true;
- return;
- }
- if (!pattern) {
- this.empty = true;
- return;
- }
-
- // step 1: figure out negation, etc.
- this.parseNegate();
-
- // step 2: expand braces
- var set = this.globSet = this.braceExpand();
-
- if (options.debug) this.debug = console.error;
-
- this.debug(this.pattern, set);
-
- // step 3: now we have a set, so turn each one into a series of path-portion
- // matching patterns.
- // These will be regexps, except in the case of "**", which is
- // set to the GLOBSTAR object for globstar behavior,
- // and will not contain any / characters
- set = this.globParts = set.map(function (s) {
- return s.split(slashSplit);
- });
-
- this.debug(this.pattern, set);
-
- // glob --> regexps
- set = set.map(function (s, si, set) {
- return s.map(this.parse, this);
- }, this);
-
- this.debug(this.pattern, set);
-
- // filter out everything that didn't compile properly.
- set = set.filter(function (s) {
- return s.indexOf(false) === -1;
- });
-
- this.debug(this.pattern, set);
-
- this.set = set;
-}
-
-Minimatch.prototype.parseNegate = parseNegate;
-function parseNegate() {
- var pattern = this.pattern;
- var negate = false;
- var options = this.options;
- var negateOffset = 0;
-
- if (options.nonegate) return;
-
- for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
- negate = !negate;
- negateOffset++;
- }
-
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
- this.negate = negate;
-}
-
-// Brace expansion:
-// a{b,c}d -> abd acd
-// a{b,}c -> abc ac
-// a{0..3}d -> a0d a1d a2d a3d
-// a{b,c{d,e}f}g -> abg acdfg acefg
-// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
-//
-// Invalid sets are not expanded.
-// a{2..}b -> a{2..}b
-// a{b}c -> a{b}c
-minimatch.braceExpand = function (pattern, options) {
- return braceExpand(pattern, options);
-};
-
-Minimatch.prototype.braceExpand = braceExpand;
-
-function braceExpand(pattern, options) {
- if (!options) {
- if (this instanceof Minimatch) {
- options = this.options;
- } else {
- options = {};
- }
- }
-
- pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
-
- if (typeof pattern === 'undefined') {
- throw new TypeError('undefined pattern');
- }
-
- if (options.nobrace || !pattern.match(/\{.*\}/)) {
- // shortcut. no need to expand.
- return [pattern];
- }
-
- return expand(pattern);
-}
-
-// parse a component of the expanded set.
-// At this point, no pattern may contain "/" in it
-// so we're going to return a 2d array, where each entry is the full
-// pattern, split on '/', and then turned into a regular expression.
-// A regexp is made at the end which joins each array with an
-// escaped /, and another full one which joins each regexp with |.
-//
-// Following the lead of Bash 4.1, note that "**" only has special meaning
-// when it is the *only* thing in a path portion. Otherwise, any series
-// of * is equivalent to a single *. Globstar behavior is enabled by
-// default, and can be disabled by setting options.noglobstar.
-Minimatch.prototype.parse = parse;
-var SUBPARSE = {};
-function parse(pattern, isSub) {
- if (pattern.length > 1024 * 64) {
- throw new TypeError('pattern is too long');
- }
-
- var options = this.options;
-
- // shortcuts
- if (!options.noglobstar && pattern === '**') return GLOBSTAR;
- if (pattern === '') return '';
-
- var re = '';
- var hasMagic = !!options.nocase;
- var escaping = false;
- // ? => one single character
- var patternListStack = [];
- var negativeLists = [];
- var stateChar;
- var inClass = false;
- var reClassStart = -1;
- var classStart = -1;
- // . and .. never match anything that doesn't start with .,
- // even when options.dot is set.
- var patternStart = pattern.charAt(0) === '.' ? '' // anything
- // not (start or / followed by . or .. followed by / or end)
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
- var self = this;
-
- function clearStateChar() {
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case '*':
- re += star;
- hasMagic = true;
- break;
- case '?':
- re += qmark;
- hasMagic = true;
- break;
- default:
- re += '\\' + stateChar;
- break;
- }
- self.debug('clearStateChar %j %j', stateChar, re);
- stateChar = false;
- }
- }
-
- for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
- this.debug('%s\t%s %s %j', pattern, i, re, c);
-
- // skip over any that are escaped.
- if (escaping && reSpecials[c]) {
- re += '\\' + c;
- escaping = false;
- continue;
- }
-
- switch (c) {
- case '/':
- // completely not allowed, even escaped.
- // Should already be path-split by now.
- return false;
-
- case '\\':
- clearStateChar();
- escaping = true;
- continue;
-
- // the various stateChar values
- // for the "extglob" stuff.
- case '?':
- case '*':
- case '+':
- case '@':
- case '!':
- this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
-
- // all of those are literals inside a class, except that
- // the glob [!a] means [^a] in regexp
- if (inClass) {
- this.debug(' in class');
- if (c === '!' && i === classStart + 1) c = '^';
- re += c;
- continue;
- }
-
- // if we already have a stateChar, then it means
- // that there was something like ** or +? in there.
- // Handle the stateChar, then proceed with this one.
- self.debug('call clearStateChar %j', stateChar);
- clearStateChar();
- stateChar = c;
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
- // just clear the statechar *now*, rather than even diving into
- // the patternList stuff.
- if (options.noext) clearStateChar();
- continue;
-
- case '(':
- if (inClass) {
- re += '(';
- continue;
- }
-
- if (!stateChar) {
- re += '\\(';
- continue;
- }
-
- patternListStack.push({
- type: stateChar,
- start: i - 1,
- reStart: re.length,
- open: plTypes[stateChar].open,
- close: plTypes[stateChar].close
- });
- // negation is (?:(?!js)[^/]*)
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
- this.debug('plType %j %j', stateChar, re);
- stateChar = false;
- continue;
-
- case ')':
- if (inClass || !patternListStack.length) {
- re += '\\)';
- continue;
- }
-
- clearStateChar();
- hasMagic = true;
- var pl = patternListStack.pop();
- // negation is (?:(?!js)[^/]*)
- // The others are (?:)
- re += pl.close;
- if (pl.type === '!') {
- negativeLists.push(pl);
- }
- pl.reEnd = re.length;
- continue;
-
- case '|':
- if (inClass || !patternListStack.length || escaping) {
- re += '\\|';
- escaping = false;
- continue;
- }
-
- clearStateChar();
- re += '|';
- continue;
-
- // these are mostly the same in regexp and glob
- case '[':
- // swallow any state-tracking char before the [
- clearStateChar();
-
- if (inClass) {
- re += '\\' + c;
- continue;
- }
-
- inClass = true;
- classStart = i;
- reClassStart = re.length;
- re += c;
- continue;
-
- case ']':
- // a right bracket shall lose its special
- // meaning and represent itself in
- // a bracket expression if it occurs
- // first in the list. -- POSIX.2 2.8.3.2
- if (i === classStart + 1 || !inClass) {
- re += '\\' + c;
- escaping = false;
- continue;
- }
-
- // handle the case where we left a class open.
- // "[z-a]" is valid, equivalent to "\[z-a\]"
- if (inClass) {
- // split where the last [ was, make sure we don't have
- // an invalid re. if so, re-walk the contents of the
- // would-be class to re-translate any characters that
- // were passed through as-is
- // TODO: It would probably be faster to determine this
- // without a try/catch and a new RegExp, but it's tricky
- // to do safely. For now, this is safe and works.
- var cs = pattern.substring(classStart + 1, i);
- try {
- RegExp('[' + cs + ']');
- } catch (er) {
- // not a valid class!
- var sp = this.parse(cs, SUBPARSE);
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
- hasMagic = hasMagic || sp[1];
- inClass = false;
- continue;
- }
- }
-
- // finish up the class.
- hasMagic = true;
- inClass = false;
- re += c;
- continue;
-
- default:
- // swallow any state char that wasn't consumed
- clearStateChar();
-
- if (escaping) {
- // no need
- escaping = false;
- } else if (reSpecials[c] && !(c === '^' && inClass)) {
- re += '\\';
- }
-
- re += c;
-
- } // switch
- } // for
-
- // handle the case where we left a class open.
- // "[abc" is valid, equivalent to "\[abc"
- if (inClass) {
- // split where the last [ was, and escape it
- // this is a huge pita. We now have to re-walk
- // the contents of the would-be class to re-translate
- // any characters that were passed through as-is
- cs = pattern.substr(classStart + 1);
- sp = this.parse(cs, SUBPARSE);
- re = re.substr(0, reClassStart) + '\\[' + sp[0];
- hasMagic = hasMagic || sp[1];
- }
-
- // handle the case where we had a +( thing at the *end*
- // of the pattern.
- // each pattern list stack adds 3 chars, and we need to go through
- // and escape any | chars that were passed through as-is for the regexp.
- // Go through and escape them, taking care not to double-escape any
- // | chars that were already escaped.
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
- var tail = re.slice(pl.reStart + pl.open.length);
- this.debug('setting tail', re, pl);
- // maybe some even number of \, then maybe 1 \, followed by a |
- tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
- if (!$2) {
- // the | isn't already escaped, so escape it.
- $2 = '\\';
- }
-
- // need to escape all those slashes *again*, without escaping the
- // one that we need for escaping the | character. As it works out,
- // escaping an even number of slashes can be done by simply repeating
- // it exactly after itself. That's why this trick works.
- //
- // I am sorry that you have to see this.
- return $1 + $1 + $2 + '|';
- });
-
- this.debug('tail=%j\n %s', tail, tail, pl, re);
- var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
-
- hasMagic = true;
- re = re.slice(0, pl.reStart) + t + '\\(' + tail;
- }
-
- // handle trailing things that only matter at the very end.
- clearStateChar();
- if (escaping) {
- // trailing \\
- re += '\\\\';
- }
-
- // only need to apply the nodot start if the re starts with
- // something that could conceivably capture a dot
- var addPatternStart = false;
- switch (re.charAt(0)) {
- case '.':
- case '[':
- case '(':
- addPatternStart = true;
- }
-
- // Hack to work around lack of negative lookbehind in JS
- // A pattern like: *.!(x).!(y|z) needs to ensure that a name
- // like 'a.xyz.yz' doesn't match. So, the first negative
- // lookahead, has to look ALL the way ahead, to the end of
- // the pattern.
- for (var n = negativeLists.length - 1; n > -1; n--) {
- var nl = negativeLists[n];
-
- var nlBefore = re.slice(0, nl.reStart);
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
- var nlAfter = re.slice(nl.reEnd);
-
- nlLast += nlAfter;
-
- // Handle nested stuff like *(*.js|!(*.json)), where open parens
- // mean that we should *not* include the ) in the bit that is considered
- // "after" the negated section.
- var openParensBefore = nlBefore.split('(').length - 1;
- var cleanAfter = nlAfter;
- for (i = 0; i < openParensBefore; i++) {
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
- }
- nlAfter = cleanAfter;
-
- var dollar = '';
- if (nlAfter === '' && isSub !== SUBPARSE) {
- dollar = '$';
- }
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
- re = newRe;
- }
-
- // if the re is not "" at this point, then we need to make sure
- // it doesn't match against an empty path part.
- // Otherwise a/* will match a/, which it should not.
- if (re !== '' && hasMagic) {
- re = '(?=.)' + re;
- }
-
- if (addPatternStart) {
- re = patternStart + re;
- }
-
- // parsing just a piece of a larger pattern.
- if (isSub === SUBPARSE) {
- return [re, hasMagic];
- }
-
- // skip the regexp for non-magical patterns
- // unescape anything in it, though, so that it'll be
- // an exact match against a file etc.
- if (!hasMagic) {
- return globUnescape(pattern);
- }
-
- var flags = options.nocase ? 'i' : '';
- try {
- var regExp = new RegExp('^' + re + '$', flags);
- } catch (er) {
- // If it was an invalid regular expression, then it can't match
- // anything. This trick looks for a character after the end of
- // the string, which is of course impossible, except in multi-line
- // mode, but it's not a /m regex.
- return new RegExp('$.');
- }
-
- regExp._glob = pattern;
- regExp._src = re;
-
- return regExp;
-}
-
-minimatch.makeRe = function (pattern, options) {
- return new Minimatch(pattern, options || {}).makeRe();
-};
-
-Minimatch.prototype.makeRe = makeRe;
-function makeRe() {
- if (this.regexp || this.regexp === false) return this.regexp;
-
- // at this point, this.set is a 2d array of partial
- // pattern strings, or "**".
- //
- // It's better to use .match(). This function shouldn't
- // be used, really, but it's pretty convenient sometimes,
- // when you just want to work with a regex.
- var set = this.set;
-
- if (!set.length) {
- this.regexp = false;
- return this.regexp;
+
+ var objectKeys = Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
+ }
+ return res;
+ };
+ },{}],109:[function(require,module,exports){
+ 'use strict';
+
+ exports.decode = exports.parse = require('./decode');
+ exports.encode = exports.stringify = require('./encode');
+ },{"./decode":107,"./encode":108}],110:[function(require,module,exports){
+ 'use strict';
+
+ /**
+ * Remove a range of items from an array
+ *
+ * @function removeItems
+ * @param {Array<*>} arr The target array
+ * @param {number} startIdx The index to begin removing from (inclusive)
+ * @param {number} removeCount How many items to remove
+ */
+
+ module.exports = function removeItems(arr, startIdx, removeCount) {
+ var i,
+ length = arr.length;
+
+ if (startIdx >= length || removeCount === 0) {
+ return;
+ }
+
+ removeCount = startIdx + removeCount > length ? length - startIdx : removeCount;
+
+ var len = length - removeCount;
+
+ for (i = startIdx; i < len; ++i) {
+ arr[i] = arr[i + removeCount];
+ }
+
+ arr.length = len;
+ };
+ },{}],111:[function(require,module,exports){
+ (function (process){(function (){
+ var isWin = process.platform === 'win32';
+
+ module.exports = function (str) {
+ var i = str.length - 1;
+ if (i < 2) {
+ return str;
+ }
+ while (isSeparator(str, i)) {
+ i--;
+ }
+ return str.substr(0, i + 1);
+ };
+
+ function isSeparator(str, i) {
+ var char = str[i];
+ return i > 0 && (char === '/' || isWin && char === '\\');
+ }
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105}],112:[function(require,module,exports){
+ (function (process){(function (){
+ /*!
+ * resolve-path
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2015-2018 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+ 'use strict';
+
+ /**
+ * Module dependencies.
+ * @private
+ */
+
+ var createError = require('http-errors');
+ var join = require('path').join;
+ var normalize = require('path').normalize;
+ var pathIsAbsolute = require('path-is-absolute');
+ var resolve = require('path').resolve;
+ var sep = require('path').sep;
+
+ /**
+ * Module exports.
+ * @public
+ */
+
+ module.exports = resolvePath;
+
+ /**
+ * Module variables.
+ * @private
+ */
+
+ var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
+
+ /**
+ * Resolve relative path against a root path
+ *
+ * @param {string} rootPath
+ * @param {string} relativePath
+ * @return {string}
+ * @public
+ */
+
+ function resolvePath(rootPath, relativePath) {
+ var path = relativePath;
+ var root = rootPath;
+
+ // root is optional, similar to root.resolve
+ if (arguments.length === 1) {
+ path = rootPath;
+ root = process.cwd();
+ }
+
+ if (root == null) {
+ throw new TypeError('argument rootPath is required');
+ }
+
+ if (typeof root !== 'string') {
+ throw new TypeError('argument rootPath must be a string');
+ }
+
+ if (path == null) {
+ throw new TypeError('argument relativePath is required');
+ }
+
+ if (typeof path !== 'string') {
+ throw new TypeError('argument relativePath must be a string');
+ }
+
+ // containing NULL bytes is malicious
+ if (path.indexOf('\0') !== -1) {
+ throw createError(400, 'Malicious Path');
+ }
+
+ // path should never be absolute
+ if (pathIsAbsolute.posix(path) || pathIsAbsolute.win32(path)) {
+ throw createError(400, 'Malicious Path');
+ }
+
+ // path outside root
+ if (UP_PATH_REGEXP.test(normalize('.' + sep + path))) {
+ throw createError(403);
+ }
+
+ // join the relative path
+ return normalize(join(resolve(root), path));
+ }
+ }).call(this)}).call(this,require('_process'))
+ },{"_process":105,"http-errors":22,"path":102,"path-is-absolute":103}],113:[function(require,module,exports){
+ module.exports = scrollToAnchor;
+
+ function scrollToAnchor(anchor, options) {
+ if (anchor) {
+ try {
+ var el = document.querySelector(anchor);
+ if (el) el.scrollIntoView(options);
+ } catch (e) {}
+ }
}
- var options = this.options;
-
- var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
- var flags = options.nocase ? 'i' : '';
-
- var re = set.map(function (pattern) {
- return pattern.map(function (p) {
- return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
- }).join('\\\/');
- }).join('|');
-
- // must match entire pattern
- // ending in a * or ** will make it less strict.
- re = '^(?:' + re + ')$';
-
- // can match anything, as long as it's not this.
- if (this.negate) re = '^(?!' + re + ').*$';
-
- try {
- this.regexp = new RegExp(re, flags);
- } catch (ex) {
- this.regexp = false;
- }
- return this.regexp;
-}
-
-minimatch.match = function (list, pattern, options) {
- options = options || {};
- var mm = new Minimatch(pattern, options);
- list = list.filter(function (f) {
- return mm.match(f);
- });
- if (mm.options.nonull && !list.length) {
- list.push(pattern);
- }
- return list;
-};
-
-Minimatch.prototype.match = match;
-function match(f, partial) {
- this.debug('match', f, this.pattern);
- // short-circuit in the case of busted things.
- // comments, etc.
- if (this.comment) return false;
- if (this.empty) return f === '';
-
- if (f === '/' && partial) return true;
-
- var options = this.options;
-
- // windows: need to use /, not \
- if (path.sep !== '/') {
- f = f.split(path.sep).join('/');
- }
-
- // treat the test path as a set of pathparts.
- f = f.split(slashSplit);
- this.debug(this.pattern, 'split', f);
-
- // just ONE of the pattern sets in this.set needs to match
- // in order for it to be valid. If negating, then just one
- // match means that we have failed.
- // Either way, return on the first hit.
-
- var set = this.set;
- this.debug(this.pattern, 'set', set);
-
- // Find the basename of the path by looking for the last non-empty segment
- var filename;
- var i;
- for (i = f.length - 1; i >= 0; i--) {
- filename = f[i];
- if (filename) break;
- }
-
- for (i = 0; i < set.length; i++) {
- var pattern = set[i];
- var file = f;
- if (options.matchBase && pattern.length === 1) {
- file = [filename];
- }
- var hit = this.matchOne(file, pattern, partial);
- if (hit) {
- if (options.flipNegate) return true;
- return !this.negate;
- }
- }
-
- // didn't get any hits. this is success if it's a negative
- // pattern, failure otherwise.
- if (options.flipNegate) return false;
- return this.negate;
-}
-
-// set partial to true to test if, for example,
-// "/a/b" matches the start of "/*/b/*/d"
-// Partial means, if you run out of file before you run
-// out of pattern, then that's fine, as long as all
-// the parts match.
-Minimatch.prototype.matchOne = function (file, pattern, partial) {
- var options = this.options;
-
- this.debug('matchOne', { 'this': this, file: file, pattern: pattern });
-
- this.debug('matchOne', file.length, pattern.length);
-
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
- this.debug('matchOne loop');
- var p = pattern[pi];
- var f = file[fi];
-
- this.debug(pattern, p, f);
-
- // should be impossible.
- // some invalid regexp stuff in the set.
- if (p === false) return false;
-
- if (p === GLOBSTAR) {
- this.debug('GLOBSTAR', [pattern, p, f]);
-
- // "**"
- // a/**/b/**/c would match the following:
- // a/b/x/y/z/c
- // a/x/y/z/b/c
- // a/b/x/b/x/c
- // a/b/c
- // To do this, take the rest of the pattern after
- // the **, and see if it would match the file remainder.
- // If so, return success.
- // If not, the ** "swallows" a segment, and try again.
- // This is recursively awful.
- //
- // a/**/b/**/c matching a/b/x/y/z/c
- // - a matches a
- // - doublestar
- // - matchOne(b/x/y/z/c, b/**/c)
- // - b matches b
- // - doublestar
- // - matchOne(x/y/z/c, c) -> no
- // - matchOne(y/z/c, c) -> no
- // - matchOne(z/c, c) -> no
- // - matchOne(c, c) yes, hit
- var fr = fi;
- var pr = pi + 1;
- if (pr === pl) {
- this.debug('** at the end');
- // a ** at the end will just swallow the rest.
- // We have found a match.
- // however, it will not swallow /.x, unless
- // options.dot is set.
- // . and .. are *never* matched by **, for explosively
- // exponential reasons.
- for (; fi < fl; fi++) {
- if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
- }
- return true;
+ },{}],114:[function(require,module,exports){
+ module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
+
+ function setProtoOf(obj, proto) {
+ obj.__proto__ = proto;
+ return obj;
+ }
+
+ function mixinProperties(obj, proto) {
+ for (var prop in proto) {
+ if (!obj.hasOwnProperty(prop)) {
+ obj[prop] = proto[prop];
}
-
- // ok, let's see if we can swallow whatever we can.
- while (fr < fl) {
- var swallowee = file[fr];
-
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
-
- // XXX remove this slice. Just pass the start index.
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
- this.debug('globstar found match!', fr, fl, swallowee);
- // found a match.
- return true;
- } else {
- // can't swallow "." or ".." ever.
- // can only swallow ".foo" when explicitly asked.
- if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
- this.debug('dot detected!', file, fr, pattern, pr);
- break;
+ }
+ return obj;
+ }
+ },{}],115:[function(require,module,exports){
+ module.exports = require('insert-css');
+ },{"insert-css":41}],116:[function(require,module,exports){
+ module.exports = {
+ stringify: require('./lib/stringify'),
+ parse: require('./lib/parse')
+ };
+ },{"./lib/parse":117,"./lib/stringify":118}],117:[function(require,module,exports){
+ var assert = require('assert');
+ var yaml = require('js-yaml');
+ var xtend = require('xtend');
+
+ var utils = require('./utils');
+
+ module.exports = parse;
+
+ function parse(str) {
+ assert.equal(typeof str, 'string', 'smarkt: arg1 str must be type string');
+
+ return str.split('\n----').filter(function (str) {
+ return str;
+ }).reduce(function (result, field) {
+ var data = field.replace(/^\s+|\s+$/g, '').split(/:([^]+)/).filter(function (str) {
+ return str.trim() !== '';
+ });
+
+ var key = data[0].replace(':', '');
+
+ if (data.length >= 2) {
+ var value = data[1];
+
+ var firstBreak = value.split('\n', 2)[1];
+ var isYaml = typeof firstBreak === 'string' ? firstBreak.substring(0, 2) === ' ' : false;
+
+ if (isYaml) {
+ try {
+ result = xtend(result, yaml.safeLoad(field));
+ } catch (err) {
+ result[key] = utils.parseSpecial(value.trim());
}
-
- // ** swallows a segment, and continue.
- this.debug('globstar swallow a segment, and continue');
- fr++;
+ } else {
+ result[key] = utils.parseSpecial(value.trim());
}
+ } else {
+ result[key] = '';
}
-
- // no match was found.
- // However, in partial mode, we can't say this is necessarily over.
- // If there's more *pattern* left, then
- if (partial) {
- // ran out of file
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
- if (fr === fl) return true;
- }
- return false;
- }
-
- // something other than **
- // non-magic patterns just have to match exactly
- // patterns with magic have been turned into regexps.
- var hit;
- if (typeof p === 'string') {
- if (options.nocase) {
- hit = f.toLowerCase() === p.toLowerCase();
+
+ return result;
+ }, {});
+ }
+ },{"./utils":119,"assert":1,"js-yaml":43,"xtend":131}],118:[function(require,module,exports){
+ 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 objectKeys = require('object-keys');
+ var assert = require('assert');
+ var yaml = require('js-yaml');
+
+ module.exports = stringify;
+
+ function stringify(obj) {
+ assert.equal(typeof obj, 'object', 'smarkt: arg1 str must be type object');
+
+ return objectKeys(obj).reduce(function (result, key) {
+ var value = typeof obj[key] === 'undefined' ? '' : obj[key];
+
+ var stringified;
+ if (value == null) {
+ stringified = key + ':';
+ } else if (typeof value === 'object') {
+ stringified = yaml.safeDump(_defineProperty({}, key, value));
} else {
- hit = f === p;
+ stringified = key + ': ' + value;
}
- this.debug('string match', p, f, hit);
- } else {
- hit = f.match(p);
- this.debug('pattern match', p, f, hit);
- }
-
- if (!hit) return false;
- }
-
- // Note: ending in / means that we'll get a final ""
- // at the end of the pattern. This can only match a
- // corresponding "" at the end of the file.
- // If the file ends in /, then it can only match a
- // a pattern that ends in /, unless the pattern just
- // doesn't have any more for it. But, a/b/ should *not*
- // match "a/b/*", even though "" matches against the
- // [^/]*? pattern, except in partial mode, where it might
- // simply not be reached yet.
- // However, a/b/ should still satisfy a/*
-
- // now either we fell off the end of the pattern, or we're done.
- if (fi === fl && pi === pl) {
- // ran out of pattern and filename at the same time.
- // an exact hit!
- return true;
- } else if (fi === fl) {
- // ran out of file, but still had pattern left.
- // this is ok if we're doing the match as part of
- // a glob fs traversal.
- return partial;
- } else if (pi === pl) {
- // ran out of pattern, still have file left.
- // this is only acceptable if we're on the very last
- // empty segment of a file with a trailing slash.
- // a/* should match a/b/
- var emptyFileEnd = fi === fl - 1 && file[fi] === '';
- return emptyFileEnd;
- }
-
- // should be unreachable.
- throw new Error('wtf?');
-};
-
-// replace stuff like \* with *
-function globUnescape(s) {
- return s.replace(/\\(.)/g, '$1');
-}
-
-function regExpEscape(s) {
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
-}
-},{"brace-expansion":7,"path":98}],73:[function(require,module,exports){
-assert.notEqual = notEqual;
-assert.notOk = notOk;
-assert.equal = equal;
-assert.ok = assert;
-
-module.exports = assert;
-
-function equal(a, b, m) {
- assert(a == b, m); // eslint-disable-line eqeqeq
-}
-
-function notEqual(a, b, m) {
- assert(a != b, m); // eslint-disable-line eqeqeq
-}
-
-function notOk(t, m) {
- assert(!t, m);
-}
-
-function assert(t, m) {
- if (!t) throw new Error(m || 'AssertionError');
-}
-},{}],74:[function(require,module,exports){
-var splice = require('remove-array-items');
-var nanotiming = require('nanotiming');
-var assert = require('assert');
-
-module.exports = Nanobus;
-
-function Nanobus(name) {
- if (!(this instanceof Nanobus)) return new Nanobus(name);
-
- this._name = name || 'nanobus';
- this._starListeners = [];
- this._listeners = {};
-}
-
-Nanobus.prototype.emit = function (eventName) {
- assert.equal(typeof eventName, 'string', 'nanobus.emit: eventName should be type string');
-
- var data = [];
- for (var i = 1, len = arguments.length; i < len; i++) {
- data.push(arguments[i]);
- }
-
- var emitTiming = nanotiming(this._name + "('" + eventName + "')");
- var listeners = this._listeners[eventName];
- if (listeners && listeners.length > 0) {
- this._emit(this._listeners[eventName], data);
- }
-
- if (this._starListeners.length > 0) {
- this._emit(this._starListeners, eventName, data, emitTiming.uuid);
- }
- emitTiming();
-
- return this;
-};
-
-Nanobus.prototype.on = Nanobus.prototype.addListener = function (eventName, listener) {
- assert.equal(typeof eventName, 'string', 'nanobus.on: eventName should be type string');
- assert.equal(typeof listener, 'function', 'nanobus.on: listener should be type function');
-
- if (eventName === '*') {
- this._starListeners.push(listener);
- } else {
- if (!this._listeners[eventName]) this._listeners[eventName] = [];
- this._listeners[eventName].push(listener);
- }
- return this;
-};
-
-Nanobus.prototype.prependListener = function (eventName, listener) {
- assert.equal(typeof eventName, 'string', 'nanobus.prependListener: eventName should be type string');
- assert.equal(typeof listener, 'function', 'nanobus.prependListener: listener should be type function');
-
- if (eventName === '*') {
- this._starListeners.unshift(listener);
- } else {
- if (!this._listeners[eventName]) this._listeners[eventName] = [];
- this._listeners[eventName].unshift(listener);
- }
- return this;
-};
-
-Nanobus.prototype.once = function (eventName, listener) {
- assert.equal(typeof eventName, 'string', 'nanobus.once: eventName should be type string');
- assert.equal(typeof listener, 'function', 'nanobus.once: listener should be type function');
-
- var self = this;
- this.on(eventName, once);
- function once() {
- listener.apply(self, arguments);
- self.removeListener(eventName, once);
- }
- return this;
-};
-
-Nanobus.prototype.prependOnceListener = function (eventName, listener) {
- assert.equal(typeof eventName, 'string', 'nanobus.prependOnceListener: eventName should be type string');
- assert.equal(typeof listener, 'function', 'nanobus.prependOnceListener: listener should be type function');
-
- var self = this;
- this.prependListener(eventName, once);
- function once() {
- listener.apply(self, arguments);
- self.removeListener(eventName, once);
- }
- return this;
-};
-
-Nanobus.prototype.removeListener = function (eventName, listener) {
- assert.equal(typeof eventName, 'string', 'nanobus.removeListener: eventName should be type string');
- assert.equal(typeof listener, 'function', 'nanobus.removeListener: listener should be type function');
-
- if (eventName === '*') {
- this._starListeners = this._starListeners.slice();
- return remove(this._starListeners, listener);
- } else {
- if (typeof this._listeners[eventName] !== 'undefined') {
- this._listeners[eventName] = this._listeners[eventName].slice();
- }
-
- return remove(this._listeners[eventName], listener);
- }
-
- function remove(arr, listener) {
- if (!arr) return;
- var index = arr.indexOf(listener);
- if (index !== -1) {
- splice(arr, index, 1);
- return true;
- }
+
+ result.push(stringified.trim());
+
+ return result;
+ }, []).join('\n----\n');
}
-};
-
-Nanobus.prototype.removeAllListeners = function (eventName) {
- if (eventName) {
- if (eventName === '*') {
- this._starListeners = [];
- } else {
- this._listeners[eventName] = [];
- }
- } else {
- this._starListeners = [];
- this._listeners = {};
+ },{"assert":1,"js-yaml":43,"object-keys":95}],119:[function(require,module,exports){
+ module.exports = {
+ parseSpecial: parseSpecial
+ };
+
+ function parseSpecial(str) {
+ if (str === 'true') return true;
+ if (str === 'false') return false;
+ if (str === '[]') return [];
+ if (str === '{}') return {};
+ return str;
}
- return this;
-};
-
-Nanobus.prototype.listeners = function (eventName) {
- var listeners = eventName !== '*' ? this._listeners[eventName] : this._starListeners;
-
- var ret = [];
- if (listeners) {
- var ilength = listeners.length;
- for (var i = 0; i < ilength; i++) {
- ret.push(listeners[i]);
- }
- }
- return ret;
-};
-
-Nanobus.prototype._emit = function (arr, eventName, data, uuid) {
- if (typeof arr === 'undefined') return;
- if (arr.length === 0) return;
- if (data === undefined) {
- data = eventName;
- eventName = null;
- }
-
- if (eventName) {
- if (uuid !== undefined) {
- data = [eventName].concat(data, uuid);
- } else {
- data = [eventName].concat(data);
- }
- }
-
- var length = arr.length;
- for (var i = 0; i < length; i++) {
- var listener = arr[i];
- listener.apply(listener, data);
- }
-};
-},{"assert":73,"nanotiming":89,"remove-array-items":106}],75:[function(require,module,exports){
-var assert = require('assert');
-
-var safeExternalLink = /(noopener|noreferrer) (noopener|noreferrer)/;
-var protocolLink = /^[\w-_]+:/;
-
-module.exports = href;
-
-function href(cb, root) {
- assert.notEqual(typeof window, 'undefined', 'nanohref: expected window to exist');
-
- root = root || window.document;
-
- assert.equal(typeof cb, 'function', 'nanohref: cb should be type function');
- assert.equal(typeof root, 'object', 'nanohref: root should be type object');
-
- window.addEventListener('click', function (e) {
- if (e.button && e.button !== 0 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.defaultPrevented) return;
-
- var anchor = function traverse(node) {
- if (!node || node === root) return;
- if (node.localName !== 'a' || node.href === undefined) {
- return traverse(node.parentNode);
- }
- return node;
- }(e.target);
-
- if (!anchor) return;
-
- if (window.location.protocol !== anchor.protocol || window.location.hostname !== anchor.hostname || window.location.port !== anchor.port || anchor.hasAttribute('data-nanohref-ignore') || anchor.hasAttribute('download') || anchor.getAttribute('target') === '_blank' && safeExternalLink.test(anchor.getAttribute('rel')) || protocolLink.test(anchor.getAttribute('href'))) return;
-
- e.preventDefault();
- cb(anchor);
- });
-}
-},{"assert":73}],76:[function(require,module,exports){
-var trailingNewlineRegex = /\n[\s]+$/;
-var leadingNewlineRegex = /^\n[\s]+/;
-var trailingSpaceRegex = /[\s]+$/;
-var leadingSpaceRegex = /^[\s]+/;
-var multiSpaceRegex = /[\n\s]+/g;
-
-var TEXT_TAGS = ['a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'data', 'dfn', 'em', 'i', 'kbd', 'mark', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'amp', 'small', 'span', 'strong', 'sub', 'sup', 'time', 'u', 'var', 'wbr'];
-
-var VERBATIM_TAGS = ['code', 'pre', 'textarea'];
-
-module.exports = function appendChild(el, childs) {
- if (!Array.isArray(childs)) return;
-
- var nodeName = el.nodeName.toLowerCase();
-
- var hadText = false;
- var value, leader;
-
- for (var i = 0, len = childs.length; i < len; i++) {
- var node = childs[i];
- if (Array.isArray(node)) {
- appendChild(el, node);
- continue;
- }
-
- if (typeof node === 'number' || typeof node === 'boolean' || typeof node === 'function' || node instanceof Date || node instanceof RegExp) {
- node = node.toString();
- }
-
- var lastChild = el.childNodes[el.childNodes.length - 1];
-
- // Iterate over text nodes
- if (typeof node === 'string') {
- hadText = true;
-
- // If we already had text, append to the existing text
- if (lastChild && lastChild.nodeName === '#text') {
- lastChild.nodeValue += node;
-
- // We didn't have a text node yet, create one
- } else {
- node = document.createTextNode(node);
- el.appendChild(node);
- lastChild = node;
- }
-
- // If this is the last of the child nodes, make sure we close it out
- // right
- if (i === len - 1) {
- hadText = false;
- // Trim the child text nodes if the current node isn't a
- // node where whitespace matters.
- if (TEXT_TAGS.indexOf(nodeName) === -1 && VERBATIM_TAGS.indexOf(nodeName) === -1) {
- value = lastChild.nodeValue.replace(leadingNewlineRegex, '').replace(trailingSpaceRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
- if (value === '') {
- el.removeChild(lastChild);
+ },{}],120:[function(require,module,exports){
+ module.exports={
+ "100": "Continue",
+ "101": "Switching Protocols",
+ "102": "Processing",
+ "103": "Early Hints",
+ "200": "OK",
+ "201": "Created",
+ "202": "Accepted",
+ "203": "Non-Authoritative Information",
+ "204": "No Content",
+ "205": "Reset Content",
+ "206": "Partial Content",
+ "207": "Multi-Status",
+ "208": "Already Reported",
+ "226": "IM Used",
+ "300": "Multiple Choices",
+ "301": "Moved Permanently",
+ "302": "Found",
+ "303": "See Other",
+ "304": "Not Modified",
+ "305": "Use Proxy",
+ "306": "(Unused)",
+ "307": "Temporary Redirect",
+ "308": "Permanent Redirect",
+ "400": "Bad Request",
+ "401": "Unauthorized",
+ "402": "Payment Required",
+ "403": "Forbidden",
+ "404": "Not Found",
+ "405": "Method Not Allowed",
+ "406": "Not Acceptable",
+ "407": "Proxy Authentication Required",
+ "408": "Request Timeout",
+ "409": "Conflict",
+ "410": "Gone",
+ "411": "Length Required",
+ "412": "Precondition Failed",
+ "413": "Payload Too Large",
+ "414": "URI Too Long",
+ "415": "Unsupported Media Type",
+ "416": "Range Not Satisfiable",
+ "417": "Expectation Failed",
+ "418": "I'm a teapot",
+ "421": "Misdirected Request",
+ "422": "Unprocessable Entity",
+ "423": "Locked",
+ "424": "Failed Dependency",
+ "425": "Unordered Collection",
+ "426": "Upgrade Required",
+ "428": "Precondition Required",
+ "429": "Too Many Requests",
+ "431": "Request Header Fields Too Large",
+ "451": "Unavailable For Legal Reasons",
+ "500": "Internal Server Error",
+ "501": "Not Implemented",
+ "502": "Bad Gateway",
+ "503": "Service Unavailable",
+ "504": "Gateway Timeout",
+ "505": "HTTP Version Not Supported",
+ "506": "Variant Also Negotiates",
+ "507": "Insufficient Storage",
+ "508": "Loop Detected",
+ "509": "Bandwidth Limit Exceeded",
+ "510": "Not Extended",
+ "511": "Network Authentication Required"
+ }
+
+ },{}],121:[function(require,module,exports){
+ /*!
+ * statuses
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2016 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+ 'use strict';
+
+ /**
+ * Module dependencies.
+ * @private
+ */
+
+ var codes = require('./codes.json');
+
+ /**
+ * Module exports.
+ * @public
+ */
+
+ module.exports = status;
+
+ // status code to message map
+ status.STATUS_CODES = codes;
+
+ // array of status codes
+ status.codes = populateStatusesMap(status, codes);
+
+ // status codes for redirects
+ status.redirect = {
+ 300: true,
+ 301: true,
+ 302: true,
+ 303: true,
+ 305: true,
+ 307: true,
+ 308: true
+
+ // status codes for empty bodies
+ };status.empty = {
+ 204: true,
+ 205: true,
+ 304: true
+
+ // status codes for when you should retry the request
+ };status.retry = {
+ 502: true,
+ 503: true,
+ 504: true
+
+ /**
+ * Populate the statuses map for given codes.
+ * @private
+ */
+
+ };function populateStatusesMap(statuses, codes) {
+ var arr = [];
+
+ Object.keys(codes).forEach(function forEachCode(code) {
+ var message = codes[code];
+ var status = Number(code);
+
+ // Populate properties
+ statuses[status] = message;
+ statuses[message] = status;
+ statuses[message.toLowerCase()] = status;
+
+ // Add to array
+ arr.push(status);
+ });
+
+ return arr;
+ }
+
+ /**
+ * Get the status code.
+ *
+ * Given a number, this will throw if it is not a known status
+ * code, otherwise the code will be returned. Given a string,
+ * the string will be parsed for a number and return the code
+ * if valid, otherwise will lookup the code assuming this is
+ * the status message.
+ *
+ * @param {string|number} code
+ * @returns {number}
+ * @public
+ */
+
+ function status(code) {
+ if (typeof code === 'number') {
+ if (!status[code]) throw new Error('invalid status code: ' + code);
+ return code;
+ }
+
+ if (typeof code !== 'string') {
+ throw new TypeError('code must be a number or string');
+ }
+
+ // '403'
+ var n = parseInt(code, 10);
+ if (!isNaN(n)) {
+ if (!status[n]) throw new Error('invalid status code: ' + n);
+ return n;
+ }
+
+ n = status[code.toLowerCase()];
+ if (!n) throw new Error('invalid status message: "' + code + '"');
+ return n;
+ }
+ },{"./codes.json":120}],122:[function(require,module,exports){
+ // Copyright Joyent, Inc. and other Node contributors.
+ //
+ // 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';
+
+ var punycode = require('punycode');
+ var util = require('./util');
+
+ exports.parse = urlParse;
+ exports.resolve = urlResolve;
+ exports.resolveObject = urlResolveObject;
+ exports.format = urlFormat;
+
+ exports.Url = Url;
+
+ function Url() {
+ this.protocol = null;
+ this.slashes = null;
+ this.auth = null;
+ this.host = null;
+ this.port = null;
+ this.hostname = null;
+ this.hash = null;
+ this.search = null;
+ this.query = null;
+ this.pathname = null;
+ this.path = null;
+ this.href = null;
+ }
+
+ // Reference: RFC 3986, RFC 1808, RFC 2396
+
+ // define these here so at least they only have to be
+ // compiled once on the first module load.
+ var protocolPattern = /^([a-z0-9.+-]+:)/i,
+ portPattern = /:[0-9]*$/,
+
+
+ // Special case for a simple path URL
+ simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
+
+
+ // RFC 2396: characters reserved for delimiting URLs.
+ // We actually just auto-escape these.
+ delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
+
+
+ // RFC 2396: characters not allowed for various reasons.
+ unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
+
+
+ // Allowed by RFCs, but cause of XSS attacks. Always escape these.
+ autoEscape = ['\''].concat(unwise),
+
+ // Characters that are never ever allowed in a hostname.
+ // Note that any invalid chars are also handled, but these
+ // are the ones that are *expected* to be seen, so we fast-path
+ // them.
+ nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
+ hostEndingChars = ['/', '?', '#'],
+ hostnameMaxLen = 255,
+ hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
+ hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
+
+ // protocols that can allow "unsafe" and "unwise" chars.
+ unsafeProtocol = {
+ 'javascript': true,
+ 'javascript:': true
+ },
+
+ // protocols that never have a hostname.
+ hostlessProtocol = {
+ 'javascript': true,
+ 'javascript:': true
+ },
+
+ // protocols that always contain a // bit.
+ slashedProtocol = {
+ 'http': true,
+ 'https': true,
+ 'ftp': true,
+ 'gopher': true,
+ 'file': true,
+ 'http:': true,
+ 'https:': true,
+ 'ftp:': true,
+ 'gopher:': true,
+ 'file:': true
+ },
+ querystring = require('querystring');
+
+ function urlParse(url, parseQueryString, slashesDenoteHost) {
+ if (url && util.isObject(url) && url instanceof Url) return url;
+
+ var u = new Url();
+ u.parse(url, parseQueryString, slashesDenoteHost);
+ return u;
+ }
+
+ Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
+ if (!util.isString(url)) {
+ throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
+ }
+
+ // Copy chrome, IE, opera backslash-handling behavior.
+ // Back slashes before the query string get converted to forward slashes
+ // See: https://code.google.com/p/chromium/issues/detail?id=25916
+ var queryIndex = url.indexOf('?'),
+ splitter = queryIndex !== -1 && queryIndex < url.indexOf('#') ? '?' : '#',
+ uSplit = url.split(splitter),
+ slashRegex = /\\/g;
+ uSplit[0] = uSplit[0].replace(slashRegex, '/');
+ url = uSplit.join(splitter);
+
+ var rest = url;
+
+ // trim before proceeding.
+ // This is to support parse stuff like " http://foo.com \n"
+ rest = rest.trim();
+
+ if (!slashesDenoteHost && url.split('#').length === 1) {
+ // Try fast path regexp
+ var simplePath = simplePathPattern.exec(rest);
+ if (simplePath) {
+ this.path = rest;
+ this.href = rest;
+ this.pathname = simplePath[1];
+ if (simplePath[2]) {
+ this.search = simplePath[2];
+ if (parseQueryString) {
+ this.query = querystring.parse(this.search.substr(1));
} else {
- lastChild.nodeValue = value;
+ this.query = this.search.substr(1);
}
- } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
- // The very first node in the list should not have leading
- // whitespace. Sibling text nodes should have whitespace if there
- // was any.
- leader = i === 0 ? '' : ' ';
- value = lastChild.nodeValue.replace(leadingNewlineRegex, leader).replace(leadingSpaceRegex, ' ').replace(trailingSpaceRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
- lastChild.nodeValue = value;
+ } else if (parseQueryString) {
+ this.search = '';
+ this.query = {};
}
+ return this;
}
-
- // Iterate over DOM nodes
- } else if (node && node.nodeType) {
- // If the last node was a text node, make sure it is properly closed out
- if (hadText) {
- hadText = false;
-
- // Trim the child text nodes if the current node isn't a
- // text node or a code node
- if (TEXT_TAGS.indexOf(nodeName) === -1 && VERBATIM_TAGS.indexOf(nodeName) === -1) {
- value = lastChild.nodeValue.replace(leadingNewlineRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
-
- // Remove empty text nodes, append otherwise
- if (value === '') {
- el.removeChild(lastChild);
- } else {
- lastChild.nodeValue = value;
- }
- // Trim the child nodes if the current node is not a node
- // where all whitespace must be preserved
- } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
- value = lastChild.nodeValue.replace(leadingSpaceRegex, ' ').replace(leadingNewlineRegex, '').replace(trailingNewlineRegex, '').replace(multiSpaceRegex, ' ');
- lastChild.nodeValue = value;
- }
+ }
+
+ var proto = protocolPattern.exec(rest);
+ if (proto) {
+ proto = proto[0];
+ var lowerProto = proto.toLowerCase();
+ this.protocol = lowerProto;
+ rest = rest.substr(proto.length);
+ }
+
+ // figure out if it's got a host
+ // user@server is *always* interpreted as a hostname, and url
+ // resolution will treat //foo/bar as host=foo,path=bar because that's
+ // how the browser resolves relative URLs.
+ if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
+ var slashes = rest.substr(0, 2) === '//';
+ if (slashes && !(proto && hostlessProtocol[proto])) {
+ rest = rest.substr(2);
+ this.slashes = true;
}
-
- // Store the last nodename
- var _nodeName = node.nodeName;
- if (_nodeName) nodeName = _nodeName.toLowerCase();
-
- // Append the node to the DOM
- el.appendChild(node);
- }
- }
-};
-},{}],77:[function(require,module,exports){
-module.exports = ['async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defaultchecked', 'defer', 'disabled', 'formnovalidate', 'hidden', 'ismap', 'loop', 'multiple', 'muted', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected'];
-},{}],78:[function(require,module,exports){
-var hyperx = require('hyperx');
-var appendChild = require('./append-child');
-var SVG_TAGS = require('./svg-tags');
-var BOOL_PROPS = require('./bool-props');
-// Props that need to be set directly rather than with el.setAttribute()
-var DIRECT_PROPS = require('./direct-props');
-
-var SVGNS = 'http://www.w3.org/2000/svg';
-var XLINKNS = 'http://www.w3.org/1999/xlink';
-
-var COMMENT_TAG = '!--';
-
-function nanoHtmlCreateElement(tag, props, children) {
- var el;
-
- // If an svg tag, it needs a namespace
- if (SVG_TAGS.indexOf(tag) !== -1) {
- props.namespace = SVGNS;
- }
-
- // If we are using a namespace
- var ns = false;
- if (props.namespace) {
- ns = props.namespace;
- delete props.namespace;
- }
-
- // Create the element
- if (ns) {
- el = document.createElementNS(ns, tag);
- } else if (tag === COMMENT_TAG) {
- return document.createComment(props.comment);
- } else {
- el = document.createElement(tag);
- }
-
- // Create the properties
- for (var p in props) {
- if (props.hasOwnProperty(p)) {
- var key = p.toLowerCase();
- var val = props[p];
- // Normalize className
- if (key === 'classname') {
- key = 'class';
- p = 'class';
- }
- // The for attribute gets transformed to htmlFor, but we just set as for
- if (p === 'htmlFor') {
- p = 'for';
- }
- // If a property is boolean, set itself to the key
- if (BOOL_PROPS.indexOf(key) !== -1) {
- if (val === 'true') val = key;else if (val === 'false') continue;
- }
- // If a property prefers being set directly vs setAttribute
- if (key.slice(0, 2) === 'on' || DIRECT_PROPS.indexOf(key) !== -1) {
- el[p] = val;
+ }
+
+ if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
+
+ // there's a hostname.
+ // the first instance of /, ?, ;, or # ends the host.
+ //
+ // If there is an @ in the hostname, then non-host chars *are* allowed
+ // to the left of the last @ sign, unless some host-ending character
+ // comes *before* the @-sign.
+ // URLs are obnoxious.
+ //
+ // ex:
+ // http://a@b@c/ => user:a@b host:c
+ // http://a@b?@c => user:a host:c path:/?@c
+
+ // v0.12 TODO(isaacs): This is not quite how Chrome does things.
+ // Review our test case against browsers more comprehensively.
+
+ // find the first instance of any hostEndingChars
+ var hostEnd = -1;
+ for (var i = 0; i < hostEndingChars.length; i++) {
+ var hec = rest.indexOf(hostEndingChars[i]);
+ if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
+ }
+
+ // at this point, either we have an explicit point where the
+ // auth portion cannot go past, or the last @ char is the decider.
+ var auth, atSign;
+ if (hostEnd === -1) {
+ // atSign can be anywhere.
+ atSign = rest.lastIndexOf('@');
} else {
- if (ns) {
- if (p === 'xlink:href') {
- el.setAttributeNS(XLINKNS, p, val);
- } else if (/^xmlns($|:)/i.test(p)) {
- // skip xmlns definitions
- } else {
- el.setAttributeNS(null, p, val);
- }
- } else {
- el.setAttribute(p, val);
- }
+ // atSign must be in auth portion.
+ // http://a@b/c@d => host:b auth:a path:/c@d
+ atSign = rest.lastIndexOf('@', hostEnd);
}
- }
- }
-
- appendChild(el, children);
- return el;
-}
-
-module.exports = hyperx(nanoHtmlCreateElement, { comments: true });
-module.exports.default = module.exports;
-module.exports.createElement = nanoHtmlCreateElement;
-},{"./append-child":76,"./bool-props":77,"./direct-props":79,"./svg-tags":80,"hyperx":24}],79:[function(require,module,exports){
-module.exports = ['indeterminate'];
-},{}],80:[function(require,module,exports){
-module.exports = ['svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'];
-},{}],81:[function(require,module,exports){
-module.exports = LRU;
-
-function LRU(opts) {
- if (!(this instanceof LRU)) return new LRU(opts);
- if (typeof opts === 'number') opts = { max: opts };
- if (!opts) opts = {};
- this.cache = {};
- this.head = this.tail = null;
- this.length = 0;
- this.max = opts.max || 1000;
- this.maxAge = opts.maxAge || 0;
-}
-
-Object.defineProperty(LRU.prototype, 'keys', {
- get: function () {
- return Object.keys(this.cache);
- }
-});
-
-LRU.prototype.clear = function () {
- this.cache = {};
- this.head = this.tail = null;
- this.length = 0;
-};
-
-LRU.prototype.remove = function (key) {
- if (typeof key !== 'string') key = '' + key;
- if (!this.cache.hasOwnProperty(key)) return;
-
- var element = this.cache[key];
- delete this.cache[key];
- this._unlink(key, element.prev, element.next);
- return element.value;
-};
-
-LRU.prototype._unlink = function (key, prev, next) {
- this.length--;
-
- if (this.length === 0) {
- this.head = this.tail = null;
- } else {
- if (this.head === key) {
- this.head = prev;
- this.cache[this.head].next = null;
- } else if (this.tail === key) {
- this.tail = next;
- this.cache[this.tail].prev = null;
- } else {
- this.cache[prev].next = next;
- this.cache[next].prev = prev;
- }
- }
-};
-
-LRU.prototype.peek = function (key) {
- if (!this.cache.hasOwnProperty(key)) return;
-
- var element = this.cache[key];
-
- if (!this._checkAge(key, element)) return;
- return element.value;
-};
-
-LRU.prototype.set = function (key, value) {
- if (typeof key !== 'string') key = '' + key;
-
- var element;
-
- if (this.cache.hasOwnProperty(key)) {
- element = this.cache[key];
- element.value = value;
- if (this.maxAge) element.modified = Date.now();
-
- // If it's already the head, there's nothing more to do:
- if (key === this.head) return value;
- this._unlink(key, element.prev, element.next);
- } else {
- element = { value: value, modified: 0, next: null, prev: null };
- if (this.maxAge) element.modified = Date.now();
- this.cache[key] = element;
-
- // Eviction is only possible if the key didn't already exist:
- if (this.length === this.max) this.evict();
- }
-
- this.length++;
- element.next = null;
- element.prev = this.head;
-
- if (this.head) this.cache[this.head].next = key;
- this.head = key;
-
- if (!this.tail) this.tail = key;
- return value;
-};
-
-LRU.prototype._checkAge = function (key, element) {
- if (this.maxAge && Date.now() - element.modified > this.maxAge) {
- this.remove(key);
- return false;
- }
- return true;
-};
-
-LRU.prototype.get = function (key) {
- if (typeof key !== 'string') key = '' + key;
- if (!this.cache.hasOwnProperty(key)) return;
-
- var element = this.cache[key];
-
- if (!this._checkAge(key, element)) return;
-
- if (this.head !== key) {
- if (key === this.tail) {
- this.tail = element.next;
- this.cache[this.tail].prev = null;
- } else {
- // Set prev.next -> element.next:
- this.cache[element.prev].next = element.next;
- }
-
- // Set element.next.prev -> element.prev:
- this.cache[element.next].prev = element.prev;
-
- // Element is the new head
- this.cache[this.head].next = key;
- element.prev = this.head;
- element.next = null;
- this.head = key;
- }
-
- return element.value;
-};
-
-LRU.prototype.evict = function () {
- if (!this.tail) return;
- this.remove(this.tail);
-};
-},{}],82:[function(require,module,exports){
-var assert = require('assert');
-var morph = require('./lib/morph');
-
-var TEXT_NODE = 3;
-// var DEBUG = false
-
-module.exports = nanomorph;
-
-// Morph one tree into another tree
-//
-// no parent
-// -> same: diff and walk children
-// -> not same: replace and return
-// old node doesn't exist
-// -> insert new node
-// new node doesn't exist
-// -> delete old node
-// nodes are not the same
-// -> diff nodes and apply patch to old node
-// nodes are the same
-// -> walk all child nodes and append to old node
-function nanomorph(oldTree, newTree) {
- // if (DEBUG) {
- // console.log(
- // 'nanomorph\nold\n %s\nnew\n %s',
- // oldTree && oldTree.outerHTML,
- // newTree && newTree.outerHTML
- // )
- // }
- assert.equal(typeof oldTree, 'object', 'nanomorph: oldTree should be an object');
- assert.equal(typeof newTree, 'object', 'nanomorph: newTree should be an object');
- var tree = walk(newTree, oldTree);
- // if (DEBUG) console.log('=> morphed\n %s', tree.outerHTML)
- return tree;
-}
-
-// Walk and morph a dom tree
-function walk(newNode, oldNode) {
- // if (DEBUG) {
- // console.log(
- // 'walk\nold\n %s\nnew\n %s',
- // oldNode && oldNode.outerHTML,
- // newNode && newNode.outerHTML
- // )
- // }
- if (!oldNode) {
- return newNode;
- } else if (!newNode) {
- return null;
- } else if (newNode.isSameNode && newNode.isSameNode(oldNode)) {
- return oldNode;
- } else if (newNode.tagName !== oldNode.tagName) {
- return newNode;
- } else {
- morph(newNode, oldNode);
- updateChildren(newNode, oldNode);
- return oldNode;
- }
-}
-
-// Update the children of elements
-// (obj, obj) -> null
-function updateChildren(newNode, oldNode) {
- // if (DEBUG) {
- // console.log(
- // 'updateChildren\nold\n %s\nnew\n %s',
- // oldNode && oldNode.outerHTML,
- // newNode && newNode.outerHTML
- // )
- // }
- var oldChild, newChild, morphed, oldMatch;
-
- // The offset is only ever increased, and used for [i - offset] in the loop
- var offset = 0;
-
- for (var i = 0;; i++) {
- oldChild = oldNode.childNodes[i];
- newChild = newNode.childNodes[i - offset];
- // if (DEBUG) {
- // console.log(
- // '===\n- old\n %s\n- new\n %s',
- // oldChild && oldChild.outerHTML,
- // newChild && newChild.outerHTML
- // )
- // }
- // Both nodes are empty, do nothing
- if (!oldChild && !newChild) {
- break;
-
- // There is no new child, remove old
- } else if (!newChild) {
- oldNode.removeChild(oldChild);
- i--;
-
- // There is no old child, add new
- } else if (!oldChild) {
- oldNode.appendChild(newChild);
- offset++;
-
- // Both nodes are the same, morph
- } else if (same(newChild, oldChild)) {
- morphed = walk(newChild, oldChild);
- if (morphed !== oldChild) {
- oldNode.replaceChild(morphed, oldChild);
- offset++;
+
+ // Now we have a portion which is definitely the auth.
+ // Pull that off.
+ if (atSign !== -1) {
+ auth = rest.slice(0, atSign);
+ rest = rest.slice(atSign + 1);
+ this.auth = decodeURIComponent(auth);
}
-
- // Both nodes do not share an ID or a placeholder, try reorder
- } else {
- oldMatch = null;
-
- // Try and find a similar node somewhere in the tree
- for (var j = i; j < oldNode.childNodes.length; j++) {
- if (same(oldNode.childNodes[j], newChild)) {
- oldMatch = oldNode.childNodes[j];
- break;
- }
+
+ // the host is the remaining to the left of the first non-host char
+ hostEnd = -1;
+ for (var i = 0; i < nonHostChars.length; i++) {
+ var hec = rest.indexOf(nonHostChars[i]);
+ if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
}
-
- // If there was a node with the same ID or placeholder in the old list
- if (oldMatch) {
- morphed = walk(newChild, oldMatch);
- if (morphed !== oldMatch) offset++;
- oldNode.insertBefore(morphed, oldChild);
-
- // It's safe to morph two nodes in-place if neither has an ID
- } else if (!newChild.id && !oldChild.id) {
- morphed = walk(newChild, oldChild);
- if (morphed !== oldChild) {
- oldNode.replaceChild(morphed, oldChild);
- offset++;
+ // if we still have not hit it, then the entire thing is a host.
+ if (hostEnd === -1) hostEnd = rest.length;
+
+ this.host = rest.slice(0, hostEnd);
+ rest = rest.slice(hostEnd);
+
+ // pull out port.
+ this.parseHost();
+
+ // we've indicated that there is a hostname,
+ // so even if it's empty, it has to be present.
+ this.hostname = this.hostname || '';
+
+ // if hostname begins with [ and ends with ]
+ // assume that it's an IPv6 address.
+ var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']';
+
+ // validate a little.
+ if (!ipv6Hostname) {
+ var hostparts = this.hostname.split(/\./);
+ for (var i = 0, l = hostparts.length; i < l; i++) {
+ var part = hostparts[i];
+ if (!part) continue;
+ if (!part.match(hostnamePartPattern)) {
+ var newpart = '';
+ for (var j = 0, k = part.length; j < k; j++) {
+ if (part.charCodeAt(j) > 127) {
+ // we replace non-ASCII char with a temporary placeholder
+ // we need this to make sure size of hostname is not
+ // broken by replacing non-ASCII by nothing
+ newpart += 'x';
+ } else {
+ newpart += part[j];
+ }
+ }
+ // we test again with ASCII char only
+ if (!newpart.match(hostnamePartPattern)) {
+ var validParts = hostparts.slice(0, i);
+ var notHost = hostparts.slice(i + 1);
+ var bit = part.match(hostnamePartStart);
+ if (bit) {
+ validParts.push(bit[1]);
+ notHost.unshift(bit[2]);
+ }
+ if (notHost.length) {
+ rest = '/' + notHost.join('.') + rest;
+ }
+ this.hostname = validParts.join('.');
+ break;
+ }
+ }
}
-
- // Insert the node at the index if we couldn't morph or find a matching node
+ }
+
+ if (this.hostname.length > hostnameMaxLen) {
+ this.hostname = '';
} else {
- oldNode.insertBefore(newChild, oldChild);
- offset++;
+ // hostnames are always lower case.
+ this.hostname = this.hostname.toLowerCase();
}
- }
- }
-}
-
-function same(a, b) {
- if (a.id) return a.id === b.id;
- if (a.isSameNode) return a.isSameNode(b);
- if (a.tagName !== b.tagName) return false;
- if (a.type === TEXT_NODE) return a.nodeValue === b.nodeValue;
- return false;
-}
-},{"./lib/morph":84,"assert":73}],83:[function(require,module,exports){
-module.exports = [
-// attribute events (can be set with attributes)
-'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onmouseenter', 'onmouseleave', 'ontouchcancel', 'ontouchend', 'ontouchmove', 'ontouchstart', 'ondragstart', 'ondrag', 'ondragenter', 'ondragleave', 'ondragover', 'ondrop', 'ondragend', 'onkeydown', 'onkeypress', 'onkeyup', 'onunload', 'onabort', 'onerror', 'onresize', 'onscroll', 'onselect', 'onchange', 'onsubmit', 'onreset', 'onfocus', 'onblur', 'oninput',
-// other common events
-'oncontextmenu', 'onfocusin', 'onfocusout'];
-},{}],84:[function(require,module,exports){
-var events = require('./events');
-var eventsLength = events.length;
-
-var ELEMENT_NODE = 1;
-var TEXT_NODE = 3;
-var COMMENT_NODE = 8;
-
-module.exports = morph;
-
-// diff elements and apply the resulting patch to the old node
-// (obj, obj) -> null
-function morph(newNode, oldNode) {
- var nodeType = newNode.nodeType;
- var nodeName = newNode.nodeName;
-
- if (nodeType === ELEMENT_NODE) {
- copyAttrs(newNode, oldNode);
- }
-
- if (nodeType === TEXT_NODE || nodeType === COMMENT_NODE) {
- if (oldNode.nodeValue !== newNode.nodeValue) {
- oldNode.nodeValue = newNode.nodeValue;
- }
- }
-
- // Some DOM nodes are weird
- // https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js
- if (nodeName === 'INPUT') updateInput(newNode, oldNode);else if (nodeName === 'OPTION') updateOption(newNode, oldNode);else if (nodeName === 'TEXTAREA') updateTextarea(newNode, oldNode);
-
- copyEvents(newNode, oldNode);
-}
-
-function copyAttrs(newNode, oldNode) {
- var oldAttrs = oldNode.attributes;
- var newAttrs = newNode.attributes;
- var attrNamespaceURI = null;
- var attrValue = null;
- var fromValue = null;
- var attrName = null;
- var attr = null;
-
- for (var i = newAttrs.length - 1; i >= 0; --i) {
- attr = newAttrs[i];
- attrName = attr.name;
- attrNamespaceURI = attr.namespaceURI;
- attrValue = attr.value;
- if (attrNamespaceURI) {
- attrName = attr.localName || attrName;
- fromValue = oldNode.getAttributeNS(attrNamespaceURI, attrName);
- if (fromValue !== attrValue) {
- oldNode.setAttributeNS(attrNamespaceURI, attrName, attrValue);
+
+ if (!ipv6Hostname) {
+ // IDNA Support: Returns a punycoded representation of "domain".
+ // It only converts parts of the domain name that
+ // have non-ASCII characters, i.e. it doesn't matter if
+ // you call it with a domain that already is ASCII-only.
+ this.hostname = punycode.toASCII(this.hostname);
}
- } else {
- if (!oldNode.hasAttribute(attrName)) {
- oldNode.setAttribute(attrName, attrValue);
- } else {
- fromValue = oldNode.getAttribute(attrName);
- if (fromValue !== attrValue) {
- // apparently values are always cast to strings, ah well
- if (attrValue === 'null' || attrValue === 'undefined') {
- oldNode.removeAttribute(attrName);
- } else {
- oldNode.setAttribute(attrName, attrValue);
- }
+
+ var p = this.port ? ':' + this.port : '';
+ var h = this.hostname || '';
+ this.host = h + p;
+ this.href += this.host;
+
+ // strip [ and ] from the hostname
+ // the host field still retains them, though
+ if (ipv6Hostname) {
+ this.hostname = this.hostname.substr(1, this.hostname.length - 2);
+ if (rest[0] !== '/') {
+ rest = '/' + rest;
}
}
}
- }
-
- // Remove any extra attributes found on the original DOM element that
- // weren't found on the target element.
- for (var j = oldAttrs.length - 1; j >= 0; --j) {
- attr = oldAttrs[j];
- if (attr.specified !== false) {
- attrName = attr.name;
- attrNamespaceURI = attr.namespaceURI;
-
- if (attrNamespaceURI) {
- attrName = attr.localName || attrName;
- if (!newNode.hasAttributeNS(attrNamespaceURI, attrName)) {
- oldNode.removeAttributeNS(attrNamespaceURI, attrName);
- }
- } else {
- if (!newNode.hasAttributeNS(null, attrName)) {
- oldNode.removeAttribute(attrName);
+
+ // now rest is set to the post-host stuff.
+ // chop off any delim chars.
+ if (!unsafeProtocol[lowerProto]) {
+
+ // First, make 100% sure that any "autoEscape" chars get
+ // escaped, even if encodeURIComponent doesn't think they
+ // need to be.
+ for (var i = 0, l = autoEscape.length; i < l; i++) {
+ var ae = autoEscape[i];
+ if (rest.indexOf(ae) === -1) continue;
+ var esc = encodeURIComponent(ae);
+ if (esc === ae) {
+ esc = escape(ae);
}
+ rest = rest.split(ae).join(esc);
}
}
- }
-}
-
-function copyEvents(newNode, oldNode) {
- for (var i = 0; i < eventsLength; i++) {
- var ev = events[i];
- if (newNode[ev]) {
- // if new element has a whitelisted attribute
- oldNode[ev] = newNode[ev]; // update existing element
- } else if (oldNode[ev]) {
- // if existing element has it and new one doesnt
- oldNode[ev] = undefined; // remove it from existing element
- }
- }
-}
-
-function updateOption(newNode, oldNode) {
- updateAttribute(newNode, oldNode, 'selected');
-}
-
-// The "value" attribute is special for the element since it sets the
-// initial value. Changing the "value" attribute without changing the "value"
-// property will have no effect since it is only used to the set the initial
-// value. Similar for the "checked" attribute, and "disabled".
-function updateInput(newNode, oldNode) {
- var newValue = newNode.value;
- var oldValue = oldNode.value;
-
- updateAttribute(newNode, oldNode, 'checked');
- updateAttribute(newNode, oldNode, 'disabled');
-
- if (newValue !== oldValue) {
- oldNode.setAttribute('value', newValue);
- oldNode.value = newValue;
- }
-
- if (newValue === 'null') {
- oldNode.value = '';
- oldNode.removeAttribute('value');
- }
-
- if (!newNode.hasAttributeNS(null, 'value')) {
- oldNode.removeAttribute('value');
- } else if (oldNode.type === 'range') {
- // this is so elements like slider move their UI thingy
- oldNode.value = newValue;
- }
-}
-
-function updateTextarea(newNode, oldNode) {
- var newValue = newNode.value;
- if (newValue !== oldNode.value) {
- oldNode.value = newValue;
- }
-
- if (oldNode.firstChild && oldNode.firstChild.nodeValue !== newValue) {
- // Needed for IE. Apparently IE sets the placeholder as the
- // node value and vise versa. This ignores an empty update.
- if (newValue === '' && oldNode.firstChild.nodeValue === oldNode.placeholder) {
- return;
+
+ // chop off from the tail first.
+ var hash = rest.indexOf('#');
+ if (hash !== -1) {
+ // got a fragment string.
+ this.hash = rest.substr(hash);
+ rest = rest.slice(0, hash);
+ }
+ var qm = rest.indexOf('?');
+ if (qm !== -1) {
+ this.search = rest.substr(qm);
+ this.query = rest.substr(qm + 1);
+ if (parseQueryString) {
+ this.query = querystring.parse(this.query);
+ }
+ rest = rest.slice(0, qm);
+ } else if (parseQueryString) {
+ // no query string, but parseQueryString still requested
+ this.search = '';
+ this.query = {};
}
-
- oldNode.firstChild.nodeValue = newValue;
- }
-}
-
-function updateAttribute(newNode, oldNode, name) {
- if (newNode[name] !== oldNode[name]) {
- oldNode[name] = newNode[name];
- if (newNode[name]) {
- oldNode.setAttribute(name, '');
- } else {
- oldNode.removeAttribute(name);
- }
- }
-}
-},{"./events":83}],85:[function(require,module,exports){
-var reg = /([^?=&]+)(=([^&]*))?/g;
-var assert = require('assert');
-
-module.exports = qs;
-
-function qs(url) {
- assert.equal(typeof url, 'string', 'nanoquery: url should be type string');
-
- var obj = {};
- url.replace(/^.*\?/, '').replace(reg, function (a0, a1, a2, a3) {
- obj[decodeURIComponent(a1)] = decodeURIComponent(a3);
- });
-
- return obj;
-}
-},{"assert":73}],86:[function(require,module,exports){
-'use strict';
-
-var assert = require('assert');
-
-module.exports = nanoraf;
-
-// Only call RAF when needed
-// (fn, fn?) -> fn
-function nanoraf(render, raf) {
- assert.equal(typeof render, 'function', 'nanoraf: render should be a function');
- assert.ok(typeof raf === 'function' || typeof raf === 'undefined', 'nanoraf: raf should be a function or undefined');
-
- if (!raf) raf = window.requestAnimationFrame;
- var redrawScheduled = false;
- var args = null;
-
- return function frame() {
- if (args === null && !redrawScheduled) {
- redrawScheduled = true;
-
- raf(function redraw() {
- redrawScheduled = false;
-
- var length = args.length;
- var _args = new Array(length);
- for (var i = 0; i < length; i++) {
- _args[i] = args[i];
- }render.apply(render, _args);
- args = null;
- });
+ if (rest) this.pathname = rest;
+ if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
+ this.pathname = '/';
}
-
- args = arguments;
+
+ //to support http.request
+ if (this.pathname || this.search) {
+ var p = this.pathname || '';
+ var s = this.search || '';
+ this.path = p + s;
+ }
+
+ // finally, reconstruct the href based on what has been validated.
+ this.href = this.format();
+ return this;
};
-}
-},{"assert":73}],87:[function(require,module,exports){
-var assert = require('assert');
-var wayfarer = require('wayfarer');
-
-// electron support
-var isLocalFile = /file:\/\//.test(typeof window === 'object' && window.location && window.location.origin);
-
-/* eslint-disable no-useless-escape */
-var electron = '^(file:\/\/|\/)(.*\.html?\/?)?';
-var protocol = '^(http(s)?(:\/\/))?(www\.)?';
-var domain = '[a-zA-Z0-9-_\.]+(:[0-9]{1,5})?(\/{1})?';
-var qs = '[\?].*$';
-/* eslint-enable no-useless-escape */
-
-var stripElectron = new RegExp(electron);
-var prefix = new RegExp(protocol + domain);
-var normalize = new RegExp('#');
-var suffix = new RegExp(qs);
-
-module.exports = Nanorouter;
-
-function Nanorouter(opts) {
- if (!(this instanceof Nanorouter)) return new Nanorouter(opts);
- opts = opts || {};
- this.router = wayfarer(opts.default || '/404');
-}
-
-Nanorouter.prototype.on = function (routename, listener) {
- assert.equal(typeof routename, 'string');
- routename = routename.replace(/^[#/]/, '');
- this.router.on(routename, listener);
-};
-
-Nanorouter.prototype.emit = function (routename) {
- assert.equal(typeof routename, 'string');
- routename = pathname(routename, isLocalFile);
- return this.router.emit(routename);
-};
-
-Nanorouter.prototype.match = function (routename) {
- assert.equal(typeof routename, 'string');
- routename = pathname(routename, isLocalFile);
- return this.router.match(routename);
-};
-
-// replace everything in a route but the pathname and hash
-function pathname(routename, isElectron) {
- if (isElectron) routename = routename.replace(stripElectron, '');else routename = routename.replace(prefix, '');
- return decodeURI(routename.replace(suffix, '').replace(normalize, '/'));
-}
-},{"assert":73,"wayfarer":122}],88:[function(require,module,exports){
-var assert = require('assert');
-
-var hasWindow = typeof window !== 'undefined';
-
-function createScheduler() {
- var scheduler;
- if (hasWindow) {
- if (!window._nanoScheduler) window._nanoScheduler = new NanoScheduler(true);
- scheduler = window._nanoScheduler;
- } else {
- scheduler = new NanoScheduler();
- }
- return scheduler;
-}
-
-function NanoScheduler(hasWindow) {
- this.hasWindow = hasWindow;
- this.hasIdle = this.hasWindow && window.requestIdleCallback;
- this.method = this.hasIdle ? window.requestIdleCallback.bind(window) : this.setTimeout;
- this.scheduled = false;
- this.queue = [];
-}
-
-NanoScheduler.prototype.push = function (cb) {
- assert.equal(typeof cb, 'function', 'nanoscheduler.push: cb should be type function');
-
- this.queue.push(cb);
- this.schedule();
-};
-
-NanoScheduler.prototype.schedule = function () {
- if (this.scheduled) return;
-
- this.scheduled = true;
- var self = this;
- this.method(function (idleDeadline) {
- var cb;
- while (self.queue.length && idleDeadline.timeRemaining() > 0) {
- cb = self.queue.shift();
- cb(idleDeadline);
- }
- self.scheduled = false;
- if (self.queue.length) self.schedule();
- });
-};
-
-NanoScheduler.prototype.setTimeout = function (cb) {
- setTimeout(cb, 0, {
- timeRemaining: function () {
- return 1;
- }
- });
-};
-
-module.exports = createScheduler;
-},{"assert":73}],89:[function(require,module,exports){
-var scheduler = require('nanoscheduler')();
-var assert = require('assert');
-
-var perf;
-nanotiming.disabled = true;
-try {
- perf = window.performance;
- nanotiming.disabled = window.localStorage.DISABLE_NANOTIMING === 'true' || !perf.mark;
-} catch (e) {}
-
-module.exports = nanotiming;
-
-function nanotiming(name) {
- assert.equal(typeof name, 'string', 'nanotiming: name should be type string');
-
- if (nanotiming.disabled) return noop;
-
- var uuid = (perf.now() * 10000).toFixed() % Number.MAX_SAFE_INTEGER;
- var startName = 'start-' + uuid + '-' + name;
- perf.mark(startName);
-
- function end(cb) {
- var endName = 'end-' + uuid + '-' + name;
- perf.mark(endName);
-
- scheduler.push(function () {
- var err = null;
- try {
- var measureName = name + ' [' + uuid + ']';
- perf.measure(measureName, startName, endName);
- perf.clearMarks(startName);
- perf.clearMarks(endName);
- } catch (e) {
- err = e;
+
+ // format a parsed object into a url string
+ function urlFormat(obj) {
+ // ensure it's an object, and not a string url.
+ // If it's an obj, this is a no-op.
+ // this way, you can call url_format() on strings
+ // to clean up potentially wonky urls.
+ if (util.isString(obj)) obj = urlParse(obj);
+ if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
+ return obj.format();
+ }
+
+ Url.prototype.format = function () {
+ var auth = this.auth || '';
+ if (auth) {
+ auth = encodeURIComponent(auth);
+ auth = auth.replace(/%3A/i, ':');
+ auth += '@';
+ }
+
+ var protocol = this.protocol || '',
+ pathname = this.pathname || '',
+ hash = this.hash || '',
+ host = false,
+ query = '';
+
+ if (this.host) {
+ host = auth + this.host;
+ } else if (this.hostname) {
+ host = auth + (this.hostname.indexOf(':') === -1 ? this.hostname : '[' + this.hostname + ']');
+ if (this.port) {
+ host += ':' + this.port;
}
- if (cb) cb(err, name);
- });
- }
-
- end.uuid = uuid;
- return end;
-}
-
-function noop(cb) {
- if (cb) {
- scheduler.push(function () {
- cb(new Error('nanotiming: performance API unavailable'));
- });
- }
-}
-},{"assert":73,"nanoscheduler":88}],90:[function(require,module,exports){
-/*!
- * normalize-path
- *
- * Copyright (c) 2014-2017, Jon Schlinkert.
- * Released under the MIT License.
- */
-
-var removeTrailingSeparator = require('remove-trailing-separator');
-
-module.exports = function normalizePath(str, stripTrailing) {
- if (typeof str !== 'string') {
- throw new TypeError('expected a string');
- }
- str = str.replace(/[\\\/]+/g, '/');
- if (stripTrailing !== false) {
- str = removeTrailingSeparator(str);
- }
- return str;
-};
-},{"remove-trailing-separator":107}],91:[function(require,module,exports){
-'use strict';
-
-// modified from https://github.com/es-shims/es5-shim
-
-var has = Object.prototype.hasOwnProperty;
-var toStr = Object.prototype.toString;
-var slice = Array.prototype.slice;
-var isArgs = require('./isArguments');
-var isEnumerable = Object.prototype.propertyIsEnumerable;
-var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
-var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
-var dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'];
-var equalsConstructorPrototype = function (o) {
- var ctor = o.constructor;
- return ctor && ctor.prototype === o;
-};
-var excludedKeys = {
- $applicationCache: true,
- $console: true,
- $external: true,
- $frame: true,
- $frameElement: true,
- $frames: true,
- $innerHeight: true,
- $innerWidth: true,
- $outerHeight: true,
- $outerWidth: true,
- $pageXOffset: true,
- $pageYOffset: true,
- $parent: true,
- $scrollLeft: true,
- $scrollTop: true,
- $scrollX: true,
- $scrollY: true,
- $self: true,
- $webkitIndexedDB: true,
- $webkitStorageInfo: true,
- $window: true
-};
-var hasAutomationEqualityBug = function () {
- /* global window */
- if (typeof window === 'undefined') {
- return false;
- }
- for (var k in window) {
- try {
- if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
- try {
- equalsConstructorPrototype(window[k]);
- } catch (e) {
- return true;
- }
- }
- } catch (e) {
- return true;
- }
- }
- return false;
-}();
-var equalsConstructorPrototypeIfNotBuggy = function (o) {
- /* global window */
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
- return equalsConstructorPrototype(o);
- }
- try {
- return equalsConstructorPrototype(o);
- } catch (e) {
- return false;
- }
-};
-
-var keysShim = function keys(object) {
- var isObject = object !== null && typeof object === 'object';
- var isFunction = toStr.call(object) === '[object Function]';
- var isArguments = isArgs(object);
- var isString = isObject && toStr.call(object) === '[object String]';
- var theKeys = [];
-
- if (!isObject && !isFunction && !isArguments) {
- throw new TypeError('Object.keys called on a non-object');
- }
-
- var skipProto = hasProtoEnumBug && isFunction;
- if (isString && object.length > 0 && !has.call(object, 0)) {
- for (var i = 0; i < object.length; ++i) {
- theKeys.push(String(i));
- }
- }
-
- if (isArguments && object.length > 0) {
- for (var j = 0; j < object.length; ++j) {
- theKeys.push(String(j));
- }
- } else {
- for (var name in object) {
- if (!(skipProto && name === 'prototype') && has.call(object, name)) {
- theKeys.push(String(name));
- }
- }
- }
-
- if (hasDontEnumBug) {
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
-
- for (var k = 0; k < dontEnums.length; ++k) {
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
- theKeys.push(dontEnums[k]);
- }
- }
- }
- return theKeys;
-};
-
-keysShim.shim = function shimObjectKeys() {
- if (Object.keys) {
- var keysWorksWithArguments = function () {
- // Safari 5.0 bug
- return (Object.keys(arguments) || '').length === 2;
- }(1, 2);
- if (!keysWorksWithArguments) {
- var originalKeys = Object.keys;
- Object.keys = function keys(object) {
- // eslint-disable-line func-name-matching
- if (isArgs(object)) {
- return originalKeys(slice.call(object));
- } else {
- return originalKeys(object);
- }
- };
- }
- } else {
- Object.keys = keysShim;
- }
- return Object.keys || keysShim;
-};
-
-module.exports = keysShim;
-},{"./isArguments":92}],92:[function(require,module,exports){
-'use strict';
-
-var toStr = Object.prototype.toString;
-
-module.exports = function isArguments(value) {
- var str = toStr.call(value);
- var isArgs = str === '[object Arguments]';
- if (!isArgs) {
- isArgs = str !== '[object Array]' && value !== null && typeof value === 'object' && typeof value.length === 'number' && value.length >= 0 && toStr.call(value.callee) === '[object Function]';
- }
- return isArgs;
-};
-},{}],93:[function(require,module,exports){
-'use strict';
-
-module.exports = function (object) {
- return Object.keys(object).map(function (i) {
- return object[i];
- });
-};
-},{}],94:[function(require,module,exports){
-/* global MutationObserver */
-var document = require('global/document');
-var window = require('global/window');
-var assert = require('assert');
-var watch = Object.create(null);
-var KEY_ID = 'onloadid' + (new Date() % 9e6).toString(36);
-var KEY_ATTR = 'data-' + KEY_ID;
-var INDEX = 0;
-
-if (window && window.MutationObserver) {
- var observer = new MutationObserver(function (mutations) {
- if (Object.keys(watch).length < 1) return;
- for (var i = 0; i < mutations.length; i++) {
- if (mutations[i].attributeName === KEY_ATTR) {
- eachAttr(mutations[i], turnon, turnoff);
- continue;
- }
- eachMutation(mutations[i].removedNodes, turnoff);
- eachMutation(mutations[i].addedNodes, turnon);
}
- });
- if (document.body) {
- beginObserve(observer);
- } else {
- document.addEventListener('DOMContentLoaded', function (event) {
- beginObserve(observer);
+
+ if (this.query && util.isObject(this.query) && Object.keys(this.query).length) {
+ query = querystring.stringify(this.query);
+ }
+
+ var search = this.search || query && '?' + query || '';
+
+ if (protocol && protocol.substr(-1) !== ':') protocol += ':';
+
+ // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
+ // unless they had them to begin with.
+ if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
+ host = '//' + (host || '');
+ if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
+ } else if (!host) {
+ host = '';
+ }
+
+ if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
+ if (search && search.charAt(0) !== '?') search = '?' + search;
+
+ pathname = pathname.replace(/[?#]/g, function (match) {
+ return encodeURIComponent(match);
});
- }
-}
-
-function beginObserve(observer) {
- observer.observe(document.documentElement, {
- childList: true,
- subtree: true,
- attributes: true,
- attributeOldValue: true,
- attributeFilter: [KEY_ATTR]
- });
-}
-
-module.exports = function onload(el, on, off, caller) {
- assert(document.body, 'on-load: will not work prior to DOMContentLoaded');
- on = on || function () {};
- off = off || function () {};
- el.setAttribute(KEY_ATTR, 'o' + INDEX);
- watch['o' + INDEX] = [on, off, 0, caller || onload.caller];
- INDEX += 1;
- return el;
-};
-
-module.exports.KEY_ATTR = KEY_ATTR;
-module.exports.KEY_ID = KEY_ID;
-
-function turnon(index, el) {
- if (watch[index][0] && watch[index][2] === 0) {
- watch[index][0](el);
- watch[index][2] = 1;
- }
-}
-
-function turnoff(index, el) {
- if (watch[index][1] && watch[index][2] === 1) {
- watch[index][1](el);
- watch[index][2] = 0;
- }
-}
-
-function eachAttr(mutation, on, off) {
- var newValue = mutation.target.getAttribute(KEY_ATTR);
- if (sameOrigin(mutation.oldValue, newValue)) {
- watch[newValue] = watch[mutation.oldValue];
- return;
- }
- if (watch[mutation.oldValue]) {
- off(mutation.oldValue, mutation.target);
- }
- if (watch[newValue]) {
- on(newValue, mutation.target);
- }
-}
-
-function sameOrigin(oldValue, newValue) {
- if (!oldValue || !newValue) return false;
- return watch[oldValue][3] === watch[newValue][3];
-}
-
-function eachMutation(nodes, fn) {
- var keys = Object.keys(watch);
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i] && nodes[i].getAttribute && nodes[i].getAttribute(KEY_ATTR)) {
- var onloadid = nodes[i].getAttribute(KEY_ATTR);
- keys.forEach(function (k) {
- if (onloadid === k) {
- fn(k, nodes[i]);
- }
- });
- }
- if (nodes[i].childNodes.length > 0) {
- eachMutation(nodes[i].childNodes, fn);
- }
- }
-}
-},{"assert":73,"global/document":20,"global/window":21}],95:[function(require,module,exports){
-var wrappy = require('wrappy');
-module.exports = wrappy(once);
-module.exports.strict = wrappy(onceStrict);
-
-once.proto = once(function () {
- Object.defineProperty(Function.prototype, 'once', {
- value: function () {
- return once(this);
- },
- configurable: true
- });
-
- Object.defineProperty(Function.prototype, 'onceStrict', {
- value: function () {
- return onceStrict(this);
- },
- configurable: true
- });
-});
-
-function once(fn) {
- var f = function () {
- if (f.called) return f.value;
- f.called = true;
- return f.value = fn.apply(this, arguments);
+ search = search.replace('#', '%23');
+
+ return protocol + host + pathname + search + hash;
};
- f.called = false;
- return f;
-}
-
-function onceStrict(fn) {
- var f = function () {
- if (f.called) throw new Error(f.onceError);
- f.called = true;
- return f.value = fn.apply(this, arguments);
+
+ function urlResolve(source, relative) {
+ return urlParse(source, false, true).resolve(relative);
+ }
+
+ Url.prototype.resolve = function (relative) {
+ return this.resolveObject(urlParse(relative, false, true)).format();
};
- var name = fn.name || 'Function wrapped with `once`';
- f.onceError = name + " shouldn't be called more than once";
- f.called = false;
- return f;
-}
-},{"wrappy":124}],96:[function(require,module,exports){
-var isNode = typeof window === 'undefined';
-var parse = isNode ? require('url').parse : browserParse;
-
-var SCHEME_REGEX = /[a-z]+:\/\//i;
-// 1 2 3 4
-var VERSION_REGEX = /^(dat:\/\/)?([^/]+)(\+[^/]+)(.*)$/i;
-
-module.exports = function parseDatURL(str, parseQS) {
- // prepend the scheme if it's missing
- if (!SCHEME_REGEX.test(str)) {
- str = 'dat://' + str;
- }
-
- var parsed,
- version = null,
- match = VERSION_REGEX.exec(str);
- if (match) {
- // run typical parse with version segment removed
- parsed = parse((match[1] || '') + (match[2] || '') + (match[4] || ''), parseQS);
- version = match[3].slice(1);
- } else {
- parsed = parse(str, parseQS);
- }
- if (isNode) parsed.href = str; // overwrite href to include actual original
- else parsed.path = parsed.pathname; // to match node
- if (!parsed.query && parsed.searchParams) {
- parsed.query = Object.fromEntries(parsed.searchParams); // to match node
- }
- parsed.version = version; // add version segment
- return parsed;
-};
-
-function browserParse(str) {
- return new URL(str);
-}
-},{"url":118}],97:[function(require,module,exports){
-var trim = function (string) {
- return string.replace(/^\s+|\s+$/g, '');
-},
- isArray = function (arg) {
- return Object.prototype.toString.call(arg) === '[object Array]';
-};
-
-module.exports = function (headers) {
- if (!headers) return {};
-
- var result = {};
-
- var headersArr = trim(headers).split('\n');
-
- for (var i = 0; i < headersArr.length; i++) {
- var row = headersArr[i];
- var index = row.indexOf(':'),
- key = trim(row.slice(0, index)).toLowerCase(),
- value = trim(row.slice(index + 1));
-
- if (typeof result[key] === 'undefined') {
- result[key] = value;
- } else if (isArray(result[key])) {
- result[key].push(value);
- } else {
- result[key] = [result[key], value];
- }
- }
-
- return result;
-};
-},{}],98:[function(require,module,exports){
-(function (process){
-// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
-// backported and transplited with Babel, with backwards-compat fixes
-
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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.
-
-// resolves . and .. elements in a path array with directory names there
-// must be no slashes, empty elements, or device names (c:\) in the array
-// (so also no leading and trailing slashes - it does not distinguish
-// relative and absolute paths)
-function normalizeArray(parts, allowAboveRoot) {
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
-
- // if the path is allowed to go above the root, restore leading ..s
- if (allowAboveRoot) {
- for (; up--; up) {
- parts.unshift('..');
- }
- }
-
- return parts;
-}
-
-// path.resolve([from ...], to)
-// posix version
-exports.resolve = function () {
- var resolvedPath = '',
- resolvedAbsolute = false;
-
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = i >= 0 ? arguments[i] : process.cwd();
-
- // Skip empty and invalid entries
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- continue;
- }
-
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
-
- // At this point the path should be resolved to a full absolute path, but
- // handle relative paths to be safe (might happen when process.cwd() fails)
-
- // Normalize the path
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
-
- return (resolvedAbsolute ? '/' : '') + resolvedPath || '.';
-};
-
-// path.normalize(path)
-// posix version
-exports.normalize = function (path) {
- var isAbsolute = exports.isAbsolute(path),
- trailingSlash = substr(path, -1) === '/';
-
- // Normalize the path
- path = normalizeArray(filter(path.split('/'), function (p) {
- return !!p;
- }), !isAbsolute).join('/');
-
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
-
- return (isAbsolute ? '/' : '') + path;
-};
-
-// posix version
-exports.isAbsolute = function (path) {
- return path.charAt(0) === '/';
-};
-
-// posix version
-exports.join = function () {
- var paths = Array.prototype.slice.call(arguments, 0);
- return exports.normalize(filter(paths, function (p, index) {
- if (typeof p !== 'string') {
- throw new TypeError('Arguments to path.join must be strings');
+
+ function urlResolveObject(source, relative) {
+ if (!source) return relative;
+ return urlParse(source, false, true).resolveObject(relative);
+ }
+
+ Url.prototype.resolveObject = function (relative) {
+ if (util.isString(relative)) {
+ var rel = new Url();
+ rel.parse(relative, false, true);
+ relative = rel;
+ }
+
+ var result = new Url();
+ var tkeys = Object.keys(this);
+ for (var tk = 0; tk < tkeys.length; tk++) {
+ var tkey = tkeys[tk];
+ result[tkey] = this[tkey];
+ }
+
+ // hash is always overridden, no matter what.
+ // even href="" will remove it.
+ result.hash = relative.hash;
+
+ // if the relative url is empty, then there's nothing left to do here.
+ if (relative.href === '') {
+ result.href = result.format();
+ return result;
}
- return p;
- }).join('/'));
-};
-
-// path.relative(from, to)
-// posix version
-exports.relative = function (from, to) {
- from = exports.resolve(from).substr(1);
- to = exports.resolve(to).substr(1);
-
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
-
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
-
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
-
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
-
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
-
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
-
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
-
- return outputParts.join('/');
-};
-
-exports.sep = '/';
-exports.delimiter = ':';
-
-exports.dirname = function (path) {
- if (typeof path !== 'string') path = path + '';
- if (path.length === 0) return '.';
- var code = path.charCodeAt(0);
- var hasRoot = code === 47 /*/*/;
- var end = -1;
- var matchedSlash = true;
- for (var i = path.length - 1; i >= 1; --i) {
- code = path.charCodeAt(i);
- if (code === 47 /*/*/) {
- if (!matchedSlash) {
- end = i;
- break;
+
+ // hrefs like //foo/bar always cut to the protocol.
+ if (relative.slashes && !relative.protocol) {
+ // take everything except the protocol from relative
+ var rkeys = Object.keys(relative);
+ for (var rk = 0; rk < rkeys.length; rk++) {
+ var rkey = rkeys[rk];
+ if (rkey !== 'protocol') result[rkey] = relative[rkey];
+ }
+
+ //urlParse appends trailing / to urls like http://www.example.com
+ if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
+ result.path = result.pathname = '/';
+ }
+
+ result.href = result.format();
+ return result;
+ }
+
+ if (relative.protocol && relative.protocol !== result.protocol) {
+ // if it's a known url protocol, then changing
+ // the protocol does weird things
+ // first, if it's not file:, then we MUST have a host,
+ // and if there was a path
+ // to begin with, then we MUST have a path.
+ // if it is file:, then the host is dropped,
+ // because that's known to be hostless.
+ // anything else is assumed to be absolute.
+ if (!slashedProtocol[relative.protocol]) {
+ var keys = Object.keys(relative);
+ for (var v = 0; v < keys.length; v++) {
+ var k = keys[v];
+ result[k] = relative[k];
}
+ result.href = result.format();
+ return result;
+ }
+
+ result.protocol = relative.protocol;
+ if (!relative.host && !hostlessProtocol[relative.protocol]) {
+ var relPath = (relative.pathname || '').split('/');
+ while (relPath.length && !(relative.host = relPath.shift())) {}
+ if (!relative.host) relative.host = '';
+ if (!relative.hostname) relative.hostname = '';
+ if (relPath[0] !== '') relPath.unshift('');
+ if (relPath.length < 2) relPath.unshift('');
+ result.pathname = relPath.join('/');
} else {
- // We saw the first non-path separator
- matchedSlash = false;
- }
- }
-
- if (end === -1) return hasRoot ? '/' : '.';
- if (hasRoot && end === 1) {
- // return '//';
- // Backwards-compat fix:
- return '/';
- }
- return path.slice(0, end);
-};
-
-function basename(path) {
- if (typeof path !== 'string') path = path + '';
-
- var start = 0;
- var end = -1;
- var matchedSlash = true;
- var i;
-
- for (i = path.length - 1; i >= 0; --i) {
- if (path.charCodeAt(i) === 47 /*/*/) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now
- if (!matchedSlash) {
- start = i + 1;
- break;
- }
- } else if (end === -1) {
- // We saw the first non-path separator, mark this as the end of our
- // path component
- matchedSlash = false;
- end = i + 1;
- }
- }
-
- if (end === -1) return '';
- return path.slice(start, end);
-}
-
-// Uses a mixed approach for backwards-compatibility, as ext behavior changed
-// in new Node.js versions, so only basename() above is backported here
-exports.basename = function (path, ext) {
- var f = basename(path);
- if (ext && f.substr(-1 * ext.length) === ext) {
- f = f.substr(0, f.length - ext.length);
- }
- return f;
-};
-
-exports.extname = function (path) {
- if (typeof path !== 'string') path = path + '';
- var startDot = -1;
- var startPart = 0;
- var end = -1;
- var matchedSlash = true;
- // Track the state of characters (if any) we see before our first dot and
- // after any path separator we find
- var preDotState = 0;
- for (var i = path.length - 1; i >= 0; --i) {
- var code = path.charCodeAt(i);
- if (code === 47 /*/*/) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now
- if (!matchedSlash) {
- startPart = i + 1;
- break;
- }
- continue;
+ result.pathname = relative.pathname;
}
- if (end === -1) {
- // We saw the first non-path separator, mark this as the end of our
- // extension
- matchedSlash = false;
- end = i + 1;
- }
- if (code === 46 /*.*/) {
- // If this is our first dot, mark it as the start of our extension
- if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
- } else if (startDot !== -1) {
- // We saw a non-dot and non-path separator before our dot, so we should
- // have a good chance at having a non-empty extension
- preDotState = -1;
- }
- }
-
- if (startDot === -1 || end === -1 ||
- // We saw a non-dot character immediately before the dot
- preDotState === 0 ||
- // The (right-most) trimmed path component is exactly '..'
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
- return '';
- }
- return path.slice(startDot, end);
-};
-
-function filter(xs, f) {
- if (xs.filter) return xs.filter(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- if (f(xs[i], i, xs)) res.push(xs[i]);
- }
- return res;
-}
-
-// String.prototype.substr - negative index don't work in IE8
-var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) {
- return str.substr(start, len);
-} : function (str, start, len) {
- if (start < 0) start = str.length + start;
- return str.substr(start, len);
-};
-}).call(this,require('_process'))
-},{"_process":101}],99:[function(require,module,exports){
-(function (process){
-'use strict';
-
-function posix(path) {
- return path.charAt(0) === '/';
-}
-
-function win32(path) {
- // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
- var result = splitDeviceRe.exec(path);
- var device = result[1] || '';
- var isUnc = Boolean(device && device.charAt(1) !== ':');
-
- // UNC paths are always absolute
- return Boolean(result[2] || isUnc);
-}
-
-module.exports = process.platform === 'win32' ? win32 : posix;
-module.exports.posix = posix;
-module.exports.win32 = win32;
-}).call(this,require('_process'))
-},{"_process":101}],100:[function(require,module,exports){
-'use strict';
-
-var processFn = function (fn, opts) {
- return function () {
- var _this = this;
-
- var P = opts.promiseModule;
- var args = new Array(arguments.length);
-
- for (var i = 0; i < arguments.length; i++) {
- args[i] = arguments[i];
- }
-
- return new P(function (resolve, reject) {
- if (opts.errorFirst) {
- args.push(function (err, result) {
- if (opts.multiArgs) {
- var results = new Array(arguments.length - 1);
-
- for (var _i = 1; _i < arguments.length; _i++) {
- results[_i - 1] = arguments[_i];
- }
-
- if (err) {
- results.unshift(err);
- reject(results);
- } else {
- resolve(results);
- }
- } else if (err) {
- reject(err);
- } else {
- resolve(result);
- }
- });
- } else {
- args.push(function (result) {
- if (opts.multiArgs) {
- var results = new Array(arguments.length - 1);
-
- for (var _i2 = 0; _i2 < arguments.length; _i2++) {
- results[_i2] = arguments[_i2];
- }
-
- resolve(results);
- } else {
- resolve(result);
- }
- });
- }
-
- fn.apply(_this, args);
- });
- };
-};
-
-module.exports = function (obj, opts) {
- opts = Object.assign({
- exclude: [/.+(Sync|Stream)$/],
- errorFirst: true,
- promiseModule: Promise
- }, opts);
-
- var filter = function (key) {
- var match = function (pattern) {
- return typeof pattern === 'string' ? key === pattern : pattern.test(key);
- };
- return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
- };
-
- var ret = void 0;
- if (typeof obj === 'function') {
- ret = function () {
- if (opts.excludeMain) {
- return obj.apply(this, arguments);
- }
-
- return processFn(obj, opts).apply(this, arguments);
- };
- } else {
- ret = Object.create(Object.getPrototypeOf(obj));
- }
-
- for (var key in obj) {
- // eslint-disable-line guard-for-in
- var x = obj[key];
- ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
- }
-
- return ret;
-};
-},{}],101:[function(require,module,exports){
-// shim for using process in browser
-var process = module.exports = {};
-
-// cached from whatever global is present so that test runners that stub it
-// don't break things. But we need to wrap it in a try catch in case it is
-// wrapped in strict mode code which doesn't define any globals. It's inside a
-// function because try/catches deoptimize in certain engines.
-
-var cachedSetTimeout;
-var cachedClearTimeout;
-
-function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
-}
-function defaultClearTimeout() {
- throw new Error('clearTimeout has not been defined');
-}
-(function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
+ result.search = relative.search;
+ result.query = relative.query;
+ result.host = relative.host || '';
+ result.auth = relative.auth;
+ result.hostname = relative.hostname || relative.host;
+ result.port = relative.port;
+ // to support http.request
+ if (result.pathname || result.search) {
+ var p = result.pathname || '';
+ var s = result.search || '';
+ result.path = p + s;
+ }
+ result.slashes = result.slashes || relative.slashes;
+ result.href = result.format();
+ return result;
}
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
+
+ var isSourceAbs = result.pathname && result.pathname.charAt(0) === '/',
+ isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === '/',
+ mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname,
+ removeAllDots = mustEndAbs,
+ srcPath = result.pathname && result.pathname.split('/') || [],
+ relPath = relative.pathname && relative.pathname.split('/') || [],
+ psychotic = result.protocol && !slashedProtocol[result.protocol];
+
+ // if the url is a non-slashed url, then relative
+ // links like ../.. should be able
+ // to crawl up to the hostname, as well. This is strange.
+ // result.protocol has already been set by now.
+ // Later on, put the first path part into the host field.
+ if (psychotic) {
+ result.hostname = '';
+ result.port = null;
+ if (result.host) {
+ if (srcPath[0] === '') srcPath[0] = result.host;else srcPath.unshift(result.host);
+ }
+ result.host = '';
+ if (relative.protocol) {
+ relative.hostname = null;
+ relative.port = null;
+ if (relative.host) {
+ if (relPath[0] === '') relPath[0] = relative.host;else relPath.unshift(relative.host);
}
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
+ relative.host = null;
+ }
+ mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
+ }
+
+ if (isRelAbs) {
+ // it's absolute.
+ result.host = relative.host || relative.host === '' ? relative.host : result.host;
+ result.hostname = relative.hostname || relative.hostname === '' ? relative.hostname : result.hostname;
+ result.search = relative.search;
+ result.query = relative.query;
+ srcPath = relPath;
+ // fall through to the dot-handling below.
+ } else if (relPath.length) {
+ // it's relative
+ // throw away the existing file, and take the new path instead.
+ if (!srcPath) srcPath = [];
+ srcPath.pop();
+ srcPath = srcPath.concat(relPath);
+ result.search = relative.search;
+ result.query = relative.query;
+ } else if (!util.isNullOrUndefined(relative.search)) {
+ // just pull out the search.
+ // like href='?foo'.
+ // Put this after the other two cases because it simplifies the booleans
+ if (psychotic) {
+ result.hostname = result.host = srcPath.shift();
+ //occationaly the auth can get stuck only in host
+ //this especially happens in cases like
+ //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
+ var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
+ if (authInHost) {
+ result.auth = authInHost.shift();
+ result.host = result.hostname = authInHost.shift();
+ }
+ }
+ result.search = relative.search;
+ result.query = relative.query;
+ //to support http.request
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
+ result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
+ }
+ result.href = result.format();
+ return result;
}
-})();
-function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
+
+ if (!srcPath.length) {
+ // no path at all. easy.
+ // we've already handled the other stuff above.
+ result.pathname = null;
+ //to support http.request
+ if (result.search) {
+ result.path = '/' + result.search;
+ } else {
+ result.path = null;
+ }
+ result.href = result.format();
+ return result;
}
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
+
+ // if a url ENDs in . or .., then it must get a trailing slash.
+ // however, if it ends in anything else non-slashy,
+ // then it must NOT get a trailing slash.
+ var last = srcPath.slice(-1)[0];
+ var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..') || last === '';
+
+ // strip single dots, resolve double dots to parent dir
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = srcPath.length; i >= 0; i--) {
+ last = srcPath[i];
+ if (last === '.') {
+ srcPath.splice(i, 1);
+ } else if (last === '..') {
+ srcPath.splice(i, 1);
+ up++;
+ } else if (up) {
+ srcPath.splice(i, 1);
+ up--;
+ }
}
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch (e) {
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch (e) {
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (!mustEndAbs && !removeAllDots) {
+ for (; up--; up) {
+ srcPath.unshift('..');
+ }
}
-}
-function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
+
+ if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
+ srcPath.unshift('');
}
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
+
+ if (hasTrailingSlash && srcPath.join('/').substr(-1) !== '/') {
+ srcPath.push('');
}
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e) {
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e) {
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
+
+ var isAbsolute = srcPath[0] === '' || srcPath[0] && srcPath[0].charAt(0) === '/';
+
+ // put the host back
+ if (psychotic) {
+ result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : '';
+ //occationaly the auth can get stuck only in host
+ //this especially happens in cases like
+ //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
+ var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
+ if (authInHost) {
+ result.auth = authInHost.shift();
+ result.host = result.hostname = authInHost.shift();
+ }
}
-}
-var queue = [];
-var draining = false;
-var currentQueue;
-var queueIndex = -1;
-
-function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
+
+ mustEndAbs = mustEndAbs || result.host && srcPath.length;
+
+ if (mustEndAbs && !isAbsolute) {
+ srcPath.unshift('');
}
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
+
+ if (!srcPath.length) {
+ result.pathname = null;
+ result.path = null;
} else {
- queueIndex = -1;
+ result.pathname = srcPath.join('/');
}
- if (queue.length) {
- drainQueue();
+
+ //to support request.http
+ if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
+ result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
}
-}
-
-function drainQueue() {
- if (draining) {
- return;
+ result.auth = relative.auth || result.auth;
+ result.slashes = result.slashes || relative.slashes;
+ result.href = result.format();
+ return result;
+ };
+
+ Url.prototype.parseHost = function () {
+ var host = this.host;
+ var port = portPattern.exec(host);
+ if (port) {
+ port = port[0];
+ if (port !== ':') {
+ this.port = port.substr(1);
+ }
+ host = host.substr(0, host.length - port.length);
}
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while (len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
+ if (host) this.hostname = host;
+ };
+ },{"./util":123,"punycode":106,"querystring":109}],123:[function(require,module,exports){
+ 'use strict';
+
+ module.exports = {
+ isString: function (arg) {
+ return typeof arg === 'string';
+ },
+ isObject: function (arg) {
+ return typeof arg === 'object' && arg !== null;
+ },
+ isNull: function (arg) {
+ return arg === null;
+ },
+ isNullOrUndefined: function (arg) {
+ return arg == null;
+ }
+ };
+ },{}],124:[function(require,module,exports){
+ arguments[4][2][0].apply(exports,arguments)
+ },{"dup":2}],125:[function(require,module,exports){
+ arguments[4][3][0].apply(exports,arguments)
+ },{"dup":3}],126:[function(require,module,exports){
+ arguments[4][4][0].apply(exports,arguments)
+ },{"./support/isBuffer":125,"_process":105,"dup":4,"inherits":124}],127:[function(require,module,exports){
+ var assert = require('assert');
+ var trie = require('./trie');
+
+ module.exports = Wayfarer;
+
+ // create a router
+ // str -> obj
+ function Wayfarer(dft) {
+ if (!(this instanceof Wayfarer)) return new Wayfarer(dft);
+
+ var _default = (dft || '').replace(/^\//, '');
+ var _trie = trie();
+
+ emit._trie = _trie;
+ emit.on = on;
+ emit.emit = emit;
+ emit.match = match;
+ emit._wayfarer = true;
+
+ return emit;
+
+ // define a route
+ // (str, fn) -> obj
+ function on(route, fn) {
+ assert.equal(typeof route, 'string');
+ assert.equal(typeof fn, 'function');
+
+ var cb = fn._wayfarer && fn._trie ? fn : proxy;
+ route = route || '/';
+ cb.route = route;
+
+ if (cb._wayfarer && cb._trie) {
+ _trie.mount(route, cb._trie.trie);
+ } else {
+ var node = _trie.create(route);
+ node.cb = cb;
+ }
+
+ return emit;
+
+ function proxy() {
+ return fn.apply(this, Array.prototype.slice.call(arguments));
+ }
+ }
+
+ // match and call a route
+ // (str, obj?) -> null
+ function emit(route) {
+ var matched = match(route);
+
+ var args = new Array(arguments.length);
+ args[0] = matched.params;
+ for (var i = 1; i < args.length; i++) {
+ args[i] = arguments[i];
+ }
+
+ return matched.cb.apply(matched.cb, args);
+ }
+
+ function match(route) {
+ assert.notEqual(route, undefined, "'route' must be defined");
+
+ var matched = _trie.match(route);
+ if (matched && matched.cb) return new Route(matched);
+
+ var dft = _trie.match(_default);
+ if (dft && dft.cb) return new Route(dft);
+
+ throw new Error("route '" + route + "' did not match");
+ }
+
+ function Route(matched) {
+ this.cb = matched.cb;
+ this.route = matched.cb.route;
+ this.params = matched.params;
+ }
+ }
+ },{"./trie":128,"assert":1}],128:[function(require,module,exports){
+ var mutate = require('xtend/mutable');
+ var assert = require('assert');
+ var xtend = require('xtend');
+
+ module.exports = Trie;
+
+ // create a new trie
+ // null -> obj
+ function Trie() {
+ if (!(this instanceof Trie)) return new Trie();
+ this.trie = { nodes: {} };
+ }
+
+ // create a node on the trie at route
+ // and return a node
+ // str -> null
+ Trie.prototype.create = function (route) {
+ assert.equal(typeof route, 'string', 'route should be a string');
+ // strip leading '/' and split routes
+ var routes = route.replace(/^\//, '').split('/');
+
+ function createNode(index, trie) {
+ var thisRoute = routes.hasOwnProperty(index) && routes[index];
+ if (thisRoute === false) return trie;
+
+ var node = null;
+ if (/^:|^\*/.test(thisRoute)) {
+ // if node is a name match, set name and append to ':' node
+ if (!trie.nodes.hasOwnProperty('$$')) {
+ node = { nodes: {} };
+ trie.nodes['$$'] = node;
+ } else {
+ node = trie.nodes['$$'];
}
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
-}
-
-process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
+
+ if (thisRoute[0] === '*') {
+ trie.wildcard = true;
}
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
-};
-
-// v8 likes predictible objects
-function Item(fun, array) {
- this.fun = fun;
- this.array = array;
-}
-Item.prototype.run = function () {
- this.fun.apply(null, this.array);
-};
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-process.versions = {};
-
-function noop() {}
-
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
-process.prependListener = noop;
-process.prependOnceListener = noop;
-
-process.listeners = function (name) {
- return [];
-};
-
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
-
-process.cwd = function () {
- return '/';
-};
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function () {
- return 0;
-};
-},{}],102:[function(require,module,exports){
-(function (global){
-/*! https://mths.be/punycode v1.4.1 by @mathias */
-;(function (root) {
-
- /** Detect free variables */
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
- var freeModule = typeof module == 'object' && module && !module.nodeType && module;
- var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
- root = freeGlobal;
- }
-
- /**
- * The `punycode` object.
- * @name punycode
- * @type Object
- */
- var punycode,
-
-
- /** Highest positive signed 32-bit float value */
- maxInt = 2147483647,
- // aka. 0x7FFFFFFF or 2^31-1
-
- /** Bootstring parameters */
- base = 36,
- tMin = 1,
- tMax = 26,
- skew = 38,
- damp = 700,
- initialBias = 72,
- initialN = 128,
- // 0x80
- delimiter = '-',
- // '\x2D'
-
- /** Regular expressions */
- regexPunycode = /^xn--/,
- regexNonASCII = /[^\x20-\x7E]/,
- // unprintable ASCII chars + non-ASCII chars
- regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
- // RFC 3490 separators
-
- /** Error messages */
- errors = {
- 'overflow': 'Overflow: input needs wider integers to process',
- 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
- 'invalid-input': 'Invalid input'
- },
-
-
- /** Convenience shortcuts */
- baseMinusTMin = base - tMin,
- floor = Math.floor,
- stringFromCharCode = String.fromCharCode,
-
-
- /** Temporary variable */
- key;
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * A generic error utility function.
- * @private
- * @param {String} type The error type.
- * @returns {Error} Throws a `RangeError` with the applicable error message.
- */
- function error(type) {
- throw new RangeError(errors[type]);
- }
-
- /**
- * A generic `Array#map` utility function.
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} callback The function that gets called for every array
- * item.
- * @returns {Array} A new array of values returned by the callback function.
- */
- function map(array, fn) {
- var length = array.length;
- var result = [];
- while (length--) {
- result[length] = fn(array[length]);
- }
- return result;
- }
-
- /**
- * A simple `Array#map`-like wrapper to work with domain name strings or email
- * addresses.
- * @private
- * @param {String} domain The domain name or email address.
- * @param {Function} callback The function that gets called for every
- * character.
- * @returns {Array} A new string of characters returned by the callback
- * function.
- */
- function mapDomain(string, fn) {
- var parts = string.split('@');
- var result = '';
- if (parts.length > 1) {
- // In email addresses, only the domain name should be punycoded. Leave
- // the local part (i.e. everything up to `@`) intact.
- result = parts[0] + '@';
- string = parts[1];
- }
- // Avoid `split(regex)` for IE8 compatibility. See #17.
- string = string.replace(regexSeparators, '\x2E');
- var labels = string.split('.');
- var encoded = map(labels, fn).join('.');
- return result + encoded;
- }
-
- /**
- * Creates an array containing the numeric code points of each Unicode
- * character in the string. While JavaScript uses UCS-2 internally,
- * this function will convert a pair of surrogate halves (each of which
- * UCS-2 exposes as separate characters) into a single code point,
- * matching UTF-16.
- * @see `punycode.ucs2.encode`
- * @see
- * @memberOf punycode.ucs2
- * @name decode
- * @param {String} string The Unicode input string (UCS-2).
- * @returns {Array} The new array of code points.
- */
- function ucs2decode(string) {
- var output = [],
- counter = 0,
- length = string.length,
- value,
- extra;
- while (counter < length) {
- value = string.charCodeAt(counter++);
- if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
- // high surrogate, and there is a next character
- extra = string.charCodeAt(counter++);
- if ((extra & 0xFC00) == 0xDC00) {
- // low surrogate
- output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
- } else {
- // unmatched surrogate; only append this code unit, in case the next
- // code unit is the high surrogate of a surrogate pair
- output.push(value);
- counter--;
- }
- } else {
- output.push(value);
- }
- }
- return output;
- }
-
- /**
- * Creates a string based on an array of numeric code points.
- * @see `punycode.ucs2.decode`
- * @memberOf punycode.ucs2
- * @name encode
- * @param {Array} codePoints The array of numeric code points.
- * @returns {String} The new Unicode string (UCS-2).
- */
- function ucs2encode(array) {
- return map(array, function (value) {
- var output = '';
- if (value > 0xFFFF) {
- value -= 0x10000;
- output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
- value = 0xDC00 | value & 0x3FF;
- }
- output += stringFromCharCode(value);
- return output;
- }).join('');
- }
-
- /**
- * Converts a basic code point into a digit/integer.
- * @see `digitToBasic()`
- * @private
- * @param {Number} codePoint The basic numeric code point value.
- * @returns {Number} The numeric value of a basic code point (for use in
- * representing integers) in the range `0` to `base - 1`, or `base` if
- * the code point does not represent a value.
- */
- function basicToDigit(codePoint) {
- if (codePoint - 48 < 10) {
- return codePoint - 22;
- }
- if (codePoint - 65 < 26) {
- return codePoint - 65;
- }
- if (codePoint - 97 < 26) {
- return codePoint - 97;
- }
- return base;
- }
-
- /**
- * Converts a digit/integer into a basic code point.
- * @see `basicToDigit()`
- * @private
- * @param {Number} digit The numeric value of a basic code point.
- * @returns {Number} The basic code point whose value (when used for
- * representing integers) is `digit`, which needs to be in the range
- * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
- * used; else, the lowercase form is used. The behavior is undefined
- * if `flag` is non-zero and `digit` has no uppercase form.
- */
- function digitToBasic(digit, flag) {
- // 0..25 map to ASCII a..z or A..Z
- // 26..35 map to ASCII 0..9
- return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
- }
-
- /**
- * Bias adaptation function as per section 3.4 of RFC 3492.
- * https://tools.ietf.org/html/rfc3492#section-3.4
- * @private
- */
- function adapt(delta, numPoints, firstTime) {
- var k = 0;
- delta = firstTime ? floor(delta / damp) : delta >> 1;
- delta += floor(delta / numPoints);
- for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
- delta = floor(delta / baseMinusTMin);
- }
- return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
- }
-
- /**
- * Converts a Punycode string of ASCII-only symbols to a string of Unicode
- * symbols.
- * @memberOf punycode
- * @param {String} input The Punycode string of ASCII-only symbols.
- * @returns {String} The resulting string of Unicode symbols.
- */
- function decode(input) {
- // Don't use UCS-2
- var output = [],
- inputLength = input.length,
- out,
- i = 0,
- n = initialN,
- bias = initialBias,
- basic,
- j,
- index,
- oldi,
- w,
- k,
- digit,
- t,
-
- /** Cached calculation results */
- baseMinusT;
-
- // Handle the basic code points: let `basic` be the number of input code
- // points before the last delimiter, or `0` if there is none, then copy
- // the first basic code points to the output.
-
- basic = input.lastIndexOf(delimiter);
- if (basic < 0) {
- basic = 0;
- }
-
- for (j = 0; j < basic; ++j) {
- // if it's not a basic code point
- if (input.charCodeAt(j) >= 0x80) {
- error('not-basic');
- }
- output.push(input.charCodeAt(j));
- }
-
- // Main decoding loop: start just after the last delimiter if any basic code
- // points were copied; start at the beginning otherwise.
-
- for (index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
-
- // `index` is the index of the next character to be consumed.
- // Decode a generalized variable-length integer into `delta`,
- // which gets added to `i`. The overflow checking is easier
- // if we increase `i` as we go, then subtract off its starting
- // value at the end to obtain `delta`.
- for (oldi = i, w = 1, k = base;; /* no condition */k += base) {
-
- if (index >= inputLength) {
- error('invalid-input');
- }
-
- digit = basicToDigit(input.charCodeAt(index++));
-
- if (digit >= base || digit > floor((maxInt - i) / w)) {
- error('overflow');
- }
-
- i += digit * w;
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
-
- if (digit < t) {
- break;
- }
-
- baseMinusT = base - t;
- if (w > floor(maxInt / baseMinusT)) {
- error('overflow');
- }
-
- w *= baseMinusT;
- }
-
- out = output.length + 1;
- bias = adapt(i - oldi, out, oldi == 0);
-
- // `i` was supposed to wrap around from `out` to `0`,
- // incrementing `n` each time, so we'll fix that now:
- if (floor(i / out) > maxInt - n) {
- error('overflow');
- }
-
- n += floor(i / out);
- i %= out;
-
- // Insert `n` at position `i` of the output
- output.splice(i++, 0, n);
- }
-
- return ucs2encode(output);
- }
-
- /**
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
- * Punycode string of ASCII-only symbols.
- * @memberOf punycode
- * @param {String} input The string of Unicode symbols.
- * @returns {String} The resulting Punycode string of ASCII-only symbols.
- */
- function encode(input) {
- var n,
- delta,
- handledCPCount,
- basicLength,
- bias,
- j,
- m,
- q,
- k,
- t,
- currentValue,
- output = [],
-
- /** `inputLength` will hold the number of code points in `input`. */
- inputLength,
-
- /** Cached calculation results */
- handledCPCountPlusOne,
- baseMinusT,
- qMinusT;
-
- // Convert the input in UCS-2 to Unicode
- input = ucs2decode(input);
-
- // Cache the length
- inputLength = input.length;
-
- // Initialize the state
- n = initialN;
- delta = 0;
- bias = initialBias;
-
- // Handle the basic code points
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue < 0x80) {
- output.push(stringFromCharCode(currentValue));
- }
- }
-
- handledCPCount = basicLength = output.length;
-
- // `handledCPCount` is the number of code points that have been handled;
- // `basicLength` is the number of basic code points.
-
- // Finish the basic string - if it is not empty - with a delimiter
- if (basicLength) {
- output.push(delimiter);
- }
-
- // Main encoding loop:
- while (handledCPCount < inputLength) {
-
- // All non-basic code points < n have been handled already. Find the next
- // larger one:
- for (m = maxInt, j = 0; j < inputLength; ++j) {
- currentValue = input[j];
- if (currentValue >= n && currentValue < m) {
- m = currentValue;
- }
- }
-
- // Increase `delta` enough to advance the decoder's state to ,
- // but guard against overflow
- handledCPCountPlusOne = handledCPCount + 1;
- if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
- error('overflow');
- }
-
- delta += (m - n) * handledCPCountPlusOne;
- n = m;
-
- for (j = 0; j < inputLength; ++j) {
- currentValue = input[j];
-
- if (currentValue < n && ++delta > maxInt) {
- error('overflow');
- }
-
- if (currentValue == n) {
- // Represent delta as a generalized variable-length integer
- for (q = delta, k = base;; /* no condition */k += base) {
- t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
- if (q < t) {
- break;
- }
- qMinusT = q - t;
- baseMinusT = base - t;
- output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
- q = floor(qMinusT / baseMinusT);
- }
-
- output.push(stringFromCharCode(digitToBasic(q, 0)));
- bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
- delta = 0;
- ++handledCPCount;
- }
- }
-
- ++delta;
- ++n;
- }
- return output.join('');
- }
-
- /**
- * Converts a Punycode string representing a domain name or an email address
- * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
- * it doesn't matter if you call it on a string that has already been
- * converted to Unicode.
- * @memberOf punycode
- * @param {String} input The Punycoded domain name or email address to
- * convert to Unicode.
- * @returns {String} The Unicode representation of the given Punycode
- * string.
- */
- function toUnicode(input) {
- return mapDomain(input, function (string) {
- return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
- });
- }
-
- /**
- * Converts a Unicode string representing a domain name or an email address to
- * Punycode. Only the non-ASCII parts of the domain name will be converted,
- * i.e. it doesn't matter if you call it with a domain that's already in
- * ASCII.
- * @memberOf punycode
- * @param {String} input The domain name or email address to convert, as a
- * Unicode string.
- * @returns {String} The Punycode representation of the given domain name or
- * email address.
- */
- function toASCII(input) {
- return mapDomain(input, function (string) {
- return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
- });
- }
-
- /*--------------------------------------------------------------------------*/
-
- /** Define the public API */
- punycode = {
- /**
- * A string representing the current Punycode.js version number.
- * @memberOf punycode
- * @type String
- */
- 'version': '1.4.1',
- /**
- * An object of methods to convert from JavaScript's internal character
- * representation (UCS-2) to Unicode code points, and back.
- * @see
- * @memberOf punycode
- * @type Object
- */
- 'ucs2': {
- 'decode': ucs2decode,
- 'encode': ucs2encode
- },
- 'decode': decode,
- 'encode': encode,
- 'toASCII': toASCII,
- 'toUnicode': toUnicode
- };
-
- /** Expose `punycode` */
- // Some AMD build optimizers, like r.js, check for specific condition patterns
- // like the following:
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
- define('punycode', function () {
- return punycode;
- });
- } else if (freeExports && freeModule) {
- if (module.exports == freeExports) {
- // in Node.js, io.js, or RingoJS v0.8.0+
- freeModule.exports = punycode;
- } else {
- // in Narwhal or RingoJS v0.7.0-
- for (key in punycode) {
- punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
- }
- }
- } else {
- // in Rhino or a web browser
- root.punycode = punycode;
- }
-})(this);
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],103:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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';
-
-// If obj.hasOwnProperty has been overridden, then calling
-// obj.hasOwnProperty(prop) will break.
-// See: https://github.com/joyent/node/issues/1707
-
-function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-
-module.exports = function (qs, sep, eq, options) {
- sep = sep || '&';
- eq = eq || '=';
- var obj = {};
-
- if (typeof qs !== 'string' || qs.length === 0) {
- return obj;
- }
-
- var regexp = /\+/g;
- qs = qs.split(sep);
-
- var maxKeys = 1000;
- if (options && typeof options.maxKeys === 'number') {
- maxKeys = options.maxKeys;
- }
-
- var len = qs.length;
- // maxKeys <= 0 means that we should not limit keys count
- if (maxKeys > 0 && len > maxKeys) {
- len = maxKeys;
- }
-
- for (var i = 0; i < len; ++i) {
- var x = qs[i].replace(regexp, '%20'),
- idx = x.indexOf(eq),
- kstr,
- vstr,
- k,
- v;
-
- if (idx >= 0) {
- kstr = x.substr(0, idx);
- vstr = x.substr(idx + 1);
- } else {
- kstr = x;
- vstr = '';
- }
-
- k = decodeURIComponent(kstr);
- v = decodeURIComponent(vstr);
-
- if (!hasOwnProperty(obj, k)) {
- obj[k] = v;
- } else if (isArray(obj[k])) {
- obj[k].push(v);
- } else {
- obj[k] = [obj[k], v];
- }
- }
-
- return obj;
-};
-
-var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
-};
-},{}],104:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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';
-
-var stringifyPrimitive = function (v) {
- switch (typeof v) {
- case 'string':
- return v;
-
- case 'boolean':
- return v ? 'true' : 'false';
-
- case 'number':
- return isFinite(v) ? v : '';
-
- default:
- return '';
- }
-};
-
-module.exports = function (obj, sep, eq, name) {
- sep = sep || '&';
- eq = eq || '=';
- if (obj === null) {
- obj = undefined;
- }
-
- if (typeof obj === 'object') {
- return map(objectKeys(obj), function (k) {
- var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
- if (isArray(obj[k])) {
- return map(obj[k], function (v) {
- return ks + encodeURIComponent(stringifyPrimitive(v));
- }).join(sep);
+
+ trie.name = thisRoute.replace(/^:|^\*/, '');
+ } else if (!trie.nodes.hasOwnProperty(thisRoute)) {
+ node = { nodes: {} };
+ trie.nodes[thisRoute] = node;
} else {
- return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
- }
- }).join(sep);
- }
-
- if (!name) return '';
- return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
-};
-
-var isArray = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
-};
-
-function map(xs, f) {
- if (xs.map) return xs.map(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- res.push(f(xs[i], i));
- }
- return res;
-}
-
-var objectKeys = Object.keys || function (obj) {
- var res = [];
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
- }
- return res;
-};
-},{}],105:[function(require,module,exports){
-'use strict';
-
-exports.decode = exports.parse = require('./decode');
-exports.encode = exports.stringify = require('./encode');
-},{"./decode":103,"./encode":104}],106:[function(require,module,exports){
-'use strict';
-
-/**
- * Remove a range of items from an array
- *
- * @function removeItems
- * @param {Array<*>} arr The target array
- * @param {number} startIdx The index to begin removing from (inclusive)
- * @param {number} removeCount How many items to remove
- */
-
-module.exports = function removeItems(arr, startIdx, removeCount) {
- var i,
- length = arr.length;
-
- if (startIdx >= length || removeCount === 0) {
- return;
- }
-
- removeCount = startIdx + removeCount > length ? length - startIdx : removeCount;
-
- var len = length - removeCount;
-
- for (i = startIdx; i < len; ++i) {
- arr[i] = arr[i + removeCount];
- }
-
- arr.length = len;
-};
-},{}],107:[function(require,module,exports){
-(function (process){
-var isWin = process.platform === 'win32';
-
-module.exports = function (str) {
- var i = str.length - 1;
- if (i < 2) {
- return str;
- }
- while (isSeparator(str, i)) {
- i--;
- }
- return str.substr(0, i + 1);
-};
-
-function isSeparator(str, i) {
- var char = str[i];
- return i > 0 && (char === '/' || isWin && char === '\\');
-}
-}).call(this,require('_process'))
-},{"_process":101}],108:[function(require,module,exports){
-(function (process){
-/*!
- * resolve-path
- * Copyright(c) 2014 Jonathan Ong
- * Copyright(c) 2015-2018 Douglas Christopher Wilson
- * MIT Licensed
- */
-
-'use strict';
-
-/**
- * Module dependencies.
- * @private
- */
-
-var createError = require('http-errors');
-var join = require('path').join;
-var normalize = require('path').normalize;
-var pathIsAbsolute = require('path-is-absolute');
-var resolve = require('path').resolve;
-var sep = require('path').sep;
-
-/**
- * Module exports.
- * @public
- */
-
-module.exports = resolvePath;
-
-/**
- * Module variables.
- * @private
- */
-
-var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
-
-/**
- * Resolve relative path against a root path
- *
- * @param {string} rootPath
- * @param {string} relativePath
- * @return {string}
- * @public
- */
-
-function resolvePath(rootPath, relativePath) {
- var path = relativePath;
- var root = rootPath;
-
- // root is optional, similar to root.resolve
- if (arguments.length === 1) {
- path = rootPath;
- root = process.cwd();
- }
-
- if (root == null) {
- throw new TypeError('argument rootPath is required');
- }
-
- if (typeof root !== 'string') {
- throw new TypeError('argument rootPath must be a string');
- }
-
- if (path == null) {
- throw new TypeError('argument relativePath is required');
- }
-
- if (typeof path !== 'string') {
- throw new TypeError('argument relativePath must be a string');
- }
-
- // containing NULL bytes is malicious
- if (path.indexOf('\0') !== -1) {
- throw createError(400, 'Malicious Path');
- }
-
- // path should never be absolute
- if (pathIsAbsolute.posix(path) || pathIsAbsolute.win32(path)) {
- throw createError(400, 'Malicious Path');
- }
-
- // path outside root
- if (UP_PATH_REGEXP.test(normalize('.' + sep + path))) {
- throw createError(403);
- }
-
- // join the relative path
- return normalize(join(resolve(root), path));
-}
-}).call(this,require('_process'))
-},{"_process":101,"http-errors":22,"path":98,"path-is-absolute":99}],109:[function(require,module,exports){
-module.exports = scrollToAnchor;
-
-function scrollToAnchor(anchor, options) {
- if (anchor) {
- try {
- var el = document.querySelector(anchor);
- if (el) el.scrollIntoView(options);
- } catch (e) {}
- }
-}
-},{}],110:[function(require,module,exports){
-module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
-
-function setProtoOf(obj, proto) {
- obj.__proto__ = proto;
- return obj;
-}
-
-function mixinProperties(obj, proto) {
- for (var prop in proto) {
- if (!obj.hasOwnProperty(prop)) {
- obj[prop] = proto[prop];
- }
- }
- return obj;
-}
-},{}],111:[function(require,module,exports){
-module.exports = require('insert-css');
-},{"insert-css":39}],112:[function(require,module,exports){
-module.exports = {
- stringify: require('./lib/stringify'),
- parse: require('./lib/parse')
-};
-},{"./lib/parse":113,"./lib/stringify":114}],113:[function(require,module,exports){
-var assert = require('assert');
-var yaml = require('js-yaml');
-var xtend = require('xtend');
-
-var utils = require('./utils');
-
-module.exports = parse;
-
-function parse(str) {
- assert.equal(typeof str, 'string', 'smarkt: arg1 str must be type string');
-
- return str.split('\n----').filter(function (str) {
- return str;
- }).reduce(function (result, field) {
- var data = field.replace(/^\s+|\s+$/g, '').split(/:([^]+)/).filter(function (str) {
- return str.trim() !== '';
- });
-
- var key = data[0].replace(':', '');
-
- if (data.length >= 2) {
- var value = data[1];
-
- var firstBreak = value.split('\n', 2)[1];
- var isYaml = typeof firstBreak === 'string' ? firstBreak.substring(0, 2) === ' ' : false;
-
- if (isYaml) {
+ node = trie.nodes[thisRoute];
+ }
+
+ // we must recurse deeper
+ return createNode(index + 1, node);
+ }
+
+ return createNode(0, this.trie);
+ };
+
+ // match a route on the trie
+ // and return the node
+ // str -> obj
+ Trie.prototype.match = function (route) {
+ assert.equal(typeof route, 'string', 'route should be a string');
+
+ var routes = route.replace(/^\//, '').split('/');
+ var params = {};
+
+ function search(index, trie) {
+ // either there's no match, or we're done searching
+ if (trie === undefined) return undefined;
+ var thisRoute = routes[index];
+ if (thisRoute === undefined) return trie;
+
+ if (trie.nodes.hasOwnProperty(thisRoute)) {
+ // match regular routes first
+ return search(index + 1, trie.nodes[thisRoute]);
+ } else if (trie.name) {
+ // match named routes
try {
- result = xtend(result, yaml.safeLoad(field));
- } catch (err) {
- result[key] = utils.parseSpecial(value.trim());
+ params[trie.name] = decodeURIComponent(thisRoute);
+ } catch (e) {
+ return search(index, undefined);
+ }
+ return search(index + 1, trie.nodes['$$']);
+ } else if (trie.wildcard) {
+ // match wildcards
+ try {
+ params['wildcard'] = decodeURIComponent(routes.slice(index).join('/'));
+ } catch (e) {
+ return search(index, undefined);
}
+ // return early, or else search may keep recursing through the wildcard
+ return trie.nodes['$$'];
} else {
- result[key] = utils.parseSpecial(value.trim());
+ // no matches found
+ return search(index + 1);
}
- } else {
- result[key] = '';
}
-
- return result;
- }, {});
-}
-},{"./utils":115,"assert":1,"js-yaml":41,"xtend":127}],114:[function(require,module,exports){
-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 objectKeys = require('object-keys');
-var assert = require('assert');
-var yaml = require('js-yaml');
-
-module.exports = stringify;
-
-function stringify(obj) {
- assert.equal(typeof obj, 'object', 'smarkt: arg1 str must be type object');
-
- return objectKeys(obj).reduce(function (result, key) {
- var value = typeof obj[key] === 'undefined' ? '' : obj[key];
-
- var stringified;
- if (value == null) {
- stringified = key + ':';
- } else if (typeof value === 'object') {
- stringified = yaml.safeDump(_defineProperty({}, key, value));
+
+ var node = search(0, this.trie);
+
+ if (!node) return undefined;
+ node = xtend(node);
+ node.params = params;
+ return node;
+ };
+
+ // mount a trie onto a node at route
+ // (str, obj) -> null
+ Trie.prototype.mount = function (route, trie) {
+ assert.equal(typeof route, 'string', 'route should be a string');
+ assert.equal(typeof trie, 'object', 'trie should be a object');
+
+ var split = route.replace(/^\//, '').split('/');
+ var node = null;
+ var key = null;
+
+ if (split.length === 1) {
+ key = split[0];
+ node = this.create(key);
} else {
- stringified = key + ': ' + value;
+ var head = split.join('/');
+ key = split[0];
+ node = this.create(head);
+ }
+
+ mutate(node.nodes, trie.nodes);
+ if (trie.name) node.name = trie.name;
+
+ // delegate properties from '/' to the new node
+ // '/' cannot be reached once mounted
+ if (node.nodes['']) {
+ Object.keys(node.nodes['']).forEach(function (key) {
+ if (key === 'nodes') return;
+ node[key] = node.nodes[''][key];
+ });
+ mutate(node.nodes, node.nodes[''].nodes);
+ delete node.nodes[''].nodes;
}
-
- result.push(stringified.trim());
-
- return result;
- }, []).join('\n----\n');
-}
-},{"assert":1,"js-yaml":41,"object-keys":91}],115:[function(require,module,exports){
-module.exports = {
- parseSpecial: parseSpecial
-};
-
-function parseSpecial(str) {
- if (str === 'true') return true;
- if (str === 'false') return false;
- if (str === '[]') return [];
- if (str === '{}') return {};
- return str;
-}
-},{}],116:[function(require,module,exports){
-module.exports={
- "100": "Continue",
- "101": "Switching Protocols",
- "102": "Processing",
- "200": "OK",
- "201": "Created",
- "202": "Accepted",
- "203": "Non-Authoritative Information",
- "204": "No Content",
- "205": "Reset Content",
- "206": "Partial Content",
- "207": "Multi-Status",
- "208": "Already Reported",
- "226": "IM Used",
- "300": "Multiple Choices",
- "301": "Moved Permanently",
- "302": "Found",
- "303": "See Other",
- "304": "Not Modified",
- "305": "Use Proxy",
- "306": "(Unused)",
- "307": "Temporary Redirect",
- "308": "Permanent Redirect",
- "400": "Bad Request",
- "401": "Unauthorized",
- "402": "Payment Required",
- "403": "Forbidden",
- "404": "Not Found",
- "405": "Method Not Allowed",
- "406": "Not Acceptable",
- "407": "Proxy Authentication Required",
- "408": "Request Timeout",
- "409": "Conflict",
- "410": "Gone",
- "411": "Length Required",
- "412": "Precondition Failed",
- "413": "Payload Too Large",
- "414": "URI Too Long",
- "415": "Unsupported Media Type",
- "416": "Range Not Satisfiable",
- "417": "Expectation Failed",
- "418": "I'm a teapot",
- "421": "Misdirected Request",
- "422": "Unprocessable Entity",
- "423": "Locked",
- "424": "Failed Dependency",
- "425": "Unordered Collection",
- "426": "Upgrade Required",
- "428": "Precondition Required",
- "429": "Too Many Requests",
- "431": "Request Header Fields Too Large",
- "451": "Unavailable For Legal Reasons",
- "500": "Internal Server Error",
- "501": "Not Implemented",
- "502": "Bad Gateway",
- "503": "Service Unavailable",
- "504": "Gateway Timeout",
- "505": "HTTP Version Not Supported",
- "506": "Variant Also Negotiates",
- "507": "Insufficient Storage",
- "508": "Loop Detected",
- "509": "Bandwidth Limit Exceeded",
- "510": "Not Extended",
- "511": "Network Authentication Required"
-}
-},{}],117:[function(require,module,exports){
-/*!
- * statuses
- * Copyright(c) 2014 Jonathan Ong
- * Copyright(c) 2016 Douglas Christopher Wilson
- * MIT Licensed
- */
-
-'use strict';
-
-/**
- * Module dependencies.
- * @private
- */
-
-var codes = require('./codes.json');
-
-/**
- * Module exports.
- * @public
- */
-
-module.exports = status;
-
-// array of status codes
-status.codes = populateStatusesMap(status, codes);
-
-// status codes for redirects
-status.redirect = {
- 300: true,
- 301: true,
- 302: true,
- 303: true,
- 305: true,
- 307: true,
- 308: true
-
- // status codes for empty bodies
-};status.empty = {
- 204: true,
- 205: true,
- 304: true
-
- // status codes for when you should retry the request
-};status.retry = {
- 502: true,
- 503: true,
- 504: true
-
- /**
- * Populate the statuses map for given codes.
- * @private
- */
-
-};function populateStatusesMap(statuses, codes) {
- var arr = [];
-
- Object.keys(codes).forEach(function forEachCode(code) {
- var message = codes[code];
- var status = Number(code);
-
- // Populate properties
- statuses[status] = message;
- statuses[message] = status;
- statuses[message.toLowerCase()] = status;
-
- // Add to array
- arr.push(status);
+ };
+ },{"assert":1,"xtend":131,"xtend/mutable":132}],129:[function(require,module,exports){
+ // Returns a wrapper function that returns a wrapped callback
+ // The wrapper function should do some stuff, and return a
+ // presumably different callback function.
+ // This makes sure that own properties are retained, so that
+ // decorations and such are not lost along the way.
+ module.exports = wrappy;
+ function wrappy(fn, cb) {
+ if (fn && cb) return wrappy(fn)(cb);
+
+ if (typeof fn !== 'function') throw new TypeError('need wrapper function');
+
+ Object.keys(fn).forEach(function (k) {
+ wrapper[k] = fn[k];
+ });
+
+ return wrapper;
+
+ function wrapper() {
+ var args = new Array(arguments.length);
+ for (var i = 0; i < args.length; i++) {
+ args[i] = arguments[i];
+ }
+ var ret = fn.apply(this, args);
+ var cb = args[args.length - 1];
+ if (typeof ret === 'function' && ret !== cb) {
+ Object.keys(cb).forEach(function (k) {
+ ret[k] = cb[k];
+ });
+ }
+ return ret;
+ }
+ }
+ },{}],130:[function(require,module,exports){
+ "use strict";
+
+ var window = require("global/window");
+ var isFunction = require("is-function");
+ var parseHeaders = require("parse-headers");
+ var xtend = require("xtend");
+
+ module.exports = createXHR;
+ // Allow use of default import syntax in TypeScript
+ module.exports.default = createXHR;
+ createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
+ createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
+
+ forEachArray(["get", "put", "post", "patch", "head", "delete"], function (method) {
+ createXHR[method === "delete" ? "del" : method] = function (uri, options, callback) {
+ options = initParams(uri, options, callback);
+ options.method = method.toUpperCase();
+ return _createXHR(options);
+ };
});
-
- return arr;
-}
-
-/**
- * Get the status code.
- *
- * Given a number, this will throw if it is not a known status
- * code, otherwise the code will be returned. Given a string,
- * the string will be parsed for a number and return the code
- * if valid, otherwise will lookup the code assuming this is
- * the status message.
- *
- * @param {string|number} code
- * @returns {number}
- * @public
- */
-
-function status(code) {
- if (typeof code === 'number') {
- if (!status[code]) throw new Error('invalid status code: ' + code);
- return code;
- }
-
- if (typeof code !== 'string') {
- throw new TypeError('code must be a number or string');
- }
-
- // '403'
- var n = parseInt(code, 10);
- if (!isNaN(n)) {
- if (!status[n]) throw new Error('invalid status code: ' + n);
- return n;
+
+ function forEachArray(array, iterator) {
+ for (var i = 0; i < array.length; i++) {
+ iterator(array[i]);
+ }
}
-
- n = status[code.toLowerCase()];
- if (!n) throw new Error('invalid status message: "' + code + '"');
- return n;
-}
-},{"./codes.json":116}],118:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// 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';
-
-var punycode = require('punycode');
-var util = require('./util');
-
-exports.parse = urlParse;
-exports.resolve = urlResolve;
-exports.resolveObject = urlResolveObject;
-exports.format = urlFormat;
-
-exports.Url = Url;
-
-function Url() {
- this.protocol = null;
- this.slashes = null;
- this.auth = null;
- this.host = null;
- this.port = null;
- this.hostname = null;
- this.hash = null;
- this.search = null;
- this.query = null;
- this.pathname = null;
- this.path = null;
- this.href = null;
-}
-
-// Reference: RFC 3986, RFC 1808, RFC 2396
-
-// define these here so at least they only have to be
-// compiled once on the first module load.
-var protocolPattern = /^([a-z0-9.+-]+:)/i,
- portPattern = /:[0-9]*$/,
-
-
-// Special case for a simple path URL
-simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
-
-
-// RFC 2396: characters reserved for delimiting URLs.
-// We actually just auto-escape these.
-delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
-
-
-// RFC 2396: characters not allowed for various reasons.
-unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
-
-
-// Allowed by RFCs, but cause of XSS attacks. Always escape these.
-autoEscape = ['\''].concat(unwise),
-
-// Characters that are never ever allowed in a hostname.
-// Note that any invalid chars are also handled, but these
-// are the ones that are *expected* to be seen, so we fast-path
-// them.
-nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
- hostEndingChars = ['/', '?', '#'],
- hostnameMaxLen = 255,
- hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
- hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
-
-// protocols that can allow "unsafe" and "unwise" chars.
-unsafeProtocol = {
- 'javascript': true,
- 'javascript:': true
-},
-
-// protocols that never have a hostname.
-hostlessProtocol = {
- 'javascript': true,
- 'javascript:': true
-},
-
-// protocols that always contain a // bit.
-slashedProtocol = {
- 'http': true,
- 'https': true,
- 'ftp': true,
- 'gopher': true,
- 'file': true,
- 'http:': true,
- 'https:': true,
- 'ftp:': true,
- 'gopher:': true,
- 'file:': true
-},
- querystring = require('querystring');
-
-function urlParse(url, parseQueryString, slashesDenoteHost) {
- if (url && util.isObject(url) && url instanceof Url) return url;
-
- var u = new Url();
- u.parse(url, parseQueryString, slashesDenoteHost);
- return u;
-}
-
-Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
- if (!util.isString(url)) {
- throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
- }
-
- // Copy chrome, IE, opera backslash-handling behavior.
- // Back slashes before the query string get converted to forward slashes
- // See: https://code.google.com/p/chromium/issues/detail?id=25916
- var queryIndex = url.indexOf('?'),
- splitter = queryIndex !== -1 && queryIndex < url.indexOf('#') ? '?' : '#',
- uSplit = url.split(splitter),
- slashRegex = /\\/g;
- uSplit[0] = uSplit[0].replace(slashRegex, '/');
- url = uSplit.join(splitter);
-
- var rest = url;
-
- // trim before proceeding.
- // This is to support parse stuff like " http://foo.com \n"
- rest = rest.trim();
-
- if (!slashesDenoteHost && url.split('#').length === 1) {
- // Try fast path regexp
- var simplePath = simplePathPattern.exec(rest);
- if (simplePath) {
- this.path = rest;
- this.href = rest;
- this.pathname = simplePath[1];
- if (simplePath[2]) {
- this.search = simplePath[2];
- if (parseQueryString) {
- this.query = querystring.parse(this.search.substr(1));
- } else {
- this.query = this.search.substr(1);
- }
- } else if (parseQueryString) {
- this.search = '';
- this.query = {};
+
+ function isEmpty(obj) {
+ for (var i in obj) {
+ if (obj.hasOwnProperty(i)) return false;
}
- return this;
- }
+ return true;
}
-
- var proto = protocolPattern.exec(rest);
- if (proto) {
- proto = proto[0];
- var lowerProto = proto.toLowerCase();
- this.protocol = lowerProto;
- rest = rest.substr(proto.length);
- }
-
- // figure out if it's got a host
- // user@server is *always* interpreted as a hostname, and url
- // resolution will treat //foo/bar as host=foo,path=bar because that's
- // how the browser resolves relative URLs.
- if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
- var slashes = rest.substr(0, 2) === '//';
- if (slashes && !(proto && hostlessProtocol[proto])) {
- rest = rest.substr(2);
- this.slashes = true;
- }
- }
-
- if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
-
- // there's a hostname.
- // the first instance of /, ?, ;, or # ends the host.
- //
- // If there is an @ in the hostname, then non-host chars *are* allowed
- // to the left of the last @ sign, unless some host-ending character
- // comes *before* the @-sign.
- // URLs are obnoxious.
- //
- // ex:
- // http://a@b@c/ => user:a@b host:c
- // http://a@b?@c => user:a host:c path:/?@c
-
- // v0.12 TODO(isaacs): This is not quite how Chrome does things.
- // Review our test case against browsers more comprehensively.
-
- // find the first instance of any hostEndingChars
- var hostEnd = -1;
- for (var i = 0; i < hostEndingChars.length; i++) {
- var hec = rest.indexOf(hostEndingChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
- }
-
- // at this point, either we have an explicit point where the
- // auth portion cannot go past, or the last @ char is the decider.
- var auth, atSign;
- if (hostEnd === -1) {
- // atSign can be anywhere.
- atSign = rest.lastIndexOf('@');
- } else {
- // atSign must be in auth portion.
- // http://a@b/c@d => host:b auth:a path:/c@d
- atSign = rest.lastIndexOf('@', hostEnd);
- }
-
- // Now we have a portion which is definitely the auth.
- // Pull that off.
- if (atSign !== -1) {
- auth = rest.slice(0, atSign);
- rest = rest.slice(atSign + 1);
- this.auth = decodeURIComponent(auth);
- }
-
- // the host is the remaining to the left of the first non-host char
- hostEnd = -1;
- for (var i = 0; i < nonHostChars.length; i++) {
- var hec = rest.indexOf(nonHostChars[i]);
- if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
- }
- // if we still have not hit it, then the entire thing is a host.
- if (hostEnd === -1) hostEnd = rest.length;
-
- this.host = rest.slice(0, hostEnd);
- rest = rest.slice(hostEnd);
-
- // pull out port.
- this.parseHost();
-
- // we've indicated that there is a hostname,
- // so even if it's empty, it has to be present.
- this.hostname = this.hostname || '';
-
- // if hostname begins with [ and ends with ]
- // assume that it's an IPv6 address.
- var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']';
-
- // validate a little.
- if (!ipv6Hostname) {
- var hostparts = this.hostname.split(/\./);
- for (var i = 0, l = hostparts.length; i < l; i++) {
- var part = hostparts[i];
- if (!part) continue;
- if (!part.match(hostnamePartPattern)) {
- var newpart = '';
- for (var j = 0, k = part.length; j < k; j++) {
- if (part.charCodeAt(j) > 127) {
- // we replace non-ASCII char with a temporary placeholder
- // we need this to make sure size of hostname is not
- // broken by replacing non-ASCII by nothing
- newpart += 'x';
- } else {
- newpart += part[j];
- }
+
+ function initParams(uri, options, callback) {
+ var params = uri;
+
+ if (isFunction(options)) {
+ callback = options;
+ if (typeof uri === "string") {
+ params = { uri: uri };
}
- // we test again with ASCII char only
- if (!newpart.match(hostnamePartPattern)) {
- var validParts = hostparts.slice(0, i);
- var notHost = hostparts.slice(i + 1);
- var bit = part.match(hostnamePartStart);
- if (bit) {
- validParts.push(bit[1]);
- notHost.unshift(bit[2]);
- }
- if (notHost.length) {
- rest = '/' + notHost.join('.') + rest;
- }
- this.hostname = validParts.join('.');
- break;
+ } else {
+ params = xtend(options, { uri: uri });
+ }
+
+ params.callback = callback;
+ return params;
+ }
+
+ function createXHR(uri, options, callback) {
+ options = initParams(uri, options, callback);
+ return _createXHR(options);
+ }
+
+ function _createXHR(options) {
+ if (typeof options.callback === "undefined") {
+ throw new Error("callback argument missing");
+ }
+
+ var called = false;
+ var callback = function cbOnce(err, response, body) {
+ if (!called) {
+ called = true;
+ options.callback(err, response, body);
+ }
+ };
+
+ function readystatechange() {
+ if (xhr.readyState === 4) {
+ setTimeout(loadFunc, 0);
}
- }
}
- }
-
- if (this.hostname.length > hostnameMaxLen) {
- this.hostname = '';
+
+ function getBody() {
+ // Chrome with requestType=blob throws errors arround when even testing access to responseText
+ var body = undefined;
+
+ if (xhr.response) {
+ body = xhr.response;
+ } else {
+ body = xhr.responseText || getXml(xhr);
+ }
+
+ if (isJson) {
+ try {
+ body = JSON.parse(body);
+ } catch (e) {}
+ }
+
+ return body;
+ }
+
+ function errorFunc(evt) {
+ clearTimeout(timeoutTimer);
+ if (!(evt instanceof Error)) {
+ evt = new Error("" + (evt || "Unknown XMLHttpRequest Error"));
+ }
+ evt.statusCode = 0;
+ return callback(evt, failureResponse);
+ }
+
+ // will load the data & process the response in a special response object
+ function loadFunc() {
+ if (aborted) return;
+ var status;
+ clearTimeout(timeoutTimer);
+ if (options.useXDR && xhr.status === undefined) {
+ //IE8 CORS GET successful response doesn't have a status field, but body is fine
+ status = 200;
+ } else {
+ status = xhr.status === 1223 ? 204 : xhr.status;
+ }
+ var response = failureResponse;
+ var err = null;
+
+ if (status !== 0) {
+ response = {
+ body: getBody(),
+ statusCode: status,
+ method: method,
+ headers: {},
+ url: uri,
+ rawRequest: xhr
+ };
+ if (xhr.getAllResponseHeaders) {
+ //remember xhr can in fact be XDR for CORS in IE
+ response.headers = parseHeaders(xhr.getAllResponseHeaders());
+ }
+ } else {
+ err = new Error("Internal XMLHttpRequest Error");
+ }
+ return callback(err, response, response.body);
+ }
+
+ var xhr = options.xhr || null;
+
+ if (!xhr) {
+ if (options.cors || options.useXDR) {
+ xhr = new createXHR.XDomainRequest();
+ } else {
+ xhr = new createXHR.XMLHttpRequest();
+ }
+ }
+
+ var key;
+ var aborted;
+ var uri = xhr.url = options.uri || options.url;
+ var method = xhr.method = options.method || "GET";
+ var body = options.body || options.data;
+ var headers = xhr.headers = options.headers || {};
+ var sync = !!options.sync;
+ var isJson = false;
+ var timeoutTimer;
+ var failureResponse = {
+ body: undefined,
+ headers: {},
+ statusCode: 0,
+ method: method,
+ url: uri,
+ rawRequest: xhr
+ };
+
+ if ("json" in options && options.json !== false) {
+ isJson = true;
+ headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user
+ if (method !== "GET" && method !== "HEAD") {
+ headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user
+ body = JSON.stringify(options.json === true ? body : options.json);
+ }
+ }
+
+ xhr.onreadystatechange = readystatechange;
+ xhr.onload = loadFunc;
+ xhr.onerror = errorFunc;
+ // IE9 must have onprogress be set to a unique function.
+ xhr.onprogress = function () {
+ // IE must die
+ };
+ xhr.onabort = function () {
+ aborted = true;
+ };
+ xhr.ontimeout = errorFunc;
+ xhr.open(method, uri, !sync, options.username, options.password);
+ //has to be after open
+ if (!sync) {
+ xhr.withCredentials = !!options.withCredentials;
+ }
+ // Cannot set timeout with sync request
+ // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
+ // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
+ if (!sync && options.timeout > 0) {
+ timeoutTimer = setTimeout(function () {
+ if (aborted) return;
+ aborted = true; //IE9 may still call readystatechange
+ xhr.abort("timeout");
+ var e = new Error("XMLHttpRequest timeout");
+ e.code = "ETIMEDOUT";
+ errorFunc(e);
+ }, options.timeout);
+ }
+
+ if (xhr.setRequestHeader) {
+ for (key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ xhr.setRequestHeader(key, headers[key]);
+ }
+ }
+ } else if (options.headers && !isEmpty(options.headers)) {
+ throw new Error("Headers cannot be set on an XDomainRequest object");
+ }
+
+ if ("responseType" in options) {
+ xhr.responseType = options.responseType;
+ }
+
+ if ("beforeSend" in options && typeof options.beforeSend === "function") {
+ options.beforeSend(xhr);
+ }
+
+ // Microsoft Edge browser sends "undefined" when send is called with undefined value.
+ // XMLHttpRequest spec says to pass null as body to indicate no body
+ // See https://github.com/naugtur/xhr/issues/100.
+ xhr.send(body || null);
+
+ return xhr;
+ }
+
+ function getXml(xhr) {
+ // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
+ // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
+ try {
+ if (xhr.responseType === "document") {
+ return xhr.responseXML;
+ }
+ var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror";
+ if (xhr.responseType === "" && !firefoxBugTakenEffect) {
+ return xhr.responseXML;
+ }
+ } catch (e) {}
+
+ return null;
+ }
+
+ function noop() {}
+ },{"global/window":21,"is-function":42,"parse-headers":101,"xtend":131}],131:[function(require,module,exports){
+ module.exports = extend;
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ function extend() {
+ var target = {};
+
+ for (var i = 0; i < arguments.length; i++) {
+ var source = arguments[i];
+
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ target[key] = source[key];
+ }
+ }
+ }
+
+ return target;
+ }
+ },{}],132:[function(require,module,exports){
+ module.exports = extend;
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ function extend(target) {
+ for (var i = 1; i < arguments.length; i++) {
+ var source = arguments[i];
+
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ target[key] = source[key];
+ }
+ }
+ }
+
+ return target;
+ }
+ },{}],133:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral([''], ['']);
+
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var html = require('choo/html');
+ var md = require('marked');
+
+ module.exports = format;
+
+ var renderer = new md.Renderer();
+
+ renderer.link = function (href, title, text) {
+ return '\n ' + text + '\n ';
+ };
+
+ // Overwrite md renderers
+ //
+ // renderer.hr = function () {
+ // return `
+ //
+ // `
+ // }
+ // renderer.blockquote = function (text) {
+ // return `
+ //
+ //
+ // ${text}
+ //
+ //
+ // `
+ // }
+
+ function format(str) {
+ var output = md(str || '', { renderer: renderer });
+ if (typeof window === 'undefined') {
+ var wrapper = new String(output);
+ wrapper.__encoded = true;
+ return wrapper;
} else {
- // hostnames are always lower case.
- this.hostname = this.hostname.toLowerCase();
- }
-
- if (!ipv6Hostname) {
- // IDNA Support: Returns a punycoded representation of "domain".
- // It only converts parts of the domain name that
- // have non-ASCII characters, i.e. it doesn't matter if
- // you call it with a domain that already is ASCII-only.
- this.hostname = punycode.toASCII(this.hostname);
- }
-
- var p = this.port ? ':' + this.port : '';
- var h = this.hostname || '';
- this.host = h + p;
- this.href += this.host;
-
- // strip [ and ] from the hostname
- // the host field still retains them, though
- if (ipv6Hostname) {
- this.hostname = this.hostname.substr(1, this.hostname.length - 2);
- if (rest[0] !== '/') {
- rest = '/' + rest;
- }
- }
- }
-
- // now rest is set to the post-host stuff.
- // chop off any delim chars.
- if (!unsafeProtocol[lowerProto]) {
-
- // First, make 100% sure that any "autoEscape" chars get
- // escaped, even if encodeURIComponent doesn't think they
- // need to be.
- for (var i = 0, l = autoEscape.length; i < l; i++) {
- var ae = autoEscape[i];
- if (rest.indexOf(ae) === -1) continue;
- var esc = encodeURIComponent(ae);
- if (esc === ae) {
- esc = escape(ae);
- }
- rest = rest.split(ae).join(esc);
- }
- }
-
- // chop off from the tail first.
- var hash = rest.indexOf('#');
- if (hash !== -1) {
- // got a fragment string.
- this.hash = rest.substr(hash);
- rest = rest.slice(0, hash);
- }
- var qm = rest.indexOf('?');
- if (qm !== -1) {
- this.search = rest.substr(qm);
- this.query = rest.substr(qm + 1);
- if (parseQueryString) {
- this.query = querystring.parse(this.query);
- }
- rest = rest.slice(0, qm);
- } else if (parseQueryString) {
- // no query string, but parseQueryString still requested
- this.search = '';
- this.query = {};
- }
- if (rest) this.pathname = rest;
- if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
- this.pathname = '/';
- }
-
- //to support http.request
- if (this.pathname || this.search) {
- var p = this.pathname || '';
- var s = this.search || '';
- this.path = p + s;
- }
-
- // finally, reconstruct the href based on what has been validated.
- this.href = this.format();
- return this;
-};
-
-// format a parsed object into a url string
-function urlFormat(obj) {
- // ensure it's an object, and not a string url.
- // If it's an obj, this is a no-op.
- // this way, you can call url_format() on strings
- // to clean up potentially wonky urls.
- if (util.isString(obj)) obj = urlParse(obj);
- if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
- return obj.format();
-}
-
-Url.prototype.format = function () {
- var auth = this.auth || '';
- if (auth) {
- auth = encodeURIComponent(auth);
- auth = auth.replace(/%3A/i, ':');
- auth += '@';
- }
-
- var protocol = this.protocol || '',
- pathname = this.pathname || '',
- hash = this.hash || '',
- host = false,
- query = '';
-
- if (this.host) {
- host = auth + this.host;
- } else if (this.hostname) {
- host = auth + (this.hostname.indexOf(':') === -1 ? this.hostname : '[' + this.hostname + ']');
- if (this.port) {
- host += ':' + this.port;
- }
- }
-
- if (this.query && util.isObject(this.query) && Object.keys(this.query).length) {
- query = querystring.stringify(this.query);
- }
-
- var search = this.search || query && '?' + query || '';
-
- if (protocol && protocol.substr(-1) !== ':') protocol += ':';
-
- // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
- // unless they had them to begin with.
- if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
- host = '//' + (host || '');
- if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
- } else if (!host) {
- host = '';
- }
-
- if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
- if (search && search.charAt(0) !== '?') search = '?' + search;
-
- pathname = pathname.replace(/[?#]/g, function (match) {
- return encodeURIComponent(match);
+ var el = html(_templateObject);
+ el.innerHTML = output;
+ return [].concat(_toConsumableArray(el.childNodes));
+ }
+ }
+ },{"choo/html":137,"marked":73}],134:[function(require,module,exports){
+ var css = 0;(null || true) && "_64e8248f";(null || true) && "_30c2a7ef";(null || true) && "_aef1c003";(null || true) && "_72f489aa";
+ },{"sheetify/insert":115}],135:[function(require,module,exports){
+ // styles
+ require('./design');
+
+ var choo = require('choo');
+ var Enoki = require('enoki');
+
+ var app = choo();
+
+ console.log('This website is deprecated. Please check out the new version at https://dat-ecosystem.github.io');
+
+ var defaults = {
+ "blueprints": "/blueprints",
+ "config": "site.json",
+ "content": "content",
+ "fallback": "./bundles/content.json",
+ "file": "index.txt"
+ };
+ app.use(require('enoki/choo')(defaults));
+ app.use(require('./plugins/scroll'));
+ app.use(async function countStore(state, emitter) {
+ var content = await fetch('./bundles/content.json').then(function (x) {
+ return x.json();
+ });
+ state.contact = { twitter: '@dat_project' };
+ state.content = content;
+ // emitter.on('increment', function (count) {
+ // state.count += count
+ // emitter.emit('render')
+ // })
});
- search = search.replace('#', '%23');
-
- return protocol + host + pathname + search + hash;
-};
-
-function urlResolve(source, relative) {
- return urlParse(source, false, true).resolve(relative);
-}
-
-Url.prototype.resolve = function (relative) {
- return this.resolveObject(urlParse(relative, false, true)).format();
-};
-
-function urlResolveObject(source, relative) {
- if (!source) return relative;
- return urlParse(source, false, true).resolveObject(relative);
-}
-
-Url.prototype.resolveObject = function (relative) {
- if (util.isString(relative)) {
- var rel = new Url();
- rel.parse(relative, false, true);
- relative = rel;
- }
-
- var result = new Url();
- var tkeys = Object.keys(this);
- for (var tk = 0; tk < tkeys.length; tk++) {
- var tkey = tkeys[tk];
- result[tkey] = this[tkey];
- }
-
- // hash is always overridden, no matter what.
- // even href="" will remove it.
- result.hash = relative.hash;
-
- // if the relative url is empty, then there's nothing left to do here.
- if (relative.href === '') {
- result.href = result.format();
- return result;
- }
-
- // hrefs like //foo/bar always cut to the protocol.
- if (relative.slashes && !relative.protocol) {
- // take everything except the protocol from relative
- var rkeys = Object.keys(relative);
- for (var rk = 0; rk < rkeys.length; rk++) {
- var rkey = rkeys[rk];
- if (rkey !== 'protocol') result[rkey] = relative[rkey];
- }
-
- //urlParse appends trailing / to urls like http://www.example.com
- if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
- result.path = result.pathname = '/';
- }
-
- result.href = result.format();
- return result;
- }
-
- if (relative.protocol && relative.protocol !== result.protocol) {
- // if it's a known url protocol, then changing
- // the protocol does weird things
- // first, if it's not file:, then we MUST have a host,
- // and if there was a path
- // to begin with, then we MUST have a path.
- // if it is file:, then the host is dropped,
- // because that's known to be hostless.
- // anything else is assumed to be absolute.
- if (!slashedProtocol[relative.protocol]) {
- var keys = Object.keys(relative);
- for (var v = 0; v < keys.length; v++) {
- var k = keys[v];
- result[k] = relative[k];
+ app.route('*', require('./views/wrapper'));
+
+ // start
+ if (!module.parent) app.mount('body');else module.exports = app;
+ },{"./design":134,"./plugins/scroll":148,"./views/wrapper":153,"choo":138,"enoki":140,"enoki/choo":139}],136:[function(require,module,exports){
+ var assert = require('assert');
+ var LRU = require('nanolru');
+
+ module.exports = ChooComponentCache;
+
+ function ChooComponentCache(state, emit, lru) {
+ assert.ok(this instanceof ChooComponentCache, 'ChooComponentCache should be created with `new`');
+
+ assert.equal(typeof state, 'object', 'ChooComponentCache: state should be type object');
+ assert.equal(typeof emit, 'function', 'ChooComponentCache: emit should be type function');
+
+ if (typeof lru === 'number') this.cache = new LRU(lru);else this.cache = lru || new LRU(100);
+ this.state = state;
+ this.emit = emit;
+ }
+
+ // Get & create component instances.
+ ChooComponentCache.prototype.render = function (Component, id) {
+ assert.equal(typeof Component, 'function', 'ChooComponentCache.render: Component should be type function');
+ assert.ok(typeof id === 'string' || typeof id === 'number', 'ChooComponentCache.render: id should be type string or type number');
+
+ var el = this.cache.get(id);
+ if (!el) {
+ var args = [];
+ for (var i = 2, len = arguments.length; i < len; i++) {
+ args.push(arguments[i]);
}
- result.href = result.format();
- return result;
+ args.unshift(Component, id, this.state, this.emit);
+ el = newCall.apply(newCall, args);
+ this.cache.set(id, el);
}
-
- result.protocol = relative.protocol;
- if (!relative.host && !hostlessProtocol[relative.protocol]) {
- var relPath = (relative.pathname || '').split('/');
- while (relPath.length && !(relative.host = relPath.shift())) {}
- if (!relative.host) relative.host = '';
- if (!relative.hostname) relative.hostname = '';
- if (relPath[0] !== '') relPath.unshift('');
- if (relPath.length < 2) relPath.unshift('');
- result.pathname = relPath.join('/');
+
+ return el;
+ };
+
+ // Because you can't call `new` and `.apply()` at the same time. This is a mad
+ // hack, but hey it works so we gonna go for it. Whoop.
+ function newCall(Cls) {
+ return new (Cls.bind.apply(Cls, arguments))(); // eslint-disable-line
+ }
+ },{"assert":75,"nanolru":84}],137:[function(require,module,exports){
+ module.exports = require('nanohtml');
+ },{"nanohtml":80}],138:[function(require,module,exports){
+ var scrollToAnchor = require('scroll-to-anchor');
+ var documentReady = require('document-ready');
+ var nanotiming = require('nanotiming');
+ var nanorouter = require('nanorouter');
+ var nanomorph = require('nanomorph');
+ var nanoquery = require('nanoquery');
+ var nanohref = require('nanohref');
+ var nanoraf = require('nanoraf');
+ var nanobus = require('nanobus');
+ var assert = require('assert');
+ var xtend = require('xtend');
+
+ var Cache = require('./component/cache');
+
+ module.exports = Choo;
+
+ var HISTORY_OBJECT = {};
+
+ function Choo(opts) {
+ if (!(this instanceof Choo)) return new Choo(opts);
+ opts = opts || {};
+
+ assert.equal(typeof opts, 'object', 'choo: opts should be type object');
+
+ var self = this;
+
+ // define events used by choo
+ this._events = {
+ DOMCONTENTLOADED: 'DOMContentLoaded',
+ DOMTITLECHANGE: 'DOMTitleChange',
+ REPLACESTATE: 'replaceState',
+ PUSHSTATE: 'pushState',
+ NAVIGATE: 'navigate',
+ POPSTATE: 'popState',
+ RENDER: 'render'
+
+ // properties for internal use only
+ };this._historyEnabled = opts.history === undefined ? true : opts.history;
+ this._hrefEnabled = opts.href === undefined ? true : opts.href;
+ this._hashEnabled = opts.hash === undefined ? true : opts.hash;
+ this._hasWindow = typeof window !== 'undefined';
+ this._cache = opts.cache;
+ this._loaded = false;
+ this._stores = [];
+ this._tree = null;
+
+ // state
+ var _state = {
+ events: this._events,
+ components: {}
+ };
+ if (this._hasWindow) {
+ this.state = window.initialState ? xtend(window.initialState, _state) : _state;
+ delete window.initialState;
} else {
- result.pathname = relative.pathname;
- }
- result.search = relative.search;
- result.query = relative.query;
- result.host = relative.host || '';
- result.auth = relative.auth;
- result.hostname = relative.hostname || relative.host;
- result.port = relative.port;
- // to support http.request
- if (result.pathname || result.search) {
- var p = result.pathname || '';
- var s = result.search || '';
- result.path = p + s;
- }
- result.slashes = result.slashes || relative.slashes;
- result.href = result.format();
- return result;
+ this.state = _state;
+ }
+
+ // properties that are part of the API
+ this.router = nanorouter({ curry: true });
+ this.emitter = nanobus('choo.emit');
+ this.emit = this.emitter.emit.bind(this.emitter);
+
+ // listen for title changes; available even when calling .toString()
+ if (this._hasWindow) this.state.title = document.title;
+ this.emitter.prependListener(this._events.DOMTITLECHANGE, function (title) {
+ assert.equal(typeof title, 'string', 'events.DOMTitleChange: title should be type string');
+ self.state.title = title;
+ if (self._hasWindow) document.title = title;
+ });
}
-
- var isSourceAbs = result.pathname && result.pathname.charAt(0) === '/',
- isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === '/',
- mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname,
- removeAllDots = mustEndAbs,
- srcPath = result.pathname && result.pathname.split('/') || [],
- relPath = relative.pathname && relative.pathname.split('/') || [],
- psychotic = result.protocol && !slashedProtocol[result.protocol];
-
- // if the url is a non-slashed url, then relative
- // links like ../.. should be able
- // to crawl up to the hostname, as well. This is strange.
- // result.protocol has already been set by now.
- // Later on, put the first path part into the host field.
- if (psychotic) {
- result.hostname = '';
- result.port = null;
- if (result.host) {
- if (srcPath[0] === '') srcPath[0] = result.host;else srcPath.unshift(result.host);
- }
- result.host = '';
- if (relative.protocol) {
- relative.hostname = null;
- relative.port = null;
- if (relative.host) {
- if (relPath[0] === '') relPath[0] = relative.host;else relPath.unshift(relative.host);
- }
- relative.host = null;
- }
- mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
- }
-
- if (isRelAbs) {
- // it's absolute.
- result.host = relative.host || relative.host === '' ? relative.host : result.host;
- result.hostname = relative.hostname || relative.hostname === '' ? relative.hostname : result.hostname;
- result.search = relative.search;
- result.query = relative.query;
- srcPath = relPath;
- // fall through to the dot-handling below.
- } else if (relPath.length) {
- // it's relative
- // throw away the existing file, and take the new path instead.
- if (!srcPath) srcPath = [];
- srcPath.pop();
- srcPath = srcPath.concat(relPath);
- result.search = relative.search;
- result.query = relative.query;
- } else if (!util.isNullOrUndefined(relative.search)) {
- // just pull out the search.
- // like href='?foo'.
- // Put this after the other two cases because it simplifies the booleans
- if (psychotic) {
- result.hostname = result.host = srcPath.shift();
- //occationaly the auth can get stuck only in host
- //this especially happens in cases like
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
- if (authInHost) {
- result.auth = authInHost.shift();
- result.host = result.hostname = authInHost.shift();
+
+ Choo.prototype.route = function (route, handler) {
+ assert.equal(typeof route, 'string', 'choo.route: route should be type string');
+ assert.equal(typeof handler, 'function', 'choo.handler: route should be type function');
+ this.router.on(route, handler);
+ };
+
+ Choo.prototype.use = function (cb) {
+ assert.equal(typeof cb, 'function', 'choo.use: cb should be type function');
+ var self = this;
+ this._stores.push(function (state) {
+ var msg = 'choo.use';
+ msg = cb.storeName ? msg + '(' + cb.storeName + ')' : msg;
+ var endTiming = nanotiming(msg);
+ cb(state, self.emitter, self);
+ endTiming();
+ });
+ };
+
+ Choo.prototype.start = function () {
+ assert.equal(typeof window, 'object', 'choo.start: window was not found. .start() must be called in a browser, use .toString() if running in Node');
+
+ var self = this;
+ if (this._historyEnabled) {
+ this.emitter.prependListener(this._events.NAVIGATE, function () {
+ self._matchRoute();
+ if (self._loaded) {
+ self.emitter.emit(self._events.RENDER);
+ setTimeout(scrollToAnchor.bind(null, window.location.hash), 0);
+ }
+ });
+
+ this.emitter.prependListener(this._events.POPSTATE, function () {
+ self.emitter.emit(self._events.NAVIGATE);
+ });
+
+ this.emitter.prependListener(this._events.PUSHSTATE, function (href) {
+ assert.equal(typeof href, 'string', 'events.pushState: href should be type string');
+ window.history.pushState(HISTORY_OBJECT, null, href);
+ self.emitter.emit(self._events.NAVIGATE);
+ });
+
+ this.emitter.prependListener(this._events.REPLACESTATE, function (href) {
+ assert.equal(typeof href, 'string', 'events.replaceState: href should be type string');
+ window.history.replaceState(HISTORY_OBJECT, null, href);
+ self.emitter.emit(self._events.NAVIGATE);
+ });
+
+ window.onpopstate = function () {
+ self.emitter.emit(self._events.POPSTATE);
+ };
+
+ if (self._hrefEnabled) {
+ nanohref(function (location) {
+ var href = location.href;
+ var hash = location.hash;
+ if (href === window.location.href) {
+ if (!this._hashEnabled && hash) scrollToAnchor(hash);
+ return;
+ }
+ self.emitter.emit(self._events.PUSHSTATE, href);
+ });
}
}
- result.search = relative.search;
- result.query = relative.query;
- //to support http.request
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
- result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
+
+ this._setCache(this.state);
+ this._stores.forEach(function (initStore) {
+ initStore(self.state);
+ });
+
+ this._matchRoute();
+ this._tree = this._prerender(this.state);
+ assert.ok(this._tree, 'choo.start: no valid DOM node returned for location ' + this.state.href);
+
+ this.emitter.prependListener(self._events.RENDER, nanoraf(function () {
+ var renderTiming = nanotiming('choo.render');
+ var newTree = self._prerender(self.state);
+ assert.ok(newTree, 'choo.render: no valid DOM node returned for location ' + self.state.href);
+
+ assert.equal(self._tree.nodeName, newTree.nodeName, 'choo.render: The target node <' + self._tree.nodeName.toLowerCase() + '> is not the same type as the new node <' + newTree.nodeName.toLowerCase() + '>.');
+
+ var morphTiming = nanotiming('choo.morph');
+ nanomorph(self._tree, newTree);
+ morphTiming();
+
+ renderTiming();
+ }));
+
+ documentReady(function () {
+ self.emitter.emit(self._events.DOMCONTENTLOADED);
+ self._loaded = true;
+ });
+
+ return this._tree;
+ };
+
+ Choo.prototype.mount = function mount(selector) {
+ if (typeof window !== 'object') {
+ assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String');
+ this.selector = selector;
+ return this;
}
- result.href = result.format();
- return result;
- }
-
- if (!srcPath.length) {
- // no path at all. easy.
- // we've already handled the other stuff above.
- result.pathname = null;
- //to support http.request
- if (result.search) {
- result.path = '/' + result.search;
+
+ assert.ok(typeof selector === 'string' || typeof selector === 'object', 'choo.mount: selector should be type String or HTMLElement');
+
+ var self = this;
+
+ documentReady(function () {
+ var renderTiming = nanotiming('choo.render');
+ var newTree = self.start();
+ if (typeof selector === 'string') {
+ self._tree = document.querySelector(selector);
+ } else {
+ self._tree = selector;
+ }
+
+ assert.ok(self._tree, 'choo.mount: could not query selector: ' + selector);
+ assert.equal(self._tree.nodeName, newTree.nodeName, 'choo.mount: The target node <' + self._tree.nodeName.toLowerCase() + '> is not the same type as the new node <' + newTree.nodeName.toLowerCase() + '>.');
+
+ var morphTiming = nanotiming('choo.morph');
+ nanomorph(self._tree, newTree);
+ morphTiming();
+
+ renderTiming();
+ });
+ };
+
+ Choo.prototype.toString = function (location, state) {
+ this.state = xtend(this.state, state || {});
+
+ assert.notEqual(typeof window, 'object', 'choo.mount: window was found. .toString() must be called in Node, use .start() or .mount() if running in the browser');
+ assert.equal(typeof location, 'string', 'choo.toString: location should be type string');
+ assert.equal(typeof this.state, 'object', 'choo.toString: state should be type object');
+
+ var self = this;
+ this._setCache(this.state);
+ this._stores.forEach(function (initStore) {
+ initStore(self.state);
+ });
+
+ this._matchRoute(location);
+ var html = this._prerender(this.state);
+ assert.ok(html, 'choo.toString: no valid value returned for the route ' + location);
+ assert(!Array.isArray(html), 'choo.toString: return value was an array for the route ' + location);
+ return typeof html.outerHTML === 'string' ? html.outerHTML : html.toString();
+ };
+
+ Choo.prototype._matchRoute = function (locationOverride) {
+ var location, queryString;
+ if (locationOverride) {
+ location = locationOverride.replace(/\?.+$/, '').replace(/\/$/, '');
+ if (!this._hashEnabled) location = location.replace(/#.+$/, '');
+ queryString = locationOverride;
} else {
- result.path = null;
+ location = window.location.pathname.replace(/\/$/, '');
+ if (this._hashEnabled) location += window.location.hash.replace(/^#/, '/');
+ queryString = window.location.search;
+ }
+ var matched = this.router.match(location);
+ this._handler = matched.cb;
+
+ if (location.startsWith('/dat.land')) location = location.slice(9);
+
+ this.state.href = location;
+ this.state.query = nanoquery(queryString);
+ this.state.route = matched.route;
+ this.state.params = matched.params;
+ return this.state;
+ };
+
+ Choo.prototype._prerender = function (state) {
+ var routeTiming = nanotiming("choo.prerender('" + state.route + "')");
+ var res = this._handler(state, this.emit);
+ routeTiming();
+ return res;
+ };
+
+ Choo.prototype._setCache = function (state) {
+ var cache = new Cache(state, this.emitter.emit.bind(this.emitter), this._cache);
+ state.cache = renderComponent;
+
+ function renderComponent(Component, id) {
+ assert.equal(typeof Component, 'function', 'choo.state.cache: Component should be type function');
+ var args = [];
+ for (var i = 0, len = arguments.length; i < len; i++) {
+ args.push(arguments[i]);
+ }
+ return cache.render.apply(cache, args);
}
- result.href = result.format();
- return result;
- }
-
- // if a url ENDs in . or .., then it must get a trailing slash.
- // however, if it ends in anything else non-slashy,
- // then it must NOT get a trailing slash.
- var last = srcPath.slice(-1)[0];
- var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..') || last === '';
-
- // strip single dots, resolve double dots to parent dir
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = srcPath.length; i >= 0; i--) {
- last = srcPath[i];
- if (last === '.') {
- srcPath.splice(i, 1);
- } else if (last === '..') {
- srcPath.splice(i, 1);
- up++;
- } else if (up) {
- srcPath.splice(i, 1);
- up--;
- }
- }
-
- // if the path is allowed to go above the root, restore leading ..s
- if (!mustEndAbs && !removeAllDots) {
- for (; up--; up) {
- srcPath.unshift('..');
- }
- }
-
- if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
- srcPath.unshift('');
- }
-
- if (hasTrailingSlash && srcPath.join('/').substr(-1) !== '/') {
- srcPath.push('');
- }
-
- var isAbsolute = srcPath[0] === '' || srcPath[0] && srcPath[0].charAt(0) === '/';
-
- // put the host back
- if (psychotic) {
- result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : '';
- //occationaly the auth can get stuck only in host
- //this especially happens in cases like
- //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
- var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
- if (authInHost) {
- result.auth = authInHost.shift();
- result.host = result.hostname = authInHost.shift();
- }
- }
-
- mustEndAbs = mustEndAbs || result.host && srcPath.length;
-
- if (mustEndAbs && !isAbsolute) {
- srcPath.unshift('');
- }
-
- if (!srcPath.length) {
- result.pathname = null;
- result.path = null;
- } else {
- result.pathname = srcPath.join('/');
- }
-
- //to support request.http
- if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
- result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
- }
- result.auth = relative.auth || result.auth;
- result.slashes = result.slashes || relative.slashes;
- result.href = result.format();
- return result;
-};
-
-Url.prototype.parseHost = function () {
- var host = this.host;
- var port = portPattern.exec(host);
- if (port) {
- port = port[0];
- if (port !== ':') {
- this.port = port.substr(1);
- }
- host = host.substr(0, host.length - port.length);
- }
- if (host) this.hostname = host;
-};
-},{"./util":119,"punycode":102,"querystring":105}],119:[function(require,module,exports){
-'use strict';
-
-module.exports = {
- isString: function (arg) {
- return typeof arg === 'string';
- },
- isObject: function (arg) {
- return typeof arg === 'object' && arg !== null;
- },
- isNull: function (arg) {
- return arg === null;
- },
- isNullOrUndefined: function (arg) {
- return arg == null;
+
+ // When the state gets stringified, make sure `state.cache` isn't
+ // stringified too.
+ renderComponent.toJSON = function () {
+ return null;
+ };
+ };
+ },{"./component/cache":136,"assert":75,"document-ready":13,"nanobus":76,"nanohref":77,"nanomorph":85,"nanoquery":88,"nanoraf":89,"nanorouter":90,"nanotiming":92,"scroll-to-anchor":113,"xtend":131}],139:[function(require,module,exports){
+ module.exports = require('./lib/adapters/choo');
+ },{"./lib/adapters/choo":141}],140:[function(require,module,exports){
+ module.exports = require('./lib');
+ },{"./lib":142}],141:[function(require,module,exports){
+ var Enoki = require('../read/async');
+ var Page = require('nanopage');
+ var xtend = require('xtend');
+
+ module.exports = plugin;
+
+ function plugin(parent, options) {
+ options = options || {};
+ return function (state, emitter, app) {
+
+ var enoki = new Enoki(parent);
+
+ // content state
+ state.site = state.site || { loaded: false, p2p: false };
+ state.content = state.content || {};
+
+ // nanopage
+ state.page = new Page(state);
+
+ // events
+ state.events.CONTENT_LOADED = 'content:loaded';
+ state.events.CONTENT_LOAD = 'content:load';
+
+ // listeners
+ emitter.on(state.events.DOMCONTENTLOADED, contentLoad);
+ emitter.on(state.events.CONTENT_LOAD, contentLoad);
+
+ /**
+ * primary method
+ */
+ async function contentLoad(props) {
+ props = props || {};
+ // load our site
+ await enoki.load(props.url);
+ // store our state
+ state.content = xtend(state.content, (await enoki.readContent()));
+ state.site = xtend(state.site, (await enoki.readSite()));
+ // good to go
+ emitter.emit(state.events.CONTENT_LOADED);
+ // render if we should
+ if (options.render !== false) emitter.emit(state.events.RENDER);
+ }
+ };
}
-};
-},{}],120:[function(require,module,exports){
-arguments[4][3][0].apply(exports,arguments)
-},{"dup":3}],121:[function(require,module,exports){
-arguments[4][4][0].apply(exports,arguments)
-},{"./support/isBuffer":120,"_process":101,"dup":4,"inherits":38}],122:[function(require,module,exports){
-var assert = require('assert');
-var trie = require('./trie');
-
-module.exports = Wayfarer;
-
-// create a router
-// str -> obj
-function Wayfarer(dft) {
- if (!(this instanceof Wayfarer)) return new Wayfarer(dft);
-
- var _default = (dft || '').replace(/^\//, '');
- var _trie = trie();
-
- emit._trie = _trie;
- emit.on = on;
- emit.emit = emit;
- emit.match = match;
- emit._wayfarer = true;
-
- return emit;
-
- // define a route
- // (str, fn) -> obj
- function on(route, fn) {
- assert.equal(typeof route, 'string');
- assert.equal(typeof fn, 'function');
-
- var cb = fn._wayfarer && fn._trie ? fn : proxy;
- route = route || '/';
- cb.route = route;
-
- if (cb._wayfarer && cb._trie) {
- _trie.mount(route, cb._trie.trie);
- } else {
- var node = _trie.create(route);
- node.cb = cb;
- }
-
- return emit;
-
- function proxy() {
- return fn.apply(this, Array.prototype.slice.call(arguments));
- }
- }
-
- // match and call a route
- // (str, obj?) -> null
- function emit(route) {
- var matched = match(route);
-
- var args = new Array(arguments.length);
- args[0] = matched.params;
- for (var i = 1; i < args.length; i++) {
- args[i] = arguments[i];
- }
-
- return matched.cb.apply(matched.cb, args);
- }
-
- function match(route) {
- assert.notEqual(route, undefined, "'route' must be defined");
-
- var matched = _trie.match(route);
- if (matched && matched.cb) return new Route(matched);
-
- var dft = _trie.match(_default);
- if (dft && dft.cb) return new Route(dft);
-
- throw new Error("route '" + route + "' did not match");
- }
-
- function Route(matched) {
- this.cb = matched.cb;
- this.route = matched.cb.route;
- this.params = matched.params;
- }
-}
-},{"./trie":123,"assert":1}],123:[function(require,module,exports){
-var mutate = require('xtend/mutable');
-var assert = require('assert');
-var xtend = require('xtend');
-
-module.exports = Trie;
-
-// create a new trie
-// null -> obj
-function Trie() {
- if (!(this instanceof Trie)) return new Trie();
- this.trie = { nodes: {} };
-}
-
-// create a node on the trie at route
-// and return a node
-// str -> null
-Trie.prototype.create = function (route) {
- assert.equal(typeof route, 'string', 'route should be a string');
- // strip leading '/' and split routes
- var routes = route.replace(/^\//, '').split('/');
-
- function createNode(index, trie) {
- var thisRoute = routes.hasOwnProperty(index) && routes[index];
- if (thisRoute === false) return trie;
-
- var node = null;
- if (/^:|^\*/.test(thisRoute)) {
- // if node is a name match, set name and append to ':' node
- if (!trie.nodes.hasOwnProperty('$$')) {
- node = { nodes: {} };
- trie.nodes['$$'] = node;
+ },{"../read/async":143,"nanopage":146,"xtend":131}],142:[function(require,module,exports){
+ module.exports = require('./read/async');
+ },{"./read/async":143}],143:[function(require,module,exports){
+ var parseDatUrl = require('parse-dat-url');
+ var hypha = require('hypha');
+ var xtend = require('xtend');
+ var path = require('path');
+ var xhr = require('xhr');
+
+ var blueprintDefault = require('./blueprint.json');
+ var defaults = require('./defaults');
+
+ module.exports = class Enoki {
+ constructor(props) {
+ this.options = xtend(defaults, props);
+ this.Api = typeof DatArchive !== 'undefined' ? this.options.api || window.DatArchive : this.options.api;
+
+ // props
+ this._loaded = false;
+ this._p2p = typeof this.options !== 'undefined';
+
+ // archives
+ this.archives = {
+ content: {},
+ site: {}
+
+ // state
+ };this.state = {
+ content: {},
+ site: {
+ info: {},
+ config: {},
+ loaded: false,
+ blueprints: {}
+ }
+
+ // public
+ };this.readContent = this.readContent;
+ this.readSite = this.readSite;
+ }
+
+ async load(url) {
+ // load dat or http
+ url = url || window.location.origin;
+ if (this.isDatUrl(url)) await this.loadDat(url);else await this.loadHttp(url);
+ }
+
+ async loadDat(url) {
+ var siteArchive = new this.Api(url);
+ var siteConfig = await this.loadDatConfig(siteArchive);
+ var siteInfo = await this.loadDatInfo(siteArchive);
+ var contentArchive;
+ var contentConfig;
+ var contentUrl;
+
+ // remote or local content
+ if (siteConfig.content && this.isDatUrl(siteConfig.content)) {
+ contentUrl = parseDatUrl(siteConfig.content);
+ contentArchive = new this.Api(contentUrl.origin);
+ contentConfig = await this.loadDatConfig(contentArchive);
+ contentConfig.content = contentConfig.content || contentUrl.pathname;
} else {
- node = trie.nodes['$$'];
+ contentArchive = siteArchive;
+ contentConfig = siteConfig;
}
-
- if (thisRoute[0] === '*') {
- trie.wildcard = true;
+
+ // remote or local config
+ var blueprintsPath = contentConfig.blueprints || this.options.blueprints;
+ var contentFile = contentConfig.file || this.options.file;
+ var contentPath = contentConfig.content || this.options.content;
+
+ // update globals
+ this.state.content = await this.loadDatContent(contentArchive, contentPath, contentFile);
+ this.state.site = await this.loadDatSite(siteArchive, blueprintsPath);
+ this.state.site.config = xtend(this.options, siteConfig);
+ this.state.site.info = siteInfo;
+ this.archives.content = contentArchive;
+ this.archives.site = siteArchive;
+ this._loaded = true;
+ }
+
+ async loadDatSite(archive, blueprintsPath) {
+ var blueprints = await this.loadDatBlueprints(archive, blueprintsPath);
+ return {
+ blueprints: blueprints,
+ loaded: true,
+ p2p: true
+ };
+ }
+
+ async loadDatContent(archive, parent, file) {
+ try {
+ var opts = { fs: archive, parent: parent, source: archive.url, file: file };
+ var files = await archive.readdir(parent, { recursive: true });
+ var glob = files.map(function (file) {
+ return path.join(parent, file);
+ });
+ return hypha.readFiles(glob, parent, opts);
+ } catch (err) {
+ throw new Error('Content directory "' + parent + '" is missing');
}
-
- trie.name = thisRoute.replace(/^:|^\*/, '');
- } else if (!trie.nodes.hasOwnProperty(thisRoute)) {
- node = { nodes: {} };
- trie.nodes[thisRoute] = node;
- } else {
- node = trie.nodes[thisRoute];
- }
-
- // we must recurse deeper
- return createNode(index + 1, node);
- }
-
- return createNode(0, this.trie);
-};
-
-// match a route on the trie
-// and return the node
-// str -> obj
-Trie.prototype.match = function (route) {
- assert.equal(typeof route, 'string', 'route should be a string');
-
- var routes = route.replace(/^\//, '').split('/');
- var params = {};
-
- function search(index, trie) {
- // either there's no match, or we're done searching
- if (trie === undefined) return undefined;
- var thisRoute = routes[index];
- if (thisRoute === undefined) return trie;
-
- if (trie.nodes.hasOwnProperty(thisRoute)) {
- // match regular routes first
- return search(index + 1, trie.nodes[thisRoute]);
- } else if (trie.name) {
- // match named routes
+ }
+
+ async loadDatConfig(archive) {
try {
- params[trie.name] = decodeURIComponent(thisRoute);
- } catch (e) {
- return search(index, undefined);
+ var config = await archive.readFile(this.options.config);
+ return JSON.parse(config);
+ } catch (err) {
+ return {};
}
- return search(index + 1, trie.nodes['$$']);
- } else if (trie.wildcard) {
- // match wildcards
+ }
+
+ async loadDatBlueprints(archive, parent) {
try {
- params['wildcard'] = decodeURIComponent(routes.slice(index).join('/'));
- } catch (e) {
- return search(index, undefined);
+ var files = await archive.readdir(parent);
+ var output = {};
+ await Promise.all(files.map(read));
+ if (!output.default) output.default = blueprintDefault;
+ return output;
+ } catch (err) {
+ return {
+ default: blueprintDefault
+ };
}
- // return early, or else search may keep recursing through the wildcard
- return trie.nodes['$$'];
- } else {
- // no matches found
- return search(index + 1);
- }
- }
-
- var node = search(0, this.trie);
-
- if (!node) return undefined;
- node = xtend(node);
- node.params = params;
- return node;
-};
-
-// mount a trie onto a node at route
-// (str, obj) -> null
-Trie.prototype.mount = function (route, trie) {
- assert.equal(typeof route, 'string', 'route should be a string');
- assert.equal(typeof trie, 'object', 'trie should be a object');
-
- var split = route.replace(/^\//, '').split('/');
- var node = null;
- var key = null;
-
- if (split.length === 1) {
- key = split[0];
- node = this.create(key);
- } else {
- var head = split.join('/');
- key = split[0];
- node = this.create(head);
- }
-
- mutate(node.nodes, trie.nodes);
- if (trie.name) node.name = trie.name;
-
- // delegate properties from '/' to the new node
- // '/' cannot be reached once mounted
- if (node.nodes['']) {
- Object.keys(node.nodes['']).forEach(function (key) {
- if (key === 'nodes') return;
- node[key] = node.nodes[''][key];
- });
- mutate(node.nodes, node.nodes[''].nodes);
- delete node.nodes[''].nodes;
- }
-};
-},{"assert":1,"xtend":127,"xtend/mutable":128}],124:[function(require,module,exports){
-// Returns a wrapper function that returns a wrapped callback
-// The wrapper function should do some stuff, and return a
-// presumably different callback function.
-// This makes sure that own properties are retained, so that
-// decorations and such are not lost along the way.
-module.exports = wrappy;
-function wrappy(fn, cb) {
- if (fn && cb) return wrappy(fn)(cb);
-
- if (typeof fn !== 'function') throw new TypeError('need wrapper function');
-
- Object.keys(fn).forEach(function (k) {
- wrapper[k] = fn[k];
- });
-
- return wrapper;
-
- function wrapper() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- var ret = fn.apply(this, args);
- var cb = args[args.length - 1];
- if (typeof ret === 'function' && ret !== cb) {
- Object.keys(cb).forEach(function (k) {
- ret[k] = cb[k];
- });
- }
- return ret;
- }
-}
-},{}],125:[function(require,module,exports){
-"use strict";
-
-var window = require("global/window");
-var isFunction = require("is-function");
-var parseHeaders = require("parse-headers");
-var xtend = require("xtend");
-
-module.exports = createXHR;
-// Allow use of default import syntax in TypeScript
-module.exports.default = createXHR;
-createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
-createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
-
-forEachArray(["get", "put", "post", "patch", "head", "delete"], function (method) {
- createXHR[method === "delete" ? "del" : method] = function (uri, options, callback) {
- options = initParams(uri, options, callback);
- options.method = method.toUpperCase();
- return _createXHR(options);
- };
-});
-
-function forEachArray(array, iterator) {
- for (var i = 0; i < array.length; i++) {
- iterator(array[i]);
- }
-}
-
-function isEmpty(obj) {
- for (var i in obj) {
- if (obj.hasOwnProperty(i)) return false;
- }
- return true;
-}
-
-function initParams(uri, options, callback) {
- var params = uri;
-
- if (isFunction(options)) {
- callback = options;
- if (typeof uri === "string") {
- params = { uri: uri };
- }
- } else {
- params = xtend(options, { uri: uri });
- }
-
- params.callback = callback;
- return params;
-}
-
-function createXHR(uri, options, callback) {
- options = initParams(uri, options, callback);
- return _createXHR(options);
-}
-
-function _createXHR(options) {
- if (typeof options.callback === "undefined") {
- throw new Error("callback argument missing");
- }
-
- var called = false;
- var callback = function cbOnce(err, response, body) {
- if (!called) {
- called = true;
- options.callback(err, response, body);
- }
- };
-
- function readystatechange() {
- if (xhr.readyState === 4) {
- setTimeout(loadFunc, 0);
+
+ async function read(blueprintPath) {
+ var ext = path.extname(blueprintPath);
+ if (ext === '.json') {
+ var data = await archive.readFile(path.join(parent, blueprintPath));
+ output[path.basename(blueprintPath, ext)] = JSON.parse(data);
+ return data;
}
+ }
}
-
- function getBody() {
- // Chrome with requestType=blob throws errors arround when even testing access to responseText
- var body = undefined;
-
- if (xhr.response) {
- body = xhr.response;
+
+ async loadDatInfo(archive) {
+ try {
+ if (archive.url.indexOf('workspace://') === 0) {
+ return {
+ isOwner: true,
+ url: archive.url
+ };
} else {
- body = xhr.responseText || getXml(xhr);
+ return archive.getInfo();
}
-
- if (isJson) {
+ } catch (err) {
+ return {};
+ }
+ }
+
+ async loadHttp(url) {
+ try {
+ var self = this;
+ return new Promise(function (resolve, reject) {
+ var bust = Math.floor(Date.now() / 1000);
+ xhr(self.options.fallback + '?' + bust, function (err, resp) {
+ self.state.site.loaded = true;
+ self._loaded = true;
+ if (err) reject(err);
try {
- body = JSON.parse(body);
- } catch (e) {}
- }
-
- return body;
- }
-
- function errorFunc(evt) {
- clearTimeout(timeoutTimer);
- if (!(evt instanceof Error)) {
- evt = new Error("" + (evt || "Unknown XMLHttpRequest Error"));
- }
- evt.statusCode = 0;
- return callback(evt, failureResponse);
- }
-
- // will load the data & process the response in a special response object
- function loadFunc() {
- if (aborted) return;
- var status;
- clearTimeout(timeoutTimer);
- if (options.useXDR && xhr.status === undefined) {
- //IE8 CORS GET successful response doesn't have a status field, but body is fine
- status = 200;
- } else {
- status = xhr.status === 1223 ? 204 : xhr.status;
- }
- var response = failureResponse;
- var err = null;
-
- if (status !== 0) {
- response = {
- body: getBody(),
- statusCode: status,
- method: method,
- headers: {},
- url: uri,
- rawRequest: xhr
- };
- if (xhr.getAllResponseHeaders) {
- //remember xhr can in fact be XDR for CORS in IE
- response.headers = parseHeaders(xhr.getAllResponseHeaders());
+ self.state.content = JSON.parse(resp.body);
+ resolve();
+ } catch (err) {
+ reject(err);
}
- } else {
- err = new Error("Internal XMLHttpRequest Error");
- }
- return callback(err, response, response.body);
- }
-
- var xhr = options.xhr || null;
-
- if (!xhr) {
- if (options.cors || options.useXDR) {
- xhr = new createXHR.XDomainRequest();
- } else {
- xhr = new createXHR.XMLHttpRequest();
- }
+ });
+ });
+ } catch (err) {
+ return {};
+ }
}
-
- var key;
- var aborted;
- var uri = xhr.url = options.uri || options.url;
- var method = xhr.method = options.method || "GET";
- var body = options.body || options.data;
- var headers = xhr.headers = options.headers || {};
- var sync = !!options.sync;
- var isJson = false;
- var timeoutTimer;
- var failureResponse = {
- body: undefined,
- headers: {},
- statusCode: 0,
- method: method,
- url: uri,
- rawRequest: xhr
- };
-
- if ("json" in options && options.json !== false) {
- isJson = true;
- headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user
- if (method !== "GET" && method !== "HEAD") {
- headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user
- body = JSON.stringify(options.json === true ? body : options.json);
- }
+
+ getArchives() {
+ return this.archives;
}
-
- xhr.onreadystatechange = readystatechange;
- xhr.onload = loadFunc;
- xhr.onerror = errorFunc;
- // IE9 must have onprogress be set to a unique function.
- xhr.onprogress = function () {
- // IE must die
- };
- xhr.onabort = function () {
- aborted = true;
- };
- xhr.ontimeout = errorFunc;
- xhr.open(method, uri, !sync, options.username, options.password);
- //has to be after open
- if (!sync) {
- xhr.withCredentials = !!options.withCredentials;
- }
- // Cannot set timeout with sync request
- // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
- // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
- if (!sync && options.timeout > 0) {
- timeoutTimer = setTimeout(function () {
- if (aborted) return;
- aborted = true; //IE9 may still call readystatechange
- xhr.abort("timeout");
- var e = new Error("XMLHttpRequest timeout");
- e.code = "ETIMEDOUT";
- errorFunc(e);
- }, options.timeout);
- }
-
- if (xhr.setRequestHeader) {
- for (key in headers) {
- if (headers.hasOwnProperty(key)) {
- xhr.setRequestHeader(key, headers[key]);
- }
- }
- } else if (options.headers && !isEmpty(options.headers)) {
- throw new Error("Headers cannot be set on an XDomainRequest object");
- }
-
- if ("responseType" in options) {
- xhr.responseType = options.responseType;
- }
-
- if ("beforeSend" in options && typeof options.beforeSend === "function") {
- options.beforeSend(xhr);
- }
-
- // Microsoft Edge browser sends "undefined" when send is called with undefined value.
- // XMLHttpRequest spec says to pass null as body to indicate no body
- // See https://github.com/naugtur/xhr/issues/100.
- xhr.send(body || null);
-
- return xhr;
-}
-
-function getXml(xhr) {
- // xhr.responseXML will throw Exception "InvalidStateError" or "DOMException"
- // See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML.
- try {
- if (xhr.responseType === "document") {
- return xhr.responseXML;
- }
- var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror";
- if (xhr.responseType === "" && !firefoxBugTakenEffect) {
- return xhr.responseXML;
- }
- } catch (e) {}
-
- return null;
-}
-
-function noop() {}
-},{"global/window":126,"is-function":40,"parse-headers":97,"xtend":127}],126:[function(require,module,exports){
-arguments[4][21][0].apply(exports,arguments)
-},{"dup":21}],127:[function(require,module,exports){
-module.exports = extend;
-
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-
-function extend() {
- var target = {};
-
- for (var i = 0; i < arguments.length; i++) {
- var source = arguments[i];
-
- for (var key in source) {
- if (hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
+
+ getContentArchive() {
+ return this.archives.content;
}
-
- return target;
-}
-},{}],128:[function(require,module,exports){
-module.exports = extend;
-
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-
-function extend(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
-
- for (var key in source) {
- if (hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
+
+ getSiteArchive() {
+ return this.archives.site;
+ }
+
+ async readContent(props) {
+ if (!this._loaded) await this.load();
+ return this.state.content;
+ }
+
+ async readSite(props) {
+ if (!this._loaded) await this.load();
+ return this.state.site;
+ }
+
+ isDatUrl(url) {
+ return url.indexOf('dat://') === 0 || url.indexOf('workspace://') === 0;
}
-
- return target;
-}
-},{}],129:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral([''], ['']);
-
-function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var html = require('choo/html');
-var md = require('marked');
-
-module.exports = format;
-
-var renderer = new md.Renderer();
-
-renderer.link = function (href, title, text) {
- return '\n ' + text + '\n ';
-};
-
-// Overwrite md renderers
-//
-// renderer.hr = function () {
-// return `
-//
-// `
-// }
-// renderer.blockquote = function (text) {
-// return `
-//
-// `
-// }
-
-function format(str) {
- var output = md(str || '', { renderer: renderer });
- if (typeof window === 'undefined') {
- var wrapper = new String(output);
- wrapper.__encoded = true;
- return wrapper;
- } else {
- var el = html(_templateObject);
- el.innerHTML = output;
- return [].concat(_toConsumableArray(el.childNodes));
- }
-}
-},{"choo/html":133,"marked":71}],130:[function(require,module,exports){
-var css = 0;(null || true) && "_55b334ff";(null || true) && "_30c2a7ef";(null || true) && "_aef1c003";(null || true) && "_72f489aa";
-},{"sheetify/insert":111}],131:[function(require,module,exports){
-// styles
-require('./design');
-
-var choo = require('choo');
-var Enoki = require('enoki');
-
-var app = choo();
-
-console.log('This website is deprecated. Please check out the new version at https://dat-ecosystem.github.io');
-
-var defaults = {
- "blueprints": "/blueprints",
- "config": "site.json",
- "content": "content",
- "fallback": "./bundles/content.json",
- "file": "index.txt"
-};
-app.use(require('enoki/choo')(defaults));
-app.use(require('./plugins/scroll'));
-app.use(async function countStore(state, emitter) {
- var content = await fetch('./bundles/content.json').then(function (x) {
- return x.json();
- });
- state.contact = { twitter: '@dat_project' };
- state.content = content;
- // emitter.on('increment', function (count) {
- // state.count += count
- // emitter.emit('render')
- // })
-});
-app.route('*', require('./views/wrapper'));
-
-// start
-if (!module.parent) app.mount('body');else module.exports = app;
-},{"./design":130,"./plugins/scroll":144,"./views/wrapper":149,"choo":134,"enoki":136,"enoki/choo":135}],132:[function(require,module,exports){
-var assert = require('assert');
-var LRU = require('nanolru');
-
-module.exports = ChooComponentCache;
-
-function ChooComponentCache(state, emit, lru) {
- assert.ok(this instanceof ChooComponentCache, 'ChooComponentCache should be created with `new`');
-
- assert.equal(typeof state, 'object', 'ChooComponentCache: state should be type object');
- assert.equal(typeof emit, 'function', 'ChooComponentCache: emit should be type function');
-
- if (typeof lru === 'number') this.cache = new LRU(lru);else this.cache = lru || new LRU(100);
- this.state = state;
- this.emit = emit;
-}
-
-// Get & create component instances.
-ChooComponentCache.prototype.render = function (Component, id) {
- assert.equal(typeof Component, 'function', 'ChooComponentCache.render: Component should be type function');
- assert.ok(typeof id === 'string' || typeof id === 'number', 'ChooComponentCache.render: id should be type string or type number');
-
- var el = this.cache.get(id);
- if (!el) {
- var args = [];
- for (var i = 2, len = arguments.length; i < len; i++) {
- args.push(arguments[i]);
- }
- args.unshift(Component, id, this.state, this.emit);
- el = newCall.apply(newCall, args);
- this.cache.set(id, el);
- }
-
- return el;
-};
-
-// Because you can't call `new` and `.apply()` at the same time. This is a mad
-// hack, but hey it works so we gonna go for it. Whoop.
-function newCall(Cls) {
- return new (Cls.bind.apply(Cls, arguments))(); // eslint-disable-line
-}
-},{"assert":73,"nanolru":81}],133:[function(require,module,exports){
-module.exports = require('nanohtml');
-},{"nanohtml":78}],134:[function(require,module,exports){
-var scrollToAnchor = require('scroll-to-anchor');
-var documentReady = require('document-ready');
-var nanotiming = require('nanotiming');
-var nanorouter = require('nanorouter');
-var nanomorph = require('nanomorph');
-var nanoquery = require('nanoquery');
-var nanohref = require('nanohref');
-var nanoraf = require('nanoraf');
-var nanobus = require('nanobus');
-var assert = require('assert');
-var xtend = require('xtend');
-
-var Cache = require('./component/cache');
-
-module.exports = Choo;
-
-var HISTORY_OBJECT = {};
-
-function Choo(opts) {
- if (!(this instanceof Choo)) return new Choo(opts);
- opts = opts || {};
-
- assert.equal(typeof opts, 'object', 'choo: opts should be type object');
-
- var self = this;
-
- // define events used by choo
- this._events = {
- DOMCONTENTLOADED: 'DOMContentLoaded',
- DOMTITLECHANGE: 'DOMTitleChange',
- REPLACESTATE: 'replaceState',
- PUSHSTATE: 'pushState',
- NAVIGATE: 'navigate',
- POPSTATE: 'popState',
- RENDER: 'render'
-
- // properties for internal use only
- };this._historyEnabled = opts.history === undefined ? true : opts.history;
- this._hrefEnabled = opts.href === undefined ? true : opts.href;
- this._hashEnabled = opts.hash === undefined ? true : opts.hash;
- this._hasWindow = typeof window !== 'undefined';
- this._cache = opts.cache;
- this._loaded = false;
- this._stores = [];
- this._tree = null;
-
- // state
- var _state = {
- events: this._events,
- components: {}
};
- if (this._hasWindow) {
- this.state = window.initialState ? xtend(window.initialState, _state) : _state;
- delete window.initialState;
- } else {
- this.state = _state;
- }
-
- // properties that are part of the API
- this.router = nanorouter({ curry: true });
- this.emitter = nanobus('choo.emit');
- this.emit = this.emitter.emit.bind(this.emitter);
-
- // listen for title changes; available even when calling .toString()
- if (this._hasWindow) this.state.title = document.title;
- this.emitter.prependListener(this._events.DOMTITLECHANGE, function (title) {
- assert.equal(typeof title, 'string', 'events.DOMTitleChange: title should be type string');
- self.state.title = title;
- if (self._hasWindow) document.title = title;
- });
-}
-
-Choo.prototype.route = function (route, handler) {
- assert.equal(typeof route, 'string', 'choo.route: route should be type string');
- assert.equal(typeof handler, 'function', 'choo.handler: route should be type function');
- this.router.on(route, handler);
-};
-
-Choo.prototype.use = function (cb) {
- assert.equal(typeof cb, 'function', 'choo.use: cb should be type function');
- var self = this;
- this._stores.push(function (state) {
- var msg = 'choo.use';
- msg = cb.storeName ? msg + '(' + cb.storeName + ')' : msg;
- var endTiming = nanotiming(msg);
- cb(state, self.emitter, self);
- endTiming();
- });
-};
-
-Choo.prototype.start = function () {
- assert.equal(typeof window, 'object', 'choo.start: window was not found. .start() must be called in a browser, use .toString() if running in Node');
-
- var self = this;
- if (this._historyEnabled) {
- this.emitter.prependListener(this._events.NAVIGATE, function () {
- self._matchRoute();
- if (self._loaded) {
- self.emitter.emit(self._events.RENDER);
- setTimeout(scrollToAnchor.bind(null, window.location.hash), 0);
+ },{"./blueprint.json":144,"./defaults":145,"hypha":26,"parse-dat-url":100,"path":102,"xhr":130,"xtend":131}],144:[function(require,module,exports){
+ module.exports={
+ "title": "Default",
+ "fields": {
+ "title": {
+ "label": "Title",
+ "type": "text"
+ },
+ "text": {
+ "label": "Text",
+ "type": "textarea"
}
- });
-
- this.emitter.prependListener(this._events.POPSTATE, function () {
- self.emitter.emit(self._events.NAVIGATE);
- });
-
- this.emitter.prependListener(this._events.PUSHSTATE, function (href) {
- assert.equal(typeof href, 'string', 'events.pushState: href should be type string');
- window.history.pushState(HISTORY_OBJECT, null, href);
- self.emitter.emit(self._events.NAVIGATE);
- });
-
- this.emitter.prependListener(this._events.REPLACESTATE, function (href) {
- assert.equal(typeof href, 'string', 'events.replaceState: href should be type string');
- window.history.replaceState(HISTORY_OBJECT, null, href);
- self.emitter.emit(self._events.NAVIGATE);
- });
-
- window.onpopstate = function () {
- self.emitter.emit(self._events.POPSTATE);
- };
-
- if (self._hrefEnabled) {
- nanohref(function (location) {
- var href = location.href;
- var hash = location.hash;
- if (href === window.location.href) {
- if (!this._hashEnabled && hash) scrollToAnchor(hash);
- return;
- }
- self.emitter.emit(self._events.PUSHSTATE, href);
- });
}
}
-
- this._setCache(this.state);
- this._stores.forEach(function (initStore) {
- initStore(self.state);
- });
-
- this._matchRoute();
- this._tree = this._prerender(this.state);
- assert.ok(this._tree, 'choo.start: no valid DOM node returned for location ' + this.state.href);
-
- this.emitter.prependListener(self._events.RENDER, nanoraf(function () {
- var renderTiming = nanotiming('choo.render');
- var newTree = self._prerender(self.state);
- assert.ok(newTree, 'choo.render: no valid DOM node returned for location ' + self.state.href);
-
- assert.equal(self._tree.nodeName, newTree.nodeName, 'choo.render: The target node <' + self._tree.nodeName.toLowerCase() + '> is not the same type as the new node <' + newTree.nodeName.toLowerCase() + '>.');
-
- var morphTiming = nanotiming('choo.morph');
- nanomorph(self._tree, newTree);
- morphTiming();
-
- renderTiming();
- }));
-
- documentReady(function () {
- self.emitter.emit(self._events.DOMCONTENTLOADED);
- self._loaded = true;
- });
-
- return this._tree;
-};
-
-Choo.prototype.mount = function mount(selector) {
- if (typeof window !== 'object') {
- assert.ok(typeof selector === 'string', 'choo.mount: selector should be type String');
- this.selector = selector;
- return this;
+ },{}],145:[function(require,module,exports){
+ module.exports={
+ "blueprints": "/blueprints",
+ "config": "site.json",
+ "content": "content",
+ "fallback": "/bundles/content.json",
+ "file": "index.txt"
+ }
+ },{}],146:[function(require,module,exports){
+ var objectValues = require('object-values');
+ var objectKeys = require('object-keys');
+ var assert = require('assert');
+ var utils = require('./utils');
+
+ module.exports = wrapper;
+
+ class Page {
+ constructor(state, value) {
+ // defaults
+ state = state || {};
+ state.content = state.content || {};
+
+ // fallback route
+ state.href = state.href || '/';
+
+ // private data
+ this._state = state || {};
+ this._value = value || {};
+ }
+
+ url() {
+ try {
+ // file or page
+ if (this._value.extension) return this._value.source || '';else return this._value.url || '';
+ } catch (err) {
+ return '';
+ }
+ }
+
+ keys(key) {
+ var obj = typeof key !== 'undefined' ? this._value[key] : this._value;
+ if (typeof obj === 'object') {
+ return objectKeys(obj) || [];
+ } else {
+ return obj || [];
+ }
+ }
+
+ toArray(key) {
+ return this.values(key);
+ }
+
+ values(key) {
+ var obj = typeof key !== 'undefined' ? this._value[key] : this._value;
+ if (typeof obj === 'object') {
+ return objectValues(obj) || [];
+ } else {
+ return obj || [];
+ }
+ }
+
+ v(key) {
+ return this.value(key);
+ }
+
+ value(key) {
+ try {
+ return typeof key !== 'undefined' ? this._value[key] || undefined : this._value || undefined;
+ } catch (err) {
+ return undefined;
+ }
+ }
}
-
- assert.ok(typeof selector === 'string' || typeof selector === 'object', 'choo.mount: selector should be type String or HTMLElement');
-
- var self = this;
-
- documentReady(function () {
- var renderTiming = nanotiming('choo.render');
- var newTree = self.start();
- if (typeof selector === 'string') {
- self._tree = document.querySelector(selector);
- } else {
- self._tree = selector;
- }
-
- assert.ok(self._tree, 'choo.mount: could not query selector: ' + selector);
- assert.equal(self._tree.nodeName, newTree.nodeName, 'choo.mount: The target node <' + self._tree.nodeName.toLowerCase() + '> is not the same type as the new node <' + newTree.nodeName.toLowerCase() + '>.');
-
- var morphTiming = nanotiming('choo.morph');
- nanomorph(self._tree, newTree);
- morphTiming();
-
- renderTiming();
- });
-};
-
-Choo.prototype.toString = function (location, state) {
- this.state = xtend(this.state, state || {});
-
- assert.notEqual(typeof window, 'object', 'choo.mount: window was found. .toString() must be called in Node, use .start() or .mount() if running in the browser');
- assert.equal(typeof location, 'string', 'choo.toString: location should be type string');
- assert.equal(typeof this.state, 'object', 'choo.toString: state should be type object');
-
- var self = this;
- this._setCache(this.state);
- this._stores.forEach(function (initStore) {
- initStore(self.state);
+
+ // dynamically add tools
+ objectKeys(utils).forEach(function (key) {
+ Page.prototype[key] = function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ this._value = utils[key].apply(utils, [this._state, this._value].concat(args));
+ return this;
+ };
});
-
- this._matchRoute(location);
- var html = this._prerender(this.state);
- assert.ok(html, 'choo.toString: no valid value returned for the route ' + location);
- assert(!Array.isArray(html), 'choo.toString: return value was an array for the route ' + location);
- return typeof html.outerHTML === 'string' ? html.outerHTML : html.toString();
-};
-
-Choo.prototype._matchRoute = function (locationOverride) {
- var location, queryString;
- if (locationOverride) {
- location = locationOverride.replace(/\?.+$/, '').replace(/\/$/, '');
- if (!this._hashEnabled) location = location.replace(/#.+$/, '');
- queryString = locationOverride;
- } else {
- location = window.location.pathname.replace(/\/$/, '');
- if (this._hashEnabled) location += window.location.hash.replace(/^#/, '/');
- queryString = window.location.search;
- }
- var matched = this.router.match(location);
- this._handler = matched.cb;
-
- if (location.startsWith('/dat.land')) location = location.slice(9);
-
- this.state.href = location;
- this.state.query = nanoquery(queryString);
- this.state.route = matched.route;
- this.state.params = matched.params;
- return this.state;
-};
-
-Choo.prototype._prerender = function (state) {
- var routeTiming = nanotiming("choo.prerender('" + state.route + "')");
- var res = this._handler(state, this.emit);
- routeTiming();
- return res;
-};
-
-Choo.prototype._setCache = function (state) {
- var cache = new Cache(state, this.emitter.emit.bind(this.emitter), this._cache);
- state.cache = renderComponent;
-
- function renderComponent(Component, id) {
- assert.equal(typeof Component, 'function', 'choo.state.cache: Component should be type function');
- var args = [];
- for (var i = 0, len = arguments.length; i < len; i++) {
- args.push(arguments[i]);
- }
- return cache.render.apply(cache, args);
- }
-
- // When the state gets stringified, make sure `state.cache` isn't
- // stringified too.
- renderComponent.toJSON = function () {
- return null;
- };
-};
-},{"./component/cache":132,"assert":73,"document-ready":13,"nanobus":74,"nanohref":75,"nanomorph":82,"nanoquery":85,"nanoraf":86,"nanorouter":87,"nanotiming":89,"scroll-to-anchor":109,"xtend":127}],135:[function(require,module,exports){
-module.exports = require('./lib/adapters/choo');
-},{"./lib/adapters/choo":137}],136:[function(require,module,exports){
-module.exports = require('./lib');
-},{"./lib":138}],137:[function(require,module,exports){
-var Enoki = require('../read/async');
-var Page = require('nanopage');
-var xtend = require('xtend');
-
-module.exports = plugin;
-
-function plugin(parent, options) {
- options = options || {};
- return function (state, emitter, app) {
-
- var enoki = new Enoki(parent);
-
- // content state
- state.site = state.site || { loaded: false, p2p: false };
+
+ function wrapper(state) {
+ // defaults
+ state = state || {};
state.content = state.content || {};
-
- // nanopage
- state.page = new Page(state);
-
- // events
- state.events.CONTENT_LOADED = 'content:loaded';
- state.events.CONTENT_LOAD = 'content:load';
-
- // listeners
- emitter.on(state.events.DOMCONTENTLOADED, contentLoad);
- emitter.on(state.events.CONTENT_LOAD, contentLoad);
-
- /**
- * primary method
- */
- async function contentLoad(props) {
- props = props || {};
- // load our site
- await enoki.load(props.url);
- // store our state
- state.content = xtend(state.content, (await enoki.readContent()));
- state.site = xtend(state.site, (await enoki.readSite()));
- // good to go
- emitter.emit(state.events.CONTENT_LOADED);
- // render if we should
- if (options.render !== false) emitter.emit(state.events.RENDER);
+
+ // compose and get on with it
+ return function (value) {
+ return new Page(state, parseValue(value));
+ };
+
+ function parseValue() {
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
+
+ // grab our content
+ var page = state.content[state.href || '/'] || {};
+ // set the value
+ switch (typeof value) {
+ case 'string':
+ // if passing a string assume we want a url
+ var result = utils.find(state, page, value);
+ console.log({ value: value, result: result });
+ return result;
+ case 'object':
+ // if an object and it contains value grab that value
+ if (typeof value.value === 'function') return value.value();else return value;
+ default:
+ // if no value, pass our page
+ return value || page;
+ }
}
+ }
+ },{"./utils":147,"assert":1,"object-keys":95,"object-values":97}],147:[function(require,module,exports){
+ var objectValues = require("object-values");
+ var objectKeys = require("object-keys");
+ var resolver = require("resolve-path");
+ var assert = require("assert");
+ var xtend = require("xtend");
+
+ module.exports = {
+ children: children,
+ file: file,
+ files: files,
+ find: find,
+ first: first,
+ hasView: hasView,
+ images: images,
+ isActive: isActive,
+ last: last,
+ pages: pages,
+ parent: parent,
+ sortBy: sortBy,
+ visible: visible
};
-}
-},{"../read/async":139,"nanopage":142,"xtend":127}],138:[function(require,module,exports){
-module.exports = require('./read/async');
-},{"./read/async":139}],139:[function(require,module,exports){
-var parseDatUrl = require('parse-dat-url');
-var hypha = require('hypha');
-var xtend = require('xtend');
-var path = require('path');
-var xhr = require('xhr');
-
-var blueprintDefault = require('./blueprint.json');
-var defaults = require('./defaults');
-
-module.exports = class Enoki {
- constructor(props) {
- this.options = xtend(defaults, props);
- this.Api = typeof DatArchive !== 'undefined' ? this.options.api || window.DatArchive : this.options.api;
-
- // props
- this._loaded = false;
- this._p2p = typeof this.options !== 'undefined';
-
- // archives
- this.archives = {
- content: {},
- site: {}
-
- // state
- };this.state = {
- content: {},
- site: {
- info: {},
- config: {},
- loaded: false,
- blueprints: {}
- }
-
- // public
- };this.readContent = this.readContent;
- this.readSite = this.readSite;
- }
-
- async load(url) {
- // load dat or http
- url = url || window.location.origin;
- if (this.isDatUrl(url)) await this.loadDat(url);else await this.loadHttp(url);
- }
-
- async loadDat(url) {
- var siteArchive = new this.Api(url);
- var siteConfig = await this.loadDatConfig(siteArchive);
- var siteInfo = await this.loadDatInfo(siteArchive);
- var contentArchive;
- var contentConfig;
- var contentUrl;
-
- // remote or local content
- if (siteConfig.content && this.isDatUrl(siteConfig.content)) {
- contentUrl = parseDatUrl(siteConfig.content);
- contentArchive = new this.Api(contentUrl.origin);
- contentConfig = await this.loadDatConfig(contentArchive);
- contentConfig.content = contentConfig.content || contentUrl.pathname;
- } else {
- contentArchive = siteArchive;
- contentConfig = siteConfig;
- }
-
- // remote or local config
- var blueprintsPath = contentConfig.blueprints || this.options.blueprints;
- var contentFile = contentConfig.file || this.options.file;
- var contentPath = contentConfig.content || this.options.content;
-
- // update globals
- this.state.content = await this.loadDatContent(contentArchive, contentPath, contentFile);
- this.state.site = await this.loadDatSite(siteArchive, blueprintsPath);
- this.state.site.config = xtend(this.options, siteConfig);
- this.state.site.info = siteInfo;
- this.archives.content = contentArchive;
- this.archives.site = siteArchive;
- this._loaded = true;
- }
-
- async loadDatSite(archive, blueprintsPath) {
- var blueprints = await this.loadDatBlueprints(archive, blueprintsPath);
- return {
- blueprints: blueprints,
- loaded: true,
- p2p: true
- };
+
+ function children(state, value) {
+ return pages(state, value);
}
-
- async loadDatContent(archive, parent, file) {
+
+ function file(state, value, key) {
try {
- var opts = { fs: archive, parent: parent, source: archive.url, file: file };
- var files = await archive.readdir(parent, { recursive: true });
- var glob = files.map(function (file) {
- return path.join(parent, file);
- });
- return hypha.readFiles(glob, parent, opts);
+ return value.files[key] || {};
} catch (err) {
- throw new Error('Content directory "' + parent + '" is missing');
+ return {};
}
}
-
- async loadDatConfig(archive) {
+
+ function files(state, value) {
try {
- var config = await archive.readFile(this.options.config);
- return JSON.parse(config);
+ return value.files || {};
} catch (err) {
return {};
}
}
-
- async loadDatBlueprints(archive, parent) {
+
+ function find(state, value, url) {
try {
- var files = await archive.readdir(parent);
- var output = {};
- await Promise.all(files.map(read));
- if (!output.default) output.default = blueprintDefault;
- return output;
- } catch (err) {
- return {
- default: blueprintDefault
- };
- }
-
- async function read(blueprintPath) {
- var ext = path.extname(blueprintPath);
- if (ext === '.json') {
- var data = await archive.readFile(path.join(parent, blueprintPath));
- output[path.basename(blueprintPath, ext)] = JSON.parse(data);
- return data;
+ // grab from root
+ if (url.indexOf('/') === 0) {
+ return state.content[url];
}
- }
- }
-
- async loadDatInfo(archive) {
- try {
- if (archive.url.indexOf('workspace://') === 0) {
- return {
- isOwner: true,
- url: archive.url
- };
- } else {
- return archive.getInfo();
+
+ // if on a page grab relative
+ if (typeof value.url === 'string') {
+ var _key = resolver(value.url, url);
+ return state.content[_key];
}
+
+ // fall back to href
+ var key = resolver(state.href || '/', url);
+ return state.content[key];
} catch (err) {
return {};
}
}
-
- async loadHttp(url) {
+
+ function first(state, value) {
try {
- var self = this;
- return new Promise(function (resolve, reject) {
- var bust = Math.floor(Date.now() / 1000);
- xhr(self.options.fallback + '?' + bust, function (err, resp) {
- self.state.site.loaded = true;
- self._loaded = true;
- if (err) reject(err);
- try {
- self.state.content = JSON.parse(resp.body);
- resolve();
- } catch (err) {
- reject(err);
- }
- });
- });
+ var obj = value || {};
+ return obj[objectKeys(obj)[0]] || {};
} catch (err) {
return {};
}
}
-
- getArchives() {
- return this.archives;
- }
-
- getContentArchive() {
- return this.archives.content;
- }
-
- getSiteArchive() {
- return this.archives.site;
- }
-
- async readContent(props) {
- if (!this._loaded) await this.load();
- return this.state.content;
- }
-
- async readSite(props) {
- if (!this._loaded) await this.load();
- return this.state.site;
- }
-
- isDatUrl(url) {
- return url.indexOf('dat://') === 0 || url.indexOf('workspace://') === 0;
- }
-};
-},{"./blueprint.json":140,"./defaults":141,"hypha":25,"parse-dat-url":96,"path":98,"xhr":125,"xtend":127}],140:[function(require,module,exports){
-module.exports={
- "title": "Default",
- "fields": {
- "title": {
- "label": "Title",
- "type": "text"
- },
- "text": {
- "label": "Text",
- "type": "textarea"
- }
- }
-}
-},{}],141:[function(require,module,exports){
-module.exports={
- "blueprints": "/blueprints",
- "config": "site.json",
- "content": "content",
- "fallback": "/bundles/content.json",
- "file": "index.txt"
-}
-},{}],142:[function(require,module,exports){
-var objectValues = require('object-values');
-var objectKeys = require('object-keys');
-var assert = require('assert');
-var utils = require('./utils');
-
-module.exports = wrapper;
-
-class Page {
- constructor(state, value) {
- // defaults
- state = state || {};
- state.content = state.content || {};
-
- // fallback route
- state.href = state.href || '/';
-
- // private data
- this._state = state || {};
- this._value = value || {};
- }
-
- url() {
+
+ function hasView(state, value) {
try {
- // file or page
- if (this._value.extension) return this._value.source || '';else return this._value.url || '';
+ return typeof this._value.view !== 'undefined';
} catch (err) {
- return '';
- }
- }
-
- keys(key) {
- var obj = typeof key !== 'undefined' ? this._value[key] : this._value;
- if (typeof obj === 'object') {
- return objectKeys(obj) || [];
- } else {
- return obj || [];
+ return false;
}
}
-
- toArray(key) {
- return this.values(key);
- }
-
- values(key) {
- var obj = typeof key !== 'undefined' ? this._value[key] : this._value;
- if (typeof obj === 'object') {
- return objectValues(obj) || [];
- } else {
- return obj || [];
+
+ function images(state, value) {
+ try {
+ return objectKeys(value.files || {}).reduce(function (res, cur) {
+ if (typeof value.files[cur] === 'object' && value.files[cur].type === 'image') {
+ res[cur] = value.files[cur];
+ }
+ return res;
+ }, {});
+ } catch (err) {
+ return {};
}
}
-
- v(key) {
- return this.value(key);
- }
-
- value(key) {
+
+ function isActive(state, value) {
try {
- return typeof key !== 'undefined' ? this._value[key] || undefined : this._value || undefined;
+ return state.href || '/' === value.url;
} catch (err) {
- return undefined;
+ return false;
}
}
-}
-
-// dynamically add tools
-objectKeys(utils).forEach(function (key) {
- Page.prototype[key] = function () {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
+
+ function isFirst(state, value) {
+ try {
+ var _parent = parent(state, value);
+ if (value.extension) {
+ return objectKeys(_parent.files).indexOf(value.filename) === 0;
+ } else {
+ return objectKeys(_parent.pages).indexOf(value.name) === 0;
+ }
+ } catch (err) {
+ return false;
}
-
- this._value = utils[key].apply(utils, [this._state, this._value].concat(args));
- return this;
- };
-});
-
-function wrapper(state) {
- // defaults
- state = state || {};
- state.content = state.content || {};
-
- // compose and get on with it
- return function (value) {
- return new Page(state, parseValue(value));
- };
-
- function parseValue() {
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
-
- // grab our content
- var page = state.content[state.href || '/'] || {};
- // set the value
- switch (typeof value) {
- case 'string':
- // if passing a string assume we want a url
- var result = utils.find(state, page, value);
- console.log({ value: value, result: result });
- return result;
- case 'object':
- // if an object and it contains value grab that value
- if (typeof value.value === 'function') return value.value();else return value;
- default:
- // if no value, pass our page
- return value || page;
- }
- }
-}
-},{"./utils":143,"assert":1,"object-keys":91,"object-values":93}],143:[function(require,module,exports){
-var objectValues = require("object-values");
-var objectKeys = require("object-keys");
-var resolver = require("resolve-path");
-var assert = require("assert");
-var xtend = require("xtend");
-
-module.exports = {
- children: children,
- file: file,
- files: files,
- find: find,
- first: first,
- hasView: hasView,
- images: images,
- isActive: isActive,
- last: last,
- pages: pages,
- parent: parent,
- sortBy: sortBy,
- visible: visible
-};
-
-function children(state, value) {
- return pages(state, value);
-}
-
-function file(state, value, key) {
- try {
- return value.files[key] || {};
- } catch (err) {
- return {};
- }
-}
-
-function files(state, value) {
- try {
- return value.files || {};
- } catch (err) {
- return {};
- }
-}
-
-function find(state, value, url) {
- try {
- // grab from root
- if (url.indexOf('/') === 0) {
- return state.content[url];
- }
-
- // if on a page grab relative
- if (typeof value.url === 'string') {
- var _key = resolver(value.url, url);
- return state.content[_key];
- }
-
- // fall back to href
- var key = resolver(state.href || '/', url);
- return state.content[key];
- } catch (err) {
- return {};
- }
-}
-
-function first(state, value) {
- try {
- var obj = value || {};
- return obj[objectKeys(obj)[0]] || {};
- } catch (err) {
- return {};
- }
-}
-
-function hasView(state, value) {
- try {
- return typeof this._value.view !== 'undefined';
- } catch (err) {
- return false;
}
-}
-
-function images(state, value) {
- try {
- return objectKeys(value.files || {}).reduce(function (res, cur) {
- if (typeof value.files[cur] === 'object' && value.files[cur].type === 'image') {
- res[cur] = value.files[cur];
+
+ function isLast(state, value) {
+ try {
+ var _parent = parent(state, value);
+ if (value.extension) {
+ var keys = objectKeys(_parent.files);
+ return keys.indexOf(value.filename) === keys.length - 1;
+ } else {
+ var keys = objectKeys(_parent.pages);
+ return keys.indexOf(value.name) === keys.length - 1;
}
- return res;
- }, {});
- } catch (err) {
- return {};
- }
-}
-
-function isActive(state, value) {
- try {
- return state.href || '/' === value.url;
- } catch (err) {
- return false;
- }
-}
-
-function isFirst(state, value) {
- try {
- var _parent = parent(state, value);
- if (value.extension) {
- return objectKeys(_parent.files).indexOf(value.filename) === 0;
- } else {
- return objectKeys(_parent.pages).indexOf(value.name) === 0;
+ } catch (err) {
+ return false;
}
- } catch (err) {
- return false;
}
-}
-
-function isLast(state, value) {
- try {
- var _parent = parent(state, value);
- if (value.extension) {
- var keys = objectKeys(_parent.files);
- return keys.indexOf(value.filename) === keys.length - 1;
- } else {
- var keys = objectKeys(_parent.pages);
- return keys.indexOf(value.name) === keys.length - 1;
+
+ function last(state, value) {
+ try {
+ var obj = value || {};
+ var keys = objectKeys(obj);
+ return obj[keys[keys.length - 1]] || {};
+ } catch (err) {
+ return {};
}
- } catch (err) {
- return false;
- }
-}
-
-function last(state, value) {
- try {
- var obj = value || {};
- var keys = objectKeys(obj);
- return obj[keys[keys.length - 1]] || {};
- } catch (err) {
- return {};
- }
-}
-
-function pages(state, value) {
- try {
- var base = !!value.url.replace(/^\//, '') ? value.url : '';
- var regex = new RegExp('^' + base + '\/[^\/]+\/?$');
- return objectKeys(state.content).filter(function (key) {
- return regex.test(key.trim());
- }).reduce(readPage, {});
- } catch (err) {
- return {};
}
-
- function readPage(result, key) {
- var page = state.content[key];
- if (page) result[key] = page;
- return result;
+
+ function pages(state, value) {
+ try {
+ var base = !!value.url.replace(/^\//, '') ? value.url : '';
+ var regex = new RegExp('^' + base + '\/[^\/]+\/?$');
+ return objectKeys(state.content).filter(function (key) {
+ return regex.test(key.trim());
+ }).reduce(readPage, {});
+ } catch (err) {
+ return {};
+ }
+
+ function readPage(result, key) {
+ var page = state.content[key];
+ if (page) result[key] = page;
+ return result;
+ }
}
-}
-
-function parent(state, value) {
- try {
- var url = resolve(value.url, '../');
- return state.content[url] || {};
- } catch (err) {
- return state.content['/'] || {};
+
+ function parent(state, value) {
+ try {
+ var url = resolve(value.url, '../');
+ return state.content[url] || {};
+ } catch (err) {
+ return state.content['/'] || {};
+ }
}
-}
-
-function sortBy(state, value, key, order) {
- try {
- return objectValues(value).sort(sort);
- } catch (err) {
- return [];
+
+ function sortBy(state, value, key, order) {
+ try {
+ return objectValues(value).sort(sort);
+ } catch (err) {
+ return [];
+ }
+
+ function sort(a, b) {
+ try {
+ var alpha = a[key];
+ var beta = b[key];
+
+ // reverse order
+ if (order === 'desc') {
+ alpha = b[key];
+ beta = a[key];
+ }
+
+ // date or string
+ if (isDate(alpha) && isDate(beta)) {
+ return new Date(alpha) - new Date(beta);
+ } else {
+ return alpha.localeCompare(beta);
+ }
+ } catch (err) {
+ return 0;
+ }
+ }
}
-
- function sort(a, b) {
+
+ function visible(state, value) {
try {
- var alpha = a[key];
- var beta = b[key];
-
- // reverse order
- if (order === 'desc') {
- alpha = b[key];
- beta = a[key];
- }
-
- // date or string
- if (isDate(alpha) && isDate(beta)) {
- return new Date(alpha) - new Date(beta);
+ if (isPage(value)) {
+ return value.visible !== false;
} else {
- return alpha.localeCompare(beta);
+ return objectValues(value).filter(function (obj) {
+ return obj.visible !== false;
+ });
}
} catch (err) {
- return 0;
+ return false;
}
}
-}
-
-function visible(state, value) {
- try {
- if (isPage(value)) {
- return value.visible !== false;
- } else {
- return objectValues(value).filter(function (obj) {
- return obj.visible !== false;
- });
- }
- } catch (err) {
- return false;
+
+ function isPage(value) {
+ return typeof value === 'object' && typeof value.url === 'string' && !value.extension;
}
-}
-
-function isPage(value) {
- return typeof value === 'object' && typeof value.url === 'string' && !value.extension;
-}
-
-function isDate(str) {
- return (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(str)
- );
-}
-},{"assert":1,"object-keys":91,"object-values":93,"resolve-path":108,"xtend":127}],144:[function(require,module,exports){
-module.exports = scroll;
-
-function scroll(state, emitter) {
- emitter.on(state.events.NAVIGATE, function () {
- window.scrollTo(0, 0);
- });
-}
-},{}],145:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral(['\n \n '], ['\n \n ']);
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var html = require('choo/html');
-var format = require('../components/format');
-
-module.exports = page;
-
-function page(state, emit) {
- return html(_templateObject);
-}
-
-//
-//
-//
-//
-// ${state.page().v('title')}
-//
-// ${state.page.subtitle}
-//
-// ${format(state.page().v('intro'))}
-//
-//
-//
-// ${text()}
-//
-//
-},{"../components/format":129,"choo/html":133}],146:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral(['\n \n \n \n
\n
\n ', '\n
\n
\n ', '\n
\n
\n ', '\n
\n \n \n '], ['\n \n \n \n
\n
\n ', '\n
\n
\n ', '\n
\n
\n ', '\n
\n \n \n ']),
- _templateObject2 = _taggedTemplateLiteral(['\n ', '\n '], ['\n ', '\n ']),
- _templateObject3 = _taggedTemplateLiteral(['\n \n ', '\n \n
\n
\n ', '\n
\n
\n by ', '\n
\n
\n \n '], ['\n \n ', '\n \n
\n
\n ', '\n
\n
\n by ', '\n
\n
\n \n ']),
- _templateObject4 = _taggedTemplateLiteral([''], ['']),
- _templateObject5 = _taggedTemplateLiteral(['\n \n '], ['\n \n ']);
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var html = require('choo/html');
-var ov = require('object-values');
-var format = require('../components/format');
-
-module.exports = page;
-
-function page(state, emit) {
- var links = state.page('/').v('links') || [];
- return html(_templateObject, format(state.page().v('intro')), ov(links).map(function (props) {
- return html(_templateObject2, props.link, props.title, props.title);
- }), ov(state.page().v('nav-links')).map(featuredBox));
-}
-
-function featuredBox(props) {
- if (props.text) return textBox();
-
- return html(_templateObject3, props.link, props.image ? img(props.image) : '', props.title, props.description, props.author);
-
- function img(url) {
- return html(_templateObject4, url);
- }
-}
-
-function textBox() {
- return html(_templateObject5);
-}
-
-//
-//
-//
-//
-// ${state.page().v('title')}
-//
-// ${state.page.subtitle}
-//
-// ${format(state.page().v('intro'))}
-//
-//
-//
-// ${text()}
-//
-//
-},{"../components/format":129,"choo/html":133,"object-values":93}],147:[function(require,module,exports){
-module.exports = {
- default: require('./default'),
- home: require('./home'),
- list: require('./list')
-};
-},{"./default":145,"./home":146,"./list":148}],148:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral(['\n \n '], ['\n \n ']),
- _templateObject2 = _taggedTemplateLiteral(['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n '], ['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n ']),
- _templateObject3 = _taggedTemplateLiteral(['\n \n TAGS: ', '\n
\n '], ['\n \n TAGS: ', '\n
\n ']);
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var html = require('choo/html');
-var ov = require('object-values');
-var format = require('../components/format');
-
-module.exports = page;
-
-function page(state, emit) {
- return html(_templateObject, format(state.page().v('text')), ov(state.page().v('list')).map(box));
-}
-
-function box(props) {
- return html(_templateObject2, props.link, props.title, props.description, tags(props.tags));
-
- function tags(tags) {
- if (!tags) return '';
- return html(_templateObject3, props.tags);
- }
-}
-},{"../components/format":129,"choo/html":133,"object-values":93}],149:[function(require,module,exports){
-var _templateObject = _taggedTemplateLiteral(['\n \n \n \n ', '\n \n ', '\n
\n \n ', '\n \n '], ['\n \n \n \n ', '\n \n ', '\n
\n \n ', '\n \n ']),
- _templateObject2 = _taggedTemplateLiteral(['\n \n \n ', '\n \n
\n \n ', '\n \n '], ['\n \n \n ', '\n \n
\n \n ', '\n \n ']),
- _templateObject3 = _taggedTemplateLiteral(['\n \n \n ', '\n \n \n
Page not found
\n
\n \n \n \n '], ['\n \n \n ', '\n \n \n
Page not found
\n \n \n \n \n ']),
- _templateObject4 = _taggedTemplateLiteral(['\n \n Built on Enoki\n \n \n '], ['\n \n ']),
- _templateObject5 = _taggedTemplateLiteral(['\n ', '\n '], ['\n ', '\n ']);
-
-function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
-
-var html = require('choo/html');
-var css = 0;
-var ov = require('object-values');
-var datIcons = require('dat-icons');
-
-var views = require('./');
-
-module.exports = view;
-
-function view(state, emit) {
- var page = state.page;
- // loading
- if (!state.site.loaded) return renderLoading(state, emit);
- // 404
- if (!page().v('url')) return renderNotFound(state, emit);
- // view
- var view = views[page().v('view')] || views.default;
-
- // title
- var title = getTitle(state);
- if (state.title !== title) emit(state.events.DOMTITLECHANGE, title);
-
- // template
- return html(_templateObject, renderNavigation(state, emit), view(state, emit), datIcons());
-}
-
-function renderLoading(state, emit) {
- return html(_templateObject2, renderNavigation(state, emit), datIcons());
-}
-
-function renderNotFound(state, emit) {
- return html(_templateObject3, renderNavigation(state, emit));
-}
-
-function renderNavigation(state, emit) {
- var logoCss = (null || true) && "_b35f0286";
- var links = state.page('/').v('nav-links') || [];
- return html(_templateObject4, logoCss, state.page('/').v('tagline'), ov(links).map(function (props) {
- return html(_templateObject5, props.link, props.title, props.title);
- }), state.page('./contact').v('twitter'));
- // function editLink () {
- // const ghPath = state.page().v('path')
- // const href = `http://github.com/dat-ecosystem/dat-land/blob/master${ghPath}/index.txt`
-
- // return html`
- //
- //
- //
- // Edit Page
- //
- //
- // `
- // }
-}
-
-function getTitle(state) {
- var siteTitle = state.page('/').v('title');
- var pageTitle = state.page().v('title');
- console.log('title', siteTitle, pageTitle);
-
- return siteTitle !== pageTitle ? siteTitle + ' | ' + pageTitle : siteTitle;
-}
-},{"./":147,"choo/html":133,"dat-icons":11,"object-values":93,"sheetify/insert":111}]},{},[131]);
+
+ function isDate(str) {
+ return (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(str)
+ );
+ }
+ },{"assert":1,"object-keys":95,"object-values":97,"resolve-path":112,"xtend":131}],148:[function(require,module,exports){
+ module.exports = scroll;
+
+ function scroll(state, emitter) {
+ emitter.on(state.events.NAVIGATE, function () {
+ window.scrollTo(0, 0);
+ });
+ }
+ },{}],149:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral(['\n \n '], ['\n \n ']);
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var html = require('choo/html');
+ var format = require('../components/format');
+
+ module.exports = page;
+
+ function page(state, emit) {
+ return html(_templateObject);
+ }
+
+ //
+ //
+ //
+ //
+ // ${state.page().v('title')}
+ //
+ // ${state.page.subtitle}
+ //
+ // ${format(state.page().v('intro'))}
+ //
+ //
+ //
+ // ${text()}
+ //
+ //
+ },{"../components/format":133,"choo/html":137}],150:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral(['\n \n \n \n
\n
\n ', '\n
\n
\n ', '\n
\n
\n ', '\n
\n \n \n '], ['\n \n \n \n
\n
\n ', '\n
\n
\n ', '\n
\n
\n ', '\n
\n \n \n ']),
+ _templateObject2 = _taggedTemplateLiteral(['\n ', '\n '], ['\n ', '\n ']),
+ _templateObject3 = _taggedTemplateLiteral(['\n \n ', '\n \n
\n
\n ', '\n
\n
\n by ', '\n
\n
\n \n '], ['\n \n ', '\n \n
\n
\n ', '\n
\n
\n by ', '\n
\n
\n \n ']),
+ _templateObject4 = _taggedTemplateLiteral([''], ['']),
+ _templateObject5 = _taggedTemplateLiteral(['\n \n '], ['\n \n ']);
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var html = require('choo/html');
+ var ov = require('object-values');
+ var format = require('../components/format');
+
+ module.exports = page;
+
+ function page(state, emit) {
+ var links = state.page('/').v('links') || [];
+ return html(_templateObject, format(state.page().v('intro')), ov(links).map(function (props) {
+ return html(_templateObject2, props.link, props.title, props.title);
+ }), ov(state.page().v('nav-links')).map(featuredBox));
+ }
+
+ function featuredBox(props) {
+ if (props.text) return textBox();
+
+ return html(_templateObject3, props.link, props.image ? img(props.image) : '', props.title, props.description, props.author);
+
+ function img(url) {
+ return html(_templateObject4, url);
+ }
+ }
+
+ function textBox() {
+ return html(_templateObject5);
+ }
+
+ //
+ //
+ //
+ //
+ // ${state.page().v('title')}
+ //
+ // ${state.page.subtitle}
+ //
+ // ${format(state.page().v('intro'))}
+ //
+ //
+ //
+ // ${text()}
+ //
+ //
+ },{"../components/format":133,"choo/html":137,"object-values":97}],151:[function(require,module,exports){
+ module.exports = {
+ default: require('./default'),
+ home: require('./home'),
+ list: require('./list')
+ };
+ },{"./default":149,"./home":150,"./list":152}],152:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral(['\n \n '], ['\n \n ']),
+ _templateObject2 = _taggedTemplateLiteral(['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n '], ['\n \n \n
\n
\n ', '\n
\n ', '\n
\n \n ']),
+ _templateObject3 = _taggedTemplateLiteral(['\n \n TAGS: ', '\n
\n '], ['\n \n TAGS: ', '\n
\n ']);
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var html = require('choo/html');
+ var ov = require('object-values');
+ var format = require('../components/format');
+
+ module.exports = page;
+
+ function page(state, emit) {
+ return html(_templateObject, format(state.page().v('text')), ov(state.page().v('list')).map(box));
+ }
+
+ function box(props) {
+ return html(_templateObject2, props.link, props.title, props.description, tags(props.tags));
+
+ function tags(tags) {
+ if (!tags) return '';
+ return html(_templateObject3, props.tags);
+ }
+ }
+ },{"../components/format":133,"choo/html":137,"object-values":97}],153:[function(require,module,exports){
+ var _templateObject = _taggedTemplateLiteral(['\n \n \n \n ', '\n \n ', '\n
\n \n ', '\n \n '], ['\n \n \n \n ', '\n \n ', '\n
\n \n ', '\n \n ']),
+ _templateObject2 = _taggedTemplateLiteral(['\n \n \n ', '\n \n
\n \n ', '\n \n '], ['\n \n \n ', '\n \n
\n \n ', '\n \n ']),
+ _templateObject3 = _taggedTemplateLiteral(['\n \n \n ', '\n \n \n
Page not found
\n \n \n \n \n '], ['\n \n \n ', '\n \n \n
Page not found
\n \n \n \n \n ']),
+ _templateObject4 = _taggedTemplateLiteral(['\n \n '], ['\n \n ']),
+ _templateObject5 = _taggedTemplateLiteral(['\n ', '\n '], ['\n ', '\n ']);
+
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
+
+ var html = require('choo/html');
+ var css = 0;
+ var ov = require('object-values');
+ var datIcons = require('dat-icons');
+
+ var views = require('./');
+
+ module.exports = view;
+
+ function view(state, emit) {
+ var page = state.page;
+ // loading
+ if (!state.site.loaded) return renderLoading(state, emit);
+ // 404
+ if (!page().v('url')) return renderNotFound(state, emit);
+ // view
+ var view = views[page().v('view')] || views.default;
+
+ // title
+ var title = getTitle(state);
+ if (state.title !== title) emit(state.events.DOMTITLECHANGE, title);
+
+ // template
+ return html(_templateObject, renderNavigation(state, emit), view(state, emit), datIcons());
+ }
+
+ function renderLoading(state, emit) {
+ return html(_templateObject2, renderNavigation(state, emit), datIcons());
+ }
+
+ function renderNotFound(state, emit) {
+ return html(_templateObject3, renderNavigation(state, emit));
+ }
+
+ function renderNavigation(state, emit) {
+ var logoCss = (null || true) && "_b35f0286";
+ var links = state.page('/').v('nav-links') || [];
+ return html(_templateObject4, logoCss, state.page('/').v('tagline'), ov(links).map(function (props) {
+ return html(_templateObject5, props.link, props.title, props.title);
+ }), state.page('./contact').v('twitter'));
+ // function editLink () {
+ // const ghPath = state.page().v('path')
+ // const href = `http://github.com/dat-ecosystem/dat-land/blob/master${ghPath}/index.txt`
+
+ // return html`
+ //
+ //
+ //
+ // Edit Page
+ //
+ //
+ // `
+ // }
+ }
+
+ function getTitle(state) {
+ var siteTitle = state.page('/').v('title');
+ var pageTitle = state.page().v('title');
+ console.log('title', siteTitle, pageTitle);
+
+ return siteTitle !== pageTitle ? siteTitle + ' | ' + pageTitle : siteTitle;
+ }
+ },{"./":151,"choo/html":137,"dat-icons":11,"object-values":97,"sheetify/insert":115}]},{},[135]);
+
\ No newline at end of file