@markuplint/types 4.0.0-alpha.1 → 4.0.0-alpha.10
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/LICENSE +1 -1
- package/README.md +63 -61
- package/lib/css-syntax.js +16 -11
- package/lib/defs.d.ts +1 -0
- package/lib/defs.js +172 -52
- package/lib/enum.js +1 -1
- package/lib/get-candidate.js +2 -2
- package/lib/keyword-type.js +3 -3
- package/lib/number.d.ts +2 -2
- package/lib/number.js +2 -2
- package/lib/primitive/is-float.js +1 -1
- package/lib/primitive/is-int.js +1 -1
- package/lib/primitive/is-non-zero-uint.js +1 -1
- package/lib/primitive/is-uint.js +3 -3
- package/lib/primitive/range.js +2 -2
- package/lib/primitive/split-unit.js +1 -1
- package/lib/token/token-collection.d.ts +4 -5
- package/lib/token/token-collection.js +23 -18
- package/lib/token/token.d.ts +1 -1
- package/lib/token/token.js +9 -8
- package/lib/types.d.ts +1 -0
- package/lib/types.schema.d.ts +1 -1
- package/lib/w3c/check-serialized-permissions-policy.js +5 -5
- package/lib/whatwg/check-autocomplete.js +10 -13
- package/lib/whatwg/check-datetime/date-string.js +3 -3
- package/lib/whatwg/check-datetime/datetime-tokens.js +18 -18
- package/lib/whatwg/check-datetime/duration-string.js +30 -29
- package/lib/whatwg/check-datetime/global-date-and-time-string.js +8 -8
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +17 -16
- package/lib/whatwg/check-datetime/month-string.js +1 -1
- package/lib/whatwg/check-datetime/time-string.js +4 -4
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +6 -6
- package/lib/whatwg/check-datetime/week-string.js +2 -2
- package/lib/whatwg/check-datetime/yearless-date-string.js +2 -2
- package/lib/whatwg/is-abs-url.js +7 -7
- package/lib/whatwg/is-browser-context-name.d.ts +2 -0
- package/lib/whatwg/is-browser-context-name.js +2 -0
- package/lib/whatwg/is-custom-element-name.d.ts +9 -4
- package/lib/whatwg/is-custom-element-name.js +21 -33
- package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
- package/lib/whatwg/is-navigable-target-name.js +20 -0
- package/package.json +12 -9
- package/types.schema.json +3 -0
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PCENChar
|
|
3
3
|
*
|
|
4
|
+
* > PCENChar ::=
|
|
5
|
+
* > "-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
6
|
+
* > [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
4
7
|
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname
|
|
5
8
|
*
|
|
9
|
+
*/
|
|
10
|
+
const onlyPCENChar =
|
|
11
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
12
|
+
/^[-.\d_a-z\u00B7\u00C0-\u00D6[\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u;
|
|
13
|
+
/**
|
|
14
|
+
* valid name of custom element
|
|
15
|
+
*
|
|
6
16
|
* > PotentialCustomElementName ::=
|
|
7
17
|
* > [a-z] (PCENChar)* '-' (PCENChar)*
|
|
8
18
|
* > PCENChar ::=
|
|
@@ -10,34 +20,7 @@
|
|
|
10
20
|
* > [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
11
21
|
* > This uses the EBNF notation from the XML specification. [XML]
|
|
12
22
|
*
|
|
13
|
-
* ASCII
|
|
14
|
-
* 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.
|
|
15
|
-
*/
|
|
16
|
-
const rePCENChar = [
|
|
17
|
-
'\\-',
|
|
18
|
-
'\\.',
|
|
19
|
-
'[0-9]',
|
|
20
|
-
'_',
|
|
21
|
-
'[a-z]',
|
|
22
|
-
'\u00B7',
|
|
23
|
-
'[\u00C0-\u00D6]',
|
|
24
|
-
'[\u00D8-\u00F6]',
|
|
25
|
-
'[\u00F8-\u037D]',
|
|
26
|
-
'[\u037F-\u1FFF]',
|
|
27
|
-
'[\u200C-\u200D]',
|
|
28
|
-
'[\u203F-\u2040]',
|
|
29
|
-
'[\u2070-\u218F]',
|
|
30
|
-
'[\u2C00-\u2FEF]',
|
|
31
|
-
'[\u3001-\uD7FF]',
|
|
32
|
-
'[\uF900-\uFDCF]',
|
|
33
|
-
'[\uFDF0-\uFFFD]',
|
|
34
|
-
'[\uD800-\uDBFF][\uDC00-\uDFFF]',
|
|
35
|
-
].join('|');
|
|
36
|
-
const rePCEN = new RegExp(`^[a-z](?:${rePCENChar})*\\-(?:${rePCENChar})*$`, 'i');
|
|
37
|
-
/**
|
|
38
|
-
* valid name of custom element
|
|
39
|
-
*
|
|
40
|
-
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
23
|
+
* > They start with an ASCII lower alpha, ensuring that the HTML parser will treat them as tags instead of as text.
|
|
41
24
|
*
|
|
42
25
|
* > - name must match the [PotentialCustomElementName](https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname) production
|
|
43
26
|
* > - name must not be any of the following:
|
|
@@ -50,9 +33,7 @@ const rePCEN = new RegExp(`^[a-z](?:${rePCENChar})*\\-(?:${rePCENChar})*$`, 'i')
|
|
|
50
33
|
* > - `<font-face-name>`
|
|
51
34
|
* > - `<missing-glyph>`
|
|
52
35
|
*
|
|
53
|
-
*
|
|
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.
|
|
55
|
-
*
|
|
36
|
+
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
56
37
|
*/
|
|
57
38
|
export const isCustomElementName = () => {
|
|
58
39
|
return tagName => {
|
|
@@ -68,6 +49,13 @@ export const isCustomElementName = () => {
|
|
|
68
49
|
return false;
|
|
69
50
|
}
|
|
70
51
|
}
|
|
71
|
-
|
|
52
|
+
// First char must be ASCII lowercase alpha.
|
|
53
|
+
if (!/^[a-z]/.test(tagName)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (!tagName.includes('-')) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return onlyPCENChar.test(tagName);
|
|
72
60
|
};
|
|
73
61
|
};
|
|
@@ -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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/types",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.10",
|
|
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>",
|
|
@@ -22,19 +22,22 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
24
24
|
"clean": "tsc --build --clean",
|
|
25
|
-
"schema": "
|
|
25
|
+
"schema": "run-s schema:types schema:schema build schema:prettier schema:eslint schema:prettier",
|
|
26
|
+
"schema:types": "node --loader ts-node/esm \"./gen/types.ts\"",
|
|
27
|
+
"schema:schema": "json2ts \"./types.schema.json\" > \"./src/types.schema.ts\"",
|
|
28
|
+
"schema:eslint": "eslint --fix \"./src/types.schema.ts\"",
|
|
29
|
+
"schema:prettier": "prettier --write \"./src/types.schema.ts\" \"./types.schema.json\" --log-level warn"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@types/
|
|
29
|
-
"@types/
|
|
30
|
-
"@types/
|
|
31
|
-
"@types/whatwg-mimetype": "3.0.0",
|
|
32
|
+
"@types/css-tree": "^2.3.4",
|
|
33
|
+
"@types/debug": "^4.1.12",
|
|
34
|
+
"@types/whatwg-mimetype": "3.0.2",
|
|
32
35
|
"bcp-47": "^2.1.0",
|
|
33
36
|
"css-tree": "^2.3.1",
|
|
34
37
|
"debug": "^4.3.4",
|
|
35
38
|
"leven": "^4.0.0",
|
|
36
|
-
"type-fest": "^4.1
|
|
37
|
-
"whatwg-mimetype": "^
|
|
39
|
+
"type-fest": "^4.10.1",
|
|
40
|
+
"whatwg-mimetype": "^4.0.0"
|
|
38
41
|
},
|
|
39
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "b41153ea665aa8f091daf6114a06047f4ccb8350"
|
|
40
43
|
}
|
package/types.schema.json
CHANGED
|
@@ -1037,6 +1037,7 @@
|
|
|
1037
1037
|
"Any",
|
|
1038
1038
|
"AutoComplete",
|
|
1039
1039
|
"BCP47",
|
|
1040
|
+
"BaseURL",
|
|
1040
1041
|
"BrowsingContextName",
|
|
1041
1042
|
"BrowsingContextNameOrKeyword",
|
|
1042
1043
|
"CustomElementName",
|
|
@@ -1049,6 +1050,8 @@
|
|
|
1049
1050
|
"Int",
|
|
1050
1051
|
"ItemProp",
|
|
1051
1052
|
"MIMEType",
|
|
1053
|
+
"NavigableTargetName",
|
|
1054
|
+
"NavigableTargetNameOrKeyword",
|
|
1052
1055
|
"NoEmptyAny",
|
|
1053
1056
|
"Number",
|
|
1054
1057
|
"OneCodePointChar",
|