0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,12 @@
# 4.0.0-rc.0
* Breaking: Drops support for Node 0.12, we now require at least Node 4.
* Breaking: Update PostCSS to 6.0.0.
# 0.1.1
* Add transpilation.
# 0.1.0
* First version.

20
web/node_modules/postcss-discard-overridden/LICENSE generated vendored Normal file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2016 Justineo <justice360@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

158
web/node_modules/postcss-discard-overridden/README.md generated vendored Normal file
View file

@ -0,0 +1,158 @@
# PostCSS Discard Overridden
[PostCSS] plugin to discard overridden `@keyframes` or `@counter-style`.
`@keyframes` or `@counter-style` will be overridden by those who share the same identifiers and appear later in stylesheets. So we can discard all of them except the last one. When defined inside a `@media` or `@supports` rule, `@keyframes` and `@counter-style` rules only override global rules in some of the client browsers so they need handled separately. This plugin has taken care of this and transforms the PostCss AST **safely**.
[PostCSS]: https://github.com/postcss/postcss
```css
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@media (max-width: 500px) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@supports (display: flex) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
```
```css
@media (max-width: 500px) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@supports (display: flex) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
```
## Usage
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.
## Contributors
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).

View file

@ -0,0 +1,57 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _postcss = require('postcss');
var _postcss2 = _interopRequireDefault(_postcss);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const OVERRIDABLE_RULES = ['keyframes', 'counter-style'];
const SCOPE_RULES = ['media', 'supports'];
function isOverridable(name) {
return ~OVERRIDABLE_RULES.indexOf(_postcss2.default.vendor.unprefixed(name.toLowerCase()));
}
function isScope(name) {
return ~SCOPE_RULES.indexOf(_postcss2.default.vendor.unprefixed(name.toLowerCase()));
}
function getScope(node) {
let current = node.parent;
const chain = [node.name.toLowerCase(), node.params];
do {
if (current.type === 'atrule' && isScope(current.name)) {
chain.unshift(current.name + ' ' + current.params);
}
current = current.parent;
} while (current);
return chain.join('|');
}
exports.default = _postcss2.default.plugin('postcss-discard-overridden', () => {
return css => {
const cache = {};
const rules = [];
css.walkAtRules(node => {
if (isOverridable(node.name)) {
const scope = getScope(node);
cache[scope] = node;
rules.push({
node,
scope
});
}
});
rules.forEach(rule => {
if (cache[rule.scope] !== rule.node) {
rule.node.remove();
}
});
};
});
module.exports = exports['default'];

View file

@ -0,0 +1,41 @@
longDescription = """
Removes at-rules which have the same identifier as another; for example two
instances of `@keyframes one`. As the browser will only count the *last* of
these declarations, all others can safely be removed.
"""
inputExample = """
@keyframes one {
0% {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes one {
0% {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
.box {
animation-name: one;
}
"""
outputExample = """
@keyframes one {
0% {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
.box {
animation-name: one;
}
"""

View file

@ -0,0 +1,36 @@
{
"name": "postcss-discard-overridden",
"version": "4.0.1",
"description": "PostCSS plugin to discard overridden @keyframes or @counter-style.",
"main": "dist/index.js",
"keywords": [
"postcss",
"css",
"postcss-plugin",
"at-rules",
"@keyframes",
"@counter-style"
],
"author": "Justineo <justice360@gmail.com>",
"license": "MIT",
"repository": "cssnano/cssnano",
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"homepage": "https://github.com/cssnano/cssnano",
"dependencies": {
"postcss": "^7.0.0"
},
"devDependencies": {
"babel-cli": "^6.0.0",
"chalk": "^2.0.0",
"cross-env": "^5.0.0",
"diff": "^3.0.0"
},
"scripts": {
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
},
"engines": {
"node": ">=6.9.0"
}
}

View file

@ -0,0 +1,39 @@
@counter-style my-alpha {
system: fixed;
symbols: A B C;
suffix: " ";
}
@COUNTER-STYLE my-alpha {
system: fixed;
symbols: A B C;
suffix: " ";
}
@counter-style my-alpha {
system: fixed;
symbols: ;
suffix: " ";
}
@media (max-width: 400px) {
@counter-style my-alpha {
system: fixed;
symbols: A B C;
suffix: " ";
}
@supports (display: flex) {
@counter-style my-alpha {
system: fixed;
symbols: a b c;
suffix: " ";
}
}
@counter-style my-alpha {
system: fixed;
symbols: ;
suffix: " ";
}
}

View file

@ -0,0 +1,22 @@
@counter-style my-alpha {
system: fixed;
symbols: ;
suffix: " ";
}
@media (max-width: 400px) {
@supports (display: flex) {
@counter-style my-alpha {
system: fixed;
symbols: a b c;
suffix: " ";
}
}
@counter-style my-alpha {
system: fixed;
symbols: ;
suffix: " ";
}
}

View file

@ -0,0 +1,100 @@
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@-WEBKIT-KEYFRAMES fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@KEYFRAMES fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@media (max-width: 500px) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@supports (display: flex) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

View file

@ -0,0 +1,52 @@
@media (max-width: 500px) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 0.8;
}
}
@supports (display: flex) {
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

View file

@ -0,0 +1,63 @@
import fs from 'fs';
import postcss from 'postcss';
import test from 'ava';
import {diffLines} from 'diff';
import chalk from 'chalk';
import plugin from '../';
function getDiff (left, right) {
let msg = ['\n'];
diffLines(left, right).forEach(item => {
if (item.added || item.removed) {
let text = item.value
.replace('\n', '\u00b6\n')
.replace('\ufeff', '[[BOM]]');
msg.push(chalk[item.added ? 'green' : 'red'](text));
} else {
let value = item.value.replace('\ufeff', '[[BOM]]');
let lines = value.split('\n');
// max line count for each item
let keepLines = 6;
// lines to be omitted
let omitLines = lines.length - keepLines;
if (lines.length > keepLines) {
lines.splice(
Math.floor(keepLines / 2),
omitLines,
chalk.gray('(...' + omitLines + ' lines omitted...)')
);
}
msg.concat(lines);
}
});
msg.push('\n');
return msg.map(line => ' ' + line).join('');
}
function read (file) {
return fs.readFileSync(__dirname + `/fixtures/${file}.css`, {encoding: 'utf-8'});
}
function exec (t, input) {
let output = read(`${input}.post`);
return postcss([ plugin() ]).process(read(input))
.then( result => {
if (result.css !== output) {
t.fail(getDiff(result.css, output));
}
t.deepEqual(result.warnings().length, 0);
});
}
test(
'Overridden @keyframes should be discarded correctly.',
exec,
'keyframes'
);
test(
'Overridden @counter-style should be discarded correctly.',
exec,
'counter-style'
);

View file

@ -0,0 +1,46 @@
import postcss from 'postcss';
const OVERRIDABLE_RULES = ['keyframes', 'counter-style'];
const SCOPE_RULES = ['media', 'supports'];
function isOverridable (name) {
return ~OVERRIDABLE_RULES.indexOf(postcss.vendor.unprefixed(name.toLowerCase()));
}
function isScope (name) {
return ~SCOPE_RULES.indexOf(postcss.vendor.unprefixed(name.toLowerCase()));
}
function getScope (node) {
let current = node.parent;
const chain = [node.name.toLowerCase(), node.params];
do {
if (current.type === 'atrule' && isScope(current.name)) {
chain.unshift(current.name + ' ' + current.params);
}
current = current.parent;
} while (current);
return chain.join('|');
}
export default postcss.plugin('postcss-discard-overridden', () => {
return css => {
const cache = {};
const rules = [];
css.walkAtRules(node => {
if (isOverridable(node.name)) {
const scope = getScope(node);
cache[scope] = node;
rules.push({
node,
scope,
});
}
});
rules.forEach(rule => {
if (cache[rule.scope] !== rule.node) {
rule.node.remove();
}
});
};
});

1072
web/node_modules/postcss-discard-overridden/yarn.lock generated vendored Normal file

File diff suppressed because it is too large Load diff