@webref/css 7.0.1-alpha → 7.0.3-alpha
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.
- package/CHANGELOG.md +5 -3
- package/README.md +40 -15
- package/css.json +3289 -3230
- package/index.js +24 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ Webref adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|
|
7
7
|
applied to data. A new major version is released whenever a breaking change is
|
|
8
8
|
made to the data structure.
|
|
9
9
|
|
|
10
|
-
## v7.0.
|
|
10
|
+
## v7.0.x - 2025-TBD
|
|
11
11
|
|
|
12
12
|
CSS extracts are now consolidated into a single file.
|
|
13
13
|
|
|
@@ -19,11 +19,13 @@ CSS extracts are now consolidated into a single file.
|
|
|
19
19
|
|
|
20
20
|
In version 6, `listAll()` resolved with an object where the keys were spec shortnames, and the values mostly matched the structure of the consolidated object that the function now returns. On top of the consolidation itself, main differences are:
|
|
21
21
|
- Functions and types were merged in a `values` category in version 6, they now appear in separate `functions` and `types` categories.
|
|
22
|
-
- Functions and types that were scoped to another CSS feature appeared nested under that CSS feature in version 6. They now appear directly under `functions` and `types` with a `for` key that contains the
|
|
22
|
+
- Functions and types that were scoped to another CSS feature appeared nested under that CSS feature in version 6. They now appear directly under `functions` and `types` with a `for` key that contains the list of scoping features for that feature. A scoping feature may be a property, a function or a type. When the scoping feature is a type, its name in the `for` key is enclosed between `<` and `>`.
|
|
23
|
+
- Feature syntaxes were stored in a `value` key. That key is now named `syntax`. Actual syntax values are the same as before and can be parsed with CSSTree.
|
|
23
24
|
- The shortname of the spec (or specs) that defines a feature is no longer readily available (but note the `href` key targets the defining spec). If you need the specs' shortnames, please [raise an issue](https://github.com/w3c/webref/issues) to describe your use case.
|
|
24
25
|
- The consolidation removes duplicates, merging extended definitions into a single feature. The definition from the latest spec level is used when a feature is defined in more than one level. If you need the definition from earlier levels, please [raise an issue](https://github.com/w3c/webref/issues) to describe your needs!
|
|
25
|
-
- Some of the possible values that a CSS feature could take appeared nested under that feature definition in a `values` key in version 6. Such values are no longer reported in the new version: they were confusing in any case because they did not cover the whole range of values that a feature could take, and could contain values that were not atomic keyword values. Values could be re-introduced when CSS specs are more systematic about them. In the meantime, you will need to parse the feature's syntax (the `
|
|
26
|
+
- Some of the possible values that a CSS feature could take appeared nested under that feature definition in a `values` key in version 6. Such values are no longer reported in the new version: they were confusing in any case because they did not cover the whole range of values that a feature could take, and could contain values that were not atomic keyword values. Values could be re-introduced when CSS specs are more systematic about them. In the meantime, you will need to parse the feature's syntax (the `syntax` key) to extract keyword values.
|
|
26
27
|
|
|
28
|
+
Additionally, the package now also exposes a new `index()` async method that resolves with an object similar to that returned by `listAll()`, except that lists of features under each category are indexed by feature names. For scoped features, the feature name is used as identifier when it is unambiguous. If a feature is defined differently for different scopes, the feature name is completed with the name of the first scoping feature to disambiguate. For example, `type() for @function`, `type() for attr()`.
|
|
27
29
|
|
|
28
30
|
## v6.0.0 - 2022-11-28
|
|
29
31
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,11 @@ This package contains a consolidated list of CSS features defined across specs,
|
|
|
6
6
|
|
|
7
7
|
# API
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Two async methods are exposed: `listAll()` and `index()`. They both resolve with an object that lists CSS features by feature type: `atrules`, `functions`, `properties`, `selectors` and `types`.
|
|
10
|
+
|
|
11
|
+
The difference between the two functions is that, under each feature type, `listAll()` returns an array of features, whereas `index()` returns an object indexed by feature name to ease direct lookups (and [transition from `mdn/data`](#transition-from-mdndata). Both functions return the same features.
|
|
12
|
+
|
|
13
|
+
Example using `listAll()`:
|
|
10
14
|
|
|
11
15
|
```js
|
|
12
16
|
const css = require('@webref/css');
|
|
@@ -18,43 +22,64 @@ for (const feature of functions) {
|
|
|
18
22
|
}
|
|
19
23
|
```
|
|
20
24
|
|
|
25
|
+
Example using `index()`:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const css = require('@webref/css');
|
|
29
|
+
|
|
30
|
+
const { atrules, functions, properties, selectors, types } = await css.index();
|
|
31
|
+
|
|
32
|
+
// Do something with the object that describes the abs() function
|
|
33
|
+
const abs = functions['abs()'];
|
|
34
|
+
```
|
|
35
|
+
|
|
21
36
|
Each CSS feature is described by:
|
|
22
37
|
- a `name` key that contains the name of the feature
|
|
23
38
|
- an `href` key that contains the URL (with a fragment) of the CSS spec that defines the feature
|
|
24
39
|
|
|
25
|
-
Many CSS features also have a `
|
|
40
|
+
Many CSS features also have a `syntax` key that describes the syntax of the feature, as defined in the spec. This syntax can be parsed with the [CSSTree Value Definition Syntax parser](https://github.com/csstree/csstree/blob/master/docs/definition-syntax.md#value-definition-syntax). Example:
|
|
26
41
|
|
|
27
42
|
```js
|
|
28
43
|
const css = require('@webref/css');
|
|
29
44
|
const { definitionSyntax } = require('css-tree');
|
|
30
45
|
|
|
31
|
-
const { properties } = await css.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const ast = definitionSyntax.parse(property.value);
|
|
37
|
-
// do something with the abstract syntax tree
|
|
38
|
-
}
|
|
46
|
+
const { properties } = await css.index();
|
|
47
|
+
const ast = definitionSyntax.parse(properties['flex'].syntax);
|
|
48
|
+
// do something with the abstract syntax tree
|
|
39
49
|
```
|
|
40
50
|
|
|
41
51
|
Additional keys may be set depending on the type of the CSS feature. For example:
|
|
42
52
|
|
|
43
53
|
- At-rules have a `descriptors` key that contains the list of descriptors defined for the given at-rule.
|
|
44
|
-
- Functions and types that are scoped to a property or other feature have a `for` key that contains the
|
|
54
|
+
- Functions and types that are scoped to a property or other feature have a `for` key that contains the list of scoping features for that feature. A scoping feature may be a property, a function or a type. When the scoping feature is a type, its name in the `for` key is enclosed between `<` and `>`.
|
|
45
55
|
- Properties have a `styleDeclaration` key that contains the list of IDL attribute names that the property generates. A number of other keys may be set to describe the property's initial value, animation type and other parameters.
|
|
46
56
|
|
|
47
57
|
Additional notes:
|
|
48
|
-
-
|
|
58
|
+
- Features returned by `index()` are indexed by their feature name, but there are exceptional cases where a given feature is defined differently (with a different syntax) for different scopes. In such cases the feature is indexed by its name completed with ` for ` and the name of the first scoping feature to which the definition applies. For example, `type() for @function`, `type() for attr()`. As of June 2025, this affects a handful of functions and types.
|
|
49
59
|
- When a feature is defined across different levels in the same spec series, the definition from the latest level is used.
|
|
50
|
-
- When a property is extended with new values in different specs, `href` links to the base definition and `
|
|
60
|
+
- When a property is extended with new values in different specs, `href` links to the base definition and `syntax` is the union (using `|`) of the syntaxes of the base and extended definitions.
|
|
51
61
|
- When new descriptors are defined for an at-rule in different specs, `descriptors` contains the merged list of known descriptors.
|
|
52
|
-
- When specs define the syntax of an at-rule in terms of `<declaration-list>` or `<declaration-rule-list>`, the `
|
|
62
|
+
- When specs define the syntax of an at-rule in terms of `<declaration-list>` or `<declaration-rule-list>`, the `syntax` key contains an "expanded" syntax that leverages the syntax of the at-rule's descriptors.
|
|
63
|
+
|
|
64
|
+
## Migrating from `mdn/data`
|
|
65
|
+
|
|
66
|
+
The structure of the consolidated list of CSS features aligns with CSS data in [`mdn/data`](https://github.com/mdn/data). If you use the `index()` method, the `@webref/css` package can *almost* serve as a drop-in replacement for the `mdn/data` package **for syntaxes**, with the following structural nuances:
|
|
67
|
+
|
|
68
|
+
- `mdn/data` reports at-rules under an `atRules` key. `@webref/css` reports them under an `atrules` key.
|
|
69
|
+
- `mdn/data` stores syntaxes of functions and types under a separate `syntaxes` key. `@webref/css` stores them in their feature definition. If you need to reproduce the `syntaxes` list, merge the entries under `functions` and `types`.
|
|
70
|
+
- `mdn/data` assumes all features are unscoped. `@webref/css` reports scopes where needed in a `for` key. Note that a few functions have a different syntax depending on the scope under which they are used.
|
|
71
|
+
- `@webref/css` does not contain information about CSS units.
|
|
72
|
+
|
|
73
|
+
Beyond structural nuances, differences in content may also affect transition:
|
|
74
|
+
- `mdn/data` contains deprecated features, proprietary features or feature variants that are not defined in specs. `@webref/css` only contains features defined in specs.
|
|
75
|
+
- `mdn/data` describes features as implemented in main browsers. `@webref/css` "lives on the edge", listing features and syntaxes from latest levels of CSS specs, regardless of the spec's maturity level and support across browsers.
|
|
76
|
+
- `mdn/data` turns specs prose into syntax when needed, `@webref/css` only has syntaxes that are explicitly defined in specs. It should be possible to improve the specs, consider submitting missing syntax reports (against the specs themselves if possible, in [Webref](https://github.com/w3c/webref/issues) otherwise).
|
|
77
|
+
|
|
53
78
|
|
|
54
79
|
# Guarantees
|
|
55
80
|
|
|
56
81
|
The following guarantees are provided by this package:
|
|
57
|
-
- All syntax values (the `
|
|
82
|
+
- All syntax values (the `syntax` keys) can be parsed by the version of [CSSTree](https://github.com/csstree/csstree) set in `peerDependencies` in `package.json`.
|
|
58
83
|
- Feature names (the `name` keys) are unique per type provided that the `for` key is also taken into account for functions and types.
|
|
59
84
|
- All features have an `href` key that targets the CSS spec that defines the feature. When the feature is extended across CSS specs, this URL targets the base definition.
|
|
60
85
|
|