Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
2474
my-app/node_modules/webpack/lib/stats/DefaultStatsFactoryPlugin.js
generated
vendored
Executable file
2474
my-app/node_modules/webpack/lib/stats/DefaultStatsFactoryPlugin.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
335
my-app/node_modules/webpack/lib/stats/DefaultStatsPresetPlugin.js
generated
vendored
Executable file
335
my-app/node_modules/webpack/lib/stats/DefaultStatsPresetPlugin.js
generated
vendored
Executable file
|
@ -0,0 +1,335 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const RequestShortener = require("../RequestShortener");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
||||
const applyDefaults = (options, defaults) => {
|
||||
for (const key of Object.keys(defaults)) {
|
||||
if (typeof options[key] === "undefined") {
|
||||
options[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const NAMED_PRESETS = {
|
||||
verbose: {
|
||||
hash: true,
|
||||
builtAt: true,
|
||||
relatedAssets: true,
|
||||
entrypoints: true,
|
||||
chunkGroups: true,
|
||||
ids: true,
|
||||
modules: false,
|
||||
chunks: true,
|
||||
chunkRelations: true,
|
||||
chunkModules: true,
|
||||
dependentModules: true,
|
||||
chunkOrigins: true,
|
||||
depth: true,
|
||||
env: true,
|
||||
reasons: true,
|
||||
usedExports: true,
|
||||
providedExports: true,
|
||||
optimizationBailout: true,
|
||||
errorDetails: true,
|
||||
errorStack: true,
|
||||
publicPath: true,
|
||||
logging: "verbose",
|
||||
orphanModules: true,
|
||||
runtimeModules: true,
|
||||
exclude: false,
|
||||
errorsSpace: Infinity,
|
||||
warningsSpace: Infinity,
|
||||
modulesSpace: Infinity,
|
||||
chunkModulesSpace: Infinity,
|
||||
assetsSpace: Infinity,
|
||||
reasonsSpace: Infinity,
|
||||
children: true
|
||||
},
|
||||
detailed: {
|
||||
hash: true,
|
||||
builtAt: true,
|
||||
relatedAssets: true,
|
||||
entrypoints: true,
|
||||
chunkGroups: true,
|
||||
ids: true,
|
||||
chunks: true,
|
||||
chunkRelations: true,
|
||||
chunkModules: false,
|
||||
chunkOrigins: true,
|
||||
depth: true,
|
||||
usedExports: true,
|
||||
providedExports: true,
|
||||
optimizationBailout: true,
|
||||
errorDetails: true,
|
||||
publicPath: true,
|
||||
logging: true,
|
||||
runtimeModules: true,
|
||||
exclude: false,
|
||||
errorsSpace: 1000,
|
||||
warningsSpace: 1000,
|
||||
modulesSpace: 1000,
|
||||
assetsSpace: 1000,
|
||||
reasonsSpace: 1000
|
||||
},
|
||||
minimal: {
|
||||
all: false,
|
||||
version: true,
|
||||
timings: true,
|
||||
modules: true,
|
||||
errorsSpace: 0,
|
||||
warningsSpace: 0,
|
||||
modulesSpace: 0,
|
||||
assets: true,
|
||||
assetsSpace: 0,
|
||||
errors: true,
|
||||
errorsCount: true,
|
||||
warnings: true,
|
||||
warningsCount: true,
|
||||
logging: "warn"
|
||||
},
|
||||
"errors-only": {
|
||||
all: false,
|
||||
errors: true,
|
||||
errorsCount: true,
|
||||
errorsSpace: Infinity,
|
||||
moduleTrace: true,
|
||||
logging: "error"
|
||||
},
|
||||
"errors-warnings": {
|
||||
all: false,
|
||||
errors: true,
|
||||
errorsCount: true,
|
||||
errorsSpace: Infinity,
|
||||
warnings: true,
|
||||
warningsCount: true,
|
||||
warningsSpace: Infinity,
|
||||
logging: "warn"
|
||||
},
|
||||
summary: {
|
||||
all: false,
|
||||
version: true,
|
||||
errorsCount: true,
|
||||
warningsCount: true
|
||||
},
|
||||
none: {
|
||||
all: false
|
||||
}
|
||||
};
|
||||
|
||||
const NORMAL_ON = ({ all }) => all !== false;
|
||||
const NORMAL_OFF = ({ all }) => all === true;
|
||||
const ON_FOR_TO_STRING = ({ all }, { forToString }) =>
|
||||
forToString ? all !== false : all === true;
|
||||
const OFF_FOR_TO_STRING = ({ all }, { forToString }) =>
|
||||
forToString ? all === true : all !== false;
|
||||
const AUTO_FOR_TO_STRING = ({ all }, { forToString }) => {
|
||||
if (all === false) return false;
|
||||
if (all === true) return true;
|
||||
if (forToString) return "auto";
|
||||
return true;
|
||||
};
|
||||
|
||||
/** @type {Record<string, (options: StatsOptions, context: CreateStatsOptionsContext, compilation: Compilation) => any>} */
|
||||
const DEFAULTS = {
|
||||
context: (options, context, compilation) => compilation.compiler.context,
|
||||
requestShortener: (options, context, compilation) =>
|
||||
compilation.compiler.context === options.context
|
||||
? compilation.requestShortener
|
||||
: new RequestShortener(options.context, compilation.compiler.root),
|
||||
performance: NORMAL_ON,
|
||||
hash: OFF_FOR_TO_STRING,
|
||||
env: NORMAL_OFF,
|
||||
version: NORMAL_ON,
|
||||
timings: NORMAL_ON,
|
||||
builtAt: OFF_FOR_TO_STRING,
|
||||
assets: NORMAL_ON,
|
||||
entrypoints: AUTO_FOR_TO_STRING,
|
||||
chunkGroups: OFF_FOR_TO_STRING,
|
||||
chunkGroupAuxiliary: OFF_FOR_TO_STRING,
|
||||
chunkGroupChildren: OFF_FOR_TO_STRING,
|
||||
chunkGroupMaxAssets: (o, { forToString }) => (forToString ? 5 : Infinity),
|
||||
chunks: OFF_FOR_TO_STRING,
|
||||
chunkRelations: OFF_FOR_TO_STRING,
|
||||
chunkModules: ({ all, modules }) => {
|
||||
if (all === false) return false;
|
||||
if (all === true) return true;
|
||||
if (modules) return false;
|
||||
return true;
|
||||
},
|
||||
dependentModules: OFF_FOR_TO_STRING,
|
||||
chunkOrigins: OFF_FOR_TO_STRING,
|
||||
ids: OFF_FOR_TO_STRING,
|
||||
modules: ({ all, chunks, chunkModules }, { forToString }) => {
|
||||
if (all === false) return false;
|
||||
if (all === true) return true;
|
||||
if (forToString && chunks && chunkModules) return false;
|
||||
return true;
|
||||
},
|
||||
nestedModules: OFF_FOR_TO_STRING,
|
||||
groupModulesByType: ON_FOR_TO_STRING,
|
||||
groupModulesByCacheStatus: ON_FOR_TO_STRING,
|
||||
groupModulesByLayer: ON_FOR_TO_STRING,
|
||||
groupModulesByAttributes: ON_FOR_TO_STRING,
|
||||
groupModulesByPath: ON_FOR_TO_STRING,
|
||||
groupModulesByExtension: ON_FOR_TO_STRING,
|
||||
modulesSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
|
||||
chunkModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
|
||||
nestedModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
|
||||
relatedAssets: OFF_FOR_TO_STRING,
|
||||
groupAssetsByEmitStatus: ON_FOR_TO_STRING,
|
||||
groupAssetsByInfo: ON_FOR_TO_STRING,
|
||||
groupAssetsByPath: ON_FOR_TO_STRING,
|
||||
groupAssetsByExtension: ON_FOR_TO_STRING,
|
||||
groupAssetsByChunk: ON_FOR_TO_STRING,
|
||||
assetsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
|
||||
orphanModules: OFF_FOR_TO_STRING,
|
||||
runtimeModules: ({ all, runtime }, { forToString }) =>
|
||||
runtime !== undefined
|
||||
? runtime
|
||||
: forToString
|
||||
? all === true
|
||||
: all !== false,
|
||||
cachedModules: ({ all, cached }, { forToString }) =>
|
||||
cached !== undefined ? cached : forToString ? all === true : all !== false,
|
||||
moduleAssets: OFF_FOR_TO_STRING,
|
||||
depth: OFF_FOR_TO_STRING,
|
||||
cachedAssets: OFF_FOR_TO_STRING,
|
||||
reasons: OFF_FOR_TO_STRING,
|
||||
reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
|
||||
groupReasonsByOrigin: ON_FOR_TO_STRING,
|
||||
usedExports: OFF_FOR_TO_STRING,
|
||||
providedExports: OFF_FOR_TO_STRING,
|
||||
optimizationBailout: OFF_FOR_TO_STRING,
|
||||
children: OFF_FOR_TO_STRING,
|
||||
source: NORMAL_OFF,
|
||||
moduleTrace: NORMAL_ON,
|
||||
errors: NORMAL_ON,
|
||||
errorsCount: NORMAL_ON,
|
||||
errorDetails: AUTO_FOR_TO_STRING,
|
||||
errorStack: OFF_FOR_TO_STRING,
|
||||
warnings: NORMAL_ON,
|
||||
warningsCount: NORMAL_ON,
|
||||
publicPath: OFF_FOR_TO_STRING,
|
||||
logging: ({ all }, { forToString }) =>
|
||||
forToString && all !== false ? "info" : false,
|
||||
loggingDebug: () => [],
|
||||
loggingTrace: OFF_FOR_TO_STRING,
|
||||
excludeModules: () => [],
|
||||
excludeAssets: () => [],
|
||||
modulesSort: () => "depth",
|
||||
chunkModulesSort: () => "name",
|
||||
nestedModulesSort: () => false,
|
||||
chunksSort: () => false,
|
||||
assetsSort: () => "!size",
|
||||
outputPath: OFF_FOR_TO_STRING,
|
||||
colors: () => false
|
||||
};
|
||||
|
||||
const normalizeFilter = item => {
|
||||
if (typeof item === "string") {
|
||||
const regExp = new RegExp(
|
||||
`[\\\\/]${item.replace(
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
/[-[\]{}()*+?.\\^$|]/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;
|
||||
}
|
||||
};
|
||||
|
||||
const NORMALIZER = {
|
||||
excludeModules: value => {
|
||||
if (!Array.isArray(value)) {
|
||||
value = value ? [value] : [];
|
||||
}
|
||||
return value.map(normalizeFilter);
|
||||
},
|
||||
excludeAssets: value => {
|
||||
if (!Array.isArray(value)) {
|
||||
value = value ? [value] : [];
|
||||
}
|
||||
return value.map(normalizeFilter);
|
||||
},
|
||||
warningsFilter: value => {
|
||||
if (!Array.isArray(value)) {
|
||||
value = value ? [value] : [];
|
||||
}
|
||||
return value.map(filter => {
|
||||
if (typeof filter === "string") {
|
||||
return (warning, warningString) => warningString.includes(filter);
|
||||
}
|
||||
if (filter instanceof RegExp) {
|
||||
return (warning, warningString) => filter.test(warningString);
|
||||
}
|
||||
if (typeof filter === "function") {
|
||||
return filter;
|
||||
}
|
||||
throw new Error(
|
||||
`Can only filter warnings with Strings or RegExps. (Given: ${filter})`
|
||||
);
|
||||
});
|
||||
},
|
||||
logging: value => {
|
||||
if (value === true) value = "log";
|
||||
return value;
|
||||
},
|
||||
loggingDebug: value => {
|
||||
if (!Array.isArray(value)) {
|
||||
value = value ? [value] : [];
|
||||
}
|
||||
return value.map(normalizeFilter);
|
||||
}
|
||||
};
|
||||
|
||||
class DefaultStatsPresetPlugin {
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap("DefaultStatsPresetPlugin", compilation => {
|
||||
for (const key of Object.keys(NAMED_PRESETS)) {
|
||||
const defaults = NAMED_PRESETS[key];
|
||||
compilation.hooks.statsPreset
|
||||
.for(key)
|
||||
.tap("DefaultStatsPresetPlugin", (options, context) => {
|
||||
applyDefaults(options, defaults);
|
||||
});
|
||||
}
|
||||
compilation.hooks.statsNormalize.tap(
|
||||
"DefaultStatsPresetPlugin",
|
||||
(options, context) => {
|
||||
for (const key of Object.keys(DEFAULTS)) {
|
||||
if (options[key] === undefined)
|
||||
options[key] = DEFAULTS[key](options, context, compilation);
|
||||
}
|
||||
for (const key of Object.keys(NORMALIZER)) {
|
||||
options[key] = NORMALIZER[key](options[key]);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = DefaultStatsPresetPlugin;
|
1423
my-app/node_modules/webpack/lib/stats/DefaultStatsPrinterPlugin.js
generated
vendored
Executable file
1423
my-app/node_modules/webpack/lib/stats/DefaultStatsPrinterPlugin.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
292
my-app/node_modules/webpack/lib/stats/StatsFactory.js
generated
vendored
Executable file
292
my-app/node_modules/webpack/lib/stats/StatsFactory.js
generated
vendored
Executable file
|
@ -0,0 +1,292 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { HookMap, SyncBailHook, SyncWaterfallHook } = require("tapable");
|
||||
const { concatComparators, keepOriginalOrder } = require("../util/comparators");
|
||||
const smartGrouping = require("../util/smartGrouping");
|
||||
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/** @typedef {import("../util/smartGrouping").GroupConfig<any, object>} GroupConfig */
|
||||
|
||||
/**
|
||||
* @typedef {Object} KnownStatsFactoryContext
|
||||
* @property {string} type
|
||||
* @property {function(string): string=} makePathsRelative
|
||||
* @property {Compilation=} compilation
|
||||
* @property {Set<Module>=} rootModules
|
||||
* @property {Map<string,Chunk[]>=} compilationFileToChunks
|
||||
* @property {Map<string,Chunk[]>=} compilationAuxiliaryFileToChunks
|
||||
* @property {RuntimeSpec=} runtime
|
||||
* @property {function(Compilation): WebpackError[]=} cachedGetErrors
|
||||
* @property {function(Compilation): WebpackError[]=} cachedGetWarnings
|
||||
*/
|
||||
|
||||
/** @typedef {KnownStatsFactoryContext & Record<string, any>} StatsFactoryContext */
|
||||
|
||||
class StatsFactory {
|
||||
constructor() {
|
||||
this.hooks = Object.freeze({
|
||||
/** @type {HookMap<SyncBailHook<[Object, any, StatsFactoryContext]>>} */
|
||||
extract: new HookMap(
|
||||
() => new SyncBailHook(["object", "data", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsFactoryContext, number, number]>>} */
|
||||
filter: new HookMap(
|
||||
() => new SyncBailHook(["item", "context", "index", "unfilteredIndex"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[(function(any, any): number)[], StatsFactoryContext]>>} */
|
||||
sort: new HookMap(() => new SyncBailHook(["comparators", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsFactoryContext, number, number]>>} */
|
||||
filterSorted: new HookMap(
|
||||
() => new SyncBailHook(["item", "context", "index", "unfilteredIndex"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[GroupConfig[], StatsFactoryContext]>>} */
|
||||
groupResults: new HookMap(
|
||||
() => new SyncBailHook(["groupConfigs", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[(function(any, any): number)[], StatsFactoryContext]>>} */
|
||||
sortResults: new HookMap(
|
||||
() => new SyncBailHook(["comparators", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsFactoryContext, number, number]>>} */
|
||||
filterResults: new HookMap(
|
||||
() => new SyncBailHook(["item", "context", "index", "unfilteredIndex"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[any[], StatsFactoryContext]>>} */
|
||||
merge: new HookMap(() => new SyncBailHook(["items", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[any[], StatsFactoryContext]>>} */
|
||||
result: new HookMap(() => new SyncWaterfallHook(["result", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsFactoryContext]>>} */
|
||||
getItemName: new HookMap(() => new SyncBailHook(["item", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsFactoryContext]>>} */
|
||||
getItemFactory: new HookMap(() => new SyncBailHook(["item", "context"]))
|
||||
});
|
||||
const hooks = this.hooks;
|
||||
this._caches =
|
||||
/** @type {Record<keyof typeof hooks, Map<string, SyncBailHook<[any[], StatsFactoryContext]>[]>>} */ ({});
|
||||
for (const key of Object.keys(hooks)) {
|
||||
this._caches[key] = new Map();
|
||||
}
|
||||
this._inCreate = false;
|
||||
}
|
||||
|
||||
_getAllLevelHooks(hookMap, cache, type) {
|
||||
const cacheEntry = cache.get(type);
|
||||
if (cacheEntry !== undefined) {
|
||||
return cacheEntry;
|
||||
}
|
||||
const hooks = [];
|
||||
const typeParts = type.split(".");
|
||||
for (let i = 0; i < typeParts.length; i++) {
|
||||
const hook = hookMap.get(typeParts.slice(i).join("."));
|
||||
if (hook) {
|
||||
hooks.push(hook);
|
||||
}
|
||||
}
|
||||
cache.set(type, hooks);
|
||||
return hooks;
|
||||
}
|
||||
|
||||
_forEachLevel(hookMap, cache, type, fn) {
|
||||
for (const hook of this._getAllLevelHooks(hookMap, cache, type)) {
|
||||
const result = fn(hook);
|
||||
if (result !== undefined) return result;
|
||||
}
|
||||
}
|
||||
|
||||
_forEachLevelWaterfall(hookMap, cache, type, data, fn) {
|
||||
for (const hook of this._getAllLevelHooks(hookMap, cache, type)) {
|
||||
data = fn(hook, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
_forEachLevelFilter(hookMap, cache, type, items, fn, forceClone) {
|
||||
const hooks = this._getAllLevelHooks(hookMap, cache, type);
|
||||
if (hooks.length === 0) return forceClone ? items.slice() : items;
|
||||
let i = 0;
|
||||
return items.filter((item, idx) => {
|
||||
for (const hook of hooks) {
|
||||
const r = fn(hook, item, idx, i);
|
||||
if (r !== undefined) {
|
||||
if (r) i++;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type type
|
||||
* @param {any} data factory data
|
||||
* @param {Omit<StatsFactoryContext, "type">} baseContext context used as base
|
||||
* @returns {any} created object
|
||||
*/
|
||||
create(type, data, baseContext) {
|
||||
if (this._inCreate) {
|
||||
return this._create(type, data, baseContext);
|
||||
} else {
|
||||
try {
|
||||
this._inCreate = true;
|
||||
return this._create(type, data, baseContext);
|
||||
} finally {
|
||||
for (const key of Object.keys(this._caches)) this._caches[key].clear();
|
||||
this._inCreate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_create(type, data, baseContext) {
|
||||
const context = {
|
||||
...baseContext,
|
||||
type,
|
||||
[type]: data
|
||||
};
|
||||
if (Array.isArray(data)) {
|
||||
// run filter on unsorted items
|
||||
const items = this._forEachLevelFilter(
|
||||
this.hooks.filter,
|
||||
this._caches.filter,
|
||||
type,
|
||||
data,
|
||||
(h, r, idx, i) => h.call(r, context, idx, i),
|
||||
true
|
||||
);
|
||||
|
||||
// sort items
|
||||
const comparators = [];
|
||||
this._forEachLevel(this.hooks.sort, this._caches.sort, type, h =>
|
||||
h.call(comparators, context)
|
||||
);
|
||||
if (comparators.length > 0) {
|
||||
items.sort(
|
||||
// @ts-expect-error number of arguments is correct
|
||||
concatComparators(...comparators, keepOriginalOrder(items))
|
||||
);
|
||||
}
|
||||
|
||||
// run filter on sorted items
|
||||
const items2 = this._forEachLevelFilter(
|
||||
this.hooks.filterSorted,
|
||||
this._caches.filterSorted,
|
||||
type,
|
||||
items,
|
||||
(h, r, idx, i) => h.call(r, context, idx, i),
|
||||
false
|
||||
);
|
||||
|
||||
// for each item
|
||||
let resultItems = items2.map((item, i) => {
|
||||
const itemContext = {
|
||||
...context,
|
||||
_index: i
|
||||
};
|
||||
|
||||
// run getItemName
|
||||
const itemName = this._forEachLevel(
|
||||
this.hooks.getItemName,
|
||||
this._caches.getItemName,
|
||||
`${type}[]`,
|
||||
h => h.call(item, itemContext)
|
||||
);
|
||||
if (itemName) itemContext[itemName] = item;
|
||||
const innerType = itemName ? `${type}[].${itemName}` : `${type}[]`;
|
||||
|
||||
// run getItemFactory
|
||||
const itemFactory =
|
||||
this._forEachLevel(
|
||||
this.hooks.getItemFactory,
|
||||
this._caches.getItemFactory,
|
||||
innerType,
|
||||
h => h.call(item, itemContext)
|
||||
) || this;
|
||||
|
||||
// run item factory
|
||||
return itemFactory.create(innerType, item, itemContext);
|
||||
});
|
||||
|
||||
// sort result items
|
||||
const comparators2 = [];
|
||||
this._forEachLevel(
|
||||
this.hooks.sortResults,
|
||||
this._caches.sortResults,
|
||||
type,
|
||||
h => h.call(comparators2, context)
|
||||
);
|
||||
if (comparators2.length > 0) {
|
||||
resultItems.sort(
|
||||
// @ts-expect-error number of arguments is correct
|
||||
concatComparators(...comparators2, keepOriginalOrder(resultItems))
|
||||
);
|
||||
}
|
||||
|
||||
// group result items
|
||||
const groupConfigs = [];
|
||||
this._forEachLevel(
|
||||
this.hooks.groupResults,
|
||||
this._caches.groupResults,
|
||||
type,
|
||||
h => h.call(groupConfigs, context)
|
||||
);
|
||||
if (groupConfigs.length > 0) {
|
||||
resultItems = smartGrouping(resultItems, groupConfigs);
|
||||
}
|
||||
|
||||
// run filter on sorted result items
|
||||
const finalResultItems = this._forEachLevelFilter(
|
||||
this.hooks.filterResults,
|
||||
this._caches.filterResults,
|
||||
type,
|
||||
resultItems,
|
||||
(h, r, idx, i) => h.call(r, context, idx, i),
|
||||
false
|
||||
);
|
||||
|
||||
// run merge on mapped items
|
||||
let result = this._forEachLevel(
|
||||
this.hooks.merge,
|
||||
this._caches.merge,
|
||||
type,
|
||||
h => h.call(finalResultItems, context)
|
||||
);
|
||||
if (result === undefined) result = finalResultItems;
|
||||
|
||||
// run result on merged items
|
||||
return this._forEachLevelWaterfall(
|
||||
this.hooks.result,
|
||||
this._caches.result,
|
||||
type,
|
||||
result,
|
||||
(h, r) => h.call(r, context)
|
||||
);
|
||||
} else {
|
||||
const object = {};
|
||||
|
||||
// run extract on value
|
||||
this._forEachLevel(this.hooks.extract, this._caches.extract, type, h =>
|
||||
h.call(object, data, context)
|
||||
);
|
||||
|
||||
// run result on extracted object
|
||||
return this._forEachLevelWaterfall(
|
||||
this.hooks.result,
|
||||
this._caches.result,
|
||||
type,
|
||||
object,
|
||||
(h, r) => h.call(r, context)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = StatsFactory;
|
249
my-app/node_modules/webpack/lib/stats/StatsPrinter.js
generated
vendored
Executable file
249
my-app/node_modules/webpack/lib/stats/StatsPrinter.js
generated
vendored
Executable file
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
|
||||
|
||||
/** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
|
||||
/** @typedef {import("tapable").Hook} Hook */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModule} StatsModule */
|
||||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleReason} StatsModuleReason */
|
||||
|
||||
/**
|
||||
* @typedef {Object} PrintedElement
|
||||
* @property {string} element
|
||||
* @property {string} content
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} KnownStatsPrinterContext
|
||||
* @property {string=} type
|
||||
* @property {StatsCompilation=} compilation
|
||||
* @property {StatsChunkGroup=} chunkGroup
|
||||
* @property {StatsAsset=} asset
|
||||
* @property {StatsModule=} module
|
||||
* @property {StatsChunk=} chunk
|
||||
* @property {StatsModuleReason=} moduleReason
|
||||
* @property {(str: string) => string=} bold
|
||||
* @property {(str: string) => string=} yellow
|
||||
* @property {(str: string) => string=} red
|
||||
* @property {(str: string) => string=} green
|
||||
* @property {(str: string) => string=} magenta
|
||||
* @property {(str: string) => string=} cyan
|
||||
* @property {(file: string, oversize?: boolean) => string=} formatFilename
|
||||
* @property {(id: string) => string=} formatModuleId
|
||||
* @property {(id: string, direction?: "parent"|"child"|"sibling") => string=} formatChunkId
|
||||
* @property {(size: number) => string=} formatSize
|
||||
* @property {(dateTime: number) => string=} formatDateTime
|
||||
* @property {(flag: string) => string=} formatFlag
|
||||
* @property {(time: number, boldQuantity?: boolean) => string=} formatTime
|
||||
* @property {string=} chunkGroupKind
|
||||
*/
|
||||
|
||||
/** @typedef {KnownStatsPrinterContext & Record<string, any>} StatsPrinterContext */
|
||||
|
||||
class StatsPrinter {
|
||||
constructor() {
|
||||
this.hooks = Object.freeze({
|
||||
/** @type {HookMap<SyncBailHook<[string[], StatsPrinterContext], true>>} */
|
||||
sortElements: new HookMap(
|
||||
() => new SyncBailHook(["elements", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[PrintedElement[], StatsPrinterContext], string>>} */
|
||||
printElements: new HookMap(
|
||||
() => new SyncBailHook(["printedElements", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[any[], StatsPrinterContext], true>>} */
|
||||
sortItems: new HookMap(() => new SyncBailHook(["items", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[any, StatsPrinterContext], string>>} */
|
||||
getItemName: new HookMap(() => new SyncBailHook(["item", "context"])),
|
||||
/** @type {HookMap<SyncBailHook<[string[], StatsPrinterContext], string>>} */
|
||||
printItems: new HookMap(
|
||||
() => new SyncBailHook(["printedItems", "context"])
|
||||
),
|
||||
/** @type {HookMap<SyncBailHook<[{}, StatsPrinterContext], string>>} */
|
||||
print: new HookMap(() => new SyncBailHook(["object", "context"])),
|
||||
/** @type {HookMap<SyncWaterfallHook<[string, StatsPrinterContext]>>} */
|
||||
result: new HookMap(() => new SyncWaterfallHook(["result", "context"]))
|
||||
});
|
||||
/** @type {Map<HookMap<Hook>, Map<string, Hook[]>>} */
|
||||
this._levelHookCache = new Map();
|
||||
this._inPrint = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all level hooks
|
||||
* @private
|
||||
* @template {Hook} T
|
||||
* @param {HookMap<T>} hookMap HookMap
|
||||
* @param {string} type type
|
||||
* @returns {T[]} hooks
|
||||
*/
|
||||
_getAllLevelHooks(hookMap, type) {
|
||||
let cache = /** @type {Map<string, T[]>} */ (
|
||||
this._levelHookCache.get(hookMap)
|
||||
);
|
||||
if (cache === undefined) {
|
||||
cache = new Map();
|
||||
this._levelHookCache.set(hookMap, cache);
|
||||
}
|
||||
const cacheEntry = cache.get(type);
|
||||
if (cacheEntry !== undefined) {
|
||||
return cacheEntry;
|
||||
}
|
||||
/** @type {T[]} */
|
||||
const hooks = [];
|
||||
const typeParts = type.split(".");
|
||||
for (let i = 0; i < typeParts.length; i++) {
|
||||
const hook = hookMap.get(typeParts.slice(i).join("."));
|
||||
if (hook) {
|
||||
hooks.push(hook);
|
||||
}
|
||||
}
|
||||
cache.set(type, hooks);
|
||||
return hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `fn` for each level
|
||||
* @private
|
||||
* @template T
|
||||
* @template R
|
||||
* @param {HookMap<SyncBailHook<T, R>>} hookMap HookMap
|
||||
* @param {string} type type
|
||||
* @param {(hook: SyncBailHook<T, R>) => R} fn function
|
||||
* @returns {R} result of `fn`
|
||||
*/
|
||||
_forEachLevel(hookMap, type, fn) {
|
||||
for (const hook of this._getAllLevelHooks(hookMap, type)) {
|
||||
const result = fn(hook);
|
||||
if (result !== undefined) return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `fn` for each level
|
||||
* @private
|
||||
* @template T
|
||||
* @param {HookMap<SyncWaterfallHook<T>>} hookMap HookMap
|
||||
* @param {string} type type
|
||||
* @param {AsArray<T>[0]} data data
|
||||
* @param {(hook: SyncWaterfallHook<T>, data: AsArray<T>[0]) => AsArray<T>[0]} fn function
|
||||
* @returns {AsArray<T>[0]} result of `fn`
|
||||
*/
|
||||
_forEachLevelWaterfall(hookMap, type, data, fn) {
|
||||
for (const hook of this._getAllLevelHooks(hookMap, type)) {
|
||||
data = fn(hook, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type The type
|
||||
* @param {Object} object Object to print
|
||||
* @param {Object=} baseContext The base context
|
||||
* @returns {string} printed result
|
||||
*/
|
||||
print(type, object, baseContext) {
|
||||
if (this._inPrint) {
|
||||
return this._print(type, object, baseContext);
|
||||
} else {
|
||||
try {
|
||||
this._inPrint = true;
|
||||
return this._print(type, object, baseContext);
|
||||
} finally {
|
||||
this._levelHookCache.clear();
|
||||
this._inPrint = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {string} type type
|
||||
* @param {Object} object object
|
||||
* @param {Object=} baseContext context
|
||||
* @returns {string} printed result
|
||||
*/
|
||||
_print(type, object, baseContext) {
|
||||
const context = {
|
||||
...baseContext,
|
||||
type,
|
||||
[type]: object
|
||||
};
|
||||
|
||||
let printResult = this._forEachLevel(this.hooks.print, type, hook =>
|
||||
hook.call(object, context)
|
||||
);
|
||||
if (printResult === undefined) {
|
||||
if (Array.isArray(object)) {
|
||||
const sortedItems = object.slice();
|
||||
this._forEachLevel(this.hooks.sortItems, type, h =>
|
||||
h.call(sortedItems, context)
|
||||
);
|
||||
const printedItems = sortedItems.map((item, i) => {
|
||||
const itemContext = {
|
||||
...context,
|
||||
_index: i
|
||||
};
|
||||
const itemName = this._forEachLevel(
|
||||
this.hooks.getItemName,
|
||||
`${type}[]`,
|
||||
h => h.call(item, itemContext)
|
||||
);
|
||||
if (itemName) itemContext[itemName] = item;
|
||||
return this.print(
|
||||
itemName ? `${type}[].${itemName}` : `${type}[]`,
|
||||
item,
|
||||
itemContext
|
||||
);
|
||||
});
|
||||
printResult = this._forEachLevel(this.hooks.printItems, type, h =>
|
||||
h.call(printedItems, context)
|
||||
);
|
||||
if (printResult === undefined) {
|
||||
const result = printedItems.filter(Boolean);
|
||||
if (result.length > 0) printResult = result.join("\n");
|
||||
}
|
||||
} else if (object !== null && typeof object === "object") {
|
||||
const elements = Object.keys(object).filter(
|
||||
key => object[key] !== undefined
|
||||
);
|
||||
this._forEachLevel(this.hooks.sortElements, type, h =>
|
||||
h.call(elements, context)
|
||||
);
|
||||
const printedElements = elements.map(element => {
|
||||
const content = this.print(`${type}.${element}`, object[element], {
|
||||
...context,
|
||||
_parent: object,
|
||||
_element: element,
|
||||
[element]: object[element]
|
||||
});
|
||||
return { element, content };
|
||||
});
|
||||
printResult = this._forEachLevel(this.hooks.printElements, type, h =>
|
||||
h.call(printedElements, context)
|
||||
);
|
||||
if (printResult === undefined) {
|
||||
const result = printedElements.map(e => e.content).filter(Boolean);
|
||||
if (result.length > 0) printResult = result.join("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this._forEachLevelWaterfall(
|
||||
this.hooks.result,
|
||||
type,
|
||||
printResult,
|
||||
(h, r) => h.call(r, context)
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = StatsPrinter;
|
Loading…
Add table
Add a link
Reference in a new issue