@linaria/atomic 3.0.0-beta.18 → 3.0.0-beta.21

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.
Files changed (42) hide show
  1. package/esm/CSSProperties.js +0 -0
  2. package/esm/CSSProperties.js.map +1 -1
  3. package/esm/css.js +0 -0
  4. package/esm/css.js.map +1 -1
  5. package/esm/index.js +2 -2
  6. package/esm/index.js.map +1 -1
  7. package/esm/processors/css.js +25 -0
  8. package/esm/processors/css.js.map +1 -0
  9. package/esm/{atomize.js → processors/helpers/atomize.js} +17 -5
  10. package/esm/processors/helpers/atomize.js.map +1 -0
  11. package/esm/{propertyPriority.js → processors/helpers/propertyPriority.js} +1 -6
  12. package/esm/processors/helpers/propertyPriority.js.map +1 -0
  13. package/esm/processors/styled.js +40 -0
  14. package/esm/processors/styled.js.map +1 -0
  15. package/lib/CSSProperties.js +0 -0
  16. package/lib/CSSProperties.js.map +1 -1
  17. package/lib/css.js +1 -3
  18. package/lib/css.js.map +1 -1
  19. package/lib/index.js +10 -23
  20. package/lib/index.js.map +1 -1
  21. package/lib/processors/css.js +41 -0
  22. package/lib/processors/css.js.map +1 -0
  23. package/lib/{atomize.js → processors/helpers/atomize.js} +18 -8
  24. package/lib/processors/helpers/atomize.js.map +1 -0
  25. package/lib/{propertyPriority.js → processors/helpers/propertyPriority.js} +1 -6
  26. package/lib/processors/helpers/propertyPriority.js.map +1 -0
  27. package/lib/processors/styled.js +61 -0
  28. package/lib/processors/styled.js.map +1 -0
  29. package/package.json +41 -28
  30. package/types/CSSProperties.d.ts +0 -0
  31. package/types/css.d.ts +1 -1
  32. package/types/index.d.ts +2 -2
  33. package/types/processors/css.d.ts +6 -0
  34. package/types/{atomize.d.ts → processors/helpers/atomize.d.ts} +1 -1
  35. package/types/processors/helpers/propertyPriority.d.ts +1 -0
  36. package/types/processors/styled.d.ts +9 -0
  37. package/CHANGELOG.md +0 -24
  38. package/esm/atomize.js.map +0 -1
  39. package/esm/propertyPriority.js.map +0 -1
  40. package/lib/atomize.js.map +0 -1
  41. package/lib/propertyPriority.js.map +0 -1
  42. package/types/propertyPriority.d.ts +0 -1
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"CSSProperties.js"}
1
+ {"version":3,"file":"CSSProperties.js","names":[],"sources":["../src/CSSProperties.ts"],"sourcesContent":["export type CSSProperties = {\n [key: string]: string | number | CSSProperties;\n};\n"],"mappings":""}
package/esm/css.js CHANGED
File without changes
package/esm/css.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/css.ts"],"names":["css","Error"],"mappings":"AAQA,OAAO,MAAMA,GAAQ,GAAG,MAAM;AAC5B,QAAM,IAAIC,KAAJ,CACJ,wGADI,CAAN;AAGD,CAJM;AAMP,eAAeD,GAAf","sourcesContent":["import type { LinariaClassName } from '@linaria/utils';\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n"],"file":"css.js"}
1
+ {"version":3,"file":"css.js","names":["css","Error"],"sources":["../src/css.ts"],"sourcesContent":["import type { LinariaClassName } from '@linaria/core';\n\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n"],"mappings":"AASA,OAAO,MAAMA,GAAQ,GAAG,MAAM;EAC5B,MAAM,IAAIC,KAAJ,CACJ,wGADI,CAAN;AAGD,CAJM;AAMP,eAAeD,GAAf"}
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as css } from './css';
2
- export { default as atomize } from './atomize';
3
- export { cx } from '@linaria/utils';
2
+ export { styled } from '@linaria/react';
3
+ export { cx } from '@linaria/core';
4
4
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["default","css","atomize","cx"],"mappings":"AAAA,SAASA,OAAO,IAAIC,GAApB,QAA+B,OAA/B;AACA,SAASD,OAAO,IAAIE,OAApB,QAAmC,WAAnC;AACA,SAASC,EAAT,QAAmB,gBAAnB","sourcesContent":["export { default as css } from './css';\nexport { default as atomize } from './atomize';\nexport { cx } from '@linaria/utils';\n\nexport type { CSSProperties } from './CSSProperties';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["default","css","styled","cx"],"sources":["../src/index.ts"],"sourcesContent":["export { default as css } from './css';\nexport { styled } from '@linaria/react';\nexport { cx } from '@linaria/core';\n\nexport type { CSSProperties } from './CSSProperties';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,GAApB,QAA+B,OAA/B;AACA,SAASC,MAAT,QAAuB,gBAAvB;AACA,SAASC,EAAT,QAAmB,eAAnB"}
@@ -0,0 +1,25 @@
1
+ import CssProcessor from '@linaria/core/processors/css';
2
+ import { debug } from '@linaria/logger';
3
+ import atomize from './helpers/atomize';
4
+ export default class AtomicCssProcessor extends CssProcessor {
5
+ extractRules(valueCache, cssText, loc) {
6
+ const rules = {};
7
+ const atomicRules = atomize(cssText, false);
8
+ atomicRules.forEach(rule => {
9
+ // eslint-disable-next-line no-param-reassign
10
+ rules[rule.cssText] = {
11
+ cssText: rule.cssText,
12
+ start: loc?.start ?? null,
13
+ className: this.className,
14
+ displayName: this.displayName,
15
+ atom: true
16
+ };
17
+ debug('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
18
+ });
19
+ const 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
+ .filter(rule => !!rule.className).map(rule => rule.className).join(' ');
21
+ return [rules, classes];
22
+ }
23
+
24
+ }
25
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","names":["CssProcessor","debug","atomize","AtomicCssProcessor","extractRules","valueCache","cssText","loc","rules","atomicRules","forEach","rule","start","className","displayName","atom","classes","filter","map","join"],"sources":["../../src/processors/css.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport CssProcessor from '@linaria/core/processors/css';\nimport type { Rules, ValueCache } from '@linaria/core/processors/types';\nimport { debug } from '@linaria/logger';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicCssProcessor extends CssProcessor {\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): [Rules, string] {\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 const 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, classes];\n }\n}\n"],"mappings":"AAEA,OAAOA,YAAP,MAAyB,8BAAzB;AAEA,SAASC,KAAT,QAAsB,iBAAtB;AAEA,OAAOC,OAAP,MAAoB,mBAApB;AAEA,eAAe,MAAMC,kBAAN,SAAiCH,YAAjC,CAA8C;EAC3CI,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAIT;IACjB,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,WAAW,GAAGP,OAAO,CAACI,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;MAQAd,KAAK,CACH,oDADG,EAEF,KAAIU,IAAI,CAACL,OAAQ,EAFf,CAAL;IAID,CAdD;IAgBA,MAAMU,OAAO,GAAGP,WAAW,CACzB;IADyB,CAExBQ,MAFa,CAELN,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbK,GAHa,CAGRP,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbM,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAO,CAACX,KAAD,EAAQQ,OAAR,CAAP;EACD;;AAhC0D"}
@@ -1,7 +1,7 @@
1
+ import { all as knownProperties } from 'known-css-properties';
1
2
  import postcss from 'postcss';
2
- import { slugify } from '@linaria/utils';
3
3
  import stylis from 'stylis';
4
- import { all as knownProperties } from 'known-css-properties';
4
+ import { slugify } from '@linaria/utils';
5
5
  import { getPropertyPriority } from './propertyPriority';
6
6
  const knownPropertiesMap = knownProperties.reduce((acc, property, i) => {
7
7
  acc[property] = i;
@@ -19,13 +19,25 @@ function hashProperty(property) {
19
19
  return slugify(property);
20
20
  }
21
21
 
22
- export default function atomize(cssText) {
22
+ const parseCss = cssText => {
23
+ try {
24
+ return postcss.parse(cssText);
25
+ } catch (e) {
26
+ if (e instanceof Error) {
27
+ throw new Error(`Error parsing CSS: ${e.message}\nCSS:\n${cssText}`);
28
+ }
29
+
30
+ throw new Error(`Unknown error parsing CSS.\nCSS:\n${cssText}`);
31
+ }
32
+ };
33
+
34
+ export default function atomize(cssText, hasPriority = false) {
23
35
  stylis.set({
24
36
  prefix: false,
25
37
  keyframe: false
26
38
  });
27
39
  const atomicRules = [];
28
- const stylesheet = postcss.parse(cssText); // We want to extract all keyframes and leave them as-is.
40
+ const stylesheet = parseCss(cssText); // We want to extract all keyframes and leave them as-is.
29
41
  // This isn't scoped locally yet
30
42
 
31
43
  stylesheet.walkAtRules('keyframes', atRule => {
@@ -75,7 +87,7 @@ export default function atomize(cssText) {
75
87
  const propertySlug = hashProperty([...atomicProperty].join(';'));
76
88
  const valueSlug = slugify(decl.value);
77
89
  const className = `atm_${propertySlug}_${valueSlug}`;
78
- const propertyPriority = getPropertyPriority(decl.prop) + (hasAtRule ? 1 : 0);
90
+ const propertyPriority = getPropertyPriority(decl.prop) + (hasAtRule ? 1 : 0) + (hasPriority ? 1 : 0);
79
91
  const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);
80
92
  atomicRules.push({
81
93
  property: atomicProperty.join(' '),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomize.js","names":["all","knownProperties","postcss","stylis","slugify","getPropertyPriority","knownPropertiesMap","reduce","acc","property","i","hashProperty","index","undefined","toString","parseCss","cssText","parse","e","Error","message","atomize","hasPriority","set","prefix","keyframe","atomicRules","stylesheet","walkAtRules","atRule","remove","push","name","walkDecls","decl","thisParent","parent","parents","atomicProperty","prop","hasAtRule","unshift","type","params","selector","root","container","forEach","newNode","clone","removeAll","append","css","propertySlug","join","valueSlug","value","className","propertyPriority","processedCss","repeat"],"sources":["../../../src/processors/helpers/atomize.ts"],"sourcesContent":["import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n"],"mappings":"AAAA,SAASA,GAAG,IAAIC,eAAhB,QAAuC,sBAAvC;AAEA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AAEA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,SAASC,mBAAT,QAAoC,oBAApC;AAEA,MAAMC,kBAAkB,GAAGL,eAAe,CAACM,MAAhB,CACzB,CAACC,GAAD,EAAsCC,QAAtC,EAAgDC,CAAhD,KAAsD;EACpDF,GAAG,CAACC,QAAD,CAAH,GAAgBC,CAAhB;EACA,OAAOF,GAAP;AACD,CAJwB,EAKzB,EALyB,CAA3B;;AAQA,SAASG,YAAT,CAAsBF,QAAtB,EAAwC;EACtC,MAAMG,KAAK,GAAGN,kBAAkB,CAACG,QAAD,CAAhC,CADsC,CAEtC;EACA;;EACA,IAAIG,KAAK,KAAKC,SAAd,EAAyB;IACvB,OAAOD,KAAK,CAACE,QAAN,CAAe,EAAf,CAAP,CADuB,CACI;EAC5B;;EACD,OAAOV,OAAO,CAACK,QAAD,CAAd;AACD;;AAED,MAAMM,QAAQ,GAAIC,OAAD,IAAqB;EACpC,IAAI;IACF,OAAOd,OAAO,CAACe,KAAR,CAAcD,OAAd,CAAP;EACD,CAFD,CAEE,OAAOE,CAAP,EAAU;IACV,IAAIA,CAAC,YAAYC,KAAjB,EAAwB;MACtB,MAAM,IAAIA,KAAJ,CAAW,sBAAqBD,CAAC,CAACE,OAAQ,WAAUJ,OAAQ,EAA5D,CAAN;IACD;;IAED,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,OAAQ,EAAvD,CAAN;EACD;AACF,CAVD;;AAYA,eAAe,SAASK,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R,EAAb;IACA,IAAIC,SAA+B,GAAGD,IAAtC;IACAR,OAAO,CAACU,OAAR,CAAiBX,MAAD,IAAY;MAC1B,MAAMY,OAAO,GAAGZ,MAAM,CAACa,KAAP,EAAhB;MACAD,OAAO,CAACE,SAAR;MACAJ,SAAS,CAACK,MAAV,CAAiBH,OAAjB;MACAF,SAAS,GAAGE,OAAZ;IACD,CALD;IAMAF,SAAS,CAACK,MAAV,CAAiBjB,IAAI,CAACe,KAAL,EAAjB;IAEA,MAAMG,GAAG,GAAGP,IAAI,CAAC/B,QAAL,EAAZ;IACA,MAAMuC,YAAY,GAAG1C,YAAY,CAAC,CAAC,GAAG2B,cAAJ,EAAoBgB,IAApB,CAAyB,GAAzB,CAAD,CAAjC;IACA,MAAMC,SAAS,GAAGnD,OAAO,CAAC8B,IAAI,CAACsB,KAAN,CAAzB;IACA,MAAMC,SAAS,GAAI,OAAMJ,YAAa,IAAGE,SAAU,EAAnD;IAEA,MAAMG,gBAAgB,GACpBrD,mBAAmB,CAAC6B,IAAI,CAACK,IAAN,CAAnB,IACCC,SAAS,GAAG,CAAH,GAAO,CADjB,KAEClB,WAAW,GAAG,CAAH,GAAO,CAFnB,CADF;IAIA,MAAMqC,YAAY,GAAGxD,MAAM,CAAE,IAAGsD,SAAU,EAAd,CAAgBG,MAAhB,CAAuBF,gBAAvB,CAAD,EAA2CN,GAA3C,CAA3B;IAEA1B,WAAW,CAACK,IAAZ,CAAiB;MACftB,QAAQ,EAAE6B,cAAc,CAACgB,IAAf,CAAoB,GAApB,CADK;MAEfG,SAFe;MAGfzC,OAAO,EAAE2C;IAHM,CAAjB;EAKD,CAxDD;EA0DA,OAAOjC,WAAP;AACD"}
@@ -62,11 +62,6 @@ const shorthandProperties = {
62
62
 
63
63
  export function getPropertyPriority(property) {
64
64
  const longhands = Object.values(shorthandProperties).reduce((a, b) => [...a, ...b], []);
65
-
66
- if (longhands.includes(property)) {
67
- return 2;
68
- } else {
69
- return 1;
70
- }
65
+ return longhands.includes(property) ? 2 : 1;
71
66
  }
72
67
  //# sourceMappingURL=propertyPriority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyPriority.js","names":["shorthandProperties","animation","background","border","columns","flex","font","gap","grid","margin","mask","offset","outline","overflow","padding","transition","getPropertyPriority","property","longhands","Object","values","reduce","a","b","includes"],"sources":["../../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG;EAC1B;EACA;EACA;EACAC,SAAS,EAAE,CACT,gBADS,EAET,oBAFS,EAGT,2BAHS,EAIT,iBAJS,EAKT,2BALS,EAMT,qBANS,EAOT,qBAPS,EAQT,sBARS,CAJe;EAc1BC,UAAU,EAAE,CACV,uBADU,EAEV,iBAFU,EAGV,kBAHU,EAIV,kBAJU,EAKV,mBALU,EAMV,qBANU,EAOV,mBAPU,EAQV,iBARU,CAdc;EAwB1BC,MAAM,EAAE,CAAC,cAAD,EAAiB,cAAjB,EAAiC,cAAjC,CAxBkB;EAyB1B,oBAAoB,CAClB,wBADkB,EAElB,wBAFkB,EAGlB,wBAHkB,CAzBM;EA8B1B,sBAAsB,CACpB,0BADoB,EAEpB,0BAFoB,EAGpB,0BAHoB,CA9BI;EAmC1B,iBAAiB,CACf,qBADe,EAEf,qBAFe,EAGf,qBAHe,CAnCS;EAwC1B,gBAAgB,CACd,qBADc,EAEd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ACV,kBADU,EAEV,qBAFU,EAGV,qBAHU,EAIV,4BAJU;AA/Kc,CAA5B,C,CAuLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,MAAMC,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAcpB,mBAAd,EAAmCqB,MAAnC,CAChB,CAACC,CAAD,EAAIC,CAAJ,KAAU,CAAC,GAAGD,CAAJ,EAAO,GAAGC,CAAV,CADM,EAEhB,EAFgB,CAAlB;EAKA,OAAOL,SAAS,CAACM,QAAV,CAAmBP,QAAnB,IAA+B,CAA/B,GAAmC,CAA1C;AACD"}
@@ -0,0 +1,40 @@
1
+ import { debug } from '@linaria/logger';
2
+ import StyledProcessor, { hasMeta } from '@linaria/react/processors/styled';
3
+ import { slugify } from '@linaria/utils';
4
+ import atomize from './helpers/atomize';
5
+ export default class AtomicStyledProcessor extends StyledProcessor {
6
+ extractRules(valueCache, cssText, loc) {
7
+ const rules = {};
8
+ const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node);
9
+ const atomicRules = atomize(cssText, hasMeta(wrappedValue));
10
+ atomicRules.forEach(rule => {
11
+ // eslint-disable-next-line no-param-reassign
12
+ rules[rule.cssText] = {
13
+ cssText: rule.cssText,
14
+ start: loc?.start ?? null,
15
+ className: this.className,
16
+ displayName: this.displayName,
17
+ atom: true
18
+ };
19
+ debug('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
20
+ });
21
+ const 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
+ .filter(rule => !!rule.className).map(rule => rule.className).join(' ');
23
+ return [rules, classes];
24
+ }
25
+
26
+ getProps(classes, uniqInterpolations) {
27
+ const props = super.getProps(classes, uniqInterpolations);
28
+ props.class = [classes, this.className].filter(Boolean).join(' ');
29
+ props.atomic = true;
30
+ return props;
31
+ } // eslint-disable-next-line class-methods-use-this
32
+
33
+
34
+ getVariableId(value) {
35
+ // id is based on the slugified value
36
+ return slugify(value);
37
+ }
38
+
39
+ }
40
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +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","classes","filter","map","join","getProps","uniqInterpolations","props","class","Boolean","atomic","getVariableId","value"],"sources":["../../src/processors/styled.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport type {\n IInterpolation,\n Rules,\n ValueCache,\n} from '@linaria/core/processors/types';\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor, { hasMeta } from '@linaria/react/processors/styled';\nimport { slugify } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): [Rules, string] {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node);\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 const 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, classes];\n }\n\n protected override getProps(\n classes: string,\n uniqInterpolations: IInterpolation[]\n ): IProps {\n const props = super.getProps(classes, uniqInterpolations);\n props.class = [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":"AAOA,SAASA,KAAT,QAAsB,iBAAtB;AAEA,OAAOC,eAAP,IAA0BC,OAA1B,QAAyC,kCAAzC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,OAAP,MAAoB,mBAApB;AAEA,eAAe,MAAMC,qBAAN,SAAoCJ,eAApC,CAAoD;EACjDK,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAIT;IACjB,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,YAAY,GAChB,OAAO,KAAKC,SAAZ,KAA0B,QAA1B,GACI,IADJ,GAEIL,UAAU,CAACM,GAAX,CAAe,KAAKD,SAAL,CAAeE,IAA9B,CAHN;IAKA,MAAMC,WAAW,GAAGX,OAAO,CAACI,OAAD,EAAUN,OAAO,CAACS,YAAD,CAAjB,CAA3B;IACAI,WAAW,CAACC,OAAZ,CAAqBC,IAAD,IAAU;MAC5B;MACAP,KAAK,CAACO,IAAI,CAACT,OAAN,CAAL,GAAsB;QACpBA,OAAO,EAAES,IAAI,CAACT,OADM;QAEpBU,KAAK,EAAET,GAAG,EAAES,KAAL,IAAc,IAFD;QAGpBC,SAAS,EAAE,KAAKA,SAHI;QAIpBC,WAAW,EAAE,KAAKA,WAJE;QAKpBC,IAAI,EAAE;MALc,CAAtB;MAQArB,KAAK,CACH,oDADG,EAEF,KAAIiB,IAAI,CAACT,OAAQ,EAFf,CAAL;IAID,CAdD;IAgBA,MAAMc,OAAO,GAAGP,WAAW,CACzB;IADyB,CAExBQ,MAFa,CAELN,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbK,GAHa,CAGRP,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbM,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAO,CAACf,KAAD,EAAQY,OAAR,CAAP;EACD;;EAEkBI,QAAQ,CACzBJ,OADyB,EAEzBK,kBAFyB,EAGjB;IACR,MAAMC,KAAK,GAAG,MAAMF,QAAN,CAAeJ,OAAf,EAAwBK,kBAAxB,CAAd;IACAC,KAAK,CAACC,KAAN,GAAc,CAACP,OAAD,EAAU,KAAKH,SAAf,EAA0BI,MAA1B,CAAiCO,OAAjC,EAA0CL,IAA1C,CAA+C,GAA/C,CAAd;IACAG,KAAK,CAACG,MAAN,GAAe,IAAf;IACA,OAAOH,KAAP;EACD,CA/CgE,CAiDjE;;;EACmBI,aAAa,CAACC,KAAD,EAAwB;IACtD;IACA,OAAO9B,OAAO,CAAC8B,KAAD,CAAd;EACD;;AArDgE"}
File without changes
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"CSSProperties.js"}
1
+ {"version":3,"file":"CSSProperties.js","names":[],"sources":["../src/CSSProperties.ts"],"sourcesContent":["export type CSSProperties = {\n [key: string]: string | number | CSSProperties;\n};\n"],"mappings":""}
package/lib/css.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
  exports.default = exports.css = void 0;
7
5
 
8
6
  const css = () => {
package/lib/css.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/css.ts"],"names":["css","Error"],"mappings":";;;;;;;AAQO,MAAMA,GAAQ,GAAG,MAAM;AAC5B,QAAM,IAAIC,KAAJ,CACJ,wGADI,CAAN;AAGD,CAJM;;;eAMQD,G","sourcesContent":["import type { LinariaClassName } from '@linaria/utils';\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n"],"file":"css.js"}
1
+ {"version":3,"file":"css.js","names":["css","Error"],"sources":["../src/css.ts"],"sourcesContent":["import type { LinariaClassName } from '@linaria/core';\n\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n"],"mappings":";;;;;AASO,MAAMA,GAAQ,GAAG,MAAM;EAC5B,MAAM,IAAIC,KAAJ,CACJ,wGADI,CAAN;AAGD,CAJM;;;eAMQD,G"}
package/lib/index.js CHANGED
@@ -1,32 +1,19 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "css", {
7
- enumerable: true,
8
- get: function () {
9
- return _css.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "atomize", {
13
- enumerable: true,
14
- get: function () {
15
- return _atomize.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "cx", {
19
- enumerable: true,
20
- get: function () {
21
- return _utils.cx;
22
- }
23
- });
3
+ exports.__esModule = true;
4
+ exports.styled = exports.cx = exports.css = void 0;
24
5
 
25
6
  var _css = _interopRequireDefault(require("./css"));
26
7
 
27
- var _atomize = _interopRequireDefault(require("./atomize"));
8
+ exports.css = _css.default;
28
9
 
29
- var _utils = require("@linaria/utils");
10
+ var _react = require("@linaria/react");
11
+
12
+ exports.styled = _react.styled;
13
+
14
+ var _core = require("@linaria/core");
15
+
16
+ exports.cx = _core.cx;
30
17
 
31
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
19
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["export { default as css } from './css';\nexport { default as atomize } from './atomize';\nexport { cx } from '@linaria/utils';\n\nexport type { CSSProperties } from './CSSProperties';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default as css } from './css';\nexport { styled } from '@linaria/react';\nexport { cx } from '@linaria/core';\n\nexport type { CSSProperties } from './CSSProperties';\n"],"mappings":";;;;;AAAA;;;;AACA;;;;AACA"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _css = _interopRequireDefault(require("@linaria/core/processors/css"));
9
+
10
+ var _logger = require("@linaria/logger");
11
+
12
+ var _atomize = _interopRequireDefault(require("./helpers/atomize"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ class AtomicCssProcessor extends _css.default {
17
+ extractRules(valueCache, cssText, loc) {
18
+ const rules = {};
19
+ const atomicRules = (0, _atomize.default)(cssText, false);
20
+ atomicRules.forEach(rule => {
21
+ var _loc$start;
22
+
23
+ // eslint-disable-next-line no-param-reassign
24
+ rules[rule.cssText] = {
25
+ cssText: rule.cssText,
26
+ start: (_loc$start = loc === null || loc === void 0 ? void 0 : loc.start) !== null && _loc$start !== void 0 ? _loc$start : null,
27
+ className: this.className,
28
+ displayName: this.displayName,
29
+ atom: true
30
+ };
31
+ (0, _logger.debug)('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
32
+ });
33
+ const 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
+ .filter(rule => !!rule.className).map(rule => rule.className).join(' ');
35
+ return [rules, classes];
36
+ }
37
+
38
+ }
39
+
40
+ exports.default = AtomicCssProcessor;
41
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","names":["AtomicCssProcessor","CssProcessor","extractRules","valueCache","cssText","loc","rules","atomicRules","atomize","forEach","rule","start","className","displayName","atom","debug","classes","filter","map","join"],"sources":["../../src/processors/css.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport CssProcessor from '@linaria/core/processors/css';\nimport type { Rules, ValueCache } from '@linaria/core/processors/types';\nimport { debug } from '@linaria/logger';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicCssProcessor extends CssProcessor {\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): [Rules, string] {\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 const 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, classes];\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAEA;;AAEA;;;;AAEe,MAAMA,kBAAN,SAAiCC,YAAjC,CAA8C;EAC3CC,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAIT;IACjB,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,MAAMY,OAAO,GAAGT,WAAW,CACzB;IADyB,CAExBU,MAFa,CAELP,IAAD,IAAU,CAAC,CAACA,IAAI,CAACE,SAFX,EAGbM,GAHa,CAGRR,IAAD,IAAUA,IAAI,CAACE,SAHN,EAIbO,IAJa,CAIR,GAJQ,CAAhB;IAMA,OAAO,CAACb,KAAD,EAAQU,OAAR,CAAP;EACD;;AAhC0D"}
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = atomize;
7
7
 
8
- var _postcss = _interopRequireDefault(require("postcss"));
8
+ var _knownCssProperties = require("known-css-properties");
9
9
 
10
- var _utils = require("@linaria/utils");
10
+ var _postcss = _interopRequireDefault(require("postcss"));
11
11
 
12
12
  var _stylis = _interopRequireDefault(require("stylis"));
13
13
 
14
- var _knownCssProperties = require("known-css-properties");
14
+ var _utils = require("@linaria/utils");
15
15
 
16
16
  var _propertyPriority = require("./propertyPriority");
17
17
 
@@ -33,18 +33,28 @@ function hashProperty(property) {
33
33
  return (0, _utils.slugify)(property);
34
34
  }
35
35
 
36
- function atomize(cssText) {
36
+ const parseCss = cssText => {
37
+ try {
38
+ return _postcss.default.parse(cssText);
39
+ } catch (e) {
40
+ if (e instanceof Error) {
41
+ throw new Error(`Error parsing CSS: ${e.message}\nCSS:\n${cssText}`);
42
+ }
43
+
44
+ throw new Error(`Unknown error parsing CSS.\nCSS:\n${cssText}`);
45
+ }
46
+ };
47
+
48
+ function atomize(cssText, hasPriority = false) {
37
49
  _stylis.default.set({
38
50
  prefix: false,
39
51
  keyframe: false
40
52
  });
41
53
 
42
54
  const atomicRules = [];
43
-
44
- const stylesheet = _postcss.default.parse(cssText); // We want to extract all keyframes and leave them as-is.
55
+ const stylesheet = parseCss(cssText); // We want to extract all keyframes and leave them as-is.
45
56
  // This isn't scoped locally yet
46
57
 
47
-
48
58
  stylesheet.walkAtRules('keyframes', atRule => {
49
59
  atRule.remove();
50
60
  atomicRules.push({
@@ -93,7 +103,7 @@ function atomize(cssText) {
93
103
  const propertySlug = hashProperty([...atomicProperty].join(';'));
94
104
  const valueSlug = (0, _utils.slugify)(decl.value);
95
105
  const className = `atm_${propertySlug}_${valueSlug}`;
96
- const propertyPriority = (0, _propertyPriority.getPropertyPriority)(decl.prop) + (hasAtRule ? 1 : 0);
106
+ const propertyPriority = (0, _propertyPriority.getPropertyPriority)(decl.prop) + (hasAtRule ? 1 : 0) + (hasPriority ? 1 : 0);
97
107
  const processedCss = (0, _stylis.default)(`.${className}`.repeat(propertyPriority), css);
98
108
  atomicRules.push({
99
109
  property: atomicProperty.join(' '),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomize.js","names":["knownPropertiesMap","knownProperties","reduce","acc","property","i","hashProperty","index","undefined","toString","slugify","parseCss","cssText","postcss","parse","e","Error","message","atomize","hasPriority","stylis","set","prefix","keyframe","atomicRules","stylesheet","walkAtRules","atRule","remove","push","name","walkDecls","decl","thisParent","parent","parents","atomicProperty","prop","hasAtRule","unshift","type","params","selector","root","container","forEach","newNode","clone","removeAll","append","css","propertySlug","join","valueSlug","value","className","propertyPriority","getPropertyPriority","processedCss","repeat"],"sources":["../../../src/processors/helpers/atomize.ts"],"sourcesContent":["import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AAEA;;;;AAEA,MAAMA,kBAAkB,GAAGC,uBAAA,CAAgBC,MAAhB,CACzB,CAACC,GAAD,EAAsCC,QAAtC,EAAgDC,CAAhD,KAAsD;EACpDF,GAAG,CAACC,QAAD,CAAH,GAAgBC,CAAhB;EACA,OAAOF,GAAP;AACD,CAJwB,EAKzB,EALyB,CAA3B;;AAQA,SAASG,YAAT,CAAsBF,QAAtB,EAAwC;EACtC,MAAMG,KAAK,GAAGP,kBAAkB,CAACI,QAAD,CAAhC,CADsC,CAEtC;EACA;;EACA,IAAIG,KAAK,KAAKC,SAAd,EAAyB;IACvB,OAAOD,KAAK,CAACE,QAAN,CAAe,EAAf,CAAP,CADuB,CACI;EAC5B;;EACD,OAAO,IAAAC,cAAA,EAAQN,QAAR,CAAP;AACD;;AAED,MAAMO,QAAQ,GAAIC,OAAD,IAAqB;EACpC,IAAI;IACF,OAAOC,gBAAA,CAAQC,KAAR,CAAcF,OAAd,CAAP;EACD,CAFD,CAEE,OAAOG,CAAP,EAAU;IACV,IAAIA,CAAC,YAAYC,KAAjB,EAAwB;MACtB,MAAM,IAAIA,KAAJ,CAAW,sBAAqBD,CAAC,CAACE,OAAQ,WAAUL,OAAQ,EAA5D,CAAN;IACD;;IAED,MAAM,IAAII,KAAJ,CAAW,qCAAoCJ,OAAQ,EAAvD,CAAN;EACD;AACF,CAVD;;AAYe,SAASM,OAAT,CAAiBN,OAAjB,EAAkCO,WAAW,GAAG,KAAhD,EAAuD;EACpEC,eAAA,CAAOC,GAAP,CAAW;IACTC,MAAM,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AMY,OAAO,GAAGZ,MAAM,CAACa,KAAP,EAAhB;MACAD,OAAO,CAACE,SAAR;MACAJ,SAAS,CAACK,MAAV,CAAiBH,OAAjB;MACAF,SAAS,GAAGE,OAAZ;IACD,CALD;IAMAF,SAAS,CAACK,MAAV,CAAiBjB,IAAI,CAACe,KAAL,EAAjB;IAEA,MAAMG,GAAG,GAAGP,IAAI,CAAClC,QAAL,EAAZ;IACA,MAAM0C,YAAY,GAAG7C,YAAY,CAAC,CAAC,GAAG8B,cAAJ,EAAoBgB,IAApB,CAAyB,GAAzB,CAAD,CAAjC;IACA,MAAMC,SAAS,GAAG,IAAA3C,cAAA,EAAQsB,IAAI,CAACsB,KAAb,CAAlB;IACA,MAAMC,SAAS,GAAI,OAAMJ,YAAa,IAAGE,SAAU,EAAnD;IAEA,MAAMG,gBAAgB,GACpB,IAAAC,qCAAA,EAAoBzB,IAAI,CAACK,IAAzB,KACCC,SAAS,GAAG,CAAH,GAAO,CADjB,KAECnB,WAAW,GAAG,CAAH,GAAO,CAFnB,CADF;IAIA,MAAMuC,YAAY,GAAG,IAAAtC,eAAA,EAAQ,IAAGmC,SAAU,EAAd,CAAgBI,MAAhB,CAAuBH,gBAAvB,CAAP,EAAiDN,GAAjD,CAArB;IAEA1B,WAAW,CAACK,IAAZ,CAAiB;MACfzB,QAAQ,EAAEgC,cAAc,CAACgB,IAAf,CAAoB,GAApB,CADK;MAEfG,SAFe;MAGf3C,OAAO,EAAE8C;IAHM,CAAjB;EAKD,CAxDD;EA0DA,OAAOlC,WAAP;AACD"}
@@ -68,11 +68,6 @@ const shorthandProperties = {
68
68
 
69
69
  function getPropertyPriority(property) {
70
70
  const longhands = Object.values(shorthandProperties).reduce((a, b) => [...a, ...b], []);
71
-
72
- if (longhands.includes(property)) {
73
- return 2;
74
- } else {
75
- return 1;
76
- }
71
+ return longhands.includes(property) ? 2 : 1;
77
72
  }
78
73
  //# sourceMappingURL=propertyPriority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyPriority.js","names":["shorthandProperties","animation","background","border","columns","flex","font","gap","grid","margin","mask","offset","outline","overflow","padding","transition","getPropertyPriority","property","longhands","Object","values","reduce","a","b","includes"],"sources":["../../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAG;EAC1B;EACA;EACA;EACAC,SAAS,EAAE,CACT,gBADS,EAET,oBAFS,EAGT,2BAHS,EAIT,iBAJS,EAKT,2BALS,EAMT,qBANS,EAOT,qBAPS,EAQT,sBARS,CAJe;EAc1BC,UAAU,EAAE,CACV,uBADU,EAEV,iBAFU,EAGV,kBAHU,EAIV,kBAJU,EAKV,mBALU,EAMV,qBANU,EAOV,mBAPU,EAQV,iBARU,CAdc;EAwB1BC,MAAM,EAAE,CAAC,cAAD,EAAiB,cAAjB,EAAiC,cAAjC,CAxBkB;EAyB1B,oBAAoB,CAClB,wBADkB,EAElB,wBAFkB,EAGlB,wBAHkB,CAzBM;EA8B1B,sBAAsB,CACpB,0BADoB,EAEpB,0BAFoB,EAGpB,0BAHoB,CA9BI;EAmC1B,iBAAiB,CACf,qBADe,EAEf,qBAFe,EAGf,qBAHe,CAnCS;EAwC1B,gBAAgB,CACd,qBADc,EAEd,mBAFc,EAGd,oBAHc,EAId,kBAJc,CAxCU;EA8C1B,gBAAgB,CACd,qBADc,EAEd,qBAFc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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,MAAMC,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAcpB,mBAAd,EAAmCqB,MAAnC,CAChB,CAACC,CAAD,EAAIC,CAAJ,KAAU,CAAC,GAAGD,CAAJ,EAAO,GAAGC,CAAV,CADM,EAEhB,EAFgB,CAAlB;EAKA,OAAOL,SAAS,CAACM,QAAV,CAAmBP,QAAnB,IAA+B,CAA/B,GAAmC,CAA1C;AACD"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _logger = require("@linaria/logger");
9
+
10
+ var _styled = _interopRequireWildcard(require("@linaria/react/processors/styled"));
11
+
12
+ var _utils = require("@linaria/utils");
13
+
14
+ var _atomize = _interopRequireDefault(require("./helpers/atomize"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ class AtomicStyledProcessor extends _styled.default {
23
+ extractRules(valueCache, cssText, loc) {
24
+ const rules = {};
25
+ const wrappedValue = typeof this.component === 'string' ? null : valueCache.get(this.component.node);
26
+ const atomicRules = (0, _atomize.default)(cssText, (0, _styled.hasMeta)(wrappedValue));
27
+ atomicRules.forEach(rule => {
28
+ var _loc$start;
29
+
30
+ // eslint-disable-next-line no-param-reassign
31
+ rules[rule.cssText] = {
32
+ cssText: rule.cssText,
33
+ start: (_loc$start = loc === null || loc === void 0 ? void 0 : loc.start) !== null && _loc$start !== void 0 ? _loc$start : null,
34
+ className: this.className,
35
+ displayName: this.displayName,
36
+ atom: true
37
+ };
38
+ (0, _logger.debug)('evaluator:template-processor:extracted-atomic-rule', `\n${rule.cssText}`);
39
+ });
40
+ const 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
+ .filter(rule => !!rule.className).map(rule => rule.className).join(' ');
42
+ return [rules, classes];
43
+ }
44
+
45
+ getProps(classes, uniqInterpolations) {
46
+ const props = super.getProps(classes, uniqInterpolations);
47
+ props.class = [classes, this.className].filter(Boolean).join(' ');
48
+ props.atomic = true;
49
+ return props;
50
+ } // eslint-disable-next-line class-methods-use-this
51
+
52
+
53
+ getVariableId(value) {
54
+ // id is based on the slugified value
55
+ return (0, _utils.slugify)(value);
56
+ }
57
+
58
+ }
59
+
60
+ exports.default = AtomicStyledProcessor;
61
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +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","classes","filter","map","join","getProps","uniqInterpolations","props","class","Boolean","atomic","getVariableId","value","slugify"],"sources":["../../src/processors/styled.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport type {\n IInterpolation,\n Rules,\n ValueCache,\n} from '@linaria/core/processors/types';\nimport { debug } from '@linaria/logger';\nimport type { IProps } from '@linaria/react/processors/styled';\nimport StyledProcessor, { hasMeta } from '@linaria/react/processors/styled';\nimport { slugify } from '@linaria/utils';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicStyledProcessor extends StyledProcessor {\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): [Rules, string] {\n const rules: Rules = {};\n\n const wrappedValue =\n typeof this.component === 'string'\n ? null\n : valueCache.get(this.component.node);\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 const 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, classes];\n }\n\n protected override getProps(\n classes: string,\n uniqInterpolations: IInterpolation[]\n ): IProps {\n const props = super.getProps(classes, uniqInterpolations);\n props.class = [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":";;;;;;;AAOA;;AAEA;;AACA;;AAEA;;;;;;;;AAEe,MAAMA,qBAAN,SAAoCC,eAApC,CAAoD;EACjDC,YAAY,CAC1BC,UAD0B,EAE1BC,OAF0B,EAG1BC,GAH0B,EAIT;IACjB,MAAMC,KAAY,GAAG,EAArB;IAEA,MAAMC,YAAY,GAChB,OAAO,KAAKC,SAAZ,KAA0B,QAA1B,GACI,IADJ,GAEIL,UAAU,C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ArDgE"}
package/package.json CHANGED
@@ -1,46 +1,59 @@
1
1
  {
2
2
  "name": "@linaria/atomic",
3
- "version": "3.0.0-beta.18",
4
- "publishConfig": {
5
- "access": "public"
6
- },
7
3
  "description": "Blazing fast zero-runtime CSS in JS library",
8
- "sideEffects": false,
9
- "main": "lib/index.js",
10
- "module": "esm/index.js",
11
- "types": "types/index.d.ts",
4
+ "version": "3.0.0-beta.21",
5
+ "bugs": "https://github.com/callstack/linaria/issues",
6
+ "dependencies": {
7
+ "@linaria/core": "^3.0.0-beta.21",
8
+ "@linaria/logger": "^3.0.0-beta.20",
9
+ "@linaria/react": "^3.0.0-beta.21",
10
+ "@linaria/utils": "^3.0.0-beta.20",
11
+ "known-css-properties": "^0.24.0",
12
+ "postcss": "^8.3.11",
13
+ "stylis": "^3.5.4",
14
+ "ts-invariant": "^0.10.3"
15
+ },
16
+ "devDependencies": {
17
+ "@babel/types": "^7.18.4"
18
+ },
19
+ "engines": {
20
+ "node": "^12.16.0 || >=13.7.0"
21
+ },
12
22
  "files": [
13
23
  "types/",
14
24
  "lib/",
15
25
  "esm/"
16
26
  ],
17
- "license": "MIT",
18
- "repository": "git@github.com:callstack/linaria.git",
19
- "bugs": {
20
- "url": "https://github.com/callstack/linaria/issues"
21
- },
22
27
  "homepage": "https://github.com/callstack/linaria#readme",
23
28
  "keywords": [
24
- "react",
25
- "linaria",
26
29
  "css",
27
30
  "css-in-js",
31
+ "linaria",
32
+ "react",
28
33
  "styled-components"
29
34
  ],
35
+ "license": "MIT",
36
+ "linaria": {
37
+ "tags": {
38
+ "css": "./lib/processors/css.js",
39
+ "styled": "./lib/processors/styled.js"
40
+ }
41
+ },
42
+ "main": "lib/index.js",
43
+ "module": "esm/index.js",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "repository": "git@github.com:callstack/linaria.git",
48
+ "sideEffects": false,
49
+ "types": "types/index.d.ts",
30
50
  "scripts": {
31
- "build:lib": "cross-env NODE_ENV=legacy babel src --out-dir lib --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
32
- "build:esm": "babel src --out-dir esm --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
33
- "build": "yarn build:lib && yarn build:esm",
51
+ "build": "npm run build:lib && npm run build:esm && npm run build:declarations",
34
52
  "build:declarations": "tsc --emitDeclarationOnly --outDir types",
35
- "prepare": "yarn build && yarn build:declarations",
53
+ "build:esm": "babel src --out-dir esm --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
54
+ "build:lib": "cross-env NODE_ENV=legacy babel src --out-dir lib --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
36
55
  "typecheck": "tsc --noEmit --composite false",
37
- "watch": "yarn build --watch"
38
- },
39
- "dependencies": {
40
- "@linaria/utils": "^3.0.0-beta.18",
41
- "known-css-properties": "^0.24.0",
42
- "postcss": "^8.3.11",
43
- "stylis": "^3.5.4"
56
+ "watch": "npm run build --watch"
44
57
  },
45
- "gitHead": "c3f093a3a7fb4e7c82d23e44adb19a94438da68c"
46
- }
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
+ }
File without changes
package/types/css.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LinariaClassName } from '@linaria/utils';
1
+ import type { LinariaClassName } from '@linaria/core';
2
2
  import type { CSSProperties } from './CSSProperties';
3
3
  declare type CSS = (strings: TemplateStringsArray, ...exprs: Array<string | number | CSSProperties>) => LinariaClassName;
4
4
  export declare const css: CSS;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as css } from './css';
2
- export { default as atomize } from './atomize';
3
- export { cx } from '@linaria/utils';
2
+ export { styled } from '@linaria/react';
3
+ export { cx } from '@linaria/core';
4
4
  export type { CSSProperties } from './CSSProperties';
@@ -0,0 +1,6 @@
1
+ import type { SourceLocation } from '@babel/types';
2
+ import CssProcessor from '@linaria/core/processors/css';
3
+ import type { Rules, ValueCache } from '@linaria/core/processors/types';
4
+ export default class AtomicCssProcessor extends CssProcessor {
5
+ extractRules(valueCache: ValueCache, cssText: string, loc?: SourceLocation | null): [Rules, string];
6
+ }
@@ -1,4 +1,4 @@
1
- export default function atomize(cssText: string): {
1
+ export default function atomize(cssText: string, hasPriority?: boolean): {
2
2
  className?: string | undefined;
3
3
  cssText: string;
4
4
  property: string;
@@ -0,0 +1 @@
1
+ export declare function getPropertyPriority(property: string): 1 | 2;
@@ -0,0 +1,9 @@
1
+ import type { SourceLocation } from '@babel/types';
2
+ import type { IInterpolation, Rules, ValueCache } from '@linaria/core/processors/types';
3
+ import type { IProps } from '@linaria/react/processors/styled';
4
+ import StyledProcessor from '@linaria/react/processors/styled';
5
+ export default class AtomicStyledProcessor extends StyledProcessor {
6
+ extractRules(valueCache: ValueCache, cssText: string, loc?: SourceLocation | null): [Rules, string];
7
+ protected getProps(classes: string, uniqInterpolations: IInterpolation[]): IProps;
8
+ protected getVariableId(value: string): string;
9
+ }
package/CHANGELOG.md DELETED
@@ -1,24 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [3.0.0-beta.18](https://github.com/callstack/linaria/compare/v3.0.0-beta.17...v3.0.0-beta.18) (2022-04-01)
7
-
8
-
9
- ### Features
10
-
11
- * **atomic:** add property priorities ([#950](https://github.com/callstack/linaria/issues/950)) ([c44becb](https://github.com/callstack/linaria/commit/c44becb11b2eec795b68c2b3d0715672ba4b3888))
12
- * **atomic:** add support for at-rules, keyframes and pseudo classes ([#913](https://github.com/callstack/linaria/issues/913)) ([dee7fa1](https://github.com/callstack/linaria/commit/dee7fa14ea912224cac9f0673be7464e93571a73))
13
- * **atomic:** string serialization of atoms ([#934](https://github.com/callstack/linaria/issues/934)) ([ef19ccb](https://github.com/callstack/linaria/commit/ef19ccb384cb7dbee561e789f637b0289d4d224c))
14
-
15
-
16
-
17
-
18
-
19
- # [3.0.0-beta.15](https://github.com/callstack/linaria/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2021-11-29)
20
-
21
-
22
- ### Features
23
-
24
- * **atomic:** create an atomic package for the css API ([#867](https://github.com/callstack/linaria/issues/867)) ([4773bcf](https://github.com/callstack/linaria/commit/4773bcf4b14f08cdc4d2b612654b962cdfc97eaa))
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/atomize.ts"],"names":["postcss","slugify","stylis","all","knownProperties","getPropertyPriority","knownPropertiesMap","reduce","acc","property","i","hashProperty","index","undefined","toString","atomize","cssText","set","prefix","keyframe","atomicRules","stylesheet","parse","walkAtRules","atRule","remove","push","name","walkDecls","decl","thisParent","parent","parents","atomicProperty","prop","hasAtRule","unshift","type","params","selector","root","container","forEach","newNode","clone","removeAll","append","css","propertySlug","join","valueSlug","value","className","propertyPriority","processedCss","repeat"],"mappings":"AAAA,OAAOA,OAAP,MAA2D,SAA3D;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,MAAP,MAAmB,QA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AAMC,SAAS,GAAI,OAAMJ,YAAa,IAAGE,SAAU,EAAnD;AAEA,UAAMG,gBAAgB,GACpBhD,mBAAmB,CAACwB,IAAI,CAACK,IAAN,CAAnB,IAAkCC,SAAS,GAAG,CAAH,GAAO,CAAlD,CADF;AAEA,UAAMmB,YAAY,GAAGpD,MAAM,CAAE,IAAGkD,SAAU,EAAd,CAAgBG,MAAhB,CAAuBF,gBAAvB,CAAD,EAA2CN,GAA3C,CAA3B;AAEA3B,IAAAA,WAAW,CAACM,IAAZ,CAAiB;AACfjB,MAAAA,QAAQ,EAAEwB,cAAc,CAACgB,IAAf,CAAoB,GAApB,CADK;AAEfG,MAAAA,SAFe;AAGfpC,MAAAA,OAAO,EAAEsC;AAHM,KAAjB;AAKD,GAtDD;AAwDA,SAAOlC,WAAP;AACD","sourcesContent":["import postcss, { Document, AtRule, Container, Rule } from 'postcss';\nimport { slugify } from '@linaria/utils';\nimport stylis from 'stylis';\nimport { all as knownProperties } from 'known-css-properties';\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nexport default function atomize(cssText: string) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = postcss.parse(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) + (hasAtRule ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n"],"file":"atomize.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/propertyPriority.ts"],"names":["shorthandProperties","animation","background","border","columns","flex","font","gap","grid","margin","mask","offset","outline","overflow","padding","transition","getPropertyPriority","property","longhands","Object","values","reduce","a","b","includes"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG;AAC1B;AACA;AACA;AACAC,EAAAA,SAAS,EAAE,CACT,gBADS,EAET,oBAFS,EAGT,2BAHS,EAIT,iBAJS,EAKT,2BALS,EAMT,qBANS,EAOT,qBAPS,EAQT,sBARS,CAJe;AAc1BC,EAAAA,UAAU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nB,EAAmC,eAAnC,EAAoD,aAApD,CAxJiB;AAyJ1B,mBAAiB,CAAC,eAAD,EAAkB,iBAAlB,CAzJS;AA0J1B,iBAAe,CAAC,aAAD,EAAgB,eAAhB,CA1JW;AA2J1B,gBAAc,CAAC,YAAD,EAAe,cAAf,CA3JY;AA4J1B,mBAAiB,CACf,sBADe,EAEf,oBAFe,EAGf,qBAHe,EAIf,mBAJe,CA5JS;AAkK1B,oBAAkB,CAChB,uBADgB,EAEhB,qBAFgB,EAGhB,sBAHgB,EAIhB,oBAJgB,CAlKQ;AAwK1B,qBAAmB,CACjB,uBADiB,EAEjB,sBAFiB,EAGjB,uBAHiB,EAIjB,2BAJiB,CAxKO;AA8K1B,mBAAiB,CAAC,qBAAD,EAAwB,qBAAxB,CA9KS;AA+K1BC,EAAAA,UAAU,EAAE,CACV,kBADU,EAEV,qBAFU,EAGV,qBAHU,EAIV,4BAJU;AA/Kc,CAA5B,C,CAuLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA6BC,QAA7B,EAA+C;AACpD,QAAMC,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAcpB,mBAAd,EAAmCqB,MAAnC,CAChB,CAACC,CAAD,EAAIC,CAAJ,KAAU,CAAC,GAAGD,CAAJ,EAAO,GAAGC,CAAV,CADM,EAEhB,EAFgB,CAAlB;;AAKA,MAAIL,SAAS,CAACM,QAAV,CAAmBP,QAAnB,CAAJ,EAAkC;AAChC,WAAO,CAAP;AACD,GAFD,MAEO;AACL,WAAO,CAAP;AACD;AACF","sourcesContent":["const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n if (longhands.includes(property)) {\n return 2;\n } else {\n return 1;\n }\n}\n"],"file":"propertyPriority.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/atomize.ts"],"names":["knownPropertiesMap","knownProperties","reduce","acc","property","i","hashProperty","index","undefined","toString","atomize","cssText","stylis","set","prefix","keyframe","atomicRules","stylesheet","postcss","parse","walkAtRules","atRule","remove","push","name","walkDecls","decl","thisParent","parent","parents","atomicProperty","prop","hasAtRule","unshift","type","params","selector","root","container","forEach","newNode","clone","removeAll","append","css","propertySlug","join","valueSlug","value","className","propertyPriority","processedCss","repeat"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,kBAAkB,GAAGC,wBAAgBC,MAAhB,CACzB,CAACC,GAAD,EAAsCC,QAAtC,EAAgDC,CAAhD,KAAsD;AACpDF,EAAAA,GAAG,CAACC,QAAD,CAAH,GAAgBC,CAAhB;AACA,SAAOF,GAAP;AACD,CAJwB,EAKzB,EALyB,CAA3B;;AAQA,SAASG,YAAT,CAAsBF,QAAtB,EAAwC;AACtC,QAAMG,KAAK,GAAGP,kBAAkB,CAACI,QAAD,CAAhC,CADsC,CAEtC;AACA;;AACA,MAAIG,KAAK,KAAKC,SAAd,EAAyB;AACvB,WAAOD,KAAK,CAACE,QAAN,CAAe,EAAf,CAAP,CADuB,CACI;AAC5B;;AACD,SAAO,oBAAQL,QAAR,CAAP;AACD;;AAEc,SAASM,OAAT,CAAiBC,OAAjB,EAAkC;AAC/CC,kBAAOC,GAAP,CAAW;AACTC,IAAAA,MAAM,EAAE,KADC;AAETC,IAAAA,QAAQ,EAAE;AAFD,GAAX;;AAIA,QAAMC,WAIH,GAAG,EAJN;;AAMA,QAAMC,UAAU,GAAGC,iBAAQC,KAA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M,CAACa,KAAP,EAAhB;AACAD,MAAAA,OAAO,CAACE,SAAR;AACAJ,MAAAA,SAAS,CAACK,MAAV,CAAiBH,OAAjB;AACAF,MAAAA,SAAS,GAAGE,OAAZ;AACD,KALD;AAMAF,IAAAA,SAAS,CAACK,MAAV,CAAiBjB,IAAI,CAACe,KAAL,EAAjB;AAEA,UAAMG,GAAG,GAAGP,IAAI,CAAC5B,QAAL,EAAZ;AACA,UAAMoC,YAAY,GAAGvC,YAAY,CAAC,CAAC,GAAGwB,cAAJ,EAAoBgB,IAApB,CAAyB,GAAzB,CAAD,CAAjC;AACA,UAAMC,SAAS,GAAG,oBAAQrB,IAAI,CAACsB,KAAb,CAAlB;AACA,UAAMC,SAAS,GAAI,OAAMJ,YAAa,IAAGE,SAAU,EAAnD;AAEA,UAAMG,gBAAgB,GACpB,2CAAoBxB,IAAI,CAACK,IAAzB,KAAkCC,SAAS,GAAG,CAAH,GAAO,CAAlD,CADF;AAEA,UAAMmB,YAAY,GAAG,qBAAQ,IAAGF,SAAU,EAAd,CAAgBG,MAAhB,CAAuBF,gBAAvB,CAAP,EAAiDN,GAAjD,CAArB;AAEA5B,IAAAA,WAAW,CAACO,IAAZ,CAAiB;AACfnB,MAAAA,QAAQ,EAAE0B,cAAc,CAACgB,IAAf,CAAoB,GAApB,CADK;AAEfG,MAAAA,SAFe;AAGftC,MAAAA,OAAO,EAAEwC;AAHM,KAAjB;AAKD,GAtDD;AAwDA,SAAOnC,WAAP;AACD","sourcesContent":["import postcss, { Document, AtRule, Container, Rule } from 'postcss';\nimport { slugify } from '@linaria/utils';\nimport stylis from 'stylis';\nimport { all as knownProperties } from 'known-css-properties';\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nexport default function atomize(cssText: string) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = postcss.parse(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) + (hasAtRule ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n"],"file":"atomize.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/propertyPriority.ts"],"names":["shorthandProperties","animation","background","border","columns","flex","font","gap","grid","margin","mask","offset","outline","overflow","padding","transition","getPropertyPriority","property","longhands","Object","values","reduce","a","b","includes"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAG;AAC1B;AACA;AACA;AACAC,EAAAA,SAAS,EAAE,CACT,gBADS,EAET,oBAFS,EAGT,2BAHS,EAIT,iBAJS,EAKT,2BALS,EAMT,qBANS,EAOT,qBAPS,EAQT,sBARS,CAJe;AAc1BC,EAAAA,UAAU,EAAE,CACV,uBADU,EAEV,iBAFU,EAGV,kBAHU,EAIV,kBAJU,EAKV,mBALU,EAMV,qBANU,EAOV,mBAPU,EAQV,iBARU,CAdc;AAwB1BC,EAAAA,MAAM,EAAE,CAAC,cAAD,EAAiB,cAAjB,EAAiC,cAAjC,CAxBkB;AAyB1B,sBAAoB,CAClB,wBADkB,EAElB,wBAFkB,EAGlB,wBAHkB,CAzBM;AA8B1B,wBAAsB,CACpB,0BADoB,EAEpB,0BAFoB,EAGpB,0BAHoB,CA9BI;AAmC1B,mBAAiB,CACf,qBADe,EAEf,qBAFe,EAGf,qBAHe,CAnCS;AAwC1B,kBAAgB,CACd,qBADc,EAEd,mBAFc,EAGd,oBAHc,EAId,kBAJc,CAxCU;AA8C1B,kBAAgB,CACd,qBADc,EAEd,qBAFc,EAGd,oBAHc,EAId,qBAJc,EAKd,oBALc,CA9CU;AAqD1B,uBAAqB,CACnB,yBADmB,EAEnB,yBAFmB,EAGnB,yBAHmB,CArDK;AA0D1B,yBAAuB,CACrB,2BADqB,EAErB,2BAFqB,EAGrB,2BAHqB,CA1DG;AA+D1B,iBAAe,CACb,mBADa,EAEb,mBAFa,EAGb,mBAHa,CA/DW;AAoE1B,mBAAiB,CACf,wBADe,EAEf,yBAFe,EAGf,4BAHe,EAIf,2BAJe,CAp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AU,CAAC,GAAGD,CAAJ,EAAO,GAAGC,CAAV,CADM,EAEhB,EAFgB,CAAlB;;AAKA,MAAIL,SAAS,CAACM,QAAV,CAAmBP,QAAnB,CAAJ,EAAkC;AAChC,WAAO,CAAP;AACD,GAFD,MAEO;AACL,WAAO,CAAP;AACD;AACF","sourcesContent":["const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n if (longhands.includes(property)) {\n return 2;\n } else {\n return 1;\n }\n}\n"],"file":"propertyPriority.js"}
@@ -1 +0,0 @@
1
- export declare function getPropertyPriority(property: string): 2 | 1;