@markuplint/types 3.0.0-dev.25 → 3.0.0-dev.290

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 (173) hide show
  1. package/README.md +63 -61
  2. package/lib/check-multi-types.d.ts +2 -2
  3. package/lib/check-multi-types.js +9 -13
  4. package/lib/check.d.ts +7 -6
  5. package/lib/check.js +20 -30
  6. package/lib/css-syntax.d.ts +1 -1
  7. package/lib/css-syntax.js +60 -63
  8. package/lib/debug.js +2 -6
  9. package/lib/defs.d.ts +1 -1
  10. package/lib/defs.js +163 -91
  11. package/lib/enum.d.ts +4 -3
  12. package/lib/enum.js +7 -12
  13. package/lib/get-candidate.d.ts +1 -1
  14. package/lib/get-candidate.js +3 -8
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +3 -6
  17. package/lib/keyword-type.d.ts +2 -2
  18. package/lib/keyword-type.js +17 -21
  19. package/lib/list.d.ts +4 -3
  20. package/lib/list.js +9 -13
  21. package/lib/match-result.d.ts +4 -4
  22. package/lib/match-result.js +6 -12
  23. package/lib/number.d.ts +3 -3
  24. package/lib/number.js +11 -15
  25. package/lib/primitive/index.d.ts +7 -7
  26. package/lib/primitive/index.js +7 -17
  27. package/lib/primitive/is-float.js +1 -5
  28. package/lib/primitive/is-int.js +1 -5
  29. package/lib/primitive/is-non-zero-uint.js +1 -5
  30. package/lib/primitive/is-quantity.d.ts +1 -1
  31. package/lib/primitive/is-quantity.js +9 -13
  32. package/lib/primitive/is-uint.d.ts +1 -1
  33. package/lib/primitive/is-uint.js +1 -5
  34. package/lib/primitive/range.js +1 -5
  35. package/lib/primitive/split-unit.js +3 -7
  36. package/lib/rfc/is-bcp-47.d.ts +1 -1
  37. package/lib/rfc/is-bcp-47.js +3 -7
  38. package/lib/token/index.d.ts +2 -2
  39. package/lib/token/index.js +2 -7
  40. package/lib/token/token-collection.d.ts +13 -13
  41. package/lib/token/token-collection.js +55 -50
  42. package/lib/token/token.d.ts +11 -10
  43. package/lib/token/token.js +16 -24
  44. package/lib/token/types.d.ts +3 -0
  45. package/lib/types.d.ts +47 -46
  46. package/lib/types.js +1 -2
  47. package/lib/types.schema.d.ts +2 -2
  48. package/lib/types.schema.js +1 -3
  49. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  50. package/lib/w3c/check-serialized-permissions-policy.js +16 -20
  51. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  52. package/lib/whatwg/check-autocomplete.js +28 -32
  53. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  54. package/lib/whatwg/check-datetime/date-string.js +9 -13
  55. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
  56. package/lib/whatwg/check-datetime/datetime-tokens.js +43 -46
  57. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  58. package/lib/whatwg/check-datetime/duration-string.js +48 -44
  59. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  60. package/lib/whatwg/check-datetime/global-date-and-time-string.js +17 -21
  61. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  62. package/lib/whatwg/check-datetime/index.js +25 -29
  63. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  64. package/lib/whatwg/check-datetime/local-date-and-time-string.js +25 -26
  65. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  66. package/lib/whatwg/check-datetime/month-string.js +9 -13
  67. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  68. package/lib/whatwg/check-datetime/time-string.js +9 -13
  69. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  70. package/lib/whatwg/check-datetime/time-zone-offset-string.js +16 -21
  71. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  72. package/lib/whatwg/check-datetime/week-string.js +9 -13
  73. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  74. package/lib/whatwg/check-datetime/year-string.js +9 -13
  75. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  76. package/lib/whatwg/check-datetime/yearless-date-string.js +9 -13
  77. package/lib/whatwg/check-mime-type.d.ts +1 -1
  78. package/lib/whatwg/check-mime-type.js +12 -18
  79. package/lib/whatwg/is-abs-url.d.ts +1 -1
  80. package/lib/whatwg/is-abs-url.js +1 -5
  81. package/lib/whatwg/is-browser-context-name.d.ts +3 -1
  82. package/lib/whatwg/is-browser-context-name.js +3 -5
  83. package/lib/whatwg/is-custom-element-name.d.ts +1 -1
  84. package/lib/whatwg/is-custom-element-name.js +1 -5
  85. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  86. package/lib/whatwg/is-itemprop-name.js +2 -6
  87. package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
  88. package/lib/whatwg/is-navigable-target-name.js +20 -0
  89. package/package.json +19 -14
  90. package/types.schema.json +314 -311
  91. package/gen/specific-schema.json +0 -98
  92. package/gen/types.ts +0 -66
  93. package/lib/check.spec.js +0 -76
  94. package/lib/css-syntax.spec.d.ts +0 -1
  95. package/lib/css-syntax.spec.js +0 -157
  96. package/lib/list.spec.d.ts +0 -1
  97. package/lib/list.spec.js +0 -129
  98. package/lib/primitive/index.spec.d.ts +0 -1
  99. package/lib/primitive/index.spec.js +0 -62
  100. package/lib/rfc/is-bcp-47.spec.d.ts +0 -1
  101. package/lib/rfc/is-bcp-47.spec.js +0 -19
  102. package/lib/token/token-collection.spec.d.ts +0 -1
  103. package/lib/token/token-collection.spec.js +0 -144
  104. package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +0 -1
  105. package/lib/w3c/check-serialized-permissions-policy.spec.js +0 -34
  106. package/lib/whatwg/check-autocomplete.spec.d.ts +0 -1
  107. package/lib/whatwg/check-autocomplete.spec.js +0 -379
  108. package/lib/whatwg/check-datetime/index.spec.d.ts +0 -1
  109. package/lib/whatwg/check-datetime/index.spec.js +0 -318
  110. package/lib/whatwg/check-mime-type.spec.d.ts +0 -1
  111. package/lib/whatwg/check-mime-type.spec.js +0 -58
  112. package/lib/whatwg/is-abs-url.spec.d.ts +0 -1
  113. package/lib/whatwg/is-abs-url.spec.js +0 -8
  114. package/patches/css-tree+2.3.1.patch +0 -23
  115. package/src/check-multi-types.ts +0 -35
  116. package/src/check.spec.ts +0 -83
  117. package/src/check.ts +0 -48
  118. package/src/css-syntax.spec.ts +0 -167
  119. package/src/css-syntax.ts +0 -188
  120. package/src/debug.ts +0 -3
  121. package/src/defs.ts +0 -811
  122. package/src/enum.ts +0 -25
  123. package/src/get-candidate.ts +0 -24
  124. package/src/index.ts +0 -3
  125. package/src/keyword-type.ts +0 -64
  126. package/src/list.spec.ts +0 -133
  127. package/src/list.ts +0 -34
  128. package/src/match-result.ts +0 -49
  129. package/src/number.ts +0 -46
  130. package/src/primitive/index.spec.ts +0 -65
  131. package/src/primitive/index.ts +0 -7
  132. package/src/primitive/is-float.ts +0 -8
  133. package/src/primitive/is-int.ts +0 -8
  134. package/src/primitive/is-non-zero-uint.ts +0 -8
  135. package/src/primitive/is-quantity.ts +0 -38
  136. package/src/primitive/is-uint.ts +0 -15
  137. package/src/primitive/range.ts +0 -14
  138. package/src/primitive/split-unit.ts +0 -20
  139. package/src/rfc/is-bcp-47.spec.ts +0 -23
  140. package/src/rfc/is-bcp-47.ts +0 -13
  141. package/src/token/index.ts +0 -2
  142. package/src/token/token-collection.spec.ts +0 -147
  143. package/src/token/token-collection.ts +0 -444
  144. package/src/token/token.ts +0 -144
  145. package/src/types.schema.ts +0 -1113
  146. package/src/types.ts +0 -118
  147. package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
  148. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  149. package/src/whatwg/check-autocomplete.spec.ts +0 -387
  150. package/src/whatwg/check-autocomplete.ts +0 -380
  151. package/src/whatwg/check-datetime/date-string.ts +0 -44
  152. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  153. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  154. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  155. package/src/whatwg/check-datetime/index.spec.ts +0 -333
  156. package/src/whatwg/check-datetime/index.ts +0 -36
  157. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  158. package/src/whatwg/check-datetime/month-string.ts +0 -31
  159. package/src/whatwg/check-datetime/time-string.ts +0 -49
  160. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  161. package/src/whatwg/check-datetime/week-string.ts +0 -41
  162. package/src/whatwg/check-datetime/year-string.ts +0 -26
  163. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  164. package/src/whatwg/check-mime-type.spec.ts +0 -59
  165. package/src/whatwg/check-mime-type.ts +0 -46
  166. package/src/whatwg/is-abs-url.spec.ts +0 -8
  167. package/src/whatwg/is-abs-url.ts +0 -31
  168. package/src/whatwg/is-browser-context-name.ts +0 -16
  169. package/src/whatwg/is-custom-element-name.ts +0 -76
  170. package/src/whatwg/is-itemprop-name.ts +0 -17
  171. package/tsconfig.test.json +0 -3
  172. package/tsconfig.tsbuildinfo +0 -1
  173. /package/lib/{check.spec.d.ts → token/types.js} +0 -0
package/README.md CHANGED
@@ -33,67 +33,69 @@ check('2020-02-30', 'DateTime');
33
33
 
34
34
  ## Type Identifiers
35
35
 
36
- | Identifier | Use on | Spec | Supported |
37
- | ------------------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------- |
38
- | `Any` | Some attributes | | ✅ |
39
- | `NoEmptyAny` | Some attributes | | ✅ |
40
- | `OneLineAny` | Some attributes | | ✅ |
41
- | `Zero` | Some attributes | | ✅ |
42
- | `Number` | Some attributes | | ✅ |
43
- | `Uint` | Some attributes | | ✅ |
44
- | `XMLName` | `svg\|[attributeName]` and more | [XML](https://www.w3.org/TR/xml/#d0e804) | ✅ |
45
- | `DOMID` | The `id` attribute and more | [WHATWG](https://html.spec.whatwg.org/multipage/dom.html#global-attributes:concept-id) | ✅ |
46
- | `FunctionBody` | Event handler attributes | | 🚧 |
47
- | `Pattern` | `input[pattern]` | [WHATWG](https://html.spec.whatwg.org/multipage/input.html#compiled-pattern-regular-expression) | ✅ |
48
- | `DateTime` | `time[datetime]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value) | ✅ |
49
- | `TabIndex` | The `tabindex` attribute | [WHATWG](https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex) | ✅ |
50
- | `BCP47` | The `lang` attribute and more | [RFC](https://tools.ietf.org/rfc/bcp/bcp47.html) | ✅ |
51
- | `URL` | Some attributes | [WHATWG](https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces) | ✅ |
52
- | `AbsoluteURL` | The `itemtype` attribute (as list) | [WHATWG](https://url.spec.whatwg.org/#syntax-url-absolute) | ✅ |
53
- | `HashName` | `img[usemap]` | [WHATWG](https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-hash-name-reference) | ✅ |
54
- | `OneCodePointChar` | The `accesskey` attribute (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute) | ✅ |
55
- | `CustomElementName` | The `is` attribute | [WHATWG](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name) | ✅ |
56
- | `BrowsingContextName` | `iframe[name]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-names) | ✅ |
57
- | `BrowsingContextNameOrKeyword` | `a[target]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name-or-keyword) | ✅ |
58
- | `HTTPSchemaURL` | `a[ping]` (as list) and more | [WHATWG](https://html.spec.whatwg.org/multipage/links.html#ping) | ✅ |
59
- | `MIMEType` | `embed[type]` and more | [WHATWG](https://mimesniff.spec.whatwg.org/#valid-mime-type) | ✅ |
60
- | `ItemProp` | The `itemprop` attribute (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/microdata.html#names:-the-itemprop-attribute) | ✅ |
61
- | `Srcset` | `img[srcset]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/images.html#srcset-attributes) | ✅ |
62
- | `SourceSizeList` | `img[sizes]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/images.html#sizes-attributes) | ✅ |
63
- | `IconSize` | `link[sizes]` (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes) | ✅ |
64
- | `AutoComplete` | `input[autocomplete]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete) | ✅ |
65
- | `Accept` | `input[accept]` | [WHATWG](https://html.spec.whatwg.org/multipage/input.html#attr-input-accept) | ✅ |
66
- | `SerializedPermissionsPolicy` | `iframe[allow]` | [W3C](https://w3c.github.io/webappsec-permissions-policy/#serialized-permissions-policy) | ✅ |
67
- | `<css-declaration-list>` | The `style` attribute | [CSS](https://drafts.csswg.org/css-style-attr/#syntax) | ✅ |
68
- | `<class-list>` | The `class` attribute | [SVG](https://www.w3.org/TR/SVG/styling.html#ClassAttribute) | ✅ |
69
- | `<svg-font-size>` | Some attributes for SVG | [CSS](https://drafts.csswg.org/css-fonts-5/#descdef-font-face-font-size) | 🚧 |
70
- | `<svg-font-size-adjust>` | Some attributes for SVG | [CSS](https://drafts.csswg.org/css-fonts-5/#propdef-font-size-adjust) | 🚧 |
71
- | `<'color-profile'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/color.html#ColorProfileProperty) | 🚧 |
72
- | `<'color-rendering'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/painting.html#ColorRenderingProperty) | 🚧 |
73
- | `<'enable-background'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty) | 🚧 |
74
- | `<list-of-svg-feature-string>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/feature.html) | 🚧 |
75
- | `<animatable-value>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#FromAttribute) | 🚧 |
76
- | `<begin-value-list>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#BeginValueListSyntax) | 🚧 |
77
- | `<end-value-list>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#EndValueListSyntax) | 🚧 |
78
- | `<list-of-value>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#ValuesAttribute) | 🚧 |
79
- | `<clock-value>` | Some attributes for SVG | [SMIL](https://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-ClockValueSyntax) | 🚧 |
80
- | `<color-matrix>` | Some attributes for SVG | [W3C](https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values) | |
81
- | `<dasharray>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/painting.html#StrokeDasharrayProperty) | |
82
- | `<key-points>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyPointsAttribute) | ✅ |
83
- | `<key-splines>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyTimesAttribute) | ✅ |
84
- | `<key-times>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyTimesAttribute) | ✅ |
85
- | `<system-language>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/struct.html#SystemLanguageAttribute) | ✅ |
86
- | `<origin>` | Some attributes for SVG | [SMIL](https://www.w3.org/TR/2001/REC-smil-animation-20010904/#MotionOriginAttribute) | ✅ |
87
- | `<svg-path>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/paths.html#PathDataBNF) | 🚧 |
88
- | `<points>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/shapes.html#DataTypePoints) | ✅ |
89
- | `<preserve-aspect-ratio>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/coords.html#PreserveAspectRatioAttribute) | |
90
- | `<view-box>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute) | ✅ |
91
- | `<rotate>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#RotateAttribute) | ✅ |
92
- | `<text-coordinate>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/text.html#TSpanAttributes) | ✅ |
93
- | `<list-of-lengths>` | Some attributes for SVG | | ✅ |
94
- | `<list-of-numbers>` | Some attributes for SVG | | ✅ |
95
- | `<list-of-percentages>` | Some attributes for SVG | | ✅ |
96
- | `<number-optional-number>` | Some attributes for SVG | | ✅ |
36
+ | Identifier | Use on | Spec | Supported |
37
+ | ---------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------- |
38
+ | `Any` | Some attributes | | ✅ |
39
+ | `NoEmptyAny` | Some attributes | | ✅ |
40
+ | `OneLineAny` | Some attributes | | ✅ |
41
+ | `Zero` | Some attributes | | ✅ |
42
+ | `Number` | Some attributes | | ✅ |
43
+ | `Uint` | Some attributes | | ✅ |
44
+ | `XMLName` | `svg\|[attributeName]` and more | [XML](https://www.w3.org/TR/xml/#d0e804) | ✅ |
45
+ | `DOMID` | The `id` attribute and more | [WHATWG](https://html.spec.whatwg.org/multipage/dom.html#global-attributes:concept-id) | ✅ |
46
+ | `FunctionBody` | Event handler attributes | | 🚧 |
47
+ | `Pattern` | `input[pattern]` | [WHATWG](https://html.spec.whatwg.org/multipage/input.html#compiled-pattern-regular-expression) | ✅ |
48
+ | `DateTime` | `time[datetime]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value) | ✅ |
49
+ | `TabIndex` | The `tabindex` attribute | [WHATWG](https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex) | ✅ |
50
+ | `BCP47` | The `lang` attribute and more | [RFC](https://tools.ietf.org/rfc/bcp/bcp47.html) | ✅ |
51
+ | `URL` | Some attributes | [WHATWG](https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces) | ✅ |
52
+ | `AbsoluteURL` | The `itemtype` attribute (as list) | [WHATWG](https://url.spec.whatwg.org/#syntax-url-absolute) | ✅ |
53
+ | `HashName` | `img[usemap]` | [WHATWG](https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-hash-name-reference) | ✅ |
54
+ | `OneCodePointChar` | The `accesskey` attribute (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute) | ✅ |
55
+ | `CustomElementName` | The `is` attribute | [WHATWG](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name) | ✅ |
56
+ | ~~`BrowsingContextName`~~ | Use `NavigableTargetName` instead. | **Obsolated** | ✅ |
57
+ | ~~`BrowsingContextNameOrKeyword`~~ | Use `NavigableTargetNameOrKeyword` instead. | **Obsolated** | ✅ |
58
+ | `NavigableTargetName` | `iframe[name]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name) | ✅ |
59
+ | `NavigableTargetNameOrKeyword` | `a[target]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name-or-keyword) | ✅ |
60
+ | `HTTPSchemaURL` | `a[ping]` (as list) and more | [WHATWG](https://html.spec.whatwg.org/multipage/links.html#ping) | ✅ |
61
+ | `MIMEType` | `embed[type]` and more | [WHATWG](https://mimesniff.spec.whatwg.org/#valid-mime-type) | ✅ |
62
+ | `ItemProp` | The `itemprop` attribute (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/microdata.html#names:-the-itemprop-attribute) | ✅ |
63
+ | `Srcset` | `img[srcset]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/images.html#srcset-attributes) | ✅ |
64
+ | `SourceSizeList` | `img[sizes]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/images.html#sizes-attributes) | ✅ |
65
+ | `IconSize` | `link[sizes]` (as list) | [WHATWG](https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes) | ✅ |
66
+ | `AutoComplete` | `input[autocomplete]` and more | [WHATWG](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete) | ✅ |
67
+ | `Accept` | `input[accept]` | [WHATWG](https://html.spec.whatwg.org/multipage/input.html#attr-input-accept) | ✅ |
68
+ | `SerializedPermissionsPolicy` | `iframe[allow]` | [W3C](https://w3c.github.io/webappsec-permissions-policy/#serialized-permissions-policy) | ✅ |
69
+ | `<css-declaration-list>` | The `style` attribute | [CSS](https://drafts.csswg.org/css-style-attr/#syntax) | |
70
+ | `<class-list>` | The `class` attribute | [SVG](https://www.w3.org/TR/SVG/styling.html#ClassAttribute) | |
71
+ | `<svg-font-size>` | Some attributes for SVG | [CSS](https://drafts.csswg.org/css-fonts-5/#descdef-font-face-font-size) | 🚧 |
72
+ | `<svg-font-size-adjust>` | Some attributes for SVG | [CSS](https://drafts.csswg.org/css-fonts-5/#propdef-font-size-adjust) | 🚧 |
73
+ | `<'color-profile'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/color.html#ColorProfileProperty) | 🚧 |
74
+ | `<'color-rendering'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/painting.html#ColorRenderingProperty) | 🚧 |
75
+ | `<'enable-background'>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty) | 🚧 |
76
+ | `<list-of-svg-feature-string>` | Some attributes for SVG | [SVG](https://www.w3.org/TR/SVG11/feature.html) | 🚧 |
77
+ | `<animatable-value>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#FromAttribute) | 🚧 |
78
+ | `<begin-value-list>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#BeginValueListSyntax) | 🚧 |
79
+ | `<end-value-list>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#EndValueListSyntax) | 🚧 |
80
+ | `<list-of-value>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#ValuesAttribute) | 🚧 |
81
+ | `<clock-value>` | Some attributes for SVG | [SMIL](https://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-ClockValueSyntax) | 🚧 |
82
+ | `<color-matrix>` | Some attributes for SVG | [W3C](https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values) | ✅ |
83
+ | `<dasharray>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/painting.html#StrokeDasharrayProperty) | ✅ |
84
+ | `<key-points>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyPointsAttribute) | ✅ |
85
+ | `<key-splines>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyTimesAttribute) | ✅ |
86
+ | `<key-times>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#KeyTimesAttribute) | ✅ |
87
+ | `<system-language>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/struct.html#SystemLanguageAttribute) | |
88
+ | `<origin>` | Some attributes for SVG | [SMIL](https://www.w3.org/TR/2001/REC-smil-animation-20010904/#MotionOriginAttribute) | ✅ |
89
+ | `<svg-path>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/paths.html#PathDataBNF) | 🚧 |
90
+ | `<points>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/shapes.html#DataTypePoints) | ✅ |
91
+ | `<preserve-aspect-ratio>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/coords.html#PreserveAspectRatioAttribute) | ✅ |
92
+ | `<view-box>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute) | ✅ |
93
+ | `<rotate>` | Some attributes for SVG | [SVG](https://svgwg.org/specs/animations/#RotateAttribute) | ✅ |
94
+ | `<text-coordinate>` | Some attributes for SVG | [SVG](https://svgwg.org/svg2-draft/text.html#TSpanAttributes) | ✅ |
95
+ | `<list-of-lengths>` | Some attributes for SVG | | ✅ |
96
+ | `<list-of-numbers>` | Some attributes for SVG | | ✅ |
97
+ | `<list-of-percentages>` | Some attributes for SVG | | ✅ |
98
+ | `<number-optional-number>` | Some attributes for SVG | | ✅ |
97
99
 
98
100
  In addition, you can use types **[CSSTree](https://github.com/csstree/csstree)** defined.
99
101
 
@@ -1,2 +1,2 @@
1
- import type { CustomSyntaxCheck, UnmatchedResult } from './types';
2
- export declare function checkMultiTypes(value: string, checks: CustomSyntaxCheck[]): import("./types").MatchedResult | UnmatchedResult;
1
+ import type { CustomSyntaxCheck, UnmatchedResult } from './types.js';
2
+ export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): import("./types.js").MatchedResult | UnmatchedResult;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkMultiTypes = void 0;
4
- const debug_1 = require("./debug");
5
- const match_result_1 = require("./match-result");
6
- function checkMultiTypes(value, checks) {
1
+ import { log } from './debug.js';
2
+ import { matched } from './match-result.js';
3
+ export function checkMultiTypes(value, checks) {
7
4
  let unmatched;
8
5
  for (const check of checks) {
9
6
  const res = check(value);
@@ -13,17 +10,16 @@ function checkMultiTypes(value, checks) {
13
10
  // @ts-ignore
14
11
  res._fn = check.name;
15
12
  // @ts-ignore
16
- (0, debug_1.log)('%s(%d) vs %s(%d)', unmatched === null || unmatched === void 0 ? void 0 : unmatched._fn, unmatched === null || unmatched === void 0 ? void 0 : unmatched.passCount, res._fn, res.passCount);
17
- const passedA = (unmatched === null || unmatched === void 0 ? void 0 : unmatched.passCount) || 0;
18
- const passedB = res.passCount || 0;
19
- const offsetA = (unmatched === null || unmatched === void 0 ? void 0 : unmatched.offset) || 0;
13
+ log('%s(%d) vs %s(%d)', unmatched?._fn, unmatched?.passCount, res._fn, res.passCount);
14
+ const passedA = unmatched?.passCount ?? 0;
15
+ const passedB = res.passCount ?? 0;
16
+ const offsetA = unmatched?.offset ?? 0;
20
17
  const offsetB = res.offset;
21
18
  if (passedA < passedB || (passedA === passedB && offsetA <= offsetB)) {
22
19
  unmatched = res;
23
20
  }
24
21
  }
25
- const result = unmatched || (0, match_result_1.matched)();
26
- (0, debug_1.log)('%d checks result: %O', checks.length, result);
22
+ const result = unmatched ?? matched();
23
+ log('%d checks result: %O', checks.length, result);
27
24
  return result;
28
25
  }
29
- exports.checkMultiTypes = checkMultiTypes;
package/lib/check.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { Type, Result, List, CustomSyntax, CustomCssSyntax, Enum, KeywordDefinedType, Number } from './types';
2
- export declare function check(value: string, type: Type, ref?: string, cache?: boolean): Result;
3
- export declare function isKeyword(type: Type): type is KeywordDefinedType;
4
- export declare function isList(type: Type): type is List;
5
- export declare function isEnum(type: Type): type is Enum;
6
- export declare function isNumber(type: Type): type is Number;
1
+ import type { Type, Result, List, CustomSyntax, CustomCssSyntax, Enum, KeywordDefinedType, Number } from './types.js';
2
+ import type { ReadonlyDeep } from 'type-fest';
3
+ export declare function check(value: string, type: ReadonlyDeep<Type>, ref?: string, cache?: boolean): Result;
4
+ export declare function isKeyword(type: ReadonlyDeep<Type>): type is ReadonlyDeep<KeywordDefinedType>;
5
+ export declare function isList(type: ReadonlyDeep<Type>): type is ReadonlyDeep<List>;
6
+ export declare function isEnum(type: ReadonlyDeep<Type>): type is ReadonlyDeep<Enum>;
7
+ export declare function isNumber(type: ReadonlyDeep<Type>): type is ReadonlyDeep<Number>;
7
8
  export declare function isCSSSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomCssSyntax;
8
9
  export declare function isCustomSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomSyntax;
package/lib/check.js CHANGED
@@ -1,49 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCustomSyntax = exports.isCSSSyntax = exports.isNumber = exports.isEnum = exports.isList = exports.isKeyword = exports.check = void 0;
4
- const debug_1 = require("./debug");
5
- const enum_1 = require("./enum");
6
- const keyword_type_1 = require("./keyword-type");
7
- const list_1 = require("./list");
8
- const number_1 = require("./number");
9
- function check(value, type, ref, cache = true) {
1
+ import { log } from './debug.js';
2
+ import { checkEnum } from './enum.js';
3
+ import { checkKeywordType } from './keyword-type.js';
4
+ import { checkList } from './list.js';
5
+ import { checkNumber } from './number.js';
6
+ export function check(value, type, ref, cache = true) {
10
7
  if (isKeyword(type)) {
11
- (0, debug_1.log)('Check keyword: %s', type);
12
- return (0, keyword_type_1.checkKeywordType)(value, type, cache);
8
+ log('Check keyword: %s', type);
9
+ return checkKeywordType(value, type, cache);
13
10
  }
14
11
  if (isList(type)) {
15
- (0, debug_1.log)('Check list: %O', type);
16
- return (0, list_1.checkList)(value, type, ref, cache);
12
+ log('Check list: %O', type);
13
+ return checkList(value, type, ref, cache);
17
14
  }
18
15
  if (isEnum(type)) {
19
- (0, debug_1.log)('Check enum: %O', type);
20
- return (0, enum_1.checkEnum)(value, type, ref);
16
+ log('Check enum: %O', type);
17
+ return checkEnum(value, type, ref);
21
18
  }
22
- (0, debug_1.log)('Check number: %O', type);
23
- return (0, number_1.checkNumber)(value, type, ref);
19
+ log('Check number: %O', type);
20
+ return checkNumber(value, type, ref);
24
21
  }
25
- exports.check = check;
26
- function isKeyword(type) {
22
+ export function isKeyword(type) {
27
23
  return typeof type === 'string';
28
24
  }
29
- exports.isKeyword = isKeyword;
30
- function isList(type) {
25
+ export function isList(type) {
31
26
  return typeof type !== 'string' && 'token' in type;
32
27
  }
33
- exports.isList = isList;
34
- function isEnum(type) {
28
+ export function isEnum(type) {
35
29
  return typeof type !== 'string' && 'enum' in type;
36
30
  }
37
- exports.isEnum = isEnum;
38
- function isNumber(type) {
31
+ export function isNumber(type) {
39
32
  return typeof type !== 'string' && 'enum' in type;
40
33
  }
41
- exports.isNumber = isNumber;
42
- function isCSSSyntax(type) {
34
+ export function isCSSSyntax(type) {
43
35
  return typeof type === 'string' || 'syntax' in type;
44
36
  }
45
- exports.isCSSSyntax = isCSSSyntax;
46
- function isCustomSyntax(type) {
37
+ export function isCustomSyntax(type) {
47
38
  return !isCSSSyntax(type);
48
39
  }
49
- exports.isCustomSyntax = isCustomSyntax;
@@ -1,2 +1,2 @@
1
- import type { CustomCssSyntax, Result, CssSyntax } from './types';
1
+ import type { CustomCssSyntax, Result, CssSyntax } from './types.js';
2
2
  export declare function cssSyntaxMatch(value: string, type: CssSyntax | CustomCssSyntax): Result;
package/lib/css-syntax.js CHANGED
@@ -1,20 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cssSyntaxMatch = void 0;
4
- const tslib_1 = require("tslib");
5
- // @ts-ignore
6
- const css_tree_1 = tslib_1.__importDefault(require("css-tree"));
7
- // @ts-ignore
8
- const error_1 = require("css-tree/lexer/error");
9
- // @ts-ignore
10
- const match_1 = require("css-tree/lexer/match");
11
- // @ts-ignore
12
- const prepare_tokens_1 = tslib_1.__importDefault(require("css-tree/lexer/prepare-tokens"));
13
- const debug_1 = require("./debug");
14
- const defs_1 = require("./defs");
15
- const match_result_1 = require("./match-result");
16
- function cssSyntaxMatch(value, type) {
17
- (0, debug_1.log)('Search CSS Syntax: "%s"', type);
1
+ import { fork } from 'css-tree';
2
+ import { log } from './debug.js';
3
+ import { tokenizers } from './defs.js';
4
+ import { matched } from './match-result.js';
5
+ const MIMIC_TAG_L = 'mimiccases---';
6
+ const MIMIC_TAG_R = '---mimiccases';
7
+ const MIMIC_LENGTH = (MIMIC_TAG_L + MIMIC_TAG_R).length;
8
+ export function cssSyntaxMatch(value, type) {
9
+ log('Search CSS Syntax: "%s"', type);
18
10
  const origin = value;
19
11
  let defName;
20
12
  const typesExtended = {};
@@ -29,13 +21,13 @@ function cssSyntaxMatch(value, type) {
29
21
  }
30
22
  else {
31
23
  defName = type.syntax.apply;
32
- ebnf = type.syntax.ebnf || null;
24
+ ebnf = type.syntax.ebnf ?? null;
33
25
  if (ebnf) {
34
26
  // Work in progress
35
- return (0, match_result_1.matched)();
27
+ return matched();
36
28
  }
37
29
  const types = {
38
- ...defs_1.tokenizers,
30
+ ...tokenizers,
39
31
  ...type.syntax.def,
40
32
  };
41
33
  Object.keys(types).forEach(key => {
@@ -43,7 +35,7 @@ function cssSyntaxMatch(value, type) {
43
35
  if (typeof valueOrChecker === 'string') {
44
36
  typesExtended[key] = valueOrChecker;
45
37
  }
46
- else {
38
+ else if (valueOrChecker) {
47
39
  typesCheckers[key] = valueOrChecker;
48
40
  }
49
41
  });
@@ -57,54 +49,53 @@ function cssSyntaxMatch(value, type) {
57
49
  ref = type.ref;
58
50
  }
59
51
  // @ts-ignore
60
- const lexer = css_tree_1.default.fork({
52
+ const lexer = fork({
61
53
  types: typesExtended,
62
54
  properties: propsExtended,
63
55
  }).lexer;
64
56
  Object.keys(typesCheckers).forEach(key => {
65
57
  const checker = typesCheckers[key];
66
- lexer.addType_(key, (token, getNextToken) => checker(token, getNextToken, cssSyntaxMatch));
58
+ // @ts-ignore
59
+ lexer.addType_(key, (token, getNextToken) => checker?.(token, getNextToken, cssSyntaxMatch));
67
60
  });
68
- const { isProp, name, matcher } = defToMatcher(lexer, defName);
61
+ const { isProp, name } = detectName(defName);
62
+ // @ts-ignore
63
+ const matcher = isProp ? lexer.properties[name] : lexer.types[name];
64
+ if (!matcher) {
65
+ log('"%s" CSS syntax not found', defName);
66
+ throw new Error('MARKUPLINT_TYPE_NO_EXIST');
67
+ }
69
68
  const refParam = isProp ? 'Property' : 'Type';
70
- ref = ref || `https://csstree.github.io/docs/syntax/#${refParam}:${name}`;
69
+ ref = ref ?? `https://csstree.github.io/docs/syntax/#${refParam}:${name}`;
71
70
  // eslint-disable-next-line no-console
72
71
  const _w = console.warn;
73
- if (debug_1.log.enabled) {
72
+ if (log.enabled) {
74
73
  // eslint-disable-next-line no-console
75
- console.warn = warn => (0, debug_1.log)('WARNING: %s (by %s => %s)', warn, value, type);
76
- }
77
- const tokens = (0, prepare_tokens_1.default)(value, lexer.syntax);
78
- const result = (0, match_1.matchAsTree)(tokens, matcher.match, lexer);
79
- if (caseSensitive) {
80
- if (result.tokens && Array.isArray(result.tokens)) {
81
- let reducer = 0;
82
- result.tokens = result.tokens.map((token) => {
83
- const value = token.value;
84
- const originValue = deMimicCases(value || '');
85
- const isMimiced = value !== originValue;
86
- reducer += isMimiced ? 'mimiccases------mimiccases'.length : 0;
87
- token.value = originValue;
88
- token.balance = token.balance - reducer;
89
- return token;
90
- });
91
- }
74
+ console.warn = warn => log('WARNING: %s (by %s => %s)', warn, value, type);
92
75
  }
93
- (0, debug_1.log)('css-tree/result: %O', result);
76
+ const result = lexer.match(defName, value);
77
+ log('css-tree/result: %O', result);
94
78
  // eslint-disable-next-line no-console
95
79
  console.warn = _w;
96
- if (result.match) {
97
- if (debug_1.log.enabled) {
98
- (0, debug_1.log)('css-tree/result.match: %s', JSON.stringify(result.match, null, 2));
99
- }
100
- return (0, match_result_1.matched)();
80
+ if (!result.error) {
81
+ return matched();
82
+ }
83
+ if (!('css' in result.error)) {
84
+ throw result.error;
101
85
  }
102
- const error = new error_1.SyntaxMatchError(result.reason, matcher.syntax, value, result);
86
+ const error = result.error;
103
87
  if (caseSensitive) {
104
- error.message = deMimicCases(error.message);
88
+ const offset = error.mismatchOffset % MIMIC_LENGTH;
89
+ const diff = error.mismatchOffset - offset;
90
+ error.message = deMimicCases(error.message).replace('-'.repeat(diff), '');
105
91
  error.syntax = deMimicCases(error.syntax);
92
+ error.css = deMimicCases(error.css);
93
+ error.mismatchOffset = offset;
94
+ error.column = error.column % MIMIC_LENGTH;
95
+ const mismatchLength = error.mismatchLength - MIMIC_LENGTH;
96
+ error.mismatchLength = mismatchLength < 0 ? error.mismatchLength : mismatchLength;
106
97
  }
107
- (0, debug_1.log)('css-tree/SyntaxMatchError: %O', error);
98
+ log('css-tree/SyntaxMatchError: %O', error);
108
99
  return {
109
100
  matched: false,
110
101
  ref,
@@ -123,28 +114,34 @@ function cssSyntaxMatch(value, type) {
123
114
  reason: 'syntax-error',
124
115
  };
125
116
  }
126
- exports.cssSyntaxMatch = cssSyntaxMatch;
127
- function defToMatcher(lexer, def) {
117
+ function detectName(def) {
128
118
  const isProp = def.search("<'") === 0;
129
119
  const name = def.replace(/^<'?|'?>$/g, '');
130
- const matcher = isProp ? lexer.properties[name] : lexer.types[name];
131
- if (!matcher) {
132
- (0, debug_1.log)('"%s" CSS syntax not found', def);
133
- throw new Error('MARKUPLINT_TYPE_NO_EXIST');
134
- }
135
120
  return {
136
121
  isProp,
137
122
  name,
138
- matcher,
139
123
  };
140
124
  }
141
- function eachMimicCases(key, obj) {
125
+ /**
126
+ *
127
+ * @param key
128
+ * @param obj
129
+ * @modifies obj
130
+ * @returns
131
+ */
132
+ function eachMimicCases(key,
133
+ // Mutable
134
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
135
+ obj) {
142
136
  const value = obj[key];
137
+ if (!value) {
138
+ return;
139
+ }
143
140
  obj[key] = mimicCases(value);
144
141
  }
145
142
  function mimicCases(value) {
146
- return value.replace(/[A-Z]/g, $0 => `mimiccases---${$0}---mimiccases`);
143
+ return value.replace(/[A-Z]/g, $0 => `${MIMIC_TAG_L}${$0}${MIMIC_TAG_R}`);
147
144
  }
148
145
  function deMimicCases(value) {
149
- return value.replace(/mimiccases---([A-Z])---mimiccases/g, (_, $1) => $1);
146
+ return value.replace(new RegExp(`${MIMIC_TAG_L}([A-Z])${MIMIC_TAG_R}`, 'g'), (_, $1) => $1);
150
147
  }
package/lib/debug.js CHANGED
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.log = void 0;
4
- const tslib_1 = require("tslib");
5
- const debug_1 = tslib_1.__importDefault(require("debug"));
6
- exports.log = (0, debug_1.default)('@markuplint/types');
1
+ import debug from 'debug';
2
+ export const log = debug('@markuplint/types');
package/lib/defs.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Defs, CssSyntaxTokenizer } from './types';
1
+ import type { Defs, CssSyntaxTokenizer } from './types.js';
2
2
  export declare const types: Defs;
3
3
  export declare const tokenizers: Record<string, CssSyntaxTokenizer>;