html-validate 8.28.0 → 8.29.0

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.
package/dist/es/core.js CHANGED
@@ -633,6 +633,9 @@ const patternProperties = {
633
633
  {
634
634
  type: "boolean"
635
635
  },
636
+ {
637
+ "function": true
638
+ },
636
639
  {
637
640
  $ref: "#/definitions/expression"
638
641
  }
@@ -1193,7 +1196,7 @@ const schemaCache = /* @__PURE__ */ new Map();
1193
1196
  function clone(src) {
1194
1197
  return JSON.parse(JSON.stringify(src));
1195
1198
  }
1196
- function overwriteMerge$1(a, b) {
1199
+ function overwriteMerge$1(_a, b) {
1197
1200
  return b;
1198
1201
  }
1199
1202
  class MetaTable {
@@ -3344,10 +3347,17 @@ const properties = {
3344
3347
  transform: {
3345
3348
  type: "object",
3346
3349
  additionalProperties: {
3347
- type: "string"
3350
+ anyOf: [
3351
+ {
3352
+ type: "string"
3353
+ },
3354
+ {
3355
+ "function": true
3356
+ }
3357
+ ]
3348
3358
  },
3349
3359
  title: "File transformations to use.",
3350
- description: "Object where key is regular expression to match filename and value is name of transformer.",
3360
+ description: "Object where key is regular expression to match filename and value is name of transformer or a function.",
3351
3361
  examples: [
3352
3362
  {
3353
3363
  "^.*\\.foo$": "my-transformer",
@@ -10955,12 +10965,13 @@ class ResolvedConfig {
10955
10965
  if (!transformer) {
10956
10966
  return [source];
10957
10967
  }
10958
- const fn = getCachedTransformerFunction(this.cache, resolvers, transformer.name, this.plugins);
10968
+ const fn = transformer.kind === "import" ? getCachedTransformerFunction(this.cache, resolvers, transformer.name, this.plugins) : transformer.function;
10969
+ const name = transformer.kind === "import" ? transformer.name : transformer.function.name;
10959
10970
  try {
10960
10971
  const transformedSources = Array.from(fn.call(context, source));
10961
10972
  for (const source2 of transformedSources) {
10962
10973
  source2.transformedBy ??= [];
10963
- source2.transformedBy.push(transformer.name);
10974
+ source2.transformedBy.push(name);
10964
10975
  }
10965
10976
  return transformedSources;
10966
10977
  } catch (err) {
@@ -11008,8 +11019,9 @@ class ResolvedConfig {
11008
11019
 
11009
11020
  const ajv = new Ajv({ strict: true, strictTuples: true, strictTypes: true });
11010
11021
  ajv.addMetaSchema(ajvSchemaDraft);
11022
+ ajv.addKeyword(ajvFunctionKeyword);
11011
11023
  const validator = ajv.compile(configurationSchema);
11012
- function overwriteMerge(a, b) {
11024
+ function overwriteMerge(_a, b) {
11013
11025
  return b;
11014
11026
  }
11015
11027
  function mergeInternal(base, rhs) {
@@ -11031,9 +11043,13 @@ function toArray(value) {
11031
11043
  }
11032
11044
  }
11033
11045
  function transformerEntries(transform) {
11034
- return Object.entries(transform).map(([pattern, name]) => {
11046
+ return Object.entries(transform).map(([pattern, value]) => {
11035
11047
  const regex = new RegExp(pattern);
11036
- return { pattern: regex, name };
11048
+ if (typeof value === "string") {
11049
+ return { kind: "import", pattern: regex, name: value };
11050
+ } else {
11051
+ return { kind: "function", pattern: regex, function: value };
11052
+ }
11037
11053
  });
11038
11054
  }
11039
11055
  class Config {
@@ -13014,7 +13030,7 @@ class HtmlValidate {
13014
13030
  }
13015
13031
 
13016
13032
  const name = "html-validate";
13017
- const version = "8.28.0";
13033
+ const version = "8.29.0";
13018
13034
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
13019
13035
 
13020
13036
  function definePlugin(plugin) {