html-validate 8.27.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.
Files changed (46) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/cli.js +1 -2
  3. package/dist/cjs/cli.js.map +1 -1
  4. package/dist/cjs/core-nodejs.js +2 -5
  5. package/dist/cjs/core-nodejs.js.map +1 -1
  6. package/dist/cjs/core.js +2760 -2745
  7. package/dist/cjs/core.js.map +1 -1
  8. package/dist/cjs/elements.js +3 -1
  9. package/dist/cjs/elements.js.map +1 -1
  10. package/dist/cjs/jest-worker.js +60 -0
  11. package/dist/cjs/jest-worker.js.map +1 -0
  12. package/dist/cjs/jest.js +2 -0
  13. package/dist/cjs/jest.js.map +1 -1
  14. package/dist/cjs/matcher-utils.js +65 -0
  15. package/dist/cjs/matcher-utils.js.map +1 -1
  16. package/dist/cjs/matchers.js +2 -5
  17. package/dist/cjs/matchers.js.map +1 -1
  18. package/dist/cjs/tsdoc-metadata.json +1 -1
  19. package/dist/cjs/vitest.js +2 -0
  20. package/dist/cjs/vitest.js.map +1 -1
  21. package/dist/es/cli.js +1 -2
  22. package/dist/es/cli.js.map +1 -1
  23. package/dist/es/core-nodejs.js +2 -5
  24. package/dist/es/core-nodejs.js.map +1 -1
  25. package/dist/es/core.js +2760 -2746
  26. package/dist/es/core.js.map +1 -1
  27. package/dist/es/elements.js +3 -1
  28. package/dist/es/elements.js.map +1 -1
  29. package/dist/es/html-validate.js +1 -1
  30. package/dist/es/jest-worker.js +59 -0
  31. package/dist/es/jest-worker.js.map +1 -0
  32. package/dist/es/jest.js +2 -0
  33. package/dist/es/jest.js.map +1 -1
  34. package/dist/es/matcher-utils.js +65 -1
  35. package/dist/es/matcher-utils.js.map +1 -1
  36. package/dist/es/matchers-jestonly.js +1 -1
  37. package/dist/es/matchers.js +4 -7
  38. package/dist/es/matchers.js.map +1 -1
  39. package/dist/es/vitest.js +2 -0
  40. package/dist/es/vitest.js.map +1 -1
  41. package/dist/schema/config.json +2 -2
  42. package/dist/schema/elements.json +5 -1
  43. package/dist/tsdoc-metadata.json +1 -1
  44. package/dist/types/browser.d.ts +20 -4
  45. package/dist/types/index.d.ts +20 -4
  46. package/package.json +1 -1
@@ -2,7 +2,7 @@ import fs from 'fs';
2
2
  import path from 'node:path';
3
3
  import kleur from 'kleur';
4
4
  import minimist from 'minimist';
5
- import { L as name, v as version, o as SchemaValidationError, U as UserError, O as bugs } from './core.js';
5
+ import { O as name, v as version, o as SchemaValidationError, U as UserError, Q as bugs } from './core.js';
6
6
  import { M as Mode, m as modeToFlag, C as CLI, l as lint, i as init, p as printConfig, d as dump, h as handleSchemaValidationError } from './cli.js';
7
7
  import 'ajv';
8
8
  import './elements.js';
@@ -0,0 +1,59 @@
1
+ import { workerData, parentPort } from 'node:worker_threads';
2
+ import { F as FileSystemConfigLoader } from './core-nodejs.js';
3
+ import { H as HtmlValidate } from './core.js';
4
+ import 'node:fs';
5
+ import 'node:path';
6
+ import 'node:module';
7
+ import 'kleur';
8
+ import 'ajv';
9
+ import './elements.js';
10
+ import './meta-helper.js';
11
+ import './utils/natural-join.js';
12
+ import '@sidvind/better-ajv-errors';
13
+ import '@html-validate/stylish';
14
+ import 'semver';
15
+
16
+ function runAsWorker(fn) {
17
+ if (!workerData) {
18
+ return;
19
+ }
20
+ const { workerPort, sharedBuffer } = workerData;
21
+ const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
22
+ parentPort.on("message", ({ id, args }) => {
23
+ async function inner() {
24
+ let isAborted = false;
25
+ const handleAbortMessage = (msg2) => {
26
+ if (msg2.id === id && msg2.cmd === "abort") {
27
+ isAborted = true;
28
+ }
29
+ };
30
+ workerPort.on("message", handleAbortMessage);
31
+ let msg;
32
+ try {
33
+ msg = { id, result: await fn(...args) };
34
+ } catch (error) {
35
+ msg = {
36
+ id,
37
+ error: error instanceof Error ? error.message : String(error)
38
+ };
39
+ }
40
+ workerPort.off("message", handleAbortMessage);
41
+ if (isAborted) {
42
+ return;
43
+ }
44
+ workerPort.postMessage(msg);
45
+ Atomics.add(sharedBufferView, 0, 1);
46
+ Atomics.notify(sharedBufferView, 0);
47
+ }
48
+ inner();
49
+ });
50
+ }
51
+ function validateString(markup, filename, config) {
52
+ const loader = new FileSystemConfigLoader({
53
+ extends: ["html-validate:recommended"]
54
+ });
55
+ const htmlvalidate = new HtmlValidate(loader);
56
+ return htmlvalidate.validateString(markup, filename, config);
57
+ }
58
+ runAsWorker(validateString);
59
+ //# sourceMappingURL=jest-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- modified by handleAbortMessage\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["msg"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAS,YAAkE,EAAa,EAAA;AACvF,EAAA,IAAI,CAAC,UAAY,EAAA;AAChB,IAAA;AAAA;AAGD,EAAM,MAAA,EAAE,UAAY,EAAA,YAAA,EAAiB,GAAA,UAAA;AACrC,EAAA,MAAM,gBAAmB,GAAA,IAAI,UAAW,CAAA,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAA,UAAA,CAAY,GAAG,SAAW,EAAA,CAAC,EAAE,EAAA,EAAI,MAA+C,KAAA;AAC/E,IAAA,eAAe,KAAuB,GAAA;AACrC,MAAA,IAAI,SAAY,GAAA,KAAA;AAChB,MAAM,MAAA,kBAAA,GAAqB,CAACA,IAA0C,KAAA;AACrE,QAAA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, b as createMatcher$2, d as cr
2
2
  import { c as createMatcher$5, a as createMatcher$6 } from './matchers-jestonly.js';
3
3
  import { d as diff } from './jest-diff.js';
4
4
  import './matcher-utils.js';
5
+ import 'node:url';
6
+ import 'node:worker_threads';
5
7
  import './core.js';
6
8
  import 'ajv';
7
9
  import './elements.js';
@@ -1 +1 @@
1
- {"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n\ttoMatchCodeframe,\n\ttoMatchInlineCodeframe,\n} from \"./matchers\";\nimport { diff } from \"./utils\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, diff),\n\ttoHaveError: toHaveError(expect, diff),\n\ttoHaveErrors: toHaveErrors(expect, diff),\n\ttoMatchCodeframe: toMatchCodeframe(),\n\ttoMatchInlineCodeframe: toMatchInlineCodeframe(),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors","toMatchCodeframe","toMatchInlineCodeframe"],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EAC3C,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACrC,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC,kBAAkBC,eAAiB,EAAA;AAAA,EACnC,wBAAwBC,eAAuB;AAChD,CAAC,CAAA"}
1
+ {"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n\ttoMatchCodeframe,\n\ttoMatchInlineCodeframe,\n} from \"./matchers\";\nimport { diff } from \"./utils\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, diff),\n\ttoHaveError: toHaveError(expect, diff),\n\ttoHaveErrors: toHaveErrors(expect, diff),\n\ttoMatchCodeframe: toMatchCodeframe(),\n\ttoMatchInlineCodeframe: toMatchInlineCodeframe(),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors","toMatchCodeframe","toMatchInlineCodeframe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EAC3C,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACrC,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC,kBAAkBC,eAAiB,EAAA;AAAA,EACnC,wBAAwBC,eAAuB;AAChD,CAAC,CAAA"}
@@ -1,3 +1,6 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { MessageChannel, Worker, receiveMessageOnPort } from 'node:worker_threads';
3
+
1
4
  function isThenable(value) {
2
5
  return value && typeof value === "object" && "then" in value && typeof value.then === "function";
3
6
  }
@@ -19,5 +22,66 @@ function flattenMessages(report) {
19
22
  }, []);
20
23
  }
21
24
 
22
- export { diverge as d, flattenMessages as f, isThenable as i };
25
+ const INT32_BYTES = 4;
26
+ const syncFnCache = /* @__PURE__ */ new Map();
27
+ const sharedBuffer = new SharedArrayBuffer(INT32_BYTES);
28
+ const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
29
+ function isWorkerError(value) {
30
+ return "error" in value;
31
+ }
32
+ function receiveMessageWithId(port, expectedId) {
33
+ const timeout = 1e4;
34
+ const status = Atomics.wait(sharedBufferView, 0, 0, timeout);
35
+ Atomics.store(sharedBufferView, 0, 0);
36
+ if (!["ok", "not-equal"].includes(status)) {
37
+ const abortMsg = {
38
+ id: expectedId,
39
+ cmd: "abort"
40
+ };
41
+ port.postMessage(abortMsg);
42
+ throw new Error(`Internal error: Atomics.wait() failed: ${status}`);
43
+ }
44
+ const reply = receiveMessageOnPort(port);
45
+ const { id, ...message } = reply.message;
46
+ if (id < expectedId) {
47
+ return receiveMessageWithId(port, expectedId);
48
+ }
49
+ if (expectedId !== id) {
50
+ throw new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);
51
+ }
52
+ return { id, ...message };
53
+ }
54
+ function startWorkerThread(workerPath) {
55
+ const { port1: mainPort, port2: workerPort } = new MessageChannel();
56
+ const workerPathUrl = pathToFileURL(require.resolve(workerPath));
57
+ const worker = new Worker(workerPathUrl, {
58
+ eval: false,
59
+ workerData: { sharedBuffer, workerPort },
60
+ transferList: [workerPort]
61
+ });
62
+ let nextID = 0;
63
+ const syncFn = (...args) => {
64
+ const id = nextID++;
65
+ const msg = { id, args };
66
+ worker.postMessage(msg);
67
+ const reply = receiveMessageWithId(mainPort, id);
68
+ if (isWorkerError(reply)) {
69
+ throw new Error(reply.error);
70
+ }
71
+ return reply.result;
72
+ };
73
+ worker.unref();
74
+ return syncFn;
75
+ }
76
+ function createSyncFn(workerPath) {
77
+ const cachedSyncFn = syncFnCache.get(workerPath);
78
+ if (cachedSyncFn) {
79
+ return cachedSyncFn;
80
+ }
81
+ const syncFn = startWorkerThread(workerPath);
82
+ syncFnCache.set(workerPath, syncFn);
83
+ return syncFn;
84
+ }
85
+
86
+ export { createSyncFn as c, diverge as d, flattenMessages as f, isThenable as i };
23
87
  //# sourceMappingURL=matcher-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n"],"names":[],"mappings":"AAGO,SAAS,WAAc,KAA4C,EAAA;AACzE,EAAO,OAAA,KAAA,IAAS,OAAO,KAAU,KAAA,QAAA,IAAY,UAAU,KAAS,IAAA,OAAO,MAAM,IAAS,KAAA,UAAA;AACvF;;ACyBO,SAAS,QACf,EAC+B,EAAA;AAO/B,EAAS,SAAA,QAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,IAAK,CAAA,CAAC,QAAa,KAAA,EAAA,CAAG,KAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KAC3D,MAAA;AACN,MAAA,OAAO,EAAG,CAAA,IAAA,CAAK,IAAM,EAAA,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA;AACrC;AAED,EAAO,OAAA,QAAA;AACR;;AC7CO,SAAS,gBAAgB,MAA2B,EAAA;AAC1D,EAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,MAAO,CAAA,CAAC,YAAuB,MAAmB,KAAA;AACvE,IAAO,OAAA,UAAA,CAAW,MAAO,CAAA,MAAA,CAAO,QAAQ,CAAA;AAAA,GACzC,EAAG,EAAE,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts","../../src/jest/worker/create-sync-fn.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n","import { pathToFileURL } from \"node:url\";\nimport {\n\ttype MessagePort,\n\tMessageChannel,\n\tWorker,\n\treceiveMessageOnPort,\n} from \"node:worker_threads\";\nimport {\n\ttype AnyAsyncFn,\n\ttype AnyFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype Syncify,\n\ttype WorkerToMainError,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\n/**\n * This is all based on the synckit library but without all the extra stuff such\n * as typescript, esbuld, pnp etc.\n */\n\nconst INT32_BYTES = 4;\nconst syncFnCache = new Map<string, AnyFn>();\nconst sharedBuffer = new SharedArrayBuffer(INT32_BYTES);\nconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\nfunction isWorkerError<T>(value: WorkerToMainMessage<T>): value is WorkerToMainError {\n\treturn \"error\" in value;\n}\n\nfunction receiveMessageWithId<R>(port: MessagePort, expectedId: number): WorkerToMainMessage<R> {\n\tconst timeout = 10000;\n\tconst status = Atomics.wait(sharedBufferView, 0, 0, timeout);\n\tAtomics.store(sharedBufferView, 0, 0);\n\n\tif (![\"ok\", \"not-equal\"].includes(status)) {\n\t\tconst abortMsg: MainToWorkerCommandMessage = {\n\t\t\tid: expectedId,\n\t\t\tcmd: \"abort\",\n\t\t};\n\t\tport.postMessage(abortMsg);\n\t\tthrow new Error(`Internal error: Atomics.wait() failed: ${status}`);\n\t}\n\n\tconst reply = receiveMessageOnPort(port) as { message: WorkerToMainMessage<R> };\n\tconst { id, ...message } = reply.message;\n\n\tif (id < expectedId) {\n\t\treturn receiveMessageWithId(port, expectedId);\n\t}\n\n\tif (expectedId !== id) {\n\t\tthrow new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);\n\t}\n\n\treturn { id, ...message };\n}\n\nfunction startWorkerThread<R, T extends AnyAsyncFn<R>>(\n\tworkerPath: string,\n): (...args: Parameters<T>) => R {\n\tconst { port1: mainPort, port2: workerPort } = new MessageChannel();\n\tconst workerPathUrl = pathToFileURL(require.resolve(workerPath));\n\tconst worker = new Worker(workerPathUrl, {\n\t\teval: false,\n\t\tworkerData: { sharedBuffer, workerPort },\n\t\ttransferList: [workerPort],\n\t});\n\n\tlet nextID = 0;\n\n\tconst syncFn = (...args: Parameters<T>): R => {\n\t\tconst id = nextID++;\n\t\tconst msg: MainToWorkerMessage<Parameters<T>> = { id, args };\n\n\t\tworker.postMessage(msg);\n\n\t\tconst reply = receiveMessageWithId<R>(mainPort, id);\n\n\t\tif (isWorkerError(reply)) {\n\t\t\tthrow new Error(reply.error);\n\t\t}\n\n\t\treturn reply.result;\n\t};\n\n\tworker.unref();\n\n\treturn syncFn;\n}\n\nexport function createSyncFn<T extends AnyAsyncFn<R>, R = unknown>(workerPath: string): Syncify<T> {\n\tconst cachedSyncFn = syncFnCache.get(workerPath);\n\tif (cachedSyncFn) {\n\t\treturn cachedSyncFn as Syncify<T>;\n\t}\n\n\tconst syncFn = startWorkerThread<R, T>(workerPath);\n\tsyncFnCache.set(workerPath, syncFn);\n\treturn syncFn as Syncify<T>;\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,WAAc,KAA4C,EAAA;AACzE,EAAO,OAAA,KAAA,IAAS,OAAO,KAAU,KAAA,QAAA,IAAY,UAAU,KAAS,IAAA,OAAO,MAAM,IAAS,KAAA,UAAA;AACvF;;ACyBO,SAAS,QACf,EAC+B,EAAA;AAO/B,EAAS,SAAA,QAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,IAAK,CAAA,CAAC,QAAa,KAAA,EAAA,CAAG,KAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KAC3D,MAAA;AACN,MAAA,OAAO,EAAG,CAAA,IAAA,CAAK,IAAM,EAAA,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA;AACrC;AAED,EAAO,OAAA,QAAA;AACR;;AC7CO,SAAS,gBAAgB,MAA2B,EAAA;AAC1D,EAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,MAAO,CAAA,CAAC,YAAuB,MAAmB,KAAA;AACvE,IAAO,OAAA,UAAA,CAAW,MAAO,CAAA,MAAA,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AAA;AAGR,EAAM,MAAA,MAAA,GAAS,kBAAwB,UAAU,CAAA;AACjD,EAAY,WAAA,CAAA,GAAA,CAAI,YAAY,MAAM,CAAA;AAClC,EAAO,OAAA,MAAA;AACR;;;;"}
@@ -1,6 +1,6 @@
1
1
  import kleur from 'kleur';
2
2
  import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
3
- import { K as codeframe } from './core.js';
3
+ import { L as codeframe } from './core.js';
4
4
  import { g as getResults } from './matchers.js';
5
5
  import { d as diverge, i as isThenable } from './matcher-utils.js';
6
6
 
@@ -1,5 +1,5 @@
1
- import { d as diverge, f as flattenMessages } from './matcher-utils.js';
2
- import { d as deepmerge, H as HtmlValidate } from './core.js';
1
+ import { d as diverge, c as createSyncFn, f as flattenMessages } from './matcher-utils.js';
2
+ import { d as deepmerge, K as workerPath, H as HtmlValidate } from './core.js';
3
3
  import { F as FileSystemConfigLoader } from './core-nodejs.js';
4
4
 
5
5
  function createMatcher$4() {
@@ -92,11 +92,8 @@ function toHTMLValidateImpl(expect, diff, actual, expectedError, userConfig, fil
92
92
  };
93
93
  const config = deepmerge(defaultConfig, userConfig ?? {});
94
94
  const actualFilename = filename ?? this.testPath ?? "inline";
95
- const loader = new FileSystemConfigLoader({
96
- extends: ["html-validate:recommended"]
97
- });
98
- const htmlvalidate = new HtmlValidate(loader);
99
- const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
95
+ const syncFn = createSyncFn(workerPath);
96
+ const report = syncFn(actual, actualFilename, config);
100
97
  const pass = report.valid;
101
98
  const result = report.results[0];
102
99
  if (pass) {
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ||\n\t\t\targ.severity ||\n\t\t\targ.message ||\n\t\t\targ.offset ||\n\t\t\targ.line ||\n\t\t\targ.column ||\n\t\t\targ.size ||\n\t\t\targ.selector ||\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string;\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<unknown, [Arg1?, Arg2?, Arg3?]> {\n\tfunction toHTMLValidate(\n\t\tthis: MatcherContext,\n\t\tactual: unknown,\n\t\targ0?: Arg1,\n\t\targ1?: Arg2,\n\t\targ2?: Arg3,\n\t): MatcherResult {\n\t\tconst markup = getMarkup(actual);\n\t\tconst message = isMessage(arg0) ? arg0 : undefined;\n\t\tconst config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\tconst report = htmlvalidate.validateStringSync(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, any?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: any,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: any,\n\t): MatcherResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3) {\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n\tflattenMessages,\n} from \"../utils\";\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): MatcherResult {\n\t\tconst flattened = flattenMessages(report);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = diff\n\t\t\t? diff(matcher, flattened, { expand: this.expand })\n\t\t\t: /* istanbul ignore next */ undefined;\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { type Report, type Result } from \"../../reporter\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst loader = new FileSystemConfigLoader({\n\t\t\textends: [\"html-validate:recommended\"],\n\t\t});\n\t\tconst htmlvalidate = new HtmlValidate(loader);\n\t\tconst report = htmlvalidate.validateStringSync(value, filename, {\n\t\t\trules: {\n\t\t\t\t\"void-style\": \"off\",\n\t\t\t},\n\t\t});\n\t\treturn report.results.map((it) => {\n\t\t\treturn { ...it, filePath: \"inline\" };\n\t\t});\n\t} else {\n\t\treturn value.results;\n\t}\n}\n"],"names":["createMatcher","actual"],"mappings":";;;;AAGA,SAASA,eAAgD,GAAA;AACxD,EAAA,SAAS,UAAU,MAA+B,EAAA;AACjD,IAAA,IAAI,OAAO,KAAO,EAAA;AACjB,MAAO,OAAA;AAAA,QACN,IAAM,EAAA,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,KACM,MAAA;AACN,MAAA,MAAM,aAAa,MAAO,CAAA,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/C,MAAO,OAAA;AAAA,QACN,IAAM,EAAA,KAAA;AAAA,QACN,OAAS,EAAA,MAAM,CAAyC,sCAAA,EAAA,UAAA,CAAW,OAAO,CAAA,CAA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AmB,CAAA,KAAA,EAAO,QAAU,EAAA;AAAA,MAC/D,KAAO,EAAA;AAAA,QACN,YAAc,EAAA;AAAA;AACf,KACA,CAAA;AACD,IAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,EAAO,KAAA;AACjC,MAAA,OAAO,EAAE,GAAG,EAAI,EAAA,QAAA,EAAU,QAAS,EAAA;AAAA,KACnC,CAAA;AAAA,GACK,MAAA;AACN,IAAA,OAAO,KAAM,CAAA,OAAA;AAAA;AAEf;;;;"}
1
+ {"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ||\n\t\t\targ.severity ||\n\t\t\targ.message ||\n\t\t\targ.offset ||\n\t\t\targ.line ||\n\t\t\targ.column ||\n\t\t\targ.size ||\n\t\t\targ.selector ||\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string;\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<unknown, [Arg1?, Arg2?, Arg3?]> {\n\tfunction toHTMLValidate(\n\t\tthis: MatcherContext,\n\t\tactual: unknown,\n\t\targ0?: Arg1,\n\t\targ1?: Arg2,\n\t\targ2?: Arg3,\n\t): MatcherResult {\n\t\tconst markup = getMarkup(actual);\n\t\tconst message = isMessage(arg0) ? arg0 : undefined;\n\t\tconst config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\n\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\tconst report = syncFn(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, any?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: any,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: any,\n\t): MatcherResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3) {\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n\tflattenMessages,\n} from \"../utils\";\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): MatcherResult {\n\t\tconst flattened = flattenMessages(report);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = diff\n\t\t\t? diff(matcher, flattened, { expand: this.expand })\n\t\t\t: /* istanbul ignore next */ undefined;\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { type Report, type Result } from \"../../reporter\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst loader = new FileSystemConfigLoader({\n\t\t\textends: [\"html-validate:recommended\"],\n\t\t});\n\t\tconst htmlvalidate = new HtmlValidate(loader);\n\t\tconst report = htmlvalidate.validateStringSync(value, filename, {\n\t\t\trules: {\n\t\t\t\t\"void-style\": \"off\",\n\t\t\t},\n\t\t});\n\t\treturn report.results.map((it) => {\n\t\t\treturn { ...it, filePath: \"inline\" };\n\t\t});\n\t} else {\n\t\treturn value.results;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vC,EAAA,OAAO,QAAQ,YAAY,CAAA;AAC5B;;ACxCgB,SAAA,UAAA,CAAW,UAAkB,KAAkC,EAAA;AAC9E,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC9B,IAAM,MAAA,MAAA,GAAS,IAAI,sBAAuB,CAAA;AAAA,MACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,KACrC,CAAA;AACD,IAAM,MAAA,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,IAAA,MAAM,MAAS,GAAA,YAAA,CAAa,kBAAmB,CAAA,KAAA,EAAO,QAAU,EAAA;AAAA,MAC/D,KAAO,EAAA;AAAA,QACN,YAAc,EAAA;AAAA;AACf,KACA,CAAA;AACD,IAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,EAAO,KAAA;AACjC,MAAA,OAAO,EAAE,GAAG,EAAI,EAAA,QAAA,EAAU,QAAS,EAAA;AAAA,KACnC,CAAA;AAAA,GACK,MAAA;AACN,IAAA,OAAO,KAAM,CAAA,OAAA;AAAA;AAEf;;;;"}
package/dist/es/vitest.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { expect } from 'vitest';
2
2
  import { c as createMatcher, a as createMatcher$1, b as createMatcher$2, d as createMatcher$3, e as createMatcher$4 } from './matchers.js';
3
3
  import './matcher-utils.js';
4
+ import 'node:url';
5
+ import 'node:worker_threads';
4
6
  import './core.js';
5
7
  import 'ajv';
6
8
  import './elements.js';
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.js","sources":["../../src/vitest/vitest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport { expect } from \"vitest\";\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n} from \"../jest/matchers\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, undefined),\n\ttoHaveError: toHaveError(expect, undefined),\n\ttoHaveErrors: toHaveErrors(expect, undefined),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors"],"mappings":";;;;;;;;;;;;;;;;;AAWA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAChD,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAC1C,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,KAAS,CAAA;AAC7C,CAAC,CAAA"}
1
+ {"version":3,"file":"vitest.js","sources":["../../src/vitest/vitest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport { expect } from \"vitest\";\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n} from \"../jest/matchers\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, undefined),\n\ttoHaveError: toHaveError(expect, undefined),\n\ttoHaveErrors: toHaveErrors(expect, undefined),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAChD,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAC1C,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,KAAS,CAAA;AAC7C,CAAC,CAAA"}
@@ -50,10 +50,10 @@
50
50
  "transform": {
51
51
  "type": "object",
52
52
  "additionalProperties": {
53
- "type": "string"
53
+ "anyOf": [{ "type": "string" }, { "function": true }]
54
54
  },
55
55
  "title": "File transformations to use.",
56
- "description": "Object where key is regular expression to match filename and value is name of transformer.",
56
+ "description": "Object where key is regular expression to match filename and value is name of transformer or a function.",
57
57
  "examples": [
58
58
  {
59
59
  "^.*\\.foo$": "my-transformer",
@@ -127,7 +127,11 @@
127
127
  "labelable": {
128
128
  "title": "Mark this element as labelable",
129
129
  "description": "This element may contain an associated label element.",
130
- "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/expression" }]
130
+ "anyOf": [
131
+ { "type": "boolean" },
132
+ { "function": true },
133
+ { "$ref": "#/definitions/expression" }
134
+ ]
131
135
  },
132
136
 
133
137
  "deprecatedAttributes": {
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.48.0"
8
+ "packageVersion": "7.48.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -1523,7 +1523,7 @@ export declare interface MetaData {
1523
1523
  form?: boolean;
1524
1524
  /** Mark element as a form-associated element */
1525
1525
  formAssociated?: Partial<FormAssociated>;
1526
- labelable?: boolean | PropertyExpression;
1526
+ labelable?: boolean | PropertyExpression | MetaLabelableCallback;
1527
1527
  /** @deprecated use {@link MetaAria.implicitRole} instead */
1528
1528
  implicitRole?: MetaImplicitRoleCallback;
1529
1529
  /** WAI-ARIA attributes */
@@ -1609,6 +1609,17 @@ export declare type MetaFocusableCallback = (node: HtmlElementLike) => boolean;
1609
1609
  */
1610
1610
  export declare type MetaImplicitRoleCallback = (node: HtmlElementLike) => string | null;
1611
1611
 
1612
+ /**
1613
+ * Callback for the `labelable` properties of `MetaData`. It takes a node and
1614
+ * returns whenever the element is labelable or not.
1615
+ *
1616
+ * @public
1617
+ * @since 8.29.0
1618
+ * @param node - The node to determine if it is labelable.
1619
+ * @returns `true` if the node is labelable.
1620
+ */
1621
+ export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
1622
+
1612
1623
  /**
1613
1624
  * Properties listed here can be used to reverse search elements with the given
1614
1625
  * property enabled. See [[MetaTable.getTagsWithProperty]].
@@ -2690,15 +2701,20 @@ export { Transformer_2 as Transformer }
2690
2701
  /**
2691
2702
  * @public
2692
2703
  */
2693
- export declare interface TransformerEntry {
2704
+ export declare type TransformerEntry = {
2705
+ kind: "import";
2694
2706
  pattern: RegExp;
2695
2707
  name: string;
2696
- }
2708
+ } | {
2709
+ kind: "function";
2710
+ pattern: RegExp;
2711
+ function: Transformer_2;
2712
+ };
2697
2713
 
2698
2714
  /**
2699
2715
  * @public
2700
2716
  */
2701
- export declare type TransformMap = Record<string, string>;
2717
+ export declare type TransformMap = Record<string, string | Transformer_2>;
2702
2718
 
2703
2719
  /**
2704
2720
  * @public
@@ -1750,7 +1750,7 @@ export declare interface MetaData {
1750
1750
  form?: boolean;
1751
1751
  /** Mark element as a form-associated element */
1752
1752
  formAssociated?: Partial<FormAssociated>;
1753
- labelable?: boolean | PropertyExpression;
1753
+ labelable?: boolean | PropertyExpression | MetaLabelableCallback;
1754
1754
  /** @deprecated use {@link MetaAria.implicitRole} instead */
1755
1755
  implicitRole?: MetaImplicitRoleCallback;
1756
1756
  /** WAI-ARIA attributes */
@@ -1836,6 +1836,17 @@ export declare type MetaFocusableCallback = (node: HtmlElementLike) => boolean;
1836
1836
  */
1837
1837
  export declare type MetaImplicitRoleCallback = (node: HtmlElementLike) => string | null;
1838
1838
 
1839
+ /**
1840
+ * Callback for the `labelable` properties of `MetaData`. It takes a node and
1841
+ * returns whenever the element is labelable or not.
1842
+ *
1843
+ * @public
1844
+ * @since 8.29.0
1845
+ * @param node - The node to determine if it is labelable.
1846
+ * @returns `true` if the node is labelable.
1847
+ */
1848
+ export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
1849
+
1839
1850
  /**
1840
1851
  * Properties listed here can be used to reverse search elements with the given
1841
1852
  * property enabled. See [[MetaTable.getTagsWithProperty]].
@@ -2942,15 +2953,20 @@ export { Transformer_2 as Transformer }
2942
2953
  /**
2943
2954
  * @public
2944
2955
  */
2945
- export declare interface TransformerEntry {
2956
+ export declare type TransformerEntry = {
2957
+ kind: "import";
2946
2958
  pattern: RegExp;
2947
2959
  name: string;
2948
- }
2960
+ } | {
2961
+ kind: "function";
2962
+ pattern: RegExp;
2963
+ function: Transformer_2;
2964
+ };
2949
2965
 
2950
2966
  /**
2951
2967
  * @public
2952
2968
  */
2953
- export declare type TransformMap = Record<string, string>;
2969
+ export declare type TransformMap = Record<string, string | Transformer_2>;
2954
2970
 
2955
2971
  /**
2956
2972
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-validate",
3
- "version": "8.27.0",
3
+ "version": "8.29.0",
4
4
  "description": "Offline html5 validator",
5
5
  "keywords": [
6
6
  "html",