Izmjenjena struktura, dodan backand

This commit is contained in:
GotPPay
2017-10-16 11:19:46 +02:00
parent 1ec88afacb
commit 048e32c4aa
37153 changed files with 2975854 additions and 1 deletions

View File

@@ -0,0 +1,55 @@
'use strict';
const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const SPACE = ' ';class ArrayContaining extends Array {}class ObjectContaining extends Object {}const print = (val, print,
indent,
opts,
colors) =>
{
const stringedValue = val.toString();
if (stringedValue === 'ArrayContaining') {
const array = ArrayContaining.from(val.sample);
return opts.spacing === SPACE ?
stringedValue + SPACE + print(array) :
print(array);
}
if (stringedValue === 'ObjectContaining') {
const object = Object.assign(new ObjectContaining(), val.sample);
return opts.spacing === SPACE ?
stringedValue + SPACE + print(object) :
print(object);
}
if (stringedValue === 'StringMatching') {
return stringedValue + SPACE + print(val.sample);
}
if (stringedValue === 'StringContaining') {
return stringedValue + SPACE + print(val.sample);
}
return val.toAsymmetricMatcher();
};
const test = object => object && object.$$typeof === asymmetricMatcher;
module.exports = { print, test };

View File

@@ -0,0 +1,49 @@
'use strict';
const ansiRegex = require('ansi-regex'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const toHumanReadableAnsi = text => {const style = require('ansi-styles');return text.replace(ansiRegex(), (match, offset, string) => {switch (match) {case style.red.close:case style.green.close:case style.reset.open:
case style.reset.close:
return '</>';
case style.red.open:
return '<red>';
case style.green.open:
return '<green>';
case style.dim.open:
return '<dim>';
case style.bold.open:
return '<bold>';
default:
return '';}
});
};
const test = value =>
typeof value === 'string' && value.match(ansiRegex());
const print = (
val,
print,
indent,
opts,
colors) =>
print(toHumanReadableAnsi(val));
module.exports = { print, test };

View File

@@ -0,0 +1,143 @@
'use strict';
const escapeHTML = require('./lib/escapeHTML'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
const HTML_ELEMENT_REGEXP = /(HTML\w*?Element)|Text|Comment/;
const test = isHTMLElement;
function isHTMLElement(value) {
return (
value !== undefined &&
value !== null && (
value.nodeType === 1 || value.nodeType === 3 || value.nodeType === 8) &&
value.constructor !== undefined &&
value.constructor.name !== undefined &&
HTML_ELEMENT_REGEXP.test(value.constructor.name));
}
function printChildren(flatChildren, print, indent, colors, opts) {
return flatChildren.
map(node => {
if (typeof node === 'object') {
return print(node, print, indent, colors, opts);
} else if (typeof node === 'string') {
return colors.content.open + escapeHTML(node) + colors.content.close;
} else {
return print(node);
}
}).
filter(value => value.trim().length).
join(opts.edgeSpacing);
}
function printAttributes(attributes, indent, colors, opts) {
return attributes.
sort().
map(attribute => {
return (
opts.spacing +
indent(colors.prop.open + attribute.name + colors.prop.close + '=') +
colors.value.open +
`"${attribute.value}"` +
colors.value.close);
}).
join('');
}
const print = (
element,
print,
indent,
opts,
colors) =>
{
if (element.nodeType === 3) {
return element.data.
split('\n').
map(text => text.trimLeft()).
filter(text => text.length).
join(' ');
} else if (element.nodeType === 8) {
return (
colors.comment.open +
'<!-- ' +
element.data.trim() +
' -->' +
colors.comment.close);
}
let result = colors.tag.open + '<';
const elementName = element.tagName.toLowerCase();
result += elementName + colors.tag.close;
const hasAttributes = element.attributes && element.attributes.length;
if (hasAttributes) {
const attributes = Array.prototype.slice.call(element.attributes);
result += printAttributes(attributes, indent, colors, opts);
}
const flatChildren = Array.prototype.slice.call(element.childNodes);
if (!flatChildren.length && element.textContent) {
flatChildren.push(element.textContent);
}
const closeInNewLine = hasAttributes && !opts.min;
if (flatChildren.length) {
const children = printChildren(flatChildren, print, indent, colors, opts);
result +=
colors.tag.open + (
closeInNewLine ? '\n' : '') +
'>' +
colors.tag.close +
opts.edgeSpacing +
indent(children) +
opts.edgeSpacing +
colors.tag.open +
'</' +
elementName +
'>' +
colors.tag.close;
} else {
result +=
colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
}
return result;
};
module.exports = { print, test };

View File

@@ -0,0 +1,26 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_LIST = '@@__IMMUTABLE_LIST__@@';const test = maybeList => !!(maybeList && maybeList[IS_LIST]);const print = (val, print, indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'List', false);
module.exports = { print, test };

View File

@@ -0,0 +1,28 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeMap => !!(maybeMap && maybeMap[IS_MAP] && !maybeMap[IS_ORDERED]);const print = (val,
print,
indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'Map', true);
module.exports = { print, test };

View File

@@ -0,0 +1,28 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_MAP = '@@__IMMUTABLE_MAP__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeOrderedMap => maybeOrderedMap && maybeOrderedMap[IS_MAP] && maybeOrderedMap[IS_ORDERED];const print = (val,
print,
indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'OrderedMap', true);
module.exports = { print, test };

View File

@@ -0,0 +1,28 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeOrderedSet => maybeOrderedSet && maybeOrderedSet[IS_SET] && maybeOrderedSet[IS_ORDERED];const print = (val,
print,
indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'OrderedSet', false);
module.exports = { print, test };

View File

@@ -0,0 +1,17 @@
'use strict'; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
module.exports = [
require('./ImmutableList'),
require('./ImmutableSet'),
require('./ImmutableMap'),
require('./ImmutableStack'),
require('./ImmutableOrderedSet'),
require('./ImmutableOrderedMap')];

View File

@@ -0,0 +1,28 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_SET = '@@__IMMUTABLE_SET__@@';const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@';const test = maybeSet => !!(maybeSet && maybeSet[IS_SET] && !maybeSet[IS_ORDERED]);const print = (val,
print,
indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'Set', false);
module.exports = { print, test };

View File

@@ -0,0 +1,26 @@
'use strict';
const printImmutable = require('./lib/printImmutable'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const IS_STACK = '@@__IMMUTABLE_STACK__@@';const test = maybeStack => !!(maybeStack && maybeStack[IS_STACK]);const print = (val, print, indent,
opts,
colors) =>
printImmutable(val, print, indent, opts, colors, 'Stack', false);
module.exports = { print, test };

View File

@@ -0,0 +1,126 @@
'use strict';
const escapeHTML = require('./lib/escapeHTML'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const reactElement = Symbol.for('react.element');function traverseChildren(opaqueChildren, cb) {if (Array.isArray(opaqueChildren)) {opaqueChildren.forEach(child => traverseChildren(child, cb));} else if (opaqueChildren != null && opaqueChildren !== false) {cb(opaqueChildren);
}
}
function printChildren(flatChildren, print, indent, colors, opts) {
return flatChildren.
map(node => {
if (typeof node === 'object') {
return print(node, print, indent, colors, opts);
} else if (typeof node === 'string') {
return colors.content.open + escapeHTML(node) + colors.content.close;
} else {
return print(node);
}
}).
join(opts.edgeSpacing);
}
function printProps(props, print, indent, colors, opts) {
return Object.keys(props).
sort().
map(name => {
if (name === 'children') {
return '';
}
const prop = props[name];
let printed = print(prop);
if (typeof prop !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed =
'{' +
opts.edgeSpacing +
indent(indent(printed) + opts.edgeSpacing + '}');
} else {
printed = '{' + printed + '}';
}
}
return (
opts.spacing +
indent(colors.prop.open + name + colors.prop.close + '=') +
colors.value.open +
printed +
colors.value.close);
}).
join('');
}
const print = (
element,
print,
indent,
opts,
colors) =>
{
let result = colors.tag.open + '<';
let elementName;
if (typeof element.type === 'string') {
elementName = element.type;
} else if (typeof element.type === 'function') {
elementName = element.type.displayName || element.type.name || 'Unknown';
} else {
elementName = 'Unknown';
}
result += elementName + colors.tag.close;
result += printProps(element.props, print, indent, colors, opts);
const opaqueChildren = element.props.children;
const hasProps = !!Object.keys(element.props).filter(
propName => propName !== 'children').
length;
const closeInNewLine = hasProps && !opts.min;
if (opaqueChildren) {
const flatChildren = [];
traverseChildren(opaqueChildren, child => {
flatChildren.push(child);
});
const children = printChildren(flatChildren, print, indent, colors, opts);
result +=
colors.tag.open + (
closeInNewLine ? '\n' : '') +
'>' +
colors.tag.close +
opts.edgeSpacing +
indent(children) +
opts.edgeSpacing +
colors.tag.open +
'</' +
elementName +
'>' +
colors.tag.close;
} else {
result +=
colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
}
return result;
};
const test = object => object && object.$$typeof === reactElement;
module.exports = { print, test };

View File

@@ -0,0 +1,121 @@
'use strict';
const escapeHTML = require('./lib/escapeHTML'); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const reactTestInstance = Symbol.for('react.test.json');function printChildren(children, print, indent, colors,
opts)
{
return children.
map(child => printInstance(child, print, indent, colors, opts)).
join(opts.edgeSpacing);
}
function printProps(props, print, indent, colors, opts) {
return Object.keys(props).
sort().
map(name => {
const prop = props[name];
let printed = print(prop);
if (typeof prop !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed =
'{' +
opts.edgeSpacing +
indent(indent(printed) + opts.edgeSpacing + '}');
} else {
printed = '{' + printed + '}';
}
}
return (
opts.spacing +
indent(colors.prop.open + name + colors.prop.close + '=') +
colors.value.open +
printed +
colors.value.close);
}).
join('');
}
function printInstance(instance, print, indent, colors, opts) {
if (typeof instance == 'number') {
return print(instance);
} else if (typeof instance === 'string') {
return colors.content.open + escapeHTML(instance) + colors.content.close;
}
let closeInNewLine = false;
let result = colors.tag.open + '<' + instance.type + colors.tag.close;
if (instance.props) {
closeInNewLine = !!Object.keys(instance.props).length && !opts.min;
result += printProps(instance.props, print, indent, colors, opts);
}
if (instance.children) {
const children = printChildren(
instance.children,
print,
indent,
colors,
opts);
result +=
colors.tag.open + (
closeInNewLine ? '\n' : '') +
'>' +
colors.tag.close +
opts.edgeSpacing +
indent(children) +
opts.edgeSpacing +
colors.tag.open +
'</' +
instance.type +
'>' +
colors.tag.close;
} else {
result +=
colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close;
}
return result;
}
const print = (
val,
print,
indent,
opts,
colors) =>
printInstance(val, print, indent, colors, opts);
const test = object =>
object && object.$$typeof === reactTestInstance;
module.exports = { print, test };

View File

@@ -0,0 +1,15 @@
'use strict'; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function escapeHTML(str) {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
module.exports = escapeHTML;

View File

@@ -0,0 +1,57 @@
'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();
const IMMUTABLE_NAMESPACE = 'Immutable.'; /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const SPACE = ' ';const addKey = (isMap, key) => isMap ? key + ': ' : '';const addFinalEdgeSpacing = (length, edgeSpacing) => length > 0 ? edgeSpacing : '';const printImmutable = (
val,
print,
indent,
opts,
colors,
immutableDataStructureName,
isMap) =>
{var _ref =
isMap ? ['{', '}'] : ['[', ']'],_ref2 = _slicedToArray(_ref, 2);const openTag = _ref2[0],closeTag = _ref2[1];
let result =
IMMUTABLE_NAMESPACE +
immutableDataStructureName +
SPACE +
openTag +
opts.edgeSpacing;
const immutableArray = [];
val.forEach((item, key) =>
immutableArray.push(
indent(addKey(isMap, key) + print(item, print, indent, opts, colors))));
result += immutableArray.join(',' + opts.spacing);
if (!opts.min && immutableArray.length > 0) {
result += ',';
}
return (
result +
addFinalEdgeSpacing(immutableArray.length, opts.edgeSpacing) +
closeTag);
};
module.exports = printImmutable;