@markuplint/types 3.12.0 → 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.
Files changed (101) hide show
  1. package/LICENSE +1 -1
  2. package/lib/check-multi-types.d.ts +2 -5
  3. package/lib/check-multi-types.js +9 -14
  4. package/lib/check.d.ts +1 -1
  5. package/lib/check.js +20 -30
  6. package/lib/css-syntax.d.ts +1 -1
  7. package/lib/css-syntax.js +33 -33
  8. package/lib/debug.js +2 -6
  9. package/lib/defs.d.ts +2 -1
  10. package/lib/defs.js +188 -138
  11. package/lib/enum.d.ts +2 -2
  12. package/lib/enum.js +7 -12
  13. package/lib/get-candidate.d.ts +1 -4
  14. package/lib/get-candidate.js +5 -10
  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 +20 -25
  19. package/lib/list.d.ts +2 -2
  20. package/lib/list.js +9 -14
  21. package/lib/match-result.d.ts +8 -21
  22. package/lib/match-result.js +6 -13
  23. package/lib/number.d.ts +3 -3
  24. package/lib/number.js +13 -17
  25. package/lib/primitive/index.d.ts +7 -7
  26. package/lib/primitive/index.js +7 -17
  27. package/lib/primitive/is-float.js +2 -6
  28. package/lib/primitive/is-int.js +2 -6
  29. package/lib/primitive/is-non-zero-uint.js +2 -6
  30. package/lib/primitive/is-quantity.d.ts +1 -5
  31. package/lib/primitive/is-quantity.js +9 -13
  32. package/lib/primitive/is-uint.d.ts +3 -6
  33. package/lib/primitive/is-uint.js +4 -8
  34. package/lib/primitive/range.js +3 -7
  35. package/lib/primitive/split-unit.d.ts +2 -2
  36. package/lib/primitive/split-unit.js +4 -8
  37. package/lib/rfc/is-bcp-47.d.ts +1 -1
  38. package/lib/rfc/is-bcp-47.js +3 -7
  39. package/lib/token/index.d.ts +2 -2
  40. package/lib/token/index.js +2 -7
  41. package/lib/token/token-collection.d.ts +58 -70
  42. package/lib/token/token-collection.js +47 -56
  43. package/lib/token/token.d.ts +54 -59
  44. package/lib/token/token.js +14 -20
  45. package/lib/token/types.js +1 -2
  46. package/lib/types.d.ts +58 -82
  47. package/lib/types.js +1 -2
  48. package/lib/types.schema.d.ts +31 -1087
  49. package/lib/types.schema.js +1 -2
  50. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  51. package/lib/w3c/check-serialized-permissions-policy.js +21 -25
  52. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  53. package/lib/whatwg/check-autocomplete.js +34 -41
  54. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  55. package/lib/whatwg/check-datetime/date-string.js +12 -16
  56. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +2 -22
  57. package/lib/whatwg/check-datetime/datetime-tokens.js +58 -64
  58. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  59. package/lib/whatwg/check-datetime/duration-string.js +64 -69
  60. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  61. package/lib/whatwg/check-datetime/global-date-and-time-string.js +24 -28
  62. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  63. package/lib/whatwg/check-datetime/index.js +25 -29
  64. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  65. package/lib/whatwg/check-datetime/local-date-and-time-string.js +37 -41
  66. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  67. package/lib/whatwg/check-datetime/month-string.js +9 -13
  68. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  69. package/lib/whatwg/check-datetime/time-string.js +13 -17
  70. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  71. package/lib/whatwg/check-datetime/time-zone-offset-string.js +22 -28
  72. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  73. package/lib/whatwg/check-datetime/week-string.js +11 -15
  74. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  75. package/lib/whatwg/check-datetime/year-string.js +9 -13
  76. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  77. package/lib/whatwg/check-datetime/yearless-date-string.js +11 -15
  78. package/lib/whatwg/check-mime-type.d.ts +5 -5
  79. package/lib/whatwg/check-mime-type.js +11 -17
  80. package/lib/whatwg/is-abs-url.d.ts +1 -1
  81. package/lib/whatwg/is-abs-url.js +8 -12
  82. package/lib/whatwg/is-browser-context-name.d.ts +1 -1
  83. package/lib/whatwg/is-browser-context-name.js +1 -5
  84. package/lib/whatwg/is-custom-element-name.d.ts +10 -5
  85. package/lib/whatwg/is-custom-element-name.js +22 -38
  86. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  87. package/lib/whatwg/is-itemprop-name.js +1 -5
  88. package/lib/whatwg/is-navigable-target-name.d.ts +1 -1
  89. package/lib/whatwg/is-navigable-target-name.js +1 -5
  90. package/package.json +17 -9
  91. package/test/check.spec.js +0 -89
  92. package/test/css-syntax.spec.js +0 -170
  93. package/test/list.spec.js +0 -133
  94. package/test/primitive/index.spec.js +0 -65
  95. package/test/rfc/is-bcp-47.spec.js +0 -23
  96. package/test/token/token-collection.spec.js +0 -146
  97. package/test/w3c/check-serialized-permissions-policy.spec.js +0 -36
  98. package/test/whatwg/check-autocomplete.spec.js +0 -387
  99. package/test/whatwg/check-datetime/index.spec.js +0 -336
  100. package/test/whatwg/check-mime-type.spec.js +0 -59
  101. package/test/whatwg/is-abs-url.spec.js +0 -8
@@ -1,7 +1,6 @@
1
- "use strict";
2
1
  /**
3
2
  * This file was automatically generated by json-schema-to-typescript.
4
3
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
4
  * and run json-schema-to-typescript to regenerate this file.
6
5
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
6
+ export {};
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../types';
1
+ import type { CustomSyntaxChecker } from '../types.js';
2
2
  /**
3
3
  * @see https://w3c.github.io/webappsec-permissions-policy/#serialized-permissions-policy
4
4
  *
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkSerializedPermissionsPolicy = void 0;
4
- const debug_1 = require("../debug");
5
- const match_result_1 = require("../match-result");
6
- const token_1 = require("../token");
1
+ import { log } from '../debug.js';
2
+ import { matched, unmatched } from '../match-result.js';
3
+ import { TokenCollection } from '../token/index.js';
7
4
  /**
8
5
  * @see https://w3c.github.io/webappsec-permissions-policy/#serialized-permissions-policy
9
6
  *
@@ -25,14 +22,13 @@ const token_1 = require("../token");
25
22
  *
26
23
  * `allow-list` is optional.
27
24
  */
28
- const checkSerializedPermissionsPolicy = () => value => {
25
+ export const checkSerializedPermissionsPolicy = () => value => {
29
26
  const res = _checkSerializedPermissionsPolicy(value);
30
27
  if (!res.matched) {
31
- (0, debug_1.log)('Failed: %O', res);
28
+ log('Failed: %O', res);
32
29
  }
33
30
  return res;
34
31
  };
35
- exports.checkSerializedPermissionsPolicy = checkSerializedPermissionsPolicy;
36
32
  function _checkSerializedPermissionsPolicy(value) {
37
33
  /**
38
34
  * The list of serialized-policy-directive
@@ -51,14 +47,14 @@ function _checkSerializedPermissionsPolicy(value) {
51
47
  */
52
48
  /;?/,
53
49
  ];
54
- const tokens = token_1.TokenCollection.fromPatterns(value, patterns, { repeat: true });
50
+ const tokens = TokenCollection.fromPatterns(value, patterns, { repeat: true });
55
51
  const serializedPolicyDirectives = tokens.chunk(patterns.length);
56
- (0, debug_1.log)('Serialized Permissions Policy: %s => %O', value, serializedPolicyDirectives);
52
+ log('Serialized Permissions Policy: %s => %O', value, serializedPolicyDirectives);
57
53
  for (const [serializedPolicyDirective] of serializedPolicyDirectives) {
58
54
  if (!serializedPolicyDirective || !serializedPolicyDirective.value) {
59
- return (0, match_result_1.unmatched)('', 'empty-token');
55
+ return unmatched('', 'empty-token');
60
56
  }
61
- const [aw, featureIdentifier, rws, allowListValue] = token_1.TokenCollection.fromPatterns(serializedPolicyDirective, [
57
+ const [aw, featureIdentifier, rws, allowListValue] = TokenCollection.fromPatterns(serializedPolicyDirective, [
62
58
  /**
63
59
  * Any whitespace
64
60
  */
@@ -70,7 +66,7 @@ function _checkSerializedPermissionsPolicy(value) {
70
66
  * > feature-identifier = 1*( ALPHA / DIGIT / "-")
71
67
  * > ```
72
68
  */
73
- /[^\s]*/,
69
+ /\S*/,
74
70
  /**
75
71
  * RWS (Required whitespace)
76
72
  *
@@ -82,7 +78,7 @@ function _checkSerializedPermissionsPolicy(value) {
82
78
  */
83
79
  /.*/,
84
80
  ]);
85
- (0, debug_1.log)('Serialized Policy Directive: %s => %O', serializedPolicyDirective.value, {
81
+ log('Serialized Policy Directive: %s => %O', serializedPolicyDirective.value, {
86
82
  aw,
87
83
  featureIdentifier,
88
84
  rws,
@@ -93,7 +89,7 @@ function _checkSerializedPermissionsPolicy(value) {
93
89
  * > feature-identifier = 1*( ALPHA / DIGIT / "-")
94
90
  * > ```
95
91
  */
96
- if (!featureIdentifier || !featureIdentifier.match(/^[a-z0-9-]+$/i)) {
92
+ if (!featureIdentifier || !featureIdentifier.matches(/^[\da-z-]+$/i)) {
97
93
  return featureIdentifier.unmatched({
98
94
  reason: 'unexpected-token',
99
95
  expects: [{ type: 'common', value: 'feature-identifier' }],
@@ -116,16 +112,16 @@ function _checkSerializedPermissionsPolicy(value) {
116
112
  }
117
113
  const allowListPatterns = [
118
114
  // Value
119
- /[^\s]*/,
115
+ /\S*/,
120
116
  // Separator
121
117
  /\s*/,
122
118
  ];
123
- const allowListTokens = token_1.TokenCollection.fromPatterns(allowListValue, allowListPatterns, { repeat: true });
119
+ const allowListTokens = TokenCollection.fromPatterns(allowListValue, allowListPatterns, { repeat: true });
124
120
  const allowList = allowListTokens.chunk(allowListPatterns.length);
125
- (0, debug_1.log)('Allow List: %s => %O', allowListTokens.value, allowList);
121
+ log('Allow List: %s => %O', allowListTokens.value, allowList);
126
122
  for (const [allow] of allowList) {
127
123
  if (!allow || !allow.value) {
128
- return (0, match_result_1.unmatched)('', 'missing-token', {
124
+ return unmatched('', 'missing-token', {
129
125
  expects: [
130
126
  { type: 'const', value: '*' },
131
127
  { type: 'const', value: "'self'" },
@@ -143,10 +139,10 @@ function _checkSerializedPermissionsPolicy(value) {
143
139
  if (origin.reason !== 'syntax-error') {
144
140
  return origin;
145
141
  }
146
- if (allow.match(['*', "'self'", "'src'", "'none'"], true)) {
142
+ if (allow.matches(['*', "'self'", "'src'", "'none'"], true)) {
147
143
  continue;
148
144
  }
149
- if (allow.match(['self', 'src', 'none'], true)) {
145
+ if (allow.matches(['self', 'src', 'none'], true)) {
150
146
  return allow.unmatched({
151
147
  reason: 'missing-token',
152
148
  expects: [{ type: 'common', value: 'single-quote' }],
@@ -166,7 +162,7 @@ function _checkSerializedPermissionsPolicy(value) {
166
162
  });
167
163
  }
168
164
  }
169
- return (0, match_result_1.matched)();
165
+ return matched();
170
166
  }
171
167
  /**
172
168
  * serialized-origin
@@ -179,7 +175,7 @@ function _checkSerializedPermissionsPolicy(value) {
179
175
  */
180
176
  function checkSerializedOrigin(token) {
181
177
  const url = parseUrl(token.value);
182
- (0, debug_1.log)('Parse URL: "%s" => %O', token.value, url);
178
+ log('Parse URL: "%s" => %O', token.value, url);
183
179
  if (!url) {
184
180
  return token.unmatched({
185
181
  expects: [{ type: 'common', value: 'serialized-origin' }],
@@ -254,7 +250,7 @@ function checkSerializedOrigin(token) {
254
250
  partName: 'serialized-origin',
255
251
  });
256
252
  }
257
- return (0, match_result_1.matched)();
253
+ return matched();
258
254
  }
259
255
  function parseUrl(value) {
260
256
  try {
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../types';
1
+ import type { CustomSyntaxChecker } from '../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete
4
4
  */
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkAutoComplete = void 0;
4
- const debug_1 = require("../debug");
5
- const get_candidate_1 = require("../get-candidate");
6
- const match_result_1 = require("../match-result");
7
- const token_1 = require("../token");
8
- const acLog = debug_1.log.extend('autocomplete');
1
+ import { log } from '../debug.js';
2
+ import { getCandidate } from '../get-candidate.js';
3
+ import { matched } from '../match-result.js';
4
+ import { TokenCollection } from '../token/index.js';
5
+ const acLog = log.extend('autocomplete');
9
6
  /**
10
7
  * https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section
11
8
  */
@@ -95,11 +92,11 @@ const URL_CONTACTABLE_FIELD = 'https://html.spec.whatwg.org/multipage/form-contr
95
92
  /**
96
93
  * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete
97
94
  */
98
- const checkAutoComplete = () => value => {
95
+ export const checkAutoComplete = () => value => {
99
96
  let hasNamedGroup = false;
100
97
  let hasPartOfAddress = false;
101
98
  let hasContactingToken = false;
102
- const tokens = new token_1.TokenCollection(value, {
99
+ const tokens = new TokenCollection(value, {
103
100
  disallowToSurroundBySpaces: false,
104
101
  allowEmpty: false,
105
102
  ordered: true,
@@ -131,7 +128,7 @@ const checkAutoComplete = () => value => {
131
128
  // > an ordered set of space-separated tokens consisting of
132
129
  // > just autofill detail tokens
133
130
  // > (i.e. the "on" and "off" keywords are not allowed).
134
- if (head.match(['on', 'off'], true)) {
131
+ if (head.matches(['on', 'off'], true)) {
135
132
  if (tail[0]) {
136
133
  acLog('[Unmatched ("%s")] Unexpected pair with "on" or "off": "%s"', value, tail.value);
137
134
  return tail[0].unmatched({
@@ -145,12 +142,12 @@ const checkAutoComplete = () => value => {
145
142
  ref: URL_ON_OFF,
146
143
  });
147
144
  }
148
- return (0, match_result_1.matched)();
145
+ return matched();
149
146
  }
150
147
  // > Optionally, a token whose first eight characters are
151
148
  // > an ASCII case-insensitive match for the string "section-",
152
149
  // > meaning that the field belongs to the named group.
153
- if (head.match(namedGroup, true)) {
150
+ if (head.matches(namedGroup, true)) {
154
151
  hasNamedGroup = true;
155
152
  const sectionToken = tail.search(namedGroup);
156
153
  if (sectionToken) {
@@ -166,14 +163,14 @@ const checkAutoComplete = () => value => {
166
163
  tail = headAndTail2.tail;
167
164
  if (!head) {
168
165
  // Missing autofill field name but it is valid
169
- return (0, match_result_1.matched)();
166
+ return matched();
170
167
  }
171
168
  }
172
169
  // > Optionally, a token that is an ASCII case-insensitive match for
173
170
  // > one of the following strings:
174
171
  // > - "shipping", meaning the field is part of the shipping address or contact information
175
172
  // > - "billing", meaning the field is part of the billing address or contact information
176
- if (head.match(partOfAddress, true)) {
173
+ if (head.matches(partOfAddress, true)) {
177
174
  hasPartOfAddress = true;
178
175
  const partToken = tail.search(partOfAddress);
179
176
  if (partToken) {
@@ -194,18 +191,18 @@ const checkAutoComplete = () => value => {
194
191
  tail = headAndTail3.tail;
195
192
  if (!head) {
196
193
  // Missing autofill field name but it is valid
197
- return (0, match_result_1.matched)();
194
+ return matched();
198
195
  }
199
196
  }
200
- if (head.match(contactingTokens, true)) {
197
+ if (head.matches(contactingTokens, true)) {
201
198
  hasContactingToken = true;
202
199
  const contactableFiledToken = tail[0];
203
200
  if (!contactableFiledToken) {
204
201
  // Missing autofill field name but it is valid
205
- return (0, match_result_1.matched)();
202
+ return matched();
206
203
  }
207
- if (!contactableFiledToken.match(contactableFieldNames, true)) {
208
- const candidate = (0, get_candidate_1.getCandidate)(contactableFiledToken.value, contactableFieldNames);
204
+ if (!contactableFiledToken.matches(contactableFieldNames, true)) {
205
+ const candidate = getCandidate(contactableFiledToken.value, contactableFieldNames);
209
206
  acLog('[Unmatched ("%s")] Unexpected token: "%s"', value, contactableFiledToken.value);
210
207
  return contactableFiledToken.unmatched({
211
208
  reason: 'unexpected-token',
@@ -218,10 +215,10 @@ const checkAutoComplete = () => value => {
218
215
  });
219
216
  }
220
217
  if (tail[1]) {
221
- if (tail[1].match(webauthnFieldNames)) {
222
- return (0, match_result_1.matched)();
218
+ if (tail[1].matches(webauthnFieldNames)) {
219
+ return matched();
223
220
  }
224
- const candidate = (0, get_candidate_1.getCandidate)(tail[1].value, webauthnFieldNames);
221
+ const candidate = getCandidate(tail[1].value, webauthnFieldNames);
225
222
  if (candidate) {
226
223
  acLog('[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ', value, tail[1].value, candidate);
227
224
  }
@@ -239,14 +236,14 @@ const checkAutoComplete = () => value => {
239
236
  ref: URL_AUTOFILL_FIELD,
240
237
  });
241
238
  }
242
- return (0, match_result_1.matched)();
239
+ return matched();
243
240
  }
244
- if (head.match([...autofillFieldNames, ...contactableFieldNames], true)) {
241
+ if (head.matches([...autofillFieldNames, ...contactableFieldNames], true)) {
245
242
  if (tail[0]) {
246
- if (tail[0].match(webauthnFieldNames)) {
247
- return (0, match_result_1.matched)();
243
+ if (tail[0].matches(webauthnFieldNames)) {
244
+ return matched();
248
245
  }
249
- const candidate = (0, get_candidate_1.getCandidate)(tail[0].value, webauthnFieldNames);
246
+ const candidate = getCandidate(tail[0].value, webauthnFieldNames);
250
247
  if (candidate) {
251
248
  acLog('[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ', value, tail[0].value, candidate);
252
249
  }
@@ -264,10 +261,10 @@ const checkAutoComplete = () => value => {
264
261
  ref: URL_AUTOFILL_FIELD,
265
262
  });
266
263
  }
267
- return (0, match_result_1.matched)();
264
+ return matched();
268
265
  }
269
- if (head.match(webauthnFieldNames)) {
270
- return (0, match_result_1.matched)();
266
+ if (head.matches(webauthnFieldNames)) {
267
+ return matched();
271
268
  }
272
269
  const expects = [
273
270
  {
@@ -283,29 +280,26 @@ const checkAutoComplete = () => value => {
283
280
  });
284
281
  // Potentially typo a named group
285
282
  const [prefix, namedGroupStr] = head.value.split('-');
286
- const candidatePrefix = (0, get_candidate_1.getCandidate)(prefix, 'section');
283
+ const candidatePrefix = getCandidate(prefix, 'section');
287
284
  if (candidatePrefix) {
288
- candidate = `${candidatePrefix}-${namedGroupStr !== null && namedGroupStr !== void 0 ? namedGroupStr : ''}`;
285
+ candidate = `${candidatePrefix}-${namedGroupStr ?? ''}`;
289
286
  }
290
287
  }
291
288
  else if (!hasPartOfAddress) {
292
- expects.unshift(...partOfAddress
293
- .slice()
294
- .reverse()
295
- .map(token => ({
289
+ expects.unshift(...[...partOfAddress].reverse().map(token => ({
296
290
  type: 'const',
297
291
  value: token,
298
292
  })));
299
- candidate = (0, get_candidate_1.getCandidate)(head.value, partOfAddress, autofillFieldNames, contactingTokens, contactableFieldNames);
293
+ candidate = getCandidate(head.value, partOfAddress, autofillFieldNames, contactingTokens, contactableFieldNames);
300
294
  }
301
295
  else if (!hasContactingToken) {
302
296
  expects.push(...contactingTokens.map(token => ({
303
297
  type: 'const',
304
298
  value: token,
305
299
  })));
306
- candidate = (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
300
+ candidate = getCandidate(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
307
301
  }
308
- candidate = candidate !== null && candidate !== void 0 ? candidate : (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames);
302
+ candidate = candidate ?? getCandidate(head.value, autofillFieldNames);
309
303
  if (candidate) {
310
304
  acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value, candidate);
311
305
  }
@@ -319,4 +313,3 @@ const checkAutoComplete = () => value => {
319
313
  ref: URL_AUTOFILL_FIELD,
320
314
  });
321
315
  };
322
- exports.checkAutoComplete = checkAutoComplete;
@@ -1,4 +1,4 @@
1
- import type { CustomSyntaxChecker } from '../../types';
1
+ import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
3
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
4
4
  */
@@ -1,31 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkDateString = void 0;
4
- const debug_1 = require("../../debug");
5
- const token_1 = require("../../token");
6
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { TokenCollection } from '../../token/index.js';
3
+ import { datetimeTokenCheck } from './datetime-tokens.js';
7
4
  /**
8
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
9
6
  */
10
- const checkDateString = () => function checkDateString(value) {
11
- (0, debug_1.log)('CHECK: date-string');
12
- const tokens = token_1.TokenCollection.fromPatterns(value, [
7
+ export const checkDateString = () => function checkDateString(value) {
8
+ log('CHECK: date-string');
9
+ const tokens = TokenCollection.fromPatterns(value, [
13
10
  // YYYY
14
11
  /[^-]*/,
15
12
  // -
16
- /[^0-9]?/,
13
+ /\D?/,
17
14
  // MM
18
15
  /[^-]*/,
19
16
  // -
20
- /[^0-9]/,
17
+ /\D/,
21
18
  // DD
22
- /.[0-9]*/,
19
+ /.\d*/,
23
20
  ]);
24
- (0, debug_1.log)('Date: "%s" => %O', tokens.value, tokens);
25
- const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.date, datetime_tokens_1.datetimeTokenCheck.extra);
21
+ log('Date: "%s" => %O', tokens.value, tokens);
22
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.extra);
26
23
  if (!res.matched) {
27
- (0, debug_1.log)('Failed: %O', res);
24
+ log('Failed: %O', res);
28
25
  }
29
26
  return res;
30
27
  };
31
- exports.checkDateString = checkDateString;
@@ -1,23 +1,3 @@
1
- import type { TokenEachCheck } from '../../token/token-collection';
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>;
1
+ import type { TokenEachCheck } from '../../token/token-collection.js';
2
+ export declare const datetimeTokenCheck: Record<'year' | 'month' | 'date' | 'hour' | 'minute' | 'second' | 'secondFractionalPart' | 'week' | 'hyphen' | 'colon' | 'extra' | 'colonOrEnd' | 'decimalPointOrEnd' | 'localDateTimeSeparator' | 'normalizedlocalDateTimeSeparator' | 'plusOrMinusSign' | 'weekSign', TokenEachCheck> & Record<'_year' | '_month', number | null>;
23
3
  export declare function getMaxWeekNum(year: number): number;