html-validate 8.22.0 → 9.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.7"
8
+ "packageVersion": "7.47.9"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { a as ConfigError, b as ConfigLoader, C as Config, J as compatibilityCheckImpl, v as version } from './core.js';
3
+ import { a as ConfigError, b as ConfigLoader, K as isThenable, U as UserError, C as Config, J as compatibilityCheckImpl, v as version } from './core.js';
4
4
  import { createRequire } from 'node:module';
5
5
  import kleur from 'kleur';
6
6
 
@@ -155,19 +155,13 @@ class FileSystemConfigLoader extends ConfigLoader {
155
155
  */
156
156
  getConfigFor(filename, configOverride) {
157
157
  const override = this.loadFromObject(configOverride ?? {});
158
- if (override.isRootFound()) {
159
- override.init();
160
- return override.resolve();
161
- }
162
- if (this.globalConfig.isRootFound()) {
163
- const merged2 = this.globalConfig.merge(this.resolvers, override);
164
- merged2.init();
165
- return merged2.resolve();
158
+ if (isThenable(override)) {
159
+ return override.then((override2) => {
160
+ return this._resolveAsync(filename, override2);
161
+ });
162
+ } else {
163
+ return this._resolveSync(filename, override);
166
164
  }
167
- const config = this.fromFilename(filename);
168
- const merged = config ? config.merge(this.resolvers, override) : this.globalConfig.merge(this.resolvers, override);
169
- merged.init();
170
- return merged.resolve();
171
165
  }
172
166
  /**
173
167
  * Flush configuration cache.
@@ -201,6 +195,9 @@ class FileSystemConfigLoader extends ConfigLoader {
201
195
  while (true) {
202
196
  for (const configFile of findConfigurationFiles(this.fs, current)) {
203
197
  const local = this.loadFromFile(configFile);
198
+ if (isThenable(local)) {
199
+ return this.fromFilenameAsync(filename);
200
+ }
204
201
  found = true;
205
202
  config = local.merge(this.resolvers, config);
206
203
  }
@@ -220,6 +217,80 @@ class FileSystemConfigLoader extends ConfigLoader {
220
217
  this.cache.set(filename, config);
221
218
  return config;
222
219
  }
220
+ /**
221
+ * Async version of [[fromFilename]].
222
+ *
223
+ * @internal
224
+ */
225
+ async fromFilenameAsync(filename) {
226
+ if (filename === "inline") {
227
+ return null;
228
+ }
229
+ const cache = this.cache.get(filename);
230
+ if (cache) {
231
+ return cache;
232
+ }
233
+ let found = false;
234
+ let current = path.resolve(path.dirname(filename));
235
+ let config = this.empty();
236
+ while (true) {
237
+ for (const configFile of findConfigurationFiles(this.fs, current)) {
238
+ const local = await this.loadFromFile(configFile);
239
+ found = true;
240
+ config = local.merge(this.resolvers, config);
241
+ }
242
+ if (config.isRootFound()) {
243
+ break;
244
+ }
245
+ const child = current;
246
+ current = path.dirname(current);
247
+ if (current === child) {
248
+ break;
249
+ }
250
+ }
251
+ if (!found) {
252
+ this.cache.set(filename, null);
253
+ return null;
254
+ }
255
+ this.cache.set(filename, config);
256
+ return config;
257
+ }
258
+ _mergeSync(globalConfig, override, config) {
259
+ const merged = config ? config.merge(this.resolvers, override) : globalConfig.merge(this.resolvers, override);
260
+ merged.init();
261
+ return merged.resolve();
262
+ }
263
+ _resolveSync(filename, override) {
264
+ if (override.isRootFound()) {
265
+ override.init();
266
+ return override.resolve();
267
+ }
268
+ const globalConfig = this.getGlobalConfigSync();
269
+ if (globalConfig.isRootFound()) {
270
+ const merged = globalConfig.merge(this.resolvers, override);
271
+ merged.init();
272
+ return merged.resolve();
273
+ }
274
+ const config = this.fromFilename(filename);
275
+ if (isThenable(config)) {
276
+ throw new UserError("Cannot load async config from sync function");
277
+ }
278
+ return this._mergeSync(globalConfig, override, config);
279
+ }
280
+ async _resolveAsync(filename, override) {
281
+ if (override.isRootFound()) {
282
+ override.init();
283
+ return override.resolve();
284
+ }
285
+ const globalConfig = await this.getGlobalConfig();
286
+ if (globalConfig.isRootFound()) {
287
+ const merged = globalConfig.merge(this.resolvers, override);
288
+ merged.init();
289
+ return merged.resolve();
290
+ }
291
+ const config = await this.fromFilenameAsync(filename);
292
+ return this._mergeSync(globalConfig, override, config);
293
+ }
223
294
  /**
224
295
  * @internal For testing only
225
296
  */
@@ -1 +1 @@
1
- {"version":3,"file":"core-nodejs.js","sources":["../../src/utils/require-uncached.ts","../../src/config/resolver/nodejs/determine-root-dir.ts","../../src/config/resolver/nodejs/expand-relative-path.ts","../../src/config/resolver/nodejs/cjs-resolver.ts","../../src/config/loaders/file-system.ts","../../src/utils/compatibility-check.nodejs.ts"],"sourcesContent":["/**\n * Similar to `require(..)` but removes the cached copy first.\n */\nexport function requireUncached(require: NodeJS.Require, moduleId: string): unknown {\n\tconst filename = require.resolve(moduleId);\n\n\t/* remove references from the parent module to prevent memory leak */\n\tconst m = require.cache[filename];\n\tif (m?.parent) {\n\t\tconst { parent } = m;\n\t\tfor (let i = parent.children.length - 1; i >= 0; i--) {\n\t\t\tif (parent.children[i].id === filename) {\n\t\t\t\tparent.children.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* remove old module from cache */\n\t/* eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- needed to perform its function */\n\tdelete require.cache[filename];\n\n\t/* eslint-disable-next-line import/no-dynamic-require, security/detect-non-literal-require -- as expected but should be moved to upcoming resolver class */\n\treturn require(filename);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nlet cachedRootDir: string | null = null;\n\ninterface FSLike {\n\texistsSync(path: string): boolean;\n}\n\n/**\n * @internal\n */\nexport function determineRootDirImpl(intial: string, fs: FSLike): string {\n\t/* try to locate package.json */\n\tlet current = intial;\n\n\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- break outs when filesystem is traversed\n\twhile (true) {\n\t\tconst search = path.join(current, \"package.json\");\n\t\tif (fs.existsSync(search)) {\n\t\t\treturn current;\n\t\t}\n\n\t\t/* get the parent directory */\n\t\tconst child = current;\n\t\tcurrent = path.dirname(current);\n\n\t\t/* stop if this is the root directory */\n\t\tif (current === child) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* default to working directory if no package.json is found */\n\treturn intial;\n}\n\n/**\n * Try to determine root directory based on the location of the closest\n * `package.json`. Fallbacks on `process.cwd()` if no package.json was found.\n *\n * @internal\n */\n/* istanbul ignore next: cached version of determineRootDirImpl, no need to test */\nexport function determineRootDir(): string {\n\tif (cachedRootDir === null) {\n\t\tcachedRootDir = determineRootDirImpl(process.cwd(), fs);\n\t}\n\treturn cachedRootDir;\n}\n","import path from \"node:path\";\n\n/**\n * @internal\n */\nexport function expandRelativePath<T>(value: string | T, { cwd }: { cwd: string }): string | T {\n\tif (typeof value === \"string\" && value.startsWith(\".\")) {\n\t\treturn path.normalize(path.join(cwd, value));\n\t} else {\n\t\treturn value;\n\t}\n}\n","import path from \"node:path\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { legacyRequire } from \"../../../resolve\";\nimport { type Transformer } from \"../../../transform\";\nimport { requireUncached } from \"../../../utils\";\nimport { type ConfigData } from \"../../config-data\";\nimport { ConfigError } from \"../../error\";\nimport { type Resolver, type ResolverOptions } from \"../resolver\";\nimport { determineRootDir } from \"./determine-root-dir\";\nimport { expandRelativePath } from \"./expand-relative-path\";\n\n/**\n * @internal\n */\nexport interface RequireError extends Error {\n\tcode: string;\n}\n\nfunction isRequireError(error: unknown): error is RequireError {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error);\n}\n\nfunction isTransformer(value: Transformer | Plugin): value is Transformer {\n\treturn typeof value === \"function\";\n}\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @since 8.8.0\n */\nexport type CommonJSResolver = Required<Resolver>;\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @deprecated Deprecated alias for [[CommonJSResolver]].\n * @since 8.0.0\n */\nexport type NodeJSResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @since 8.8.0\n */\nexport function cjsResolver(options: { rootDir?: string } = {}): CommonJSResolver {\n\tconst rootDir = options.rootDir ?? determineRootDir();\n\n\tfunction internalRequire<T = unknown>(id: string, { cache }: ResolverOptions): T | null {\n\t\tconst moduleName = id.replace(\"<rootDir>\", rootDir);\n\t\ttry {\n\t\t\t/* istanbul ignore else: the tests only runs the cached versions to get\n\t\t\t * unmodified access to `require`, the implementation of `requireUncached`\n\t\t\t * is assumed to be tested elsewhere */\n\t\t\tif (cache) {\n\t\t\t\treturn legacyRequire(moduleName) as T;\n\t\t\t} else {\n\t\t\t\treturn requireUncached(legacyRequire, moduleName) as T;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tif (isRequireError(err) && err.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"nodejs-resolver\",\n\n\t\tresolveElements(id: string, options: ResolverOptions): MetaDataTable | null {\n\t\t\treturn internalRequire(id, options);\n\t\t},\n\n\t\tresolveConfig(id: string, options: ResolverOptions): ConfigData | null {\n\t\t\tconst configData = internalRequire<ConfigData>(id, options);\n\t\t\tif (!configData) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t/* expand any relative paths */\n\t\t\tconst cwd = path.dirname(id);\n\t\t\tconst expand = <T>(value: string | T): string | T => expandRelativePath(value, { cwd });\n\n\t\t\tif (Array.isArray(configData.elements)) {\n\t\t\t\tconfigData.elements = configData.elements.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.extends)) {\n\t\t\t\tconfigData.extends = configData.extends.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.plugins)) {\n\t\t\t\tconfigData.plugins = configData.plugins.map(expand);\n\t\t\t}\n\n\t\t\treturn configData;\n\t\t},\n\n\t\tresolvePlugin(id: string, options: ResolverOptions): Plugin | null {\n\t\t\treturn internalRequire<Plugin>(id, options);\n\t\t},\n\n\t\tresolveTransformer(id: string, options: ResolverOptions): Transformer | null {\n\t\t\tconst mod = internalRequire<Transformer | Plugin>(id, options);\n\t\t\tif (!mod) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (isTransformer(mod)) {\n\t\t\t\treturn mod;\n\t\t\t}\n\n\t\t\t/* this is not a proper transformer, is it a plugin exposing a transformer? */\n\t\t\tif (mod.transformer) {\n\t\t\t\tthrow new ConfigError(\n\t\t\t\t\t`Module \"${id}\" is not a valid transformer. This looks like a plugin, did you forget to load the plugin first?`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new ConfigError(`Module \"${id}\" is not a valid transformer.`);\n\t\t},\n\t};\n}\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @deprecated Deprecated alias for [[commonjsResolver]].\n * @since 8.0.0\n */\n/* istanbul ignore next -- deprecated alias */\nexport function nodejsResolver(options: { rootDir?: string } = {}): NodeJSResolver {\n\treturn cjsResolver(options);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Config } from \"../config\";\nimport { type ConfigData } from \"../config-data\";\nimport { ConfigLoader } from \"../config-loader\";\nimport { type ResolvedConfig } from \"../resolved-config\";\nimport { type Resolver } from \"../resolver\";\nimport { type FSLike, cjsResolver } from \"../resolver/nodejs\";\n\n/**\n * Options for [[FileSystemConfigLoader]].\n *\n * @public\n */\nexport interface FileSystemConfigLoaderOptions {\n\t/** An implementation of `fs` as needed by [[FileSystemConfigLoader]] */\n\tfs: FSLike;\n}\n\n/**\n * @internal\n */\nfunction findConfigurationFiles(fs: FSLike, directory: string): string[] {\n\treturn [\"json\", \"cjs\", \"js\"]\n\t\t.map((extension) => path.join(directory, `.htmlvalidate.${extension}`))\n\t\t.filter((filePath) => fs.existsSync(filePath));\n}\n\nconst defaultResolvers: Resolver[] = [cjsResolver()];\n\ntype ConstructorParametersDefault = [ConfigData?, Partial<FileSystemConfigLoaderOptions>?];\ntype ConstructorParametersResolver = [\n\tResolver[],\n\tConfigData?,\n\tPartial<FileSystemConfigLoaderOptions>?,\n];\ntype ConstructorParameters = ConstructorParametersDefault | ConstructorParametersResolver;\n\nfunction hasResolver(value: ConstructorParameters): value is ConstructorParametersResolver {\n\treturn Array.isArray(value[0]);\n}\n\n/**\n * Loads configuration by traversing filesystem.\n *\n * Configuration is read from three sources and in the following order:\n *\n * 1. Global configuration passed to constructor.\n * 2. Configuration files found when traversing the directory structure.\n * 3. Override passed to this function.\n *\n * The following configuration filenames are searched:\n *\n * - `.htmlvalidate.json`\n * - `.htmlvalidate.js`\n * - `.htmlvalidate.cjs`\n *\n * Global configuration is used when no configuration file is found. The\n * result is always merged with override if present.\n *\n * The `root` property set to `true` affects the configuration as following:\n *\n * 1. If set in override the override is returned as-is.\n * 2. If set in the global config the override is merged into global and\n * returned. No configuration files are searched.\n * 3. Setting `root` in configuration file only stops directory traversal.\n *\n * @public\n */\nexport class FileSystemConfigLoader extends ConfigLoader {\n\tprotected cache: Map<string, Config | null>;\n\tprivate fs: FSLike;\n\n\t/**\n\t * Create a filesystem configuration loader with default resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(config?: ConfigData, options?: Partial<FileSystemConfigLoaderOptions>);\n\n\t/**\n\t * Create a filesystem configuration loader with custom resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param resolvers - Resolvers to use.\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(\n\t\tresolvers: Resolver[],\n\t\tconfig?: ConfigData,\n\t\toptions?: Partial<FileSystemConfigLoaderOptions>,\n\t);\n\n\tpublic constructor(...args: ConstructorParameters) {\n\t\tif (hasResolver(args)) {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [resolvers, config, options = {}] = args;\n\t\t\tsuper(resolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t} else {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [config, options = {}] = args;\n\t\t\tsuper(defaultResolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t}\n\t\tthis.cache = new Map();\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to merge final result with.\n\t */\n\tpublic override getConfigFor(filename: string, configOverride?: ConfigData): ResolvedConfig {\n\t\t/* special case when the overridden configuration is marked as root, should\n\t\t * not try to load any more configuration files */\n\t\tconst override = this.loadFromObject(configOverride ?? {});\n\t\tif (override.isRootFound()) {\n\t\t\toverride.init();\n\t\t\treturn override.resolve();\n\t\t}\n\n\t\t/* special case when the global configuration is marked as root, should not\n\t\t * try to load and more configuration files */\n\t\tif (this.globalConfig.isRootFound()) {\n\t\t\tconst merged = this.globalConfig.merge(this.resolvers, override);\n\t\t\tmerged.init();\n\t\t\treturn merged.resolve();\n\t\t}\n\n\t\tconst config = this.fromFilename(filename);\n\t\tconst merged = config\n\t\t\t? config.merge(this.resolvers, override)\n\t\t\t: this.globalConfig.merge(this.resolvers, override);\n\t\tmerged.init();\n\t\treturn merged.resolve();\n\t}\n\n\t/**\n\t * Flush configuration cache.\n\t *\n\t * @param filename - If given only the cache for that file is flushed.\n\t */\n\tpublic override flushCache(filename?: string): void {\n\t\tif (filename) {\n\t\t\tthis.cache.delete(filename);\n\t\t} else {\n\t\t\tthis.cache.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Load raw configuration from directory traversal.\n\t *\n\t * This configuration is not merged with global configuration and may return\n\t * `null` if no configuration files are found.\n\t */\n\tpublic fromFilename(filename: string): Config | null {\n\t\tif (filename === \"inline\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cache = this.cache.get(filename);\n\t\tif (cache) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tlet found = false;\n\t\tlet current = path.resolve(path.dirname(filename));\n\t\tlet config = this.empty();\n\n\t\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- it will break out when filesystem is traversed\n\t\twhile (true) {\n\t\t\t/* search configuration files in current directory */\n\t\t\tfor (const configFile of findConfigurationFiles(this.fs, current)) {\n\t\t\t\tconst local = this.loadFromFile(configFile);\n\t\t\t\tfound = true;\n\t\t\t\tconfig = local.merge(this.resolvers, config);\n\t\t\t}\n\n\t\t\t/* stop if a configuration with \"root\" is set to true */\n\t\t\tif (config.isRootFound()) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* get the parent directory */\n\t\t\tconst child = current;\n\t\t\tcurrent = path.dirname(current);\n\n\t\t\t/* stop if this is the root directory */\n\t\t\tif (current === child) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* no config was found by loader, return null and let caller decide what to do */\n\t\tif (!found) {\n\t\t\tthis.cache.set(filename, null);\n\t\t\treturn null;\n\t\t}\n\n\t\tthis.cache.set(filename, config);\n\t\treturn config;\n\t}\n\n\t/**\n\t * @internal For testing only\n\t */\n\tpublic _getInternalCache(): Map<string, Config | null> {\n\t\treturn this.cache;\n\t}\n\n\tprotected defaultConfig(): Config {\n\t\treturn Config.defaultConfig();\n\t}\n}\n","import kleur from \"kleur\";\nimport { version } from \"../generated/package\";\nimport { type CompatibilityOptions, compatibilityCheckImpl } from \"./compatibility-check\";\n\nconst defaults: CompatibilityOptions = {\n\tsilent: false,\n\tversion,\n\tlogger(text: string): void {\n\t\t/* eslint-disable-next-line no-console -- expected to log */\n\t\tconsole.error(kleur.red(text));\n\t},\n};\n\n/**\n * Tests if plugin is compatible with html-validate library. Unless the `silent`\n * option is used a warning is displayed on the console.\n *\n * @public\n * @since v5.0.0\n * @param name - Name of plugin\n * @param declared - What library versions the plugin support (e.g. declared peerDependencies)\n * @returns - `true` if version is compatible\n */\nexport function compatibilityCheck(\n\tname: string,\n\tdeclared: string,\n\toptions?: Partial<CompatibilityOptions>,\n): boolean {\n\treturn compatibilityCheckImpl(name, declared, {\n\t\t...defaults,\n\t\t...options,\n\t});\n}\n"],"names":["fs","options","merged"],"mappings":";;;;;;AAGgB,SAAA,eAAA,CAAgB,SAAyB,QAA2B,EAAA;AACnF,EAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AAGzC,EAAM,MAAA,CAAA,GAAI,OAAQ,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAChC,EAAA,IAAI,uBAAG,MAAQ,EAAA;AACd,IAAM,MAAA,EAAE,QAAW,GAAA,CAAA,CAAA;AACnB,IAAA,KAAA,IAAS,IAAI,MAAO,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACrD,MAAA,IAAI,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,CAAE,OAAO,QAAU,EAAA;AACvC,QAAO,MAAA,CAAA,QAAA,CAAS,MAAO,CAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAAA,OAC5B;AAAA,KACD;AAAA,GACD;AAIA,EAAO,OAAA,OAAA,CAAQ,MAAM,QAAQ,CAAA,CAAA;AAG7B,EAAA,OAAO,QAAQ,QAAQ,CAAA,CAAA;AACxB;;;;ACpBA,IAAI,aAA+B,GAAA,IAAA,CAAA;AASnB,SAAA,oBAAA,CAAqB,QAAgBA,GAAoB,EAAA;AAExE,EAAA,IAAI,OAAU,GAAA,MAAA,CAAA;AAGd,EAAA,OAAO,IAAM,EAAA;AACZ,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,IAAK,CAAA,OAAA,EAAS,cAAc,CAAA,CAAA;A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KO,iBAAgD,GAAA;AACtD,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GACb;AAAA,EAEU,aAAwB,GAAA;AACjC,IAAA,OAAO,OAAO,aAAc,EAAA,CAAA;AAAA,GAC7B;AACD;;ACvNA,MAAM,QAAiC,GAAA;AAAA,EACtC,MAAQ,EAAA,KAAA;AAAA,EACR,OAAA;AAAA,EACA,OAAO,IAAoB,EAAA;AAE1B,IAAA,OAAA,CAAQ,KAAM,CAAA,KAAA,CAAM,GAAI,CAAA,IAAI,CAAC,CAAA,CAAA;AAAA,GAC9B;AACD,CAAA,CAAA;AAYgB,SAAA,kBAAA,CACf,IACA,EAAA,QAAA,EACA,OACU,EAAA;AACV,EAAO,OAAA,sBAAA,CAAuB,MAAM,QAAU,EAAA;AAAA,IAC7C,GAAG,QAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACH,CAAA,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"core-nodejs.js","sources":["../../src/utils/require-uncached.ts","../../src/config/resolver/nodejs/determine-root-dir.ts","../../src/config/resolver/nodejs/expand-relative-path.ts","../../src/config/resolver/nodejs/cjs-resolver.ts","../../src/config/loaders/file-system.ts","../../src/utils/compatibility-check.nodejs.ts"],"sourcesContent":["/**\n * Similar to `require(..)` but removes the cached copy first.\n */\nexport function requireUncached(require: NodeJS.Require, moduleId: string): unknown {\n\tconst filename = require.resolve(moduleId);\n\n\t/* remove references from the parent module to prevent memory leak */\n\tconst m = require.cache[filename];\n\tif (m?.parent) {\n\t\tconst { parent } = m;\n\t\tfor (let i = parent.children.length - 1; i >= 0; i--) {\n\t\t\tif (parent.children[i].id === filename) {\n\t\t\t\tparent.children.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* remove old module from cache */\n\t/* eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- needed to perform its function */\n\tdelete require.cache[filename];\n\n\t/* eslint-disable-next-line import/no-dynamic-require, security/detect-non-literal-require -- as expected but should be moved to upcoming resolver class */\n\treturn require(filename);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nlet cachedRootDir: string | null = null;\n\ninterface FSLike {\n\texistsSync(path: string): boolean;\n}\n\n/**\n * @internal\n */\nexport function determineRootDirImpl(intial: string, fs: FSLike): string {\n\t/* try to locate package.json */\n\tlet current = intial;\n\n\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- break outs when filesystem is traversed\n\twhile (true) {\n\t\tconst search = path.join(current, \"package.json\");\n\t\tif (fs.existsSync(search)) {\n\t\t\treturn current;\n\t\t}\n\n\t\t/* get the parent directory */\n\t\tconst child = current;\n\t\tcurrent = path.dirname(current);\n\n\t\t/* stop if this is the root directory */\n\t\tif (current === child) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* default to working directory if no package.json is found */\n\treturn intial;\n}\n\n/**\n * Try to determine root directory based on the location of the closest\n * `package.json`. Fallbacks on `process.cwd()` if no package.json was found.\n *\n * @internal\n */\n/* istanbul ignore next: cached version of determineRootDirImpl, no need to test */\nexport function determineRootDir(): string {\n\tif (cachedRootDir === null) {\n\t\tcachedRootDir = determineRootDirImpl(process.cwd(), fs);\n\t}\n\treturn cachedRootDir;\n}\n","import path from \"node:path\";\n\n/**\n * @internal\n */\nexport function expandRelativePath<T>(value: string | T, { cwd }: { cwd: string }): string | T {\n\tif (typeof value === \"string\" && value.startsWith(\".\")) {\n\t\treturn path.normalize(path.join(cwd, value));\n\t} else {\n\t\treturn value;\n\t}\n}\n","import path from \"node:path\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { legacyRequire } from \"../../../resolve\";\nimport { type Transformer } from \"../../../transform\";\nimport { requireUncached } from \"../../../utils\";\nimport { type ConfigData } from \"../../config-data\";\nimport { ConfigError } from \"../../error\";\nimport { type Resolver, type ResolverOptions } from \"../resolver\";\nimport { determineRootDir } from \"./determine-root-dir\";\nimport { expandRelativePath } from \"./expand-relative-path\";\n\n/**\n * @internal\n */\nexport interface RequireError extends Error {\n\tcode: string;\n}\n\nfunction isRequireError(error: unknown): error is RequireError {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error);\n}\n\nfunction isTransformer(value: Transformer | Plugin): value is Transformer {\n\treturn typeof value === \"function\";\n}\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @since 8.8.0\n */\nexport type CommonJSResolver = Required<Resolver>;\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @deprecated Deprecated alias for [[CommonJSResolver]].\n * @since 8.0.0\n */\nexport type NodeJSResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @since 8.8.0\n */\nexport function cjsResolver(options: { rootDir?: string } = {}): CommonJSResolver {\n\tconst rootDir = options.rootDir ?? determineRootDir();\n\n\tfunction internalRequire<T = unknown>(id: string, { cache }: ResolverOptions): T | null {\n\t\tconst moduleName = id.replace(\"<rootDir>\", rootDir);\n\t\ttry {\n\t\t\t/* istanbul ignore else: the tests only runs the cached versions to get\n\t\t\t * unmodified access to `require`, the implementation of `requireUncached`\n\t\t\t * is assumed to be tested elsewhere */\n\t\t\tif (cache) {\n\t\t\t\treturn legacyRequire(moduleName) as T;\n\t\t\t} else {\n\t\t\t\treturn requireUncached(legacyRequire, moduleName) as T;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tif (isRequireError(err) && err.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"nodejs-resolver\",\n\n\t\tresolveElements(id: string, options: ResolverOptions): MetaDataTable | null {\n\t\t\treturn internalRequire(id, options);\n\t\t},\n\n\t\tresolveConfig(id: string, options: ResolverOptions): ConfigData | null {\n\t\t\tconst configData = internalRequire<ConfigData>(id, options);\n\t\t\tif (!configData) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t/* expand any relative paths */\n\t\t\tconst cwd = path.dirname(id);\n\t\t\tconst expand = <T>(value: string | T): string | T => expandRelativePath(value, { cwd });\n\n\t\t\tif (Array.isArray(configData.elements)) {\n\t\t\t\tconfigData.elements = configData.elements.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.extends)) {\n\t\t\t\tconfigData.extends = configData.extends.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.plugins)) {\n\t\t\t\tconfigData.plugins = configData.plugins.map(expand);\n\t\t\t}\n\n\t\t\treturn configData;\n\t\t},\n\n\t\tresolvePlugin(id: string, options: ResolverOptions): Plugin | null {\n\t\t\treturn internalRequire<Plugin>(id, options);\n\t\t},\n\n\t\tresolveTransformer(id: string, options: ResolverOptions): Transformer | null {\n\t\t\tconst mod = internalRequire<Transformer | Plugin>(id, options);\n\t\t\tif (!mod) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (isTransformer(mod)) {\n\t\t\t\treturn mod;\n\t\t\t}\n\n\t\t\t/* this is not a proper transformer, is it a plugin exposing a transformer? */\n\t\t\tif (mod.transformer) {\n\t\t\t\tthrow new ConfigError(\n\t\t\t\t\t`Module \"${id}\" is not a valid transformer. This looks like a plugin, did you forget to load the plugin first?`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new ConfigError(`Module \"${id}\" is not a valid transformer.`);\n\t\t},\n\t};\n}\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @deprecated Deprecated alias for [[commonjsResolver]].\n * @since 8.0.0\n */\n/* istanbul ignore next -- deprecated alias */\nexport function nodejsResolver(options: { rootDir?: string } = {}): NodeJSResolver {\n\treturn cjsResolver(options);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Config } from \"../config\";\nimport { type ConfigData } from \"../config-data\";\nimport { ConfigLoader } from \"../config-loader\";\nimport { type ResolvedConfig } from \"../resolved-config\";\nimport { type Resolver } from \"../resolver\";\nimport { type FSLike, cjsResolver } from \"../resolver/nodejs\";\nimport { isThenable } from \"../../utils\";\nimport { UserError } from \"../../error\";\n\n/**\n * Options for [[FileSystemConfigLoader]].\n *\n * @public\n */\nexport interface FileSystemConfigLoaderOptions {\n\t/** An implementation of `fs` as needed by [[FileSystemConfigLoader]] */\n\tfs: FSLike;\n}\n\n/**\n * @internal\n */\nfunction findConfigurationFiles(fs: FSLike, directory: string): string[] {\n\treturn [\"json\", \"cjs\", \"js\"]\n\t\t.map((extension) => path.join(directory, `.htmlvalidate.${extension}`))\n\t\t.filter((filePath) => fs.existsSync(filePath));\n}\n\nconst defaultResolvers: Resolver[] = [cjsResolver()];\n\ntype ConstructorParametersDefault = [ConfigData?, Partial<FileSystemConfigLoaderOptions>?];\ntype ConstructorParametersResolver = [\n\tResolver[],\n\tConfigData?,\n\tPartial<FileSystemConfigLoaderOptions>?,\n];\ntype ConstructorParameters = ConstructorParametersDefault | ConstructorParametersResolver;\n\nfunction hasResolver(value: ConstructorParameters): value is ConstructorParametersResolver {\n\treturn Array.isArray(value[0]);\n}\n\n/**\n * Loads configuration by traversing filesystem.\n *\n * Configuration is read from three sources and in the following order:\n *\n * 1. Global configuration passed to constructor.\n * 2. Configuration files found when traversing the directory structure.\n * 3. Override passed to this function.\n *\n * The following configuration filenames are searched:\n *\n * - `.htmlvalidate.json`\n * - `.htmlvalidate.js`\n * - `.htmlvalidate.cjs`\n *\n * Global configuration is used when no configuration file is found. The\n * result is always merged with override if present.\n *\n * The `root` property set to `true` affects the configuration as following:\n *\n * 1. If set in override the override is returned as-is.\n * 2. If set in the global config the override is merged into global and\n * returned. No configuration files are searched.\n * 3. Setting `root` in configuration file only stops directory traversal.\n *\n * @public\n */\nexport class FileSystemConfigLoader extends ConfigLoader {\n\tprotected cache: Map<string, Config | null>;\n\tprivate fs: FSLike;\n\n\t/**\n\t * Create a filesystem configuration loader with default resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(config?: ConfigData, options?: Partial<FileSystemConfigLoaderOptions>);\n\n\t/**\n\t * Create a filesystem configuration loader with custom resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param resolvers - Resolvers to use.\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(\n\t\tresolvers: Resolver[],\n\t\tconfig?: ConfigData,\n\t\toptions?: Partial<FileSystemConfigLoaderOptions>,\n\t);\n\n\tpublic constructor(...args: ConstructorParameters) {\n\t\tif (hasResolver(args)) {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [resolvers, config, options = {}] = args;\n\t\t\tsuper(resolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t} else {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [config, options = {}] = args;\n\t\t\tsuper(defaultResolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t}\n\t\tthis.cache = new Map();\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to merge final result with.\n\t */\n\tpublic override getConfigFor(\n\t\tfilename: string,\n\t\tconfigOverride?: ConfigData,\n\t): ResolvedConfig | Promise<ResolvedConfig> {\n\t\tconst override = this.loadFromObject(configOverride ?? {});\n\t\tif (isThenable(override)) {\n\t\t\treturn override.then((override) => {\n\t\t\t\treturn this._resolveAsync(filename, override);\n\t\t\t});\n\t\t} else {\n\t\t\treturn this._resolveSync(filename, override);\n\t\t}\n\t}\n\n\t/**\n\t * Flush configuration cache.\n\t *\n\t * @param filename - If given only the cache for that file is flushed.\n\t */\n\tpublic override flushCache(filename?: string): void {\n\t\tif (filename) {\n\t\t\tthis.cache.delete(filename);\n\t\t} else {\n\t\t\tthis.cache.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Load raw configuration from directory traversal.\n\t *\n\t * This configuration is not merged with global configuration and may return\n\t * `null` if no configuration files are found.\n\t */\n\tpublic fromFilename(filename: string): Config | Promise<Config | null> | null {\n\t\tif (filename === \"inline\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cache = this.cache.get(filename);\n\t\tif (cache) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tlet found = false;\n\t\tlet current = path.resolve(path.dirname(filename));\n\t\tlet config = this.empty();\n\n\t\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- it will break out when filesystem is traversed\n\t\twhile (true) {\n\t\t\t/* search configuration files in current directory */\n\t\t\tfor (const configFile of findConfigurationFiles(this.fs, current)) {\n\t\t\t\tconst local = this.loadFromFile(configFile);\n\n\t\t\t\t/* if the loader returns an async config we exit out of the synchronous\n\t\t\t\t * processing and enter the async method so we can resolve any promises\n\t\t\t\t * as we go */\n\t\t\t\tif (isThenable(local)) {\n\t\t\t\t\treturn this.fromFilenameAsync(filename);\n\t\t\t\t}\n\n\t\t\t\tfound = true;\n\t\t\t\tconfig = local.merge(this.resolvers, config);\n\t\t\t}\n\n\t\t\t/* stop if a configuration with \"root\" is set to true */\n\t\t\tif (config.isRootFound()) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* get the parent directory */\n\t\t\tconst child = current;\n\t\t\tcurrent = path.dirname(current);\n\n\t\t\t/* stop if this is the root directory */\n\t\t\tif (current === child) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* no config was found by loader, return null and let caller decide what to do */\n\t\tif (!found) {\n\t\t\tthis.cache.set(filename, null);\n\t\t\treturn null;\n\t\t}\n\n\t\tthis.cache.set(filename, config);\n\t\treturn config;\n\t}\n\n\t/**\n\t * Async version of [[fromFilename]].\n\t *\n\t * @internal\n\t */\n\tpublic async fromFilenameAsync(filename: string): Promise<Config | null> {\n\t\tif (filename === \"inline\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cache = this.cache.get(filename);\n\t\tif (cache) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tlet found = false;\n\t\tlet current = path.resolve(path.dirname(filename));\n\t\tlet config = this.empty();\n\n\t\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- it will break out when filesystem is traversed\n\t\twhile (true) {\n\t\t\t/* search configuration files in current directory */\n\t\t\tfor (const configFile of findConfigurationFiles(this.fs, current)) {\n\t\t\t\tconst local = await this.loadFromFile(configFile);\n\t\t\t\tfound = true;\n\t\t\t\tconfig = local.merge(this.resolvers, config);\n\t\t\t}\n\n\t\t\t/* stop if a configuration with \"root\" is set to true */\n\t\t\tif (config.isRootFound()) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* get the parent directory */\n\t\t\tconst child = current;\n\t\t\tcurrent = path.dirname(current);\n\n\t\t\t/* stop if this is the root directory */\n\t\t\tif (current === child) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* no config was found by loader, return null and let caller decide what to do */\n\t\tif (!found) {\n\t\t\tthis.cache.set(filename, null);\n\t\t\treturn null;\n\t\t}\n\n\t\tthis.cache.set(filename, config);\n\t\treturn config;\n\t}\n\n\tprivate _mergeSync(\n\t\tglobalConfig: Config,\n\t\toverride: Config,\n\t\tconfig: Config | null,\n\t): ResolvedConfig {\n\t\tconst merged = config\n\t\t\t? config.merge(this.resolvers, override)\n\t\t\t: globalConfig.merge(this.resolvers, override);\n\t\tmerged.init();\n\t\treturn merged.resolve();\n\t}\n\n\tprivate _resolveSync(filename: string, override: Config): ResolvedConfig {\n\t\tif (override.isRootFound()) {\n\t\t\toverride.init();\n\t\t\treturn override.resolve();\n\t\t}\n\n\t\tconst globalConfig = this.getGlobalConfigSync();\n\n\t\t/* special case when the global configuration is marked as root, should not\n\t\t * try to load and more configuration files */\n\t\tif (globalConfig.isRootFound()) {\n\t\t\tconst merged = globalConfig.merge(this.resolvers, override);\n\t\t\tmerged.init();\n\t\t\treturn merged.resolve();\n\t\t}\n\n\t\tconst config = this.fromFilename(filename);\n\t\tif (isThenable(config)) {\n\t\t\tthrow new UserError(\"Cannot load async config from sync function\");\n\t\t}\n\n\t\treturn this._mergeSync(globalConfig, override, config);\n\t}\n\n\tprivate async _resolveAsync(filename: string, override: Config): Promise<ResolvedConfig> {\n\t\tif (override.isRootFound()) {\n\t\t\toverride.init();\n\t\t\treturn override.resolve();\n\t\t}\n\n\t\tconst globalConfig = await this.getGlobalConfig();\n\n\t\t/* special case when the global configuration is marked as root, should not\n\t\t * try to load and more configuration files */\n\t\tif (globalConfig.isRootFound()) {\n\t\t\tconst merged = globalConfig.merge(this.resolvers, override);\n\t\t\tmerged.init();\n\t\t\treturn merged.resolve();\n\t\t}\n\n\t\tconst config = await this.fromFilenameAsync(filename);\n\t\treturn this._mergeSync(globalConfig, override, config);\n\t}\n\n\t/**\n\t * @internal For testing only\n\t */\n\tpublic _getInternalCache(): Map<string, Config | null> {\n\t\treturn this.cache;\n\t}\n\n\tprotected defaultConfig(): Config | Promise<Config> {\n\t\treturn Config.defaultConfig();\n\t}\n}\n","import kleur from \"kleur\";\nimport { version } from \"../generated/package\";\nimport { type CompatibilityOptions, compatibilityCheckImpl } from \"./compatibility-check\";\n\nconst defaults: CompatibilityOptions = {\n\tsilent: false,\n\tversion,\n\tlogger(text: string): void {\n\t\t/* eslint-disable-next-line no-console -- expected to log */\n\t\tconsole.error(kleur.red(text));\n\t},\n};\n\n/**\n * Tests if plugin is compatible with html-validate library. Unless the `silent`\n * option is used a warning is displayed on the console.\n *\n * @public\n * @since v5.0.0\n * @param name - Name of plugin\n * @param declared - What library versions the plugin support (e.g. declared peerDependencies)\n * @returns - `true` if version is compatible\n */\nexport function compatibilityCheck(\n\tname: string,\n\tdeclared: string,\n\toptions?: Partial<CompatibilityOptions>,\n): boolean {\n\treturn compatibilityCheckImpl(name, declared, {\n\t\t...defaults,\n\t\t...options,\n\t});\n}\n"],"names":["fs","options","override"],"mappings":";;;;;;AAGgB,SAAA,eAAA,CAAgB,SAAyB,QAA2B,EAAA;AACnF,EAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AAGzC,EAAM,MAAA,CAAA,GAAI,OAAQ,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAChC,EAAA,IAAI,uBAAG,MAAQ,EAAA;AACd,IAAM,MAAA,EAAE,QAAW,GAAA,CAAA,CAAA;AACnB,IAAA,KAAA,IAAS,IAAI,MAAO,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACrD,MAAA,IAAI,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,CAAE,OAAO,QAAU,EAAA;AACvC,QAAO,MAAA,CAAA,QAAA,CAAS,MAAO,CAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAAA,OAC5B;AAAA,KACD;AAAA,GACD;AAIA,EAAO,OAAA,OAAA,CAAQ,MAAM,QAAQ,CAAA,CAAA;AAG7B,EAAA,OAAO,QAAQ,QAAQ,CAAA,CAAA;AACxB;;;;ACpBA,IAAI,aAA+B,GAAA,IAAA,CAAA;AASnB,SAAA,oBAAA,CAAqB,QAAgBA,GAAoB,EAAA;AAExE,EAAA,IAAI,OAAU,GAAA,MAAA,CAAA;AAGd,EAAA,OAAO,IAAM,EAAA;AACZ,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,IAAK,CAAA,OAAA,EAAS,cAAc,CAAA,CAAA;AAChD,IAAIA,IAAAA,GAAAA,CAAG,UAAW,CAAA,MAAM,CAAG,EAAA;AAC1B,MAAO,OAAA,OAAA,CAAA;AAAA,KACR;AAGA,IAAA,MAAM,KAAQ,GAAA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AQ,EAAA,CAAA;AAAA,KACvB;AAEA,IAAA,MAAM,MAAS,GAAA,MAAM,IAAK,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AACpD,IAAA,OAAO,IAAK,CAAA,UAAA,CAAW,YAAc,EAAA,QAAA,EAAU,MAAM,CAAA,CAAA;AAAA,GACtD;AAAA;AAAA;AAAA;AAAA,EAKO,iBAAgD,GAAA;AACtD,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GACb;AAAA,EAEU,aAA0C,GAAA;AACnD,IAAA,OAAO,OAAO,aAAc,EAAA,CAAA;AAAA,GAC7B;AACD;;ACnUA,MAAM,QAAiC,GAAA;AAAA,EACtC,MAAQ,EAAA,KAAA;AAAA,EACR,OAAA;AAAA,EACA,OAAO,IAAoB,EAAA;AAE1B,IAAA,OAAA,CAAQ,KAAM,CAAA,KAAA,CAAM,GAAI,CAAA,IAAI,CAAC,CAAA,CAAA;AAAA,GAC9B;AACD,CAAA,CAAA;AAYgB,SAAA,kBAAA,CACf,IACA,EAAA,QAAA,EACA,OACU,EAAA;AACV,EAAO,OAAA,sBAAA,CAAuB,MAAM,QAAU,EAAA;AAAA,IAC7C,GAAG,QAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACH,CAAA,CAAA;AACF;;;;"}
package/dist/es/core.js CHANGED
@@ -10775,7 +10775,7 @@ function resolveTransformer(resolvers, id, options) {
10775
10775
  function staticResolver(map = {}) {
10776
10776
  const { elements = {}, configs = {}, plugins = {}, transformers = {} } = map;
10777
10777
  return {
10778
- name: "static-qresolver",
10778
+ name: "static-resolver",
10779
10779
  addElements(id, value) {
10780
10780
  elements[id] = value;
10781
10781
  },
@@ -10850,7 +10850,7 @@ class Config {
10850
10850
  * Create a new blank configuration. See also `Config.defaultConfig()`.
10851
10851
  */
10852
10852
  static empty() {
10853
- return Config.create([], {
10853
+ return new Config([], {
10854
10854
  extends: [],
10855
10855
  rules: {},
10856
10856
  plugins: [],
@@ -10909,7 +10909,7 @@ class Config {
10909
10909
  * Load a default configuration object.
10910
10910
  */
10911
10911
  static defaultConfig() {
10912
- return Config.create([], defaultConfig);
10912
+ return new Config([], defaultConfig);
10913
10913
  }
10914
10914
  /**
10915
10915
  * @internal
@@ -10919,12 +10919,20 @@ class Config {
10919
10919
  instance.plugins = instance.loadPlugins(instance.config.plugins ?? []);
10920
10920
  instance.configurations = instance.loadConfigurations(instance.plugins);
10921
10921
  instance.extendMeta(instance.plugins);
10922
- instance.config = instance.extendConfig(instance.config.extends ?? []);
10923
- instance.config.extends = [];
10924
- if (options.rules) {
10925
- instance.config = mergeInternal(instance.config, { rules: options.rules });
10922
+ const update = (extendedConfig2) => {
10923
+ instance.config = extendedConfig2;
10924
+ instance.config.extends = [];
10925
+ if (options.rules) {
10926
+ instance.config = mergeInternal(instance.config, { rules: options.rules });
10927
+ }
10928
+ return instance;
10929
+ };
10930
+ const extendedConfig = instance.extendConfig(instance.config.extends ?? []);
10931
+ if (isThenable(extendedConfig)) {
10932
+ return extendedConfig.then((extended) => update(extended));
10933
+ } else {
10934
+ return update(extendedConfig);
10926
10935
  }
10927
- return instance;
10928
10936
  }
10929
10937
  /**
10930
10938
  * Initialize plugins, transforms etc.
@@ -10955,7 +10963,11 @@ class Config {
10955
10963
  * @param rhs - Configuration to merge with this one.
10956
10964
  */
10957
10965
  merge(resolvers, rhs) {
10958
- return Config.create(resolvers, mergeInternal(this.config, rhs.config));
10966
+ const instance = new Config(resolvers, mergeInternal(this.config, rhs.config));
10967
+ instance.plugins = instance.loadPlugins(instance.config.plugins ?? []);
10968
+ instance.configurations = instance.loadConfigurations(instance.plugins);
10969
+ instance.extendMeta(instance.plugins);
10970
+ return instance;
10959
10971
  }
10960
10972
  extendConfig(entries) {
10961
10973
  if (entries.length === 0) {
@@ -10967,7 +10979,28 @@ class Config {
10967
10979
  if (this.configurations.has(entry)) {
10968
10980
  extended = this.configurations.get(entry);
10969
10981
  } else {
10970
- extended = Config.fromFile(this.resolvers, entry).config;
10982
+ const loadedConfig = Config.fromFile(this.resolvers, entry);
10983
+ if (isThenable(loadedConfig)) {
10984
+ return this.extendConfigAsync(entries);
10985
+ }
10986
+ extended = loadedConfig.config;
10987
+ }
10988
+ base = mergeInternal(base, extended);
10989
+ }
10990
+ return mergeInternal(base, this.config);
10991
+ }
10992
+ async extendConfigAsync(entries) {
10993
+ if (entries.length === 0) {
10994
+ return this.config;
10995
+ }
10996
+ let base = {};
10997
+ for (const entry of entries) {
10998
+ let extended;
10999
+ if (this.configurations.has(entry)) {
11000
+ extended = this.configurations.get(entry);
11001
+ } else {
11002
+ const loadedConfig = await Config.fromFile(this.resolvers, entry);
11003
+ extended = loadedConfig.config;
10971
11004
  }
10972
11005
  base = mergeInternal(base, extended);
10973
11006
  }
@@ -11231,26 +11264,86 @@ class Config {
11231
11264
  }
11232
11265
 
11233
11266
  class ConfigLoader {
11234
- constructor(resolvers, config) {
11235
- const defaults = Config.empty();
11267
+ /**
11268
+ * Create a new ConfigLoader.
11269
+ *
11270
+ * @param resolvers - Sorted list of resolvers to use (in order).
11271
+ * @param configData - Default configuration (which all configurations will inherit from).
11272
+ */
11273
+ constructor(resolvers, configData) {
11236
11274
  this.resolvers = resolvers;
11237
- this.globalConfig = defaults.merge(
11238
- this.resolvers,
11239
- config ? this.loadFromObject(config) : this.defaultConfig()
11240
- );
11275
+ this._configData = configData;
11276
+ this._globalConfig = null;
11277
+ }
11278
+ /**
11279
+ * Set a new default configuration on this loader. Resets cached global
11280
+ * configuration.
11281
+ *
11282
+ * @internal
11283
+ */
11284
+ setConfigData(configData) {
11285
+ this._configData = configData;
11286
+ this._globalConfig = null;
11287
+ }
11288
+ /**
11289
+ * Get the global configuration.
11290
+ *
11291
+ * @returns A promise resolving to the global configuration.
11292
+ */
11293
+ getGlobalConfig() {
11294
+ if (this._globalConfig) {
11295
+ return this._globalConfig;
11296
+ }
11297
+ const defaults = Config.empty();
11298
+ const config = this._configData ? this.loadFromObject(this._configData) : this.defaultConfig();
11299
+ if (isThenable(config)) {
11300
+ return config.then((config2) => {
11301
+ this._globalConfig = defaults.merge(this.resolvers, config2);
11302
+ return this._globalConfig;
11303
+ });
11304
+ } else {
11305
+ this._globalConfig = defaults.merge(this.resolvers, config);
11306
+ return this._globalConfig;
11307
+ }
11308
+ }
11309
+ /**
11310
+ * Get the global configuration.
11311
+ *
11312
+ * The synchronous version does not support async resolvers.
11313
+ *
11314
+ * @returns The global configuration.
11315
+ */
11316
+ getGlobalConfigSync() {
11317
+ if (this._globalConfig) {
11318
+ return this._globalConfig;
11319
+ }
11320
+ const defaults = Config.empty();
11321
+ const config = this._configData ? this.loadFromObject(this._configData) : this.defaultConfig();
11322
+ if (isThenable(config)) {
11323
+ throw new UserError("Cannot load async config from sync function");
11324
+ }
11325
+ this._globalConfig = defaults.merge(this.resolvers, config);
11326
+ return this._globalConfig;
11241
11327
  }
11242
11328
  /**
11243
11329
  * @internal For testing only
11244
11330
  */
11245
- _getGlobalConfig() {
11246
- return this.globalConfig.get();
11331
+ async _getGlobalConfig() {
11332
+ const config = await this.getGlobalConfig();
11333
+ return config.get();
11247
11334
  }
11248
11335
  empty() {
11249
11336
  return Config.empty();
11250
11337
  }
11338
+ /**
11339
+ * Load configuration from object.
11340
+ */
11251
11341
  loadFromObject(options, filename) {
11252
11342
  return Config.fromObject(this.resolvers, options, filename);
11253
11343
  }
11344
+ /**
11345
+ * Load configuration from filename.
11346
+ */
11254
11347
  loadFromFile(filename) {
11255
11348
  return Config.fromFile(this.resolvers, filename);
11256
11349
  }
@@ -12403,20 +12496,16 @@ class StaticConfigLoader extends ConfigLoader {
12403
12496
  * @since 8.20.0
12404
12497
  * @param config - New configuration to use.
12405
12498
  */
12406
- /* istanbul ignore next -- not testing setters/getters */
12407
12499
  setConfig(config) {
12408
- const defaults = Config.empty();
12409
- this.globalConfig = defaults.merge(this.resolvers, this.loadFromObject(config));
12500
+ this.setConfigData(config);
12410
12501
  }
12411
12502
  getConfigFor(_handle, configOverride) {
12412
12503
  const override = this.loadFromObject(configOverride ?? {});
12413
- if (override.isRootFound()) {
12414
- override.init();
12415
- return override.resolve();
12504
+ if (isThenable(override)) {
12505
+ return override.then((override2) => this._resolveConfig(override2));
12506
+ } else {
12507
+ return this._resolveConfig(override);
12416
12508
  }
12417
- const merged = this.globalConfig.merge(this.resolvers, override);
12418
- merged.init();
12419
- return merged.resolve();
12420
12509
  }
12421
12510
  flushCache() {
12422
12511
  }
@@ -12426,6 +12515,24 @@ class StaticConfigLoader extends ConfigLoader {
12426
12515
  elements: ["html5"]
12427
12516
  });
12428
12517
  }
12518
+ _resolveConfig(override) {
12519
+ if (override.isRootFound()) {
12520
+ override.init();
12521
+ return override.resolve();
12522
+ }
12523
+ const globalConfig = this.getGlobalConfig();
12524
+ if (isThenable(globalConfig)) {
12525
+ return globalConfig.then((globalConfig2) => {
12526
+ const merged = globalConfig2.merge(this.resolvers, override);
12527
+ merged.init();
12528
+ return merged.resolve();
12529
+ });
12530
+ } else {
12531
+ const merged = globalConfig.merge(this.resolvers, override);
12532
+ merged.init();
12533
+ return merged.resolve();
12534
+ }
12535
+ }
12429
12536
  }
12430
12537
 
12431
12538
  function isSourceHooks(value) {
@@ -12795,7 +12902,11 @@ class HtmlValidate {
12795
12902
  * @param configOverride - Configuration to apply last.
12796
12903
  */
12797
12904
  getConfigForSync(filename, configOverride) {
12798
- return this.configLoader.getConfigFor(filename, configOverride);
12905
+ const config = this.configLoader.getConfigFor(filename, configOverride);
12906
+ if (isThenable(config)) {
12907
+ throw new UserError("Cannot use asynchronous config loader with synchronous api");
12908
+ }
12909
+ return config;
12799
12910
  }
12800
12911
  /**
12801
12912
  * Get current configuration loader.
@@ -12833,7 +12944,7 @@ class HtmlValidate {
12833
12944
  }
12834
12945
 
12835
12946
  const name = "html-validate";
12836
- const version = "8.22.0";
12947
+ const version = "9.0.0-rc.2";
12837
12948
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12838
12949
 
12839
12950
  function definePlugin(plugin) {
@@ -13788,5 +13899,5 @@ function compatibilityCheckImpl(name, declared, options) {
13788
13899
  return false;
13789
13900
  }
13790
13901
 
13791
- export { Attribute as A, definePlugin as B, Config as C, DOMNode as D, Parser as E, ruleExists as F, walk as G, HtmlValidate as H, EventHandler as I, compatibilityCheckImpl as J, codeframe as K, name as L, MetaCopyableProperty as M, NodeClosed as N, bugs as O, Presets as P, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, defineConfig as c, deepmerge$1 as d, ensureError as e, StaticConfigLoader as f, getFormatter as g, DOMTokenList as h, ignore$1 as i, DOMTree as j, DynamicValue as k, HtmlElement as l, NodeType as m, NestedError as n, SchemaValidationError as o, MetaTable as p, TextContent$1 as q, Rule as r, staticResolver as s, ariaNaming as t, TextClassification as u, version as v, classifyNodeText as w, keywordPatternMatcher as x, sliceLocation as y, Reporter as z };
13902
+ export { Attribute as A, definePlugin as B, Config as C, DOMNode as D, Parser as E, ruleExists as F, walk as G, HtmlValidate as H, EventHandler as I, compatibilityCheckImpl as J, isThenable as K, codeframe as L, MetaCopyableProperty as M, NodeClosed as N, name as O, Presets as P, bugs as Q, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, defineConfig as c, deepmerge$1 as d, ensureError as e, StaticConfigLoader as f, getFormatter as g, DOMTokenList as h, ignore$1 as i, DOMTree as j, DynamicValue as k, HtmlElement as l, NodeType as m, NestedError as n, SchemaValidationError as o, MetaTable as p, TextContent$1 as q, Rule as r, staticResolver as s, ariaNaming as t, TextClassification as u, version as v, classifyNodeText as w, keywordPatternMatcher as x, sliceLocation as y, Reporter as z };
13792
13903
  //# sourceMappingURL=core.js.map