-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The output of generateImplementedProperties.mjs is much nicer now. It was needlessly complex before.
- Loading branch information
Showing
6 changed files
with
86 additions
and
162 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
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,52 @@ | ||
// The W3C CSSWG provides a JSON list of all CSS properties and their status in the standard. | ||
// See the documentation at https://www.w3.org/Style/CSS/all-properties.en.html. | ||
// | ||
// This script downloads that file and uses it to write an appropriately-filtered Set of property | ||
// names to a file. | ||
|
||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const url = 'https://www.w3.org/Style/CSS/all-properties.en.json'; | ||
const outputFile = resolve('../lib/allProperties.js'); | ||
const unwantedStatuses = new Set(['NOTE', 'ED', 'FPWD']); | ||
|
||
console.log('Downloading CSS properties...'); | ||
|
||
const res = await fetch(url); | ||
if (res.status !== 200) { | ||
throw new Error('Bad status code: ' + res.status); | ||
} | ||
|
||
const rawCSSProperties = await res.json(); | ||
|
||
const propertyNames = new Set(); | ||
for (const cssProp of rawCSSProperties) { | ||
// Filter out properties from too-new statuses. | ||
// Also, '--*' needs additional logic to this module, so filter it out for now. | ||
if (unwantedStatuses.has(cssProp.status) || cssProp.property === '--*') { | ||
continue; | ||
} | ||
|
||
propertyNames.add(cssProp.property); | ||
} | ||
|
||
const propertyNamesJSON = JSON.stringify(Array.from(propertyNames), undefined, 2); | ||
const dateToday = new Date(); | ||
const dateTodayFormatted = dateToday.toISOString().split('T')[0]; | ||
|
||
const output = ` | ||
'use strict'; | ||
// autogenerated - ${dateTodayFormatted} | ||
// https://www.w3.org/Style/CSS/all-properties.en.html | ||
module.exports = new Set(${propertyNamesJSON}); | ||
`; | ||
|
||
fs.writeFileSync(outputFile, output); | ||
|
||
// TODO: remove when we can drop Node.js 18 support and use import.meta.dirname. | ||
function resolve(relativePath) { | ||
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath); | ||
} |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { camelToDashed } from '../lib/parsers.js'; | ||
|
||
const dashedProperties = fs | ||
.readdirSync(resolve('../lib/properties')) | ||
.filter((propertyFile) => path.extname(propertyFile) === '.js') | ||
.map((propertyFile) => camelToDashed(path.basename(propertyFile, '.js'))); | ||
|
||
const outputFile = resolve('../lib/implementedProperties.js'); | ||
|
||
const propertyNamesJSON = JSON.stringify(dashedProperties, undefined, 2); | ||
const dateToday = new Date(); | ||
const dateTodayFormatted = dateToday.toISOString().split('T')[0]; | ||
|
||
const output = ` | ||
'use strict'; | ||
// autogenerated - ${dateTodayFormatted} | ||
// https://www.w3.org/Style/CSS/all-properties.en.html | ||
module.exports = new Set(${propertyNamesJSON}); | ||
`; | ||
|
||
fs.writeFileSync(outputFile, output); | ||
|
||
// TODO: remove when we can drop Node.js 18 support and use import.meta.dirname. | ||
function resolve(relativePath) { | ||
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath); | ||
} |
This file was deleted.
Oops, something went wrong.