Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -0,0 +1,17 @@
{
"presets": [
"es2015",
"stage-0"
],
"plugins": [
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
],
"env": {
"test": {
"plugins": [
"rewire"
]
}
}
}

View File

@@ -0,0 +1,7 @@
{
"extends": "eslint-config-jss",
"parser": "babel-eslint",
"globals": {
"benchmark": true
}
}

View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2014-present Oleg Slobodskoi
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.

View File

@@ -0,0 +1,15 @@
## 1.0.1 / 2018-01-17
- Don't warn when extra new lines are used at the end or beginning
## 1.0.0 / 2017-09-30
- Fix the build
## 0.1.1 / 2017-08-09
- Fix the build
## 0.1.0 / 2017-08-08
- First release

View File

@@ -0,0 +1,38 @@
const webpackConfig = require('./webpack.config')
const isBench = process.env.BENCHMARK === 'true'
module.exports = (config) => {
config.set({
browsers: ['Chrome'],
frameworks: ['mocha'],
files: ['tests.webpack.js'],
preprocessors: {
'tests.webpack.js': ['webpack', 'sourcemap']
},
webpack: Object.assign(webpackConfig, {
devtool: 'inline-source-map'
}),
webpackServer: {
noInfo: true
},
reporters: ['mocha', 'coverage'],
coverageReporter: {
dir: 'coverage',
file: 'coverage.json',
type: 'json'
}
})
if (isBench) {
Object.assign(config, {
browsers: ['Chrome'],
frameworks: ['benchmark'],
files: ['benchmark/**/*.js'],
preprocessors: {'benchmark/**/*.js': ['webpack']},
reporters: ['benchmark'],
// Some tests are slow.
browserNoActivityTimeout: 20000
})
}
}

View File

@@ -0,0 +1,21 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _parse = require('./parse');
var _parse2 = _interopRequireDefault(_parse);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var onProcessRule = function onProcessRule(rule) {
if (typeof rule.style === 'string') {
rule.style = (0, _parse2['default'])(rule.style);
}
};
exports['default'] = function () {
return { onProcessRule: onProcessRule };
};

View File

@@ -0,0 +1,112 @@
'use strict';
var _templateObject = _taggedTemplateLiteral(['\n .a-id {\n color: red;\n }\n '], ['\n .a-id {\n color: red;\n }\n ']),
_templateObject2 = _taggedTemplateLiteral(['\n .a-id {\n color: red;\n float: left;\n }\n '], ['\n .a-id {\n color: red;\n float: left;\n }\n ']),
_templateObject3 = _taggedTemplateLiteral(['\n @media print {\n .button-id {\n color: black;\n }\n }\n '], ['\n @media print {\n .button-id {\n color: black;\n }\n }\n ']),
_templateObject4 = _taggedTemplateLiteral(['\n @keyframes id {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n '], ['\n @keyframes id {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n ']);
var _expect = require('expect.js');
var _expect2 = _interopRequireDefault(_expect);
var _commonTags = require('common-tags');
var _ = require('./');
var _2 = _interopRequireDefault(_);
var _parse = require('./parse');
var _parse2 = _interopRequireDefault(_parse);
var _jss = require('jss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } /* eslint-disable no-underscore-dangle */
var settings = {
createGenerateClassName: function createGenerateClassName() {
return function (rule) {
return rule.key + '-id';
};
}
};
describe('jss-template', function () {
var jss = void 0;
var warning = void 0;
beforeEach(function () {
_parse2['default'].__Rewire__('warning', function (condition, message) {
warning = message;
});
jss = (0, _jss.create)(settings).use((0, _2['default'])());
});
afterEach(function () {
_parse2['default'].__ResetDependency__('warning');
warning = undefined;
});
describe('template literals', function () {
it('should convert a single single property/value', function () {
var sheet = jss.createStyleSheet({
a: '\n color: red;\n '
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject));
});
it('should parse multiple props/values', function () {
var sheet = jss.createStyleSheet({
a: '\n color: red;\n float: left;\n '
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject2));
(0, _expect2['default'])(warning).to.be(undefined);
});
it('should warn when there is no colon found', function () {
jss.createStyleSheet({
a: 'color red;'
});
jss.createStyleSheet({
a: '\n color: red;\n float: left;\n '
});
(0, _expect2['default'])(warning).to.not.be(undefined);
});
it('should strip spaces', function () {
var sheet = jss.createStyleSheet({
a: '\n color: red ;\n float: left ;\n '
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject2));
});
it('should allow skiping last semicolon', function () {
var sheet = jss.createStyleSheet({
a: '\n color: red;\n float: left\n '
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject2));
});
it('should support @media', function () {
var sheet = jss.createStyleSheet({
'@media print': {
button: 'color: black'
}
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject3));
});
it('should support @keyframes', function () {
var sheet = jss.createStyleSheet({
'@keyframes id': {
from: 'opacity: 0',
to: 'opacity: 1'
}
});
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject4));
});
});
});

View File

@@ -0,0 +1,39 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var semiWithNl = /;\n/;
/**
* Naive CSS parser.
* - Supports only rule body (no selectors)
* - Requires semicolon and new line after the value (except of last line)
* - No nested rules support
*/
exports['default'] = function (cssText) {
var style = {};
var split = cssText.split(semiWithNl);
for (var i = 0; i < split.length; i++) {
var decl = (split[i] || '').trim();
if (!decl) continue;
var colonIndex = decl.indexOf(':');
if (colonIndex === -1) {
(0, _warning2['default'])(false, 'Malformed CSS string "%s"', decl);
continue;
}
var prop = decl.substr(0, colonIndex).trim();
var value = decl.substr(colonIndex + 1).trim();
style[prop] = value;
}
return style;
};

View File

@@ -0,0 +1,123 @@
{
"_args": [
[
"jss-template@1.0.1",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI"
]
],
"_from": "jss-template@1.0.1",
"_id": "jss-template@1.0.1",
"_inBundle": false,
"_integrity": "sha512-m5BqEWha17fmIVXm1z8xbJhY6GFJxNB9H68GVnCWPyGYfxiAgY9WTQyvDAVj+pYRgrXSOfN5V1T4+SzN1sJTeg==",
"_location": "/material-ui/jss-template",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "jss-template@1.0.1",
"name": "jss-template",
"escapedName": "jss-template",
"rawSpec": "1.0.1",
"saveSpec": null,
"fetchSpec": "1.0.1"
},
"_requiredBy": [
"/material-ui/jss-preset-default"
],
"_resolved": "https://registry.npmjs.org/jss-template/-/jss-template-1.0.1.tgz",
"_spec": "1.0.1",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI",
"author": {
"name": "Oleg Slobodskoi",
"email": "oleg008@gmail.com"
},
"bugs": {
"url": "https://github.com/cssinjs/jss-template/issues"
},
"dependencies": {
"warning": "^3.0.0"
},
"description": "JSS plugin enables string templates",
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-core": "^6.5.1",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.4",
"babel-plugin-rewire": "^1.0.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"common-tags": "^1.4.0",
"cross-env": "^3.1.3",
"eslint": "^2.8.0",
"eslint-config-airbnb": "^8.0.0",
"eslint-config-jss": "^1.1.0",
"eslint-plugin-import": "^1.12.0",
"eslint-plugin-jsx-a11y": "^1.5.5",
"eslint-plugin-react": "^5.0.1",
"expect.js": "^0.3.1",
"json-loader": "^0.5.4",
"jss": "^9.0.0",
"karma": "^1.1.1",
"karma-benchmark": "^0.6.0",
"karma-benchmark-reporter": "^0.1.1",
"karma-browserstack-launcher": "^1.0.0",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^1.1.0",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.2",
"karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0",
"lint-staged": "^3.0.1",
"mocha": "^3.0.2",
"pre-commit": "^1.1.3",
"rimraf": "^2.5.4",
"webpack": "^1.12.2"
},
"homepage": "https://github.com/cssinjs/jss-template#readme",
"keywords": [
"cssinjs",
"css-in-js",
"css in js",
"jss",
"plugin",
"template"
],
"license": "MIT",
"lint-staged": {
"./src/*.js": [
"eslint --fix",
"git add"
]
},
"main": "./lib/index.js",
"name": "jss-template",
"peerDependencies": {
"jss": "^9.0.0"
},
"pre-commit": "lint:staged",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/cssinjs/jss-template.git"
},
"scripts": {
"all": "npm run lint && npm run test && npm run build",
"bench": "cross-env BENCHMARK=true npm run test",
"build": "npm run clean && npm run build:lib && npm run build:tests && npm run build:dist",
"build:dist": "npm run build:dist:max && npm run build:dist:min",
"build:dist:max": "cross-env NODE_ENV=development webpack src/index.js dist/jss-template.js",
"build:dist:min": "cross-env NODE_ENV=production webpack src/index.js dist/jss-template.min.js",
"build:lib": "babel src --out-dir lib",
"build:tests": "npm run build:tests:lib && npm run build:tests:local",
"build:tests:lib": "cross-env NODE_ENV=test babel src --out-dir tests",
"build:tests:local": "cross-env NODE_ENV=test webpack src/index.test.js tmp/tests.js",
"clean": "rimraf '{lib,dist,tests,tmp}/*'",
"lint": "eslint ./src ./benchmark",
"lint:staged": "lint-staged",
"prepublishOnly": "npm run all",
"test": "cross-env NODE_ENV=test karma start --single-run ",
"test:watch": "cross-env NODE_ENV=test karma start"
},
"version": "1.0.1"
}

View File

@@ -0,0 +1,47 @@
# JSS plugin enables string templates
[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/cssinjs/lobby)
Make sure you read [how to use
plugins](https://github.com/cssinjs/jss/blob/master/docs/setup.md#setup-with-plugins)
in general.
This plugin allows you to use string templates to declare CSS rules. It implements a __very naive__ but __very fast (~42000 ops/sec)__ runtime CSS parser, with certain limitations:
- Supports only rule body (no selectors)
- Requires semicolon and new line after the value (except of last line)
- No nested rules support
```js
const styles = {
button: `
border-radius: 3px;
background-color: green;
color: red;
margin: 20px 40px;
padding: 10px;
`,
'@media print': {
button: `color: black`
},
'@keyframes id': {
from: `opacity: 0`,
to: `opacity: 1`
}
}
```
## Issues
File a bug against [cssinjs/jss prefixed with \[jss-template\]](https://github.com/cssinjs/jss/issues/new?title=[jss-template]%20).
## Run tests
```bash
npm i
npm run test
```
## License
MIT

View File

@@ -0,0 +1,19 @@
<html>
<head>
<meta charset="utf-8">
<title>JSS Tests</title>
<link href="./node_modules/mocha/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="./node_modules/expect.js/index.js"></script>
<script src="./node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="./tmp/tests.js"></script>
<script>
mocha.checkLeaks();
mocha.run();
</script>
</body>
</html>

View File

@@ -0,0 +1,2 @@
const context = require.context('./src', true, /\.test\.js$/)
context.keys().forEach(context)

View File

@@ -0,0 +1,39 @@
const webpack = require('webpack')
const plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
__DEV__: process.env.NODE_ENV === 'development',
__TEST__: process.env.NODE_ENV === 'test'
})
]
if (process.env.NODE_ENV === 'production') {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
}
module.exports = {
output: {
library: 'jssNested',
libraryTarget: 'umd'
},
plugins,
module: {
loaders: [
{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
},
{
loader: 'json-loader',
test: /\.json$/
}
]
},
devtool: 'source-map'
}