Update checked-in dependencies
This commit is contained in:
parent
7fdbca3ba3
commit
357e0ceaa9
360 changed files with 25673 additions and 917 deletions
83
node_modules/@open-draft/logger/lib/index.d.ts
generated
vendored
Normal file
83
node_modules/@open-draft/logger/lib/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
type ColorFunction = (text: string) => void;
|
||||
declare function yellow(text: string): string;
|
||||
declare function blue(text: string): string;
|
||||
declare function gray(text: string): string;
|
||||
declare function red(text: string): string;
|
||||
declare function green(text: string): string;
|
||||
|
||||
type colors_ColorFunction = ColorFunction;
|
||||
declare const colors_blue: typeof blue;
|
||||
declare const colors_gray: typeof gray;
|
||||
declare const colors_green: typeof green;
|
||||
declare const colors_red: typeof red;
|
||||
declare const colors_yellow: typeof yellow;
|
||||
declare namespace colors {
|
||||
export {
|
||||
colors_ColorFunction as ColorFunction,
|
||||
colors_blue as blue,
|
||||
colors_gray as gray,
|
||||
colors_green as green,
|
||||
colors_red as red,
|
||||
colors_yellow as yellow,
|
||||
};
|
||||
}
|
||||
|
||||
type LogLevel = 'debug' | 'info' | 'success' | 'warning' | 'error';
|
||||
type LogColors = keyof typeof colors;
|
||||
interface LogEntry {
|
||||
timestamp: Date;
|
||||
level: LogLevel;
|
||||
message: any;
|
||||
}
|
||||
declare class Logger {
|
||||
private readonly name;
|
||||
private prefix;
|
||||
constructor(name: string);
|
||||
extend(domain: string): Logger;
|
||||
/**
|
||||
* Print a debug message.
|
||||
* @example
|
||||
* logger.debug('no duplicates found, creating a document...')
|
||||
*/
|
||||
debug(message: any, ...positionals: Array<unknown>): void;
|
||||
/**
|
||||
* Print an info message.
|
||||
* @example
|
||||
* logger.info('start parsing...')
|
||||
*/
|
||||
info(message: any, ...positionals: Array<unknown>): (message: any, ...positionals: Array<unknown>) => void;
|
||||
/**
|
||||
* Print a success message.
|
||||
* @example
|
||||
* logger.success('successfully created document')
|
||||
*/
|
||||
success(message: any, ...positionals: Array<unknown>): void;
|
||||
/**
|
||||
* Print a warning.
|
||||
* @example
|
||||
* logger.warning('found legacy document format')
|
||||
*/
|
||||
warning(message: any, ...positionals: Array<unknown>): void;
|
||||
/**
|
||||
* Print an error message.
|
||||
* @example
|
||||
* logger.error('something went wrong')
|
||||
*/
|
||||
error(message: any, ...positionals: Array<unknown>): void;
|
||||
/**
|
||||
* Execute the given callback only when the logging is enabled.
|
||||
* This is skipped in its entirety and has no runtime cost otherwise.
|
||||
* This executes regardless of the log level.
|
||||
* @example
|
||||
* logger.only(() => {
|
||||
* logger.info('additional info')
|
||||
* })
|
||||
*/
|
||||
only(callback: () => void): void;
|
||||
private createEntry;
|
||||
private logEntry;
|
||||
private formatTimestamp;
|
||||
private getWriter;
|
||||
}
|
||||
|
||||
export { LogColors, LogEntry, LogLevel, Logger };
|
||||
295
node_modules/@open-draft/logger/lib/index.js
generated
vendored
Normal file
295
node_modules/@open-draft/logger/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
Logger: () => Logger
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_is_node_process = require("is-node-process");
|
||||
var import_outvariant = require("outvariant");
|
||||
|
||||
// src/colors.ts
|
||||
var colors_exports = {};
|
||||
__export(colors_exports, {
|
||||
blue: () => blue,
|
||||
gray: () => gray,
|
||||
green: () => green,
|
||||
red: () => red,
|
||||
yellow: () => yellow
|
||||
});
|
||||
function yellow(text) {
|
||||
return `\x1B[33m${text}\x1B[0m`;
|
||||
}
|
||||
function blue(text) {
|
||||
return `\x1B[34m${text}\x1B[0m`;
|
||||
}
|
||||
function gray(text) {
|
||||
return `\x1B[90m${text}\x1B[0m`;
|
||||
}
|
||||
function red(text) {
|
||||
return `\x1B[31m${text}\x1B[0m`;
|
||||
}
|
||||
function green(text) {
|
||||
return `\x1B[32m${text}\x1B[0m`;
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
var IS_NODE = (0, import_is_node_process.isNodeProcess)();
|
||||
var Logger = class {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.prefix = `[${this.name}]`;
|
||||
const LOGGER_NAME = getVariable("DEBUG");
|
||||
const LOGGER_LEVEL = getVariable("LOG_LEVEL");
|
||||
const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME);
|
||||
if (isLoggingEnabled) {
|
||||
this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug;
|
||||
this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info;
|
||||
this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success;
|
||||
this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning;
|
||||
this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error;
|
||||
} else {
|
||||
this.info = noop;
|
||||
this.success = noop;
|
||||
this.warning = noop;
|
||||
this.error = noop;
|
||||
this.only = noop;
|
||||
}
|
||||
}
|
||||
prefix;
|
||||
extend(domain) {
|
||||
return new Logger(`${this.name}:${domain}`);
|
||||
}
|
||||
/**
|
||||
* Print a debug message.
|
||||
* @example
|
||||
* logger.debug('no duplicates found, creating a document...')
|
||||
*/
|
||||
debug(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "debug",
|
||||
message: gray(message),
|
||||
positionals,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "gray"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print an info message.
|
||||
* @example
|
||||
* logger.info('start parsing...')
|
||||
*/
|
||||
info(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message,
|
||||
positionals,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "blue"
|
||||
}
|
||||
});
|
||||
const performance2 = new PerformanceEntry();
|
||||
return (message2, ...positionals2) => {
|
||||
performance2.measure();
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message: `${message2} ${gray(`${performance2.deltaTime}ms`)}`,
|
||||
positionals: positionals2,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "blue"
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Print a success message.
|
||||
* @example
|
||||
* logger.success('successfully created document')
|
||||
*/
|
||||
success(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u2714 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "green",
|
||||
prefix: "green"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print a warning.
|
||||
* @example
|
||||
* logger.warning('found legacy document format')
|
||||
*/
|
||||
warning(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "warning",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u26A0 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "yellow",
|
||||
prefix: "yellow"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print an error message.
|
||||
* @example
|
||||
* logger.error('something went wrong')
|
||||
*/
|
||||
error(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "error",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u2716 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "red",
|
||||
prefix: "red"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Execute the given callback only when the logging is enabled.
|
||||
* This is skipped in its entirety and has no runtime cost otherwise.
|
||||
* This executes regardless of the log level.
|
||||
* @example
|
||||
* logger.only(() => {
|
||||
* logger.info('additional info')
|
||||
* })
|
||||
*/
|
||||
only(callback) {
|
||||
callback();
|
||||
}
|
||||
createEntry(level, message) {
|
||||
return {
|
||||
timestamp: /* @__PURE__ */ new Date(),
|
||||
level,
|
||||
message
|
||||
};
|
||||
}
|
||||
logEntry(args) {
|
||||
const {
|
||||
level,
|
||||
message,
|
||||
prefix,
|
||||
colors: customColors,
|
||||
positionals = []
|
||||
} = args;
|
||||
const entry = this.createEntry(level, message);
|
||||
const timestampColor = customColors?.timestamp || "gray";
|
||||
const prefixColor = customColors?.prefix || "gray";
|
||||
const colorize = {
|
||||
timestamp: colors_exports[timestampColor],
|
||||
prefix: colors_exports[prefixColor]
|
||||
};
|
||||
const write = this.getWriter(level);
|
||||
write(
|
||||
[colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message)).join(" "),
|
||||
...positionals.map(serializeInput)
|
||||
);
|
||||
}
|
||||
formatTimestamp(timestamp) {
|
||||
return `${timestamp.toLocaleTimeString(
|
||||
"en-GB"
|
||||
)}:${timestamp.getMilliseconds()}`;
|
||||
}
|
||||
getWriter(level) {
|
||||
switch (level) {
|
||||
case "debug":
|
||||
case "success":
|
||||
case "info": {
|
||||
return log;
|
||||
}
|
||||
case "warning": {
|
||||
return warn;
|
||||
}
|
||||
case "error": {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var PerformanceEntry = class {
|
||||
startTime;
|
||||
endTime;
|
||||
deltaTime;
|
||||
constructor() {
|
||||
this.startTime = performance.now();
|
||||
}
|
||||
measure() {
|
||||
this.endTime = performance.now();
|
||||
const deltaTime = this.endTime - this.startTime;
|
||||
this.deltaTime = deltaTime.toFixed(2);
|
||||
}
|
||||
};
|
||||
var noop = () => void 0;
|
||||
function log(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stdout.write((0, import_outvariant.format)(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.log(message, ...positionals);
|
||||
}
|
||||
function warn(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stderr.write((0, import_outvariant.format)(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.warn(message, ...positionals);
|
||||
}
|
||||
function error(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stderr.write((0, import_outvariant.format)(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.error(message, ...positionals);
|
||||
}
|
||||
function getVariable(variableName) {
|
||||
if (IS_NODE) {
|
||||
return process.env[variableName];
|
||||
}
|
||||
return globalThis[variableName]?.toString();
|
||||
}
|
||||
function isDefinedAndNotEquals(value, expected) {
|
||||
return value !== void 0 && value !== expected;
|
||||
}
|
||||
function serializeInput(message) {
|
||||
if (typeof message === "undefined") {
|
||||
return "undefined";
|
||||
}
|
||||
if (message === null) {
|
||||
return "null";
|
||||
}
|
||||
if (typeof message === "string") {
|
||||
return message;
|
||||
}
|
||||
if (typeof message === "object") {
|
||||
return JSON.stringify(message);
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
281
node_modules/@open-draft/logger/lib/index.mjs
generated
vendored
Normal file
281
node_modules/@open-draft/logger/lib/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
var __defProp = Object.defineProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
|
||||
// src/index.ts
|
||||
import { isNodeProcess } from "is-node-process";
|
||||
import { format } from "outvariant";
|
||||
|
||||
// src/colors.ts
|
||||
var colors_exports = {};
|
||||
__export(colors_exports, {
|
||||
blue: () => blue,
|
||||
gray: () => gray,
|
||||
green: () => green,
|
||||
red: () => red,
|
||||
yellow: () => yellow
|
||||
});
|
||||
function yellow(text) {
|
||||
return `\x1B[33m${text}\x1B[0m`;
|
||||
}
|
||||
function blue(text) {
|
||||
return `\x1B[34m${text}\x1B[0m`;
|
||||
}
|
||||
function gray(text) {
|
||||
return `\x1B[90m${text}\x1B[0m`;
|
||||
}
|
||||
function red(text) {
|
||||
return `\x1B[31m${text}\x1B[0m`;
|
||||
}
|
||||
function green(text) {
|
||||
return `\x1B[32m${text}\x1B[0m`;
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
var IS_NODE = isNodeProcess();
|
||||
var Logger = class {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.prefix = `[${this.name}]`;
|
||||
const LOGGER_NAME = getVariable("DEBUG");
|
||||
const LOGGER_LEVEL = getVariable("LOG_LEVEL");
|
||||
const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME);
|
||||
if (isLoggingEnabled) {
|
||||
this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug;
|
||||
this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info;
|
||||
this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success;
|
||||
this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning;
|
||||
this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error;
|
||||
} else {
|
||||
this.info = noop;
|
||||
this.success = noop;
|
||||
this.warning = noop;
|
||||
this.error = noop;
|
||||
this.only = noop;
|
||||
}
|
||||
}
|
||||
prefix;
|
||||
extend(domain) {
|
||||
return new Logger(`${this.name}:${domain}`);
|
||||
}
|
||||
/**
|
||||
* Print a debug message.
|
||||
* @example
|
||||
* logger.debug('no duplicates found, creating a document...')
|
||||
*/
|
||||
debug(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "debug",
|
||||
message: gray(message),
|
||||
positionals,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "gray"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print an info message.
|
||||
* @example
|
||||
* logger.info('start parsing...')
|
||||
*/
|
||||
info(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message,
|
||||
positionals,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "blue"
|
||||
}
|
||||
});
|
||||
const performance2 = new PerformanceEntry();
|
||||
return (message2, ...positionals2) => {
|
||||
performance2.measure();
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message: `${message2} ${gray(`${performance2.deltaTime}ms`)}`,
|
||||
positionals: positionals2,
|
||||
prefix: this.prefix,
|
||||
colors: {
|
||||
prefix: "blue"
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Print a success message.
|
||||
* @example
|
||||
* logger.success('successfully created document')
|
||||
*/
|
||||
success(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "info",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u2714 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "green",
|
||||
prefix: "green"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print a warning.
|
||||
* @example
|
||||
* logger.warning('found legacy document format')
|
||||
*/
|
||||
warning(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "warning",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u26A0 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "yellow",
|
||||
prefix: "yellow"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Print an error message.
|
||||
* @example
|
||||
* logger.error('something went wrong')
|
||||
*/
|
||||
error(message, ...positionals) {
|
||||
this.logEntry({
|
||||
level: "error",
|
||||
message,
|
||||
positionals,
|
||||
prefix: `\u2716 ${this.prefix}`,
|
||||
colors: {
|
||||
timestamp: "red",
|
||||
prefix: "red"
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Execute the given callback only when the logging is enabled.
|
||||
* This is skipped in its entirety and has no runtime cost otherwise.
|
||||
* This executes regardless of the log level.
|
||||
* @example
|
||||
* logger.only(() => {
|
||||
* logger.info('additional info')
|
||||
* })
|
||||
*/
|
||||
only(callback) {
|
||||
callback();
|
||||
}
|
||||
createEntry(level, message) {
|
||||
return {
|
||||
timestamp: /* @__PURE__ */ new Date(),
|
||||
level,
|
||||
message
|
||||
};
|
||||
}
|
||||
logEntry(args) {
|
||||
const {
|
||||
level,
|
||||
message,
|
||||
prefix,
|
||||
colors: customColors,
|
||||
positionals = []
|
||||
} = args;
|
||||
const entry = this.createEntry(level, message);
|
||||
const timestampColor = customColors?.timestamp || "gray";
|
||||
const prefixColor = customColors?.prefix || "gray";
|
||||
const colorize = {
|
||||
timestamp: colors_exports[timestampColor],
|
||||
prefix: colors_exports[prefixColor]
|
||||
};
|
||||
const write = this.getWriter(level);
|
||||
write(
|
||||
[colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message)).join(" "),
|
||||
...positionals.map(serializeInput)
|
||||
);
|
||||
}
|
||||
formatTimestamp(timestamp) {
|
||||
return `${timestamp.toLocaleTimeString(
|
||||
"en-GB"
|
||||
)}:${timestamp.getMilliseconds()}`;
|
||||
}
|
||||
getWriter(level) {
|
||||
switch (level) {
|
||||
case "debug":
|
||||
case "success":
|
||||
case "info": {
|
||||
return log;
|
||||
}
|
||||
case "warning": {
|
||||
return warn;
|
||||
}
|
||||
case "error": {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var PerformanceEntry = class {
|
||||
startTime;
|
||||
endTime;
|
||||
deltaTime;
|
||||
constructor() {
|
||||
this.startTime = performance.now();
|
||||
}
|
||||
measure() {
|
||||
this.endTime = performance.now();
|
||||
const deltaTime = this.endTime - this.startTime;
|
||||
this.deltaTime = deltaTime.toFixed(2);
|
||||
}
|
||||
};
|
||||
var noop = () => void 0;
|
||||
function log(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stdout.write(format(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.log(message, ...positionals);
|
||||
}
|
||||
function warn(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stderr.write(format(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.warn(message, ...positionals);
|
||||
}
|
||||
function error(message, ...positionals) {
|
||||
if (IS_NODE) {
|
||||
process.stderr.write(format(message, ...positionals) + "\n");
|
||||
return;
|
||||
}
|
||||
console.error(message, ...positionals);
|
||||
}
|
||||
function getVariable(variableName) {
|
||||
if (IS_NODE) {
|
||||
return process.env[variableName];
|
||||
}
|
||||
return globalThis[variableName]?.toString();
|
||||
}
|
||||
function isDefinedAndNotEquals(value, expected) {
|
||||
return value !== void 0 && value !== expected;
|
||||
}
|
||||
function serializeInput(message) {
|
||||
if (typeof message === "undefined") {
|
||||
return "undefined";
|
||||
}
|
||||
if (message === null) {
|
||||
return "null";
|
||||
}
|
||||
if (typeof message === "string") {
|
||||
return message;
|
||||
}
|
||||
if (typeof message === "object") {
|
||||
return JSON.stringify(message);
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
export {
|
||||
Logger
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue