├── CNAME
├── .eslintignore
├── src
├── babel-plugin
│ └── index.ts
├── stylis
│ ├── built
│ │ ├── umd
│ │ │ ├── package.json
│ │ │ ├── stylis.js
│ │ │ └── stylis.js.map
│ │ ├── stylis.mjs
│ │ └── stylis.mjs.map
│ ├── package.json
│ └── index.d.ts
├── elements.ts
└── index.ts
├── .commitlintrc.json
├── .huskyrc
├── tests
└── react
│ ├── .babelrc
│ └── render.test.tsx
├── .lintstagedrc
├── .prettierrc
├── example
├── index.html
└── index.tsx
├── tsconfig.build.json
├── foliage.ts
├── .editorconfig
├── .github
├── workflows
│ ├── release-drafter.yml
│ ├── test.yml
│ └── publish.yml
├── FUNDING.yml
└── release-drafter.yml
├── tsconfig.json
├── .eslintrc.json
├── rollup.config.js
├── babel.config.js
├── .gitignore
├── package.json
├── react.tsx
├── README.md
├── jest.config.ts
├── babel-plugin.test.ts
├── babel-plugin.js
└── __snapshots__
└── babel-plugin.test.ts.snap
/CNAME:
--------------------------------------------------------------------------------
1 | foliage.sova.dev
2 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | types
3 | *.snap
4 |
--------------------------------------------------------------------------------
/src/babel-plugin/index.ts:
--------------------------------------------------------------------------------
1 | export const a = 1;
2 |
--------------------------------------------------------------------------------
/src/stylis/built/umd/package.json:
--------------------------------------------------------------------------------
1 | { "type": "commonjs" }
2 |
--------------------------------------------------------------------------------
/.commitlintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["@commitlint/config-conventional"]
3 | }
4 |
--------------------------------------------------------------------------------
/.huskyrc:
--------------------------------------------------------------------------------
1 | {
2 | "hooks": {
3 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
4 | "pre-commit": "lint-staged"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/tests/react/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | ["../../babel-plugin", {
4 | "allowedModules": ["../../react"],
5 | "debug": true
6 | }]
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/.lintstagedrc:
--------------------------------------------------------------------------------
1 | {
2 | "*.{ts,tsx,js,jsx,mjs}": ["eslint --fix", "prettier --write"],
3 | "{*.json,.huskyrc,.prettierrc,.lintstagedrc,.eslintrc}": [
4 | "prettier --write --parser json"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "always",
3 | "printWidth": 80,
4 | "semi": true,
5 | "singleQuote": true,
6 | "tabWidth": 2,
7 | "trailingComma": "all",
8 | "useTabs": false
9 | }
10 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Foliage example
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "dist",
5 | "jsx": "react",
6 | "declaration": true,
7 | "emitDeclarationOnly": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/foliage.ts:
--------------------------------------------------------------------------------
1 | export const css: any = () => null;
2 | export const keyframes: any = () => null;
3 | export const createGlobalStyle: any = () => null;
4 |
5 | export function assertSelector(a: any) {
6 | return `.${a.css}`;
7 | }
8 |
--------------------------------------------------------------------------------
/src/stylis/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "main": "built/umd/stylis.js",
4 | "exports": {
5 | ".": {
6 | "require": "./built/umd/stylis.js",
7 | "import": "./built/stylis.mjs"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | #root = true
2 | [*]
3 | indent_style = space
4 | end_of_line = lf
5 | charset = utf-8
6 | trim_trailing_whitespace = true
7 | insert_final_newline = true
8 | max_line_length = 80
9 | indent_size = 2
10 | [*.md]
11 | trim_trailing_whitespace = false
12 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | name: Release Drafter
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | workflow_dispatch:
8 |
9 | jobs:
10 | update_release_draft:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: release-drafter/release-drafter@v5
14 | env:
15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 |
--------------------------------------------------------------------------------
/src/stylis/index.d.ts:
--------------------------------------------------------------------------------
1 | interface CompilationResult {
2 | __NONE: number;
3 | }
4 | export function serialize(
5 | compilationResult: CompilationResult,
6 | // eslint-disable-next-line @typescript-eslint/ban-types
7 | stringifier: Function,
8 | ): string;
9 | export function compile(styles: string): CompilationResult;
10 | export function stringify(): void;
11 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test It
2 |
3 | on: [push]
4 |
5 | jobs:
6 | test-package:
7 | runs-on: ubuntu-18.04
8 | steps:
9 | - name: Checkout
10 | uses: actions/checkout@v2
11 |
12 | - name: Use Node.js 16.x
13 | uses: actions/setup-node@v1
14 | with:
15 | node-version: 16.x
16 |
17 | - name: Install dependencies
18 | run: yarn install --frozen-lockfile
19 |
20 | - name: Build
21 | run: yarn build
22 |
23 | - name: Run tests
24 | run: yarn test
25 | env:
26 | CI: true
27 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: sergeysova
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ['https://www.buymeacoffee.com/sergeysova', 'https://vk.com/sovadev']
13 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | categories:
2 | - title: '⚠️ Breaking changes'
3 | label: 'BREAKING CHANGES'
4 |
5 | - title: '🚀 Features'
6 | labels:
7 | - 'feature'
8 | - 'enhancement'
9 |
10 | - title: '🐛 Bug Fixes'
11 | labels:
12 | - 'fix'
13 | - 'bugfix'
14 | - 'bug'
15 |
16 | - title: '🧰 Maintenance'
17 | labels:
18 | - 'chore'
19 | - 'dependencies'
20 |
21 | - title: '📚 Documentation'
22 | label: 'documentation'
23 |
24 | - title: '🧪 Tests'
25 | label: 'tests'
26 |
27 | - title: '🏎 Optimizations'
28 | label: 'optimizations'
29 |
30 | version-resolver:
31 | major:
32 | labels:
33 | - 'BREAKING CHANGES'
34 | minor:
35 | labels:
36 | - 'feature'
37 | - 'enhancement'
38 | patch:
39 | labels:
40 | - 'fix'
41 | default: patch
42 |
43 | name-template: 'v$RESOLVED_VERSION'
44 | tag-template: 'v$RESOLVED_VERSION'
45 |
46 | change-template: '- $TITLE #$NUMBER (@$AUTHOR)'
47 | template: |
48 | $CHANGES
49 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "allowSyntheticDefaultImports": true,
5 | "allowUnreachableCode": false,
6 | "baseUrl": "src",
7 | "downlevelIteration": true,
8 | "esModuleInterop": true,
9 | "forceConsistentCasingInFileNames": true,
10 | "lib": ["es6", "es2015", "es2017", "dom"],
11 | "module": "esnext",
12 | "moduleResolution": "Node",
13 | "noFallthroughCasesInSwitch": true,
14 | "noImplicitAny": true,
15 | "noImplicitReturns": true,
16 | "noImplicitThis": true,
17 | "noUnusedLocals": false,
18 | "pretty": true,
19 | "sourceMap": true,
20 | "strict": true,
21 | "jsx": "react",
22 | "strictNullChecks": true,
23 | "suppressImplicitAnyIndexErrors": true,
24 | "resolveJsonModule": true,
25 | "target": "es2016",
26 | "types": ["jest", "node"],
27 | "plugins": [
28 | {
29 | "name": "typescript-styled-plugin",
30 | "tags": ["styled", "css", "createGlobalStyle"]
31 | }
32 | ]
33 | },
34 | "include": ["./src/", "./types"]
35 | }
36 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish CI
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | publish-to-npm:
9 | runs-on: ubuntu-18.04
10 | steps:
11 | - name: Checkout
12 | uses: actions/checkout@v2
13 |
14 | - name: Use Node.js 16.x
15 | uses: actions/setup-node@v1
16 | with:
17 | node-version: 16.x
18 |
19 | - name: Install dependencies
20 | run: yarn install --frozen-lockfile
21 |
22 | - name: Build
23 | run: yarn build
24 |
25 | - name: Run tests
26 | run: yarn test
27 | env:
28 | CI: true
29 |
30 | - name: Extract version
31 | id: version
32 | uses: olegtarasov/get-tag@v2.1
33 | with:
34 | tagRegex: 'v(.*)'
35 |
36 | - name: Set version from release
37 | uses: reedyuk/npm-version@1.0.1
38 | with:
39 | version: ${{ steps.version.outputs.tag }}
40 | git-tag-version: false
41 |
42 | - name: Create NPM config
43 | run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
44 | env:
45 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
46 |
47 | - name: Publish package
48 | run: npm publish
49 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "overrides": [
3 | {
4 | "files": ["**/*.test.ts", "**/*.test.tsx"],
5 | "env": {
6 | "jest": true
7 | },
8 | "rules": {
9 | "import/no-extraneous-dependencies": "off"
10 | }
11 | },
12 | {
13 | "files": ["**/*.ts", "**/*.tsx"],
14 | "extends": [
15 | "plugin:@typescript-eslint/eslint-plugin/recommended",
16 | "plugin:@typescript-eslint/eslint-plugin/eslint-recommended"
17 | ],
18 | "rules": {
19 | "no-unused-vars": "off",
20 | "@typescript-eslint/explicit-function-return-type": "off",
21 | "@typescript-eslint/no-use-before-define": "off"
22 | }
23 | }
24 | ],
25 | "rules": {
26 | "import/extensions": ["off", "ignorePackages", "error"],
27 | "@typescript-eslint/no-use-before-define": "off",
28 | "@typescript-eslint/explicit-function-return-type": "off",
29 | "no-use-before-define": "off",
30 | "unicorn/no-null": "off",
31 | "no-magic-numbers": "off",
32 | "unicorn/number-literal-case": "off"
33 | },
34 | "env": {
35 | "browser": true
36 | },
37 | "extends": [
38 | "@eslint-kit/base",
39 | "@eslint-kit/typescript",
40 | "@eslint-kit/node",
41 | "@eslint-kit/prettier"
42 | ],
43 | "parser": "@typescript-eslint/parser"
44 | }
45 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path';
2 | import pluginResolve from '@rollup/plugin-node-resolve';
3 | import { terser } from 'rollup-plugin-terser';
4 | import { babel } from '@rollup/plugin-babel';
5 | import commonjs from '@rollup/plugin-commonjs';
6 | import typescript from '@rollup/plugin-typescript';
7 | import Package from './package.json';
8 |
9 | const extensions = ['.mjs', '.tsx', '.ts', '.js', '.json'];
10 |
11 | function createBuild(input, format) {
12 | return {
13 | input: resolve(__dirname, `src/${input}.ts`),
14 | output: {
15 | file: `${input}.${format === 'esm' ? 'mjs' : 'js'}`,
16 | format,
17 | plugins: [terser()],
18 | sourcemap: true,
19 | },
20 | plugins: [
21 | pluginResolve({ extensions }),
22 | commonjs({ extensions: ['.js'] }),
23 | typescript({
24 | tsconfig: './tsconfig.build.json',
25 | }),
26 | babel({
27 | babelHelpers: 'bundled',
28 | extensions,
29 | skipPreflightCheck: true,
30 | babelrc: false,
31 | ...require('./babel.config').generateConfig({
32 | isEsm: format === 'esm',
33 | }),
34 | }),
35 | ].filter(Boolean),
36 | external: ['forest/forest.mjs', 'effector/effector.mjs'].concat(
37 | Object.keys(Package.peerDependencies),
38 | Object.keys(Package.dependencies),
39 | ),
40 | };
41 | }
42 |
43 | const inputs = ['index'];
44 | const formats = ['cjs', 'esm'];
45 |
46 | const config = inputs.flatMap((i) => formats.map((f) => createBuild(i, f)));
47 |
48 | export default config;
49 |
--------------------------------------------------------------------------------
/example/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { css } from '../foliage';
4 | import { component } from '../react';
5 |
6 | const button = css`
7 | --main: black;
8 | --text: white;
9 | padding: 1rem 2rem;
10 | border: 2px solid gray;
11 | border-radius: 1rem;
12 | color: var(--text);
13 | background-color: var(--main);
14 | appearance: none;
15 |
16 | &:hover {
17 | box-shadow: 0 0 15px -3px black;
18 | }
19 | `;
20 |
21 | const Button = component('button', button, {
22 | defaults: { color: 'default' },
23 | variants: {
24 | color: {
25 | primary: css`
26 | --main: blue;
27 | --text: white;
28 | `,
29 | default: css`
30 | --main: gray;
31 | --text: black;
32 | `,
33 | },
34 | },
35 | });
36 |
37 | const primary = css`
38 | background-color: black;
39 | color: white;
40 | padding: 1rem 2rem;
41 |
42 | ${button} {
43 | --main: red;
44 | --text: white;
45 | }
46 |
47 | ${button}:hover {
48 | --main: pink;
49 | --text: black;
50 | }
51 |
52 | ${button} + ${button} {
53 | margin-left: 15px;
54 | }
55 | `;
56 |
57 | const Wrapper = component('div', [primary]);
58 |
59 | const vertical = css`
60 | display: flex;
61 | flex-flow: column;
62 | max-width: 20rem;
63 |
64 | & > * + * {
65 | margin-top: 1rem;
66 | }
67 | `;
68 |
69 | const Vertical = component('div', [vertical]);
70 |
71 | const root = document.querySelector('#root');
72 | const head = document.querySelector('head');
73 |
74 | const App = () => (
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | );
83 |
84 | ReactDOM.render(, root);
85 |
--------------------------------------------------------------------------------
/src/elements.ts:
--------------------------------------------------------------------------------
1 | export const domElements = [
2 | 'a',
3 | 'abbr',
4 | 'address',
5 | 'area',
6 | 'article',
7 | 'aside',
8 | 'audio',
9 | 'b',
10 | 'base',
11 | 'bdi',
12 | 'bdo',
13 | // 'big',
14 | 'blockquote',
15 | 'body',
16 | 'br',
17 | 'button',
18 | 'canvas',
19 | 'caption',
20 | 'cite',
21 | 'code',
22 | 'col',
23 | 'colgroup',
24 | 'data',
25 | 'datalist',
26 | 'dd',
27 | 'del',
28 | 'details',
29 | 'dfn',
30 | 'dialog',
31 | 'div',
32 | 'dl',
33 | 'dt',
34 | 'em',
35 | 'embed',
36 | 'fieldset',
37 | 'figcaption',
38 | 'figure',
39 | 'footer',
40 | 'form',
41 | 'h1',
42 | 'h2',
43 | 'h3',
44 | 'h4',
45 | 'h5',
46 | 'h6',
47 | 'head',
48 | 'header',
49 | 'hgroup',
50 | 'hr',
51 | 'html',
52 | 'i',
53 | 'iframe',
54 | 'img',
55 | 'input',
56 | 'ins',
57 | 'kbd',
58 | // 'keygen',
59 | 'label',
60 | 'legend',
61 | 'li',
62 | 'link',
63 | 'main',
64 | 'map',
65 | 'mark',
66 | 'marquee',
67 | 'menu',
68 | // 'menuitem',
69 | 'meta',
70 | 'meter',
71 | 'nav',
72 | 'noscript',
73 | 'object',
74 | 'ol',
75 | 'optgroup',
76 | 'option',
77 | 'output',
78 | 'p',
79 | 'param',
80 | 'picture',
81 | 'pre',
82 | 'progress',
83 | 'q',
84 | 'rp',
85 | 'rt',
86 | 'ruby',
87 | 's',
88 | 'samp',
89 | 'script',
90 | 'section',
91 | 'select',
92 | 'small',
93 | 'source',
94 | 'span',
95 | 'strong',
96 | 'style',
97 | 'sub',
98 | 'summary',
99 | 'sup',
100 | 'table',
101 | 'tbody',
102 | 'td',
103 | 'textarea',
104 | 'tfoot',
105 | 'th',
106 | 'thead',
107 | 'time',
108 | 'title',
109 | 'tr',
110 | 'track',
111 | 'u',
112 | 'ul',
113 | 'var',
114 | 'video',
115 | 'wbr',
116 |
117 | // SVG
118 | 'circle',
119 | 'clipPath',
120 | 'defs',
121 | 'ellipse',
122 | 'foreignObject',
123 | 'g',
124 | 'image',
125 | 'line',
126 | 'linearGradient',
127 | 'marker',
128 | 'mask',
129 | 'path',
130 | 'pattern',
131 | 'polygon',
132 | 'polyline',
133 | 'radialGradient',
134 | 'rect',
135 | 'stop',
136 | 'svg',
137 | 'text',
138 | 'tspan',
139 | ] as const;
140 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | const { resolve: resolvePath } = require('path');
2 |
3 | module.exports = (api) => {
4 | api && api.cache && api.cache.never && api.cache.never();
5 | // const env = api.cache(() => process.env.NODE_ENV)
6 | return generateConfig(meta, babelConfig);
7 | };
8 |
9 | const meta = {
10 | isEsm: true,
11 | };
12 |
13 | function generateConfig(meta, config = babelConfig) {
14 | const result = {};
15 | for (const key in config) {
16 | const value = config[key];
17 | result[key] = typeof value === 'function' ? value(meta) : value;
18 | }
19 | return result;
20 | }
21 |
22 | module.exports.generateConfig = generateConfig;
23 |
24 | const aliases = {
25 | effector: {
26 | esm: 'effector/effector.mjs',
27 | },
28 | forest: {
29 | esm: 'forest/forest.mjs',
30 | },
31 | stylis: {
32 | esm: 'stylis/dist/stylis.mjs',
33 | },
34 | };
35 |
36 | const babelConfig = {
37 | presets: [
38 | '@babel/preset-env',
39 | '@babel/preset-typescript',
40 | '@babel/preset-react',
41 | ],
42 | plugins: [
43 | // [
44 | // './babel-plugin.js',
45 | // {
46 | // allowedModules: ['foliage', '../../react'],
47 | // },
48 | // ],
49 | ],
50 | // plugins(meta) {
51 | // const alias = parseAliases(meta, aliases);
52 | // return [
53 | // // [
54 | // // require.resolve('./babel-plugin.js'),
55 | // // {
56 | // // allowedModules: ['../foliage', 'foliage', '../../react'],
57 | // // debug: false,
58 | // // },
59 | // // ],
60 | // // ['effector/babel-plugin', { addLoc: true }],
61 | // // [
62 | // // 'babel-plugin-module-resolver',
63 | // // {
64 | // // alias: {
65 | // // ...alias,
66 | // // foliage: './react',
67 | // // },
68 | // // loglevel: 'silent',
69 | // // },
70 | // // ],
71 | // ];
72 | // },
73 | };
74 |
75 | // eslint-disable-next-line sonarjs/cognitive-complexity
76 | function parseAliases(meta, object) {
77 | const result = {};
78 | for (const key in object) {
79 | const value = object[key];
80 | if (typeof value === 'function') {
81 | const name = value(meta);
82 | if (name === undefined || name === null) continue;
83 | result[key] = name;
84 | } else if (typeof value === 'object' && value !== null) {
85 | const name = applyPaths(value);
86 | if (name === undefined || name === null) continue;
87 | result[key] = name;
88 | } else {
89 | const name = value;
90 | if (name === undefined || name === null) continue;
91 | result[key] = name;
92 | }
93 | }
94 | return result;
95 |
96 | function applyPaths(paths) {
97 | if (meta.isEsm) return paths.esm;
98 | return paths.default;
99 | }
100 | }
101 |
102 | module.exports.getAliases = (metadata = meta) =>
103 | parseAliases(metadata, aliases);
104 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { createEvent, createStore } from 'effector';
2 | import { DOMTag, h, node, spec } from 'forest';
3 | import * as stylis from './stylis';
4 |
5 | import { domElements } from './elements';
6 |
7 | const addStyle = createEvent<{ id: string; styles: string }>();
8 | const $styles = createStore<{ map: Map }>({ map: new Map() });
9 |
10 | export function StyledRoot(): void {
11 | const text = $styles.map(({ map }) => [...map.values()].join(' '));
12 | h('style', { text });
13 | }
14 |
15 | $styles.on(addStyle, (state, { id, styles }) => {
16 | if (state.map.has(id)) return state;
17 | state.map.set(id, make(id, styles));
18 | return { map: state.map };
19 | });
20 |
21 | function make(id: string, styles: string) {
22 | return stylis.serialize(
23 | stylis.compile(`.es-${id} { ${styles} }`),
24 | stylis.stringify,
25 | );
26 | }
27 |
28 | const idCount = () => {
29 | let id = 9005000;
30 | return () => (++id).toString(36);
31 | };
32 |
33 | const styledId = idCount();
34 |
35 | type Callback = () => void;
36 |
37 | export type FunctionComponent = (config: Spec | Callback) => void;
38 |
39 | export type Component = FunctionComponent & {
40 | STYLED_ID: string;
41 | };
42 |
43 | // eslint-disable-next-line @typescript-eslint/ban-types
44 | function hasStyledId(fn: object | Function): fn is { STYLED_ID: string } {
45 | // eslint-disable-next-line dot-notation
46 | return typeof fn['STYLED_ID'] === 'string';
47 | }
48 |
49 | function join(
50 | strings: TemplateStringsArray,
51 | interps: (string | FunctionComponent | Component | number)[],
52 | ) {
53 | const result = [strings[0]];
54 | interps.forEach((part, index) => {
55 | if (typeof part === 'function') {
56 | if (hasStyledId(part)) {
57 | result.push(`.es-${part.STYLED_ID}`);
58 | } else {
59 | throw new TypeError('Passed not an effector styled component');
60 | }
61 | } else {
62 | result.push(String(part));
63 | }
64 | result.push(strings[index + 1]);
65 | });
66 |
67 | return result.join('');
68 | }
69 |
70 | export type Spec = Parameters[0] & { fn?: Callback };
71 |
72 | type Creator = (
73 | content: TemplateStringsArray,
74 | ...interpolations: (string | Component | number)[]
75 | ) => Component;
76 |
77 | type TagFabric = (tag: DOMTag) => Creator;
78 |
79 | type TagMap = {
80 | [P in DOMTag]: Creator;
81 | };
82 |
83 | const fabric: TagFabric & Partial =
84 | (tag: DOMTag) =>
85 | (content, ...interpolations) => {
86 | const id = styledId();
87 |
88 | const styles = join(content, interpolations);
89 |
90 | const Component = (config: Spec | Callback) => {
91 | addStyle({ id, styles });
92 |
93 | h(tag, () => {
94 | node((reference) => {
95 | reference.classList.add(`es-${id}`);
96 | });
97 | if (config) {
98 | if (typeof config === 'function') {
99 | config();
100 | } else {
101 | spec(config);
102 | if (typeof config.fn === 'function') {
103 | config.fn();
104 | }
105 | }
106 | }
107 | });
108 | };
109 |
110 | Component.STYLED_ID = id;
111 |
112 | return Component;
113 | };
114 |
115 | domElements.forEach((element) => {
116 | fabric[element] = fabric(element);
117 | });
118 |
119 | export const styled = fabric as TagFabric & TagMap;
120 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/node,windows,linux,macos
3 | # Edit at https://www.gitignore.io/?templates=node,windows,linux,macos
4 | ### Linux ###
5 | *~
6 | # temporary files which can be created if a process still has a handle open of a deleted file
7 | .fuse_hidden*
8 | # KDE directory preferences
9 | .directory
10 | # Linux trash folder which might appear on any partition or disk
11 | .Trash-*
12 | # .nfs files are created when an open file is removed but is still being accessed
13 | .nfs*
14 | ### macOS ###
15 | # General
16 | .DS_Store
17 | .AppleDouble
18 | .LSOverride
19 | # Icon must end with two \r
20 | Icon
21 | # Thumbnails
22 | ._*
23 | # Files that might appear in the root of a volume
24 | .DocumentRevisions-V100
25 | .fseventsd
26 | .Spotlight-V100
27 | .TemporaryItems
28 | .Trashes
29 | .VolumeIcon.icns
30 | .com.apple.timemachine.donotpresent
31 | # Directories potentially created on remote AFP share
32 | .AppleDB
33 | .AppleDesktop
34 | Network Trash Folder
35 | Temporary Items
36 | .apdisk
37 | ### Node ###
38 | # Logs
39 | logs
40 | *.log
41 | npm-debug.log*
42 | yarn-debug.log*
43 | yarn-error.log*
44 | lerna-debug.log*
45 | # Diagnostic reports (https://nodejs.org/api/report.html)
46 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
47 | # Runtime data
48 | pids
49 | *.pid
50 | *.seed
51 | *.pid.lock
52 | # Directory for instrumented libs generated by jscoverage/JSCover
53 | lib-cov
54 | # Coverage directory used by tools like istanbul
55 | coverage
56 | *.lcov
57 | # nyc test coverage
58 | .nyc_output
59 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
60 | .grunt
61 | # Bower dependency directory (https://bower.io/)
62 | bower_components
63 | # node-waf configuration
64 | .lock-wscript
65 | # Compiled binary addons (https://nodejs.org/api/addons.html)
66 | build/Release
67 | # Dependency directories
68 | node_modules/
69 | jspm_packages/
70 | # TypeScript v1 declaration files
71 | typings/
72 | # TypeScript cache
73 | *.tsbuildinfo
74 | # Optional npm cache directory
75 | .npm
76 | # Optional eslint cache
77 | .eslintcache
78 | # Optional REPL history
79 | .node_repl_history
80 | # Output of 'npm pack'
81 | *.tgz
82 | # Yarn Integrity file
83 | .yarn-integrity
84 | # dotenv environment variables file
85 | .env
86 | .env.test
87 | # parcel-bundler cache (https://parceljs.org/)
88 | .cache
89 | # next.js build output
90 | .next
91 | # nuxt.js build output
92 | .nuxt
93 | # rollup.js default build output
94 | dist/
95 | # Uncomment the public line if your project uses Gatsby
96 | # https://nextjs.org/blog/next-9-1#public-directory-support
97 | # https://create-react-app.dev/docs/using-the-public-folder/#docsNav
98 | # public
99 | # Storybook build outputs
100 | .out
101 | .storybook-out
102 | # vuepress build output
103 | .vuepress/dist
104 | # Serverless directories
105 | .serverless/
106 | # FuseBox cache
107 | .fusebox/
108 | # DynamoDB Local files
109 | .dynamodb/
110 | # Temporary folders
111 | tmp/
112 | temp/
113 | ### Windows ###
114 | # Windows thumbnail cache files
115 | Thumbs.db
116 | Thumbs.db:encryptable
117 | ehthumbs.db
118 | ehthumbs_vista.db
119 | # Dump file
120 | *.stackdump
121 | # Folder config file
122 | [Dd]esktop.ini
123 | # Recycle Bin used on file shares
124 | $RECYCLE.BIN/
125 | # Windows Installer files
126 | *.cab
127 | *.msi
128 | *.msix
129 | *.msm
130 | *.msp
131 | # Windows shortcuts
132 | *.lnk
133 | # End of https://www.gitignore.io/api/node,windows,linux,macos
134 | Icon
135 | /build
136 | !.vscode/extensions.json
137 | !.vscode/launch.json
138 | !.vscode/settings.json
139 | !.vscode/tasks.json
140 | .history
141 | .idea/
142 | .vscode/*
143 |
144 | # Built package artifacts
145 | index.js
146 | index.js.map
147 | index.mjs
148 | index.mjs.map
149 | .jest-cache
150 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "foliage",
3 | "version": "0.0.0-real-version-will-be-set-on-ci",
4 | "description": "Styled Components for forest",
5 | "main": "index.js",
6 | "module": "index.mjs",
7 | "exports": {
8 | ".": {
9 | "import": "./index.mjs",
10 | "require": "./index.js",
11 | "default": "./index.mjs"
12 | },
13 | "./index.mjs": "./index.mjs"
14 | },
15 | "types": "dist/index.d.ts",
16 | "homepage": "https://foliage.dev",
17 | "sideEffects": false,
18 | "scripts": {
19 | "test": "jest",
20 | "commit": "git-cz",
21 | "lint": "eslint ./",
22 | "build": "tsc --build ./tsconfig.build.json && rollup --config rollup.config.js",
23 | "format": "prettier --write \"./src/**/**.{ts,tsx,js,jsx,json}\"",
24 | "start": "parcel example/index.html --no-cache",
25 | "prepublishOnly": "rm -rf dist && yarn build"
26 | },
27 | "publishConfig": {
28 | "access": "public"
29 | },
30 | "repository": {
31 | "url": "https://github.com/foliage-ui/foliage"
32 | },
33 | "files": ["index.js", "index.js.map", "index.mjs", "index.mjs.map", "dist"],
34 | "keywords": [
35 | "components",
36 | "dom",
37 | "effector",
38 | "foliage",
39 | "forest",
40 | "style",
41 | "styled"
42 | ],
43 | "author": "Sergey Sova (https://sergeysova.com/)",
44 | "license": "MIT",
45 | "config": {
46 | "commitizen": {
47 | "path": "cz-conventional-changelog"
48 | }
49 | },
50 | "devDependencies": {
51 | "@babel/cli": "^7.16.0",
52 | "@babel/core": "^7.16.0",
53 | "@babel/preset-env": "^7.16.4",
54 | "@babel/preset-react": "^7.16.0",
55 | "@babel/preset-typescript": "^7.16.0",
56 | "@babel/types": "^7.16.0",
57 | "@commitlint/cli": "^8.3.5",
58 | "@commitlint/config-conventional": "^8.3.4",
59 | "@eslint-kit/eslint-config-base": "^3.0.0",
60 | "@eslint-kit/eslint-config-node": "^2.0.0",
61 | "@eslint-kit/eslint-config-prettier": "^2.0.0",
62 | "@eslint-kit/eslint-config-typescript": "^3.2.0",
63 | "@rollup/plugin-babel": "^5.3.0",
64 | "@rollup/plugin-commonjs": "^20.0.0",
65 | "@rollup/plugin-node-resolve": "^13.0.4",
66 | "@rollup/plugin-typescript": "^8.2.5",
67 | "@testing-library/jest-dom": "^5.15.0",
68 | "@testing-library/react": "^12.1.2",
69 | "@types/jest": "^25.2.1",
70 | "@types/js-beautify": "^1.13.3",
71 | "@types/node": "^13.13.5",
72 | "@types/react": "^17.0.20",
73 | "@types/react-dom": "^17.0.9",
74 | "@typescript-eslint/parser": "^4.4.1",
75 | "babel-jest": "^26.6.3",
76 | "babel-plugin-module-resolver": "^4.1.0",
77 | "babel-plugin-tester": "^10.0.0",
78 | "change-case": "^4.1.2",
79 | "commitizen": "^4.1.2",
80 | "cz-conventional-changelog": "^3.2.0",
81 | "effector": "^22.1.0",
82 | "eslint": "7.10.0",
83 | "forest": "^0.20.2",
84 | "husky": "^4.2.5",
85 | "jest": "^26.0.1",
86 | "js-beautify": "^1.14.0",
87 | "lint-staged": "^10.2.2",
88 | "parcel-bundler": "^1.12.4",
89 | "prettier": "^2.0.5",
90 | "react": "^17.0.2",
91 | "react-dom": "^17.0.2",
92 | "rollup": "^2.58.0",
93 | "rollup-plugin-terser": "^7.0.2",
94 | "sharec-sova-config": "^0.1.0",
95 | "terser-webpack-plugin": "^3.0.2",
96 | "ts-node": "^9.1.1",
97 | "typescript": "^4.5.2",
98 | "typescript-styled-plugin": "^0.15.0"
99 | },
100 | "sharec": {
101 | "config": "sharec-sova-config",
102 | "version": "0.1.1"
103 | },
104 | "dependencies": {
105 | "autoprefixer": "^10.2.4",
106 | "csso": "^4.2.0",
107 | "postcss": "^8.2.6",
108 | "postcss-nested": "^5.0.3"
109 | },
110 | "peerDependencies": {
111 | "effector": "^22.1.0",
112 | "forest": "^0.20.2"
113 | },
114 | "browserslist": {
115 | "development": ["last 1 ie version", "last 5 chrome version"]
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/react.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | export const css: any = () => {
4 | throw new Error(`Looks like you didn't setup foliage/babel-plugin`);
5 | };
6 | export const keyframes: any = () => {
7 | throw new Error(`Looks like you didn't setup foliage/babel-plugin`);
8 | };
9 | export const createGlobalStyle: any = () => {
10 | throw new Error(`Looks like you didn't setup foliage/babel-plugin`);
11 | };
12 |
13 | export const assertKeyframe = (input: any) => {
14 | if (input.keyframes) {
15 | return input;
16 | }
17 | throw new Error(
18 | 'Looks like you passed wrong element to an "animation" property',
19 | );
20 | };
21 |
22 | export const assertVariable = (input: any) => {
23 | return input;
24 | // throw new Error('Looks like you passed wrong element as css-custom-property');
25 | };
26 |
27 | interface BlockCSS {
28 | content: string;
29 | css: string;
30 | }
31 |
32 | interface ComponentConfig {
33 | component?: React.FC;
34 | children?: React.FC;
35 | mapVariants?: Record any>;
36 | variants?: Record>;
37 | compound?: Array<{ css: BlockCSS } & Record>;
38 | defaults?: Record;
39 | }
40 |
41 | interface ComponentProps {
42 | className?: string;
43 | }
44 |
45 | export const Global: React.FC<{ styles: any[] | any }> = ({ styles }) => {
46 | React.useEffect(() => {
47 | if (Array.isArray(styles)) {
48 | styles.forEach((style) => add(style));
49 | } else {
50 | add(styles);
51 | }
52 | }, [styles]);
53 | return null;
54 | };
55 |
56 | export function component(
57 | tag: string, // eslint-disable-line @typescript-eslint/naming-convention
58 | styles: BlockCSS | BlockCSS[],
59 | {
60 | component: _c = () => null,
61 | children: _h = () => null,
62 | mapVariants = {},
63 | variants = {},
64 | compound = [],
65 | defaults = {},
66 | }: ComponentConfig = {},
67 | ): React.FC> {
68 | const styleClasses = toArray(styles).map((style) => style.css);
69 |
70 | return ({ className, children, ...props }) => {
71 | const mainRef = React.useRef(null);
72 |
73 | React.useEffect(() => {
74 | toArray(styles).forEach((block) => add(block));
75 | }, [...styleClasses]);
76 |
77 | React.useEffect(() => {
78 | if (isString(className)) mainRef.current?.classList.add(className);
79 | styleClasses.forEach((css) => mainRef.current?.classList.add(css));
80 | }, [className]);
81 |
82 | React.useEffect(() => {
83 | Object.keys(variants).forEach((variantName) => {
84 | const propValue = props[variantName] ?? defaults[variantName];
85 | const mapper = mapVariants[variantName] ?? id;
86 | const variantCase = mapper(propValue);
87 | const cssBlock = variants[variantName][variantCase];
88 | if (cssBlock) {
89 | mainRef.current?.classList.add(cssBlock.css);
90 | add(cssBlock);
91 | }
92 | });
93 | }, [variants, props, defaults, mapVariants]);
94 |
95 | React.useEffect(() => {
96 | compound.forEach(({ css: cssBlock, ...matchers }) => {
97 | const isMatched = Object.keys(matchers).every((variantName) => {
98 | const expectedVariantCase = matchers[variantName];
99 | const propValue = props[variantName] ?? defaults[variantName];
100 | const mapper = mapVariants[variantName] ?? id;
101 | const variantCase = mapper(propValue);
102 | return expectedVariantCase === variantCase;
103 | });
104 | if (isMatched) {
105 | mainRef.current?.classList.add(cssBlock.css);
106 | add(cssBlock);
107 | }
108 | });
109 | }, [compound, props, defaults, mapVariants]);
110 |
111 | const Tag = tag as unknown as React.FC<{ className?: string; ref?: any }>;
112 | return {children};
113 | };
114 | }
115 |
116 | function toArray(maybe: T | T[]): T[] {
117 | return Array.isArray(maybe) ? maybe : [maybe];
118 | }
119 |
120 | function id(value: T): T {
121 | return value;
122 | }
123 |
124 | function isString(value: unknown): value is string {
125 | return typeof value === 'string';
126 | }
127 |
128 | function add(cssBlock: BlockCSS) {
129 | if (!document.querySelector(`[data-foliage="${cssBlock.css}"]`)) {
130 | const style = document.createElement('style');
131 | style.dataset.foliage = cssBlock.css;
132 | style.textContent = cssBlock.content;
133 | document.head.append(style);
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # foliage 🍃
2 |
3 |
4 |
5 | [GitHub](https://github.com/effector/foliage) [dev.to](https://dev.to/foliage)
6 |
7 | ## Usage with React
8 |
9 | > Work in progress. Most of this examples are just concept
10 |
11 |
12 |
13 | ```ts
14 | import { css, component } from 'foliage-react';
15 |
16 | const button = css`
17 | display: inline-block;
18 | border-radius: 3px;
19 | padding: 0.5rem 0;
20 | margin: 0.5rem 1rem;
21 | width: 11rem;
22 | border: 2px solid white;
23 | `;
24 |
25 | export const Button = component('a', button, {
26 | defaults: { color: 'default' },
27 | variants: {
28 | color: {
29 | primary: css`
30 | background: white;
31 | color: black;
32 | `,
33 | default: css`
34 | background: transparent;
35 | color: white;
36 | `,
37 | },
38 | },
39 | });
40 | ```
41 |
42 | ### Extending styles
43 |
44 | ```ts
45 | import { css, component } from 'foliage-react';
46 |
47 | const button = css`
48 | color: palevioletred;
49 | font-size: 1em;
50 | margin: 1em;
51 | padding: 0.25em 1em;
52 | border: 2px solid palevioletred;
53 | border-radius: 3px;
54 | `;
55 |
56 | export const Button = component('button', button);
57 |
58 | const tomato = css`
59 | color: tomato;
60 | border-color: tomato;
61 | `;
62 |
63 | export const TomatoButton = component('button', [button, tomato]);
64 | ```
65 |
66 | ### Pseudoelement, pseudoselectors, and nesting
67 |
68 | ```tsx
69 | import { css, component } from 'foliage-react';
70 |
71 | const thing = css`
72 | color: blue;
73 |
74 | &:hover {
75 | color: red; // when hovered
76 | }
77 |
78 | & ~ & {
79 | background: tomato; // as a sibling of , but maybe not directly next to it
80 | }
81 |
82 | & + & {
83 | background: lime; // next to
84 | }
85 |
86 | &.something {
87 | background: orange; // tagged with an additional CSS class ".something"
88 | }
89 |
90 | .something-else & {
91 | border: 1px solid; // inside another element labeled ".something-else"
92 | }
93 | `;
94 |
95 | export const Thing = component('div', thing, { attrs: { tabIndex: 0 } });
96 |
97 | const Example = () => (
98 | <>
99 | Hello world!
100 | How ya doing?
101 | The sun is shining...
102 | Pretty nice day today.
103 | Don't you think?
104 |
105 | Splendid.
106 |
107 | >
108 | );
109 | ```
110 |
111 | ### Animations
112 |
113 | ```ts
114 | import { css, keyframes, component } from 'foliage-react';
115 |
116 | const rotate = keyframes`
117 | from { transform: rotate(0deg) }
118 | to { transform: rotate(360deg) }
119 | `;
120 |
121 | const block = css`
122 | display: inline-block;
123 | animation: ${rotate} 2s linear infinite;
124 | padding: 2rem 1rem;
125 | font-size: 1.2rem;
126 | `;
127 |
128 | export const Block = component('div', block);
129 | ```
130 |
131 | ### Theming
132 |
133 | ```tsx
134 | import { css, keyframes, createGlobalStyle, Global } from 'foliage-react';
135 | const theme = {
136 | main: '--theme-main',
137 | };
138 |
139 | const button = css`
140 | font-size: 1em;
141 | margin: 1em;
142 | padding: 0.25em 1em;
143 | border-radius: 3px;
144 |
145 | /* Color the border and text with theme.main */
146 | color: var(${theme.main});
147 | border: 2px solid var(${theme.main});
148 | `;
149 |
150 | const Button = component('button', button);
151 |
152 | const primaryTheme = createGlobalStyle`
153 | :root {
154 | ${theme.main}: palevioletred;
155 | }
156 | `;
157 |
158 | const secondaryTheme = createGlobalStyle`
159 | :root {
160 | ${theme.main}: mediumseagreen;
161 | }
162 | `;
163 |
164 | const Example = () => (
165 | <>
166 |
167 |
168 | >
169 | );
170 | ```
171 |
172 | ### Composable components
173 |
174 | ```tsx
175 | import { css, component } from 'foliage-react';
176 |
177 | const baseStyles = css`
178 | color: white;
179 | background-color: mediumseagreen;
180 | border-radius: 4px;
181 | `;
182 |
183 | export const Button = component('button', baseStyles, {
184 | variants: {
185 | color: {
186 | gray: css`
187 | background-color: gainsboro;
188 | `,
189 | blue: css`
190 | background-color: dodgerblue;
191 | `,
192 | },
193 | size: {
194 | md: css`
195 | height: 26px;
196 | `,
197 | lg: css`
198 | height: 36px;
199 | `,
200 | },
201 | },
202 | compound: [
203 | {
204 | color: 'blue',
205 | size: 'lg',
206 | css: css`
207 | background-color: purple;
208 | `,
209 | },
210 | ],
211 | defaults: {
212 | color: 'gray',
213 | size: 'md',
214 | },
215 | });
216 | ```
217 |
218 | ## Release process
219 |
220 | 1. Check out the [draft release](https://github.com/foliage-ui/foliage/releases).
221 | 1. All PRs should have correct labels and useful titles. You can [review available labels here](https://github.com/foliage-ui/foliage/blob/master/.github/release-drafter.yml).
222 | 1. Update labels for PRs and titles, next [manually run the release drafter action](https://github.com/foliage-ui/foliage/actions/workflows/release-drafter.yml) to regenerate the draft release.
223 | 1. Review the new version and press "Publish"
224 | 1. If required check "Create discussion for this release"
225 |
--------------------------------------------------------------------------------
/jest.config.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/no-anonymous-default-export */
2 | /*
3 | * For a detailed explanation regarding each configuration property and type check, visit:
4 | * https://jestjs.io/docs/en/configuration.html
5 | */
6 |
7 | export default {
8 | // All imported modules in your tests should be mocked automatically
9 | // automock: false,
10 |
11 | // Stop running tests after `n` failures
12 | // bail: 0,
13 |
14 | // The directory where Jest should store its cached dependency information
15 | cacheDirectory: './.jest-cache',
16 |
17 | // Automatically clear mock calls and instances between every test
18 | clearMocks: true,
19 |
20 | // Indicates whether the coverage information should be collected while executing the test
21 | // collectCoverage: false,
22 |
23 | // An array of glob patterns indicating a set of files for which coverage information should be collected
24 | // collectCoverageFrom: undefined,
25 |
26 | // The directory where Jest should output its coverage files
27 | coverageDirectory: 'coverage',
28 |
29 | // An array of regexp pattern strings used to skip coverage collection
30 | // eslint-disable-next-line sonarjs/no-duplicate-string
31 | coveragePathIgnorePatterns: ['/node_modules/'],
32 |
33 | // Indicates which provider should be used to instrument code for coverage
34 | coverageProvider: 'babel',
35 |
36 | // A list of reporter names that Jest uses when writing coverage reports
37 | // coverageReporters: [
38 | // "json",
39 | // "text",
40 | // "lcov",
41 | // "clover"
42 | // ],
43 |
44 | // An object that configures minimum threshold enforcement for coverage results
45 | // coverageThreshold: undefined,
46 |
47 | // A path to a custom dependency extractor
48 | // dependencyExtractor: undefined,
49 |
50 | // Make calling deprecated APIs throw helpful error messages
51 | // errorOnDeprecated: false,
52 |
53 | // Force coverage collection from ignored files using an array of glob patterns
54 | // forceCoverageMatch: [],
55 |
56 | // A path to a module which exports an async function that is triggered once before all test suites
57 | // globalSetup: undefined,
58 |
59 | // A path to a module which exports an async function that is triggered once after all test suites
60 | // globalTeardown: undefined,
61 |
62 | // A set of global variables that need to be available in all test environments
63 | // globals: {},
64 |
65 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66 | // maxWorkers: "50%",
67 |
68 | // An array of directory names to be searched recursively up from the requiring module's location
69 | // moduleDirectories: [
70 | // "node_modules"
71 | // ],
72 |
73 | // An array of file extensions your modules use
74 | moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
75 |
76 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
77 | // moduleNameMapper: {},
78 |
79 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
80 | // modulePathIgnorePatterns: [],
81 |
82 | // Activates notifications for test results
83 | // notify: false,
84 |
85 | // An enum that specifies notification mode. Requires { notify: true }
86 | // notifyMode: "failure-change",
87 |
88 | // A preset that is used as a base for Jest's configuration
89 | // preset: undefined,
90 |
91 | // Run tests from one or more projects
92 | // projects: undefined,
93 |
94 | // Use this configuration option to add custom reporters to Jest
95 | // reporters: undefined,
96 |
97 | // Automatically reset mock state between every test
98 | // resetMocks: false,
99 |
100 | // Reset the module registry before running each individual test
101 | // resetModules: false,
102 |
103 | // A path to a custom resolver
104 | // resolver: undefined,
105 |
106 | // Automatically restore mock state between every test
107 | // restoreMocks: false,
108 |
109 | // The root directory that Jest should scan for tests and modules within
110 | // rootDir: undefined,
111 |
112 | // A list of paths to directories that Jest should use to search for files in
113 | roots: [''],
114 |
115 | // Allows you to use a custom runner instead of Jest's default test runner
116 | // runner: "jest-runner",
117 |
118 | // The paths to modules that run some code to configure or set up the testing environment before each test
119 | // setupFiles: [],
120 |
121 | // A list of paths to modules that run some code to configure or set up the testing framework before each test
122 | // setupFilesAfterEnv: [],
123 |
124 | // The number of seconds after which a test is considered as slow and reported as such in the results.
125 | // slowTestThreshold: 5,
126 |
127 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing
128 | // snapshotSerializers: [],
129 |
130 | // The test environment that will be used for testing
131 | testEnvironment: 'jsdom',
132 |
133 | // Options that will be passed to the testEnvironment
134 | // testEnvironmentOptions: {},
135 |
136 | // Adds a location field to test results
137 | // testLocationInResults: false,
138 |
139 | // The glob patterns Jest uses to detect test files
140 | // testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
141 |
142 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
143 | testPathIgnorePatterns: ['/node_modules/'],
144 |
145 | // The regexp pattern or array of patterns that Jest uses to detect test files
146 | testRegex: ['\\.test\\.[tj]sx?$'],
147 |
148 | // This option allows the use of a custom results processor
149 | // testResultsProcessor: undefined,
150 |
151 | // This option allows use of a custom test runner
152 | // testRunner: "jasmine2",
153 |
154 | // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
155 | // testURL: "http://localhost",
156 |
157 | // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
158 | // timers: "real",
159 |
160 | // A map from regular expressions to paths to transformers
161 | transform: {
162 | '.+\\.[tj]sx?$': 'babel-jest',
163 | },
164 |
165 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
166 | transformIgnorePatterns: ['/node_modules/', '\\.pnp\\.[^\\/]+$'],
167 |
168 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
169 | // unmockedModulePathPatterns: undefined,
170 |
171 | // Indicates whether each individual test should be reported during the run
172 | // verbose: undefined,
173 |
174 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
175 | // watchPathIgnorePatterns: [],
176 |
177 | // Whether to use watchman for file crawling
178 | // watchman: true,
179 | };
180 |
--------------------------------------------------------------------------------
/babel-plugin.test.ts:
--------------------------------------------------------------------------------
1 | import pluginTester from 'babel-plugin-tester';
2 | import plugin from './babel-plugin';
3 |
4 | const fullExample = `
5 | import { css, keyframes, createGlobalStyle } from 'foliage';
6 | const part = css\`
7 | color: black;
8 | & > * { padding-left: 1rem; }
9 | \`
10 |
11 | const anim = keyframes\`
12 | 0% { transform: rotate(0deg) }
13 | 100% { transform: rotate(180deg) }
14 | \`
15 |
16 | const glob = createGlobalStyle\`
17 | body {
18 | position: fixed;
19 | top: 0;
20 | left: 0;
21 | }
22 | \`
23 | `;
24 |
25 | const namespaceSupport = `
26 | import * as example from 'foliage';
27 | const part = example.css\`
28 | color: black;
29 | & > * { padding-left: 1rem; }
30 | \`
31 |
32 | const anim = example.keyframes\`
33 | 0% { transform: rotate(0deg) }
34 | 100% { transform: rotate(180deg) }
35 | \`
36 |
37 | const glob = example.createGlobalStyle\`
38 | body {
39 | position: fixed;
40 | top: 0;
41 | left: 0;
42 | }
43 | \`
44 |
45 | const theme = example.vars\`
46 | --demo: 123px;
47 | \`
48 | `;
49 |
50 | const doNotCompilesThirdParty = `
51 | import { css, keyframes, createGlobalStyle } from 'styled-components';
52 | const part = css\`color:black;\`
53 | const anim = keyframes\`from{color: black;} to {color: white;}\`
54 | const glob = createGlobalStyle\`body{display: grid}\`
55 | `;
56 |
57 | const cssInterpolationInCss = `
58 | import { css } from 'foliage';
59 | const first = css\`
60 | color: black;
61 | & > * { padding-left: 1rem; }
62 | \`
63 | const second = css\`
64 | color: red;
65 | & \${first} {
66 | color: white;
67 | }
68 | \`
69 | `;
70 |
71 | const keyframesInterpolationInCss = `
72 | import { css, keyframes } from 'foliage';
73 |
74 | const anim = keyframes\`
75 | 0% { transform: rotate(0deg) }
76 | 100% { transform: rotate(180deg) }
77 | \`
78 |
79 | const element = css\`
80 | color: red;
81 | animation: 3s ease-in 1s infinite \${anim};
82 | \`
83 | `;
84 |
85 | const interpolation = `
86 | import { css, keyframes } from 'foliage';
87 |
88 | const theme = {
89 | size: {
90 | normal: '--demo-size-normal',
91 | }
92 | }
93 |
94 | const first = css\`
95 | display: block;
96 | \`
97 |
98 | const pulse = keyframes\`
99 | 0% { opacity: 1 }
100 | 50% { opacity: 0.2 }
101 | 100% { opacity: 1 }
102 | \`
103 |
104 | const second = css\`
105 | font-size: var(\${theme.size.normal});
106 | animation: 1s ease-in-out infinite \${pulse};
107 |
108 | \${first} & {
109 | display: flex;
110 | }
111 | \`
112 | `;
113 |
114 | const interpolationWithNamespace = `
115 | import * as foli from 'foliage';
116 |
117 | const theme = {
118 | size: {
119 | normal: '--demo-size-normal',
120 | }
121 | }
122 |
123 | const first = foli.css\`
124 | display: block;
125 | \`
126 |
127 | const pulse = foli.keyframes\`
128 | 0% { opacity: 1 }
129 | 50% { opacity: 0.2 }
130 | 100% { opacity: 1 }
131 | \`
132 |
133 | const second = foli.css\`
134 | font-size: var(\${theme.size.normal});
135 | animation: 1s ease-in-out infinite \${pulse};
136 |
137 | \${first} & {
138 | display: flex;
139 | }
140 | \`
141 | `;
142 |
143 | const combination = `
144 | import { css } from 'foliage'
145 | import * as f from 'foliage'
146 |
147 | const theme = {
148 | size: {
149 | normal: '--demo-size-normal',
150 | }
151 | }
152 |
153 | const first = css\`
154 | display: block;
155 | \${theme.size.normal}: 12px;
156 | \`
157 |
158 | const pulse = f.keyframes\`
159 | 0% { opacity: 1 }
160 | 50% { opacity: 0.2 }
161 | 100% { opacity: 1 }
162 | \`
163 |
164 | const second = f.css\`
165 | font-size: var(\${theme.size.normal});
166 | animation: 1s ease-in-out infinite \${pulse};
167 |
168 | \${first} & {
169 | display: flex;
170 | }
171 | \`
172 | `;
173 |
174 | const assertsDoNotConflictsWithExistsDeclarations = `
175 | import { css, keyframes } from 'foliage'
176 |
177 | function _assertKeyframe() {}
178 | const _assertVariable = 1;
179 | const _assertSelector = () => {};
180 | function assertKeyframe() {}
181 |
182 | const size = '--demo-size';
183 | const speed = '--demo-anim-speed';
184 |
185 | const anim = keyframes\`
186 | from { opacity: 0 };
187 | to: { opacity: 1 };
188 | \`;
189 |
190 | const first = css\`
191 | color: black;
192 | font-size: var(\${size});
193 | animation: var(\${speed}) infinite linear \${anim};
194 | \`;
195 | `;
196 |
197 | const componentWithVariantsDeclaration = `
198 | import { css, component } from 'foliage-react';
199 |
200 | const size = '--ui-size';
201 |
202 | const chip = css\`
203 | color: white;
204 | background-color: black;
205 | border-radius: 4px;
206 | padding: var(\${size});
207 | \`
208 |
209 | export const Chip = component('div', [chip], {
210 | defaults: { size: 'normal' },
211 | variants: {
212 | size: {
213 | small: css\` \${size}: 6px; \`,
214 | normal: css\` \${size}: 8px; \`,
215 | large: css\` \${size}: 12px; \`,
216 | }
217 | }
218 | })
219 | `;
220 |
221 | const deepNestingDeterminesName = `
222 | import { css } from 'foliage';
223 | const first = {
224 | second: {
225 | third: css\` color: black \`,
226 | fifth: {
227 | sixth: css\`color:white;\`
228 | },
229 | },
230 | fourth: css\`color:red\`
231 | }
232 | `;
233 |
234 | const selectorOfComponent = `
235 | import { css } from 'foliage';
236 | const button = css\`
237 | padding: 1rem 2rem;
238 | border: 2px solid gray;
239 | border-radius: 1rem;
240 | color: white;
241 | background-color: black;
242 | appearance: none;
243 | \`;
244 |
245 | const primary = css\`
246 | background-color: black;
247 | color: white;
248 | padding: 1rem 2rem;
249 |
250 | \${button} {
251 | background-color: red;
252 | color: white;
253 | }
254 | \`;
255 | `;
256 |
257 | const selectorOfComponentWithPseudoSelector = `
258 | import { css } from 'foliage';
259 | const button = css\`
260 | padding: 1rem 2rem;
261 | border: 2px solid gray;
262 | border-radius: 1rem;
263 | color: white;
264 | background-color: black;
265 | appearance: none;
266 | \`;
267 |
268 | const primary = css\`
269 | background-color: black;
270 | color: white;
271 | padding: 1rem 2rem;
272 |
273 | \${button}:hover {
274 | background-color: red;
275 | color: white;
276 | }
277 | \`;
278 | `;
279 |
280 | pluginTester({
281 | pluginName: 'foliage',
282 | plugin,
283 | pluginOptions: { debug: true },
284 | root: __dirname,
285 | filename: __filename,
286 | babelOptions: { filename: __filename },
287 | snapshot: true,
288 | tests: {
289 | cssImportedFromPackage: `import {css} from 'foliage'; const example = css\`color: black\``,
290 | cssRenamedFromPackage: `import {css as demo} from 'foliage'; const example = demo\`justify-content: center;\``,
291 | withoutDebugNamesNotAdded: {
292 | code: `import {css} from 'foliage'; const example = css\`span{display:grid}\``,
293 | pluginOptions: { debug: false },
294 | },
295 | cssImportedFromReact: `import {css} from 'foliage-react'; const demo = css\`.global & { [data-demo="a"] {color: black} }\``,
296 | cssImportedFromLocal: {
297 | code: `import {css} from '../react'; const demo = css\`.global & { [data-demo="a"] {color: black} }\``,
298 | pluginOptions: {
299 | allowedModules: ['../react'],
300 | },
301 | },
302 | keyframesAndGlobalStylesShouldCompile: fullExample,
303 | varsNotCompiles: `import {vars, css} from 'foliage'; const a = css\`outline: none;\`; const b = vars\`--random: 1px;\``,
304 | namespaceSupport,
305 | doNotCompilesThirdParty,
306 | cssInterpolationInCss,
307 | interpolationWithNamespace,
308 | keyframesInterpolationInCss,
309 | prefixAdd: {
310 | code: fullExample,
311 | pluginOptions: { prefix: 'prefix', debug: true },
312 | },
313 | prefixExistsWithoutDebug: {
314 | code: fullExample,
315 | pluginOptions: { prefix: 'prefix', debug: false },
316 | },
317 | fullInterpolationExample: interpolation,
318 | assertsDoNotConflictsWithExistsDeclarations,
319 | componentWithVariantsDeclaration,
320 | deepNestingDeterminesName,
321 | combination,
322 | selectorOfComponent,
323 | selectorOfComponentWithPseudoSelector,
324 | },
325 | });
326 |
--------------------------------------------------------------------------------
/tests/react/render.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import '@testing-library/jest-dom';
3 | import {
4 | render,
5 | fireEvent,
6 | waitFor,
7 | screen,
8 | prettyDOM as reactTestingLibraryPrettyDOM,
9 | } from '@testing-library/react';
10 | import beautify from 'js-beautify';
11 | import {
12 | component,
13 | css,
14 | keyframes,
15 | createGlobalStyle,
16 | Global,
17 | } from '../../react';
18 |
19 | export const getCSS = (scope: Document | HTMLElement): string =>
20 | beautify.css(
21 | Array.from(scope.querySelectorAll('style'))
22 | .map((tag) => tag.innerHTML)
23 | .join('\n')
24 | .replace(/ {/g, '{')
25 | .replace(/:\s+/g, ':')
26 | .replace(/:\s+;/g, ':;'),
27 | );
28 |
29 | export const printDOM = (element: Element | HTMLDocument): string | false =>
30 | reactTestingLibraryPrettyDOM(element, undefined, { highlight: false });
31 |
32 | beforeEach(() => {
33 | document.head.innerHTML = '';
34 | });
35 |
36 | test('check it rendering', () => {
37 | const style = css`
38 | color: red;
39 | &:hover {
40 | color: black;
41 | }
42 | @media (min-width: 800px) {
43 | padding: 20px;
44 | }
45 | `;
46 |
47 | const Example = component('button', style);
48 |
49 | const { baseElement } = render(content);
50 |
51 | expect(getCSS(document)).toMatchInlineSnapshot(`
52 | ".fqwyk1a-style {
53 | color: red
54 | }
55 |
56 | .fqwyk1a-style:hover {
57 | color: #000
58 | }
59 |
60 | @media (min-width:800px) {
61 | .fqwyk1a-style {
62 | padding: 20px
63 | }
64 | }"
65 | `);
66 | expect(printDOM(baseElement)).toMatchInlineSnapshot(`
67 | "
68 |
69 |
74 |
75 | "
76 | `);
77 | });
78 |
79 | test('variants from readme', () => {
80 | const button = css`
81 | display: inline-block;
82 | border-radius: 3px;
83 | padding: 0.5rem 0;
84 | margin: 0.5rem 1rem;
85 | width: 11rem;
86 | border: 2px solid white;
87 | `;
88 |
89 | const Button = component('a', button, {
90 | defaults: { color: 'default' },
91 | variants: {
92 | color: {
93 | primary: css`
94 | background: white;
95 | color: black;
96 | `,
97 | default: css`
98 | background: transparent;
99 | color: white;
100 | `,
101 | },
102 | },
103 | });
104 |
105 | const defaultOption = render();
106 | expect(getCSS(document)).toMatchInlineSnapshot(`
107 | ".f89xayi-button {
108 | display: inline-block;
109 | border-radius: 3px;
110 | padding: .5rem 0;
111 | margin: .5rem 1rem;
112 | width: 11rem;
113 | border: 2px solid #fff
114 | }
115 |
116 | .f-tt0vsb-Button-variants-color-default {
117 | background: 0 0;
118 | color: #fff
119 | }"
120 | `);
121 | expect(printDOM(defaultOption.baseElement)).toMatchInlineSnapshot(`
122 | "
123 |
130 | "
131 | `);
132 | defaultOption.unmount();
133 |
134 | const changedOption = render();
135 | expect(getCSS(document)).toMatchInlineSnapshot(`
136 | ".f89xayi-button {
137 | display: inline-block;
138 | border-radius: 3px;
139 | padding: .5rem 0;
140 | margin: .5rem 1rem;
141 | width: 11rem;
142 | border: 2px solid #fff
143 | }
144 |
145 | .f-tt0vsb-Button-variants-color-default {
146 | background: 0 0;
147 | color: #fff
148 | }
149 |
150 | .f-k92sfa-Button-variants-color-primary {
151 | background: #fff;
152 | color: #000
153 | }"
154 | `);
155 | expect(printDOM(changedOption.baseElement)).toMatchInlineSnapshot(`
156 | "
157 |
158 |
165 | "
166 | `);
167 | });
168 |
169 | test('extending variants', () => {
170 | const button = css`
171 | color: palevioletred;
172 | font-size: 1em;
173 | margin: 1em;
174 | padding: 0.25em 1em;
175 | border: 2px solid palevioletred;
176 | border-radius: 3px;
177 | `;
178 |
179 | const Button = component('button', button);
180 |
181 | const tomato = css`
182 | color: tomato;
183 | border-color: tomato;
184 | `;
185 |
186 | const TomatoButton = component('button', [button, tomato]);
187 |
188 | const result = render(
189 | <>
190 |
191 | Extended
192 | >,
193 | );
194 |
195 | expect(getCSS(document)).toMatchInlineSnapshot(`
196 | ".fhjc0iy-button {
197 | color: #db7093;
198 | font-size: 1em;
199 | margin: 1em;
200 | padding: .25em 1em;
201 | border: 2px solid #db7093;
202 | border-radius: 3px
203 | }
204 |
205 | .f2d2unm-tomato {
206 | color: tomato;
207 | border-color: tomato
208 | }"
209 | `);
210 | expect(printDOM(result.baseElement)).toMatchInlineSnapshot(`
211 | "
212 |
213 |
218 |
223 |
224 | "
225 | `);
226 | });
227 |
228 | test('preudoelement, pseudoselectors, nesting', () => {
229 | const thing = css`
230 | color: blue;
231 |
232 | &:hover {
233 | color: red;
234 | }
235 |
236 | & ~ & {
237 | background: tomato;
238 | }
239 |
240 | & + & {
241 | background: lime;
242 | }
243 |
244 | &.something {
245 | background: orange;
246 | }
247 |
248 | .something-else & {
249 | border: 1px solid;
250 | }
251 | `;
252 |
253 | const Thing = component('div', thing);
254 |
255 | const Example = () => (
256 | <>
257 | Hello world!
258 | How ya doing?
259 | The sun is shining...
260 | Pretty nice day today.
261 | Don't you think?
262 |
263 | Splendid.
264 |
265 | >
266 | );
267 |
268 | const result = render();
269 | expect(getCSS(document)).toMatchInlineSnapshot(`
270 | ".f-j90c5c-thing {
271 | color: #00f
272 | }
273 |
274 | .f-j90c5c-thing:hover {
275 | color: red
276 | }
277 |
278 | .f-j90c5c-thing~.f-j90c5c-thing {
279 | background: tomato
280 | }
281 |
282 | .f-j90c5c-thing+.f-j90c5c-thing {
283 | background: #0f0
284 | }
285 |
286 | .f-j90c5c-thing.something {
287 | background: orange
288 | }
289 |
290 | .something-else .f-j90c5c-thing {
291 | border: 1px solid
292 | }"
293 | `);
294 | expect(printDOM(result.baseElement)).toMatchInlineSnapshot(`
295 | "
296 |
297 |
300 | Hello world!
301 |
302 |
305 | How ya doing?
306 |
307 |
310 | The sun is shining...
311 |
312 |
313 | Pretty nice day today.
314 |
315 |
318 | Don't you think?
319 |
320 |
323 |
326 | Splendid.
327 |
328 |
329 |
330 | "
331 | `);
332 | });
333 |
334 | test('animations', () => {
335 | const rotate = keyframes`
336 | from { transform: rotate(0deg) }
337 | to { transform: rotate(360deg) }
338 | `;
339 |
340 | const block = css`
341 | display: inline-block;
342 | animation: ${rotate} 2s linear infinite;
343 | padding: 2rem 1rem;
344 | font-size: 1.2rem;
345 | `;
346 |
347 | const Block = component('div', block);
348 |
349 | const result = render();
350 |
351 | // TODO: keyframes should be appended to a styles
352 | expect(getCSS(document)).toMatchInlineSnapshot(`
353 | ".f-a6lm45-block {
354 | display: inline-block;
355 | -webkit-animation: [object Object] 2s linear infinite;
356 | animation: [object Object] 2s linear infinite;
357 | padding: 2rem 1rem;
358 | font-size: 1.2rem
359 | }"
360 | `);
361 | expect(printDOM(result.baseElement)).toMatchInlineSnapshot(`
362 | "
363 |
368 | "
369 | `);
370 | });
371 |
372 | test('theming and globalStyle', () => {
373 | const theme = {
374 | main: '--theme-main',
375 | };
376 |
377 | const button = css`
378 | font-size: 1em;
379 | margin: 1em;
380 | padding: 0.25em 1em;
381 | border-radius: 3px;
382 |
383 | /* Color the border and text with theme.main */
384 | color: var(${theme.main});
385 | border: 2px solid var(${theme.main});
386 | `;
387 |
388 | const Button = component('button', button);
389 |
390 | const primaryTheme = createGlobalStyle`
391 | :root {
392 | ${theme.main}: palevioletred;
393 | }
394 | `;
395 |
396 | const Example = () => (
397 | <>
398 |
399 |
400 | >
401 | );
402 |
403 | const result = render();
404 |
405 | expect(getCSS(document)).toMatchInlineSnapshot(`
406 | ":root {
407 | --theme-main: palevioletred
408 | }
409 |
410 | .f7gs9fl-button {
411 | font-size: 1em;
412 | margin: 1em;
413 | padding: .25em 1em;
414 | border-radius: 3px;
415 | color: var(--theme-main);
416 | border: 2px solid var(--theme-main)
417 | }"
418 | `);
419 | expect(printDOM(result.baseElement)).toMatchInlineSnapshot(`
420 | "
421 |
422 |
425 |
426 | "
427 | `);
428 | });
429 |
430 | test('composable components', () => {
431 | const baseStyles = css`
432 | color: white;
433 | background-color: mediumseagreen;
434 | border-radius: 4px;
435 | `;
436 |
437 | const Button = component('button', baseStyles, {
438 | variants: {
439 | color: {
440 | gray: css`
441 | background-color: gainsboro;
442 | `,
443 | blue: css`
444 | background-color: dodgerblue;
445 | `,
446 | },
447 | size: {
448 | md: css`
449 | height: 26px;
450 | `,
451 | lg: css`
452 | height: 36px;
453 | `,
454 | },
455 | },
456 | compound: [
457 | {
458 | color: 'blue',
459 | size: 'lg',
460 | css: css`
461 | background-color: purple;
462 | `,
463 | },
464 | ],
465 | defaults: {
466 | color: 'gray',
467 | size: 'md',
468 | },
469 | });
470 |
471 | const defaultOptions = render();
472 | expect(getCSS(document)).toMatchInlineSnapshot(`
473 | ".f-40ddeg-baseStyles {
474 | color: #fff;
475 | background-color: #3cb371;
476 | border-radius: 4px
477 | }
478 |
479 | .fx4y0y0-Button-variants-color-gray {
480 | background-color: #dcdcdc
481 | }
482 |
483 | .f-4ritl8-Button-variants-size-md {
484 | height: 26px
485 | }"
486 | `);
487 | expect(printDOM(defaultOptions.baseElement)).toMatchInlineSnapshot(`
488 | "
489 |
490 |
493 |
494 | "
495 | `);
496 | defaultOptions.unmount();
497 |
498 | const compoundOptions = render();
499 | expect(getCSS(document)).toMatchInlineSnapshot(`
500 | ".f-40ddeg-baseStyles {
501 | color: #fff;
502 | background-color: #3cb371;
503 | border-radius: 4px
504 | }
505 |
506 | .fx4y0y0-Button-variants-color-gray {
507 | background-color: #dcdcdc
508 | }
509 |
510 | .f-4ritl8-Button-variants-size-md {
511 | height: 26px
512 | }
513 |
514 | .f14ofny-Button-variants-color-blue {
515 | background-color: #1e90ff
516 | }
517 |
518 | .f-uxnw08-Button-variants-size-lg {
519 | height: 36px
520 | }
521 |
522 | .f-z7u4br-css {
523 | background-color: purple
524 | }"
525 | `);
526 | expect(printDOM(compoundOptions.baseElement)).toMatchInlineSnapshot(`
527 | "
528 |
529 |
530 |
533 |
534 | "
535 | `);
536 | compoundOptions.unmount();
537 |
538 | const partialOptions = render();
539 | expect(getCSS(document)).toMatchInlineSnapshot(`
540 | ".f-40ddeg-baseStyles {
541 | color: #fff;
542 | background-color: #3cb371;
543 | border-radius: 4px
544 | }
545 |
546 | .fx4y0y0-Button-variants-color-gray {
547 | background-color: #dcdcdc
548 | }
549 |
550 | .f-4ritl8-Button-variants-size-md {
551 | height: 26px
552 | }
553 |
554 | .f14ofny-Button-variants-color-blue {
555 | background-color: #1e90ff
556 | }
557 |
558 | .f-uxnw08-Button-variants-size-lg {
559 | height: 36px
560 | }
561 |
562 | .f-z7u4br-css {
563 | background-color: purple
564 | }"
565 | `);
566 | expect(printDOM(partialOptions.baseElement)).toMatchInlineSnapshot(`
567 | "
568 |
569 |
570 |
571 |
574 |
575 | "
576 | `);
577 | partialOptions.unmount();
578 | });
579 |
--------------------------------------------------------------------------------
/src/stylis/built/stylis.mjs:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | var e = '-ms-';
3 | var r = '-moz-';
4 | var a = '-webkit-';
5 | var c = 'comm';
6 | var n = 'rule';
7 | var t = 'decl';
8 | var s = '@page';
9 | var u = '@media';
10 | var i = '@import';
11 | var f = '@charset';
12 | var o = '@viewport';
13 | var l = '@supports';
14 | var v = '@document';
15 | var h = '@namespace';
16 | var p = '@keyframes';
17 | var b = '@font-face';
18 | var w = '@counter-style';
19 | var $ = '@font-feature-values';
20 | var k = Math.abs;
21 | var d = String.fromCharCode;
22 | function m(e, r) {
23 | return (
24 | (((((((r << 2) ^ z(e, 0)) << 2) ^ z(e, 1)) << 2) ^ z(e, 2)) << 2) ^ z(e, 3)
25 | );
26 | }
27 | function g(e) {
28 | return e.trim();
29 | }
30 | function x(e, r) {
31 | return (e = r.exec(e)) ? e[0] : e;
32 | }
33 | function y(e, r, a) {
34 | return e.replace(r, a);
35 | }
36 | function j(e, r) {
37 | return e.indexOf(r);
38 | }
39 | function z(e, r) {
40 | return e.charCodeAt(r) | 0;
41 | }
42 | function C(e, r, a) {
43 | return e.slice(r, a);
44 | }
45 | function A(e) {
46 | return e.length;
47 | }
48 | function M(e) {
49 | return e.length;
50 | }
51 | function O(e, r) {
52 | return r.push(e), e;
53 | }
54 | function S(e, r) {
55 | return e.map(r).join('');
56 | }
57 | var q = 1;
58 | var B = 1;
59 | var D = 0;
60 | var E = 0;
61 | var F = 0;
62 | var G = '';
63 | function H(e, r, a, c, n, t, s) {
64 | return {
65 | value: e,
66 | root: r,
67 | parent: a,
68 | type: c,
69 | props: n,
70 | children: t,
71 | line: q,
72 | column: B,
73 | length: s,
74 | return: '',
75 | };
76 | }
77 | function I(e, r, a) {
78 | return H(e, r.root, r.parent, a, r.props, r.children, 0);
79 | }
80 | function J() {
81 | return F;
82 | }
83 | function K() {
84 | F = E > 0 ? z(G, --E) : 0;
85 | if ((B--, F === 10)) (B = 1), q--;
86 | return F;
87 | }
88 | function L() {
89 | F = E < D ? z(G, E++) : 0;
90 | if ((B++, F === 10)) (B = 1), q++;
91 | return F;
92 | }
93 | function N() {
94 | return z(G, E);
95 | }
96 | function P() {
97 | return E;
98 | }
99 | function Q(e, r) {
100 | return C(G, e, r);
101 | }
102 | function R(e) {
103 | switch (e) {
104 | case 0:
105 | case 9:
106 | case 10:
107 | case 13:
108 | case 32:
109 | return 5;
110 | case 33:
111 | case 43:
112 | case 44:
113 | case 47:
114 | case 62:
115 | case 64:
116 | case 126:
117 | case 59:
118 | case 123:
119 | case 125:
120 | return 4;
121 | case 58:
122 | return 3;
123 | case 34:
124 | case 39:
125 | case 40:
126 | case 91:
127 | return 2;
128 | case 41:
129 | case 93:
130 | return 1;
131 | }
132 | return 0;
133 | }
134 | function T(e) {
135 | return (q = B = 1), (D = A((G = e))), (E = 0), [];
136 | }
137 | function U(e) {
138 | return (G = ''), e;
139 | }
140 | function V(e) {
141 | return g(Q(E - 1, _(e === 91 ? e + 2 : e === 40 ? e + 1 : e)));
142 | }
143 | function W(e) {
144 | return U(Y(T(e)));
145 | }
146 | function X(e) {
147 | while ((F = N()))
148 | if (F < 33) L();
149 | else break;
150 | return R(e) > 2 || R(F) > 3 ? '' : ' ';
151 | }
152 | function Y(e) {
153 | while (L())
154 | switch (R(F)) {
155 | case 0:
156 | O(re(E - 1), e);
157 | break;
158 | case 2:
159 | O(V(F), e);
160 | break;
161 | default:
162 | O(d(F), e);
163 | }
164 | return e;
165 | }
166 | function Z(e, r) {
167 | while (--r && L())
168 | if (F < 48 || F > 102 || (F > 57 && F < 65) || (F > 70 && F < 97)) break;
169 | return Q(e, P() + (r < 6 && N() == 32 && L() == 32));
170 | }
171 | function _(e) {
172 | while (L())
173 | switch (F) {
174 | case e:
175 | return E;
176 | case 34:
177 | case 39:
178 | return _(e === 34 || e === 39 ? e : F);
179 | case 40:
180 | if (e === 41) _(e);
181 | break;
182 | case 92:
183 | L();
184 | break;
185 | }
186 | return E;
187 | }
188 | function ee(e, r) {
189 | while (L())
190 | if (e + F === 47 + 10) break;
191 | else if (e + F === 42 + 42 && N() === 47) break;
192 | return '/*' + Q(r, E - 1) + '*' + d(e === 47 ? e : L());
193 | }
194 | function re(e) {
195 | while (!R(N())) L();
196 | return Q(e, E);
197 | }
198 | function ae(e) {
199 | return U(ce('', null, null, null, [''], (e = T(e)), 0, [0], e));
200 | }
201 | function ce(e, r, a, c, n, t, s, u, i) {
202 | var f = 0;
203 | var o = 0;
204 | var l = s;
205 | var v = 0;
206 | var h = 0;
207 | var p = 0;
208 | var b = 1;
209 | var w = 1;
210 | var $ = 1;
211 | var k = 0;
212 | var m = '';
213 | var g = n;
214 | var x = t;
215 | var j = c;
216 | var z = m;
217 | while (w)
218 | switch (((p = k), (k = L()))) {
219 | case 34:
220 | case 39:
221 | case 91:
222 | case 40:
223 | z += V(k);
224 | break;
225 | case 9:
226 | case 10:
227 | case 13:
228 | case 32:
229 | z += X(p);
230 | break;
231 | case 92:
232 | z += Z(P() - 1, 7);
233 | continue;
234 | case 47:
235 | switch (N()) {
236 | case 42:
237 | case 47:
238 | O(te(ee(L(), P()), r, a), i);
239 | break;
240 | default:
241 | z += '/';
242 | }
243 | break;
244 | case 123 * b:
245 | u[f++] = A(z) * $;
246 | case 125 * b:
247 | case 59:
248 | case 0:
249 | switch (k) {
250 | case 0:
251 | case 125:
252 | w = 0;
253 | case 59 + o:
254 | if (h > 0 && A(z) - l)
255 | O(
256 | h > 32
257 | ? se(z + ';', c, a, l - 1)
258 | : se(y(z, ' ', '') + ';', c, a, l - 2),
259 | i,
260 | );
261 | break;
262 | case 59:
263 | z += ';';
264 | default:
265 | O((j = ne(z, r, a, f, o, n, u, m, (g = []), (x = []), l)), t);
266 | if (k === 123)
267 | if (o === 0) ce(z, r, j, j, g, t, l, u, x);
268 | else
269 | switch (v) {
270 | case 100:
271 | case 109:
272 | case 115:
273 | ce(
274 | e,
275 | j,
276 | j,
277 | c && O(ne(e, j, j, 0, 0, n, u, m, n, (g = []), l), x),
278 | n,
279 | x,
280 | l,
281 | u,
282 | c ? g : x,
283 | );
284 | break;
285 | default:
286 | ce(z, j, j, j, [''], x, l, u, x);
287 | }
288 | }
289 | (f = o = h = 0), (b = $ = 1), (m = z = ''), (l = s);
290 | break;
291 | case 58:
292 | (l = 1 + A(z)), (h = p);
293 | default:
294 | if (b < 1)
295 | if (k == 123) --b;
296 | else if (k == 125 && b++ == 0 && K() == 125) continue;
297 | switch (((z += d(k)), k * b)) {
298 | case 38:
299 | $ = o > 0 ? 1 : ((z += '\f'), -1);
300 | break;
301 | case 44:
302 | (u[f++] = (A(z) - 1) * $), ($ = 1);
303 | break;
304 | case 64:
305 | if (N() === 45) z += V(L());
306 | (v = N()), (o = A((m = z += re(P())))), k++;
307 | break;
308 | case 45:
309 | if (p === 45 && A(z) == 2) b = 0;
310 | }
311 | }
312 | return t;
313 | }
314 | function ne(e, r, a, c, t, s, u, i, f, o, l) {
315 | var v = t - 1;
316 | var h = t === 0 ? s : [''];
317 | var p = M(h);
318 | for (var b = 0, w = 0, $ = 0; b < c; ++b)
319 | for (var d = 0, m = C(e, v + 1, (v = k((w = u[b])))), x = e; d < p; ++d)
320 | if ((x = g(w > 0 ? h[d] + ' ' + m : y(m, /&\f/g, h[d])))) f[$++] = x;
321 | return H(e, r, a, t === 0 ? n : i, f, o, l);
322 | }
323 | function te(e, r, a) {
324 | return H(e, r, a, c, d(J()), C(e, 2, -2), 0);
325 | }
326 | function se(e, r, a, c) {
327 | return H(e, r, a, t, C(e, 0, c), C(e, c + 1, -1), c);
328 | }
329 | function ue(c, n) {
330 | switch (m(c, n)) {
331 | case 5103:
332 | return a + 'print-' + c + c;
333 | case 5737:
334 | case 4201:
335 | case 3177:
336 | case 3433:
337 | case 1641:
338 | case 4457:
339 | case 2921:
340 | case 5572:
341 | case 6356:
342 | case 5844:
343 | case 3191:
344 | case 6645:
345 | case 3005:
346 | case 6391:
347 | case 5879:
348 | case 5623:
349 | case 6135:
350 | case 4599:
351 | case 4855:
352 | case 4215:
353 | case 6389:
354 | case 5109:
355 | case 5365:
356 | case 5621:
357 | case 3829:
358 | return a + c + c;
359 | case 5349:
360 | case 4246:
361 | case 4810:
362 | case 6968:
363 | case 2756:
364 | return a + c + r + c + e + c + c;
365 | case 6828:
366 | case 4268:
367 | return a + c + e + c + c;
368 | case 6165:
369 | return a + c + e + 'flex-' + c + c;
370 | case 5187:
371 | return (
372 | a + c + y(c, /(\w+).+(:[^]+)/, a + 'box-$1$2' + e + 'flex-$1$2') + c
373 | );
374 | case 5443:
375 | return a + c + e + 'flex-item-' + y(c, /flex-|-self/, '') + c;
376 | case 4675:
377 | return (
378 | a + c + e + 'flex-line-pack' + y(c, /align-content|flex-|-self/, '') + c
379 | );
380 | case 5548:
381 | return a + c + e + y(c, 'shrink', 'negative') + c;
382 | case 5292:
383 | return a + c + e + y(c, 'basis', 'preferred-size') + c;
384 | case 6060:
385 | return (
386 | a +
387 | 'box-' +
388 | y(c, '-grow', '') +
389 | a +
390 | c +
391 | e +
392 | y(c, 'grow', 'positive') +
393 | c
394 | );
395 | case 4554:
396 | return a + y(c, /([^-])(transform)/g, '$1' + a + '$2') + c;
397 | case 6187:
398 | return (
399 | y(y(y(c, /(zoom-|grab)/, a + '$1'), /(image-set)/, a + '$1'), c, '') + c
400 | );
401 | case 5495:
402 | case 3959:
403 | return y(c, /(image-set\([^]*)/, a + '$1' + '$`$1');
404 | case 4968:
405 | return (
406 | y(
407 | y(c, /(.+:)(flex-)?(.*)/, a + 'box-pack:$3' + e + 'flex-pack:$3'),
408 | /s.+-b[^;]+/,
409 | 'justify',
410 | ) +
411 | a +
412 | c +
413 | c
414 | );
415 | case 4095:
416 | case 3583:
417 | case 4068:
418 | case 2532:
419 | return y(c, /(.+)-inline(.+)/, a + '$1$2') + c;
420 | case 8116:
421 | case 7059:
422 | case 5753:
423 | case 5535:
424 | case 5445:
425 | case 5701:
426 | case 4933:
427 | case 4677:
428 | case 5533:
429 | case 5789:
430 | case 5021:
431 | case 4765:
432 | if (A(c) - 1 - n > 6)
433 | switch (z(c, n + 1)) {
434 | case 109:
435 | if (z(c, n + 4) !== 45) break;
436 | case 102:
437 | return (
438 | y(
439 | c,
440 | /(.+:)(.+)-([^]+)/,
441 | '$1' +
442 | a +
443 | '$2-$3' +
444 | '$1' +
445 | r +
446 | (z(c, n + 3) == 108 ? '$3' : '$2-$3'),
447 | ) + c
448 | );
449 | case 115:
450 | return ~j(c, 'stretch')
451 | ? ue(y(c, 'stretch', 'fill-available'), n) + c
452 | : c;
453 | }
454 | break;
455 | case 4949:
456 | if (z(c, n + 1) !== 115) break;
457 | case 6444:
458 | switch (z(c, A(c) - 3 - (~j(c, '!important') && 10))) {
459 | case 107:
460 | return y(c, ':', ':' + a) + c;
461 | case 101:
462 | return (
463 | y(
464 | c,
465 | /(.+:)([^;!]+)(;|!.+)?/,
466 | '$1' +
467 | a +
468 | (z(c, 14) === 45 ? 'inline-' : '') +
469 | 'box$3' +
470 | '$1' +
471 | a +
472 | '$2$3' +
473 | '$1' +
474 | e +
475 | '$2box$3',
476 | ) + c
477 | );
478 | }
479 | break;
480 | case 5936:
481 | switch (z(c, n + 11)) {
482 | case 114:
483 | return a + c + e + y(c, /[svh]\w+-[tblr]{2}/, 'tb') + c;
484 | case 108:
485 | return a + c + e + y(c, /[svh]\w+-[tblr]{2}/, 'tb-rl') + c;
486 | case 45:
487 | return a + c + e + y(c, /[svh]\w+-[tblr]{2}/, 'lr') + c;
488 | }
489 | return a + c + e + c + c;
490 | }
491 | return c;
492 | }
493 | function ie(e, r) {
494 | var a = '';
495 | var c = M(e);
496 | for (var n = 0; n < c; n++) a += r(e[n], n, e, r) || '';
497 | return a;
498 | }
499 | function fe(e, r, a, s) {
500 | switch (e.type) {
501 | case i:
502 | case t:
503 | return (e.return = e.return || e.value);
504 | case c:
505 | return '';
506 | case n:
507 | e.value = e.props.join(',');
508 | }
509 | return A((a = ie(e.children, s))) ? (e.return = e.value + '{' + a + '}') : '';
510 | }
511 | function oe(e) {
512 | var r = M(e);
513 | return function (a, c, n, t) {
514 | var s = '';
515 | for (var u = 0; u < r; u++) s += e[u](a, c, n, t) || '';
516 | return s;
517 | };
518 | }
519 | function le(e) {
520 | return function (r) {
521 | if (!r.root) if ((r = r.return)) e(r);
522 | };
523 | }
524 | function ve(c, s, u, i) {
525 | if (!c.return)
526 | switch (c.type) {
527 | case t:
528 | c.return = ue(c.value, c.length);
529 | break;
530 | case p:
531 | return ie([I(y(c.value, '@', '@' + a), c, '')], i);
532 | case n:
533 | if (c.length)
534 | return S(c.props, function (n) {
535 | switch (x(n, /(::plac\w+|:read-\w+)/)) {
536 | case ':read-only':
537 | case ':read-write':
538 | return ie([I(y(n, /:(read-\w+)/, ':' + r + '$1'), c, '')], i);
539 | case '::placeholder':
540 | return ie(
541 | [
542 | I(y(n, /:(plac\w+)/, ':' + a + 'input-$1'), c, ''),
543 | I(y(n, /:(plac\w+)/, ':' + r + '$1'), c, ''),
544 | I(y(n, /:(plac\w+)/, e + 'input-$1'), c, ''),
545 | ],
546 | i,
547 | );
548 | }
549 | return '';
550 | });
551 | }
552 | }
553 | function he(e) {
554 | switch (e.type) {
555 | case n:
556 | e.props = e.props.map(function (r) {
557 | return S(W(r), function (r, a, c) {
558 | switch (z(r, 0)) {
559 | case 12:
560 | return C(r, 1, A(r));
561 | case 0:
562 | case 40:
563 | case 43:
564 | case 62:
565 | case 126:
566 | return r;
567 | case 58:
568 | if (c[++a] === 'global')
569 | (c[a] = ''), (c[++a] = '\f' + C(c[a], (a = 1), -1));
570 | case 32:
571 | return a === 1 ? '' : r;
572 | default:
573 | switch (a) {
574 | case 0:
575 | e = r;
576 | return M(c) > 1 ? '' : r;
577 | case (a = M(c) - 1):
578 | case 2:
579 | return a === 2 ? r + e + e : r + e;
580 | default:
581 | return r;
582 | }
583 | }
584 | });
585 | });
586 | }
587 | }
588 | export {
589 | f as CHARSET,
590 | c as COMMENT,
591 | w as COUNTER_STYLE,
592 | t as DECLARATION,
593 | v as DOCUMENT,
594 | b as FONT_FACE,
595 | $ as FONT_FEATURE_VALUES,
596 | i as IMPORT,
597 | p as KEYFRAMES,
598 | u as MEDIA,
599 | r as MOZ,
600 | e as MS,
601 | h as NAMESPACE,
602 | s as PAGE,
603 | n as RULESET,
604 | l as SUPPORTS,
605 | o as VIEWPORT,
606 | a as WEBKIT,
607 | k as abs,
608 | T as alloc,
609 | O as append,
610 | P as caret,
611 | J as char,
612 | F as character,
613 | G as characters,
614 | z as charat,
615 | B as column,
616 | S as combine,
617 | te as comment,
618 | ee as commenter,
619 | ae as compile,
620 | I as copy,
621 | U as dealloc,
622 | se as declaration,
623 | V as delimit,
624 | _ as delimiter,
625 | Z as escaping,
626 | d as from,
627 | m as hash,
628 | re as identifier,
629 | j as indexof,
630 | D as length,
631 | q as line,
632 | x as match,
633 | oe as middleware,
634 | he as namespace,
635 | L as next,
636 | H as node,
637 | ce as parse,
638 | N as peek,
639 | E as position,
640 | ue as prefix,
641 | ve as prefixer,
642 | K as prev,
643 | y as replace,
644 | ne as ruleset,
645 | le as rulesheet,
646 | ie as serialize,
647 | M as sizeof,
648 | Q as slice,
649 | fe as stringify,
650 | A as strlen,
651 | C as substr,
652 | R as token,
653 | W as tokenize,
654 | Y as tokenizer,
655 | g as trim,
656 | X as whitespace,
657 | };
658 | //# sourceMappingURL=stylis.mjs.map
659 |
--------------------------------------------------------------------------------
/babel-plugin.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/no-extraneous-dependencies, sonarjs/cognitive-complexity, no-bitwise */
2 | const postcss = require('postcss');
3 | const autoprefixer = require('autoprefixer');
4 | const nested = require('postcss-nested');
5 | const csso = require('csso');
6 |
7 | module.exports = function (babel, options = {}) {
8 | const { types: t } = babel;
9 | const {
10 | debug = false,
11 | allowedModules = ['foliage', 'foliage-react'],
12 | allowedMethods = ['css', 'keyframes', 'createGlobalStyle'],
13 | prefix,
14 | } = options;
15 |
16 | const nameCreate = debug
17 | ? (sid, name) => [prefix, sid, name].filter(Boolean).join('-')
18 | : (sid) => [prefix, sid].filter(Boolean).join('-');
19 |
20 | const markerRegexp = new RegExp(interpolationMark('\\d+'), 'gm');
21 | const varMarkerRegexp = new RegExp(
22 | `var\\(\\s*${interpolationMark('\\d+')}`,
23 | 'gm',
24 | );
25 |
26 | const compiler = postcss([autoprefixer(), nested()]);
27 |
28 | function compile(source, file = 'source.css') {
29 | const ast = postcss.parse(source);
30 | const derivedInterpolations = {};
31 |
32 | function addInterpolation(list, type) {
33 | list.forEach((name) => {
34 | if (!derivedInterpolations[name]) derivedInterpolations[name] = type;
35 | });
36 | }
37 |
38 | ast.walk((node) => {
39 | switch (node.type) {
40 | // Detect if interpolation found in selector
41 | case 'rule': {
42 | const found = node.selector.match(markerRegexp);
43 | if (found) addInterpolation(found, 'selector');
44 | break;
45 | }
46 |
47 | // Detect when interpolation is used inside css properties or values
48 | case 'decl': {
49 | // Interpolation found in property declaration
50 | // Maybe it is custom property declaration
51 | const foundProp = node.prop.match(markerRegexp);
52 | if (foundProp) addInterpolation(foundProp, 'custom-property'); // user wants to set custom property value
53 |
54 | // When interpolation is used inside var(), we need not to match it below
55 | // Here we need to remove entire interpolation from content to mark, that it is already processed
56 | let content = node.value;
57 | const foundVars = content.match(varMarkerRegexp);
58 | if (foundVars) {
59 | // Found var() with interpolation
60 | foundVars.forEach((cssVar) => {
61 | // We need to find actual interpolation name to mark it as var
62 | const name = cssVar.match(markerRegexp);
63 | if (name) addInterpolation(name, 'var');
64 | // Remove `var(interpolation` from processing content, to mark it as already processed
65 | content = content.replace(cssVar, '');
66 | });
67 | }
68 |
69 | // Search for another interpolations
70 | const foundValues = content.match(markerRegexp);
71 | if (foundValues) {
72 | // If interpolation is used for animation, we know that it is a keyframe block
73 | if (node.prop === 'animation') {
74 | addInterpolation(foundValues, 'keyframe');
75 | } else {
76 | // Another types of interpolation is not supported yet
77 | addInterpolation(foundValues, 'INVALID');
78 | }
79 | }
80 |
81 | break;
82 | }
83 |
84 | default: /* noop */
85 | }
86 | });
87 |
88 | const result = compiler.process(ast, { from: file });
89 | const compiled = result.css;
90 | return {
91 | css: csso.minify(compiled).css,
92 | interpolations: derivedInterpolations,
93 | };
94 | }
95 |
96 | return {
97 | name: 'foliage/babel-plugin',
98 | visitor: {
99 | TaggedTemplateExpression(path, state) {
100 | resolveImport(
101 | t,
102 | path,
103 | ({ methodName, moduleName, module, namespace }) => {
104 | // Check that template tag imported from allowed module
105 | // And method supports for compilation
106 | if (
107 | allowedModules.includes(moduleName) &&
108 | allowedMethods.includes(methodName)
109 | ) {
110 | // Create stable unique id with readable name
111 | const derivedName = determineName(t, path);
112 | const sid = generateStableID(
113 | state.file.opts.root,
114 | state.filename,
115 | derivedName,
116 | path.node.loc.start.line,
117 | path.node.loc.start.column,
118 | );
119 | const fullName = nameCreate(sid, derivedName);
120 |
121 | // Content of compiled css (can be template literal or string literal)
122 | let content = null;
123 |
124 | // Process only tagged literals without interpolations
125 | if (path.node.quasi.quasis.length === 1) {
126 | const source = path.node.quasi.quasis[0].value.raw;
127 | const wrapped = createContainer(source, methodName, fullName);
128 | const { css } = compile(wrapped);
129 | content = t.stringLiteral(css);
130 | } else {
131 | // Tagged template literal with interpolation expressions
132 | const { quasis, expressions } = path.node.quasi;
133 | const firstQuasisSource = quasis[0].value.cooked;
134 |
135 | const draftCssSource = [firstQuasisSource];
136 |
137 | // Create interpolation marker for each expression
138 | // Markers would be in css in order not to brake
139 | expressions.forEach((_, index) => {
140 | draftCssSource.push(interpolationMark(index));
141 | draftCssSource.push(quasis[index + 1].value.cooked);
142 | });
143 | const source = draftCssSource.join('');
144 |
145 | // Source wrapped with .class {} or @keyframes name {}, etc.
146 | const wrapped = createContainer(source, methodName, fullName);
147 | const { css, interpolations: interpolationTypes } =
148 | compile(wrapped);
149 |
150 | // After compilation, we need to detect each marker and split string back
151 | // But after compilation marker may be duplicated, ex.: @keyframes autoprefixing as @-webkit-keyframes
152 | let chunks = [css];
153 |
154 | // Will be passed to AST as is
155 | const interpolationNodes = [];
156 |
157 | expressions.forEach((nodeOriginal, index) => {
158 | const currentMarker = interpolationMark(index);
159 | const splatQuasis = [];
160 |
161 | // iterate over each quasis
162 | chunks.forEach((chunk) => {
163 | // if it has interpolation, split it
164 | if (chunk.includes(currentMarker)) {
165 | chunk
166 | .split(currentMarker)
167 | .forEach((part, index, list) => {
168 | const isLatest = index === list.length - 1;
169 |
170 | splatQuasis.push(part);
171 |
172 | // poscss compiler returned type for each interpolation
173 | // get interpolation type for current marker
174 | const interpolationType =
175 | interpolationTypes[currentMarker];
176 |
177 | // What kind of assertion is required for interpolation type
178 | const assertMethodName =
179 | wrapperMethod[interpolationType];
180 |
181 | const node = t.cloneNode(nodeOriginal);
182 |
183 | const wrappedNode = namespace
184 | ? wrapNamespaceInterpolation(
185 | t,
186 | namespace,
187 | assertMethodName,
188 | node,
189 | )
190 | : wrapInterpolation(
191 | t,
192 | interpolationType,
193 | addSpecifier(t, module, assertMethodName),
194 | node,
195 | );
196 |
197 | // Add expression only after not last
198 | if (!isLatest) interpolationNodes.push(wrappedNode);
199 | });
200 | } else {
201 | // if no interpolation in chunk
202 | splatQuasis.push(chunk);
203 | }
204 | });
205 | chunks = splatQuasis;
206 | });
207 |
208 | const templateElements = chunks.map((item, index, list) => {
209 | const tail = index === list.length - 1;
210 | return t.templateElement({ raw: item, cooked: item }, tail);
211 | });
212 |
213 | content = t.templateLiteral(
214 | templateElements,
215 | interpolationNodes,
216 | );
217 | }
218 | // { content: 'compiled css', [methodType]: 'hashed-name' }
219 | path.replaceWith(
220 | t.objectExpression([
221 | t.objectProperty(
222 | t.identifier('content'),
223 | t.cloneNode(content),
224 | ),
225 | t.objectProperty(
226 | t.identifier(methodName),
227 | t.stringLiteral(fullName),
228 | ),
229 | ]),
230 | );
231 | }
232 | },
233 | );
234 | },
235 | },
236 | };
237 | };
238 |
239 | const interpolationMark = (index) => `foliageInterpolationIndex${index}`;
240 |
241 | /**
242 | * Add import specifier to exist import declaration
243 | * Rename local binding name and return it
244 | */
245 | function addSpecifier(t, module, specifierName) {
246 | const alreadyImported = module.node.specifiers.find(
247 | (specifier) => specifier.imported.name === specifierName,
248 | );
249 | if (alreadyImported) return alreadyImported.local.name;
250 |
251 | const program = module.find((path) => path.isProgram());
252 |
253 | // Add named import to declaration
254 | module.node.specifiers.push(
255 | t.importSpecifier(
256 | module.scope.generateUidIdentifier(specifierName),
257 | t.identifier(specifierName),
258 | ),
259 | );
260 |
261 | // Resolve actual specifier with bound references
262 | let foundSpecifier;
263 |
264 | module.get('specifiers').forEach((specifier) => {
265 | if (specifier.node.imported.name === specifierName) {
266 | foundSpecifier = specifier;
267 | }
268 | // it is required to bind local import specifier with references in another code
269 | });
270 |
271 | program.scope.registerBinding('module', foundSpecifier);
272 |
273 | // Rename local name, to solve potential conflicts with already declared names
274 | // program.scope.rename(specifierName);
275 |
276 | return foundSpecifier.node.local.name;
277 | }
278 |
279 | const wrapperMethod = {
280 | selector: 'assertSelector',
281 | var: 'assertVariable',
282 | 'custom-property': 'assertVariable',
283 | keyframe: 'assertKeyframe',
284 | INVALID: 'assertInvalid',
285 | };
286 |
287 | function wrapNamespaceInterpolation(t, source, specifier, node) {
288 | return t.callExpression(
289 | t.memberExpression(t.identifier(source), t.identifier(specifier)),
290 | [node],
291 | );
292 | }
293 |
294 | function wrapInterpolation(t, type, specifier, node) {
295 | if (specifier) {
296 | return t.callExpression(t.identifier(specifier), [node]);
297 | }
298 |
299 | throw new TypeError(
300 | `Invalid interpolation type "${type}". Please, report an issue at https://github.com/effector/foliage/issues`,
301 | );
302 | }
303 |
304 | /**
305 | * CSS block should be wrapped with class name
306 | * Keyframes should have name and @keyframes
307 | * Global styles should be just compiled, no wrapper are required
308 | */
309 | function createContainer(source, type, fullName) {
310 | if (type === 'css') {
311 | return `.${fullName}{${source}}`;
312 | }
313 | if (type === 'keyframes') {
314 | return `@keyframes ${fullName}{${source}}`;
315 | }
316 | if (type === 'createGlobalStyle') {
317 | return source;
318 | }
319 | throw new TypeError(
320 | `Unsupported node type "${type}" detected on "${fullName}" with source "${source}"`,
321 | );
322 | }
323 |
324 | /**
325 | * Find import for passed path
326 | * Path should be TaggedTemplateExpression
327 | * @param {(p: { methodName: string, moduleName: string, module: Path, namespace: string | null }) => void} fn
328 | */
329 | function resolveImport(t, path, fn) {
330 | const programPath = path.find((path) => path.isProgram());
331 | if (!t.isTaggedTemplateExpression(path)) {
332 | throw new TypeError(
333 | `resolveImport called on unsupported type "${path.type}". It is should be "TaggedTemplateExpression"`,
334 | );
335 | }
336 |
337 | // Check that tag.object is a `* as import from 'foliage'`
338 | // foliage.css``
339 | if (
340 | t.isMemberExpression(path.node.tag) &&
341 | t.isIdentifier(path.node.tag.object) &&
342 | t.isIdentifier(path.node.tag.property)
343 | ) {
344 | const objectName = path.node.tag.object.name;
345 | const methodName = path.node.tag.property.name;
346 | const binding = path.scope.getOwnBinding(objectName);
347 | if (binding) {
348 | const resolved = resolveNamespaceImport(t, binding);
349 | if (resolved) {
350 | const moduleName = resolved.module.node.source.value;
351 | return fn({
352 | moduleName,
353 | methodName,
354 | module: resolved.module,
355 | namespace: objectName,
356 | });
357 | }
358 | }
359 | }
360 |
361 | // css``
362 | if (t.isIdentifier(path.node.tag)) {
363 | const localMethodName = path.node.tag.name;
364 | const binding = programPath.scope.getOwnBinding(localMethodName);
365 | if (binding) {
366 | const resolved = resolveSpecifierImport(t, binding);
367 | if (resolved) {
368 | const { methodName, module } = resolved;
369 | const moduleName = module.node.source.value;
370 | fn({ methodName, moduleName, module, namespace: null });
371 | }
372 | }
373 | }
374 | }
375 |
376 | /**
377 | * Find import declaration for binding and resolve original name
378 | * For example we have next two lines:
379 | * import { foo as bar } from 'module';
380 | * const demo = bar``
381 | *
382 | * This function allows to resolve `foo` from `bar` usage
383 | * with import declaration
384 | */
385 | function resolveSpecifierImport(t, binding) {
386 | const local = binding.identifier;
387 | const module = binding.path.find((path) => path.isImportDeclaration());
388 |
389 | if (!module) return null;
390 |
391 | const specifier = module.node.specifiers
392 | .filter((node) => t.isImportSpecifier(node))
393 | .find((node) => node.local.name === local.name);
394 |
395 | if (!specifier) return null;
396 |
397 | return { methodName: specifier.imported.name, module };
398 | }
399 |
400 | function resolveNamespaceImport(t, binding) {
401 | const module = binding.path.find((path) => path.isImportDeclaration());
402 | if (!module) return null;
403 |
404 | const specifier = module.node.specifiers.find((node) =>
405 | t.isImportNamespaceSpecifier(node),
406 | );
407 | if (!specifier) return null;
408 |
409 | return { module, specifier };
410 | }
411 |
412 | function determineName(t, path) {
413 | // TODO: detect when css`` is nested to variants and add simple name `variant-value` without `variants` prefix
414 | // TODO: detect when css`` is nested to compound and add name `variant1-value1--variant2-value2`
415 | if (t.isIdentifier(path)) {
416 | return path.name;
417 | }
418 | if (t.isLiteral(path)) {
419 | return String(path.value);
420 | }
421 | if (t.isVariableDeclarator(path.parent) && t.isIdentifier(path.parent.id)) {
422 | return path.parent.id.name;
423 | }
424 | if (t.isObjectExpression(path.parent) || t.isCallExpression(path.parent)) {
425 | return determineName(t, path.parentPath);
426 | }
427 | if (t.isObjectProperty(path.parent)) {
428 | const local = determineName(t, path.parent.key);
429 | const determined = determineName(t, path.parentPath);
430 | if (local && determined) {
431 | return `${determined}-${local}`;
432 | }
433 | if (local) {
434 | return local;
435 | }
436 | }
437 | return '';
438 | }
439 |
440 | function generateStableID(babelRoot, fileName, varName, line, column) {
441 | const normalizedPath = stripRoot(babelRoot, fileName, false);
442 | const hash = hashCode(`${varName} ${normalizedPath} [${line}, ${column}]`);
443 | return `f${hash}`;
444 | }
445 |
446 | function stripRoot(babelRoot, fileName, omitFirstSlash) {
447 | const { sep, normalize } = require('path');
448 | const rawPath = fileName.replace(babelRoot, '');
449 | let normalizedSeq = normalize(rawPath).split(sep);
450 | if (omitFirstSlash && normalizedSeq.length > 0 && normalizedSeq[0] === '') {
451 | normalizedSeq = normalizedSeq.slice(1);
452 | }
453 | return normalizedSeq.join('/');
454 | }
455 |
456 | function hashCode(s) {
457 | let h = 0;
458 | let i = 0;
459 | if (s.length > 0)
460 | while (i < s.length) h = ((h << 5) - h + s.charCodeAt(i++)) | 0;
461 | return h.toString(36);
462 | }
463 |
--------------------------------------------------------------------------------
/src/stylis/built/umd/stylis.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | (function (e, r) {
3 | typeof exports === 'object' && typeof module !== 'undefined'
4 | ? r(exports)
5 | : typeof define === 'function' && define.amd
6 | ? define(['exports'], r)
7 | : ((e = e || self), r((e.stylis = {})));
8 | })(this, function (e) {
9 | 'use strict';
10 | var r = '-ms-';
11 | var a = '-moz-';
12 | var c = '-webkit-';
13 | var t = 'comm';
14 | var n = 'rule';
15 | var s = 'decl';
16 | var i = '@page';
17 | var u = '@media';
18 | var o = '@import';
19 | var f = '@charset';
20 | var l = '@viewport';
21 | var h = '@supports';
22 | var p = '@document';
23 | var v = '@namespace';
24 | var b = '@keyframes';
25 | var m = '@font-face';
26 | var w = '@counter-style';
27 | var d = '@font-feature-values';
28 | var $ = Math.abs;
29 | var k = String.fromCharCode;
30 | function g(e, r) {
31 | return (
32 | (((((((r << 2) ^ A(e, 0)) << 2) ^ A(e, 1)) << 2) ^ A(e, 2)) << 2) ^
33 | A(e, 3)
34 | );
35 | }
36 | function x(e) {
37 | return e.trim();
38 | }
39 | function E(e, r) {
40 | return (e = r.exec(e)) ? e[0] : e;
41 | }
42 | function y(e, r, a) {
43 | return e.replace(r, a);
44 | }
45 | function T(e, r) {
46 | return e.indexOf(r);
47 | }
48 | function A(e, r) {
49 | return e.charCodeAt(r) | 0;
50 | }
51 | function O(e, r, a) {
52 | return e.slice(r, a);
53 | }
54 | function M(e) {
55 | return e.length;
56 | }
57 | function C(e) {
58 | return e.length;
59 | }
60 | function S(e, r) {
61 | return r.push(e), e;
62 | }
63 | function R(e, r) {
64 | return e.map(r).join('');
65 | }
66 | e.line = 1;
67 | e.column = 1;
68 | e.length = 0;
69 | e.position = 0;
70 | e.character = 0;
71 | e.characters = '';
72 | function z(r, a, c, t, n, s, i) {
73 | return {
74 | value: r,
75 | root: a,
76 | parent: c,
77 | type: t,
78 | props: n,
79 | children: s,
80 | line: e.line,
81 | column: e.column,
82 | length: i,
83 | return: '',
84 | };
85 | }
86 | function N(e, r, a) {
87 | return z(e, r.root, r.parent, a, r.props, r.children, 0);
88 | }
89 | function P() {
90 | return e.character;
91 | }
92 | function U() {
93 | e.character = e.position > 0 ? A(e.characters, --e.position) : 0;
94 | if ((e.column--, e.character === 10)) (e.column = 1), e.line--;
95 | return e.character;
96 | }
97 | function _() {
98 | e.character = e.position < e.length ? A(e.characters, e.position++) : 0;
99 | if ((e.column++, e.character === 10)) (e.column = 1), e.line++;
100 | return e.character;
101 | }
102 | function j() {
103 | return A(e.characters, e.position);
104 | }
105 | function F() {
106 | return e.position;
107 | }
108 | function I(r, a) {
109 | return O(e.characters, r, a);
110 | }
111 | function L(e) {
112 | switch (e) {
113 | case 0:
114 | case 9:
115 | case 10:
116 | case 13:
117 | case 32:
118 | return 5;
119 | case 33:
120 | case 43:
121 | case 44:
122 | case 47:
123 | case 62:
124 | case 64:
125 | case 126:
126 | case 59:
127 | case 123:
128 | case 125:
129 | return 4;
130 | case 58:
131 | return 3;
132 | case 34:
133 | case 39:
134 | case 40:
135 | case 91:
136 | return 2;
137 | case 41:
138 | case 93:
139 | return 1;
140 | }
141 | return 0;
142 | }
143 | function D(r) {
144 | return (
145 | (e.line = e.column = 1),
146 | (e.length = M((e.characters = r))),
147 | (e.position = 0),
148 | []
149 | );
150 | }
151 | function K(r) {
152 | return (e.characters = ''), r;
153 | }
154 | function V(r) {
155 | return x(I(e.position - 1, H(r === 91 ? r + 2 : r === 40 ? r + 1 : r)));
156 | }
157 | function W(e) {
158 | return K(B(D(e)));
159 | }
160 | function Y(r) {
161 | while ((e.character = j()))
162 | if (e.character < 33) _();
163 | else break;
164 | return L(r) > 2 || L(e.character) > 3 ? '' : ' ';
165 | }
166 | function B(r) {
167 | while (_())
168 | switch (L(e.character)) {
169 | case 0:
170 | S(q(e.position - 1), r);
171 | break;
172 | case 2:
173 | S(V(e.character), r);
174 | break;
175 | default:
176 | S(k(e.character), r);
177 | }
178 | return r;
179 | }
180 | function G(r, a) {
181 | while (--a && _())
182 | if (
183 | e.character < 48 ||
184 | e.character > 102 ||
185 | (e.character > 57 && e.character < 65) ||
186 | (e.character > 70 && e.character < 97)
187 | )
188 | break;
189 | return I(r, F() + (a < 6 && j() == 32 && _() == 32));
190 | }
191 | function H(r) {
192 | while (_())
193 | switch (e.character) {
194 | case r:
195 | return e.position;
196 | case 34:
197 | case 39:
198 | return H(r === 34 || r === 39 ? r : e.character);
199 | case 40:
200 | if (r === 41) H(r);
201 | break;
202 | case 92:
203 | _();
204 | break;
205 | }
206 | return e.position;
207 | }
208 | function Z(r, a) {
209 | while (_())
210 | if (r + e.character === 47 + 10) break;
211 | else if (r + e.character === 42 + 42 && j() === 47) break;
212 | return '/*' + I(a, e.position - 1) + '*' + k(r === 47 ? r : _());
213 | }
214 | function q(r) {
215 | while (!L(j())) _();
216 | return I(r, e.position);
217 | }
218 | function J(e) {
219 | return K(Q('', null, null, null, [''], (e = D(e)), 0, [0], e));
220 | }
221 | function Q(e, r, a, c, t, n, s, i, u) {
222 | var o = 0;
223 | var f = 0;
224 | var l = s;
225 | var h = 0;
226 | var p = 0;
227 | var v = 0;
228 | var b = 1;
229 | var m = 1;
230 | var w = 1;
231 | var d = 0;
232 | var $ = '';
233 | var g = t;
234 | var x = n;
235 | var E = c;
236 | var T = $;
237 | while (m)
238 | switch (((v = d), (d = _()))) {
239 | case 34:
240 | case 39:
241 | case 91:
242 | case 40:
243 | T += V(d);
244 | break;
245 | case 9:
246 | case 10:
247 | case 13:
248 | case 32:
249 | T += Y(v);
250 | break;
251 | case 92:
252 | T += G(F() - 1, 7);
253 | continue;
254 | case 47:
255 | switch (j()) {
256 | case 42:
257 | case 47:
258 | S(ee(Z(_(), F()), r, a), u);
259 | break;
260 | default:
261 | T += '/';
262 | }
263 | break;
264 | case 123 * b:
265 | i[o++] = M(T) * w;
266 | case 125 * b:
267 | case 59:
268 | case 0:
269 | switch (d) {
270 | case 0:
271 | case 125:
272 | m = 0;
273 | case 59 + f:
274 | if (p > 0 && M(T) - l)
275 | S(
276 | p > 32
277 | ? re(T + ';', c, a, l - 1)
278 | : re(y(T, ' ', '') + ';', c, a, l - 2),
279 | u,
280 | );
281 | break;
282 | case 59:
283 | T += ';';
284 | default:
285 | S((E = X(T, r, a, o, f, t, i, $, (g = []), (x = []), l)), n);
286 | if (d === 123)
287 | if (f === 0) Q(T, r, E, E, g, n, l, i, x);
288 | else
289 | switch (h) {
290 | case 100:
291 | case 109:
292 | case 115:
293 | Q(
294 | e,
295 | E,
296 | E,
297 | c && S(X(e, E, E, 0, 0, t, i, $, t, (g = []), l), x),
298 | t,
299 | x,
300 | l,
301 | i,
302 | c ? g : x,
303 | );
304 | break;
305 | default:
306 | Q(T, E, E, E, [''], x, l, i, x);
307 | }
308 | }
309 | (o = f = p = 0), (b = w = 1), ($ = T = ''), (l = s);
310 | break;
311 | case 58:
312 | (l = 1 + M(T)), (p = v);
313 | default:
314 | if (b < 1)
315 | if (d == 123) --b;
316 | else if (d == 125 && b++ == 0 && U() == 125) continue;
317 | switch (((T += k(d)), d * b)) {
318 | case 38:
319 | w = f > 0 ? 1 : ((T += '\f'), -1);
320 | break;
321 | case 44:
322 | (i[o++] = (M(T) - 1) * w), (w = 1);
323 | break;
324 | case 64:
325 | if (j() === 45) T += V(_());
326 | (h = j()), (f = M(($ = T += q(F())))), d++;
327 | break;
328 | case 45:
329 | if (v === 45 && M(T) == 2) b = 0;
330 | }
331 | }
332 | return n;
333 | }
334 | function X(e, r, a, c, t, s, i, u, o, f, l) {
335 | var h = t - 1;
336 | var p = t === 0 ? s : [''];
337 | var v = C(p);
338 | for (var b = 0, m = 0, w = 0; b < c; ++b)
339 | for (var d = 0, k = O(e, h + 1, (h = $((m = i[b])))), g = e; d < v; ++d)
340 | if ((g = x(m > 0 ? p[d] + ' ' + k : y(k, /&\f/g, p[d])))) o[w++] = g;
341 | return z(e, r, a, t === 0 ? n : u, o, f, l);
342 | }
343 | function ee(e, r, a) {
344 | return z(e, r, a, t, k(P()), O(e, 2, -2), 0);
345 | }
346 | function re(e, r, a, c) {
347 | return z(e, r, a, s, O(e, 0, c), O(e, c + 1, -1), c);
348 | }
349 | function ae(e, t) {
350 | switch (g(e, t)) {
351 | case 5103:
352 | return c + 'print-' + e + e;
353 | case 5737:
354 | case 4201:
355 | case 3177:
356 | case 3433:
357 | case 1641:
358 | case 4457:
359 | case 2921:
360 | case 5572:
361 | case 6356:
362 | case 5844:
363 | case 3191:
364 | case 6645:
365 | case 3005:
366 | case 6391:
367 | case 5879:
368 | case 5623:
369 | case 6135:
370 | case 4599:
371 | case 4855:
372 | case 4215:
373 | case 6389:
374 | case 5109:
375 | case 5365:
376 | case 5621:
377 | case 3829:
378 | return c + e + e;
379 | case 5349:
380 | case 4246:
381 | case 4810:
382 | case 6968:
383 | case 2756:
384 | return c + e + a + e + r + e + e;
385 | case 6828:
386 | case 4268:
387 | return c + e + r + e + e;
388 | case 6165:
389 | return c + e + r + 'flex-' + e + e;
390 | case 5187:
391 | return (
392 | c + e + y(e, /(\w+).+(:[^]+)/, c + 'box-$1$2' + r + 'flex-$1$2') + e
393 | );
394 | case 5443:
395 | return c + e + r + 'flex-item-' + y(e, /flex-|-self/, '') + e;
396 | case 4675:
397 | return (
398 | c +
399 | e +
400 | r +
401 | 'flex-line-pack' +
402 | y(e, /align-content|flex-|-self/, '') +
403 | e
404 | );
405 | case 5548:
406 | return c + e + r + y(e, 'shrink', 'negative') + e;
407 | case 5292:
408 | return c + e + r + y(e, 'basis', 'preferred-size') + e;
409 | case 6060:
410 | return (
411 | c +
412 | 'box-' +
413 | y(e, '-grow', '') +
414 | c +
415 | e +
416 | r +
417 | y(e, 'grow', 'positive') +
418 | e
419 | );
420 | case 4554:
421 | return c + y(e, /([^-])(transform)/g, '$1' + c + '$2') + e;
422 | case 6187:
423 | return (
424 | y(y(y(e, /(zoom-|grab)/, c + '$1'), /(image-set)/, c + '$1'), e, '') +
425 | e
426 | );
427 | case 5495:
428 | case 3959:
429 | return y(e, /(image-set\([^]*)/, c + '$1' + '$`$1');
430 | case 4968:
431 | return (
432 | y(
433 | y(e, /(.+:)(flex-)?(.*)/, c + 'box-pack:$3' + r + 'flex-pack:$3'),
434 | /s.+-b[^;]+/,
435 | 'justify',
436 | ) +
437 | c +
438 | e +
439 | e
440 | );
441 | case 4095:
442 | case 3583:
443 | case 4068:
444 | case 2532:
445 | return y(e, /(.+)-inline(.+)/, c + '$1$2') + e;
446 | case 8116:
447 | case 7059:
448 | case 5753:
449 | case 5535:
450 | case 5445:
451 | case 5701:
452 | case 4933:
453 | case 4677:
454 | case 5533:
455 | case 5789:
456 | case 5021:
457 | case 4765:
458 | if (M(e) - 1 - t > 6)
459 | switch (A(e, t + 1)) {
460 | case 109:
461 | if (A(e, t + 4) !== 45) break;
462 | case 102:
463 | return (
464 | y(
465 | e,
466 | /(.+:)(.+)-([^]+)/,
467 | '$1' +
468 | c +
469 | '$2-$3' +
470 | '$1' +
471 | a +
472 | (A(e, t + 3) == 108 ? '$3' : '$2-$3'),
473 | ) + e
474 | );
475 | case 115:
476 | return ~T(e, 'stretch')
477 | ? ae(y(e, 'stretch', 'fill-available'), t) + e
478 | : e;
479 | }
480 | break;
481 | case 4949:
482 | if (A(e, t + 1) !== 115) break;
483 | case 6444:
484 | switch (A(e, M(e) - 3 - (~T(e, '!important') && 10))) {
485 | case 107:
486 | return y(e, ':', ':' + c) + e;
487 | case 101:
488 | return (
489 | y(
490 | e,
491 | /(.+:)([^;!]+)(;|!.+)?/,
492 | '$1' +
493 | c +
494 | (A(e, 14) === 45 ? 'inline-' : '') +
495 | 'box$3' +
496 | '$1' +
497 | c +
498 | '$2$3' +
499 | '$1' +
500 | r +
501 | '$2box$3',
502 | ) + e
503 | );
504 | }
505 | break;
506 | case 5936:
507 | switch (A(e, t + 11)) {
508 | case 114:
509 | return c + e + r + y(e, /[svh]\w+-[tblr]{2}/, 'tb') + e;
510 | case 108:
511 | return c + e + r + y(e, /[svh]\w+-[tblr]{2}/, 'tb-rl') + e;
512 | case 45:
513 | return c + e + r + y(e, /[svh]\w+-[tblr]{2}/, 'lr') + e;
514 | }
515 | return c + e + r + e + e;
516 | }
517 | return e;
518 | }
519 | function ce(e, r) {
520 | var a = '';
521 | var c = C(e);
522 | for (var t = 0; t < c; t++) a += r(e[t], t, e, r) || '';
523 | return a;
524 | }
525 | function te(e, r, a, c) {
526 | switch (e.type) {
527 | case o:
528 | case s:
529 | return (e.return = e.return || e.value);
530 | case t:
531 | return '';
532 | case n:
533 | e.value = e.props.join(',');
534 | }
535 | return M((a = ce(e.children, c)))
536 | ? (e.return = e.value + '{' + a + '}')
537 | : '';
538 | }
539 | function ne(e) {
540 | var r = C(e);
541 | return function (a, c, t, n) {
542 | var s = '';
543 | for (var i = 0; i < r; i++) s += e[i](a, c, t, n) || '';
544 | return s;
545 | };
546 | }
547 | function se(e) {
548 | return function (r) {
549 | if (!r.root) if ((r = r.return)) e(r);
550 | };
551 | }
552 | function ie(e, t, i, u) {
553 | if (!e.return)
554 | switch (e.type) {
555 | case s:
556 | e.return = ae(e.value, e.length);
557 | break;
558 | case b:
559 | return ce([N(y(e.value, '@', '@' + c), e, '')], u);
560 | case n:
561 | if (e.length)
562 | return R(e.props, function (t) {
563 | switch (E(t, /(::plac\w+|:read-\w+)/)) {
564 | case ':read-only':
565 | case ':read-write':
566 | return ce([N(y(t, /:(read-\w+)/, ':' + a + '$1'), e, '')], u);
567 | case '::placeholder':
568 | return ce(
569 | [
570 | N(y(t, /:(plac\w+)/, ':' + c + 'input-$1'), e, ''),
571 | N(y(t, /:(plac\w+)/, ':' + a + '$1'), e, ''),
572 | N(y(t, /:(plac\w+)/, r + 'input-$1'), e, ''),
573 | ],
574 | u,
575 | );
576 | }
577 | return '';
578 | });
579 | }
580 | }
581 | function ue(e) {
582 | switch (e.type) {
583 | case n:
584 | e.props = e.props.map(function (r) {
585 | return R(W(r), function (r, a, c) {
586 | switch (A(r, 0)) {
587 | case 12:
588 | return O(r, 1, M(r));
589 | case 0:
590 | case 40:
591 | case 43:
592 | case 62:
593 | case 126:
594 | return r;
595 | case 58:
596 | if (c[++a] === 'global')
597 | (c[a] = ''), (c[++a] = '\f' + O(c[a], (a = 1), -1));
598 | case 32:
599 | return a === 1 ? '' : r;
600 | default:
601 | switch (a) {
602 | case 0:
603 | e = r;
604 | return C(c) > 1 ? '' : r;
605 | case (a = C(c) - 1):
606 | case 2:
607 | return a === 2 ? r + e + e : r + e;
608 | default:
609 | return r;
610 | }
611 | }
612 | });
613 | });
614 | }
615 | }
616 | e.CHARSET = f;
617 | e.COMMENT = t;
618 | e.COUNTER_STYLE = w;
619 | e.DECLARATION = s;
620 | e.DOCUMENT = p;
621 | e.FONT_FACE = m;
622 | e.FONT_FEATURE_VALUES = d;
623 | e.IMPORT = o;
624 | e.KEYFRAMES = b;
625 | e.MEDIA = u;
626 | e.MOZ = a;
627 | e.MS = r;
628 | e.NAMESPACE = v;
629 | e.PAGE = i;
630 | e.RULESET = n;
631 | e.SUPPORTS = h;
632 | e.VIEWPORT = l;
633 | e.WEBKIT = c;
634 | e.abs = $;
635 | e.alloc = D;
636 | e.append = S;
637 | e.caret = F;
638 | e.char = P;
639 | e.charat = A;
640 | e.combine = R;
641 | e.comment = ee;
642 | e.commenter = Z;
643 | e.compile = J;
644 | e.copy = N;
645 | e.dealloc = K;
646 | e.declaration = re;
647 | e.delimit = V;
648 | e.delimiter = H;
649 | e.escaping = G;
650 | e.from = k;
651 | e.hash = g;
652 | e.identifier = q;
653 | e.indexof = T;
654 | e.match = E;
655 | e.middleware = ne;
656 | e.namespace = ue;
657 | e.next = _;
658 | e.node = z;
659 | e.parse = Q;
660 | e.peek = j;
661 | e.prefix = ae;
662 | e.prefixer = ie;
663 | e.prev = U;
664 | e.replace = y;
665 | e.ruleset = X;
666 | e.rulesheet = se;
667 | e.serialize = ce;
668 | e.sizeof = C;
669 | e.slice = I;
670 | e.stringify = te;
671 | e.strlen = M;
672 | e.substr = O;
673 | e.token = L;
674 | e.tokenize = W;
675 | e.tokenizer = B;
676 | e.trim = x;
677 | e.whitespace = Y;
678 | Object.defineProperty(e, '__esModule', { value: true });
679 | });
680 | //# sourceMappingURL=stylis.js.map
681 |
--------------------------------------------------------------------------------
/__snapshots__/babel-plugin.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`foliage assertsDoNotConflictsWithExistsDeclarations: assertsDoNotConflictsWithExistsDeclarations 1`] = `
4 |
5 | import { css, keyframes } from 'foliage'
6 |
7 | function _assertKeyframe() {}
8 | const _assertVariable = 1;
9 | const _assertSelector = () => {};
10 | function assertKeyframe() {}
11 |
12 | const size = '--demo-size';
13 | const speed = '--demo-anim-speed';
14 |
15 | const anim = keyframes\`
16 | from { opacity: 0 };
17 | to: { opacity: 1 };
18 | \`;
19 |
20 | const first = css\`
21 | color: black;
22 | font-size: var(\${size});
23 | animation: var(\${speed}) infinite linear \${anim};
24 | \`;
25 |
26 | ↓ ↓ ↓ ↓ ↓ ↓
27 |
28 | import {
29 | css,
30 | keyframes,
31 | assertVariable as _assertVariable2,
32 | assertKeyframe as _assertKeyframe2,
33 | } from 'foliage';
34 |
35 | function _assertKeyframe() {}
36 |
37 | const _assertVariable = 1;
38 |
39 | const _assertSelector = () => {};
40 |
41 | function assertKeyframe() {}
42 |
43 | const size = '--demo-size';
44 | const speed = '--demo-anim-speed';
45 | const anim = {
46 | content:
47 | '@-webkit-keyframes f-vcmc2f-anim{0%{opacity:0}}@keyframes f-vcmc2f-anim{0%{opacity:0}}',
48 | keyframes: 'f-vcmc2f-anim',
49 | };
50 | const first = {
51 | content: \`.f-k1pbks-first{color:#000;font-size:var(\${_assertVariable2(
52 | size,
53 | )});-webkit-animation:var(\${_assertVariable2(
54 | speed,
55 | )}) infinite linear \${_assertVariable2(
56 | speed,
57 | )};animation:var(\${_assertKeyframe2(
58 | anim,
59 | )}) infinite linear \${_assertKeyframe2(anim)}}\`,
60 | css: 'f-k1pbks-first',
61 | };
62 |
63 |
64 | `;
65 |
66 | exports[`foliage combination: combination 1`] = `
67 |
68 | import { css } from 'foliage'
69 | import * as f from 'foliage'
70 |
71 | const theme = {
72 | size: {
73 | normal: '--demo-size-normal',
74 | }
75 | }
76 |
77 | const first = css\`
78 | display: block;
79 | \${theme.size.normal}: 12px;
80 | \`
81 |
82 | const pulse = f.keyframes\`
83 | 0% { opacity: 1 }
84 | 50% { opacity: 0.2 }
85 | 100% { opacity: 1 }
86 | \`
87 |
88 | const second = f.css\`
89 | font-size: var(\${theme.size.normal});
90 | animation: 1s ease-in-out infinite \${pulse};
91 |
92 | \${first} & {
93 | display: flex;
94 | }
95 | \`
96 |
97 | ↓ ↓ ↓ ↓ ↓ ↓
98 |
99 | import { css, assertVariable as _assertVariable } from 'foliage';
100 | import * as f from 'foliage';
101 | const theme = {
102 | size: {
103 | normal: '--demo-size-normal',
104 | },
105 | };
106 | const first = {
107 | content: \`.f-mvz1xy-first{display:block;\${_assertVariable(
108 | theme.size.normal,
109 | )}:12px}\`,
110 | css: 'f-mvz1xy-first',
111 | };
112 | const pulse = {
113 | content:
114 | '@-webkit-keyframes f-o40sxw-pulse{0%,to{opacity:1}50%{opacity:.2}}@keyframes f-o40sxw-pulse{0%,to{opacity:1}50%{opacity:.2}}',
115 | keyframes: 'f-o40sxw-pulse',
116 | };
117 | const second = {
118 | content: \`.fc3a8th-second{font-size:var(\${f.assertVariable(
119 | theme.size.normal,
120 | )});-webkit-animation:1s ease-in-out infinite \${f.assertKeyframe(
121 | pulse,
122 | )};animation:1s ease-in-out infinite \${f.assertKeyframe(
123 | pulse,
124 | )}}\${f.assertSelector(first)} .fc3a8th-second{display:flex}\`,
125 | css: 'fc3a8th-second',
126 | };
127 |
128 |
129 | `;
130 |
131 | exports[`foliage componentWithVariantsDeclaration: componentWithVariantsDeclaration 1`] = `
132 |
133 | import { css, component } from 'foliage-react';
134 |
135 | const size = '--ui-size';
136 |
137 | const chip = css\`
138 | color: white;
139 | background-color: black;
140 | border-radius: 4px;
141 | padding: var(\${size});
142 | \`
143 |
144 | export const Chip = component('div', [chip], {
145 | defaults: { size: 'normal' },
146 | variants: {
147 | size: {
148 | small: css\` \${size}: 6px; \`,
149 | normal: css\` \${size}: 8px; \`,
150 | large: css\` \${size}: 12px; \`,
151 | }
152 | }
153 | })
154 |
155 | ↓ ↓ ↓ ↓ ↓ ↓
156 |
157 | import {
158 | css,
159 | component,
160 | assertVariable as _assertVariable,
161 | } from 'foliage-react';
162 | const size = '--ui-size';
163 | const chip = {
164 | content: \`.f-d0u6l1-chip{color:#fff;background-color:#000;border-radius:4px;padding:var(\${_assertVariable(
165 | size,
166 | )})}\`,
167 | css: 'f-d0u6l1-chip',
168 | };
169 | export const Chip = component('div', [chip], {
170 | defaults: {
171 | size: 'normal',
172 | },
173 | variants: {
174 | size: {
175 | small: {
176 | content: \`.f-h2aov8-Chip-variants-size-small{\${_assertVariable(
177 | size,
178 | )}:6px}\`,
179 | css: 'f-h2aov8-Chip-variants-size-small',
180 | },
181 | normal: {
182 | content: \`.fz7zr1a-Chip-variants-size-normal{\${_assertVariable(
183 | size,
184 | )}:8px}\`,
185 | css: 'fz7zr1a-Chip-variants-size-normal',
186 | },
187 | large: {
188 | content: \`.f-osz4ka-Chip-variants-size-large{\${_assertVariable(
189 | size,
190 | )}:12px}\`,
191 | css: 'f-osz4ka-Chip-variants-size-large',
192 | },
193 | },
194 | },
195 | });
196 |
197 |
198 | `;
199 |
200 | exports[`foliage cssImportedFromLocal: cssImportedFromLocal 1`] = `
201 |
202 | import {css} from '../react'; const demo = css\`.global & { [data-demo="a"] {color: black} }\`
203 |
204 | ↓ ↓ ↓ ↓ ↓ ↓
205 |
206 | import { css } from '../react';
207 | const demo = {
208 | content: '.global .f-se2apj [data-demo=a]{color:#000}',
209 | css: 'f-se2apj',
210 | };
211 |
212 |
213 | `;
214 |
215 | exports[`foliage cssImportedFromPackage: cssImportedFromPackage 1`] = `
216 |
217 | import {css} from 'foliage'; const example = css\`color: black\`
218 |
219 | ↓ ↓ ↓ ↓ ↓ ↓
220 |
221 | import { css } from 'foliage';
222 | const example = {
223 | content: '.f1lijm6-example{color:#000}',
224 | css: 'f1lijm6-example',
225 | };
226 |
227 |
228 | `;
229 |
230 | exports[`foliage cssImportedFromReact: cssImportedFromReact 1`] = `
231 |
232 | import {css} from 'foliage-react'; const demo = css\`.global & { [data-demo="a"] {color: black} }\`
233 |
234 | ↓ ↓ ↓ ↓ ↓ ↓
235 |
236 | import { css } from 'foliage-react';
237 | const demo = {
238 | content: '.global .f-se2al8-demo [data-demo=a]{color:#000}',
239 | css: 'f-se2al8-demo',
240 | };
241 |
242 |
243 | `;
244 |
245 | exports[`foliage cssInterpolationInCss: cssInterpolationInCss 1`] = `
246 |
247 | import { css } from 'foliage';
248 | const first = css\`
249 | color: black;
250 | & > * { padding-left: 1rem; }
251 | \`
252 | const second = css\`
253 | color: red;
254 | & \${first} {
255 | color: white;
256 | }
257 | \`
258 |
259 | ↓ ↓ ↓ ↓ ↓ ↓
260 |
261 | import { css, assertSelector as _assertSelector } from 'foliage';
262 | const first = {
263 | content: '.f-gdcl67-first{color:#000}.f-gdcl67-first>*{padding-left:1rem}',
264 | css: 'f-gdcl67-first',
265 | };
266 | const second = {
267 | content: \`.f-if491s-second{color:red}.f-if491s-second \${_assertSelector(
268 | first,
269 | )}{color:#fff}\`,
270 | css: 'f-if491s-second',
271 | };
272 |
273 |
274 | `;
275 |
276 | exports[`foliage cssRenamedFromPackage: cssRenamedFromPackage 1`] = `
277 |
278 | import {css as demo} from 'foliage'; const example = demo\`justify-content: center;\`
279 |
280 | ↓ ↓ ↓ ↓ ↓ ↓
281 |
282 | import { css as demo } from 'foliage';
283 | const example = {
284 | content: '.f1likb5-example{justify-content:center}',
285 | css: 'f1likb5-example',
286 | };
287 |
288 |
289 | `;
290 |
291 | exports[`foliage deepNestingDeterminesName: deepNestingDeterminesName 1`] = `
292 |
293 | import { css } from 'foliage';
294 | const first = {
295 | second: {
296 | third: css\` color: black \`,
297 | fifth: {
298 | sixth: css\`color:white;\`
299 | },
300 | },
301 | fourth: css\`color:red\`
302 | }
303 |
304 | ↓ ↓ ↓ ↓ ↓ ↓
305 |
306 | import { css } from 'foliage';
307 | const first = {
308 | second: {
309 | third: {
310 | content: '.fq8i00d-first-second-third{color:#000}',
311 | css: 'fq8i00d-first-second-third',
312 | },
313 | fifth: {
314 | sixth: {
315 | content: '.f5yqwwy-first-second-fifth-sixth{color:#fff}',
316 | css: 'f5yqwwy-first-second-fifth-sixth',
317 | },
318 | },
319 | },
320 | fourth: {
321 | content: '.fuv4pzp-first-fourth{color:red}',
322 | css: 'fuv4pzp-first-fourth',
323 | },
324 | };
325 |
326 |
327 | `;
328 |
329 | exports[`foliage doNotCompilesThirdParty: doNotCompilesThirdParty 1`] = `
330 |
331 | import { css, keyframes, createGlobalStyle } from 'styled-components';
332 | const part = css\`color:black;\`
333 | const anim = keyframes\`from{color: black;} to {color: white;}\`
334 | const glob = createGlobalStyle\`body{display: grid}\`
335 |
336 | ↓ ↓ ↓ ↓ ↓ ↓
337 |
338 | import { css, keyframes, createGlobalStyle } from 'styled-components';
339 | const part = css\`
340 | color: black;
341 | \`;
342 | const anim = keyframes\`from{color: black;} to {color: white;}\`;
343 | const glob = createGlobalStyle\`body{display: grid}\`;
344 |
345 |
346 | `;
347 |
348 | exports[`foliage fullInterpolationExample: fullInterpolationExample 1`] = `
349 |
350 | import { css, keyframes } from 'foliage';
351 |
352 | const theme = {
353 | size: {
354 | normal: '--demo-size-normal',
355 | }
356 | }
357 |
358 | const first = css\`
359 | display: block;
360 | \`
361 |
362 | const pulse = keyframes\`
363 | 0% { opacity: 1 }
364 | 50% { opacity: 0.2 }
365 | 100% { opacity: 1 }
366 | \`
367 |
368 | const second = css\`
369 | font-size: var(\${theme.size.normal});
370 | animation: 1s ease-in-out infinite \${pulse};
371 |
372 | \${first} & {
373 | display: flex;
374 | }
375 | \`
376 |
377 | ↓ ↓ ↓ ↓ ↓ ↓
378 |
379 | import {
380 | css,
381 | keyframes,
382 | assertVariable as _assertVariable,
383 | assertKeyframe as _assertKeyframe,
384 | assertSelector as _assertSelector,
385 | } from 'foliage';
386 | const theme = {
387 | size: {
388 | normal: '--demo-size-normal',
389 | },
390 | };
391 | const first = {
392 | content: '.f-d218eu-first{display:block}',
393 | css: 'f-d218eu-first',
394 | };
395 | const pulse = {
396 | content:
397 | '@-webkit-keyframes f-p241qa-pulse{0%,to{opacity:1}50%{opacity:.2}}@keyframes f-p241qa-pulse{0%,to{opacity:1}50%{opacity:.2}}',
398 | keyframes: 'f-p241qa-pulse',
399 | };
400 | const second = {
401 | content: \`.f178xr0-second{font-size:var(\${_assertVariable(
402 | theme.size.normal,
403 | )});-webkit-animation:1s ease-in-out infinite \${_assertKeyframe(
404 | pulse,
405 | )};animation:1s ease-in-out infinite \${_assertKeyframe(
406 | pulse,
407 | )}}\${_assertSelector(first)} .f178xr0-second{display:flex}\`,
408 | css: 'f178xr0-second',
409 | };
410 |
411 |
412 | `;
413 |
414 | exports[`foliage interpolationWithNamespace: interpolationWithNamespace 1`] = `
415 |
416 | import * as foli from 'foliage';
417 |
418 | const theme = {
419 | size: {
420 | normal: '--demo-size-normal',
421 | }
422 | }
423 |
424 | const first = foli.css\`
425 | display: block;
426 | \`
427 |
428 | const pulse = foli.keyframes\`
429 | 0% { opacity: 1 }
430 | 50% { opacity: 0.2 }
431 | 100% { opacity: 1 }
432 | \`
433 |
434 | const second = foli.css\`
435 | font-size: var(\${theme.size.normal});
436 | animation: 1s ease-in-out infinite \${pulse};
437 |
438 | \${first} & {
439 | display: flex;
440 | }
441 | \`
442 |
443 | ↓ ↓ ↓ ↓ ↓ ↓
444 |
445 | import * as foli from 'foliage';
446 | const theme = {
447 | size: {
448 | normal: '--demo-size-normal',
449 | },
450 | };
451 | const first = {
452 | content: '.f-d218eu-first{display:block}',
453 | css: 'f-d218eu-first',
454 | };
455 | const pulse = {
456 | content:
457 | '@-webkit-keyframes f-p241qa-pulse{0%,to{opacity:1}50%{opacity:.2}}@keyframes f-p241qa-pulse{0%,to{opacity:1}50%{opacity:.2}}',
458 | keyframes: 'f-p241qa-pulse',
459 | };
460 | const second = {
461 | content: \`.f178xr0-second{font-size:var(\${foli.assertVariable(
462 | theme.size.normal,
463 | )});-webkit-animation:1s ease-in-out infinite \${foli.assertKeyframe(
464 | pulse,
465 | )};animation:1s ease-in-out infinite \${foli.assertKeyframe(
466 | pulse,
467 | )}}\${foli.assertSelector(first)} .f178xr0-second{display:flex}\`,
468 | css: 'f178xr0-second',
469 | };
470 |
471 |
472 | `;
473 |
474 | exports[`foliage keyframesAndGlobalStylesShouldCompile: keyframesAndGlobalStylesShouldCompile 1`] = `
475 |
476 | import { css, keyframes, createGlobalStyle } from 'foliage';
477 | const part = css\`
478 | color: black;
479 | & > * { padding-left: 1rem; }
480 | \`
481 |
482 | const anim = keyframes\`
483 | 0% { transform: rotate(0deg) }
484 | 100% { transform: rotate(180deg) }
485 | \`
486 |
487 | const glob = createGlobalStyle\`
488 | body {
489 | position: fixed;
490 | top: 0;
491 | left: 0;
492 | }
493 | \`
494 |
495 | ↓ ↓ ↓ ↓ ↓ ↓
496 |
497 | import { css, keyframes, createGlobalStyle } from 'foliage';
498 | const part = {
499 | content: '.f-u8us0b-part{color:#000}.f-u8us0b-part>*{padding-left:1rem}',
500 | css: 'f-u8us0b-part',
501 | };
502 | const anim = {
503 | content:
504 | '@-webkit-keyframes f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}@keyframes f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}',
505 | keyframes: 'f41ecfi-anim',
506 | };
507 | const glob = {
508 | content: 'body{position:fixed;top:0;left:0}',
509 | createGlobalStyle: 'f-spiibj-glob',
510 | };
511 |
512 |
513 | `;
514 |
515 | exports[`foliage keyframesInterpolationInCss: keyframesInterpolationInCss 1`] = `
516 |
517 | import { css, keyframes } from 'foliage';
518 |
519 | const anim = keyframes\`
520 | 0% { transform: rotate(0deg) }
521 | 100% { transform: rotate(180deg) }
522 | \`
523 |
524 | const element = css\`
525 | color: red;
526 | animation: 3s ease-in 1s infinite \${anim};
527 | \`
528 |
529 | ↓ ↓ ↓ ↓ ↓ ↓
530 |
531 | import { css, keyframes, assertKeyframe as _assertKeyframe } from 'foliage';
532 | const anim = {
533 | content:
534 | '@-webkit-keyframes f257uuq-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}@keyframes f257uuq-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}',
535 | keyframes: 'f257uuq-anim',
536 | };
537 | const element = {
538 | content: \`.f7qew45-element{color:red;-webkit-animation:3s ease-in 1s infinite \${_assertKeyframe(
539 | anim,
540 | )};animation:3s ease-in 1s infinite \${_assertKeyframe(anim)}}\`,
541 | css: 'f7qew45-element',
542 | };
543 |
544 |
545 | `;
546 |
547 | exports[`foliage namespaceSupport: namespaceSupport 1`] = `
548 |
549 | import * as example from 'foliage';
550 | const part = example.css\`
551 | color: black;
552 | & > * { padding-left: 1rem; }
553 | \`
554 |
555 | const anim = example.keyframes\`
556 | 0% { transform: rotate(0deg) }
557 | 100% { transform: rotate(180deg) }
558 | \`
559 |
560 | const glob = example.createGlobalStyle\`
561 | body {
562 | position: fixed;
563 | top: 0;
564 | left: 0;
565 | }
566 | \`
567 |
568 | const theme = example.vars\`
569 | --demo: 123px;
570 | \`
571 |
572 | ↓ ↓ ↓ ↓ ↓ ↓
573 |
574 | import * as example from 'foliage';
575 | const part = {
576 | content: '.f-u8us0b-part{color:#000}.f-u8us0b-part>*{padding-left:1rem}',
577 | css: 'f-u8us0b-part',
578 | };
579 | const anim = {
580 | content:
581 | '@-webkit-keyframes f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}@keyframes f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}',
582 | keyframes: 'f41ecfi-anim',
583 | };
584 | const glob = {
585 | content: 'body{position:fixed;top:0;left:0}',
586 | createGlobalStyle: 'f-spiibj-glob',
587 | };
588 | const theme = example.vars\`
589 | --demo: 123px;
590 | \`;
591 |
592 |
593 | `;
594 |
595 | exports[`foliage prefixAdd: prefixAdd 1`] = `
596 |
597 | import { css, keyframes, createGlobalStyle } from 'foliage';
598 | const part = css\`
599 | color: black;
600 | & > * { padding-left: 1rem; }
601 | \`
602 |
603 | const anim = keyframes\`
604 | 0% { transform: rotate(0deg) }
605 | 100% { transform: rotate(180deg) }
606 | \`
607 |
608 | const glob = createGlobalStyle\`
609 | body {
610 | position: fixed;
611 | top: 0;
612 | left: 0;
613 | }
614 | \`
615 |
616 | ↓ ↓ ↓ ↓ ↓ ↓
617 |
618 | import { css, keyframes, createGlobalStyle } from 'foliage';
619 | const part = {
620 | content:
621 | '.prefix-f-u8us0b-part{color:#000}.prefix-f-u8us0b-part>*{padding-left:1rem}',
622 | css: 'prefix-f-u8us0b-part',
623 | };
624 | const anim = {
625 | content:
626 | '@-webkit-keyframes prefix-f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}@keyframes prefix-f41ecfi-anim{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}',
627 | keyframes: 'prefix-f41ecfi-anim',
628 | };
629 | const glob = {
630 | content: 'body{position:fixed;top:0;left:0}',
631 | createGlobalStyle: 'prefix-f-spiibj-glob',
632 | };
633 |
634 |
635 | `;
636 |
637 | exports[`foliage prefixExistsWithoutDebug: prefixExistsWithoutDebug 1`] = `
638 |
639 | import { css, keyframes, createGlobalStyle } from 'foliage';
640 | const part = css\`
641 | color: black;
642 | & > * { padding-left: 1rem; }
643 | \`
644 |
645 | const anim = keyframes\`
646 | 0% { transform: rotate(0deg) }
647 | 100% { transform: rotate(180deg) }
648 | \`
649 |
650 | const glob = createGlobalStyle\`
651 | body {
652 | position: fixed;
653 | top: 0;
654 | left: 0;
655 | }
656 | \`
657 |
658 | ↓ ↓ ↓ ↓ ↓ ↓
659 |
660 | import { css, keyframes, createGlobalStyle } from 'foliage';
661 | const part = {
662 | content: '.prefix-f-u8us0b{color:#000}.prefix-f-u8us0b>*{padding-left:1rem}',
663 | css: 'prefix-f-u8us0b',
664 | };
665 | const anim = {
666 | content:
667 | '@-webkit-keyframes prefix-f41ecfi{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}@keyframes prefix-f41ecfi{0%{transform:rotate(0deg)}to{transform:rotate(180deg)}}',
668 | keyframes: 'prefix-f41ecfi',
669 | };
670 | const glob = {
671 | content: 'body{position:fixed;top:0;left:0}',
672 | createGlobalStyle: 'prefix-f-spiibj',
673 | };
674 |
675 |
676 | `;
677 |
678 | exports[`foliage selectorOfComponent: selectorOfComponent 1`] = `
679 |
680 | import { css } from 'foliage';
681 | const button = css\`
682 | padding: 1rem 2rem;
683 | border: 2px solid gray;
684 | border-radius: 1rem;
685 | color: white;
686 | background-color: black;
687 | appearance: none;
688 | \`;
689 |
690 | const primary = css\`
691 | background-color: black;
692 | color: white;
693 | padding: 1rem 2rem;
694 |
695 | \${button} {
696 | background-color: red;
697 | color: white;
698 | }
699 | \`;
700 |
701 | ↓ ↓ ↓ ↓ ↓ ↓
702 |
703 | import { css, assertSelector as _assertSelector } from 'foliage';
704 | const button = {
705 | content:
706 | '.fkgkq9e-button{padding:1rem 2rem;border:2px solid gray;border-radius:1rem;color:#fff;background-color:#000;-webkit-appearance:none;-moz-appearance:none;appearance:none}',
707 | css: 'fkgkq9e-button',
708 | };
709 | const primary = {
710 | content: \`.f6pubp1-primary{background-color:#000;color:#fff;padding:1rem 2rem}.f6pubp1-primary \${_assertSelector(
711 | button,
712 | )}{background-color:red;color:#fff}\`,
713 | css: 'f6pubp1-primary',
714 | };
715 |
716 |
717 | `;
718 |
719 | exports[`foliage selectorOfComponentWithPseudoSelector: selectorOfComponentWithPseudoSelector 1`] = `
720 |
721 | import { css } from 'foliage';
722 | const button = css\`
723 | padding: 1rem 2rem;
724 | border: 2px solid gray;
725 | border-radius: 1rem;
726 | color: white;
727 | background-color: black;
728 | appearance: none;
729 | \`;
730 |
731 | const primary = css\`
732 | background-color: black;
733 | color: white;
734 | padding: 1rem 2rem;
735 |
736 | \${button}:hover {
737 | background-color: red;
738 | color: white;
739 | }
740 | \`;
741 |
742 | ↓ ↓ ↓ ↓ ↓ ↓
743 |
744 | import { css, assertSelector as _assertSelector } from 'foliage';
745 | const button = {
746 | content:
747 | '.fkgkq9e-button{padding:1rem 2rem;border:2px solid gray;border-radius:1rem;color:#fff;background-color:#000;-webkit-appearance:none;-moz-appearance:none;appearance:none}',
748 | css: 'fkgkq9e-button',
749 | };
750 | const primary = {
751 | content: \`.f6pubp1-primary{background-color:#000;color:#fff;padding:1rem 2rem}.f6pubp1-primary \${_assertSelector(
752 | button,
753 | )}:hover{background-color:red;color:#fff}\`,
754 | css: 'f6pubp1-primary',
755 | };
756 |
757 |
758 | `;
759 |
760 | exports[`foliage varsNotCompiles: varsNotCompiles 1`] = `
761 |
762 | import {vars, css} from 'foliage'; const a = css\`outline: none;\`; const b = vars\`--random: 1px;\`
763 |
764 | ↓ ↓ ↓ ↓ ↓ ↓
765 |
766 | import { vars, css } from 'foliage';
767 | const a = {
768 | content: '.f-3x0vwb-a{outline:0}',
769 | css: 'f-3x0vwb-a',
770 | };
771 | const b = vars\`--random: 1px;\`;
772 |
773 |
774 | `;
775 |
776 | exports[`foliage withoutDebugNamesNotAdded: withoutDebugNamesNotAdded 1`] = `
777 |
778 | import {css} from 'foliage'; const example = css\`span{display:grid}\`
779 |
780 | ↓ ↓ ↓ ↓ ↓ ↓
781 |
782 | import { css } from 'foliage';
783 | const example = {
784 | content: '.f1lijm6 span{display:grid}',
785 | css: 'f1lijm6',
786 | };
787 |
788 |
789 | `;
790 |
--------------------------------------------------------------------------------
/src/stylis/built/umd/stylis.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"stylis.js","sources":["../../src/Enum.js","../../src/Utility.js","../../src/Tokenizer.js","../../src/Parser.js","../../src/Prefixer.js","../../src/Serializer.js","../../src/Middleware.js"],"sourcesContent":["export var MS = '-ms-'\nexport var MOZ = '-moz-'\nexport var WEBKIT = '-webkit-'\n\nexport var COMMENT = 'comm'\nexport var RULESET = 'rule'\nexport var DECLARATION = 'decl'\n\nexport var PAGE = '@page'\nexport var MEDIA = '@media'\nexport var IMPORT = '@import'\nexport var CHARSET = '@charset'\nexport var VIEWPORT = '@viewport'\nexport var SUPPORTS = '@supports'\nexport var DOCUMENT = '@document'\nexport var NAMESPACE = '@namespace'\nexport var KEYFRAMES = '@keyframes'\nexport var FONT_FACE = '@font-face'\nexport var COUNTER_STYLE = '@counter-style'\nexport var FONT_FEATURE_VALUES = '@font-feature-values'\n","/**\n * @param {number}\n * @return {number}\n */\nexport var abs = Math.abs\n\n/**\n * @param {number}\n * @return {string}\n */\nexport var from = String.fromCharCode\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {number}\n */\nexport function hash (value, length) {\n\treturn (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3)\n}\n\n/**\n * @param {string} value\n * @return {string}\n */\nexport function trim (value) {\n\treturn value.trim()\n}\n\n/**\n * @param {string} value\n * @param {RegExp} pattern\n * @return {string?}\n */\nexport function match (value, pattern) {\n\treturn (value = pattern.exec(value)) ? value[0] : value\n}\n\n/**\n * @param {string} value\n * @param {(string|RegExp)} pattern\n * @param {string} replacement\n * @return {string}\n */\nexport function replace (value, pattern, replacement) {\n\treturn value.replace(pattern, replacement)\n}\n\n/**\n * @param {string} value\n * @param {string} value\n * @return {number}\n */\nexport function indexof (value, search) {\n\treturn value.indexOf(search)\n}\n\n/**\n * @param {string} value\n * @param {number} index\n * @return {number}\n */\nexport function charat (value, index) {\n\treturn value.charCodeAt(index) | 0\n}\n\n/**\n * @param {string} value\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function substr (value, begin, end) {\n\treturn value.slice(begin, end)\n}\n\n/**\n * @param {string} value\n * @return {number}\n */\nexport function strlen (value) {\n\treturn value.length\n}\n\n/**\n * @param {any[]} value\n * @return {number}\n */\nexport function sizeof (value) {\n\treturn value.length\n}\n\n/**\n * @param {any} value\n * @param {any[]} array\n * @return {any}\n */\nexport function append (value, array) {\n\treturn array.push(value), value\n}\n\n/**\n * @param {string[]} array\n * @param {function} callback\n * @return {string}\n */\nexport function combine (array, callback) {\n\treturn array.map(callback).join('')\n}\n","import {from, trim, charat, strlen, substr, append} from './Utility.js'\n\nexport var line = 1\nexport var column = 1\nexport var length = 0\nexport var position = 0\nexport var character = 0\nexport var characters = ''\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string} type\n * @param {string[]} props\n * @param {object[]} children\n * @param {number} length\n */\nexport function node (value, root, parent, type, props, children, length) {\n\treturn {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {string} type\n */\nexport function copy (value, root, type) {\n\treturn node(value, root.root, root.parent, type, root.props, root.children, 0)\n}\n\n/**\n * @return {number}\n */\nexport function char () {\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function prev () {\n\tcharacter = position > 0 ? charat(characters, --position) : 0\n\n\tif (column--, character === 10)\n\t\tcolumn = 1, line--\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function next () {\n\tcharacter = position < length ? charat(characters, position++) : 0\n\n\tif (column++, character === 10)\n\t\tcolumn = 1, line++\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function peek () {\n\treturn charat(characters, position)\n}\n\n/**\n * @return {number}\n */\nexport function caret () {\n\treturn position\n}\n\n/**\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function slice (begin, end) {\n\treturn substr(characters, begin, end)\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function token (type) {\n\tswitch (type) {\n\t\t// \\0 \\t \\n \\r \\s whitespace token\n\t\tcase 0: case 9: case 10: case 13: case 32:\n\t\t\treturn 5\n\t\t// ! + , / > @ ~ isolate token\n\t\tcase 33: case 43: case 44: case 47: case 62: case 64: case 126:\n\t\t// ; { } breakpoint token\n\t\tcase 59: case 123: case 125:\n\t\t\treturn 4\n\t\t// : accompanied token\n\t\tcase 58:\n\t\t\treturn 3\n\t\t// \" ' ( [ opening delimit token\n\t\tcase 34: case 39: case 40: case 91:\n\t\t\treturn 2\n\t\t// ) ] closing delimit token\n\t\tcase 41: case 93:\n\t\t\treturn 1\n\t}\n\n\treturn 0\n}\n\n/**\n * @param {string} value\n * @return {any[]}\n */\nexport function alloc (value) {\n\treturn line = column = 1, length = strlen(characters = value), position = 0, []\n}\n\n/**\n * @param {any} value\n * @return {any}\n */\nexport function dealloc (value) {\n\treturn characters = '', value\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function delimit (type) {\n\treturn trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))\n}\n\n/**\n * @param {string} value\n * @return {string[]}\n */\nexport function tokenize (value) {\n\treturn dealloc(tokenizer(alloc(value)))\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function whitespace (type) {\n\twhile (character = peek())\n\t\tif (character < 33)\n\t\t\tnext()\n\t\telse\n\t\t\tbreak\n\n\treturn token(type) > 2 || token(character) > 3 ? '' : ' '\n}\n\n/**\n * @param {string[]} children\n * @return {string[]}\n */\nexport function tokenizer (children) {\n\twhile (next())\n\t\tswitch (token(character)) {\n\t\t\tcase 0: append(identifier(position - 1), children)\n\t\t\t\tbreak\n\t\t\tcase 2: append(delimit(character), children)\n\t\t\t\tbreak\n\t\t\tdefault: append(from(character), children)\n\t\t}\n\n\treturn children\n}\n\n/**\n * @param {number} index\n * @param {number} count\n * @return {string}\n */\nexport function escaping (index, count) {\n\twhile (--count && next())\n\t\t// not 0-9 A-F a-f\n\t\tif (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))\n\t\t\tbreak\n\n\treturn slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function delimiter (type) {\n\twhile (next())\n\t\tswitch (character) {\n\t\t\t// ] ) \" '\n\t\t\tcase type:\n\t\t\t\treturn position\n\t\t\t// \" '\n\t\t\tcase 34: case 39:\n\t\t\t\treturn delimiter(type === 34 || type === 39 ? type : character)\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (type === 41)\n\t\t\t\t\tdelimiter(type)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tnext()\n\t\t\t\tbreak\n\t\t}\n\n\treturn position\n}\n\n/**\n * @param {number} type\n * @param {number} index\n * @return {number}\n */\nexport function commenter (type, index) {\n\twhile (next())\n\t\t// //\n\t\tif (type + character === 47 + 10)\n\t\t\tbreak\n\t\t// /*\n\t\telse if (type + character === 42 + 42 && peek() === 47)\n\t\t\tbreak\n\n\treturn '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())\n}\n\n/**\n * @param {number} index\n * @return {string}\n */\nexport function identifier (index) {\n\twhile (!token(peek()))\n\t\tnext()\n\n\treturn slice(index, position)\n}\n","import {COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {abs, trim, from, sizeof, strlen, substr, append, replace} from './Utility.js'\nimport {node, char, prev, next, peek, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'\n\n/**\n * @param {string} value\n * @return {object[]}\n */\nexport function compile (value) {\n\treturn dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string[]} rule\n * @param {string[]} rules\n * @param {string[]} rulesets\n * @param {number[]} pseudo\n * @param {number[]} points\n * @param {string[]} declarations\n * @return {object}\n */\nexport function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {\n\tvar index = 0\n\tvar offset = 0\n\tvar length = pseudo\n\tvar atrule = 0\n\tvar property = 0\n\tvar previous = 0\n\tvar variable = 1\n\tvar scanning = 1\n\tvar ampersand = 1\n\tvar character = 0\n\tvar type = ''\n\tvar props = rules\n\tvar children = rulesets\n\tvar reference = rule\n\tvar characters = type\n\n\twhile (scanning)\n\t\tswitch (previous = character, character = next()) {\n\t\t\t// \" ' [ (\n\t\t\tcase 34: case 39: case 91: case 40:\n\t\t\t\tcharacters += delimit(character)\n\t\t\t\tbreak\n\t\t\t// \\t \\n \\r \\s\n\t\t\tcase 9: case 10: case 13: case 32:\n\t\t\t\tcharacters += whitespace(previous)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tcharacters += escaping(caret() - 1, 7)\n\t\t\t\tcontinue\n\t\t\t// /\n\t\t\tcase 47:\n\t\t\t\tswitch (peek()) {\n\t\t\t\t\tcase 42: case 47:\n\t\t\t\t\t\tappend(comment(commenter(next(), caret()), root, parent), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcharacters += '/'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t// {\n\t\t\tcase 123 * variable:\n\t\t\t\tpoints[index++] = strlen(characters) * ampersand\n\t\t\t// } ; \\0\n\t\t\tcase 125 * variable: case 59: case 0:\n\t\t\t\tswitch (character) {\n\t\t\t\t\t// \\0 }\n\t\t\t\t\tcase 0: case 125: scanning = 0\n\t\t\t\t\t// ;\n\t\t\t\t\tcase 59 + offset:\n\t\t\t\t\t\tif (property > 0 && (strlen(characters) - length))\n\t\t\t\t\t\t\tappend(property > 32 ? declaration(characters + ';', rule, parent, length - 1) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @ ;\n\t\t\t\t\tcase 59: characters += ';'\n\t\t\t\t\t// { rule/at-rule\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tappend(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets)\n\n\t\t\t\t\t\tif (character === 123)\n\t\t\t\t\t\t\tif (offset === 0)\n\t\t\t\t\t\t\t\tparse(characters, root, reference, reference, props, rulesets, length, points, children)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tswitch (atrule) {\n\t\t\t\t\t\t\t\t\t// d m s\n\t\t\t\t\t\t\t\t\tcase 100: case 109: case 115:\n\t\t\t\t\t\t\t\t\t\tparse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children)\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\tparse(characters, reference, reference, reference, [''], children, length, points, children)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tindex = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo\n\t\t\t\tbreak\n\t\t\t// :\n\t\t\tcase 58:\n\t\t\t\tlength = 1 + strlen(characters), property = previous\n\t\t\tdefault:\n\t\t\t\tif (variable < 1)\n\t\t\t\t\tif (character == 123)\n\t\t\t\t\t\t--variable\n\t\t\t\t\telse if (character == 125 && variable++ == 0 && prev() == 125)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\tswitch (characters += from(character), character * variable) {\n\t\t\t\t\t// &\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\tampersand = offset > 0 ? 1 : (characters += '\\f', -1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// ,\n\t\t\t\t\tcase 44:\n\t\t\t\t\t\tpoints[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @\n\t\t\t\t\tcase 64:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (peek() === 45)\n\t\t\t\t\t\t\tcharacters += delimit(next())\n\n\t\t\t\t\t\tatrule = peek(), offset = strlen(type = characters += identifier(caret())), character++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// -\n\t\t\t\t\tcase 45:\n\t\t\t\t\t\tif (previous === 45 && strlen(characters) == 2)\n\t\t\t\t\t\t\tvariable = 0\n\t\t\t\t}\n\t\t}\n\n\treturn rulesets\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} index\n * @param {number} offset\n * @param {string[]} rules\n * @param {number[]} points\n * @param {string} type\n * @param {string[]} props\n * @param {string[]} children\n * @param {number} length\n * @return {object}\n */\nexport function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length) {\n\tvar post = offset - 1\n\tvar rule = offset === 0 ? rules : ['']\n\tvar size = sizeof(rule)\n\n\tfor (var i = 0, j = 0, k = 0; i < index; ++i)\n\t\tfor (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)\n\t\t\tif (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\\f/g, rule[x])))\n\t\t\t\tprops[k++] = z\n\n\treturn node(value, root, parent, offset === 0 ? RULESET : type, props, children, length)\n}\n\n/**\n * @param {number} value\n * @param {object} root\n * @param {object?} parent\n * @return {object}\n */\nexport function comment (value, root, parent) {\n\treturn node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0)\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} length\n * @return {object}\n */\nexport function declaration (value, root, parent, length) {\n\treturn node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length)\n}\n","import {MS, MOZ, WEBKIT} from './Enum.js'\nimport {hash, charat, strlen, indexof, replace} from './Utility.js'\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {string}\n */\nexport function prefix (value, length) {\n\tswitch (hash(value, length)) {\n\t\t// color-adjust\n\t\tcase 5103:\n\t\t\treturn WEBKIT + 'print-' + value + value\n\t\t// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)\n\t\tcase 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921:\n\t\t// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break\n\t\tcase 5572: case 6356: case 5844: case 3191: case 6645: case 3005:\n\t\t// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,\n\t\tcase 6391: case 5879: case 5623: case 6135: case 4599: case 4855:\n\t\t// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)\n\t\tcase 4215: case 6389: case 5109: case 5365: case 5621: case 3829:\n\t\t\treturn WEBKIT + value + value\n\t\t// appearance, user-select, transform, hyphens, text-size-adjust\n\t\tcase 5349: case 4246: case 4810: case 6968: case 2756:\n\t\t\treturn WEBKIT + value + MOZ + value + MS + value + value\n\t\t// flex, flex-direction\n\t\tcase 6828: case 4268:\n\t\t\treturn WEBKIT + value + MS + value + value\n\t\t// order\n\t\tcase 6165:\n\t\t\treturn WEBKIT + value + MS + 'flex-' + value + value\n\t\t// align-items\n\t\tcase 5187:\n\t\t\treturn WEBKIT + value + replace(value, /(\\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value\n\t\t// align-self\n\t\tcase 5443:\n\t\t\treturn WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/, '') + value\n\t\t// align-content\n\t\tcase 4675:\n\t\t\treturn WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/, '') + value\n\t\t// flex-shrink\n\t\tcase 5548:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value\n\t\t// flex-basis\n\t\tcase 5292:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value\n\t\t// flex-grow\n\t\tcase 6060:\n\t\t\treturn WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value\n\t\t// transition\n\t\tcase 4554:\n\t\t\treturn WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value\n\t\t// cursor\n\t\tcase 6187:\n\t\t\treturn replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value\n\t\t// background, background-image\n\t\tcase 5495: case 3959:\n\t\t\treturn replace(value, /(image-set\\([^]*)/, WEBKIT + '$1' + '$`$1')\n\t\t// justify-content\n\t\tcase 4968:\n\t\t\treturn replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + WEBKIT + value + value\n\t\t// (margin|padding)-inline-(start|end)\n\t\tcase 4095: case 3583: case 4068: case 2532:\n\t\t\treturn replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value\n\t\t// (min|max)?(width|height|inline-size|block-size)\n\t\tcase 8116: case 7059: case 5753: case 5535:\n\t\tcase 5445: case 5701: case 4933: case 4677:\n\t\tcase 5533: case 5789: case 5021: case 4765:\n\t\t\t// stretch, max-content, min-content, fill-available\n\t\t\tif (strlen(value) - 1 - length > 6)\n\t\t\t\tswitch (charat(value, length + 1)) {\n\t\t\t\t\t// (m)ax-content, (m)in-content\n\t\t\t\t\tcase 109:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (charat(value, length + 4) !== 45)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t// (f)ill-available, (f)it-content\n\t\t\t\t\tcase 102:\n\t\t\t\t\t\treturn replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value\n\t\t\t\t\t// (s)tretch\n\t\t\t\t\tcase 115:\n\t\t\t\t\t\treturn ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length) + value : value\n\t\t\t\t}\n\t\t\tbreak\n\t\t// position: sticky\n\t\tcase 4949:\n\t\t\t// (s)ticky?\n\t\t\tif (charat(value, length + 1) !== 115)\n\t\t\t\tbreak\n\t\t// display: (flex|inline-flex)\n\t\tcase 6444:\n\t\t\tswitch (charat(value, strlen(value) - 3 - (~indexof(value, '!important') && 10))) {\n\t\t\t\t// stic(k)y\n\t\t\t\tcase 107:\n\t\t\t\t\treturn replace(value, ':', ':' + WEBKIT) + value\n\t\t\t\t// (inline-)?fl(e)x\n\t\t\t\tcase 101:\n\t\t\t\t\treturn replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value\n\t\t\t}\n\t\t\tbreak\n\t\t// writing-mode\n\t\tcase 5936:\n\t\t\tswitch (charat(value, length + 11)) {\n\t\t\t\t// vertical-l(r)\n\t\t\t\tcase 114:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb') + value\n\t\t\t\t// vertical-r(l)\n\t\t\t\tcase 108:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb-rl') + value\n\t\t\t\t// horizontal(-)tb\n\t\t\t\tcase 45:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'lr') + value\n\t\t\t}\n\n\t\t\treturn WEBKIT + value + MS + value + value\n\t}\n\n\treturn value\n}\n","import {IMPORT, COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {strlen, sizeof} from './Utility.js'\n\n/**\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function serialize (children, callback) {\n\tvar output = ''\n\tvar length = sizeof(children)\n\n\tfor (var i = 0; i < length; i++)\n\t\toutput += callback(children[i], i, children, callback) || ''\n\n\treturn output\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function stringify (element, index, children, callback) {\n\tswitch (element.type) {\n\t\tcase IMPORT: case DECLARATION: return element.return = element.return || element.value\n\t\tcase COMMENT: return ''\n\t\tcase RULESET: element.value = element.props.join(',')\n\t}\n\n\treturn strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''\n}\n","import {MS, MOZ, WEBKIT, RULESET, KEYFRAMES, DECLARATION} from './Enum.js'\nimport {match, charat, substr, strlen, sizeof, replace, combine} from './Utility.js'\nimport {copy, tokenize} from './Tokenizer.js'\nimport {serialize} from './Serializer.js'\nimport {prefix} from './Prefixer.js'\n\n/**\n * @param {function[]} collection\n * @return {function}\n */\nexport function middleware (collection) {\n\tvar length = sizeof(collection)\n\n\treturn function (element, index, children, callback) {\n\t\tvar output = ''\n\n\t\tfor (var i = 0; i < length; i++)\n\t\t\toutput += collection[i](element, index, children, callback) || ''\n\n\t\treturn output\n\t}\n}\n\n/**\n * @param {function} callback\n * @return {function}\n */\nexport function rulesheet (callback) {\n\treturn function (element) {\n\t\tif (!element.root)\n\t\t\tif (element = element.return)\n\t\t\t\tcallback(element)\n\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n */\nexport function prefixer (element, index, children, callback) {\n\tif (!element.return)\n\t\tswitch (element.type) {\n\t\t\tcase DECLARATION: element.return = prefix(element.value, element.length)\n\t\t\t\tbreak\n\t\t\tcase KEYFRAMES:\n\t\t\t\treturn serialize([copy(replace(element.value, '@', '@' + WEBKIT), element, '')], callback)\n\t\t\tcase RULESET:\n\t\t\t\tif (element.length)\n\t\t\t\t\treturn combine(element.props, function (value) {\n\t\t\t\t\t\tswitch (match(value, /(::plac\\w+|:read-\\w+)/)) {\n\t\t\t\t\t\t\t// :read-(only|write)\n\t\t\t\t\t\t\tcase ':read-only': case ':read-write':\n\t\t\t\t\t\t\t\treturn serialize([copy(replace(value, /:(read-\\w+)/, ':' + MOZ + '$1'), element, '')], callback)\n\t\t\t\t\t\t\t// :placeholder\n\t\t\t\t\t\t\tcase '::placeholder':\n\t\t\t\t\t\t\t\treturn serialize([\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, ':' + WEBKIT + 'input-$1'), element, ''),\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, ':' + MOZ + '$1'), element, ''),\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, MS + 'input-$1'), element, '')\n\t\t\t\t\t\t\t\t], callback)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ''\n\t\t\t\t\t})\n\t\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n */\nexport function namespace (element) {\n\tswitch (element.type) {\n\t\tcase RULESET:\n\t\t\telement.props = element.props.map(function (value) {\n\t\t\t\treturn combine(tokenize(value), function (value, index, children) {\n\t\t\t\t\tswitch (charat(value, 0)) {\n\t\t\t\t\t\t// \\f\n\t\t\t\t\t\tcase 12:\n\t\t\t\t\t\t\treturn substr(value, 1, strlen(value))\n\t\t\t\t\t\t// \\0 ( + > ~\n\t\t\t\t\t\tcase 0: case 40: case 43: case 62: case 126:\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t// :\n\t\t\t\t\t\tcase 58:\n\t\t\t\t\t\t\tif (children[++index] === 'global')\n\t\t\t\t\t\t\t\tchildren[index] = '', children[++index] = '\\f' + substr(children[index], index = 1, -1)\n\t\t\t\t\t\t// \\s\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\treturn index === 1 ? '' : value\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tswitch (index) {\n\t\t\t\t\t\t\t\tcase 0: element = value\n\t\t\t\t\t\t\t\t\treturn sizeof(children) > 1 ? '' : value\n\t\t\t\t\t\t\t\tcase index = sizeof(children) - 1: case 2:\n\t\t\t\t\t\t\t\t\treturn index === 2 ? value + element + element : value + element\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t}\n}\n"],"names":["MS","MOZ","WEBKIT","COMMENT","RULESET","DECLARATION","PAGE","MEDIA","IMPORT","CHARSET","VIEWPORT","SUPPORTS","DOCUMENT","NAMESPACE","KEYFRAMES","FONT_FACE","COUNTER_STYLE","FONT_FEATURE_VALUES","abs","Math","from","String","fromCharCode","hash","value","length","charat","trim","match","pattern","exec","replace","replacement","indexof","search","indexOf","index","charCodeAt","substr","begin","end","slice","strlen","sizeof","append","array","push","combine","callback","map","join","node","root","parent","type","props","children","line","column","return","copy","char","character","prev","position","characters","next","peek","caret","token","alloc","dealloc","delimit","delimiter","tokenize","tokenizer","whitespace","identifier","escaping","count","commenter","compile","parse","rule","rules","rulesets","pseudo","points","declarations","offset","atrule","property","previous","variable","scanning","ampersand","reference","comment","declaration","ruleset","post","size","i","j","k","x","y","z","prefix","serialize","output","stringify","element","middleware","collection","rulesheet","prefixer","namespace"],"mappings":"8MAAWA,EAAK,WACLC,EAAM,YACNC,EAAS,eAETC,EA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,OAAOmB,EAAOa,GAAY,EAAI,GAAKhC,EACpC,KAAKY,EAAQO,EAAOa,GAAY,EAAG,KAAK,EACvC,OAAOpB,IAAU,EAAIZ,EAAQwF,EAAUA,EAAUxF,EAAQwF,EAC1D,QACC,OAAOxF"}
--------------------------------------------------------------------------------
/src/stylis/built/stylis.mjs.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"stylis.mjs","sources":["../src/Enum.js","../src/Utility.js","../src/Tokenizer.js","../src/Parser.js","../src/Prefixer.js","../src/Serializer.js","../src/Middleware.js"],"sourcesContent":["export var MS = '-ms-'\nexport var MOZ = '-moz-'\nexport var WEBKIT = '-webkit-'\n\nexport var COMMENT = 'comm'\nexport var RULESET = 'rule'\nexport var DECLARATION = 'decl'\n\nexport var PAGE = '@page'\nexport var MEDIA = '@media'\nexport var IMPORT = '@import'\nexport var CHARSET = '@charset'\nexport var VIEWPORT = '@viewport'\nexport var SUPPORTS = '@supports'\nexport var DOCUMENT = '@document'\nexport var NAMESPACE = '@namespace'\nexport var KEYFRAMES = '@keyframes'\nexport var FONT_FACE = '@font-face'\nexport var COUNTER_STYLE = '@counter-style'\nexport var FONT_FEATURE_VALUES = '@font-feature-values'\n","/**\n * @param {number}\n * @return {number}\n */\nexport var abs = Math.abs\n\n/**\n * @param {number}\n * @return {string}\n */\nexport var from = String.fromCharCode\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {number}\n */\nexport function hash (value, length) {\n\treturn (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3)\n}\n\n/**\n * @param {string} value\n * @return {string}\n */\nexport function trim (value) {\n\treturn value.trim()\n}\n\n/**\n * @param {string} value\n * @param {RegExp} pattern\n * @return {string?}\n */\nexport function match (value, pattern) {\n\treturn (value = pattern.exec(value)) ? value[0] : value\n}\n\n/**\n * @param {string} value\n * @param {(string|RegExp)} pattern\n * @param {string} replacement\n * @return {string}\n */\nexport function replace (value, pattern, replacement) {\n\treturn value.replace(pattern, replacement)\n}\n\n/**\n * @param {string} value\n * @param {string} value\n * @return {number}\n */\nexport function indexof (value, search) {\n\treturn value.indexOf(search)\n}\n\n/**\n * @param {string} value\n * @param {number} index\n * @return {number}\n */\nexport function charat (value, index) {\n\treturn value.charCodeAt(index) | 0\n}\n\n/**\n * @param {string} value\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function substr (value, begin, end) {\n\treturn value.slice(begin, end)\n}\n\n/**\n * @param {string} value\n * @return {number}\n */\nexport function strlen (value) {\n\treturn value.length\n}\n\n/**\n * @param {any[]} value\n * @return {number}\n */\nexport function sizeof (value) {\n\treturn value.length\n}\n\n/**\n * @param {any} value\n * @param {any[]} array\n * @return {any}\n */\nexport function append (value, array) {\n\treturn array.push(value), value\n}\n\n/**\n * @param {string[]} array\n * @param {function} callback\n * @return {string}\n */\nexport function combine (array, callback) {\n\treturn array.map(callback).join('')\n}\n","import {from, trim, charat, strlen, substr, append} from './Utility.js'\n\nexport var line = 1\nexport var column = 1\nexport var length = 0\nexport var position = 0\nexport var character = 0\nexport var characters = ''\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string} type\n * @param {string[]} props\n * @param {object[]} children\n * @param {number} length\n */\nexport function node (value, root, parent, type, props, children, length) {\n\treturn {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {string} type\n */\nexport function copy (value, root, type) {\n\treturn node(value, root.root, root.parent, type, root.props, root.children, 0)\n}\n\n/**\n * @return {number}\n */\nexport function char () {\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function prev () {\n\tcharacter = position > 0 ? charat(characters, --position) : 0\n\n\tif (column--, character === 10)\n\t\tcolumn = 1, line--\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function next () {\n\tcharacter = position < length ? charat(characters, position++) : 0\n\n\tif (column++, character === 10)\n\t\tcolumn = 1, line++\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function peek () {\n\treturn charat(characters, position)\n}\n\n/**\n * @return {number}\n */\nexport function caret () {\n\treturn position\n}\n\n/**\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function slice (begin, end) {\n\treturn substr(characters, begin, end)\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function token (type) {\n\tswitch (type) {\n\t\t// \\0 \\t \\n \\r \\s whitespace token\n\t\tcase 0: case 9: case 10: case 13: case 32:\n\t\t\treturn 5\n\t\t// ! + , / > @ ~ isolate token\n\t\tcase 33: case 43: case 44: case 47: case 62: case 64: case 126:\n\t\t// ; { } breakpoint token\n\t\tcase 59: case 123: case 125:\n\t\t\treturn 4\n\t\t// : accompanied token\n\t\tcase 58:\n\t\t\treturn 3\n\t\t// \" ' ( [ opening delimit token\n\t\tcase 34: case 39: case 40: case 91:\n\t\t\treturn 2\n\t\t// ) ] closing delimit token\n\t\tcase 41: case 93:\n\t\t\treturn 1\n\t}\n\n\treturn 0\n}\n\n/**\n * @param {string} value\n * @return {any[]}\n */\nexport function alloc (value) {\n\treturn line = column = 1, length = strlen(characters = value), position = 0, []\n}\n\n/**\n * @param {any} value\n * @return {any}\n */\nexport function dealloc (value) {\n\treturn characters = '', value\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function delimit (type) {\n\treturn trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))\n}\n\n/**\n * @param {string} value\n * @return {string[]}\n */\nexport function tokenize (value) {\n\treturn dealloc(tokenizer(alloc(value)))\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function whitespace (type) {\n\twhile (character = peek())\n\t\tif (character < 33)\n\t\t\tnext()\n\t\telse\n\t\t\tbreak\n\n\treturn token(type) > 2 || token(character) > 3 ? '' : ' '\n}\n\n/**\n * @param {string[]} children\n * @return {string[]}\n */\nexport function tokenizer (children) {\n\twhile (next())\n\t\tswitch (token(character)) {\n\t\t\tcase 0: append(identifier(position - 1), children)\n\t\t\t\tbreak\n\t\t\tcase 2: append(delimit(character), children)\n\t\t\t\tbreak\n\t\t\tdefault: append(from(character), children)\n\t\t}\n\n\treturn children\n}\n\n/**\n * @param {number} index\n * @param {number} count\n * @return {string}\n */\nexport function escaping (index, count) {\n\twhile (--count && next())\n\t\t// not 0-9 A-F a-f\n\t\tif (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))\n\t\t\tbreak\n\n\treturn slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function delimiter (type) {\n\twhile (next())\n\t\tswitch (character) {\n\t\t\t// ] ) \" '\n\t\t\tcase type:\n\t\t\t\treturn position\n\t\t\t// \" '\n\t\t\tcase 34: case 39:\n\t\t\t\treturn delimiter(type === 34 || type === 39 ? type : character)\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (type === 41)\n\t\t\t\t\tdelimiter(type)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tnext()\n\t\t\t\tbreak\n\t\t}\n\n\treturn position\n}\n\n/**\n * @param {number} type\n * @param {number} index\n * @return {number}\n */\nexport function commenter (type, index) {\n\twhile (next())\n\t\t// //\n\t\tif (type + character === 47 + 10)\n\t\t\tbreak\n\t\t// /*\n\t\telse if (type + character === 42 + 42 && peek() === 47)\n\t\t\tbreak\n\n\treturn '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())\n}\n\n/**\n * @param {number} index\n * @return {string}\n */\nexport function identifier (index) {\n\twhile (!token(peek()))\n\t\tnext()\n\n\treturn slice(index, position)\n}\n","import {COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {abs, trim, from, sizeof, strlen, substr, append, replace} from './Utility.js'\nimport {node, char, prev, next, peek, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'\n\n/**\n * @param {string} value\n * @return {object[]}\n */\nexport function compile (value) {\n\treturn dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string[]} rule\n * @param {string[]} rules\n * @param {string[]} rulesets\n * @param {number[]} pseudo\n * @param {number[]} points\n * @param {string[]} declarations\n * @return {object}\n */\nexport function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {\n\tvar index = 0\n\tvar offset = 0\n\tvar length = pseudo\n\tvar atrule = 0\n\tvar property = 0\n\tvar previous = 0\n\tvar variable = 1\n\tvar scanning = 1\n\tvar ampersand = 1\n\tvar character = 0\n\tvar type = ''\n\tvar props = rules\n\tvar children = rulesets\n\tvar reference = rule\n\tvar characters = type\n\n\twhile (scanning)\n\t\tswitch (previous = character, character = next()) {\n\t\t\t// \" ' [ (\n\t\t\tcase 34: case 39: case 91: case 40:\n\t\t\t\tcharacters += delimit(character)\n\t\t\t\tbreak\n\t\t\t// \\t \\n \\r \\s\n\t\t\tcase 9: case 10: case 13: case 32:\n\t\t\t\tcharacters += whitespace(previous)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tcharacters += escaping(caret() - 1, 7)\n\t\t\t\tcontinue\n\t\t\t// /\n\t\t\tcase 47:\n\t\t\t\tswitch (peek()) {\n\t\t\t\t\tcase 42: case 47:\n\t\t\t\t\t\tappend(comment(commenter(next(), caret()), root, parent), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcharacters += '/'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t// {\n\t\t\tcase 123 * variable:\n\t\t\t\tpoints[index++] = strlen(characters) * ampersand\n\t\t\t// } ; \\0\n\t\t\tcase 125 * variable: case 59: case 0:\n\t\t\t\tswitch (character) {\n\t\t\t\t\t// \\0 }\n\t\t\t\t\tcase 0: case 125: scanning = 0\n\t\t\t\t\t// ;\n\t\t\t\t\tcase 59 + offset:\n\t\t\t\t\t\tif (property > 0 && (strlen(characters) - length))\n\t\t\t\t\t\t\tappend(property > 32 ? declaration(characters + ';', rule, parent, length - 1) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @ ;\n\t\t\t\t\tcase 59: characters += ';'\n\t\t\t\t\t// { rule/at-rule\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tappend(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets)\n\n\t\t\t\t\t\tif (character === 123)\n\t\t\t\t\t\t\tif (offset === 0)\n\t\t\t\t\t\t\t\tparse(characters, root, reference, reference, props, rulesets, length, points, children)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tswitch (atrule) {\n\t\t\t\t\t\t\t\t\t// d m s\n\t\t\t\t\t\t\t\t\tcase 100: case 109: case 115:\n\t\t\t\t\t\t\t\t\t\tparse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children)\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\tparse(characters, reference, reference, reference, [''], children, length, points, children)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tindex = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo\n\t\t\t\tbreak\n\t\t\t// :\n\t\t\tcase 58:\n\t\t\t\tlength = 1 + strlen(characters), property = previous\n\t\t\tdefault:\n\t\t\t\tif (variable < 1)\n\t\t\t\t\tif (character == 123)\n\t\t\t\t\t\t--variable\n\t\t\t\t\telse if (character == 125 && variable++ == 0 && prev() == 125)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\tswitch (characters += from(character), character * variable) {\n\t\t\t\t\t// &\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\tampersand = offset > 0 ? 1 : (characters += '\\f', -1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// ,\n\t\t\t\t\tcase 44:\n\t\t\t\t\t\tpoints[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @\n\t\t\t\t\tcase 64:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (peek() === 45)\n\t\t\t\t\t\t\tcharacters += delimit(next())\n\n\t\t\t\t\t\tatrule = peek(), offset = strlen(type = characters += identifier(caret())), character++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// -\n\t\t\t\t\tcase 45:\n\t\t\t\t\t\tif (previous === 45 && strlen(characters) == 2)\n\t\t\t\t\t\t\tvariable = 0\n\t\t\t\t}\n\t\t}\n\n\treturn rulesets\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} index\n * @param {number} offset\n * @param {string[]} rules\n * @param {number[]} points\n * @param {string} type\n * @param {string[]} props\n * @param {string[]} children\n * @param {number} length\n * @return {object}\n */\nexport function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length) {\n\tvar post = offset - 1\n\tvar rule = offset === 0 ? rules : ['']\n\tvar size = sizeof(rule)\n\n\tfor (var i = 0, j = 0, k = 0; i < index; ++i)\n\t\tfor (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)\n\t\t\tif (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\\f/g, rule[x])))\n\t\t\t\tprops[k++] = z\n\n\treturn node(value, root, parent, offset === 0 ? RULESET : type, props, children, length)\n}\n\n/**\n * @param {number} value\n * @param {object} root\n * @param {object?} parent\n * @return {object}\n */\nexport function comment (value, root, parent) {\n\treturn node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0)\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} length\n * @return {object}\n */\nexport function declaration (value, root, parent, length) {\n\treturn node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length)\n}\n","import {MS, MOZ, WEBKIT} from './Enum.js'\nimport {hash, charat, strlen, indexof, replace} from './Utility.js'\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {string}\n */\nexport function prefix (value, length) {\n\tswitch (hash(value, length)) {\n\t\t// color-adjust\n\t\tcase 5103:\n\t\t\treturn WEBKIT + 'print-' + value + value\n\t\t// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)\n\t\tcase 5737: case 4201: case 3177: case 3433: case 1641: case 4457: case 2921:\n\t\t// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break\n\t\tcase 5572: case 6356: case 5844: case 3191: case 6645: case 3005:\n\t\t// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,\n\t\tcase 6391: case 5879: case 5623: case 6135: case 4599: case 4855:\n\t\t// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)\n\t\tcase 4215: case 6389: case 5109: case 5365: case 5621: case 3829:\n\t\t\treturn WEBKIT + value + value\n\t\t// appearance, user-select, transform, hyphens, text-size-adjust\n\t\tcase 5349: case 4246: case 4810: case 6968: case 2756:\n\t\t\treturn WEBKIT + value + MOZ + value + MS + value + value\n\t\t// flex, flex-direction\n\t\tcase 6828: case 4268:\n\t\t\treturn WEBKIT + value + MS + value + value\n\t\t// order\n\t\tcase 6165:\n\t\t\treturn WEBKIT + value + MS + 'flex-' + value + value\n\t\t// align-items\n\t\tcase 5187:\n\t\t\treturn WEBKIT + value + replace(value, /(\\w+).+(:[^]+)/, WEBKIT + 'box-$1$2' + MS + 'flex-$1$2') + value\n\t\t// align-self\n\t\tcase 5443:\n\t\t\treturn WEBKIT + value + MS + 'flex-item-' + replace(value, /flex-|-self/, '') + value\n\t\t// align-content\n\t\tcase 4675:\n\t\t\treturn WEBKIT + value + MS + 'flex-line-pack' + replace(value, /align-content|flex-|-self/, '') + value\n\t\t// flex-shrink\n\t\tcase 5548:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value\n\t\t// flex-basis\n\t\tcase 5292:\n\t\t\treturn WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value\n\t\t// flex-grow\n\t\tcase 6060:\n\t\t\treturn WEBKIT + 'box-' + replace(value, '-grow', '') + WEBKIT + value + MS + replace(value, 'grow', 'positive') + value\n\t\t// transition\n\t\tcase 4554:\n\t\t\treturn WEBKIT + replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') + value\n\t\t// cursor\n\t\tcase 6187:\n\t\t\treturn replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + '$1'), /(image-set)/, WEBKIT + '$1'), value, '') + value\n\t\t// background, background-image\n\t\tcase 5495: case 3959:\n\t\t\treturn replace(value, /(image-set\\([^]*)/, WEBKIT + '$1' + '$`$1')\n\t\t// justify-content\n\t\tcase 4968:\n\t\t\treturn replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + WEBKIT + value + value\n\t\t// (margin|padding)-inline-(start|end)\n\t\tcase 4095: case 3583: case 4068: case 2532:\n\t\t\treturn replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value\n\t\t// (min|max)?(width|height|inline-size|block-size)\n\t\tcase 8116: case 7059: case 5753: case 5535:\n\t\tcase 5445: case 5701: case 4933: case 4677:\n\t\tcase 5533: case 5789: case 5021: case 4765:\n\t\t\t// stretch, max-content, min-content, fill-available\n\t\t\tif (strlen(value) - 1 - length > 6)\n\t\t\t\tswitch (charat(value, length + 1)) {\n\t\t\t\t\t// (m)ax-content, (m)in-content\n\t\t\t\t\tcase 109:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (charat(value, length + 4) !== 45)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t// (f)ill-available, (f)it-content\n\t\t\t\t\tcase 102:\n\t\t\t\t\t\treturn replace(value, /(.+:)(.+)-([^]+)/, '$1' + WEBKIT + '$2-$3' + '$1' + MOZ + (charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value\n\t\t\t\t\t// (s)tretch\n\t\t\t\t\tcase 115:\n\t\t\t\t\t\treturn ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length) + value : value\n\t\t\t\t}\n\t\t\tbreak\n\t\t// position: sticky\n\t\tcase 4949:\n\t\t\t// (s)ticky?\n\t\t\tif (charat(value, length + 1) !== 115)\n\t\t\t\tbreak\n\t\t// display: (flex|inline-flex)\n\t\tcase 6444:\n\t\t\tswitch (charat(value, strlen(value) - 3 - (~indexof(value, '!important') && 10))) {\n\t\t\t\t// stic(k)y\n\t\t\t\tcase 107:\n\t\t\t\t\treturn replace(value, ':', ':' + WEBKIT) + value\n\t\t\t\t// (inline-)?fl(e)x\n\t\t\t\tcase 101:\n\t\t\t\t\treturn replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + WEBKIT + (charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + WEBKIT + '$2$3' + '$1' + MS + '$2box$3') + value\n\t\t\t}\n\t\t\tbreak\n\t\t// writing-mode\n\t\tcase 5936:\n\t\t\tswitch (charat(value, length + 11)) {\n\t\t\t\t// vertical-l(r)\n\t\t\t\tcase 114:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb') + value\n\t\t\t\t// vertical-r(l)\n\t\t\t\tcase 108:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'tb-rl') + value\n\t\t\t\t// horizontal(-)tb\n\t\t\t\tcase 45:\n\t\t\t\t\treturn WEBKIT + value + MS + replace(value, /[svh]\\w+-[tblr]{2}/, 'lr') + value\n\t\t\t}\n\n\t\t\treturn WEBKIT + value + MS + value + value\n\t}\n\n\treturn value\n}\n","import {IMPORT, COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {strlen, sizeof} from './Utility.js'\n\n/**\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function serialize (children, callback) {\n\tvar output = ''\n\tvar length = sizeof(children)\n\n\tfor (var i = 0; i < length; i++)\n\t\toutput += callback(children[i], i, children, callback) || ''\n\n\treturn output\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function stringify (element, index, children, callback) {\n\tswitch (element.type) {\n\t\tcase IMPORT: case DECLARATION: return element.return = element.return || element.value\n\t\tcase COMMENT: return ''\n\t\tcase RULESET: element.value = element.props.join(',')\n\t}\n\n\treturn strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''\n}\n","import {MS, MOZ, WEBKIT, RULESET, KEYFRAMES, DECLARATION} from './Enum.js'\nimport {match, charat, substr, strlen, sizeof, replace, combine} from './Utility.js'\nimport {copy, tokenize} from './Tokenizer.js'\nimport {serialize} from './Serializer.js'\nimport {prefix} from './Prefixer.js'\n\n/**\n * @param {function[]} collection\n * @return {function}\n */\nexport function middleware (collection) {\n\tvar length = sizeof(collection)\n\n\treturn function (element, index, children, callback) {\n\t\tvar output = ''\n\n\t\tfor (var i = 0; i < length; i++)\n\t\t\toutput += collection[i](element, index, children, callback) || ''\n\n\t\treturn output\n\t}\n}\n\n/**\n * @param {function} callback\n * @return {function}\n */\nexport function rulesheet (callback) {\n\treturn function (element) {\n\t\tif (!element.root)\n\t\t\tif (element = element.return)\n\t\t\t\tcallback(element)\n\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n */\nexport function prefixer (element, index, children, callback) {\n\tif (!element.return)\n\t\tswitch (element.type) {\n\t\t\tcase DECLARATION: element.return = prefix(element.value, element.length)\n\t\t\t\tbreak\n\t\t\tcase KEYFRAMES:\n\t\t\t\treturn serialize([copy(replace(element.value, '@', '@' + WEBKIT), element, '')], callback)\n\t\t\tcase RULESET:\n\t\t\t\tif (element.length)\n\t\t\t\t\treturn combine(element.props, function (value) {\n\t\t\t\t\t\tswitch (match(value, /(::plac\\w+|:read-\\w+)/)) {\n\t\t\t\t\t\t\t// :read-(only|write)\n\t\t\t\t\t\t\tcase ':read-only': case ':read-write':\n\t\t\t\t\t\t\t\treturn serialize([copy(replace(value, /:(read-\\w+)/, ':' + MOZ + '$1'), element, '')], callback)\n\t\t\t\t\t\t\t// :placeholder\n\t\t\t\t\t\t\tcase '::placeholder':\n\t\t\t\t\t\t\t\treturn serialize([\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, ':' + WEBKIT + 'input-$1'), element, ''),\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, ':' + MOZ + '$1'), element, ''),\n\t\t\t\t\t\t\t\t\tcopy(replace(value, /:(plac\\w+)/, MS + 'input-$1'), element, '')\n\t\t\t\t\t\t\t\t], callback)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn ''\n\t\t\t\t\t})\n\t\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n */\nexport function namespace (element) {\n\tswitch (element.type) {\n\t\tcase RULESET:\n\t\t\telement.props = element.props.map(function (value) {\n\t\t\t\treturn combine(tokenize(value), function (value, index, children) {\n\t\t\t\t\tswitch (charat(value, 0)) {\n\t\t\t\t\t\t// \\f\n\t\t\t\t\t\tcase 12:\n\t\t\t\t\t\t\treturn substr(value, 1, strlen(value))\n\t\t\t\t\t\t// \\0 ( + > ~\n\t\t\t\t\t\tcase 0: case 40: case 43: case 62: case 126:\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t// :\n\t\t\t\t\t\tcase 58:\n\t\t\t\t\t\t\tif (children[++index] === 'global')\n\t\t\t\t\t\t\t\tchildren[index] = '', children[++index] = '\\f' + substr(children[index], index = 1, -1)\n\t\t\t\t\t\t// \\s\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\treturn index === 1 ? '' : value\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tswitch (index) {\n\t\t\t\t\t\t\t\tcase 0: element = value\n\t\t\t\t\t\t\t\t\treturn sizeof(children) > 1 ? '' : value\n\t\t\t\t\t\t\t\tcase index = sizeof(children) - 1: case 2:\n\t\t\t\t\t\t\t\t\treturn index === 2 ? value + element + element : value + element\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t}\n}\n"],"names":["MS","MOZ","WEBKIT","COMMENT","RULESET","DECLARATION","PAGE","MEDIA","IMPORT","CHARSET","VIEWPORT","SUPPORTS","DOCUMENT","NAMESPACE","KEYFRAMES","FONT_FACE","COUNTER_STYLE","FONT_FEATURE_VALUES","abs","Math","from","String","fromCharCode","hash","value","length","charat","trim","match","pattern","exec","replace","replacement","indexof","search","indexOf","index","charCodeAt","substr","begin","end","slice","strlen","sizeof","append","array","push","combine","callback","map","join","line","column","position","character","characters","node","root","parent","type","props","children","return","copy","char","prev","next","peek","caret","token","alloc","dealloc","delimit","delimiter","tokenize","tokenizer","whitespace","identifier","escaping","count","commenter","compile","parse","rule","rules","rulesets","pseudo","points","declarations","offset","atrule","property","previous","variable","scanning","ampersand","reference","comment","declaration","ruleset","post","size","i","j","k","x","y","z","prefix","serialize","output","stringify","element","middleware","collection","rulesheet","prefixer","namespace"],"mappings":"AAAU,IAACA,EAAK,OACN,IAACC,EAAM,QACP,IAACC,EAAS,WAEV,IAACC,EAAU,OACX,IAACC,EAAU,OACX,IAACC,EAAc,OAEf,IAACC,EAAO,QACR,IAACC,EAAQ,SACT,IAACC,EAAS,UACV,IAACC,EAAU,WACX,IAACC,EAAW,YACZ,IAACC,EAAW,YACZ,IAACC,EAAW,YACZ,IAACC,EAAY,aACb,IAACC,EAAY,aACb,IAACC,EAAY,aACb,IAACC,EAAgB,iBACjB,IAACC,EAAsB,uBCfvB,IAACC,EAAMC,KAAKD,IAMZ,IAACE,EAAOC,OAAOC,aAOlB,SAASC,EAAMC,EAAOC,GAC5B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