@linaria/atomic 4.1.3 → 4.1.5
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/esm/processors/styled.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { debug } from '@linaria/logger';
|
|
2
2
|
import StyledProcessor from '@linaria/react/processors/styled';
|
|
3
3
|
import { hasMeta } from '@linaria/tags';
|
|
4
|
-
import { slugify } from '@linaria/utils';
|
|
5
4
|
import atomize from './helpers/atomize';
|
|
6
5
|
export default class AtomicStyledProcessor extends StyledProcessor {
|
|
7
6
|
#classes;
|
|
@@ -39,12 +38,18 @@ export default class AtomicStyledProcessor extends StyledProcessor {
|
|
|
39
38
|
props.class = [this.classes, this.className].filter(Boolean).join(' ');
|
|
40
39
|
props.atomic = true;
|
|
41
40
|
return props;
|
|
42
|
-
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getVariableId(source, unit, precedingCss) {
|
|
44
|
+
const id = this.getCustomVariableId(source, unit, precedingCss);
|
|
45
|
+
|
|
46
|
+
if (id) {
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
43
49
|
|
|
50
|
+
const context = this.getVariableContext(source, unit, precedingCss); // id is based on the slugified value
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
// id is based on the slugified value
|
|
47
|
-
return slugify(value);
|
|
52
|
+
return context.valueSlug;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","names":["debug","StyledProcessor","hasMeta","
|
|
1
|
+
{"version":3,"file":"styled.js","names":["debug","StyledProcessor","hasMeta","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","source","unit","precedingCss","id","getCustomVariableId","context","getVariableContext","valueSlug"],"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';\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 protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n"],"mappings":"AAEA,SAASA,KAAT,QAAsB,iBAAtB;AAEA,OAAOC,eAAP,MAA4B,kCAA5B;AACA,SAASC,OAAT,QAAwB,eAAxB;AAGA,OAAOC,O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Ad;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;;EAEkBI,aAAa,CAC9BC,MAD8B,EAE9BC,IAF8B,EAG9BC,YAH8B,EAItB;IACR,MAAMC,EAAE,GAAG,KAAKC,mBAAL,CAAyBJ,MAAzB,EAAiCC,IAAjC,EAAuCC,YAAvC,CAAX;;IACA,IAAIC,EAAJ,EAAQ;MACN,OAAOA,EAAP;IACD;;IAED,MAAME,OAAO,GAAG,KAAKC,kBAAL,CAAwBN,MAAxB,EAAgCC,IAAhC,EAAsCC,YAAtC,CAAhB,CANQ,CAOR;;IACA,OAAOG,OAAO,CAACE,SAAf;EACD;;AAvEgE"}
|
package/lib/processors/styled.js
CHANGED
|
@@ -11,8 +11,6 @@ var _styled = _interopRequireDefault(require("@linaria/react/processors/styled")
|
|
|
11
11
|
|
|
12
12
|
var _tags = require("@linaria/tags");
|
|
13
13
|
|
|
14
|
-
var _utils = require("@linaria/utils");
|
|
15
|
-
|
|
16
14
|
var _atomize = _interopRequireDefault(require("./helpers/atomize"));
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -55,12 +53,18 @@ class AtomicStyledProcessor extends _styled.default {
|
|
|
55
53
|
props.class = [this.classes, this.className].filter(Boolean).join(' ');
|
|
56
54
|
props.atomic = true;
|
|
57
55
|
return props;
|
|
58
|
-
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getVariableId(source, unit, precedingCss) {
|
|
59
|
+
const id = this.getCustomVariableId(source, unit, precedingCss);
|
|
60
|
+
|
|
61
|
+
if (id) {
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
59
64
|
|
|
65
|
+
const context = this.getVariableContext(source, unit, precedingCss); // id is based on the slugified value
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
// id is based on the slugified value
|
|
63
|
-
return (0, _utils.slugify)(value);
|
|
67
|
+
return context.valueSlug;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
}
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","source","unit","precedingCss","id","getCustomVariableId","context","getVariableContext","valueSlug"],"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';\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 protected override getVariableId(\n source: string,\n unit: string,\n precedingCss: string\n ): string {\n const id = this.getCustomVariableId(source, unit, precedingCss);\n if (id) {\n return id;\n }\n\n const context = this.getVariableContext(source, unit, precedingCss);\n // id is based on the slugified value\n return context.valueSlug;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAEA;;AACA;;AAGA;;;;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,EAAE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3
3
|
"description": "Blazing fast zero-runtime CSS in JS library",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.5",
|
|
5
5
|
"bugs": "https://github.com/callstack/linaria/issues",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@linaria/core": "^4.1.
|
|
7
|
+
"@linaria/core": "^4.1.4",
|
|
8
8
|
"@linaria/logger": "^4.0.0",
|
|
9
|
-
"@linaria/react": "^4.1.
|
|
10
|
-
"@linaria/tags": "^4.1.
|
|
11
|
-
"@linaria/utils": "^4.2.
|
|
9
|
+
"@linaria/react": "^4.1.5",
|
|
10
|
+
"@linaria/tags": "^4.1.4",
|
|
11
|
+
"@linaria/utils": "^4.2.2",
|
|
12
12
|
"known-css-properties": "^0.24.0",
|
|
13
13
|
"postcss": "^8.3.11",
|
|
14
14
|
"stylis": "^3.5.4",
|
|
@@ -7,5 +7,5 @@ export default class AtomicStyledProcessor extends StyledProcessor {
|
|
|
7
7
|
private get classes();
|
|
8
8
|
extractRules(valueCache: ValueCache, cssText: string, loc?: SourceLocation | null): Rules;
|
|
9
9
|
protected getProps(): IProps;
|
|
10
|
-
protected getVariableId(
|
|
10
|
+
protected getVariableId(source: string, unit: string, precedingCss: string): string;
|
|
11
11
|
}
|