-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
366 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
["acronym","applet","basefont","bgsound","big","blink","center","command","content","dir","element","font","frame","frameset","image","isindex","keygen","listing","marquee","menuitem","multicol","nextid","nobr","noembed","noframes","plaintext","shadow","spacer","strike","tt","xmp"] | ||
[ | ||
"acronym", | ||
"applet", | ||
"basefont", | ||
"bgsound", | ||
"big", | ||
"blink", | ||
"center", | ||
"dir", | ||
"font", | ||
"frame", | ||
"frameset", | ||
"isindex", | ||
"keygen", | ||
"listing", | ||
"marquee", | ||
"menuitem", | ||
"multicol", | ||
"nextid", | ||
"nobr", | ||
"noembed", | ||
"noframes", | ||
"param", | ||
"plaintext", | ||
"rb", | ||
"rtc", | ||
"spacer", | ||
"strike", | ||
"tt", | ||
"xmp" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,113 @@ | ||
["html","body","base","head","link","meta","style","title","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","nav","section","div","dd","dl","dt","figcaption","figure","hr","img","li","main","ol","p","pre","ul","a","b","abbr","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","area","audio","map","track","video","embed","object","param","source","canvas","script","noscript","del","ins","caption","col","colgroup","table","thead","tbody","tfoot","td","th","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","menuitem","summary","content","element","shadow","template","slot","blockquote","iframe","noframes","picture"] | ||
[ | ||
"a", | ||
"abbr", | ||
"address", | ||
"area", | ||
"article", | ||
"aside", | ||
"audio", | ||
"b", | ||
"base", | ||
"bdi", | ||
"bdo", | ||
"blockquote", | ||
"body", | ||
"br", | ||
"button", | ||
"canvas", | ||
"caption", | ||
"cite", | ||
"code", | ||
"col", | ||
"colgroup", | ||
"data", | ||
"datalist", | ||
"dd", | ||
"del", | ||
"details", | ||
"dfn", | ||
"dialog", | ||
"div", | ||
"dl", | ||
"dt", | ||
"em", | ||
"embed", | ||
"fieldset", | ||
"figcaption", | ||
"figure", | ||
"footer", | ||
"form", | ||
"h1", | ||
"h2", | ||
"h3", | ||
"h4", | ||
"h5", | ||
"h6", | ||
"head", | ||
"header", | ||
"hgroup", | ||
"hr", | ||
"html", | ||
"i", | ||
"iframe", | ||
"img", | ||
"input", | ||
"ins", | ||
"kbd", | ||
"label", | ||
"legend", | ||
"li", | ||
"link", | ||
"main", | ||
"map", | ||
"mark", | ||
"menu", | ||
"meta", | ||
"meter", | ||
"nav", | ||
"noscript", | ||
"object", | ||
"ol", | ||
"optgroup", | ||
"option", | ||
"output", | ||
"p", | ||
"picture", | ||
"pre", | ||
"progress", | ||
"q", | ||
"rp", | ||
"rt", | ||
"ruby", | ||
"s", | ||
"samp", | ||
"script", | ||
"section", | ||
"select", | ||
"slot", | ||
"small", | ||
"source", | ||
"span", | ||
"strong", | ||
"style", | ||
"sub", | ||
"summary", | ||
"sup", | ||
"table", | ||
"tbody", | ||
"td", | ||
"template", | ||
"textarea", | ||
"tfoot", | ||
"th", | ||
"thead", | ||
"time", | ||
"title", | ||
"tr", | ||
"track", | ||
"u", | ||
"ul", | ||
"var", | ||
"video", | ||
"wbr" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,65 @@ | ||
["a","animate","animateMotion","animateTransform","audio","canvas","circle","clipPath","defs","desc","discard","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","iframe","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","unknown","use","video","view"] | ||
[ | ||
"a", | ||
"animate", | ||
"animateMotion", | ||
"animateTransform", | ||
"circle", | ||
"clipPath", | ||
"defs", | ||
"desc", | ||
"ellipse", | ||
"feBlend", | ||
"feColorMatrix", | ||
"feComponentTransfer", | ||
"feComposite", | ||
"feConvolveMatrix", | ||
"feDiffuseLighting", | ||
"feDisplacementMap", | ||
"feDistantLight", | ||
"feDropShadow", | ||
"feFlood", | ||
"feFuncA", | ||
"feFuncB", | ||
"feFuncG", | ||
"feFuncR", | ||
"feGaussianBlur", | ||
"feImage", | ||
"feMerge", | ||
"feMergeNode", | ||
"feMorphology", | ||
"feOffset", | ||
"fePointLight", | ||
"feSpecularLighting", | ||
"feSpotLight", | ||
"feTile", | ||
"feTurbulence", | ||
"filter", | ||
"foreignObject", | ||
"g", | ||
"image", | ||
"line", | ||
"linearGradient", | ||
"marker", | ||
"mask", | ||
"metadata", | ||
"mpath", | ||
"path", | ||
"pattern", | ||
"polygon", | ||
"polyline", | ||
"radialGradient", | ||
"rect", | ||
"script", | ||
"set", | ||
"stop", | ||
"style", | ||
"svg", | ||
"switch", | ||
"symbol", | ||
"text", | ||
"textPath", | ||
"title", | ||
"tspan", | ||
"use", | ||
"view" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const https = require('https') | ||
const { URL } = require('url') | ||
|
||
module.exports = { | ||
httpGet | ||
} | ||
function httpGet(url) { | ||
return new Promise((resolve, reject) => { | ||
let result = '' | ||
https | ||
.get(url, (res) => { | ||
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400) { | ||
// redirect | ||
let redirectUrl = res.headers.location | ||
if (!redirectUrl.startsWith('http')) { | ||
const baseUrl = new URL(url) | ||
baseUrl.pathname = redirectUrl | ||
redirectUrl = String(baseUrl) | ||
} | ||
resolve(httpGet(redirectUrl)) | ||
return | ||
} | ||
res.setEncoding('utf8') | ||
res.on('data', (chunk) => { | ||
result += String(chunk) | ||
}) | ||
res.on('end', () => { | ||
resolve(result) | ||
}) | ||
res.on('error', reject) | ||
}) | ||
.on('error', reject) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const tsParser = require('@typescript-eslint/parser') | ||
const { httpGet } = require('./lib/http') | ||
|
||
/** | ||
* @typedef {import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration} TSInterfaceDeclaration | ||
*/ | ||
|
||
main() | ||
|
||
async function main() { | ||
const libDomDTsText = await httpGet( | ||
'https://unpkg.com/typescript/lib/lib.dom.d.ts' | ||
) | ||
const rootNode = tsParser.parse(libDomDTsText, { | ||
loc: true, | ||
range: true | ||
}) | ||
updateDeprecatedHTMLElements() | ||
updateHTMLElements() | ||
updateSVGElements() | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Update deprecated-html-elements.json | ||
// ------------------------------------------------------------------------------ | ||
function updateDeprecatedHTMLElements() { | ||
const DEPRECATED_HTML_ELEMENTS_PATH = require.resolve( | ||
'../lib/utils/deprecated-html-elements.json' | ||
) | ||
const elements = new Set() | ||
/** @type {TSInterfaceDeclaration} */ | ||
const interfaceDeclaration = rootNode.body.find( | ||
(body) => | ||
body.type === 'TSInterfaceDeclaration' && | ||
body.id.name === 'HTMLElementDeprecatedTagNameMap' | ||
) | ||
|
||
for (const name of extractPropNames(interfaceDeclaration)) { | ||
elements.add(name) | ||
} | ||
|
||
fs.writeFileSync( | ||
DEPRECATED_HTML_ELEMENTS_PATH, | ||
`${JSON.stringify([...elements].sort(), null, 2)}\n`, | ||
'utf8' | ||
) | ||
} | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Update html-elements.json | ||
// ------------------------------------------------------------------------------ | ||
function updateHTMLElements() { | ||
const HTML_ELEMENTS_PATH = require.resolve( | ||
'../lib/utils/html-elements.json' | ||
) | ||
const elements = new Set() | ||
const deprecatedHtmlElements = new Set( | ||
require('../lib/utils/deprecated-html-elements.json') | ||
) | ||
/** @type {TSInterfaceDeclaration} */ | ||
const interfaceDeclaration = rootNode.body.find( | ||
(body) => | ||
body.type === 'TSInterfaceDeclaration' && | ||
body.id.name === 'HTMLElementTagNameMap' | ||
) | ||
|
||
for (const name of extractPropNames(interfaceDeclaration)) { | ||
if (deprecatedHtmlElements.has(name)) { | ||
continue | ||
} | ||
elements.add(name) | ||
} | ||
|
||
fs.writeFileSync( | ||
HTML_ELEMENTS_PATH, | ||
`${JSON.stringify([...elements].sort(), null, 2)}\n`, | ||
'utf8' | ||
) | ||
} | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Update svg-elements.json | ||
// ------------------------------------------------------------------------------ | ||
function updateSVGElements() { | ||
const SVG_ELEMENTS_PATH = require.resolve('../lib/utils/svg-elements.json') | ||
const elements = new Set() | ||
/** @type {TSInterfaceDeclaration} */ | ||
const interfaceDeclaration = rootNode.body.find( | ||
(body) => | ||
body.type === 'TSInterfaceDeclaration' && | ||
body.id.name === 'SVGElementTagNameMap' | ||
) | ||
|
||
for (const name of extractPropNames(interfaceDeclaration)) { | ||
elements.add(name) | ||
} | ||
|
||
fs.writeFileSync( | ||
SVG_ELEMENTS_PATH, | ||
`${JSON.stringify([...elements].sort(), null, 2)}\n`, | ||
'utf8' | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* @param {TSInterfaceDeclaration} node | ||
*/ | ||
function* extractPropNames(node) { | ||
for (const m of node.body.body) { | ||
if ( | ||
(m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') && | ||
(m.key.type === 'Identifier' || m.key.type === 'Literal') | ||
) { | ||
yield m.key.type === 'Identifier' ? m.key.name : `${m.key.value}` | ||
} | ||
} | ||
} |
Oops, something went wrong.