Change endpoint from persons to people

This commit is contained in:
xfarrow
2025-03-23 21:00:08 +01:00
parent 4ae263662c
commit d005193f63
7158 changed files with 700476 additions and 735 deletions

View File

@ -0,0 +1,113 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _constants = require('../constants');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
class Prompt {
_entering;
_value;
_onChange;
_onSuccess;
_onCancel;
_offset;
_promptLength;
_selection;
constructor() {
// Copied from `enter` to satisfy TS
this._entering = true;
this._value = '';
this._selection = null;
this._offset = -1;
this._promptLength = 0;
/* eslint-disable @typescript-eslint/no-empty-function */
this._onChange = () => {};
this._onSuccess = () => {};
this._onCancel = () => {};
/* eslint-enable */
}
_onResize = () => {
this._onChange();
};
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;

View File

@ -0,0 +1,30 @@
'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) Meta Platforms, Inc. and affiliates.
*
* 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))
);
}

View File

@ -0,0 +1,67 @@
'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) Meta Platforms, Inc. and affiliates.
*
* 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
)}`;
}

View File

@ -0,0 +1,54 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printPatternCaret = printPatternCaret;
exports.printRestoredPatternCaret = printRestoredPatternCaret;
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) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function printPatternCaret(pattern, pipe) {
const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
pipe.write(_ansiEscapes().default.eraseDown);
pipe.write(inputText);
pipe.write(_ansiEscapes().default.cursorSavePosition);
}
function 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);
}

View File

@ -0,0 +1,31 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = scroll;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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
};
}