@markuplint/types 3.0.0-canary.5 → 3.0.0-dev.176

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 (110) hide show
  1. package/README.md +1 -1
  2. package/lib/check-multi-types.d.ts +4 -1
  3. package/lib/check-multi-types.js +5 -4
  4. package/lib/check.d.ts +6 -5
  5. package/lib/check.spec.js +64 -58
  6. package/lib/css-syntax.js +49 -47
  7. package/lib/css-syntax.spec.js +152 -149
  8. package/lib/defs.js +2 -2
  9. package/lib/enum.d.ts +2 -1
  10. package/lib/enum.js +1 -1
  11. package/lib/get-candidate.d.ts +4 -1
  12. package/lib/keyword-type.js +3 -2
  13. package/lib/list.d.ts +2 -1
  14. package/lib/list.js +2 -1
  15. package/lib/list.spec.js +118 -117
  16. package/lib/match-result.d.ts +21 -8
  17. package/lib/match-result.js +2 -1
  18. package/lib/number.d.ts +1 -1
  19. package/lib/primitive/index.spec.js +53 -52
  20. package/lib/primitive/is-quantity.d.ts +5 -1
  21. package/lib/primitive/is-uint.d.ts +6 -3
  22. package/lib/primitive/split-unit.d.ts +2 -2
  23. package/lib/primitive/split-unit.js +2 -2
  24. package/lib/rfc/is-bcp-47.spec.js +9 -8
  25. package/lib/token/token-collection.d.ts +71 -56
  26. package/lib/token/token-collection.js +30 -23
  27. package/lib/token/token-collection.spec.js +156 -134
  28. package/lib/token/token.d.ts +58 -52
  29. package/lib/token/token.js +19 -20
  30. package/lib/token/types.d.ts +3 -0
  31. package/lib/token/types.js +2 -0
  32. package/lib/types.d.ts +79 -55
  33. package/lib/types.schema.d.ts +1084 -31
  34. package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
  35. package/lib/whatwg/check-autocomplete.js +6 -6
  36. package/lib/whatwg/check-autocomplete.spec.js +361 -360
  37. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +21 -1
  38. package/lib/whatwg/check-datetime/datetime-tokens.js +9 -6
  39. package/lib/whatwg/check-datetime/duration-string.js +12 -2
  40. package/lib/whatwg/check-datetime/index.spec.js +277 -276
  41. package/lib/whatwg/check-datetime/local-date-and-time-string.js +6 -2
  42. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
  43. package/lib/whatwg/check-datetime/time-zone-offset-string.js +3 -2
  44. package/lib/whatwg/check-mime-type.d.ts +4 -4
  45. package/lib/whatwg/check-mime-type.js +1 -1
  46. package/lib/whatwg/check-mime-type.spec.js +53 -52
  47. package/lib/whatwg/is-abs-url.spec.js +6 -5
  48. package/lib/whatwg/is-itemprop-name.js +1 -1
  49. package/package.json +12 -10
  50. package/{src/check.spec.ts → test/check.spec.js} +7 -1
  51. package/{src/css-syntax.spec.ts → test/css-syntax.spec.js} +10 -12
  52. package/{src/list.spec.ts → test/list.spec.js} +7 -7
  53. package/{src/primitive/index.spec.ts → test/primitive/index.spec.js} +1 -1
  54. package/{src/rfc/is-bcp-47.spec.ts → test/rfc/is-bcp-47.spec.js} +1 -1
  55. package/{src/token/token-collection.spec.ts → test/token/token-collection.spec.js} +2 -3
  56. package/{src/w3c/check-serialized-permissions-policy.spec.ts → test/w3c/check-serialized-permissions-policy.spec.js} +1 -3
  57. package/{src/whatwg/check-autocomplete.spec.ts → test/whatwg/check-autocomplete.spec.js} +1 -1
  58. package/{src/whatwg/check-datetime/index.spec.ts → test/whatwg/check-datetime/index.spec.js} +18 -15
  59. package/{src/whatwg/check-mime-type.spec.ts → test/whatwg/check-mime-type.spec.js} +1 -1
  60. package/{src/whatwg/is-abs-url.spec.ts → test/whatwg/is-abs-url.spec.js} +1 -1
  61. package/types.schema.json +369 -318
  62. package/gen/specific-schema.json +0 -98
  63. package/gen/types.ts +0 -66
  64. package/src/check-multi-types.ts +0 -35
  65. package/src/check.ts +0 -48
  66. package/src/css-syntax.ts +0 -188
  67. package/src/debug.ts +0 -3
  68. package/src/defs.ts +0 -811
  69. package/src/enum.ts +0 -25
  70. package/src/get-candidate.ts +0 -24
  71. package/src/index.ts +0 -3
  72. package/src/keyword-type.ts +0 -64
  73. package/src/list.ts +0 -34
  74. package/src/match-result.ts +0 -49
  75. package/src/number.ts +0 -46
  76. package/src/primitive/index.ts +0 -7
  77. package/src/primitive/is-float.ts +0 -8
  78. package/src/primitive/is-int.ts +0 -8
  79. package/src/primitive/is-non-zero-uint.ts +0 -8
  80. package/src/primitive/is-quantity.ts +0 -38
  81. package/src/primitive/is-uint.ts +0 -15
  82. package/src/primitive/range.ts +0 -14
  83. package/src/primitive/split-unit.ts +0 -20
  84. package/src/rfc/is-bcp-47.ts +0 -13
  85. package/src/token/index.ts +0 -2
  86. package/src/token/token-collection.ts +0 -444
  87. package/src/token/token.ts +0 -144
  88. package/src/types.schema.ts +0 -1062
  89. package/src/types.ts +0 -118
  90. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  91. package/src/whatwg/check-autocomplete.ts +0 -380
  92. package/src/whatwg/check-datetime/date-string.ts +0 -44
  93. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  94. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  95. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  96. package/src/whatwg/check-datetime/index.ts +0 -36
  97. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  98. package/src/whatwg/check-datetime/month-string.ts +0 -31
  99. package/src/whatwg/check-datetime/time-string.ts +0 -49
  100. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  101. package/src/whatwg/check-datetime/week-string.ts +0 -41
  102. package/src/whatwg/check-datetime/year-string.ts +0 -26
  103. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  104. package/src/whatwg/check-mime-type.ts +0 -46
  105. package/src/whatwg/is-abs-url.ts +0 -31
  106. package/src/whatwg/is-browser-context-name.ts +0 -16
  107. package/src/whatwg/is-custom-element-name.ts +0 -76
  108. package/src/whatwg/is-itemprop-name.ts +0 -17
  109. package/tsconfig.test.json +0 -3
  110. package/tsconfig.tsbuildinfo +0 -1
@@ -1,3 +1,23 @@
1
1
  import type { TokenEachCheck } from '../../token/token-collection';
2
- export declare const datetimeTokenCheck: Record<'year' | 'month' | 'date' | 'hour' | 'minute' | 'second' | 'secondFractionalPart' | 'week' | 'hyphen' | 'colon' | 'extra' | 'colonOrEnd' | 'decimalPointOrEnd' | 'localDateTimeSeparator' | 'normalizedlocalDateTimeSeparator' | 'plusOrMinusSign' | 'weekSign', TokenEachCheck> & Record<'_year' | '_month', number | null>;
2
+ export declare const datetimeTokenCheck: Record<
3
+ | 'year'
4
+ | 'month'
5
+ | 'date'
6
+ | 'hour'
7
+ | 'minute'
8
+ | 'second'
9
+ | 'secondFractionalPart'
10
+ | 'week'
11
+ | 'hyphen'
12
+ | 'colon'
13
+ | 'extra'
14
+ | 'colonOrEnd'
15
+ | 'decimalPointOrEnd'
16
+ | 'localDateTimeSeparator'
17
+ | 'normalizedlocalDateTimeSeparator'
18
+ | 'plusOrMinusSign'
19
+ | 'weekSign',
20
+ TokenEachCheck
21
+ > &
22
+ Record<'_year' | '_month', number | null>;
3
23
  export declare function getMaxWeekNum(year: number): number;
@@ -95,6 +95,7 @@ exports.datetimeTokenCheck = {
95
95
  * > then the day can be 29, as if the year was a leap year.
96
96
  */
97
97
  date(date) {
98
+ var _a, _b, _c;
98
99
  (0, debug_1.log)('Parsing Datetime Date: "%s"', date === null || date === void 0 ? void 0 : date.value);
99
100
  if (!date || !date.value) {
100
101
  return (0, match_result_1.unmatched)('', 'missing-token', {
@@ -117,10 +118,10 @@ exports.datetimeTokenCheck = {
117
118
  });
118
119
  }
119
120
  // Set the leap year if _year is null
120
- const year = this._year || 2000;
121
+ const year = (_a = this._year) !== null && _a !== void 0 ? _a : 2000;
121
122
  const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
122
- const month = this._month || 1;
123
- const dayOfMonth = daysOfMonth[month] + (month === 2 && isLeap ? 1 : 0);
123
+ const month = (_b = this._month) !== null && _b !== void 0 ? _b : 1;
124
+ const dayOfMonth = ((_c = daysOfMonth[month]) !== null && _c !== void 0 ? _c : 0) + (month === 2 && isLeap ? 1 : 0);
124
125
  const _date = date.toNumber();
125
126
  (0, debug_1.log)('Temporary Year and Month: %s, %s', this._year, this._month);
126
127
  (0, debug_1.log)('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
@@ -264,6 +265,7 @@ exports.datetimeTokenCheck = {
264
265
  * > Two ASCII digits, representing the week week, in the range 1 ≤ week ≤ maxweek, where maxweek is the week number of the last day of week-year year
265
266
  */
266
267
  week(week) {
268
+ var _a;
267
269
  (0, debug_1.log)('Parsing Datetime Week: "%s"', week === null || week === void 0 ? void 0 : week.value);
268
270
  if (!week || !week.value) {
269
271
  return (0, match_result_1.unmatched)('', 'missing-token', {
@@ -285,7 +287,7 @@ exports.datetimeTokenCheck = {
285
287
  partName: 'week',
286
288
  });
287
289
  }
288
- const maxweek = getMaxWeekNum(this._year || 0);
290
+ const maxweek = getMaxWeekNum((_a = this._year) !== null && _a !== void 0 ? _a : 0);
289
291
  const _week = week.toNumber();
290
292
  if (!(1 <= _week && _week <= maxweek)) {
291
293
  return week.unmatched({
@@ -494,9 +496,10 @@ const daysOfMonth = [
494
496
  ];
495
497
  function getMaxWeekNum(year) {
496
498
  let date = 31;
497
- while (date) {
499
+ while (date > 0) {
498
500
  const d = new Date(Date.UTC(year, 11, date, 0, 0, 0, 0));
499
- d.setDate(d.getDate() + 4 - (d.getDay() || 7));
501
+ const day = d.getDay();
502
+ d.setDate(d.getDate() + 4 - (day > 0 ? day : 7));
500
503
  const yearStart = new Date(d.getFullYear(), 0, 1);
501
504
  const weekNo = Math.ceil(((d.valueOf() - yearStart.valueOf()) / 86400000 + 1) / 7);
502
505
  if (weekNo !== 1) {
@@ -41,6 +41,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
41
41
  return;
42
42
  }
43
43
  const [num, sign, extra] = token_1.TokenCollection.fromPatterns(d, [/[0-9]+/, /./]);
44
+ if (!num) {
45
+ return;
46
+ }
44
47
  (0, debug_1.log)('Date part: "%s" => %O', d.value, { num, sign });
45
48
  if (!num.match(/^[0-9]+$/)) {
46
49
  return num.unmatched({
@@ -81,6 +84,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
81
84
  });
82
85
  }
83
86
  }, time => {
87
+ var _a, _b, _c;
84
88
  if (!time) {
85
89
  return (0, match_result_1.unmatched)('', 'missing-token', {
86
90
  expects: [
@@ -101,7 +105,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
101
105
  ]);
102
106
  (0, debug_1.log)('Time part: "%s" => %O', timeTokens.value, timeTokens);
103
107
  const [h, m, s] = timeTokens;
104
- if (((h === null || h === void 0 ? void 0 : h.value) || '') + ((m === null || m === void 0 ? void 0 : m.value) || '') + ((s === null || s === void 0 ? void 0 : s.value) || '') === '') {
108
+ if (((_a = h === null || h === void 0 ? void 0 : h.value) !== null && _a !== void 0 ? _a : '') + ((_b = m === null || m === void 0 ? void 0 : m.value) !== null && _b !== void 0 ? _b : '') + ((_c = s === null || s === void 0 ? void 0 : s.value) !== null && _c !== void 0 ? _c : '') === '') {
105
109
  return (0, match_result_1.unmatched)('', 'missing-token', {
106
110
  expects: [
107
111
  { type: 'common', value: 'hour' },
@@ -112,7 +116,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
112
116
  }
113
117
  const specified = new Set();
114
118
  for (const t of timeTokens) {
115
- if (!t || !t.value) {
119
+ if (!t.value) {
116
120
  continue;
117
121
  }
118
122
  if (specified.has('S')) {
@@ -121,6 +125,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
121
125
  });
122
126
  }
123
127
  const [num, dpfp, sign] = token_1.TokenCollection.fromPatterns(t, [/[0-9]+/, /(\.[0-9]*)?/, /[^0-9]+/]);
128
+ if (!num) {
129
+ continue;
130
+ }
124
131
  (0, debug_1.log)('Time part (h|m|s): "%s" => %O', t.value, { num, dpfp, sign });
125
132
  if (!num.match(/^[0-9]+$/)) {
126
133
  return num.unmatched({
@@ -131,6 +138,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
131
138
  }
132
139
  if (dpfp && dpfp.value) {
133
140
  const [dp, fp] = token_1.TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
141
+ if (!dp) {
142
+ continue;
143
+ }
134
144
  (0, debug_1.log)('Second fractional part (h|m|s): "%s" => %O', dpfp.value, { dp, fp });
135
145
  if (!dp.match('.')) {
136
146
  return dp.unmatched({