@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,31 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
2
|
-
|
|
3
|
-
import { log } from '../../debug';
|
|
4
|
-
import { TokenCollection } from '../../token';
|
|
5
|
-
|
|
6
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-month-string
|
|
10
|
-
*/
|
|
11
|
-
export const checkMonthString: CustomSyntaxChecker = () =>
|
|
12
|
-
function checkMonthString(value) {
|
|
13
|
-
log('CHECK: month-string');
|
|
14
|
-
|
|
15
|
-
const tokens = TokenCollection.fromPatterns(value, [/[^-]*/, /[^0-9]?/, /.[0-9]*/]);
|
|
16
|
-
|
|
17
|
-
log('Month: "%s" => %O', tokens.value, tokens);
|
|
18
|
-
|
|
19
|
-
const res = tokens.eachCheck(
|
|
20
|
-
datetimeTokenCheck.year,
|
|
21
|
-
datetimeTokenCheck.hyphen,
|
|
22
|
-
datetimeTokenCheck.month,
|
|
23
|
-
datetimeTokenCheck.extra,
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (!res.matched) {
|
|
27
|
-
log('Failed: %O', res);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return res;
|
|
31
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
2
|
-
|
|
3
|
-
import { log } from '../../debug';
|
|
4
|
-
import { TokenCollection } from '../../token';
|
|
5
|
-
|
|
6
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
|
|
10
|
-
*/
|
|
11
|
-
export const checkTimeString: CustomSyntaxChecker = () =>
|
|
12
|
-
function checkTimeString(value) {
|
|
13
|
-
log('CHECK: time-string');
|
|
14
|
-
|
|
15
|
-
const tokens = TokenCollection.fromPatterns(value, [
|
|
16
|
-
// hh
|
|
17
|
-
/[^:]*/,
|
|
18
|
-
// :
|
|
19
|
-
/[^0-9]?/,
|
|
20
|
-
// mm
|
|
21
|
-
/[^:]*/,
|
|
22
|
-
// :
|
|
23
|
-
/[^0-9]?/,
|
|
24
|
-
// ss
|
|
25
|
-
/[^.]*/,
|
|
26
|
-
// .
|
|
27
|
-
/[^0-9]?/,
|
|
28
|
-
// sss
|
|
29
|
-
/.[0-9]*/,
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
log('Time: "%s" => %O', tokens.value, tokens);
|
|
33
|
-
|
|
34
|
-
const res = tokens.eachCheck(
|
|
35
|
-
datetimeTokenCheck.hour,
|
|
36
|
-
datetimeTokenCheck.colon,
|
|
37
|
-
datetimeTokenCheck.minute,
|
|
38
|
-
datetimeTokenCheck.colonOrEnd,
|
|
39
|
-
datetimeTokenCheck.second,
|
|
40
|
-
datetimeTokenCheck.decimalPointOrEnd,
|
|
41
|
-
datetimeTokenCheck.secondFractionalPart,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (!res.matched) {
|
|
45
|
-
log('Failed: %O', res);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return res;
|
|
49
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { Token } from '../../token';
|
|
2
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
3
|
-
|
|
4
|
-
import { log } from '../../debug';
|
|
5
|
-
import { matched, unmatched } from '../../match-result';
|
|
6
|
-
import { TokenCollection } from '../../token';
|
|
7
|
-
|
|
8
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
|
|
12
|
-
*/
|
|
13
|
-
export const checkTimeZoneOffsetString: CustomSyntaxChecker = () =>
|
|
14
|
-
function checkTimeZoneOffsetString(value) {
|
|
15
|
-
log('CHECK: time-zone-offset-string');
|
|
16
|
-
|
|
17
|
-
return parseTimeZone(value);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function parseTimeZone(zone: string | Token) {
|
|
21
|
-
const value = typeof zone === 'string' ? zone : zone.value;
|
|
22
|
-
|
|
23
|
-
const zoneTokens = TokenCollection.fromPatterns(zone, [
|
|
24
|
-
// Z + -
|
|
25
|
-
/[^0-9]?/,
|
|
26
|
-
// hh
|
|
27
|
-
/[^:]{0,2}/,
|
|
28
|
-
// :
|
|
29
|
-
/[^0-9]?/,
|
|
30
|
-
// mm
|
|
31
|
-
/.[0-9]*/,
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
log('Time-zone Part: "%s" => %O', value, zoneTokens);
|
|
35
|
-
|
|
36
|
-
const res = zoneTokens.eachCheck(
|
|
37
|
-
(sign, tail) => {
|
|
38
|
-
if (!sign || !sign.value) {
|
|
39
|
-
return unmatched(value, 'missing-token', {
|
|
40
|
-
expects: [
|
|
41
|
-
{ type: 'const', value: 'Z' },
|
|
42
|
-
{ type: 'const', value: '+' },
|
|
43
|
-
{ type: 'const', value: '-' },
|
|
44
|
-
],
|
|
45
|
-
partName: 'time-zone',
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (sign.match('Z')) {
|
|
50
|
-
if (tail.value) {
|
|
51
|
-
return tail[0].unmatched({
|
|
52
|
-
reason: 'extra-token',
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return matched();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!sign.match(['+', '-'])) {
|
|
60
|
-
return sign.unmatched({
|
|
61
|
-
reason: 'unexpected-token',
|
|
62
|
-
expects: [
|
|
63
|
-
{ type: 'const', value: '+' },
|
|
64
|
-
{ type: 'const', value: '-' },
|
|
65
|
-
],
|
|
66
|
-
partName: 'time-zone',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
datetimeTokenCheck.hour,
|
|
71
|
-
colon => {
|
|
72
|
-
if (!colon || !colon.value) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!colon.match(':')) {
|
|
77
|
-
return colon.unmatched({
|
|
78
|
-
reason: 'unexpected-token',
|
|
79
|
-
expects: [{ type: 'const', value: ':' }],
|
|
80
|
-
partName: 'time-zone',
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
datetimeTokenCheck.minute,
|
|
85
|
-
datetimeTokenCheck.extra,
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
if (!res.matched) {
|
|
89
|
-
log('Failed: %O', res);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return res;
|
|
93
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
2
|
-
|
|
3
|
-
import { log } from '../../debug';
|
|
4
|
-
import { TokenCollection } from '../../token';
|
|
5
|
-
|
|
6
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
|
|
10
|
-
*/
|
|
11
|
-
export const checkWeekString: CustomSyntaxChecker = () =>
|
|
12
|
-
function checkWeekString(value) {
|
|
13
|
-
log('CHECK: week-string');
|
|
14
|
-
|
|
15
|
-
const tokens = TokenCollection.fromPatterns(value, [
|
|
16
|
-
// YYYY
|
|
17
|
-
/[^-]+/,
|
|
18
|
-
// -
|
|
19
|
-
/[^W]?/,
|
|
20
|
-
// W
|
|
21
|
-
/[^0-9]?/,
|
|
22
|
-
// ww
|
|
23
|
-
/.[0-9]*/,
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
log('Week: "%s" => %O', tokens.value, tokens);
|
|
27
|
-
|
|
28
|
-
const res = tokens.eachCheck(
|
|
29
|
-
datetimeTokenCheck.year,
|
|
30
|
-
datetimeTokenCheck.hyphen,
|
|
31
|
-
datetimeTokenCheck.weekSign,
|
|
32
|
-
datetimeTokenCheck.week,
|
|
33
|
-
datetimeTokenCheck.extra,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (!res.matched) {
|
|
37
|
-
log('Failed: %O', res);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return res;
|
|
41
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
2
|
-
|
|
3
|
-
import { log } from '../../debug';
|
|
4
|
-
import { TokenCollection } from '../../token';
|
|
5
|
-
|
|
6
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html
|
|
10
|
-
*/
|
|
11
|
-
export const checkYearString: CustomSyntaxChecker = () =>
|
|
12
|
-
function checkYearString(value) {
|
|
13
|
-
log('CHECK: year-string');
|
|
14
|
-
|
|
15
|
-
const tokens = TokenCollection.fromPatterns(value, [/.*/]);
|
|
16
|
-
|
|
17
|
-
log('Year: "%s" => %O', tokens.value, tokens);
|
|
18
|
-
|
|
19
|
-
const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.extra);
|
|
20
|
-
|
|
21
|
-
if (!res.matched) {
|
|
22
|
-
log('Failed: %O', res);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return res;
|
|
26
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../../types';
|
|
2
|
-
|
|
3
|
-
import { log } from '../../debug';
|
|
4
|
-
import { TokenCollection } from '../../token';
|
|
5
|
-
|
|
6
|
-
import { datetimeTokenCheck } from './datetime-tokens';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#yearless-dates
|
|
10
|
-
*/
|
|
11
|
-
export const checkYearlessDateString: CustomSyntaxChecker = () =>
|
|
12
|
-
function checkYearlessDateString(value) {
|
|
13
|
-
log('CHECK: yearless-date-string');
|
|
14
|
-
|
|
15
|
-
const tokens = TokenCollection.fromPatterns(value, [
|
|
16
|
-
// MM
|
|
17
|
-
/[^-]*/,
|
|
18
|
-
// -
|
|
19
|
-
/[^0-9]?/,
|
|
20
|
-
// DD
|
|
21
|
-
/.[0-9]*/,
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
log('Yearless Date: "%s" => %O', tokens.value, tokens);
|
|
25
|
-
|
|
26
|
-
const res = tokens.eachCheck(
|
|
27
|
-
datetimeTokenCheck.month,
|
|
28
|
-
datetimeTokenCheck.hyphen,
|
|
29
|
-
datetimeTokenCheck.date,
|
|
30
|
-
datetimeTokenCheck.extra,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
if (!res.matched) {
|
|
34
|
-
log('Failed: %O', res);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return res;
|
|
38
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxChecker } from '../types';
|
|
2
|
-
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import MIMEType from 'whatwg-mimetype';
|
|
5
|
-
|
|
6
|
-
import { matched, unmatched } from '../match-result';
|
|
7
|
-
import { Token } from '../token';
|
|
8
|
-
|
|
9
|
-
const expects = (withoutParameters: boolean) => [
|
|
10
|
-
{
|
|
11
|
-
type: 'format' as const,
|
|
12
|
-
value: withoutParameters ? 'MIME Type with no parameters' : 'MIME Type',
|
|
13
|
-
},
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* MIME Type
|
|
18
|
-
* @see https://mimesniff.spec.whatwg.org/#valid-mime-type
|
|
19
|
-
*/
|
|
20
|
-
export const checkMIMEType: CustomSyntaxChecker<{
|
|
21
|
-
/**
|
|
22
|
-
* @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
|
|
23
|
-
*/
|
|
24
|
-
withoutParameters?: boolean;
|
|
25
|
-
}> = options => value => {
|
|
26
|
-
const withoutParameters = options?.withoutParameters ?? false;
|
|
27
|
-
if (!value) {
|
|
28
|
-
return unmatched(value, 'empty-token', { expects: expects(withoutParameters) });
|
|
29
|
-
}
|
|
30
|
-
const mimeType = MIMEType.parse(value);
|
|
31
|
-
if (mimeType) {
|
|
32
|
-
if (value.toLowerCase() === mimeType.essence) {
|
|
33
|
-
return matched();
|
|
34
|
-
}
|
|
35
|
-
if (!withoutParameters && mimeType.parameters.size) {
|
|
36
|
-
return matched();
|
|
37
|
-
}
|
|
38
|
-
const extraToken = value.slice(mimeType.essence.length);
|
|
39
|
-
return new Token(extraToken, mimeType.essence.length, value).unmatched({
|
|
40
|
-
reason: 'extra-token',
|
|
41
|
-
expects: expects(withoutParameters),
|
|
42
|
-
candidate: mimeType.essence,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return unmatched(value, 'syntax-error', { expects: expects(withoutParameters) });
|
|
46
|
-
};
|
package/src/whatwg/is-abs-url.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { FormattedPrimitiveTypeCreator } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://url.spec.whatwg.org/#syntax-url-absolute
|
|
5
|
-
*
|
|
6
|
-
* > An absolute-URL string must be one of the following:
|
|
7
|
-
* > - a URL-scheme string that is an ASCII case-insensitive match
|
|
8
|
-
* > for a special scheme and not an ASCII case-insensitive match for "file",
|
|
9
|
-
* > followed by U+003A (:) and a scheme-relative-special-URL string
|
|
10
|
-
* > - a URL-scheme string that is not an ASCII case-insensitive match
|
|
11
|
-
* > for a special scheme, followed by U+003A (:) and a relative-URL string
|
|
12
|
-
* > - a URL-scheme string that is an ASCII case-insensitive match for "file",
|
|
13
|
-
* > followed by U+003A (:) and a scheme-relative-file-URL string
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export const isAbsURL: FormattedPrimitiveTypeCreator = () => {
|
|
17
|
-
return value => {
|
|
18
|
-
try {
|
|
19
|
-
new URL(value);
|
|
20
|
-
} catch (e: unknown) {
|
|
21
|
-
if (e && typeof e === 'object' && 'code' in e) {
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
if (e.code === 'ERR_INVALID_URL') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
throw e;
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FormattedPrimitiveTypeCreator } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @see https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name
|
|
6
|
-
*
|
|
7
|
-
* > A valid browsing context name is any string with at least one character
|
|
8
|
-
* > that does not start with a U+005F LOW LINE character.
|
|
9
|
-
* > (Names starting with an underscore are reserved for special keywords.)
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export const isBrowserContextName: FormattedPrimitiveTypeCreator = () => {
|
|
13
|
-
return value => {
|
|
14
|
-
return !!value && value[0] !== '_';
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { FormattedPrimitiveTypeCreator } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* PotentialCustomElementName
|
|
5
|
-
*
|
|
6
|
-
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname
|
|
7
|
-
*
|
|
8
|
-
* > PotentialCustomElementName ::=
|
|
9
|
-
* > [a-z] (PCENChar)* '-' (PCENChar)*
|
|
10
|
-
* > PCENChar ::=
|
|
11
|
-
* > "-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
12
|
-
* > [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
13
|
-
* > This uses the EBNF notation from the XML specification. [XML]
|
|
14
|
-
*
|
|
15
|
-
* ASCII-case-insensitively.
|
|
16
|
-
* 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.
|
|
17
|
-
*/
|
|
18
|
-
const rePCENChar = [
|
|
19
|
-
'\\-',
|
|
20
|
-
'\\.',
|
|
21
|
-
'[0-9]',
|
|
22
|
-
'_',
|
|
23
|
-
'[a-z]',
|
|
24
|
-
'\u00B7',
|
|
25
|
-
'[\u00C0-\u00D6]',
|
|
26
|
-
'[\u00D8-\u00F6]',
|
|
27
|
-
'[\u00F8-\u037D]',
|
|
28
|
-
'[\u037F-\u1FFF]',
|
|
29
|
-
'[\u200C-\u200D]',
|
|
30
|
-
'[\u203F-\u2040]',
|
|
31
|
-
'[\u2070-\u218F]',
|
|
32
|
-
'[\u2C00-\u2FEF]',
|
|
33
|
-
'[\u3001-\uD7FF]',
|
|
34
|
-
'[\uF900-\uFDCF]',
|
|
35
|
-
'[\uFDF0-\uFFFD]',
|
|
36
|
-
'[\uD800-\uDBFF][\uDC00-\uDFFF]',
|
|
37
|
-
].join('|');
|
|
38
|
-
const rePCEN = new RegExp(`^[a-z](?:${rePCENChar})*\\-(?:${rePCENChar})*$`, 'i');
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* valid name of custom element
|
|
42
|
-
*
|
|
43
|
-
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
44
|
-
*
|
|
45
|
-
* > - name must match the [PotentialCustomElementName](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname) production
|
|
46
|
-
* > - name must not be any of the following:
|
|
47
|
-
* > - `<annotation-xml>`
|
|
48
|
-
* > - `<color-profile>`
|
|
49
|
-
* > - `<font-face>`
|
|
50
|
-
* > - `<font-face-src>`
|
|
51
|
-
* > - `<font-face-uri>`
|
|
52
|
-
* > - `<font-face-format>`
|
|
53
|
-
* > - `<font-face-name>`
|
|
54
|
-
* > - `<missing-glyph>`
|
|
55
|
-
*
|
|
56
|
-
* ASCII-case-insensitively.
|
|
57
|
-
* 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
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
export const isCustomElementName: FormattedPrimitiveTypeCreator = () => {
|
|
61
|
-
return tagName => {
|
|
62
|
-
switch (tagName) {
|
|
63
|
-
case 'annotation-xml':
|
|
64
|
-
case 'color-profile':
|
|
65
|
-
case 'font-face':
|
|
66
|
-
case 'font-face-src':
|
|
67
|
-
case 'font-face-uri':
|
|
68
|
-
case 'font-face-format':
|
|
69
|
-
case 'font-face-name':
|
|
70
|
-
case 'missing-glyph': {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return rePCEN.test(tagName);
|
|
75
|
-
};
|
|
76
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { FormattedPrimitiveTypeCreator } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @see https://html.spec.whatwg.org/multipage/microdata.html#defined-property-name
|
|
6
|
-
*
|
|
7
|
-
* > The rules above disallow U+003A COLON characters (:) in non-URL values
|
|
8
|
-
* > because otherwise they could not be distinguished from URLs.
|
|
9
|
-
* > Values with U+002E FULL STOP characters (.) are reserved for future extensions.
|
|
10
|
-
* > ASCII whitespace are disallowed because otherwise the values would be parsed as multiple tokens.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export const isItempropName: FormattedPrimitiveTypeCreator = () => {
|
|
14
|
-
return value => {
|
|
15
|
-
return value.indexOf(':') === -1 && value.indexOf('.') === -1 && value.indexOf(' ') === -1;
|
|
16
|
-
};
|
|
17
|
-
};
|
package/tsconfig.test.json
DELETED