@markuplint/types 3.1.0 → 3.3.0

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.
@@ -132,7 +132,7 @@ const checkAutoComplete = () => value => {
132
132
  // > just autofill detail tokens
133
133
  // > (i.e. the "on" and "off" keywords are not allowed).
134
134
  if (head.match(['on', 'off'], true)) {
135
- if (tail.length) {
135
+ if (tail[0]) {
136
136
  acLog('[Unmatched ("%s")] Unexpected pair with "on" or "off": "%s"', value, tail.value);
137
137
  return tail[0].unmatched({
138
138
  reason: 'extra-token',
@@ -242,7 +242,7 @@ const checkAutoComplete = () => value => {
242
242
  return (0, match_result_1.matched)();
243
243
  }
244
244
  if (head.match([...autofillFieldNames, ...contactableFieldNames], true)) {
245
- if (tail.length) {
245
+ if (tail[0]) {
246
246
  if (tail[0].match(webauthnFieldNames)) {
247
247
  return (0, match_result_1.matched)();
248
248
  }
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // @ts-nocheck
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const check_autocomplete_1 = require("./check-autocomplete");
4
5
  const check = (0, check_autocomplete_1.checkAutoComplete)();
@@ -1,3 +1,23 @@
1
1
  import type { TokenEachCheck } from '../../token/token-collection';
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>;
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>;
3
23
  export declare function getMaxWeekNum(year: number): number;
@@ -95,6 +95,7 @@ exports.datetimeTokenCheck = {
95
95
  * > then the day can be 29, as if the year was a leap year.
96
96
  */
97
97
  date(date) {
98
+ var _a;
98
99
  (0, debug_1.log)('Parsing Datetime Date: "%s"', date === null || date === void 0 ? void 0 : date.value);
99
100
  if (!date || !date.value) {
100
101
  return (0, match_result_1.unmatched)('', 'missing-token', {
@@ -120,7 +121,7 @@ exports.datetimeTokenCheck = {
120
121
  const year = this._year || 2000;
121
122
  const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
122
123
  const month = this._month || 1;
123
- const dayOfMonth = daysOfMonth[month] + (month === 2 && isLeap ? 1 : 0);
124
+ const dayOfMonth = ((_a = daysOfMonth[month]) !== null && _a !== void 0 ? _a : 0) + (month === 2 && isLeap ? 1 : 0);
124
125
  const _date = date.toNumber();
125
126
  (0, debug_1.log)('Temporary Year and Month: %s, %s', this._year, this._month);
126
127
  (0, debug_1.log)('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
@@ -41,6 +41,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
41
41
  return;
42
42
  }
43
43
  const [num, sign, extra] = token_1.TokenCollection.fromPatterns(d, [/[0-9]+/, /./]);
44
+ if (!num) {
45
+ return;
46
+ }
44
47
  (0, debug_1.log)('Date part: "%s" => %O', d.value, { num, sign });
45
48
  if (!num.match(/^[0-9]+$/)) {
46
49
  return num.unmatched({
@@ -121,6 +124,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
121
124
  });
122
125
  }
123
126
  const [num, dpfp, sign] = token_1.TokenCollection.fromPatterns(t, [/[0-9]+/, /(\.[0-9]*)?/, /[^0-9]+/]);
127
+ if (!num) {
128
+ continue;
129
+ }
124
130
  (0, debug_1.log)('Time part (h|m|s): "%s" => %O', t.value, { num, dpfp, sign });
125
131
  if (!num.match(/^[0-9]+$/)) {
126
132
  return num.unmatched({
@@ -131,6 +137,9 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
131
137
  }
132
138
  if (dpfp && dpfp.value) {
133
139
  const [dp, fp] = token_1.TokenCollection.fromPatterns(dpfp, [/\./, /[0-9]+/]);
140
+ if (!dp) {
141
+ continue;
142
+ }
134
143
  (0, debug_1.log)('Second fractional part (h|m|s): "%s" => %O', dpfp.value, { dp, fp });
135
144
  if (!dp.match('.')) {
136
145
  return dp.unmatched({
@@ -91,6 +91,10 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
91
91
  * > if the given time is zero seconds past the minute)
92
92
  */
93
93
  const [, , , , , , , , , , second, , fp] = tokens;
94
+ if (!second || !fp) {
95
+ (0, debug_1.log)('Failed: %O', res);
96
+ return res;
97
+ }
94
98
  const _second = second.toNumber() || 0;
95
99
  const _fp = fp.toNumber() || 0;
96
100
  (0, debug_1.log)('Omitting the seconds component: "%s.%s" => %d, %d', second === null || second === void 0 ? void 0 : second.value, fp === null || fp === void 0 ? void 0 : fp.value, _second, _fp);
@@ -4,4 +4,4 @@ import type { CustomSyntaxChecker } from '../../types';
4
4
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
5
5
  */
6
6
  export declare const checkTimeZoneOffsetString: CustomSyntaxChecker;
7
- export declare function parseTimeZone(zone: string | Token): import("../../types").Result;
7
+ export declare function parseTimeZone(zone: string | Token): import('../../types').Result;
@@ -27,6 +27,7 @@ function parseTimeZone(zone) {
27
27
  ]);
28
28
  (0, debug_1.log)('Time-zone Part: "%s" => %O', value, zoneTokens);
29
29
  const res = zoneTokens.eachCheck((sign, tail) => {
30
+ var _a, _b;
30
31
  if (!sign || !sign.value) {
31
32
  return (0, match_result_1.unmatched)(value, 'missing-token', {
32
33
  expects: [
@@ -39,9 +40,9 @@ function parseTimeZone(zone) {
39
40
  }
40
41
  if (sign.match('Z')) {
41
42
  if (tail.value) {
42
- return tail[0].unmatched({
43
+ return ((_b = (_a = tail[0]) === null || _a === void 0 ? void 0 : _a.unmatched({
43
44
  reason: 'extra-token',
44
- });
45
+ })) !== null && _b !== void 0 ? _b : (0, match_result_1.unmatched)(tail.value, 'extra-token'));
45
46
  }
46
47
  return (0, match_result_1.matched)();
47
48
  }
@@ -4,8 +4,8 @@ import type { CustomSyntaxChecker } from '../types';
4
4
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
5
5
  */
6
6
  export declare const checkMIMEType: CustomSyntaxChecker<{
7
- /**
8
- * @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
9
- */
10
- withoutParameters?: boolean;
7
+ /**
8
+ * @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
9
+ */
10
+ withoutParameters?: boolean;
11
11
  }>;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // @ts-nocheck
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const check_mime_type_1 = require("./check-mime-type");
4
5
  const check = (0, check_mime_type_1.checkMIMEType)();
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // @ts-nocheck
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const is_abs_url_1 = require("./is-abs-url");
4
5
  const is = (0, is_abs_url_1.isAbsURL)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/types",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Type declaration and value checker",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -11,6 +11,9 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
+ "typedoc": {
15
+ "entryPoint": "./src/index.ts"
16
+ },
14
17
  "scripts": {
15
18
  "build": "tsc",
16
19
  "clean": "tsc --build --clean",
@@ -29,5 +32,5 @@
29
32
  "@types/debug": "^4.1.7",
30
33
  "@types/whatwg-mimetype": "2"
31
34
  },
32
- "gitHead": "26b04e045d91e29befca34c10dda2147b1bca9c7"
35
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
33
36
  }