@markuplint/types 3.9.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/lib/check-multi-types.d.ts +2 -2
  2. package/lib/check-multi-types.js +9 -14
  3. package/lib/check.d.ts +1 -1
  4. package/lib/check.js +20 -30
  5. package/lib/css-syntax.d.ts +1 -1
  6. package/lib/css-syntax.js +18 -23
  7. package/lib/debug.js +2 -6
  8. package/lib/defs.d.ts +1 -1
  9. package/lib/defs.js +82 -85
  10. package/lib/enum.d.ts +2 -2
  11. package/lib/enum.js +6 -11
  12. package/lib/get-candidate.js +3 -8
  13. package/lib/index.d.ts +3 -3
  14. package/lib/index.js +3 -6
  15. package/lib/keyword-type.d.ts +2 -2
  16. package/lib/keyword-type.js +17 -22
  17. package/lib/list.d.ts +2 -2
  18. package/lib/list.js +9 -14
  19. package/lib/match-result.d.ts +1 -1
  20. package/lib/match-result.js +6 -13
  21. package/lib/number.d.ts +2 -2
  22. package/lib/number.js +11 -15
  23. package/lib/primitive/index.d.ts +7 -7
  24. package/lib/primitive/index.js +7 -17
  25. package/lib/primitive/is-float.js +1 -5
  26. package/lib/primitive/is-int.js +1 -5
  27. package/lib/primitive/is-non-zero-uint.js +1 -5
  28. package/lib/primitive/is-quantity.js +9 -13
  29. package/lib/primitive/is-uint.js +1 -5
  30. package/lib/primitive/range.js +1 -5
  31. package/lib/primitive/split-unit.js +3 -7
  32. package/lib/rfc/is-bcp-47.d.ts +1 -1
  33. package/lib/rfc/is-bcp-47.js +3 -7
  34. package/lib/token/index.d.ts +2 -2
  35. package/lib/token/index.js +2 -7
  36. package/lib/token/token-collection.d.ts +4 -5
  37. package/lib/token/token-collection.js +35 -43
  38. package/lib/token/token.d.ts +2 -2
  39. package/lib/token/token.js +6 -13
  40. package/lib/token/types.js +1 -2
  41. package/lib/types.d.ts +2 -2
  42. package/lib/types.js +1 -2
  43. package/lib/types.schema.js +1 -2
  44. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  45. package/lib/w3c/check-serialized-permissions-policy.js +16 -20
  46. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  47. package/lib/whatwg/check-autocomplete.js +24 -28
  48. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  49. package/lib/whatwg/check-datetime/date-string.js +9 -13
  50. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
  51. package/lib/whatwg/check-datetime/datetime-tokens.js +40 -46
  52. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  53. package/lib/whatwg/check-datetime/duration-string.js +38 -44
  54. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  55. package/lib/whatwg/check-datetime/global-date-and-time-string.js +17 -21
  56. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  57. package/lib/whatwg/check-datetime/index.js +25 -29
  58. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  59. package/lib/whatwg/check-datetime/local-date-and-time-string.js +20 -25
  60. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  61. package/lib/whatwg/check-datetime/month-string.js +9 -13
  62. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  63. package/lib/whatwg/check-datetime/time-string.js +9 -13
  64. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  65. package/lib/whatwg/check-datetime/time-zone-offset-string.js +16 -22
  66. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  67. package/lib/whatwg/check-datetime/week-string.js +9 -13
  68. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  69. package/lib/whatwg/check-datetime/year-string.js +9 -13
  70. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  71. package/lib/whatwg/check-datetime/yearless-date-string.js +9 -13
  72. package/lib/whatwg/check-mime-type.d.ts +1 -1
  73. package/lib/whatwg/check-mime-type.js +11 -17
  74. package/lib/whatwg/is-abs-url.d.ts +1 -1
  75. package/lib/whatwg/is-abs-url.js +1 -5
  76. package/lib/whatwg/is-browser-context-name.d.ts +1 -1
  77. package/lib/whatwg/is-browser-context-name.js +1 -5
  78. package/lib/whatwg/is-custom-element-name.d.ts +1 -1
  79. package/lib/whatwg/is-custom-element-name.js +1 -5
  80. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  81. package/lib/whatwg/is-itemprop-name.js +1 -5
  82. package/package.json +13 -8
  83. package/test/check.spec.js +0 -89
  84. package/test/css-syntax.spec.js +0 -170
  85. package/test/list.spec.js +0 -133
  86. package/test/primitive/index.spec.js +0 -65
  87. package/test/rfc/is-bcp-47.spec.js +0 -23
  88. package/test/token/token-collection.spec.js +0 -146
  89. package/test/w3c/check-serialized-permissions-policy.spec.js +0 -36
  90. package/test/whatwg/check-autocomplete.spec.js +0 -387
  91. package/test/whatwg/check-datetime/index.spec.js +0 -336
  92. package/test/whatwg/check-mime-type.spec.js +0 -59
  93. package/test/whatwg/is-abs-url.spec.js +0 -8
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMaxWeekNum = exports.datetimeTokenCheck = void 0;
4
- const debug_1 = require("../../debug");
5
- const match_result_1 = require("../../match-result");
6
- exports.datetimeTokenCheck = {
1
+ import { log } from '../../debug.js';
2
+ import { matched, unmatched } from '../../match-result.js';
3
+ export const datetimeTokenCheck = {
7
4
  /**
8
5
  * Temporary year state
9
6
  */
@@ -16,10 +13,10 @@ exports.datetimeTokenCheck = {
16
13
  * > Four or more ASCII digits, representing year, where year > 0
17
14
  */
18
15
  year(year) {
19
- (0, debug_1.log)('Parsing Datetime Year: "%s"', year === null || year === void 0 ? void 0 : year.value);
16
+ log('Parsing Datetime Year: "%s"', year?.value);
20
17
  this._year = null;
21
18
  if (!year || !year.value) {
22
- return (0, match_result_1.unmatched)('', 'missing-token', {
19
+ return unmatched('', 'missing-token', {
23
20
  expects: [{ type: 'common', value: 'year' }],
24
21
  partName: 'year',
25
22
  });
@@ -51,10 +48,10 @@ exports.datetimeTokenCheck = {
51
48
  * > Two ASCII digits, representing the month month, in the range 1 ≤ month ≤ 12
52
49
  */
53
50
  month(month) {
54
- (0, debug_1.log)('Parsing Datetime Month: "%s"', month === null || month === void 0 ? void 0 : month.value);
51
+ log('Parsing Datetime Month: "%s"', month?.value);
55
52
  this._month = null;
56
53
  if (!month || !month.value) {
57
- return (0, match_result_1.unmatched)('', 'missing-token', {
54
+ return unmatched('', 'missing-token', {
58
55
  expects: [{ type: 'common', value: 'month' }],
59
56
  partName: 'month',
60
57
  });
@@ -95,10 +92,9 @@ exports.datetimeTokenCheck = {
95
92
  * > then the day can be 29, as if the year was a leap year.
96
93
  */
97
94
  date(date) {
98
- var _a, _b, _c;
99
- (0, debug_1.log)('Parsing Datetime Date: "%s"', date === null || date === void 0 ? void 0 : date.value);
95
+ log('Parsing Datetime Date: "%s"', date?.value);
100
96
  if (!date || !date.value) {
101
- return (0, match_result_1.unmatched)('', 'missing-token', {
97
+ return unmatched('', 'missing-token', {
102
98
  expects: [{ type: 'common', value: 'date' }],
103
99
  partName: 'date',
104
100
  });
@@ -118,13 +114,13 @@ exports.datetimeTokenCheck = {
118
114
  });
119
115
  }
120
116
  // Set the leap year if _year is null
121
- const year = (_a = this._year) !== null && _a !== void 0 ? _a : 2000;
117
+ const year = this._year ?? 2000;
122
118
  const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
123
- const month = (_b = this._month) !== null && _b !== void 0 ? _b : 1;
124
- const dayOfMonth = ((_c = daysOfMonth[month]) !== null && _c !== void 0 ? _c : 0) + (month === 2 && isLeap ? 1 : 0);
119
+ const month = this._month ?? 1;
120
+ const dayOfMonth = (daysOfMonth[month] ?? 0) + (month === 2 && isLeap ? 1 : 0);
125
121
  const _date = date.toNumber();
126
- (0, debug_1.log)('Temporary Year and Month: %s, %s', this._year, this._month);
127
- (0, debug_1.log)('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
122
+ log('Temporary Year and Month: %s, %s', this._year, this._month);
123
+ log('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
128
124
  if (!(1 <= _date && _date <= dayOfMonth)) {
129
125
  return date.unmatched({
130
126
  reason: { type: 'out-of-range', gte: 1, lte: dayOfMonth },
@@ -137,9 +133,9 @@ exports.datetimeTokenCheck = {
137
133
  * > Two ASCII digits, representing hour, in the range 0 ≤ hour ≤ 23
138
134
  */
139
135
  hour(hour) {
140
- (0, debug_1.log)('Parsing Datetime Hour: "%s"', hour === null || hour === void 0 ? void 0 : hour.value);
136
+ log('Parsing Datetime Hour: "%s"', hour?.value);
141
137
  if (!hour || !hour.value) {
142
- return (0, match_result_1.unmatched)('', 'missing-token', {
138
+ return unmatched('', 'missing-token', {
143
139
  expects: [{ type: 'common', value: 'hour' }],
144
140
  partName: 'hour',
145
141
  });
@@ -171,9 +167,9 @@ exports.datetimeTokenCheck = {
171
167
  * > Two ASCII digits, representing minute, in the range 0 ≤ minute ≤ 59
172
168
  */
173
169
  minute(minute) {
174
- (0, debug_1.log)('Parsing Datetime Minute: "%s"', minute === null || minute === void 0 ? void 0 : minute.value);
170
+ log('Parsing Datetime Minute: "%s"', minute?.value);
175
171
  if (!minute || !minute.value) {
176
- return (0, match_result_1.unmatched)('', 'missing-token', {
172
+ return unmatched('', 'missing-token', {
177
173
  expects: [{ type: 'common', value: 'minute' }],
178
174
  partName: 'minute',
179
175
  });
@@ -205,9 +201,9 @@ exports.datetimeTokenCheck = {
205
201
  * > Two ASCII digits, representing the integer part of second, in the range 0 ≤ s ≤ 59
206
202
  */
207
203
  second(second) {
208
- (0, debug_1.log)('Parsing Datetime Second: "%s"', second === null || second === void 0 ? void 0 : second.value);
204
+ log('Parsing Datetime Second: "%s"', second?.value);
209
205
  if (!second || !second.value) {
210
- return (0, match_result_1.unmatched)('', 'missing-token', {
206
+ return unmatched('', 'missing-token', {
211
207
  expects: [{ type: 'common', value: 'second' }],
212
208
  partName: 'second',
213
209
  });
@@ -239,9 +235,9 @@ exports.datetimeTokenCheck = {
239
235
  * > One, two, or three ASCII digits, representing the fractional part of second
240
236
  */
241
237
  secondFractionalPart(secondFP) {
242
- (0, debug_1.log)('Parsing Datetime Second Fractional Part: "%s"', secondFP === null || secondFP === void 0 ? void 0 : secondFP.value);
238
+ log('Parsing Datetime Second Fractional Part: "%s"', secondFP?.value);
243
239
  if (!secondFP || !secondFP.value) {
244
- return (0, match_result_1.unmatched)('', 'missing-token', {
240
+ return unmatched('', 'missing-token', {
245
241
  expects: [{ type: 'common', value: 'fractional part' }],
246
242
  partName: 'fractional part',
247
243
  });
@@ -265,10 +261,9 @@ exports.datetimeTokenCheck = {
265
261
  * > Two ASCII digits, representing the week week, in the range 1 ≤ week ≤ maxweek, where maxweek is the week number of the last day of week-year year
266
262
  */
267
263
  week(week) {
268
- var _a;
269
- (0, debug_1.log)('Parsing Datetime Week: "%s"', week === null || week === void 0 ? void 0 : week.value);
264
+ log('Parsing Datetime Week: "%s"', week?.value);
270
265
  if (!week || !week.value) {
271
- return (0, match_result_1.unmatched)('', 'missing-token', {
266
+ return unmatched('', 'missing-token', {
272
267
  expects: [{ type: 'common', value: 'week' }],
273
268
  partName: 'week',
274
269
  });
@@ -287,7 +282,7 @@ exports.datetimeTokenCheck = {
287
282
  partName: 'week',
288
283
  });
289
284
  }
290
- const maxweek = getMaxWeekNum((_a = this._year) !== null && _a !== void 0 ? _a : 0);
285
+ const maxweek = getMaxWeekNum(this._year ?? 0);
291
286
  const _week = week.toNumber();
292
287
  if (!(1 <= _week && _week <= maxweek)) {
293
288
  return week.unmatched({
@@ -301,9 +296,9 @@ exports.datetimeTokenCheck = {
301
296
  * > A U+002D HYPHEN-MINUS character (-)
302
297
  */
303
298
  hyphen(hyphen) {
304
- (0, debug_1.log)('Parsing Datetime hyphen: "%s"', hyphen === null || hyphen === void 0 ? void 0 : hyphen.value);
299
+ log('Parsing Datetime hyphen: "%s"', hyphen?.value);
305
300
  if (!hyphen || !hyphen.value) {
306
- return (0, match_result_1.unmatched)('', 'missing-token', {
301
+ return unmatched('', 'missing-token', {
307
302
  expects: [{ type: 'common', value: 'hyphen' }],
308
303
  partName: 'datetime',
309
304
  });
@@ -320,9 +315,9 @@ exports.datetimeTokenCheck = {
320
315
  * > A U+003A COLON character (:)
321
316
  */
322
317
  colon(colon) {
323
- (0, debug_1.log)('Parsing Datetime colon: "%s"', colon === null || colon === void 0 ? void 0 : colon.value);
318
+ log('Parsing Datetime colon: "%s"', colon?.value);
324
319
  if (!colon || !colon.value) {
325
- return (0, match_result_1.unmatched)('', 'missing-token', {
320
+ return unmatched('', 'missing-token', {
326
321
  expects: [{ type: 'common', value: 'colon' }],
327
322
  partName: 'time',
328
323
  });
@@ -342,7 +337,7 @@ exports.datetimeTokenCheck = {
342
337
  */
343
338
  colonOrEnd(colon) {
344
339
  if (!colon || !colon.value) {
345
- return (0, match_result_1.matched)();
340
+ return matched();
346
341
  }
347
342
  if (!colon.match(':')) {
348
343
  return colon.unmatched({
@@ -359,7 +354,7 @@ exports.datetimeTokenCheck = {
359
354
  */
360
355
  decimalPointOrEnd(dot) {
361
356
  if (!dot || !dot.value) {
362
- return (0, match_result_1.matched)();
357
+ return matched();
363
358
  }
364
359
  if (!dot.match('.')) {
365
360
  return dot.unmatched({
@@ -373,9 +368,9 @@ exports.datetimeTokenCheck = {
373
368
  * > A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character
374
369
  */
375
370
  localDateTimeSeparator(sep) {
376
- (0, debug_1.log)('Parsing Datetime Local-Date-Time separator: "%s"', sep === null || sep === void 0 ? void 0 : sep.value);
371
+ log('Parsing Datetime Local-Date-Time separator: "%s"', sep?.value);
377
372
  if (!sep || !sep.value) {
378
- return (0, match_result_1.unmatched)('', 'missing-token', {
373
+ return unmatched('', 'missing-token', {
379
374
  expects: [
380
375
  { type: 'const', value: 'T' },
381
376
  { type: 'common', value: 'space' },
@@ -396,9 +391,9 @@ exports.datetimeTokenCheck = {
396
391
  * > A U+0054 LATIN CAPITAL LETTER T character (T)
397
392
  */
398
393
  normalizedlocalDateTimeSeparator(sep) {
399
- (0, debug_1.log)('Parsing Datetime Normalized-Local-Date-Time separator: %s', sep === null || sep === void 0 ? void 0 : sep.value);
394
+ log('Parsing Datetime Normalized-Local-Date-Time separator: %s', sep?.value);
400
395
  if (!sep || !sep.value) {
401
- return (0, match_result_1.unmatched)('', 'missing-token', {
396
+ return unmatched('', 'missing-token', {
402
397
  expects: [{ type: 'const', value: 'T' }],
403
398
  });
404
399
  }
@@ -417,7 +412,7 @@ exports.datetimeTokenCheck = {
417
412
  */
418
413
  plusOrMinusSign(colon) {
419
414
  if (!colon) {
420
- return (0, match_result_1.unmatched)('', 'missing-token', {
415
+ return unmatched('', 'missing-token', {
421
416
  expects: [
422
417
  { type: 'const', value: '+' },
423
418
  { type: 'const', value: '-' },
@@ -440,9 +435,9 @@ exports.datetimeTokenCheck = {
440
435
  * > A U+0057 LATIN CAPITAL LETTER W character (W)
441
436
  */
442
437
  weekSign(weekSign) {
443
- (0, debug_1.log)('Parsing Datetime W sign: "%s"', weekSign === null || weekSign === void 0 ? void 0 : weekSign.value);
438
+ log('Parsing Datetime W sign: "%s"', weekSign?.value);
444
439
  if (!weekSign || !weekSign.value) {
445
- return (0, match_result_1.unmatched)('', 'missing-token', {
440
+ return unmatched('', 'missing-token', {
446
441
  expects: [{ type: 'const', value: 'W' }],
447
442
  partName: 'time-zone',
448
443
  });
@@ -459,7 +454,7 @@ exports.datetimeTokenCheck = {
459
454
  * Extra token
460
455
  */
461
456
  extra(extra) {
462
- (0, debug_1.log)('Parsing Datetime EXTRA STRING: "%s"', extra === null || extra === void 0 ? void 0 : extra.value);
457
+ log('Parsing Datetime EXTRA STRING: "%s"', extra?.value);
463
458
  if (extra && extra.value) {
464
459
  return extra.unmatched({
465
460
  reason: 'extra-token',
@@ -494,7 +489,7 @@ const daysOfMonth = [
494
489
  // 12
495
490
  31,
496
491
  ];
497
- function getMaxWeekNum(year) {
492
+ export function getMaxWeekNum(year) {
498
493
  let date = 31;
499
494
  while (date > 0) {
500
495
  const d = new Date(Date.UTC(year, 11, date, 0, 0, 0, 0));
@@ -509,4 +504,3 @@ function getMaxWeekNum(year) {
509
504
  }
510
505
  return NaN;
511
506
  }
512
- exports.getMaxWeekNum = getMaxWeekNum;
@@ -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#durations
4
4
  */
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkDurationComponentListString = exports.checkDurationISO8601LikeString = void 0;
4
- const debug_1 = require("../../debug");
5
- const match_result_1 = require("../../match-result");
6
- const token_1 = require("../../token");
7
- const datetime_tokens_1 = require("./datetime-tokens");
1
+ import { log } from '../../debug.js';
2
+ import { matched, unmatched } from '../../match-result.js';
3
+ import { TokenCollection } from '../../token/index.js';
4
+ import { datetimeTokenCheck } from './datetime-tokens.js';
8
5
  /**
9
6
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#durations
10
7
  */
11
- const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeString(value) {
12
- (0, debug_1.log)('CHECK: duration-string (ISO8601 like)');
8
+ export const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeString(value) {
9
+ log('CHECK: duration-string (ISO8601 like)');
13
10
  // PnDTnHnMnS
14
- const tokens = token_1.TokenCollection.fromPatterns(value, [
11
+ const tokens = TokenCollection.fromPatterns(value, [
15
12
  // Start sign P
16
13
  /[^0-9T]?/,
17
14
  // date part
@@ -21,10 +18,10 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
21
18
  // Time part
22
19
  /.*/,
23
20
  ]);
24
- (0, debug_1.log)('Duration ISO8601: "%s" => %O', tokens.value, tokens);
21
+ log('Duration ISO8601: "%s" => %O', tokens.value, tokens);
25
22
  const res = tokens.eachCheck(p => {
26
23
  if (!p || !p.value) {
27
- return (0, match_result_1.unmatched)('', 'missing-token', {
24
+ return unmatched('', 'missing-token', {
28
25
  expects: [{ type: 'const', value: 'P' }],
29
26
  partName: 'duration',
30
27
  });
@@ -40,11 +37,11 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
40
37
  if (!d || !d.value) {
41
38
  return;
42
39
  }
43
- const [num, sign, extra] = token_1.TokenCollection.fromPatterns(d, [/[0-9]+/, /./]);
40
+ const [num, sign, extra] = TokenCollection.fromPatterns(d, [/[0-9]+/, /./]);
44
41
  if (!num) {
45
42
  return;
46
43
  }
47
- (0, debug_1.log)('Date part: "%s" => %O', d.value, { num, sign });
44
+ log('Date part: "%s" => %O', d.value, { num, sign });
48
45
  if (!num.match(/^[0-9]+$/)) {
49
46
  return num.unmatched({
50
47
  reason: 'unexpected-token',
@@ -53,7 +50,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
53
50
  });
54
51
  }
55
52
  if (!sign || !sign.value) {
56
- return (0, match_result_1.unmatched)('', 'missing-token', {
53
+ return unmatched('', 'missing-token', {
57
54
  expects: [{ type: 'const', value: 'D' }],
58
55
  partName: 'date',
59
56
  });
@@ -73,7 +70,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
73
70
  }
74
71
  }, t => {
75
72
  if (!t || !t.value) {
76
- return (0, match_result_1.unmatched)('', 'missing-token', {
73
+ return unmatched('', 'missing-token', {
77
74
  expects: [{ type: 'const', value: 'T' }],
78
75
  });
79
76
  }
@@ -84,9 +81,8 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
84
81
  });
85
82
  }
86
83
  }, time => {
87
- var _a, _b, _c;
88
84
  if (!time) {
89
- return (0, match_result_1.unmatched)('', 'missing-token', {
85
+ return unmatched('', 'missing-token', {
90
86
  expects: [
91
87
  { type: 'common', value: 'hour' },
92
88
  { type: 'common', value: 'minute' },
@@ -95,7 +91,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
95
91
  partName: 'time',
96
92
  });
97
93
  }
98
- const timeTokens = token_1.TokenCollection.fromPatterns(time, [
94
+ const timeTokens = TokenCollection.fromPatterns(time, [
99
95
  // Hour part
100
96
  /[0-9]+(\.[0-9]*)?[^0-9]?/,
101
97
  // Minute part
@@ -103,10 +99,10 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
103
99
  // Second part
104
100
  /[0-9]+(\.[0-9]*)?[^0-9]?/,
105
101
  ]);
106
- (0, debug_1.log)('Time part: "%s" => %O', timeTokens.value, timeTokens);
102
+ log('Time part: "%s" => %O', timeTokens.value, timeTokens);
107
103
  const [h, m, s] = timeTokens;
108
- if (((_a = h === null || h === void 0 ? void 0 : h.value) !== null && _a !== void 0 ? _a : '') + ((_b = m === null || m === void 0 ? void 0 : m.value) !== null && _b !== void 0 ? _b : '') + ((_c = s === null || s === void 0 ? void 0 : s.value) !== null && _c !== void 0 ? _c : '') === '') {
109
- return (0, match_result_1.unmatched)('', 'missing-token', {
104
+ if ((h?.value ?? '') + (m?.value ?? '') + (s?.value ?? '') === '') {
105
+ return unmatched('', 'missing-token', {
110
106
  expects: [
111
107
  { type: 'common', value: 'hour' },
112
108
  { type: 'common', value: 'minute' },
@@ -124,11 +120,11 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
124
120
  reason: 'extra-token',
125
121
  });
126
122
  }
127
- const [num, dpfp, sign] = token_1.TokenCollection.fromPatterns(t, [/[0-9]+/, /(\.[0-9]*)?/, /[^0-9]+/]);
123
+ const [num, dpfp, sign] = TokenCollection.fromPatterns(t, [/[0-9]+/, /(\.[0-9]*)?/, /[^0-9]+/]);
128
124
  if (!num) {
129
125
  continue;
130
126
  }
131
- (0, debug_1.log)('Time part (h|m|s): "%s" => %O', t.value, { num, dpfp, sign });
127
+ log('Time part (h|m|s): "%s" => %O', t.value, { num, dpfp, sign });
132
128
  if (!num.match(/^[0-9]+$/)) {
133
129
  return num.unmatched({
134
130
  reason: 'unexpected-token',
@@ -137,11 +133,11 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
137
133
  });
138
134
  }
139
135
  if (dpfp && dpfp.value) {
140
- const [dp, fp] = token_1.TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
136
+ const [dp, fp] = TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
141
137
  if (!dp) {
142
138
  continue;
143
139
  }
144
- (0, debug_1.log)('Second fractional part (h|m|s): "%s" => %O', dpfp.value, { dp, fp });
140
+ log('Second fractional part (h|m|s): "%s" => %O', dpfp.value, { dp, fp });
145
141
  if (!dp.match('.')) {
146
142
  return dp.unmatched({
147
143
  reason: 'unexpected-token',
@@ -150,7 +146,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
150
146
  });
151
147
  }
152
148
  if (!fp || !fp.value) {
153
- return (0, match_result_1.unmatched)('', 'missing-token', {
149
+ return unmatched('', 'missing-token', {
154
150
  expects: [{ type: 'common', value: 'fractional part' }],
155
151
  partName: 'second',
156
152
  });
@@ -176,7 +172,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
176
172
  { type: 'const', value: 'S' },
177
173
  ];
178
174
  if (!sign || !sign.value) {
179
- return (0, match_result_1.unmatched)('', 'missing-token', {
175
+ return unmatched('', 'missing-token', {
180
176
  expects: expects.filter(e => !specified.has(e.value)),
181
177
  partName: 'time',
182
178
  });
@@ -199,17 +195,16 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
199
195
  }
200
196
  specified.add(sign.value);
201
197
  }
202
- }, datetime_tokens_1.datetimeTokenCheck.extra);
198
+ }, datetimeTokenCheck.extra);
203
199
  if (!res.matched) {
204
- (0, debug_1.log)('Failed: %O', res);
200
+ log('Failed: %O', res);
205
201
  }
206
202
  return res;
207
203
  };
208
- exports.checkDurationISO8601LikeString = checkDurationISO8601LikeString;
209
- const checkDurationComponentListString = () => function checkDurationComponentListString(value) {
210
- (0, debug_1.log)('CHECK: duration-string (duration component list)');
204
+ export const checkDurationComponentListString = () => function checkDurationComponentListString(value) {
205
+ log('CHECK: duration-string (duration component list)');
211
206
  if (!value) {
212
- return (0, match_result_1.unmatched)('', 'empty-token', {
207
+ return unmatched('', 'empty-token', {
213
208
  expects: [{ type: 'common', value: 'time' }],
214
209
  });
215
210
  }
@@ -232,16 +227,16 @@ const checkDurationComponentListString = () => function checkDurationComponentLi
232
227
  // 6. Zero or more ASCII whitespace.
233
228
  /\s*/,
234
229
  ];
235
- const tokens = token_1.TokenCollection.fromPatterns(value, patterns, { repeat: true });
230
+ const tokens = TokenCollection.fromPatterns(value, patterns, { repeat: true });
236
231
  const components = tokens.chunk(patterns.length);
237
232
  const specified = new Set();
238
233
  for (const component of components) {
239
- (0, debug_1.log)('Duration Component: "%s" => %O', component.value, component);
234
+ log('Duration Component: "%s" => %O', component.value, component);
240
235
  const [, , dpfp, , unit] = component;
241
236
  const res = component.eachCheck(ws => { }, num => {
242
237
  if (!num || !num.value) {
243
- const reason = (dpfp === null || dpfp === void 0 ? void 0 : dpfp.value) || (unit === null || unit === void 0 ? void 0 : unit.value) ? 'unexpected-token' : 'missing-token';
244
- return (0, match_result_1.unmatched)('', reason, {
238
+ const reason = dpfp?.value || unit?.value ? 'unexpected-token' : 'missing-token';
239
+ return unmatched('', reason, {
245
240
  expects: [{ type: 'common', value: 'time' }],
246
241
  });
247
242
  }
@@ -263,9 +258,9 @@ const checkDurationComponentListString = () => function checkDurationComponentLi
263
258
  partName: 'unit',
264
259
  });
265
260
  }
266
- const [, fp] = token_1.TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
261
+ const [, fp] = TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
267
262
  if (!fp || !fp.value) {
268
- return (0, match_result_1.unmatched)('', 'missing-token', {
263
+ return unmatched('', 'missing-token', {
269
264
  expects: [{ type: 'common', value: 'fractional part' }],
270
265
  partName: 'fractional part',
271
266
  });
@@ -293,7 +288,7 @@ const checkDurationComponentListString = () => function checkDurationComponentLi
293
288
  { type: 'const', value: 's' },
294
289
  ].filter(e => !specified.has(e.value));
295
290
  if (!unit || !unit.value) {
296
- return (0, match_result_1.unmatched)('', 'missing-token', {
291
+ return unmatched('', 'missing-token', {
297
292
  expects,
298
293
  partName: 'unit',
299
294
  });
@@ -323,10 +318,9 @@ const checkDurationComponentListString = () => function checkDurationComponentLi
323
318
  specified.add(unitVal);
324
319
  }, ws => { });
325
320
  if (!res.matched) {
326
- (0, debug_1.log)('Failed: %O', res);
321
+ log('Failed: %O', res);
327
322
  return res;
328
323
  }
329
324
  }
330
- return (0, match_result_1.matched)();
325
+ return matched();
331
326
  };
332
- exports.checkDurationComponentListString = checkDurationComponentListString;
@@ -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#global-dates-and-times
4
4
  */
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkGlobalDateAndTimeString = void 0;
4
- const debug_1 = require("../../debug");
5
- const match_result_1 = require("../../match-result");
6
- const token_1 = require("../../token");
7
- const datetime_tokens_1 = require("./datetime-tokens");
8
- const time_zone_offset_string_1 = require("./time-zone-offset-string");
1
+ import { log } from '../../debug.js';
2
+ import { unmatched } from '../../match-result.js';
3
+ import { TokenCollection } from '../../token/index.js';
4
+ import { datetimeTokenCheck } from './datetime-tokens.js';
5
+ import { parseTimeZone } from './time-zone-offset-string.js';
9
6
  /**
10
7
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#global-dates-and-times
11
8
  */
12
- const checkGlobalDateAndTimeString = () => function checkGlobalDateAndTimeString(value) {
13
- (0, debug_1.log)('CHECK: global-date-and-time-string');
14
- const tokens = token_1.TokenCollection.fromPatterns(value, [
9
+ export const checkGlobalDateAndTimeString = () => function checkGlobalDateAndTimeString(value) {
10
+ log('CHECK: global-date-and-time-string');
11
+ const tokens = TokenCollection.fromPatterns(value, [
15
12
  // YYYY
16
13
  /[^-]*/,
17
14
  // -
@@ -35,32 +32,31 @@ const checkGlobalDateAndTimeString = () => function checkGlobalDateAndTimeString
35
32
  // time-zone
36
33
  /.*/,
37
34
  ]);
38
- (0, debug_1.log)('Global Date and Time "%s" => %O', tokens.value, tokens);
39
- 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.localDateTimeSeparator, datetime_tokens_1.datetimeTokenCheck.hour, datetime_tokens_1.datetimeTokenCheck.colon, datetime_tokens_1.datetimeTokenCheck.minute, second => {
35
+ log('Global Date and Time "%s" => %O', tokens.value, tokens);
36
+ const res = tokens.eachCheck(datetimeTokenCheck.year, datetimeTokenCheck.hyphen, datetimeTokenCheck.month, datetimeTokenCheck.hyphen, datetimeTokenCheck.date, datetimeTokenCheck.localDateTimeSeparator, datetimeTokenCheck.hour, datetimeTokenCheck.colon, datetimeTokenCheck.minute, second => {
40
37
  if (!second || !second.value) {
41
38
  return;
42
39
  }
43
- const secondTokens = token_1.TokenCollection.fromPatterns(second, [/:?/, /[0-9]*/, /\.?/, /[0-9]*/]);
44
- (0, debug_1.log)('Second Part: "%s" => %O', secondTokens.value, secondTokens);
45
- const res = secondTokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.colon, datetime_tokens_1.datetimeTokenCheck.second, datetime_tokens_1.datetimeTokenCheck.decimalPointOrEnd, datetime_tokens_1.datetimeTokenCheck.secondFractionalPart);
40
+ const secondTokens = TokenCollection.fromPatterns(second, [/:?/, /[0-9]*/, /\.?/, /[0-9]*/]);
41
+ log('Second Part: "%s" => %O', secondTokens.value, secondTokens);
42
+ const res = secondTokens.eachCheck(datetimeTokenCheck.colon, datetimeTokenCheck.second, datetimeTokenCheck.decimalPointOrEnd, datetimeTokenCheck.secondFractionalPart);
46
43
  if (!res.matched) {
47
44
  return res;
48
45
  }
49
46
  }, zone => {
50
47
  if (!zone || !zone.value) {
51
- return (0, match_result_1.unmatched)(value, 'missing-token', {
48
+ return unmatched(value, 'missing-token', {
52
49
  expects: [{ type: 'common', value: 'time-zone' }],
53
50
  partName: 'time-zone',
54
51
  });
55
52
  }
56
- const res = (0, time_zone_offset_string_1.parseTimeZone)(zone);
53
+ const res = parseTimeZone(zone);
57
54
  if (!res.matched) {
58
55
  return res;
59
56
  }
60
- }, datetime_tokens_1.datetimeTokenCheck.extra);
57
+ }, datetimeTokenCheck.extra);
61
58
  if (!res.matched) {
62
- (0, debug_1.log)('Failed: %O', res);
59
+ log('Failed: %O', res);
63
60
  }
64
61
  return res;
65
62
  };
66
- exports.checkGlobalDateAndTimeString = checkGlobalDateAndTimeString;
@@ -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-and-times
4
4
  */
@@ -1,35 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkDateTime = void 0;
4
- const check_multi_types_1 = require("../../check-multi-types");
5
- const date_string_1 = require("./date-string");
6
- const duration_string_1 = require("./duration-string");
7
- const global_date_and_time_string_1 = require("./global-date-and-time-string");
8
- const local_date_and_time_string_1 = require("./local-date-and-time-string");
9
- const month_string_1 = require("./month-string");
10
- const time_string_1 = require("./time-string");
11
- const time_zone_offset_string_1 = require("./time-zone-offset-string");
12
- const week_string_1 = require("./week-string");
13
- const year_string_1 = require("./year-string");
14
- const yearless_date_string_1 = require("./yearless-date-string");
1
+ import { checkMultiTypes } from '../../check-multi-types.js';
2
+ import { checkDateString } from './date-string.js';
3
+ import { checkDurationComponentListString, checkDurationISO8601LikeString } from './duration-string.js';
4
+ import { checkGlobalDateAndTimeString } from './global-date-and-time-string.js';
5
+ import { checkLocalDateAndTimeString, checkNormalizedLocalDateAndTimeString } from './local-date-and-time-string.js';
6
+ import { checkMonthString } from './month-string.js';
7
+ import { checkTimeString } from './time-string.js';
8
+ import { checkTimeZoneOffsetString } from './time-zone-offset-string.js';
9
+ import { checkWeekString } from './week-string.js';
10
+ import { checkYearString } from './year-string.js';
11
+ import { checkYearlessDateString } from './yearless-date-string.js';
15
12
  const checks = [
16
- (0, date_string_1.checkDateString)(),
17
- (0, time_string_1.checkTimeString)(),
18
- (0, month_string_1.checkMonthString)(),
19
- (0, yearless_date_string_1.checkYearlessDateString)(),
20
- (0, local_date_and_time_string_1.checkLocalDateAndTimeString)(),
21
- (0, local_date_and_time_string_1.checkNormalizedLocalDateAndTimeString)(),
22
- (0, time_zone_offset_string_1.checkTimeZoneOffsetString)(),
23
- (0, global_date_and_time_string_1.checkGlobalDateAndTimeString)(),
24
- (0, week_string_1.checkWeekString)(),
25
- (0, year_string_1.checkYearString)(),
26
- (0, duration_string_1.checkDurationISO8601LikeString)(),
27
- (0, duration_string_1.checkDurationComponentListString)(),
13
+ checkDateString(),
14
+ checkTimeString(),
15
+ checkMonthString(),
16
+ checkYearlessDateString(),
17
+ checkLocalDateAndTimeString(),
18
+ checkNormalizedLocalDateAndTimeString(),
19
+ checkTimeZoneOffsetString(),
20
+ checkGlobalDateAndTimeString(),
21
+ checkWeekString(),
22
+ checkYearString(),
23
+ checkDurationISO8601LikeString(),
24
+ checkDurationComponentListString(),
28
25
  ];
29
26
  /**
30
27
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates-and-times
31
28
  */
32
- const checkDateTime = () => value => {
33
- return (0, check_multi_types_1.checkMultiTypes)(value, checks);
29
+ export const checkDateTime = () => value => {
30
+ return checkMultiTypes(value, checks);
34
31
  };
35
- exports.checkDateTime = checkDateTime;
@@ -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#valid-local-date-and-time-string
4
4
  */