Enhance refactor commands with controller-aware Route() updates and fix code quality violations

Add semantic token highlighting for 'that' variable and comment file references in VS Code extension
Add Phone_Text_Input and Currency_Input components with formatting utilities
Implement client widgets, form standardization, and soft delete functionality
Add modal scroll lock and update documentation
Implement comprehensive modal system with form integration and validation
Fix modal component instantiation using jQuery plugin API
Implement modal system with responsive sizing, queuing, and validation support
Implement form submission with validation, error handling, and loading states
Implement country/state selectors with dynamic data loading and Bootstrap styling
Revert Rsx::Route() highlighting in Blade/PHP files
Target specific PHP scopes for Rsx::Route() highlighting in Blade
Expand injection selector for Rsx::Route() highlighting
Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls
Update jqhtml packages to v2.2.165
Add bundle path validation for common mistakes (development mode only)
Create Ajax_Select_Input widget and Rsx_Reference_Data controller
Create Country_Select_Input widget with default country support
Initialize Tom Select on Select_Input widgets
Add Tom Select bundle for enhanced select dropdowns
Implement ISO 3166 geographic data system for country/region selection
Implement widget-based form system with disabled state support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-30 06:21:56 +00:00
parent e678b987c2
commit f6ac36c632
5683 changed files with 5854736 additions and 22329 deletions

View File

@@ -17,6 +17,7 @@ const {
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
@@ -89,7 +90,9 @@ class ArrayPushCallbackChunkFormatPlugin {
runtime.add(
Template.renderRuntimeModules(runtimeModules, {
...renderContext,
codeGenerationResults: compilation.codeGenerationResults
codeGenerationResults:
/** @type {CodeGenerationResults} */
(compilation.codeGenerationResults)
})
);
}

View File

@@ -8,6 +8,9 @@
/** @typedef {import("estree").Node} Node */
/** @typedef {import("./JavascriptParser").Range} Range */
/** @typedef {import("./JavascriptParser").VariableInfo} VariableInfo */
/** @typedef {import("./JavascriptParser").Members} Members */
/** @typedef {import("./JavascriptParser").MembersOptionals} MembersOptionals */
/** @typedef {import("./JavascriptParser").MemberRanges} MemberRanges */
const TypeUnknown = 0;
const TypeUndefined = 1;
@@ -24,6 +27,10 @@ const TypeWrapped = 11;
const TypeTemplateString = 12;
const TypeBigInt = 13;
/** @typedef {() => Members} GetMembers */
/** @typedef {() => MembersOptionals} GetMembersOptionals */
/** @typedef {() => MemberRanges} GetMemberRanges */
class BasicEvaluatedExpression {
constructor() {
this.type = TypeUnknown;
@@ -67,11 +74,11 @@ class BasicEvaluatedExpression {
this.identifier = undefined;
/** @type {string | VariableInfo | undefined} */
this.rootInfo = undefined;
/** @type {(() => string[]) | undefined} */
/** @type {GetMembers | undefined} */
this.getMembers = undefined;
/** @type {(() => boolean[]) | undefined} */
/** @type {GetMembersOptionals | undefined} */
this.getMembersOptionals = undefined;
/** @type {(() => Range[]) | undefined} */
/** @type {GetMemberRanges | undefined} */
this.getMemberRanges = undefined;
/** @type {Node | undefined} */
this.expression = undefined;
@@ -388,9 +395,9 @@ class BasicEvaluatedExpression {
* Set's the value of this expression to a particular identifier and its members.
* @param {string | VariableInfo} identifier identifier to set
* @param {string | VariableInfo} rootInfo root info
* @param {() => string[]} getMembers members
* @param {() => boolean[]=} getMembersOptionals optional members
* @param {() => Range[]=} getMemberRanges ranges of progressively increasing sub-expressions
* @param {GetMembers} getMembers members
* @param {GetMembersOptionals=} getMembersOptionals optional members
* @param {GetMemberRanges=} getMemberRanges ranges of progressively increasing sub-expressions
* @returns {this} this
*/
setIdentifier(

View File

@@ -18,7 +18,7 @@ const { updateHashForEntryStartup } = require("./StartupHelpers");
* Gets information about a chunk including its entries and runtime chunk
* @param {Chunk} chunk The chunk to get information for
* @param {ChunkGraph} chunkGraph The chunk graph containing the chunk
* @returns {{entries: Array<[Module, Entrypoint | undefined]>, runtimeChunk: Chunk|null}} Object containing chunk entries and runtime chunk
* @returns {{ entries: [Module, Entrypoint | undefined][], runtimeChunk: Chunk | null }} Object containing chunk entries and runtime chunk
*/
function getChunkInfo(chunk, chunkGraph) {
const entries = [

View File

@@ -21,7 +21,6 @@ const { generateEntryStartup } = require("./StartupHelpers");
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Entrypoint")} Entrypoint */
const PLUGIN_NAME = "CommonJsChunkFormatPlugin";

View File

@@ -13,17 +13,16 @@ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
/** @typedef {import("../DependenciesBlock")} DependenciesBlock */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../NormalModule")} NormalModule */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
const DEFAULT_SOURCE = {
source() {
@@ -213,7 +212,7 @@ class JavascriptGenerator extends Generator {
*/
sourceDependency(module, dependency, initFragments, source, generateContext) {
const constructor =
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
/** @type {DependencyConstructor} */
(dependency.constructor);
const template = generateContext.dependencyTemplates.get(constructor);
if (!template) {

View File

@@ -52,8 +52,7 @@ const JavascriptParser = require("./JavascriptParser");
/** @typedef {import("eslint-scope").Variable} Variable */
/** @typedef {import("estree").Program} Program */
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
@@ -445,7 +444,6 @@ class JavascriptModulesPlugin {
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
const {
chunkGraph,
codeGenerationResults,
moduleGraph,
runtimeTemplate,
outputOptions: {
@@ -455,7 +453,10 @@ class JavascriptModulesPlugin {
hashFunction
}
} = compilation;
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
const codeGenerationResults =
/** @type {CodeGenerationResults} */
(compilation.codeGenerationResults);
const hash = createHash(hashFunction);
if (hashSalt) hash.update(hashSalt);
if (chunk.hasRuntime()) {
this.updateHashWithBootstrap(
@@ -502,11 +503,10 @@ class JavascriptModulesPlugin {
}
xor.updateHash(hash);
}
const digest = /** @type {string} */ (hash.digest(hashDigest));
const digest = hash.digest(hashDigest);
chunk.contentHash.javascript = nonNumericOnlyHash(
digest,
/** @type {number} */
(hashDigestLength)
hashDigestLength
);
});
compilation.hooks.additionalTreeRuntimeRequirements.tap(
@@ -591,11 +591,11 @@ class JavascriptModulesPlugin {
if (chunk.filenameTemplate) {
return chunk.filenameTemplate;
} else if (chunk instanceof HotUpdateChunk) {
return /** @type {TemplatePath} */ (outputOptions.hotUpdateChunkFilename);
return outputOptions.hotUpdateChunkFilename;
} else if (chunk.canBeInitial()) {
return /** @type {TemplatePath} */ (outputOptions.filename);
return outputOptions.filename;
}
return /** @type {TemplatePath} */ (outputOptions.chunkFilename);
return outputOptions.chunkFilename;
}
/**
@@ -1356,6 +1356,16 @@ class JavascriptModulesPlugin {
"// This entry module used 'module' so it can't be inlined"
);
}
if (
result.allowInlineStartup &&
entryRuntimeRequirements.has(RuntimeGlobals.thisAsExports)
) {
buf2.push(
"// This entry module used `this` as exports so it can't be inlined"
);
result.allowInlineStartup = false;
}
if (chunks.length > 0) {
buf2.push(
`${i === 0 ? `var ${RuntimeGlobals.exports} = ` : ""}${
@@ -1374,21 +1384,33 @@ class JavascriptModulesPlugin {
);
} else {
if (i === 0) buf2.push(`var ${RuntimeGlobals.exports} = {};`);
if (requireScopeUsed) {
buf2.push(
`__webpack_modules__[${moduleIdExpr}](0, ${
i === 0 ? RuntimeGlobals.exports : "{}"
}, ${RuntimeGlobals.require});`
);
} else if (entryRuntimeRequirements.has(RuntimeGlobals.exports)) {
buf2.push(
`__webpack_modules__[${moduleIdExpr}](0, ${
i === 0 ? RuntimeGlobals.exports : "{}"
});`
);
} else {
buf2.push(`__webpack_modules__[${moduleIdExpr}]();`);
const needThisAsExports = entryRuntimeRequirements.has(
RuntimeGlobals.thisAsExports
);
/** @type {string[]} */
const args = [];
if (
requireScopeUsed ||
entryRuntimeRequirements.has(RuntimeGlobals.exports)
) {
const exportsArg = i === 0 ? RuntimeGlobals.exports : "{}";
args.push("0", exportsArg);
if (requireScopeUsed) {
args.push(RuntimeGlobals.require);
}
}
buf2.push(
Template.asString(
(() => {
if (needThisAsExports) {
const comma = args.length ? "," : "";
return `__webpack_modules__[${moduleIdExpr}].call(${RuntimeGlobals.exports}${comma}${args.join(",")});`;
}
return `__webpack_modules__[${moduleIdExpr}](${args.join(",")});`;
})()
)
);
}
}
if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {

View File

@@ -24,7 +24,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").BlockStatement} BlockStatement */
/** @typedef {import("estree").SequenceExpression} SequenceExpression */
/** @typedef {import("estree").CallExpression} CallExpression */
/** @typedef {import("estree").BaseCallExpression} BaseCallExpression */
/** @typedef {import("estree").StaticBlock} StaticBlock */
/** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
/** @typedef {import("estree").ForStatement} ForStatement */
@@ -36,6 +35,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").ImportAttribute} ImportAttribute */
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
/** @typedef {import("estree").IfStatement} IfStatement */
@@ -48,7 +49,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").MetaProperty} MetaProperty */
/** @typedef {import("estree").Property} Property */
/** @typedef {import("estree").AssignmentPattern} AssignmentPattern */
/** @typedef {import("estree").ChainElement} ChainElement */
/** @typedef {import("estree").Pattern} Pattern */
/** @typedef {import("estree").UpdateExpression} UpdateExpression */
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
@@ -74,6 +74,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").WhileStatement} WhileStatement */
/** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
/** @typedef {import("estree").ExpressionStatement} ExpressionStatement */
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
/** @typedef {import("estree").DoWhileStatement} DoWhileStatement */
/** @typedef {import("estree").TryStatement} TryStatement */
@@ -83,10 +85,9 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").Statement} Statement */
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
/** @typedef {import("estree").Super} Super */
/** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
/** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
/** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
/** @typedef {import("estree").MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration */
/** @typedef {import("estree").MaybeNamedClassDeclaration} MaybeNamedClassDeclaration */
/**
@@ -95,19 +96,17 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
*/
/** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges }} GetInfoResult */
/** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
/** @typedef {(ident: string) => void} OnIdentString */
/** @typedef {(ident: string, identifier: Identifier) => void} OnIdent */
/** @typedef {StatementPathItem[]} StatementPath */
/** @typedef {Set<DestructuringAssignmentProperty>} DestructuringAssignmentProperties */
// TODO remove cast when @types/estree has been updated to import assertions
/** @typedef {import("estree").BaseNode & { type: "ImportAttribute", key: Identifier | Literal, value: Literal }} ImportAttribute */
/** @typedef {import("estree").ImportDeclaration & { attributes?: Array<ImportAttribute>, phase?: "defer" }} ImportDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration & { attributes?: Array<ImportAttribute> }} ExportNamedDeclaration */
/** @typedef {import("estree").ExportAllDeclaration & { attributes?: Array<ImportAttribute> }} ExportAllDeclaration */
/** @typedef {import("estree").ImportExpression & { options?: Expression | null, phase?: "defer" }} ImportExpression */
/** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
/** @typedef {import("estree").ImportExpression & { phase?: "defer" }} ImportExpression */
/** @type {string[]} */
const EMPTY_ARRAY = [];
@@ -301,7 +300,15 @@ class VariableInfo {
/** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
/** @typedef {symbol} Tag */
/** @typedef {Record<string, TODO>} TagData */
/** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
/** @typedef {import("../dependencies/ImportParserPlugin").ImportSettings} ImportSettings */
/** @typedef {import("../dependencies/CommonJsImportsParserPlugin").CommonJsImportSettings} CommonJsImportSettings */
/** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
/** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings} KnownTagData */
/** @typedef {KnownTagData | Record<string, EXPECTED_ANY>} TagData */
/**
* @typedef {object} TagInfo
@@ -310,6 +317,11 @@ class VariableInfo {
* @property {TagInfo | undefined} next
*/
/** @typedef {string[]} CalleeMembers */
/** @typedef {string[]} Members */
/** @typedef {boolean[]} MembersOptionals */
/** @typedef {Range[]} MemberRanges */
const SCOPE_INFO_TERMINATED_RETURN = 1;
const SCOPE_INFO_TERMINATED_THROW = 2;
@@ -330,7 +342,8 @@ const SCOPE_INFO_TERMINATED_THROW = 2;
/**
* @typedef {object} DestructuringAssignmentProperty
* @property {string} id
* @property {Range | undefined=} range
* @property {Range} range
* @property {Set<DestructuringAssignmentProperty> | undefined=} pattern
* @property {boolean | string} shorthand
*/
@@ -359,7 +372,7 @@ const joinRanges = (startRange, endRange) => {
* Helper function used to generate a string representation of a
* [member expression](https://github.com/estree/estree/blob/master/es5.md#memberexpression).
* @param {string} object object to name
* @param {string[]} membersReversed reversed list of members
* @param {Members} membersReversed reversed list of members
* @returns {string} member expression as a string
* @example
* ```js
@@ -532,20 +545,20 @@ class JavascriptParser extends Parser {
rename: new HookMap(() => new SyncBailHook(["initExpression"])),
/** @type {HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>} */
assign: new HookMap(() => new SyncBailHook(["expression"])),
/** @type {HookMap<SyncBailHook<[AssignmentExpression, string[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[AssignmentExpression, Members], boolean | void>>} */
assignMemberChain: new HookMap(
() => new SyncBailHook(["expression", "members"])
),
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
typeof: new HookMap(() => new SyncBailHook(["expression"])),
/** @type {SyncBailHook<[ImportExpression], boolean | void>} */
importCall: new SyncBailHook(["expression"]),
/** @type {SyncBailHook<[ImportExpression, CallExpression?], boolean | void>} */
importCall: new SyncBailHook(["expression", "importThen"]),
/** @type {SyncBailHook<[Expression | ForOfStatement], boolean | void>} */
topLevelAwait: new SyncBailHook(["expression"]),
/** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
call: new HookMap(() => new SyncBailHook(["expression"])),
/** Something like "a.b()" */
/** @type {HookMap<SyncBailHook<[CallExpression, string[], boolean[], Range[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[CallExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
callMemberChain: new HookMap(
() =>
new SyncBailHook([
@@ -556,7 +569,7 @@ class JavascriptParser extends Parser {
])
),
/** Something like "a.b().c.d" */
/** @type {HookMap<SyncBailHook<[Expression, string[], CallExpression, string[], Range[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[Expression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
memberChainOfCallMemberChain: new HookMap(
() =>
new SyncBailHook([
@@ -568,7 +581,7 @@ class JavascriptParser extends Parser {
])
),
/** Something like "a.b().c.d()"" */
/** @type {HookMap<SyncBailHook<[CallExpression, string[], CallExpression, string[], Range[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[CallExpression, CalleeMembers, CallExpression, Members, MemberRanges], boolean | void>>} */
callMemberChainOfCallMemberChain: new HookMap(
() =>
new SyncBailHook([
@@ -587,7 +600,7 @@ class JavascriptParser extends Parser {
binaryExpression: new SyncBailHook(["binaryExpression"]),
/** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
expression: new HookMap(() => new SyncBailHook(["expression"])),
/** @type {HookMap<SyncBailHook<[MemberExpression, string[], boolean[], Range[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[MemberExpression, Members, MembersOptionals, MemberRanges], boolean | void>>} */
expressionMemberChain: new HookMap(
() =>
new SyncBailHook([
@@ -597,7 +610,7 @@ class JavascriptParser extends Parser {
"memberRanges"
])
),
/** @type {HookMap<SyncBailHook<[MemberExpression, string[]], boolean | void>>} */
/** @type {HookMap<SyncBailHook<[MemberExpression, Members], boolean | void>>} */
unhandledExpressionMemberChain: new HookMap(
() => new SyncBailHook(["expression", "members"])
),
@@ -616,9 +629,9 @@ class JavascriptParser extends Parser {
});
this.sourceType = sourceType;
/** @type {ScopeInfo} */
this.scope = /** @type {TODO} */ (undefined);
this.scope = /** @type {EXPECTED_ANY} */ (undefined);
/** @type {ParserState} */
this.state = /** @type {TODO} */ (undefined);
this.state = /** @type {EXPECTED_ANY} */ (undefined);
/** @type {Comment[] | undefined} */
this.comments = undefined;
/** @type {Set<number> | undefined} */
@@ -627,7 +640,7 @@ class JavascriptParser extends Parser {
this.statementPath = undefined;
/** @type {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | undefined} */
this.prevStatement = undefined;
/** @type {WeakMap<Expression, Set<DestructuringAssignmentProperty>> | undefined} */
/** @type {WeakMap<Expression, DestructuringAssignmentProperties> | undefined} */
this.destructuringAssignmentProperties = undefined;
/** @type {TagData | undefined} */
this.currentTagData = undefined;
@@ -1891,7 +1904,7 @@ class JavascriptParser extends Parser {
/**
* @param {Expression} node node
* @returns {Set<DestructuringAssignmentProperty> | undefined} destructured identifiers
* @returns {DestructuringAssignmentProperties | undefined} destructured identifiers
*/
destructuringAssignmentPropertiesFor(node) {
if (!this.destructuringAssignmentProperties) return;
@@ -2644,7 +2657,7 @@ class JavascriptParser extends Parser {
// check multiple assignments
if (this.destructuringAssignmentProperties.has(destructuring)) {
const set =
/** @type {Set<DestructuringAssignmentProperty>} */
/** @type {DestructuringAssignmentProperties} */
(this.destructuringAssignmentProperties.get(destructuring));
for (const id of keys) set.add(id);
} else {
@@ -2829,11 +2842,16 @@ class JavascriptParser extends Parser {
* @param {ExportDefaultDeclaration} statement statement
*/
blockPreWalkExportDefaultDeclaration(statement) {
const prev = this.prevStatement;
if (
statement.declaration.type === "FunctionDeclaration" ||
statement.declaration.type === "ClassDeclaration"
) {
const prev = this.prevStatement;
this.preWalkStatement(/** @type {TODO} */ (statement.declaration));
this.prevStatement = prev;
this.blockPreWalkStatement(/** @type {TODO} */ (statement.declaration));
this.preWalkStatement(statement.declaration);
this.prevStatement = prev;
this.blockPreWalkStatement(statement.declaration);
}
if (
/** @type {MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} */
@@ -2885,15 +2903,7 @@ class JavascriptParser extends Parser {
this.walkExpression(statement.declaration);
}
if (!this.hooks.exportExpression.call(statement, statement.declaration)) {
this.hooks.exportSpecifier.call(
statement,
/** @type {TODO} */
(statement.declaration),
"default",
undefined
);
}
this.hooks.exportExpression.call(statement, statement.declaration);
}
}
@@ -2963,10 +2973,10 @@ class JavascriptParser extends Parser {
/**
* @param {ObjectPattern} objectPattern object pattern
* @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
* @returns {DestructuringAssignmentProperties | undefined} set of names or undefined if not all keys are identifiers
*/
_preWalkObjectPattern(objectPattern) {
/** @type {Set<DestructuringAssignmentProperty>} */
/** @type {DestructuringAssignmentProperties} */
const props = new Set();
const properties = objectPattern.properties;
for (let i = 0; i < properties.length; i++) {
@@ -2984,18 +2994,32 @@ class JavascriptParser extends Parser {
}
const key = property.key;
if (key.type === "Identifier" && !property.computed) {
const pattern =
property.value.type === "ObjectPattern"
? this._preWalkObjectPattern(property.value)
: property.value.type === "ArrayPattern"
? this._preWalkArrayPattern(property.value)
: undefined;
props.add({
id: key.name,
range: key.range,
range: /** @type {Range} */ (key.range),
pattern,
shorthand: this.scope.inShorthand
});
} else {
const id = this.evaluateExpression(key);
const str = id.asString();
if (str) {
const pattern =
property.value.type === "ObjectPattern"
? this._preWalkObjectPattern(property.value)
: property.value.type === "ArrayPattern"
? this._preWalkArrayPattern(property.value)
: undefined;
props.add({
id: str,
range: key.range,
range: /** @type {Range} */ (key.range),
pattern,
shorthand: this.scope.inShorthand
});
} else {
@@ -3009,6 +3033,35 @@ class JavascriptParser extends Parser {
return props;
}
/**
* @param {ArrayPattern} arrayPattern array pattern
* @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
*/
_preWalkArrayPattern(arrayPattern) {
/** @type {Set<DestructuringAssignmentProperty>} */
const props = new Set();
const elements = arrayPattern.elements;
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
if (!element) continue;
if (element.type === "RestElement") return;
const pattern =
element.type === "ObjectPattern"
? this._preWalkObjectPattern(element)
: element.type === "ArrayPattern"
? this._preWalkArrayPattern(element)
: undefined;
props.add({
id: `${i}`,
range: /** @type {Range} */ (element.range),
pattern,
shorthand: false
});
}
return props;
}
/**
* @param {VariableDeclarator} declarator variable declarator
*/
@@ -3833,6 +3886,18 @@ class JavascriptParser extends Parser {
);
if (result === true) return;
}
// import("./m").then(m => { ... })
if (
expression.callee.object.type === "ImportExpression" &&
expression.callee.property.type === "Identifier" &&
expression.callee.property.name === "then"
) {
const result = this.hooks.importCall.call(
expression.callee.object,
expression
);
if (result === true) return;
}
}
const callee = this.evaluateExpression(expression.callee);
if (callee.isIdentifier()) {
@@ -3945,7 +4010,7 @@ class JavascriptParser extends Parser {
* @param {MemberExpression} expression member expression
* @param {string} name name
* @param {string | VariableInfo} rootInfo root info
* @param {string[]} members members
* @param {Members} members members
* @param {() => R | undefined} onUnhandled on unhandled callback
*/
walkMemberExpressionWithExpressionName(
@@ -4027,7 +4092,7 @@ class JavascriptParser extends Parser {
* @template R
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {Expression | Super} expr expression info
* @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => string[]) => R) | undefined} fallback callback when variable in not handled by hooks
* @param {((name: string, rootInfo: string | ScopeInfo | VariableInfo, getMembers: () => Members) => R) | undefined} fallback callback when variable in not handled by hooks
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
@@ -4098,7 +4163,7 @@ class JavascriptParser extends Parser {
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {ExportedVariableInfo} info variable info
* @param {((name: string) => R | undefined) | undefined} fallback callback when variable in not handled by hooks
* @param {((result?: string) => TODO) | undefined} defined callback when variable is defined
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/
@@ -4286,7 +4351,7 @@ class JavascriptParser extends Parser {
}
/**
* @param {Array<Directive | Statement | ModuleDeclaration>} statements statements
* @param {(Directive | Statement | ModuleDeclaration)[]} statements statements
*/
detectMode(statements) {
const isLiteral =
@@ -4606,7 +4671,7 @@ class JavascriptParser extends Parser {
terminated: undefined,
definitions: new StackedMap()
};
this.state = /** @type {ParserState} */ (state);
this.state = state;
this.comments = comments;
this.semicolons = semicolons;
this.statementPath = [];
@@ -4960,7 +5025,7 @@ class JavascriptParser extends Parser {
/**
* @param {string} name variable name
* @returns {string | ExportedVariableInfo} info for this variable
* @returns {ExportedVariableInfo} info for this variable
*/
getVariableInfo(name) {
const value = this.scope.definitions.get(name);
@@ -4972,7 +5037,7 @@ class JavascriptParser extends Parser {
/**
* @param {string} name variable name
* @param {string | ExportedVariableInfo} variableInfo new info for this variable
* @param {ExportedVariableInfo} variableInfo new info for this variable
* @returns {void}
*/
setVariable(name, variableInfo) {
@@ -5053,7 +5118,7 @@ class JavascriptParser extends Parser {
/**
* @param {Expression | Super} expression a member expression
* @returns {{ members: string[], object: Expression | Super, membersOptionals: boolean[], memberRanges: Range[] }} member names (reverse order) and remaining object
* @returns {{ members: Members, object: Expression | Super, membersOptionals: MembersOptionals, memberRanges: MemberRanges }} member names (reverse order) and remaining object
*/
extractMemberExpressionChain(expression) {
/** @type {Node} */
@@ -5119,8 +5184,8 @@ class JavascriptParser extends Parser {
return { info, name };
}
/** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[]}} CallExpressionInfo */
/** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[]}} ExpressionExpressionInfo */
/** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => CalleeMembers, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} CallExpressionInfo */
/** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => Members, getMembersOptionals: () => MembersOptionals, getMemberRanges: () => MemberRanges}} ExpressionExpressionInfo */
/**
* @param {Expression | Super} expression a member expression
@@ -5181,7 +5246,7 @@ class JavascriptParser extends Parser {
/**
* @param {Expression} expression an expression
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => string[]} | undefined} name info
* @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => Members} | undefined} name info
*/
getNameForExpression(expression) {
return this.getMemberExpressionInfo(

View File

@@ -10,10 +10,10 @@ const ConstDependency = require("../dependencies/ConstDependency");
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").Node} Node */
/** @typedef {import("estree").SourceLocation} SourceLocation */
/** @typedef {import("./JavascriptParser")} JavascriptParser */
/** @typedef {import("./JavascriptParser").Range} Range */
/** @typedef {import("./BasicEvaluatedExpression").GetMembers} GetMembers */
module.exports.approve = () => true;
@@ -31,7 +31,7 @@ module.exports.evaluateToBoolean = (value) =>
/**
* @param {string} identifier identifier
* @param {string} rootInfo rootInfo
* @param {() => string[]} getMembers getMembers
* @param {GetMembers} getMembers getMembers
* @param {boolean | null=} truthy is truthy, null if nullish
* @returns {(expression: Expression) => BasicEvaluatedExpression} callback
*/

View File

@@ -13,14 +13,11 @@ const { getAllChunks } = require("./ChunkHelpers");
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Chunk").ChunkId} ChunkId */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
/** @typedef {import("../Entrypoint")} Entrypoint */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {(string|number)[]} EntryItem */
const EXPORT_PREFIX = `var ${RuntimeGlobals.exports} = `;
@@ -137,9 +134,10 @@ module.exports.generateEntryStartup = (
* @param {Chunk} chunk the chunk
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
* @returns {Set<number | string>} initially fulfilled chunk ids
* @returns {Set<ChunkId>} initially fulfilled chunk ids
*/
module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
/** @type {Set<ChunkId>} */
const initialChunkIds = new Set(chunk.ids);
for (const c of chunk.getAllInitialChunks()) {
if (c === chunk || filterFn(c, chunkGraph)) continue;