Comparing version
@@ -137,3 +137,3 @@ /* | ||
* @typedef {object} APIPluginOptions | ||
* @property {boolean} [module] the output filename | ||
* @property {boolean=} module the output filename | ||
*/ | ||
@@ -143,3 +143,3 @@ | ||
/** | ||
* @param {APIPluginOptions} [options] options | ||
* @param {APIPluginOptions=} options options | ||
*/ | ||
@@ -146,0 +146,0 @@ constructor(options = {}) { |
@@ -259,2 +259,3 @@ /* | ||
/** @type {Map<RuntimeSpec, BlockModulesMap>} */ | ||
const blockModulesRuntimeMap = new Map(); | ||
@@ -292,3 +293,3 @@ | ||
* @param {RuntimeSpec} runtime runtime | ||
* @returns {BlockModulesInFlattenTuples} block modules in flatten tuples | ||
* @returns {BlockModulesInFlattenTuples | undefined} block modules in flatten tuples | ||
*/ | ||
@@ -298,2 +299,3 @@ const getBlockModules = (block, runtime) => { | ||
if (blockModulesMap === undefined) { | ||
/** @type {BlockModulesMap} */ | ||
blockModulesMap = new Map(); | ||
@@ -307,2 +309,3 @@ blockModulesRuntimeMap.set(runtime, blockModulesMap); | ||
if (memCache !== undefined) { | ||
/** @type {BlockModulesMap} */ | ||
const map = memCache.provide( | ||
@@ -1169,3 +1172,5 @@ "bundleChunkGraph.blockModules", | ||
const process = (current, visited) => { | ||
const blockModules = getBlockModules(current, runtime); | ||
const blockModules = | ||
/** @type {BlockModulesInFlattenTuples} */ | ||
(getBlockModules(current, runtime)); | ||
for (let i = 0, len = blockModules.length; i < len; i += 3) { | ||
@@ -1172,0 +1177,0 @@ const activeState = /** @type {ConnectionState} */ ( |
@@ -29,3 +29,3 @@ /* | ||
/** @typedef {TODO} Data */ | ||
/** @typedef {EXPECTED_ANY} Data */ | ||
@@ -32,0 +32,0 @@ /** |
@@ -132,3 +132,3 @@ /* | ||
/** @type {Promise<any>} */ | ||
/** @type {Promise<TODO>} */ | ||
let currentIdlePromise = resolvedPromise; | ||
@@ -135,0 +135,0 @@ let isIdle = false; |
@@ -11,2 +11,3 @@ /* | ||
/** @typedef {import("webpack-sources").Source} Source */ | ||
/** @typedef {import("../Cache").Data} Data */ | ||
/** @typedef {import("../Cache").Etag} Etag */ | ||
@@ -23,3 +24,3 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
apply(compiler) { | ||
/** @type {Map<string, { etag: Etag | null, data: any } | null>} */ | ||
/** @type {Map<string, { etag: Etag | null, data: Data } | null>} */ | ||
const cache = new Map(); | ||
@@ -26,0 +27,0 @@ compiler.cache.hooks.store.tap( |
@@ -11,2 +11,3 @@ /* | ||
/** @typedef {import("webpack-sources").Source} Source */ | ||
/** @typedef {import("../Cache").Data} Data */ | ||
/** @typedef {import("../Cache").Etag} Etag */ | ||
@@ -36,5 +37,5 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
const maxGenerations = this._maxGenerations; | ||
/** @type {Map<string, { etag: Etag | null, data: any } | undefined | null>} */ | ||
/** @type {Map<string, { etag: Etag | null, data: Data } | undefined | null>} */ | ||
const cache = new Map(); | ||
/** @type {Map<string, { entry: { etag: Etag | null, data: any } | null, until: number }>} */ | ||
/** @type {Map<string, { entry: { etag: Etag | null, data: Data } | null, until: number }>} */ | ||
const oldCache = new Map(); | ||
@@ -41,0 +42,0 @@ let generation = 0; |
@@ -21,2 +21,3 @@ /* | ||
/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */ | ||
/** @typedef {import("../Cache").Data} Data */ | ||
/** @typedef {import("../Cache").Etag} Etag */ | ||
@@ -100,5 +101,2 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
/** @typedef {TODO | undefined} Value */ | ||
/** @typedef {TODO | undefined} LazyValue */ | ||
class PackItemInfo { | ||
@@ -108,3 +106,3 @@ /** | ||
* @param {string | null | undefined} etag etag of item | ||
* @param {Value} value fresh value of item | ||
* @param {Data} value fresh value of item | ||
*/ | ||
@@ -164,3 +162,3 @@ constructor(identifier, etag, value) { | ||
* @param {string | null} etag etag of the resource | ||
* @returns {Value} cached content | ||
* @returns {Data} cached content | ||
*/ | ||
@@ -188,3 +186,3 @@ get(identifier, etag) { | ||
* @param {string | null} etag etag of the resource | ||
* @param {Value} data cached content | ||
* @param {Data} data cached content | ||
* @returns {void} | ||
@@ -675,3 +673,3 @@ */ | ||
/** @typedef {Map<string, Value>} Content */ | ||
/** @typedef {Map<string, Data>} Content */ | ||
@@ -808,3 +806,3 @@ class PackContentItems { | ||
/** @typedef {(() => Promise<PackContentItems> | PackContentItems)} LazyFunction */ | ||
/** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number }}>} LazyFunction */ | ||
@@ -840,3 +838,3 @@ class PackContent { | ||
this.items = items; | ||
/** @type {LazyValue} */ | ||
/** @type {LazyFunction | undefined} */ | ||
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined; | ||
@@ -888,6 +886,3 @@ /** @type {Content | undefined} */ | ||
this.content = map; | ||
this.lazy = SerializerMiddleware.unMemoizeLazy( | ||
/** @type {LazyFunction} */ | ||
(this.lazy) | ||
); | ||
this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy); | ||
return map.get(identifier); | ||
@@ -903,6 +898,3 @@ }); | ||
this.content = map; | ||
this.lazy = SerializerMiddleware.unMemoizeLazy( | ||
/** @type {LazyFunction} */ | ||
(this.lazy) | ||
); | ||
this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy); | ||
return map.get(identifier); | ||
@@ -979,4 +971,3 @@ } | ||
/** | ||
* @template T | ||
* @param {(item?: LazyValue) => (() => Promise<PackContentItems> | PackContentItems)} write write function | ||
* @param {(lazy: LazyFunction) => (() => PackContentItems | Promise<PackContentItems>)} write write function | ||
* @returns {void} | ||
@@ -1114,2 +1105,3 @@ */ | ||
}) { | ||
/** @type {import("../serialization/Serializer")<PackContainer, null, {}>} */ | ||
this.fileSerializer = createFileSerializer( | ||
@@ -1334,3 +1326,3 @@ fs, | ||
* @param {Etag | null} etag etag of the resource | ||
* @param {Value} data cached content | ||
* @param {Data} data cached content | ||
* @returns {Promise<void>} promise | ||
@@ -1349,3 +1341,3 @@ */ | ||
* @param {Etag | null} etag etag of the resource | ||
* @returns {Promise<Value>} promise to the cached content | ||
* @returns {Promise<Data>} promise to the cached content | ||
*/ | ||
@@ -1352,0 +1344,0 @@ restore(identifier, etag) { |
@@ -98,2 +98,4 @@ /* | ||
/** @typedef {NonNullable<ResolveContext["yield"]>} Yield */ | ||
class ResolverCachePlugin { | ||
@@ -257,3 +259,3 @@ /** | ||
const activeRequests = new Map(); | ||
/** @type {Map<string, [ActiveRequest, NonNullable<ResolveContext["yield"]>][]>} */ | ||
/** @type {Map<string, [ActiveRequest[], Yield[]]>} */ | ||
const activeRequestsWithYield = new Map(); | ||
@@ -264,3 +266,7 @@ const hook = | ||
hook.tap("ResolverCachePlugin", (resolver, options, userOptions) => { | ||
if (/** @type {TODO} */ (options).cache !== true) return; | ||
if ( | ||
/** @type {ResolveOptions & { cache: boolean }} */ | ||
(options).cache !== true | ||
) | ||
return; | ||
const optionsIdent = objectToString(userOptions, false); | ||
@@ -294,3 +300,3 @@ const cacheWithContext = | ||
activeRequest[1].push( | ||
/** @type {NonNullable<ResolveContext["yield"]>} */ | ||
/** @type {Yield} */ | ||
(resolveContext.yield) | ||
@@ -310,3 +316,3 @@ ); | ||
let callbacks; | ||
/** @type {NonNullable<ResolveContext["yield"]>[] | undefined} */ | ||
/** @type {Yield[] | undefined} */ | ||
let yields; | ||
@@ -327,3 +333,3 @@ | ||
)) { | ||
/** @type {NonNullable<ResolveContext["yield"]>} */ | ||
/** @type {Yield} */ | ||
(resolveContext.yield)(r); | ||
@@ -345,5 +351,3 @@ } | ||
const cb = definedCallbacks[i]; | ||
const yield_ = | ||
/** @type {NonNullable<ResolveContext["yield"]>[]} */ | ||
(yields)[i]; | ||
const yield_ = /** @type {Yield[]} */ (yields)[i]; | ||
if (result) | ||
@@ -434,10 +438,4 @@ for (const r of /** @type {ResolveRequest[]} */ ( | ||
callbacks = [callback]; | ||
yields = [ | ||
/** @type {NonNullable<ResolveContext["yield"]>} */ | ||
(resolveContext.yield) | ||
]; | ||
activeRequestsWithYield.set( | ||
identifier, | ||
/** @type {[any, any]} */ ([callbacks, yields]) | ||
); | ||
yields = [/** @type {Yield} */ (resolveContext.yield)]; | ||
activeRequestsWithYield.set(identifier, [callbacks, yields]); | ||
} else if (callbacks === undefined) { | ||
@@ -444,0 +442,0 @@ callbacks = [callback]; |
@@ -37,3 +37,5 @@ /* | ||
/** @typedef {string | null} ChunkName */ | ||
/** @typedef {number | string} ChunkId */ | ||
/** @typedef {SortableSet<string>} IdNameHints */ | ||
@@ -50,5 +52,5 @@ const ChunkFilesSet = createArrayToSetDeprecationSet("chunk.files"); | ||
* @typedef {object} ChunkMaps | ||
* @property {Record<string|number, string>} hash | ||
* @property {Record<string|number, Record<string, string>>} contentHash | ||
* @property {Record<string|number, string>} name | ||
* @property {Record<string | number, string>} hash | ||
* @property {Record<string | number, Record<string, string>>} contentHash | ||
* @property {Record<string | number, string>} name | ||
*/ | ||
@@ -71,3 +73,3 @@ | ||
/** | ||
* @param {(string | null)=} name of chunk being created, is optional (for subclasses) | ||
* @param {ChunkName=} name of chunk being created, is optional (for subclasses) | ||
* @param {boolean} backCompat enable backward-compatibility | ||
@@ -82,5 +84,5 @@ */ | ||
this.debugId = debugId++; | ||
/** @type {string | null | undefined} */ | ||
/** @type {ChunkName | undefined} */ | ||
this.name = name; | ||
/** @type {SortableSet<string>} */ | ||
/** @type {IdNameHints} */ | ||
this.idNameHints = new SortableSet(); | ||
@@ -703,3 +705,3 @@ /** @type {boolean} */ | ||
* @param {ChunkFilterPredicate=} filterFn function used to filter chunks | ||
* @returns {Record<string, (string | number)[]>} a record object of names to lists of child ids(?) | ||
* @returns {Record<string, ChunkId[]>} a record object of names to lists of child ids(?) | ||
*/ | ||
@@ -725,3 +727,4 @@ getChildIdsByOrders(chunkGraph, filterFn) { | ||
childGroup.options[ | ||
/** @type {keyof ChunkGroupOptions} */ (key) | ||
/** @type {keyof ChunkGroupOptions} */ | ||
(key) | ||
] | ||
@@ -744,3 +747,3 @@ ), | ||
}); | ||
/** @type {Set<string | number>} */ | ||
/** @type {Set<ChunkId>} */ | ||
const chunkIdSet = new Set(); | ||
@@ -747,0 +750,0 @@ for (const item of list) { |
@@ -47,7 +47,7 @@ /* | ||
* @typedef {object} ArgumentConfig | ||
* @property {string | undefined} description | ||
* @property {string} [negatedDescription] | ||
* @property {string=} description | ||
* @property {string=} negatedDescription | ||
* @property {string} path | ||
* @property {boolean} multiple | ||
* @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type | ||
* @property {"enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset"} type | ||
* @property {EnumValue[]=} values | ||
@@ -54,0 +54,0 @@ */ |
@@ -43,3 +43,3 @@ /* | ||
/** @typedef {import("./Chunk")} Chunk */ | ||
/** @typedef {import("./Compilation").References} References */ | ||
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ | ||
/** @typedef {import("./Dependency")} Dependency */ | ||
@@ -94,6 +94,7 @@ /** @typedef {import("./Module")} Module */ | ||
/** @typedef {{ sizeOnlySource: SizeOnlySource | undefined, writtenTo: Map<string, number> }} CacheEntry */ | ||
/** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: CacheEntry, file: string }[] | undefined) }} SimilarEntry */ | ||
/** @typedef {{ buildInfo: BuildInfo, references: References | undefined, memCache: import("./util/WeakTupleMap")<Module[], string> }} ModuleMemCachesItem */ | ||
/** @typedef {WeakMap<Dependency, Module>} WeakReferences */ | ||
/** @typedef {import("./util/WeakTupleMap")<EXPECTED_ANY[], EXPECTED_ANY>} MemCache */ | ||
/** @typedef {{ buildInfo: BuildInfo, references: WeakReferences | undefined, memCache: MemCache }} ModuleMemCachesItem */ | ||
@@ -100,0 +101,0 @@ /** |
@@ -169,3 +169,3 @@ /* | ||
* @param {WebpackOptionsNormalized} options options to be modified | ||
* @param {number} [compilerIndex] index of compiler | ||
* @param {number=} compilerIndex index of compiler | ||
* @returns {ResolvedOptions} Resolved options after apply defaults | ||
@@ -409,3 +409,3 @@ */ | ||
* @param {boolean} options.development is development mode | ||
* @param {number} [options.compilerIndex] index of compiler | ||
* @param {number=} options.compilerIndex index of compiler | ||
* @param {Experiments["cacheUnaffected"]} options.cacheUnaffected the cacheUnaffected experiment is enabled | ||
@@ -412,0 +412,0 @@ * @returns {void} |
@@ -25,8 +25,8 @@ /* | ||
* @typedef {object} PlatformTargetProperties | ||
* @property {boolean | null} [web] web platform, importing of http(s) and std: is available | ||
* @property {boolean | null} [browser] browser platform, running in a normal web browser | ||
* @property {boolean | null} [webworker] (Web)Worker platform, running in a web/shared/service worker | ||
* @property {boolean | null} [node] node platform, require of node built-in modules is available | ||
* @property {boolean | null} [nwjs] nwjs platform, require of legacy nw.gui is available | ||
* @property {boolean | null} [electron] electron platform, require of some electron built-in modules is available | ||
* @property {boolean | null=} web web platform, importing of http(s) and std: is available | ||
* @property {boolean | null=} browser browser platform, running in a normal web browser | ||
* @property {boolean | null=} webworker (Web)Worker platform, running in a web/shared/service worker | ||
* @property {boolean | null=} node node platform, require of node built-in modules is available | ||
* @property {boolean | null=} nwjs nwjs platform, require of legacy nw.gui is available | ||
* @property {boolean | null=} electron electron platform, require of some electron built-in modules is available | ||
*/ | ||
@@ -33,0 +33,0 @@ |
@@ -32,2 +32,3 @@ /* | ||
/** @typedef {import("webpack-sources").Source} Source */ | ||
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
@@ -87,3 +88,3 @@ /** @typedef {import("./Chunk")} Chunk */ | ||
* @property {string=} resourceFragment | ||
* @property {TODO} resolveOptions | ||
* @property {ResolveOptions=} resolveOptions | ||
*/ | ||
@@ -90,0 +91,0 @@ |
@@ -296,3 +296,3 @@ /* | ||
/** | ||
* @param {CssParserOptions} [options] options | ||
* @param {CssParserOptions=} options options | ||
*/ | ||
@@ -299,0 +299,0 @@ constructor({ |
@@ -91,3 +91,3 @@ /* | ||
* @param {string} method method name | ||
* @param {Record<string, EXPECTED_ANY>} [params] params | ||
* @param {Record<string, EXPECTED_ANY>=} params params | ||
* @returns {Promise<TODO>} Promise for the result | ||
@@ -94,0 +94,0 @@ */ |
@@ -45,3 +45,3 @@ /* | ||
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */ | ||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: [number, number], ...args: any[]): ContextDependency }} ContextDependencyConstructor */ | ||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: any[]): ContextDependency }} ContextDependencyConstructor */ | ||
@@ -48,0 +48,0 @@ /** |
@@ -19,2 +19,3 @@ /* | ||
/** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -30,8 +31,8 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
* @param {string} exportName export name | ||
* @param {[number, number]} range the range of dependency | ||
* @param {Range} range the range of dependency | ||
*/ | ||
constructor(request, exportName, range) { | ||
super(request); | ||
this.exportName = exportName; | ||
this.range = range; | ||
this.exportName = exportName; | ||
} | ||
@@ -38,0 +39,0 @@ |
@@ -30,3 +30,3 @@ /* | ||
* @param {string} prefix prefix | ||
* @param {string | { range: Range, prefix: string, suffix: string }} [declarationId] declaration id | ||
* @param {string | { range: Range, prefix: string, suffix: string }=} declarationId declaration id | ||
*/ | ||
@@ -33,0 +33,0 @@ constructor(range, rangeStatement, prefix, declarationId) { |
@@ -229,3 +229,4 @@ /* | ||
moduleGraph, | ||
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule | ||
/** @type {BuildMeta} */ | ||
(parentModule.buildMeta).strictHarmonyModule | ||
); | ||
@@ -232,0 +233,0 @@ |
@@ -51,3 +51,3 @@ /* | ||
* @property {boolean} await | ||
* @property {Record<string, any> | undefined} attributes | ||
* @property {ImportAttributes=} attributes | ||
*/ | ||
@@ -54,0 +54,0 @@ |
@@ -25,3 +25,3 @@ /* | ||
* @param {JsonValue} data raw json data | ||
* @param {number} [curDepth] current depth | ||
* @param {number=} curDepth current depth | ||
* @returns {ExportSpec[] | null} export spec or nothing | ||
@@ -28,0 +28,0 @@ */ |
@@ -53,3 +53,3 @@ /* | ||
* @param {string} name name | ||
* @param {string} [namedModule] named module | ||
* @param {string=} namedModule named module | ||
* @returns {LocalModule | null} local module or null | ||
@@ -56,0 +56,0 @@ */ |
@@ -22,3 +22,3 @@ /* | ||
* @param {Range} range location in source code | ||
* @param {string} [context] context | ||
* @param {string=} context context | ||
*/ | ||
@@ -25,0 +25,0 @@ constructor(request, range, context) { |
@@ -122,3 +122,3 @@ /* | ||
* @param {Expression} expr expression | ||
* @returns {[string, [number, number]] | void} parsed | ||
* @returns {[string, Range] | void} parsed | ||
*/ | ||
@@ -263,3 +263,3 @@ const parseModuleUrl = (parser, expr) => { | ||
let url; | ||
/** @type {[number, number]} */ | ||
/** @type {Range} */ | ||
let range; | ||
@@ -266,0 +266,0 @@ /** @type {boolean} */ |
@@ -76,6 +76,26 @@ /* | ||
// We need public path only when we prefetch/preload chunk or public path is not `auto` | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.prefetchChunkHandlers) | ||
.tap("ModuleChunkLoadingPlugin", (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) return; | ||
set.add(RuntimeGlobals.publicPath); | ||
}); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.preloadChunkHandlers) | ||
.tap("ModuleChunkLoadingPlugin", (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) return; | ||
set.add(RuntimeGlobals.publicPath); | ||
}); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.ensureChunkHandlers) | ||
.tap("ModuleChunkLoadingPlugin", (chunk, set) => { | ||
if (!isEnabledForChunk(chunk)) return; | ||
if (compilation.outputOptions.publicPath !== "auto") { | ||
set.add(RuntimeGlobals.publicPath); | ||
} | ||
set.add(RuntimeGlobals.getChunkScriptFilename); | ||
@@ -82,0 +102,0 @@ }); |
@@ -217,5 +217,7 @@ /* | ||
"// setup Promise in chunk cache", | ||
`var promise = ${importFunctionName}(${JSON.stringify( | ||
rootOutputDir | ||
)} + ${ | ||
`var promise = ${importFunctionName}(${ | ||
compilation.outputOptions.publicPath === "auto" | ||
? "" | ||
: `${RuntimeGlobals.publicPath} + ` | ||
}${JSON.stringify(rootOutputDir)} + ${ | ||
RuntimeGlobals.getChunkScriptFilename | ||
@@ -252,2 +254,5 @@ }(chunkId)).then(installChunk, ${runtimeTemplate.basicFunction( | ||
}.j = ${runtimeTemplate.basicFunction("chunkId", [ | ||
isNeutralPlatform | ||
? "if (typeof document === 'undefined') return;" | ||
: "", | ||
`if((!${ | ||
@@ -260,5 +265,2 @@ RuntimeGlobals.hasOwnProperty | ||
"installedChunks[chunkId] = null;", | ||
isNeutralPlatform | ||
? "if (typeof document === 'undefined') return;" | ||
: "", | ||
linkPrefetch.call( | ||
@@ -294,2 +296,5 @@ Template.asString([ | ||
}.j = ${runtimeTemplate.basicFunction("chunkId", [ | ||
isNeutralPlatform | ||
? "if (typeof document === 'undefined') return;" | ||
: "", | ||
`if((!${ | ||
@@ -302,5 +307,2 @@ RuntimeGlobals.hasOwnProperty | ||
"installedChunks[chunkId] = null;", | ||
isNeutralPlatform | ||
? "if (typeof document === 'undefined') return;" | ||
: "", | ||
linkPreload.call( | ||
@@ -307,0 +309,0 @@ Template.asString([ |
@@ -379,7 +379,7 @@ /* | ||
}); | ||
/** @type {TupleSet<[Module, Chunk]>} */ | ||
/** @type {TupleSet<Module, Chunk>} */ | ||
const updatedModules = new TupleSet(); | ||
/** @type {TupleSet<[Module, Chunk]>} */ | ||
/** @type {TupleSet<Module, Chunk>} */ | ||
const fullHashModules = new TupleSet(); | ||
/** @type {TupleSet<[Module, RuntimeSpec]>} */ | ||
/** @type {TupleSet<Module, RuntimeSpec>} */ | ||
const nonCodeGeneratedModules = new TupleSet(); | ||
@@ -386,0 +386,0 @@ compilation.hooks.fullHash.tap(PLUGIN_NAME, hash => { |
@@ -26,3 +26,3 @@ /* | ||
/** | ||
* @param {DeterministicChunkIdsPluginOptions} [options] options | ||
* @param {DeterministicChunkIdsPluginOptions=} options options | ||
*/ | ||
@@ -29,0 +29,0 @@ constructor(options = {}) { |
@@ -32,3 +32,3 @@ /* | ||
/** | ||
* @param {DeterministicModuleIdsPluginOptions} [options] options | ||
* @param {DeterministicModuleIdsPluginOptions=} options options | ||
*/ | ||
@@ -35,0 +35,0 @@ constructor(options = {}) { |
@@ -24,4 +24,4 @@ /* | ||
* @typedef {object} NamedChunkIdsPluginOptions | ||
* @property {string} [context] context | ||
* @property {string} [delimiter] delimiter | ||
* @property {string=} context context | ||
* @property {string=} delimiter delimiter | ||
*/ | ||
@@ -28,0 +28,0 @@ |
@@ -23,3 +23,3 @@ /* | ||
* @typedef {object} NamedModuleIdsPluginOptions | ||
* @property {string} [context] context | ||
* @property {string=} context context | ||
*/ | ||
@@ -29,3 +29,3 @@ | ||
/** | ||
* @param {NamedModuleIdsPluginOptions} [options] options | ||
* @param {NamedModuleIdsPluginOptions=} options options | ||
*/ | ||
@@ -32,0 +32,0 @@ constructor(options = {}) { |
@@ -73,3 +73,3 @@ /* | ||
const fac = memoize(factory); | ||
const f = /** @type {any} */ ( | ||
const f = /** @type {unknown} */ ( | ||
/** | ||
@@ -76,0 +76,0 @@ * @param {...EXPECTED_ANY} args args |
@@ -182,3 +182,3 @@ /* | ||
* Gets the compile-time value of the expression | ||
* @returns {any} the javascript value | ||
* @returns {undefined | null | string | number | boolean | RegExp | EXPECTED_ANY[] | bigint} the javascript value | ||
*/ | ||
@@ -528,3 +528,3 @@ asCompileTimeValue() { | ||
* Set's the range for the expression. | ||
* @param {[number, number]} range range to set | ||
* @param {Range} range range to set | ||
* @returns {this} this | ||
@@ -531,0 +531,0 @@ */ |
@@ -16,2 +16,7 @@ /* | ||
/** | ||
* @typedef {object} EnableLibraryPluginOptions | ||
* @property {() => void=} additionalApply function that runs when applying the current plugin. | ||
*/ | ||
/** | ||
* @param {Compiler} compiler the compiler instance | ||
@@ -32,5 +37,9 @@ * @returns {Set<LibraryType>} enabled types | ||
* @param {LibraryType} type library type that should be available | ||
* @param {EnableLibraryPluginOptions} options options of EnableLibraryPlugin | ||
*/ | ||
constructor(type) { | ||
constructor(type, options = {}) { | ||
/** @type {LibraryType} */ | ||
this.type = type; | ||
/** @type {EnableLibraryPluginOptions} */ | ||
this.options = options; | ||
} | ||
@@ -72,3 +81,3 @@ | ||
apply(compiler) { | ||
const { type } = this; | ||
const { type, options } = this; | ||
@@ -80,2 +89,6 @@ // Only enable once | ||
if (typeof options.additionalApply === "function") { | ||
options.additionalApply(); | ||
} | ||
if (typeof type === "string") { | ||
@@ -82,0 +95,0 @@ const enableExportProperty = () => { |
@@ -190,3 +190,8 @@ /* | ||
if (finalName && (finalName.includes(".") || finalName.includes("["))) { | ||
if ( | ||
finalName && | ||
(finalName.includes(".") || | ||
finalName.includes("[") || | ||
finalName.includes("(")) | ||
) { | ||
exports.push([exportInfo.name, finalName]); | ||
@@ -193,0 +198,0 @@ } else { |
@@ -92,3 +92,2 @@ /* | ||
); | ||
/** @type {number} */ | ||
const loglevel = LogLevel[`${level}`] || 0; | ||
@@ -95,0 +94,0 @@ |
@@ -45,4 +45,2 @@ /* | ||
/** @typedef {import("./util/Hash")} Hash */ | ||
/** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */ | ||
/** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */ | ||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -53,2 +51,12 @@ /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */ | ||
/** | ||
* @template T | ||
* @typedef {import("./util/LazySet")<T>} LazySet<T> | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef {import("./util/SortableSet")<T>} SortableSet<T> | ||
*/ | ||
/** | ||
* @typedef {object} SourceContext | ||
@@ -55,0 +63,0 @@ * @property {DependencyTemplates} dependencyTemplates the dependency templates |
@@ -265,3 +265,3 @@ /* | ||
* @param {(duplicateItem: T, duplicateItemIndex: number, numberOfTimesReplaced: number) => T} fn callback function to generate new values for the duplicate items | ||
* @param {(firstElement:T, nextElement:T) => -1 | 0 | 1} [comparator] optional comparator function to sort the duplicate items | ||
* @param {(firstElement:T, nextElement:T) => -1 | 0 | 1=} comparator optional comparator function to sort the duplicate items | ||
* @returns {T[]} the array with duplicates replaced | ||
@@ -268,0 +268,0 @@ * @example |
@@ -146,3 +146,3 @@ /* | ||
/** | ||
* @type {WeakTupleMap<any[], any> | undefined} | ||
* @type {WeakTupleMap<EXPECTED_ANY[], EXPECTED_ANY> | undefined} | ||
* @private | ||
@@ -801,6 +801,6 @@ */ | ||
* @template T | ||
* @template V | ||
* @param {(moduleGraph: ModuleGraph, ...args: T[]) => V} fn computer | ||
* @template R | ||
* @param {(moduleGraph: ModuleGraph, ...args: T[]) => R} fn computer | ||
* @param {...T} args arguments | ||
* @returns {V} computed value or cached | ||
* @returns {R} computed value or cached | ||
*/ | ||
@@ -820,12 +820,17 @@ cached(fn, ...args) { | ||
/** | ||
* @param {Dependency} dependency dependency | ||
* @param {...any} args arguments, last argument is a function called with moduleGraph, dependency, ...args | ||
* @returns {any} computed value or cached | ||
* @template {Dependency} D | ||
* @template {EXPECTED_ANY[]} ARGS | ||
* @template R | ||
* @param {D} dependency dependency | ||
* @param {[...ARGS, (moduleGraph: ModuleGraph, dependency: D, ...args: ARGS) => R]} args arguments, last argument is a function called with moduleGraph, dependency, ...args | ||
* @returns {R} computed value or cached | ||
*/ | ||
dependencyCacheProvide(dependency, ...args) { | ||
/** @type {(moduleGraph: ModuleGraph, dependency: Dependency, ...args: any[]) => any} */ | ||
const fn = args.pop(); | ||
const fn = | ||
/** @type {(moduleGraph: ModuleGraph, dependency: D, ...args: EXPECTED_ANY[]) => R} */ | ||
(args.pop()); | ||
if (this._moduleMemCaches && this._cacheStage) { | ||
const memCache = this._moduleMemCaches.get( | ||
/** @type {Module} */ (this.getParentModule(dependency)) | ||
/** @type {Module} */ | ||
(this.getParentModule(dependency)) | ||
); | ||
@@ -832,0 +837,0 @@ if (memCache !== undefined) { |
@@ -16,3 +16,3 @@ /* | ||
* @typedef {object} CommonJsChunkLoadingPluginOptions | ||
* @property {boolean} [asyncChunkLoading] enable async chunk loading | ||
* @property {boolean=} asyncChunkLoading enable async chunk loading | ||
*/ | ||
@@ -22,3 +22,3 @@ | ||
/** | ||
* @param {CommonJsChunkLoadingPluginOptions} [options] options | ||
* @param {CommonJsChunkLoadingPluginOptions=} options options | ||
*/ | ||
@@ -25,0 +25,0 @@ constructor(options = {}) { |
@@ -15,3 +15,3 @@ /* | ||
* @typedef {object} NodeTemplatePluginOptions | ||
* @property {boolean} [asyncChunkLoading] enable async chunk loading | ||
* @property {boolean=} asyncChunkLoading enable async chunk loading | ||
*/ | ||
@@ -21,3 +21,3 @@ | ||
/** | ||
* @param {NodeTemplatePluginOptions} [options] options object | ||
* @param {NodeTemplatePluginOptions=} options options object | ||
*/ | ||
@@ -24,0 +24,0 @@ constructor(options = {}) { |
@@ -18,3 +18,3 @@ /* | ||
* @typedef {object} ReadFileCompileAsyncWasmPluginOptions | ||
* @property {boolean} [import] use import? | ||
* @property {boolean=} import use import? | ||
*/ | ||
@@ -26,3 +26,3 @@ | ||
/** | ||
* @param {ReadFileCompileAsyncWasmPluginOptions} [options] options object | ||
* @param {ReadFileCompileAsyncWasmPluginOptions=} options options object | ||
*/ | ||
@@ -29,0 +29,0 @@ constructor({ import: useImport = false } = {}) { |
@@ -18,4 +18,4 @@ /* | ||
* @typedef {object} ReadFileCompileWasmPluginOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean} [import] use import? | ||
* @property {boolean=} mangleImports mangle imports | ||
* @property {boolean=} import use import? | ||
*/ | ||
@@ -29,3 +29,3 @@ | ||
/** | ||
* @param {ReadFileCompileWasmPluginOptions} [options] options object | ||
* @param {ReadFileCompileWasmPluginOptions=} options options object | ||
*/ | ||
@@ -32,0 +32,0 @@ constructor(options = {}) { |
@@ -666,3 +666,3 @@ /* | ||
/** | ||
* @param {import("../declarations/LoaderContext").Schema} [schema] schema | ||
* @param {import("../declarations/LoaderContext").Schema=} schema schema | ||
* @returns {T} options | ||
@@ -669,0 +669,0 @@ */ |
@@ -20,3 +20,3 @@ /* | ||
/** | ||
* @param {AggressiveMergingPluginOptions=} [options] options object | ||
* @param {AggressiveMergingPluginOptions=} options options object | ||
*/ | ||
@@ -23,0 +23,0 @@ constructor(options) { |
@@ -29,2 +29,3 @@ /* | ||
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */ | ||
/** @typedef {import("../Chunk").ChunkName} ChunkName */ | ||
/** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
@@ -1391,3 +1392,3 @@ /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
/** @type {Chunk["name"] | undefined} */ | ||
/** @type {ChunkName | undefined} */ | ||
let chunkName = item.name; | ||
@@ -1394,0 +1395,0 @@ // Variable for the new chunk (lazy created) |
@@ -15,3 +15,3 @@ /* | ||
* @param {string} context context or request if context is not set | ||
* @param {string} [request] request | ||
* @param {string=} request request | ||
*/ | ||
@@ -18,0 +18,0 @@ constructor(context, request) { |
@@ -42,3 +42,3 @@ /* | ||
/** | ||
* @param {RecordIdsPluginOptions} [options] object | ||
* @param {RecordIdsPluginOptions=} options object | ||
*/ | ||
@@ -45,0 +45,0 @@ constructor(options) { |
@@ -13,2 +13,3 @@ /* | ||
/** @typedef {import("../Chunk")} Chunk */ | ||
/** @typedef {import("../Chunk").ChunkId} ChunkId */ | ||
/** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
@@ -160,3 +161,3 @@ /** @typedef {import("../Compilation")} Compilation */ | ||
chunk: { | ||
id: unquotedStringify(/** @type {number | string} */ (c.id)), | ||
id: unquotedStringify(/** @type {ChunkId} */ (c.id)), | ||
hash: unquotedStringify(/** @type {string} */ (c.renderedHash)), | ||
@@ -166,5 +167,3 @@ hashWithLength: unquotedStringifyWithLength( | ||
), | ||
name: unquotedStringify( | ||
c.name || /** @type {number | string} */ (c.id) | ||
), | ||
name: unquotedStringify(c.name || /** @type {ChunkId} */ (c.id)), | ||
contentHash: { | ||
@@ -171,0 +170,0 @@ [contentType]: unquotedStringify(c.contentHash[contentType]) |
@@ -10,11 +10,5 @@ /* | ||
/** @typedef {import("./SerializerMiddleware").Context} Context */ | ||
/** @typedef {import("./types").BufferSerializableType} BufferSerializableType */ | ||
/** @typedef {import("./types").PrimitiveSerializableType} PrimitiveSerializableType */ | ||
/** | ||
* @template LAZY_RESULT | ||
* @typedef {import("./SerializerMiddleware").LazyFunction<LAZY_RESULT>} LazyFunction | ||
*/ | ||
/* | ||
@@ -145,7 +139,15 @@ Format: | ||
/** @typedef {PrimitiveSerializableType[]} DeserializedType */ | ||
/** @typedef {BufferSerializableType[]} SerializedType} */ | ||
/** @typedef {{ retainedBuffer?: (x: Buffer) => Buffer }} Context} */ | ||
/** | ||
* @typedef {PrimitiveSerializableType[]} DeserializedType | ||
* @typedef {BufferSerializableType[]} SerializedType | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType>} | ||
* @template LazyInputValue | ||
* @template LazyOutputValue | ||
* @typedef {import("./SerializerMiddleware").LazyFunction<LazyInputValue, LazyOutputValue, BinaryMiddleware, undefined>} LazyFunction | ||
*/ | ||
/** | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>} | ||
*/ | ||
class BinaryMiddleware extends SerializerMiddleware { | ||
@@ -162,5 +164,5 @@ /** | ||
/** | ||
* @param {LazyFunction<DeserializedType>} fn lazy function | ||
* @param {LazyFunction<DeserializedType, SerializedType>} fn lazy function | ||
* @param {Context} context serialize function | ||
* @returns {LazyFunction<SerializedType>} new lazy | ||
* @returns {LazyFunction<SerializedType, DeserializedType>} new lazy | ||
*/ | ||
@@ -287,3 +289,3 @@ _serializeLazy(fn, context) { | ||
throw new Error(`Unexpected function ${thing}`); | ||
/** @type {SerializedType | LazyFunction<SerializedType>} */ | ||
/** @type {SerializedType | LazyFunction<SerializedType, DeserializedType> | undefined} */ | ||
let serializedData = | ||
@@ -301,14 +303,6 @@ SerializerMiddleware.getLazySerializedValue(thing); | ||
allocationScope.leftOverBuffer = null; | ||
SerializerMiddleware.setLazySerializedValue( | ||
/** @type {LazyFunction<DeserializedType>} */ | ||
(thing), | ||
data | ||
); | ||
SerializerMiddleware.setLazySerializedValue(thing, data); | ||
serializedData = data; | ||
} else { | ||
serializedData = this._serializeLazy( | ||
/** @type {LazyFunction<DeserializedType>} */ | ||
(thing), | ||
context | ||
); | ||
serializedData = this._serializeLazy(thing, context); | ||
flush(); | ||
@@ -674,3 +668,3 @@ buffers.push(serializedData); | ||
* @param {Context} context context object | ||
* @returns {LazyFunction<DeserializedType>} lazy function | ||
* @returns {LazyFunction<DeserializedType, SerializedType>} lazy function | ||
*/ | ||
@@ -688,5 +682,5 @@ _createLazyDeserialized(content, context) { | ||
* @private | ||
* @param {LazyFunction<SerializedType>} fn lazy function | ||
* @param {LazyFunction<SerializedType, DeserializedType>} fn lazy function | ||
* @param {Context} context context object | ||
* @returns {LazyFunction<DeserializedType>} new lazy | ||
* @returns {LazyFunction<DeserializedType, SerializedType>} new lazy | ||
*/ | ||
@@ -711,3 +705,2 @@ _deserializeLazy(fn, context) { | ||
/** @type {(x: Buffer) => Buffer} */ | ||
const retainedBuffer = context.retainedBuffer || (x => x); | ||
@@ -829,3 +822,3 @@ | ||
const lengths = Array.from({ length: count }).map(() => readU32()); | ||
/** @type {(Buffer | LazyFunction<BufferSerializableType[]>)[]} */ | ||
/** @type {(Buffer | LazyFunction<SerializedType, DeserializedType>)[]} */ | ||
const content = []; | ||
@@ -837,6 +830,3 @@ for (let l of lengths) { | ||
} | ||
content.push( | ||
/** @type {LazyFunction<BufferSerializableType[]>} */ | ||
(currentBuffer) | ||
); | ||
content.push(currentBuffer); | ||
currentDataItem++; | ||
@@ -1157,9 +1147,3 @@ currentBuffer = | ||
if (typeof currentBuffer === "function") { | ||
result.push( | ||
this._deserializeLazy( | ||
/** @type {LazyFunction<SerializedType>} */ | ||
(currentBuffer), | ||
context | ||
) | ||
); | ||
result.push(this._deserializeLazy(currentBuffer, context)); | ||
currentDataItem++; | ||
@@ -1166,0 +1150,0 @@ currentBuffer = |
@@ -25,10 +25,4 @@ /* | ||
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
/** @typedef {import("./SerializerMiddleware").Context} Context */ | ||
/** @typedef {import("./types").BufferSerializableType} BufferSerializableType */ | ||
/** | ||
* @template LAZY_RESULT | ||
* @typedef {import("./SerializerMiddleware").LazyFunction<LAZY_RESULT>} LazyFunction | ||
*/ | ||
/* | ||
@@ -99,5 +93,10 @@ Format: | ||
/** @typedef {{ name: string, size: number }} LazyOptions */ | ||
/** | ||
* @typedef {import("./SerializerMiddleware").LazyFunction<BufferSerializableType[], Buffer, FileMiddleware, LazyOptions>} LazyFunction | ||
*/ | ||
/** | ||
* @param {FileMiddleware} middleware this | ||
* @param {BufferSerializableType[] | Promise<BufferSerializableType[]>} data data to be serialized | ||
* @param {(BufferSerializableType | LazyFunction)[]} data data to be serialized | ||
* @param {string | boolean} name file base name | ||
@@ -117,3 +116,3 @@ * @param {(name: string | false, buffers: Buffer[], size: number) => Promise<void>} writeFile writes a file | ||
const processedData = []; | ||
/** @type {WeakMap<SerializeResult, LazyFunction<BufferSerializableType[]>>} */ | ||
/** @type {WeakMap<SerializeResult, LazyFunction>} */ | ||
const resultToLazy = new WeakMap(); | ||
@@ -144,10 +143,8 @@ /** @type {Buffer[] | undefined} */ | ||
if (content) { | ||
const options = SerializerMiddleware.getLazyOptions( | ||
/** @type {LazyFunction<Buffer[]>} */ | ||
(item) | ||
); | ||
const options = SerializerMiddleware.getLazyOptions(item); | ||
processedData.push( | ||
serialize( | ||
middleware, | ||
content, | ||
/** @type {BufferSerializableType[]} */ | ||
(content), | ||
(options && options.name) || true, | ||
@@ -157,9 +154,5 @@ writeFile, | ||
).then(result => { | ||
/** @type {LazyFunction<Buffer[]>} */ | ||
(item).options.size = result.size; | ||
resultToLazy.set( | ||
result, | ||
/** @type {LazyFunction<Buffer[]>} */ | ||
(item) | ||
); | ||
/** @type {LazyOptions} */ | ||
(item.options).size = result.size; | ||
resultToLazy.set(result, item); | ||
return result; | ||
@@ -201,3 +194,3 @@ }) | ||
const lazy = | ||
/** @type {LazyFunction<BufferSerializableType[]>} */ | ||
/** @type {LazyFunction} */ | ||
(resultToLazy.get(item)); | ||
@@ -360,3 +353,3 @@ SerializerMiddleware.setLazySerializedValue(lazy, buf); | ||
} | ||
/** @type {(Buffer | LazyFunction<BufferSerializableType[]>)[]} */ | ||
/** @type {BufferSerializableType[]} */ | ||
const result = []; | ||
@@ -369,9 +362,12 @@ for (let length of lengths) { | ||
const name = nameBuffer.toString(); | ||
/** @type {LazyFunction<BufferSerializableType[]>} */ | ||
const lazy = SerializerMiddleware.createLazy( | ||
memoize(() => deserialize(middleware, name, readFile)), | ||
middleware, | ||
{ name, size }, | ||
slice | ||
); | ||
const lazy = | ||
/** @type {LazyFunction} */ | ||
( | ||
SerializerMiddleware.createLazy( | ||
memoize(() => deserialize(middleware, name, readFile)), | ||
middleware, | ||
{ name, size }, | ||
slice | ||
) | ||
); | ||
result.push(lazy); | ||
@@ -434,8 +430,8 @@ } else { | ||
/** @typedef {{ filename: string, extension?: string }} FileMiddlewareContext */ | ||
/** @typedef {BufferSerializableType[]} DeserializedType */ | ||
/** @typedef {true} SerializedType */ | ||
/** @typedef {{ filename: string, extension?: string }} Context */ | ||
/** | ||
* @typedef {BufferSerializableType[]} DeserializedType | ||
* @typedef {true} SerializedType | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType>} | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>} | ||
*/ | ||
@@ -442,0 +438,0 @@ class FileMiddleware extends SerializerMiddleware { |
@@ -19,4 +19,5 @@ /* | ||
/** @typedef {import("../logging/Logger").Logger} Logger */ | ||
/** @typedef {typeof import("../util/Hash")} Hash */ | ||
/** @typedef {import("./SerializerMiddleware").Context} Context */ | ||
/** @typedef {import("./SerializerMiddleware").LazyOptions} LazyOptions */ | ||
/** @typedef {import("./types").ComplexSerializableType} ComplexSerializableType */ | ||
@@ -27,7 +28,2 @@ /** @typedef {import("./types").PrimitiveSerializableType} PrimitiveSerializableType */ | ||
/** | ||
* @template LAZY_RESULT | ||
* @typedef {import("./SerializerMiddleware").LazyFunction<LAZY_RESULT>} LazyFunction | ||
*/ | ||
/* | ||
@@ -64,11 +60,13 @@ | ||
*/ | ||
/** @typedef {TODO} Value */ | ||
/** @typedef {EXPECTED_OBJECT | string} ReferenceableItem */ | ||
/** | ||
* @typedef {object} ObjectSerializerContext | ||
* @property {(value: any) => void} write | ||
* @property {(value: any) => void} setCircularReference | ||
* @property {(value: Value) => void} write | ||
* @property {(value: ReferenceableItem) => void} setCircularReference | ||
* @property {() => ObjectSerializerSnapshot} snapshot | ||
* @property {(snapshot: ObjectSerializerSnapshot) => void} rollback | ||
* @property {((item: any) => void)=} writeLazy | ||
* @property {((item: any, obj?: TODO) => (() => Promise<any> | any))=} writeSeparate | ||
* @property {((item: Value | (() => Value)) => void)=} writeLazy | ||
* @property {((item: (Value | (() => Value)), obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY, LazyOptions>)=} writeSeparate | ||
*/ | ||
@@ -78,4 +76,4 @@ | ||
* @typedef {object} ObjectDeserializerContext | ||
* @property {() => any} read | ||
* @property {(value: any) => void} setCircularReference | ||
* @property {() => Value} read | ||
* @property {(value: ReferenceableItem) => void} setCircularReference | ||
*/ | ||
@@ -85,4 +83,4 @@ | ||
* @typedef {object} ObjectSerializer | ||
* @property {(value: any, context: ObjectSerializerContext) => void} serialize | ||
* @property {(context: ObjectDeserializerContext) => any} deserialize | ||
* @property {(value: Value, context: ObjectSerializerContext) => void} serialize | ||
* @property {(context: ObjectDeserializerContext) => Value} deserialize | ||
*/ | ||
@@ -149,4 +147,2 @@ | ||
/** @typedef {TODO} Item */ | ||
const jsTypes = new Map(); | ||
@@ -204,6 +200,8 @@ jsTypes.set(Object, new PlainObjectSerializer()); | ||
/** @typedef {ComplexSerializableType[]} DeserializedType */ | ||
/** @typedef {PrimitiveSerializableType[]} SerializedType */ | ||
/** @typedef {{ logger: Logger }} Context */ | ||
/** | ||
* @typedef {ComplexSerializableType[]} DeserializedType | ||
* @typedef {PrimitiveSerializableType[]} SerializedType | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType>} | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>} | ||
*/ | ||
@@ -276,3 +274,3 @@ class ObjectMiddleware extends SerializerMiddleware { | ||
/** | ||
* @param {TODO} object for serialization | ||
* @param {Constructor} object for serialization | ||
* @returns {SerializerConfigWithSerializer} Serializer config | ||
@@ -335,9 +333,9 @@ */ | ||
serialize(data, context) { | ||
/** @type {Item[]} */ | ||
/** @type {Value[]} */ | ||
let result = [CURRENT_VERSION]; | ||
let currentPos = 0; | ||
/** @type {Map<Item, number>} */ | ||
/** @type {Map<ReferenceableItem, number>} */ | ||
let referenceable = new Map(); | ||
/** | ||
* @param {Item} item referenceable item | ||
* @param {ReferenceableItem} item referenceable item | ||
*/ | ||
@@ -413,3 +411,3 @@ const addReferenceable = item => { | ||
/** | ||
* @param {Item} item item to stack | ||
* @param {Value} item item to stack | ||
* @returns {string} stack | ||
@@ -510,3 +508,3 @@ */ | ||
/** | ||
* @param {Item} item item to serialize | ||
* @param {Value} item item to serialize | ||
*/ | ||
@@ -601,5 +599,7 @@ const process = item => { | ||
throw new Error(`Unexpected function ${item}`); | ||
/** @type {SerializedType} */ | ||
/** @type {SerializedType | undefined} */ | ||
const serializedData = | ||
SerializerMiddleware.getLazySerializedValue(item); | ||
if (serializedData !== undefined) { | ||
@@ -670,6 +670,6 @@ if (typeof serializedData === "function") { | ||
let currentPos = 0; | ||
/** @type {Item[]} */ | ||
/** @type {ReferenceableItem[]} */ | ||
let referenceable = []; | ||
/** | ||
* @param {Item} item referenceable item | ||
* @param {Value} item referenceable item | ||
*/ | ||
@@ -807,4 +807,3 @@ const addReferenceable = item => { | ||
return SerializerMiddleware.deserializeLazy( | ||
/** @type {LazyFunction<SerializedType>} */ | ||
(item), | ||
item, | ||
data => | ||
@@ -811,0 +810,0 @@ /** @type {[DeserializedType]} */ |
@@ -7,13 +7,16 @@ /* | ||
/** @typedef {import("./SerializerMiddleware").Context} Context */ | ||
/** | ||
* @template T, K, C | ||
* @typedef {import("./SerializerMiddleware")<T, K, C>} SerializerMiddleware | ||
*/ | ||
/** | ||
* @template T, K | ||
* @typedef {import("./SerializerMiddleware")<T, K>} SerializerMiddleware | ||
* @template DeserializedValue | ||
* @template SerializedValue | ||
* @template Context | ||
*/ | ||
class Serializer { | ||
/** | ||
* @param {SerializerMiddleware<any, any>[]} middlewares serializer middlewares | ||
* @param {Context} [context] context | ||
* @param {SerializerMiddleware<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY>[]} middlewares serializer middlewares | ||
* @param {Context=} context context | ||
*/ | ||
@@ -27,5 +30,6 @@ constructor(middlewares, context) { | ||
/** | ||
* @param {TODO | Promise<TODO>} obj object | ||
* @param {Context} context context object | ||
* @returns {Promise<TODO>} result | ||
* @template ExtendedContext | ||
* @param {DeserializedValue | Promise<DeserializedValue>} obj object | ||
* @param {Context & ExtendedContext} context context object | ||
* @returns {Promise<SerializedValue>} result | ||
*/ | ||
@@ -36,5 +40,9 @@ serialize(obj, context) { | ||
for (const middleware of this.serializeMiddlewares) { | ||
if (current && typeof current.then === "function") { | ||
if ( | ||
current && | ||
typeof (/** @type {Promise<DeserializedValue>} */ (current).then) === | ||
"function" | ||
) { | ||
current = | ||
/** @type {Promise<TODO>} */ | ||
/** @type {Promise<DeserializedValue>} */ | ||
(current).then(data => data && middleware.serialize(data, ctx)); | ||
@@ -49,9 +57,10 @@ } else if (current) { | ||
} | ||
return current; | ||
return /** @type {Promise<SerializedValue>} */ (current); | ||
} | ||
/** | ||
* @param {TODO | Promise<TODO>} value value | ||
* @param {Context} context object | ||
* @returns {Promise<TODO>} result | ||
* @template ExtendedContext | ||
* @param {SerializedValue | Promise<SerializedValue>} value value | ||
* @param {Context & ExtendedContext} context object | ||
* @returns {Promise<DeserializedValue>} result | ||
*/ | ||
@@ -63,4 +72,6 @@ deserialize(value, context) { | ||
current = | ||
current && typeof current.then === "function" | ||
? /** @type {Promise<TODO>} */ (current).then(data => | ||
current && | ||
typeof (/** @type {Promise<SerializedValue>} */ (current).then) === | ||
"function" | ||
? /** @type {Promise<SerializedValue>} */ (current).then(data => | ||
middleware.deserialize(data, ctx) | ||
@@ -70,3 +81,3 @@ ) | ||
} | ||
return current; | ||
return /** @type {Promise<DeserializedValue>} */ (current); | ||
} | ||
@@ -73,0 +84,0 @@ } |
@@ -12,19 +12,17 @@ /* | ||
/** @typedef {TODO} Context */ | ||
/** @typedef {SerializerMiddleware<EXPECTED_ANY, EXPECTED_ANY, Record<string, EXPECTED_ANY>>} LazyTarget */ | ||
/** @typedef {Record<string, EXPECTED_ANY>} LazyOptions */ | ||
/** | ||
* @template LazyResult | ||
* @typedef {() => LazyResult | Promise<LazyResult>} InternalLazyFunction | ||
* @template InputValue | ||
* @template OutputValue | ||
* @template {LazyTarget} InternalLazyTarget | ||
* @template {LazyOptions | undefined} InternalLazyOptions | ||
* @typedef {(() => InputValue | Promise<InputValue>) & Partial<{ [LAZY_TARGET]: InternalLazyTarget, options: InternalLazyOptions, [LAZY_SERIALIZED_VALUE]?: OutputValue | LazyFunction<OutputValue, InputValue, InternalLazyTarget, InternalLazyOptions> | undefined }>} LazyFunction | ||
*/ | ||
/** @typedef {Record<string, any>} LazyOptions */ | ||
/** | ||
* @template LazyResult | ||
* @typedef {InternalLazyFunction<LazyResult> & { [LAZY_TARGET]: TODO, [LAZY_SERIALIZED_VALUE]?: TODO, options: LazyOptions }} LazyFunction | ||
*/ | ||
/** | ||
* @template DeserializedType | ||
* @template SerializedType | ||
* @template Context | ||
*/ | ||
@@ -57,13 +55,21 @@ class SerializerMiddleware { | ||
/** | ||
* @template LazyResult | ||
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} value contained value or function to value | ||
* @param {SerializerMiddleware<any, any>} target target middleware | ||
* @param {LazyOptions=} options lazy options | ||
* @param {any=} serializedValue serialized value | ||
* @returns {LazyFunction<LazyResult>} lazy function | ||
* @template TLazyInputValue | ||
* @template TLazyOutputValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions | undefined} TLazyOptions | ||
* @param {TLazyInputValue | (() => TLazyInputValue)} value contained value or function to value | ||
* @param {TLazyTarget} target target middleware | ||
* @param {TLazyOptions=} options lazy options | ||
* @param {TLazyOutputValue=} serializedValue serialized value | ||
* @returns {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} lazy function | ||
*/ | ||
static createLazy(value, target, options = {}, serializedValue = undefined) { | ||
static createLazy( | ||
value, | ||
target, | ||
options = /** @type {TLazyOptions} */ ({}), | ||
serializedValue = undefined | ||
) { | ||
if (SerializerMiddleware.isLazy(value, target)) return value; | ||
const fn = | ||
/** @type {LazyFunction<LazyResult>} */ | ||
/** @type {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} */ | ||
(typeof value === "function" ? value : () => value); | ||
@@ -77,5 +83,6 @@ fn[LAZY_TARGET] = target; | ||
/** | ||
* @template {LazyTarget} TLazyTarget | ||
* @param {EXPECTED_ANY} fn lazy function | ||
* @param {SerializerMiddleware<any, any>=} target target middleware | ||
* @returns {boolean} true, when fn is a lazy function (optionally of that target) | ||
* @param {TLazyTarget=} target target middleware | ||
* @returns {fn is LazyFunction<EXPECTED_ANY, EXPECTED_ANY, TLazyTarget, EXPECTED_ANY>} true, when fn is a lazy function (optionally of that target) | ||
*/ | ||
@@ -89,4 +96,8 @@ static isLazy(fn, target) { | ||
/** | ||
* @template LazyResult | ||
* @param {LazyFunction<LazyResult>} fn lazy function | ||
* @template TLazyInputValue | ||
* @template TLazyOutputValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {Record<string, EXPECTED_ANY>} TLazyOptions | ||
* @template TLazySerializedValue | ||
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function | ||
* @returns {LazyOptions | undefined} options | ||
@@ -96,9 +107,12 @@ */ | ||
if (typeof fn !== "function") return; | ||
return /** @type {any} */ (fn).options; | ||
return fn.options; | ||
} | ||
/** | ||
* @template LazyResult | ||
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} fn lazy function | ||
* @returns {any | undefined} serialized value | ||
* @template TLazyInputValue | ||
* @template TLazyOutputValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions} TLazyOptions | ||
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions> | EXPECTED_ANY} fn lazy function | ||
* @returns {TLazyOutputValue | undefined} serialized value | ||
*/ | ||
@@ -111,5 +125,8 @@ static getLazySerializedValue(fn) { | ||
/** | ||
* @template LazyResult | ||
* @param {LazyFunction<LazyResult>} fn lazy function | ||
* @param {TODO} value serialized value | ||
* @template TLazyInputValue | ||
* @template TLazyOutputValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions} TLazyOptions | ||
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, LazyTarget, LazyOptions>} fn lazy function | ||
* @param {TLazyOutputValue} value serialized value | ||
* @returns {void} | ||
@@ -122,23 +139,29 @@ */ | ||
/** | ||
* @template LazyResult, R | ||
* @param {LazyFunction<LazyResult>} lazy lazy function | ||
* @param {(lazyResult: LazyResult) => Promise<R> | R} serialize serialize function | ||
* @returns {LazyFunction<R>} new lazy | ||
* @template TLazyInputValue DeserializedValue | ||
* @template TLazyOutputValue SerializedValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions | undefined} TLazyOptions | ||
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} lazy lazy function | ||
* @param {(value: TLazyInputValue) => TLazyOutputValue} serialize serialize function | ||
* @returns {LazyFunction<TLazyOutputValue, TLazyInputValue, TLazyTarget, TLazyOptions>} new lazy | ||
*/ | ||
static serializeLazy(lazy, serialize) { | ||
const fn = /** @type {LazyFunction<R>} */ ( | ||
memoize(() => { | ||
const r = lazy(); | ||
if ( | ||
r && | ||
typeof (/** @type {Promise<LazyResult>} */ (r).then) === "function" | ||
) { | ||
return ( | ||
/** @type {Promise<LazyResult>} */ | ||
(r).then(data => data && serialize(data)) | ||
); | ||
} | ||
return serialize(/** @type {LazyResult} */ (r)); | ||
}) | ||
); | ||
const fn = | ||
/** @type {LazyFunction<TLazyOutputValue, TLazyInputValue, TLazyTarget, TLazyOptions>} */ | ||
( | ||
memoize(() => { | ||
const r = lazy(); | ||
if ( | ||
r && | ||
typeof (/** @type {Promise<TLazyInputValue>} */ (r).then) === | ||
"function" | ||
) { | ||
return ( | ||
/** @type {Promise<TLazyInputValue>} */ | ||
(r).then(data => data && serialize(data)) | ||
); | ||
} | ||
return serialize(/** @type {TLazyInputValue} */ (r)); | ||
}) | ||
); | ||
fn[LAZY_TARGET] = lazy[LAZY_TARGET]; | ||
@@ -151,23 +174,29 @@ fn.options = lazy.options; | ||
/** | ||
* @template LazyResult, R | ||
* @param {LazyFunction<LazyResult>} lazy lazy function | ||
* @param {(lazyResult: LazyResult) => Promise<R> | R} deserialize deserialize function | ||
* @returns {LazyFunction<R>} new lazy | ||
* @template TLazyInputValue SerializedValue | ||
* @template TLazyOutputValue DeserializedValue | ||
* @template SerializedValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions | undefined} TLazyOptions | ||
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} lazy lazy function | ||
* @param {(data: TLazyInputValue) => TLazyOutputValue} deserialize deserialize function | ||
* @returns {LazyFunction<TLazyOutputValue, TLazyInputValue, TLazyTarget, TLazyOptions>} new lazy | ||
*/ | ||
static deserializeLazy(lazy, deserialize) { | ||
const fn = /** @type {LazyFunction<R>} */ ( | ||
memoize(() => { | ||
const r = lazy(); | ||
if ( | ||
r && | ||
typeof (/** @type {Promise<LazyResult>} */ (r).then) === "function" | ||
) { | ||
return ( | ||
/** @type {Promise<LazyResult>} */ | ||
(r).then(data => deserialize(data)) | ||
); | ||
} | ||
return deserialize(/** @type {LazyResult} */ (r)); | ||
}) | ||
); | ||
const fn = | ||
/** @type {LazyFunction<TLazyOutputValue, TLazyInputValue, TLazyTarget, TLazyOptions>} */ ( | ||
memoize(() => { | ||
const r = lazy(); | ||
if ( | ||
r && | ||
typeof (/** @type {Promise<TLazyInputValue>} */ (r).then) === | ||
"function" | ||
) { | ||
return ( | ||
/** @type {Promise<TLazyInputValue>} */ | ||
(r).then(data => deserialize(data)) | ||
); | ||
} | ||
return deserialize(/** @type {TLazyInputValue} */ (r)); | ||
}) | ||
); | ||
fn[LAZY_TARGET] = lazy[LAZY_TARGET]; | ||
@@ -180,9 +209,12 @@ fn.options = lazy.options; | ||
/** | ||
* @template LazyResult | ||
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} lazy lazy function | ||
* @returns {LazyFunction<LazyResult> | EXPECTED_ANY} new lazy | ||
* @template TLazyInputValue | ||
* @template TLazyOutputValue | ||
* @template {LazyTarget} TLazyTarget | ||
* @template {LazyOptions} TLazyOptions | ||
* @param {LazyFunction<TLazyInputValue | TLazyOutputValue, TLazyInputValue | TLazyOutputValue, TLazyTarget, TLazyOptions> | undefined} lazy lazy function | ||
* @returns {LazyFunction<TLazyInputValue | TLazyOutputValue, TLazyInputValue | TLazyOutputValue, TLazyTarget, TLazyOptions> | undefined} new lazy | ||
*/ | ||
static unMemoizeLazy(lazy) { | ||
if (!SerializerMiddleware.isLazy(lazy)) return lazy; | ||
/** @type {LazyFunction<LazyResult>} */ | ||
/** @type {LazyFunction<TLazyInputValue | TLazyOutputValue, TLazyInputValue | TLazyOutputValue, TLazyTarget, TLazyOptions>} */ | ||
const fn = () => { | ||
@@ -194,3 +226,4 @@ throw new Error( | ||
fn[LAZY_SERIALIZED_VALUE] = SerializerMiddleware.unMemoizeLazy( | ||
lazy[LAZY_SERIALIZED_VALUE] | ||
/** @type {LazyFunction<TLazyInputValue | TLazyOutputValue, TLazyInputValue | TLazyOutputValue, TLazyTarget, TLazyOptions>} */ | ||
(lazy[LAZY_SERIALIZED_VALUE]) | ||
); | ||
@@ -197,0 +230,0 @@ fn[LAZY_TARGET] = lazy[LAZY_TARGET]; |
@@ -9,9 +9,8 @@ /* | ||
/** @typedef {import("./SerializerMiddleware").Context} Context */ | ||
/** @typedef {EXPECTED_ANY} DeserializedType */ | ||
/** @typedef {EXPECTED_ANY[]} SerializedType */ | ||
/** @typedef {{}} Context */ | ||
/** @typedef {any} DeserializedType */ | ||
/** @typedef {any[]} SerializedType */ | ||
/** | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType>} | ||
* @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>} | ||
*/ | ||
@@ -18,0 +17,0 @@ class SingleItemMiddleware extends SerializerMiddleware { |
@@ -136,3 +136,3 @@ /* | ||
/** | ||
* @param {SourceMapDevToolPluginOptions} [options] options object | ||
* @param {SourceMapDevToolPluginOptions=} options options object | ||
* @throws {Error} throws error, if got more than 1 arguments | ||
@@ -139,0 +139,0 @@ */ |
@@ -9,13 +9,30 @@ /* | ||
/** @typedef {import("../Compiler")} Compiler */ | ||
/** @typedef {import("../logging/Logger").LogTypeEnum} LogTypeEnum */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkId} ChunkId */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkName} ChunkName */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAsset} KnownStatsAsset */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunk} KnownStatsAssetChunk */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkIdHint} KnownStatsAssetChunkIdHint */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkName} KnownStatsAssetChunkName */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunk} KnownStatsChunk */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkOrigin} KnownStatsChunkOrigin */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsCompilation} KnownStatsCompilation */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsError} KnownStatsError */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsLogging} KnownStatsLogging */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsLoggingEntry} KnownStatsLoggingEntry */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModule} KnownStatsModule */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleIssuer} KnownStatsModuleIssuer */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleReason} KnownStatsModuleReason */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleTraceDependency} KnownStatsModuleTraceDependency */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleTraceItem} KnownStatsModuleTraceItem */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsProfile} KnownStatsProfile */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */ | ||
/** @typedef {import("./StatsPrinter")} StatsPrinter */ | ||
/** @typedef {import("./StatsPrinter").KnownStatsPrinterColorFn} KnownStatsPrinterColorFn */ | ||
/** @typedef {import("./StatsPrinter").ColorFunction} ColorFunction */ | ||
/** @typedef {import("./StatsPrinter").KnownStatsPrinterColorFunctions} KnownStatsPrinterColorFunctions */ | ||
/** @typedef {import("./StatsPrinter").KnownStatsPrinterContext} KnownStatsPrinterContext */ | ||
/** @typedef {import("./StatsPrinter").KnownStatsPrinterFormatters} KnownStatsPrinterFormatters */ | ||
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */ | ||
/** @typedef {import("./StatsPrinter").StatsPrinterContextWithExtra} StatsPrinterContextWithExtra */ | ||
@@ -48,6 +65,7 @@ const DATA_URI_CONTENT_LENGTH = 16; | ||
/** | ||
* @param {string} resource resource | ||
* @param {string | null} resource resource | ||
* @returns {string} resource name for display | ||
*/ | ||
const getResourceName = resource => { | ||
if (!resource) return ""; | ||
const dataUrl = /^data:[^,]+,/.exec(resource); | ||
@@ -102,7 +120,13 @@ if (!dataUrl) return resource; | ||
/** | ||
* @param {string | number} id an id | ||
* @returns {boolean | string} is i | ||
* @param {string | number | null} id an id | ||
* @returns {id is string | number} is i | ||
*/ | ||
const isValidId = id => typeof id === "number" || id; | ||
const isValidId = id => { | ||
if (typeof id === "number" || id) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
/** | ||
@@ -125,3 +149,3 @@ * @template T | ||
* @template {keyof StatsPrinterContext} RequiredStatsPrinterContextKeys | ||
* @typedef {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | RequiredStatsPrinterContextKeys>} DefineStatsPrinterContext | ||
* @typedef {StatsPrinterContextWithExtra & WithRequired<StatsPrinterContext, "compilation" | RequiredStatsPrinterContextKeys>} DefineStatsPrinterContext | ||
*/ | ||
@@ -132,3 +156,3 @@ | ||
* @template {keyof StatsPrinterContext} RequiredStatsPrinterContextKeys | ||
* @typedef {(thing: Exclude<T, undefined>, context: DefineStatsPrinterContext<RequiredStatsPrinterContextKeys>, printer: StatsPrinter) => string | undefined} ModuleSimplePrinter | ||
* @typedef {(thing: Exclude<T, undefined>, context: DefineStatsPrinterContext<RequiredStatsPrinterContextKeys>, printer: StatsPrinter) => string | undefined} SimplePrinter | ||
*/ | ||
@@ -143,10 +167,12 @@ | ||
* @template {object} O | ||
* @template {keyof O} P | ||
* @template {keyof O} K | ||
* @template {string} B | ||
* @typedef {P extends string ? `${B}.${P}` : never} PropertyName | ||
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? never : `${B}.${K}` : never} PropertyName | ||
*/ | ||
/** | ||
* @template {string} T | ||
* @typedef {{ [property in `${T}.separator!`]: () => string }} Separator | ||
* @template {object} O | ||
* @template {keyof O} K | ||
* @template {string} B | ||
* @typedef {K extends string ? NonNullable<O[K]> extends EXPECTED_ANY[] ? `${B}.${K}[]` : never : never} ArrayPropertyName | ||
*/ | ||
@@ -156,8 +182,34 @@ | ||
* @template {object} O | ||
* @template {keyof O} K | ||
* @template {string} B | ||
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? `${B}.${K}` : never : never} MultiplePropertyName | ||
*/ | ||
/** | ||
* @template {object} O | ||
* @template {string} K | ||
* @template {string} E | ||
* @typedef {{ [property in `${K}!`]?: SimplePrinter<O, "compilation" | E> }} Exclamation | ||
*/ | ||
/** | ||
* @template {object} O | ||
* @template {string} B | ||
* @template {string} [R=B] | ||
* @typedef {{ [P in keyof O as PropertyName<O, P, B>]?: ModuleSimplePrinter<O[P], R> }} Printers | ||
* @typedef {{ [K in keyof O as PropertyName<O, K, B>]?: SimplePrinter<O[K], R> } & | ||
* { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never } & | ||
* { [K in keyof O as MultiplePropertyName<O, K, B>]?: SimplePrinter<O[K], R> } | ||
* } Printers | ||
*/ | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsCompilation, "compilation"> & | ||
* { ["compilation.summary!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> } & | ||
* { ["compilation.errorsInChildren!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> } & | ||
* { ["compilation.warningsInChildren!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> }} CompilationSimplePrinters | ||
*/ | ||
/** | ||
* @type {CompilationSimplePrinters} | ||
*/ | ||
const COMPILATION_SIMPLE_PRINTERS = { | ||
@@ -278,3 +330,7 @@ "compilation.summary!": ( | ||
group => | ||
!Object.prototype.hasOwnProperty.call(entrypoints, group.name) | ||
!Object.prototype.hasOwnProperty.call( | ||
entrypoints, | ||
/** @type {string} */ | ||
(group.name) | ||
) | ||
); | ||
@@ -370,3 +426,13 @@ } | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "asset">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsAsset, "asset"> & | ||
* Printers<KnownStatsAsset["info"], "asset.info"> & | ||
* Exclamation<KnownStatsAsset, "asset.separator", "asset"> & | ||
* { ["asset.filteredChildren"]?: SimplePrinter<number, "asset"> } & | ||
* { assetChunk?: SimplePrinter<KnownStatsAssetChunk, "asset"> } & | ||
* { assetChunkName?: SimplePrinter<KnownStatsAssetChunkName, "asset"> } & | ||
* { assetChunkIdHint?: SimplePrinter<KnownStatsAssetChunkIdHint, "asset"> }} AssetSimplePrinters | ||
*/ | ||
/** @type {AssetSimplePrinters} */ | ||
const ASSET_SIMPLE_PRINTERS = { | ||
@@ -419,7 +485,14 @@ "asset.type": type => type, | ||
assetChunkName: name => name, | ||
assetChunkIdHint: name => name | ||
assetChunkName: name => name || undefined, | ||
assetChunkIdHint: name => name || undefined | ||
}; | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "module">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsModule, "module"> & | ||
* Exclamation<KnownStatsModule, "module.separator", "module"> & | ||
* { ["module.filteredChildren"]?: SimplePrinter<number, "module"> } & | ||
* { ["module.filteredReasons"]?: SimplePrinter<number, "module"> }} ModuleSimplePrinters | ||
*/ | ||
/** @type {ModuleSimplePrinters} */ | ||
const MODULE_SIMPLE_PRINTERS = { | ||
@@ -444,4 +517,4 @@ "module.type": type => (type !== "module" ? type : undefined), | ||
orphan ? yellow(formatFlag("orphan")) : undefined, | ||
"module.runtime": (runtime, { formatFlag, yellow }) => | ||
runtime ? yellow(formatFlag("runtime")) : undefined, | ||
// "module.runtime": (runtime, { formatFlag, yellow }) => | ||
// runtime ? yellow(formatFlag("runtime")) : undefined, | ||
"module.optional": (optional, { formatFlag, yellow }) => | ||
@@ -468,15 +541,11 @@ optional ? yellow(formatFlag("optional")) : undefined, | ||
"module.warnings": (warnings, { formatFlag, yellow }) => | ||
warnings === true | ||
? yellow(formatFlag("warnings")) | ||
: warnings | ||
? yellow( | ||
formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`) | ||
) | ||
: undefined, | ||
warnings | ||
? yellow( | ||
formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`) | ||
) | ||
: undefined, | ||
"module.errors": (errors, { formatFlag, red }) => | ||
errors === true | ||
? red(formatFlag("errors")) | ||
: errors | ||
? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`)) | ||
: undefined, | ||
errors | ||
? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`)) | ||
: undefined, | ||
"module.providedExports": (providedExports, { formatFlag, cyan }) => { | ||
@@ -543,3 +612,8 @@ if (Array.isArray(providedExports)) { | ||
/** @type {Printers<KnownStatsModuleIssuer, "moduleIssuer"> & Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} */ | ||
/** | ||
* @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> & | ||
* Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters | ||
*/ | ||
/** @type {ModuleIssuerPrinters} */ | ||
const MODULE_ISSUER_PRINTERS = { | ||
@@ -550,5 +624,10 @@ "moduleIssuer.id": (id, { formatModuleId }) => formatModuleId(id), | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleReason">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsModuleReason, "moduleReason"> & | ||
* { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters | ||
*/ | ||
/** @type {ModuleReasonsPrinters} */ | ||
const MODULE_REASON_PRINTERS = { | ||
"moduleReason.type": type => type, | ||
"moduleReason.type": type => type || undefined, | ||
"moduleReason.userRequest": (userRequest, { cyan }) => | ||
@@ -558,8 +637,11 @@ cyan(getResourceName(userRequest)), | ||
isValidId(moduleId) ? formatModuleId(moduleId) : undefined, | ||
"moduleReason.module": (module, { magenta }) => magenta(module), | ||
"moduleReason.loc": loc => loc, | ||
"moduleReason.explanation": (explanation, { cyan }) => cyan(explanation), | ||
"moduleReason.module": (module, { magenta }) => | ||
module ? magenta(module) : undefined, | ||
"moduleReason.loc": loc => loc || undefined, | ||
"moduleReason.explanation": (explanation, { cyan }) => | ||
explanation ? cyan(explanation) : undefined, | ||
"moduleReason.active": (active, { formatFlag }) => | ||
active ? undefined : formatFlag("inactive"), | ||
"moduleReason.resolvedModule": (module, { magenta }) => magenta(module), | ||
"moduleReason.resolvedModule": (module, { magenta }) => | ||
module ? magenta(module) : undefined, | ||
"moduleReason.filteredChildren": ( | ||
@@ -578,3 +660,5 @@ filteredChildren, | ||
/** @type {Printers<KnownStatsProfile, "module.profile", "profile">} */ | ||
/** @typedef {Printers<KnownStatsProfile, "module.profile", "profile">} ModuleProfilePrinters */ | ||
/** @type {ModuleProfilePrinters} */ | ||
const MODULE_PROFILE_PRINTERS = { | ||
@@ -598,7 +682,19 @@ "module.profile.total": (value, { formatTime }) => formatTime(value), | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunkGroupKind" | "chunkGroup">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Exclamation<KnownStatsChunkGroup, "chunkGroup.kind", "chunkGroupKind"> & | ||
* Exclamation<KnownStatsChunkGroup, "chunkGroup.separator", "chunkGroup"> & | ||
* Printers<KnownStatsChunkGroup, "chunkGroup"> & | ||
* Exclamation<KnownStatsChunkGroup, "chunkGroup.is", "chunkGroup"> & | ||
* Printers<Exclude<KnownStatsChunkGroup["assets"], undefined>[number], "chunkGroupAsset" | "chunkGroup"> & | ||
* { ['chunkGroupChildGroup.type']?: SimplePrinter<string, "chunkGroupAsset"> } & | ||
* { ['chunkGroupChild.assets[]']?: SimplePrinter<string, "chunkGroupAsset"> } & | ||
* { ['chunkGroupChild.chunks[]']?: SimplePrinter<ChunkId, "chunkGroupAsset"> } & | ||
* { ['chunkGroupChild.name']?: SimplePrinter<ChunkName, "chunkGroupAsset"> }} ChunkGroupPrinters | ||
*/ | ||
/** @type {ChunkGroupPrinters} */ | ||
const CHUNK_GROUP_PRINTERS = { | ||
"chunkGroup.kind!": (_, { chunkGroupKind }) => chunkGroupKind, | ||
"chunkGroup.separator!": () => "\n", | ||
"chunkGroup.name": (name, { bold }) => bold(name), | ||
"chunkGroup.name": (name, { bold }) => (name ? bold(name) : undefined), | ||
"chunkGroup.isOverSizeLimit": (isOverSizeLimit, { formatFlag, yellow }) => | ||
@@ -651,3 +747,11 @@ isOverSizeLimit ? yellow(formatFlag("big")) : undefined, | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunk">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsChunk, "chunk"> & | ||
* { ["chunk.childrenByOrder[].type"]: SimplePrinter<string, "chunk"> } & | ||
* { ["chunk.childrenByOrder[].children[]"]: SimplePrinter<ChunkId, "chunk"> } & | ||
* Exclamation<KnownStatsChunk, "chunk.separator", "chunk"> & | ||
* Printers<KnownStatsChunkOrigin, "chunkOrigin">} ChunkPrinters | ||
*/ | ||
/** @type {ChunkPrinters} */ | ||
const CHUNK_PRINTERS = { | ||
@@ -706,3 +810,11 @@ "chunk.id": (id, { formatChunkId }) => formatChunkId(id), | ||
/** @type {Printers<KnownStatsError, "error"> & { ["error.filteredDetails"]?: (filteredDetails: number) => string | undefined } & Separator<"error">} */ | ||
/** | ||
* @typedef {Printers<KnownStatsError, "error"> & | ||
* { ["error.filteredDetails"]?: SimplePrinter<number, "error"> } & | ||
* Exclamation<KnownStatsError, "error.separator", "error">} ErrorPrinters | ||
*/ | ||
/** | ||
* @type {ErrorPrinters} | ||
*/ | ||
const ERROR_PRINTERS = { | ||
@@ -733,3 +845,12 @@ "error.compilerPath": (compilerPath, { bold }) => | ||
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormatters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "logging">, printer: StatsPrinter) => string | undefined>} */ | ||
/** | ||
* @typedef {Printers<KnownStatsLoggingEntry, `loggingEntry(${LogTypeEnum}).loggingEntry`> & | ||
* { ["loggingEntry(clear).loggingEntry"]?: SimplePrinter<KnownStatsLoggingEntry, "logging"> } & | ||
* { ["loggingEntry.trace[]"]?: SimplePrinter<Exclude<KnownStatsLoggingEntry["trace"], undefined>[number], "logging"> } & | ||
* { loggingGroup?: SimplePrinter<KnownStatsLogging[], "logging"> } & | ||
* Printers<KnownStatsLogging & { name: string }, `loggingGroup`> & | ||
* Exclamation<KnownStatsLogging, "loggingGroup.separator", "loggingGroup">} LogEntryPrinters | ||
*/ | ||
/** @type {LogEntryPrinters} */ | ||
const LOG_ENTRY_PRINTERS = { | ||
@@ -774,3 +895,5 @@ "loggingEntry(error).loggingEntry.message": (message, { red }) => | ||
/** @type {Printers<KnownStatsModuleTraceItem, "moduleTraceItem">} */ | ||
/** @typedef {Printers<KnownStatsModuleTraceItem, "moduleTraceItem">} ModuleTraceItemPrinters */ | ||
/** @type {ModuleTraceItemPrinters} */ | ||
const MODULE_TRACE_ITEM_PRINTERS = { | ||
@@ -780,3 +903,5 @@ "moduleTraceItem.originName": originName => originName | ||
/** @type {Printers<KnownStatsModuleTraceDependency, "moduleTraceDependency">} */ | ||
/** @typedef {Printers<KnownStatsModuleTraceDependency, "moduleTraceDependency">} ModuleTraceDependencyPrinters */ | ||
/** @type {ModuleTraceDependencyPrinters} */ | ||
const MODULE_TRACE_DEPENDENCY_PRINTERS = { | ||
@@ -787,3 +912,3 @@ "moduleTraceDependency.loc": loc => loc | ||
/** | ||
* @type {Record<string, string | ((item: EXPECTED_ANY) => string)>} | ||
* @type {Record<string, string | ((item: KnownStatsLoggingEntry) => string)>} | ||
*/ | ||
@@ -1180,3 +1305,3 @@ const ITEM_NAMES = { | ||
* @param {Item[]} items items | ||
* @param {Required<StatsPrinterContext>} ctx context | ||
* @param {StatsPrinterContextWithExtra} ctx context | ||
* @returns {string} result | ||
@@ -1190,4 +1315,4 @@ */ | ||
/** @typedef {{ element: string, content: string }} Item */ | ||
/** @typedef {(items: Item[], context: Required<StatsPrinterContext>) => string} SimpleElementJoiner */ | ||
/** @typedef {{ element: string, content: string | undefined }} Item */ | ||
/** @typedef {(items: Item[], context: StatsPrinterContextWithExtra & Required<KnownStatsPrinterContext>) => string} SimpleElementJoiner */ | ||
@@ -1353,5 +1478,3 @@ /** @type {Record<string, SimpleElementJoiner>} */ | ||
/** @typedef {"bold" | "yellow" | "red" | "green" | "cyan" | "magenta"} ColorNames */ | ||
/** @type {Record<ColorNames, string>} */ | ||
/** @type {Record<keyof KnownStatsPrinterColorFunctions, string>} */ | ||
const AVAILABLE_COLORS = { | ||
@@ -1366,3 +1489,5 @@ bold: "\u001B[1m", | ||
/** @type {Record<string, (value: any, options: Required<KnownStatsPrinterColorFn> & StatsPrinterContext, ...args: any) => string>} */ | ||
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContext, ...args: TODO[]) => string }>} AvailableFormats */ | ||
/** @type {AvailableFormats} */ | ||
const AVAILABLE_FORMATS = { | ||
@@ -1506,3 +1631,5 @@ formatChunkId: (id, { yellow }, direction) => { | ||
for (const color of Object.keys(AVAILABLE_COLORS)) { | ||
const name = /** @type {ColorNames} */ (color); | ||
const name = | ||
/** @type {keyof KnownStatsPrinterColorFunctions} */ | ||
(color); | ||
/** @type {string | undefined} */ | ||
@@ -1521,6 +1648,3 @@ let start; | ||
if (start) { | ||
/** | ||
* @param {string} str string | ||
* @returns {string} string with color | ||
*/ | ||
/** @type {ColorFunction} */ | ||
context[color] = str => | ||
@@ -1551,5 +1675,11 @@ `${start}${ | ||
(content, ...args) => | ||
AVAILABLE_FORMATS[format]( | ||
/** @type {TODO} */ | ||
( | ||
AVAILABLE_FORMATS[ | ||
/** @type {keyof AvailableFormats} */ | ||
(format) | ||
] | ||
)( | ||
content, | ||
/** @type {Required<KnownStatsPrinterColorFn> & StatsPrinterContext} */ | ||
/** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */ | ||
(context), | ||
@@ -1566,3 +1696,9 @@ ...args | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
COMPILATION_SIMPLE_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
( | ||
COMPILATION_SIMPLE_PRINTERS[ | ||
/** @type {keyof CompilationSimplePrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1580,5 +1716,11 @@ /** @type {DefineStatsPrinterContext<"compilation">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
ASSET_SIMPLE_PRINTERS[key]( | ||
/** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */ | ||
( | ||
ASSET_SIMPLE_PRINTERS[ | ||
/** @type {keyof AssetSimplePrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
/** @type {DefineStatsPrinterContext<"asset">} */ | ||
/** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */ | ||
(ctx), | ||
@@ -1594,3 +1736,9 @@ stats | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
MODULE_SIMPLE_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
( | ||
MODULE_SIMPLE_PRINTERS[ | ||
/** @type {keyof ModuleSimplePrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1608,4 +1756,9 @@ /** @type {DefineStatsPrinterContext<"module">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
/** @type {Record<string, ModuleSimplePrinter<KnownStatsModuleIssuer[keyof KnownStatsModuleIssuer] | KnownStatsModuleIssuer["profile"][keyof KnownStatsModuleIssuer["profile"]], "type" | "compilation" | "moduleIssuer">>} */ | ||
(MODULE_ISSUER_PRINTERS)[key]( | ||
/** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */ | ||
( | ||
MODULE_ISSUER_PRINTERS[ | ||
/** @type {keyof ModuleIssuerPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1623,3 +1776,9 @@ /** @type {DefineStatsPrinterContext<"moduleIssuer">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
MODULE_REASON_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
( | ||
MODULE_REASON_PRINTERS[ | ||
/** @type {keyof ModuleReasonsPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1637,4 +1796,9 @@ /** @type {DefineStatsPrinterContext<"moduleReason">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
/** @type {Record<string, ModuleSimplePrinter<KnownStatsProfile[keyof KnownStatsProfile], "type" | "compilation" | "profile">>} */ | ||
(MODULE_PROFILE_PRINTERS)[key]( | ||
/** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */ | ||
( | ||
MODULE_PROFILE_PRINTERS[ | ||
/** @type {keyof ModuleProfilePrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1652,3 +1816,9 @@ /** @type {DefineStatsPrinterContext<"profile">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
CHUNK_GROUP_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
( | ||
CHUNK_GROUP_PRINTERS[ | ||
/** @type {keyof ChunkGroupPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1666,3 +1836,4 @@ /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
CHUNK_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
(CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])( | ||
obj, | ||
@@ -1680,4 +1851,4 @@ /** @type {DefineStatsPrinterContext<"chunk">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
/** @type {Record<string, ModuleSimplePrinter<KnownStatsError[keyof KnownStatsError], "type" | "compilation" | "error">>} */ | ||
(ERROR_PRINTERS)[key]( | ||
/** @type {TODO} */ | ||
(ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])( | ||
obj, | ||
@@ -1695,3 +1866,9 @@ /** @type {DefineStatsPrinterContext<"error">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
LOG_ENTRY_PRINTERS[key]( | ||
/** @type {TODO} */ | ||
( | ||
LOG_ENTRY_PRINTERS[ | ||
/** @type {keyof LogEntryPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1709,4 +1886,9 @@ /** @type {DefineStatsPrinterContext<"logging">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
/** @type {Record<string, ModuleSimplePrinter<KnownStatsModuleTraceDependency[keyof KnownStatsModuleTraceDependency], "type" | "compilation" | "moduleTraceDependency">>} */ | ||
(MODULE_TRACE_DEPENDENCY_PRINTERS)[key]( | ||
/** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */ | ||
( | ||
MODULE_TRACE_DEPENDENCY_PRINTERS[ | ||
/** @type {keyof ModuleTraceDependencyPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1724,4 +1906,9 @@ /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */ | ||
.tap("DefaultStatsPrinterPlugin", (obj, ctx) => | ||
/** @type {Record<string, ModuleSimplePrinter<KnownStatsModuleTraceItem[keyof KnownStatsModuleTraceItem], "type" | "compilation" | "moduleTraceItem">>} */ | ||
(MODULE_TRACE_ITEM_PRINTERS)[key]( | ||
/** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */ | ||
( | ||
MODULE_TRACE_ITEM_PRINTERS[ | ||
/** @type {keyof ModuleTraceItemPrinters} */ | ||
(key) | ||
] | ||
)( | ||
obj, | ||
@@ -1728,0 +1915,0 @@ /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */ |
@@ -13,9 +13,29 @@ /* | ||
/** @typedef {import("../Chunk")} Chunk */ | ||
/** @typedef {import("../ChunkGroup").OriginRecord} OriginRecord */ | ||
/** @typedef {import("../Compilation")} Compilation */ | ||
/** @typedef {import("../Compilation").Asset} Asset */ | ||
/** @typedef {import("../Compilation").NormalizedStatsOptions} NormalizedStatsOptions */ | ||
/** @typedef {import("../Dependency")} Dependency */ | ||
/** @typedef {import("../Module")} Module */ | ||
/** @typedef {import("../ModuleGraph").ModuleProfile} ModuleProfile */ | ||
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
/** @typedef {import("../WebpackError")} WebpackError */ | ||
/** @typedef {import("../util/comparators").Comparator<TODO>} Comparator */ | ||
/** @typedef {import("../util/comparators").Comparator<EXPECTED_ANY>} Comparator */ | ||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
/** @typedef {import("../util/smartGrouping").GroupConfig<TODO, EXPECTED_OBJECT>} GroupConfig */ | ||
/** @typedef {import("../util/smartGrouping").GroupConfig<EXPECTED_ANY, EXPECTED_OBJECT>} GroupConfig */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkGroupInfoWithName} ChunkGroupInfoWithName */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").ModuleIssuerPath} ModuleIssuerPath */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").ModuleTrace} ModuleTrace */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunkOrigin} StatsChunkOrigin */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsError} StatsError */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModule} StatsModule */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleIssuer} StatsModuleIssuer */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleReason} StatsModuleReason */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleTraceDependency} StatsModuleTraceDependency */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleTraceItem} StatsModuleTraceItem */ | ||
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsProfile} StatsProfile */ | ||
@@ -37,9 +57,22 @@ /** | ||
/** @typedef {any} CreatedObject */ | ||
/** @typedef {any} FactoryData */ | ||
/** @typedef {any} FactoryDataItem */ | ||
/** @typedef {any} Result */ | ||
/** @typedef {Record<string, any>} ObjectForExtract */ | ||
// StatsLogging StatsLoggingEntry | ||
/** | ||
* @template T | ||
* @template F | ||
* @typedef {T extends Compilation ? StatsCompilation : T extends ChunkGroupInfoWithName ? StatsChunkGroup : T extends Chunk ? StatsChunk : T extends OriginRecord ? StatsChunkOrigin : T extends Module ? StatsModule : T extends ModuleGraphConnection ? StatsModuleReason : T extends Asset ? StatsAsset : T extends ModuleTrace ? StatsModuleTraceItem : T extends Dependency ? StatsModuleTraceDependency : T extends Error ? StatsError : T extends ModuleProfile ? StatsProfile : F} StatsObject | ||
*/ | ||
/** | ||
* @template T | ||
* @template F | ||
* @typedef {T extends ChunkGroupInfoWithName[] ? Record<string, StatsObject<ChunkGroupInfoWithName, F>> : T extends (infer V)[] ? StatsObject<V, F>[] : StatsObject<T, F>} CreatedObject | ||
*/ | ||
/** @typedef {TODO} FactoryData */ | ||
/** @typedef {TODO} FactoryDataItem */ | ||
/** @typedef {TODO} Result */ | ||
/** @typedef {Record<string, TODO>} ObjectForExtract */ | ||
/** | ||
* @typedef {object} StatsFactoryHooks | ||
@@ -193,6 +226,8 @@ * @property {HookMap<SyncBailHook<[ObjectForExtract, FactoryData, StatsFactoryContext], void>>} extract | ||
/** | ||
* @template FactoryData | ||
* @template FallbackCreatedObject | ||
* @param {string} type type | ||
* @param {FactoryData} data factory data | ||
* @param {Omit<StatsFactoryContext, "type">} baseContext context used as base | ||
* @returns {CreatedObject} created object | ||
* @returns {CreatedObject<FactoryData, FallbackCreatedObject>} created object | ||
*/ | ||
@@ -214,7 +249,9 @@ create(type, data, baseContext) { | ||
/** | ||
* @private | ||
* @template FactoryData | ||
* @template FallbackCreatedObject | ||
* @param {string} type type | ||
* @param {FactoryData} data factory data | ||
* @param {Omit<StatsFactoryContext, "type">} baseContext context used as base | ||
* @returns {CreatedObject} created object | ||
* @private | ||
* @returns {CreatedObject<FactoryData, FallbackCreatedObject>} created object | ||
*/ | ||
@@ -221,0 +258,0 @@ _create(type, data, baseContext) { |
@@ -26,3 +26,3 @@ /* | ||
* @property {string} element | ||
* @property {string} content | ||
* @property {string | undefined} content | ||
*/ | ||
@@ -48,10 +48,12 @@ | ||
/** @typedef {(value: string | number) => string} ColorFunction */ | ||
/** | ||
* @typedef {object} KnownStatsPrinterColorFn | ||
* @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 | ||
* @typedef {object} KnownStatsPrinterColorFunctions | ||
* @property {ColorFunction=} bold | ||
* @property {ColorFunction=} yellow | ||
* @property {ColorFunction=} red | ||
* @property {ColorFunction=} green | ||
* @property {ColorFunction=} magenta | ||
* @property {ColorFunction=} cyan | ||
*/ | ||
@@ -72,4 +74,5 @@ | ||
/** @typedef {KnownStatsPrinterColorFn & KnownStatsPrinterFormatters & KnownStatsPrinterContext & Record<string, EXPECTED_ANY>} StatsPrinterContext */ | ||
/** @typedef {TODO} PrintObject */ | ||
/** @typedef {KnownStatsPrinterColorFunctions & KnownStatsPrinterFormatters & KnownStatsPrinterContext & Record<string, EXPECTED_ANY>} StatsPrinterContext */ | ||
/** @typedef {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions> & Required<KnownStatsPrinterFormatters> & { type: string }} StatsPrinterContextWithExtra */ | ||
/** @typedef {EXPECTED_ANY} PrintObject */ | ||
@@ -79,7 +82,7 @@ /** | ||
* @property {HookMap<SyncBailHook<[string[], StatsPrinterContext], void>>} sortElements | ||
* @property {HookMap<SyncBailHook<[PrintedElement[], StatsPrinterContext], string | void>>} printElements | ||
* @property {HookMap<SyncBailHook<[PrintedElement[], StatsPrinterContext], string | undefined | void>>} printElements | ||
* @property {HookMap<SyncBailHook<[PrintObject[], StatsPrinterContext], boolean | void>>} sortItems | ||
* @property {HookMap<SyncBailHook<[PrintObject, StatsPrinterContext], string | void>>} getItemName | ||
* @property {HookMap<SyncBailHook<[string[], StatsPrinterContext], string | void>>} printItems | ||
* @property {HookMap<SyncBailHook<[PrintObject, StatsPrinterContext], string | void>>} print | ||
* @property {HookMap<SyncBailHook<[string[], StatsPrinterContext], string | undefined>>} printItems | ||
* @property {HookMap<SyncBailHook<[PrintObject, StatsPrinterContext], string | undefined | void>>} print | ||
* @property {HookMap<SyncWaterfallHook<[string, StatsPrinterContext]>>} result | ||
@@ -104,3 +107,2 @@ */ | ||
print: new HookMap(() => new SyncBailHook(["object", "context"])), | ||
/** @type {HookMap<SyncWaterfallHook<[string, StatsPrinterContext]>>} */ | ||
result: new HookMap(() => new SyncWaterfallHook(["result", "context"])) | ||
@@ -155,4 +157,4 @@ }); | ||
* @param {string} type type | ||
* @param {(hooK: H) => R | void} fn fn | ||
* @returns {R | void} hook | ||
* @param {(hooK: H) => R | undefined | void} fn fn | ||
* @returns {R | undefined} hook | ||
*/ | ||
@@ -162,3 +164,3 @@ _forEachLevel(hookMap, type, fn) { | ||
const result = fn(/** @type {H} */ (hook)); | ||
if (result !== undefined) return result; | ||
if (result !== undefined) return /** @type {R} */ (result); | ||
} | ||
@@ -176,3 +178,3 @@ } | ||
* @param {(hook: H, data: string) => string} fn fn | ||
* @returns {string} result of `fn` | ||
* @returns {string | undefined} result of `fn` | ||
*/ | ||
@@ -190,3 +192,3 @@ _forEachLevelWaterfall(hookMap, type, data, fn) { | ||
* @param {StatsPrinterContext=} baseContext The base context | ||
* @returns {string} printed result | ||
* @returns {string | undefined} printed result | ||
*/ | ||
@@ -211,3 +213,3 @@ print(type, object, baseContext) { | ||
* @param {StatsPrinterContext=} baseContext context | ||
* @returns {string} printed result | ||
* @returns {string | undefined} printed result | ||
*/ | ||
@@ -222,2 +224,3 @@ _print(type, object, baseContext) { | ||
/** @type {string | undefined} */ | ||
let printResult = this._forEachLevel(this.hooks.print, type, hook => | ||
@@ -230,10 +233,15 @@ hook.call(object, context) | ||
this._forEachLevel(this.hooks.sortItems, type, h => | ||
h.call(sortedItems, context) | ||
h.call( | ||
sortedItems, | ||
/** @type {StatsPrinterContextWithExtra} */ | ||
(context) | ||
) | ||
); | ||
const printedItems = sortedItems.map((item, i) => { | ||
/** @type {StatsPrinterContext} */ | ||
const itemContext = { | ||
...context, | ||
_index: i | ||
}; | ||
const itemContext = | ||
/** @type {StatsPrinterContextWithExtra} */ | ||
({ | ||
...context, | ||
_index: i | ||
}); | ||
const itemName = this._forEachLevel( | ||
@@ -252,3 +260,7 @@ this.hooks.getItemName, | ||
printResult = this._forEachLevel(this.hooks.printItems, type, h => | ||
h.call(printedItems, context) | ||
h.call( | ||
/** @type {string[]} */ (printedItems), | ||
/** @type {StatsPrinterContextWithExtra} */ | ||
(context) | ||
) | ||
); | ||
@@ -264,3 +276,7 @@ if (printResult === undefined) { | ||
this._forEachLevel(this.hooks.sortElements, type, h => | ||
h.call(elements, context) | ||
h.call( | ||
elements, | ||
/** @type {StatsPrinterContextWithExtra} */ | ||
(context) | ||
) | ||
); | ||
@@ -277,3 +293,7 @@ const printedElements = elements.map(element => { | ||
printResult = this._forEachLevel(this.hooks.printElements, type, h => | ||
h.call(printedElements, context) | ||
h.call( | ||
printedElements, | ||
/** @type {StatsPrinterContextWithExtra} */ | ||
(context) | ||
) | ||
); | ||
@@ -290,4 +310,5 @@ if (printResult === undefined) { | ||
type, | ||
/** @type {string} */ (printResult), | ||
(h, r) => h.call(r, context) | ||
/** @type {string} */ | ||
(printResult), | ||
(h, r) => h.call(r, /** @type {StatsPrinterContextWithExtra} */ (context)) | ||
); | ||
@@ -294,0 +315,0 @@ } |
@@ -253,3 +253,3 @@ /* | ||
* @typedef {object} WithId | ||
* @property {string|number} id | ||
* @property {string | number} id | ||
*/ | ||
@@ -256,0 +256,0 @@ |
@@ -13,3 +13,3 @@ /* | ||
/** | ||
* @param {Iterable<T>} [items] The initial elements. | ||
* @param {Iterable<T>=} items The initial elements. | ||
*/ | ||
@@ -16,0 +16,0 @@ constructor(items) { |
@@ -72,3 +72,3 @@ /* | ||
* @param {string=} options.context context of execution | ||
* @param {AsyncQueue<any, any, any>=} options.parent parent queue, which will have priority over this queue and with shared parallelism | ||
* @param {AsyncQueue<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY>=} options.parent parent queue, which will have priority over this queue and with shared parallelism | ||
* @param {getKey<T, K>=} options.getKey extract key from item | ||
@@ -75,0 +75,0 @@ * @param {Processor<T, R>} options.processor async function to process items |
@@ -92,5 +92,5 @@ /* | ||
* @typedef {object} ObjectParsedPropertyEntry | ||
* @property {any | undefined} base base value | ||
* @property {TODO | undefined} base base value | ||
* @property {string | undefined} byProperty the name of the selector property | ||
* @property {ByValues<any>} byValues value depending on selector property, merged with base | ||
* @property {ByValues<TODO>} byValues value depending on selector property, merged with base | ||
*/ | ||
@@ -97,0 +97,0 @@ |
@@ -364,3 +364,3 @@ /* | ||
/** @type {TwoKeyWeakMap<Selector<any, any>, Comparator<any>, Comparator<any>>}} */ | ||
/** @type {TwoKeyWeakMap<Selector<EXPECTED_ANY, EXPECTED_ANY>, Comparator<EXPECTED_ANY>, Comparator<EXPECTED_ANY>>}} */ | ||
const compareSelectCache = new TwoKeyWeakMap(); | ||
@@ -367,0 +367,0 @@ |
@@ -22,3 +22,3 @@ /* | ||
* @param {Hash | HashFactory} hashOrFactory function to create a hash | ||
* @param {string} [hashKey] key for caching | ||
* @param {string=} hashKey key for caching | ||
*/ | ||
@@ -25,0 +25,0 @@ constructor(hashOrFactory, hashKey) { |
@@ -132,3 +132,3 @@ /* | ||
* @typedef {object} ObjectEncodingOptions | ||
* @property {BufferEncoding | null | undefined} [encoding] | ||
* @property {BufferEncoding | null | undefined=} encoding | ||
*/ | ||
@@ -135,0 +135,0 @@ |
@@ -56,3 +56,3 @@ /* | ||
* @param {string} request the request which will be required when deserializing | ||
* @param {string | null} [name] the name to make multiple serializer unique when sharing a request | ||
* @param {string | null=} name the name to make multiple serializer unique when sharing a request | ||
*/ | ||
@@ -59,0 +59,0 @@ module.exports = (Constructor, request, name = null) => { |
@@ -434,2 +434,3 @@ /* | ||
constructor(clone) { | ||
/** @type {0 | 1 | 2} */ | ||
this._mode = clone ? clone._mode : 0; // 0 = empty, 1 = single entry, 2 = map | ||
@@ -436,0 +437,0 @@ /** @type {RuntimeSpec} */ |
@@ -12,6 +12,10 @@ /* | ||
/** @typedef {import("../serialization/BinaryMiddleware").MEASURE_START_OPERATION_TYPE} MEASURE_START_OPERATION */ | ||
/** @typedef {import("../serialization/Serializer")} Serializer */ | ||
/** @typedef {typeof import("../util/Hash")} Hash */ | ||
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
/** | ||
* @template D, S, C | ||
* @typedef {import("../serialization/Serializer")<D, S, C>} Serializer | ||
*/ | ||
const getBinaryMiddleware = memoize(() => | ||
@@ -57,3 +61,5 @@ require("../serialization/BinaryMiddleware") | ||
/** @type {Serializer} */ | ||
/** | ||
* @type {Serializer<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY>} | ||
*/ | ||
let buffersSerializer; | ||
@@ -83,5 +89,2 @@ | ||
}, | ||
/** | ||
* @returns {Serializer} buffer serializer | ||
*/ | ||
get buffersSerializer() { | ||
@@ -94,20 +97,23 @@ if (buffersSerializer !== undefined) return buffersSerializer; | ||
const SingleItemMiddleware = getSingleItemMiddleware(); | ||
return (buffersSerializer = new Serializer([ | ||
new SingleItemMiddleware(), | ||
new (getObjectMiddleware())(context => { | ||
if ("write" in context) { | ||
context.writeLazy = value => { | ||
context.write( | ||
SerializerMiddleware.createLazy(value, binaryMiddleware) | ||
); | ||
}; | ||
} | ||
}, DEFAULTS.HASH_FUNCTION), | ||
binaryMiddleware | ||
])); | ||
return /** @type {Serializer<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY>} */ ( | ||
buffersSerializer = new Serializer([ | ||
new SingleItemMiddleware(), | ||
new (getObjectMiddleware())(context => { | ||
if ("write" in context) { | ||
context.writeLazy = value => { | ||
context.write( | ||
SerializerMiddleware.createLazy(value, binaryMiddleware) | ||
); | ||
}; | ||
} | ||
}, DEFAULTS.HASH_FUNCTION), | ||
binaryMiddleware | ||
]) | ||
); | ||
}, | ||
/** | ||
* @template D, S, C | ||
* @param {IntermediateFileSystem} fs filesystem | ||
* @param {string | Hash} hashFunction hash function to use | ||
* @returns {Serializer} file serializer | ||
* @returns {Serializer<D, S, C>} file serializer | ||
*/ | ||
@@ -122,26 +128,28 @@ createFileSerializer: (fs, hashFunction) => { | ||
const SingleItemMiddleware = getSingleItemMiddleware(); | ||
return new Serializer([ | ||
new SingleItemMiddleware(), | ||
new (getObjectMiddleware())(context => { | ||
if ("write" in context) { | ||
context.writeLazy = value => { | ||
context.write( | ||
SerializerMiddleware.createLazy(value, binaryMiddleware) | ||
); | ||
}; | ||
context.writeSeparate = (value, options) => { | ||
const lazy = SerializerMiddleware.createLazy( | ||
value, | ||
fileMiddleware, | ||
options | ||
); | ||
context.write(lazy); | ||
return lazy; | ||
}; | ||
} | ||
}, hashFunction), | ||
binaryMiddleware, | ||
fileMiddleware | ||
]); | ||
return /** @type {Serializer<D, S, C>} */ ( | ||
new Serializer([ | ||
new SingleItemMiddleware(), | ||
new (getObjectMiddleware())(context => { | ||
if ("write" in context) { | ||
context.writeLazy = value => { | ||
context.write( | ||
SerializerMiddleware.createLazy(value, binaryMiddleware) | ||
); | ||
}; | ||
context.writeSeparate = (value, options) => { | ||
const lazy = SerializerMiddleware.createLazy( | ||
value, | ||
fileMiddleware, | ||
options | ||
); | ||
context.write(lazy); | ||
return lazy; | ||
}; | ||
} | ||
}, hashFunction), | ||
binaryMiddleware, | ||
fileMiddleware | ||
]) | ||
); | ||
} | ||
}; |
@@ -16,3 +16,3 @@ /* | ||
/** | ||
* @param {Iterable<[T, V]>=} items The initial elements. | ||
* @param {Iterable<[T, V, ...EXPECTED_ANY]>=} items The initial elements. | ||
*/ | ||
@@ -22,3 +22,3 @@ constructor(items) { | ||
* @private | ||
* @type {TupleSet<[T, V]>} | ||
* @type {TupleSet<T, V>} | ||
*/ | ||
@@ -28,3 +28,3 @@ this._set = new TupleSet(items); | ||
* @private | ||
* @type {Iterator<[T, V]>} | ||
* @type {Iterator<[T, V, ...EXPECTED_ANY]>} | ||
*/ | ||
@@ -44,3 +44,3 @@ this._iterator = this._set[Symbol.iterator](); | ||
* Appends the specified element to this queue. | ||
* @param {[T, V]} item The element to add. | ||
* @param {[T, V, ...EXPECTED_ANY]} item The element to add. | ||
* @returns {void} | ||
@@ -54,3 +54,3 @@ */ | ||
* Retrieves and removes the head of this queue. | ||
* @returns {[T, V] | undefined} The head of the queue of `undefined` if this queue is empty. | ||
* @returns {[T, V, ...EXPECTED_ANY] | undefined} The head of the queue of `undefined` if this queue is empty. | ||
*/ | ||
@@ -62,3 +62,5 @@ dequeue() { | ||
this._iterator = this._set[Symbol.iterator](); | ||
const value = /** @type {[T, V]} */ (this._iterator.next().value); | ||
const value = | ||
/** @type {[T, V, ...EXPECTED_ANY]} */ | ||
(this._iterator.next().value); | ||
this._set.delete(...value); | ||
@@ -69,3 +71,3 @@ return value; | ||
} | ||
this._set.delete(.../** @type {[T, V]} */ (result.value)); | ||
this._set.delete(.../** @type {[T, V, ...EXPECTED_ANY]} */ (result.value)); | ||
return result.value; | ||
@@ -72,0 +74,0 @@ } |
@@ -9,10 +9,17 @@ /* | ||
/** | ||
* @template {any[]} T | ||
* @template K | ||
* @template V | ||
* @typedef {Map<K, InnerMap<K, V> | Set<V>>} InnerMap | ||
*/ | ||
/** | ||
* @template T | ||
* @template V | ||
*/ | ||
class TupleSet { | ||
/** | ||
* @param {Iterable<T>=} init init | ||
* @param {Iterable<[T, V, ...EXPECTED_ANY]>=} init init | ||
*/ | ||
constructor(init) { | ||
/** @type {Map<T, TODO>} */ | ||
/** @type {InnerMap<T, V>} */ | ||
this._map = new Map(); | ||
@@ -28,3 +35,3 @@ this.size = 0; | ||
/** | ||
* @param {T} args tuple | ||
* @param {[T, V, ...EXPECTED_ANY]} args tuple | ||
* @returns {void} | ||
@@ -40,3 +47,3 @@ */ | ||
} else { | ||
map = innerMap; | ||
map = /** @type {InnerMap<T, V>} */ (innerMap); | ||
} | ||
@@ -46,3 +53,3 @@ } | ||
const beforeLast = args[args.length - 2]; | ||
let set = map.get(beforeLast); | ||
let set = /** @type {Set<V>} */ (map.get(beforeLast)); | ||
if (set === undefined) { | ||
@@ -59,3 +66,3 @@ map.set(beforeLast, (set = new Set())); | ||
/** | ||
* @param {T} args tuple | ||
* @param {[T, V, ...EXPECTED_ANY]} args tuple | ||
* @returns {boolean} true, if the tuple is in the Set | ||
@@ -67,3 +74,3 @@ */ | ||
const arg = args[i]; | ||
map = map.get(arg); | ||
map = /** @type {InnerMap<T, V>} */ (map.get(arg)); | ||
if (map === undefined) { | ||
@@ -85,3 +92,3 @@ return false; | ||
/** | ||
* @param {T} args tuple | ||
* @param {[T, V, ...EXPECTED_ANY]} args tuple | ||
* @returns {void} | ||
@@ -93,3 +100,3 @@ */ | ||
const arg = args[i]; | ||
map = map.get(arg); | ||
map = /** @type {InnerMap<T, V>} */ (map.get(arg)); | ||
if (map === undefined) { | ||
@@ -113,14 +120,16 @@ return; | ||
/** | ||
* @returns {Iterator<T>} iterator | ||
* @returns {Iterator<[T, V, ...EXPECTED_ANY]>} iterator | ||
*/ | ||
[Symbol.iterator]() { | ||
/** @type {TODO[]} */ | ||
// This is difficult to type because we can have a map inside a map inside a map, etc. where the end is a set (each key is an argument) | ||
// But in basic use we only have 2 arguments in our methods, so we have `Map<K, Set<V>>` | ||
/** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>[]} */ | ||
const iteratorStack = []; | ||
/** @type {T[]} */ | ||
/** @type {[T?, V?, ...EXPECTED_ANY]} */ | ||
const tuple = []; | ||
/** @type {Iterator<T> | undefined} */ | ||
/** @type {SetIterator<V> | undefined} */ | ||
let currentSetIterator; | ||
/** | ||
* @param {TODO} it iterator | ||
* @param {MapIterator<[T, InnerMap<T, V> | Set<V>]>} it iterator | ||
* @returns {boolean} result | ||
@@ -133,3 +142,6 @@ */ | ||
tuple.pop(); | ||
return next(iteratorStack.pop()); | ||
return next( | ||
/** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */ | ||
(iteratorStack.pop()) | ||
); | ||
} | ||
@@ -154,3 +166,8 @@ const [key, value] = result.value; | ||
tuple.pop(); | ||
if (!next(iteratorStack.pop())) { | ||
if ( | ||
!next( | ||
/** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */ | ||
(iteratorStack.pop()) | ||
) | ||
) { | ||
currentSetIterator = undefined; | ||
@@ -161,3 +178,5 @@ } | ||
done: false, | ||
value: /** @type {T} */ (tuple.concat(result.value)) | ||
value: | ||
/** @type {[T, V, ...EXPECTED_ANY]} */ | ||
(tuple.concat(result.value)) | ||
}; | ||
@@ -164,0 +183,0 @@ } |
@@ -9,11 +9,11 @@ /* | ||
/** | ||
* @template T | ||
* @template {EXPECTED_ANY[]} T | ||
* @template V | ||
* @typedef {Map<EXPECTED_ANY, WeakTupleMap<T[], V>>} M | ||
* @typedef {Map<EXPECTED_ANY, WeakTupleMap<T, V>>} M | ||
*/ | ||
/** | ||
* @template T | ||
* @template {EXPECTED_ANY[]} T | ||
* @template V | ||
* @typedef {WeakMap<EXPECTED_OBJECT, WeakTupleMap<T[], V>>} W | ||
* @typedef {WeakMap<EXPECTED_OBJECT, WeakTupleMap<T, V>>} W | ||
*/ | ||
@@ -28,3 +28,8 @@ | ||
/** | ||
* @template {any[]} T | ||
* @template {unknown[]} T | ||
* @typedef {T extends readonly (infer ElementType)[] ? ElementType : never} ArrayElement | ||
*/ | ||
/** | ||
* @template {EXPECTED_ANY[]} K | ||
* @template V | ||
@@ -43,3 +48,3 @@ */ | ||
* @private | ||
* @type {M<T, V> | undefined} | ||
* @type {M<K, V> | undefined} | ||
*/ | ||
@@ -49,3 +54,3 @@ this.m = undefined; | ||
* @private | ||
* @type {W<T, V> | undefined} | ||
* @type {W<K, V> | undefined} | ||
*/ | ||
@@ -56,23 +61,23 @@ this.w = undefined; | ||
/** | ||
* @param {[...T, V]} args tuple | ||
* @param {[...K, V]} args tuple | ||
* @returns {void} | ||
*/ | ||
set(...args) { | ||
/** @type {WeakTupleMap<T, V>} */ | ||
/** @type {WeakTupleMap<K, V>} */ | ||
let node = this; | ||
for (let i = 0; i < args.length - 1; i++) { | ||
node = node._get(args[i]); | ||
node = node._get(/** @type {ArrayElement<K>} */ (args[i])); | ||
} | ||
node._setValue(args[args.length - 1]); | ||
node._setValue(/** @type {V} */ (args[args.length - 1])); | ||
} | ||
/** | ||
* @param {T} args tuple | ||
* @param {K} args tuple | ||
* @returns {boolean} true, if the tuple is in the Set | ||
*/ | ||
has(...args) { | ||
/** @type {WeakTupleMap<T, V> | undefined} */ | ||
/** @type {WeakTupleMap<K, V> | undefined} */ | ||
let node = this; | ||
for (let i = 0; i < args.length; i++) { | ||
node = node._peek(args[i]); | ||
node = node._peek(/** @type {ArrayElement<K>} */ (args[i])); | ||
if (node === undefined) return false; | ||
@@ -84,10 +89,10 @@ } | ||
/** | ||
* @param {T} args tuple | ||
* @param {K} args tuple | ||
* @returns {V | undefined} the value | ||
*/ | ||
get(...args) { | ||
/** @type {WeakTupleMap<T, V> | undefined} */ | ||
/** @type {WeakTupleMap<K, V> | undefined} */ | ||
let node = this; | ||
for (let i = 0; i < args.length; i++) { | ||
node = node._peek(args[i]); | ||
node = node._peek(/** @type {ArrayElement<K>} */ (args[i])); | ||
if (node === undefined) return; | ||
@@ -99,14 +104,14 @@ } | ||
/** | ||
* @param {[...T, () => V]} args tuple | ||
* @param {[...K, (...args: K) => V]} args tuple | ||
* @returns {V} the value | ||
*/ | ||
provide(...args) { | ||
/** @type {WeakTupleMap<T, V>} */ | ||
/** @type {WeakTupleMap<K, V>} */ | ||
let node = this; | ||
for (let i = 0; i < args.length - 1; i++) { | ||
node = node._get(args[i]); | ||
node = node._get(/** @type {ArrayElement<K>} */ (args[i])); | ||
} | ||
if (node._hasValue()) return /** @type {V} */ (node._getValue()); | ||
const fn = args[args.length - 1]; | ||
const newValue = fn(...args.slice(0, -1)); | ||
const fn = /** @type {(...args: K) => V} */ (args[args.length - 1]); | ||
const newValue = fn(.../** @type {K} */ (args.slice(0, -1))); | ||
node._setValue(newValue); | ||
@@ -117,10 +122,10 @@ return newValue; | ||
/** | ||
* @param {T} args tuple | ||
* @param {K} args tuple | ||
* @returns {void} | ||
*/ | ||
delete(...args) { | ||
/** @type {WeakTupleMap<T, V> | undefined} */ | ||
/** @type {WeakTupleMap<K, V> | undefined} */ | ||
let node = this; | ||
for (let i = 0; i < args.length; i++) { | ||
node = node._peek(args[i]); | ||
node = node._peek(/** @type {ArrayElement<K>} */ (args[i])); | ||
if (node === undefined) return; | ||
@@ -164,4 +169,4 @@ } | ||
/** | ||
* @param {EXPECTED_ANY} thing thing | ||
* @returns {WeakTupleMap<T, V> | undefined} thing | ||
* @param {ArrayElement<K>} thing thing | ||
* @returns {WeakTupleMap<K, V> | undefined} thing | ||
* @private | ||
@@ -172,6 +177,10 @@ */ | ||
if ((this.f & 4) !== 4) return; | ||
return /** @type {W<T, V>} */ (this.w).get(thing); | ||
return /** @type {WeakMap<ArrayElement<K>, WeakTupleMap<K, V>>} */ ( | ||
this.w | ||
).get(thing); | ||
} | ||
if ((this.f & 2) !== 2) return; | ||
return /** @type {M<T, V>} */ (this.m).get(thing); | ||
return /** @type {Map<ArrayElement<K>, WeakTupleMap<K, V>>} */ (this.m).get( | ||
thing | ||
); | ||
} | ||
@@ -181,4 +190,4 @@ | ||
* @private | ||
* @param {EXPECTED_ANY} thing thing | ||
* @returns {WeakTupleMap<T, V>} value | ||
* @param {ArrayElement<K>} thing thing | ||
* @returns {WeakTupleMap<K, V>} value | ||
*/ | ||
@@ -188,4 +197,6 @@ _get(thing) { | ||
if ((this.f & 4) !== 4) { | ||
/** @type {W<K, V>} */ | ||
const newMap = new WeakMap(); | ||
this.f |= 4; | ||
/** @type {WeakTupleMap<K, V>} */ | ||
const newNode = new WeakTupleMap(); | ||
@@ -195,10 +206,9 @@ (this.w = newMap).set(thing, newNode); | ||
} | ||
const entry = | ||
/** @type {W<T, V>} */ | ||
(this.w).get(thing); | ||
const entry = /** @type {W<K, V>} */ (this.w).get(thing); | ||
if (entry !== undefined) { | ||
return entry; | ||
} | ||
/** @type {WeakTupleMap<K, V>} */ | ||
const newNode = new WeakTupleMap(); | ||
/** @type {W<T, V>} */ | ||
/** @type {W<K, V>} */ | ||
(this.w).set(thing, newNode); | ||
@@ -208,4 +218,6 @@ return newNode; | ||
if ((this.f & 2) !== 2) { | ||
/** @type {M<K, V>} */ | ||
const newMap = new Map(); | ||
this.f |= 2; | ||
/** @type {WeakTupleMap<K, V>} */ | ||
const newNode = new WeakTupleMap(); | ||
@@ -216,3 +228,3 @@ (this.m = newMap).set(thing, newNode); | ||
const entry = | ||
/** @type {M<T, V>} */ | ||
/** @type {M<K, V>} */ | ||
(this.m).get(thing); | ||
@@ -222,4 +234,5 @@ if (entry !== undefined) { | ||
} | ||
/** @type {WeakTupleMap<K, V>} */ | ||
const newNode = new WeakTupleMap(); | ||
/** @type {M<T, V>} */ | ||
/** @type {M<K, V>} */ | ||
(this.m).set(thing, newNode); | ||
@@ -226,0 +239,0 @@ return newNode; |
@@ -19,3 +19,3 @@ /* | ||
* @typedef {object} AsyncWebAssemblyGeneratorOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean=} mangleImports mangle imports | ||
*/ | ||
@@ -22,0 +22,0 @@ |
@@ -58,3 +58,3 @@ /* | ||
* @typedef {object} AsyncWebAssemblyModulesPluginOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean=} mangleImports mangle imports | ||
*/ | ||
@@ -61,0 +61,0 @@ |
@@ -216,4 +216,4 @@ /* | ||
* @property {(path: string) => string} generateLoadBinaryCode | ||
* @property {boolean} [supportsStreaming] | ||
* @property {boolean} [mangleImports] | ||
* @property {boolean=} supportsStreaming | ||
* @property {boolean=} mangleImports | ||
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements | ||
@@ -220,0 +220,0 @@ */ |
@@ -410,3 +410,3 @@ /* | ||
* @typedef {object} WebAssemblyGeneratorOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean=} mangleImports mangle imports | ||
*/ | ||
@@ -413,0 +413,0 @@ |
@@ -35,3 +35,3 @@ /* | ||
* @typedef {object} WebAssemblyModulesPluginOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean=} mangleImports mangle imports | ||
*/ | ||
@@ -38,0 +38,0 @@ |
@@ -17,3 +17,3 @@ /* | ||
* @typedef {object} FetchCompileWasmPluginOptions | ||
* @property {boolean} [mangleImports] mangle imports | ||
* @property {boolean=} mangleImports mangle imports | ||
*/ | ||
@@ -27,3 +27,3 @@ | ||
/** | ||
* @param {FetchCompileWasmPluginOptions} [options] options | ||
* @param {FetchCompileWasmPluginOptions=} options options | ||
*/ | ||
@@ -30,0 +30,0 @@ constructor(options = {}) { |
@@ -62,3 +62,3 @@ /* | ||
* @param {WebpackOptions} rawOptions options object | ||
* @param {number} [compilerIndex] index of compiler | ||
* @param {number=} compilerIndex index of compiler | ||
* @returns {Compiler} a compiler | ||
@@ -65,0 +65,0 @@ */ |
@@ -51,2 +51,3 @@ /* | ||
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin"); | ||
const JavascriptMetaInfoPlugin = require("./JavascriptMetaInfoPlugin"); | ||
@@ -240,5 +241,20 @@ const DefaultStatsFactoryPlugin = require("./stats/DefaultStatsFactoryPlugin"); | ||
if (enabledLibraryTypes.length > 0) { | ||
let once = true; | ||
for (const type of enabledLibraryTypes) { | ||
const EnableLibraryPlugin = require("./library/EnableLibraryPlugin"); | ||
new EnableLibraryPlugin(type).apply(compiler); | ||
new EnableLibraryPlugin(type, { | ||
// eslint-disable-next-line no-loop-func | ||
additionalApply: () => { | ||
if (!once) return; | ||
once = false; | ||
// We rely on `exportInfo` to generate the `export statement` in certain library bundles. | ||
// Therefore, we ignore the disabling of `optimization.providedExport` and continue to apply `FlagDependencyExportsPlugin`. | ||
if ( | ||
["module", "commonjs-static", "modern-module"].includes(type) && | ||
!options.optimization.providedExports | ||
) { | ||
new FlagDependencyExportsPlugin().apply(compiler); | ||
} | ||
} | ||
}).apply(compiler); | ||
} | ||
@@ -463,3 +479,2 @@ } | ||
if (options.optimization.providedExports) { | ||
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin"); | ||
new FlagDependencyExportsPlugin().apply(compiler); | ||
@@ -466,0 +481,0 @@ } |
{ | ||
"name": "webpack", | ||
"version": "5.99.5", | ||
"version": "5.99.6", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
5301633
0.35%151363
0.28%28
3.7%