feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

42
node_modules/webpack/lib/Template.js generated vendored
View File

@@ -13,6 +13,7 @@ const RuntimeGlobals = require("./RuntimeGlobals");
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").PathData} PathData */
@@ -22,6 +23,7 @@ const RuntimeGlobals = require("./RuntimeGlobals");
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */
/** @typedef {import("./RuntimeModule")} RuntimeModule */
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
/** @typedef {import("./javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
@@ -59,7 +61,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
/**
* @typedef {object} RenderManifestEntryTemplated
* @property {function(): Source} render
* @property {string | function(PathData, AssetInfo=): string} filenameTemplate
* @property {TemplatePath} filenameTemplate
* @property {PathData=} pathOptions
* @property {AssetInfo=} info
* @property {string} identifier
@@ -88,7 +90,6 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
class Template {
/**
*
* @param {Function} fn a runtime function (.runtime.js) "template"
* @returns {string} the updated and normalized function string
*/
@@ -110,8 +111,8 @@ class Template {
.replace(IDENTIFIER_NAME_REPLACE_REGEX, "_$1")
.replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
}
/**
*
* @param {string} str string to be converted to commented in bundle code
* @returns {string} returns a commented version of string
*/
@@ -121,7 +122,6 @@ class Template {
}
/**
*
* @param {string} str string to be converted to "normal comment"
* @returns {string} returns a commented version of string
*/
@@ -211,23 +211,20 @@ class Template {
}
/**
*
* @param {string | string[]} s string to convert to identity
* @returns {string} converted identity
*/
static indent(s) {
if (Array.isArray(s)) {
return s.map(Template.indent).join("\n");
} else {
const str = s.trimEnd();
if (!str) return "";
const ind = str[0] === "\n" ? "" : "\t";
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
}
const str = s.trimEnd();
if (!str) return "";
const ind = str[0] === "\n" ? "" : "\t";
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
}
/**
*
* @param {string|string[]} s string to create prefix for
* @param {string} prefix prefix to compose
* @returns {string} returns new prefix string
@@ -236,11 +233,10 @@ class Template {
const str = Template.asString(s).trim();
if (!str) return "";
const ind = str[0] === "\n" ? "" : prefix;
return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
return ind + str.replace(/\n([^\n])/g, `\n${prefix}$1`);
}
/**
*
* @param {string|string[]} str string or string collection
* @returns {string} returns a single string from array
*/
@@ -270,7 +266,7 @@ class Template {
if (maxId < moduleId) maxId = moduleId;
if (minId > moduleId) minId = moduleId;
}
if (minId < 16 + ("" + minId).length) {
if (minId < 16 + String(minId).length) {
// add minId x ',' instead of 'Array(minId).concat(…)'
minId = 0;
}
@@ -288,23 +284,21 @@ class Template {
/**
* @param {ChunkRenderContext} renderContext render context
* @param {Module[]} modules modules to render (should be ordered by identifier)
* @param {function(Module): Source} renderModule function to render a module
* @param {function(Module): Source | null} renderModule function to render a module
* @param {string=} prefix applying prefix strings
* @returns {Source | null} rendered chunk modules in a Source object or null if no modules
*/
static renderChunkModules(renderContext, modules, renderModule, prefix = "") {
const { chunkGraph } = renderContext;
var source = new ConcatSource();
const source = new ConcatSource();
if (modules.length === 0) {
return null;
}
/** @type {{id: string|number, source: Source|string}[]} */
const allModules = modules.map(module => {
return {
id: chunkGraph.getModuleId(module),
source: renderModule(module) || "false"
};
});
const allModules = modules.map(module => ({
id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)),
source: renderModule(module) || "false"
}));
const bounds = Template.getModulesArrayBounds(allModules);
if (bounds) {
// Render a spare array
@@ -330,7 +324,7 @@ class Template {
source.add(module.source);
}
}
source.add("\n" + prefix + "]");
source.add(`\n${prefix}]`);
if (minId !== 0) {
source.add(")");
}
@@ -379,7 +373,7 @@ class Template {
runtimeSource = codeGenResult.sources.get("runtime");
}
if (runtimeSource) {
source.add(Template.toNormalComment(module.identifier()) + "\n");
source.add(`${Template.toNormalComment(module.identifier())}\n`);
if (!module.shouldIsolate()) {
source.add(runtimeSource);
source.add("\n\n");