@markuplint/types 3.0.0-alpha.1 → 3.0.0-alpha.27

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 (75) hide show
  1. package/README.md +12 -8
  2. package/lib/check-multi-types.d.ts +1 -1
  3. package/lib/css-syntax.js +6 -6
  4. package/lib/defs.js +1 -0
  5. package/lib/get-candidate.d.ts +1 -1
  6. package/lib/match-result.d.ts +1 -1
  7. package/lib/token/token-collection.d.ts +3 -3
  8. package/lib/token/token-collection.js +47 -47
  9. package/lib/token/token.d.ts +1 -1
  10. package/lib/token/token.js +7 -7
  11. package/lib/types.d.ts +16 -16
  12. package/lib/types.schema.d.ts +5 -5
  13. package/package.json +7 -5
  14. package/patches/css-tree+2.3.1.patch +23 -0
  15. package/types.schema.json +67 -16
  16. package/gen/specific-schema.json +0 -98
  17. package/gen/types.ts +0 -66
  18. package/src/check-multi-types.ts +0 -35
  19. package/src/check.spec.ts +0 -83
  20. package/src/check.ts +0 -48
  21. package/src/css-syntax.spec.ts +0 -167
  22. package/src/css-syntax.ts +0 -188
  23. package/src/debug.ts +0 -3
  24. package/src/defs.ts +0 -810
  25. package/src/enum.ts +0 -25
  26. package/src/get-candidate.ts +0 -24
  27. package/src/index.ts +0 -3
  28. package/src/keyword-type.ts +0 -64
  29. package/src/list.spec.ts +0 -133
  30. package/src/list.ts +0 -34
  31. package/src/match-result.ts +0 -49
  32. package/src/number.ts +0 -46
  33. package/src/primitive/index.spec.ts +0 -65
  34. package/src/primitive/index.ts +0 -7
  35. package/src/primitive/is-float.ts +0 -8
  36. package/src/primitive/is-int.ts +0 -8
  37. package/src/primitive/is-non-zero-uint.ts +0 -8
  38. package/src/primitive/is-quantity.ts +0 -38
  39. package/src/primitive/is-uint.ts +0 -15
  40. package/src/primitive/range.ts +0 -14
  41. package/src/primitive/split-unit.ts +0 -20
  42. package/src/rfc/is-bcp-47.spec.ts +0 -23
  43. package/src/rfc/is-bcp-47.ts +0 -13
  44. package/src/token/index.ts +0 -2
  45. package/src/token/token-collection.spec.ts +0 -147
  46. package/src/token/token-collection.ts +0 -444
  47. package/src/token/token.ts +0 -144
  48. package/src/types.schema.ts +0 -1062
  49. package/src/types.ts +0 -118
  50. package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
  51. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  52. package/src/whatwg/check-autocomplete.spec.ts +0 -387
  53. package/src/whatwg/check-autocomplete.ts +0 -380
  54. package/src/whatwg/check-datetime/date-string.ts +0 -44
  55. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  56. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  57. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  58. package/src/whatwg/check-datetime/index.spec.ts +0 -333
  59. package/src/whatwg/check-datetime/index.ts +0 -36
  60. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  61. package/src/whatwg/check-datetime/month-string.ts +0 -31
  62. package/src/whatwg/check-datetime/time-string.ts +0 -49
  63. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  64. package/src/whatwg/check-datetime/week-string.ts +0 -41
  65. package/src/whatwg/check-datetime/year-string.ts +0 -26
  66. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  67. package/src/whatwg/check-mime-type.spec.ts +0 -59
  68. package/src/whatwg/check-mime-type.ts +0 -46
  69. package/src/whatwg/is-abs-url.spec.ts +0 -8
  70. package/src/whatwg/is-abs-url.ts +0 -31
  71. package/src/whatwg/is-browser-context-name.ts +0 -16
  72. package/src/whatwg/is-custom-element-name.ts +0 -76
  73. package/src/whatwg/is-itemprop-name.ts +0 -17
  74. package/tsconfig.test.json +0 -3
  75. package/tsconfig.tsbuildinfo +0 -1
package/src/defs.ts DELETED
@@ -1,810 +0,0 @@
1
- import type { Defs, CssSyntaxTokenizer } from './types';
2
-
3
- import { checkMultiTypes } from './check-multi-types';
4
- import { getCandidate } from './get-candidate';
5
- import { matched, matches, unmatched } from './match-result';
6
- import { splitUnit, isFloat, isUint, isInt } from './primitive';
7
- import { isBCP47 } from './rfc/is-bcp-47';
8
- import { Token, TokenCollection } from './token';
9
- import { checkSerializedPermissionsPolicy } from './w3c/check-serialized-permissions-policy';
10
- import { checkAutoComplete } from './whatwg/check-autocomplete';
11
- import { checkDateTime } from './whatwg/check-datetime';
12
- import { checkMIMEType } from './whatwg/check-mime-type';
13
- import { isAbsURL } from './whatwg/is-abs-url';
14
- import { isBrowserContextName } from './whatwg/is-browser-context-name';
15
- import { isCustomElementName } from './whatwg/is-custom-element-name';
16
- import { isItempropName } from './whatwg/is-itemprop-name';
17
-
18
- export const types: Defs = {
19
- Any: {
20
- ref: '',
21
- is: () => matched(),
22
- },
23
-
24
- NoEmptyAny: {
25
- ref: '',
26
- is: value => (0 < value.length ? matched() : unmatched(value, 'empty-token')),
27
- },
28
-
29
- OneLineAny: {
30
- ref: '',
31
- is: value => {
32
- const tokens = new TokenCollection(value);
33
- /**
34
- * @see https://infra.spec.whatwg.org/#ascii-tab-or-newline
35
- */
36
- const newline = ['\u000A', '\u000D'];
37
- const newlineToken = tokens.search(newline);
38
- if (newlineToken) {
39
- return newlineToken.unmatched({
40
- reason: 'unexpected-newline',
41
- });
42
- }
43
- return matched();
44
- },
45
- },
46
-
47
- Zero: {
48
- ref: '',
49
- expects: [
50
- {
51
- type: 'common',
52
- value: 'zero',
53
- },
54
- ],
55
- is: value => (value === '0' ? matched() : unmatched(value, 'syntax-error')),
56
- },
57
-
58
- Number: {
59
- ref: '',
60
- expects: [
61
- {
62
- type: 'common',
63
- value: 'number',
64
- },
65
- ],
66
- is: value => (isFloat(value) ? matched() : unmatched(value, 'unexpected-token')),
67
- },
68
-
69
- Int: {
70
- ref: '',
71
- expects: [
72
- {
73
- type: 'common',
74
- value: 'integer',
75
- },
76
- ],
77
- is: value => (isInt(value) ? matched() : unmatched(value, 'unexpected-token')),
78
- },
79
-
80
- Uint: {
81
- ref: '',
82
- expects: [
83
- {
84
- type: 'common',
85
- value: 'non-negative integer',
86
- },
87
- ],
88
- is: value => (isUint(value) ? matched() : unmatched(value, 'unexpected-token')),
89
- },
90
-
91
- XMLName: {
92
- ref: 'https://www.w3.org/TR/xml/#NT-Name',
93
- expects: [
94
- {
95
- type: 'format',
96
- value: 'XML name',
97
- },
98
- ],
99
- is: value => {
100
- // NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
101
- const nameStartChar =
102
- /[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]/u;
103
- // NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
104
- const nameCharTail = /-|[.0-9\u00B7]|[\u0300-\u036F\u203F-\u2040]/;
105
- // Name ::= NameStartChar (NameChar)*
106
- const name = RegExp(`(?:${nameStartChar.source})(?:${nameCharTail})*`, 'u');
107
- return name.test(value) ? matched() : unmatched(value, 'unexpected-token');
108
- },
109
- },
110
-
111
- DOMID: {
112
- ref: 'https://html.spec.whatwg.org/multipage/dom.html#global-attributes:concept-id',
113
- expects: [
114
- {
115
- type: 'format',
116
- value: 'ID',
117
- },
118
- ],
119
- is: value => {
120
- const tokens = new TokenCollection(value);
121
- const ws = tokens.search(Token.WhiteSpace);
122
- if (ws) {
123
- return ws.unmatched({
124
- reason: 'unexpected-space',
125
- });
126
- }
127
- if (!tokens.length) {
128
- return unmatched(value, 'empty-token');
129
- }
130
- return matched();
131
- },
132
- },
133
-
134
- FunctionBody: {
135
- ref: '',
136
- expects: [
137
- {
138
- type: 'syntax',
139
- value: 'JavaScript',
140
- },
141
- ],
142
- // **NO IMPLEMENT PLAN NOW**
143
- is: () => matched(),
144
- },
145
-
146
- Pattern: {
147
- ref: 'https://html.spec.whatwg.org/multipage/input.html#compiled-pattern-regular-expression',
148
- expects: [
149
- {
150
- type: 'common',
151
- value: 'regular expression',
152
- },
153
- ],
154
- is: value => {
155
- try {
156
- new RegExp(`^(?:${value})$`);
157
- } catch {
158
- return unmatched(value);
159
- }
160
- return matched();
161
- },
162
- },
163
-
164
- DateTime: {
165
- ref: 'https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value',
166
- expects: [
167
- {
168
- type: 'format',
169
- value: 'date time',
170
- },
171
- ],
172
- is: checkDateTime(),
173
- },
174
-
175
- /**
176
- * It doesn't check the meaningless number less than -1
177
- * that is the same as -1.
178
- * It is another rule.
179
- */
180
- TabIndex: {
181
- expects: [
182
- {
183
- type: 'common',
184
- value: '-1',
185
- },
186
- {
187
- type: 'common',
188
- value: '0',
189
- },
190
- {
191
- type: 'common',
192
- value: 'non-negative integer',
193
- },
194
- ],
195
- ref: 'https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex',
196
- is: matches(value => isInt(value)),
197
- },
198
-
199
- BCP47: {
200
- expects: [
201
- {
202
- type: 'format',
203
- value: 'BCP47',
204
- },
205
- ],
206
- ref: 'https://tools.ietf.org/rfc/bcp/bcp47.html',
207
- is: matches(isBCP47(), { reason: 'unexpected-token' }),
208
- },
209
-
210
- /**
211
- * **NO IMPLEMENT NEVER**
212
- *
213
- * We can evaluate the absolute URL through WHATWG API,
214
- * but it isn't easy to check the relative URL.
215
- * And the relative URL expects almost all of the characters.
216
- * In short, this checking is meaningless.
217
- *
218
- * So it always returns the matched object.
219
- *
220
- * If you want to expect the URL without multi-byte characters,
221
- * it should use another rule.
222
- */
223
- URL: {
224
- ref: 'https://html.spec.whatwg.org/multipage/urls-and-fetching.html#valid-url-potentially-surrounded-by-spaces',
225
- is: () => matched(),
226
- },
227
-
228
- AbsoluteURL: {
229
- ref: 'https://url.spec.whatwg.org/#syntax-url-absolute',
230
- is: matches(isAbsURL()),
231
- },
232
-
233
- HashName: {
234
- ref: 'https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-hash-name-reference',
235
- expects: [
236
- {
237
- type: 'format',
238
- value: 'hash name',
239
- },
240
- ],
241
- is: value => (value[0] === '#' ? matched() : unmatched(value, 'unexpected-token')),
242
- },
243
-
244
- OneCodePointChar: {
245
- ref: 'https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute',
246
- expects: [
247
- {
248
- type: 'common',
249
- value: 'one code point character',
250
- },
251
- ],
252
- is: value => (value.length === 1 ? matched() : unmatched(value, 'unexpected-token')),
253
- },
254
-
255
- CustomElementName: {
256
- ref: 'https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name',
257
- expects: [
258
- {
259
- type: 'format',
260
- value: 'custom element name',
261
- },
262
- ],
263
- is: matches(isCustomElementName()),
264
- },
265
-
266
- BrowsingContextName: {
267
- ref: 'https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-names',
268
- expects: [
269
- {
270
- type: 'common',
271
- value: 'browsing context name',
272
- },
273
- ],
274
- // <iframe name="[HERE]">
275
- is: matches(isBrowserContextName()),
276
- },
277
-
278
- BrowsingContextNameOrKeyword: {
279
- ref: 'https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name-or-keyword',
280
- expects: [
281
- { type: 'const', value: '_blank' },
282
- { type: 'const', value: '_self' },
283
- { type: 'const', value: '_parent' },
284
- { type: 'const', value: '_top' },
285
- {
286
- type: 'common',
287
- value: 'browsing context name',
288
- },
289
- ],
290
- // <a target="[HERE]">
291
- is(value) {
292
- value = value.toLowerCase();
293
- const keywords = ['_blank', '_self', '_parent', '_top'];
294
- if (keywords.includes(value)) {
295
- return matched();
296
- }
297
- if (value[0] === '_') {
298
- const candidate = getCandidate(value, keywords);
299
- return unmatched(value, 'unexpected-token', { candidate });
300
- }
301
- return matches(isBrowserContextName())(value);
302
- },
303
- },
304
-
305
- HTTPSchemaURL: {
306
- ref: 'https://html.spec.whatwg.org/multipage/links.html#ping',
307
- expects: [
308
- {
309
- type: 'format',
310
- value: 'URL who schema is an HTTP(S) schema',
311
- },
312
- ],
313
- is(value) {
314
- if (isAbsURL()(value)) {
315
- return unmatched(value, 'unexpected-token');
316
- }
317
- if (/^https?/i.test(value)) {
318
- return matched();
319
- }
320
- return unmatched(value, 'unexpected-token', {
321
- expects: [
322
- {
323
- type: 'format',
324
- value: 'HTTP(S) schema',
325
- },
326
- ],
327
- });
328
- },
329
- },
330
-
331
- MIMEType: {
332
- ref: 'https://mimesniff.spec.whatwg.org/#valid-mime-type',
333
- expects: [
334
- {
335
- type: 'format',
336
- value: 'MIME Type',
337
- },
338
- ],
339
- is: checkMIMEType(),
340
- },
341
-
342
- ItemProp: {
343
- ref: 'https://html.spec.whatwg.org/multipage/microdata.html#names:-the-itemprop-attribute',
344
- expects: [
345
- {
346
- type: 'common',
347
- value: 'absolute URL',
348
- },
349
- {
350
- type: 'format',
351
- value: 'property name',
352
- },
353
- ],
354
- is(value) {
355
- const _matched = matched();
356
- const _unmatched = unmatched(value, 'unexpected-token');
357
- return checkMultiTypes(value, [
358
- value => (isAbsURL()(value) ? _matched : _unmatched),
359
- value => (isItempropName()(value) ? _matched : _unmatched),
360
- ]);
361
- },
362
- },
363
-
364
- Srcset: {
365
- ref: 'https://html.spec.whatwg.org/multipage/images.html#srcset-attributes',
366
- syntax: {
367
- apply: '<srcset>',
368
- def: {
369
- srcset: '<image-candidate-strings> [, <image-candidate-strings>]*',
370
- 'image-candidate-strings': '<valid-non-empty-url> [ <width-descriptor> | <pixel-density-descriptor> ]?',
371
- 'valid-non-empty-url'(token, getNextToken) {
372
- if (!token) {
373
- return 0;
374
- }
375
- let willAdoptTokenLength = 0;
376
- do {
377
- if (token.type === 13) {
378
- break;
379
- }
380
- willAdoptTokenLength++;
381
- } while ((token = getNextToken(willAdoptTokenLength)));
382
- return willAdoptTokenLength;
383
- },
384
- 'width-descriptor'(token) {
385
- if (!token) {
386
- return 0;
387
- }
388
- const { num, unit } = splitUnit(token.value);
389
- if (unit !== 'w') {
390
- return 0;
391
- }
392
- if (!isUint(num)) {
393
- return 0;
394
- }
395
- return 1;
396
- },
397
- 'pixel-density-descriptor'(token) {
398
- if (!token) {
399
- return 0;
400
- }
401
- const { num, unit } = splitUnit(token.value);
402
- if (unit !== 'x') {
403
- return 0;
404
- }
405
- if (!isFloat(num)) {
406
- return 0;
407
- }
408
- return 1;
409
- },
410
- },
411
- },
412
- },
413
-
414
- SourceSizeList: {
415
- ref: 'https://html.spec.whatwg.org/multipage/images.html#sizes-attributes',
416
- expects: [
417
- {
418
- type: 'syntax',
419
- value: '<source-size-list>',
420
- },
421
- ],
422
- syntax: {
423
- apply: '<source-size-list>',
424
- def: {
425
- 'source-size-list': '[ <source-size># , ]? <source-size-value>',
426
- 'source-size': '<media-condition> <source-size-value>',
427
- 'source-size-value': '<length>',
428
- },
429
- },
430
- },
431
-
432
- IconSize: {
433
- ref: 'https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes',
434
- expects: [
435
- {
436
- type: 'const',
437
- value: 'any',
438
- },
439
- {
440
- type: 'syntax',
441
- value: '[WIDTH]x[HEIGHT]',
442
- },
443
- ],
444
- is(value) {
445
- value = value.toLowerCase();
446
- if (value === 'any') {
447
- return matched();
448
- }
449
- const tokens = new TokenCollection(value, { specificSeparator: 'x' });
450
- const [width, sep, height, ...tail] = tokens;
451
- if (!width) {
452
- return unmatched(value, 'unexpected-token');
453
- }
454
- if (!sep) {
455
- return width.unmatched({ reason: 'unexpected-token' });
456
- }
457
- if (!height) {
458
- return sep.unmatched({ reason: 'unexpected-token' });
459
- }
460
- if (tail && tail.length) {
461
- return tail[0].unmatched({ reason: 'extra-token' });
462
- }
463
- if (!isUint(width.value)) {
464
- return width.unmatched({ reason: 'unexpected-token' });
465
- }
466
- if (width.value === '0') {
467
- return width.unmatched({ reason: 'out-of-range' });
468
- }
469
- if (sep.value !== 'x') {
470
- return sep.unmatched({ reason: 'out-of-range' });
471
- }
472
- if (!isUint(height.value)) {
473
- return height.unmatched({ reason: 'unexpected-token' });
474
- }
475
- if (height.value === '0') {
476
- return height.unmatched({ reason: 'out-of-range' });
477
- }
478
- return matched();
479
- },
480
- },
481
-
482
- AutoComplete: {
483
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
484
- is: checkAutoComplete(),
485
- },
486
-
487
- Accept: {
488
- ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
489
- expects: [
490
- {
491
- type: 'const',
492
- value: 'audio/*',
493
- },
494
- {
495
- type: 'const',
496
- value: 'video/*',
497
- },
498
- {
499
- type: 'const',
500
- value: 'image/*',
501
- },
502
- {
503
- type: 'format',
504
- value: 'MIME Type',
505
- },
506
- {
507
- type: 'format',
508
- value: 'Extension',
509
- },
510
- ],
511
- // input[type=file] accept: { type: { token: "Accept", "separator": "comma" } }
512
- is(value) {
513
- const extMap = ['audio/*', 'video/*', 'image/*'];
514
- if (extMap.includes(value)) return matched();
515
- // A valid MIME type string with no parameters
516
- const mimeMatched = checkMIMEType({ withoutParameters: true })(value);
517
- if (mimeMatched.matched) return matched();
518
- // A string whose first character is a U+002E FULL STOP character (.)
519
- return value[0] === '.' && value[1] ? matched() : mimeMatched;
520
- },
521
- },
522
-
523
- SerializedPermissionsPolicy: {
524
- ref: 'https://w3c.github.io/webappsec-permissions-policy/#serialized-permissions-policy',
525
- is: checkSerializedPermissionsPolicy(),
526
- },
527
-
528
- '<css-declaration-list>': {
529
- ref: 'https://drafts.csswg.org/css-style-attr/#syntax',
530
- syntax: {
531
- apply: '<css-declaration-list>',
532
- def: {
533
- 'css-declaration-list': '<declaration-list>',
534
- },
535
- },
536
- },
537
-
538
- '<class-list>': {
539
- ref: 'https://www.w3.org/TR/SVG/styling.html#ClassAttribute',
540
- syntax: {
541
- apply: '<class-list>',
542
- def: {
543
- 'class-list': '<ident-token>*',
544
- },
545
- },
546
- },
547
-
548
- '<svg-font-size>': {
549
- ref: 'https://drafts.csswg.org/css-fonts-5/#descdef-font-face-font-size',
550
- // TODO:
551
- is: () => matched(),
552
- },
553
-
554
- '<svg-font-size-adjust>': {
555
- ref: 'https://drafts.csswg.org/css-fonts-5/#propdef-font-size-adjust',
556
- // TODO:
557
- is: () => matched(),
558
- },
559
-
560
- "<'color-profile'>": {
561
- ref: 'https://www.w3.org/TR/SVG11/color.html#ColorProfileProperty',
562
- // TODO:
563
- is: () => matched(),
564
- },
565
-
566
- "<'color-rendering'>": {
567
- ref: 'https://www.w3.org/TR/SVG11/painting.html#ColorRenderingProperty',
568
- // TODO:
569
- is: () => matched(),
570
- },
571
-
572
- "<'enable-background'>": {
573
- ref: 'https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty',
574
- // TODO:
575
- is: () => matched(),
576
- },
577
-
578
- '<list-of-svg-feature-string>': {
579
- ref: 'https://www.w3.org/TR/SVG11/feature.html',
580
- // TODO:
581
- is: () => matched(),
582
- },
583
-
584
- '<animatable-value>': {
585
- ref: 'https://svgwg.org/specs/animations/#FromAttribute',
586
- // TODO:
587
- is: () => matched(),
588
- },
589
-
590
- '<begin-value-list>': {
591
- ref: 'https://svgwg.org/specs/animations/#BeginValueListSyntax',
592
- // TODO:
593
- is: () => matched(),
594
- },
595
-
596
- '<end-value-list>': {
597
- ref: 'https://svgwg.org/specs/animations/#EndValueListSyntax',
598
- // TODO:
599
- is: () => matched(),
600
- },
601
-
602
- '<list-of-value>': {
603
- ref: 'https://svgwg.org/specs/animations/#ValuesAttribute',
604
- // TODO:
605
- is: () => matched(),
606
- },
607
-
608
- '<clock-value>': {
609
- ref: 'https://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-ClockValueSyntax',
610
- syntax: {
611
- // TODO:
612
- apply: '<clock-value>',
613
- def: {
614
- 'clock-value': '<any-value>',
615
- },
616
- },
617
- },
618
-
619
- '<color-matrix>': {
620
- ref: 'https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values',
621
- syntax: {
622
- apply: '<color-matrix>',
623
- def: {
624
- 'color-matrix': '[ <number-zero-one> [,]? ]{19} <number-zero-one>',
625
- },
626
- },
627
- },
628
-
629
- '<dasharray>': {
630
- ref: 'https://svgwg.org/svg2-draft/painting.html#StrokeDasharrayProperty',
631
- syntax: {
632
- apply: '<dasharray>',
633
- def: {
634
- dasharray: '[ [ <svg-length> | <percentage> | <number> ]+ ]#',
635
- },
636
- },
637
- },
638
-
639
- '<key-points>': {
640
- ref: 'https://svgwg.org/specs/animations/#KeyPointsAttribute',
641
- syntax: {
642
- apply: '<key-points>',
643
- def: {
644
- 'key-points': '<number> [; <number>]* [;]?',
645
- },
646
- },
647
- },
648
-
649
- '<key-splines>': {
650
- ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
651
- syntax: {
652
- apply: '<key-splines>',
653
- def: {
654
- 'key-splines': '<control-point> [; <control-point>]* [;]?',
655
- 'control-point': '<number> [,]? <number> [,]? <number> [,]? <number>',
656
- },
657
- },
658
- },
659
-
660
- '<key-times>': {
661
- ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
662
- syntax: {
663
- apply: '<key-times>',
664
- def: {
665
- 'key-times': '<number> [; <number>]* [;]?',
666
- },
667
- },
668
- },
669
-
670
- '<system-language>': {
671
- ref: 'https://svgwg.org/svg2-draft/struct.html#SystemLanguageAttribute',
672
- syntax: {
673
- apply: '<system-language>',
674
- def: {
675
- 'system-language': '<bcp-47>#',
676
- },
677
- },
678
- },
679
-
680
- '<origin>': {
681
- ref: 'https://www.w3.org/TR/2001/REC-smil-animation-20010904/#MotionOriginAttribute',
682
- syntax: {
683
- apply: '<origin>',
684
- def: {
685
- origin: 'default',
686
- },
687
- },
688
- },
689
-
690
- '<svg-path>': {
691
- ref: 'https://svgwg.org/svg2-draft/paths.html#PathDataBNF',
692
- syntax: {
693
- apply: '<svg-path>',
694
- // TODO:
695
- def: {
696
- 'svg-path': '<any-value>',
697
- },
698
- },
699
- },
700
-
701
- '<points>': {
702
- ref: 'https://svgwg.org/svg2-draft/shapes.html#DataTypePoints',
703
- syntax: {
704
- apply: '<points>',
705
- def: {
706
- points: '[ <number>+ ]#',
707
- },
708
- },
709
- },
710
-
711
- '<preserve-aspect-ratio>': {
712
- ref: 'https://svgwg.org/svg2-draft/coords.html#PreserveAspectRatioAttribute',
713
- syntax: {
714
- apply: '<preserve-aspect-ratio>',
715
- def: {
716
- 'preserve-aspect-ratio': '<align> <meet-or-slice>?',
717
- align: 'none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid| xMinYMax | xMidYMax | xMaxYMax',
718
- 'meet-or-slice': 'meet | slice',
719
- },
720
- // A new spec
721
- // @see https://drafts.fxtf.org/filter-effects/#element-attrdef-feimage-preserveaspectratio
722
- // > preserveAspectRatio = "[defer] <align> [<meetOrSlice>]"
723
- },
724
- },
725
-
726
- '<view-box>': {
727
- ref: 'https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute',
728
- syntax: {
729
- apply: '<view-box>',
730
- def: {
731
- 'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>', // As '[<min-x>,? <min-y>,? <width>,? <height>]',
732
- 'min-x': '<number>',
733
- 'min-y': '<number>',
734
- width: '<number>',
735
- height: '<number>',
736
- },
737
- },
738
- },
739
-
740
- '<rotate>': {
741
- ref: 'https://svgwg.org/specs/animations/#RotateAttribute',
742
- syntax: {
743
- apply: '<rotate>',
744
- def: {
745
- rotate: '<number> | auto | auto-reverse',
746
- },
747
- },
748
- },
749
-
750
- '<text-coordinate>': {
751
- ref: 'https://svgwg.org/svg2-draft/text.html#TSpanAttributes',
752
- syntax: {
753
- apply: '<text-coordinate>',
754
- def: {
755
- 'text-coordinate': '[ [ <svg-length> | <percentage> | <number> ]+ ]#',
756
- },
757
- },
758
- },
759
-
760
- '<list-of-lengths>': {
761
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts',
762
- syntax: {
763
- apply: '<list-of-lengths>',
764
- def: {
765
- 'list-of-lengths': '[ <svg-length> [,]? ]* <svg-length>',
766
- },
767
- },
768
- },
769
-
770
- '<list-of-numbers>': {
771
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts',
772
- syntax: {
773
- apply: '<list-of-numbers>',
774
- def: {
775
- 'list-of-numbers': '[ <number> [,]? ]* <number>',
776
- },
777
- },
778
- },
779
-
780
- '<list-of-percentages>': {
781
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage',
782
- syntax: {
783
- apply: '<list-of-percentages>',
784
- def: {
785
- 'list-of-percentages': '[ <percentage> [,]? ]* <percentage>',
786
- },
787
- },
788
- },
789
-
790
- '<number-optional-number>': {
791
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number-optional-number',
792
- syntax: {
793
- apply: '<number-optional-number>',
794
- def: {
795
- 'number-optional-number': '<number> | <number> , <number>',
796
- },
797
- },
798
- },
799
- };
800
-
801
- export const tokenizers: Record<string, CssSyntaxTokenizer> = {
802
- // RFC
803
- // https://tools.ietf.org/rfc/bcp/bcp47.html
804
- 'bcp-47'(token) {
805
- if (!token) {
806
- return 0;
807
- }
808
- return isBCP47()(token.value) ? 1 : 0;
809
- },
810
- };