@markuplint/types 3.4.0 → 3.5.1
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/lib/check-multi-types.d.ts +1 -1
- package/lib/check-multi-types.js +5 -4
- package/lib/check.spec.js +5 -0
- package/lib/css-syntax.js +3 -2
- package/lib/defs.js +2 -2
- package/lib/get-candidate.d.ts +4 -1
- package/lib/keyword-type.js +3 -2
- package/lib/list.js +2 -1
- package/lib/match-result.d.ts +1 -1
- package/lib/match-result.js +2 -1
- 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/token/token-collection.d.ts +1 -1
- package/lib/token/token-collection.js +19 -16
- package/lib/token/token.d.ts +1 -1
- package/lib/token/token.js +6 -5
- package/lib/types.d.ts +79 -55
- package/lib/types.schema.d.ts +1084 -31
- package/lib/whatwg/check-autocomplete.js +2 -2
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +21 -1
- package/lib/whatwg/check-datetime/datetime-tokens.js +9 -7
- package/lib/whatwg/check-datetime/duration-string.js +3 -2
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +2 -2
- package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
- package/lib/whatwg/check-mime-type.d.ts +4 -4
- package/lib/whatwg/check-mime-type.js +1 -1
- package/lib/whatwg/is-itemprop-name.js +1 -1
- package/package.json +2 -2
|
@@ -285,7 +285,7 @@ const checkAutoComplete = () => value => {
|
|
|
285
285
|
const [prefix, namedGroupStr] = head.value.split('-');
|
|
286
286
|
const candidatePrefix = (0, get_candidate_1.getCandidate)(prefix, 'section');
|
|
287
287
|
if (candidatePrefix) {
|
|
288
|
-
candidate = `${candidatePrefix}-${namedGroupStr
|
|
288
|
+
candidate = `${candidatePrefix}-${namedGroupStr !== null && namedGroupStr !== void 0 ? namedGroupStr : ''}`;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
else if (!hasPartOfAddress) {
|
|
@@ -305,7 +305,7 @@ const checkAutoComplete = () => value => {
|
|
|
305
305
|
})));
|
|
306
306
|
candidate = (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
|
|
307
307
|
}
|
|
308
|
-
candidate = candidate
|
|
308
|
+
candidate = candidate !== null && candidate !== void 0 ? candidate : (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames);
|
|
309
309
|
if (candidate) {
|
|
310
310
|
acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value, candidate);
|
|
311
311
|
}
|
|
@@ -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,7 +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;
|
|
98
|
+
var _a, _b, _c;
|
|
99
99
|
(0, debug_1.log)('Parsing Datetime Date: "%s"', date === null || date === void 0 ? void 0 : date.value);
|
|
100
100
|
if (!date || !date.value) {
|
|
101
101
|
return (0, match_result_1.unmatched)('', 'missing-token', {
|
|
@@ -118,10 +118,10 @@ exports.datetimeTokenCheck = {
|
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
// Set the leap year if _year is null
|
|
121
|
-
const year = this._year
|
|
121
|
+
const year = (_a = this._year) !== null && _a !== void 0 ? _a : 2000;
|
|
122
122
|
const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
123
|
-
const month = this._month
|
|
124
|
-
const dayOfMonth = ((
|
|
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);
|
|
125
125
|
const _date = date.toNumber();
|
|
126
126
|
(0, debug_1.log)('Temporary Year and Month: %s, %s', this._year, this._month);
|
|
127
127
|
(0, debug_1.log)('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
|
|
@@ -265,6 +265,7 @@ exports.datetimeTokenCheck = {
|
|
|
265
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
|
|
266
266
|
*/
|
|
267
267
|
week(week) {
|
|
268
|
+
var _a;
|
|
268
269
|
(0, debug_1.log)('Parsing Datetime Week: "%s"', week === null || week === void 0 ? void 0 : week.value);
|
|
269
270
|
if (!week || !week.value) {
|
|
270
271
|
return (0, match_result_1.unmatched)('', 'missing-token', {
|
|
@@ -286,7 +287,7 @@ exports.datetimeTokenCheck = {
|
|
|
286
287
|
partName: 'week',
|
|
287
288
|
});
|
|
288
289
|
}
|
|
289
|
-
const maxweek = getMaxWeekNum(this._year
|
|
290
|
+
const maxweek = getMaxWeekNum((_a = this._year) !== null && _a !== void 0 ? _a : 0);
|
|
290
291
|
const _week = week.toNumber();
|
|
291
292
|
if (!(1 <= _week && _week <= maxweek)) {
|
|
292
293
|
return week.unmatched({
|
|
@@ -495,9 +496,10 @@ const daysOfMonth = [
|
|
|
495
496
|
];
|
|
496
497
|
function getMaxWeekNum(year) {
|
|
497
498
|
let date = 31;
|
|
498
|
-
while (date) {
|
|
499
|
+
while (date > 0) {
|
|
499
500
|
const d = new Date(Date.UTC(year, 11, date, 0, 0, 0, 0));
|
|
500
|
-
|
|
501
|
+
const day = d.getDay();
|
|
502
|
+
d.setDate(d.getDate() + 4 - (day > 0 ? day : 7));
|
|
501
503
|
const yearStart = new Date(d.getFullYear(), 0, 1);
|
|
502
504
|
const weekNo = Math.ceil(((d.valueOf() - yearStart.valueOf()) / 86400000 + 1) / 7);
|
|
503
505
|
if (weekNo !== 1) {
|
|
@@ -84,6 +84,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
}, time => {
|
|
87
|
+
var _a, _b, _c;
|
|
87
88
|
if (!time) {
|
|
88
89
|
return (0, match_result_1.unmatched)('', 'missing-token', {
|
|
89
90
|
expects: [
|
|
@@ -104,7 +105,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
|
|
|
104
105
|
]);
|
|
105
106
|
(0, debug_1.log)('Time part: "%s" => %O', timeTokens.value, timeTokens);
|
|
106
107
|
const [h, m, s] = timeTokens;
|
|
107
|
-
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 : '') === '') {
|
|
108
109
|
return (0, match_result_1.unmatched)('', 'missing-token', {
|
|
109
110
|
expects: [
|
|
110
111
|
{ type: 'common', value: 'hour' },
|
|
@@ -115,7 +116,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
|
|
|
115
116
|
}
|
|
116
117
|
const specified = new Set();
|
|
117
118
|
for (const t of timeTokens) {
|
|
118
|
-
if (!t
|
|
119
|
+
if (!t.value) {
|
|
119
120
|
continue;
|
|
120
121
|
}
|
|
121
122
|
if (specified.has('S')) {
|
|
@@ -95,8 +95,8 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
|
|
|
95
95
|
(0, debug_1.log)('Failed: %O', res);
|
|
96
96
|
return res;
|
|
97
97
|
}
|
|
98
|
-
const _second = second.toNumber()
|
|
99
|
-
const _fp = fp.toNumber()
|
|
98
|
+
const _second = second.toNumber();
|
|
99
|
+
const _fp = fp.toNumber();
|
|
100
100
|
(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);
|
|
101
101
|
if (second.value && _second === 0 && (!fp.value || (fp.value && _fp === 0))) {
|
|
102
102
|
const res = second.unmatched({
|
|
@@ -4,4 +4,4 @@ import type { CustomSyntaxChecker } from '../../types';
|
|
|
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 | Readonly<Token>): import(
|
|
7
|
+
export declare function parseTimeZone(zone: string | Readonly<Token>): import('../../types').Result;
|
|
@@ -4,8 +4,8 @@ import type { CustomSyntaxChecker } from '../types';
|
|
|
4
4
|
* @see https://mimesniff.spec.whatwg.org/#valid-mime-type
|
|
5
5
|
*/
|
|
6
6
|
export declare const checkMIMEType: CustomSyntaxChecker<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
|
|
9
|
+
*/
|
|
10
|
+
withoutParameters?: boolean;
|
|
11
11
|
}>;
|
|
@@ -27,7 +27,7 @@ const checkMIMEType = options => value => {
|
|
|
27
27
|
if (value.toLowerCase() === mimeType.essence) {
|
|
28
28
|
return (0, match_result_1.matched)();
|
|
29
29
|
}
|
|
30
|
-
if (!withoutParameters && mimeType.parameters.size) {
|
|
30
|
+
if (!withoutParameters && mimeType.parameters.size > 0) {
|
|
31
31
|
return (0, match_result_1.matched)();
|
|
32
32
|
}
|
|
33
33
|
const extraToken = value.slice(mimeType.essence.length);
|
|
@@ -13,7 +13,7 @@ exports.isItempropName = void 0;
|
|
|
13
13
|
*/
|
|
14
14
|
const isItempropName = () => {
|
|
15
15
|
return value => {
|
|
16
|
-
return value.
|
|
16
|
+
return !value.includes(':') && !value.includes('.') && !value.includes(' ');
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
exports.isItempropName = isItempropName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Type declaration and value checker",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"@types/whatwg-mimetype": "2",
|
|
34
34
|
"type-fest": "^3.6.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "3cdf5a088b2da03773d5d4461d0e65ec32290a00"
|
|
37
37
|
}
|