@markuplint/types 3.0.0-canary.5 → 3.0.0-dev.177
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/README.md +1 -1
- package/lib/check-multi-types.d.ts +4 -1
- package/lib/check-multi-types.js +5 -4
- package/lib/check.d.ts +6 -5
- package/lib/check.spec.js +64 -58
- package/lib/css-syntax.js +49 -47
- package/lib/css-syntax.spec.js +152 -149
- package/lib/defs.js +2 -2
- package/lib/enum.d.ts +2 -1
- package/lib/enum.js +1 -1
- package/lib/get-candidate.d.ts +4 -1
- package/lib/keyword-type.js +3 -2
- package/lib/list.d.ts +2 -1
- package/lib/list.js +2 -1
- package/lib/list.spec.js +118 -117
- package/lib/match-result.d.ts +21 -8
- package/lib/match-result.js +2 -1
- package/lib/number.d.ts +1 -1
- package/lib/primitive/index.spec.js +53 -52
- package/lib/primitive/is-quantity.d.ts +5 -1
- package/lib/primitive/is-uint.d.ts +6 -3
- package/lib/primitive/split-unit.d.ts +2 -2
- package/lib/primitive/split-unit.js +2 -2
- package/lib/rfc/is-bcp-47.spec.js +9 -8
- package/lib/token/token-collection.d.ts +71 -56
- package/lib/token/token-collection.js +30 -23
- package/lib/token/token-collection.spec.js +156 -134
- package/lib/token/token.d.ts +58 -52
- package/lib/token/token.js +19 -20
- package/lib/token/types.d.ts +3 -0
- package/lib/token/types.js +2 -0
- package/lib/types.d.ts +79 -55
- package/lib/types.schema.d.ts +1084 -31
- package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
- package/lib/whatwg/check-autocomplete.js +6 -6
- package/lib/whatwg/check-autocomplete.spec.js +361 -360
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +21 -1
- package/lib/whatwg/check-datetime/datetime-tokens.js +9 -6
- package/lib/whatwg/check-datetime/duration-string.js +12 -2
- package/lib/whatwg/check-datetime/index.spec.js +277 -276
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +6 -2
- package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +3 -2
- package/lib/whatwg/check-mime-type.d.ts +4 -4
- package/lib/whatwg/check-mime-type.js +1 -1
- package/lib/whatwg/check-mime-type.spec.js +53 -52
- package/lib/whatwg/is-abs-url.spec.js +6 -5
- package/lib/whatwg/is-itemprop-name.js +1 -1
- package/package.json +12 -10
- package/{src/check.spec.ts → test/check.spec.js} +7 -1
- package/{src/css-syntax.spec.ts → test/css-syntax.spec.js} +10 -12
- package/{src/list.spec.ts → test/list.spec.js} +7 -7
- package/{src/primitive/index.spec.ts → test/primitive/index.spec.js} +1 -1
- package/{src/rfc/is-bcp-47.spec.ts → test/rfc/is-bcp-47.spec.js} +1 -1
- package/{src/token/token-collection.spec.ts → test/token/token-collection.spec.js} +2 -3
- package/{src/w3c/check-serialized-permissions-policy.spec.ts → test/w3c/check-serialized-permissions-policy.spec.js} +1 -3
- package/{src/whatwg/check-autocomplete.spec.ts → test/whatwg/check-autocomplete.spec.js} +1 -1
- package/{src/whatwg/check-datetime/index.spec.ts → test/whatwg/check-datetime/index.spec.js} +18 -15
- package/{src/whatwg/check-mime-type.spec.ts → test/whatwg/check-mime-type.spec.js} +1 -1
- package/{src/whatwg/is-abs-url.spec.ts → test/whatwg/is-abs-url.spec.js} +1 -1
- package/types.schema.json +369 -318
- package/gen/specific-schema.json +0 -98
- package/gen/types.ts +0 -66
- package/src/check-multi-types.ts +0 -35
- package/src/check.ts +0 -48
- package/src/css-syntax.ts +0 -188
- package/src/debug.ts +0 -3
- package/src/defs.ts +0 -811
- package/src/enum.ts +0 -25
- package/src/get-candidate.ts +0 -24
- package/src/index.ts +0 -3
- package/src/keyword-type.ts +0 -64
- package/src/list.ts +0 -34
- package/src/match-result.ts +0 -49
- package/src/number.ts +0 -46
- package/src/primitive/index.ts +0 -7
- package/src/primitive/is-float.ts +0 -8
- package/src/primitive/is-int.ts +0 -8
- package/src/primitive/is-non-zero-uint.ts +0 -8
- package/src/primitive/is-quantity.ts +0 -38
- package/src/primitive/is-uint.ts +0 -15
- package/src/primitive/range.ts +0 -14
- package/src/primitive/split-unit.ts +0 -20
- package/src/rfc/is-bcp-47.ts +0 -13
- package/src/token/index.ts +0 -2
- package/src/token/token-collection.ts +0 -444
- package/src/token/token.ts +0 -144
- package/src/types.schema.ts +0 -1062
- package/src/types.ts +0 -118
- package/src/w3c/check-serialized-permissions-policy.ts +0 -303
- package/src/whatwg/check-autocomplete.ts +0 -380
- package/src/whatwg/check-datetime/date-string.ts +0 -44
- package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
- package/src/whatwg/check-datetime/duration-string.ts +0 -399
- package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
- package/src/whatwg/check-datetime/index.ts +0 -36
- package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
- package/src/whatwg/check-datetime/month-string.ts +0 -31
- package/src/whatwg/check-datetime/time-string.ts +0 -49
- package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
- package/src/whatwg/check-datetime/week-string.ts +0 -41
- package/src/whatwg/check-datetime/year-string.ts +0 -26
- package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
- package/src/whatwg/check-mime-type.ts +0 -46
- package/src/whatwg/is-abs-url.ts +0 -31
- package/src/whatwg/is-browser-context-name.ts +0 -16
- package/src/whatwg/is-custom-element-name.ts +0 -76
- package/src/whatwg/is-itemprop-name.ts +0 -17
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
import type { TokenEachCheck } from '../../token/token-collection';
|
|
2
|
-
export declare const datetimeTokenCheck: Record<
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
|
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({
|