@linaria/atomic 3.0.0-beta.21 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/esm/CSSProperties.js +0 -0
- package/esm/CSSProperties.js.map +0 -0
- package/esm/css.js +0 -0
- package/esm/css.js.map +0 -0
- package/esm/index.js +0 -0
- package/esm/index.js.map +0 -0
- package/esm/processors/css.js +16 -2
- package/esm/processors/css.js.map +1 -1
- package/esm/processors/helpers/atomize.js +0 -0
- package/esm/processors/helpers/atomize.js.map +0 -0
- package/esm/processors/helpers/propertyPriority.js +0 -0
- package/esm/processors/helpers/propertyPriority.js.map +0 -0
- package/esm/processors/styled.js +18 -7
- package/esm/processors/styled.js.map +1 -1
- package/lib/CSSProperties.js +0 -0
- package/lib/CSSProperties.js.map +0 -0
- package/lib/css.js +0 -0
- package/lib/css.js.map +0 -0
- package/lib/index.js +0 -0
- package/lib/index.js.map +0 -0
- package/lib/processors/css.js +16 -2
- package/lib/processors/css.js.map +1 -1
- package/lib/processors/helpers/atomize.js +0 -0
- package/lib/processors/helpers/atomize.js.map +0 -0
- package/lib/processors/helpers/propertyPriority.js +0 -0
- package/lib/processors/helpers/propertyPriority.js.map +0 -0
- package/lib/processors/styled.js +19 -11
- package/lib/processors/styled.js.map +1 -1
- package/package.json +11 -10
- package/processors/css.js +5 -0
- package/processors/styled.js +5 -0
- package/types/CSSProperties.d.ts +0 -0
- package/types/css.d.ts +0 -0
- package/types/index.d.ts +0 -0
- package/types/processors/css.d.ts +5 -2
- package/types/processors/helpers/atomize.d.ts +0 -0
- package/types/processors/helpers/propertyPriority.d.ts +0 -0
- package/types/processors/styled.d.ts +5 -3
package/README.md
CHANGED
|
@@ -25,11 +25,11 @@ Zero-runtime CSS in JS library.
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
npm install @linaria/core @linaria/react @linaria/babel-preset
|
|
28
|
+
npm install @linaria/core @linaria/react @linaria/babel-preset
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
or
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
yarn add @linaria/core @linaria/react @linaria/babel-preset
|
|
34
|
+
yarn add @linaria/core @linaria/react @linaria/babel-preset
|
|
35
35
|
```
|
package/esm/CSSProperties.js
CHANGED
|
File without changes
|
package/esm/CSSProperties.js.map
CHANGED
|
File without changes
|
package/esm/css.js
CHANGED
|
File without changes
|
package/esm/css.js.map
CHANGED
|
File without changes
|
package/esm/index.js
CHANGED
|
File without changes
|
package/esm/index.js.map
CHANGED
|
File without changes
|
package/esm/processors/css.js
CHANGED
|
@@ -2,6 +2,20 @@ import CssProcessor from '@linaria/core/processors/css';
|
|
|
2
2
|
import { debug } from '@linaria/logger';
|
|
3
3
|
import atomize from './helpers/atomize';
|
|
4
4
|
export default class AtomicCssProcessor extends CssProcessor {
|
|
5
|
+
#classes;
|
|
6
|
+
|
|
7
|
+
get classes() {
|
|
8
|
+
if (this.#classes) {
|
|
9
|
+
return this.#classes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
throw new Error('Styles are not extracted yet. Please call `build` first.');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
doRuntimeReplacement() {
|
|
16
|
+
this.replacer(this.astService.stringLiteral(this.classes), false);
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
extractRules(valueCache, cssText, loc) {
|
|
6
20
|
const rules = {};
|
|
7
21
|
const atomicRules = atomize(cssText, false);
|
|
@@ -16,9 +30,9 @@ export default class AtomicCssProcessor extends CssProcessor {
|
|
|
16
30
|
};
|
|
17
31
|
debug('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
|
|
18
32
|
});
|
|
19
|
-
|
|
33
|
+
this.#classes = atomicRules // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object
|
|
20
34
|
.filter(rule => !!rule.className).map(rule => rule.className).join(' ');
|
|
21
|
-
return
|
|
35
|
+
return rules;
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","names":["CssProcessor","debug","atomize","AtomicCssProcessor","extractRules","valueCache","cssText","loc","rules","atomicRules","forEach","rule","start","className","displayName","atom","
|
|
1
|
+
{"version":3,"file":"css.js","names":["CssProcessor","debug","atomize","AtomicCssProcessor","classes","Error","doRuntimeReplacement","replacer","astService","stringLiteral","extractRules","valueCache","cssText","loc","rules","atomicRules","forEach","rule","start","className","displayName","atom","filter","map","join"],"sources":["../../src/processors/css.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport CssProcessor from '@linaria/core/processors/css';\nimport { debug } from '@linaria/logger';\nimport type { Rules, ValueCache } from '@linaria/tags';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicCssProcessor extends CssProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error('Styles are not extracted yet. Please call `build` first.');\n }\n\n public override doRuntimeReplacement(): void {\n this.replacer(this.astService.stringLiteral(this.classes), false);\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const atomicRules = atomize(cssText, false);\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className!,\n displayName: this.displayName!,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n}\n"],"mappings":"AAEA,OAAOA,YAAP,MAAyB,8BAAzB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAGA,OAAOC,OAAP,MAAoB,mBAApB;AAEA,eAAe,MAAMC,kBAAN,SAAiCH,YAAjC,CAA8C;EAC3D,CAACI,OAAD;;EAEmB,IAAPA,OAAO,GAAW;IAC5B,IAAI,KAAK,CAACA,OAAV,EAAmB;MACjB,OAAO,KAAK,CAACA,OAAb;IACD;;IAED,MAAM,IAAIC,KAAJ,CAAU,0DAAV,CAAN;EACD;;EAEeC,oBAAoB,GAAS;IAC3C,KAAKC,QAAL,CAAc,KAAKC,UAAL,CAAgBC,aAAhB,CAA8B,KAAKL,OAAnC,CAAd,EAA2D,KAA3D;EACD;;EAEeM,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAInB;IACP,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,WAAW,GAAGb,OAAO,CAACU,OAAD,EAAU,KAAV,CAA3B;IACAG,WAAW,CAACC,OAAZ,CAAqBC,IAAD,IAAU;MAC5B;MACAH,KAAK,CAACG,IAAI,CAACL,OAAN,CAAL,GAAsB;QACpBA,OAAO,EAAEK,IAAI,CAACL,OADM;QAEpBM,KAAK,EAAEL,GAAG,EAAEK,KAAL,IAAc,IAFD;QAGpBC,SAAS,EAAE,KAAKA,SAHI;QAIpBC,WAAW,EAAE,KAAKA,WAJE;QAKpBC,IAAI,EAAE;MALc,CAAtB;MAQApB,KAAK,CACH,oDADG,EAEF,KAAIgB,IAAI,CAACL,OAAQ,EAFf,CAAL;IAID,CAdD;IAgBA,KAAK,CAACR,OAAN,GAAgBW,WAAW,CACzB;IADyB,CAExBO,MAFa,CAELL,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbI,GAHa,CAGRN,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbK,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAOV,KAAP;EACD;;AA9C0D"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/esm/processors/styled.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { debug } from '@linaria/logger';
|
|
2
|
-
import StyledProcessor
|
|
2
|
+
import StyledProcessor from '@linaria/react/processors/styled';
|
|
3
|
+
import { hasMeta } from '@linaria/tags';
|
|
3
4
|
import { slugify } from '@linaria/utils';
|
|
4
5
|
import atomize from './helpers/atomize';
|
|
5
6
|
export default class AtomicStyledProcessor extends StyledProcessor {
|
|
7
|
+
#classes;
|
|
8
|
+
|
|
9
|
+
get classes() {
|
|
10
|
+
if (this.#classes) {
|
|
11
|
+
return this.#classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
throw new Error('Styles are not extracted yet. Please call `extractRules` first.');
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
extractRules(valueCache, cssText, loc) {
|
|
7
18
|
const rules = {};
|
|
8
|
-
const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node);
|
|
19
|
+
const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node.name);
|
|
9
20
|
const atomicRules = atomize(cssText, hasMeta(wrappedValue));
|
|
10
21
|
atomicRules.forEach(rule => {
|
|
11
22
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -18,14 +29,14 @@ export default class AtomicStyledProcessor extends StyledProcessor {
|
|
|
18
29
|
};
|
|
19
30
|
debug('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
|
|
20
31
|
});
|
|
21
|
-
|
|
32
|
+
this.#classes = atomicRules // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object
|
|
22
33
|
.filter(rule => !!rule.className).map(rule => rule.className).join(' ');
|
|
23
|
-
return
|
|
34
|
+
return rules;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
|
-
getProps(
|
|
27
|
-
const props = super.getProps(
|
|
28
|
-
props.class = [classes, this.className].filter(Boolean).join(' ');
|
|
37
|
+
getProps() {
|
|
38
|
+
const props = super.getProps();
|
|
39
|
+
props.class = [this.classes, this.className].filter(Boolean).join(' ');
|
|
29
40
|
props.atomic = true;
|
|
30
41
|
return props;
|
|
31
42
|
} // eslint-disable-next-line class-methods-use-this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","names":["debug","StyledProcessor","hasMeta","slugify","atomize","AtomicStyledProcessor","extractRules","valueCache","cssText","loc","rules","wrappedValue","component","get","node","atomicRules","forEach","rule","start","className","displayName","atom","
|
|
1
|
+
{"version":3,"file":"styled.js","names":["debug","StyledProcessor","hasMeta","slugify","atomize","AtomicStyledProcessor","classes","Error","extractRules","valueCache","cssText","loc","rules","wrappedValue","component","get","node","name","atomicRules","forEach","rule","start","className","displayName","atom","filter","map","join","getProps","props","class","Boolean","atomic","getVariableId","value"],"sources":["../../src/processors/styled.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport { hasMeta } from '@linaria/tags';\nimport type { Rules, ValueCache } from '@linaria/tags';\nimport { slugify } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected override getVariableId(value: string): string {\n // id is based on the slugified value\n return slugify(value);\n }\n}\n"],"mappings":"AAEA,SAASA,KAAT,QAAsB,iBAAtB;AAEA,OAAOC,eAAP,MAA4B,kCAA5B;AACA,SAASC,OAAT,QAAwB,eAAxB;AAEA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,OAAP,MAAoB,mBAApB;AAEA,eAAe,MAAMC,qBAAN,SAAoCJ,eAApC,CAAoD;EACjE,CAACK,OAAD;;EAEmB,IAAPA,OAAO,GAAW;IAC5B,IAAI,KAAK,CAACA,OAAV,EAAmB;MACjB,OAAO,KAAK,CAACA,OAAb;IACD;;IAED,MAAM,IAAIC,KAAJ,CACJ,iEADI,CAAN;EAGD;;EAEeC,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAInB;IACP,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,YAAY,GAChB,OAAO,KAAKC,SAAZ,KAA0B,QAA1B,GACI,IADJ,GAEIL,UAAU,CAACM,GAAX,CAAe,KAAKD,SAAL,CAAeE,IAAf,CAAoBC,IAAnC,CAHN;IAKA,MAAMC,WAAW,GAAGd,OAAO,CAACM,OAAD,EAAUR,OAAO,CAACW,YAAD,CAAjB,CAA3B;IACAK,WAAW,CAACC,OAAZ,CAAqBC,IAAD,IAAU;MAC5B;MACAR,KAAK,CAACQ,IAAI,CAACV,OAAN,CAAL,GAAsB;QACpBA,OAAO,EAAEU,IAAI,CAACV,OADM;QAEpBW,KAAK,EAAEV,GAAG,EAAEU,KAAL,IAAc,IAFD;QAGpBC,SAAS,EAAE,KAAKA,SAHI;QAIpBC,WAAW,EAAE,KAAKA,WAJE;QAKpBC,IAAI,EAAE;MALc,CAAtB;MAQAxB,KAAK,CACH,oDADG,EAEF,KAAIoB,IAAI,CAACV,OAAQ,EAFf,CAAL;IAID,CAdD;IAgBA,KAAK,CAACJ,OAAN,GAAgBY,WAAW,CACzB;IADyB,CAExBO,MAFa,CAELL,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbI,GAHa,CAGRN,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbK,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAOf,KAAP;EACD;;EAEkBgB,QAAQ,GAAW;IACpC,MAAMC,KAAK,GAAG,MAAMD,QAAN,EAAd;IACAC,KAAK,CAACC,KAAN,GAAc,CAAC,KAAKxB,OAAN,EAAe,KAAKgB,SAApB,EAA+BG,MAA/B,CAAsCM,OAAtC,EAA+CJ,IAA/C,CAAoD,GAApD,CAAd;IACAE,KAAK,CAACG,MAAN,GAAe,IAAf;IACA,OAAOH,KAAP;EACD,CAxDgE,CA0DjE;;;EACmBI,aAAa,CAACC,KAAD,EAAwB;IACtD;IACA,OAAO/B,OAAO,CAAC+B,KAAD,CAAd;EACD;;AA9DgE"}
|
package/lib/CSSProperties.js
CHANGED
|
File without changes
|
package/lib/CSSProperties.js.map
CHANGED
|
File without changes
|
package/lib/css.js
CHANGED
|
File without changes
|
package/lib/css.js.map
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/index.js.map
CHANGED
|
File without changes
|
package/lib/processors/css.js
CHANGED
|
@@ -14,6 +14,20 @@ var _atomize = _interopRequireDefault(require("./helpers/atomize"));
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
class AtomicCssProcessor extends _css.default {
|
|
17
|
+
#classes;
|
|
18
|
+
|
|
19
|
+
get classes() {
|
|
20
|
+
if (this.#classes) {
|
|
21
|
+
return this.#classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error('Styles are not extracted yet. Please call `build` first.');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
doRuntimeReplacement() {
|
|
28
|
+
this.replacer(this.astService.stringLiteral(this.classes), false);
|
|
29
|
+
}
|
|
30
|
+
|
|
17
31
|
extractRules(valueCache, cssText, loc) {
|
|
18
32
|
const rules = {};
|
|
19
33
|
const atomicRules = (0, _atomize.default)(cssText, false);
|
|
@@ -30,9 +44,9 @@ class AtomicCssProcessor extends _css.default {
|
|
|
30
44
|
};
|
|
31
45
|
(0, _logger.debug)('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
|
|
32
46
|
});
|
|
33
|
-
|
|
47
|
+
this.#classes = atomicRules // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object
|
|
34
48
|
.filter(rule => !!rule.className).map(rule => rule.className).join(' ');
|
|
35
|
-
return
|
|
49
|
+
return rules;
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","names":["AtomicCssProcessor","CssProcessor","extractRules","valueCache","cssText","loc","rules","atomicRules","atomize","forEach","rule","start","className","displayName","atom","debug","
|
|
1
|
+
{"version":3,"file":"css.js","names":["AtomicCssProcessor","CssProcessor","classes","Error","doRuntimeReplacement","replacer","astService","stringLiteral","extractRules","valueCache","cssText","loc","rules","atomicRules","atomize","forEach","rule","start","className","displayName","atom","debug","filter","map","join"],"sources":["../../src/processors/css.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport CssProcessor from '@linaria/core/processors/css';\nimport { debug } from '@linaria/logger';\nimport type { Rules, ValueCache } from '@linaria/tags';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicCssProcessor extends CssProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error('Styles are not extracted yet. Please call `build` first.');\n }\n\n public override doRuntimeReplacement(): void {\n this.replacer(this.astService.stringLiteral(this.classes), false);\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const atomicRules = atomize(cssText, false);\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className!,\n displayName: this.displayName!,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;AAGA;;;;AAEe,MAAMA,kBAAN,SAAiCC,YAAjC,CAA8C;EAC3D,CAACC,OAAD;;EAEmB,IAAPA,OAAO,GAAW;IAC5B,IAAI,KAAK,CAACA,OAAV,EAAmB;MACjB,OAAO,KAAK,CAACA,OAAb;IACD;;IAED,MAAM,IAAIC,KAAJ,CAAU,0DAAV,CAAN;EACD;;EAEeC,oBAAoB,GAAS;IAC3C,KAAKC,QAAL,CAAc,KAAKC,UAAL,CAAgBC,aAAhB,CAA8B,KAAKL,OAAnC,CAAd,EAA2D,KAA3D;EACD;;EAEeM,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAInB;IACP,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,WAAW,GAAG,IAAAC,gBAAA,EAAQJ,OAAR,EAAiB,KAAjB,CAApB;IACAG,WAAW,CAACE,OAAZ,CAAqBC,IAAD,IAAU;MAAA;;MAC5B;MACAJ,KAAK,CAACI,IAAI,CAACN,OAAN,CAAL,GAAsB;QACpBA,OAAO,EAAEM,IAAI,CAACN,OADM;QAEpBO,KAAK,gBAAEN,GAAF,aAAEA,GAAF,uBAAEA,GAAG,CAAEM,KAAP,mDAAgB,IAFD;QAGpBC,SAAS,EAAE,KAAKA,SAHI;QAIpBC,WAAW,EAAE,KAAKA,WAJE;QAKpBC,IAAI,EAAE;MALc,CAAtB;MAQA,IAAAC,aAAA,EACE,oDADF,EAEG,KAAIL,IAAI,CAACN,OAAQ,EAFpB;IAID,CAdD;IAgBA,KAAK,CAACR,OAAN,GAAgBW,WAAW,CACzB;IADyB,CAExBS,MAFa,CAELN,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbK,GAHa,CAGRP,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbM,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAOZ,KAAP;EACD;;AA9C0D"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/processors/styled.js
CHANGED
|
@@ -7,7 +7,9 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _logger = require("@linaria/logger");
|
|
9
9
|
|
|
10
|
-
var _styled =
|
|
10
|
+
var _styled = _interopRequireDefault(require("@linaria/react/processors/styled"));
|
|
11
|
+
|
|
12
|
+
var _tags = require("@linaria/tags");
|
|
11
13
|
|
|
12
14
|
var _utils = require("@linaria/utils");
|
|
13
15
|
|
|
@@ -15,15 +17,21 @@ var _atomize = _interopRequireDefault(require("./helpers/atomize"));
|
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
class AtomicStyledProcessor extends _styled.default {
|
|
21
|
+
#classes;
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
get classes() {
|
|
24
|
+
if (this.#classes) {
|
|
25
|
+
return this.#classes;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
throw new Error('Styles are not extracted yet. Please call `extractRules` first.');
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
class AtomicStyledProcessor extends _styled.default {
|
|
23
31
|
extractRules(valueCache, cssText, loc) {
|
|
24
32
|
const rules = {};
|
|
25
|
-
const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node);
|
|
26
|
-
const atomicRules = (0, _atomize.default)(cssText, (0,
|
|
33
|
+
const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node.name);
|
|
34
|
+
const atomicRules = (0, _atomize.default)(cssText, (0, _tags.hasMeta)(wrappedValue));
|
|
27
35
|
atomicRules.forEach(rule => {
|
|
28
36
|
var _loc$start;
|
|
29
37
|
|
|
@@ -37,14 +45,14 @@ class AtomicStyledProcessor extends _styled.default {
|
|
|
37
45
|
};
|
|
38
46
|
(0, _logger.debug)('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
|
|
39
47
|
});
|
|
40
|
-
|
|
48
|
+
this.#classes = atomicRules // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object
|
|
41
49
|
.filter(rule => !!rule.className).map(rule => rule.className).join(' ');
|
|
42
|
-
return
|
|
50
|
+
return rules;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
getProps(
|
|
46
|
-
const props = super.getProps(
|
|
47
|
-
props.class = [classes, this.className].filter(Boolean).join(' ');
|
|
53
|
+
getProps() {
|
|
54
|
+
const props = super.getProps();
|
|
55
|
+
props.class = [this.classes, this.className].filter(Boolean).join(' ');
|
|
48
56
|
props.atomic = true;
|
|
49
57
|
return props;
|
|
50
58
|
} // eslint-disable-next-line class-methods-use-this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","names":["AtomicStyledProcessor","StyledProcessor","extractRules","valueCache","cssText","loc","rules","wrappedValue","component","get","node","atomicRules","atomize","hasMeta","forEach","rule","start","className","displayName","atom","debug","
|
|
1
|
+
{"version":3,"file":"styled.js","names":["AtomicStyledProcessor","StyledProcessor","classes","Error","extractRules","valueCache","cssText","loc","rules","wrappedValue","component","get","node","name","atomicRules","atomize","hasMeta","forEach","rule","start","className","displayName","atom","debug","filter","map","join","getProps","props","class","Boolean","atomic","getVariableId","value","slugify"],"sources":["../../src/processors/styled.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor from '@linaria/react/processors/styled';\nimport { hasMeta } from '@linaria/tags';\nimport type { Rules, ValueCache } from '@linaria/tags';\nimport { slugify } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error(\n 'Styles are not extracted yet. Please call `extractRules` first.'\n );\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node.name);\n\n const atomicRules = atomize(cssText, hasMeta(wrappedValue));\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className,\n displayName: this.displayName,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n\n protected override getProps(): IProps {\n const props = super.getProps();\n props.class = [this.classes, this.className].filter(Boolean).join(' ');\n props.atomic = true;\n return props;\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected override getVariableId(value: string): string {\n // id is based on the slugified value\n return slugify(value);\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;;;AAEe,MAAMA,qBAAN,SAAoCC,eAApC,CAAoD;EACjE,CAACC,OAAD;;EAEmB,IAAPA,OAAO,GAAW;IAC5B,IAAI,KAAK,CAACA,OAAV,EAAmB;MACjB,OAAO,KAAK,CAACA,OAAb;IACD;;IAED,MAAM,IAAIC,KAAJ,CACJ,iEADI,CAAN;EAGD;;EAEeC,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAInB;IACP,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,YAAY,GAChB,OAAO,KAAKC,SAAZ,KAA0B,QAA1B,GACI,IADJ,GAEIL,UAAU,CAACM,GAAX,CAAe,KAAKD,SAAL,CAAeE,IAAf,CAAoBC,IAAnC,CAHN;IAKA,MAAMC,WAAW,GAAG,IAAAC,gBAAA,EAAQT,OAAR,EAAiB,IAAAU,aAAA,EAAQP,YAAR,CAAjB,CAApB;IACAK,WAAW,CAACG,OAAZ,CAAqBC,IAAD,IAAU;MAAA;;MAC5B;MACAV,KAAK,CAACU,IAAI,CAACZ,OAAN,CAAL,GAAsB;QACpBA,OAAO,EAAEY,IAAI,CAACZ,OADM;QAEpBa,KAAK,gBAAEZ,GAAF,aAAEA,GAAF,uBAAEA,GAAG,CAAEY,KAAP,mDAAgB,IAFD;QAGpBC,SAAS,EAAE,KAAKA,SAHI;QAIpBC,WAAW,EAAE,KAAKA,WAJE;QAKpBC,IAAI,EAAE;MALc,CAAtB;MAQA,IAAAC,aAAA,EACE,oDADF,EAEG,KAAIL,IAAI,CAACZ,OAAQ,EAFpB;IAID,CAdD;IAgBA,KAAK,CAACJ,OAAN,GAAgBY,WAAW,CACzB;IADyB,CAExBU,MAFa,CAELN,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbK,GAHa,CAGRP,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbM,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAOlB,KAAP;EACD;;EAEkBmB,QAAQ,GAAW;IACpC,MAAMC,KAAK,GAAG,MAAMD,QAAN,EAAd;IACAC,KAAK,CAACC,KAAN,GAAc,CAAC,KAAK3B,OAAN,EAAe,KAAKkB,SAApB,EAA+BI,MAA/B,CAAsCM,OAAtC,EAA+CJ,IAA/C,CAAoD,GAApD,CAAd;IACAE,KAAK,CAACG,MAAN,GAAe,IAAf;IACA,OAAOH,KAAP;EACD,CAxDgE,CA0DjE;;;EACmBI,aAAa,CAACC,KAAD,EAAwB;IACtD;IACA,OAAO,IAAAC,cAAA,EAAQD,KAAR,CAAP;EACD;;AA9DgE"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linaria/atomic",
|
|
3
3
|
"description": "Blazing fast zero-runtime CSS in JS library",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-beta.1",
|
|
5
5
|
"bugs": "https://github.com/callstack/linaria/issues",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@linaria/core": "^
|
|
8
|
-
"@linaria/logger": "^
|
|
9
|
-
"@linaria/react": "^
|
|
10
|
-
"@linaria/
|
|
7
|
+
"@linaria/core": "^4.0.0-beta.1",
|
|
8
|
+
"@linaria/logger": "^4.0.0-beta.1",
|
|
9
|
+
"@linaria/react": "^4.0.0-beta.1",
|
|
10
|
+
"@linaria/tags": "^4.0.0-beta.1",
|
|
11
|
+
"@linaria/utils": "^4.0.0-beta.1",
|
|
11
12
|
"known-css-properties": "^0.24.0",
|
|
12
13
|
"postcss": "^8.3.11",
|
|
13
14
|
"stylis": "^3.5.4",
|
|
14
15
|
"ts-invariant": "^0.10.3"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@babel/types": "^7.18.
|
|
18
|
+
"@babel/types": "^7.18.9"
|
|
18
19
|
},
|
|
19
20
|
"engines": {
|
|
20
21
|
"node": "^12.16.0 || >=13.7.0"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
|
-
"
|
|
24
|
+
"esm/",
|
|
24
25
|
"lib/",
|
|
25
|
-
"
|
|
26
|
+
"processors/",
|
|
27
|
+
"types/"
|
|
26
28
|
],
|
|
27
29
|
"homepage": "https://github.com/callstack/linaria#readme",
|
|
28
30
|
"keywords": [
|
|
@@ -54,6 +56,5 @@
|
|
|
54
56
|
"build:lib": "cross-env NODE_ENV=legacy babel src --out-dir lib --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
|
|
55
57
|
"typecheck": "tsc --noEmit --composite false",
|
|
56
58
|
"watch": "npm run build --watch"
|
|
57
|
-
}
|
|
58
|
-
"readme": "<p align=\"center\">\n <img alt=\"Linaria\" src=\"https://raw.githubusercontent.com/callstack/linaria/HEAD/website/assets/linaria-logo@2x.png\" width=\"496\">\n</p>\n\n<p align=\"center\">\nZero-runtime CSS in JS library.\n</p>\n\n---\n\n### 📖 Please refer to the [GitHub](https://github.com/callstack/linaria#readme) for full documentation.\n\n## Features\n\n- Write CSS in JS, but with **zero runtime**, CSS is extracted to CSS files during build\n- Familiar **CSS syntax** with Sass like nesting\n- Use **dynamic prop based styles** with the React bindings, uses CSS variables behind the scenes\n- Easily find where the style was defined with **CSS sourcemaps**\n- **Lint your CSS** in JS with [stylelint](https://github.com/stylelint/stylelint)\n- Use **JavaScript for logic**, no CSS preprocessor needed\n- Optionally use any **CSS preprocessor** such as Sass or PostCSS\n\n**[Why use Linaria](../../docs/BENEFITS.md)**\n\n## Installation\n\n```sh\nnpm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker\n```\n\nor\n\n```sh\nyarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker\n```\n"
|
|
59
|
+
}
|
|
59
60
|
}
|
package/types/CSSProperties.d.ts
CHANGED
|
File without changes
|
package/types/css.d.ts
CHANGED
|
File without changes
|
package/types/index.d.ts
CHANGED
|
File without changes
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { SourceLocation } from '@babel/types';
|
|
2
2
|
import CssProcessor from '@linaria/core/processors/css';
|
|
3
|
-
import type { Rules, ValueCache } from '@linaria/
|
|
3
|
+
import type { Rules, ValueCache } from '@linaria/tags';
|
|
4
4
|
export default class AtomicCssProcessor extends CssProcessor {
|
|
5
|
-
|
|
5
|
+
#private;
|
|
6
|
+
private get classes();
|
|
7
|
+
doRuntimeReplacement(): void;
|
|
8
|
+
extractRules(valueCache: ValueCache, cssText: string, loc?: SourceLocation | null): Rules;
|
|
6
9
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SourceLocation } from '@babel/types';
|
|
2
|
-
import type { IInterpolation, Rules, ValueCache } from '@linaria/core/processors/types';
|
|
3
2
|
import type { IProps } from '@linaria/react/processors/styled';
|
|
4
3
|
import StyledProcessor from '@linaria/react/processors/styled';
|
|
4
|
+
import type { Rules, ValueCache } from '@linaria/tags';
|
|
5
5
|
export default class AtomicStyledProcessor extends StyledProcessor {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
#private;
|
|
7
|
+
private get classes();
|
|
8
|
+
extractRules(valueCache: ValueCache, cssText: string, loc?: SourceLocation | null): Rules;
|
|
9
|
+
protected getProps(): IProps;
|
|
8
10
|
protected getVariableId(value: string): string;
|
|
9
11
|
}
|