@shawngoh87/react-sketch-canvas
Version:
react-sketch-canvas - Freehand vector drawing tool for React using SVG as canvas
2,331 lines (2,324 loc) • 175 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return n;
}
var React__namespace = /*#__PURE__*/_interopNamespace(React);
function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (val) {
var object = Object(val),
keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function cov_rf5jsemfd() {
var path = "/Users/shawn/dev/packages/react-sketch-canvas/src/Paths/index.tsx";
var hash = "28b1df9bcddc9d649143907e4539ec532cd67cd6";
var global = new Function("return this")();
var gcv = "__coverage__";
var coverageData = {
path: "/Users/shawn/dev/packages/react-sketch-canvas/src/Paths/index.tsx",
statementMap: {
"0": {
start: {
line: 5,
column: 23
},
end: {
line: 13,
column: 1
}
},
"1": {
start: {
line: 6,
column: 4
},
end: {
line: 10,
column: 5
}
},
"2": {
start: {
line: 7,
column: 25
},
end: {
line: 7,
column: 33
}
},
"3": {
start: {
line: 8,
column: 23
},
end: {
line: 8,
column: 38
}
},
"4": {
start: {
line: 9,
column: 8
},
end: {
line: 9,
column: 133
}
},
"5": {
start: {
line: 11,
column: 14
},
end: {
line: 11,
column: 124
}
},
"6": {
start: {
line: 11,
column: 49
},
end: {
line: 11,
column: 119
}
},
"7": {
start: {
line: 12,
column: 4
},
end: {
line: 12,
column: 153
}
},
"8": {
start: {
line: 14,
column: 20
},
end: {
line: 21,
column: 1
}
},
"9": {
start: {
line: 15,
column: 20
},
end: {
line: 15,
column: 39
}
},
"10": {
start: {
line: 16,
column: 20
},
end: {
line: 16,
column: 39
}
},
"11": {
start: {
line: 17,
column: 4
},
end: {
line: 20,
column: 6
}
},
"12": {
start: {
line: 22,
column: 21
},
end: {
line: 33,
column: 1
}
},
"13": {
start: {
line: 23,
column: 49
},
end: {
line: 23,
column: 62
}
},
"14": {
start: {
line: 24,
column: 14
},
end: {
line: 24,
column: 33
}
},
"15": {
start: {
line: 25,
column: 14
},
end: {
line: 25,
column: 29
}
},
"16": {
start: {
line: 26,
column: 22
},
end: {
line: 26,
column: 25
}
},
"17": {
start: {
line: 27,
column: 14
},
end: {
line: 27,
column: 24
}
},
"18": {
start: {
line: 28,
column: 18
},
end: {
line: 28,
column: 51
}
},
"19": {
start: {
line: 29,
column: 19
},
end: {
line: 29,
column: 39
}
},
"20": {
start: {
line: 30,
column: 14
},
end: {
line: 30,
column: 50
}
},
"21": {
start: {
line: 31,
column: 14
},
end: {
line: 31,
column: 50
}
},
"22": {
start: {
line: 32,
column: 4
},
end: {
line: 32,
column: 18
}
},
"23": {
start: {
line: 34,
column: 29
},
end: {
line: 64,
column: 1
}
},
"24": {
start: {
line: 35,
column: 15
},
end: {
line: 35,
column: 19
}
},
"25": {
start: {
line: 36,
column: 15
},
end: {
line: 36,
column: 19
}
},
"26": {
start: {
line: 37,
column: 4
},
end: {
line: 56,
column: 5
}
},
"27": {
start: {
line: 39,
column: 12
},
end: {
line: 41,
column: 15
}
},
"28": {
start: {
line: 42,
column: 12
},
end: {
line: 42,
column: 18
}
},
"29": {
start: {
line: 44,
column: 12
},
end: {
line: 47,
column: 15
}
},
"30": {
start: {
line: 48,
column: 12
},
end: {
line: 48,
column: 18
}
},
"31": {
start: {
line: 50,
column: 12
},
end: {
line: 54,
column: 15
}
},
"32": {
start: {
line: 55,
column: 12
},
end: {
line: 55,
column: 18
}
},
"33": {
start: {
line: 57,
column: 25
},
end: {
line: 62,
column: 6
}
},
"34": {
start: {
line: 63,
column: 4
},
end: {
line: 63,
column: 70
}
},
"35": {
start: {
line: 65,
column: 14
},
end: {
line: 65,
column: 292
}
},
"36": {
start: {
line: 65,
column: 34
},
end: {
line: 65,
column: 291
}
},
"37": {
start: {
line: 65,
column: 104
},
end: {
line: 65,
column: 288
}
}
},
fnMap: {
"0": {
name: "(anonymous_0)",
decl: {
start: {
line: 5,
column: 23
},
end: {
line: 5,
column: 24
}
},
loc: {
start: {
line: 5,
column: 94
},
end: {
line: 13,
column: 1
}
},
line: 5
},
"1": {
name: "(anonymous_1)",
decl: {
start: {
line: 11,
column: 27
},
end: {
line: 11,
column: 28
}
},
loc: {
start: {
line: 11,
column: 49
},
end: {
line: 11,
column: 119
}
},
line: 11
},
"2": {
name: "(anonymous_2)",
decl: {
start: {
line: 14,
column: 20
},
end: {
line: 14,
column: 21
}
},
loc: {
start: {
line: 14,
column: 40
},
end: {
line: 21,
column: 1
}
},
line: 14
},
"3": {
name: "(anonymous_3)",
decl: {
start: {
line: 22,
column: 21
},
end: {
line: 22,
column: 22
}
},
loc: {
start: {
line: 22,
column: 40
},
end: {
line: 33,
column: 1
}
},
line: 22
},
"4": {
name: "(anonymous_4)",
decl: {
start: {
line: 34,
column: 29
},
end: {
line: 34,
column: 30
}
},
loc: {
start: {
line: 34,
column: 46
},
end: {
line: 64,
column: 1
}
},
line: 34
},
"5": {
name: "(anonymous_5)",
decl: {
start: {
line: 65,
column: 14
},
end: {
line: 65,
column: 15
}
},
loc: {
start: {
line: 65,
column: 34
},
end: {
line: 65,
column: 291
}
},
line: 65
},
"6": {
name: "(anonymous_6)",
decl: {
start: {
line: 65,
column: 86
},
end: {
line: 65,
column: 87
}
},
loc: {
start: {
line: 65,
column: 104
},
end: {
line: 65,
column: 288
}
},
line: 65
}
},
branchMap: {
"0": {
loc: {
start: {
line: 5,
column: 63
},
end: {
line: 5,
column: 86
}
},
type: "default-arg",
locations: [{
start: {
line: 5,
column: 73
},
end: {
line: 5,
column: 86
}
}],
line: 5
},
"1": {
loc: {
start: {
line: 6,
column: 4
},
end: {
line: 10,
column: 5
}
},
type: "if",
locations: [{
start: {
line: 6,
column: 4
},
end: {
line: 10,
column: 5
}
}, {
start: {
line: undefined,
column: undefined
},
end: {
line: undefined,
column: undefined
}
}],
line: 6
},
"2": {
loc: {
start: {
line: 11,
column: 49
},
end: {
line: 11,
column: 119
}
},
type: "cond-expr",
locations: [{
start: {
line: 11,
column: 59
},
end: {
line: 11,
column: 84
}
}, {
start: {
line: 11,
column: 87
},
end: {
line: 11,
column: 119
}
}],
line: 11
},
"3": {
loc: {
start: {
line: 24,
column: 14
},
end: {
line: 24,
column: 33
}
},
type: "binary-expr",
locations: [{
start: {
line: 24,
column: 14
},
end: {
line: 24,
column: 22
}
}, {
start: {
line: 24,
column: 26
},
end: {
line: 24,
column: 33
}
}],
line: 24
},
"4": {
loc: {
start: {
line: 25,
column: 14
},
end: {
line: 25,
column: 29
}
},
type: "binary-expr",
locations: [{
start: {
line: 25,
column: 14
},
end: {
line: 25,
column: 18
}
}, {
start: {
line: 25,
column: 22
},
end: {
line: 25,
column: 29
}
}],
line: 25
},
"5": {
loc: {
start: {
line: 28,
column: 29
},
end: {
line: 28,
column: 50
}
},
type: "cond-expr",
locations: [{
start: {
line: 28,
column: 39
},
end: {
line: 28,
column: 46
}
}, {
start: {
line: 28,
column: 49
},
end: {
line: 28,
column: 50
}
}],
line: 28
},
"6": {
loc: {
start: {
line: 37,
column: 4
},
end: {
line: 56,
column: 5
}
},
type: "switch",
locations: [{
start: {
line: 38,
column: 8
},
end: {
line: 42,
column: 18
}
}, {
start: {
line: 43,
column: 8
},
end: {
line: 48,
column: 18
}
}, {
start: {
line: 49,
column: 8
},
end: {
line: 55,
column: 18
}
}],
line: 37
}
},
s: {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0,
"10": 0,
"11": 0,
"12": 0,
"13": 0,
"14": 0,
"15": 0,
"16": 0,
"17": 0,
"18": 0,
"19": 0,
"20": 0,
"21": 0,
"22": 0,
"23": 0,
"24": 0,
"25": 0,
"26": 0,
"27": 0,
"28": 0,
"29": 0,
"30": 0,
"31": 0,
"32": 0,
"33": 0,
"34": 0,
"35": 0,
"36": 0,
"37": 0
},
f: {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0
},
b: {
"0": [0],
"1": [0, 0],
"2": [0, 0],
"3": [0, 0],
"4": [0, 0],
"5": [0, 0],
"6": [0, 0, 0]
},
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
hash: "28b1df9bcddc9d649143907e4539ec532cd67cd6"
};
var coverage = global[gcv] || (global[gcv] = {});
if (!coverage[path] || coverage[path].hash !== hash) {
coverage[path] = coverageData;
}
var actualCoverage = coverage[path];
{
// @ts-ignore
cov_rf5jsemfd = function () {
return actualCoverage;
};
}
return actualCoverage;
}
cov_rf5jsemfd();
/**
* Generate SVG Path tag from the given points
*/
cov_rf5jsemfd().s[0]++;
var SvgPath = function SvgPath(_ref) {
var paths = _ref.paths,
id = _ref.id,
strokeWidth = _ref.strokeWidth,
strokeColor = _ref.strokeColor,
_ref$command = _ref.command,
command = _ref$command === void 0 ? (cov_rf5jsemfd().b[0][0]++, bezierCommand) : _ref$command;
cov_rf5jsemfd().f[0]++;
cov_rf5jsemfd().s[1]++;
if (paths.length === 1) {
cov_rf5jsemfd().b[1][0]++;
var _ref2 = (cov_rf5jsemfd().s[2]++, paths[0]),
x = _ref2.x,
y = _ref2.y;
var radius = (cov_rf5jsemfd().s[3]++, strokeWidth / 2);
cov_rf5jsemfd().s[4]++;
return React__namespace.createElement("circle", {
key: id,
id: id,
cx: x,
cy: y,
r: radius,
stroke: strokeColor,
fill: strokeColor
});
} else {
cov_rf5jsemfd().b[1][1]++;
}
var d = (cov_rf5jsemfd().s[5]++, paths.reduce(function (acc, point, i, a) {
cov_rf5jsemfd().f[1]++;
cov_rf5jsemfd().s[6]++;
return i === 0 ? (cov_rf5jsemfd().b[2][0]++, "M " + point.x + "," + point.y) : (cov_rf5jsemfd().b[2][1]++, acc + " " + command(point, i, a));
}, ''));
cov_rf5jsemfd().s[7]++;
return React__namespace.createElement("path", {
key: id,
id: id,
d: d,
fill: "none",
strokeLinecap: "round",
stroke: strokeColor,
strokeWidth: strokeWidth
});
};
cov_rf5jsemfd().s[8]++;
var line = function line(pointA, pointB) {
cov_rf5jsemfd().f[2]++;
var lengthX = (cov_rf5jsemfd().s[9]++, pointB.x - pointA.x);
var lengthY = (cov_rf5jsemfd().s[10]++, pointB.y - pointA.y);
cov_rf5jsemfd().s[11]++;
return {
length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
angle: Math.atan2(lengthY, lengthX)
};
};
cov_rf5jsemfd().s[12]++;
var controlPoint = function controlPoint(controlPoints) {
cov_rf5jsemfd().f[3]++;
var _ref3 = (cov_rf5jsemfd().s[13]++, controlPoints),
current = _ref3.current,
next = _ref3.next,
previous = _ref3.previous,
reverse = _ref3.reverse;
var p = (cov_rf5jsemfd().s[14]++, (cov_rf5jsemfd().b[3][0]++, previous) || (cov_rf5jsemfd().b[3][1]++, current));
var n = (cov_rf5jsemfd().s[15]++, (cov_rf5jsemfd().b[4][0]++, next) || (cov_rf5jsemfd().b[4][1]++, current));
var smoothing = (cov_rf5jsemfd().s[16]++, 0.2);
var o = (cov_rf5jsemfd().s[17]++, line(p, n));
var angle = (cov_rf5jsemfd().s[18]++, o.angle + (reverse ? (cov_rf5jsemfd().b[5][0]++, Math.PI) : (cov_rf5jsemfd().b[5][1]++, 0)));
var length = (cov_rf5jsemfd().s[19]++, o.length * smoothing);
var x = (cov_rf5jsemfd().s[20]++, current.x + Math.cos(angle) * length);
var y = (cov_rf5jsemfd().s[21]++, current.y + Math.sin(angle) * length);
cov_rf5jsemfd().s[22]++;
return [x, y];
};
cov_rf5jsemfd().s[23]++;
var bezierCommand = function bezierCommand(point, i, a) {
cov_rf5jsemfd().f[4]++;
var cpsX = (cov_rf5jsemfd().s[24]++, null);
var cpsY = (cov_rf5jsemfd().s[25]++, null);
cov_rf5jsemfd().s[26]++;
switch (i) {
case 0:
cov_rf5jsemfd().b[6][0]++;
cov_rf5jsemfd().s[27]++;
var _controlPoint = controlPoint({
current: point
});
cpsX = _controlPoint[0];
cpsY = _controlPoint[1];
cov_rf5jsemfd().s[28]++;
break;
case 1:
cov_rf5jsemfd().b[6][1]++;
cov_rf5jsemfd().s[29]++;
var _controlPoint2 = controlPoint({
current: a[i - 1],
next: point
});
cpsX = _controlPoint2[0];
cpsY = _controlPoint2[1];
cov_rf5jsemfd().s[30]++;
break;
default:
cov_rf5jsemfd().b[6][2]++;
cov_rf5jsemfd().s[31]++;
var _controlPoint3 = controlPoint({
current: a[i - 1],
previous: a[i - 2],
next: point
});
cpsX = _controlPoint3[0];
cpsY = _controlPoint3[1];
cov_rf5jsemfd().s[32]++;
break;
}
var _ref4 = (cov_rf5jsemfd().s[33]++, controlPoint({
current: point,
previous: a[i - 1],
next: a[i + 1],
reverse: true
})),
cpeX = _ref4[0],
cpeY = _ref4[1];
cov_rf5jsemfd().s[34]++;
return "C " + cpsX + "," + cpsY + " " + cpeX + "," + cpeY + " " + point.x + ", " + point.y;
};
cov_rf5jsemfd().s[35]++;
var Paths = function Paths(_ref5) {
var id = _ref5.id,
paths = _ref5.paths;
cov_rf5jsemfd().f[5]++;
cov_rf5jsemfd().s[36]++;
return React__namespace.createElement(React__namespace.Fragment, null, paths.map(function (path, index) {
cov_rf5jsemfd().f[6]++;
cov_rf5jsemfd().s[37]++;
return React__namespace.createElement(SvgPath, {
key: id + "__" + index,
paths: path.paths,
id: id + "__" + index,
strokeWidth: path.strokeWidth,
strokeColor: path.strokeColor,
command: bezierCommand
});
}));
};
function cov_58vp5xgs2() {
var path = "/Users/shawn/dev/packages/react-sketch-canvas/src/Canvas/index.tsx";
var hash = "6de0af96c9abb792c57de102cc896fbb3acc3359";
var global = new Function("return this")();
var gcv = "__coverage__";
var coverageData = {
path: "/Users/shawn/dev/packages/react-sketch-canvas/src/Canvas/index.tsx",
statementMap: {
"0": {
start: {
line: 3,
column: 18
},
end: {
line: 14,
column: 2
}
},
"1": {
start: {
line: 3,
column: 27
},
end: {
line: 14,
column: 2
}
},
"2": {
start: {
line: 4,
column: 16
},
end: {
line: 4,
column: 27
}
},
"3": {
start: {
line: 5,
column: 4
},
end: {
line: 10,
column: 7
}
},
"4": {
start: {
line: 6,
column: 8
},
end: {
line: 8,
column: 9
}
},
"5": {
start: {
line: 7,
column: 12
},
end: {
line: 7,
column: 25
}
},
"6": {
start: {
line: 9,
column: 8
},
end: {
line: 9,
column: 34
}
},
"7": {
start: {
line: 11,
column: 4
},
end: {
line: 11,
column: 56
}
},
"8": {
start: {
line: 11,
column: 43
},
end: {
line: 11,
column: 54
}
},
"9": {
start: {
line: 12,
column: 4
},
end: {
line: 12,
column: 18
}
},
"10": {
start: {
line: 13,
column: 4
},
end: {
line: 13,
column: 49
}
},
"11": {
start: {
line: 16,
column: 22
},
end: {
line: 16,
column: 56
}
},
"12": {
start: {
line: 17,
column: 18
},
end: {
line: 17,
column: 36
}
},
"13": {
start: {
line: 18,
column: 19
},
end: {
line: 18,
column: 38
}
},
"14": {
start: {
line: 19,
column: 4
},
end: {
line: 19,
column: 64
}
},
"15": {
start: {
line: 20,
column: 4
},
end: {
line: 20,
column: 54
}
},
"16": {
start: {
line: 21,
column: 4
},
end: {
line: 21,
column: 56
}
},
"17": {
start: {
line: 22,
column: 4
},
end: {
line: 22,
column: 40
}
},
"18": {
start: {
line: 24,
column: 22
},
end: {
line: 190,
column: 2
}
},
"19": {
start: {
line: 28,
column: 26
},
end: {
line: 28,
column: 31
}
},
"20": {
start: {
line: 29,
column: 22
},
end: {
line: 29,
column: 40
}
},
"21": {
start: {
line: 31,
column: 27
},
end: {
line: 43,
column: 5
}
},
"22": {
start: {
line: 32,
column: 29
},
end: {
line: 32,
column: 71
}
},
"23": {
start: {
line: 33,
column: 27
},
end: {
line: 33,
column: 46
}
},
"24": {
start: {
line: 34,
column: 26
},
end: {
line: 34,
column: 45
}
},
"25": {
start: {
line: 35,
column: 8
},
end: {
line: 37,
column: 9
}
},
"26": {
start: {
line: 36,
column: 12
},
end: {
line: 36,
column: 34
}
},
"27": {
start: {
line: 38,
column: 22
},
end: {
line: 41,
column: 9
}
},
"28": {
start: {
line: 42,
column: 8
},
end: {
line: 42,
column: 21
}
},
"29": {
start: {
line: 45,
column: 30
},
end: {
line: 55,
column: 5
}
},
"30": {
start: {
line: 47,
column: 8
},
end: {
line: 50,
column: 9
}
},
"31": {
start: {
line: 49,
column: 12
},
end: {
line: 49,
column: 19
}
},
"32": {
start: {
line: 51,
column: 8
},
end: {
line: 52,
column: 19
}
},
"33": {
start: {
line: 52,
column: 12
},
end: {
line: 52,
column: 19
}
},
"34": {
start: {
line: 53,
column: 22
},
end: {
line: 53,
column: 43
}
},
"35": {
start: {
line: 54,
column: 8
},
end: {
line: 54,
column: 29
}
},
"36": {
start: {
line: 56,
column: 30
},
end: {
line: 66,
column: 5
}
},
"37": {
start: {
line: 57,
column: 8
},
end: {
line: 58,
column: 19
}
},
"38": {
start: {
line: 58,
column: 12
},
end: {
line: 58,
column: 19
}
},
"39": {
start: {
line: 60,
column: 8
},
end: {
line: 63,
column: 9
}
},
"40": {
start: {
line: 62,
column: 12
},
end: {
line: 62,
column: 19
}
},
"41": {
start: {
line: 64,
column: 22
},
end: {
line: 64,
column: 43
}
},
"42": {
start: {
line: 65,
column: 8
},
end: {
line: 65,
column: 29
}
},
"43": {
start: {
line: 67,
column: 28
},
end: {
line: 76,
column: 5
}
},
"44": {
start: {
line: 68,
column: 8
},
end: {
line: 69,
column: 19
}
},
"45": {
start: {
line: 69,
column: 12
},
end: {
line: 69,
column: 19
}
},
"46": {
start: {
line: 71,
column: 8
},
end: {
line: 74,
column: 9
}
},
"47": {
start: {
line: 73,
column: 12
},
end: {
line: 73,
column: 19
}
},
"48": {
start: {
line: 75,
column: 8
},
end: {
line: 75,
column: 22
}
},
"49": {
start: {
line: 78,
column: 4
},
end: {
line: 144,
column: 8
}
},
"50": {
start: {
line: 78,
column: 42
},
end: {
line: 144,
column: 5
}
},
"51": {
start: {
line: 80,
column: 12
},
end: {
line: 119,
column: 15
}
},
"52": {
start: {
line: 81,
column: 16
},
end: {
line: 118,
column: 17
}
},
"53": {
start: {
line: 82,
column: 35
},
end: {
line: 82,
column: 52
}
},
"54": {
start: {
line: 83,
column: 20
},
end: {
line: 85,
column: 21
}
},
"55": {
start: {
line: 84,
column: 24
},
end: {
line: 84,
column: 63
}
},
"56": {
start: {
line: 86,
column: 57
},
end: {
line: 86,
column: 85
}
},
"57": {
start: {
line: 87,
column: 41
},
end: {
line: 87,
column: 97
}
},
"58": {
start: {
line: 88,
column: 46
},
end: {
line: 88,
column: 77
}
},
"59": {
start: {
line: 89,
column: 20
},
end: {
line: 97,
column: 21
}
},
"60": {
start: {
line: 90,
column: 24
},
end: {
line: 96,
column: 25
}
},
"61": {
start: {
line: 91,
column: 40
},
end: {
line: 91,
column: 72
}
},
"62": {
start: {
line: 92,
column: 28
},
end: {
line: 92,
column: 56
}
},
"63": {
start: {
line: 95,
column: 28
},
end: {
line: 95,
column: 144
}
},
"64": {
start: {
line: 98,
column: 20
},
end: {
line: 114,
column: 23
}
},
"65": {
start: {
line: 100,
column: 45
},
end: {
line: 100,
column: 77
}
},
"66": {
start: {
line: 101,
column: 24
},
end: {
line: 101,
column: 77
}
},
"67": {
start: {
line: 102,
column: 24
},
end: {
line: 102,
column: 79
}
},
"68": {
start: {
line: 103,
column: 40
},
end: {
line: 103,
column: 69
}
},
"69": {
start: {
line: 104,
column: 24
},
end: {
line: 106,
column: 25
}
},
"70": {
start: {
line: 105,
column: 28
},
end: {
line: 105,
column: 67
}
},
"71": {
start: {
line: 107,
column: 24
},
end: {
line: 109,
column: 27
}
},
"72": {
start: {
line: 108,
column: 28
},
end: {
line: 108,
column: 59
}
},
"73": {
start: {
line: 110,
column: 24
},
end: {
line: 110,
column: 78
}
},
"74": {
start: {
line: 113,
column: 24
},
end: {
line: 113,
column: 32
}
},
"75": {
start: {
line: 117,
column: 20
},
end: {
line: 117,
column: 30
}
},
"76": {
start: {
line: 122,
column: 12
},
end: {
line: 142,
column: 15
}
},
"77": {
start: {
line: 123,
column: 16
},
end: {
line: 141,
column: 17
}
},
"78": {
start: {
line: 124,
column: 35
},
end: {
line: 124,
column: 60
}
},
"79": {
start: {
line: 125,
column: 20
},
end: {
line: 136,
column: 21
}
},
"80": {
start: {
line: 126,
column: 46
},
end: {
line: 126,
column: 74
}
},
"81": {
start: {
line: 127,
column: 24
},
end: {
line: 130,
column: 25
}
},
"82": {
start: {
line: 128,
column: 28
},
end: {
line: 128,
column: 57
}
},
"83": {
start: {
line: 129,
column: 28
},
end: {
line: 129,
column: 35
}
},
"84": {
start: {
line: 131,
column: 24
},
end: {
line: 131,
column: 80
}
},
"85": {
start: {
line: 132,
column: 24
},
end: {
line: 134,
column: 64
}
},
"86": {
start: {
line: 135,
column: 24
},
end: {
line: 135,
column: 53
}
},
"87": {
start: {
line: 137,
column: 20
},
end: {
line: 137,
column: 59
}
},
"88": {
start: {
line: 140,
column: 20
},
end: {
line: 140,
column: 30
}
},
"89": {
start: {
line: 147,
column: 4
},
end: {
line: 152,
column: 26
}
},
"90": {
start: {
line: 148,
column: 8
},
end: {
line: 148,
column: 64
}
},
"91": {
start: {
line: 149,
column: 8
},
end: {
line: 151,
column: 10
}
},
"92": {
start: {
line: 150,
column: 12
},
end: {
line: 150,
column: 71
}
},
"93": {
start: {
line: 153,
colu