html-validate 9.0.0-rc.7 → 9.0.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/cjs/core-nodejs.js +14 -9
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +39 -188
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/elements.js +30 -10
- package/dist/cjs/elements.js.map +1 -1
- package/dist/cjs/test-utils.js +8 -1
- package/dist/cjs/test-utils.js.map +1 -1
- package/dist/es/core-nodejs.js +17 -10
- package/dist/es/core-nodejs.js.map +1 -1
- package/dist/es/core.js +39 -188
- package/dist/es/core.js.map +1 -1
- package/dist/es/elements.js +30 -10
- package/dist/es/elements.js.map +1 -1
- package/dist/es/test-utils.js +8 -1
- package/dist/es/test-utils.js.map +1 -1
- package/dist/schema/config.json +2 -2
- package/dist/schema/elements.json +2 -35
- package/dist/types/browser.d.ts +55 -21
- package/dist/types/index.d.ts +55 -21
- package/dist/types/test-utils.d.ts +12 -8
- package/package.json +1 -1
package/dist/es/test-utils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
|
|
3
|
+
function isIterable(value) {
|
|
4
|
+
return Symbol.iterator in value;
|
|
5
|
+
}
|
|
3
6
|
function transformFile(fn, filename, chain) {
|
|
4
7
|
const data = fs.readFileSync(filename, "utf-8");
|
|
5
8
|
const source = {
|
|
@@ -31,7 +34,11 @@ async function transformSource(fn, source, chain) {
|
|
|
31
34
|
chain: chain ?? defaultChain
|
|
32
35
|
};
|
|
33
36
|
const result = await fn.call(context, source);
|
|
34
|
-
|
|
37
|
+
if (isIterable(result)) {
|
|
38
|
+
return await Promise.all(Array.from(result));
|
|
39
|
+
} else {
|
|
40
|
+
return [result];
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
export { transformFile, transformSource, transformString };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sources":["../../src/transform/test-utils.ts"],"sourcesContent":["import fs from \"fs\";\nimport {
|
|
1
|
+
{"version":3,"file":"test-utils.js","sources":["../../src/transform/test-utils.ts"],"sourcesContent":["import fs from \"fs\";\nimport {\n\ttype Source,\n\ttype TransformContext,\n\ttype Transformer,\n\ttype TransformerChainedResult,\n} from \"html-validate\";\n\n/* eslint-disable-next-line import/no-extraneous-dependencies -- this is the package itself */\nexport {\n\ttype Source,\n\ttype Transformer,\n\ttype TransformerResult,\n\ttype TransformerChainedResult,\n} from \"html-validate\";\n\nfunction isIterable(\n\tvalue: Source | Iterable<Source | Promise<Source>>,\n): value is Iterable<Source | Promise<Source>> {\n\treturn Symbol.iterator in value;\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param filename - Filename to read data from. Must be readable.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformFile(\n\tfn: Transformer,\n\tfilename: string,\n\tchain?: (source: Source, filename: string) => TransformerChainedResult,\n): Promise<Source[]> {\n\tconst data = fs.readFileSync(filename, \"utf-8\");\n\tconst source: Source = {\n\t\tfilename,\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - String to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformString(\n\tfn: Transformer,\n\tdata: string,\n\tchain?: (source: Source, filename: string) => TransformerChainedResult,\n): Promise<Source[]> {\n\tconst source: Source = {\n\t\tfilename: \"inline\",\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - Source to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport async function transformSource(\n\tfn: Transformer,\n\tsource: Source,\n\tchain?: (source: Source, filename: string) => TransformerChainedResult,\n): Promise<Source[]> {\n\tconst defaultChain = (source: Source): Iterable<Source> => [source];\n\tconst context: TransformContext = {\n\t\thasChain: /* istanbul ignore next */ () => true,\n\t\tchain: chain ?? defaultChain,\n\t};\n\tconst result = await fn.call(context, source);\n\tif (isIterable(result)) {\n\t\treturn await Promise.all(Array.from(result));\n\t} else {\n\t\treturn [result];\n\t}\n}\n"],"names":["source"],"mappings":";;AAgBA,SAAS,WACR,KAC8C,EAAA;AAC9C,EAAA,OAAO,OAAO,QAAY,IAAA,KAAA;AAC3B;AAUgB,SAAA,aAAA,CACf,EACA,EAAA,QAAA,EACA,KACoB,EAAA;AACpB,EAAA,MAAM,IAAO,GAAA,EAAA,CAAG,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA;AAC9C,EAAA,MAAM,MAAiB,GAAA;AAAA,IACtB,QAAA;AAAA,IACA,IAAM,EAAA,CAAA;AAAA,IACN,MAAQ,EAAA,CAAA;AAAA,IACR,MAAQ,EAAA,CAAA;AAAA,IACR;AAAA,GACD;AACA,EAAO,OAAA,eAAA,CAAgB,EAAI,EAAA,MAAA,EAAQ,KAAK,CAAA;AACzC;AAUgB,SAAA,eAAA,CACf,EACA,EAAA,IAAA,EACA,KACoB,EAAA;AACpB,EAAA,MAAM,MAAiB,GAAA;AAAA,IACtB,QAAU,EAAA,QAAA;AAAA,IACV,IAAM,EAAA,CAAA;AAAA,IACN,MAAQ,EAAA,CAAA;AAAA,IACR,MAAQ,EAAA,CAAA;AAAA,IACR;AAAA,GACD;AACA,EAAO,OAAA,eAAA,CAAgB,EAAI,EAAA,MAAA,EAAQ,KAAK,CAAA;AACzC;AAUsB,eAAA,eAAA,CACrB,EACA,EAAA,MAAA,EACA,KACoB,EAAA;AACpB,EAAA,MAAM,YAAe,GAAA,CAACA,OAAqC,KAAA,CAACA,OAAM,CAAA;AAClE,EAAA,MAAM,OAA4B,GAAA;AAAA,IACjC,QAAA;AAAA;AAAA,MAAqC,MAAM;AAAA,KAAA;AAAA,IAC3C,OAAO,KAAS,IAAA;AAAA,GACjB;AACA,EAAA,MAAM,MAAS,GAAA,MAAM,EAAG,CAAA,IAAA,CAAK,SAAS,MAAM,CAAA;AAC5C,EAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,IAAA,OAAO,MAAM,OAAQ,CAAA,GAAA,CAAI,KAAM,CAAA,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA,GACrC,MAAA;AACN,IAAA,OAAO,CAAC,MAAM,CAAA;AAAA;AAEhB;;;;"}
|
package/dist/schema/config.json
CHANGED
|
@@ -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,7 @@
|
|
|
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" }, { "
|
|
130
|
+
"anyOf": [{ "type": "boolean" }, { "function": true }]
|
|
131
131
|
},
|
|
132
132
|
|
|
133
133
|
"deprecatedAttributes": {
|
|
@@ -207,40 +207,7 @@
|
|
|
207
207
|
},
|
|
208
208
|
|
|
209
209
|
"contentCategory": {
|
|
210
|
-
"anyOf": [{ "type": "boolean" }, { "
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
"expression": {
|
|
214
|
-
"type": "array",
|
|
215
|
-
"minItems": 2,
|
|
216
|
-
"maxItems": 2,
|
|
217
|
-
"items": [
|
|
218
|
-
{
|
|
219
|
-
"type": "string",
|
|
220
|
-
"enum": ["isDescendant", "hasAttribute", "matchAttribute"]
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"anyOf": [{ "type": "string" }, { "$ref": "#/definitions/operation" }]
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
"operation": {
|
|
229
|
-
"type": "array",
|
|
230
|
-
"minItems": 3,
|
|
231
|
-
"maxItems": 3,
|
|
232
|
-
"items": [
|
|
233
|
-
{
|
|
234
|
-
"type": "string"
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"type": "string",
|
|
238
|
-
"enum": ["!=", "="]
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
"type": "string"
|
|
242
|
-
}
|
|
243
|
-
]
|
|
210
|
+
"anyOf": [{ "type": "boolean" }, { "function": true }]
|
|
244
211
|
},
|
|
245
212
|
|
|
246
213
|
"deprecatedElement": {
|
package/dist/types/browser.d.ts
CHANGED
|
@@ -694,7 +694,7 @@ export declare interface ErrorDescriptor<ContextType> {
|
|
|
694
694
|
* ESM resolver.
|
|
695
695
|
*
|
|
696
696
|
* @public
|
|
697
|
-
* @since 9.0.0
|
|
697
|
+
* @since 9.0.0
|
|
698
698
|
*/
|
|
699
699
|
export declare type ESMResolver = Required<Resolver>;
|
|
700
700
|
|
|
@@ -702,7 +702,7 @@ export declare type ESMResolver = Required<Resolver>;
|
|
|
702
702
|
* Create a new resolver for using `import(..)`.
|
|
703
703
|
*
|
|
704
704
|
* @public
|
|
705
|
-
* @since 9.0.0
|
|
705
|
+
* @since 9.0.0
|
|
706
706
|
*/
|
|
707
707
|
export declare function esmResolver(): ESMResolver;
|
|
708
708
|
|
|
@@ -1539,13 +1539,13 @@ export declare const MetaCopyableProperty: Array<keyof MetaElement>;
|
|
|
1539
1539
|
*/
|
|
1540
1540
|
export declare interface MetaData {
|
|
1541
1541
|
inherit?: string;
|
|
1542
|
-
metadata?: boolean |
|
|
1543
|
-
flow?: boolean |
|
|
1544
|
-
sectioning?: boolean |
|
|
1545
|
-
heading?: boolean |
|
|
1546
|
-
phrasing?: boolean |
|
|
1547
|
-
embedded?: boolean |
|
|
1548
|
-
interactive?: boolean |
|
|
1542
|
+
metadata?: boolean | MetaCategoryCallback;
|
|
1543
|
+
flow?: boolean | MetaCategoryCallback;
|
|
1544
|
+
sectioning?: boolean | MetaCategoryCallback;
|
|
1545
|
+
heading?: boolean | MetaCategoryCallback;
|
|
1546
|
+
phrasing?: boolean | MetaCategoryCallback;
|
|
1547
|
+
embedded?: boolean | MetaCategoryCallback;
|
|
1548
|
+
interactive?: boolean | MetaCategoryCallback;
|
|
1549
1549
|
deprecated?: boolean | string | DeprecatedElement;
|
|
1550
1550
|
foreign?: boolean;
|
|
1551
1551
|
void?: boolean;
|
|
@@ -1557,7 +1557,7 @@ export declare interface MetaData {
|
|
|
1557
1557
|
form?: boolean;
|
|
1558
1558
|
/** Mark element as a form-associated element */
|
|
1559
1559
|
formAssociated?: Partial<FormAssociated>;
|
|
1560
|
-
labelable?: boolean |
|
|
1560
|
+
labelable?: boolean | MetaLabelableCallback;
|
|
1561
1561
|
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1562
1562
|
implicitRole?: MetaImplicitRoleCallback;
|
|
1563
1563
|
/** WAI-ARIA attributes */
|
|
@@ -1643,6 +1643,17 @@ export declare type MetaFocusableCallback = (node: HtmlElementLike) => boolean;
|
|
|
1643
1643
|
*/
|
|
1644
1644
|
export declare type MetaImplicitRoleCallback = (node: HtmlElementLike) => string | null;
|
|
1645
1645
|
|
|
1646
|
+
/**
|
|
1647
|
+
* Callback for the `labelable` properties of `MetaData`. It takes a node and
|
|
1648
|
+
* returns whenever the element is labelable or not.
|
|
1649
|
+
*
|
|
1650
|
+
* @public
|
|
1651
|
+
* @since 8.29.0
|
|
1652
|
+
* @param node - The node to determine if it is labelable.
|
|
1653
|
+
* @returns `true` if the node is labelable.
|
|
1654
|
+
*/
|
|
1655
|
+
export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
|
|
1656
|
+
|
|
1646
1657
|
/**
|
|
1647
1658
|
* Properties listed here can be used to reverse search elements with the given
|
|
1648
1659
|
* property enabled. See [[MetaTable.getTagsWithProperty]].
|
|
@@ -1991,12 +2002,6 @@ export declare interface ProcessElementContext {
|
|
|
1991
2002
|
getMetaFor(this: void, tagName: string): MetaElement | null;
|
|
1992
2003
|
}
|
|
1993
2004
|
|
|
1994
|
-
/**
|
|
1995
|
-
* @public
|
|
1996
|
-
* @deprecated Use callback variant instead.
|
|
1997
|
-
*/
|
|
1998
|
-
export declare type PropertyExpression = string | [string, any];
|
|
1999
|
-
|
|
2000
2005
|
/**
|
|
2001
2006
|
* Report object returned by [[HtmlValidate]].
|
|
2002
2007
|
*
|
|
@@ -2687,7 +2692,7 @@ export declare interface TransformContext {
|
|
|
2687
2692
|
* @param filename - Filename to use to match next transformer (unrelated to
|
|
2688
2693
|
* filename set in source)
|
|
2689
2694
|
*/
|
|
2690
|
-
chain(source: Source, filename: string):
|
|
2695
|
+
chain(source: Source, filename: string): TransformerChainedResult;
|
|
2691
2696
|
}
|
|
2692
2697
|
|
|
2693
2698
|
/**
|
|
@@ -2698,8 +2703,14 @@ export declare interface TransformContext {
|
|
|
2698
2703
|
declare interface Transformer_2 {
|
|
2699
2704
|
/**
|
|
2700
2705
|
* Callback function to transform a source to plain HTML sources.
|
|
2706
|
+
*
|
|
2707
|
+
* Since 9.0.0 the transformer may return:
|
|
2708
|
+
*
|
|
2709
|
+
* - A single `Source` object or a `Promise` resolving to one.
|
|
2710
|
+
* - An array of `Source` objects or a `Promise` resolving to one.
|
|
2711
|
+
* - An array of `Promise` resolving to `Source` objects.
|
|
2701
2712
|
*/
|
|
2702
|
-
(this: TransformContext, source: Source):
|
|
2713
|
+
(this: TransformContext, source: Source): TransformerResult;
|
|
2703
2714
|
/**
|
|
2704
2715
|
* API version. Must be specified, it is deprecated to leave it out as it
|
|
2705
2716
|
* assumes version 0 (deprecated version).
|
|
@@ -2708,18 +2719,41 @@ declare interface Transformer_2 {
|
|
|
2708
2719
|
}
|
|
2709
2720
|
export { Transformer_2 as Transformer }
|
|
2710
2721
|
|
|
2722
|
+
/**
|
|
2723
|
+
* The result of a transformer chain.
|
|
2724
|
+
*
|
|
2725
|
+
* Similar to the regular `TransformerResult` but flattened for easier usage.
|
|
2726
|
+
*
|
|
2727
|
+
* @public
|
|
2728
|
+
* @since 9.0.0
|
|
2729
|
+
*/
|
|
2730
|
+
export declare type TransformerChainedResult = Iterable<Source> | Promise<Iterable<Source>>;
|
|
2731
|
+
|
|
2711
2732
|
/**
|
|
2712
2733
|
* @public
|
|
2713
2734
|
*/
|
|
2714
|
-
export declare
|
|
2735
|
+
export declare type TransformerEntry = {
|
|
2736
|
+
kind: "import";
|
|
2715
2737
|
pattern: RegExp;
|
|
2716
2738
|
name: string;
|
|
2717
|
-
}
|
|
2739
|
+
} | {
|
|
2740
|
+
kind: "function";
|
|
2741
|
+
pattern: RegExp;
|
|
2742
|
+
function: Transformer_2;
|
|
2743
|
+
};
|
|
2744
|
+
|
|
2745
|
+
/**
|
|
2746
|
+
* The result of a transformer (or its chain).
|
|
2747
|
+
*
|
|
2748
|
+
* @public
|
|
2749
|
+
* @since 9.0.0
|
|
2750
|
+
*/
|
|
2751
|
+
export declare type TransformerResult = Source | Iterable<Source | Promise<Source>> | Promise<Source> | Promise<Source | Iterable<Source | Promise<Source>>>;
|
|
2718
2752
|
|
|
2719
2753
|
/**
|
|
2720
2754
|
* @public
|
|
2721
2755
|
*/
|
|
2722
|
-
export declare type TransformMap = Record<string, string>;
|
|
2756
|
+
export declare type TransformMap = Record<string, string | Transformer_2>;
|
|
2723
2757
|
|
|
2724
2758
|
/**
|
|
2725
2759
|
* @public
|
package/dist/types/index.d.ts
CHANGED
|
@@ -792,7 +792,7 @@ export declare interface ErrorDescriptor<ContextType> {
|
|
|
792
792
|
* ESM resolver.
|
|
793
793
|
*
|
|
794
794
|
* @public
|
|
795
|
-
* @since 9.0.0
|
|
795
|
+
* @since 9.0.0
|
|
796
796
|
*/
|
|
797
797
|
export declare type ESMResolver = Required<Resolver>;
|
|
798
798
|
|
|
@@ -805,7 +805,7 @@ export declare type ESMResolver = Required<Resolver>;
|
|
|
805
805
|
* file (starting at the current working directory).
|
|
806
806
|
*
|
|
807
807
|
* @public
|
|
808
|
-
* @since 9.0.0
|
|
808
|
+
* @since 9.0.0
|
|
809
809
|
*/
|
|
810
810
|
export declare function esmResolver(options?: {
|
|
811
811
|
rootDir?: string;
|
|
@@ -1779,13 +1779,13 @@ export declare const MetaCopyableProperty: Array<keyof MetaElement>;
|
|
|
1779
1779
|
*/
|
|
1780
1780
|
export declare interface MetaData {
|
|
1781
1781
|
inherit?: string;
|
|
1782
|
-
metadata?: boolean |
|
|
1783
|
-
flow?: boolean |
|
|
1784
|
-
sectioning?: boolean |
|
|
1785
|
-
heading?: boolean |
|
|
1786
|
-
phrasing?: boolean |
|
|
1787
|
-
embedded?: boolean |
|
|
1788
|
-
interactive?: boolean |
|
|
1782
|
+
metadata?: boolean | MetaCategoryCallback;
|
|
1783
|
+
flow?: boolean | MetaCategoryCallback;
|
|
1784
|
+
sectioning?: boolean | MetaCategoryCallback;
|
|
1785
|
+
heading?: boolean | MetaCategoryCallback;
|
|
1786
|
+
phrasing?: boolean | MetaCategoryCallback;
|
|
1787
|
+
embedded?: boolean | MetaCategoryCallback;
|
|
1788
|
+
interactive?: boolean | MetaCategoryCallback;
|
|
1789
1789
|
deprecated?: boolean | string | DeprecatedElement;
|
|
1790
1790
|
foreign?: boolean;
|
|
1791
1791
|
void?: boolean;
|
|
@@ -1797,7 +1797,7 @@ export declare interface MetaData {
|
|
|
1797
1797
|
form?: boolean;
|
|
1798
1798
|
/** Mark element as a form-associated element */
|
|
1799
1799
|
formAssociated?: Partial<FormAssociated>;
|
|
1800
|
-
labelable?: boolean |
|
|
1800
|
+
labelable?: boolean | MetaLabelableCallback;
|
|
1801
1801
|
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1802
1802
|
implicitRole?: MetaImplicitRoleCallback;
|
|
1803
1803
|
/** WAI-ARIA attributes */
|
|
@@ -1883,6 +1883,17 @@ export declare type MetaFocusableCallback = (node: HtmlElementLike) => boolean;
|
|
|
1883
1883
|
*/
|
|
1884
1884
|
export declare type MetaImplicitRoleCallback = (node: HtmlElementLike) => string | null;
|
|
1885
1885
|
|
|
1886
|
+
/**
|
|
1887
|
+
* Callback for the `labelable` properties of `MetaData`. It takes a node and
|
|
1888
|
+
* returns whenever the element is labelable or not.
|
|
1889
|
+
*
|
|
1890
|
+
* @public
|
|
1891
|
+
* @since 8.29.0
|
|
1892
|
+
* @param node - The node to determine if it is labelable.
|
|
1893
|
+
* @returns `true` if the node is labelable.
|
|
1894
|
+
*/
|
|
1895
|
+
export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
|
|
1896
|
+
|
|
1886
1897
|
/**
|
|
1887
1898
|
* Properties listed here can be used to reverse search elements with the given
|
|
1888
1899
|
* property enabled. See [[MetaTable.getTagsWithProperty]].
|
|
@@ -2256,12 +2267,6 @@ export declare interface ProcessElementContext {
|
|
|
2256
2267
|
getMetaFor(this: void, tagName: string): MetaElement | null;
|
|
2257
2268
|
}
|
|
2258
2269
|
|
|
2259
|
-
/**
|
|
2260
|
-
* @public
|
|
2261
|
-
* @deprecated Use callback variant instead.
|
|
2262
|
-
*/
|
|
2263
|
-
export declare type PropertyExpression = string | [string, any];
|
|
2264
|
-
|
|
2265
2270
|
/**
|
|
2266
2271
|
* Report object returned by [[HtmlValidate]].
|
|
2267
2272
|
*
|
|
@@ -2952,7 +2957,7 @@ export declare interface TransformContext {
|
|
|
2952
2957
|
* @param filename - Filename to use to match next transformer (unrelated to
|
|
2953
2958
|
* filename set in source)
|
|
2954
2959
|
*/
|
|
2955
|
-
chain(source: Source, filename: string):
|
|
2960
|
+
chain(source: Source, filename: string): TransformerChainedResult;
|
|
2956
2961
|
}
|
|
2957
2962
|
|
|
2958
2963
|
/**
|
|
@@ -2963,8 +2968,14 @@ export declare interface TransformContext {
|
|
|
2963
2968
|
declare interface Transformer_2 {
|
|
2964
2969
|
/**
|
|
2965
2970
|
* Callback function to transform a source to plain HTML sources.
|
|
2971
|
+
*
|
|
2972
|
+
* Since 9.0.0 the transformer may return:
|
|
2973
|
+
*
|
|
2974
|
+
* - A single `Source` object or a `Promise` resolving to one.
|
|
2975
|
+
* - An array of `Source` objects or a `Promise` resolving to one.
|
|
2976
|
+
* - An array of `Promise` resolving to `Source` objects.
|
|
2966
2977
|
*/
|
|
2967
|
-
(this: TransformContext, source: Source):
|
|
2978
|
+
(this: TransformContext, source: Source): TransformerResult;
|
|
2968
2979
|
/**
|
|
2969
2980
|
* API version. Must be specified, it is deprecated to leave it out as it
|
|
2970
2981
|
* assumes version 0 (deprecated version).
|
|
@@ -2973,18 +2984,41 @@ declare interface Transformer_2 {
|
|
|
2973
2984
|
}
|
|
2974
2985
|
export { Transformer_2 as Transformer }
|
|
2975
2986
|
|
|
2987
|
+
/**
|
|
2988
|
+
* The result of a transformer chain.
|
|
2989
|
+
*
|
|
2990
|
+
* Similar to the regular `TransformerResult` but flattened for easier usage.
|
|
2991
|
+
*
|
|
2992
|
+
* @public
|
|
2993
|
+
* @since 9.0.0
|
|
2994
|
+
*/
|
|
2995
|
+
export declare type TransformerChainedResult = Iterable<Source> | Promise<Iterable<Source>>;
|
|
2996
|
+
|
|
2976
2997
|
/**
|
|
2977
2998
|
* @public
|
|
2978
2999
|
*/
|
|
2979
|
-
export declare
|
|
3000
|
+
export declare type TransformerEntry = {
|
|
3001
|
+
kind: "import";
|
|
2980
3002
|
pattern: RegExp;
|
|
2981
3003
|
name: string;
|
|
2982
|
-
}
|
|
3004
|
+
} | {
|
|
3005
|
+
kind: "function";
|
|
3006
|
+
pattern: RegExp;
|
|
3007
|
+
function: Transformer_2;
|
|
3008
|
+
};
|
|
3009
|
+
|
|
3010
|
+
/**
|
|
3011
|
+
* The result of a transformer (or its chain).
|
|
3012
|
+
*
|
|
3013
|
+
* @public
|
|
3014
|
+
* @since 9.0.0
|
|
3015
|
+
*/
|
|
3016
|
+
export declare type TransformerResult = Source | Iterable<Source | Promise<Source>> | Promise<Source> | Promise<Source | Iterable<Source | Promise<Source>>>;
|
|
2983
3017
|
|
|
2984
3018
|
/**
|
|
2985
3019
|
* @public
|
|
2986
3020
|
*/
|
|
2987
|
-
export declare type TransformMap = Record<string, string>;
|
|
3021
|
+
export declare type TransformMap = Record<string, string | Transformer_2>;
|
|
2988
3022
|
|
|
2989
3023
|
/**
|
|
2990
3024
|
* @public
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Source } from 'html-validate';
|
|
2
|
-
import {
|
|
2
|
+
import { Transformer as Transformer_2 } from 'html-validate';
|
|
3
|
+
import { TransformerChainedResult } from 'html-validate';
|
|
4
|
+
import { TransformerResult } from 'html-validate';
|
|
5
|
+
|
|
6
|
+
export { Source }
|
|
3
7
|
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
declare type Transformer_2 = (this: TransformContext, source: Source) => Iterable<Source> | Promise<Iterable<Source>>;
|
|
8
8
|
export { Transformer_2 as Transformer }
|
|
9
9
|
|
|
10
|
+
export { TransformerChainedResult }
|
|
11
|
+
|
|
12
|
+
export { TransformerResult }
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Helper function to call a transformer function in test-cases.
|
|
12
16
|
*
|
|
@@ -15,7 +19,7 @@ export { Transformer_2 as Transformer }
|
|
|
15
19
|
* @param filename - Filename to read data from. Must be readable.
|
|
16
20
|
* @param chain - If set this function is called when chaining transformers. Default is pass-thru.
|
|
17
21
|
*/
|
|
18
|
-
export declare function transformFile(fn: Transformer_2, filename: string, chain?: (source: Source, filename: string) =>
|
|
22
|
+
export declare function transformFile(fn: Transformer_2, filename: string, chain?: (source: Source, filename: string) => TransformerChainedResult): Promise<Source[]>;
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
25
|
* Helper function to call a transformer function in test-cases.
|
|
@@ -25,7 +29,7 @@ export declare function transformFile(fn: Transformer_2, filename: string, chain
|
|
|
25
29
|
* @param data - Source to transform.
|
|
26
30
|
* @param chain - If set this function is called when chaining transformers. Default is pass-thru.
|
|
27
31
|
*/
|
|
28
|
-
export declare function transformSource(fn: Transformer_2, source: Source, chain?: (source: Source, filename: string) =>
|
|
32
|
+
export declare function transformSource(fn: Transformer_2, source: Source, chain?: (source: Source, filename: string) => TransformerChainedResult): Promise<Source[]>;
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* Helper function to call a transformer function in test-cases.
|
|
@@ -35,6 +39,6 @@ export declare function transformSource(fn: Transformer_2, source: Source, chain
|
|
|
35
39
|
* @param data - String to transform.
|
|
36
40
|
* @param chain - If set this function is called when chaining transformers. Default is pass-thru.
|
|
37
41
|
*/
|
|
38
|
-
export declare function transformString(fn: Transformer_2, data: string, chain?: (source: Source, filename: string) =>
|
|
42
|
+
export declare function transformString(fn: Transformer_2, data: string, chain?: (source: Source, filename: string) => TransformerChainedResult): Promise<Source[]>;
|
|
39
43
|
|
|
40
44
|
export { }
|