Add JS-CATCH-FALLBACK-01 rule and update npm packages
Add PHP-ALIAS-01 rule: prohibit field aliasing in serialization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
50
node_modules/webpack/lib/css/CssGenerator.js
generated
vendored
50
node_modules/webpack/lib/css/CssGenerator.js
generated
vendored
@@ -12,10 +12,10 @@ const InitFragment = require("../InitFragment");
|
||||
const {
|
||||
CSS_TYPE,
|
||||
CSS_TYPES,
|
||||
JS_AND_CSS_TYPES,
|
||||
JS_TYPE,
|
||||
JS_TYPES
|
||||
} = require("../ModuleSourceTypesConstants");
|
||||
JAVASCRIPT_AND_CSS_TYPES,
|
||||
JAVASCRIPT_TYPE,
|
||||
JAVASCRIPT_TYPES
|
||||
} = require("../ModuleSourceTypeConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const Template = require("../Template");
|
||||
const CssImportDependency = require("../dependencies/CssImportDependency");
|
||||
@@ -23,8 +23,6 @@ const { getUndoPath } = require("../util/identifier");
|
||||
const memoize = require("../util/memoize");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
@@ -36,6 +34,7 @@ const memoize = require("../util/memoize");
|
||||
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("../Module").SourceType} SourceType */
|
||||
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../NormalModule")} NormalModule */
|
||||
@@ -51,13 +50,12 @@ const getCssModulesPlugin = memoize(() => require("./CssModulesPlugin"));
|
||||
|
||||
class CssGenerator extends Generator {
|
||||
/**
|
||||
* @param {CssAutoGeneratorOptions | CssGlobalGeneratorOptions | CssModuleGeneratorOptions} options options
|
||||
* @param {CssModuleGeneratorOptions} options options
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
*/
|
||||
constructor(options, moduleGraph) {
|
||||
super();
|
||||
this.convention = options.exportsConvention;
|
||||
this.localIdentName = options.localIdentName;
|
||||
this.options = options;
|
||||
this._exportsOnly = options.exportsOnly;
|
||||
this._esModule = options.esModule;
|
||||
this._moduleGraph = moduleGraph;
|
||||
@@ -127,7 +125,7 @@ class CssGenerator extends Generator {
|
||||
const moduleSourceContent = /** @type {Source} */ (
|
||||
this.generate(module, {
|
||||
...generateContext,
|
||||
type: "css"
|
||||
type: CSS_TYPE
|
||||
})
|
||||
);
|
||||
|
||||
@@ -266,7 +264,7 @@ class CssGenerator extends Generator {
|
||||
generate(module, generateContext) {
|
||||
const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType;
|
||||
const source =
|
||||
generateContext.type === "javascript"
|
||||
generateContext.type === JAVASCRIPT_TYPE
|
||||
? exportType === "link"
|
||||
? new ReplaceSource(new RawSource(""))
|
||||
: new ReplaceSource(/** @type {Source} */ (module.originalSource()))
|
||||
@@ -330,7 +328,7 @@ class CssGenerator extends Generator {
|
||||
};
|
||||
|
||||
switch (generateContext.type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
const isCSSModule = /** @type {BuildMeta} */ (module.buildMeta)
|
||||
.isCSSModule;
|
||||
const defaultExport = generateJSDefaultExport();
|
||||
@@ -374,14 +372,15 @@ class CssGenerator extends Generator {
|
||||
if (!usedName) {
|
||||
continue;
|
||||
}
|
||||
let identifier = Template.toIdentifier(usedName);
|
||||
|
||||
let identifier = Template.toIdentifier(usedName);
|
||||
if (RESERVED_IDENTIFIER.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
const i = 0;
|
||||
let i = 0;
|
||||
while (usedIdentifiers.has(identifier)) {
|
||||
identifier = Template.toIdentifier(name + i);
|
||||
i += 1;
|
||||
}
|
||||
usedIdentifiers.add(identifier);
|
||||
generateContext.concatenationScope.registerExport(name, identifier);
|
||||
@@ -428,7 +427,7 @@ class CssGenerator extends Generator {
|
||||
}.exports = {\n${exports.join(",\n")}\n}${needNsObj ? ")" : ""};`
|
||||
);
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
if (!this._generatesJsOnly(module)) {
|
||||
generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);
|
||||
}
|
||||
@@ -448,12 +447,12 @@ class CssGenerator extends Generator {
|
||||
*/
|
||||
generateError(error, module, generateContext) {
|
||||
switch (generateContext.type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
return new RawSource(
|
||||
`throw new Error(${JSON.stringify(error.message)});`
|
||||
);
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
return new RawSource(`/**\n ${error.message} \n**/`);
|
||||
}
|
||||
default:
|
||||
@@ -467,32 +466,35 @@ class CssGenerator extends Generator {
|
||||
*/
|
||||
getTypes(module) {
|
||||
if (this._generatesJsOnly(module)) {
|
||||
return JS_TYPES;
|
||||
return JAVASCRIPT_TYPES;
|
||||
}
|
||||
const sourceTypes = new Set();
|
||||
const connections = this._moduleGraph.getIncomingConnections(module);
|
||||
for (const connection of connections) {
|
||||
if (connection.dependency instanceof CssImportDependency) {
|
||||
continue;
|
||||
}
|
||||
if (!connection.originModule) {
|
||||
continue;
|
||||
}
|
||||
if (connection.originModule.type.split("/")[0] !== CSS_TYPE) {
|
||||
sourceTypes.add(JS_TYPE);
|
||||
sourceTypes.add(JAVASCRIPT_TYPE);
|
||||
}
|
||||
}
|
||||
if (sourceTypes.has(JS_TYPE)) {
|
||||
return JS_AND_CSS_TYPES;
|
||||
if (sourceTypes.has(JAVASCRIPT_TYPE)) {
|
||||
return JAVASCRIPT_AND_CSS_TYPES;
|
||||
}
|
||||
return CSS_TYPES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NormalModule} module the module
|
||||
* @param {string=} type source type
|
||||
* @param {SourceType=} type source type
|
||||
* @returns {number} estimate size of the module
|
||||
*/
|
||||
getSize(module, type) {
|
||||
switch (type) {
|
||||
case "javascript": {
|
||||
case JAVASCRIPT_TYPE: {
|
||||
const cssData = /** @type {BuildInfo} */ (module.buildInfo).cssData;
|
||||
if (!cssData) {
|
||||
return 42;
|
||||
@@ -513,7 +515,7 @@ class CssGenerator extends Generator {
|
||||
|
||||
return stringifiedExports.length + 42;
|
||||
}
|
||||
case "css": {
|
||||
case CSS_TYPE: {
|
||||
const originalSource = module.originalSource();
|
||||
|
||||
if (!originalSource) {
|
||||
|
||||
16
node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
generated
vendored
16
node_modules/webpack/lib/css/CssLoadingRuntimeModule.js
generated
vendored
@@ -7,6 +7,7 @@
|
||||
|
||||
const { SyncWaterfallHook } = require("tapable");
|
||||
const Compilation = require("../Compilation");
|
||||
const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const RuntimeModule = require("../RuntimeModule");
|
||||
const Template = require("../Template");
|
||||
@@ -86,7 +87,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
* @returns {boolean} true, if the chunk has css
|
||||
*/
|
||||
(chunk, chunkGraph) =>
|
||||
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css"))
|
||||
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE))
|
||||
);
|
||||
const hasCssMatcher = compileBooleanMatcher(conditionMap);
|
||||
|
||||
@@ -429,7 +430,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
"while(oldTags.length) {",
|
||||
Template.indent([
|
||||
"var oldTag = oldTags.pop();",
|
||||
"if(oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
|
||||
"if(oldTag && oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
|
||||
]),
|
||||
"}"
|
||||
])}, apply: ${runtimeTemplate.basicFunction("", [
|
||||
@@ -451,17 +452,24 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
||||
`${
|
||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
||||
}.css = ${runtimeTemplate.basicFunction(
|
||||
"chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList",
|
||||
"chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList, css",
|
||||
[
|
||||
isNeutralPlatform
|
||||
? "if (typeof document === 'undefined') return;"
|
||||
: "",
|
||||
"applyHandlers.push(applyHandler);",
|
||||
"// Read CSS removed chunks from update manifest",
|
||||
"var cssRemovedChunks = css && css.r;",
|
||||
`chunkIds.forEach(${runtimeTemplate.basicFunction("chunkId", [
|
||||
`var filename = ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
|
||||
`var url = ${RuntimeGlobals.publicPath} + filename;`,
|
||||
"var oldTag = loadStylesheet(chunkId, url);",
|
||||
"if(!oldTag) return;",
|
||||
`if(!oldTag && !${withHmr} ) return;`,
|
||||
"// Skip if CSS was removed",
|
||||
"if(cssRemovedChunks && cssRemovedChunks.indexOf(chunkId) >= 0) {",
|
||||
Template.indent(["oldTags.push(oldTag);", "return;"]),
|
||||
"}",
|
||||
"",
|
||||
"// create error before stack unwound to get useful stacktrace later",
|
||||
"var error = new Error();",
|
||||
`promises.push(new Promise(${runtimeTemplate.basicFunction(
|
||||
|
||||
103
node_modules/webpack/lib/css/CssModulesPlugin.js
generated
vendored
103
node_modules/webpack/lib/css/CssModulesPlugin.js
generated
vendored
@@ -17,6 +17,7 @@ const Compilation = require("../Compilation");
|
||||
const CssModule = require("../CssModule");
|
||||
const { tryRunOrWebpackError } = require("../HookWebpackError");
|
||||
const HotUpdateChunk = require("../HotUpdateChunk");
|
||||
const { CSS_IMPORT_TYPE, CSS_TYPE } = require("../ModuleSourceTypeConstants");
|
||||
const {
|
||||
CSS_MODULE_TYPE,
|
||||
CSS_MODULE_TYPE_AUTO,
|
||||
@@ -25,15 +26,10 @@ const {
|
||||
} = require("../ModuleTypeConstants");
|
||||
const NormalModule = require("../NormalModule");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const SelfModuleFactory = require("../SelfModuleFactory");
|
||||
const Template = require("../Template");
|
||||
const WebpackError = require("../WebpackError");
|
||||
const CssIcssExportDependency = require("../dependencies/CssIcssExportDependency");
|
||||
const CssIcssFromIdentifierDependency = require("../dependencies/CssIcssFromIdentifierDependency");
|
||||
const CssIcssGlobalIdentifierDependency = require("../dependencies/CssIcssGlobalIdentifierDependency");
|
||||
const CssIcssImportDependency = require("../dependencies/CssIcssImportDependency");
|
||||
const CssIcssLocalIdentifierDependency = require("../dependencies/CssIcssLocalIdentifierDependency");
|
||||
const CssIcssSelfLocalIdentifierDependency = require("../dependencies/CssIcssSelfLocalIdentifierDependency");
|
||||
const CssIcssSymbolDependency = require("../dependencies/CssIcssSymbolDependency");
|
||||
const CssImportDependency = require("../dependencies/CssImportDependency");
|
||||
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
||||
@@ -130,8 +126,8 @@ const validateGeneratorOptions = {
|
||||
generatorValidationOptions
|
||||
),
|
||||
"css/auto": createSchemaValidation(
|
||||
require("../../schemas/plugins/css/CssAutoGeneratorOptions.check"),
|
||||
() => getSchema("CssAutoGeneratorOptions"),
|
||||
require("../../schemas/plugins/css/CssModuleGeneratorOptions.check"),
|
||||
() => getSchema("CssModuleGeneratorOptions"),
|
||||
generatorValidationOptions
|
||||
),
|
||||
"css/module": createSchemaValidation(
|
||||
@@ -140,8 +136,8 @@ const validateGeneratorOptions = {
|
||||
generatorValidationOptions
|
||||
),
|
||||
"css/global": createSchemaValidation(
|
||||
require("../../schemas/plugins/css/CssGlobalGeneratorOptions.check"),
|
||||
() => getSchema("CssGlobalGeneratorOptions"),
|
||||
require("../../schemas/plugins/css/CssModuleGeneratorOptions.check"),
|
||||
() => getSchema("CssModuleGeneratorOptions"),
|
||||
generatorValidationOptions
|
||||
)
|
||||
};
|
||||
@@ -157,8 +153,8 @@ const validateParserOptions = {
|
||||
parserValidationOptions
|
||||
),
|
||||
"css/auto": createSchemaValidation(
|
||||
require("../../schemas/plugins/css/CssAutoParserOptions.check"),
|
||||
() => getSchema("CssAutoParserOptions"),
|
||||
require("../../schemas/plugins/css/CssModuleParserOptions.check"),
|
||||
() => getSchema("CssModuleParserOptions"),
|
||||
parserValidationOptions
|
||||
),
|
||||
"css/module": createSchemaValidation(
|
||||
@@ -167,8 +163,8 @@ const validateParserOptions = {
|
||||
parserValidationOptions
|
||||
),
|
||||
"css/global": createSchemaValidation(
|
||||
require("../../schemas/plugins/css/CssGlobalParserOptions.check"),
|
||||
() => getSchema("CssGlobalParserOptions"),
|
||||
require("../../schemas/plugins/css/CssModuleParserOptions.check"),
|
||||
() => getSchema("CssModuleParserOptions"),
|
||||
parserValidationOptions
|
||||
)
|
||||
};
|
||||
@@ -219,7 +215,6 @@ class CssModulesPlugin {
|
||||
PLUGIN_NAME,
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
const hooks = CssModulesPlugin.getCompilationHooks(compilation);
|
||||
const selfFactory = new SelfModuleFactory(compilation.moduleGraph);
|
||||
compilation.dependencyFactories.set(
|
||||
CssImportDependency,
|
||||
normalModuleFactory
|
||||
@@ -236,18 +231,6 @@ class CssModulesPlugin {
|
||||
CssUrlDependency,
|
||||
new CssUrlDependency.Template()
|
||||
);
|
||||
compilation.dependencyTemplates.set(
|
||||
CssIcssLocalIdentifierDependency,
|
||||
new CssIcssLocalIdentifierDependency.Template()
|
||||
);
|
||||
compilation.dependencyFactories.set(
|
||||
CssIcssSelfLocalIdentifierDependency,
|
||||
selfFactory
|
||||
);
|
||||
compilation.dependencyTemplates.set(
|
||||
CssIcssSelfLocalIdentifierDependency,
|
||||
new CssIcssSelfLocalIdentifierDependency.Template()
|
||||
);
|
||||
compilation.dependencyFactories.set(
|
||||
CssIcssImportDependency,
|
||||
normalModuleFactory
|
||||
@@ -256,22 +239,6 @@ class CssModulesPlugin {
|
||||
CssIcssImportDependency,
|
||||
new CssIcssImportDependency.Template()
|
||||
);
|
||||
compilation.dependencyFactories.set(
|
||||
CssIcssFromIdentifierDependency,
|
||||
normalModuleFactory
|
||||
);
|
||||
compilation.dependencyTemplates.set(
|
||||
CssIcssFromIdentifierDependency,
|
||||
new CssIcssFromIdentifierDependency.Template()
|
||||
);
|
||||
compilation.dependencyFactories.set(
|
||||
CssIcssGlobalIdentifierDependency,
|
||||
normalModuleFactory
|
||||
);
|
||||
compilation.dependencyTemplates.set(
|
||||
CssIcssGlobalIdentifierDependency,
|
||||
new CssIcssGlobalIdentifierDependency.Template()
|
||||
);
|
||||
compilation.dependencyTemplates.set(
|
||||
CssIcssExportDependency,
|
||||
new CssIcssExportDependency.Template()
|
||||
@@ -293,45 +260,31 @@ class CssModulesPlugin {
|
||||
normalModuleFactory.hooks.createParser
|
||||
.for(type)
|
||||
.tap(PLUGIN_NAME, (parserOptions) => {
|
||||
validateParserOptions[type](parserOptions);
|
||||
const {
|
||||
url,
|
||||
import: importOption,
|
||||
namedExports,
|
||||
exportType
|
||||
} = parserOptions;
|
||||
|
||||
switch (type) {
|
||||
case CSS_MODULE_TYPE:
|
||||
return new CssParser({
|
||||
importOption,
|
||||
url,
|
||||
namedExports,
|
||||
exportType
|
||||
});
|
||||
validateParserOptions[type](parserOptions);
|
||||
|
||||
return new CssParser(parserOptions);
|
||||
case CSS_MODULE_TYPE_GLOBAL:
|
||||
validateParserOptions[type](parserOptions);
|
||||
|
||||
return new CssParser({
|
||||
defaultMode: "global",
|
||||
importOption,
|
||||
url,
|
||||
namedExports,
|
||||
exportType
|
||||
...parserOptions
|
||||
});
|
||||
case CSS_MODULE_TYPE_MODULE:
|
||||
validateParserOptions[type](parserOptions);
|
||||
|
||||
return new CssParser({
|
||||
defaultMode: "local",
|
||||
importOption,
|
||||
url,
|
||||
namedExports,
|
||||
exportType
|
||||
...parserOptions
|
||||
});
|
||||
case CSS_MODULE_TYPE_AUTO:
|
||||
validateParserOptions[type](parserOptions);
|
||||
|
||||
return new CssParser({
|
||||
defaultMode: "auto",
|
||||
importOption,
|
||||
url,
|
||||
namedExports,
|
||||
exportType
|
||||
...parserOptions
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -778,7 +731,7 @@ class CssModulesPlugin {
|
||||
(
|
||||
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
||||
chunk,
|
||||
"css-import",
|
||||
CSS_IMPORT_TYPE,
|
||||
compareModulesByIdOrIdentifier(chunkGraph)
|
||||
)
|
||||
),
|
||||
@@ -790,7 +743,7 @@ class CssModulesPlugin {
|
||||
(
|
||||
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
||||
chunk,
|
||||
"css",
|
||||
CSS_TYPE,
|
||||
compareModulesByIdOrIdentifier(chunkGraph)
|
||||
)
|
||||
),
|
||||
@@ -920,8 +873,8 @@ class CssModulesPlugin {
|
||||
const moduleSourceContent =
|
||||
/** @type {Source} */
|
||||
(
|
||||
codeGenResult.sources.get("css") ||
|
||||
codeGenResult.sources.get("css-import")
|
||||
codeGenResult.sources.get(CSS_TYPE) ||
|
||||
codeGenResult.sources.get(CSS_IMPORT_TYPE)
|
||||
);
|
||||
const moduleSource = CssModulesPlugin.renderModule(
|
||||
module,
|
||||
@@ -970,9 +923,11 @@ class CssModulesPlugin {
|
||||
*/
|
||||
static chunkHasCss(chunk, chunkGraph) {
|
||||
return (
|
||||
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css")) ||
|
||||
Boolean(
|
||||
chunkGraph.getChunkModulesIterableBySourceType(chunk, "css-import")
|
||||
chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE)
|
||||
) ||
|
||||
Boolean(
|
||||
chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_IMPORT_TYPE)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
1169
node_modules/webpack/lib/css/CssParser.js
generated
vendored
1169
node_modules/webpack/lib/css/CssParser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
46
node_modules/webpack/lib/css/walkCssTokens.js
generated
vendored
46
node_modules/webpack/lib/css/walkCssTokens.js
generated
vendored
@@ -10,16 +10,18 @@
|
||||
* @property {((input: string, start: number, end: number, innerStart: number, innerEnd: number) => number)=} url
|
||||
* @property {((input: string, start: number, end: number) => number)=} comment
|
||||
* @property {((input: string, start: number, end: number) => number)=} string
|
||||
* @property {((input: string, start: number, end: number) => number)=} leftCurlyBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} rightCurlyBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} leftParenthesis
|
||||
* @property {((input: string, start: number, end: number) => number)=} rightParenthesis
|
||||
* @property {((input: string, start: number, end: number) => number)=} leftSquareBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} rightSquareBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} function
|
||||
* @property {((input: string, start: number, end: number) => number)=} colon
|
||||
* @property {((input: string, start: number, end: number) => number)=} atKeyword
|
||||
* @property {((input: string, start: number, end: number) => number)=} delim
|
||||
* @property {((input: string, start: number, end: number) => number)=} identifier
|
||||
* @property {((input: string, start: number, end: number, isId: boolean) => number)=} hash
|
||||
* @property {((input: string, start: number, end: number) => number)=} leftCurlyBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} rightCurlyBracket
|
||||
* @property {((input: string, start: number, end: number) => number)=} semicolon
|
||||
* @property {((input: string, start: number, end: number) => number)=} comma
|
||||
* @property {(() => boolean)=} needTerminate
|
||||
@@ -717,14 +719,22 @@ const consumeRightParenthesis = (input, pos, callbacks) => {
|
||||
};
|
||||
|
||||
/** @type {CharHandler} */
|
||||
const consumeLeftSquareBracket = (input, pos, _callbacks) =>
|
||||
const consumeLeftSquareBracket = (input, pos, callbacks) => {
|
||||
// Return a <]-token>.
|
||||
pos;
|
||||
if (callbacks.leftSquareBracket !== undefined) {
|
||||
return callbacks.leftSquareBracket(input, pos - 1, pos);
|
||||
}
|
||||
return pos;
|
||||
};
|
||||
|
||||
/** @type {CharHandler} */
|
||||
const consumeRightSquareBracket = (input, pos, _callbacks) =>
|
||||
const consumeRightSquareBracket = (input, pos, callbacks) => {
|
||||
// Return a <]-token>.
|
||||
pos;
|
||||
if (callbacks.rightSquareBracket !== undefined) {
|
||||
return callbacks.rightSquareBracket(input, pos - 1, pos);
|
||||
}
|
||||
return pos;
|
||||
};
|
||||
|
||||
/** @type {CharHandler} */
|
||||
const consumeLeftCurlyBracket = (input, pos, callbacks) => {
|
||||
@@ -1201,7 +1211,7 @@ module.exports = (input, pos = 0, callbacks = {}) => {
|
||||
* @param {string} input input css
|
||||
* @param {number} pos pos
|
||||
* @param {CssTokenCallbacks} callbacks callbacks
|
||||
* @param {CssTokenCallbacks} additional additional callbacks
|
||||
* @param {CssTokenCallbacks=} additional additional callbacks
|
||||
* @param {{ onlyTopLevel?: boolean, declarationValue?: boolean, atRulePrelude?: boolean, functionValue?: boolean }=} options options
|
||||
* @returns {number} pos
|
||||
*/
|
||||
@@ -1221,7 +1231,7 @@ const consumeUntil = (input, pos, callbacks, additional, options = {}) => {
|
||||
needHandle = false;
|
||||
}
|
||||
|
||||
if (additional.function !== undefined) {
|
||||
if (additional && additional.function !== undefined) {
|
||||
return additional.function(input, start, end);
|
||||
}
|
||||
|
||||
@@ -1265,6 +1275,10 @@ const consumeUntil = (input, pos, callbacks, additional, options = {}) => {
|
||||
needTerminate = true;
|
||||
return end;
|
||||
};
|
||||
servicedCallbacks.semicolon = (_input, _start, end) => {
|
||||
needTerminate = true;
|
||||
return end;
|
||||
};
|
||||
}
|
||||
|
||||
while (pos < input.length) {
|
||||
@@ -1326,13 +1340,18 @@ const eatWhitespace = (input, pos) => {
|
||||
/**
|
||||
* @param {string} input input
|
||||
* @param {number} pos position
|
||||
* @returns {number} position after whitespace and comments
|
||||
* @returns {[number, boolean]} position after whitespace and comments
|
||||
*/
|
||||
const eatWhitespaceAndComments = (input, pos) => {
|
||||
let foundWhitespace = false;
|
||||
|
||||
for (;;) {
|
||||
const originalPos = pos;
|
||||
pos = consumeComments(input, pos, {});
|
||||
while (_isWhiteSpace(input.charCodeAt(pos))) {
|
||||
if (!foundWhitespace) {
|
||||
foundWhitespace = true;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (originalPos === pos) {
|
||||
@@ -1340,7 +1359,7 @@ const eatWhitespaceAndComments = (input, pos) => {
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
return [pos, foundWhitespace];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1394,7 +1413,7 @@ const skipCommentsAndEatIdentSequence = (input, pos) => {
|
||||
* @returns {[number, number] | undefined} positions of ident sequence
|
||||
*/
|
||||
const eatString = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
pos = eatWhitespaceAndComments(input, pos)[0];
|
||||
|
||||
const start = pos;
|
||||
|
||||
@@ -1627,7 +1646,7 @@ const eatImportTokens = (input, pos, cbs) => {
|
||||
* @returns {[number, number] | undefined} positions of ident sequence
|
||||
*/
|
||||
const eatIdentSequence = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
pos = eatWhitespaceAndComments(input, pos)[0];
|
||||
|
||||
const start = pos;
|
||||
|
||||
@@ -1652,7 +1671,7 @@ const eatIdentSequence = (input, pos) => {
|
||||
* @returns {[number, number, boolean] | undefined} positions of ident sequence or string
|
||||
*/
|
||||
const eatIdentSequenceOrString = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
pos = eatWhitespaceAndComments(input, pos)[0];
|
||||
|
||||
const start = pos;
|
||||
|
||||
@@ -1716,5 +1735,6 @@ module.exports.eatWhiteLine = eatWhiteLine;
|
||||
module.exports.eatWhitespace = eatWhitespace;
|
||||
module.exports.eatWhitespaceAndComments = eatWhitespaceAndComments;
|
||||
module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
||||
module.exports.isWhiteSpace = _isWhiteSpace;
|
||||
module.exports.skipCommentsAndEatIdentSequence =
|
||||
skipCommentsAndEatIdentSequence;
|
||||
|
||||
Reference in New Issue
Block a user