@siteimprove/alfa-dom 0.89.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +291 -0
  2. package/dist/h.d.ts +37 -0
  3. package/dist/h.js +214 -0
  4. package/dist/index.d.ts +32 -0
  5. package/dist/index.js +32 -0
  6. package/dist/jsx-runtime.d.ts +26 -0
  7. package/dist/jsx-runtime.js +41 -0
  8. package/dist/jsx.d.ts +44 -0
  9. package/dist/jsx.js +45 -0
  10. package/dist/namespace.d.ts +43 -0
  11. package/dist/namespace.js +57 -0
  12. package/dist/native.d.ts +18 -0
  13. package/dist/native.js +449 -0
  14. package/dist/node/attribute/predicate/has-name.d.ts +11 -0
  15. package/dist/node/attribute/predicate/has-name.js +13 -0
  16. package/dist/node/attribute/predicate.d.ts +2 -0
  17. package/dist/node/attribute/predicate.js +2 -0
  18. package/dist/node/attribute.d.ts +90 -0
  19. package/dist/node/attribute.js +164 -0
  20. package/dist/node/comment.d.ts +42 -0
  21. package/dist/node/comment.js +74 -0
  22. package/dist/node/document.d.ts +59 -0
  23. package/dist/node/document.js +113 -0
  24. package/dist/node/element/input-type.d.ts +12 -0
  25. package/dist/node/element/input-type.js +10 -0
  26. package/dist/node/element/predicate/has-attribute.d.ts +12 -0
  27. package/dist/node/element/predicate/has-attribute.js +11 -0
  28. package/dist/node/element/predicate/has-box.d.ts +9 -0
  29. package/dist/node/element/predicate/has-box.js +7 -0
  30. package/dist/node/element/predicate/has-display-size.d.ts +7 -0
  31. package/dist/node/element/predicate/has-display-size.js +28 -0
  32. package/dist/node/element/predicate/has-id.d.ts +16 -0
  33. package/dist/node/element/predicate/has-id.js +17 -0
  34. package/dist/node/element/predicate/has-input-type.d.ts +12 -0
  35. package/dist/node/element/predicate/has-input-type.js +17 -0
  36. package/dist/node/element/predicate/has-name.d.ts +11 -0
  37. package/dist/node/element/predicate/has-name.js +13 -0
  38. package/dist/node/element/predicate/has-namespace.d.ts +12 -0
  39. package/dist/node/element/predicate/has-namespace.js +13 -0
  40. package/dist/node/element/predicate/has-tab-index.d.ts +12 -0
  41. package/dist/node/element/predicate/has-tab-index.js +11 -0
  42. package/dist/node/element/predicate/has-unique-id.d.ts +7 -0
  43. package/dist/node/element/predicate/has-unique-id.js +31 -0
  44. package/dist/node/element/predicate/is-actually-disabled.d.ts +8 -0
  45. package/dist/node/element/predicate/is-actually-disabled.js +47 -0
  46. package/dist/node/element/predicate/is-browsing-context-container.d.ts +8 -0
  47. package/dist/node/element/predicate/is-browsing-context-container.js +20 -0
  48. package/dist/node/element/predicate/is-content.d.ts +10 -0
  49. package/dist/node/element/predicate/is-content.js +17 -0
  50. package/dist/node/element/predicate/is-document-element.d.ts +6 -0
  51. package/dist/node/element/predicate/is-document-element.js +13 -0
  52. package/dist/node/element/predicate/is-draggable.d.ts +8 -0
  53. package/dist/node/element/predicate/is-draggable.js +28 -0
  54. package/dist/node/element/predicate/is-editing-host.d.ts +8 -0
  55. package/dist/node/element/predicate/is-editing-host.js +20 -0
  56. package/dist/node/element/predicate/is-fallback.d.ts +15 -0
  57. package/dist/node/element/predicate/is-fallback.js +28 -0
  58. package/dist/node/element/predicate/is-replaced.d.ts +8 -0
  59. package/dist/node/element/predicate/is-replaced.js +17 -0
  60. package/dist/node/element/predicate/is-scoped-to.d.ts +7 -0
  61. package/dist/node/element/predicate/is-scoped-to.js +11 -0
  62. package/dist/node/element/predicate/is-suggested-focusable.d.ts +14 -0
  63. package/dist/node/element/predicate/is-suggested-focusable.js +47 -0
  64. package/dist/node/element/predicate.d.ts +20 -0
  65. package/dist/node/element/predicate.js +20 -0
  66. package/dist/node/element.d.ts +122 -0
  67. package/dist/node/element.js +330 -0
  68. package/dist/node/fragment.d.ts +38 -0
  69. package/dist/node/fragment.js +68 -0
  70. package/dist/node/predicate/has-child.d.ts +7 -0
  71. package/dist/node/predicate/has-child.js +8 -0
  72. package/dist/node/predicate/has-descendant.d.ts +7 -0
  73. package/dist/node/predicate/has-descendant.js +8 -0
  74. package/dist/node/predicate/has-inclusive-descendant.d.ts +7 -0
  75. package/dist/node/predicate/has-inclusive-descendant.js +8 -0
  76. package/dist/node/predicate/has-text-content.d.ts +7 -0
  77. package/dist/node/predicate/has-text-content.js +12 -0
  78. package/dist/node/predicate/is-root.d.ts +7 -0
  79. package/dist/node/predicate/is-root.js +7 -0
  80. package/dist/node/predicate.d.ts +6 -0
  81. package/dist/node/predicate.js +6 -0
  82. package/dist/node/query/element-descendants.d.ts +8 -0
  83. package/dist/node/query/element-descendants.js +17 -0
  84. package/dist/node/query/element-id-map.d.ts +14 -0
  85. package/dist/node/query/element-id-map.js +30 -0
  86. package/dist/node/query/inclusive-element-descendants.d.ts +8 -0
  87. package/dist/node/query/inclusive-element-descendants.js +10 -0
  88. package/dist/node/query/index.d.ts +12 -0
  89. package/dist/node/query/index.js +13 -0
  90. package/dist/node/shadow.d.ts +66 -0
  91. package/dist/node/shadow.js +128 -0
  92. package/dist/node/slot.d.ts +29 -0
  93. package/dist/node/slot.js +41 -0
  94. package/dist/node/slotable.d.ts +29 -0
  95. package/dist/node/slotable.js +40 -0
  96. package/dist/node/text.d.ts +46 -0
  97. package/dist/node/text.js +83 -0
  98. package/dist/node/traversal/get-nodes-between.d.ts +24 -0
  99. package/dist/node/traversal/get-nodes-between.js +62 -0
  100. package/dist/node/traversal/lowest-common-ancestor.d.ts +13 -0
  101. package/dist/node/traversal/lowest-common-ancestor.js +19 -0
  102. package/dist/node/traversal.d.ts +2 -0
  103. package/dist/node/traversal.js +2 -0
  104. package/dist/node/type.d.ts +45 -0
  105. package/dist/node/type.js +74 -0
  106. package/dist/node.d.ts +263 -0
  107. package/dist/node.js +325 -0
  108. package/dist/style/block.d.ts +30 -0
  109. package/dist/style/block.js +63 -0
  110. package/dist/style/declaration.d.ts +65 -0
  111. package/dist/style/declaration.js +103 -0
  112. package/dist/style/rule/condition.d.ts +21 -0
  113. package/dist/style/rule/condition.js +30 -0
  114. package/dist/style/rule/font-face.d.ts +29 -0
  115. package/dist/style/rule/font-face.js +47 -0
  116. package/dist/style/rule/grouping.d.ts +22 -0
  117. package/dist/style/rule/grouping.js +34 -0
  118. package/dist/style/rule/import.d.ts +47 -0
  119. package/dist/style/rule/import.js +114 -0
  120. package/dist/style/rule/keyframe.d.ts +32 -0
  121. package/dist/style/rule/keyframe.js +53 -0
  122. package/dist/style/rule/keyframes.d.ts +28 -0
  123. package/dist/style/rule/keyframes.js +49 -0
  124. package/dist/style/rule/layer.d.ts +61 -0
  125. package/dist/style/rule/layer.js +106 -0
  126. package/dist/style/rule/media.d.ts +32 -0
  127. package/dist/style/rule/media.js +54 -0
  128. package/dist/style/rule/namespace.d.ts +31 -0
  129. package/dist/style/rule/namespace.js +52 -0
  130. package/dist/style/rule/page.d.ts +32 -0
  131. package/dist/style/rule/page.js +53 -0
  132. package/dist/style/rule/style.d.ts +35 -0
  133. package/dist/style/rule/style.js +62 -0
  134. package/dist/style/rule/supports.d.ts +32 -0
  135. package/dist/style/rule/supports.js +56 -0
  136. package/dist/style/rule.d.ts +60 -0
  137. package/dist/style/rule.js +109 -0
  138. package/dist/style/sheet.d.ts +37 -0
  139. package/dist/style/sheet.js +66 -0
  140. package/package.json +69 -0
@@ -0,0 +1,47 @@
1
+ import { String } from "@siteimprove/alfa-string";
2
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
3
+ import { Block } from "../block.js";
4
+ import { Rule } from "../rule.js";
5
+ /**
6
+ * @public
7
+ */
8
+ export class FontFaceRule extends Rule {
9
+ static of(declarations) {
10
+ return new FontFaceRule(Array.from(declarations));
11
+ }
12
+ _style;
13
+ constructor(declarations) {
14
+ super("font-face");
15
+ this._style = Block.of(declarations.filter((declaration) => declaration._attachParent(this)));
16
+ }
17
+ get style() {
18
+ return this._style;
19
+ }
20
+ toJSON() {
21
+ return {
22
+ ...super.toJSON(),
23
+ style: this._style.toJSON(),
24
+ };
25
+ }
26
+ toString() {
27
+ const style = this._style.toString();
28
+ return `@font-face {${style === "" ? "" : `\n${String.indent(style)}\n`}}`;
29
+ }
30
+ }
31
+ /**
32
+ * @public
33
+ */
34
+ (function (FontFaceRule) {
35
+ function isFontFaceRule(value) {
36
+ return value instanceof FontFaceRule;
37
+ }
38
+ FontFaceRule.isFontFaceRule = isFontFaceRule;
39
+ /**
40
+ * @internal
41
+ */
42
+ function fromFontFaceRule(json) {
43
+ return Trampoline.done(FontFaceRule.of(Block.from(json.style)));
44
+ }
45
+ FontFaceRule.fromFontFaceRule = fromFontFaceRule;
46
+ })(FontFaceRule || (FontFaceRule = {}));
47
+ //# sourceMappingURL=font-face.js.map
@@ -0,0 +1,22 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Rule } from "../rule.js";
3
+ /**
4
+ * @public
5
+ */
6
+ export declare abstract class GroupingRule<T extends string = string> extends Rule<T> {
7
+ protected readonly _rules: Array<Rule>;
8
+ protected constructor(type: T, rules: Array<Rule>);
9
+ get rules(): Iterable<Rule>;
10
+ children(): Iterable<Rule>;
11
+ toJSON(): GroupingRule.JSON<T>;
12
+ }
13
+ /**
14
+ * @public
15
+ */
16
+ export declare namespace GroupingRule {
17
+ interface JSON<T extends string = string> extends Rule.JSON<T> {
18
+ rules: Array<Rule.JSON>;
19
+ }
20
+ function isGroupingRule(value: unknown): value is GroupingRule;
21
+ }
22
+ //# sourceMappingURL=grouping.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Rule } from "../rule.js";
3
+ /**
4
+ * @public
5
+ */
6
+ export class GroupingRule extends Rule {
7
+ _rules;
8
+ constructor(type, rules) {
9
+ super(type);
10
+ this._rules = rules.filter((rule) => rule._attachParent(this));
11
+ }
12
+ get rules() {
13
+ return this._rules;
14
+ }
15
+ *children() {
16
+ yield* this._rules;
17
+ }
18
+ toJSON() {
19
+ return {
20
+ ...super.toJSON(),
21
+ rules: Array.toJSON(this._rules),
22
+ };
23
+ }
24
+ }
25
+ /**
26
+ * @public
27
+ */
28
+ (function (GroupingRule) {
29
+ function isGroupingRule(value) {
30
+ return value instanceof GroupingRule;
31
+ }
32
+ GroupingRule.isGroupingRule = isGroupingRule;
33
+ })(GroupingRule || (GroupingRule = {}));
34
+ //# sourceMappingURL=grouping.js.map
@@ -0,0 +1,47 @@
1
+ import { Feature } from "@siteimprove/alfa-css-feature";
2
+ import type { Device } from "@siteimprove/alfa-device";
3
+ import { Option } from "@siteimprove/alfa-option";
4
+ import { Predicate } from "@siteimprove/alfa-predicate";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import { Rule } from "../rule.js";
7
+ import { Sheet } from "../sheet.js";
8
+ import { ConditionRule } from "./condition.js";
9
+ /**
10
+ * @public
11
+ */
12
+ export declare class ImportRule extends ConditionRule<"import"> {
13
+ static of(href: string, sheet: Sheet, mediaCondition?: Option<string>, supportCondition?: Option<string>, layer?: Option<string>): ImportRule;
14
+ private readonly _href;
15
+ private readonly _sheet;
16
+ private readonly _mediaQueries;
17
+ private readonly _supportCondition;
18
+ private readonly _supportQuery;
19
+ private _layer;
20
+ private constructor();
21
+ get supportCondition(): Option<string>;
22
+ get mediaQueries(): Feature.Media.List;
23
+ get supportQuery(): Option<Option<Feature.Supports.Query>>;
24
+ get layer(): Option<string>;
25
+ get rules(): Iterable<Rule>;
26
+ get href(): string;
27
+ get sheet(): Sheet;
28
+ toJSON(): ImportRule.JSON;
29
+ toString(): string;
30
+ }
31
+ /**
32
+ * @public
33
+ */
34
+ export declare namespace ImportRule {
35
+ interface JSON extends ConditionRule.JSON<"import"> {
36
+ href: string;
37
+ supportText: string | null;
38
+ layer: string | null;
39
+ }
40
+ function isImportRule(value: unknown): value is ImportRule;
41
+ function matches(device: Device): Predicate<ImportRule>;
42
+ /**
43
+ * @internal
44
+ */
45
+ function fromImportRule(json: JSON): Trampoline<ImportRule>;
46
+ }
47
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1,114 @@
1
+ import { Lexer } from "@siteimprove/alfa-css";
2
+ import { Feature } from "@siteimprove/alfa-css-feature";
3
+ import { Option, None } from "@siteimprove/alfa-option";
4
+ import { Predicate } from "@siteimprove/alfa-predicate";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import { Rule } from "../rule.js";
7
+ import { Sheet } from "../sheet.js";
8
+ import { ConditionRule } from "./condition.js";
9
+ const { and } = Predicate;
10
+ /**
11
+ * @public
12
+ */
13
+ export class ImportRule extends ConditionRule {
14
+ static of(href, sheet, mediaCondition = None, supportCondition = None, layer = None) {
15
+ return new ImportRule(href, sheet, mediaCondition, supportCondition, layer);
16
+ }
17
+ _href;
18
+ _sheet;
19
+ _mediaQueries;
20
+ _supportCondition;
21
+ // There may be no support condition, or an unparsable (i.e. non-supported) one.
22
+ // The former is None, the later is Some(None).
23
+ _supportQuery;
24
+ // Anonymous layers are represented with the empty string, matching the
25
+ // CSSImportRule interface
26
+ _layer;
27
+ constructor(href, sheet, mediaCondition, supportCondition, layer) {
28
+ super("import", mediaCondition.getOr("all"), []);
29
+ this._href = href;
30
+ this._sheet = sheet;
31
+ this._supportCondition = supportCondition;
32
+ this._layer = layer;
33
+ this._mediaQueries = mediaCondition
34
+ .flatMap((condition) => Feature.parseMediaQuery(Lexer.lex(condition)).ok())
35
+ .map(([, queries]) => queries)
36
+ .getOr(Feature.Media.List.of([]));
37
+ this._supportQuery = supportCondition.map((condition) => Feature.parseSupportsQuery(
38
+ // We're not sure where the condition comes from, but Alfa only parses
39
+ // them when they are parenthesised, while CSSImportRule.supportsText
40
+ // provides the raw text. Extra parenthesis don't block parsing.
41
+ // In doubt, adding some to avoid potential problems.
42
+ Lexer.lex(`(${condition})`))
43
+ .ok()
44
+ .map(([, query]) => query));
45
+ }
46
+ get supportCondition() {
47
+ return this._supportCondition;
48
+ }
49
+ get mediaQueries() {
50
+ return this._mediaQueries;
51
+ }
52
+ get supportQuery() {
53
+ return this._supportQuery;
54
+ }
55
+ get layer() {
56
+ return this._layer;
57
+ }
58
+ get rules() {
59
+ return this._sheet.rules;
60
+ }
61
+ get href() {
62
+ return this._href;
63
+ }
64
+ get sheet() {
65
+ return this._sheet;
66
+ }
67
+ toJSON() {
68
+ return {
69
+ ...super.toJSON(),
70
+ href: this._href,
71
+ // We match the CSSImportRule interface returning null when no support
72
+ // text exist
73
+ supportText: this._supportCondition.getOr(null),
74
+ // We match the CSSImportRule interface returning null when no layer
75
+ // is declared, and "" for an anonymous layer.
76
+ layer: this._layer.getOr(null),
77
+ };
78
+ }
79
+ toString() {
80
+ return (`@import url(${this._href}) ` +
81
+ `${this._layer.map((layer) => `layer${layer === "" ? "" : `(${layer}) `}`)}` +
82
+ `${this._supportCondition.map((condition) => `supports(${condition}) `).getOr("")}` +
83
+ `${this._condition}`);
84
+ }
85
+ }
86
+ /**
87
+ * @public
88
+ */
89
+ (function (ImportRule) {
90
+ function isImportRule(value) {
91
+ return value instanceof ImportRule;
92
+ }
93
+ ImportRule.isImportRule = isImportRule;
94
+ function matchesMedia(device) {
95
+ return (rule) => rule.mediaQueries.matches(device);
96
+ }
97
+ function matchesSupport(device) {
98
+ // If there is no support condition (None), it is matched.
99
+ // If there is an unparsable one (Some(None)), it is not matched.
100
+ return (rule) => rule.supportQuery.every((option) => option.some((query) => query.matches(device)));
101
+ }
102
+ function matches(device) {
103
+ return and(matchesMedia(device), matchesSupport(device));
104
+ }
105
+ ImportRule.matches = matches;
106
+ /**
107
+ * @internal
108
+ */
109
+ function fromImportRule(json) {
110
+ return Trampoline.traverse(json.rules, Rule.fromRule).map((rules) => ImportRule.of(json.href, Sheet.of(rules), Option.of(json.condition), Option.from(json.supportText), Option.from(json.layer)));
111
+ }
112
+ ImportRule.fromImportRule = fromImportRule;
113
+ })(ImportRule || (ImportRule = {}));
114
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1,32 @@
1
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
2
+ import { Block } from "../block.js";
3
+ import type { Declaration } from "../declaration.js";
4
+ import { Rule } from "../rule.js";
5
+ /**
6
+ * @public
7
+ */
8
+ export declare class KeyframeRule extends Rule<"keyframe"> {
9
+ static of(key: string, declarations: Iterable<Declaration>): KeyframeRule;
10
+ private readonly _key;
11
+ private readonly _style;
12
+ private constructor();
13
+ get key(): string;
14
+ get style(): Block;
15
+ toJSON(): KeyframeRule.JSON;
16
+ toString(): string;
17
+ }
18
+ /**
19
+ * @public
20
+ */
21
+ export declare namespace KeyframeRule {
22
+ interface JSON extends Rule.JSON<"keyframe"> {
23
+ key: string;
24
+ style: Block.JSON | string;
25
+ }
26
+ function isKeyframeRule(value: unknown): value is KeyframeRule;
27
+ /**
28
+ * @internal
29
+ */
30
+ function fromKeyframeRule(json: JSON): Trampoline<KeyframeRule>;
31
+ }
32
+ //# sourceMappingURL=keyframe.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { String } from "@siteimprove/alfa-string";
2
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
3
+ import { Block } from "../block.js";
4
+ import { Rule } from "../rule.js";
5
+ /**
6
+ * @public
7
+ */
8
+ export class KeyframeRule extends Rule {
9
+ static of(key, declarations) {
10
+ return new KeyframeRule(key, Array.from(declarations));
11
+ }
12
+ _key;
13
+ _style;
14
+ constructor(key, declarations) {
15
+ super("keyframe");
16
+ this._key = key;
17
+ this._style = Block.of(declarations.filter((declaration) => declaration._attachParent(this)));
18
+ }
19
+ get key() {
20
+ return this._key;
21
+ }
22
+ get style() {
23
+ return this._style;
24
+ }
25
+ toJSON() {
26
+ return {
27
+ ...super.toJSON(),
28
+ key: this._key,
29
+ style: this._style.toJSON(),
30
+ };
31
+ }
32
+ toString() {
33
+ const style = this._style.toString();
34
+ return `@keyframe ${this._key} {${style === "" ? "" : `\n${String.indent(style)}\n`}}`;
35
+ }
36
+ }
37
+ /**
38
+ * @public
39
+ */
40
+ (function (KeyframeRule) {
41
+ function isKeyframeRule(value) {
42
+ return value instanceof KeyframeRule;
43
+ }
44
+ KeyframeRule.isKeyframeRule = isKeyframeRule;
45
+ /**
46
+ * @internal
47
+ */
48
+ function fromKeyframeRule(json) {
49
+ return Trampoline.done(KeyframeRule.of(json.key, Block.from(json.style).declarations));
50
+ }
51
+ KeyframeRule.fromKeyframeRule = fromKeyframeRule;
52
+ })(KeyframeRule || (KeyframeRule = {}));
53
+ //# sourceMappingURL=keyframe.js.map
@@ -0,0 +1,28 @@
1
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
2
+ import { Rule } from "../rule.js";
3
+ import { GroupingRule } from "./grouping.js";
4
+ /**
5
+ * @public
6
+ */
7
+ export declare class KeyframesRule extends GroupingRule<"keyframes"> {
8
+ static of(name: string, rules: Iterable<Rule>): KeyframesRule;
9
+ private readonly _name;
10
+ private constructor();
11
+ get name(): string;
12
+ toJSON(): KeyframesRule.JSON;
13
+ toString(): string;
14
+ }
15
+ /**
16
+ * @public
17
+ */
18
+ export declare namespace KeyframesRule {
19
+ interface JSON extends GroupingRule.JSON<"keyframes"> {
20
+ name: string;
21
+ }
22
+ function isKeyframesRule(value: unknown): value is KeyframesRule;
23
+ /**
24
+ * @internal
25
+ */
26
+ function fromKeyframesRule(json: JSON): Trampoline<KeyframesRule>;
27
+ }
28
+ //# sourceMappingURL=keyframes.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { String } from "@siteimprove/alfa-string";
2
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
3
+ import { Rule } from "../rule.js";
4
+ import { GroupingRule } from "./grouping.js";
5
+ /**
6
+ * @public
7
+ */
8
+ export class KeyframesRule extends GroupingRule {
9
+ static of(name, rules) {
10
+ return new KeyframesRule(name, Array.from(rules));
11
+ }
12
+ _name;
13
+ constructor(name, rules) {
14
+ super("keyframes", rules);
15
+ this._name = name;
16
+ }
17
+ get name() {
18
+ return this._name;
19
+ }
20
+ toJSON() {
21
+ return {
22
+ ...super.toJSON(),
23
+ name: this._name,
24
+ };
25
+ }
26
+ toString() {
27
+ const rules = this._rules
28
+ .map((rule) => String.indent(rule.toString()))
29
+ .join("\n\n");
30
+ return `@keyframes ${this._name} {${rules === "" ? "" : `\n${rules}\n`}}`;
31
+ }
32
+ }
33
+ /**
34
+ * @public
35
+ */
36
+ (function (KeyframesRule) {
37
+ function isKeyframesRule(value) {
38
+ return value instanceof KeyframesRule;
39
+ }
40
+ KeyframesRule.isKeyframesRule = isKeyframesRule;
41
+ /**
42
+ * @internal
43
+ */
44
+ function fromKeyframesRule(json) {
45
+ return Trampoline.traverse(json.rules, Rule.fromRule).map((rules) => KeyframesRule.of(json.name, rules));
46
+ }
47
+ KeyframesRule.fromKeyframesRule = fromKeyframesRule;
48
+ })(KeyframesRule || (KeyframesRule = {}));
49
+ //# sourceMappingURL=keyframes.js.map
@@ -0,0 +1,61 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Option } from "@siteimprove/alfa-option";
3
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
4
+ import { Rule } from "../rule.js";
5
+ import { GroupingRule } from "./grouping.js";
6
+ /**
7
+ * Model for CSS layers
8
+ *
9
+ * @remarks
10
+ * There are actually two kinds of `@layer` rules: block and statements.
11
+ * Both are introduced by the same keyword, and work closely together,
12
+ * hence they are kept here for better cohesion. They are, however,
13
+ * represented as separated Classes, with separated `type`, mimicking the two
14
+ * JS interfaces that exist in native DOM.
15
+ *
16
+ * @public
17
+ */
18
+ export declare namespace Layer {
19
+ /**
20
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@layer}
21
+ * {@link https://drafts.csswg.org/css-cascade-5/#layer-empty}
22
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSLayerStatementRule}
23
+ */
24
+ class StatementRule extends Rule<"layer-statement"> {
25
+ static of(layers: Iterable<string>): StatementRule;
26
+ private readonly _layers;
27
+ private constructor();
28
+ get layers(): Iterable<string>;
29
+ toJSON(): StatementRule.JSON;
30
+ toString(): string;
31
+ }
32
+ namespace StatementRule {
33
+ interface JSON extends Rule.JSON<"layer-statement"> {
34
+ layers: Array<string>;
35
+ }
36
+ function fromLayerStatementRule(json: JSON): Trampoline<StatementRule>;
37
+ function isLayerStatementRule(value: unknown): value is StatementRule;
38
+ }
39
+ /**
40
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@layer}
41
+ * {@link https://drafts.csswg.org/css-cascade-5/#layer-block}
42
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSLayerBlockRule}
43
+ */
44
+ class BlockRule extends GroupingRule<"layer-block"> {
45
+ static of(rules: Iterable<Rule>, layer?: string | null): BlockRule;
46
+ private readonly _layer;
47
+ private constructor();
48
+ get layer(): Option<string>;
49
+ equals(value: unknown): value is this;
50
+ toJSON(): BlockRule.JSON;
51
+ toString(): string;
52
+ }
53
+ namespace BlockRule {
54
+ interface JSON extends GroupingRule.JSON<"layer-block"> {
55
+ layer: string | null;
56
+ }
57
+ function fromLayerBlockRule(json: JSON): Trampoline<BlockRule>;
58
+ function isLayerBlockRule(value: unknown): value is BlockRule;
59
+ }
60
+ }
61
+ //# sourceMappingURL=layer.d.ts.map
@@ -0,0 +1,106 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Option } from "@siteimprove/alfa-option";
3
+ import { String } from "@siteimprove/alfa-string";
4
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
5
+ import { Rule } from "../rule.js";
6
+ import { GroupingRule } from "./grouping.js";
7
+ /**
8
+ * Model for CSS layers
9
+ *
10
+ * @remarks
11
+ * There are actually two kinds of `@layer` rules: block and statements.
12
+ * Both are introduced by the same keyword, and work closely together,
13
+ * hence they are kept here for better cohesion. They are, however,
14
+ * represented as separated Classes, with separated `type`, mimicking the two
15
+ * JS interfaces that exist in native DOM.
16
+ *
17
+ * @public
18
+ */
19
+ export var Layer;
20
+ (function (Layer) {
21
+ /**
22
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@layer}
23
+ * {@link https://drafts.csswg.org/css-cascade-5/#layer-empty}
24
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSLayerStatementRule}
25
+ */
26
+ class StatementRule extends Rule {
27
+ static of(layers) {
28
+ return new StatementRule(Array.from(layers));
29
+ }
30
+ _layers;
31
+ constructor(layers) {
32
+ super("layer-statement");
33
+ this._layers = layers;
34
+ }
35
+ get layers() {
36
+ return this._layers;
37
+ }
38
+ toJSON() {
39
+ return {
40
+ ...super.toJSON(),
41
+ layers: this._layers,
42
+ };
43
+ }
44
+ toString() {
45
+ return `@layer ${this._layers.join(", ")};`;
46
+ }
47
+ }
48
+ Layer.StatementRule = StatementRule;
49
+ (function (StatementRule) {
50
+ function fromLayerStatementRule(json) {
51
+ return Trampoline.done(StatementRule.of(json.layers));
52
+ }
53
+ StatementRule.fromLayerStatementRule = fromLayerStatementRule;
54
+ function isLayerStatementRule(value) {
55
+ return value instanceof StatementRule;
56
+ }
57
+ StatementRule.isLayerStatementRule = isLayerStatementRule;
58
+ })(StatementRule = Layer.StatementRule || (Layer.StatementRule = {}));
59
+ /**
60
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@layer}
61
+ * {@link https://drafts.csswg.org/css-cascade-5/#layer-block}
62
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSLayerBlockRule}
63
+ */
64
+ class BlockRule extends GroupingRule {
65
+ static of(rules, layer) {
66
+ return new BlockRule(Option.from(layer), Array.from(rules));
67
+ }
68
+ _layer;
69
+ constructor(layer, rules) {
70
+ super("layer-block", rules);
71
+ this._layer = layer;
72
+ }
73
+ get layer() {
74
+ return this._layer;
75
+ }
76
+ equals(value) {
77
+ return (value instanceof BlockRule &&
78
+ value._layer.equals(this._layer) &&
79
+ super.equals(value));
80
+ }
81
+ toJSON() {
82
+ return {
83
+ ...super.toJSON(),
84
+ layer: this._layer.getOr(null),
85
+ };
86
+ }
87
+ toString() {
88
+ const rules = this._rules
89
+ .map((rule) => String.indent(rule.toString()))
90
+ .join("\n\n");
91
+ return `@layer ${this._layer.isSome() ? this._layer.getUnsafe() + " " : ""}{${rules === "" ? "" : `\n${rules}\n`}}`;
92
+ }
93
+ }
94
+ Layer.BlockRule = BlockRule;
95
+ (function (BlockRule) {
96
+ function fromLayerBlockRule(json) {
97
+ return Trampoline.traverse(json.rules, Rule.fromRule).map((rules) => BlockRule.of(rules, json.layer));
98
+ }
99
+ BlockRule.fromLayerBlockRule = fromLayerBlockRule;
100
+ function isLayerBlockRule(value) {
101
+ return value instanceof BlockRule;
102
+ }
103
+ BlockRule.isLayerBlockRule = isLayerBlockRule;
104
+ })(BlockRule = Layer.BlockRule || (Layer.BlockRule = {}));
105
+ })(Layer || (Layer = {}));
106
+ //# sourceMappingURL=layer.js.map
@@ -0,0 +1,32 @@
1
+ import { Feature } from "@siteimprove/alfa-css-feature";
2
+ import type { Device } from "@siteimprove/alfa-device";
3
+ import type { Iterable } from "@siteimprove/alfa-iterable";
4
+ import type { Predicate } from "@siteimprove/alfa-predicate";
5
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
6
+ import { Rule } from "../rule.js";
7
+ import { ConditionRule } from "./condition.js";
8
+ /**
9
+ * @public
10
+ */
11
+ export declare class MediaRule extends ConditionRule<"media"> {
12
+ static of(condition: string, rules: Iterable<Rule>): MediaRule;
13
+ private readonly _queries;
14
+ private constructor();
15
+ get queries(): Feature.Media.List;
16
+ toJSON(): MediaRule.JSON;
17
+ toString(): string;
18
+ }
19
+ /**
20
+ * @public
21
+ */
22
+ export declare namespace MediaRule {
23
+ interface JSON extends ConditionRule.JSON<"media"> {
24
+ }
25
+ function isMediaRule(value: unknown): value is MediaRule;
26
+ function matches(device: Device): Predicate<MediaRule>;
27
+ /**
28
+ * @internal
29
+ */
30
+ function fromMediaRule(json: JSON): Trampoline<MediaRule>;
31
+ }
32
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { Lexer } from "@siteimprove/alfa-css";
2
+ import { Feature } from "@siteimprove/alfa-css-feature";
3
+ import { String } from "@siteimprove/alfa-string";
4
+ import { Trampoline } from "@siteimprove/alfa-trampoline";
5
+ import { Rule } from "../rule.js";
6
+ import { ConditionRule } from "./condition.js";
7
+ /**
8
+ * @public
9
+ */
10
+ export class MediaRule extends ConditionRule {
11
+ static of(condition, rules) {
12
+ return new MediaRule(condition, Array.from(rules));
13
+ }
14
+ _queries;
15
+ constructor(condition, rules) {
16
+ super("media", condition, rules);
17
+ this._queries = Feature.parseMediaQuery(Lexer.lex(condition))
18
+ .map(([, queries]) => queries)
19
+ .getOr(Feature.Media.List.of([]));
20
+ }
21
+ get queries() {
22
+ return this._queries;
23
+ }
24
+ toJSON() {
25
+ return super.toJSON();
26
+ }
27
+ toString() {
28
+ const rules = this._rules
29
+ .map((rule) => String.indent(rule.toString()))
30
+ .join("\n\n");
31
+ return `@media ${this._condition} {${rules === "" ? "" : `\n${rules}\n`}}`;
32
+ }
33
+ }
34
+ /**
35
+ * @public
36
+ */
37
+ (function (MediaRule) {
38
+ function isMediaRule(value) {
39
+ return value instanceof MediaRule;
40
+ }
41
+ MediaRule.isMediaRule = isMediaRule;
42
+ function matches(device) {
43
+ return (rule) => rule.queries.matches(device);
44
+ }
45
+ MediaRule.matches = matches;
46
+ /**
47
+ * @internal
48
+ */
49
+ function fromMediaRule(json) {
50
+ return Trampoline.traverse(json.rules, Rule.fromRule).map((rules) => MediaRule.of(json.condition, rules));
51
+ }
52
+ MediaRule.fromMediaRule = fromMediaRule;
53
+ })(MediaRule || (MediaRule = {}));
54
+ //# sourceMappingURL=media.js.map