svg.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. import {caseSensitiveTransform} from './util/case-sensitive-transform.js'
  2. import {create} from './util/create.js'
  3. import {
  4. boolean,
  5. commaOrSpaceSeparated,
  6. commaSeparated,
  7. number,
  8. spaceSeparated
  9. } from './util/types.js'
  10. export const svg = create({
  11. attributes: {
  12. accentHeight: 'accent-height',
  13. alignmentBaseline: 'alignment-baseline',
  14. arabicForm: 'arabic-form',
  15. baselineShift: 'baseline-shift',
  16. capHeight: 'cap-height',
  17. className: 'class',
  18. clipPath: 'clip-path',
  19. clipRule: 'clip-rule',
  20. colorInterpolation: 'color-interpolation',
  21. colorInterpolationFilters: 'color-interpolation-filters',
  22. colorProfile: 'color-profile',
  23. colorRendering: 'color-rendering',
  24. crossOrigin: 'crossorigin',
  25. dataType: 'datatype',
  26. dominantBaseline: 'dominant-baseline',
  27. enableBackground: 'enable-background',
  28. fillOpacity: 'fill-opacity',
  29. fillRule: 'fill-rule',
  30. floodColor: 'flood-color',
  31. floodOpacity: 'flood-opacity',
  32. fontFamily: 'font-family',
  33. fontSize: 'font-size',
  34. fontSizeAdjust: 'font-size-adjust',
  35. fontStretch: 'font-stretch',
  36. fontStyle: 'font-style',
  37. fontVariant: 'font-variant',
  38. fontWeight: 'font-weight',
  39. glyphName: 'glyph-name',
  40. glyphOrientationHorizontal: 'glyph-orientation-horizontal',
  41. glyphOrientationVertical: 'glyph-orientation-vertical',
  42. hrefLang: 'hreflang',
  43. horizAdvX: 'horiz-adv-x',
  44. horizOriginX: 'horiz-origin-x',
  45. horizOriginY: 'horiz-origin-y',
  46. imageRendering: 'image-rendering',
  47. letterSpacing: 'letter-spacing',
  48. lightingColor: 'lighting-color',
  49. markerEnd: 'marker-end',
  50. markerMid: 'marker-mid',
  51. markerStart: 'marker-start',
  52. navDown: 'nav-down',
  53. navDownLeft: 'nav-down-left',
  54. navDownRight: 'nav-down-right',
  55. navLeft: 'nav-left',
  56. navNext: 'nav-next',
  57. navPrev: 'nav-prev',
  58. navRight: 'nav-right',
  59. navUp: 'nav-up',
  60. navUpLeft: 'nav-up-left',
  61. navUpRight: 'nav-up-right',
  62. onAbort: 'onabort',
  63. onActivate: 'onactivate',
  64. onAfterPrint: 'onafterprint',
  65. onBeforePrint: 'onbeforeprint',
  66. onBegin: 'onbegin',
  67. onCancel: 'oncancel',
  68. onCanPlay: 'oncanplay',
  69. onCanPlayThrough: 'oncanplaythrough',
  70. onChange: 'onchange',
  71. onClick: 'onclick',
  72. onClose: 'onclose',
  73. onCopy: 'oncopy',
  74. onCueChange: 'oncuechange',
  75. onCut: 'oncut',
  76. onDblClick: 'ondblclick',
  77. onDrag: 'ondrag',
  78. onDragEnd: 'ondragend',
  79. onDragEnter: 'ondragenter',
  80. onDragExit: 'ondragexit',
  81. onDragLeave: 'ondragleave',
  82. onDragOver: 'ondragover',
  83. onDragStart: 'ondragstart',
  84. onDrop: 'ondrop',
  85. onDurationChange: 'ondurationchange',
  86. onEmptied: 'onemptied',
  87. onEnd: 'onend',
  88. onEnded: 'onended',
  89. onError: 'onerror',
  90. onFocus: 'onfocus',
  91. onFocusIn: 'onfocusin',
  92. onFocusOut: 'onfocusout',
  93. onHashChange: 'onhashchange',
  94. onInput: 'oninput',
  95. onInvalid: 'oninvalid',
  96. onKeyDown: 'onkeydown',
  97. onKeyPress: 'onkeypress',
  98. onKeyUp: 'onkeyup',
  99. onLoad: 'onload',
  100. onLoadedData: 'onloadeddata',
  101. onLoadedMetadata: 'onloadedmetadata',
  102. onLoadStart: 'onloadstart',
  103. onMessage: 'onmessage',
  104. onMouseDown: 'onmousedown',
  105. onMouseEnter: 'onmouseenter',
  106. onMouseLeave: 'onmouseleave',
  107. onMouseMove: 'onmousemove',
  108. onMouseOut: 'onmouseout',
  109. onMouseOver: 'onmouseover',
  110. onMouseUp: 'onmouseup',
  111. onMouseWheel: 'onmousewheel',
  112. onOffline: 'onoffline',
  113. onOnline: 'ononline',
  114. onPageHide: 'onpagehide',
  115. onPageShow: 'onpageshow',
  116. onPaste: 'onpaste',
  117. onPause: 'onpause',
  118. onPlay: 'onplay',
  119. onPlaying: 'onplaying',
  120. onPopState: 'onpopstate',
  121. onProgress: 'onprogress',
  122. onRateChange: 'onratechange',
  123. onRepeat: 'onrepeat',
  124. onReset: 'onreset',
  125. onResize: 'onresize',
  126. onScroll: 'onscroll',
  127. onSeeked: 'onseeked',
  128. onSeeking: 'onseeking',
  129. onSelect: 'onselect',
  130. onShow: 'onshow',
  131. onStalled: 'onstalled',
  132. onStorage: 'onstorage',
  133. onSubmit: 'onsubmit',
  134. onSuspend: 'onsuspend',
  135. onTimeUpdate: 'ontimeupdate',
  136. onToggle: 'ontoggle',
  137. onUnload: 'onunload',
  138. onVolumeChange: 'onvolumechange',
  139. onWaiting: 'onwaiting',
  140. onZoom: 'onzoom',
  141. overlinePosition: 'overline-position',
  142. overlineThickness: 'overline-thickness',
  143. paintOrder: 'paint-order',
  144. panose1: 'panose-1',
  145. pointerEvents: 'pointer-events',
  146. referrerPolicy: 'referrerpolicy',
  147. renderingIntent: 'rendering-intent',
  148. shapeRendering: 'shape-rendering',
  149. stopColor: 'stop-color',
  150. stopOpacity: 'stop-opacity',
  151. strikethroughPosition: 'strikethrough-position',
  152. strikethroughThickness: 'strikethrough-thickness',
  153. strokeDashArray: 'stroke-dasharray',
  154. strokeDashOffset: 'stroke-dashoffset',
  155. strokeLineCap: 'stroke-linecap',
  156. strokeLineJoin: 'stroke-linejoin',
  157. strokeMiterLimit: 'stroke-miterlimit',
  158. strokeOpacity: 'stroke-opacity',
  159. strokeWidth: 'stroke-width',
  160. tabIndex: 'tabindex',
  161. textAnchor: 'text-anchor',
  162. textDecoration: 'text-decoration',
  163. textRendering: 'text-rendering',
  164. transformOrigin: 'transform-origin',
  165. typeOf: 'typeof',
  166. underlinePosition: 'underline-position',
  167. underlineThickness: 'underline-thickness',
  168. unicodeBidi: 'unicode-bidi',
  169. unicodeRange: 'unicode-range',
  170. unitsPerEm: 'units-per-em',
  171. vAlphabetic: 'v-alphabetic',
  172. vHanging: 'v-hanging',
  173. vIdeographic: 'v-ideographic',
  174. vMathematical: 'v-mathematical',
  175. vectorEffect: 'vector-effect',
  176. vertAdvY: 'vert-adv-y',
  177. vertOriginX: 'vert-origin-x',
  178. vertOriginY: 'vert-origin-y',
  179. wordSpacing: 'word-spacing',
  180. writingMode: 'writing-mode',
  181. xHeight: 'x-height',
  182. // These were camelcased in Tiny. Now lowercased in SVG 2
  183. playbackOrder: 'playbackorder',
  184. timelineBegin: 'timelinebegin'
  185. },
  186. properties: {
  187. about: commaOrSpaceSeparated,
  188. accentHeight: number,
  189. accumulate: null,
  190. additive: null,
  191. alignmentBaseline: null,
  192. alphabetic: number,
  193. amplitude: number,
  194. arabicForm: null,
  195. ascent: number,
  196. attributeName: null,
  197. attributeType: null,
  198. azimuth: number,
  199. bandwidth: null,
  200. baselineShift: null,
  201. baseFrequency: null,
  202. baseProfile: null,
  203. bbox: null,
  204. begin: null,
  205. bias: number,
  206. by: null,
  207. calcMode: null,
  208. capHeight: number,
  209. className: spaceSeparated,
  210. clip: null,
  211. clipPath: null,
  212. clipPathUnits: null,
  213. clipRule: null,
  214. color: null,
  215. colorInterpolation: null,
  216. colorInterpolationFilters: null,
  217. colorProfile: null,
  218. colorRendering: null,
  219. content: null,
  220. contentScriptType: null,
  221. contentStyleType: null,
  222. crossOrigin: null,
  223. cursor: null,
  224. cx: null,
  225. cy: null,
  226. d: null,
  227. dataType: null,
  228. defaultAction: null,
  229. descent: number,
  230. diffuseConstant: number,
  231. direction: null,
  232. display: null,
  233. dur: null,
  234. divisor: number,
  235. dominantBaseline: null,
  236. download: boolean,
  237. dx: null,
  238. dy: null,
  239. edgeMode: null,
  240. editable: null,
  241. elevation: number,
  242. enableBackground: null,
  243. end: null,
  244. event: null,
  245. exponent: number,
  246. externalResourcesRequired: null,
  247. fill: null,
  248. fillOpacity: number,
  249. fillRule: null,
  250. filter: null,
  251. filterRes: null,
  252. filterUnits: null,
  253. floodColor: null,
  254. floodOpacity: null,
  255. focusable: null,
  256. focusHighlight: null,
  257. fontFamily: null,
  258. fontSize: null,
  259. fontSizeAdjust: null,
  260. fontStretch: null,
  261. fontStyle: null,
  262. fontVariant: null,
  263. fontWeight: null,
  264. format: null,
  265. fr: null,
  266. from: null,
  267. fx: null,
  268. fy: null,
  269. g1: commaSeparated,
  270. g2: commaSeparated,
  271. glyphName: commaSeparated,
  272. glyphOrientationHorizontal: null,
  273. glyphOrientationVertical: null,
  274. glyphRef: null,
  275. gradientTransform: null,
  276. gradientUnits: null,
  277. handler: null,
  278. hanging: number,
  279. hatchContentUnits: null,
  280. hatchUnits: null,
  281. height: null,
  282. href: null,
  283. hrefLang: null,
  284. horizAdvX: number,
  285. horizOriginX: number,
  286. horizOriginY: number,
  287. id: null,
  288. ideographic: number,
  289. imageRendering: null,
  290. initialVisibility: null,
  291. in: null,
  292. in2: null,
  293. intercept: number,
  294. k: number,
  295. k1: number,
  296. k2: number,
  297. k3: number,
  298. k4: number,
  299. kernelMatrix: commaOrSpaceSeparated,
  300. kernelUnitLength: null,
  301. keyPoints: null, // SEMI_COLON_SEPARATED
  302. keySplines: null, // SEMI_COLON_SEPARATED
  303. keyTimes: null, // SEMI_COLON_SEPARATED
  304. kerning: null,
  305. lang: null,
  306. lengthAdjust: null,
  307. letterSpacing: null,
  308. lightingColor: null,
  309. limitingConeAngle: number,
  310. local: null,
  311. markerEnd: null,
  312. markerMid: null,
  313. markerStart: null,
  314. markerHeight: null,
  315. markerUnits: null,
  316. markerWidth: null,
  317. mask: null,
  318. maskContentUnits: null,
  319. maskUnits: null,
  320. mathematical: null,
  321. max: null,
  322. media: null,
  323. mediaCharacterEncoding: null,
  324. mediaContentEncodings: null,
  325. mediaSize: number,
  326. mediaTime: null,
  327. method: null,
  328. min: null,
  329. mode: null,
  330. name: null,
  331. navDown: null,
  332. navDownLeft: null,
  333. navDownRight: null,
  334. navLeft: null,
  335. navNext: null,
  336. navPrev: null,
  337. navRight: null,
  338. navUp: null,
  339. navUpLeft: null,
  340. navUpRight: null,
  341. numOctaves: null,
  342. observer: null,
  343. offset: null,
  344. onAbort: null,
  345. onActivate: null,
  346. onAfterPrint: null,
  347. onBeforePrint: null,
  348. onBegin: null,
  349. onCancel: null,
  350. onCanPlay: null,
  351. onCanPlayThrough: null,
  352. onChange: null,
  353. onClick: null,
  354. onClose: null,
  355. onCopy: null,
  356. onCueChange: null,
  357. onCut: null,
  358. onDblClick: null,
  359. onDrag: null,
  360. onDragEnd: null,
  361. onDragEnter: null,
  362. onDragExit: null,
  363. onDragLeave: null,
  364. onDragOver: null,
  365. onDragStart: null,
  366. onDrop: null,
  367. onDurationChange: null,
  368. onEmptied: null,
  369. onEnd: null,
  370. onEnded: null,
  371. onError: null,
  372. onFocus: null,
  373. onFocusIn: null,
  374. onFocusOut: null,
  375. onHashChange: null,
  376. onInput: null,
  377. onInvalid: null,
  378. onKeyDown: null,
  379. onKeyPress: null,
  380. onKeyUp: null,
  381. onLoad: null,
  382. onLoadedData: null,
  383. onLoadedMetadata: null,
  384. onLoadStart: null,
  385. onMessage: null,
  386. onMouseDown: null,
  387. onMouseEnter: null,
  388. onMouseLeave: null,
  389. onMouseMove: null,
  390. onMouseOut: null,
  391. onMouseOver: null,
  392. onMouseUp: null,
  393. onMouseWheel: null,
  394. onOffline: null,
  395. onOnline: null,
  396. onPageHide: null,
  397. onPageShow: null,
  398. onPaste: null,
  399. onPause: null,
  400. onPlay: null,
  401. onPlaying: null,
  402. onPopState: null,
  403. onProgress: null,
  404. onRateChange: null,
  405. onRepeat: null,
  406. onReset: null,
  407. onResize: null,
  408. onScroll: null,
  409. onSeeked: null,
  410. onSeeking: null,
  411. onSelect: null,
  412. onShow: null,
  413. onStalled: null,
  414. onStorage: null,
  415. onSubmit: null,
  416. onSuspend: null,
  417. onTimeUpdate: null,
  418. onToggle: null,
  419. onUnload: null,
  420. onVolumeChange: null,
  421. onWaiting: null,
  422. onZoom: null,
  423. opacity: null,
  424. operator: null,
  425. order: null,
  426. orient: null,
  427. orientation: null,
  428. origin: null,
  429. overflow: null,
  430. overlay: null,
  431. overlinePosition: number,
  432. overlineThickness: number,
  433. paintOrder: null,
  434. panose1: null,
  435. path: null,
  436. pathLength: number,
  437. patternContentUnits: null,
  438. patternTransform: null,
  439. patternUnits: null,
  440. phase: null,
  441. ping: spaceSeparated,
  442. pitch: null,
  443. playbackOrder: null,
  444. pointerEvents: null,
  445. points: null,
  446. pointsAtX: number,
  447. pointsAtY: number,
  448. pointsAtZ: number,
  449. preserveAlpha: null,
  450. preserveAspectRatio: null,
  451. primitiveUnits: null,
  452. propagate: null,
  453. property: commaOrSpaceSeparated,
  454. r: null,
  455. radius: null,
  456. referrerPolicy: null,
  457. refX: null,
  458. refY: null,
  459. rel: commaOrSpaceSeparated,
  460. rev: commaOrSpaceSeparated,
  461. renderingIntent: null,
  462. repeatCount: null,
  463. repeatDur: null,
  464. requiredExtensions: commaOrSpaceSeparated,
  465. requiredFeatures: commaOrSpaceSeparated,
  466. requiredFonts: commaOrSpaceSeparated,
  467. requiredFormats: commaOrSpaceSeparated,
  468. resource: null,
  469. restart: null,
  470. result: null,
  471. rotate: null,
  472. rx: null,
  473. ry: null,
  474. scale: null,
  475. seed: null,
  476. shapeRendering: null,
  477. side: null,
  478. slope: null,
  479. snapshotTime: null,
  480. specularConstant: number,
  481. specularExponent: number,
  482. spreadMethod: null,
  483. spacing: null,
  484. startOffset: null,
  485. stdDeviation: null,
  486. stemh: null,
  487. stemv: null,
  488. stitchTiles: null,
  489. stopColor: null,
  490. stopOpacity: null,
  491. strikethroughPosition: number,
  492. strikethroughThickness: number,
  493. string: null,
  494. stroke: null,
  495. strokeDashArray: commaOrSpaceSeparated,
  496. strokeDashOffset: null,
  497. strokeLineCap: null,
  498. strokeLineJoin: null,
  499. strokeMiterLimit: number,
  500. strokeOpacity: number,
  501. strokeWidth: null,
  502. style: null,
  503. surfaceScale: number,
  504. syncBehavior: null,
  505. syncBehaviorDefault: null,
  506. syncMaster: null,
  507. syncTolerance: null,
  508. syncToleranceDefault: null,
  509. systemLanguage: commaOrSpaceSeparated,
  510. tabIndex: number,
  511. tableValues: null,
  512. target: null,
  513. targetX: number,
  514. targetY: number,
  515. textAnchor: null,
  516. textDecoration: null,
  517. textRendering: null,
  518. textLength: null,
  519. timelineBegin: null,
  520. title: null,
  521. transformBehavior: null,
  522. type: null,
  523. typeOf: commaOrSpaceSeparated,
  524. to: null,
  525. transform: null,
  526. transformOrigin: null,
  527. u1: null,
  528. u2: null,
  529. underlinePosition: number,
  530. underlineThickness: number,
  531. unicode: null,
  532. unicodeBidi: null,
  533. unicodeRange: null,
  534. unitsPerEm: number,
  535. values: null,
  536. vAlphabetic: number,
  537. vMathematical: number,
  538. vectorEffect: null,
  539. vHanging: number,
  540. vIdeographic: number,
  541. version: null,
  542. vertAdvY: number,
  543. vertOriginX: number,
  544. vertOriginY: number,
  545. viewBox: null,
  546. viewTarget: null,
  547. visibility: null,
  548. width: null,
  549. widths: null,
  550. wordSpacing: null,
  551. writingMode: null,
  552. x: null,
  553. x1: null,
  554. x2: null,
  555. xChannelSelector: null,
  556. xHeight: number,
  557. y: null,
  558. y1: null,
  559. y2: null,
  560. yChannelSelector: null,
  561. z: null,
  562. zoomAndPan: null
  563. },
  564. space: 'svg',
  565. transform: caseSensitiveTransform
  566. })