first commit
This commit is contained in:
216
app_vue/node_modules/webpack/lib/logging/Logger.js
generated
vendored
Normal file
216
app_vue/node_modules/webpack/lib/logging/Logger.js
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const LogType = Object.freeze({
|
||||
error: /** @type {"error"} */ ("error"), // message, c style arguments
|
||||
warn: /** @type {"warn"} */ ("warn"), // message, c style arguments
|
||||
info: /** @type {"info"} */ ("info"), // message, c style arguments
|
||||
log: /** @type {"log"} */ ("log"), // message, c style arguments
|
||||
debug: /** @type {"debug"} */ ("debug"), // message, c style arguments
|
||||
|
||||
trace: /** @type {"trace"} */ ("trace"), // no arguments
|
||||
|
||||
group: /** @type {"group"} */ ("group"), // [label]
|
||||
groupCollapsed: /** @type {"groupCollapsed"} */ ("groupCollapsed"), // [label]
|
||||
groupEnd: /** @type {"groupEnd"} */ ("groupEnd"), // [label]
|
||||
|
||||
profile: /** @type {"profile"} */ ("profile"), // [profileName]
|
||||
profileEnd: /** @type {"profileEnd"} */ ("profileEnd"), // [profileName]
|
||||
|
||||
time: /** @type {"time"} */ ("time"), // name, time as [seconds, nanoseconds]
|
||||
|
||||
clear: /** @type {"clear"} */ ("clear"), // no arguments
|
||||
status: /** @type {"status"} */ ("status") // message, arguments
|
||||
});
|
||||
|
||||
module.exports.LogType = LogType;
|
||||
|
||||
/** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
|
||||
|
||||
const LOG_SYMBOL = Symbol("webpack logger raw log method");
|
||||
const TIMERS_SYMBOL = Symbol("webpack logger times");
|
||||
const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
|
||||
|
||||
class WebpackLogger {
|
||||
/**
|
||||
* @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
|
||||
* @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
|
||||
*/
|
||||
constructor(log, getChildLogger) {
|
||||
this[LOG_SYMBOL] = log;
|
||||
this.getChildLogger = getChildLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
error(...args) {
|
||||
this[LOG_SYMBOL](LogType.error, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
warn(...args) {
|
||||
this[LOG_SYMBOL](LogType.warn, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
info(...args) {
|
||||
this[LOG_SYMBOL](LogType.info, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
log(...args) {
|
||||
this[LOG_SYMBOL](LogType.log, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
debug(...args) {
|
||||
this[LOG_SYMBOL](LogType.debug, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {EXPECTED_ANY} assertion assertion
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
assert(assertion, ...args) {
|
||||
if (!assertion) {
|
||||
this[LOG_SYMBOL](LogType.error, args);
|
||||
}
|
||||
}
|
||||
|
||||
trace() {
|
||||
this[LOG_SYMBOL](LogType.trace, ["Trace"]);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this[LOG_SYMBOL](LogType.clear);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
status(...args) {
|
||||
this[LOG_SYMBOL](LogType.status, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
group(...args) {
|
||||
this[LOG_SYMBOL](LogType.group, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...EXPECTED_ANY} args args
|
||||
*/
|
||||
groupCollapsed(...args) {
|
||||
this[LOG_SYMBOL](LogType.groupCollapsed, args);
|
||||
}
|
||||
|
||||
groupEnd() {
|
||||
this[LOG_SYMBOL](LogType.groupEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
profile(label) {
|
||||
this[LOG_SYMBOL](LogType.profile, [label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
profileEnd(label) {
|
||||
this[LOG_SYMBOL](LogType.profileEnd, [label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} label label
|
||||
*/
|
||||
time(label) {
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
|
||||
this[TIMERS_SYMBOL].set(label, process.hrtime());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeLog(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`);
|
||||
}
|
||||
const time = process.hrtime(prev);
|
||||
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeEnd(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
|
||||
}
|
||||
const time = process.hrtime(prev);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
(this[TIMERS_SYMBOL]).delete(label);
|
||||
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeAggregate(label) {
|
||||
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
||||
if (!prev) {
|
||||
throw new Error(
|
||||
`No such label '${label}' for WebpackLogger.timeAggregate()`
|
||||
);
|
||||
}
|
||||
const time = process.hrtime(prev);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
(this[TIMERS_SYMBOL]).delete(label);
|
||||
/** @type {Map<string | undefined, [number, number]>} */
|
||||
this[TIMERS_AGGREGATES_SYMBOL] =
|
||||
this[TIMERS_AGGREGATES_SYMBOL] || new Map();
|
||||
const current = this[TIMERS_AGGREGATES_SYMBOL].get(label);
|
||||
if (current !== undefined) {
|
||||
if (time[1] + current[1] > 1e9) {
|
||||
time[0] += current[0] + 1;
|
||||
time[1] = time[1] - 1e9 + current[1];
|
||||
} else {
|
||||
time[0] += current[0];
|
||||
time[1] += current[1];
|
||||
}
|
||||
}
|
||||
this[TIMERS_AGGREGATES_SYMBOL].set(label, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} label label
|
||||
*/
|
||||
timeAggregateEnd(label) {
|
||||
if (this[TIMERS_AGGREGATES_SYMBOL] === undefined) return;
|
||||
const time = this[TIMERS_AGGREGATES_SYMBOL].get(label);
|
||||
if (time === undefined) return;
|
||||
this[TIMERS_AGGREGATES_SYMBOL].delete(label);
|
||||
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.Logger = WebpackLogger;
|
212
app_vue/node_modules/webpack/lib/logging/createConsoleLogger.js
generated
vendored
Normal file
212
app_vue/node_modules/webpack/lib/logging/createConsoleLogger.js
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { LogType } = require("./Logger");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").FilterItemTypes} FilterItemTypes */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
|
||||
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
|
||||
|
||||
/** @typedef {(item: string) => boolean} FilterFunction */
|
||||
/** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */
|
||||
|
||||
/**
|
||||
* @typedef {object} LoggerConsole
|
||||
* @property {() => void} clear
|
||||
* @property {() => void} trace
|
||||
* @property {(...args: EXPECTED_ANY[]) => void} info
|
||||
* @property {(...args: EXPECTED_ANY[]) => void} log
|
||||
* @property {(...args: EXPECTED_ANY[]) => void} warn
|
||||
* @property {(...args: EXPECTED_ANY[]) => void} error
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} debug
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} group
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} groupCollapsed
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} groupEnd
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} status
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} profile
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} profileEnd
|
||||
* @property {(...args: EXPECTED_ANY[]) => void=} logTime
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} LoggerOptions
|
||||
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
|
||||
* @property {FilterTypes|boolean} debug filter for debug logging
|
||||
* @property {LoggerConsole} console the console to log to
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {FilterItemTypes} item an input item
|
||||
* @returns {FilterFunction | undefined} filter function
|
||||
*/
|
||||
const filterToFunction = item => {
|
||||
if (typeof item === "string") {
|
||||
const regExp = new RegExp(
|
||||
`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`
|
||||
);
|
||||
return ident => regExp.test(ident);
|
||||
}
|
||||
if (item && typeof item === "object" && typeof item.test === "function") {
|
||||
return ident => item.test(ident);
|
||||
}
|
||||
if (typeof item === "function") {
|
||||
return item;
|
||||
}
|
||||
if (typeof item === "boolean") {
|
||||
return () => item;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
const LogLevel = {
|
||||
none: 6,
|
||||
false: 6,
|
||||
error: 5,
|
||||
warn: 4,
|
||||
info: 3,
|
||||
log: 2,
|
||||
true: 2,
|
||||
verbose: 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {LoggerOptions} options options object
|
||||
* @returns {LoggingFunction} logging function
|
||||
*/
|
||||
module.exports = ({ level = "info", debug = false, console }) => {
|
||||
const debugFilters =
|
||||
/** @type {FilterFunction[]} */
|
||||
(
|
||||
typeof debug === "boolean"
|
||||
? [() => debug]
|
||||
: /** @type {FilterItemTypes[]} */ ([])
|
||||
.concat(debug)
|
||||
.map(filterToFunction)
|
||||
);
|
||||
const loglevel = LogLevel[`${level}`] || 0;
|
||||
|
||||
/**
|
||||
* @param {string} name name of the logger
|
||||
* @param {LogTypeEnum} type type of the log entry
|
||||
* @param {EXPECTED_ANY[]=} args arguments of the log entry
|
||||
* @returns {void}
|
||||
*/
|
||||
const logger = (name, type, args) => {
|
||||
const labeledArgs = () => {
|
||||
if (Array.isArray(args)) {
|
||||
if (args.length > 0 && typeof args[0] === "string") {
|
||||
return [`[${name}] ${args[0]}`, ...args.slice(1)];
|
||||
}
|
||||
return [`[${name}]`, ...args];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
const debug = debugFilters.some(f => f(name));
|
||||
switch (type) {
|
||||
case LogType.debug:
|
||||
if (!debug) return;
|
||||
if (typeof console.debug === "function") {
|
||||
console.debug(...labeledArgs());
|
||||
} else {
|
||||
console.log(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
case LogType.log:
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
console.log(...labeledArgs());
|
||||
break;
|
||||
case LogType.info:
|
||||
if (!debug && loglevel > LogLevel.info) return;
|
||||
console.info(...labeledArgs());
|
||||
break;
|
||||
case LogType.warn:
|
||||
if (!debug && loglevel > LogLevel.warn) return;
|
||||
console.warn(...labeledArgs());
|
||||
break;
|
||||
case LogType.error:
|
||||
if (!debug && loglevel > LogLevel.error) return;
|
||||
console.error(...labeledArgs());
|
||||
break;
|
||||
case LogType.trace:
|
||||
if (!debug) return;
|
||||
console.trace();
|
||||
break;
|
||||
case LogType.groupCollapsed:
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
if (!debug && loglevel > LogLevel.verbose) {
|
||||
if (typeof console.groupCollapsed === "function") {
|
||||
console.groupCollapsed(...labeledArgs());
|
||||
} else {
|
||||
console.log(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
case LogType.group:
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
if (typeof console.group === "function") {
|
||||
console.group(...labeledArgs());
|
||||
} else {
|
||||
console.log(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
case LogType.groupEnd:
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
if (typeof console.groupEnd === "function") {
|
||||
console.groupEnd();
|
||||
}
|
||||
break;
|
||||
case LogType.time: {
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
const [label, start, end] =
|
||||
/** @type {[string, number, number]} */
|
||||
(args);
|
||||
const ms = start * 1000 + end / 1000000;
|
||||
const msg = `[${name}] ${label}: ${ms} ms`;
|
||||
if (typeof console.logTime === "function") {
|
||||
console.logTime(msg);
|
||||
} else {
|
||||
console.log(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LogType.profile:
|
||||
if (typeof console.profile === "function") {
|
||||
console.profile(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
case LogType.profileEnd:
|
||||
if (typeof console.profileEnd === "function") {
|
||||
console.profileEnd(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
case LogType.clear:
|
||||
if (!debug && loglevel > LogLevel.log) return;
|
||||
if (typeof console.clear === "function") {
|
||||
console.clear();
|
||||
}
|
||||
break;
|
||||
case LogType.status:
|
||||
if (!debug && loglevel > LogLevel.info) return;
|
||||
if (typeof console.status === "function") {
|
||||
if (!args || args.length === 0) {
|
||||
console.status();
|
||||
} else {
|
||||
console.status(...labeledArgs());
|
||||
}
|
||||
} else if (args && args.length !== 0) {
|
||||
console.info(...labeledArgs());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected LogType ${type}`);
|
||||
}
|
||||
};
|
||||
return logger;
|
||||
};
|
45
app_vue/node_modules/webpack/lib/logging/runtime.js
generated
vendored
Normal file
45
app_vue/node_modules/webpack/lib/logging/runtime.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { SyncBailHook } = require("tapable");
|
||||
const { Logger } = require("./Logger");
|
||||
const createConsoleLogger = require("./createConsoleLogger");
|
||||
|
||||
/** @type {createConsoleLogger.LoggerOptions} */
|
||||
const currentDefaultLoggerOptions = {
|
||||
level: "info",
|
||||
debug: false,
|
||||
console
|
||||
};
|
||||
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
||||
|
||||
/**
|
||||
* @param {string} name name of the logger
|
||||
* @returns {Logger} a logger
|
||||
*/
|
||||
module.exports.getLogger = name =>
|
||||
new Logger(
|
||||
(type, args) => {
|
||||
if (module.exports.hooks.log.call(name, type, args) === undefined) {
|
||||
currentDefaultLogger(name, type, args);
|
||||
}
|
||||
},
|
||||
childName => module.exports.getLogger(`${name}/${childName}`)
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.configureDefaultLogger = options => {
|
||||
Object.assign(currentDefaultLoggerOptions, options);
|
||||
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
||||
};
|
||||
|
||||
module.exports.hooks = {
|
||||
log: new SyncBailHook(["origin", "type", "args"])
|
||||
};
|
83
app_vue/node_modules/webpack/lib/logging/truncateArgs.js
generated
vendored
Normal file
83
app_vue/node_modules/webpack/lib/logging/truncateArgs.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @param {Array<number>} array array of numbers
|
||||
* @returns {number} sum of all numbers in array
|
||||
*/
|
||||
const arraySum = array => {
|
||||
let sum = 0;
|
||||
for (const item of array) sum += item;
|
||||
return sum;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {EXPECTED_ANY[]} args items to be truncated
|
||||
* @param {number} maxLength maximum length of args including spaces between
|
||||
* @returns {string[]} truncated args
|
||||
*/
|
||||
const truncateArgs = (args, maxLength) => {
|
||||
const lengths = args.map(a => `${a}`.length);
|
||||
const availableLength = maxLength - lengths.length + 1;
|
||||
|
||||
if (availableLength > 0 && args.length === 1) {
|
||||
if (availableLength >= args[0].length) {
|
||||
return args;
|
||||
} else if (availableLength > 3) {
|
||||
return [`...${args[0].slice(-availableLength + 3)}`];
|
||||
}
|
||||
return [args[0].slice(-availableLength)];
|
||||
}
|
||||
|
||||
// Check if there is space for at least 4 chars per arg
|
||||
if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) {
|
||||
// remove args
|
||||
if (args.length > 1) return truncateArgs(args.slice(0, -1), maxLength);
|
||||
return [];
|
||||
}
|
||||
|
||||
let currentLength = arraySum(lengths);
|
||||
|
||||
// Check if all fits into maxLength
|
||||
if (currentLength <= availableLength) return args;
|
||||
|
||||
// Try to remove chars from the longest items until it fits
|
||||
while (currentLength > availableLength) {
|
||||
const maxLength = Math.max(...lengths);
|
||||
const shorterItems = lengths.filter(l => l !== maxLength);
|
||||
const nextToMaxLength =
|
||||
shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
|
||||
const maxReduce = maxLength - nextToMaxLength;
|
||||
let maxItems = lengths.length - shorterItems.length;
|
||||
let overrun = currentLength - availableLength;
|
||||
for (let i = 0; i < lengths.length; i++) {
|
||||
if (lengths[i] === maxLength) {
|
||||
const reduce = Math.min(Math.floor(overrun / maxItems), maxReduce);
|
||||
lengths[i] -= reduce;
|
||||
currentLength -= reduce;
|
||||
overrun -= reduce;
|
||||
maxItems--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return args reduced to length in lengths
|
||||
return args.map((a, i) => {
|
||||
const str = `${a}`;
|
||||
const length = lengths[i];
|
||||
if (str.length === length) {
|
||||
return str;
|
||||
} else if (length > 5) {
|
||||
return `...${str.slice(-length + 3)}`;
|
||||
} else if (length > 0) {
|
||||
return str.slice(-length);
|
||||
}
|
||||
return "";
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = truncateArgs;
|
Reference in New Issue
Block a user