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

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 (65) hide show
  1. package/lib/css-syntax.js +6 -6
  2. package/lib/types.schema.d.ts +1 -1
  3. package/package.json +4 -6
  4. package/types.schema.json +16 -67
  5. package/gen/specific-schema.json +0 -98
  6. package/gen/types.ts +0 -66
  7. package/patches/css-tree+2.3.1.patch +0 -23
  8. package/src/check-multi-types.ts +0 -35
  9. package/src/check.spec.ts +0 -83
  10. package/src/check.ts +0 -48
  11. package/src/css-syntax.spec.ts +0 -167
  12. package/src/css-syntax.ts +0 -188
  13. package/src/debug.ts +0 -3
  14. package/src/defs.ts +0 -811
  15. package/src/enum.ts +0 -25
  16. package/src/get-candidate.ts +0 -24
  17. package/src/index.ts +0 -3
  18. package/src/keyword-type.ts +0 -64
  19. package/src/list.spec.ts +0 -133
  20. package/src/list.ts +0 -34
  21. package/src/match-result.ts +0 -49
  22. package/src/number.ts +0 -46
  23. package/src/primitive/index.spec.ts +0 -65
  24. package/src/primitive/index.ts +0 -7
  25. package/src/primitive/is-float.ts +0 -8
  26. package/src/primitive/is-int.ts +0 -8
  27. package/src/primitive/is-non-zero-uint.ts +0 -8
  28. package/src/primitive/is-quantity.ts +0 -38
  29. package/src/primitive/is-uint.ts +0 -15
  30. package/src/primitive/range.ts +0 -14
  31. package/src/primitive/split-unit.ts +0 -20
  32. package/src/rfc/is-bcp-47.spec.ts +0 -23
  33. package/src/rfc/is-bcp-47.ts +0 -13
  34. package/src/token/index.ts +0 -2
  35. package/src/token/token-collection.spec.ts +0 -147
  36. package/src/token/token-collection.ts +0 -444
  37. package/src/token/token.ts +0 -144
  38. package/src/types.schema.ts +0 -1113
  39. package/src/types.ts +0 -118
  40. package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
  41. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  42. package/src/whatwg/check-autocomplete.spec.ts +0 -387
  43. package/src/whatwg/check-autocomplete.ts +0 -380
  44. package/src/whatwg/check-datetime/date-string.ts +0 -44
  45. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  46. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  47. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  48. package/src/whatwg/check-datetime/index.spec.ts +0 -333
  49. package/src/whatwg/check-datetime/index.ts +0 -36
  50. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  51. package/src/whatwg/check-datetime/month-string.ts +0 -31
  52. package/src/whatwg/check-datetime/time-string.ts +0 -49
  53. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  54. package/src/whatwg/check-datetime/week-string.ts +0 -41
  55. package/src/whatwg/check-datetime/year-string.ts +0 -26
  56. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  57. package/src/whatwg/check-mime-type.spec.ts +0 -59
  58. package/src/whatwg/check-mime-type.ts +0 -46
  59. package/src/whatwg/is-abs-url.spec.ts +0 -8
  60. package/src/whatwg/is-abs-url.ts +0 -31
  61. package/src/whatwg/is-browser-context-name.ts +0 -16
  62. package/src/whatwg/is-custom-element-name.ts +0 -76
  63. package/src/whatwg/is-itemprop-name.ts +0 -17
  64. package/tsconfig.test.json +0 -3
  65. package/tsconfig.tsbuildinfo +0 -1
package/src/defs.ts DELETED
@@ -1,811 +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
- // DO NOT USE: Issue #564
539
- '<class-list>': {
540
- ref: 'https://www.w3.org/TR/SVG/styling.html#ClassAttribute',
541
- syntax: {
542
- apply: '<class-list>',
543
- def: {
544
- 'class-list': '<ident-token>*',
545
- },
546
- },
547
- },
548
-
549
- '<svg-font-size>': {
550
- ref: 'https://drafts.csswg.org/css-fonts-5/#descdef-font-face-font-size',
551
- // TODO:
552
- is: () => matched(),
553
- },
554
-
555
- '<svg-font-size-adjust>': {
556
- ref: 'https://drafts.csswg.org/css-fonts-5/#propdef-font-size-adjust',
557
- // TODO:
558
- is: () => matched(),
559
- },
560
-
561
- "<'color-profile'>": {
562
- ref: 'https://www.w3.org/TR/SVG11/color.html#ColorProfileProperty',
563
- // TODO:
564
- is: () => matched(),
565
- },
566
-
567
- "<'color-rendering'>": {
568
- ref: 'https://www.w3.org/TR/SVG11/painting.html#ColorRenderingProperty',
569
- // TODO:
570
- is: () => matched(),
571
- },
572
-
573
- "<'enable-background'>": {
574
- ref: 'https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty',
575
- // TODO:
576
- is: () => matched(),
577
- },
578
-
579
- '<list-of-svg-feature-string>': {
580
- ref: 'https://www.w3.org/TR/SVG11/feature.html',
581
- // TODO:
582
- is: () => matched(),
583
- },
584
-
585
- '<animatable-value>': {
586
- ref: 'https://svgwg.org/specs/animations/#FromAttribute',
587
- // TODO:
588
- is: () => matched(),
589
- },
590
-
591
- '<begin-value-list>': {
592
- ref: 'https://svgwg.org/specs/animations/#BeginValueListSyntax',
593
- // TODO:
594
- is: () => matched(),
595
- },
596
-
597
- '<end-value-list>': {
598
- ref: 'https://svgwg.org/specs/animations/#EndValueListSyntax',
599
- // TODO:
600
- is: () => matched(),
601
- },
602
-
603
- '<list-of-value>': {
604
- ref: 'https://svgwg.org/specs/animations/#ValuesAttribute',
605
- // TODO:
606
- is: () => matched(),
607
- },
608
-
609
- '<clock-value>': {
610
- ref: 'https://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-ClockValueSyntax',
611
- syntax: {
612
- // TODO:
613
- apply: '<clock-value>',
614
- def: {
615
- 'clock-value': '<any-value>',
616
- },
617
- },
618
- },
619
-
620
- '<color-matrix>': {
621
- ref: 'https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values',
622
- syntax: {
623
- apply: '<color-matrix>',
624
- def: {
625
- 'color-matrix': '[ <number-zero-one> [,]? ]{19} <number-zero-one>',
626
- },
627
- },
628
- },
629
-
630
- '<dasharray>': {
631
- ref: 'https://svgwg.org/svg2-draft/painting.html#StrokeDasharrayProperty',
632
- syntax: {
633
- apply: '<dasharray>',
634
- def: {
635
- dasharray: '[ [ <svg-length> | <percentage> | <number> ]+ ]#',
636
- },
637
- },
638
- },
639
-
640
- '<key-points>': {
641
- ref: 'https://svgwg.org/specs/animations/#KeyPointsAttribute',
642
- syntax: {
643
- apply: '<key-points>',
644
- def: {
645
- 'key-points': '<number> [; <number>]* [;]?',
646
- },
647
- },
648
- },
649
-
650
- '<key-splines>': {
651
- ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
652
- syntax: {
653
- apply: '<key-splines>',
654
- def: {
655
- 'key-splines': '<control-point> [; <control-point>]* [;]?',
656
- 'control-point': '<number> [,]? <number> [,]? <number> [,]? <number>',
657
- },
658
- },
659
- },
660
-
661
- '<key-times>': {
662
- ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
663
- syntax: {
664
- apply: '<key-times>',
665
- def: {
666
- 'key-times': '<number> [; <number>]* [;]?',
667
- },
668
- },
669
- },
670
-
671
- '<system-language>': {
672
- ref: 'https://svgwg.org/svg2-draft/struct.html#SystemLanguageAttribute',
673
- syntax: {
674
- apply: '<system-language>',
675
- def: {
676
- 'system-language': '<bcp-47>#',
677
- },
678
- },
679
- },
680
-
681
- '<origin>': {
682
- ref: 'https://www.w3.org/TR/2001/REC-smil-animation-20010904/#MotionOriginAttribute',
683
- syntax: {
684
- apply: '<origin>',
685
- def: {
686
- origin: 'default',
687
- },
688
- },
689
- },
690
-
691
- '<svg-path>': {
692
- ref: 'https://svgwg.org/svg2-draft/paths.html#PathDataBNF',
693
- syntax: {
694
- apply: '<svg-path>',
695
- // TODO:
696
- def: {
697
- 'svg-path': '<any-value>',
698
- },
699
- },
700
- },
701
-
702
- '<points>': {
703
- ref: 'https://svgwg.org/svg2-draft/shapes.html#DataTypePoints',
704
- syntax: {
705
- apply: '<points>',
706
- def: {
707
- points: '[ <number>+ ]#',
708
- },
709
- },
710
- },
711
-
712
- '<preserve-aspect-ratio>': {
713
- ref: 'https://svgwg.org/svg2-draft/coords.html#PreserveAspectRatioAttribute',
714
- syntax: {
715
- apply: '<preserve-aspect-ratio>',
716
- def: {
717
- 'preserve-aspect-ratio': '<align> <meet-or-slice>?',
718
- align: 'none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid| xMinYMax | xMidYMax | xMaxYMax',
719
- 'meet-or-slice': 'meet | slice',
720
- },
721
- // A new spec
722
- // @see https://drafts.fxtf.org/filter-effects/#element-attrdef-feimage-preserveaspectratio
723
- // > preserveAspectRatio = "[defer] <align> [<meetOrSlice>]"
724
- },
725
- },
726
-
727
- '<view-box>': {
728
- ref: 'https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute',
729
- syntax: {
730
- apply: '<view-box>',
731
- def: {
732
- 'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>', // As '[<min-x>,? <min-y>,? <width>,? <height>]',
733
- 'min-x': '<number>',
734
- 'min-y': '<number>',
735
- width: '<number>',
736
- height: '<number>',
737
- },
738
- },
739
- },
740
-
741
- '<rotate>': {
742
- ref: 'https://svgwg.org/specs/animations/#RotateAttribute',
743
- syntax: {
744
- apply: '<rotate>',
745
- def: {
746
- rotate: '<number> | auto | auto-reverse',
747
- },
748
- },
749
- },
750
-
751
- '<text-coordinate>': {
752
- ref: 'https://svgwg.org/svg2-draft/text.html#TSpanAttributes',
753
- syntax: {
754
- apply: '<text-coordinate>',
755
- def: {
756
- 'text-coordinate': '[ [ <svg-length> | <percentage> | <number> ]+ ]#',
757
- },
758
- },
759
- },
760
-
761
- '<list-of-lengths>': {
762
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts',
763
- syntax: {
764
- apply: '<list-of-lengths>',
765
- def: {
766
- 'list-of-lengths': '[ <svg-length> [,]? ]* <svg-length>',
767
- },
768
- },
769
- },
770
-
771
- '<list-of-numbers>': {
772
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts',
773
- syntax: {
774
- apply: '<list-of-numbers>',
775
- def: {
776
- 'list-of-numbers': '[ <number> [,]? ]* <number>',
777
- },
778
- },
779
- },
780
-
781
- '<list-of-percentages>': {
782
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage',
783
- syntax: {
784
- apply: '<list-of-percentages>',
785
- def: {
786
- 'list-of-percentages': '[ <percentage> [,]? ]* <percentage>',
787
- },
788
- },
789
- },
790
-
791
- '<number-optional-number>': {
792
- ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number-optional-number',
793
- syntax: {
794
- apply: '<number-optional-number>',
795
- def: {
796
- 'number-optional-number': '<number> | <number> , <number>',
797
- },
798
- },
799
- },
800
- };
801
-
802
- export const tokenizers: Record<string, CssSyntaxTokenizer> = {
803
- // RFC
804
- // https://tools.ietf.org/rfc/bcp/bcp47.html
805
- 'bcp-47'(token) {
806
- if (!token) {
807
- return 0;
808
- }
809
- return isBCP47()(token.value) ? 1 : 0;
810
- },
811
- };