aboutsummaryrefslogtreecommitdiff
path: root/node_modules/jest-watcher/build/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/jest-watcher/build/lib')
-rw-r--r--node_modules/jest-watcher/build/lib/Prompt.d.ts25
-rw-r--r--node_modules/jest-watcher/build/lib/Prompt.js158
-rw-r--r--node_modules/jest-watcher/build/lib/colorize.d.ts7
-rw-r--r--node_modules/jest-watcher/build/lib/colorize.js34
-rw-r--r--node_modules/jest-watcher/build/lib/formatTestNameByPattern.d.ts7
-rw-r--r--node_modules/jest-watcher/build/lib/formatTestNameByPattern.js81
-rw-r--r--node_modules/jest-watcher/build/lib/patternModeHelpers.d.ts9
-rw-r--r--node_modules/jest-watcher/build/lib/patternModeHelpers.js68
-rw-r--r--node_modules/jest-watcher/build/lib/scroll.d.ts12
-rw-r--r--node_modules/jest-watcher/build/lib/scroll.js34
10 files changed, 435 insertions, 0 deletions
diff --git a/node_modules/jest-watcher/build/lib/Prompt.d.ts b/node_modules/jest-watcher/build/lib/Prompt.d.ts
new file mode 100644
index 0000000..563b9f1
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/Prompt.d.ts
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+import type { ScrollOptions } from '../types';
+export default class Prompt {
+ private _entering;
+ private _value;
+ private _onChange;
+ private _onSuccess;
+ private _onCancel;
+ private _offset;
+ private _promptLength;
+ private _selection;
+ constructor();
+ private _onResize;
+ enter(onChange: (pattern: string, options: ScrollOptions) => void, onSuccess: (pattern: string) => void, onCancel: () => void): void;
+ setPromptLength(length: number): void;
+ setPromptSelection(selected: string): void;
+ put(key: string): void;
+ abort(): void;
+ isEntering(): boolean;
+}
diff --git a/node_modules/jest-watcher/build/lib/Prompt.js b/node_modules/jest-watcher/build/lib/Prompt.js
new file mode 100644
index 0000000..1adf550
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/Prompt.js
@@ -0,0 +1,158 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.default = void 0;
+
+var _constants = require('../constants');
+
+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;
+}
+
+class Prompt {
+ constructor() {
+ _defineProperty(this, '_entering', void 0);
+
+ _defineProperty(this, '_value', void 0);
+
+ _defineProperty(this, '_onChange', void 0);
+
+ _defineProperty(this, '_onSuccess', void 0);
+
+ _defineProperty(this, '_onCancel', void 0);
+
+ _defineProperty(this, '_offset', void 0);
+
+ _defineProperty(this, '_promptLength', void 0);
+
+ _defineProperty(this, '_selection', void 0);
+
+ _defineProperty(this, '_onResize', () => {
+ this._onChange();
+ });
+
+ // Copied from `enter` to satisfy TS
+ this._entering = true;
+ this._value = '';
+ this._selection = null;
+ this._offset = -1;
+ this._promptLength = 0;
+
+ this._onChange = () => {};
+
+ this._onSuccess = () => {};
+
+ this._onCancel = () => {};
+ }
+
+ enter(onChange, onSuccess, onCancel) {
+ this._entering = true;
+ this._value = '';
+ this._onSuccess = onSuccess;
+ this._onCancel = onCancel;
+ this._selection = null;
+ this._offset = -1;
+ this._promptLength = 0;
+
+ this._onChange = () =>
+ onChange(this._value, {
+ max: 10,
+ offset: this._offset
+ });
+
+ this._onChange();
+
+ process.stdout.on('resize', this._onResize);
+ }
+
+ setPromptLength(length) {
+ this._promptLength = length;
+ }
+
+ setPromptSelection(selected) {
+ this._selection = selected;
+ }
+
+ put(key) {
+ switch (key) {
+ case _constants.KEYS.ENTER:
+ this._entering = false;
+
+ this._onSuccess(this._selection || this._value);
+
+ this.abort();
+ break;
+
+ case _constants.KEYS.ESCAPE:
+ this._entering = false;
+
+ this._onCancel(this._value);
+
+ this.abort();
+ break;
+
+ case _constants.KEYS.ARROW_DOWN:
+ this._offset = Math.min(this._offset + 1, this._promptLength - 1);
+
+ this._onChange();
+
+ break;
+
+ case _constants.KEYS.ARROW_UP:
+ this._offset = Math.max(this._offset - 1, -1);
+
+ this._onChange();
+
+ break;
+
+ case _constants.KEYS.ARROW_LEFT:
+ case _constants.KEYS.ARROW_RIGHT:
+ break;
+
+ case _constants.KEYS.CONTROL_U:
+ this._value = '';
+ this._offset = -1;
+ this._selection = null;
+
+ this._onChange();
+
+ break;
+
+ default:
+ this._value =
+ key === _constants.KEYS.BACKSPACE
+ ? this._value.slice(0, -1)
+ : this._value + key;
+ this._offset = -1;
+ this._selection = null;
+
+ this._onChange();
+
+ break;
+ }
+ }
+
+ abort() {
+ this._entering = false;
+ this._value = '';
+ process.stdout.removeListener('resize', this._onResize);
+ }
+
+ isEntering() {
+ return this._entering;
+ }
+}
+
+exports.default = Prompt;
diff --git a/node_modules/jest-watcher/build/lib/colorize.d.ts b/node_modules/jest-watcher/build/lib/colorize.d.ts
new file mode 100644
index 0000000..9825297
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/colorize.d.ts
@@ -0,0 +1,7 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+export default function colorize(str: string, start: number, end: number): string;
diff --git a/node_modules/jest-watcher/build/lib/colorize.js b/node_modules/jest-watcher/build/lib/colorize.js
new file mode 100644
index 0000000..456f220
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/colorize.js
@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.default = colorize;
+
+function _chalk() {
+ const data = _interopRequireDefault(require('chalk'));
+
+ _chalk = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : {default: obj};
+}
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+function colorize(str, start, end) {
+ return (
+ _chalk().default.dim(str.slice(0, start)) +
+ _chalk().default.reset(str.slice(start, end)) +
+ _chalk().default.dim(str.slice(end))
+ );
+}
diff --git a/node_modules/jest-watcher/build/lib/formatTestNameByPattern.d.ts b/node_modules/jest-watcher/build/lib/formatTestNameByPattern.d.ts
new file mode 100644
index 0000000..7ccb579
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/formatTestNameByPattern.d.ts
@@ -0,0 +1,7 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+export default function formatTestNameByPattern(testName: string, pattern: string, width: number): string;
diff --git a/node_modules/jest-watcher/build/lib/formatTestNameByPattern.js b/node_modules/jest-watcher/build/lib/formatTestNameByPattern.js
new file mode 100644
index 0000000..7137225
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/formatTestNameByPattern.js
@@ -0,0 +1,81 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.default = formatTestNameByPattern;
+
+function _chalk() {
+ const data = _interopRequireDefault(require('chalk'));
+
+ _chalk = function () {
+ return data;
+ };
+
+ return data;
+}
+
+var _colorize = _interopRequireDefault(require('./colorize'));
+
+function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : {default: obj};
+}
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+const DOTS = '...';
+const ENTER = '⏎';
+
+function formatTestNameByPattern(testName, pattern, width) {
+ const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);
+ let regexp;
+
+ try {
+ regexp = new RegExp(pattern, 'i');
+ } catch {
+ return _chalk().default.dim(inlineTestName);
+ }
+
+ const match = inlineTestName.match(regexp);
+
+ if (!match) {
+ return _chalk().default.dim(inlineTestName);
+ }
+
+ const startPatternIndex = Math.max(match.index || 0, 0);
+ const endPatternIndex = startPatternIndex + match[0].length;
+
+ if (inlineTestName.length <= width) {
+ return (0, _colorize.default)(
+ inlineTestName,
+ startPatternIndex,
+ endPatternIndex
+ );
+ }
+
+ const slicedTestName = inlineTestName.slice(0, width - DOTS.length);
+
+ if (startPatternIndex < slicedTestName.length) {
+ if (endPatternIndex > slicedTestName.length) {
+ return (0, _colorize.default)(
+ slicedTestName + DOTS,
+ startPatternIndex,
+ slicedTestName.length + DOTS.length
+ );
+ } else {
+ return (0, _colorize.default)(
+ slicedTestName + DOTS,
+ Math.min(startPatternIndex, slicedTestName.length),
+ endPatternIndex
+ );
+ }
+ }
+
+ return `${_chalk().default.dim(slicedTestName)}${_chalk().default.reset(
+ DOTS
+ )}`;
+}
diff --git a/node_modules/jest-watcher/build/lib/patternModeHelpers.d.ts b/node_modules/jest-watcher/build/lib/patternModeHelpers.d.ts
new file mode 100644
index 0000000..99487c2
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/patternModeHelpers.d.ts
@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+/// <reference types="node" />
+export declare const printPatternCaret: (pattern: string, pipe: NodeJS.WritableStream) => void;
+export declare const printRestoredPatternCaret: (pattern: string, currentUsageRows: number, pipe: NodeJS.WritableStream) => void;
diff --git a/node_modules/jest-watcher/build/lib/patternModeHelpers.js b/node_modules/jest-watcher/build/lib/patternModeHelpers.js
new file mode 100644
index 0000000..6e652e6
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/patternModeHelpers.js
@@ -0,0 +1,68 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.printRestoredPatternCaret = exports.printPatternCaret = void 0;
+
+function _ansiEscapes() {
+ const data = _interopRequireDefault(require('ansi-escapes'));
+
+ _ansiEscapes = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _chalk() {
+ const data = _interopRequireDefault(require('chalk'));
+
+ _chalk = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _stringLength() {
+ const data = _interopRequireDefault(require('string-length'));
+
+ _stringLength = function () {
+ return data;
+ };
+
+ return data;
+}
+
+function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : {default: obj};
+}
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+const printPatternCaret = (pattern, pipe) => {
+ const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
+ pipe.write(_ansiEscapes().default.eraseDown);
+ pipe.write(inputText);
+ pipe.write(_ansiEscapes().default.cursorSavePosition);
+};
+
+exports.printPatternCaret = printPatternCaret;
+
+const printRestoredPatternCaret = (pattern, currentUsageRows, pipe) => {
+ const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
+ pipe.write(
+ _ansiEscapes().default.cursorTo(
+ (0, _stringLength().default)(inputText),
+ currentUsageRows - 1
+ )
+ );
+ pipe.write(_ansiEscapes().default.cursorRestorePosition);
+};
+
+exports.printRestoredPatternCaret = printRestoredPatternCaret;
diff --git a/node_modules/jest-watcher/build/lib/scroll.d.ts b/node_modules/jest-watcher/build/lib/scroll.d.ts
new file mode 100644
index 0000000..536c3b7
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/scroll.d.ts
@@ -0,0 +1,12 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+import type { ScrollOptions } from '../types';
+export default function scroll(size: number, { offset, max }: ScrollOptions): {
+ end: number;
+ index: number;
+ start: number;
+};
diff --git a/node_modules/jest-watcher/build/lib/scroll.js b/node_modules/jest-watcher/build/lib/scroll.js
new file mode 100644
index 0000000..4a54504
--- /dev/null
+++ b/node_modules/jest-watcher/build/lib/scroll.js
@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports.default = scroll;
+
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+function scroll(size, {offset, max}) {
+ let start = 0;
+ let index = Math.min(offset, size);
+ const halfScreen = max / 2;
+
+ if (index <= halfScreen) {
+ start = 0;
+ } else {
+ if (size >= max) {
+ start = Math.min(index - halfScreen - 1, size - max);
+ }
+
+ index = Math.min(index - start, size);
+ }
+
+ return {
+ end: Math.min(size, start + max),
+ index,
+ start
+ };
+}