Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
182
node_modules/webpack/lib/javascript/JavascriptParser.js
generated
vendored
Executable file → Normal file
182
node_modules/webpack/lib/javascript/JavascriptParser.js
generated
vendored
Executable file → Normal file
@@ -8,6 +8,7 @@
|
||||
const vm = require("vm");
|
||||
const { Parser: AcornParser, tokTypes } = require("acorn");
|
||||
const { HookMap, SyncBailHook } = require("tapable");
|
||||
const NormalModule = require("../NormalModule");
|
||||
const Parser = require("../Parser");
|
||||
const StackedMap = require("../util/StackedMap");
|
||||
const binarySearchBounds = require("../util/binarySearchBounds");
|
||||
@@ -19,6 +20,7 @@ const memoize = require("../util/memoize");
|
||||
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||
|
||||
/** @typedef {import("acorn").Options} AcornOptions */
|
||||
/** @typedef {import("acorn").ecmaVersion} EcmaVersion */
|
||||
/** @typedef {import("estree").AssignmentExpression} AssignmentExpression */
|
||||
/** @typedef {import("estree").BinaryExpression} BinaryExpression */
|
||||
/** @typedef {import("estree").BlockStatement} BlockStatement */
|
||||
@@ -29,7 +31,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||
/** @typedef {import("estree").ForStatement} ForStatement */
|
||||
/** @typedef {import("estree").SwitchStatement} SwitchStatement */
|
||||
/** @typedef {import("estree").ClassExpression} ClassExpression */
|
||||
/** @typedef {import("estree").Comment} Comment */
|
||||
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("estree").Comment & { start: number, end: number, loc: SourceLocation }} Comment */
|
||||
/** @typedef {import("estree").ConditionalExpression} ConditionalExpression */
|
||||
/** @typedef {import("estree").Declaration} Declaration */
|
||||
/** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
|
||||
@@ -97,6 +100,9 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
||||
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
|
||||
/** @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 */
|
||||
@@ -297,7 +303,33 @@ class VariableInfo {
|
||||
|
||||
/** @typedef {string | ScopeInfo | VariableInfo} ExportedVariableInfo */
|
||||
/** @typedef {Literal | string | null | undefined} ImportSource */
|
||||
/** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
|
||||
|
||||
/**
|
||||
* @typedef {Omit<ParseOptions, "sourceType"> & {sourceType: "module" | "script" | "auto"}} InternalParseOptions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ParseOptions
|
||||
* @property {"module" | "script"} sourceType
|
||||
* @property {EcmaVersion=} ecmaVersion
|
||||
* @property {boolean=} locations
|
||||
* @property {boolean=} comments
|
||||
* @property {boolean=} ranges
|
||||
* @property {boolean=} semicolons
|
||||
* @property {boolean=} allowHashBang
|
||||
* @property {boolean=} allowReturnOutsideFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ParseResult
|
||||
* @property {Program} ast
|
||||
* @property {Comment[]} comments
|
||||
* @property {Set<number>} semicolons
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {(code: string, options: ParseOptions) => ParseResult} ParseFunction
|
||||
*/
|
||||
|
||||
/** @typedef {symbol} Tag */
|
||||
|
||||
@@ -343,6 +375,7 @@ const SCOPE_INFO_TERMINATED_THROW = 2;
|
||||
* @typedef {object} DestructuringAssignmentProperty
|
||||
* @property {string} id
|
||||
* @property {Range} range
|
||||
* @property {SourceLocation} loc
|
||||
* @property {Set<DestructuringAssignmentProperty> | undefined=} pattern
|
||||
* @property {boolean | string} shorthand
|
||||
*/
|
||||
@@ -412,15 +445,15 @@ const getRootName = (expression) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {AcornOptions} */
|
||||
/** @type {ParseOptions} */
|
||||
const defaultParserOptions = {
|
||||
ranges: true,
|
||||
locations: true,
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
ranges: false,
|
||||
locations: false,
|
||||
comments: false,
|
||||
// https://github.com/tc39/proposal-hashbang
|
||||
allowHashBang: true,
|
||||
onComment: undefined
|
||||
allowHashBang: true
|
||||
};
|
||||
|
||||
const EMPTY_COMMENT_OPTIONS = {
|
||||
@@ -432,9 +465,10 @@ const CLASS_NAME = "JavascriptParser";
|
||||
|
||||
class JavascriptParser extends Parser {
|
||||
/**
|
||||
* @param {"module" | "script" | "auto"} sourceType default source type
|
||||
* @param {"module" | "script" | "auto"=} sourceType default source type
|
||||
* @param {{ parse?: ParseFunction }=} options parser options
|
||||
*/
|
||||
constructor(sourceType = "auto") {
|
||||
constructor(sourceType = "auto", options = {}) {
|
||||
super();
|
||||
this.hooks = Object.freeze({
|
||||
/** @type {HookMap<SyncBailHook<[UnaryExpression], BasicEvaluatedExpression | null | undefined>>} */
|
||||
@@ -628,6 +662,8 @@ class JavascriptParser extends Parser {
|
||||
unusedStatement: new SyncBailHook(["statement"])
|
||||
});
|
||||
this.sourceType = sourceType;
|
||||
this.options = options;
|
||||
|
||||
/** @type {ScopeInfo} */
|
||||
this.scope = /** @type {EXPECTED_ANY} */ (undefined);
|
||||
/** @type {ParserState} */
|
||||
@@ -3003,6 +3039,7 @@ class JavascriptParser extends Parser {
|
||||
props.add({
|
||||
id: key.name,
|
||||
range: /** @type {Range} */ (key.range),
|
||||
loc: /** @type {SourceLocation} */ (key.loc),
|
||||
pattern,
|
||||
shorthand: this.scope.inShorthand
|
||||
});
|
||||
@@ -3019,6 +3056,7 @@ class JavascriptParser extends Parser {
|
||||
props.add({
|
||||
id: str,
|
||||
range: /** @type {Range} */ (key.range),
|
||||
loc: /** @type {SourceLocation} */ (key.loc),
|
||||
pattern,
|
||||
shorthand: this.scope.inShorthand
|
||||
});
|
||||
@@ -3054,6 +3092,7 @@ class JavascriptParser extends Parser {
|
||||
props.add({
|
||||
id: `${i}`,
|
||||
range: /** @type {Range} */ (element.range),
|
||||
loc: /** @type {SourceLocation} */ (element.loc),
|
||||
pattern,
|
||||
shorthand: false
|
||||
});
|
||||
@@ -4626,17 +4665,23 @@ class JavascriptParser extends Parser {
|
||||
* @returns {ParserState} the parser state
|
||||
*/
|
||||
parse(source, state) {
|
||||
let ast;
|
||||
/** @type {import("acorn").Comment[]} */
|
||||
let comments;
|
||||
const semicolons = new Set();
|
||||
if (source === null) {
|
||||
throw new Error("source must not be null");
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(source)) {
|
||||
source = source.toString("utf8");
|
||||
}
|
||||
|
||||
let ast;
|
||||
/** @type {Comment[]} */
|
||||
let comments;
|
||||
/** @type {Set<number>} */
|
||||
let semicolons;
|
||||
|
||||
if (typeof source === "object") {
|
||||
semicolons = new Set();
|
||||
|
||||
ast = /** @type {Program} */ (source);
|
||||
comments = source.comments;
|
||||
if (source.semicolons) {
|
||||
@@ -4647,12 +4692,17 @@ class JavascriptParser extends Parser {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
comments = [];
|
||||
ast = JavascriptParser._parse(source, {
|
||||
sourceType: this.sourceType,
|
||||
onComment: comments,
|
||||
onInsertedSemicolon: (pos) => semicolons.add(pos)
|
||||
});
|
||||
({ ast, comments, semicolons } = JavascriptParser._parse(
|
||||
source,
|
||||
{
|
||||
sourceType: this.sourceType,
|
||||
locations: true,
|
||||
ranges: true,
|
||||
comments: true,
|
||||
semicolons: true
|
||||
},
|
||||
this.options.parse
|
||||
));
|
||||
}
|
||||
|
||||
const oldScope = this.scope;
|
||||
@@ -4702,10 +4752,11 @@ class JavascriptParser extends Parser {
|
||||
* @returns {BasicEvaluatedExpression} evaluation result
|
||||
*/
|
||||
evaluate(source) {
|
||||
const ast = JavascriptParser._parse(`(${source})`, {
|
||||
sourceType: this.sourceType,
|
||||
locations: false
|
||||
});
|
||||
const { ast } = JavascriptParser._parse(
|
||||
`(${source})`,
|
||||
{ sourceType: this.sourceType },
|
||||
this.options.parse
|
||||
);
|
||||
if (ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement") {
|
||||
throw new Error("evaluate: Source is not a expression");
|
||||
}
|
||||
@@ -5256,26 +5307,83 @@ class JavascriptParser extends Parser {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code source code
|
||||
* @param {ParseOptions} options parsing options
|
||||
* @returns {Program} parsed ast
|
||||
* @param {Compilation} compilation compilation
|
||||
* @param {Module} module module
|
||||
* @returns {ParseFunction | undefined} parser
|
||||
*/
|
||||
static _parse(code, options) {
|
||||
static _getModuleParseFunction(compilation, module) {
|
||||
// Get from module if available
|
||||
if (
|
||||
module instanceof NormalModule &&
|
||||
module.parser instanceof JavascriptParser
|
||||
) {
|
||||
return module.parser.options.parse;
|
||||
}
|
||||
|
||||
// Fallback to the global javascript parse function
|
||||
if (typeof compilation.options.module.parser.javascript !== "undefined") {
|
||||
return compilation.options.module.parser.javascript.parse;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code source code
|
||||
* @param {InternalParseOptions} options parsing options
|
||||
* @param {ParseFunction=} customParse custom function to parse
|
||||
* @returns {ParseResult} parse result
|
||||
*/
|
||||
static _parse(code, options, customParse) {
|
||||
const type = options ? options.sourceType : "module";
|
||||
/** @type {AcornOptions} */
|
||||
/** @type {ParseOptions} */
|
||||
const parserOptions = {
|
||||
...defaultParserOptions,
|
||||
allowReturnOutsideFunction: type === "script",
|
||||
...options,
|
||||
sourceType: type === "auto" ? "module" : type
|
||||
};
|
||||
/**
|
||||
* @param {string} code source code
|
||||
* @param {ParseOptions} options parsing options
|
||||
* @returns {ParseResult} parse result
|
||||
*/
|
||||
const internalParse = (code, options) => {
|
||||
if (typeof customParse === "function") {
|
||||
return customParse(code, options);
|
||||
}
|
||||
|
||||
/** @type {import("acorn").Program | undefined} */
|
||||
/** @type {Comment[]} */
|
||||
const comments = [];
|
||||
|
||||
if (options.comments) {
|
||||
/** @type {AcornOptions} */
|
||||
(options).onComment = comments;
|
||||
}
|
||||
|
||||
/** @type {Set<number>} */
|
||||
const semicolons = new Set();
|
||||
|
||||
if (options.semicolons) {
|
||||
/** @type {AcornOptions} */
|
||||
(options).onInsertedSemicolon = (pos) => semicolons.add(pos);
|
||||
}
|
||||
|
||||
const ast =
|
||||
/** @type {Program} */
|
||||
(parser.parse(code, /** @type {AcornOptions} */ (options)));
|
||||
|
||||
return { ast, comments, semicolons };
|
||||
};
|
||||
|
||||
/** @type {Program | undefined} */
|
||||
let ast;
|
||||
/** @type {Comment[] | undefined} */
|
||||
let comments;
|
||||
/** @type {Set<number> | undefined} */
|
||||
let semicolons;
|
||||
let error;
|
||||
let threw = false;
|
||||
try {
|
||||
ast = parser.parse(code, parserOptions);
|
||||
({ ast, comments, semicolons } = internalParse(code, parserOptions));
|
||||
} catch (err) {
|
||||
error = err;
|
||||
threw = true;
|
||||
@@ -5283,14 +5391,10 @@ class JavascriptParser extends Parser {
|
||||
|
||||
if (threw && type === "auto") {
|
||||
parserOptions.sourceType = "script";
|
||||
if (!("allowReturnOutsideFunction" in options)) {
|
||||
parserOptions.allowReturnOutsideFunction = true;
|
||||
}
|
||||
if (Array.isArray(parserOptions.onComment)) {
|
||||
parserOptions.onComment.length = 0;
|
||||
}
|
||||
parserOptions.allowReturnOutsideFunction = true;
|
||||
|
||||
try {
|
||||
ast = parser.parse(code, parserOptions);
|
||||
({ ast, comments, semicolons } = internalParse(code, parserOptions));
|
||||
threw = false;
|
||||
} catch (_err) {
|
||||
// we use the error from first parse try
|
||||
@@ -5302,7 +5406,7 @@ class JavascriptParser extends Parser {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return /** @type {Program} */ (ast);
|
||||
return /** @type {ParseResult} */ ({ ast, comments, semicolons });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user