@markuplint/types 3.0.0-dev.24 → 3.0.0-dev.290

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 (173) hide show
  1. package/README.md +63 -61
  2. package/lib/check-multi-types.d.ts +2 -2
  3. package/lib/check-multi-types.js +9 -13
  4. package/lib/check.d.ts +7 -6
  5. package/lib/check.js +20 -30
  6. package/lib/css-syntax.d.ts +1 -1
  7. package/lib/css-syntax.js +60 -63
  8. package/lib/debug.js +2 -6
  9. package/lib/defs.d.ts +1 -1
  10. package/lib/defs.js +163 -91
  11. package/lib/enum.d.ts +4 -3
  12. package/lib/enum.js +7 -12
  13. package/lib/get-candidate.d.ts +1 -1
  14. package/lib/get-candidate.js +3 -8
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +3 -6
  17. package/lib/keyword-type.d.ts +2 -2
  18. package/lib/keyword-type.js +17 -21
  19. package/lib/list.d.ts +4 -3
  20. package/lib/list.js +9 -13
  21. package/lib/match-result.d.ts +4 -4
  22. package/lib/match-result.js +6 -12
  23. package/lib/number.d.ts +3 -3
  24. package/lib/number.js +11 -15
  25. package/lib/primitive/index.d.ts +7 -7
  26. package/lib/primitive/index.js +7 -17
  27. package/lib/primitive/is-float.js +1 -5
  28. package/lib/primitive/is-int.js +1 -5
  29. package/lib/primitive/is-non-zero-uint.js +1 -5
  30. package/lib/primitive/is-quantity.d.ts +1 -1
  31. package/lib/primitive/is-quantity.js +9 -13
  32. package/lib/primitive/is-uint.d.ts +1 -1
  33. package/lib/primitive/is-uint.js +1 -5
  34. package/lib/primitive/range.js +1 -5
  35. package/lib/primitive/split-unit.js +3 -7
  36. package/lib/rfc/is-bcp-47.d.ts +1 -1
  37. package/lib/rfc/is-bcp-47.js +3 -7
  38. package/lib/token/index.d.ts +2 -2
  39. package/lib/token/index.js +2 -7
  40. package/lib/token/token-collection.d.ts +13 -13
  41. package/lib/token/token-collection.js +55 -50
  42. package/lib/token/token.d.ts +11 -10
  43. package/lib/token/token.js +16 -24
  44. package/lib/token/types.d.ts +3 -0
  45. package/lib/types.d.ts +47 -46
  46. package/lib/types.js +1 -2
  47. package/lib/types.schema.d.ts +2 -2
  48. package/lib/types.schema.js +1 -3
  49. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  50. package/lib/w3c/check-serialized-permissions-policy.js +16 -20
  51. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  52. package/lib/whatwg/check-autocomplete.js +28 -32
  53. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  54. package/lib/whatwg/check-datetime/date-string.js +9 -13
  55. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
  56. package/lib/whatwg/check-datetime/datetime-tokens.js +43 -46
  57. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  58. package/lib/whatwg/check-datetime/duration-string.js +48 -44
  59. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  60. package/lib/whatwg/check-datetime/global-date-and-time-string.js +17 -21
  61. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  62. package/lib/whatwg/check-datetime/index.js +25 -29
  63. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  64. package/lib/whatwg/check-datetime/local-date-and-time-string.js +25 -26
  65. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  66. package/lib/whatwg/check-datetime/month-string.js +9 -13
  67. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  68. package/lib/whatwg/check-datetime/time-string.js +9 -13
  69. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  70. package/lib/whatwg/check-datetime/time-zone-offset-string.js +16 -21
  71. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  72. package/lib/whatwg/check-datetime/week-string.js +9 -13
  73. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  74. package/lib/whatwg/check-datetime/year-string.js +9 -13
  75. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  76. package/lib/whatwg/check-datetime/yearless-date-string.js +9 -13
  77. package/lib/whatwg/check-mime-type.d.ts +1 -1
  78. package/lib/whatwg/check-mime-type.js +12 -18
  79. package/lib/whatwg/is-abs-url.d.ts +1 -1
  80. package/lib/whatwg/is-abs-url.js +1 -5
  81. package/lib/whatwg/is-browser-context-name.d.ts +3 -1
  82. package/lib/whatwg/is-browser-context-name.js +3 -5
  83. package/lib/whatwg/is-custom-element-name.d.ts +1 -1
  84. package/lib/whatwg/is-custom-element-name.js +1 -5
  85. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  86. package/lib/whatwg/is-itemprop-name.js +2 -6
  87. package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
  88. package/lib/whatwg/is-navigable-target-name.js +20 -0
  89. package/package.json +19 -13
  90. package/types.schema.json +314 -311
  91. package/gen/specific-schema.json +0 -98
  92. package/gen/types.ts +0 -66
  93. package/lib/check.spec.js +0 -76
  94. package/lib/css-syntax.spec.d.ts +0 -1
  95. package/lib/css-syntax.spec.js +0 -157
  96. package/lib/list.spec.d.ts +0 -1
  97. package/lib/list.spec.js +0 -129
  98. package/lib/primitive/index.spec.d.ts +0 -1
  99. package/lib/primitive/index.spec.js +0 -62
  100. package/lib/rfc/is-bcp-47.spec.d.ts +0 -1
  101. package/lib/rfc/is-bcp-47.spec.js +0 -19
  102. package/lib/token/token-collection.spec.d.ts +0 -1
  103. package/lib/token/token-collection.spec.js +0 -144
  104. package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +0 -1
  105. package/lib/w3c/check-serialized-permissions-policy.spec.js +0 -34
  106. package/lib/whatwg/check-autocomplete.spec.d.ts +0 -1
  107. package/lib/whatwg/check-autocomplete.spec.js +0 -379
  108. package/lib/whatwg/check-datetime/index.spec.d.ts +0 -1
  109. package/lib/whatwg/check-datetime/index.spec.js +0 -318
  110. package/lib/whatwg/check-mime-type.spec.d.ts +0 -1
  111. package/lib/whatwg/check-mime-type.spec.js +0 -58
  112. package/lib/whatwg/is-abs-url.spec.d.ts +0 -1
  113. package/lib/whatwg/is-abs-url.spec.js +0 -8
  114. package/patches/css-tree+2.3.1.patch +0 -23
  115. package/src/check-multi-types.ts +0 -35
  116. package/src/check.spec.ts +0 -83
  117. package/src/check.ts +0 -48
  118. package/src/css-syntax.spec.ts +0 -167
  119. package/src/css-syntax.ts +0 -188
  120. package/src/debug.ts +0 -3
  121. package/src/defs.ts +0 -811
  122. package/src/enum.ts +0 -25
  123. package/src/get-candidate.ts +0 -24
  124. package/src/index.ts +0 -3
  125. package/src/keyword-type.ts +0 -64
  126. package/src/list.spec.ts +0 -133
  127. package/src/list.ts +0 -34
  128. package/src/match-result.ts +0 -49
  129. package/src/number.ts +0 -46
  130. package/src/primitive/index.spec.ts +0 -65
  131. package/src/primitive/index.ts +0 -7
  132. package/src/primitive/is-float.ts +0 -8
  133. package/src/primitive/is-int.ts +0 -8
  134. package/src/primitive/is-non-zero-uint.ts +0 -8
  135. package/src/primitive/is-quantity.ts +0 -38
  136. package/src/primitive/is-uint.ts +0 -15
  137. package/src/primitive/range.ts +0 -14
  138. package/src/primitive/split-unit.ts +0 -20
  139. package/src/rfc/is-bcp-47.spec.ts +0 -23
  140. package/src/rfc/is-bcp-47.ts +0 -13
  141. package/src/token/index.ts +0 -2
  142. package/src/token/token-collection.spec.ts +0 -147
  143. package/src/token/token-collection.ts +0 -444
  144. package/src/token/token.ts +0 -144
  145. package/src/types.schema.ts +0 -1113
  146. package/src/types.ts +0 -118
  147. package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
  148. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  149. package/src/whatwg/check-autocomplete.spec.ts +0 -387
  150. package/src/whatwg/check-autocomplete.ts +0 -380
  151. package/src/whatwg/check-datetime/date-string.ts +0 -44
  152. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  153. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  154. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  155. package/src/whatwg/check-datetime/index.spec.ts +0 -333
  156. package/src/whatwg/check-datetime/index.ts +0 -36
  157. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  158. package/src/whatwg/check-datetime/month-string.ts +0 -31
  159. package/src/whatwg/check-datetime/time-string.ts +0 -49
  160. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  161. package/src/whatwg/check-datetime/week-string.ts +0 -41
  162. package/src/whatwg/check-datetime/year-string.ts +0 -26
  163. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  164. package/src/whatwg/check-mime-type.spec.ts +0 -59
  165. package/src/whatwg/check-mime-type.ts +0 -46
  166. package/src/whatwg/is-abs-url.spec.ts +0 -8
  167. package/src/whatwg/is-abs-url.ts +0 -31
  168. package/src/whatwg/is-browser-context-name.ts +0 -16
  169. package/src/whatwg/is-custom-element-name.ts +0 -76
  170. package/src/whatwg/is-itemprop-name.ts +0 -17
  171. package/tsconfig.test.json +0 -3
  172. package/tsconfig.tsbuildinfo +0 -1
  173. /package/lib/{check.spec.d.ts → token/types.js} +0 -0
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkNormalizedLocalDateAndTimeString = exports.checkLocalDateAndTimeString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string
9
6
  */
10
- const checkLocalDateAndTimeString = () => function checkLocalDateAndTimeString(value) {
11
- (0, debug_1.log)('CHECK: local-date-and-time-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [
7
+ export const checkLocalDateAndTimeString = () => function checkLocalDateAndTimeString(value) {
8
+ log('CHECK: local-date-and-time-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [
13
10
  // YYYY
14
11
  /[^-]*/,
15
12
  // -
@@ -37,20 +34,19 @@ const checkLocalDateAndTimeString = () => function checkLocalDateAndTimeString(v
37
34
  // sss
38
35
  /.[0-9]*/,
39
36
  ]);
40
- (0, debug_1.log)('Local Date and Time: "%s" => %O', tokens.value, tokens);
41
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.date, datetime_tokens_1.datetimeTokenCheck.localDateTimeSeparator, datetime_tokens_1.datetimeTokenCheck.hour, datetime_tokens_1.datetimeTokenCheck.colon, datetime_tokens_1.datetimeTokenCheck.minute, datetime_tokens_1.datetimeTokenCheck.colonOrEnd, datetime_tokens_1.datetimeTokenCheck.second, datetime_tokens_1.datetimeTokenCheck.decimalPointOrEnd, datetime_tokens_1.datetimeTokenCheck.secondFractionalPart, datetime_tokens_1.datetimeTokenCheck.extra);
37
+ log('Local Date and Time: "%s" => %O', tokens.value, tokens);
38
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.localDateTimeSeparator, datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart, datetimeTokenCheck.extra);
42
39
  if (!res.matched) {
43
- (0, debug_1.log)('Failed: %O', res);
40
+ log('Failed: %O', res);
44
41
  }
45
42
  return res;
46
43
  };
47
- exports.checkLocalDateAndTimeString = checkLocalDateAndTimeString;
48
44
  /**
49
45
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string
50
46
  */
51
- const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLocalDateAndTimeString(value) {
52
- (0, debug_1.log)('CHECK: normalized-local-date-and-time-string');
53
- const tokens = token_1.TokenCollection.fromPatterns(value, [
47
+ export const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLocalDateAndTimeString(value) {
48
+ log('CHECK: normalized-local-date-and-time-string');
49
+ const tokens = TokenCollection.fromPatterns(value, [
54
50
  // YYYY
55
51
  /[^-]*/,
56
52
  // -
@@ -78,10 +74,10 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
78
74
  // sss
79
75
  /.[0-9]*/,
80
76
  ]);
81
- (0, debug_1.log)('Normalized Local Date and Time: "%s" => %O', tokens.value, tokens);
82
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.date, datetime_tokens_1.datetimeTokenCheck.normalizedlocalDateTimeSeparator, datetime_tokens_1.datetimeTokenCheck.hour, datetime_tokens_1.datetimeTokenCheck.colon, datetime_tokens_1.datetimeTokenCheck.minute, datetime_tokens_1.datetimeTokenCheck.colonOrEnd, datetime_tokens_1.datetimeTokenCheck.second, datetime_tokens_1.datetimeTokenCheck.decimalPointOrEnd, datetime_tokens_1.datetimeTokenCheck.secondFractionalPart, datetime_tokens_1.datetimeTokenCheck.extra);
77
+ log('Normalized Local Date and Time: "%s" => %O', tokens.value, tokens);
78
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.normalizedlocalDateTimeSeparator, datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart, datetimeTokenCheck.extra);
83
79
  if (!res.matched) {
84
- (0, debug_1.log)('Failed: %O', res);
80
+ log('Failed: %O', res);
85
81
  return res;
86
82
  }
87
83
  /**
@@ -91,15 +87,19 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
91
87
  * > if the given time is zero seconds past the minute)
92
88
  */
93
89
  const [, , , , , , , , , , second, , fp] = tokens;
94
- const _second = second.toNumber() || 0;
95
- const _fp = fp.toNumber() || 0;
96
- (0, debug_1.log)('Omitting the seconds component: "%s.%s" => %d, %d', second === null || second === void 0 ? void 0 : second.value, fp === null || fp === void 0 ? void 0 : fp.value, _second, _fp);
90
+ if (!second || !fp) {
91
+ log('Failed: %O', res);
92
+ return res;
93
+ }
94
+ const _second = second.toNumber();
95
+ const _fp = fp.toNumber();
96
+ log('Omitting the seconds component: "%s.%s" => %d, %d', second?.value, fp?.value, _second, _fp);
97
97
  if (second.value && _second === 0 && (!fp.value || (fp.value && _fp === 0))) {
98
98
  const res = second.unmatched({
99
99
  partName: 'second',
100
100
  reason: 'extra-token',
101
101
  });
102
- (0, debug_1.log)('Failed: %O', res);
102
+ log('Failed: %O', res);
103
103
  return res;
104
104
  }
105
105
  if (fp.value && _fp === 0) {
@@ -107,10 +107,9 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
107
107
  partName: 'fractional part',
108
108
  reason: 'extra-token',
109
109
  });
110
- (0, debug_1.log)('Failed: %O', res);
110
+ log('Failed: %O', res);
111
111
  return res;
112
112
  }
113
- (0, debug_1.log)('Failed: %O', res);
113
+ log('Failed: %O', res);
114
114
  return res;
115
115
  };
116
- exports.checkNormalizedLocalDateAndTimeString = checkNormalizedLocalDateAndTimeString;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-month-string
4
4
  */
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkMonthString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-month-string
9
6
  */
10
- const checkMonthString = () => function checkMonthString(value) {
11
- (0, debug_1.log)('CHECK: month-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [/[^-]*/, /[^0-9]?/, /.[0-9]*/]);
13
- (0, debug_1.log)('Month: "%s" => %O', tokens.value, tokens);
14
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.extra);
7
+ export const checkMonthString = () => function checkMonthString(value) {
8
+ log('CHECK: month-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [/[^-]*/, /[^0-9]?/, /.[0-9]*/]);
10
+ log('Month: "%s" => %O', tokens.value, tokens);
11
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.extra);
15
12
  if (!res.matched) {
16
- (0, debug_1.log)('Failed: %O', res);
13
+ log('Failed: %O', res);
17
14
  }
18
15
  return res;
19
16
  };
20
- exports.checkMonthString = checkMonthString;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
4
4
  */
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkTimeString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
9
6
  */
10
- const checkTimeString = () => function checkTimeString(value) {
11
- (0, debug_1.log)('CHECK: time-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [
7
+ export const checkTimeString = () => function checkTimeString(value) {
8
+ log('CHECK: time-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [
13
10
  // hh
14
11
  /[^:]*/,
15
12
  // :
@@ -25,11 +22,10 @@ const checkTimeString = () => function checkTimeString(value) {
25
22
  // sss
26
23
  /.[0-9]*/,
27
24
  ]);
28
- (0, debug_1.log)('Time: "%s" => %O', tokens.value, tokens);
29
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.hour, datetime_tokens_1.datetimeTokenCheck.colon, datetime_tokens_1.datetimeTokenCheck.minute, datetime_tokens_1.datetimeTokenCheck.colonOrEnd, datetime_tokens_1.datetimeTokenCheck.second, datetime_tokens_1.datetimeTokenCheck.decimalPointOrEnd, datetime_tokens_1.datetimeTokenCheck.secondFractionalPart);
25
+ log('Time: "%s" => %O', tokens.value, tokens);
26
+ const res = tokens.eachCheck(datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, datetimeTokenCheck.colonOrEnd, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart);
30
27
  if (!res.matched) {
31
- (0, debug_1.log)('Failed: %O', res);
28
+ log('Failed: %O', res);
32
29
  }
33
30
  return res;
34
31
  };
35
- exports.checkTimeString = checkTimeString;
@@ -1,7 +1,7 @@
1
- import type { Token } from '../../token';
2
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { Token } from '../../token/index.js';
2
+ import type { CustomSyntaxChecker } from '../../types.js';
3
3
  /**
4
4
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
5
5
  */
6
6
  export declare const checkTimeZoneOffsetString: CustomSyntaxChecker;
7
- export declare function parseTimeZone(zone: string | Token): import("../../types").Result;
7
+ export declare function parseTimeZone(zone: string | Readonly<Token>): import("../../types.js").Result;
@@ -1,21 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseTimeZone = exports.checkTimeZoneOffsetString = void 0;
4
- const debug_1 = require("../../debug");
5
- const match_result_1 = require("../../match-result");
6
- const token_1 = require("../../token");
7
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { matched, unmatched } from '../../match-result.js';
3
+ import { TokenCollection } from '../../token/index.js';
4
+ import { datetimeTokenCheck } from './datetime-tokens.js';
8
5
  /**
9
6
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
10
7
  */
11
- const checkTimeZoneOffsetString = () => function checkTimeZoneOffsetString(value) {
12
- (0, debug_1.log)('CHECK: time-zone-offset-string');
8
+ export const checkTimeZoneOffsetString = () => function checkTimeZoneOffsetString(value) {
9
+ log('CHECK: time-zone-offset-string');
13
10
  return parseTimeZone(value);
14
11
  };
15
- exports.checkTimeZoneOffsetString = checkTimeZoneOffsetString;
16
- function parseTimeZone(zone) {
12
+ export function parseTimeZone(zone) {
17
13
  const value = typeof zone === 'string' ? zone : zone.value;
18
- const zoneTokens = token_1.TokenCollection.fromPatterns(zone, [
14
+ const zoneTokens = TokenCollection.fromPatterns(zone, [
19
15
  // Z + -
20
16
  /[^0-9]?/,
21
17
  // hh
@@ -25,10 +21,10 @@ function parseTimeZone(zone) {
25
21
  // mm
26
22
  /.[0-9]*/,
27
23
  ]);
28
- (0, debug_1.log)('Time-zone Part: "%s" => %O', value, zoneTokens);
24
+ log('Time-zone Part: "%s" => %O', value, zoneTokens);
29
25
  const res = zoneTokens.eachCheck((sign, tail) => {
30
26
  if (!sign || !sign.value) {
31
- return (0, match_result_1.unmatched)(value, 'missing-token', {
27
+ return unmatched(value, 'missing-token', {
32
28
  expects: [
33
29
  { type: 'const', value: 'Z' },
34
30
  { type: 'const', value: '+' },
@@ -39,11 +35,11 @@ function parseTimeZone(zone) {
39
35
  }
40
36
  if (sign.match('Z')) {
41
37
  if (tail.value) {
42
- return tail[0].unmatched({
38
+ return (tail[0]?.unmatched({
43
39
  reason: 'extra-token',
44
- });
40
+ }) ?? unmatched(tail.value, 'extra-token'));
45
41
  }
46
- return (0, match_result_1.matched)();
42
+ return matched();
47
43
  }
48
44
  if (!sign.match(['+', '-'])) {
49
45
  return sign.unmatched({
@@ -55,7 +51,7 @@ function parseTimeZone(zone) {
55
51
  partName: 'time-zone',
56
52
  });
57
53
  }
58
- }, datetime_tokens_1.datetimeTokenCheck.hour, colon => {
54
+ }, datetimeTokenCheck.hour, colon => {
59
55
  if (!colon || !colon.value) {
60
56
  return;
61
57
  }
@@ -66,10 +62,9 @@ function parseTimeZone(zone) {
66
62
  partName: 'time-zone',
67
63
  });
68
64
  }
69
- }, datetime_tokens_1.datetimeTokenCheck.minute, datetime_tokens_1.datetimeTokenCheck.extra);
65
+ }, datetimeTokenCheck.minute, datetimeTokenCheck.extra);
70
66
  if (!res.matched) {
71
- (0, debug_1.log)('Failed: %O', res);
67
+ log('Failed: %O', res);
72
68
  }
73
69
  return res;
74
70
  }
75
- exports.parseTimeZone = parseTimeZone;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
4
4
  */
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkWeekString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
9
6
  */
10
- const checkWeekString = () => function checkWeekString(value) {
11
- (0, debug_1.log)('CHECK: week-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [
7
+ export const checkWeekString = () => function checkWeekString(value) {
8
+ log('CHECK: week-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [
13
10
  // YYYY
14
11
  /[^-]+/,
15
12
  // -
@@ -19,11 +16,10 @@ const checkWeekString = () => function checkWeekString(value) {
19
16
  // ww
20
17
  /.[0-9]*/,
21
18
  ]);
22
- (0, debug_1.log)('Week: "%s" => %O', tokens.value, tokens);
23
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.weekSign, datetime_tokens_1.datetimeTokenCheck.week, datetime_tokens_1.datetimeTokenCheck.extra);
19
+ log('Week: "%s" => %O', tokens.value, tokens);
20
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.weekSign, datetimeTokenCheck.week, datetimeTokenCheck.extra);
24
21
  if (!res.matched) {
25
- (0, debug_1.log)('Failed: %O', res);
22
+ log('Failed: %O', res);
26
23
  }
27
24
  return res;
28
25
  };
29
- exports.checkWeekString = checkWeekString;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html
4
4
  */
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkYearString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html
9
6
  */
10
- const checkYearString = () => function checkYearString(value) {
11
- (0, debug_1.log)('CHECK: year-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [/.*/]);
13
- (0, debug_1.log)('Year: "%s" => %O', tokens.value, tokens);
14
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.extra);
7
+ export const checkYearString = () => function checkYearString(value) {
8
+ log('CHECK: year-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [/.*/]);
10
+ log('Year: "%s" => %O', tokens.value, tokens);
11
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.extra);
15
12
  if (!res.matched) {
16
- (0, debug_1.log)('Failed: %O', res);
13
+ log('Failed: %O', res);
17
14
  }
18
15
  return res;
19
16
  };
20
- exports.checkYearString = checkYearString;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#yearless-dates
4
4
  */
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkYearlessDateString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#yearless-dates
9
6
  */
10
- const checkYearlessDateString = () => function checkYearlessDateString(value) {
11
- (0, debug_1.log)('CHECK: yearless-date-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [
7
+ export const checkYearlessDateString = () => function checkYearlessDateString(value) {
8
+ log('CHECK: yearless-date-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [
13
10
  // MM
14
11
  /[^-]*/,
15
12
  // -
@@ -17,11 +14,10 @@ const checkYearlessDateString = () => function checkYearlessDateString(value) {
17
14
  // DD
18
15
  /.[0-9]*/,
19
16
  ]);
20
- (0, debug_1.log)('Yearless Date: "%s" => %O', tokens.value, tokens);
21
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.date, datetime_tokens_1.datetimeTokenCheck.extra);
17
+ log('Yearless Date: "%s" => %O', tokens.value, tokens);
18
+ const res = tokens.eachCheck(datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.extra);
22
19
  if (!res.matched) {
23
- (0, debug_1.log)('Failed: %O', res);
20
+ log('Failed: %O', res);
24
21
  }
25
22
  return res;
26
23
  };
27
- exports.checkYearlessDateString = checkYearlessDateString;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../types';
1
+ import type { CustomSyntaxChecker } from '../types.js';
2
2
  /**
3
3
  * MIME Type
4
4
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkMIMEType = void 0;
4
- const tslib_1 = require("tslib");
5
1
  // @ts-ignore
6
- const whatwg_mimetype_1 = tslib_1.__importDefault(require("whatwg-mimetype"));
7
- const match_result_1 = require("../match-result");
8
- const token_1 = require("../token");
2
+ import MIMEType from 'whatwg-mimetype';
3
+ import { matched, unmatched } from '../match-result.js';
4
+ import { Token } from '../token/index.js';
9
5
  const expects = (withoutParameters) => [
10
6
  {
11
7
  type: 'format',
@@ -16,27 +12,25 @@ const expects = (withoutParameters) => [
16
12
  * MIME Type
17
13
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
18
14
  */
19
- const checkMIMEType = options => value => {
20
- var _a;
21
- const withoutParameters = (_a = options === null || options === void 0 ? void 0 : options.withoutParameters) !== null && _a !== void 0 ? _a : false;
15
+ export const checkMIMEType = options => value => {
16
+ const withoutParameters = options?.withoutParameters ?? false;
22
17
  if (!value) {
23
- return (0, match_result_1.unmatched)(value, 'empty-token', { expects: expects(withoutParameters) });
18
+ return unmatched(value, 'empty-token', { expects: expects(withoutParameters) });
24
19
  }
25
- const mimeType = whatwg_mimetype_1.default.parse(value);
20
+ const mimeType = MIMEType.parse(value);
26
21
  if (mimeType) {
27
22
  if (value.toLowerCase() === mimeType.essence) {
28
- return (0, match_result_1.matched)();
23
+ return matched();
29
24
  }
30
- if (!withoutParameters && mimeType.parameters.size) {
31
- return (0, match_result_1.matched)();
25
+ if (!withoutParameters && mimeType.parameters.size > 0) {
26
+ return matched();
32
27
  }
33
28
  const extraToken = value.slice(mimeType.essence.length);
34
- return new token_1.Token(extraToken, mimeType.essence.length, value).unmatched({
29
+ return new Token(extraToken, mimeType.essence.length, value).unmatched({
35
30
  reason: 'extra-token',
36
31
  expects: expects(withoutParameters),
37
32
  candidate: mimeType.essence,
38
33
  });
39
34
  }
40
- return (0, match_result_1.unmatched)(value, 'syntax-error', { expects: expects(withoutParameters) });
35
+ return unmatched(value, 'syntax-error', { expects: expects(withoutParameters) });
41
36
  };
42
- exports.checkMIMEType = checkMIMEType;
@@ -1,4 +1,4 @@
1
- import type { FormattedPrimitiveTypeCreator } from '../types';
1
+ import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
3
  * @see https://url.spec.whatwg.org/#syntax-url-absolute
4
4
  *
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAbsURL = void 0;
4
1
  /**
5
2
  * @see https://url.spec.whatwg.org/#syntax-url-absolute
6
3
  *
@@ -14,7 +11,7 @@ exports.isAbsURL = void 0;
14
11
  * > followed by U+003A (:) and a scheme-relative-file-URL string
15
12
  *
16
13
  */
17
- const isAbsURL = () => {
14
+ export const isAbsURL = () => {
18
15
  return value => {
19
16
  try {
20
17
  new URL(value);
@@ -31,4 +28,3 @@ const isAbsURL = () => {
31
28
  return true;
32
29
  };
33
30
  };
34
- exports.isAbsURL = isAbsURL;
@@ -1,4 +1,4 @@
1
- import type { FormattedPrimitiveTypeCreator } from '../types';
1
+ import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
3
  *
4
4
  * @see https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name
@@ -7,5 +7,7 @@ import type { FormattedPrimitiveTypeCreator } from '../types';
7
7
  * > that does not start with a U+005F LOW LINE character.
8
8
  * > (Names starting with an underscore are reserved for special keywords.)
9
9
  *
10
+ * @deprecated
11
+ *
10
12
  */
11
13
  export declare const isBrowserContextName: FormattedPrimitiveTypeCreator;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBrowserContextName = void 0;
4
1
  /**
5
2
  *
6
3
  * @see https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name
@@ -9,10 +6,11 @@ exports.isBrowserContextName = void 0;
9
6
  * > that does not start with a U+005F LOW LINE character.
10
7
  * > (Names starting with an underscore are reserved for special keywords.)
11
8
  *
9
+ * @deprecated
10
+ *
12
11
  */
13
- const isBrowserContextName = () => {
12
+ export const isBrowserContextName = () => {
14
13
  return value => {
15
14
  return !!value && value[0] !== '_';
16
15
  };
17
16
  };
18
- exports.isBrowserContextName = isBrowserContextName;
@@ -1,4 +1,4 @@
1
- import type { FormattedPrimitiveTypeCreator } from '../types';
1
+ import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
3
  * valid name of custom element
4
4
  *
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCustomElementName = void 0;
4
1
  /**
5
2
  * PotentialCustomElementName
6
3
  *
@@ -57,7 +54,7 @@ const rePCEN = new RegExp(`^[a-z](?:${rePCENChar})*\\-(?:${rePCENChar})*$`, 'i')
57
54
  * Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
58
55
  *
59
56
  */
60
- const isCustomElementName = () => {
57
+ export const isCustomElementName = () => {
61
58
  return tagName => {
62
59
  switch (tagName) {
63
60
  case 'annotation-xml':
@@ -74,4 +71,3 @@ const isCustomElementName = () => {
74
71
  return rePCEN.test(tagName);
75
72
  };
76
73
  };
77
- exports.isCustomElementName = isCustomElementName;
@@ -1,4 +1,4 @@
1
- import type { FormattedPrimitiveTypeCreator } from '../types';
1
+ import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
3
  *
4
4
  * @see https://html.spec.whatwg.org/multipage/microdata.html#defined-property-name
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isItempropName = void 0;
4
1
  /**
5
2
  *
6
3
  * @see https://html.spec.whatwg.org/multipage/microdata.html#defined-property-name
@@ -11,9 +8,8 @@ exports.isItempropName = void 0;
11
8
  * > ASCII whitespace are disallowed because otherwise the values would be parsed as multiple tokens.
12
9
  *
13
10
  */
14
- const isItempropName = () => {
11
+ export const isItempropName = () => {
15
12
  return value => {
16
- return value.indexOf(':') === -1 && value.indexOf('.') === -1 && value.indexOf(' ') === -1;
13
+ return !value.includes(':') && !value.includes('.') && !value.includes(' ');
17
14
  };
18
15
  };
19
- exports.isItempropName = isItempropName;
@@ -0,0 +1,11 @@
1
+ import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
+ /**
3
+ * @see https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name
4
+ *
5
+ * > A valid navigable target name is any string with at least one character
6
+ * > that does not contain both an ASCII tab or newline and a U+003C (<),
7
+ * > and it does not start with a U+005F (_).
8
+ * > (Names starting with a U+005F (_) are reserved for special keywords.)
9
+ *
10
+ */
11
+ export declare const isNavigableTargetName: FormattedPrimitiveTypeCreator;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @see https://infra.spec.whatwg.org/#ascii-tab-or-newline
3
+ *
4
+ * > An ASCII tab or newline is U+0009 TAB, U+000A LF, or U+000D CR.
5
+ */
6
+ const TAB_OR_NEWLINE = /[\t\n\r]/;
7
+ /**
8
+ * @see https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name
9
+ *
10
+ * > A valid navigable target name is any string with at least one character
11
+ * > that does not contain both an ASCII tab or newline and a U+003C (<),
12
+ * > and it does not start with a U+005F (_).
13
+ * > (Names starting with a U+005F (_) are reserved for special keywords.)
14
+ *
15
+ */
16
+ export const isNavigableTargetName = () => {
17
+ return value => {
18
+ return !!value && !TAB_OR_NEWLINE.test(value) && value[0] !== '_';
19
+ };
20
+ };