pax_global_header 0000666 0000000 0000000 00000000064 15171163067 0014521 g ustar 00root root 0000000 0000000 52 comment=6ff0e46fa370c714d7c46e1e48076cb65891f1b8
thysultan-stylis-6e5175f/ 0000775 0000000 0000000 00000000000 15171163067 0015445 5 ustar 00root root 0000000 0000000 thysultan-stylis-6e5175f/.github/ 0000775 0000000 0000000 00000000000 15171163067 0017005 5 ustar 00root root 0000000 0000000 thysultan-stylis-6e5175f/.github/FUNDING.yml 0000664 0000000 0000000 00000001336 15171163067 0020625 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: stylis
ko_fi: # thysultan
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
thysultan-stylis-6e5175f/.github/workflows/ 0000775 0000000 0000000 00000000000 15171163067 0021042 5 ustar 00root root 0000000 0000000 thysultan-stylis-6e5175f/.github/workflows/main.yaml 0000664 0000000 0000000 00000001066 15171163067 0022655 0 ustar 00root root 0000000 0000000 name: main
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [11.4.0]
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: test
run: |
npm install
npm test
- name: report
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./coverage/lcov.info
thysultan-stylis-6e5175f/.gitignore 0000664 0000000 0000000 00000000301 15171163067 0017427 0 ustar 00root root 0000000 0000000 .DS_Store
Thumbs.db
Desktop.ini
node_modules
npm-debug.log
*~
*.pyc
*.sublime-project
*.sublime-workspace
.idea
*.iml
.vscode
*.swp
*.swo
coverage
.nyc_output
dist/
package-lock.json
yarn.lock
thysultan-stylis-6e5175f/LICENSE 0000664 0000000 0000000 00000002066 15171163067 0016456 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2016-present Sultan Tarimo
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.
thysultan-stylis-6e5175f/README.md 0000664 0000000 0000000 00000013772 15171163067 0016736 0 ustar 00root root 0000000 0000000 # STYLIS
[](https://github.com/thysultan/stylis.js)
A Light–weight CSS Preprocessor.
[](https://coveralls.io/github/thysultan/stylis.js)
[](https://bundlephobia.com/result?p=stylis)
[](https://github.com/thysultan/stylis.js/blob/master/LICENSE)
[](https://www.npmjs.com/package/stylis)
## Installation
* Use a Direct Download: ``
* Use a CDN: ``
* Use NPM: `npm install stylis --save`
## Features
- nesting `a { &:hover {} }`
- selector namespacing
- vendor prefixing (flex-box, etc...)
- minification
- esm module compatible
- tree-shaking-able
## Abstract Syntax Structure
```js
const declaration = {
value: 'color:red;',
type: 'decl',
props: 'color',
children: 'red',
line: 1, column: 1
}
const comment = {
value: '/*@noflip*/',
type: 'comm',
props: '/',
children: '@noflip',
line: 1, column: 1
}
const ruleset = {
value: 'h1,h2',
type: 'rule',
props: ['h1', 'h2'],
children: [/* ... */],
line: 1, column: 1
}
const atruleset = {
value: '@media (max-width:100), (min-width:100)',
type: '@media',
props: ['(max-width:100)', '(min-width:100)'],
children: [/* ... */],
line: 1, column: 1
}
```
## Example:
```js
import {compile, serialize, stringify} from 'stylis'
serialize(compile(`h1{all:unset}`), stringify)
```
### Compile
```js
compile('h1{all:unset}') === [{value: 'h1', type: 'rule', props: ['h1'], children: [/* ... */]}]
compile('--foo:unset;') === [{value: '--foo:unset;', type: 'decl', props: '--foo', children: 'unset'}]
```
### Tokenize
```js
tokenize('h1 h2 h3 [h4 h5] fn(args) "a b c"') === ['h1', 'h2', 'h3', '[h4 h5]', 'fn', '(args)', '"a b c"']
```
### Serialize
```js
serialize(compile('h1{all:unset}'), stringify)
```
### Vendor Prefixing
```js
import {compile, serialize, stringify, middleware, prefixer } from 'stylis';
serialize(compile('div{display:flex;}'), middleware([prefixer, stringify]))
```
## Middleware
The middleware helper is a convenient helper utility, that for all intents and purposes you can do without if you intend to implement your own traversal logic. The `stringify` middleware is one such middleware that can be used in conjunction with it.
Elements passed to middlewares have a `root` property that is the immediate root/parent of the current element **in the compiled output**, so it references the parent in the already expanded CSS-like structure. Elements have also `parent` property that is the immediate parent of the current element **from the input structure** (structure representing the input string).
### Traversal
```js
serialize(compile('h1{all:unset}'), middleware([(element, index, children) => {
assert(children === element.root.children && children[index] === element.children)
}, stringify])) === 'h1{all:unset;}'
```
The abstract syntax tree also includes an additional `return` property for more niche uses.
### Prefixing
```js
serialize(compile('h1{all:unset}'), middleware([(element, index, children, callback) => {
if (element.type === 'decl' && element.props === 'all' && element.children === 'unset')
element.return = 'color:red;' + element.value
}, stringify])) === 'h1{color:red;all:unset;}'
```
```js
serialize(compile('h1{all:unset}'), middleware([(element, index, children, callback) => {
if (element.type === 'rule' && element.props.indexOf('h1') > -1)
return serialize([{...element, props: ['h2', 'h3']}], callback)
}, stringify])) === 'h2,h3{all:unset;}h1{all:unset;}'
```
### Reading
```js
serialize(compile('h1{all:unset}'), middleware([stringify, (element, index, children) => {
assert(element.return === 'h1{all:unset;}')
}])) === 'h1{all:unset;color:red;}'
```
The middlewares in [src/Middleware.js](src/Middleware.js) dive into tangible examples of how you might implement a middleware, alternatively you could also create your own middleware system as `compile` returns all the nessessary structure to fork from.
## Variables
CSS variables are supported but a note should be made about the exotic use of css variables. The css spec mentions the following
>The allowed syntax for custom properties is extremely permissive. The production matches any sequence of one or more tokens, so long as the sequence does not contain , , unmatched <)-token>, <]-token>, or <}-token>, or top-level tokens or tokens with a value of "!".
That is to say css variables according to the spec allows: `--foo: if(x > 5) this.width = 10;` and while this value is obviously useless as a variable, and would be invalid in any normal property, it still might be read and acted on by JavaScript and this is supported by Stylis, however things become slightly undefined when we start to include the `{` and `}` productions in our use of exotic css variables.
For example consider the following: `--foo: {};`
While this is valid CSS and supported. It is unclear what should happen when the rule collides with the implicit block termination rule that allows i.e `h1{color:red}`(notice the omitted semicolon) to also be a valid CSS production. This results in the following contradiction in: `h1{--example: {}` is it to be treated as `h1{--foo:{;}` or `h1{--foo:{}` the later of which is an unterminated block or in the following: `h1{--foo:{} h1{color:red;}` should it be `h1 {--foo:{}h1{color:red;};` where `{}h1{color:red;` is part of the css variable `--foo` and not a new rule or should it be something else?
Nevertheless Stylis still supports the exotic forms highlighted in the spec, however you should consider it as a general rule to delimit such exotic uses of variables in strings or parentheses i.e: `h1{--foo:'{'}` or `h1{--foo:({)}`.
## Benchmark
Stylis is at-least 2X faster than its predecesor.
### License
Stylis is [MIT licensed](./LICENSE).
thysultan-stylis-6e5175f/docs/ 0000775 0000000 0000000 00000000000 15171163067 0016375 5 ustar 00root root 0000000 0000000 thysultan-stylis-6e5175f/docs/CNAME 0000664 0000000 0000000 00000000016 15171163067 0017140 0 ustar 00root root 0000000 0000000 stylis.js.org
thysultan-stylis-6e5175f/docs/assets/ 0000775 0000000 0000000 00000000000 15171163067 0017677 5 ustar 00root root 0000000 0000000 thysultan-stylis-6e5175f/docs/assets/logo.svg 0000664 0000000 0000000 00000003370 15171163067 0021363 0 ustar 00root root 0000000 0000000